diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-13 18:46:17 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-13 18:46:17 +0100 |
commit | d55de707c3352a468a227d69920a56ef2550a7cc (patch) | |
tree | 3f7ac91962d7e09328fb24d4eb52707a3f6e7f22 /plugingui/lineedit.cc | |
parent | c17046353762a0893914e671f1f19eadce6f94f5 (diff) |
Added path lineedit and drive selection (win32) to filebrowser. Made a lot of small layout tweaks.
Diffstat (limited to 'plugingui/lineedit.cc')
-rw-r--r-- | plugingui/lineedit.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/plugingui/lineedit.cc b/plugingui/lineedit.cc index 66d1e59..17174b9 100644 --- a/plugingui/lineedit.cc +++ b/plugingui/lineedit.cc @@ -38,6 +38,17 @@ GUI::LineEdit::LineEdit(Widget *parent) : GUI::Widget(parent) { pos = 0; + setReadOnly(false); +} + +void GUI::LineEdit::setReadOnly(bool ro) +{ + readonly = ro; +} + +bool GUI::LineEdit::readOnly() +{ + return readonly; } void GUI::LineEdit::setText(std::string text) @@ -54,6 +65,8 @@ std::string GUI::LineEdit::text() void GUI::LineEdit::buttonEvent(ButtonEvent *e) { + if(readOnly()) return; + if(e->direction == 1) { for(int i = 0; i < (int)_text.length(); i++) { if(e->x < (int)(font.textWidth(_text.substr(0, i)) + BORDER)) { @@ -67,6 +80,8 @@ void GUI::LineEdit::buttonEvent(ButtonEvent *e) void GUI::LineEdit::keyEvent(GUI::KeyEvent *e) { + if(readOnly()) return; + bool change = false; if(e->direction == -1) { @@ -124,12 +139,14 @@ void GUI::LineEdit::repaintEvent(GUI::RepaintEvent *e) p.setColour(Colour(1,1,1)); p.drawRectangle(0,0,width()-1,height()-1); p.drawRectangle(2,2,width()-3,height()-3); - p.drawText(BORDER, height()/2+5, font, _text); + p.drawText(BORDER - 4, height()/2+5 + 1, font, _text); + + if(readOnly()) return; if(hasKeyboardFocus()) { size_t px = font.textWidth(_text.substr(0, pos)); p.setColour(Colour(0.8)); - p.drawLine(px + BORDER - 1, 4, px + BORDER - 1, height() - 5); + p.drawLine(px + BORDER - 1 - 4, 4, px + BORDER - 1 - 4, height() - 5); } } |