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 #undef STRDUP /* get rid of memutil.h definition. Use def in BaseUI.h. */
41 #include "MotifThread.h"
44 extern XtPointer _XmStringUngenerate (
48 XmTextType output_type);
55 #define PointInRect(RECT, X, Y) \
56 (X >= (int) (RECT).x && \
57 Y >= (int) (RECT).y && \
58 X <= (int) (RECT).x + (int) (RECT).width && \
59 Y <= (int) (RECT).y + (int) (RECT).height)
66 } PixmapLookupStruct, *PixmapLookup, **PixmapLookupList;
71 class MotifUI : public BaseUI {
77 static void WidgetDestroyCB(Widget, XtPointer, XtPointer);
78 static void WidgetHelpCB(Widget, XtPointer, XtPointer);
79 Cursor InitHourGlassCursor();
80 static void DumpWidget(Widget w, boolean verbose = false, int level = 0);
81 static void DumpWidgets(Widget w, boolean verbose = false, int level = 0);
82 static void ThreadCB(MotifThread *_thread, BaseUI *obj, ThreadCallback cb);
89 MotifUI(MotifUI *parent,
92 const char *widgetName = NULL);
93 void InstallDestroyCB();
95 virtual void WidgetDestroyed();
96 void GetPixmaps(Widget widget, char *iconFile, Pixmap *pixmap,
98 void FillBackground(Widget widget, Pixmap pixmap, Pixmap mask);
99 void SetDefaultResources(const Widget, const String *);
100 void GetResources(const XtResourceList, const int);
101 XmString StringCreate(char *string)
102 { if (string) return XmStringCreateLocalized(string);
105 void StringFree(XmString string)
106 { if (string) XmStringFree(string); string = NULL; }
107 char * StringExtract(XmString string)
109 s = (char *) _XmStringUngenerate(
111 XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
114 // Definitions for BaseUI virtual functions
115 virtual boolean SetCategory(char * /*name*/) { return true; }
116 virtual boolean SetName(char *name);
117 virtual boolean SetActivity(boolean flag);
118 virtual boolean SetVisiblity(boolean flag);
119 virtual boolean SetSelected(boolean flag);
120 void DoSetFocus(Widget);
123 void DoContextualHelp();
124 virtual void DoMakeVisible();
125 virtual boolean DoIsVisible();
126 virtual void DoBeginUpdate() { }
127 virtual void DoEndUpdate() { }
128 virtual void DoUpdateMessage(char * /*message*/) { }
129 virtual boolean SetOrder(int new_postion);
131 // Containers widgets should override SetView
132 virtual boolean SetView(ViewStyle) { return true; }
134 // Containers and icon widgets should override these
135 virtual boolean SetOpen(boolean) { return true; }
137 // Icon widgets should override these
138 virtual boolean SetIcon(IconStyle) { return true; }
139 virtual boolean SetParent(BaseUI *) { return true; }
141 virtual void NotifyDelete(BaseUI *);
142 static PixmapLookupList pixmap_table;
143 static int n_pixmaps;
144 static PointerCursor pointer_style;
148 static Widget topLevel;
149 static Display *display;
150 static XtAppContext appContext;
151 static XmFontList userFont;
157 static int shadowThickness;
158 static int bMenuButton;
162 void Thread(const char *cmd, ThreadCallback, int buf_len);
163 void Thread(int pid, int fd, ThreadCallback, int buf_len);
164 void Thread(int socket, ThreadCallback, int buf_len);
166 virtual void SetFocus();
167 void PointerShape(PointerCursor style);
168 PointerCursor PointerShape();
169 virtual void WidthHeight(int w, int h);
170 virtual void WidthHeight(int *w, int *h);
171 virtual void Width(int w);
173 virtual void Height(int h);
174 virtual int Height();
175 void AttachAll(int offset = 0);
176 void AttachTop(int offset = 0);
177 void AttachBottom(int offset = 0);
178 void AttachLeft(int offset = 0);
179 void AttachRight(int offset = 0);
180 void AttachTop(BaseUI *, int offset = 0, boolean opposite = false);
181 void AttachBottom(BaseUI *, int offset = 0, boolean opposite = false);
182 void AttachLeft(BaseUI *, int offset = 0, boolean opposite = false);
183 void AttachRight(BaseUI *, int offset = 0, boolean opposite = false);
184 void StringWidthHeight(const char *string, int *w, int *h);
185 int StringWidth(const char *string);
186 int StringHeight(const char *string);
187 void SetAddTimeOut(TimeOutCallback, void *callback_data, long interval);
188 void DumpUIHierarchy(boolean verbose = false, int level = 0);
190 const Widget BaseWidget() { return _w; }
191 virtual const Widget InnerWidget() { return _w; }
193 void Dump(boolean verbose = false,
196 // returns a classname to be used in GetResources
197 virtual const char *const className() { return "MotifUI"; }
201 #endif /* MOTIFUI_H */