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
|
//===============================================================
// vtipwin.cxx - vTipWindow class functions - X11R5
//
// Copyright (C) 1998 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/vapp.h> // we are a friend of App
#include <v/vtipwin.h> // our header
#include <v/vctlclrs.h>
#include <v/vxutil.h> // Athena/Motif mapping
extern "C"
{
#include <X11/Xlib.h>
#include <X11/Shell.h>
#ifdef Motif
#include <Xm/Xm.h>
#include <Xm/Label.h>
#else
#include <X11/Xaw/Label.h>
#endif
}
#ifdef Motif
#define setLabel(x,y) XmString x = XmStringCreateSimple(y);
#define freeLabel(x) XmStringFree(x);
#define lblWidgetClass xmLabelWidgetClass
#define Nlabel XmNlabelString
//@@ These use athena parent for now
#else
#define setLabel(x,y) char* x = y;
#define freeLabel(x)
#define lblWidgetClass labelWidgetClass
#define Nlabel XtNlabel
#endif
//======================>>> vTipWindow::vTipWindow <<<=======================
vTipWindow::vTipWindow()
{
SysDebug(Constructor,"vTipWindow::vTipWindow")
_popup = 0;
_wLbl = 0;
}
//======================>>> vTipWindow::vTipWindow <<<=======================
vTipWindow::vTipWindow(const vTipWindow& w) // Copy Constructor
{
// Copy is shallow, but we track that it is a copy
vSysError("vTipWindow - V semantics do not support copy constructors!");
}
//======================>>> vTipWindow::~vTipWindow <<<=======================
vTipWindow::~vTipWindow() // destructor
{
SysDebug(Destructor,"vTipWindow::~vTipWindow destructor\n")
if (_popup == 0)
return;
if (PoppedUp)
XtPopdown(_popup); // another way to get it down
}
//======================>>> vTipWindow::initialize <<<=======================
void vTipWindow::initialize(void)
{
_popup = XtVaCreatePopupShell(
"vTipWindow", // use name supplied
overrideShellWidgetClass, // a toplevel shell
theApp->vHandle(), // based on App window
XtNoverrideRedirect,1,
XtNallowShellResize,1,
NULL);
PoppedUp = 0;
setLabel(tmp," ")
_wLbl = XtVaCreateManagedWidget(
"vTipLabel", // name
lblWidgetClass, // class
_popup, // parent
Nlabel, tmp, // label
#ifdef Motif
XmNmarginTop,2,
XmNmarginBottom,2,
XmNmarginLeft,2,
XmNmarginRight,2,
#else
XtNinternalWidth,2,
XtNinternalHeight,3, // adjust to make same height as button
#endif
NULL);
freeLabel(tmp)
}
//============================>>> vTipWindow::CloseTipWindow <<<==========================
void vTipWindow::CloseTipWindow(void)
{
SysDebug(Build,"vTipWindow::CloseTipWin()")
if (!PoppedUp)
return;
XtPopdown(_popup); // another way to get it down
PoppedUp = 0;
}
//======================>>> vTipWindow::ShowTipWindow <<<=======================
void vTipWindow::ShowTipWindow(int x, int y, char* tip)
{
if (PoppedUp)
return;
if (_popup == 0) // have to create popups
initialize();
XtVaSetValues(_popup, // set loc of popup
XtNx, x,
XtNy, y,
NULL);
setLabel(tmp,tip)
XtVaSetValues(_wLbl, // the widget to set
Nlabel, tmp, // label
NULL);
freeLabel(tmp)
XtPopup(_popup,XtGrabNone);
PoppedUp = 1;
}
//================>>> vTipWindow::GetPosition <<<========================
void vTipWindow::GetPosition(int& left, int& top, int& width, int& height)
{
Dimension w,h,b;
Position l,t;
XtVaGetValues(_popup, XtNwidth, &w, XtNheight, &h,
XtNx, &l, XtNy, &t, XtNborderWidth, &b, NULL);
left = l; top = t; width = w+b+b; height = h+b+b;
}
//================>>> vTipWindow::SetPosition <<<========================
void vTipWindow::SetPosition(int left, int top)
{
Position l = left;
Position t = top;
XtVaSetValues(_popup,XtNx,l, XtNy,t,NULL);
}
//================>>> vTipWindow::RaiseWindow <<<========================
void vTipWindow::RaiseWindow(void)
{
// raise this window to the top of all other windows
XRaiseWindow(XtDisplay(_popup), // our display
XtWindow(_popup)); // our window
}
|