]> git.saurik.com Git - wxWidgets.git/blame - src/motif/utils.cpp
fixed wxSVGFileDC::write() to output UTF-8 even in ANSI build
[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
c2ca375c
VZ
139wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer* timer)
140{
141 return new wxMotifTimerImpl(timer);
142}
143
2b5f62a0
VZ
144// ----------------------------------------------------------------------------
145// display info
146// ----------------------------------------------------------------------------
147
148void wxGetMousePosition( int* x, int* y )
149{
150#if wxUSE_NANOX
151 // TODO
152 *x = 0;
153 *y = 0;
154#else
155 XMotionEvent xev;
156 Window root, child;
eb6fa4b4
MB
157 XQueryPointer(wxGlobalDisplay(),
158 DefaultRootWindow(wxGlobalDisplay()),
2b5f62a0
VZ
159 &root, &child,
160 &(xev.x_root), &(xev.y_root),
161 &(xev.x), &(xev.y),
162 &(xev.state));
163 *x = xev.x_root;
164 *y = xev.y_root;
165#endif
e933b5bc 166}
2b5f62a0 167
ea76a6a5 168// Return true if we have a colour display
2b5f62a0
VZ
169bool wxColourDisplay()
170{
171 return wxDisplayDepth() > 1;
172}
173
174// Returns depth of screen
175int wxDisplayDepth()
176{
eb6fa4b4 177 Display *dpy = wxGlobalDisplay();
2b5f62a0
VZ
178
179 return DefaultDepth (dpy, DefaultScreen (dpy));
180}
181
182// Get size of display
183void wxDisplaySize(int *width, int *height)
184{
eb6fa4b4 185 Display *dpy = wxGlobalDisplay();
2b5f62a0
VZ
186
187 if ( width )
188 *width = DisplayWidth (dpy, DefaultScreen (dpy));
189 if ( height )
190 *height = DisplayHeight (dpy, DefaultScreen (dpy));
191}
192
193void wxDisplaySizeMM(int *width, int *height)
194{
eb6fa4b4 195 Display *dpy = wxGlobalDisplay();
2b5f62a0
VZ
196
197 if ( width )
198 *width = DisplayWidthMM(dpy, DefaultScreen (dpy));
199 if ( height )
200 *height = DisplayHeightMM(dpy, DefaultScreen (dpy));
201}
202
203void wxClientDisplayRect(int *x, int *y, int *width, int *height)
204{
205 // This is supposed to return desktop dimensions minus any window
206 // manager panels, menus, taskbars, etc. If there is a way to do that
207 // for this platform please fix this function, otherwise it defaults
208 // to the entire desktop.
209 if (x) *x = 0;
210 if (y) *y = 0;
211 wxDisplaySize(width, height);
212}
213
214
215// Configurable display in wxX11 and wxMotif
216static WXDisplay *gs_currentDisplay = NULL;
217static wxString gs_displayName;
218
219WXDisplay *wxGetDisplay()
220{
221 if (gs_currentDisplay)
222 return gs_currentDisplay;
2b5f62a0
VZ
223 else if (wxTheApp)
224 return wxTheApp->GetInitialDisplay();
225 return NULL;
2b5f62a0
VZ
226}
227
228bool wxSetDisplay(const wxString& display_name)
229{
230 gs_displayName = display_name;
231
ea76a6a5 232 if ( display_name.empty() )
2b5f62a0
VZ
233 {
234 gs_currentDisplay = NULL;
235
ea76a6a5 236 return true;
2b5f62a0
VZ
237 }
238 else
239 {
2b5f62a0
VZ
240 Cardinal argc = 0;
241
242 Display *display = XtOpenDisplay((XtAppContext) wxTheApp->GetAppContext(),
3e2d47e1
MB
243 display_name.c_str(),
244 wxTheApp->GetAppName().c_str(),
245 wxTheApp->GetClassName().c_str(),
2b5f62a0
VZ
246 NULL,
247#if XtSpecificationRelease < 5
248 0, &argc,
249#else
250 0, (int *)&argc,
251#endif
252 NULL);
253
254 if (display)
255 {
256 gs_currentDisplay = (WXDisplay*) display;
ea76a6a5 257 return true;
2b5f62a0
VZ
258 }
259 else
96be256b 260 return false;
2b5f62a0
VZ
261 }
262}
263
264wxString wxGetDisplayName()
265{
266 return gs_displayName;
267}
268
269wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
270{
271 return wxGenericFindWindowAtPoint(pt);
272}
273
2b5f62a0
VZ
274// ----------------------------------------------------------------------------
275// Some colour manipulation routines
276// ----------------------------------------------------------------------------
277
278void wxHSVToXColor(wxHSV *hsv,XColor *rgb)
279{
280 int h = hsv->h;
281 int s = hsv->s;
282 int v = hsv->v;
283 int r = 0, g = 0, b = 0;
284 int i, f;
285 int p, q, t;
286 s = (s * wxMAX_RGB) / wxMAX_SV;
287 v = (v * wxMAX_RGB) / wxMAX_SV;
288 if (h == 360) h = 0;
289 if (s == 0) { h = 0; r = g = b = v; }
290 i = h / 60;
291 f = h % 60;
292 p = v * (wxMAX_RGB - s) / wxMAX_RGB;
293 q = v * (wxMAX_RGB - s * f / 60) / wxMAX_RGB;
294 t = v * (wxMAX_RGB - s * (60 - f) / 60) / wxMAX_RGB;
295 switch (i)
296 {
297 case 0: r = v, g = t, b = p; break;
298 case 1: r = q, g = v, b = p; break;
299 case 2: r = p, g = v, b = t; break;
300 case 3: r = p, g = q, b = v; break;
301 case 4: r = t, g = p, b = v; break;
302 case 5: r = v, g = p, b = q; break;
303 }
355b4d3d
WS
304 rgb->red = (unsigned short)(r << 8);
305 rgb->green = (unsigned short)(g << 8);
306 rgb->blue = (unsigned short)(b << 8);
2b5f62a0
VZ
307}
308
309void wxXColorToHSV(wxHSV *hsv,XColor *rgb)
310{
311 int r = rgb->red >> 8;
312 int g = rgb->green >> 8;
313 int b = rgb->blue >> 8;
314 int maxv = wxMax3(r, g, b);
315 int minv = wxMin3(r, g, b);
316 int h = 0, s, v;
317 v = maxv;
318 if (maxv) s = (maxv - minv) * wxMAX_RGB / maxv;
319 else s = 0;
320 if (s == 0) h = 0;
321 else
322 {
323 int rc, gc, bc, hex = 0;
324 rc = (maxv - r) * wxMAX_RGB / (maxv - minv);
325 gc = (maxv - g) * wxMAX_RGB / (maxv - minv);
326 bc = (maxv - b) * wxMAX_RGB / (maxv - minv);
327 if (r == maxv) { h = bc - gc, hex = 0; }
328 else if (g == maxv) { h = rc - bc, hex = 2; }
329 else if (b == maxv) { h = gc - rc, hex = 4; }
330 h = hex * 60 + (h * 60 / wxMAX_RGB);
331 if (h < 0) h += 360;
332 }
333 hsv->h = h;
334 hsv->s = (s * wxMAX_SV) / wxMAX_RGB;
335 hsv->v = (v * wxMAX_SV) / wxMAX_RGB;
336}
337
338void wxAllocNearestColor(Display *d,Colormap cmp,XColor *xc)
339{
340#if !wxUSE_NANOX
341 int llp;
342
343 int screen = DefaultScreen(d);
344 int num_colors = DisplayCells(d,screen);
345
346 XColor *color_defs = new XColor[num_colors];
347 for(llp = 0;llp < num_colors;llp++) color_defs[llp].pixel = llp;
348 XQueryColors(d,cmp,color_defs,num_colors);
349
350 wxHSV hsv_defs, hsv;
351 wxXColorToHSV(&hsv,xc);
352
353 int diff, min_diff = 0, pixel = 0;
354
355 for(llp = 0;llp < num_colors;llp++)
356 {
357 wxXColorToHSV(&hsv_defs,&color_defs[llp]);
358 diff = wxSIGN(wxH_WEIGHT * (hsv.h - hsv_defs.h)) +
359 wxSIGN(wxS_WEIGHT * (hsv.s - hsv_defs.s)) +
360 wxSIGN(wxV_WEIGHT * (hsv.v - hsv_defs.v));
361 if (llp == 0) min_diff = diff;
362 if (min_diff > diff) { min_diff = diff; pixel = llp; }
363 if (min_diff == 0) break;
364 }
365
366 xc -> red = color_defs[pixel].red;
367 xc -> green = color_defs[pixel].green;
368 xc -> blue = color_defs[pixel].blue;
369 xc -> flags = DoRed | DoGreen | DoBlue;
370
371/* FIXME, TODO
372 if (!XAllocColor(d,cmp,xc))
373 cout << "wxAllocNearestColor : Warning : Cannot find nearest color !\n";
374*/
375
376 delete[] color_defs;
377#endif
378}
379
380void wxAllocColor(Display *d,Colormap cmp,XColor *xc)
381{
382 if (!XAllocColor(d,cmp,xc))
383 {
384 // cout << "wxAllocColor : Warning : Can not allocate color, attempt find nearest !\n";
385 wxAllocNearestColor(d,cmp,xc);
386 }
387}
388
389#ifdef __WXDEBUG__
390wxString wxGetXEventName(XEvent& event)
391{
392#if wxUSE_NANOX
393 wxString str(wxT("(some event)"));
394 return str;
395#else
396 int type = event.xany.type;
ea76a6a5 397 static char* event_name[] = {
f1db433a
VZ
398 wxMOTIF_STR(""), wxMOTIF_STR("unknown(-)"), // 0-1
399 wxMOTIF_STR("KeyPress"), wxMOTIF_STR("KeyRelease"), wxMOTIF_STR("ButtonPress"), wxMOTIF_STR("ButtonRelease"), // 2-5
400 wxMOTIF_STR("MotionNotify"), wxMOTIF_STR("EnterNotify"), wxMOTIF_STR("LeaveNotify"), wxMOTIF_STR("FocusIn"), // 6-9
401 wxMOTIF_STR("FocusOut"), wxMOTIF_STR("KeymapNotify"), wxMOTIF_STR("Expose"), wxMOTIF_STR("GraphicsExpose"), // 10-13
402 wxMOTIF_STR("NoExpose"), wxMOTIF_STR("VisibilityNotify"), wxMOTIF_STR("CreateNotify"), // 14-16
403 wxMOTIF_STR("DestroyNotify"), wxMOTIF_STR("UnmapNotify"), wxMOTIF_STR("MapNotify"), wxMOTIF_STR("MapRequest"),// 17-20
404 wxMOTIF_STR("ReparentNotify"), wxMOTIF_STR("ConfigureNotify"), wxMOTIF_STR("ConfigureRequest"), // 21-23
405 wxMOTIF_STR("GravityNotify"), wxMOTIF_STR("ResizeRequest"), wxMOTIF_STR("CirculateNotify"), // 24-26
406 wxMOTIF_STR("CirculateRequest"), wxMOTIF_STR("PropertyNotify"), wxMOTIF_STR("SelectionClear"), // 27-29
407 wxMOTIF_STR("SelectionRequest"), wxMOTIF_STR("SelectionNotify"), wxMOTIF_STR("ColormapNotify"), // 30-32
408 wxMOTIF_STR("ClientMessage"), wxMOTIF_STR("MappingNotify"), // 33-34
409 wxMOTIF_STR("unknown(+)")}; // 35
ea76a6a5
WS
410 type = wxMin(35, type); type = wxMax(1, type);
411 wxString str(event_name[type]);
412 return str;
2b5f62a0
VZ
413#endif
414}
415#endif
416
2b5f62a0
VZ
417// ----------------------------------------------------------------------------
418// accelerators
419// ----------------------------------------------------------------------------
420
421// Find the letter corresponding to the mnemonic, for Motif
422char wxFindMnemonic (const char *s)
423{
424 char mnem = 0;
425 int len = strlen (s);
426 int i;
eb6fa4b4 427
2b5f62a0
VZ
428 for (i = 0; i < len; i++)
429 {
430 if (s[i] == '&')
431 {
432 // Carefully handle &&
433 if ((i + 1) <= len && s[i + 1] == '&')
434 i++;
435 else
436 {
437 mnem = s[i + 1];
438 break;
439 }
440 }
441 }
442 return mnem;
443}
444
eb6fa4b4 445char* wxFindAccelerator( const char *s )
2b5f62a0 446{
eb6fa4b4 447#if 1
355b4d3d 448 wxUnusedVar(s);
2b5f62a0
VZ
449 // VZ: this function returns incorrect keysym which completely breaks kbd
450 // handling
451 return NULL;
eb6fa4b4
MB
452#else
453 // The accelerator text is after the \t char.
454 s = strchr( s, '\t' );
455
456 if( !s ) return NULL;
2b5f62a0 457
2b5f62a0
VZ
458 /*
459 Now we need to format it as X standard:
460
461 input output
462
463 F7 --> <Key>F7
464 Ctrl+N --> Ctrl<Key>N
465 Alt+k --> Meta<Key>k
466 Ctrl+Shift+A --> Ctrl Shift<Key>A
467
eb6fa4b4 468 and handle Ctrl-N & similia
2b5f62a0
VZ
469 */
470
471 static char buf[256];
eb6fa4b4 472
2b5f62a0 473 buf[0] = '\0';
eb6fa4b4
MB
474 wxString tmp = s + 1; // skip TAB
475 size_t index = 0;
2b5f62a0 476
eb6fa4b4 477 while( index < tmp.length() )
2b5f62a0 478 {
eb6fa4b4
MB
479 size_t plus = tmp.find( '+', index );
480 size_t minus = tmp.find( '-', index );
481
482 // neither '+' nor '-', add <Key>
483 if( plus == wxString::npos && minus == wxString::npos )
2b5f62a0 484 {
eb6fa4b4
MB
485 strcat( buf, "<Key>" );
486 strcat( buf, tmp.c_str() + index );
487
488 return buf;
2b5f62a0 489 }
eb6fa4b4
MB
490
491 // OK: npos is big and positive
492 size_t sep = wxMin( plus, minus );
493 wxString mod = tmp.substr( index, sep - index );
494
495 // Ctrl -> Ctrl
496 // Shift -> Shift
497 // Alt -> Meta
498 if( mod == "Alt" )
499 mod = "Meta";
500
501 if( buf[0] )
502 strcat( buf, " " );
503
504 strcat( buf, mod.c_str() );
505
506 index = sep + 1;
2b5f62a0 507 }
eb6fa4b4
MB
508
509 return NULL;
2b5f62a0
VZ
510#endif
511}
512
513XmString wxFindAcceleratorText (const char *s)
514{
eb6fa4b4 515#if 1
355b4d3d 516 wxUnusedVar(s);
2b5f62a0
VZ
517 // VZ: this function returns incorrect keysym which completely breaks kbd
518 // handling
519 return NULL;
eb6fa4b4
MB
520#else
521 // The accelerator text is after the \t char.
522 s = strchr( s, '\t' );
2b5f62a0 523
eb6fa4b4
MB
524 if( !s ) return NULL;
525
526 return wxStringToXmString( s + 1 ); // skip TAB!
2b5f62a0
VZ
527#endif
528}
529
2b5f62a0 530// Change a widget's foreground and background colours.
2b5f62a0
VZ
531void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
532{
105fbe1f
MB
533 if (!foregroundColour.Ok())
534 return;
535
2b5f62a0
VZ
536 // When should we specify the foreground, if it's calculated
537 // by wxComputeColours?
538 // Solution: say we start with the default (computed) foreground colour.
539 // If we call SetForegroundColour explicitly for a control or window,
540 // then the foreground is changed.
541 // Therefore SetBackgroundColour computes the foreground colour, and
542 // SetForegroundColour changes the foreground colour. The ordering is
543 // important.
544
545 XtVaSetValues ((Widget) widget,
546 XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
547 NULL);
548}
549
f516d986 550void wxDoChangeBackgroundColour(WXWidget widget, const wxColour& backgroundColour, bool changeArmColour)
2b5f62a0 551{
105fbe1f
MB
552 if (!backgroundColour.Ok())
553 return;
554
2b5f62a0
VZ
555 wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
556 (wxColour*) NULL);
557
558 XtVaSetValues ((Widget) widget,
559 XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
560 XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
561 XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
562 XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
563 NULL);
564
565 if (changeArmColour)
566 XtVaSetValues ((Widget) widget,
567 XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
568 NULL);
569}
570
fbfb8bcc 571extern void wxDoChangeFont(WXWidget widget, const wxFont& font)
e1aae528 572{
101b4778
MB
573 // Lesstif 0.87 hangs here, but 0.93 does not; MBN: sometimes it does
574#if !wxCHECK_LESSTIF() // || wxCHECK_LESSTIF_VERSION( 0, 93 )
e1aae528 575 Widget w = (Widget)widget;
e1aae528 576 XtVaSetValues( w,
73608949 577 wxFont::GetFontTag(), font.GetFontTypeC( XtDisplay(w) ),
e1aae528 578 NULL );
355b4d3d
WS
579#else
580 wxUnusedVar(widget);
581 wxUnusedVar(font);
e1aae528
MB
582#endif
583
584}
585
e1aae528
MB
586wxString wxXmStringToString( const XmString& xmString )
587{
588 char *txt;
589 if( XmStringGetLtoR( xmString, XmSTRING_DEFAULT_CHARSET, &txt ) )
590 {
591 wxString str(txt);
592 XtFree (txt);
593 return str;
594 }
595
596 return wxEmptyString;
597}
598
3e2d47e1
MB
599XmString wxStringToXmString( const wxString& str )
600{
9b135950 601 return wxStringToXmString(str.mb_str());
3e2d47e1
MB
602}
603
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}