4 #include <WINGs/WINGsP.h>
8 typedef struct W_GeometryView
{
22 unsigned width
, height
;
26 unsigned showPosition
:1;
31 static void handleEvents(XEvent
*event
, void *clientData
);
32 static void paint(WGeometryView
*gview
);
36 WCreateGeometryView(WMScreen
*scr
)
40 static W_Class widgetClass
= 0;
43 widgetClass
= W_RegisterUserWidget();
46 gview
= malloc(sizeof(WGeometryView
));
50 memset(gview
, 0, sizeof(WGeometryView
));
52 gview
->widgetClass
= widgetClass
;
54 gview
->view
= W_CreateTopView(scr
);
60 gview
->view
->self
= gview
;
62 gview
->font
= WMSystemFontOfSize(scr
, 12);
64 W_DestroyView(gview
->view
);
71 WMColor
*black
= WMBlackColor(scr
);
72 WMColor
*gray
= WMGrayColor(scr
);
75 gcv
.foreground
= WMColorPixel(black
);
76 gcv
.background
= WMColorPixel(gray
);
78 gview
->gc
= XCreateGC(WMScreenDisplay(scr
), W_DRAWABLE(scr
),
79 GCForeground
|GCBackground
, &gcv
);
81 WMReleaseColor(black
);
85 WMCreateEventHandler(gview
->view
, ExposureMask
, handleEvents
, gview
);
87 sprintf(buffer
, "%+05i, %+05i", 0, 0);
89 gview
->textSize
.width
= WMWidthOfString(gview
->font
, buffer
,
91 gview
->textSize
.height
= WMFontHeight(gview
->font
);
93 W_ResizeView(gview
->view
, gview
->textSize
.width
+8,
94 gview
->textSize
.height
+6);
101 WSetGeometryViewShownPosition(WGeometryView
*gview
, int x
, int y
)
103 gview
->showPosition
= 1;
104 gview
->data
.pos
.x
= x
;
105 gview
->data
.pos
.y
= y
;
112 WSetGeometryViewShownSize(WGeometryView
*gview
,
113 unsigned width
, unsigned height
)
115 gview
->showPosition
= 0;
116 gview
->data
.size
.width
= width
;
117 gview
->data
.size
.height
= height
;
125 paint(WGeometryView
*gview
)
129 if (gview
->showPosition
) {
130 sprintf(buffer
, "%+5i , %+5i ", gview
->data
.pos
.x
, gview
->data
.pos
.y
);
132 sprintf(buffer
, "%+5i x %+5i ", gview
->data
.size
.width
, gview
->data
.size
.height
);
135 WMDrawImageString(W_VIEW_SCREEN(gview
->view
),
136 W_VIEW_DRAWABLE(gview
->view
),
137 gview
->gc
, gview
->font
,
138 (W_VIEW_WIDTH(gview
->view
)-gview
->textSize
.width
)/2,
139 (W_VIEW_HEIGHT(gview
->view
)-gview
->textSize
.height
)/2,
140 buffer
, strlen(buffer
));
142 W_DrawRelief(W_VIEW_SCREEN(gview
->view
), W_VIEW_DRAWABLE(gview
->view
),
143 0, 0, W_VIEW_WIDTH(gview
->view
), W_VIEW_HEIGHT(gview
->view
),
150 handleEvents(XEvent
*event
, void *clientData
)
152 WGeometryView
*gview
= (WGeometryView
*)clientData
;
154 switch (event
->type
) {