wxaui multi-book prep work for left/right buttons on tab bar
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42587 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -140,6 +140,7 @@ class WXDLLIMPEXP_AUI wxAuiTabContainerButton
|
|||||||
public:
|
public:
|
||||||
int id; // button's id
|
int id; // button's id
|
||||||
int cur_state; // current state (normal, hover, pressed)
|
int cur_state; // current state (normal, hover, pressed)
|
||||||
|
int location; // buttons location (wxLEFT or wxRIGHT)
|
||||||
wxBitmap bitmap; // button's bitmap
|
wxBitmap bitmap; // button's bitmap
|
||||||
wxRect rect; // button's hit rectangle
|
wxRect rect; // button's hit rectangle
|
||||||
};
|
};
|
||||||
@@ -180,7 +181,7 @@ public:
|
|||||||
void SetMeasuringFont(const wxFont& measuring_font);
|
void SetMeasuringFont(const wxFont& measuring_font);
|
||||||
void DoShowHide();
|
void DoShowHide();
|
||||||
void SetRect(const wxRect& rect);
|
void SetRect(const wxRect& rect);
|
||||||
void AddButton(int id, const wxBitmap& bmp);
|
void AddButton(int id, int location, const wxBitmap& bmp);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@@ -448,11 +448,12 @@ size_t wxAuiTabContainer::GetPageCount() const
|
|||||||
return m_pages.GetCount();
|
return m_pages.GetCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxAuiTabContainer::AddButton(int id, const wxBitmap& bmp)
|
void wxAuiTabContainer::AddButton(int id, int location, const wxBitmap& bmp)
|
||||||
{
|
{
|
||||||
wxAuiTabContainerButton button;
|
wxAuiTabContainerButton button;
|
||||||
button.id = id;
|
button.id = id;
|
||||||
button.bitmap = bmp;
|
button.bitmap = bmp;
|
||||||
|
button.location = location;
|
||||||
button.cur_state = wxAUI_BUTTON_STATE_NORMAL;
|
button.cur_state = wxAUI_BUTTON_STATE_NORMAL;
|
||||||
|
|
||||||
m_buttons.Add(button);
|
m_buttons.Add(button);
|
||||||
@@ -470,11 +471,64 @@ void wxAuiTabContainer::Render(wxDC* raw_dc)
|
|||||||
bmp.Create(m_rect.GetWidth(), m_rect.GetHeight());
|
bmp.Create(m_rect.GetWidth(), m_rect.GetHeight());
|
||||||
dc.SelectObject(bmp);
|
dc.SelectObject(bmp);
|
||||||
|
|
||||||
|
|
||||||
m_art->DrawBackground(&dc, m_rect);
|
m_art->DrawBackground(&dc, m_rect);
|
||||||
|
|
||||||
size_t i, page_count = m_pages.GetCount();
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
// draw the buttons on the right side
|
||||||
|
offset = m_rect.x + m_rect.width;
|
||||||
|
size_t button_count = m_buttons.GetCount();
|
||||||
|
for (i = 0; i < button_count; ++i)
|
||||||
|
{
|
||||||
|
wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1);
|
||||||
|
|
||||||
|
if (button.location != wxRIGHT)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
wxRect button_rect(offset - button.bitmap.GetWidth(), 1,
|
||||||
|
button.bitmap.GetWidth(), button.bitmap.GetHeight());
|
||||||
|
|
||||||
|
button.rect = button_rect;
|
||||||
|
|
||||||
|
DrawButton(dc, button.rect, button.bitmap,
|
||||||
|
//m_bkbrush.GetColour(),
|
||||||
|
*wxWHITE,
|
||||||
|
button.cur_state);
|
||||||
|
|
||||||
|
offset -= button.bitmap.GetWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
// draw the buttons on the left side
|
||||||
|
|
||||||
|
for (i = 0; i < button_count; ++i)
|
||||||
|
{
|
||||||
|
wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1);
|
||||||
|
|
||||||
|
if (button.location != wxLEFT)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
wxRect button_rect(offset, 1,
|
||||||
|
button.bitmap.GetWidth(),
|
||||||
|
button.bitmap.GetHeight());
|
||||||
|
|
||||||
|
button.rect = button_rect;
|
||||||
|
|
||||||
|
DrawButton(dc, button.rect, button.bitmap,
|
||||||
|
//m_bkbrush.GetColour(),
|
||||||
|
*wxWHITE,
|
||||||
|
button.cur_state);
|
||||||
|
|
||||||
|
offset += button.bitmap.GetWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// draw the tabs
|
||||||
|
size_t page_count = m_pages.GetCount();
|
||||||
|
|
||||||
size_t active = 999;
|
size_t active = 999;
|
||||||
int active_offset = 0;
|
int active_offset = 0;
|
||||||
@@ -521,26 +575,6 @@ void wxAuiTabContainer::Render(wxDC* raw_dc)
|
|||||||
&x_extent);
|
&x_extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the buttons
|
|
||||||
offset = m_rect.x + m_rect.width;
|
|
||||||
size_t button_count = m_buttons.GetCount();
|
|
||||||
for (i = 0; i < button_count; ++i)
|
|
||||||
{
|
|
||||||
wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1);
|
|
||||||
|
|
||||||
wxRect button_rect(offset - button.bitmap.GetWidth(), 1,
|
|
||||||
button.bitmap.GetWidth(), button.bitmap.GetHeight());
|
|
||||||
|
|
||||||
button.rect = button_rect;
|
|
||||||
|
|
||||||
DrawButton(dc, button.rect, button.bitmap,
|
|
||||||
//m_bkbrush.GetColour(),
|
|
||||||
*wxWHITE,
|
|
||||||
button.cur_state);
|
|
||||||
|
|
||||||
offset -= button.bitmap.GetWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
raw_dc->Blit(m_rect.x, m_rect.y, m_rect.GetWidth(), m_rect.GetHeight(), &dc, 0, 0);
|
raw_dc->Blit(m_rect.x, m_rect.y, m_rect.GetWidth(), m_rect.GetHeight(), &dc, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -686,7 +720,7 @@ wxAuiTabCtrl::wxAuiTabCtrl(wxWindow* parent,
|
|||||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
|
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AddButton(101, BitmapFromBits(close_bits, 16, 16, *wxBLACK));
|
AddButton(101, wxRIGHT, BitmapFromBits(close_bits, 16, 16, *wxBLACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -780,6 +814,14 @@ void wxAuiTabCtrl::OnMotion(wxMouseEvent& evt)
|
|||||||
wxAuiTabContainerButton* button;
|
wxAuiTabContainerButton* button;
|
||||||
if (ButtonHitTest(pos.x, pos.y, &button))
|
if (ButtonHitTest(pos.x, pos.y, &button))
|
||||||
{
|
{
|
||||||
|
if (m_hover_button && button != m_hover_button)
|
||||||
|
{
|
||||||
|
m_hover_button->cur_state = wxAUI_BUTTON_STATE_NORMAL;
|
||||||
|
m_hover_button = NULL;
|
||||||
|
Refresh();
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
if (button->cur_state != wxAUI_BUTTON_STATE_HOVER)
|
if (button->cur_state != wxAUI_BUTTON_STATE_HOVER)
|
||||||
{
|
{
|
||||||
button->cur_state = wxAUI_BUTTON_STATE_HOVER;
|
button->cur_state = wxAUI_BUTTON_STATE_HOVER;
|
||||||
|
Reference in New Issue
Block a user