]> git.saurik.com Git - wxWidgets.git/blame - src/motif/toolbar.cpp
fixed incorrect GetTextExtent for wxTELETYPE font
[wxWidgets.git] / src / motif / toolbar.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
8a0681f9 2// Name: motif/toolbar.cpp
4bb6408c
JS
3// Purpose: wxToolBar
4// Author: Julian Smart
8a0681f9 5// Modified by: 13.12.99 by VZ during toolbar classes reorganization
4bb6408c
JS
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
8a0681f9 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
8a0681f9
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
4bb6408c 20#ifdef __GNUG__
8a0681f9 21 #pragma implementation "toolbar.h"
4bb6408c
JS
22#endif
23
4dff3400
JJ
24#ifdef __VMS
25#define XtDisplay XTDISPLAY
26#endif
27
4bb6408c 28#include "wx/wx.h"
1a3ac83f
JS
29#include "wx/app.h"
30#include "wx/timer.h"
1ccbb61a 31#include "wx/toolbar.h"
0d57be45 32
338dd992
JJ
33#ifdef __VMS__
34#pragma message disable nosimpint
35#endif
0d57be45
JS
36#include <Xm/Xm.h>
37#include <Xm/PushBG.h>
38#include <Xm/PushB.h>
1a3ac83f 39#include <Xm/Label.h>
0d57be45
JS
40#include <Xm/ToggleB.h>
41#include <Xm/ToggleBG.h>
42#include <Xm/Form.h>
338dd992
JJ
43#ifdef __VMS__
44#pragma message enable nosimpint
45#endif
0d57be45
JS
46
47#include "wx/motif/private.h"
4bb6408c 48
8a0681f9
VZ
49// ----------------------------------------------------------------------------
50// wxWin macros
51// ----------------------------------------------------------------------------
52
53#if !USE_SHARED_LIBRARY
12ed316d 54IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
8a0681f9 55#endif
4bb6408c 56
8a0681f9
VZ
57// ----------------------------------------------------------------------------
58// private functions
59// ----------------------------------------------------------------------------
4bb6408c 60
1a3ac83f 61static void wxToolButtonCallback (Widget w, XtPointer clientData,
bf6c2b35 62 XtPointer ptr);
1a3ac83f
JS
63static void wxToolButtonPopupCallback (Widget w, XtPointer client_data,
64 XEvent *event, Boolean *continue_to_dispatch);
65
8a0681f9
VZ
66// ----------------------------------------------------------------------------
67// private classes
68// ----------------------------------------------------------------------------
69
70class wxToolBarTimer : public wxTimer
1a3ac83f
JS
71{
72public:
8a0681f9 73 virtual void Notify();
1a3ac83f 74
8a0681f9
VZ
75 static Widget help_popup;
76 static Widget buttonWidget;
77 static wxString helpString;
1a3ac83f
JS
78};
79
8a0681f9
VZ
80class wxToolBarTool : public wxToolBarToolBase
81{
82public:
83 wxToolBarTool(wxToolBar *tbar,
84 int id,
85 const wxBitmap& bitmap1,
86 const wxBitmap& bitmap2,
87 bool toggle,
88 wxObject *clientData,
89 const wxString& shortHelpString,
90 const wxString& longHelpString)
91 : wxToolBarToolBase(tbar, id, bitmap1, bitmap2, toggle,
92 clientData, shortHelpString, longHelpString)
93 {
94 Init();
95 }
96
97 wxToolBarTool(wxToolBar *tbar, wxControl *control)
98 : wxToolBarToolBase(tbar, control)
99 {
100 Init();
101 }
102
103 virtual ~wxToolBarTool();
104
105 // accessors
106 void SetWidget(Widget widget) { m_widget = widget; }
107 Widget GetButtonWidget() const { return m_widget; }
108
109 void SetPixmap(Pixmap pixmap) { m_pixmap = pixmap; }
110 Pixmap GetPixmap() const { return m_pixmap; }
111
112protected:
113 void Init();
114
115 Widget m_widget;
116 Pixmap m_pixmap;
117};
118
119// ----------------------------------------------------------------------------
120// globals
121// ----------------------------------------------------------------------------
122
1a3ac83f
JS
123static wxToolBarTimer* wxTheToolBarTimer = (wxToolBarTimer*) NULL;
124
125Widget wxToolBarTimer::help_popup = (Widget) 0;
126Widget wxToolBarTimer::buttonWidget = (Widget) 0;
8a0681f9
VZ
127wxString wxToolBarTimer::helpString;
128
129// ============================================================================
130// implementation
131// ============================================================================
132
133// ----------------------------------------------------------------------------
134// wxToolBarTool
135// ----------------------------------------------------------------------------
136
982b2cfc
VZ
137wxToolBarToolBase *wxToolBar::CreateTool(int id,
138 const wxBitmap& bitmap1,
139 const wxBitmap& bitmap2,
140 bool toggle,
141 wxObject *clientData,
142 const wxString& shortHelpString,
143 const wxString& longHelpString)
8a0681f9 144{
982b2cfc 145 return new wxToolBarTool(this, id, bitmap1, bitmap2, toggle,
8a0681f9
VZ
146 clientData, shortHelpString, longHelpString);
147}
1a3ac83f 148
982b2cfc 149wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
4bb6408c 150{
982b2cfc 151 return new wxToolBarTool(this, control);
4bb6408c
JS
152}
153
8a0681f9
VZ
154void wxToolBarTool::Init()
155{
156 m_widget = (Widget)0;
157 m_pixmap = (Pixmap)0;
158}
159
160wxToolBarTool::~wxToolBarTool()
161{
982b2cfc
VZ
162 if ( m_widget )
163 XtDestroyWidget(m_widget);
164 if ( m_pixmap )
165 XmDestroyPixmap(DefaultScreenOfDisplay((Display*)wxGetDisplay()),
166 m_pixmap);
8a0681f9
VZ
167}
168
169// ----------------------------------------------------------------------------
170// wxToolBar construction
171// ----------------------------------------------------------------------------
172
173void wxToolBar::Init()
4bb6408c
JS
174{
175 m_maxWidth = -1;
176 m_maxHeight = -1;
4bb6408c
JS
177 m_defaultWidth = 24;
178 m_defaultHeight = 22;
7b28757f
JS
179 m_toolPacking = 2;
180 m_toolSeparation = 8;
181 m_xMargin = 2;
182 m_yMargin = 2;
183 m_maxRows = 100;
184 m_maxCols = 100;
8a0681f9
VZ
185}
186
187bool wxToolBar::Create(wxWindow *parent,
188 wxWindowID id,
189 const wxPoint& pos,
190 const wxSize& size,
191 long style,
192 const wxString& name)
193{
194 Init();
195
196 m_windowId = id;
197
4bb6408c 198 SetName(name);
0d57be45
JS
199 m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
200 m_foregroundColour = parent->GetForegroundColour();
4bb6408c
JS
201 m_windowStyle = style;
202
203 SetParent(parent);
204
205 if (parent) parent->AddChild(this);
206
0d57be45
JS
207 Widget parentWidget = (Widget) parent->GetClientWidget();
208
209 Widget toolbar = XtVaCreateManagedWidget("toolbar",
7fe7d506
JS
210 xmBulletinBoardWidgetClass, (Widget) parentWidget,
211 XmNmarginWidth, 0,
212 XmNmarginHeight, 0,
213 XmNresizePolicy, XmRESIZE_NONE,
214 NULL);
215/*
216 Widget toolbar = XtVaCreateManagedWidget("toolbar",
217 xmFormWidgetClass, (Widget) m_clientWidget,
0d57be45
JS
218 XmNtraversalOn, False,
219 XmNhorizontalSpacing, 0,
220 XmNverticalSpacing, 0,
1a3ac83f
JS
221 XmNleftOffset, 0,
222 XmNrightOffset, 0,
223 XmNmarginWidth, 0,
224 XmNmarginHeight, 0,
0d57be45 225 NULL);
7fe7d506 226*/
0d57be45
JS
227
228 m_mainWidget = (WXWidget) toolbar;
229
da175b2c 230 m_font = parent->GetFont();
4b5f3fe6
JS
231 ChangeFont(FALSE);
232
0d57be45
JS
233 SetCanAddEventHandler(TRUE);
234 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
235
0d57be45 236 ChangeBackgroundColour();
bf6c2b35 237
0d57be45 238 return TRUE;
4bb6408c
JS
239}
240
241wxToolBar::~wxToolBar()
242{
1a3ac83f
JS
243 delete wxTheToolBarTimer;
244 wxTheToolBarTimer = NULL;
4bb6408c
JS
245}
246
8a0681f9 247bool wxToolBar::Realize()
7fe7d506 248{
8a0681f9
VZ
249 if ( m_tools.GetCount() == 0 )
250 {
251 // nothing to do
252 return TRUE;
253 }
7fe7d506
JS
254
255 // Separator spacing
256 const int separatorSize = GetToolSeparation(); // 8;
257 wxSize margins = GetToolMargins();
f3979fcc 258 int packing = GetToolPacking();
7fe7d506
JS
259 int marginX = margins.x;
260 int marginY = margins.y;
261
262 int currentX = marginX;
263 int currentY = marginY;
264
265 int buttonHeight = 0;
266
267 int currentSpacing = 0;
268
8a0681f9
VZ
269 Widget button;
270 Pixmap pixmap, insensPixmap;
271 wxBitmap bmp;
272
273 wxToolBarToolsList::Node *node = m_tools.GetFirst();
274 while ( node )
7fe7d506 275 {
8a0681f9 276 wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
7fe7d506 277
8a0681f9 278 switch ( tool->GetStyle() )
7fe7d506 279 {
8a0681f9 280 case wxTOOL_STYLE_CONTROL:
f3979fcc 281 {
66f55ec6
JS
282 wxControl* control = tool->GetControl();
283 wxSize sz = control->GetSize();
f3979fcc 284 wxPoint pos = control->GetPosition();
66f55ec6 285 control->Move(currentX, pos.y);
f3979fcc 286 currentX += sz.x + packing;
66f55ec6 287
8a0681f9 288 break;
f3979fcc 289 }
8a0681f9
VZ
290 case wxTOOL_STYLE_SEPARATOR:
291 currentX += separatorSize;
292 break;
7fe7d506 293
8a0681f9
VZ
294 case wxTOOL_STYLE_BUTTON:
295 button = (Widget) 0;
bf6c2b35 296
8a0681f9 297 if ( tool->CanBeToggled() )
7fe7d506 298 {
8a0681f9
VZ
299 button = XtVaCreateWidget("toggleButton",
300 xmToggleButtonWidgetClass, (Widget) m_mainWidget,
301 XmNx, currentX, XmNy, currentY,
e838cc14
VZ
302 XmNindicatorOn, False,
303 XmNshadowThickness, 2,
304 XmNborderWidth, 0,
305 XmNspacing, 0,
306 XmNmarginWidth, 0,
307 XmNmarginHeight, 0,
8a0681f9
VZ
308 XmNmultiClick, XmMULTICLICK_KEEP,
309 XmNlabelType, XmPIXMAP,
310 NULL);
311 XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback,
312 (XtPointer) this);
313
314 XtVaSetValues ((Widget) button,
315 XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)),
316 NULL);
bf6c2b35 317 }
7fe7d506 318 else
8a0681f9
VZ
319 {
320 button = XtVaCreateWidget("button",
321 xmPushButtonWidgetClass, (Widget) m_mainWidget,
322 XmNx, currentX, XmNy, currentY,
323 XmNpushButtonEnabled, True,
324 XmNmultiClick, XmMULTICLICK_KEEP,
325 XmNlabelType, XmPIXMAP,
326 NULL);
327 XtAddCallback (button,
328 XmNactivateCallback, (XtCallbackProc) wxToolButtonCallback,
329 (XtPointer) this);
330 }
7fe7d506 331
8a0681f9 332 DoChangeBackgroundColour((WXWidget) button, m_backgroundColour, TRUE);
7fe7d506 333
8a0681f9 334 tool->SetWidget(button);
7fe7d506 335
8a0681f9
VZ
336 // For each button, if there is a mask, we must create
337 // a new wxBitmap that has the correct background colour
338 // for the button. Otherwise the background will just be
339 // e.g. black if a transparent XPM has been loaded.
340 bmp = tool->GetBitmap1();
341 if ( bmp.GetMask() )
7fe7d506 342 {
8a0681f9
VZ
343 int backgroundPixel;
344 XtVaGetValues(button, XmNbackground, &backgroundPixel,
345 NULL);
346
347 wxColour col;
348 col.SetPixel(backgroundPixel);
349
e838cc14 350 bmp = wxCreateMaskedBitmap(bmp, col);
8a0681f9 351
e838cc14 352 tool->SetBitmap1(bmp);
7fe7d506 353 }
8a0681f9
VZ
354
355 // Create a selected/toggled bitmap. If there isn't a 2nd
356 // bitmap, we need to create it (with a darker, selected
357 // background)
358 int backgroundPixel;
359 if ( tool->CanBeToggled() )
360 XtVaGetValues(button, XmNselectColor, &backgroundPixel,
361 NULL);
7fe7d506 362 else
8a0681f9
VZ
363 XtVaGetValues(button, XmNarmColor, &backgroundPixel,
364 NULL);
365
366 wxColour col;
367 col.SetPixel(backgroundPixel);
368
369 if (tool->GetBitmap2().Ok() && tool->GetBitmap2().GetMask())
7fe7d506 370 {
8a0681f9
VZ
371 // Use what's there
372 wxBitmap newBitmap = wxCreateMaskedBitmap(tool->GetBitmap2(), col);
373 tool->SetBitmap2(newBitmap);
7fe7d506 374 }
8a0681f9 375 else
7fe7d506 376 {
8a0681f9
VZ
377 // Use unselected bitmap
378 if ( bmp.GetMask() )
379 {
380 wxBitmap newBitmap = wxCreateMaskedBitmap(bmp, col);
381 tool->SetBitmap2(newBitmap);
382 }
383 else
384 tool->SetBitmap2(bmp);
385 }
386
387 pixmap = (Pixmap) bmp.GetPixmap();
388 insensPixmap = (Pixmap) bmp.GetInsensPixmap();
389
390 if (tool->CanBeToggled())
391 {
392 // Toggle button
393 Pixmap pixmap2 = (Pixmap) 0;
394 Pixmap insensPixmap2 = (Pixmap) 0;
395
396 // If there's a bitmap for the toggled state, use it,
397 // otherwise generate one.
398 if (tool->GetBitmap2().Ok())
399 {
400 wxBitmap bmp2 = tool->GetBitmap2();
401 pixmap2 = (Pixmap) bmp2.GetPixmap();
402 insensPixmap2 = (Pixmap) bmp2.GetInsensPixmap();
403 }
404 else
405 {
406 pixmap2 = (Pixmap) bmp.GetArmPixmap(button);
407 insensPixmap2 = XCreateInsensitivePixmap((Display*) wxGetDisplay(), pixmap2);
408 }
409
982b2cfc
VZ
410 tool->SetPixmap(pixmap2);
411
8a0681f9 412 XtVaSetValues (button,
8a0681f9
VZ
413 XmNfillOnSelect, True,
414 XmNlabelPixmap, pixmap,
415 XmNselectPixmap, pixmap2,
416 XmNlabelInsensitivePixmap, insensPixmap,
417 XmNselectInsensitivePixmap, insensPixmap2,
418 XmNlabelType, XmPIXMAP,
419 NULL);
7fe7d506
JS
420 }
421 else
422 {
8a0681f9
VZ
423 Pixmap pixmap2 = (Pixmap) 0;
424
425 // If there's a bitmap for the armed state, use it,
426 // otherwise generate one.
427 if (tool->GetBitmap2().Ok())
428 {
429 pixmap2 = (Pixmap) tool->GetBitmap2().GetPixmap();
430 }
431 else
432 {
433 pixmap2 = (Pixmap) bmp.GetArmPixmap(button);
434
435 }
982b2cfc
VZ
436
437 tool->SetPixmap(pixmap2);
438
8a0681f9
VZ
439 // Normal button
440 XtVaSetValues(button,
441 XmNlabelPixmap, pixmap,
442 XmNlabelInsensitivePixmap, insensPixmap,
443 XmNarmPixmap, pixmap2,
444 NULL);
445 }
982b2cfc 446
8a0681f9 447 XtManageChild(button);
7fe7d506 448
8a0681f9
VZ
449 {
450 Dimension width, height;
451 XtVaGetValues(button,
452 XmNwidth, &width,
453 XmNheight, & height,
454 NULL);
f3979fcc 455 currentX += width + packing;
8a0681f9 456 buttonHeight = wxMax(buttonHeight, height);
7fe7d506 457 }
8a0681f9
VZ
458
459 XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
460 False, wxToolButtonPopupCallback, (XtPointer) this);
461
462 currentSpacing = 0;
463 break;
7fe7d506 464 }
8a0681f9
VZ
465
466 node = node->GetNext();
7fe7d506
JS
467 }
468
469 SetSize(-1, -1, currentX, buttonHeight + 2*marginY);
470
471 return TRUE;
472}
473
982b2cfc
VZ
474wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x),
475 wxCoord WXUNUSED(y)) const
4bb6408c 476{
8a0681f9 477 wxFAIL_MSG( _T("TODO") );
4b5f3fe6 478
982b2cfc 479 return (wxToolBarToolBase *)NULL;
4bb6408c
JS
480}
481
982b2cfc 482bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
4bb6408c 483{
8a0681f9 484 tool->Attach(this);
4bb6408c 485
8a0681f9 486 return TRUE;
4bb6408c
JS
487}
488
982b2cfc 489bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
4bb6408c 490{
8a0681f9 491 tool->Detach();
0d57be45 492
8a0681f9 493 return TRUE;
4bb6408c
JS
494}
495
982b2cfc 496void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable)
1a3ac83f 497{
982b2cfc
VZ
498 wxToolBarTool *tool = (wxToolBarTool *)toolBase;
499
8a0681f9 500 XtSetSensitive(tool->GetButtonWidget(), (Boolean) enable);
1a3ac83f
JS
501}
502
982b2cfc 503void wxToolBar::DoToggleTool(wxToolBarToolBase *toolBase, bool toggle)
4bb6408c 504{
982b2cfc
VZ
505 wxToolBarTool *tool = (wxToolBarTool *)toolBase;
506
8a0681f9 507 XmToggleButtonSetState(tool->GetButtonWidget(), (Boolean) toggle, False);
4bb6408c
JS
508}
509
982b2cfc
VZ
510void wxToolBar::DoSetToggle(wxToolBarToolBase * WXUNUSED(tool),
511 bool WXUNUSED(toggle))
1a3ac83f 512{
982b2cfc 513 // nothing to do
1a3ac83f
JS
514}
515
8a0681f9
VZ
516// ----------------------------------------------------------------------------
517// Motif callbacks
518// ----------------------------------------------------------------------------
1a3ac83f 519
982b2cfc 520wxToolBarToolBase *wxToolBar::FindToolByWidget(WXWidget w) const
7fe7d506 521{
8a0681f9
VZ
522 wxToolBarToolsList::Node* node = m_tools.GetFirst();
523 while ( node )
524 {
525 wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
526 if ( tool->GetButtonWidget() == w)
527 {
528 return tool;
529 }
7fe7d506 530
8a0681f9
VZ
531 node = node->GetNext();
532 }
7fe7d506 533
982b2cfc 534 return (wxToolBarToolBase *)NULL;
7fe7d506
JS
535}
536
8a0681f9
VZ
537static void wxToolButtonCallback(Widget w,
538 XtPointer clientData,
539 XtPointer WXUNUSED(ptr))
1a3ac83f
JS
540{
541 wxToolBar *toolBar = (wxToolBar *) clientData;
982b2cfc 542 wxToolBarToolBase *tool = toolBar->FindToolByWidget((WXWidget) w);
8a0681f9
VZ
543 if ( !tool )
544 return;
1a3ac83f 545
8a0681f9
VZ
546 if ( tool->CanBeToggled() )
547 tool->Toggle();
548
549 if ( !toolBar->OnLeftClick(tool->GetId(), tool->IsToggled()) )
1a3ac83f 550 {
8a0681f9
VZ
551 // revert
552 tool->Toggle();
1a3ac83f 553 }
1a3ac83f
JS
554}
555
1a3ac83f 556
8a0681f9
VZ
557static void wxToolButtonPopupCallback(Widget w,
558 XtPointer client_data,
559 XEvent *event,
560 Boolean *WXUNUSED(continue_to_dispatch))
1a3ac83f
JS
561{
562 // TODO: retrieve delay before popping up tooltip from wxSystemSettings.
8a0681f9 563 static const int delayMilli = 800;
1a3ac83f 564
8a0681f9 565 wxToolBar* toolBar = (wxToolBar*) client_data;
982b2cfc 566 wxToolBarToolBase *tool = toolBar->FindToolByWidget((WXWidget) w);
1a3ac83f 567
8a0681f9
VZ
568 if ( !tool )
569 return;
1a3ac83f 570
8a0681f9
VZ
571 wxString tooltip = tool->GetShortHelp();
572 if ( !tooltip )
573 return;
1a3ac83f 574
8a0681f9
VZ
575 if (!wxTheToolBarTimer)
576 wxTheToolBarTimer = new wxToolBarTimer;
1a3ac83f 577
8a0681f9
VZ
578 wxToolBarTimer::buttonWidget = w;
579 wxToolBarTimer::helpString = tooltip;
1a3ac83f
JS
580
581 /************************************************************/
582 /* Popup help label */
583 /************************************************************/
584 if (event->type == EnterNotify)
585 {
586 if (wxToolBarTimer::help_popup != (Widget) 0)
587 {
588 XtDestroyWidget (wxToolBarTimer::help_popup);
589 XtPopdown (wxToolBarTimer::help_popup);
bf6c2b35 590 }
1a3ac83f
JS
591 wxToolBarTimer::help_popup = (Widget) 0;
592
593 // One shot
594 wxTheToolBarTimer->Start(delayMilli, TRUE);
595
596 }
597 /************************************************************/
598 /* Popdown help label */
599 /************************************************************/
600 else if (event->type == LeaveNotify)
601 {
602 if (wxTheToolBarTimer)
603 wxTheToolBarTimer->Stop();
604 if (wxToolBarTimer::help_popup != (Widget) 0)
605 {
606 XtDestroyWidget (wxToolBarTimer::help_popup);
607 XtPopdown (wxToolBarTimer::help_popup);
bf6c2b35 608 }
1a3ac83f
JS
609 wxToolBarTimer::help_popup = (Widget) 0;
610 }
1a3ac83f
JS
611}
612
613void wxToolBarTimer::Notify()
614{
615 Position x, y;
616
617 /************************************************************/
618 /* Create shell without window decorations */
619 /************************************************************/
bf6c2b35
VZ
620 help_popup = XtVaCreatePopupShell ("shell",
621 overrideShellWidgetClass, (Widget) wxTheApp->GetTopLevelWidget(),
1a3ac83f
JS
622 NULL);
623
624 /************************************************************/
625 /* Get absolute position on display of toolbar button */
626 /************************************************************/
627 XtTranslateCoords (buttonWidget,
bf6c2b35
VZ
628 (Position) 0,
629 (Position) 0,
1a3ac83f
JS
630 &x, &y);
631
632 // Move the tooltip more or less above the button
633 int yOffset = 20; // TODO: What should be really?
634 y -= yOffset;
635 if (y < yOffset) y = 0;
636
637 /************************************************************/
638 /* Set the position of the help popup */
639 /************************************************************/
bf6c2b35
VZ
640 XtVaSetValues (help_popup,
641 XmNx, (Position) x,
642 XmNy, (Position) y,
1a3ac83f 643 NULL);
bf6c2b35 644
1a3ac83f
JS
645 /************************************************************/
646 /* Create help label */
647 /************************************************************/
648 XmString text = XmStringCreateSimple ((char*) (const char*) helpString);
bf6c2b35
VZ
649 XtVaCreateManagedWidget ("help_label",
650 xmLabelWidgetClass, help_popup,
1a3ac83f 651 XmNlabelString, text,
bf6c2b35
VZ
652 XtVaTypedArg,
653 XmNforeground, XtRString, "black",
654 strlen("black")+1,
655 XtVaTypedArg,
656 XmNbackground, XtRString, "LightGoldenrod",
657 strlen("LightGoldenrod")+1,
1a3ac83f
JS
658 NULL);
659 XmStringFree (text);
660
661 /************************************************************/
662 /* Popup help label */
663 /************************************************************/
664 XtPopup (help_popup, XtGrabNone);
665}
666