4 #include <WINGs/WINGsP.h>
8 typedef struct W_GeometryView
{
24 unsigned width
, height
;
28 unsigned showPosition
:1;
33 static void handleEvents(XEvent
*event
, void *clientData
);
34 static void paint(WGeometryView
*gview
);
38 WCreateGeometryView(WMScreen
*scr
)
42 static W_Class widgetClass
= 0;
45 widgetClass
= W_RegisterUserWidget();
48 gview
= malloc(sizeof(WGeometryView
));
52 memset(gview
, 0, sizeof(WGeometryView
));
54 gview
->widgetClass
= widgetClass
;
56 gview
->view
= W_CreateTopView(scr
);
62 gview
->view
->self
= gview
;
64 gview
->font
= WMSystemFontOfSize(scr
, 12);
66 W_DestroyView(gview
->view
);
72 gview
->bgColor
= WMCreateRGBColor(scr
, 0x3333, 0x6666, 0x9999, True
);
73 gview
->color
= WMWhiteColor(scr
);
75 WMCreateEventHandler(gview
->view
, ExposureMask
, handleEvents
, gview
);
77 snprintf(buffer
, sizeof(buffer
), "%+05i, %+05i", 0, 0);
79 gview
->textSize
.width
= WMWidthOfString(gview
->font
, buffer
,
81 gview
->textSize
.height
= WMFontHeight(gview
->font
);
83 WMSetWidgetBackgroundColor(gview
, gview
->bgColor
);
85 W_ResizeView(gview
->view
, gview
->textSize
.width
+8,
86 gview
->textSize
.height
+6);
93 WSetGeometryViewShownPosition(WGeometryView
*gview
, int x
, int y
)
95 gview
->showPosition
= 1;
96 gview
->data
.pos
.x
= x
;
97 gview
->data
.pos
.y
= y
;
104 WSetGeometryViewShownSize(WGeometryView
*gview
,
105 unsigned width
, unsigned height
)
107 gview
->showPosition
= 0;
108 gview
->data
.size
.width
= width
;
109 gview
->data
.size
.height
= height
;
117 paint(WGeometryView
*gview
)
121 if (gview
->showPosition
) {
122 snprintf(buffer
, sizeof(buffer
), "%+5i , %+5i ",
123 gview
->data
.pos
.x
, gview
->data
.pos
.y
);
125 snprintf(buffer
, sizeof(buffer
), "%+5i x %+5i ",
126 gview
->data
.size
.width
, gview
->data
.size
.height
);
129 WMDrawImageString(W_VIEW_SCREEN(gview
->view
),
130 W_VIEW_DRAWABLE(gview
->view
),
131 gview
->color
, gview
->bgColor
, gview
->font
,
132 (W_VIEW_WIDTH(gview
->view
)-gview
->textSize
.width
)/2,
133 (W_VIEW_HEIGHT(gview
->view
)-gview
->textSize
.height
)/2,
134 buffer
, strlen(buffer
));
136 W_DrawRelief(W_VIEW_SCREEN(gview
->view
), W_VIEW_DRAWABLE(gview
->view
),
137 0, 0, W_VIEW_WIDTH(gview
->view
), W_VIEW_HEIGHT(gview
->view
),
144 handleEvents(XEvent
*event
, void *clientData
)
146 WGeometryView
*gview
= (WGeometryView
*)clientData
;
148 switch (event
->type
) {