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.
24 #endif /* __cplusplus */
27 #define DOUBLE_BUFFER 1
29 #define WC_UserWidget 128
31 #define SCROLLER_WIDTH 20
33 #define XDND_VERSION 3
36 typedef struct W_Application
{
37 char *applicationName
;
44 typedef struct W_Font
{
45 struct W_Screen
*screen
;
47 struct _XftFont
*font
;
56 typedef struct W_Pixmap
{
57 struct W_Screen
*screen
;
61 unsigned short height
;
67 typedef struct W_Color
{
68 struct W_Screen
*screen
;
80 typedef struct W_FocusInfo
{
81 struct W_View
*toplevel
;
82 struct W_View
*focused
; /* view that has the focus in this toplevel */
83 struct W_FocusInfo
*next
;
88 typedef void* W_DndState(WMView
*destView
, XClientMessageEvent
*event
,
89 WMDraggingInfo
*info
);
92 typedef struct W_DragOperationItem
{
93 WMDragOperationType type
;
95 } W_DragOperationItem
;
98 typedef struct W_DragSourceInfo
{
100 Window destinationWindow
;
102 WMSelectionProcs
*selectionProcs
;
104 WMPoint imageLocation
;
105 WMPoint mouseOffset
; /* mouse pos in icon */
107 WMRect noPositionMessageZone
;
108 Atom firstThreeTypes
[3];
112 typedef struct W_DragDestinationInfo
{
114 WMView
*xdndAwareView
;
117 Bool sourceActionChanged
;
118 WMArray
*sourceTypes
;
119 WMArray
*requiredTypes
;
120 Bool typeListAvailable
;
122 } W_DragDestinationInfo
;
125 struct W_DraggingInfo
{
126 unsigned char protocolVersion
; /* version supported on the other side */
130 Atom destinationAction
;
132 W_DragSourceInfo
* sourceInfo
; /* infos needed by source */
133 W_DragDestinationInfo
* destInfo
; /* infos needed by destination */
137 typedef struct W_Screen
{
150 struct W_View
*rootView
;
154 struct W_IMContext
*imctx
;
156 struct _XftDraw
*xftdraw
; /* shared XftDraw */
158 /* application related */
160 W_FocusInfo
*focusInfo
;
162 RImage
*applicationIconImage
; /* image (can have alpha channel) */
163 struct W_Pixmap
*applicationIconPixmap
; /* pixmap - no alpha channel */
164 Window applicationIconWindow
;
166 struct W_Window
*windowList
; /* list of windows in the app */
168 Window groupLeader
; /* the leader of the application */
169 /* also used for other things */
171 struct W_SelectionHandlers
*selectionHandlerList
;
174 unsigned int hasAppIcon
:1;
175 unsigned int simpleApplication
:1;
178 WMOpenPanel
*sharedOpenPanel
;
179 WMSavePanel
*sharedSavePanel
;
181 struct W_FontPanel
*sharedFontPanel
;
183 struct W_ColorPanel
*sharedColorPanel
;
187 struct W_View
*dragSourceView
;
188 struct W_DraggingInfo dragInfo
;
201 GC monoGC
; /* GC for 1bpp visuals */
205 GC ixorGC
; /* IncludeInferiors XOR */
207 GC drawStringGC
; /* for WMDrawString() */
209 GC drawImStringGC
; /* for WMDrawImageString() */
215 WMHashTable
*fontCache
;
217 Bool antialiasedText
;
219 unsigned int ignoredModifierMask
; /* modifiers to ignore when typing txt */
221 struct W_Balloon
*balloon
;
224 struct W_Pixmap
*checkButtonImageOn
;
225 struct W_Pixmap
*checkButtonImageOff
;
227 struct W_Pixmap
*radioButtonImageOn
;
228 struct W_Pixmap
*radioButtonImageOff
;
230 struct W_Pixmap
*buttonArrow
;
231 struct W_Pixmap
*pushedButtonArrow
;
233 struct W_Pixmap
*scrollerDimple
;
235 struct W_Pixmap
*upArrow
;
236 struct W_Pixmap
*downArrow
;
237 struct W_Pixmap
*leftArrow
;
238 struct W_Pixmap
*rightArrow
;
240 struct W_Pixmap
*hiUpArrow
;
241 struct W_Pixmap
*hiDownArrow
;
242 struct W_Pixmap
*hiLeftArrow
;
243 struct W_Pixmap
*hiRightArrow
;
245 struct W_Pixmap
*pullDownIndicator
;
246 struct W_Pixmap
*popUpIndicator
;
248 struct W_Pixmap
*checkMark
;
250 struct W_Pixmap
*homeIcon
;
251 struct W_Pixmap
*altHomeIcon
;
253 struct W_Pixmap
*trashcanIcon
;
254 struct W_Pixmap
*altTrashcanIcon
;
256 struct W_Pixmap
*createDirIcon
;
257 struct W_Pixmap
*altCreateDirIcon
;
259 struct W_Pixmap
*disketteIcon
;
260 struct W_Pixmap
*altDisketteIcon
;
261 struct W_Pixmap
*unmountIcon
;
262 struct W_Pixmap
*altUnmountIcon
;
264 struct W_Pixmap
*magnifyIcon
;
265 /*struct W_Pixmap *altMagnifyIcon;*/
266 struct W_Pixmap
*wheelIcon
;
267 struct W_Pixmap
*grayIcon
;
268 struct W_Pixmap
*rgbIcon
;
269 struct W_Pixmap
*cmykIcon
;
270 struct W_Pixmap
*hsbIcon
;
271 struct W_Pixmap
*customPaletteIcon
;
272 struct W_Pixmap
*colorListIcon
;
274 struct W_Pixmap
*defaultObjectIcon
;
276 Cursor defaultCursor
;
280 Cursor invisibleCursor
;
282 Atom attribsAtom
; /* GNUstepWindowAttributes */
284 Atom deleteWindowAtom
; /* WM_DELETE_WINDOW */
286 Atom protocolsAtom
; /* _XA_WM_PROTOCOLS */
288 Atom clipboardAtom
; /* CLIPBOARD */
290 Atom xdndAwareAtom
; /* XdndAware */
291 Atom xdndSelectionAtom
;
294 Atom xdndPositionAtom
;
296 Atom xdndFinishedAtom
;
297 Atom xdndTypeListAtom
;
298 Atom xdndActionListAtom
;
299 Atom xdndActionDescriptionAtom
;
306 Atom xdndActionPrivate
;
308 Atom wmIconDragOffsetAtom
;
310 Atom wmStateAtom
; /* WM_STATE */
318 /* stuff for detecting double-clicks */
319 Time lastClickTime
; /* time of last mousedown event */
320 Window lastClickWindow
; /* window of the last mousedown */
322 struct W_View
*modalView
;
323 unsigned modalLoop
:1;
324 unsigned ignoreNextDoubleClick
:1;
329 typedef struct W_ViewDelegate
{
332 void (*didMove
)(struct W_ViewDelegate
*, WMView
*);
334 void (*didResize
)(struct W_ViewDelegate
*, WMView
*);
336 void (*willMove
)(struct W_ViewDelegate
*, WMView
*, int*, int*);
338 void (*willResize
)(struct W_ViewDelegate
*, WMView
*,
339 unsigned int*, unsigned int*);
344 typedef struct W_View
{
345 struct W_Screen
*screen
;
347 WMWidget
*self
; /* must point to the widget the view belongs to */
349 W_ViewDelegate
*delegate
;
362 struct W_View
*nextFocusChain
; /* next/prev in focus chain */
363 struct W_View
*prevFocusChain
;
365 struct W_View
*nextResponder
; /* next to receive keyboard events */
367 struct W_View
*parent
; /* parent WMView */
369 struct W_View
*childrenList
; /* first in list of child windows */
371 struct W_View
*nextSister
; /* next on parent's children list */
373 WMArray
*eventHandlers
; /* event handlers for this window */
375 unsigned long attribFlags
;
376 XSetWindowAttributes attribs
;
378 void *hangedData
; /* data holder for user program */
384 Atom
*droppableTypes
;
385 struct W_DragSourceProcs
*dragSourceProcs
;
386 struct W_DragDestinationProcs
*dragDestinationProcs
;
393 unsigned int realized
:1;
394 unsigned int mapped
:1;
395 unsigned int parentDying
:1;
396 unsigned int dying
:1; /* the view is being destroyed */
397 unsigned int topLevel
:1; /* is a top level window */
398 unsigned int root
:1; /* is the root window */
399 unsigned int mapWhenRealized
:1; /* map the view when it's realized */
400 unsigned int alreadyDead
:1; /* view was freed */
402 unsigned int dontCompressMotion
:1; /* motion notify event compress */
403 unsigned int notifySizeChanged
:1;
404 unsigned int dontCompressExpose
:1; /* expose event compress */
407 unsigned int worksWhenModal
:1;
408 unsigned int pendingRelease1
:1;
409 unsigned int pendingRelease2
:1;
410 unsigned int pendingRelease3
:1;
411 unsigned int pendingRelease4
:1;
412 unsigned int pendingRelease5
:1;
413 unsigned int xdndHintSet
:1;
420 typedef struct W_EventHandler
{
421 unsigned long eventMask
;
431 typedef struct _WINGsConfiguration
{
433 char *boldSystemFont
;
435 Bool antialiasedText
;
437 unsigned doubleClickDelay
;
438 unsigned mouseWheelUp
;
439 unsigned mouseWheelDown
;
440 } _WINGsConfiguration
;
442 extern _WINGsConfiguration WINGsConfiguration
;
446 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
449 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
450 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
452 #define W_VIEW_REALIZED(view) (view)->flags.realized
453 #define W_VIEW_MAPPED(view) (view)->flags.mapped
455 #define W_VIEW_DISPLAY(view) (view)->screen->display
456 #define W_VIEW_SCREEN(view) (view)->screen
457 #define W_VIEW_DRAWABLE(view) (view)->window
459 #define W_VIEW_WIDTH(view) (view)->size.width
460 #define W_VIEW_HEIGHT(view) (view)->size.height
463 #define W_PIXEL(c) (c)->color.pixel
465 #define W_FONTID(f) (f)->font->fid
467 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
471 W_View
*W_GetViewForXWindow(Display
*display
, Window window
);
473 W_View
*W_CreateView(W_View
*parent
);
475 W_View
*W_CreateTopView(W_Screen
*screen
);
477 W_View
*W_CreateUnmanagedTopView(W_Screen
*screen
);
480 W_View
*W_CreateRootView(W_Screen
*screen
);
482 void W_DestroyView(W_View
*view
);
484 void W_RealizeView(W_View
*view
);
486 void W_ReparentView(W_View
*view
, W_View
*newParent
, int x
, int y
);
488 void W_RaiseView(W_View
*view
);
490 void W_LowerView(W_View
*view
);
493 void W_MapView(W_View
*view
);
495 void W_MapSubviews(W_View
*view
);
497 void W_UnmapSubviews(W_View
*view
);
499 W_View
*W_TopLevelOfView(W_View
*view
);
501 void W_UnmapView(W_View
*view
);
503 void W_MoveView(W_View
*view
, int x
, int y
);
505 void W_ResizeView(W_View
*view
, unsigned int width
, unsigned int height
);
507 void W_SetViewBackgroundColor(W_View
*view
, WMColor
*color
);
509 void W_SetViewCursor(W_View
*view
, Cursor cursor
);
511 void W_DrawRelief(W_Screen
*scr
, Drawable d
, int x
, int y
, unsigned int width
,
512 unsigned int height
, WMReliefType relief
);
514 void W_DrawReliefWithGC(W_Screen
*scr
, Drawable d
, int x
, int y
,
515 unsigned int width
, unsigned int height
,
517 GC black
, GC dark
, GC light
, GC white
);
519 void W_CallDestroyHandlers(W_View
*view
);
521 void W_PaintTextAndImage(W_View
*view
, int wrap
, WMColor
*textColor
,
522 W_Font
*font
, WMReliefType relief
, char *text
,
523 WMAlignment alignment
, W_Pixmap
*image
,
524 WMImagePosition position
, WMColor
*backColor
, int ofs
);
526 void W_PaintText(W_View
*view
, Drawable d
, WMFont
*font
, int x
, int y
,
527 int width
, WMAlignment alignment
, WMColor
*color
,
528 int wrap
, char *text
, int length
);
530 int W_GetTextHeight(WMFont
*font
, char *text
, int width
, int wrap
);
533 int W_TextWidth(WMFont
*font
, char *text
, int length
);
536 void W_BroadcastMessage(W_View
*targetParent
, XEvent
*event
);
538 void W_DispatchMessage(W_View
*target
, XEvent
*event
);
540 void W_SetFocusOfToplevel(W_View
*toplevel
, W_View
*view
);
542 W_View
*W_FocusedViewOfToplevel(W_View
*view
);
544 void W_SetFocusOfTopLevel(W_View
*toplevel
, W_View
*view
);
546 void W_ReleaseView(WMView
*view
);
548 WMView
*W_RetainView(WMView
*view
);
550 void W_InitApplication(WMScreen
*scr
);
552 void W_InitNotificationCenter(void);
554 W_Class
W_RegisterUserWidget(void);
556 void W_RedisplayView(WMView
*view
);
558 Bool
W_ApplicationInitialized(void);
560 void W_HandleSelectionEvent(XEvent
*event
);
562 void W_HandleDNDClientMessage(WMView
*toplevel
, XClientMessageEvent
*event
);
564 void W_FlushASAPNotificationQueue(void);
566 void W_FlushIdleNotificationQueue(void);
568 struct W_Balloon
*W_CreateBalloon(WMScreen
*scr
);
570 void W_BalloonHandleEnterView(WMView
*view
);
572 void W_BalloonHandleLeaveView(WMView
*view
);
574 Bool
W_CheckIdleHandlers(void);
576 void W_CheckTimerHandlers(void);
578 Bool
W_HandleInputEvents(Bool waitForInput
, int inputfd
);
581 Atom
W_OperationToAction(WMScreen
*scr
, WMDragOperationType operation
);
583 WMDragOperationType
W_ActionToOperation(WMScreen
*scr
, Atom action
);
585 void W_FreeDragOperationItem(void* item
);
587 Bool
W_SendDnDClientMessage(Display
*dpy
, Window win
, Atom message
,
588 unsigned long data1
, unsigned long data2
,
589 unsigned long data3
, unsigned long data4
,
590 unsigned long data5
);
592 void W_DragSourceStartTimer(WMDraggingInfo
*info
);
594 void W_DragSourceStopTimer(void);
596 void W_DragSourceStateHandler(WMDraggingInfo
*info
, XClientMessageEvent
*event
);
598 void W_DragDestinationStartTimer(WMDraggingInfo
*info
);
600 void W_DragDestinationStopTimer(void);
602 void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo
*info
, WMView
*toplevel
,
603 XClientMessageEvent
*event
);
605 void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo
*info
,
607 XClientMessageEvent
*event
);
609 void W_DragDestinationCancelDropOnEnter(WMView
*toplevel
, WMDraggingInfo
*info
);
611 void W_DragDestinationStateHandler(WMDraggingInfo
*info
,
612 XClientMessageEvent
*event
);
614 void W_DragDestinationInfoClear(WMDraggingInfo
*info
);
616 void W_FreeViewXdndPart(WMView
*view
);
619 void W_InitIM(WMScreen
*scr
);
621 void W_CreateIC(WMView
*view
);
623 void W_DestroyIC(WMView
*view
);
625 void W_FocusIC(WMView
*view
);
627 void W_UnFocusIC(WMView
*view
);
629 void W_SetPreeditPositon(W_View
*view
, int x
, int y
);
631 int W_LookupString(W_View
*view
, XKeyPressedEvent
*event
, char *buffer
,
632 int buflen
, KeySym
*keysym
, Status
*status
);
636 #endif /* __cplusplus */
638 #endif /* _WINGSP_H_ */