Updating to version 0.20.2
[wmaker-crm.git] / WINGs / WINGsP.h
blob537e4f6fd8419c90bbef079822d7b487be8e4f70
2 #include <X11/Xlib.h>
3 #include <X11/Xutil.h>
6 #include "WINGs.h"
7 #include "WUtil.h"
9 #if WINGS_H_VERSION < 980930
10 #error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
11 #endif
13 #include <assert.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <stdio.h>
19 #define DOUBLE_BUFFER
23 #define WC_UserWidget 128
27 #define SCROLLER_WIDTH 20
29 /* internal messages */
30 #define WM_UPDATE_COLORWELL 130
33 #define WM_USER_MESSAGE 1024
36 #define SETUP_INTERNAL_MESSAGE(event, scrPtr) \
37 event.xclient.type=ClientMessage;\
38 event.xclient.display=scrPtr->display;\
39 event.xclient.send_event=False;\
40 event.xclient.serial=0;\
41 event.xclient.format=32;\
42 event.xclient.message_type=scrPtr->internalMessage;
45 typedef struct W_Font {
46 struct W_Screen *screen;
48 union {
49 XFontSet set;
50 XFontStruct *normal;
51 } font;
52 short height;
53 short y;
54 short refCount;
55 unsigned int notFontSet:1;
56 } W_Font;
59 typedef struct W_Pixmap {
60 struct W_Screen *screen;
61 Pixmap pixmap;
62 Pixmap mask;
63 unsigned short width;
64 unsigned short height;
65 short depth;
66 short refCount;
67 } W_Pixmap;
70 typedef struct W_Color {
71 struct W_Screen *screen;
73 XColor color;
74 short refCount;
75 GC gc;
76 struct {
77 unsigned int exact:1;
78 } flags;
79 } W_Color;
82 typedef struct W_FocusInfo {
83 struct W_View *toplevel;
84 struct W_View *focused; /* view that has the focus in this toplevel */
85 struct W_FocusInfo *next;
86 } W_FocusInfo;
88 typedef struct W_Screen {
89 Display *display;
90 int screen;
91 int depth;
93 Colormap colormap;
95 Visual *visual;
97 Time lastEventTime;
99 Window rootWin;
101 struct W_View *rootView;
103 RContext *rcontext;
105 /* application related */
107 W_FocusInfo *focusInfo;
109 struct W_Pixmap *applicationIcon;
111 struct W_Window *windowList; /* list of windows in the app */
113 Window groupLeader; /* the leader of the application */
114 /* also used for other things */
116 struct W_SelectionHandlers *selectionHandlerList;
118 struct {
119 unsigned int hasAppIcon:1;
120 unsigned int simpleApplication:1;
121 } aflags;
123 WMOpenPanel *sharedOpenPanel;
124 WMSavePanel *sharedSavePanel;
126 struct W_FontPanel *sharedFontPanel;
128 struct W_ColorPanel *sharedColorPanel;
130 /* colors */
131 W_Color *white;
132 W_Color *black;
133 W_Color *gray;
134 W_Color *darkGray;
136 GC stippleGC;
138 GC copyGC;
139 GC clipGC;
141 GC monoGC; /* GC for 1bpp visuals */
143 GC xorGC;
145 GC ixorGC; /* IncludeInferiors XOR */
147 GC textFieldGC;
149 W_Font *normalFont;
151 W_Font *boldFont;
153 struct W_Pixmap *checkButtonImageOn;
154 struct W_Pixmap *checkButtonImageOff;
156 struct W_Pixmap *radioButtonImageOn;
157 struct W_Pixmap *radioButtonImageOff;
159 struct W_Pixmap *buttonArrow;
160 struct W_Pixmap *pushedButtonArrow;
162 struct W_Pixmap *scrollerDimple;
164 struct W_Pixmap *upArrow;
165 struct W_Pixmap *downArrow;
166 struct W_Pixmap *leftArrow;
167 struct W_Pixmap *rightArrow;
169 struct W_Pixmap *hiUpArrow;
170 struct W_Pixmap *hiDownArrow;
171 struct W_Pixmap *hiLeftArrow;
172 struct W_Pixmap *hiRightArrow;
174 struct W_Pixmap *pullDownIndicator;
175 struct W_Pixmap *popUpIndicator;
177 struct W_Pixmap *homeIcon;
179 struct W_Pixmap *defaultObjectIcon;
181 Cursor defaultCursor;
183 Cursor textCursor;
185 Atom internalMessage; /* for ClientMessage */
187 Atom attribsAtom; /* GNUstepWindowAttributes */
189 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
191 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
193 Atom clipboardAtom; /* CLIPBOARD */
196 /* stuff for detecting double-clicks */
197 Time lastClickTime; /* time of last mousedown event */
198 Window lastClickWindow; /* window of the last mousedown */
200 struct W_View *modalView;
201 unsigned modal:1;
202 unsigned ignoreNextDoubleClick:1;
203 } W_Screen;
207 typedef struct W_View {
208 struct W_Screen *screen;
210 WMWidget *self; /* must point to the widget the
211 * view belongs to */
213 Window window;
215 WMSize size;
217 WMPoint pos;
219 struct W_View *nextFocusChain; /* next/prev in focus chain */
220 struct W_View *prevFocusChain;
222 struct W_View *parent; /* parent WMView */
224 struct W_View *childrenList; /* first in list of child windows */
226 struct W_View *nextSister; /* next on parent's children list */
228 struct W_EventHandler *handlerList;/* list of event handlers for this window */
230 unsigned long attribFlags;
231 XSetWindowAttributes attribs;
233 void *hangedData; /* data holder for user program */
234 #if 0
235 struct W_DragSourceProcs *dragSourceProcs;
236 struct W_DragDestinationProcs *dragDestinationProcs;
237 int helpContext;
238 #endif
240 struct {
241 unsigned int realized:1;
242 unsigned int mapped:1;
243 unsigned int parentDying:1;
244 unsigned int dying:1; /* the view is being destroyed */
245 unsigned int topLevel:1; /* is a top level window */
246 unsigned int root:1; /* is the root window */
247 unsigned int mapWhenRealized:1;/* map the view when it's realized */
248 unsigned int alreadyDead:1; /* view was freed */
250 unsigned int dontCompressMotion:1; /* motion notify event compress */
251 unsigned int notifySizeChanged:1;
252 unsigned int dontCompressExpose:1; /* will compress all expose
253 events into one */
254 /* toplevel only */
255 unsigned int worksWhenModal:1;
256 unsigned int pendingRelease1:1;
257 unsigned int pendingRelease2:1;
258 unsigned int pendingRelease3:1;
259 unsigned int pendingRelease4:1;
260 unsigned int pendingRelease5:1;
261 } flags;
263 int refCount;
264 } W_View;
267 typedef struct W_EventHandler {
268 unsigned long eventMask;
270 WMEventProc *proc;
272 void *clientData;
274 struct W_EventHandler *nextHandler;
275 } W_EventHandler;
279 typedef struct W_ViewProcedureTable {
280 void (*setBackgroundColor)(WMWidget*, WMColor *color);
281 void (*resize)(WMWidget*, unsigned int, unsigned int);
282 void (*move)(WMWidget*, int, int);
283 } W_ViewProcedureTable;
287 typedef struct _WINGsConfiguration {
288 char *systemFont;
289 char *boldSystemFont;
290 unsigned doubleClickDelay;
291 } _WINGsConfiguration;
293 _WINGsConfiguration WINGsConfiguration;
297 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
300 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
301 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
303 #define W_VIEW_REALIZED(view) (view)->flags.realized
304 #define W_VIEW_MAPPED(view) (view)->flags.mapped
306 #define W_PIXEL(c) (c)->color.pixel
307 #define W_GC(c) (c)->gc
309 #define W_FONTID(f) (f)->font->fid
311 #define W_DRAWABLE(scr) (scr)->rootWin
314 W_View *W_GetViewForXWindow(Display *display, Window window);
316 W_View *W_CreateView(W_View *parent);
318 W_View *W_CreateTopView(W_Screen *screen);
321 W_View *W_CreateRootView(W_Screen *screen);
323 void W_DestroyView(W_View *view);
325 void W_RealizeView(W_View *view);
327 void W_ReparentView(W_View *view, W_View *newParent);
329 void W_MapView(W_View *view);
331 void W_MapSubviews(W_View *view);
333 void W_UnmapSubviews(W_View *view);
335 W_View *W_TopLevelOfView(W_View *view);
337 void W_UnmapView(W_View *view);
339 void W_MoveView(W_View *view, int x, int y);
341 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
343 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
345 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
346 unsigned int height, WMReliefType relief);
349 void W_CleanUpEvents(W_View *view);
351 void W_CallDestroyHandlers(W_View *view);
353 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
354 WMReliefType relief, char *text,
355 WMAlignment alignment, W_Pixmap *image,
356 WMImagePosition position, GC backGC, int ofs);
358 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
359 int width, WMAlignment alignment, GC gc,
360 int wrap, char *text, int length);
362 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
365 int W_TextWidth(WMFont *font, char *text, int length);
368 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
370 void W_DispatchMessage(W_View *target, XEvent *event);
372 Bool W_CheckInternalMessage(W_Screen *scr, XClientMessageEvent *cev, int event);
374 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
376 W_View *W_FocusedViewOfToplevel(W_View *view);
378 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
380 void W_ReleaseView(WMView *view);
382 WMView *W_RetainView(WMView *view);
384 void W_InitApplication(WMScreen *scr);
386 void W_InitNotificationCenter(void);
388 W_Class W_RegisterUserWidget(W_ViewProcedureTable *procTable);
390 void W_RedisplayView(WMView *view);
392 Bool W_ApplicationInitialized(void);
394 char *W_GetTextSelection(WMScreen *scr, Atom selection);