]> git.saurik.com Git - wxWidgets.git/blame - src/motif/utils.cpp
generate #line references to source .xrc files in wxrc --gettext (patch #1803492...
[wxWidgets.git] / src / motif / utils.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
355b4d3d 2// Name: src/motif/utils.cpp
4bb6408c
JS
3// Purpose: Various utilities
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
518b5d2f
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
4bb6408c 19
1248b41f
MB
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
bcd055ae
JJ
23#ifdef __VMS
24#define XtDisplay XTDISPLAY
2b5f62a0 25#endif
1248b41f 26
2b5f62a0 27#include "wx/utils.h"
670f9935
WS
28
29#ifndef WX_PRECOMP
30 #include "wx/app.h"
f38924e8 31 #include "wx/dcmemory.h"
0bca0373 32 #include "wx/bitmap.h"
670f9935
WS
33#endif
34
d48568a5 35#include "wx/apptrait.h"
eb6fa4b4 36#include "wx/evtloop.h"
c2ca375c 37#include "wx/motif/private/timer.h"
2b5f62a0 38
2b5f62a0 39#include <string.h>
2b5f62a0
VZ
40
41#if (defined(__SUNCC__) || defined(__CLCC__))
42 #include <sysent.h>
43#endif
44
45#ifdef __VMS__
46#pragma message disable nosimpint
47#endif
48
49#include "wx/unix/execute.h"
50
2b5f62a0 51#include <Xm/Xm.h>
6769d0cb
MB
52#include <Xm/Frame.h>
53
2b5f62a0 54#include "wx/motif/private.h"
2b5f62a0 55
2b5f62a0
VZ
56#include "X11/Xutil.h"
57
58#ifdef __VMS__
59#pragma message enable nosimpint
60#endif
61
2b5f62a0
VZ
62
63// ============================================================================
64// implementation
65// ============================================================================
66
67// ----------------------------------------------------------------------------
68// async event processing
69// ----------------------------------------------------------------------------
70
71// Consume all events until no more left
eb6fa4b4 72void wxFlushEvents(WXDisplay* wxdisplay)
2b5f62a0 73{
eb6fa4b4
MB
74 Display *display = (Display*)wxdisplay;
75 wxEventLoop evtLoop;
2b5f62a0 76
96be256b 77 XSync (display, False);
2b5f62a0 78
eb6fa4b4 79 while (evtLoop.Pending())
2b5f62a0 80 {
eb6fa4b4
MB
81 XFlush (display);
82 evtLoop.Dispatch();
2b5f62a0 83 }
2b5f62a0
VZ
84}
85
2b5f62a0
VZ
86// ----------------------------------------------------------------------------
87// wxExecute stuff
88// ----------------------------------------------------------------------------
b229c8a9 89
2b5f62a0
VZ
90static void xt_notify_end_process(XtPointer data, int *WXUNUSED(fid),
91 XtInputId *id)
92{
93 wxEndProcessData *proc_data = (wxEndProcessData *)data;
94
95 wxHandleProcessTermination(proc_data);
96
97 // VZ: I think they should be the same...
98 wxASSERT( (int)*id == proc_data->tag );
99
100 XtRemoveInput(*id);
101}
2b5f62a0
VZ
102
103int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
104{
2b5f62a0
VZ
105 XtInputId id = XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(),
106 fd,
107 (XtPointer *) XtInputReadMask,
108 (XtInputCallbackProc) xt_notify_end_process,
109 (XtPointer) proc_data);
bcd055ae 110
2b5f62a0 111 return (int)id;
2b5f62a0
VZ
112}
113
114// ----------------------------------------------------------------------------
115// misc
116// ----------------------------------------------------------------------------
117
118// Emit a beeeeeep
189d1ae7
SN
119#ifndef __EMX__
120// on OS/2, we use the wxBell from wxBase library (src/os2/utils.cpp)
2b5f62a0
VZ
121void wxBell()
122{
123 // Use current setting for the bell
eb6fa4b4 124 XBell (wxGlobalDisplay(), 0);
2b5f62a0 125}
189d1ae7 126#endif
2b5f62a0 127
8bb6b2c0 128wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
2b5f62a0 129{
8bb6b2c0
VZ
130 // XmVERSION and XmREVISION are defined in Xm/Xm.h
131 if ( verMaj )
132 *verMaj = XmVERSION;
133 if ( verMin )
134 *verMin = XmREVISION;
f9788a11 135
8bb6b2c0 136 return wxPORT_MOTIF;
2b5f62a0
VZ
137}
138
2ddff00c 139wxEventLoopBase* wxGUIAppTraits::CreateEventLoop()
b46b1d59
VZ
140{
141 return new wxEventLoop;
142}
143
c2ca375c
VZ
144wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer* timer)
145{
146 return new wxMotifTimerImpl(timer);
147}
148
2b5f62a0
VZ
149// ----------------------------------------------------------------------------
150// display info
151// ----------------------------------------------------------------------------
152
153void wxGetMousePosition( int* x, int* y )
154{
155#if wxUSE_NANOX
156 // TODO
157 *x = 0;
158 *y = 0;
159#else
160 XMotionEvent xev;
161 Window root, child;
eb6fa4b4
MB
162 XQueryPointer(wxGlobalDisplay(),
163 DefaultRootWindow(wxGlobalDisplay()),
2b5f62a0
VZ
164 &root, &child,
165 &(xev.x_root), &(xev.y_root),
166 &(xev.x), &(xev.y),
167 &(xev.state));
168 *x = xev.x_root;
169 *y = xev.y_root;
170#endif
e933b5bc 171}
2b5f62a0 172
ea76a6a5 173// Return true if we have a colour display
2b5f62a0
VZ
174bool wxColourDisplay()
175{
176 return wxDisplayDepth() > 1;
177}
178
179// Returns depth of screen
180int wxDisplayDepth()
181{
eb6fa4b4 182 Display *dpy = wxGlobalDisplay();
2b5f62a0
VZ
183
184 return DefaultDepth (dpy, DefaultScreen (dpy));
185}
186
187// Get size of display
188void wxDisplaySize(int *width, int *height)
189{
eb6fa4b4 190 Display *dpy = wxGlobalDisplay();
2b5f62a0
VZ
191
192 if ( width )
193 *width = DisplayWidth (dpy, DefaultScreen (dpy));
194 if ( height )
195 *height = DisplayHeight (dpy, DefaultScreen (dpy));
196}
197
198void wxDisplaySizeMM(int *width, int *height)
199{
eb6fa4b4 200 Display *dpy = wxGlobalDisplay();
2b5f62a0
VZ
201
202 if ( width )
203 *width = DisplayWidthMM(dpy, DefaultScreen (dpy));
204 if ( height )
205 *height = DisplayHeightMM(dpy, DefaultScreen (dpy));
206}
207
208void wxClientDisplayRect(int *x, int *y, int *width, int *height)
209{
210 // This is supposed to return desktop dimensions minus any window
211 // manager panels, menus, taskbars, etc. If there is a way to do that
212 // for this platform please fix this function, otherwise it defaults
213 // to the entire desktop.
214 if (x) *x = 0;
215 if (y) *y = 0;
216 wxDisplaySize(width, height);
217}
218
219
220// Configurable display in wxX11 and wxMotif
221static WXDisplay *gs_currentDisplay = NULL;
222static wxString gs_displayName;
223
224WXDisplay *wxGetDisplay()
225{
226 if (gs_currentDisplay)
227 return gs_currentDisplay;
2b5f62a0
VZ
228 else if (wxTheApp)
229 return wxTheApp->GetInitialDisplay();
230 return NULL;
2b5f62a0
VZ
231}
232
233bool wxSetDisplay(const wxString& display_name)
234{
235 gs_displayName = display_name;
236
ea76a6a5 237 if ( display_name.empty() )
2b5f62a0
VZ
238 {
239 gs_currentDisplay = NULL;
240
ea76a6a5 241 return true;
2b5f62a0
VZ
242 }
243 else
244 {
2b5f62a0
VZ
245 Cardinal argc = 0;
246
247 Display *display = XtOpenDisplay((XtAppContext) wxTheApp->GetAppContext(),
3e2d47e1
MB
248 display_name.c_str(),
249 wxTheApp->GetAppName().c_str(),
250 wxTheApp->GetClassName().c_str(),
2b5f62a0
VZ
251 NULL,
252#if XtSpecificationRelease < 5
253 0, &argc,
254#else
255 0, (int *)&argc,
256#endif
257 NULL);
258
259 if (display)
260 {
261 gs_currentDisplay = (WXDisplay*) display;
ea76a6a5 262 return true;
2b5f62a0
VZ
263 }
264 else
96be256b 265 return false;
2b5f62a0
VZ
266 }
267}
268
269wxString wxGetDisplayName()
270{
271 return gs_displayName;
272}
273
274wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
275{
276 return wxGenericFindWindowAtPoint(pt);
277}
278
2b5f62a0
VZ
279// ----------------------------------------------------------------------------
280// Some colour manipulation routines
281// ----------------------------------------------------------------------------
282
283void wxHSVToXColor(wxHSV *hsv,XColor *rgb)
284{
285 int h = hsv->h;
286 int s = hsv->s;
287 int v = hsv->v;
288 int r = 0, g = 0, b = 0;
289 int i, f;
290 int p, q, t;
291 s = (s * wxMAX_RGB) / wxMAX_SV;
292 v = (v * wxMAX_RGB) / wxMAX_SV;
293 if (h == 360) h = 0;
294 if (s == 0) { h = 0; r = g = b = v; }
295 i = h / 60;
296 f = h % 60;
297 p = v * (wxMAX_RGB - s) / wxMAX_RGB;
298 q = v * (wxMAX_RGB - s * f / 60) / wxMAX_RGB;
299 t = v * (wxMAX_RGB - s * (60 - f) / 60) / wxMAX_RGB;
300 switch (i)
301 {
302 case 0: r = v, g = t, b = p; break;
303 case 1: r = q, g = v, b = p; break;
304 case 2: r = p, g = v, b = t; break;
305 case 3: r = p, g = q, b = v; break;
306 case 4: r = t, g = p, b = v; break;
307 case 5: r = v, g = p, b = q; break;
308 }
355b4d3d
WS
309 rgb->red = (unsigned short)(r << 8);
310 rgb->green = (unsigned short)(g << 8);
311 rgb->blue = (unsigned short)(b << 8);
2b5f62a0
VZ
312}
313
314void wxXColorToHSV(wxHSV *hsv,XColor *rgb)
315{
316 int r = rgb->red >> 8;
317 int g = rgb->green >> 8;
318 int b = rgb->blue >> 8;
319 int maxv = wxMax3(r, g, b);
320 int minv = wxMin3(r, g, b);
321 int h = 0, s, v;
322 v = maxv;
323 if (maxv) s = (maxv - minv) * wxMAX_RGB / maxv;
324 else s = 0;
325 if (s == 0) h = 0;
326 else
327 {
328 int rc, gc, bc, hex = 0;
329 rc = (maxv - r) * wxMAX_RGB / (maxv - minv);
330 gc = (maxv - g) * wxMAX_RGB / (maxv - minv);
331 bc = (maxv - b) * wxMAX_RGB / (maxv - minv);
332 if (r == maxv) { h = bc - gc, hex = 0; }
333 else if (g == maxv) { h = rc - bc, hex = 2; }
334 else if (b == maxv) { h = gc - rc, hex = 4; }
335 h = hex * 60 + (h * 60 / wxMAX_RGB);
336 if (h < 0) h += 360;
337 }
338 hsv->h = h;
339 hsv->s = (s * wxMAX_SV) / wxMAX_RGB;
340 hsv->v = (v * wxMAX_SV) / wxMAX_RGB;
341}
342
343void wxAllocNearestColor(Display *d,Colormap cmp,XColor *xc)
344{
345#if !wxUSE_NANOX
346 int llp;
347
348 int screen = DefaultScreen(d);
349 int num_colors = DisplayCells(d,screen);
350
351 XColor *color_defs = new XColor[num_colors];
352 for(llp = 0;llp < num_colors;llp++) color_defs[llp].pixel = llp;
353 XQueryColors(d,cmp,color_defs,num_colors);
354
355 wxHSV hsv_defs, hsv;
356 wxXColorToHSV(&hsv,xc);
357
358 int diff, min_diff = 0, pixel = 0;
359
360 for(llp = 0;llp < num_colors;llp++)
361 {
362 wxXColorToHSV(&hsv_defs,&color_defs[llp]);
363 diff = wxSIGN(wxH_WEIGHT * (hsv.h - hsv_defs.h)) +
364 wxSIGN(wxS_WEIGHT * (hsv.s - hsv_defs.s)) +
365 wxSIGN(wxV_WEIGHT * (hsv.v - hsv_defs.v));
366 if (llp == 0) min_diff = diff;
367 if (min_diff > diff) { min_diff = diff; pixel = llp; }
368 if (min_diff == 0) break;
369 }
370
371 xc -> red = color_defs[pixel].red;
372 xc -> green = color_defs[pixel].green;
373 xc -> blue = color_defs[pixel].blue;
374 xc -> flags = DoRed | DoGreen | DoBlue;
375
376/* FIXME, TODO
377 if (!XAllocColor(d,cmp,xc))
378 cout << "wxAllocNearestColor : Warning : Cannot find nearest color !\n";
379*/
380
381 delete[] color_defs;
382#endif
383}
384
385void wxAllocColor(Display *d,Colormap cmp,XColor *xc)
386{
387 if (!XAllocColor(d,cmp,xc))
388 {
389 // cout << "wxAllocColor : Warning : Can not allocate color, attempt find nearest !\n";
390 wxAllocNearestColor(d,cmp,xc);
391 }
392}
393
394#ifdef __WXDEBUG__
395wxString wxGetXEventName(XEvent& event)
396{
397#if wxUSE_NANOX
398 wxString str(wxT("(some event)"));
399 return str;
400#else
401 int type = event.xany.type;
ea76a6a5 402 static char* event_name[] = {
f1db433a
VZ
403 wxMOTIF_STR(""), wxMOTIF_STR("unknown(-)"), // 0-1
404 wxMOTIF_STR("KeyPress"), wxMOTIF_STR("KeyRelease"), wxMOTIF_STR("ButtonPress"), wxMOTIF_STR("ButtonRelease"), // 2-5
405 wxMOTIF_STR("MotionNotify"), wxMOTIF_STR("EnterNotify"), wxMOTIF_STR("LeaveNotify"), wxMOTIF_STR("FocusIn"), // 6-9
406 wxMOTIF_STR("FocusOut"), wxMOTIF_STR("KeymapNotify"), wxMOTIF_STR("Expose"), wxMOTIF_STR("GraphicsExpose"), // 10-13
407 wxMOTIF_STR("NoExpose"), wxMOTIF_STR("VisibilityNotify"), wxMOTIF_STR("CreateNotify"), // 14-16
408 wxMOTIF_STR("DestroyNotify"), wxMOTIF_STR("UnmapNotify"), wxMOTIF_STR("MapNotify"), wxMOTIF_STR("MapRequest"),// 17-20
409 wxMOTIF_STR("ReparentNotify"), wxMOTIF_STR("ConfigureNotify"), wxMOTIF_STR("ConfigureRequest"), // 21-23
410 wxMOTIF_STR("GravityNotify"), wxMOTIF_STR("ResizeRequest"), wxMOTIF_STR("CirculateNotify"), // 24-26
411 wxMOTIF_STR("CirculateRequest"), wxMOTIF_STR("PropertyNotify"), wxMOTIF_STR("SelectionClear"), // 27-29
412 wxMOTIF_STR("SelectionRequest"), wxMOTIF_STR("SelectionNotify"), wxMOTIF_STR("ColormapNotify"), // 30-32
413 wxMOTIF_STR("ClientMessage"), wxMOTIF_STR("MappingNotify"), // 33-34
414 wxMOTIF_STR("unknown(+)")}; // 35
ea76a6a5
WS
415 type = wxMin(35, type); type = wxMax(1, type);
416 wxString str(event_name[type]);
417 return str;
2b5f62a0
VZ
418#endif
419}
420#endif
421
2b5f62a0
VZ
422// ----------------------------------------------------------------------------
423// accelerators
424// ----------------------------------------------------------------------------
425
426// Find the letter corresponding to the mnemonic, for Motif
427char wxFindMnemonic (const char *s)
428{
429 char mnem = 0;
430 int len = strlen (s);
431 int i;
eb6fa4b4 432
2b5f62a0
VZ
433 for (i = 0; i < len; i++)
434 {
435 if (s[i] == '&')
436 {
437 // Carefully handle &&
438 if ((i + 1) <= len && s[i + 1] == '&')
439 i++;
440 else
441 {
442 mnem = s[i + 1];
443 break;
444 }
445 }
446 }
447 return mnem;
448}
449
eb6fa4b4 450char* wxFindAccelerator( const char *s )
2b5f62a0 451{
eb6fa4b4 452#if 1
355b4d3d 453 wxUnusedVar(s);
2b5f62a0
VZ
454 // VZ: this function returns incorrect keysym which completely breaks kbd
455 // handling
456 return NULL;
eb6fa4b4
MB
457#else
458 // The accelerator text is after the \t char.
459 s = strchr( s, '\t' );
460
461 if( !s ) return NULL;
2b5f62a0 462
2b5f62a0
VZ
463 /*
464 Now we need to format it as X standard:
465
466 input output
467
468 F7 --> <Key>F7
469 Ctrl+N --> Ctrl<Key>N
470 Alt+k --> Meta<Key>k
471 Ctrl+Shift+A --> Ctrl Shift<Key>A
472
eb6fa4b4 473 and handle Ctrl-N & similia
2b5f62a0
VZ
474 */
475
476 static char buf[256];
eb6fa4b4 477
2b5f62a0 478 buf[0] = '\0';
eb6fa4b4
MB
479 wxString tmp = s + 1; // skip TAB
480 size_t index = 0;
2b5f62a0 481
eb6fa4b4 482 while( index < tmp.length() )
2b5f62a0 483 {
eb6fa4b4
MB
484 size_t plus = tmp.find( '+', index );
485 size_t minus = tmp.find( '-', index );
486
487 // neither '+' nor '-', add <Key>
488 if( plus == wxString::npos && minus == wxString::npos )
2b5f62a0 489 {
eb6fa4b4
MB
490 strcat( buf, "<Key>" );
491 strcat( buf, tmp.c_str() + index );
492
493 return buf;
2b5f62a0 494 }
eb6fa4b4
MB
495
496 // OK: npos is big and positive
497 size_t sep = wxMin( plus, minus );
498 wxString mod = tmp.substr( index, sep - index );
499
500 // Ctrl -> Ctrl
501 // Shift -> Shift
502 // Alt -> Meta
503 if( mod == "Alt" )
504 mod = "Meta";
505
506 if( buf[0] )
507 strcat( buf, " " );
508
509 strcat( buf, mod.c_str() );
510
511 index = sep + 1;
2b5f62a0 512 }
eb6fa4b4
MB
513
514 return NULL;
2b5f62a0
VZ
515#endif
516}
517
518XmString wxFindAcceleratorText (const char *s)
519{
eb6fa4b4 520#if 1
355b4d3d 521 wxUnusedVar(s);
2b5f62a0
VZ
522 // VZ: this function returns incorrect keysym which completely breaks kbd
523 // handling
524 return NULL;
eb6fa4b4
MB
525#else
526 // The accelerator text is after the \t char.
527 s = strchr( s, '\t' );
2b5f62a0 528
eb6fa4b4
MB
529 if( !s ) return NULL;
530
531 return wxStringToXmString( s + 1 ); // skip TAB!
2b5f62a0
VZ
532#endif
533}
534
2b5f62a0 535// Change a widget's foreground and background colours.
2b5f62a0
VZ
536void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
537{
105fbe1f
MB
538 if (!foregroundColour.Ok())
539 return;
540
2b5f62a0
VZ
541 // When should we specify the foreground, if it's calculated
542 // by wxComputeColours?
543 // Solution: say we start with the default (computed) foreground colour.
544 // If we call SetForegroundColour explicitly for a control or window,
545 // then the foreground is changed.
546 // Therefore SetBackgroundColour computes the foreground colour, and
547 // SetForegroundColour changes the foreground colour. The ordering is
548 // important.
549
550 XtVaSetValues ((Widget) widget,
551 XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
552 NULL);
553}
554
f516d986 555void wxDoChangeBackgroundColour(WXWidget widget, const wxColour& backgroundColour, bool changeArmColour)
2b5f62a0 556{
105fbe1f
MB
557 if (!backgroundColour.Ok())
558 return;
559
2b5f62a0
VZ
560 wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
561 (wxColour*) NULL);
562
563 XtVaSetValues ((Widget) widget,
564 XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
565 XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
566 XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
567 XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
568 NULL);
569
570 if (changeArmColour)
571 XtVaSetValues ((Widget) widget,
572 XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
573 NULL);
574}
575
fbfb8bcc 576extern void wxDoChangeFont(WXWidget widget, const wxFont& font)
e1aae528 577{
101b4778
MB
578 // Lesstif 0.87 hangs here, but 0.93 does not; MBN: sometimes it does
579#if !wxCHECK_LESSTIF() // || wxCHECK_LESSTIF_VERSION( 0, 93 )
e1aae528 580 Widget w = (Widget)widget;
e1aae528 581 XtVaSetValues( w,
73608949 582 wxFont::GetFontTag(), font.GetFontTypeC( XtDisplay(w) ),
e1aae528 583 NULL );
355b4d3d
WS
584#else
585 wxUnusedVar(widget);
586 wxUnusedVar(font);
e1aae528
MB
587#endif
588
589}
590
e1aae528
MB
591wxString wxXmStringToString( const XmString& xmString )
592{
593 char *txt;
594 if( XmStringGetLtoR( xmString, XmSTRING_DEFAULT_CHARSET, &txt ) )
595 {
596 wxString str(txt);
597 XtFree (txt);
598 return str;
599 }
600
601 return wxEmptyString;
602}
603
3e2d47e1
MB
604XmString wxStringToXmString( const char* str )
605{
606 return XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET);
607}
aae0472b
MB
608
609// ----------------------------------------------------------------------------
610// wxBitmap utility functions
611// ----------------------------------------------------------------------------
612
613// Creates a bitmap with transparent areas drawn in
614// the given colour.
fbfb8bcc 615wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, const wxColour& colour)
aae0472b
MB
616{
617 wxBitmap newBitmap(bitmap.GetWidth(),
618 bitmap.GetHeight(),
619 bitmap.GetDepth());
620 wxMemoryDC destDC;
621 wxMemoryDC srcDC;
622
f536319d 623 srcDC.SelectObjectAsSource(bitmap);
aae0472b
MB
624 destDC.SelectObject(newBitmap);
625
626 wxBrush brush(colour, wxSOLID);
aae0472b
MB
627 destDC.SetBackground(brush);
628 destDC.Clear();
629 destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(),
ea76a6a5 630 &srcDC, 0, 0, wxCOPY, true);
aae0472b
MB
631
632 return newBitmap;
633}
6769d0cb
MB
634
635// ----------------------------------------------------------------------------
636// Miscellaneous functions
637// ----------------------------------------------------------------------------
638
639WXWidget wxCreateBorderWidget( WXWidget parent, long style )
640{
641 Widget borderWidget = (Widget)NULL, parentWidget = (Widget)parent;
642
643 if (style & wxSIMPLE_BORDER)
644 {
645 borderWidget = XtVaCreateManagedWidget
646 (
647 "simpleBorder",
648 xmFrameWidgetClass, parentWidget,
649 XmNshadowType, XmSHADOW_ETCHED_IN,
650 XmNshadowThickness, 1,
651 NULL
652 );
653 }
654 else if (style & wxSUNKEN_BORDER)
655 {
656 borderWidget = XtVaCreateManagedWidget
657 (
658 "sunkenBorder",
659 xmFrameWidgetClass, parentWidget,
660 XmNshadowType, XmSHADOW_IN,
661 NULL
662 );
663 }
664 else if (style & wxRAISED_BORDER)
665 {
666 borderWidget = XtVaCreateManagedWidget
667 (
668 "raisedBorder",
669 xmFrameWidgetClass, parentWidget,
670 XmNshadowType, XmSHADOW_OUT,
671 NULL
672 );
673 }
674
675 return borderWidget;
676}