X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2FWM%2Frenderers%2Fwidget%2Ftextinput.c;h=853d28c85bf2cbf3d5cde7039191e176540a8a28;hb=b1488ae9beae34068d38d00e191b90ef0bf812f3;hp=b2b68e044cac356a1947117a04399203153c9668;hpb=dd2491a82880ed9b01b5d66b1814d271921797a4;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin3_src/WM/renderers/widget/textinput.c b/Usermode/Applications/axwin3_src/WM/renderers/widget/textinput.c index b2b68e04..853d28c8 100644 --- a/Usermode/Applications/axwin3_src/WM/renderers/widget/textinput.c +++ b/Usermode/Applications/axwin3_src/WM/renderers/widget/textinput.c @@ -4,36 +4,64 @@ * * renderer/widget/textinput.c * - Single line text box + * + * TODO: Support Right-to-Left text */ #include #include "./common.h" #include "./colours.h" +struct sTextInputInfo +{ + int DrawOfs; // Byte offset for the leftmost character + int CursorXOfs; // Pixel offset of the cursor +}; + void Widget_TextInput_Render(tWindow *Window, tElement *Element) { - WM_Render_FillRect( - Window, + struct sTextInputInfo *info = (void*)Element->Data; + struct sWidgetWin *wininfo = Window->RendererInfo; + + WM_Render_FillRect(Window, Element->CachedX, Element->CachedY, Element->CachedW, Element->CachedH, TEXTINPUT_BACKGROUND ); - WM_Render_DrawRect( - Window, + WM_Render_DrawRect(Window, Element->CachedX, Element->CachedY, Element->CachedW, Element->CachedH, TEXTINPUT_BORDER_OUT ); - WM_Render_DrawRect( - Window, + WM_Render_DrawRect(Window, Element->CachedX+1, Element->CachedY+1, Element->CachedW-2, Element->CachedH-2, TEXTINPUT_BORDER_IN ); - // TODO: Cursor? + + // Text + WM_Render_DrawText(Window, + Element->CachedX+2, Element->CachedY+2, + Element->CachedW-4, Element->CachedW-4, + NULL, TEXTINPUT_TEXT, + &Element->Text[info->DrawOfs] + ); + + // TODO: Determine if this element has focus + if( wininfo->FocusedElement == Element ) + { + // TODO: Multiple Cursors + WM_Render_SetTextCursor(Window, + Element->CachedX+2+info->CursorXOfs, + Element->CachedY+2, + Element->CachedW-4, 1, + TEXTINPUT_TEXT + ); + } } void Widget_TextInput_Init(tElement *Element) { + struct sTextInputInfo *info; int h; // TODO: Select font correctly @@ -41,12 +69,12 @@ void Widget_TextInput_Init(tElement *Element) h += 2+2; // Border padding - if( Element->Parent && (Element->Parent->Flags & ELEFLAG_VERTICAL) ) - Element->MinWith = h; - else - Element->MinCross = h; + Element->MinH = h; + Element->MinW = 4; - _SysDebug("h = %i", h); + info = Element->Data = malloc(sizeof(*info)); + info->DrawOfs = 0; + info->CursorXOfs = 0; // No need to explicitly update parent min dims, as the AddElement routine does that } @@ -57,4 +85,3 @@ DEFWIDGETTYPE(ELETYPE_TEXTINPUT, .Init = Widget_TextInput_Init ); -