5 typedef struct W_Frame
{
13 WMReliefType relief
:4;
14 WMTitlePosition titlePosition
:4;
19 #define DEFAULT_RELIEF WRGroove
20 #define DEFAULT_TITLE_POSITION WTPAtTop
21 #define DEFAULT_WIDTH 40
22 #define DEFAULT_HEIGHT 40
25 static void destroyFrame(Frame
*fPtr
);
26 static void paintFrame(Frame
*fPtr
);
31 WMSetFrameTitlePosition(WMFrame
*fPtr
, WMTitlePosition position
)
33 fPtr
->flags
.titlePosition
= position
;
35 if (fPtr
->view
->flags
.realized
) {
42 WMSetFrameRelief(WMFrame
*fPtr
, WMReliefType relief
)
44 fPtr
->flags
.relief
= relief
;
46 if (fPtr
->view
->flags
.realized
) {
53 WMSetFrameTitle(WMFrame
*fPtr
, char *title
)
58 fPtr
->caption
= wstrdup(title
);
62 if (fPtr
->view
->flags
.realized
) {
69 paintFrame(Frame
*fPtr
)
71 W_View
*view
= fPtr
->view
;
72 W_Screen
*scrPtr
= view
->screen
;
76 if (fPtr
->caption
!=NULL
)
77 th
= WMFontHeight(scrPtr
->normalFont
);
82 fh
= view
->size
.height
;
85 switch (fPtr
->flags
.titlePosition
) {
89 fh
= view
->size
.height
- fy
;
95 fh
= view
->size
.height
- fy
;
101 fh
= view
->size
.height
;
105 ty
= view
->size
.height
- th
- 4;
107 fh
= view
->size
.height
;
111 ty
= view
->size
.height
- th
;
113 fh
= view
->size
.height
- th
/2;
117 ty
= view
->size
.height
- th
;
119 fh
= view
->size
.height
- th
- 4;
125 fh
= view
->size
.height
;
128 XClearArea(scrPtr->display, view->window, fy+2, 2, fh-4, view->size.width-4,
131 XClearWindow(scrPtr
->display
, view
->window
);
133 W_DrawRelief(scrPtr
, view
->window
, 0, fy
, view
->size
.width
, fh
,
136 if (fPtr
->caption
!=NULL
&& fPtr
->flags
.titlePosition
!=WTPNoTitle
) {
139 tw
= WMWidthOfString(scrPtr
->normalFont
, fPtr
->caption
,
140 strlen(fPtr
->caption
));
142 tx
= (view
->size
.width
- tw
) / 2;
144 XFillRectangle(scrPtr
->display
, view
->window
, WMColorGC(scrPtr
->gray
),
147 WMDrawString(scrPtr
, view
->window
, WMColorGC(scrPtr
->black
),
148 scrPtr
->normalFont
, tx
, ty
, fPtr
->caption
,
149 strlen(fPtr
->caption
));
158 handleEvents(XEvent
*event
, void *data
)
160 Frame
*fPtr
= (Frame
*)data
;
162 CHECK_CLASS(data
, WC_Frame
);
164 switch (event
->type
) {
166 if (event
->xexpose
.count
!=0)
179 WMCreateFrame(WMWidget
*parent
)
183 fPtr
= wmalloc(sizeof(Frame
));
184 memset(fPtr
, 0, sizeof(Frame
));
186 fPtr
->widgetClass
= WC_Frame
;
188 fPtr
->view
= W_CreateView(W_VIEW(parent
));
193 fPtr
->view
->self
= fPtr
;
195 WMCreateEventHandler(fPtr
->view
, ExposureMask
|StructureNotifyMask
,
199 fPtr
->flags
.relief
= DEFAULT_RELIEF
;
200 fPtr
->flags
.titlePosition
= DEFAULT_TITLE_POSITION
;
202 WMResizeWidget(fPtr
, DEFAULT_WIDTH
, DEFAULT_HEIGHT
);
209 destroyFrame(Frame
*fPtr
)