diff options
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r-- | src/FbWinFrame.cc | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 31dfae0..387b159 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: FbWinFrame.cc,v 1.48 2003/09/11 19:55:27 rathnor Exp $ | 22 | // $Id: FbWinFrame.cc,v 1.49 2003/09/12 22:49:14 fluxgen Exp $ |
23 | 23 | ||
24 | #include "FbWinFrame.hh" | 24 | #include "FbWinFrame.hh" |
25 | 25 | ||
@@ -109,6 +109,7 @@ FbWinFrame::FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, | |||
109 | */ | 109 | */ |
110 | 110 | ||
111 | FbWinFrame::~FbWinFrame() { | 111 | FbWinFrame::~FbWinFrame() { |
112 | m_update_timer.stop(); | ||
112 | removeEventHandler(); | 113 | removeEventHandler(); |
113 | removeAllButtons(); | 114 | removeAllButtons(); |
114 | } | 115 | } |
@@ -137,7 +138,6 @@ void FbWinFrame::hide() { | |||
137 | 138 | ||
138 | void FbWinFrame::show() { | 139 | void FbWinFrame::show() { |
139 | m_visible = true; | 140 | m_visible = true; |
140 | reconfigure(); | ||
141 | m_window.showSubwindows(); | 141 | m_window.showSubwindows(); |
142 | m_window.show(); | 142 | m_window.show(); |
143 | } | 143 | } |
@@ -221,8 +221,17 @@ void FbWinFrame::setFocus(bool newvalue) { | |||
221 | if (m_focused == newvalue) // no need to change focus | 221 | if (m_focused == newvalue) // no need to change focus |
222 | return; | 222 | return; |
223 | 223 | ||
224 | |||
225 | |||
226 | if (m_focused && !newvalue && currentLabel()) { | ||
227 | renderButtonUnfocus(*m_current_label); | ||
228 | } else if (!m_focused && newvalue && currentLabel()) { | ||
229 | renderButtonFocus(*m_current_label); | ||
230 | } | ||
231 | |||
224 | m_focused = newvalue; | 232 | m_focused = newvalue; |
225 | reconfigure(); // reconfigure rendering for new focus value | 233 | renderButtons(); |
234 | renderHandles(); | ||
226 | } | 235 | } |
227 | 236 | ||
228 | void FbWinFrame::setDoubleClickTime(unsigned int time) { | 237 | void FbWinFrame::setDoubleClickTime(unsigned int time) { |
@@ -231,7 +240,6 @@ void FbWinFrame::setDoubleClickTime(unsigned int time) { | |||
231 | 240 | ||
232 | void FbWinFrame::setBevel(int bevel) { | 241 | void FbWinFrame::setBevel(int bevel) { |
233 | m_bevel = bevel; | 242 | m_bevel = bevel; |
234 | reconfigure(); | ||
235 | } | 243 | } |
236 | 244 | ||
237 | void FbWinFrame::addLeftButton(FbTk::Button *btn) { | 245 | void FbWinFrame::addLeftButton(FbTk::Button *btn) { |
@@ -284,13 +292,16 @@ void FbWinFrame::removeLabelButton(FbTk::TextButton &btn) { | |||
284 | return; | 292 | return; |
285 | 293 | ||
286 | m_labelbuttons.erase(erase_it); | 294 | m_labelbuttons.erase(erase_it); |
295 | |||
296 | if (*erase_it == m_current_label) | ||
297 | m_current_label = 0; | ||
287 | } | 298 | } |
288 | 299 | ||
289 | 300 | ||
290 | void FbWinFrame::moveLabelButtonLeft(const FbTk::TextButton &btn) { | 301 | void FbWinFrame::moveLabelButtonLeft(const FbTk::TextButton &btn) { |
291 | LabelList::iterator it = find(m_labelbuttons.begin(), | 302 | LabelList::iterator it = find(m_labelbuttons.begin(), |
292 | m_labelbuttons.end(), | 303 | m_labelbuttons.end(), |
293 | &btn); | 304 | &btn); |
294 | // make sure we found it and we're not at the begining | 305 | // make sure we found it and we're not at the begining |
295 | if (it == m_labelbuttons.end() || it == m_labelbuttons.begin()) | 306 | if (it == m_labelbuttons.end() || it == m_labelbuttons.begin()) |
296 | return; | 307 | return; |
@@ -333,9 +344,7 @@ void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) { | |||
333 | 344 | ||
334 | 345 | ||
335 | // render label buttons | 346 | // render label buttons |
336 | 347 | if (currentLabel() != 0) | |
337 | |||
338 | if (m_current_label != 0) | ||
339 | renderButtonUnfocus(*m_current_label); | 348 | renderButtonUnfocus(*m_current_label); |
340 | 349 | ||
341 | m_current_label = *it; // current focused button | 350 | m_current_label = *it; // current focused button |
@@ -528,9 +537,10 @@ void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { | |||
528 | } | 537 | } |
529 | 538 | ||
530 | void FbWinFrame::exposeEvent(XExposeEvent &event) { | 539 | void FbWinFrame::exposeEvent(XExposeEvent &event) { |
531 | if (m_label == event.window) | 540 | if (m_label == event.window) { |
532 | redrawTitle(); | 541 | m_label.clearArea(event.x, event.y, event.width, event.height); |
533 | else if (m_handle == event.window) { | 542 | m_label.updateTransparent(event.x, event.y, event.width, event.height); |
543 | } else if (m_handle == event.window) { | ||
534 | m_handle.clearArea(event.x, event.y, event.width, event.height); | 544 | m_handle.clearArea(event.x, event.y, event.width, event.height); |
535 | m_handle.updateTransparent(); | 545 | m_handle.updateTransparent(); |
536 | } else if (m_grip_left == event.window) { | 546 | } else if (m_grip_left == event.window) { |
@@ -570,6 +580,7 @@ void FbWinFrame::exposeEvent(XExposeEvent &event) { | |||
570 | if (it != m_buttons_right.end()) | 580 | if (it != m_buttons_right.end()) |
571 | (*it)->exposeEvent(event); | 581 | (*it)->exposeEvent(event); |
572 | } | 582 | } |
583 | |||
573 | } | 584 | } |
574 | 585 | ||
575 | void FbWinFrame::handleEvent(XEvent &event) { | 586 | void FbWinFrame::handleEvent(XEvent &event) { |
@@ -582,6 +593,8 @@ void FbWinFrame::configureNotifyEvent(XConfigureEvent &event) { | |||
582 | } | 593 | } |
583 | 594 | ||
584 | void FbWinFrame::reconfigure() { | 595 | void FbWinFrame::reconfigure() { |
596 | if (m_labelbuttons.size() == 0) | ||
597 | return; | ||
585 | 598 | ||
586 | // align titlebar and render it | 599 | // align titlebar and render it |
587 | if (m_use_titlebar) | 600 | if (m_use_titlebar) |
@@ -660,14 +673,13 @@ unsigned int FbWinFrame::buttonHeight() const { | |||
660 | return m_titlebar.height() - m_bevel*2; | 673 | return m_titlebar.height() - m_bevel*2; |
661 | } | 674 | } |
662 | 675 | ||
663 | |||
664 | //--------------------- private area | 676 | //--------------------- private area |
665 | 677 | ||
666 | /** | 678 | /** |
667 | aligns and redraws title | 679 | aligns and redraws title |
668 | */ | 680 | */ |
669 | void FbWinFrame::redrawTitle() { | 681 | void FbWinFrame::redrawTitle() { |
670 | if (m_labelbuttons.size() == 0 || !m_visible) | 682 | if (m_labelbuttons.size() == 0) |
671 | return; | 683 | return; |
672 | 684 | ||
673 | int button_width = label().width()/m_labelbuttons.size(); | 685 | int button_width = label().width()/m_labelbuttons.size(); |
@@ -687,7 +699,7 @@ void FbWinFrame::redrawTitle() { | |||
687 | button_width, | 699 | button_width, |
688 | label().height() + border_width); | 700 | label().height() + border_width); |
689 | (*btn_it)->clear(); | 701 | (*btn_it)->clear(); |
690 | (*btn_it)->updateTransparent(); | 702 | (*btn_it)->updateTransparent(); |
691 | } | 703 | } |
692 | m_titlebar.clear(); | 704 | m_titlebar.clear(); |
693 | m_titlebar.updateTransparent(); | 705 | m_titlebar.updateTransparent(); |
@@ -696,7 +708,7 @@ void FbWinFrame::redrawTitle() { | |||
696 | } | 708 | } |
697 | 709 | ||
698 | void FbWinFrame::redrawTitlebar() { | 710 | void FbWinFrame::redrawTitlebar() { |
699 | if (!m_use_titlebar || !m_visible) | 711 | if (!m_use_titlebar) |
700 | return; | 712 | return; |
701 | 713 | ||
702 | redrawTitle(); | 714 | redrawTitle(); |
@@ -754,7 +766,7 @@ void FbWinFrame::reconfigureTitlebar() { | |||
754 | } | 766 | } |
755 | 767 | ||
756 | void FbWinFrame::renderTitlebar() { | 768 | void FbWinFrame::renderTitlebar() { |
757 | if (!m_use_titlebar || !m_visible) | 769 | if (!m_use_titlebar) |
758 | return; | 770 | return; |
759 | 771 | ||
760 | // render pixmaps | 772 | // render pixmaps |
@@ -918,7 +930,7 @@ void FbWinFrame::init() { | |||
918 | // Note: we don't show clientarea yet | 930 | // Note: we don't show clientarea yet |
919 | 931 | ||
920 | setEventHandler(*this); | 932 | setEventHandler(*this); |
921 | reconfigure(); | 933 | // reconfigure(); |
922 | } | 934 | } |
923 | 935 | ||
924 | /** | 936 | /** |
@@ -1063,9 +1075,12 @@ void FbWinFrame::renderButtonFocus(FbTk::TextButton &button) { | |||
1063 | button.setBorderWidth(1); | 1075 | button.setBorderWidth(1); |
1064 | button.setAlpha(theme().alpha()); | 1076 | button.setAlpha(theme().alpha()); |
1065 | 1077 | ||
1066 | if (m_label_focused_pm != 0) | 1078 | if (m_label_focused_pm != 0) { |
1079 | // already set | ||
1080 | if (button.backgroundPixmap() == m_label_focused_pm) | ||
1081 | return; | ||
1067 | button.setBackgroundPixmap(m_label_focused_pm); | 1082 | button.setBackgroundPixmap(m_label_focused_pm); |
1068 | else | 1083 | } else |
1069 | button.setBackgroundColor(m_label_focused_color); | 1084 | button.setBackgroundColor(m_label_focused_color); |
1070 | 1085 | ||
1071 | button.clear(); | 1086 | button.clear(); |
@@ -1078,9 +1093,12 @@ void FbWinFrame::renderButtonUnfocus(FbTk::TextButton &button) { | |||
1078 | button.setBorderWidth(1); | 1093 | button.setBorderWidth(1); |
1079 | button.setAlpha(theme().alpha()); | 1094 | button.setAlpha(theme().alpha()); |
1080 | 1095 | ||
1081 | if (m_label_unfocused_pm != 0) | 1096 | if (m_label_unfocused_pm != 0) { |
1097 | // already set | ||
1098 | if (button.backgroundPixmap() == m_label_unfocused_pm) | ||
1099 | return; | ||
1082 | button.setBackgroundPixmap(m_label_unfocused_pm); | 1100 | button.setBackgroundPixmap(m_label_unfocused_pm); |
1083 | else | 1101 | } else |
1084 | button.setBackgroundColor(m_label_unfocused_color); | 1102 | button.setBackgroundColor(m_label_unfocused_color); |
1085 | 1103 | ||
1086 | button.clear(); | 1104 | button.clear(); |