2 #include <WINGs/WINGsP.h>
4 typedef struct W_GeometryView
{
20 unsigned width
, height
;
24 unsigned showPosition
:1;
27 static void handleEvents(XEvent
* event
, void *clientData
);
28 static void paint(WGeometryView
* gview
);
30 WGeometryView
*WCreateGeometryView(WMScreen
* scr
)
34 static W_Class widgetClass
= 0;
37 widgetClass
= W_RegisterUserWidget();
40 gview
= malloc(sizeof(WGeometryView
));
44 memset(gview
, 0, sizeof(WGeometryView
));
46 gview
->widgetClass
= widgetClass
;
48 gview
->view
= W_CreateTopView(scr
);
54 gview
->view
->self
= gview
;
56 gview
->font
= WMSystemFontOfSize(scr
, 12);
58 W_DestroyView(gview
->view
);
64 gview
->bgColor
= WMCreateRGBColor(scr
, 0x3333, 0x6666, 0x9999, True
);
65 gview
->color
= WMWhiteColor(scr
);
67 WMCreateEventHandler(gview
->view
, ExposureMask
, handleEvents
, gview
);
69 snprintf(buffer
, sizeof(buffer
), "%+05i, %+05i", 0, 0);
71 gview
->textSize
.width
= WMWidthOfString(gview
->font
, buffer
, strlen(buffer
));
72 gview
->textSize
.height
= WMFontHeight(gview
->font
);
74 WMSetWidgetBackgroundColor(gview
, gview
->bgColor
);
76 W_ResizeView(gview
->view
, gview
->textSize
.width
+ 8, gview
->textSize
.height
+ 6);
81 void WSetGeometryViewShownPosition(WGeometryView
* gview
, int x
, int y
)
83 gview
->showPosition
= 1;
84 gview
->data
.pos
.x
= x
;
85 gview
->data
.pos
.y
= y
;
90 void WSetGeometryViewShownSize(WGeometryView
* gview
, unsigned width
, unsigned height
)
92 gview
->showPosition
= 0;
93 gview
->data
.size
.width
= width
;
94 gview
->data
.size
.height
= height
;
99 static void paint(WGeometryView
* gview
)
103 if (gview
->showPosition
) {
104 snprintf(buffer
, sizeof(buffer
), "%+5i , %+5i ", gview
->data
.pos
.x
, gview
->data
.pos
.y
);
106 snprintf(buffer
, sizeof(buffer
), "%+5i x %+5i ",
107 gview
->data
.size
.width
, gview
->data
.size
.height
);
110 WMDrawImageString(W_VIEW_SCREEN(gview
->view
),
111 W_VIEW_DRAWABLE(gview
->view
),
112 gview
->color
, gview
->bgColor
, gview
->font
,
113 (W_VIEW_WIDTH(gview
->view
) - gview
->textSize
.width
) / 2,
114 (W_VIEW_HEIGHT(gview
->view
) - gview
->textSize
.height
) / 2, buffer
, strlen(buffer
));
116 W_DrawRelief(W_VIEW_SCREEN(gview
->view
), W_VIEW_DRAWABLE(gview
->view
),
117 0, 0, W_VIEW_WIDTH(gview
->view
), W_VIEW_HEIGHT(gview
->view
), WRSimple
);
120 static void handleEvents(XEvent
* event
, void *clientData
)
122 WGeometryView
*gview
= (WGeometryView
*) clientData
;
124 switch (event
->type
) {