Merge branch 'master' of git://localhost/acess2
[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, -1
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, -1, &w, &h);
32
33         // Apply edge padding
34         w += 2; h += 2;
35         
36         Element->MinW = w;
37         Element->MinH = h;
38
39         Widget_UpdateMinDims(Element->Parent);
40 }
41
42 DEFWIDGETTYPE(ELETYPE_TEXT,
43         WIDGETTYPE_FLAG_NOCHILDREN,
44         .Render = Widget_DispText_Render,
45         .UpdateText = Widget_DispText_UpdateText
46         );
47

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