9 #include <WINGs/WINGs.h>
11 #if WINGS_H_VERSION < 20040406
12 #error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
23 #endif /* __cplusplus */
26 #define DOUBLE_BUFFER 1
28 #define WC_UserWidget 128
30 #define SCROLLER_WIDTH 20
32 #define XDND_VERSION 4
35 typedef struct W_Application
{
36 char *applicationName
;
43 typedef struct W_Font
{
44 struct W_Screen
*screen
;
46 struct _XftFont
*font
;
55 typedef struct W_Pixmap
{
56 struct W_Screen
*screen
;
60 unsigned short height
;
66 typedef struct W_Color
{
67 struct W_Screen
*screen
;
79 typedef struct W_FocusInfo
{
80 struct W_View
*toplevel
;
81 struct W_View
*focused
; /* view that has the focus in this toplevel */
82 struct W_FocusInfo
*next
;
87 typedef void* W_DndState(WMView
*destView
, XClientMessageEvent
*event
,
88 WMDraggingInfo
*info
);
91 typedef struct W_DragOperationItem
{
92 WMDragOperationType type
;
94 } W_DragOperationItem
;
97 typedef struct W_DragSourceInfo
{
99 Window destinationWindow
;
101 WMSelectionProcs
*selectionProcs
;
103 WMPoint imageLocation
;
104 WMPoint mouseOffset
; /* mouse pos in icon */
106 WMRect noPositionMessageZone
;
107 Atom firstThreeTypes
[3];
111 typedef struct W_DragDestinationInfo
{
115 WMArray
*sourceTypes
;
116 WMArray
*requiredTypes
;
117 Bool typeListAvailable
;
119 } W_DragDestinationInfo
;
122 struct W_DraggingInfo
{
123 unsigned char protocolVersion
;
127 Atom destinationAction
;
129 W_DragSourceInfo
* sourceInfo
; /* infos needed by source */
130 W_DragDestinationInfo
* destInfo
; /* infos needed by destination */
134 typedef struct W_Screen
{
147 struct W_View
*rootView
;
151 struct W_IMContext
*imctx
;
153 struct _XftDraw
*xftdraw
; /* shared XftDraw */
155 /* application related */
157 W_FocusInfo
*focusInfo
;
159 RImage
*applicationIconImage
; /* image (can have alpha channel) */
160 struct W_Pixmap
*applicationIconPixmap
; /* pixmap - no alpha channel */
161 Window applicationIconWindow
;
163 struct W_Window
*windowList
; /* list of windows in the app */
165 Window groupLeader
; /* the leader of the application */
166 /* also used for other things */
168 struct W_SelectionHandlers
*selectionHandlerList
;
171 unsigned int hasAppIcon
:1;
172 unsigned int simpleApplication
:1;
175 WMOpenPanel
*sharedOpenPanel
;
176 WMSavePanel
*sharedSavePanel
;
178 struct W_FontPanel
*sharedFontPanel
;
180 struct W_ColorPanel
*sharedColorPanel
;
184 struct W_View
*dragSourceView
;
185 struct W_DraggingInfo dragInfo
;
198 GC monoGC
; /* GC for 1bpp visuals */
202 GC ixorGC
; /* IncludeInferiors XOR */
204 GC drawStringGC
; /* for WMDrawString() */
206 GC drawImStringGC
; /* for WMDrawImageString() */
212 WMHashTable
*fontCache
;
214 Bool antialiasedText
;
216 unsigned int ignoredModifierMask
; /* modifiers to ignore when typing txt */
218 struct W_Balloon
*balloon
;
221 struct W_Pixmap
*checkButtonImageOn
;
222 struct W_Pixmap
*checkButtonImageOff
;
224 struct W_Pixmap
*radioButtonImageOn
;
225 struct W_Pixmap
*radioButtonImageOff
;
227 struct W_Pixmap
*buttonArrow
;
228 struct W_Pixmap
*pushedButtonArrow
;
230 struct W_Pixmap
*scrollerDimple
;
232 struct W_Pixmap
*upArrow
;
233 struct W_Pixmap
*downArrow
;
234 struct W_Pixmap
*leftArrow
;
235 struct W_Pixmap
*rightArrow
;
237 struct W_Pixmap
*hiUpArrow
;
238 struct W_Pixmap
*hiDownArrow
;
239 struct W_Pixmap
*hiLeftArrow
;
240 struct W_Pixmap
*hiRightArrow
;
242 struct W_Pixmap
*pullDownIndicator
;
243 struct W_Pixmap
*popUpIndicator
;
245 struct W_Pixmap
*checkMark
;
247 struct W_Pixmap
*homeIcon
;
248 struct W_Pixmap
*altHomeIcon
;
250 struct W_Pixmap
*trashcanIcon
;
251 struct W_Pixmap
*altTrashcanIcon
;
253 struct W_Pixmap
*createDirIcon
;
254 struct W_Pixmap
*altCreateDirIcon
;
256 struct W_Pixmap
*disketteIcon
;
257 struct W_Pixmap
*altDisketteIcon
;
258 struct W_Pixmap
*unmountIcon
;
259 struct W_Pixmap
*altUnmountIcon
;
261 struct W_Pixmap
*magnifyIcon
;
262 /*struct W_Pixmap *altMagnifyIcon;*/
263 struct W_Pixmap
*wheelIcon
;
264 struct W_Pixmap
*grayIcon
;
265 struct W_Pixmap
*rgbIcon
;
266 struct W_Pixmap
*cmykIcon
;
267 struct W_Pixmap
*hsbIcon
;
268 struct W_Pixmap
*customPaletteIcon
;
269 struct W_Pixmap
*colorListIcon
;
271 struct W_Pixmap
*defaultObjectIcon
;
273 Cursor defaultCursor
;
277 Cursor invisibleCursor
;
279 Atom attribsAtom
; /* GNUstepWindowAttributes */
281 Atom deleteWindowAtom
; /* WM_DELETE_WINDOW */
283 Atom protocolsAtom
; /* _XA_WM_PROTOCOLS */
285 Atom clipboardAtom
; /* CLIPBOARD */
287 Atom xdndAwareAtom
; /* XdndAware */
288 Atom xdndSelectionAtom
;
291 Atom xdndPositionAtom
;
293 Atom xdndFinishedAtom
;
294 Atom xdndTypeListAtom
;
295 Atom xdndActionListAtom
;
296 Atom xdndActionDescriptionAtom
;
303 Atom xdndActionPrivate
;
305 Atom wmIconDragOffsetAtom
;
307 Atom wmStateAtom
; /* WM_STATE */
315 /* stuff for detecting double-clicks */
316 Time lastClickTime
; /* time of last mousedown event */
317 Window lastClickWindow
; /* window of the last mousedown */
319 struct W_View
*modalView
;
320 unsigned modalLoop
:1;
321 unsigned ignoreNextDoubleClick
:1;
326 typedef struct W_ViewDelegate
{
329 void (*didMove
)(struct W_ViewDelegate
*, WMView
*);
331 void (*didResize
)(struct W_ViewDelegate
*, WMView
*);
333 void (*willMove
)(struct W_ViewDelegate
*, WMView
*, int*, int*);
335 void (*willResize
)(struct W_ViewDelegate
*, WMView
*,
336 unsigned int*, unsigned int*);
341 typedef struct W_View
{
342 struct W_Screen
*screen
;
344 WMWidget
*self
; /* must point to the widget the
347 W_ViewDelegate
*delegate
;
360 struct W_View
*nextFocusChain
; /* next/prev in focus chain */
361 struct W_View
*prevFocusChain
;
363 struct W_View
*nextResponder
; /* next to receive keyboard events */
365 struct W_View
*parent
; /* parent WMView */
367 struct W_View
*childrenList
; /* first in list of child windows */
369 struct W_View
*nextSister
; /* next on parent's children list */
371 WMArray
*eventHandlers
; /* event handlers for this window */
373 unsigned long attribFlags
;
374 XSetWindowAttributes attribs
;
376 void *hangedData
; /* data holder for user program */
382 Atom
*droppableTypes
;
383 struct W_DragSourceProcs
*dragSourceProcs
;
384 struct W_DragDestinationProcs
*dragDestinationProcs
;
390 unsigned int realized
:1;
391 unsigned int mapped
:1;
392 unsigned int parentDying
:1;
393 unsigned int dying
:1; /* the view is being destroyed */
394 unsigned int topLevel
:1; /* is a top level window */
395 unsigned int root
:1; /* is the root window */
396 unsigned int mapWhenRealized
:1; /* map the view when it's realized */
397 unsigned int alreadyDead
:1; /* view was freed */
399 unsigned int dontCompressMotion
:1; /* motion notify event compress */
400 unsigned int notifySizeChanged
:1;
401 unsigned int dontCompressExpose
:1; /* expose event compress */
404 unsigned int worksWhenModal
:1;
405 unsigned int pendingRelease1
:1;
406 unsigned int pendingRelease2
:1;
407 unsigned int pendingRelease3
:1;
408 unsigned int pendingRelease4
:1;
409 unsigned int pendingRelease5
:1;
410 unsigned int xdndHintSet
:1;
417 typedef struct W_EventHandler
{
418 unsigned long eventMask
;
428 typedef struct _WINGsConfiguration
{
430 char *boldSystemFont
;
432 Bool antialiasedText
;
434 unsigned doubleClickDelay
;
435 unsigned mouseWheelUp
;
436 unsigned mouseWheelDown
;
437 } _WINGsConfiguration
;
439 extern _WINGsConfiguration WINGsConfiguration
;
443 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
446 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
447 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
449 #define W_VIEW_REALIZED(view) (view)->flags.realized
450 #define W_VIEW_MAPPED(view) (view)->flags.mapped
452 #define W_VIEW_DISPLAY(view) (view)->screen->display
453 #define W_VIEW_SCREEN(view) (view)->screen
454 #define W_VIEW_DRAWABLE(view) (view)->window
456 #define W_VIEW_WIDTH(view) (view)->size.width
457 #define W_VIEW_HEIGHT(view) (view)->size.height
460 #define W_PIXEL(c) (c)->color.pixel
462 #define W_FONTID(f) (f)->font->fid
464 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
468 W_View
*W_GetViewForXWindow(Display
*display
, Window window
);
470 W_View
*W_CreateView(W_View
*parent
);
472 W_View
*W_CreateTopView(W_Screen
*screen
);
474 W_View
*W_CreateUnmanagedTopView(W_Screen
*screen
);
477 W_View
*W_CreateRootView(W_Screen
*screen
);
479 void W_DestroyView(W_View
*view
);
481 void W_RealizeView(W_View
*view
);
483 void W_ReparentView(W_View
*view
, W_View
*newParent
, int x
, int y
);
485 void W_RaiseView(W_View
*view
);
487 void W_LowerView(W_View
*view
);
490 void W_MapView(W_View
*view
);
492 void W_MapSubviews(W_View
*view
);
494 void W_UnmapSubviews(W_View
*view
);
496 W_View
*W_TopLevelOfView(W_View
*view
);
498 void W_UnmapView(W_View
*view
);
500 void W_MoveView(W_View
*view
, int x
, int y
);
502 void W_ResizeView(W_View
*view
, unsigned int width
, unsigned int height
);
504 void W_SetViewBackgroundColor(W_View
*view
, WMColor
*color
);
506 void W_SetViewCursor(W_View
*view
, Cursor cursor
);
508 void W_DrawRelief(W_Screen
*scr
, Drawable d
, int x
, int y
, unsigned int width
,
509 unsigned int height
, WMReliefType relief
);
511 void W_DrawReliefWithGC(W_Screen
*scr
, Drawable d
, int x
, int y
,
512 unsigned int width
, unsigned int height
,
514 GC black
, GC dark
, GC light
, GC white
);
516 void W_CallDestroyHandlers(W_View
*view
);
518 void W_PaintTextAndImage(W_View
*view
, int wrap
, WMColor
*textColor
,
519 W_Font
*font
, WMReliefType relief
, char *text
,
520 WMAlignment alignment
, W_Pixmap
*image
,
521 WMImagePosition position
, WMColor
*backColor
, int ofs
);
523 void W_PaintText(W_View
*view
, Drawable d
, WMFont
*font
, int x
, int y
,
524 int width
, WMAlignment alignment
, WMColor
*color
,
525 int wrap
, char *text
, int length
);
527 int W_GetTextHeight(WMFont
*font
, char *text
, int width
, int wrap
);
530 int W_TextWidth(WMFont
*font
, char *text
, int length
);
533 void W_BroadcastMessage(W_View
*targetParent
, XEvent
*event
);
535 void W_DispatchMessage(W_View
*target
, XEvent
*event
);
537 void W_SetFocusOfToplevel(W_View
*toplevel
, W_View
*view
);
539 W_View
*W_FocusedViewOfToplevel(W_View
*view
);
541 void W_SetFocusOfTopLevel(W_View
*toplevel
, W_View
*view
);
543 void W_ReleaseView(WMView
*view
);
545 WMView
*W_RetainView(WMView
*view
);
547 void W_InitApplication(WMScreen
*scr
);
549 void W_InitNotificationCenter(void);
551 W_Class
W_RegisterUserWidget(void);
553 void W_RedisplayView(WMView
*view
);
555 Bool
W_ApplicationInitialized(void);
557 void W_HandleSelectionEvent(XEvent
*event
);
559 void W_HandleDNDClientMessage(WMView
*toplevel
, XClientMessageEvent
*event
);
561 void W_FlushASAPNotificationQueue(void);
563 void W_FlushIdleNotificationQueue(void);
565 struct W_Balloon
*W_CreateBalloon(WMScreen
*scr
);
567 void W_BalloonHandleEnterView(WMView
*view
);
569 void W_BalloonHandleLeaveView(WMView
*view
);
571 Bool
W_CheckIdleHandlers(void);
573 void W_CheckTimerHandlers(void);
575 Bool
W_HandleInputEvents(Bool waitForInput
, int inputfd
);
578 Atom
W_OperationToAction(WMScreen
*scr
, WMDragOperationType operation
);
580 WMDragOperationType
W_ActionToOperation(WMScreen
*scr
, Atom action
);
582 void W_FreeDragOperationItem(void* item
);
584 Bool
W_SendDnDClientMessage(Display
*dpy
, Window win
, Atom message
,
585 unsigned long data1
, unsigned long data2
,
586 unsigned long data3
, unsigned long data4
,
587 unsigned long data5
);
589 void W_DragSourceStartTimer(WMDraggingInfo
*info
);
591 void W_DragSourceStopTimer();
593 void W_DragSourceStateHandler(WMDraggingInfo
*info
, XClientMessageEvent
*event
);
595 void W_DragDestinationStartTimer(WMDraggingInfo
*info
);
597 void W_DragDestinationStopTimer();
599 void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo
*info
, WMView
*toplevel
,
600 XClientMessageEvent
*event
);
602 void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo
*info
,
604 XClientMessageEvent
*event
);
606 void W_DragDestinationCancelDropOnEnter(WMView
*toplevel
, WMDraggingInfo
*info
);
608 void W_DragDestinationStateHandler(WMDraggingInfo
*info
,
609 XClientMessageEvent
*event
);
611 void W_DragDestinationInfoClear(WMDraggingInfo
*info
);
613 void W_FreeViewXdndPart(WMView
*view
);
617 #endif /* __cplusplus */
619 #endif /* _WINGSP_H_ */