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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
//===============================================================
// vframec.cxx - a frame for holding commands
//
// 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/vframec.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/Form.h>
#include <Xm/Frame.h>
#else
#include <X11/Xaw/Form.h>
#endif
}
#ifdef Motif // --------------------------------------
#define formWidgetC xmFormWidgetClass
#define Ncallback XmNactivateCallback
#define Nheight XmNheight
#define Nlabel XmNlabelString
#define NmappedWhenManaged XmNmappedWhenManaged
#define Nwidth XmNwidth
#define NborderWidth XmNborderWidth
//@@ These use athena parent for now
#define Nresizable(x) // XtNresizable,x,
#define setLabel(x,y) XmString x = XmStringCreateSimple(y);
#define freeLabel(x) XmStringFree(x);
#else //------------------------------------------------------
#define formWidgetC formWidgetClass
#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 // -----------------------------------------------------
//=====================>>> vFrameCmd::vFrameCmd <<<=======================
vFrameCmd::vFrameCmd(vCmdParent* dp, CommandObject* dc) :
vCmd(dp, dc)
{
initialize();
}
//=====================>>> vFrameCmd::~vFrameCmd <<<=======================
vFrameCmd::~vFrameCmd()
{
SysDebug(Destructor,"vFrameCmd::~vFrameCmd() destructor\n")
}
//=====================>>> vFrameCmd::initialize <<<=======================
void vFrameCmd::initialize(void)
{
// build a button command for use in a parent window
SysDebug(Constructor,"vFrameCmd::vFrameCmd() constructor\n")
CopyToLocal();
Widget WfHoriz = _parentWin->getWidgetFromId(dlgCmd->cRightOf);
Widget WfVert = _parentWin->getWidgetFromId(dlgCmd->cBelow);
#ifdef Motif
int border = (dlgCmd->attrs & CA_NoBorder) ? 0 : 3; // border?
#else
int border = (dlgCmd->attrs & CA_NoBorder) ? 0 : 1; // border?
#endif
int map = !(dlgCmd->attrs & CA_Hidden);
wBox = XtVaCreateManagedWidget(
"vFrame", // name
formWidgetC, // class
wParent, // parent
Nresizable(TRUE)
NmappedWhenManaged, map,
#ifdef Motif
XmNmarginHeight,3,
XmNmarginWidth,3,
XmNshadowThickness,border,
XmNshadowType,XmSHADOW_ETCHED_IN,
#else
NborderWidth, border,
#endif
NULL);
if (WfVert != 0)
XtVaSetValues(wBox, Nbelow(WfVert) NULL);
if (WfHoriz != 0)
XtVaSetValues(wBox, NrightOf(WfHoriz) NULL);
#ifdef Motif
if (dlgCmd->attrs & CA_NoSpace) // Tight spacing?
{
XtVaSetValues(wBox, // the widget to set
XmNverticalSpacing,0,
XmNhorizontalSpacing,0,
NULL);
}
else
{
XtVaSetValues(wBox, // the widget to set
XmNverticalSpacing,3,
XmNhorizontalSpacing,3,
NULL);
}
#else
if (dlgCmd->attrs & CA_NoSpace) // Tight spacing?
{
XtVaSetValues(wBox, // the widget to set
XtNdefaultDistance,0,
NULL);
}
XtVaSetValues(wBox, // the widget to set
XtNbackground, _vDialogBG, NULL);
#endif
wCmd = 0; // wCmd not used
}
//================>>> vFrameCmd::SetCmdVal <<<============================
void vFrameCmd::SetCmdVal(ItemVal val, ItemSetType st)
{
SysDebug1(Misc,"vFrameCmd::SetCmdVal(val:%d)\n",val)
if (st == Hidden) // hide or unhide
{
if (val)
{
::XtUnmapWidget(wBox); // unmap this widget
}
else
{
::XtMapWidget(wBox); // unmap this widget
}
}
else if (st == Value && dlgCmd->cmdType == C_ToggleFrame) // Toggle?
{
if (val) // have to hide/show me first
{
::XtMapWidget(wBox); // unmap this widget
}
else
{
::XtUnmapWidget(wBox); // unmap this widget
}
_parentWin->SetFrameChildren(_cmdId,val); // and now set value of childe
}
}
|