many bug fixes, finished some delegate code, updated menu file bug from EXEC
[wmaker-crm.git] / WINGs / WINGsP.h
blob35a0f7760c49c57931a21ef99ae37b3619e96bd6
1 #ifndef _WINGSP_H_
2 #define _WINGSP_H_
5 #include <X11/Xlib.h>
6 #include <X11/Xutil.h>
9 #include "WINGs.h"
11 #if WINGS_H_VERSION < 990516
12 #error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
13 #endif
15 #include <assert.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <stdio.h>
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
25 #define DOUBLE_BUFFER
29 #define WC_UserWidget 128
33 #define SCROLLER_WIDTH 20
35 /* internal messages */
36 #define WM_UPDATE_COLORWELL 130
39 #define WM_USER_MESSAGE 1024
42 #define SETUP_INTERNAL_MESSAGE(event, scrPtr) \
43 event.xclient.type=ClientMessage;\
44 event.xclient.display=scrPtr->display;\
45 event.xclient.send_event=False;\
46 event.xclient.serial=0;\
47 event.xclient.format=32;\
48 event.xclient.message_type=scrPtr->internalMessage;
51 typedef struct W_Font {
52 struct W_Screen *screen;
54 union {
55 XFontSet set;
56 XFontStruct *normal;
57 } font;
58 short height;
59 short y;
60 short refCount;
61 char *name;
62 unsigned int notFontSet:1;
63 } W_Font;
66 typedef struct W_Pixmap {
67 struct W_Screen *screen;
68 Pixmap pixmap;
69 Pixmap mask;
70 unsigned short width;
71 unsigned short height;
72 short depth;
73 short refCount;
74 } W_Pixmap;
77 typedef struct W_Color {
78 struct W_Screen *screen;
80 XColor color;
81 short refCount;
82 GC gc;
83 struct {
84 unsigned int exact:1;
85 } flags;
86 } W_Color;
89 typedef struct W_FocusInfo {
90 struct W_View *toplevel;
91 struct W_View *focused; /* view that has the focus in this toplevel */
92 struct W_FocusInfo *next;
93 } W_FocusInfo;
96 typedef struct W_Screen {
97 Display *display;
98 int screen;
99 int depth;
101 Colormap colormap;
103 Visual *visual;
105 Time lastEventTime;
107 Window rootWin;
109 struct W_View *rootView;
111 RContext *rcontext;
113 /* application related */
115 W_FocusInfo *focusInfo;
117 struct W_Pixmap *applicationIcon;
119 struct W_Window *windowList; /* list of windows in the app */
121 Window groupLeader; /* the leader of the application */
122 /* also used for other things */
124 struct W_SelectionHandlers *selectionHandlerList;
126 struct {
127 unsigned int hasAppIcon:1;
128 unsigned int simpleApplication:1;
129 } aflags;
131 WMOpenPanel *sharedOpenPanel;
132 WMSavePanel *sharedSavePanel;
134 struct W_FontPanel *sharedFontPanel;
136 struct W_ColorPanel *sharedColorPanel;
138 Pixmap stipple;
140 /* colors */
141 W_Color *white;
142 W_Color *black;
143 W_Color *gray;
144 W_Color *darkGray;
146 GC stippleGC;
148 GC copyGC;
149 GC clipGC;
151 GC monoGC; /* GC for 1bpp visuals */
153 GC xorGC;
155 GC ixorGC; /* IncludeInferiors XOR */
157 GC textFieldGC;
159 W_Font *normalFont;
161 W_Font *boldFont;
163 WMHashTable *fontCache;
166 struct W_Balloon *balloon;
169 struct W_Pixmap *checkButtonImageOn;
170 struct W_Pixmap *checkButtonImageOff;
172 struct W_Pixmap *radioButtonImageOn;
173 struct W_Pixmap *radioButtonImageOff;
175 struct W_Pixmap *buttonArrow;
176 struct W_Pixmap *pushedButtonArrow;
178 struct W_Pixmap *scrollerDimple;
180 struct W_Pixmap *upArrow;
181 struct W_Pixmap *downArrow;
182 struct W_Pixmap *leftArrow;
183 struct W_Pixmap *rightArrow;
185 struct W_Pixmap *hiUpArrow;
186 struct W_Pixmap *hiDownArrow;
187 struct W_Pixmap *hiLeftArrow;
188 struct W_Pixmap *hiRightArrow;
190 struct W_Pixmap *pullDownIndicator;
191 struct W_Pixmap *popUpIndicator;
193 struct W_Pixmap *checkMark;
195 struct W_Pixmap *homeIcon;
196 struct W_Pixmap *altHomeIcon;
198 struct W_Pixmap *magnifyIcon;
199 /* struct W_Pixmap *altMagnifyIcon;*/
200 struct W_Pixmap *wheelIcon;
201 struct W_Pixmap *grayIcon;
202 struct W_Pixmap *rgbIcon;
203 struct W_Pixmap *cmykIcon;
204 struct W_Pixmap *hsbIcon;
205 struct W_Pixmap *customPaletteIcon;
206 struct W_Pixmap *colorListIcon;
208 struct W_Pixmap *defaultObjectIcon;
210 Cursor defaultCursor;
212 Cursor textCursor;
214 Cursor invisibleCursor;
216 Atom internalMessage; /* for ClientMessage */
218 Atom attribsAtom; /* GNUstepWindowAttributes */
220 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
222 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
224 Atom clipboardAtom; /* CLIPBOARD */
227 /* stuff for detecting double-clicks */
228 Time lastClickTime; /* time of last mousedown event */
229 Window lastClickWindow; /* window of the last mousedown */
231 struct W_View *modalView;
232 unsigned modal:1;
233 unsigned ignoreNextDoubleClick:1;
234 } W_Screen;
238 typedef struct W_ViewDelegate {
239 void *data;
241 void (*didMove)(struct W_ViewDelegate*, WMView*);
243 void (*didResize)(struct W_ViewDelegate*, WMView*);
245 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
247 void (*willResize)(struct W_ViewDelegate*, WMView*,
248 unsigned int*, unsigned int*);
249 } W_ViewDelegate;
253 typedef struct W_View {
254 struct W_Screen *screen;
256 WMWidget *self; /* must point to the widget the
257 * view belongs to */
259 W_ViewDelegate *delegate;
261 Window window;
263 WMSize size;
265 WMPoint pos;
267 struct W_View *nextFocusChain; /* next/prev in focus chain */
268 struct W_View *prevFocusChain;
270 struct W_View *parent; /* parent WMView */
272 struct W_View *childrenList; /* first in list of child windows */
274 struct W_View *nextSister; /* next on parent's children list */
276 struct W_EventHandler *handlerList;/* list of event handlers for this window */
278 unsigned long attribFlags;
279 XSetWindowAttributes attribs;
281 void *hangedData; /* data holder for user program */
283 WMColor *backColor;
285 #if 0
286 struct W_DragSourceProcs *dragSourceProcs;
287 struct W_DragDestinationProcs *dragDestinationProcs;
288 int helpContext;
289 #endif
291 struct {
292 unsigned int realized:1;
293 unsigned int mapped:1;
294 unsigned int parentDying:1;
295 unsigned int dying:1; /* the view is being destroyed */
296 unsigned int topLevel:1; /* is a top level window */
297 unsigned int root:1; /* is the root window */
298 unsigned int mapWhenRealized:1;/* map the view when it's realized */
299 unsigned int alreadyDead:1; /* view was freed */
301 unsigned int dontCompressMotion:1; /* motion notify event compress */
302 unsigned int notifySizeChanged:1;
303 unsigned int dontCompressExpose:1; /* will compress all expose
304 events into one */
305 /* toplevel only */
306 unsigned int worksWhenModal:1;
307 unsigned int pendingRelease1:1;
308 unsigned int pendingRelease2:1;
309 unsigned int pendingRelease3:1;
310 unsigned int pendingRelease4:1;
311 unsigned int pendingRelease5:1;
312 } flags;
314 int refCount;
315 } W_View;
318 typedef struct W_EventHandler {
319 unsigned long eventMask;
321 WMEventProc *proc;
323 void *clientData;
325 struct W_EventHandler *nextHandler;
326 } W_EventHandler;
331 typedef struct _WINGsConfiguration {
332 char *systemFont;
333 char *boldSystemFont;
334 unsigned doubleClickDelay;
335 } _WINGsConfiguration;
337 _WINGsConfiguration WINGsConfiguration;
341 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
344 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
345 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
347 #define W_VIEW_REALIZED(view) (view)->flags.realized
348 #define W_VIEW_MAPPED(view) (view)->flags.mapped
350 #define W_PIXEL(c) (c)->color.pixel
352 #define W_FONTID(f) (f)->font->fid
354 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
358 W_View *W_GetViewForXWindow(Display *display, Window window);
360 W_View *W_CreateView(W_View *parent);
362 W_View *W_CreateTopView(W_Screen *screen);
365 W_View *W_CreateRootView(W_Screen *screen);
367 void W_DestroyView(W_View *view);
369 void W_RealizeView(W_View *view);
371 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
373 void W_MapView(W_View *view);
375 void W_MapSubviews(W_View *view);
377 void W_UnmapSubviews(W_View *view);
379 W_View *W_TopLevelOfView(W_View *view);
381 void W_UnmapView(W_View *view);
383 void W_MoveView(W_View *view, int x, int y);
385 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
387 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
389 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
390 unsigned int height, WMReliefType relief);
393 void W_CleanUpEvents(W_View *view);
395 void W_CallDestroyHandlers(W_View *view);
397 void W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font,
398 WMReliefType relief, char *text,
399 WMAlignment alignment, W_Pixmap *image,
400 WMImagePosition position, GC backGC, int ofs);
402 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
403 int width, WMAlignment alignment, GC gc,
404 int wrap, char *text, int length);
406 int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
409 int W_TextWidth(WMFont *font, char *text, int length);
412 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
414 void W_DispatchMessage(W_View *target, XEvent *event);
416 Bool W_CheckInternalMessage(W_Screen *scr, XClientMessageEvent *cev, int event);
418 void W_SetFocusOfToplevel(W_View *toplevel, W_View *view);
420 W_View *W_FocusedViewOfToplevel(W_View *view);
422 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
424 void W_ReleaseView(WMView *view);
426 WMView *W_RetainView(WMView *view);
428 void W_InitApplication(WMScreen *scr);
430 void W_InitNotificationCenter(void);
432 W_Class W_RegisterUserWidget(void);
434 void W_RedisplayView(WMView *view);
436 Bool W_ApplicationInitialized(void);
438 char *W_GetTextSelection(WMScreen *scr, Atom selection);
440 void W_HandleSelectionEvent(XEvent *event);
442 #ifdef __cplusplus
444 #endif /* __cplusplus */
446 #endif /* _WINGSP_H_ */
448 void W_FlushASAPNotificationQueue();
450 void W_FlushIdleNotificationQueue();
452 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
454 void W_BalloonHandleEnterView(WMView *view);
456 void W_BalloonHandleLeaveView(WMView *view);