diff options
author | markt <markt> | 2007-10-13 21:51:37 (GMT) |
---|---|---|
committer | markt <markt> | 2007-10-13 21:51:37 (GMT) |
commit | a59428d67a95a9df16554962f0a6257d6378328a (patch) | |
tree | f856ed9300c34f7a17d499f22d895610cfbc08e5 /src/FbWinFrame.cc | |
parent | 41b5c6dadb1f474675660cef18b812d4c2338ed2 (diff) | |
download | fluxbox_lack-a59428d67a95a9df16554962f0a6257d6378328a.zip fluxbox_lack-a59428d67a95a9df16554962f0a6257d6378328a.tar.bz2 |
merged changes from pre-devel
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r-- | src/FbWinFrame.cc | 143 |
1 files changed, 23 insertions, 120 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index fbf1102..cc7d379 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "FbWinFrameTheme.hh" | 33 | #include "FbWinFrameTheme.hh" |
34 | #include "Screen.hh" | 34 | #include "Screen.hh" |
35 | 35 | ||
36 | #include "IconButton.hh" | ||
36 | #include "Container.hh" | 37 | #include "Container.hh" |
37 | 38 | ||
38 | #ifdef SHAPE | 39 | #ifdef SHAPE |
@@ -52,7 +53,8 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr | |||
52 | m_screen(screen), | 53 | m_screen(screen), |
53 | m_theme(theme), | 54 | m_theme(theme), |
54 | m_imagectrl(imgctrl), | 55 | m_imagectrl(imgctrl), |
55 | m_window(theme.screenNum(), x, y, width, height, ButtonPressMask | ButtonReleaseMask | | 56 | m_window(theme.screenNum(), x, y, width, height, |
57 | ButtonPressMask | ButtonReleaseMask | | ||
56 | ButtonMotionMask | EnterWindowMask, true), | 58 | ButtonMotionMask | EnterWindowMask, true), |
57 | m_layeritem(window(), layer), | 59 | m_layeritem(window(), layer), |
58 | m_titlebar(m_window, 0, 0, 100, 16, | 60 | m_titlebar(m_window, 0, 0, 100, 16, |
@@ -512,13 +514,6 @@ void FbWinFrame::setFocus(bool newvalue) { | |||
512 | } | 514 | } |
513 | } | 515 | } |
514 | 516 | ||
515 | if (currentLabel()) { | ||
516 | if (newvalue) // focused | ||
517 | applyFocusLabel(*m_current_label); | ||
518 | else // unfocused | ||
519 | applyUnfocusLabel(*m_current_label); | ||
520 | } | ||
521 | |||
522 | applyAll(); | 517 | applyAll(); |
523 | clearAll(); | 518 | clearAll(); |
524 | } | 519 | } |
@@ -610,11 +605,9 @@ void FbWinFrame::removeAllButtons() { | |||
610 | } | 605 | } |
611 | } | 606 | } |
612 | 607 | ||
613 | FbWinFrame::ButtonId FbWinFrame::createTab(const string &title, FbTk::Command *command, | 608 | IconButton *FbWinFrame::createTab(Focusable &client) { |
614 | int tabs_padding) { | 609 | IconButton *button = new IconButton(m_tab_container, theme().iconbarTheme(), |
615 | FbTk::TextButton *button = new FbTk::TextButton(m_tab_container, | 610 | client); |
616 | theme().font(), | ||
617 | title); | ||
618 | 611 | ||
619 | button->show(); | 612 | button->show(); |
620 | button->setEventMask(ExposureMask | ButtonPressMask | | 613 | button->setEventMask(ExposureMask | ButtonPressMask | |
@@ -622,29 +615,14 @@ FbWinFrame::ButtonId FbWinFrame::createTab(const string &title, FbTk::Command *c | |||
622 | EnterWindowMask); | 615 | EnterWindowMask); |
623 | FbTk::EventManager::instance()->add(*button, button->window()); | 616 | FbTk::EventManager::instance()->add(*button, button->window()); |
624 | 617 | ||
625 | FbTk::RefCount<FbTk::Command> refcmd(command); | ||
626 | button->setOnClick(refcmd); | ||
627 | |||
628 | button->setTextPadding(tabs_padding); | ||
629 | button->setJustify(theme().justify()); | ||
630 | button->setBorderColor(theme().border().color()); | ||
631 | button->setBorderWidth(m_window.borderWidth()); | ||
632 | |||
633 | m_tab_container.insertItem(button); | 618 | m_tab_container.insertItem(button); |
634 | 619 | ||
635 | if (currentLabel() == 0) | ||
636 | setLabelButtonFocus(*button); | ||
637 | |||
638 | return button; | 620 | return button; |
639 | } | 621 | } |
640 | 622 | ||
641 | void FbWinFrame::removeTab(ButtonId btn) { | 623 | void FbWinFrame::removeTab(IconButton *btn) { |
642 | if (btn == m_current_label) | ||
643 | m_current_label = 0; | ||
644 | |||
645 | if (m_tab_container.removeItem(btn)) | 624 | if (m_tab_container.removeItem(btn)) |
646 | delete btn; | 625 | delete btn; |
647 | |||
648 | } | 626 | } |
649 | 627 | ||
650 | 628 | ||
@@ -688,33 +666,10 @@ void FbWinFrame::moveLabelButtonRightOf(FbTk::TextButton &btn, const FbTk::TextB | |||
688 | m_tab_container.moveItem(&btn, movement); | 666 | m_tab_container.moveItem(&btn, movement); |
689 | } | 667 | } |
690 | 668 | ||
691 | void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) { | 669 | void FbWinFrame::setLabelButtonFocus(IconButton &btn) { |
692 | if (&btn == currentLabel() || btn.parent() != &m_tab_container) | ||
693 | return; | ||
694 | |||
695 | // render label buttons | ||
696 | if (currentLabel() != 0) | ||
697 | applyUnfocusLabel(*m_current_label); | ||
698 | |||
699 | m_current_label = &btn; // current focused button | ||
700 | m_label.setText(btn.text()); | ||
701 | |||
702 | if (m_focused) | ||
703 | applyFocusLabel(*m_current_label); | ||
704 | else | ||
705 | applyUnfocusLabel(*m_current_label); | ||
706 | } | ||
707 | |||
708 | void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn, bool value) { | ||
709 | if (btn.parent() != &m_tab_container) | 670 | if (btn.parent() != &m_tab_container) |
710 | return; | 671 | return; |
711 | 672 | m_label.setText(btn.text()); | |
712 | if (value) | ||
713 | applyFocusLabel(btn); | ||
714 | else | ||
715 | applyUnfocusLabel(btn); | ||
716 | |||
717 | btn.clear(); | ||
718 | } | 673 | } |
719 | 674 | ||
720 | void FbWinFrame::setClientWindow(FbTk::FbWindow &win) { | 675 | void FbWinFrame::setClientWindow(FbTk::FbWindow &win) { |
@@ -745,7 +700,8 @@ void FbWinFrame::setClientWindow(FbTk::FbWindow &win) { | |||
745 | XChangeWindowAttributes(win.display(), win.window(), CWEventMask|CWDontPropagate, &attrib_set); | 700 | XChangeWindowAttributes(win.display(), win.window(), CWEventMask|CWDontPropagate, &attrib_set); |
746 | 701 | ||
747 | m_clientarea.raise(); | 702 | m_clientarea.raise(); |
748 | win.show(); | 703 | if (isVisible()) |
704 | win.show(); | ||
749 | win.raise(); | 705 | win.raise(); |
750 | m_window.showSubwindows(); | 706 | m_window.showSubwindows(); |
751 | 707 | ||
@@ -900,10 +856,6 @@ void FbWinFrame::removeEventHandler() { | |||
900 | } | 856 | } |
901 | 857 | ||
902 | void FbWinFrame::buttonPressEvent(XButtonEvent &event) { | 858 | void FbWinFrame::buttonPressEvent(XButtonEvent &event) { |
903 | // we can ignore which window the event was generated for | ||
904 | if (event.window == m_label.window() && m_current_label) | ||
905 | event.window = m_current_label->window(); | ||
906 | |||
907 | m_tab_container.tryButtonPressEvent(event); | 859 | m_tab_container.tryButtonPressEvent(event); |
908 | if (event.window == m_grip_right.window() || | 860 | if (event.window == m_grip_right.window() || |
909 | event.window == m_grip_left.window() || | 861 | event.window == m_grip_left.window() || |
@@ -919,10 +871,6 @@ void FbWinFrame::buttonPressEvent(XButtonEvent &event) { | |||
919 | } | 871 | } |
920 | 872 | ||
921 | void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { | 873 | void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { |
922 | // we can ignore which window the event was generated for | ||
923 | if (event.window == m_label.window() && m_current_label) | ||
924 | event.window = m_current_label->window(); | ||
925 | |||
926 | // we continue even if a button got the event | 874 | // we continue even if a button got the event |
927 | m_tab_container.tryButtonReleaseEvent(event); | 875 | m_tab_container.tryButtonReleaseEvent(event); |
928 | 876 | ||
@@ -1274,11 +1222,11 @@ void FbWinFrame::renderTitlebar() { | |||
1274 | 1222 | ||
1275 | //!! TODO: don't render label if internal tabs | 1223 | //!! TODO: don't render label if internal tabs |
1276 | 1224 | ||
1277 | render(m_theme.labelFocusTexture(), m_label_focused_color, | 1225 | render(m_theme.iconbarTheme().focusedTexture(), m_label_focused_color, |
1278 | m_label_focused_pm, | 1226 | m_label_focused_pm, |
1279 | m_label.width(), m_label.height()); | 1227 | m_label.width(), m_label.height()); |
1280 | 1228 | ||
1281 | render(m_theme.labelUnfocusTexture(), m_label_unfocused_color, | 1229 | render(m_theme.iconbarTheme().unfocusedTexture(), m_label_unfocused_color, |
1282 | m_label_unfocused_pm, | 1230 | m_label_unfocused_pm, |
1283 | m_label.width(), m_label.height()); | 1231 | m_label.width(), m_label.height()); |
1284 | 1232 | ||
@@ -1290,8 +1238,8 @@ void FbWinFrame::renderTabContainer() { | |||
1290 | return; | 1238 | return; |
1291 | } | 1239 | } |
1292 | 1240 | ||
1293 | const FbTk::Texture *tc_focused = &m_theme.labelFocusTexture(); | 1241 | const FbTk::Texture *tc_focused = &m_theme.iconbarTheme().focusedTexture(); |
1294 | const FbTk::Texture *tc_unfocused = &m_theme.labelUnfocusTexture(); | 1242 | const FbTk::Texture *tc_unfocused = &m_theme.iconbarTheme().unfocusedTexture(); |
1295 | 1243 | ||
1296 | if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) | 1244 | if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) |
1297 | tc_focused = &m_theme.titleFocusTexture(); | 1245 | tc_focused = &m_theme.titleFocusTexture(); |
@@ -1306,14 +1254,6 @@ void FbWinFrame::renderTabContainer() { | |||
1306 | m_tabcontainer_unfocused_pm, | 1254 | m_tabcontainer_unfocused_pm, |
1307 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); | 1255 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); |
1308 | 1256 | ||
1309 | render(m_theme.labelFocusTexture(), m_labelbutton_focused_color, | ||
1310 | m_labelbutton_focused_pm, | ||
1311 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); | ||
1312 | |||
1313 | render(m_theme.labelUnfocusTexture(), m_labelbutton_unfocused_color, | ||
1314 | m_labelbutton_unfocused_pm, | ||
1315 | m_tab_container.width(), m_tab_container.height(), m_tab_container.orientation()); | ||
1316 | |||
1317 | renderButtons(); | 1257 | renderButtons(); |
1318 | 1258 | ||
1319 | } | 1259 | } |
@@ -1333,8 +1273,12 @@ void FbWinFrame::applyTitlebar() { | |||
1333 | m_label.setAlpha(alpha); | 1273 | m_label.setAlpha(alpha); |
1334 | 1274 | ||
1335 | if (m_tabmode != INTERNAL) { | 1275 | if (m_tabmode != INTERNAL) { |
1336 | m_label.setGC(m_focused?theme().labelTextFocusGC():theme().labelTextUnfocusGC()); | 1276 | m_label.setGC(m_focused ? |
1337 | m_label.setJustify(theme().justify()); | 1277 | theme().iconbarTheme().focusedText().textGC() : |
1278 | theme().iconbarTheme().unfocusedText().textGC()); | ||
1279 | m_label.setJustify(m_focused ? | ||
1280 | theme().iconbarTheme().focusedText().justify() : | ||
1281 | theme().iconbarTheme().unfocusedText().justify()); | ||
1338 | 1282 | ||
1339 | if (label_pm != 0) | 1283 | if (label_pm != 0) |
1340 | m_label.setBackgroundPixmap(label_pm); | 1284 | m_label.setBackgroundPixmap(label_pm); |
@@ -1455,15 +1399,12 @@ void FbWinFrame::init() { | |||
1455 | 1399 | ||
1456 | m_disable_themeshape = false; | 1400 | m_disable_themeshape = false; |
1457 | 1401 | ||
1458 | m_current_label = 0; // no focused button at first | ||
1459 | |||
1460 | m_handle.showSubwindows(); | 1402 | m_handle.showSubwindows(); |
1461 | 1403 | ||
1462 | // clear pixmaps | 1404 | // clear pixmaps |
1463 | m_title_focused_pm = m_title_unfocused_pm = 0; | 1405 | m_title_focused_pm = m_title_unfocused_pm = 0; |
1464 | m_label_focused_pm = m_label_unfocused_pm = 0; | 1406 | m_label_focused_pm = m_label_unfocused_pm = 0; |
1465 | m_tabcontainer_focused_pm = m_tabcontainer_unfocused_pm = 0; | 1407 | m_tabcontainer_focused_pm = m_tabcontainer_unfocused_pm = 0; |
1466 | m_labelbutton_focused_pm = m_labelbutton_unfocused_pm = 0; | ||
1467 | m_handle_focused_pm = m_handle_unfocused_pm = 0; | 1408 | m_handle_focused_pm = m_handle_unfocused_pm = 0; |
1468 | m_button_pm = m_button_unfocused_pm = m_button_pressed_pm = 0; | 1409 | m_button_pm = m_button_unfocused_pm = m_button_pressed_pm = 0; |
1469 | m_grip_unfocused_pm = m_grip_focused_pm = 0; | 1410 | m_grip_unfocused_pm = m_grip_focused_pm = 0; |
@@ -1586,11 +1527,8 @@ void FbWinFrame::applyTabContainer() { | |||
1586 | Container::ItemList::iterator btn_it = m_tab_container.begin(); | 1527 | Container::ItemList::iterator btn_it = m_tab_container.begin(); |
1587 | Container::ItemList::iterator btn_it_end = m_tab_container.end(); | 1528 | Container::ItemList::iterator btn_it_end = m_tab_container.end(); |
1588 | for (; btn_it != btn_it_end; ++btn_it) { | 1529 | for (; btn_it != btn_it_end; ++btn_it) { |
1589 | FbTk::TextButton *btn = static_cast<FbTk::TextButton *>(*btn_it); | 1530 | IconButton *btn = static_cast<IconButton *>(*btn_it); |
1590 | if (btn == m_current_label && m_focused) | 1531 | btn->reconfigTheme(); |
1591 | applyFocusLabel(*btn); | ||
1592 | else | ||
1593 | applyUnfocusLabel(*btn); | ||
1594 | } | 1532 | } |
1595 | } | 1533 | } |
1596 | 1534 | ||
@@ -1626,15 +1564,6 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { | |||
1626 | gripRight().setBorderWidth(border_width); | 1564 | gripRight().setBorderWidth(border_width); |
1627 | gripRight().setBorderColor(theme().border().color()); | 1565 | gripRight().setBorderColor(theme().border().color()); |
1628 | 1566 | ||
1629 | // and the labelbuttons | ||
1630 | Container::ItemList::iterator btn_it = m_tab_container.begin(); | ||
1631 | Container::ItemList::iterator btn_it_end = m_tab_container.end(); | ||
1632 | for (; btn_it != btn_it_end; ++btn_it) { | ||
1633 | (*btn_it)->setBorderWidth(border_width); | ||
1634 | (*btn_it)->setBorderColor(theme().border().color()); | ||
1635 | } | ||
1636 | m_tab_container.update(); | ||
1637 | |||
1638 | if (bw_changes != 0) | 1567 | if (bw_changes != 0) |
1639 | resize(width(), height() + bw_changes); | 1568 | resize(width(), height() + bw_changes); |
1640 | 1569 | ||
@@ -1648,32 +1577,6 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { | |||
1648 | 1577 | ||
1649 | } | 1578 | } |
1650 | 1579 | ||
1651 | void FbWinFrame::applyFocusLabel(FbTk::TextButton &button) { | ||
1652 | |||
1653 | button.setGC(theme().labelTextFocusGC()); | ||
1654 | button.setJustify(theme().justify()); | ||
1655 | button.setAlpha(getAlpha(m_focused)); | ||
1656 | |||
1657 | if (m_labelbutton_focused_pm != 0) { | ||
1658 | button.setBackgroundPixmap(m_labelbutton_focused_pm); | ||
1659 | } else | ||
1660 | button.setBackgroundColor(m_labelbutton_focused_color); | ||
1661 | |||
1662 | } | ||
1663 | |||
1664 | void FbWinFrame::applyUnfocusLabel(FbTk::TextButton &button) { | ||
1665 | |||
1666 | button.setGC(theme().labelTextUnfocusGC()); | ||
1667 | button.setJustify(theme().justify()); | ||
1668 | button.setAlpha(getAlpha(m_focused)); | ||
1669 | |||
1670 | if (m_labelbutton_unfocused_pm != 0) { | ||
1671 | button.setBackgroundPixmap(m_labelbutton_unfocused_pm); | ||
1672 | } else | ||
1673 | button.setBackgroundColor(m_labelbutton_unfocused_color); | ||
1674 | |||
1675 | } | ||
1676 | |||
1677 | // this function translates its arguments according to win_gravity | 1580 | // this function translates its arguments according to win_gravity |
1678 | // if win_gravity is negative, it does an inverse translation | 1581 | // if win_gravity is negative, it does an inverse translation |
1679 | // This function should be used when a window is mapped/unmapped/pos configured | 1582 | // This function should be used when a window is mapped/unmapped/pos configured |