summaryrefslogtreecommitdiff
path: root/dw/fltkui.cc
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2011-07-03 19:45:26 +0000
committercorvid <corvid@lavabit.com>2011-07-03 19:45:26 +0000
commita9a2e89f9840938e1802cf457f887b17ead7376d (patch)
treea4a691a00be5f6fb8e0fcf22f46ea700b0d00c13 /dw/fltkui.cc
parent78032a7c42d76105620bd87c7bcac786194f27d5 (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/fltkui.cc')
-rw-r--r--dw/fltkui.cc27
1 files changed, 25 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 ();