2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: MotifUI.C /main/8 1998/08/03 08:59:09 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
39 #include <X11/cursorfont.h>
40 #include <X11/IntrinsicP.h>
44 #include <X11/keysym.h>
50 #include <Xm/ToggleB.h>
51 #include <Xm/RowColumn.h>
52 #include <Xm/ScrolledW.h>
55 PixmapLookupList MotifUI::pixmap_table = NULL;
56 XtAppContext MotifUI::appContext = NULL;
57 XmFontList MotifUI::userFont = NULL;
58 Display * MotifUI::display = NULL;
59 Widget MotifUI::topLevel;
64 int MotifUI::shadowThickness;
66 int MotifUI::bMenuButton;
67 int MotifUI::n_pixmaps = 0;
68 PointerCursor MotifUI::pointer_style = LEFT_SLANTED_ARROW_CURSOR;
71 MotifUI::MotifUI(MotifUI *parent,
74 const char *widgetName)
75 : BaseUI(parent, name, category)
79 _widgetName = STRDUP(widgetName);
81 _widgetName = STRDUP(name);
87 XtRemoveCallback(_w, XmNdestroyCallback, &MotifUI::WidgetDestroyCB,
92 void MotifUI::ThreadCB(MotifThread *_thread, BaseUI *obj, ThreadCallback cb)
94 (*cb)(obj, _thread->output, _thread->status);
98 void MotifUI::Thread(const char *cmd, ThreadCallback cb, int buf_len)
101 new MotifThread(this, cmd, &(MotifUI::ThreadCB), cb, buf_len);
104 void MotifUI::Thread(int pid, int fd, ThreadCallback cb, int buf_len)
106 new MotifThread(this, pid, fd, &(MotifUI::ThreadCB), cb, buf_len);
109 void MotifUI::Thread(int socket, ThreadCallback cb, int buf_len)
111 new MotifThread(this, socket, &(MotifUI::ThreadCB), cb, buf_len);
114 void MotifUI::SetFocus()
119 void MotifUI::DoSetFocus(Widget w)
121 XmProcessTraversal(w, XmTRAVERSE_CURRENT);
124 boolean MotifUI::DoIsVisible()
129 if (UIClass() == APPLICATION)
131 if (XtIsRealized(_w))
133 XWindowAttributes attributes;
134 XGetWindowAttributes(display, XtWindow(_w), &attributes);
135 if (attributes.map_state == IsUnmapped)
139 else if (XmGetVisibility(_w) == XmVISIBILITY_FULLY_OBSCURED)
145 void MotifUI::DoMakeVisible()
147 Widget sw = XtParent(_w);
148 if (sw && !XmIsScrolledWindow(sw))
150 if (sw && !XmIsScrolledWindow(sw))
152 if (sw && XmIsScrolledWindow(sw) && !XmIsMainWindow(sw))
153 XmScrollVisible(sw, _w, 0, 0);
156 void MotifUI::DoContextualHelp()
158 Widget context_widget, shell;
161 static Cursor cursor = (Cursor) NULL;
163 if (cursor == (Cursor) NULL)
164 cursor = XCreateFontCursor(display, XC_question_arrow);
167 BaseUI *window = this;
168 while (window->UIClass() != MAIN_WINDOW)
169 window = window->Parent();
170 shell = ((MotifUI *)window)->_w;
172 context_widget = XmTrackingEvent(shell, cursor, False, &event);
174 if (event.type == KeyPress || event.type == KeyRelease)
179 // Look for ESC key press and stop if we get one
180 if (event.xkey.state & ShiftMask)
185 keySym = XLookupKeysym((XKeyEvent *)&event, offset);
186 if (keySym == XK_Escape)
190 if (context_widget != NULL)
193 int returnVal = DtHelpReturnSelectedWidgetId(shell, NULL, &context_widget);
194 if (returnVal == DtHELP_SELECT_VALID)
197 XmAnyCallbackStruct cb;
199 cb.reason = XmCR_HELP;
203 while (context_widget != NULL)
205 // If there is no help at this widget, back track to find help
206 if (XtHasCallbacks(context_widget, XmNhelpCallback) ==
209 XtCallCallbacks(context_widget, XmNhelpCallback, &cb);
213 context_widget = XtParent(context_widget);
218 void MotifUI::WidgetHelpCB(Widget,
219 XtPointer clientData,
222 MotifUI * obj = (MotifUI *) clientData;
224 obj->HandleHelpRequest();
227 void MotifUI::WidgetDestroyCB(Widget,
228 XtPointer clientData,
231 MotifUI * obj = (MotifUI *) clientData;
233 obj->WidgetDestroyed();
236 void MotifUI::WidgetDestroyed()
242 void MotifUI::DoRefresh()
248 void MotifUI::DoToFront()
252 if (XtIsShell(XtParent(_w)))
253 XRaiseWindow(display, XtWindow(XtParent(_w)));
255 XRaiseWindow(display, XtWindow(_w));
259 void MotifUI::InstallDestroyCB()
262 XtAddCallback(_w, XmNdestroyCallback, &MotifUI::WidgetDestroyCB,
266 void MotifUI::InstallHelpCB()
271 if (UIClass() == MENU && UISubClass() != POPUP_MENU)
272 XtAddCallback(((Menu*)this)->GetCascade(), XmNhelpCallback,
273 &MotifUI::WidgetHelpCB, (XtPointer) this);
275 XtAddCallback(_w, XmNhelpCallback, &MotifUI::WidgetHelpCB,
279 boolean MotifUI::SetSelected(boolean flag)
285 XtVaSetValues(_w, GuiNselected, flag, NULL);
286 else if (XmIsToggleButton(_w))
287 XmToggleButtonSetState(_w, flag, False);
292 boolean MotifUI::SetName(char *name)
297 XmString xm_string = StringCreate(name);
298 XtVaSetValues(InnerWidget(), XmNlabelString, xm_string, NULL);
299 StringFree(xm_string);
304 boolean MotifUI::SetActivity(boolean flag)
310 XtVaSetValues(_w, GuiNactive, flag, NULL);
312 XtSetSensitive(_w, flag);
317 boolean MotifUI::SetVisiblity(boolean flag)
330 void MotifUI::GetResources(const XtResourceList resources,
331 const int numResources)
334 XtGetSubresources(XtParent(_w), (XtPointer) this, _widgetName,
335 className(), resources, numResources, NULL, 0);
338 void MotifUI::SetDefaultResources(const Widget,
339 const String *resources)
341 XrmDatabase rdb = NULL;
344 rdb = XrmGetStringDatabase("");
349 char *buf = new char[1000];
351 sprintf(buf, "%s%s", _name, resources[i]);
352 XrmPutLineResource(&rdb, buf);
359 XrmMergeDatabases(XtDatabase(display), &rdb);
360 XrmSetDatabase(display, rdb);
364 void MotifUI::NotifyDelete(BaseUI *obj)
366 MotifUI *p = (MotifUI *) obj;
369 XtRemoveCallback(_w, XmNdestroyCallback, &MotifUI::WidgetDestroyCB,
371 XtDestroyWidget(p->_w);
376 void MotifUI::Width(int width)
378 XtVaSetValues(this->BaseWidget(), XmNwidth, width, NULL);
384 XtVaGetValues(this->BaseWidget(), XmNwidth, &w, NULL);
388 void MotifUI::Height(int height)
390 XtVaSetValues(this->BaseWidget(), XmNheight, height, NULL);
393 int MotifUI::Height()
396 XtVaGetValues(this->BaseWidget(), XmNheight, &h, NULL);
400 void MotifUI::WidthHeight(int width, int height)
402 XtVaSetValues(this->BaseWidget(), XmNwidth, width, XmNheight, height, NULL);
405 void MotifUI::WidthHeight(int *width, int *height)
409 XtVaGetValues(this->BaseWidget(), XmNwidth, &w, XmNheight, &h, NULL);
414 void MotifUI::AttachAll(int offset)
416 XtVaSetValues(this->BaseWidget(),
417 XmNtopAttachment, XmATTACH_NONE,
418 XmNbottomAttachment, XmATTACH_NONE,
419 XmNleftAttachment, XmATTACH_NONE,
420 XmNrightAttachment, XmATTACH_NONE,
422 XtVaSetValues(this->BaseWidget(),
423 XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, offset,
424 XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, offset,
425 XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, offset,
426 XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, offset,
430 void MotifUI::AttachTop(int offset)
432 XtVaSetValues(this->BaseWidget(), XmNtopAttachment, XmATTACH_NONE, NULL);
433 XtVaSetValues(this->BaseWidget(), XmNtopAttachment, XmATTACH_FORM,
434 XmNtopOffset, offset, NULL);
437 void MotifUI::AttachBottom(int offset)
439 XtVaSetValues(this->BaseWidget(), XmNbottomAttachment, XmATTACH_NONE, NULL);
440 XtVaSetValues(this->BaseWidget(), XmNbottomAttachment, XmATTACH_FORM,
441 XmNbottomOffset, offset, NULL);
444 void MotifUI::AttachLeft(int offset)
446 XtVaSetValues(this->BaseWidget(), XmNleftAttachment, XmATTACH_NONE, NULL);
447 XtVaSetValues(this->BaseWidget(), XmNleftAttachment, XmATTACH_FORM,
448 XmNleftOffset, offset, NULL);
451 void MotifUI::AttachRight(int offset)
453 XtVaSetValues(this->BaseWidget(), XmNrightAttachment, XmATTACH_NONE, NULL);
454 XtVaSetValues(this->BaseWidget(), XmNrightAttachment, XmATTACH_FORM,
455 XmNrightOffset, offset, NULL);
458 void MotifUI::AttachTop(BaseUI *obj, int offset, boolean opposite)
460 XtVaSetValues(this->BaseWidget(), XmNtopAttachment, XmATTACH_NONE, NULL);
463 Widget w = ((MotifUI *)obj)->BaseWidget();
466 attachment = XmATTACH_OPPOSITE_WIDGET;
468 attachment = XmATTACH_WIDGET;
470 XtVaSetValues(this->BaseWidget(), XmNtopAttachment, attachment,
471 XmNtopWidget, w, XmNtopOffset, offset, NULL);
475 void MotifUI::AttachBottom(BaseUI *obj, int offset, boolean opposite)
477 XtVaSetValues(this->BaseWidget(), XmNbottomAttachment, XmATTACH_NONE, NULL);
480 Widget w = ((MotifUI *)obj)->BaseWidget();
483 attachment = XmATTACH_OPPOSITE_WIDGET;
485 attachment = XmATTACH_WIDGET;
487 XtVaSetValues(this->BaseWidget(), XmNbottomAttachment, attachment,
488 XmNbottomWidget, w, XmNbottomOffset, offset, NULL);
492 void MotifUI::AttachLeft(BaseUI *obj, int offset, boolean opposite)
494 XtVaSetValues(this->BaseWidget(), XmNleftAttachment, XmATTACH_NONE, NULL);
499 attachment = XmATTACH_OPPOSITE_WIDGET;
501 attachment = XmATTACH_WIDGET;
502 Widget w = ((MotifUI *)obj)->BaseWidget();
503 XtVaSetValues(this->BaseWidget(), XmNleftAttachment, attachment,
504 XmNleftWidget, w, XmNleftOffset, offset, NULL);
508 void MotifUI::AttachRight(BaseUI *obj, int offset, boolean opposite)
510 XtVaSetValues(this->BaseWidget(), XmNrightAttachment, XmATTACH_NONE, NULL);
513 Widget w = ((MotifUI *)obj)->BaseWidget();
516 attachment = XmATTACH_OPPOSITE_WIDGET;
518 attachment = XmATTACH_WIDGET;
520 XtVaSetValues(this->BaseWidget(), XmNrightAttachment, attachment,
521 XmNrightWidget, w, XmNrightOffset, offset, NULL);
525 void MotifUI::StringWidthHeight(const char *string, int *width, int *height)
529 XmString xm_string = StringCreate((char *)string);
530 XmStringExtent(userFont, xm_string, &w, &h);
533 StringFree(xm_string);
536 int MotifUI::StringWidth(const char *string)
540 StringWidthHeight(string, &width, &dummy);
544 int MotifUI::StringHeight(const char *string)
548 StringWidthHeight(string, &dummy, &height);
552 boolean MotifUI::SetOrder(int new_position)
554 if (XmIsRowColumn(((MotifUI *)Parent())->InnerWidget()))
555 XtVaSetValues(BaseWidget(), XmNpositionIndex, new_position, NULL);
559 void MotifUI::Dump(boolean verbose,
564 BaseUI::Dump(true, level);
567 for (i = -2; i < level; i++) printf(" ");
568 printf("BaseWidget : %08lx\n", _w);
571 BaseUI::Dump(false, level);
581 } TimeOutCallbackData;
584 ObjectTimeProc(XtPointer callback_data, XtIntervalId * /*id*/)
586 TimeOutCallbackData *data = (TimeOutCallbackData *) callback_data;
587 (*data->fp)(data->obj, data->callback_data);
592 void MotifUI::SetAddTimeOut(TimeOutCallback timeoutCB,
599 TimeOutCallbackData * data = new TimeOutCallbackData;
600 data->fp = timeoutCB;
602 data->callback_data = callback_data;
603 XtAppAddTimeOut(appContext, (unsigned long) interval, ObjectTimeProc, data);
606 void MotifUI::FillBackground(Widget widget, Pixmap pixmap, Pixmap mask)
608 static Pixmap temp = 0L;
610 static unsigned int old_width = 0, old_height = 0, old_depth = 0;
611 unsigned int width, height, junk, dep;
615 XGetGeometry(display, pixmap, &root, (int *) &junk,
616 (int *) &junk, &width, &height, &junk, &dep);
618 (old_width < width || old_height < height || old_depth != dep))
621 XFreeGC(display, gc);
622 XFreePixmap(display, temp);
630 if (dep == 1 && UIClass() == MAIN_WINDOW)
631 XtVaGetValues(widget, XmNforeground, &xgc.foreground, NULL);
633 XtVaGetValues(widget, XmNbackground, &xgc.foreground, NULL);
636 temp = XCreatePixmap(display, RootWindowOfScreen(XtScreen(widget)),
638 xgc.function = GXcopy;
639 gc = XCreateGC(display, pixmap, GCForeground|GCFunction, &xgc);
642 XSetForeground(display, gc, xgc.foreground);
644 XFillRectangle(display, temp, gc, 0, 0, width, height);
645 if (mask != XmUNSPECIFIED_PIXMAP)
646 XSetClipMask(display, gc, mask);
648 XSetClipMask(display, gc, None);
649 XCopyArea(display, pixmap, temp, gc, 0, 0, width, height, 0, 0);
650 XSetClipMask(display, gc, None);
651 XCopyArea(display, temp, pixmap, gc, 0, 0, width, height, 0, 0);
654 // Pixmap caching utility
655 void MotifUI::GetPixmaps(Widget w,
660 // Try to find pixmap in cache
661 PixmapLookupList pixmaps = pixmap_table;
663 for (i = 0; i < n_pixmaps; i++, pixmaps++)
664 if (!strcmp((**pixmaps).name, name))
666 *pixmap = (**pixmaps).pixmap;
668 *mask = (**pixmaps).mask;
674 SubstitutionRec subs[1];
676 char *PIXMAP_DIR = "/usr/dt/appconfig/icons/%L/%B:"
677 "/usr/dt/appconfig/icons/C/%B:"
678 "/usr/include/X11/bitmaps/%B";
685 if ((s = getenv("XBMLANGPATH")) && *s)
687 if ((s = getenv("XMICONSEARCHPATH")) && *s)
690 bmPath = new char [strlen(s) + strlen(PIXMAP_DIR) + 2];
691 sprintf(bmPath, "%s:%s", PIXMAP_DIR, s);
696 subs[0].substitution = name;
697 s = XtFindFile(bmPath, subs, XtNumber(subs), NULL);
698 if (bmPath != PIXMAP_DIR)
703 if (!s || stat(s, &statbuf) < 0)
705 *pixmap = XmUNSPECIFIED_PIXMAP;
707 *mask = XmUNSPECIFIED_PIXMAP;
712 if (!strcmp(s + len - 3, ".pm"))
714 XpmAttributes attributes;
715 memset((char *)&attributes, 0, sizeof(XpmAttributes));
717 XpmReadFileToPixmap(display, root, s, pixmap, &_mask, &attributes);
719 _DtXpmReadFileToPixmap(display, root, s, pixmap, &_mask, &attributes);
723 FillBackground(w, *pixmap, _mask);
725 XpmFreeAttributes(&attributes);
727 _DtXpmFreeAttributes(&attributes);
732 if (UIClass() == MAIN_WINDOW)
733 *pixmap = XmGetPixmapByDepth(XtScreen(w), s, white, black, depth);
735 *pixmap = XmGetPixmapByDepth(XtScreen(w), s, black, white, depth);
736 char *s1 = new char [len + 3];
738 strcpy(s1 + len - 3, "_m.bm");
739 if (stat(s1, &statbuf) < 0)
740 _mask = XmUNSPECIFIED_PIXMAP;
743 _mask = XmGetPixmapByDepth(XtScreen(w), s1, white, black, 1);
744 FillBackground(w, *pixmap, _mask);
753 // Add pixmap to table
754 if (!(n_pixmaps % 8))
756 pixmaps = new PixmapLookup [n_pixmaps + 8];
757 for (i = 0; i < n_pixmaps; i++)
758 pixmaps[i] = pixmap_table[i];
759 for (i = n_pixmaps; i < n_pixmaps + 8; i++)
760 pixmaps[i] = new PixmapLookupStruct;
761 delete []pixmap_table;
762 pixmap_table = pixmaps;
764 pixmap_table[n_pixmaps]->name = strdup(name);
765 pixmap_table[n_pixmaps]->pixmap = *pixmap;
766 pixmap_table[n_pixmaps]->mask = _mask;
770 // Cursor Shape support
772 #define time32_width 32
773 #define time32_height 32
774 #define time32_x_hot 15
775 #define time32_y_hot 15
776 static unsigned char time32_bits[] = {
777 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
778 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
779 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
780 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
781 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
782 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
783 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
784 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
785 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
786 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
787 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
789 #define time32m_width 32
790 #define time32m_height 32
791 static unsigned char time32m_bits[] = {
792 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
793 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
794 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
795 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
796 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
797 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
798 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
799 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
800 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
801 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
802 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
804 #define time16_x_hot 7
805 #define time16_y_hot 7
806 #define time16_width 16
807 #define time16_height 16
808 static unsigned char time16_bits[] = {
809 0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
810 0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
811 0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
813 #define time16m_width 16
814 #define time16m_height 16
815 static unsigned char time16m_bits[] = {
816 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
817 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
818 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
820 Cursor MotifUI::InitHourGlassCursor()
824 unsigned int xHotspot;
825 unsigned int yHotspot;
831 Cursor cursor = None;
833 if (XQueryBestCursor(display, root, 32, 32, &width, &height))
835 if ((width >= 32) && (height >= 32))
837 width = time32_width;
838 height = time32_height;
839 bits = (char *)time32_bits;
840 maskBits = (char *)time32m_bits;
841 xHotspot = time32_x_hot;
842 yHotspot = time32_y_hot;
846 width = time16_width;
847 height = time16_height;
848 bits = (char *)time16_bits;
849 maskBits = (char *)time16m_bits;
850 xHotspot = time16_x_hot;
851 yHotspot = time16_y_hot;
854 pixmap = XCreateBitmapFromData(display, root, bits, width, height);
856 maskPixmap = XCreateBitmapFromData(display, root, maskBits,
858 xcolors[0].pixel = black;
859 xcolors[1].pixel = white;
861 XQueryColors(display,
862 DefaultColormapOfScreen(DefaultScreenOfDisplay (display)),
864 cursor = XCreatePixmapCursor(display, pixmap, maskPixmap,
865 &(xcolors[0]), &(xcolors[1]), xHotspot, yHotspot);
866 XFreePixmap(display, pixmap);
867 XFreePixmap(display, maskPixmap);
872 PointerCursor MotifUI::PointerShape()
874 return pointer_style;
877 void MotifUI::PointerShape(PointerCursor style)
879 static Cursor left = (Cursor) 0L;
880 static Cursor right = (Cursor) 0L;
881 static Cursor watch = (Cursor) 0L;
882 static Cursor hour_glass = (Cursor) 0L;
883 static Cursor ibeam = (Cursor) 0L;
884 static Cursor cross_hair = (Cursor) 0L;
890 switch (pointer_style = style)
892 case LEFT_SLANTED_ARROW_CURSOR:
894 left = XCreateFontCursor(display, XC_left_ptr);
897 case RIGHT_SLANTED_ARROW_CURSOR:
899 right = XCreateFontCursor(display, XC_right_ptr);
904 watch = XCreateFontCursor(display, XC_watch);
907 case HOUR_GLASS_CURSOR:
909 hour_glass = InitHourGlassCursor();
914 ibeam = XCreateFontCursor(display, XC_xterm);
917 case CROSS_HAIRS_CURSOR:
919 cross_hair = XCreateFontCursor(display, XC_crosshair);
922 default: cursor = None; break;
925 if (XtIsRealized(_w))
926 XDefineCursor(display, XtWindow(_w), cursor);
931 static void VerbosePass1(Widget w, int level)
936 int new_width = (level * 3) + strlen(XrmQuarkToString(w->core.xrm_name)) +
937 strlen(w->core.widget_class->core_class.class_name) + 3;
938 if (new_width > G_width)
941 for (i = 0; i < w->core.num_popups; i++)
942 VerbosePass1(w->core.popup_list[i], level + 1);
943 if (XtIsComposite(w))
945 CompositeWidget cw = (CompositeWidget) w;
946 for (i = 0; i < cw->composite.num_children; i++)
947 VerbosePass1(cw->composite.children[i], level + 1);
951 void MotifUI::DumpWidget(Widget w, boolean verbose, int level)
955 for (i = 0; i < level; i++)
957 printf("%s : %s", XrmQuarkToString(w->core.xrm_name),
958 w->core.widget_class->core_class.class_name);
961 int n = (level * 3) + strlen(XrmQuarkToString(w->core.xrm_name)) +
962 strlen(w->core.widget_class->core_class.class_name) + 3;
963 for ( ; n < G_width; n++)
968 printf(" Unmanaged");
969 if (XtIsSensitive(w))
970 printf(" Sensitive ");
972 printf(" Insensitive");
974 printf(" Realized ");
976 printf(" Unrealized");
978 printf(" Visible\n");
980 printf(" Invisible\n");
986 void MotifUI::DumpWidgets(Widget w, boolean verbose, int level)
988 DumpWidget(w, verbose, level);
993 for (i = 0; i < w->core.num_popups; i++)
994 DumpWidgets(w->core.popup_list[i], verbose, level + 1);
996 if (XtIsComposite(w))
998 CompositeWidget cw = (CompositeWidget) w;
999 for (i = 0; i < cw->composite.num_children; i++)
1000 DumpWidgets(cw->composite.children[i], verbose, level + 1);
1004 void MotifUI::DumpUIHierarchy(boolean verbose, int level)
1007 VerbosePass1(_w, 0);
1008 DumpWidgets(_w, verbose, level);