5 typedef struct W_Frame
{
13 WMReliefType relief
:3;
14 WMTitlePosition titlePosition
:3;
20 struct W_ViewProcedureTable _FrameViewProcedures
= {
27 #define DEFAULT_RELIEF WRGroove
28 #define DEFAULT_TITLE_POSITION WTPAtTop
29 #define DEFAULT_WIDTH 40
30 #define DEFAULT_HEIGHT 40
33 static void destroyFrame(Frame
*fPtr
);
34 static void paintFrame(Frame
*fPtr
);
39 WMSetFrameTitlePosition(WMFrame
*fPtr
, WMTitlePosition position
)
41 fPtr
->flags
.titlePosition
= position
;
43 if (fPtr
->view
->flags
.realized
) {
50 WMSetFrameRelief(WMFrame
*fPtr
, WMReliefType relief
)
52 fPtr
->flags
.relief
= relief
;
54 if (fPtr
->view
->flags
.realized
) {
61 WMSetFrameTitle(WMFrame
*fPtr
, char *title
)
66 fPtr
->caption
= wstrdup(title
);
70 if (fPtr
->view
->flags
.realized
) {
77 paintFrame(Frame
*fPtr
)
79 W_View
*view
= fPtr
->view
;
80 W_Screen
*scrPtr
= view
->screen
;
84 if (fPtr
->caption
!=NULL
)
85 th
= WMFontHeight(scrPtr
->normalFont
);
90 fh
= view
->size
.height
;
93 switch (fPtr
->flags
.titlePosition
) {
97 fh
= view
->size
.height
- fy
;
103 fh
= view
->size
.height
- fy
;
109 fh
= view
->size
.height
;
113 ty
= view
->size
.height
- th
- 4;
115 fh
= view
->size
.height
;
119 ty
= view
->size
.height
- th
;
121 fh
= view
->size
.height
- th
/2;
125 ty
= view
->size
.height
- th
;
127 fh
= view
->size
.height
- th
- 4;
133 fh
= view
->size
.height
;
136 XClearArea(scrPtr->display, view->window, fy+2, 2, fh-4, view->size.width-4,
139 XClearWindow(scrPtr
->display
, view
->window
);
141 W_DrawRelief(scrPtr
, view
->window
, 0, fy
, view
->size
.width
, fh
,
144 if (fPtr
->caption
!=NULL
&& fPtr
->flags
.titlePosition
!=WTPNoTitle
) {
147 tw
= WMWidthOfString(scrPtr
->normalFont
, fPtr
->caption
,
148 strlen(fPtr
->caption
));
150 tx
= (view
->size
.width
- tw
) / 2;
152 XFillRectangle(scrPtr
->display
, view
->window
, WMColorGC(scrPtr
->gray
),
155 WMDrawString(scrPtr
, view
->window
, WMColorGC(scrPtr
->black
),
156 scrPtr
->normalFont
, tx
, ty
, fPtr
->caption
,
157 strlen(fPtr
->caption
));
166 handleEvents(XEvent
*event
, void *data
)
168 Frame
*fPtr
= (Frame
*)data
;
170 CHECK_CLASS(data
, WC_Frame
);
172 switch (event
->type
) {
174 if (event
->xexpose
.count
!=0)
187 WMCreateFrame(WMWidget
*parent
)
191 fPtr
= wmalloc(sizeof(Frame
));
192 memset(fPtr
, 0, sizeof(Frame
));
194 fPtr
->widgetClass
= WC_Frame
;
196 fPtr
->view
= W_CreateView(W_VIEW(parent
));
201 fPtr
->view
->self
= fPtr
;
203 WMCreateEventHandler(fPtr
->view
, ExposureMask
|StructureNotifyMask
,
207 fPtr
->flags
.relief
= DEFAULT_RELIEF
;
208 fPtr
->flags
.titlePosition
= DEFAULT_TITLE_POSITION
;
210 WMResizeWidget(fPtr
, DEFAULT_WIDTH
, DEFAULT_HEIGHT
);
217 destroyFrame(Frame
*fPtr
)