Usermode/AxWin3 - Splitting widget types out into separate files
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / renderers / widget / textinput.c
1 /*
2  * Acess2 Window Manager v3
3  * - By John Hodge (thePowersGang)
4  * 
5  * renderer/widget/textinput.c
6  * - Single line text box
7  */
8 #include <common.h>
9 #include "./common.h"
10 #include "./colours.h"
11
12 void Widget_TextInput_Render(tWindow *Window, tElement *Element)
13 {
14         WM_Render_FillRect(
15                 Window, 
16                 Element->CachedX, Element->CachedY,
17                 Element->CachedW, Element->CachedH,
18                 TEXTINPUT_BACKGROUND
19                 );
20         WM_Render_DrawRect(
21                 Window, 
22                 Element->CachedX, Element->CachedY,
23                 Element->CachedW, Element->CachedH,
24                 TEXTINPUT_BORDER_OUT
25                 );
26         WM_Render_DrawRect(
27                 Window, 
28                 Element->CachedX+1, Element->CachedY+1,
29                 Element->CachedW-2, Element->CachedH-2,
30                 TEXTINPUT_BORDER_IN
31                 );
32         // TODO: Cursor?
33 }
34
35 void Widget_TextInput_Init(tElement *Element)
36 {
37          int    h;
38
39         // TODO: Select font correctly  
40         WM_Render_GetTextDims(NULL, "jJ", NULL, &h);
41         
42         if( Element->Parent && (Element->Parent->Flags & ELEFLAG_VERTICAL) )
43                 Element->MinWith = h;
44         else
45                 Element->MinCross = h;
46
47         // No need to explicitly update parent min dims, as the AddElement routine does that    
48 }
49
50 DEFWIDGETTYPE(ELETYPE_TEXTINPUT,
51         .Render = Widget_TextInput_Render,
52         .Init = Widget_TextInput_Init
53         );
54
55

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