]> git.decadent.org.uk Git - ion3.git/blobdiff - mod_query/wedln.c
[svn-upgrade] Integrating new upstream version, ion3 (20070318)
[ion3.git] / mod_query / wedln.c
index fa9193c5e9460312abc15eba5266aa9307a30754..470b05b8bee51b2e665b05ba8e63b2d8bcbcc68c 100644 (file)
@@ -26,6 +26,8 @@
 #include <ioncore/event.h>
 #include <ioncore/regbind.h>
 #include <ioncore/gr-util.h>
+#include <ioncore/sizehint.h>
+#include <ioncore/resize.h>
 #include "edln.h"
 #include "wedln.h"
 #include "inputp.h"
@@ -225,14 +227,12 @@ static bool wedln_update_cursor(WEdln *wedln, int iw)
 
 static int get_textarea_height(WEdln *wedln, bool with_spacing)
 {
-    GrBorderWidths bdw;
-    GrFontExtents fnte;
+    int w=1, h=1;
     
-    grbrush_get_border_widths(WEDLN_BRUSH(wedln), &bdw);
-    grbrush_get_font_extents(WEDLN_BRUSH(wedln), &fnte);
+    if(WEDLN_BRUSH(wedln)!=NULL)
+        mod_query_get_minimum_extents(WEDLN_BRUSH(wedln), with_spacing, &w, &h);
     
-    return (fnte.max_height+bdw.top+bdw.bottom+
-            (with_spacing ? bdw.spacing : 0));
+    return h;
 }
 
 
@@ -355,6 +355,22 @@ static void wedln_calc_size(WEdln *wedln, WRectangle *geom)
 }
 
 
+void wedln_size_hints(WEdln *wedln, WSizeHints *hints_ret)
+{
+    int w=1, h=1;
+    
+    if(WEDLN_BRUSH(wedln)!=NULL){
+        mod_query_get_minimum_extents(WEDLN_BRUSH(wedln), FALSE, &w, &h);
+        w+=wedln->prompt_w+wedln->info_w;
+        w+=grbrush_get_text_width(WEDLN_BRUSH(wedln), "xxxxxxxxxx", 10);
+    }
+        
+    hints_ret->min_set=TRUE;
+    hints_ret->min_width=w;
+    hints_ret->min_height=h;
+}
+
+
 /*}}}*/
 
 
@@ -1011,8 +1027,7 @@ static void wedln_do_finish(WEdln *wedln)
     wedln->handler=extl_fn_none();
     p=edln_finish(&(wedln->edln));
     
-    if(region_manager_allows_destroying((WRegion*)wedln))
-       destroy_obj((Obj*)wedln);
+    region_rqdispose((WRegion*)wedln);
     
     if(p!=NULL)
         extl_call(handler, "s", NULL, p);
@@ -1077,6 +1092,7 @@ static DynFunTab wedln_dynfuntab[]={
     {input_scrolldown, wedln_scrolldown_completions},
     {window_insstr, wedln_insstr},
     {(DynFun*)input_style, (DynFun*)wedln_style},
+    {region_size_hints, wedln_size_hints},
     END_DYNFUNTAB
 };