fixed rendering problem on focused textbutton
fluxgen fluxgen
2 files changed,
61 insertions(+),
26 deletions(-)
M
src/FbWinFrame.cc
→
src/FbWinFrame.cc
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.cc,v 1.35 2003/08/13 09:34:40 fluxgen Exp $ +// $Id: FbWinFrame.cc,v 1.36 2003/08/13 16:36:37 fluxgen Exp $ #include "FbWinFrame.hh" #include "ImageControl.hh"@@ -271,7 +271,7 @@ m_buttons_right.pop_back();
} } -void FbWinFrame::addLabelButton(FbTk::Button &btn) { +void FbWinFrame::addLabelButton(TextButton &btn) { LabelList::iterator found_it = find(m_labelbuttons.begin(), m_labelbuttons.end(), &btn);@@ -282,7 +282,7 @@
m_labelbuttons.push_back(&btn); } -void FbWinFrame::removeLabelButton(FbTk::Button &btn) { +void FbWinFrame::removeLabelButton(TextButton &btn) { LabelList::iterator erase_it = remove(m_labelbuttons.begin(), m_labelbuttons.end(), &btn);@@ -293,7 +293,7 @@ m_labelbuttons.erase(erase_it);
} -void FbWinFrame::moveLabelButtonLeft(const FbTk::Button &btn) { +void FbWinFrame::moveLabelButtonLeft(const TextButton &btn) { LabelList::iterator it = find(m_labelbuttons.begin(), m_labelbuttons.end(), &btn);@@ -303,7 +303,7 @@ return;
LabelList::iterator new_pos = it; new_pos--; - FbTk::Button *item = *it; + TextButton *item = *it; // remove from list m_labelbuttons.erase(it); // insert on the new place@@ -312,7 +312,7 @@ // update titlebar
redrawTitle(); } -void FbWinFrame::moveLabelButtonRight(const FbTk::Button &btn) { +void FbWinFrame::moveLabelButtonRight(const TextButton &btn) { LabelList::iterator it = find(m_labelbuttons.begin(), m_labelbuttons.end(), &btn);@@ -320,7 +320,7 @@ // make sure we found it and we're not at the last item
if (it == m_labelbuttons.end() || *it == m_labelbuttons.back()) return; - FbTk::Button *item = *it; + TextButton *item = *it; // remove from list LabelList::iterator new_pos = m_labelbuttons.erase(it); new_pos++;@@ -330,15 +330,23 @@ // update titlebar
redrawTitle(); } -void FbWinFrame::setLabelButtonFocus(FbTk::Button &btn) { +void FbWinFrame::setLabelButtonFocus(TextButton &btn) { LabelList::iterator it = find(m_labelbuttons.begin(), m_labelbuttons.end(), &btn); if (it == m_labelbuttons.end()) return; + + // render label buttons + + + if (m_current_label != 0) + renderButtonUnfocus(*m_current_label); + m_current_label = *it; // current focused button - renderLabelButtons(); + + renderButtonFocus(*m_current_label); } void FbWinFrame::setClientWindow(FbTk::FbWindow &win) {@@ -986,16 +994,11 @@
LabelList::iterator btn_it = m_labelbuttons.begin(); LabelList::iterator btn_it_end = m_labelbuttons.end(); for (; btn_it != btn_it_end; ++btn_it) { + if (*btn_it == m_current_label) + renderButtonFocus(**btn_it); + else + renderButtonUnfocus(**btn_it); - (*btn_it)->setGC(theme().labelTextFocusGC()); - (*btn_it)->setBorderWidth(1); - (*btn_it)->setAlpha(theme().alpha()); - - if (m_label_unfocused_pm != 0) - (*btn_it)->setBackgroundPixmap(m_label_unfocused_pm); - else - (*btn_it)->setBackgroundColor(m_label_unfocused_color); - } if (m_current_label != 0) {@@ -1028,3 +1031,31 @@ if (bw_changes != 0)
resize(width(), height() + bw_changes); } +void FbWinFrame::renderButtonFocus(TextButton &button) { + + button.setGC(theme().labelTextFocusGC()); + button.setJustify(theme().justify()); + button.setBorderWidth(1); + button.setAlpha(theme().alpha()); + + if (m_label_focused_pm != 0) + button.setBackgroundPixmap(m_label_focused_pm); + else + button.setBackgroundColor(m_label_focused_color); + + button.clear(); +} + +void FbWinFrame::renderButtonUnfocus(TextButton &button) { + button.setGC(theme().labelTextUnfocusGC()); + button.setJustify(theme().justify()); + button.setBorderWidth(1); + button.setAlpha(theme().alpha()); + + if (m_label_unfocused_pm != 0) + button.setBackgroundPixmap(m_label_unfocused_pm); + else + button.setBackgroundColor(m_label_unfocused_color); + + button.clear(); +}
M
src/FbWinFrame.hh
→
src/FbWinFrame.hh
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.hh,v 1.11 2003/07/28 12:11:57 fluxgen Exp $ +// $Id: FbWinFrame.hh,v 1.12 2003/08/13 16:36:37 fluxgen Exp $ #ifndef FBWINFRAME_HH #define FBWINFRAME_HH@@ -38,6 +38,8 @@ #include <memory>
class Shape; class FbWinFrameTheme; +class TextButton; + namespace FbTk { class ImageControl; class Command;@@ -91,15 +93,15 @@ void addRightButton(FbTk::Button *btn);
/// remove all buttons from titlebar void removeAllButtons(); /// adds a button to label window - void addLabelButton(FbTk::Button &btn); + void addLabelButton(TextButton &btn); /// removes a specific button from label window - void removeLabelButton(FbTk::Button &btn); + void removeLabelButton(TextButton &btn); /// move label button to the left - void moveLabelButtonLeft(const FbTk::Button &btn); + void moveLabelButtonLeft(const TextButton &btn); /// move label button to the right - void moveLabelButtonRight(const FbTk::Button &btn); + void moveLabelButtonRight(const TextButton &btn); /// which button is to be rendered focused - void setLabelButtonFocus(FbTk::Button &btn); + void setLabelButtonFocus(TextButton &btn); /// attach a client window for client area void setClientWindow(Window win); /// same as above but with FbWindow@@ -180,6 +182,8 @@ //@{
void renderTitlebar(); void renderHandles(); void renderButtons(); + void renderButtonFocus(TextButton &button); + void renderButtonUnfocus(TextButton &button); void renderLabel(); /// renders to pixmap or sets color void render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,@@ -213,9 +217,9 @@ //@}
typedef std::vector<FbTk::Button *> ButtonList; ButtonList m_buttons_left, ///< buttons to the left m_buttons_right; ///< buttons to the right - typedef std::list<FbTk::Button *> LabelList; + typedef std::list<TextButton *> LabelList; LabelList m_labelbuttons; ///< holds label buttons inside label window - FbTk::Button *m_current_label; ///< which client button is focused at the moment + TextButton *m_current_label; ///< which client button is focused at the moment std::string m_titletext; ///< text to be displayed int m_label int m_bevel; ///< bevel between titlebar items and titlebar bool m_use_titlebar; ///< if we should use titlebar