summaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Button.cc14
-rw-r--r--src/FbTk/Button.hh2
-rw-r--r--src/FbTk/TextButton.cc23
-rw-r--r--src/FbTk/TextButton.hh2
4 files changed, 35 insertions, 6 deletions
diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc
index 0284fea..9edbe5c 100644
--- a/src/FbTk/Button.cc
+++ b/src/FbTk/Button.cc
@@ -30,7 +30,8 @@ namespace FbTk {
30Button::Button(int screen_num, int x, int y, 30Button::Button(int screen_num, int x, int y,
31 unsigned int width, unsigned int height): 31 unsigned int width, unsigned int height):
32 FbWindow(screen_num, x, y, width, height, 32 FbWindow(screen_num, x, y, width, height,
33 ExposureMask | ButtonPressMask | ButtonReleaseMask), 33 ExposureMask | ButtonPressMask | EnterWindowMask |
34 LeaveWindowMask | ButtonReleaseMask),
34 m_background_pm(0), 35 m_background_pm(0),
35 m_pressed_pm(0), 36 m_pressed_pm(0),
36 m_pressed_color(), 37 m_pressed_color(),
@@ -45,7 +46,8 @@ Button::Button(int screen_num, int x, int y,
45Button::Button(const FbWindow &parent, int x, int y, 46Button::Button(const FbWindow &parent, int x, int y,
46 unsigned int width, unsigned int height): 47 unsigned int width, unsigned int height):
47 FbWindow(parent, x, y, width, height, 48 FbWindow(parent, x, y, width, height,
48 ExposureMask | ButtonPressMask | ButtonReleaseMask), 49 ExposureMask | ButtonPressMask | ButtonReleaseMask |
50 EnterWindowMask | LeaveWindowMask),
49 m_background_pm(0), 51 m_background_pm(0),
50 m_pressed_pm(0), 52 m_pressed_pm(0),
51 m_pressed_color(), 53 m_pressed_color(),
@@ -90,6 +92,14 @@ void Button::setBackgroundPixmap(Pixmap pm) {
90 FbTk::FbWindow::setBackgroundPixmap(pm); 92 FbTk::FbWindow::setBackgroundPixmap(pm);
91} 93}
92 94
95
96void Button::enterNotifyEvent(XCrossingEvent &ce){
97
98}
99void Button::leaveNotifyEvent(XCrossingEvent &ce){
100
101}
102
93void Button::buttonPressEvent(XButtonEvent &event) { 103void Button::buttonPressEvent(XButtonEvent &event) {
94 bool update = false; 104 bool update = false;
95 if (m_pressed_pm != 0) { 105 if (m_pressed_pm != 0) {
diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh
index 99d8ee9..1f65799 100644
--- a/src/FbTk/Button.hh
+++ b/src/FbTk/Button.hh
@@ -61,6 +61,8 @@ public:
61 //@{ 61 //@{
62 virtual void buttonPressEvent(XButtonEvent &event); 62 virtual void buttonPressEvent(XButtonEvent &event);
63 virtual void buttonReleaseEvent(XButtonEvent &event); 63 virtual void buttonReleaseEvent(XButtonEvent &event);
64 virtual void enterNotifyEvent(XCrossingEvent &ce);
65 virtual void leaveNotifyEvent(XCrossingEvent &ce);
64 virtual void exposeEvent(XExposeEvent &event); 66 virtual void exposeEvent(XExposeEvent &event);
65 //@} 67 //@}
66 68
diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc
index 561fe21..f259d89 100644
--- a/src/FbTk/TextButton.cc
+++ b/src/FbTk/TextButton.cc
@@ -158,11 +158,9 @@ void TextButton::drawText(int x_offset, int y_offset, FbDrawable *drawable) {
158 translateSize(m_orientation, textw, texth); 158 translateSize(m_orientation, textw, texth);
159 159
160 int align_x = FbTk::doAlignment(textw - x_offset - m_left_padding - m_right_padding, 160 int align_x = FbTk::doAlignment(textw - x_offset - m_left_padding - m_right_padding,
161 bevel(), 161 bevel(), justify(), font(),
162 justify(),
163 font(),
164 text().data(), text().size(), 162 text().data(), text().size(),
165 textlen); // return new text lne 163 textlen); // return new text len
166 164
167 // center text by default 165 // center text by default
168 int center_pos = texth/2 + font().ascent()/2 - 1; 166 int center_pos = texth/2 + font().ascent()/2 - 1;
@@ -183,6 +181,23 @@ void TextButton::drawText(int x_offset, int y_offset, FbDrawable *drawable) {
183 textx, texty, m_orientation); // position 181 textx, texty, m_orientation); // position
184} 182}
185 183
184
185bool TextButton::textExceeds(int x_offset) {
186
187 unsigned int textlen = text().size();
188 // do text alignment
189
190 unsigned int textw = width(), texth = height();
191 translateSize(m_orientation, textw, texth);
192
193 FbTk::doAlignment(textw - x_offset - m_left_padding - m_right_padding,
194 bevel(), justify(), font(), text().data(), text().size(),
195 textlen); // return new text len
196
197 return text().size()>textlen;
198
199}
200
186void TextButton::exposeEvent(XExposeEvent &event) { 201void TextButton::exposeEvent(XExposeEvent &event) {
187 clearArea(event.x, event.y, event.width, event.height, false); 202 clearArea(event.x, event.y, event.width, event.height, false);
188} 203}
diff --git a/src/FbTk/TextButton.hh b/src/FbTk/TextButton.hh
index eb48e61..22cda82 100644
--- a/src/FbTk/TextButton.hh
+++ b/src/FbTk/TextButton.hh
@@ -80,6 +80,8 @@ public:
80 80
81protected: 81protected:
82 virtual void drawText(int x_offset, int y_offset, FbDrawable *drawable_override); 82 virtual void drawText(int x_offset, int y_offset, FbDrawable *drawable_override);
83 // return true if the text will be truncated
84 bool textExceeds(int x_offset);
83 85
84private: 86private:
85 FbTk::Font *m_font; 87 FbTk::Font *m_font;