9 #include <WINGs/WINGs.h>
11 #if WINGS_H_VERSION < 20041030
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 3
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
{
113 WMView
*xdndAwareView
;
116 Bool sourceActionChanged
;
117 WMArray
*sourceTypes
;
118 WMArray
*requiredTypes
;
119 Bool typeListAvailable
;
121 } W_DragDestinationInfo
;
124 struct W_DraggingInfo
{
125 unsigned char protocolVersion
; /* version supported on the other side */
129 Atom destinationAction
;
131 W_DragSourceInfo
* sourceInfo
; /* infos needed by source */
132 W_DragDestinationInfo
* destInfo
; /* infos needed by destination */
136 typedef struct W_Screen
{
149 struct W_View
*rootView
;
153 struct W_IMContext
*imctx
;
155 struct _XftDraw
*xftdraw
; /* shared XftDraw */
157 /* application related */
159 W_FocusInfo
*focusInfo
;
161 RImage
*applicationIconImage
; /* image (can have alpha channel) */
162 struct W_Pixmap
*applicationIconPixmap
; /* pixmap - no alpha channel */
163 Window applicationIconWindow
;
165 struct W_Window
*windowList
; /* list of windows in the app */
167 Window groupLeader
; /* the leader of the application */
168 /* also used for other things */
170 struct W_SelectionHandlers
*selectionHandlerList
;
173 unsigned int hasAppIcon
:1;
174 unsigned int simpleApplication
:1;
177 WMOpenPanel
*sharedOpenPanel
;
178 WMSavePanel
*sharedSavePanel
;
180 struct W_FontPanel
*sharedFontPanel
;
182 struct W_ColorPanel
*sharedColorPanel
;
186 struct W_View
*dragSourceView
;
187 struct W_DraggingInfo dragInfo
;
200 GC monoGC
; /* GC for 1bpp visuals */
204 GC ixorGC
; /* IncludeInferiors XOR */
206 GC drawStringGC
; /* for WMDrawString() */
208 GC drawImStringGC
; /* for WMDrawImageString() */
214 WMHashTable
*fontCache
;
216 Bool antialiasedText
;
218 unsigned int ignoredModifierMask
; /* modifiers to ignore when typing txt */
220 struct W_Balloon
*balloon
;
223 struct W_Pixmap
*checkButtonImageOn
;
224 struct W_Pixmap
*checkButtonImageOff
;
226 struct W_Pixmap
*radioButtonImageOn
;
227 struct W_Pixmap
*radioButtonImageOff
;
229 struct W_Pixmap
*buttonArrow
;
230 struct W_Pixmap
*pushedButtonArrow
;
232 struct W_Pixmap
*scrollerDimple
;
234 struct W_Pixmap
*upArrow
;
235 struct W_Pixmap
*downArrow
;
236 struct W_Pixmap
*leftArrow
;
237 struct W_Pixmap
*rightArrow
;
239 struct W_Pixmap
*hiUpArrow
;
240 struct W_Pixmap
*hiDownArrow
;
241 struct W_Pixmap
*hiLeftArrow
;
242 struct W_Pixmap
*hiRightArrow
;
244 struct W_Pixmap
*pullDownIndicator
;
245 struct W_Pixmap
*popUpIndicator
;
247 struct W_Pixmap
*checkMark
;
249 struct W_Pixmap
*homeIcon
;
250 struct W_Pixmap
*altHomeIcon
;
252 struct W_Pixmap
*trashcanIcon
;
253 struct W_Pixmap
*altTrashcanIcon
;
255 struct W_Pixmap
*createDirIcon
;
256 struct W_Pixmap
*altCreateDirIcon
;
258 struct W_Pixmap
*disketteIcon
;
259 struct W_Pixmap
*altDisketteIcon
;
260 struct W_Pixmap
*unmountIcon
;
261 struct W_Pixmap
*altUnmountIcon
;
263 struct W_Pixmap
*magnifyIcon
;
264 /*struct W_Pixmap *altMagnifyIcon;*/
265 struct W_Pixmap
*wheelIcon
;
266 struct W_Pixmap
*grayIcon
;
267 struct W_Pixmap
*rgbIcon
;
268 struct W_Pixmap
*cmykIcon
;
269 struct W_Pixmap
*hsbIcon
;
270 struct W_Pixmap
*customPaletteIcon
;
271 struct W_Pixmap
*colorListIcon
;
273 struct W_Pixmap
*defaultObjectIcon
;
275 Cursor defaultCursor
;
279 Cursor invisibleCursor
;
281 Atom attribsAtom
; /* GNUstepWindowAttributes */
283 Atom deleteWindowAtom
; /* WM_DELETE_WINDOW */
285 Atom protocolsAtom
; /* _XA_WM_PROTOCOLS */
287 Atom clipboardAtom
; /* CLIPBOARD */
289 Atom xdndAwareAtom
; /* XdndAware */
290 Atom xdndSelectionAtom
;
293 Atom xdndPositionAtom
;
295 Atom xdndFinishedAtom
;
296 Atom xdndTypeListAtom
;
297 Atom xdndActionListAtom
;
298 Atom xdndActionDescriptionAtom
;
305 Atom xdndActionPrivate
;
307 Atom wmIconDragOffsetAtom
;
309 Atom wmStateAtom
; /* WM_STATE */
317 /* stuff for detecting double-clicks */
318 Time lastClickTime
; /* time of last mousedown event */
319 Window lastClickWindow
; /* window of the last mousedown */
321 struct W_View
*modalView
;
322 unsigned modalLoop
:1;
323 unsigned ignoreNextDoubleClick
:1;
328 typedef struct W_ViewDelegate
{
331 void (*didMove
)(struct W_ViewDelegate
*, WMView
*);
333 void (*didResize
)(struct W_ViewDelegate
*, WMView
*);
335 void (*willMove
)(struct W_ViewDelegate
*, WMView
*, int*, int*);
337 void (*willResize
)(struct W_ViewDelegate
*, WMView
*,
338 unsigned int*, unsigned int*);
343 typedef struct W_View
{
344 struct W_Screen
*screen
;
346 WMWidget
*self
; /* must point to the widget the view belongs to */
348 W_ViewDelegate
*delegate
;
361 struct W_View
*nextFocusChain
; /* next/prev in focus chain */
362 struct W_View
*prevFocusChain
;
364 struct W_View
*nextResponder
; /* next to receive keyboard events */
366 struct W_View
*parent
; /* parent WMView */
368 struct W_View
*childrenList
; /* first in list of child windows */
370 struct W_View
*nextSister
; /* next on parent's children list */
372 WMArray
*eventHandlers
; /* event handlers for this window */
374 unsigned long attribFlags
;
375 XSetWindowAttributes attribs
;
377 void *hangedData
; /* data holder for user program */
383 Atom
*droppableTypes
;
384 struct W_DragSourceProcs
*dragSourceProcs
;
385 struct W_DragDestinationProcs
*dragDestinationProcs
;
392 unsigned int realized
:1;
393 unsigned int mapped
:1;
394 unsigned int parentDying
:1;
395 unsigned int dying
:1; /* the view is being destroyed */
396 unsigned int topLevel
:1; /* is a top level window */
397 unsigned int root
:1; /* is the root window */
398 unsigned int mapWhenRealized
:1; /* map the view when it's realized */
399 unsigned int alreadyDead
:1; /* view was freed */
401 unsigned int dontCompressMotion
:1; /* motion notify event compress */
402 unsigned int notifySizeChanged
:1;
403 unsigned int dontCompressExpose
:1; /* expose event compress */
406 unsigned int worksWhenModal
:1;
407 unsigned int pendingRelease1
:1;
408 unsigned int pendingRelease2
:1;
409 unsigned int pendingRelease3
:1;
410 unsigned int pendingRelease4
:1;
411 unsigned int pendingRelease5
:1;
412 unsigned int xdndHintSet
:1;
419 typedef struct W_EventHandler
{
420 unsigned long eventMask
;
430 typedef struct _WINGsConfiguration
{
432 char *boldSystemFont
;
434 Bool antialiasedText
;
436 unsigned doubleClickDelay
;
437 unsigned mouseWheelUp
;
438 unsigned mouseWheelDown
;
439 } _WINGsConfiguration
;
441 extern _WINGsConfiguration WINGsConfiguration
;
445 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
448 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
449 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
451 #define W_VIEW_REALIZED(view) (view)->flags.realized
452 #define W_VIEW_MAPPED(view) (view)->flags.mapped
454 #define W_VIEW_DISPLAY(view) (view)->screen->display
455 #define W_VIEW_SCREEN(view) (view)->screen
456 #define W_VIEW_DRAWABLE(view) (view)->window
458 #define W_VIEW_WIDTH(view) (view)->size.width
459 #define W_VIEW_HEIGHT(view) (view)->size.height
462 #define W_PIXEL(c) (c)->color.pixel
464 #define W_FONTID(f) (f)->font->fid
466 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
470 W_View
*W_GetViewForXWindow(Display
*display
, Window window
);
472 W_View
*W_CreateView(W_View
*parent
);
474 W_View
*W_CreateTopView(W_Screen
*screen
);
476 W_View
*W_CreateUnmanagedTopView(W_Screen
*screen
);
479 W_View
*W_CreateRootView(W_Screen
*screen
);
481 void W_DestroyView(W_View
*view
);
483 void W_RealizeView(W_View
*view
);
485 void W_ReparentView(W_View
*view
, W_View
*newParent
, int x
, int y
);
487 void W_RaiseView(W_View
*view
);
489 void W_LowerView(W_View
*view
);
492 void W_MapView(W_View
*view
);
494 void W_MapSubviews(W_View
*view
);
496 void W_UnmapSubviews(W_View
*view
);
498 W_View
*W_TopLevelOfView(W_View
*view
);
500 void W_UnmapView(W_View
*view
);
502 void W_MoveView(W_View
*view
, int x
, int y
);
504 void W_ResizeView(W_View
*view
, unsigned int width
, unsigned int height
);
506 void W_SetViewBackgroundColor(W_View
*view
, WMColor
*color
);
508 void W_SetViewCursor(W_View
*view
, Cursor cursor
);
510 void W_DrawRelief(W_Screen
*scr
, Drawable d
, int x
, int y
, unsigned int width
,
511 unsigned int height
, WMReliefType relief
);
513 void W_DrawReliefWithGC(W_Screen
*scr
, Drawable d
, int x
, int y
,
514 unsigned int width
, unsigned int height
,
516 GC black
, GC dark
, GC light
, GC white
);
518 void W_CallDestroyHandlers(W_View
*view
);
520 void W_PaintTextAndImage(W_View
*view
, int wrap
, WMColor
*textColor
,
521 W_Font
*font
, WMReliefType relief
, char *text
,
522 WMAlignment alignment
, W_Pixmap
*image
,
523 WMImagePosition position
, WMColor
*backColor
, int ofs
);
525 void W_PaintText(W_View
*view
, Drawable d
, WMFont
*font
, int x
, int y
,
526 int width
, WMAlignment alignment
, WMColor
*color
,
527 int wrap
, char *text
, int length
);
529 int W_GetTextHeight(WMFont
*font
, char *text
, int width
, int wrap
);
532 int W_TextWidth(WMFont
*font
, char *text
, int length
);
535 void W_BroadcastMessage(W_View
*targetParent
, XEvent
*event
);
537 void W_DispatchMessage(W_View
*target
, XEvent
*event
);
539 void W_SetFocusOfToplevel(W_View
*toplevel
, W_View
*view
);
541 W_View
*W_FocusedViewOfToplevel(W_View
*view
);
543 void W_SetFocusOfTopLevel(W_View
*toplevel
, W_View
*view
);
545 void W_ReleaseView(WMView
*view
);
547 WMView
*W_RetainView(WMView
*view
);
549 void W_InitApplication(WMScreen
*scr
);
551 void W_InitNotificationCenter(void);
553 W_Class
W_RegisterUserWidget(void);
555 void W_RedisplayView(WMView
*view
);
557 Bool
W_ApplicationInitialized(void);
559 void W_HandleSelectionEvent(XEvent
*event
);
561 void W_HandleDNDClientMessage(WMView
*toplevel
, XClientMessageEvent
*event
);
563 void W_FlushASAPNotificationQueue(void);
565 void W_FlushIdleNotificationQueue(void);
567 struct W_Balloon
*W_CreateBalloon(WMScreen
*scr
);
569 void W_BalloonHandleEnterView(WMView
*view
);
571 void W_BalloonHandleLeaveView(WMView
*view
);
573 Bool
W_CheckIdleHandlers(void);
575 void W_CheckTimerHandlers(void);
577 Bool
W_HandleInputEvents(Bool waitForInput
, int inputfd
);
580 Atom
W_OperationToAction(WMScreen
*scr
, WMDragOperationType operation
);
582 WMDragOperationType
W_ActionToOperation(WMScreen
*scr
, Atom action
);
584 void W_FreeDragOperationItem(void* item
);
586 Bool
W_SendDnDClientMessage(Display
*dpy
, Window win
, Atom message
,
587 unsigned long data1
, unsigned long data2
,
588 unsigned long data3
, unsigned long data4
,
589 unsigned long data5
);
591 void W_DragSourceStartTimer(WMDraggingInfo
*info
);
593 void W_DragSourceStopTimer(void);
595 void W_DragSourceStateHandler(WMDraggingInfo
*info
, XClientMessageEvent
*event
);
597 void W_DragDestinationStartTimer(WMDraggingInfo
*info
);
599 void W_DragDestinationStopTimer(void);
601 void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo
*info
, WMView
*toplevel
,
602 XClientMessageEvent
*event
);
604 void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo
*info
,
606 XClientMessageEvent
*event
);
608 void W_DragDestinationCancelDropOnEnter(WMView
*toplevel
, WMDraggingInfo
*info
);
610 void W_DragDestinationStateHandler(WMDraggingInfo
*info
,
611 XClientMessageEvent
*event
);
613 void W_DragDestinationInfoClear(WMDraggingInfo
*info
);
615 void W_FreeViewXdndPart(WMView
*view
);
618 void W_InitIM(WMScreen
*scr
);
620 void W_CreateIC(WMView
*view
);
622 void W_DestroyIC(WMView
*view
);
624 void W_FocusIC(WMView
*view
);
626 void W_UnFocusIC(WMView
*view
);
628 void W_SetPreeditPositon(W_View
*view
, int x
, int y
);
630 int W_LookupString(W_View
*view
, XKeyPressedEvent
*event
, char *buffer
,
631 int buflen
, KeySym
*keysym
, Status
*status
);
635 #endif /* __cplusplus */
637 #endif /* _WINGSP_H_ */