Usermode/AxWin3 - Splitting widget types out into separate files
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / renderers / widget / disptext.c
1 /*
2  * Acess2 Window Manager v3
3  * - By John Hodge (thePowersGang)
4  * 
5  * renderer/widget/button.c
6  * - Button Widget Type
7  */
8 #include <common.h>
9 #include "./common.h"
10 #include "./colours.h"
11 #include <string.h>
12
13 void Widget_DispText_Render(tWindow *Window, tElement *Element)
14 {
15         WM_Render_DrawText(
16                 Window,
17                 Element->CachedX+1, Element->CachedY+1,
18                 Element->CachedW-2, Element->CachedH-2,
19                 NULL, TEXT_COLOUR,
20                 Element->Text
21                 );
22 }
23
24 void Widget_DispText_UpdateText(tElement *Element, const char *Text)
25 {
26          int    w=0, h=0;
27
28         if(Element->Text)       free(Element->Text);
29         Element->Text = strdup(Text);
30
31         WM_Render_GetTextDims(NULL, Element->Text, &w, &h);
32         if(Element->Parent && (Element->Parent->Flags & ELEFLAG_VERTICAL)) {
33                 Element->MinCross = w;
34                 Element->MinWith = h;
35         }
36         else {
37                 Element->MinWith = w;
38                 Element->MinCross = h;
39         }
40
41         Widget_UpdateMinDims(Element->Parent);
42 }
43
44 DEFWIDGETTYPE(ELETYPE_TEXT,
45         .Render = Widget_DispText_Render,
46         .UpdateText = Widget_DispText_UpdateText
47         );
48

UCC git Repository :: git.ucc.asn.au