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
;
47 struct _XftFont
*font
;
58 //unsigned int notFontSet:1;
59 //unsigned int antialiased:1;
63 typedef struct W_Pixmap
{
64 struct W_Screen
*screen
;
68 unsigned short height
;
74 typedef struct W_Color
{
75 struct W_Screen
*screen
;
87 typedef struct W_FocusInfo
{
88 struct W_View
*toplevel
;
89 struct W_View
*focused
; /* view that has the focus in this toplevel */
90 struct W_FocusInfo
*next
;
95 typedef void* W_DndState(WMView
*destView
, XClientMessageEvent
*event
,
96 WMDraggingInfo
*info
);
99 typedef struct W_DragOperationItem
{
100 WMDragOperationType type
;
102 } W_DragOperationItem
;
105 typedef struct W_DragSourceInfo
{
107 Window destinationWindow
;
109 WMSelectionProcs
*selectionProcs
;
111 WMPoint imageLocation
;
112 WMPoint mouseOffset
; /* mouse pos in icon */
114 WMRect noPositionMessageZone
;
115 Atom firstThreeTypes
[3];
119 typedef struct W_DragDestinationInfo
{
123 WMArray
*sourceTypes
;
124 WMArray
*requiredTypes
;
125 Bool typeListAvailable
;
127 } W_DragDestinationInfo
;
130 struct W_DraggingInfo
{
131 unsigned char protocolVersion
;
135 Atom destinationAction
;
137 W_DragSourceInfo
* sourceInfo
; /* infos needed by source */
138 W_DragDestinationInfo
* destInfo
; /* infos needed by destination */
142 struct W_DraggingInfo {
143 Window destinationWindow;
148 unsigned sourceOperation;
150 WMPoint imageLocation;
158 // should be treated as internal data
167 typedef struct W_Screen
{
180 struct W_View
*rootView
;
184 struct W_IMContext
*imctx
;
186 struct _XftDraw
*xftdraw
; /* shared XftDraw */
188 /* application related */
190 W_FocusInfo
*focusInfo
;
192 RImage
*applicationIconImage
; /* image (can have alpha channel) */
193 struct W_Pixmap
*applicationIconPixmap
; /* pixmap - no alpha channel */
194 Window applicationIconWindow
;
196 struct W_Window
*windowList
; /* list of windows in the app */
198 Window groupLeader
; /* the leader of the application */
199 /* also used for other things */
201 struct W_SelectionHandlers
*selectionHandlerList
;
204 unsigned int hasAppIcon
:1;
205 unsigned int simpleApplication
:1;
208 WMOpenPanel
*sharedOpenPanel
;
209 WMSavePanel
*sharedSavePanel
;
211 struct W_FontPanel
*sharedFontPanel
;
213 struct W_ColorPanel
*sharedColorPanel
;
217 struct W_View
*dragSourceView
;
218 struct W_DraggingInfo dragInfo
;
231 GC monoGC
; /* GC for 1bpp visuals */
235 GC ixorGC
; /* IncludeInferiors XOR */
237 GC drawStringGC
; /* for WMDrawString() */
239 GC drawImStringGC
; /* for WMDrawImageString() */
245 WMHashTable
*fontCache
;
251 Bool antialiasedText
;
253 unsigned int ignoredModifierMask
; /* modifiers to ignore when typing txt */
255 struct W_Balloon
*balloon
;
258 struct W_Pixmap
*checkButtonImageOn
;
259 struct W_Pixmap
*checkButtonImageOff
;
261 struct W_Pixmap
*radioButtonImageOn
;
262 struct W_Pixmap
*radioButtonImageOff
;
264 struct W_Pixmap
*buttonArrow
;
265 struct W_Pixmap
*pushedButtonArrow
;
267 struct W_Pixmap
*scrollerDimple
;
269 struct W_Pixmap
*upArrow
;
270 struct W_Pixmap
*downArrow
;
271 struct W_Pixmap
*leftArrow
;
272 struct W_Pixmap
*rightArrow
;
274 struct W_Pixmap
*hiUpArrow
;
275 struct W_Pixmap
*hiDownArrow
;
276 struct W_Pixmap
*hiLeftArrow
;
277 struct W_Pixmap
*hiRightArrow
;
279 struct W_Pixmap
*pullDownIndicator
;
280 struct W_Pixmap
*popUpIndicator
;
282 struct W_Pixmap
*checkMark
;
284 struct W_Pixmap
*homeIcon
;
285 struct W_Pixmap
*altHomeIcon
;
287 struct W_Pixmap
*trashcanIcon
;
288 struct W_Pixmap
*altTrashcanIcon
;
290 struct W_Pixmap
*createDirIcon
;
291 struct W_Pixmap
*altCreateDirIcon
;
293 struct W_Pixmap
*disketteIcon
;
294 struct W_Pixmap
*altDisketteIcon
;
295 struct W_Pixmap
*unmountIcon
;
296 struct W_Pixmap
*altUnmountIcon
;
298 struct W_Pixmap
*magnifyIcon
;
299 /*struct W_Pixmap *altMagnifyIcon;*/
300 struct W_Pixmap
*wheelIcon
;
301 struct W_Pixmap
*grayIcon
;
302 struct W_Pixmap
*rgbIcon
;
303 struct W_Pixmap
*cmykIcon
;
304 struct W_Pixmap
*hsbIcon
;
305 struct W_Pixmap
*customPaletteIcon
;
306 struct W_Pixmap
*colorListIcon
;
308 struct W_Pixmap
*defaultObjectIcon
;
310 Cursor defaultCursor
;
314 Cursor invisibleCursor
;
316 Atom attribsAtom
; /* GNUstepWindowAttributes */
318 Atom deleteWindowAtom
; /* WM_DELETE_WINDOW */
320 Atom protocolsAtom
; /* _XA_WM_PROTOCOLS */
322 Atom clipboardAtom
; /* CLIPBOARD */
324 Atom xdndAwareAtom
; /* XdndAware */
325 Atom xdndSelectionAtom
;
328 Atom xdndPositionAtom
;
330 Atom xdndFinishedAtom
;
331 Atom xdndTypeListAtom
;
332 Atom xdndActionListAtom
;
333 Atom xdndActionDescriptionAtom
;
340 Atom xdndActionPrivate
;
342 Atom wmIconDragOffsetAtom
;
344 Atom wmStateAtom
; /* WM_STATE */
346 /* stuff for detecting double-clicks */
347 Time lastClickTime
; /* time of last mousedown event */
348 Window lastClickWindow
; /* window of the last mousedown */
350 struct W_View
*modalView
;
351 unsigned modalLoop
:1;
352 unsigned ignoreNextDoubleClick
:1;
357 typedef struct W_ViewDelegate
{
360 void (*didMove
)(struct W_ViewDelegate
*, WMView
*);
362 void (*didResize
)(struct W_ViewDelegate
*, WMView
*);
364 void (*willMove
)(struct W_ViewDelegate
*, WMView
*, int*, int*);
366 void (*willResize
)(struct W_ViewDelegate
*, WMView
*,
367 unsigned int*, unsigned int*);
372 typedef struct W_View
{
373 struct W_Screen
*screen
;
375 WMWidget
*self
; /* must point to the widget the
378 W_ViewDelegate
*delegate
;
391 struct W_View
*nextFocusChain
; /* next/prev in focus chain */
392 struct W_View
*prevFocusChain
;
394 struct W_View
*nextResponder
; /* next to receive keyboard events */
396 struct W_View
*parent
; /* parent WMView */
398 struct W_View
*childrenList
; /* first in list of child windows */
400 struct W_View
*nextSister
; /* next on parent's children list */
402 WMArray
*eventHandlers
; /* event handlers for this window */
404 unsigned long attribFlags
;
405 XSetWindowAttributes attribs
;
407 void *hangedData
; /* data holder for user program */
413 Atom
*droppableTypes
;
414 struct W_DragSourceProcs
*dragSourceProcs
;
415 struct W_DragDestinationProcs
*dragDestinationProcs
;
421 unsigned int realized
:1;
422 unsigned int mapped
:1;
423 unsigned int parentDying
:1;
424 unsigned int dying
:1; /* the view is being destroyed */
425 unsigned int topLevel
:1; /* is a top level window */
426 unsigned int root
:1; /* is the root window */
427 unsigned int mapWhenRealized
:1; /* map the view when it's realized */
428 unsigned int alreadyDead
:1; /* view was freed */
430 unsigned int dontCompressMotion
:1; /* motion notify event compress */
431 unsigned int notifySizeChanged
:1;
432 unsigned int dontCompressExpose
:1; /* expose event compress */
435 unsigned int worksWhenModal
:1;
436 unsigned int pendingRelease1
:1;
437 unsigned int pendingRelease2
:1;
438 unsigned int pendingRelease3
:1;
439 unsigned int pendingRelease4
:1;
440 unsigned int pendingRelease5
:1;
441 unsigned int xdndHintSet
:1;
448 typedef struct W_EventHandler
{
449 unsigned long eventMask
;
459 typedef struct _WINGsConfiguration
{
461 char *boldSystemFont
;
463 Bool antialiasedText
;
466 unsigned doubleClickDelay
;
467 unsigned mouseWheelUp
;
468 unsigned mouseWheelDown
;
469 } _WINGsConfiguration
;
471 extern _WINGsConfiguration WINGsConfiguration
;
475 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
478 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
479 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
481 #define W_VIEW_REALIZED(view) (view)->flags.realized
482 #define W_VIEW_MAPPED(view) (view)->flags.mapped
484 #define W_VIEW_DISPLAY(view) (view)->screen->display
485 #define W_VIEW_SCREEN(view) (view)->screen
486 #define W_VIEW_DRAWABLE(view) (view)->window
488 #define W_VIEW_WIDTH(view) (view)->size.width
489 #define W_VIEW_HEIGHT(view) (view)->size.height
492 #define W_PIXEL(c) (c)->color.pixel
494 #define W_FONTID(f) (f)->font->fid
496 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
500 W_View
*W_GetViewForXWindow(Display
*display
, Window window
);
502 W_View
*W_CreateView(W_View
*parent
);
504 W_View
*W_CreateTopView(W_Screen
*screen
);
506 W_View
*W_CreateUnmanagedTopView(W_Screen
*screen
);
509 W_View
*W_CreateRootView(W_Screen
*screen
);
511 void W_DestroyView(W_View
*view
);
513 void W_RealizeView(W_View
*view
);
515 void W_ReparentView(W_View
*view
, W_View
*newParent
, int x
, int y
);
517 void W_RaiseView(W_View
*view
);
519 void W_LowerView(W_View
*view
);
522 void W_MapView(W_View
*view
);
524 void W_MapSubviews(W_View
*view
);
526 void W_UnmapSubviews(W_View
*view
);
528 W_View
*W_TopLevelOfView(W_View
*view
);
530 void W_UnmapView(W_View
*view
);
532 void W_MoveView(W_View
*view
, int x
, int y
);
534 void W_ResizeView(W_View
*view
, unsigned int width
, unsigned int height
);
536 void W_SetViewBackgroundColor(W_View
*view
, WMColor
*color
);
538 void W_SetViewCursor(W_View
*view
, Cursor cursor
);
540 void W_DrawRelief(W_Screen
*scr
, Drawable d
, int x
, int y
, unsigned int width
,
541 unsigned int height
, WMReliefType relief
);
543 void W_DrawReliefWithGC(W_Screen
*scr
, Drawable d
, int x
, int y
,
544 unsigned int width
, unsigned int height
,
546 GC black
, GC dark
, GC light
, GC white
);
548 void W_CallDestroyHandlers(W_View
*view
);
550 void W_PaintTextAndImage(W_View
*view
, int wrap
, WMColor
*textColor
,
551 W_Font
*font
, WMReliefType relief
, char *text
,
552 WMAlignment alignment
, W_Pixmap
*image
,
553 WMImagePosition position
, WMColor
*backColor
, int ofs
);
555 void W_PaintText(W_View
*view
, Drawable d
, WMFont
*font
, int x
, int y
,
556 int width
, WMAlignment alignment
, WMColor
*color
,
557 int wrap
, char *text
, int length
);
559 int W_GetTextHeight(WMFont
*font
, char *text
, int width
, int wrap
);
562 int W_TextWidth(WMFont
*font
, char *text
, int length
);
565 void W_BroadcastMessage(W_View
*targetParent
, XEvent
*event
);
567 void W_DispatchMessage(W_View
*target
, XEvent
*event
);
569 void W_SetFocusOfToplevel(W_View
*toplevel
, W_View
*view
);
571 W_View
*W_FocusedViewOfToplevel(W_View
*view
);
573 void W_SetFocusOfTopLevel(W_View
*toplevel
, W_View
*view
);
575 void W_ReleaseView(WMView
*view
);
577 WMView
*W_RetainView(WMView
*view
);
579 void W_InitApplication(WMScreen
*scr
);
581 void W_InitNotificationCenter(void);
583 W_Class
W_RegisterUserWidget(void);
585 void W_RedisplayView(WMView
*view
);
587 Bool
W_ApplicationInitialized(void);
589 void W_HandleSelectionEvent(XEvent
*event
);
591 void W_HandleDNDClientMessage(WMView
*toplevel
, XClientMessageEvent
*event
);
593 void W_FlushASAPNotificationQueue(void);
595 void W_FlushIdleNotificationQueue(void);
597 struct W_Balloon
*W_CreateBalloon(WMScreen
*scr
);
599 void W_BalloonHandleEnterView(WMView
*view
);
601 void W_BalloonHandleLeaveView(WMView
*view
);
603 Bool
W_CheckIdleHandlers(void);
605 void W_CheckTimerHandlers(void);
607 Bool
W_HandleInputEvents(Bool waitForInput
, int inputfd
);
610 Atom
W_OperationToAction(WMScreen
*scr
, WMDragOperationType operation
);
612 WMDragOperationType
W_ActionToOperation(WMScreen
*scr
, Atom action
);
614 void W_FreeDragOperationItem(void* item
);
616 Bool
W_SendDnDClientMessage(Display
*dpy
, Window win
, Atom message
,
617 unsigned long data1
, unsigned long data2
,
618 unsigned long data3
, unsigned long data4
,
619 unsigned long data5
);
621 void W_DragSourceStartTimer(WMDraggingInfo
*info
);
623 void W_DragSourceStopTimer();
625 void W_DragSourceStateHandler(WMDraggingInfo
*info
, XClientMessageEvent
*event
);
627 void W_DragDestinationStartTimer(WMDraggingInfo
*info
);
629 void W_DragDestinationStopTimer();
631 void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo
*info
, WMView
*toplevel
,
632 XClientMessageEvent
*event
);
634 void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo
*info
,
636 XClientMessageEvent
*event
);
638 void W_DragDestinationCancelDropOnEnter(WMView
*toplevel
, WMDraggingInfo
*info
);
640 void W_DragDestinationStateHandler(WMDraggingInfo
*info
,
641 XClientMessageEvent
*event
);
643 void W_DragDestinationInfoClear(WMDraggingInfo
*info
);
645 void W_FreeViewXdndPart(WMView
*view
);
649 #endif /* __cplusplus */
651 #endif /* _WINGSP_H_ */