diff options
author | corvid <corvid@lavabit.com> | 2011-07-03 19:45:26 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2011-07-03 19:45:26 +0000 |
commit | a9a2e89f9840938e1802cf457f887b17ead7376d (patch) | |
tree | a4a691a00be5f6fb8e0fcf22f46ea700b0d00c13 /dw | |
parent | 78032a7c42d76105620bd87c7bcac786194f27d5 (diff) |
draw the labels when hidden inputs are shown
In fltk-1.3, it doesn't draw inside labels for Fl_Inputs, and it
wasn't very nice anyway. Here I move them to the left.
Johannes took a look at this change:
"The only issue I could think of is that the additional
draw_outside_label() would cause excessive redraws for
some reason. But I didn't see anything like that during short
testing here."
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkui.cc | 27 | ||||
-rw-r--r-- | dw/fltkui.hh | 2 | ||||
-rw-r--r-- | dw/fltkviewbase.cc | 1 |
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 |