Usermode/AxWin3 - Fiddling with text presentation
authorJohn Hodge <[email protected]>
Thu, 17 Nov 2011 14:41:06 +0000 (22:41 +0800)
committerJohn Hodge <[email protected]>
Thu, 17 Nov 2011 14:41:06 +0000 (22:41 +0800)
Usermode/Applications/axwin3_src/Interface/main.c
Usermode/Applications/axwin3_src/WM/renderers/widget.c
Usermode/Applications/axwin3_src/WM/renderers/widget/disptext.c

index d43845b..b7c06ca 100644 (file)
@@ -132,9 +132,9 @@ int run_close(tAxWin3_Widget *unused)
 tAxWin3_Widget *make_textbutton(tAxWin3_Widget *Parent, const char *Label, tAxWin3_Widget_FireCb handler)
 {
        tAxWin3_Widget  *ret, *txt;
-       ret = AxWin3_Widget_AddWidget(Parent, ELETYPE_BUTTON, ELEFLAG_NOSTRETCH, "_btn");
+       ret = AxWin3_Widget_AddWidget(Parent, ELETYPE_BUTTON, ELEFLAG_ALIGN_CENTER, "_btn");
        AxWin3_Widget_SetFireHandler(ret, handler);
-       txt = AxWin3_Widget_AddWidget(ret, ELETYPE_TEXT, 0, "_txt");
+       txt = AxWin3_Widget_AddWidget(ret, ELETYPE_TEXT, ELEFLAG_NOSTRETCH|ELEFLAG_NOEXPAND, "_txt");
        AxWin3_Widget_SetText(txt, Label);
        return ret;
 }
index 1bd437d..d77a67a 100644 (file)
@@ -319,40 +319,50 @@ void Widget_UpdatePosition(tElement *Element)
 void Widget_UpdateMinDims(tElement *Element)
 {
        tElement        *child;
+        int    minW, minH;
        
        if(!Element)    return;
        
-       Element->MinCross = 0;
-       Element->MinWith = 0;
+       minW = 0;
+       minH = 0;
        
        for(child = Element->FirstChild; child; child = child->NextSibling)
        {
-               if( Element->Parent &&
-                       (Element->Flags & ELEFLAG_VERTICAL) == (Element->Parent->Flags & ELEFLAG_VERTICAL)
-                       )
+               if( (Element->Flags & ELEFLAG_VERTICAL) )
                {
                        if(child->FixedCross)
-                               Element->MinCross += child->FixedCross;
+                               minW += child->FixedCross;
                        else
-                               Element->MinCross += child->MinCross;
+                               minW += child->MinCross;
                        if(child->FixedWith)
-                               Element->MinWith += child->FixedWith;
+                               minH += child->FixedWith;
                        else
-                               Element->MinWith += child->MinWith;
+                               minH += child->MinWith;
                }
                else
                {
                        if(child->FixedCross)
-                               Element->MinWith += child->FixedCross;
+                               minH += child->FixedCross;
                        else
-                               Element->MinWith += child->MinCross;
+                               minH += child->MinCross;
                        if(child->FixedWith)
-                               Element->MinCross += child->FixedWith;
+                               minW += child->FixedWith;
                        else
-                               Element->MinCross += child->MinWith;
+                               minW += child->MinWith;
                }
        }
        
+       if( Element->Parent && (Element->Parent->Flags & ELEFLAG_VERTICAL) )
+       {
+               Element->MinCross = Element->PaddingL + minW + Element->PaddingR;
+               Element->MinWith  = Element->PaddingT + minH + Element->PaddingB;
+       }
+       else
+       {
+               Element->MinWith  = Element->PaddingL + minW + Element->PaddingR;
+               Element->MinCross = Element->PaddingL + minH + Element->PaddingR;
+       }
+
        // Recurse upwards
        Widget_UpdateMinDims(Element->Parent);
 }
index 4a091de..4ea4833 100644 (file)
@@ -29,6 +29,10 @@ void Widget_DispText_UpdateText(tElement *Element, const char *Text)
        Element->Text = strdup(Text);
 
        WM_Render_GetTextDims(NULL, Element->Text, &w, &h);
+
+       // Apply edge padding
+       w += 2; h += 2;
+       
        if(Element->Parent && (Element->Parent->Flags & ELEFLAG_VERTICAL)) {
                Element->MinCross = w;
                Element->MinWith = h;

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