On Sun, Dec 16, 2007 at 08:19:57PM +0100, Johannes Hofmann wrote:
I would do it as it is done for the maxLength and password members of FltkEntryResource: Add parameters to createMultiLineTextResource() and store the values in private members of FltkMultiLineTextResource.
OK, here's the patch to dw2. I'll follow up with the (extremely short) patch to dillo2. How should extra stuff like word-wrap be supported? More arguments to the constructor or some other API? Regards, Jeremy Henty diff -pru -- dw2-ref/dw/fltkplatform.cc dw2-cur/dw/fltkplatform.cc --- dw2-ref/dw/fltkplatform.cc 2007-12-16 16:02:02.000000000 +0000 +++ dw2-cur/dw/fltkplatform.cc 2007-12-16 22:23:40.000000000 +0000 @@ -142,9 +142,10 @@ FltkPlatform::FltkResourceFactory::creat } core::ui::MultiLineTextResource * -FltkPlatform::FltkResourceFactory::createMultiLineTextResource () +FltkPlatform::FltkResourceFactory::createMultiLineTextResource (int cols, + int rows) { - return new ui::FltkMultiLineTextResource (platform); + return new ui::FltkMultiLineTextResource (platform, cols, rows); } core::ui::CheckButtonResource * diff -pru -- dw2-ref/dw/fltkplatform.hh dw2-cur/dw/fltkplatform.hh --- dw2-ref/dw/fltkplatform.hh 2007-12-06 17:29:59.000000000 +0000 +++ dw2-cur/dw/fltkplatform.hh 2007-12-16 22:22:55.000000000 +0000 @@ -70,7 +70,8 @@ private: core::ui::OptionMenuResource *createOptionMenuResource (); core::ui::EntryResource *createEntryResource (int maxLength, bool password); - core::ui::MultiLineTextResource *createMultiLineTextResource (); + core::ui::MultiLineTextResource *createMultiLineTextResource (int cols, + int rows); core::ui::CheckButtonResource *createCheckButtonResource (bool activated); core::ui::RadioButtonResource * diff -pru -- dw2-ref/dw/fltkui.cc dw2-cur/dw/fltkui.cc --- dw2-ref/dw/fltkui.cc 2007-12-16 16:02:02.000000000 +0000 +++ dw2-cur/dw/fltkui.cc 2007-12-16 22:32:49.000000000 +0000 @@ -528,8 +528,10 @@ void FltkEntryResource::setEditable (boo // ---------------------------------------------------------------------- -FltkMultiLineTextResource::FltkMultiLineTextResource (FltkPlatform *platform): - FltkSpecificResource <dw::core::ui::MultiLineTextResource> (platform) +FltkMultiLineTextResource::FltkMultiLineTextResource (FltkPlatform *platform, + int cols, int rows): + FltkSpecificResource <dw::core::ui::MultiLineTextResource> (platform), + numCols(cols), numRows(rows) { initText = NULL; editable = false; @@ -569,11 +571,11 @@ void FltkMultiLineTextResource::sizeRequ if (style) { FltkFont *font = (FltkFont*)style->font; requisition->width = - (int)::fltk::getwidth ("M", 1) * 20 + (int)::fltk::getwidth ("M", 1) * numCols + 2 * RELIEF_X_THICKNESS; requisition->ascent = RELIEF_Y_THICKNESS; requisition->descent = - (font->ascent + font->descent) * 10 + RELIEF_Y_THICKNESS; + (font->ascent + font->descent) * numRows + RELIEF_Y_THICKNESS; } else { requisition->width = 1; requisition->ascent = 1; diff -pru -- dw2-ref/dw/fltkui.hh dw2-cur/dw/fltkui.hh --- dw2-ref/dw/fltkui.hh 2007-12-16 16:02:02.000000000 +0000 +++ dw2-cur/dw/fltkui.hh 2007-12-16 22:20:40.000000000 +0000 @@ -319,6 +319,7 @@ class FltkMultiLineTextResource: private: const char *initText; bool editable; + int numCols, numRows; static void widgetCallback (::fltk::Widget *widget, void *data); @@ -326,7 +327,7 @@ protected: ::fltk::Widget *createNewWidget (core::Allocation *allocation); public: - FltkMultiLineTextResource (FltkPlatform *platform); + FltkMultiLineTextResource (FltkPlatform *platform, int cols, int rows); ~FltkMultiLineTextResource (); void sizeRequest (core::Requisition *requisition); diff -pru -- dw2-ref/dw/ui.hh dw2-cur/dw/ui.hh --- dw2-ref/dw/ui.hh 2007-10-06 23:03:01.000000000 +0100 +++ dw2-cur/dw/ui.hh 2007-12-16 22:19:32.000000000 +0000 @@ -537,7 +537,8 @@ public: virtual OptionMenuResource *createOptionMenuResource () = 0; virtual EntryResource *createEntryResource (int maxLength, bool password) = 0; - virtual MultiLineTextResource *createMultiLineTextResource () = 0; + virtual MultiLineTextResource *createMultiLineTextResource (int cols, + int rows) = 0; virtual CheckButtonResource *createCheckButtonResource (bool activated) = 0; virtual RadioButtonResource *createRadioButtonResource (RadioButtonResource *groupedWith, diff -pru -- dw2-ref/test/dw_ui_test.cc dw2-cur/test/dw_ui_test.cc --- dw2-ref/test/dw_ui_test.cc 2007-12-16 16:02:03.000000000 +0000 +++ dw2-cur/test/dw_ui_test.cc 2007-12-16 22:24:19.000000000 +0000 @@ -84,7 +84,7 @@ int main(int argc, char **argv) EntryResource *entryres2 = layout->getResourceFactory()->createEntryResource (10, true); MultiLineTextResource *textres = - layout->getResourceFactory()->createMultiLineTextResource (); + layout->getResourceFactory()->createMultiLineTextResource (15,3); RadioButtonResource *radiores1 = layout->getResourceFactory()->createRadioButtonResource (NULL, false); RadioButtonResource *radiores2 =