4ea48331d85ca6b6a02ed3cf27b8667ce305ebf6
[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
33         // Apply edge padding
34         w += 2; h += 2;
35         
36         if(Element->Parent && (Element->Parent->Flags & ELEFLAG_VERTICAL)) {
37                 Element->MinCross = w;
38                 Element->MinWith = h;
39         }
40         else {
41                 Element->MinWith = w;
42                 Element->MinCross = h;
43         }
44
45         Widget_UpdateMinDims(Element->Parent);
46 }
47
48 DEFWIDGETTYPE(ELETYPE_TEXT,
49         .Render = Widget_DispText_Render,
50         .UpdateText = Widget_DispText_UpdateText
51         );
52

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