File: vtextc.cxx

package info (click to toggle)
v1 1.20-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,240 kB
  • ctags: 9,439
  • sloc: cpp: 48,033; ansic: 8,939; makefile: 1,369; sh: 30
file content (160 lines) | stat: -rw-r--r-- 4,107 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//===============================================================
// vtextc.cxx	- Text output cmd
//
// Copyright (C) 1995,1996  Bruce E. Wampler
//
// This file is part of the V C++ GUI Framework, and is covered
// under the terms of the GNU Library General Public License,
// Version 2. This library has NO WARRANTY. See the source file
// vapp.cxx for more complete information about license terms.
//===============================================================

#include <v/vxutil.h>	// Motif/Athena mapping
#include <v/vapp.h>
#include <v/vtextc.h>	// our definitions
#include <v/vcmdprnt.h>	// a command parent
#include <v/vctlclrs.h>

extern "C"
{
#include <X11/StringDefs.h>

#ifdef Motif
#include <Xm/Xm.h>
#include <Xm/Label.h>
#else

#include <X11/Xaw/Label.h>
#include <X11/Xaw/Form.h>
#endif
}

#ifdef Motif	// --------------------------------------

#define lblWidgetClass xmLabelWidgetClass
#define NborderWidth XmNborderWidth
#define Ncallback XmNactivateCallback
#define Nheight XmNheight
#define Nlabel XmNlabelString
#define NmappedWhenManaged XmNmappedWhenManaged
#define Nwidth XmNwidth
//@@ These use athena parent for now
#define Nresizable(x) // XtNresizable,x,

#define setLabel(x,y) XmString x = XmStringCreateLtoR(y,XmFONTLIST_DEFAULT_TAG);
#define freeLabel(x) XmStringFree(x);

#else	//------------------------------------------------------

#define lblWidgetClass labelWidgetClass
#define NborderWidth XtNborderWidth
#define Ncallback XtNcallback
#define Nheight XtNheight
#define Nlabel XtNlabel
#define NmappedWhenManaged XtNmappedWhenManaged
#define Nwidth XtNwidth
#define Nresizable(x) XtNresizable,x,
#define setLabel(x,y) char* x = y;
#define freeLabel(x)

#endif	// -----------------------------------------------------


//=====================>>> vTextCmd::vTextCmd <<<=======================
  vTextCmd::vTextCmd(vCmdParent* dp, CommandObject* dc) :
	    vCmd(dp, dc)
  {
    initialize();
  }

//=====================>>> vTextCmd::~vTextCmd <<<=======================
  vTextCmd::~vTextCmd()
  {

    SysDebug(Destructor,"vTextCmd::~vTextCmd() destructor\n")

  }

//=====================>>> vTextCmd::initialize <<<=======================
  void vTextCmd::initialize(void)
  {
    // build a button command for use in a parent window


    SysDebug(Constructor,"vTextCmd::vTextCmd() constructor\n")

    CopyToLocal();		// make local copies

    Widget WfHoriz = _parentWin->getWidgetFromId(dlgCmd->cRightOf);
    Widget WfVert = _parentWin->getWidgetFromId(dlgCmd->cBelow);

    char* theText = (_itemList && *(char*)_itemList) ? (char *) _itemList
						   : _title;
    int border = (dlgCmd->attrs & CA_NoBorder) ? 0 : 1;    // border?

    int map = !(dlgCmd->attrs & CA_Hidden);

    setLabel(tmp,theText)
#ifdef Motif
    wCmd = XtVaCreateManagedWidget(
        "vText",		// name
	lblWidgetClass,		// class
	wParent,		// parent
	Nlabel, tmp, 	// label
	NborderWidth,border,	// A border!
	NmappedWhenManaged, map,
	NULL);
#else
    wCmd = XtVaCreateManagedWidget(
        "vText",		// name
	lblWidgetClass,		// class
	wParent,		// parent
	Nlabel, tmp, // label
	NborderWidth,border,	// A border!
	Nresizable(TRUE)
	NmappedWhenManaged, map,
	XtNbackground, _vControlBG,
	NULL);
#endif
    if (WfVert != 0)
	XtVaSetValues(wCmd, Nbelow(WfVert) NULL);
    if (WfHoriz != 0)
	XtVaSetValues(wCmd, NrightOf(WfHoriz) NULL);
    freeLabel(tmp)

    wBox = 0;		// no Box, but make copy for placement

  }

//================>>> vTextCmd::SetCmdVal <<<============================
  void vTextCmd::SetCmdVal(ItemVal val, ItemSetType st)
  {

    if (st == Hidden)		// hide or unhide
      {
	if (val)
	  {
	    XtUnmapWidget(wCmd);	// unmap this widget
	  }
	else
	  {
	    XtMapWidget(wCmd);	// unmap this widget
	  }
      }
  }

//================>>> vTextCmd::SetCmdStr <<<============================
  void vTextCmd::SetCmdStr(char* str)
  {

    SysDebug1(Misc,"vTextCmd::SetCmdStr(str:%s)\n",str)

    _title = str;
    setLabel(tmp,str)		// allocate label
    XtVaSetValues(wCmd,		// the widget to set
	Nlabel, tmp, // label
	NULL);
    freeLabel(tmp)


  }