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 libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: MotifUI.h /main/6 1996/10/21 17:29:46 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. *
37 #include "MotifThread.h"
40 extern XtPointer _XmStringUngenerate (
44 XmTextType output_type);
51 #define PointInRect(RECT, X, Y) \
52 (X >= (int) (RECT).x && \
53 Y >= (int) (RECT).y && \
54 X <= (int) (RECT).x + (int) (RECT).width && \
55 Y <= (int) (RECT).y + (int) (RECT).height)
62 } PixmapLookupStruct, *PixmapLookup, **PixmapLookupList;
67 class MotifUI : public BaseUI {
73 static void WidgetDestroyCB(Widget, XtPointer, XtPointer);
74 static void WidgetHelpCB(Widget, XtPointer, XtPointer);
75 Cursor InitHourGlassCursor();
76 static void DumpWidget(Widget w, boolean verbose = false, int level = 0);
77 static void DumpWidgets(Widget w, boolean verbose = false, int level = 0);
78 static void ThreadCB(MotifThread *_thread, BaseUI *obj, ThreadCallback cb);
85 MotifUI(MotifUI *parent,
88 const char *widgetName = NULL);
89 void InstallDestroyCB();
91 virtual void WidgetDestroyed();
92 void GetPixmaps(Widget widget, char *iconFile, Pixmap *pixmap,
94 void FillBackground(Widget widget, Pixmap pixmap, Pixmap mask);
95 void SetDefaultResources(const Widget, const String *);
96 void GetResources(const XtResourceList, const int);
97 XmString StringCreate(char *string)
98 { if (string) return XmStringCreateLocalized(string);
101 void StringFree(XmString string)
102 { if (string) XmStringFree(string); string = NULL; }
103 char * StringExtract(XmString string)
105 s = (char *) _XmStringUngenerate(
107 XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
110 // Definitions for BaseUI virtual functions
111 virtual boolean SetCategory(char * /*name*/) { return true; }
112 virtual boolean SetName(char *name);
113 virtual boolean SetActivity(boolean flag);
114 virtual boolean SetVisiblity(boolean flag);
115 virtual boolean SetSelected(boolean flag);
116 void DoSetFocus(Widget);
119 void DoContextualHelp();
120 virtual void DoMakeVisible();
121 virtual boolean DoIsVisible();
122 virtual void DoBeginUpdate() { }
123 virtual void DoEndUpdate() { }
124 virtual void DoUpdateMessage(char * /*message*/) { }
125 virtual boolean SetOrder(int new_postion);
127 // Containers widgets should override SetView
128 virtual boolean SetView(ViewStyle) { return true; }
130 // Containers and icon widgets should override these
131 virtual boolean SetOpen(boolean) { return true; }
133 // Icon widgets should override these
134 virtual boolean SetIcon(IconStyle) { return true; }
135 virtual boolean SetParent(BaseUI *) { return true; }
137 virtual void NotifyDelete(BaseUI *);
138 static PixmapLookupList pixmap_table;
139 static int n_pixmaps;
140 static PointerCursor pointer_style;
144 static Widget topLevel;
145 static Display *display;
146 static XtAppContext appContext;
147 static XmFontList userFont;
153 static int shadowThickness;
154 static int bMenuButton;
158 void Thread(const char *cmd, ThreadCallback, int buf_len);
159 void Thread(int pid, int fd, ThreadCallback, int buf_len);
160 void Thread(int socket, ThreadCallback, int buf_len);
162 virtual void SetFocus();
163 void PointerShape(PointerCursor style);
164 PointerCursor PointerShape();
165 virtual void WidthHeight(int w, int h);
166 virtual void WidthHeight(int *w, int *h);
167 virtual void Width(int w);
169 virtual void Height(int h);
170 virtual int Height();
171 void AttachAll(int offset = 0);
172 void AttachTop(int offset = 0);
173 void AttachBottom(int offset = 0);
174 void AttachLeft(int offset = 0);
175 void AttachRight(int offset = 0);
176 void AttachTop(BaseUI *, int offset = 0, boolean opposite = false);
177 void AttachBottom(BaseUI *, int offset = 0, boolean opposite = false);
178 void AttachLeft(BaseUI *, int offset = 0, boolean opposite = false);
179 void AttachRight(BaseUI *, int offset = 0, boolean opposite = false);
180 void StringWidthHeight(const char *string, int *w, int *h);
181 int StringWidth(const char *string);
182 int StringHeight(const char *string);
183 void SetAddTimeOut(TimeOutCallback, void *callback_data, long interval);
184 void DumpUIHierarchy(boolean verbose = false, int level = 0);
186 const Widget BaseWidget() { return _w; }
187 virtual const Widget InnerWidget() { return _w; }
189 void Dump(boolean verbose = false,
192 // returns a classname to be used in GetResources
193 virtual const char *const className() { return "MotifUI"; }
197 #endif /* MOTIFUI_H */