4 #include <WINGs/WINGsP.h>
8 typedef struct W_GeometryView
{
23 unsigned width
, height
;
27 unsigned showPosition
:1;
32 static void handleEvents(XEvent
*event
, void *clientData
);
33 static void paint(WGeometryView
*gview
);
37 WCreateGeometryView(WMScreen
*scr
)
41 static W_Class widgetClass
= 0;
44 widgetClass
= W_RegisterUserWidget();
47 gview
= malloc(sizeof(WGeometryView
));
51 memset(gview
, 0, sizeof(WGeometryView
));
53 gview
->widgetClass
= widgetClass
;
55 gview
->view
= W_CreateTopView(scr
);
61 gview
->view
->self
= gview
;
63 gview
->font
= WMSystemFontOfSize(scr
, 12);
65 W_DestroyView(gview
->view
);
71 gview
->black
= WMBlackColor(scr
);
72 gview
->gray
= WMGrayColor(scr
);
74 WMCreateEventHandler(gview
->view
, ExposureMask
, handleEvents
, gview
);
76 snprintf(buffer
, sizeof(buffer
), "%+05i, %+05i", 0, 0);
78 gview
->textSize
.width
= WMWidthOfString(gview
->font
, buffer
,
80 gview
->textSize
.height
= WMFontHeight(gview
->font
);
82 W_ResizeView(gview
->view
, gview
->textSize
.width
+8,
83 gview
->textSize
.height
+6);
90 WSetGeometryViewShownPosition(WGeometryView
*gview
, int x
, int y
)
92 gview
->showPosition
= 1;
93 gview
->data
.pos
.x
= x
;
94 gview
->data
.pos
.y
= y
;
101 WSetGeometryViewShownSize(WGeometryView
*gview
,
102 unsigned width
, unsigned height
)
104 gview
->showPosition
= 0;
105 gview
->data
.size
.width
= width
;
106 gview
->data
.size
.height
= height
;
114 paint(WGeometryView
*gview
)
118 if (gview
->showPosition
) {
119 snprintf(buffer
, sizeof(buffer
), "%+5i , %+5i ",
120 gview
->data
.pos
.x
, gview
->data
.pos
.y
);
122 snprintf(buffer
, sizeof(buffer
), "%+5i x %+5i ",
123 gview
->data
.size
.width
, gview
->data
.size
.height
);
126 WMDrawImageString(W_VIEW_SCREEN(gview
->view
),
127 W_VIEW_DRAWABLE(gview
->view
),
128 gview
->black
, gview
->gray
, gview
->font
,
129 (W_VIEW_WIDTH(gview
->view
)-gview
->textSize
.width
)/2,
130 (W_VIEW_HEIGHT(gview
->view
)-gview
->textSize
.height
)/2,
131 buffer
, strlen(buffer
));
133 W_DrawRelief(W_VIEW_SCREEN(gview
->view
), W_VIEW_DRAWABLE(gview
->view
),
134 0, 0, W_VIEW_WIDTH(gview
->view
), W_VIEW_HEIGHT(gview
->view
),
141 handleEvents(XEvent
*event
, void *clientData
)
143 WGeometryView
*gview
= (WGeometryView
*)clientData
;
145 switch (event
->type
) {