Remove Unixware and openserver support
[oweals/cde.git] / cde / programs / dtprintinfo / libUI / MotifUI / MotifUI.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: MotifUI.h /main/6 1996/10/21 17:29:46 mgreess $ */
24 /*                                                                      *
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.                                *
29  */
30
31 #ifndef MOTIFUI_H
32 #define MOTIFUI_H
33
34 #include <Xm/Xm.h>
35
36 #include "BaseUI.h"
37 #include "MotifThread.h"
38
39 extern "C" {
40 extern XtPointer _XmStringUngenerate (
41                                 XmString string,
42                                 XmStringTag tag,
43                                 XmTextType tag_type,
44                                 XmTextType output_type);
45 }
46
47
48 #define AnyUI MotifUI
49 #define HasDumpUI 1
50
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)
56
57 typedef struct
58 {
59    char *name;
60    Pixmap pixmap;
61    Pixmap mask;
62 } PixmapLookupStruct, *PixmapLookup, **PixmapLookupList;
63
64 class DtDND;
65 class MotifThread;
66
67 class MotifUI : public BaseUI {
68
69  friend class DtDND;
70
71  private:
72
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);
79
80  protected:
81
82    Widget _w;
83    char *_widgetName;
84
85    MotifUI(MotifUI *parent, 
86            const char *name,
87            const char *category,
88            const char *widgetName = NULL);
89    void InstallDestroyCB();
90    void InstallHelpCB();
91    virtual void WidgetDestroyed();
92    void GetPixmaps(Widget widget, char *iconFile, Pixmap *pixmap,
93                    Pixmap *mask = NULL);
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);
99          else return NULL;
100        }
101    void StringFree(XmString string) 
102        { if (string) XmStringFree(string); string = NULL; }
103    char * StringExtract(XmString string)
104        { char *s = NULL;
105          s = (char *) _XmStringUngenerate(
106                         string, NULL,
107                         XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
108          return s; };
109
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);
117    void DoRefresh();
118    void DoToFront();
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);
126
127    // Containers widgets should override SetView
128    virtual boolean SetView(ViewStyle) { return true; }
129
130    // Containers and icon widgets should override these
131    virtual boolean SetOpen(boolean) { return true; }
132
133    // Icon widgets should override these
134    virtual boolean SetIcon(IconStyle) { return true; }
135    virtual boolean SetParent(BaseUI *) { return true; }
136
137    virtual void NotifyDelete(BaseUI *);
138    static PixmapLookupList pixmap_table;
139    static int n_pixmaps;
140    static PointerCursor pointer_style;
141
142  public:
143
144    static Widget topLevel;
145    static Display *display;
146    static XtAppContext appContext;
147    static XmFontList userFont;
148    static Font font;
149    static Window root;
150    static Pixel black;
151    static Pixel white;
152    static int depth;
153    static int shadowThickness;
154    static int bMenuButton;
155
156    virtual ~MotifUI();
157
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);
161
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);
168    virtual int Width();
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);
185
186    const Widget BaseWidget()             { return _w; }
187    virtual const Widget InnerWidget()    { return _w; }
188
189    void Dump(boolean verbose = false,
190              int level = 0);
191
192    // returns a classname to be used in GetResources
193    virtual const char *const className() { return "MotifUI"; }
194
195 };
196
197 #endif /* MOTIFUI_H */