Update for 0.51.0
[wmaker-crm.git] / WINGs / WINGsP.h
blobccf0edc76471aec9ddf1a4369dcda3f495d39fcd
2 #include <X11/Xlib.h>
3 #include <X11/Xutil.h>
6 #include "WINGs.h"
7 #include "WUtil.h"
9 #if WINGS_H_VERSION < 981220
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 *checkMark;
179 struct W_Pixmap *homeIcon;
180 struct W_Pixmap *homeAltIcon;
182 struct W_Pixmap *magnifyIcon;
183 struct W_Pixmap *wheelIcon;
184 struct W_Pixmap *grayIcon;
185 struct W_Pixmap *rgbIcon;
186 struct W_Pixmap *cmykIcon;
187 struct W_Pixmap *hsbIcon;
188 struct W_Pixmap *customPaletteIcon;
189 struct W_Pixmap *colorListIcon;
191 struct W_Pixmap *magnifyAltIcon;
192 struct W_Pixmap *wheelAltIcon;
193 struct W_Pixmap *grayAltIcon;
194 struct W_Pixmap *rgbAltIcon;
195 struct W_Pixmap *cmykAltIcon;
196 struct W_Pixmap *hsbAltIcon;
197 struct W_Pixmap *customPaletteAltIcon;
198 struct W_Pixmap *colorListAltIcon;
200 struct W_Pixmap *defaultObjectIcon;
202 Cursor defaultCursor;
204 Cursor textCursor;
206 Atom internalMessage; /* for ClientMessage */
208 Atom attribsAtom; /* GNUstepWindowAttributes */
210 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
212 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
214 Atom clipboardAtom; /* CLIPBOARD */
217 /* stuff for detecting double-clicks */
218 Time lastClickTime; /* time of last mousedown event */
219 Window lastClickWindow; /* window of the last mousedown */
221 struct W_View *modalView;
222 unsigned modal:1;
223 unsigned ignoreNextDoubleClick:1;
224 } W_Screen;
228 typedef struct W_View {
229 struct W_Screen *screen;
231 WMWidget *self; /* must point to the widget the
232 * view belongs to */
234 Window window;
236 WMSize size;
238 WMPoint pos;
240 struct W_View *nextFocusChain; /* next/prev in focus chain */
241 struct W_View *prevFocusChain;
243 struct W_View *parent; /* parent WMView */
245 struct W_View *childrenList; /* first in list of child windows */
247 struct W_View *nextSister; /* next on parent's children list */
249 struct W_EventHandler *handlerList;/* list of event handlers for this window */
251 unsigned long attribFlags;
252 XSetWindowAttributes attribs;
254 void *hangedData; /* data holder for user program */
255 #if 0
256 struct W_DragSourceProcs *dragSourceProcs;
257 struct W_DragDestinationProcs *dragDestinationProcs;
258 int helpContext;
259 #endif
261 struct {
262 unsigned int realized:1;
263 unsigned int mapped:1;
264 unsigned int parentDying:1;
265 unsigned int dying:1; /* the view is being destroyed */
266 unsigned int topLevel:1; /* is a top level window */
267 unsigned int root:1; /* is the root window */
268 unsigned int mapWhenRealized:1;/* map the view when it's realized */
269 unsigned int alreadyDead:1; /* view was freed */
271 unsigned int dontCompressMotion:1; /* motion notify event compress */
272 unsigned int notifySizeChanged:1;
273 unsigned int dontCompressExpose:1; /* will compress all expose
274 events into one */
275 /* toplevel only */
276 unsigned int worksWhenModal:1;
277 unsigned int pendingRelease1:1;
278 unsigned int pendingRelease2:1;
279 unsigned int pendingRelease3:1;
280 unsigned int pendingRelease4:1;
281 unsigned int pendingRelease5:1;
282 } flags;
284 int refCount;
285 } W_View;
288 typedef struct W_EventHandler {
289 unsigned long eventMask;
291 WMEventProc *proc;
293 void *clientData;
295 struct W_EventHandler *nextHandler;
296 } W_EventHandler;
300 typedef struct W_ViewProcedureTable {
301 void (*setBackgroundColor)(WMWidget*, WMColor *color);
302 void (*resize)(WMWidget*, unsigned int, unsigned int);
303 void (*move)(WMWidget*, int, int);
304 } W_ViewProcedureTable;
308 typedef struct _WINGsConfiguration {
309 char *systemFont;
310 char *boldSystemFont;
311 unsigned doubleClickDelay;
312 } _WINGsConfiguration;
314 _WINGsConfiguration WINGsConfiguration;
318 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
321 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
322 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
324 #define W_VIEW_REALIZED(view) (view)->flags.realized
325 #define W_VIEW_MAPPED(view) (view)->flags.mapped
327 #define W_PIXEL(c) (c)->color.pixel
328 #define W_GC(c) (c)->gc
330 #define W_FONTID(f) (f)->font->fid
332 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
336 W_View *W_GetViewForXWindow(Display *display, Window window);
338 W_View *W_CreateView(W_View *parent);
340 W_View *W_CreateTopView(W_Screen *screen);
343 W_View *W_CreateRootView(W_Screen *screen);
345 void W_DestroyView(W_View *view);
347 void W_RealizeView(W_View *view);
349 void W_ReparentView(W_View *view, W_View *newParent);
351 void W_MapView(W_View *view);
353 void W_MapSubviews(W_View *view);
355 void W_UnmapSubviews(W_View *view);
357 W_View *W_TopLevelOfView(W_View *view);
359 void W_UnmapView(W_View *view);
361 void W_MoveView(W_View *view, int x, int y);
363 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
365 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
367 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
368 unsigned int height, WMReliefType relief);
371 void W_CleanUpEvents(W_View *view);
373 void W_CallDestroyHandlers(W_View *view);
375 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
376 WMReliefType relief, char *text,
377 WMAlignment alignment, W_Pixmap *image,
378 WMImagePosition position, GC backGC, int ofs);
380 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
381 int width, WMAlignment alignment, GC gc,
382 int wrap, char *text, int length);
384 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
387 int W_TextWidth(WMFont *font, char *text, int length);
390 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
392 void W_DispatchMessage(W_View *target, XEvent *event);
394 Bool W_CheckInternalMessage(W_Screen *scr, XClientMessageEvent *cev, int event);
396 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
398 W_View *W_FocusedViewOfToplevel(W_View *view);
400 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
402 void W_ReleaseView(WMView *view);
404 WMView *W_RetainView(WMView *view);
406 void W_InitApplication(WMScreen *scr);
408 void W_InitNotificationCenter(void);
410 W_Class W_RegisterUserWidget(W_ViewProcedureTable *procTable);
412 void W_RedisplayView(WMView *view);
414 Bool W_ApplicationInitialized(void);
416 char *W_GetTextSelection(WMScreen *scr, Atom selection);
418 void W_HandleSelectionEvent(XEvent *event);