aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/fltkui.cc27
-rw-r--r--dw/fltkui.hh2
-rw-r--r--dw/fltkviewbase.cc1
3 files changed, 28 insertions, 2 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc
index b854218f..fe55ff5f 100644
--- a/dw/fltkui.cc
+++ b/dw/fltkui.cc
@@ -471,6 +471,7 @@ FltkEntryResource::FltkEntryResource (FltkPlatform *platform, int maxLength,
this->maxLength = maxLength;
this->password = password;
this->label = label ? strdup(label) : NULL;
+ this->label_w = 0;
initText = NULL;
editable = false;
@@ -499,7 +500,7 @@ Fl_Widget *FltkEntryResource::createNewWidget (core::Allocation
if (label) {
input->label(label);
- input->align(FL_ALIGN_INSIDE);
+ input->align(FL_ALIGN_LEFT);
}
if (initText)
input->value (initText);
@@ -518,6 +519,13 @@ void FltkEntryResource::setWidgetStyle (Fl_Widget *widget,
in->cursor_color(in->textcolor());
in->textsize(in->labelsize());
in->textfont(in->labelfont());
+
+ if (label) {
+ int h;
+ label_w = 0;
+ widget->measure_label(label_w, h);
+ label_w += RELIEF_X_THICKNESS;
+ }
}
void FltkEntryResource::setDisplayed(bool displayed)
@@ -534,7 +542,7 @@ void FltkEntryResource::sizeRequest (core::Requisition *requisition)
requisition->width =
(int)fl_width ('n')
* (maxLength == UNLIMITED_MAX_LENGTH ? 10 : maxLength)
- + 2 * RELIEF_X_THICKNESS;
+ + label_w + (2 * RELIEF_X_THICKNESS);
requisition->ascent = font->ascent + RELIEF_Y_THICKNESS;
requisition->descent = font->descent + RELIEF_Y_THICKNESS;
} else {
@@ -544,6 +552,21 @@ void FltkEntryResource::sizeRequest (core::Requisition *requisition)
}
}
+void FltkEntryResource::sizeAllocate (core::Allocation *allocation)
+{
+ if (!label) {
+ FltkResource::sizeAllocate(allocation);
+ } else {
+ this->allocation = *allocation;
+
+ /* push the Fl_Input over to the right of the label */
+ core::Allocation a = this->allocation;
+ a.x += this->label_w;
+ a.width -= this->label_w;
+ view->allocateFltkWidget (widget, &a);
+ }
+}
+
void FltkEntryResource::widgetCallback (Fl_Widget *widget, void *data)
{
((FltkEntryResource*)data)->emitActivate ();
diff --git a/dw/fltkui.hh b/dw/fltkui.hh
index daddfb78..a5bddc5a 100644
--- a/dw/fltkui.hh
+++ b/dw/fltkui.hh
@@ -286,6 +286,7 @@ private:
bool password;
const char *initText;
char *label;
+ int label_w;
bool editable;
static void widgetCallback (Fl_Widget *widget, void *data);
@@ -301,6 +302,7 @@ public:
~FltkEntryResource ();
void sizeRequest (core::Requisition *requisition);
+ void sizeAllocate (core::Allocation *allocation);
const char *getText ();
void setText (const char *text);
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc
index 22fb06ef..9e23cf19 100644
--- a/dw/fltkviewbase.cc
+++ b/dw/fltkviewbase.cc
@@ -614,6 +614,7 @@ void FltkWidgetView::drawFltkWidget (Fl_Widget *widget,
core::Rectangle *area)
{
draw_child (*widget);
+ draw_outside_label(*widget);
}
} // namespace fltk