1
///////////////////////////////////////////////////////////////////////////////
2
// Name: wxFlatNotebook.cpp
3
// Purpose: generic implementation of flat style notebook class.
4
// Author: Eran Ifrah <eranif@bezeqint.net>
5
// Modified by: Priyank Bolia <soft@priyank.in>
7
// Modified: 01/01/2006
8
// Copyright: Eran Ifrah (c)
9
// Licence: wxWindows license <http://www.wxwidgets.org/licence3.txt>
10
///////////////////////////////////////////////////////////////////////////////
12
#include <wx/wxFlatNotebook/wxFlatNotebook.h>
13
#include <wx/wxFlatNotebook/renderer.h>
14
#include <wx/wxFlatNotebook/popup_dlg.h>
15
#include <wx/wxFlatNotebook/fnb_customize_dlg.h>
17
#include <wx/tooltip.h>
18
#include <wx/tipwin.h>
19
#include <wx/arrimpl.cpp>
22
# define FNB_LOG_MSG( msg ) { wxString logmsg; logmsg << msg; wxLogMessage( logmsg ); }
24
# define FNB_LOG_MSG( msg ) { wxString logmsg; logmsg << msg; }
27
static bool InsideRect(const wxRect &rect, const wxPoint &pt)
29
#if wxCHECK_VERSION(2, 8, 0)
30
return rect.Contains(pt);
32
return rect.Inside(pt);
38
wxString WhereToString( int where )
40
static std::map<int, wxString> whereMap;
41
static bool first = true;
45
whereMap[wxFNB_TAB] = wxT("wxFNB_TAB");
46
whereMap[wxFNB_X] = wxT("wxFNB_X");
47
whereMap[wxFNB_TAB_X] = wxT("wxFNB_TAB_X");
48
whereMap[wxFNB_LEFT_ARROW] = wxT("wxFNB_LEFT_ARROW");
49
whereMap[wxFNB_RIGHT_ARROW] = wxT("wxFNB_RIGHT_ARROW");
50
whereMap[wxFNB_DROP_DOWN_ARROW] = wxT("wxFNB_DROP_DOWN_ARROW");
51
whereMap[wxFNB_NOWHERE] = wxT("wxFNB_NOWHERE");
54
return whereMap[where];
58
//-------------------------------------------------------------------
59
// Provide user with a nice feedback when tab is being dragged
60
//-------------------------------------------------------------------
61
bool wxFNBDropSource::GiveFeedback(wxDragResult effect)
64
static_cast<wxPageContainer*>( m_win )->DrawDragHint();
68
IMPLEMENT_DYNAMIC_CLASS(wxFlatNotebookEvent, wxNotifyEvent)
69
DEFINE_EVENT_TYPE(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED)
70
DEFINE_EVENT_TYPE(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGING)
71
DEFINE_EVENT_TYPE(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING)
72
DEFINE_EVENT_TYPE(wxEVT_COMMAND_FLATNOTEBOOK_CONTEXT_MENU)
73
DEFINE_EVENT_TYPE(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSED)
75
IMPLEMENT_DYNAMIC_CLASS(wxFlatNotebook, wxPanel)
77
WX_DEFINE_OBJARRAY(wxFlatNotebookImageList);
78
WX_DEFINE_OBJARRAY(wxPageInfoArray)
79
WX_DEFINE_OBJARRAY(wxWindowPtrArray)
81
BEGIN_EVENT_TABLE(wxFlatNotebook, wxPanel)
82
EVT_NAVIGATION_KEY(wxFlatNotebook::OnNavigationKey)
85
wxFlatNotebook::wxFlatNotebook(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
88
Create(parent, id, pos, size, style, name);
91
void wxFlatNotebook::CleanUp ()
93
wxFNBRendererMgrST::Free();
96
wxFlatNotebook::~wxFlatNotebook(void)
100
void wxFlatNotebook::Init()
103
m_sendPageChangeEvent = true;
104
m_bForceSelection = false;
108
m_mainSizer = new wxBoxSizer(wxVERTICAL);
109
SetSizer(m_mainSizer);
112
bool wxFlatNotebook::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
113
long style, const wxString& name)
115
style |= wxTAB_TRAVERSAL;
116
wxPanel::Create(parent, id, pos, size, style, name);
118
m_pages = new wxPageContainer(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
119
m_pages->m_colorBorder = wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
121
m_mainSizer = new wxBoxSizer(wxVERTICAL);
122
SetSizer(m_mainSizer);
124
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
126
// Set default page height
129
wxBitmap bmp(10, 10);
130
memDc.SelectObject(bmp);
136
// For GTK it seems that we must do this steps in order
137
// for the tabs will get the proper height on initialization
138
// on MSW, preforming these steps yields wierd results
139
wxFont normalFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
140
wxFont boldFont = normalFont;
141
boldFont.SetWeight(wxFONTWEIGHT_BOLD);
142
memDc.SetFont( boldFont );
145
wxString stam = wxT("Tp"); // Temp data to get the text height;
146
memDc.GetTextExtent(stam, &width, &height);
148
int tabHeight = height + wxFNB_HEIGHT_SPACER; // We use 8 pixels as padding
150
// On GTK the tabs are should be larger
153
m_pages->SetSizeHints(wxSize(-1, tabHeight));
155
// Add the tab container to the sizer
156
m_mainSizer->Insert(0, m_pages, 0, wxEXPAND);
157
m_mainSizer->Layout();
159
m_pages->m_nFrom = m_nFrom;
160
m_pDropTarget = new wxFNBDropTarget<wxFlatNotebook>(this, &wxFlatNotebook::OnDropTarget);
161
SetDropTarget(m_pDropTarget);
165
void wxFlatNotebook::SetActiveTabTextColour(const wxColour& textColour)
167
m_pages->m_activeTextColor = textColour;
170
wxDragResult wxFlatNotebook::OnDropTarget(wxCoord x, wxCoord y, int nTabPage, wxWindow * wnd_oldContainer)
172
return m_pages->OnDropTarget(x, y, nTabPage, wnd_oldContainer);
175
int wxFlatNotebook::GetPreviousSelection() const
177
return m_pages->GetPreviousSelection();
180
const wxArrayInt &wxFlatNotebook::GetBrowseHistory() const
182
return m_pages->m_history;
185
bool wxFlatNotebook::AddPage(wxWindow* window, const wxString& caption, const bool selected, const int imgindex)
187
return InsertPage(m_windows.GetCount(), window, caption, selected, imgindex);
190
void wxFlatNotebook::SetImageList(wxFlatNotebookImageList * imglist)
192
m_pages->SetImageList(imglist);
195
wxFlatNotebookImageList * wxFlatNotebook::GetImageList()
197
return m_pages->GetImageList();
200
bool wxFlatNotebook::InsertPage(size_t index, wxWindow* page, const wxString& text, bool select, const int imgindex)
206
// reparent the window to us
207
page->Reparent(this);
209
if( !m_pages->IsShown() )
212
index = FNB_MIN((unsigned int)index, (unsigned int)m_windows.GetCount());
214
bool bSelected = select || m_windows.empty();
215
int curSel = m_pages->GetSelection();
217
if(index <= m_windows.GetCount())
219
m_windows.Insert(page, index);
226
if( !m_pages->InsertPage(index, page, text, bSelected, imgindex) )
229
if((int)index <= curSel) curSel++;
233
// Check if a new selection was made
238
// Remove the window from the main sizer
239
m_mainSizer->Detach(m_windows[curSel]);
240
m_windows[curSel]->Hide();
242
m_pages->SetSelection(index);
249
m_mainSizer->Layout();
256
void wxFlatNotebook::SetSelection(size_t page)
258
if(page >= m_windows.GetCount())
261
// Support for disabed tabs
262
if(!m_pages->GetEnabled(page) && m_windows.GetCount() > 1 && !m_bForceSelection)
265
if( m_sendPageChangeEvent )
267
// Allow the user to veto the selection
268
int oldSelection = GetSelection();
270
wxFlatNotebookEvent event(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGING, GetId());
271
event.SetSelection( (int)page );
272
event.SetOldSelection( oldSelection );
273
event.SetEventObject( this );
274
GetEventHandler()->ProcessEvent(event);
276
if( !event.IsAllowed() )
282
int curSel = m_pages->GetSelection();
284
// program allows the page change
288
// Remove the window from the main sizer
289
m_mainSizer->Detach(m_windows[curSel]);
290
m_windows[curSel]->Hide();
293
if(m_windowStyle & wxFNB_BOTTOM)
295
m_mainSizer->Insert(0, m_windows[page], 1, wxEXPAND);
299
// We leave a space of 1 pixel around the window
300
m_mainSizer->Add(m_windows[page], 1, wxEXPAND);
303
m_windows[page]->Show();
304
m_mainSizer->Layout();
307
if( page != (size_t)m_pages->m_iActivePage ){
308
//keep the page history
309
m_pages->PushPageHistory(m_pages->m_iActivePage);
312
m_pages->m_iActivePage = (int)page;
313
m_pages->DoSetSelection(page);
315
if( m_sendPageChangeEvent )
317
// Fire event 'Page Changed'
318
wxFlatNotebookEvent event(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED, GetId());
319
event.SetSelection( (int)page );
320
event.SetEventObject( this );
321
GetEventHandler()->ProcessEvent(event);
325
void wxFlatNotebook::DeletePage(size_t page, bool notify)
327
if(page >= m_windows.GetCount())
330
// Fire a closing event
333
wxFlatNotebookEvent event(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING, GetId());
334
event.SetSelection((int)page);
335
event.SetEventObject(this);
336
GetEventHandler()->ProcessEvent(event);
339
// The event handler allows it?
340
if (!event.IsAllowed())
346
// Delete the requested page
347
wxWindow *pageRemoved = m_windows[page];
349
// If the page is the current window, remove it from the sizer
351
if((int)page == m_pages->GetSelection())
353
m_mainSizer->Detach(pageRemoved);
356
// Remove it from the array as well
357
m_windows.RemoveAt(page);
359
// Now we can destroy it; in wxWidgets use Destroy instead of delete
360
pageRemoved->Destroy();
364
m_pages->DoDeletePage(page);
367
// Fire a closed event
370
wxFlatNotebookEvent closedEvent(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSED, GetId());
371
closedEvent.SetSelection((int)page);
372
closedEvent.SetEventObject(this);
373
GetEventHandler()->ProcessEvent(closedEvent);
377
bool wxFlatNotebook::DeleteAllPages()
379
if(m_windows.empty())
384
for(; i<(int)m_windows.GetCount(); i++)
392
// Clear the container of the tabs as well
393
m_pages->DeleteAllPages();
397
wxWindow* wxFlatNotebook::GetCurrentPage() const
399
int sel = m_pages->GetSelection();
403
return m_windows[sel];
406
wxWindow* wxFlatNotebook::GetPage(size_t page) const
408
if(page >= m_windows.GetCount())
411
return m_windows[page];
414
int wxFlatNotebook::GetPageIndex(wxWindow* win) const
416
for (size_t i = 0; i < m_windows.GetCount(); ++i)
418
if (m_windows[i] == win)
424
int wxFlatNotebook::GetSelection() const
426
return m_pages->GetSelection();
429
void wxFlatNotebook::AdvanceSelection(bool bForward)
431
m_pages->AdvanceSelection(bForward);
434
int wxFlatNotebook::GetPageCount() const
436
return (int)m_pages->GetPageCount();
439
void wxFlatNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
441
if ( event.IsWindowChange() )
443
if( HasFlag(wxFNB_SMART_TABS) )
445
if( !m_popupWin && GetPageCount() > 0)
447
m_popupWin = new wxTabNavigatorWindow( this );
448
m_popupWin->ShowModal();
449
m_popupWin->Destroy();
450
SetSelection((size_t)GetSelection());
453
else if( m_popupWin )
455
// a dialog is already opened
456
m_popupWin->OnNavigationKey( event );
463
AdvanceSelection(event.GetDirection());
468
// pass to the parent
471
event.SetCurrentFocus(this);
472
GetParent()->ProcessEvent(event);
477
bool wxFlatNotebook::GetPageShapeAngle(int page_index, unsigned int * result)
479
if(page_index < 0 || page_index >= (int)m_pages->m_pagesInfoVec.GetCount()) return false;
480
*result = m_pages->m_pagesInfoVec[page_index].GetTabAngle();
484
void wxFlatNotebook::SetPageShapeAngle(int page_index, unsigned int angle)
486
if(page_index < 0 || page_index >= (int)m_pages->m_pagesInfoVec.GetCount()) return;
487
if(angle > 15) return;
489
m_pages->m_pagesInfoVec[page_index].SetTabAngle(angle);
492
void wxFlatNotebook::SetAllPagesShapeAngle(unsigned int angle)
494
if(angle > 15) return;
495
for(unsigned int i = 0; i < m_pages->m_pagesInfoVec.GetCount(); i++)
497
m_pages->m_pagesInfoVec[i].SetTabAngle(angle);
502
wxSize wxFlatNotebook::GetPageBestSize()
504
return m_pages->GetClientSize();
507
bool wxFlatNotebook::SetPageText(size_t page, const wxString& text)
509
bool bVal = m_pages->SetPageText(page, text);
514
void wxFlatNotebook::SetPadding(const wxSize& padding)
516
m_nPadding = padding.GetWidth();
519
void wxFlatNotebook::SetWindowStyleFlag(long style)
521
wxPanel::SetWindowStyleFlag(style);
525
// For changing the tab position (i.e. placing them top/bottom)
526
// refreshing the tab container is not enough
527
m_sendPageChangeEvent = false;
528
SetSelection(m_pages->m_iActivePage);
529
m_sendPageChangeEvent = true;
533
bool wxFlatNotebook::RemovePage(size_t page, bool notify)
535
if(page >= m_windows.GetCount())
538
// Fire a closing event
541
wxFlatNotebookEvent event(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING, GetId());
542
event.SetSelection((int)page);
543
event.SetEventObject(this);
544
GetEventHandler()->ProcessEvent(event);
546
// The event handler allows it?
547
if (!event.IsAllowed())
553
// Remove the requested page
554
wxWindow *pageRemoved = m_windows[page];
556
// If the page is the current window, remove it from the sizer
558
if((int)page == m_pages->GetSelection())
560
m_mainSizer->Detach(pageRemoved);
563
// Remove it from the array as well
564
m_windows.RemoveAt(page);
567
m_pages->DoDeletePage(page);
569
// Fire a closed event
572
wxFlatNotebookEvent closedEvent(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSED, GetId());
573
closedEvent.SetSelection((int)page);
574
closedEvent.SetEventObject(this);
575
GetEventHandler()->ProcessEvent(closedEvent);
580
void wxFlatNotebook::SetRightClickMenu(wxMenu* menu)
582
m_pages->m_pRightClickMenu = menu;
585
wxString wxFlatNotebook::GetPageText(size_t page)
587
return m_pages->GetPageText(page);
590
void wxFlatNotebook::SetGradientColors(const wxColour& from, const wxColour& to, const wxColour& border)
592
m_pages->m_colorFrom = from;
593
m_pages->m_colorTo = to;
594
m_pages->m_colorBorder = border;
597
void wxFlatNotebook::SetGradientColorFrom(const wxColour& from)
599
m_pages->m_colorFrom = from;
602
void wxFlatNotebook::SetGradientColorTo(const wxColour& to)
604
m_pages->m_colorTo = to;
607
void wxFlatNotebook::SetGradientColorBorder(const wxColour& border)
609
m_pages->m_colorBorder = border;
612
/// Gets first gradient colour
613
const wxColour& wxFlatNotebook::GetGradientColorFrom()
615
return m_pages->m_colorFrom;
618
/// Gets second gradient colour
619
const wxColour& wxFlatNotebook::GetGradientColorTo()
621
return m_pages->m_colorTo;
624
/// Gets the tab border colour
625
const wxColour& wxFlatNotebook::SetGradientColorBorder()
627
return m_pages->m_colorBorder;
630
/// Get the active tab text
631
const wxColour& wxFlatNotebook::GetActiveTabTextColour()
633
return m_pages->m_activeTextColor;
636
void wxFlatNotebook::SetPageImageIndex(size_t page, int imgindex)
638
m_pages->SetPageImageIndex(page, imgindex);
641
int wxFlatNotebook::GetPageImageIndex(size_t page)
643
return m_pages->GetPageImageIndex(page);
646
bool wxFlatNotebook::GetEnabled(size_t page)
648
return m_pages->GetEnabled(page);
651
void wxFlatNotebook::Enable(size_t page, bool enabled)
653
if(page >= m_windows.GetCount())
656
m_windows[page]->Enable(enabled);
657
m_pages->Enable(page, enabled);
660
const wxColour& wxFlatNotebook::GetNonActiveTabTextColour()
662
return m_pages->m_nonActiveTextColor;
665
void wxFlatNotebook::SetNonActiveTabTextColour(const wxColour& color)
667
m_pages->m_nonActiveTextColor = color;
670
void wxFlatNotebook::SetTabAreaColour(const wxColour& color)
672
m_pages->m_tabAreaColor = color;
675
const wxColour& wxFlatNotebook::GetTabAreaColour()
677
return m_pages->m_tabAreaColor;
680
void wxFlatNotebook::SetActiveTabColour(const wxColour& color)
682
m_pages->m_activeTabColor = color;
685
const wxColour& wxFlatNotebook::GetActiveTabColour()
687
return m_pages->m_activeTabColor;
690
long wxFlatNotebook::GetCustomizeOptions() const {
691
return m_pages->GetCustomizeOptions();
694
void wxFlatNotebook::SetCustomizeOptions(long options) {
695
m_pages->SetCustomizeOptions(options);
698
///////////////////////////////////////////////////////////////////////////////////////////
702
///////////////////////////////////////////////////////////////////////////////////////////
704
BEGIN_EVENT_TABLE(wxPageContainer, wxPanel)
705
EVT_PAINT(wxPageContainer::OnPaint)
706
EVT_SIZE(wxPageContainer::OnSize)
707
EVT_LEFT_DOWN(wxPageContainer::OnLeftDown)
708
EVT_LEFT_UP(wxPageContainer::OnLeftUp)
709
EVT_RIGHT_DOWN(wxPageContainer::OnRightDown)
710
EVT_MIDDLE_DOWN(wxPageContainer::OnMiddleDown)
711
EVT_MOTION(wxPageContainer::OnMouseMove)
712
EVT_ERASE_BACKGROUND(wxPageContainer::OnEraseBackground)
713
EVT_LEAVE_WINDOW(wxPageContainer::OnMouseLeave)
714
EVT_ENTER_WINDOW(wxPageContainer::OnMouseEnterWindow)
715
EVT_LEFT_DCLICK(wxPageContainer::OnLeftDClick)
718
wxPageContainer::wxPageContainer(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
722
, m_pDropTarget(NULL)
723
, m_nLeftClickZone(wxFNB_NOWHERE)
724
, m_customizeOptions(wxFNB_CUSTOM_ALL)
726
m_pRightClickMenu = NULL;
727
m_nXButtonStatus = wxFNB_BTN_NONE;
728
m_nArrowDownButtonStatus = wxFNB_BTN_NONE;
730
m_nRightButtonStatus = wxFNB_BTN_NONE;
731
m_nLeftButtonStatus = wxFNB_BTN_NONE;
732
m_nTabXButtonStatus = wxFNB_BTN_NONE;
735
m_colorTo = wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
736
m_colorFrom = wxColor(*wxWHITE);
737
m_activeTabColor = wxColor(*wxWHITE);
738
m_activeTextColor = wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
739
m_nonActiveTextColor = wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
740
m_tabAreaColor = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
742
// Set default page height, this is done according to the system font
744
wxBitmap bmp(10, 10);
745
memDc.SelectObject(bmp);
750
wxFont normalFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
751
wxFont boldFont = normalFont;
752
boldFont.SetWeight(wxBOLD);
753
memDc.SetFont( boldFont );
756
memDc.GetTextExtent(wxT("Tp"), &width, &height);
757
int tabHeight = height + wxFNB_HEIGHT_SPACER; // We use 10 pixels as padding
759
wxWindow::Create(parent, id, pos, wxSize(size.x, tabHeight), style | wxNO_BORDER | wxNO_FULL_REPAINT_ON_RESIZE);
761
m_pDropTarget = new wxFNBDropTarget<wxPageContainer>(this, &wxPageContainer::OnDropTarget);
762
SetDropTarget(m_pDropTarget);
765
wxPageContainer::~wxPageContainer(void)
767
if(m_pRightClickMenu)
769
delete m_pRightClickMenu;
770
m_pRightClickMenu = NULL;
780
void wxPageContainer::OnPaint(wxPaintEvent & event)
782
wxBufferedPaintDC dc(this);
783
wxFNBRendererPtr render = wxFNBRendererMgrST::Get()->GetRenderer( GetParent()->GetWindowStyleFlag() );
785
render->DrawTabs(this, dc, event);
788
void wxPageContainer::PopPageHistory(int page)
790
int tabIdx(wxNOT_FOUND);
791
int where = m_history.Index(page);
792
while(where != wxNOT_FOUND){
793
tabIdx = m_history.Item(where);
794
m_history.Remove(page);
795
//remove all appearances of this page
796
where = m_history.Index(page);
800
if(tabIdx != wxNOT_FOUND){
801
for(size_t i=0; i<m_history.size(); i++){
802
int &tt = m_history.Item(i);
810
void wxPageContainer::PushPageHistory(int page)
812
if(page == wxNOT_FOUND)
815
int where = m_history.Index(page);
816
if(where != wxNOT_FOUND){
817
m_history.Remove(page);
819
m_history.Insert(page, 0);
822
bool wxPageContainer::AddPage(const wxString& caption, const bool selected, const int imgindex)
826
PushPageHistory(m_iActivePage);
827
m_iActivePage = (int)m_pagesInfoVec.GetCount();
830
/// Create page info and add it to the vector
831
wxPageInfo pageInfo(caption, imgindex);
832
m_pagesInfoVec.Add(pageInfo);
837
bool wxPageContainer::InsertPage(size_t index, wxWindow* /*page*/, const wxString& text, bool select, const int imgindex)
841
PushPageHistory(m_iActivePage);
842
m_iActivePage = (int)index;
844
wxPageInfo pgInfo(text, imgindex);
845
m_pagesInfoVec.Insert(pgInfo, index);
850
void wxPageContainer::OnSize(wxSizeEvent& WXUNUSED(event))
852
// When resizing the control, try to fit to screen as many tabs as we we can
853
long style = GetParent()->GetWindowStyleFlag();
854
wxFNBRendererPtr render = wxFNBRendererMgrST::Get()->GetRenderer(style);
855
std::vector<wxRect> vTabInfo;
858
int page = GetSelection();
859
for(; from<m_nFrom; from++)
862
render->NumberTabsCanFit( this, vTabInfo, from );
863
if(page - from >= static_cast<int>( vTabInfo.size() ))
868
Refresh(); // Call on paint
871
void wxPageContainer::OnMiddleDown(wxMouseEvent& event)
873
// Test if this style is enabled
874
long style = GetParent()->GetWindowStyleFlag();
875
if(!(style & wxFNB_MOUSE_MIDDLE_CLOSES_TABS))
880
int where = HitTest(event.GetPosition(), pgInfo, tabIdx);
885
DeletePage((size_t)tabIdx);
895
void wxPageContainer::OnShowCustomizeDialog(wxCommandEvent &event)
898
wxFNBCustomizeDialog *dlg = new wxFNBCustomizeDialog(this, m_customizeOptions);
903
void wxPageContainer::OnRightDown(wxMouseEvent& event)
905
FNB_LOG_MSG(wxT("OnRightDown") << event.GetPosition().x << wxT(",") << event.GetPosition().y );
908
int where = HitTest(event.GetPosition(), pgInfo, tabIdx);
913
// Incase user right clicked on 'anywhere' and style wxFNB_CUSTOM_DLG is set,
914
// popup the customize dialog
915
long style = GetParent()->GetWindowStyleFlag();
916
if( style & wxFNB_CUSTOM_DLG ){
918
m_customMenu = new wxMenu();
919
wxMenuItem *item = new wxMenuItem(m_customMenu, wxID_ANY, wxT("Properties..."));
920
m_customMenu->Append(item);
921
Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( wxPageContainer::OnShowCustomizeDialog ));
923
PopupMenu(m_customMenu);
931
if(!m_pagesInfoVec[tabIdx].GetEnabled())
934
// Set the current tab to be active
936
if(tabIdx != GetSelection())
938
SetSelection((size_t)tabIdx);
941
// If the owner has defined a context menu for the tabs,
942
// popup the right click menu
943
if (m_pRightClickMenu)
944
PopupMenu(m_pRightClickMenu);
947
// send a message to popup a custom menu
948
wxFlatNotebookEvent event(wxEVT_COMMAND_FLATNOTEBOOK_CONTEXT_MENU, GetParent()->GetId());
949
event.SetSelection((int)tabIdx);
950
event.SetOldSelection((int)m_iActivePage);
951
event.SetEventObject(GetParent());
952
GetParent()->GetEventHandler()->ProcessEvent(event);
963
void wxPageContainer::OnLeftDown(wxMouseEvent& event)
968
// Reset buttons status
969
m_nXButtonStatus = wxFNB_BTN_NONE;
970
m_nLeftButtonStatus = wxFNB_BTN_NONE;
971
m_nRightButtonStatus = wxFNB_BTN_NONE;
972
m_nTabXButtonStatus = wxFNB_BTN_NONE;
973
m_nArrowDownButtonStatus = wxFNB_BTN_NONE;
975
m_nLeftClickZone = HitTest(event.GetPosition(), pgInfo, tabIdx);
976
switch(m_nLeftClickZone)
978
case wxFNB_DROP_DOWN_ARROW:
979
m_nArrowDownButtonStatus = wxFNB_BTN_PRESSED;
982
case wxFNB_LEFT_ARROW:
983
m_nLeftButtonStatus = wxFNB_BTN_PRESSED;
986
case wxFNB_RIGHT_ARROW:
987
m_nRightButtonStatus = wxFNB_BTN_PRESSED;
991
m_nXButtonStatus = wxFNB_BTN_PRESSED;
995
m_nTabXButtonStatus = wxFNB_BTN_PRESSED;
1000
if(m_iActivePage != tabIdx)
1002
// Incase the tab is disabled, we dont allow to choose it
1003
if(!m_pagesInfoVec[tabIdx].GetEnabled())
1006
SetSelection(tabIdx);
1013
void wxPageContainer::RotateLeft()
1018
// Make sure that the button was pressed before
1019
if(m_nLeftButtonStatus != wxFNB_BTN_PRESSED)
1022
m_nLeftButtonStatus = wxFNB_BTN_HOVER;
1024
// We scroll left with bulks of 5
1025
int scrollLeft = GetNumTabsCanScrollLeft();
1027
m_nFrom -= scrollLeft;
1035
void wxPageContainer::RotateRight()
1037
if(m_nFrom >= (int)m_pagesInfoVec.GetCount() - 1)
1040
// Make sure that the button was pressed before
1041
if(m_nRightButtonStatus != wxFNB_BTN_PRESSED)
1044
m_nRightButtonStatus = wxFNB_BTN_HOVER;
1046
// Check if the right most tab is visible, if it is
1047
// don't rotate right anymore
1048
if(m_pagesInfoVec[m_pagesInfoVec.GetCount()-1].GetPosition() != wxPoint(-1, -1))
1055
void wxPageContainer::OnLeftUp(wxMouseEvent& event)
1060
// forget the zone that was initially clicked
1061
m_nLeftClickZone = wxFNB_NOWHERE;
1063
int where = HitTest(event.GetPosition(), pgInfo, tabIdx);
1066
case wxFNB_LEFT_ARROW:
1071
case wxFNB_RIGHT_ARROW:
1078
// Make sure that the button was pressed before
1079
if(m_nXButtonStatus != wxFNB_BTN_PRESSED)
1082
m_nXButtonStatus = wxFNB_BTN_HOVER;
1084
DeletePage((size_t)m_iActivePage);
1089
// Make sure that the button was pressed before
1090
if(m_nTabXButtonStatus != wxFNB_BTN_PRESSED)
1093
m_nTabXButtonStatus = wxFNB_BTN_HOVER;
1095
DeletePage((size_t)m_iActivePage);
1098
case wxFNB_DROP_DOWN_ARROW:
1100
// Make sure that the button was pressed before
1101
if(m_nArrowDownButtonStatus != wxFNB_BTN_PRESSED)
1104
m_nArrowDownButtonStatus = wxFNB_BTN_NONE;
1106
// Refresh the button status
1107
wxFNBRendererPtr render = wxFNBRendererMgrST::Get()->GetRenderer( GetParent()->GetWindowStyleFlag() );
1108
wxClientDC dc(this);
1109
render->DrawDropDownArrow(this, dc);
1118
int wxPageContainer::HitTest(const wxPoint& pt, wxPageInfo& pageInfo, int &tabIdx)
1120
wxFNBRendererPtr render = wxFNBRendererMgrST::Get()->GetRenderer( GetParent()->GetWindowStyleFlag() );
1122
wxRect rect = GetClientRect();
1123
int btnLeftPos = render->GetLeftButtonPos(this);
1124
int btnRightPos = render->GetRightButtonPos(this);
1125
int btnXPos =render->GetXPos(this);
1126
long style = GetParent()->GetWindowStyleFlag();
1129
if(m_pagesInfoVec.IsEmpty())
1131
return wxFNB_NOWHERE;
1134
rect = wxRect(btnXPos, 8, 16, 16);
1135
if(InsideRect(rect, pt))
1137
return (style & wxFNB_NO_X_BUTTON) ? wxFNB_NOWHERE : wxFNB_X;
1140
rect = wxRect(btnRightPos, 8, 16, 16);
1141
if( style & wxFNB_DROPDOWN_TABS_LIST )
1143
rect = wxRect(render->GetDropArrowButtonPos( this ), 8, 16, 16);
1144
if(InsideRect(rect, pt))
1145
return wxFNB_DROP_DOWN_ARROW;
1148
if(InsideRect(rect, pt))
1150
return (style & wxFNB_NO_NAV_BUTTONS) ? wxFNB_NOWHERE : wxFNB_RIGHT_ARROW;
1154
rect = wxRect(btnLeftPos, 8, 16, 16);
1155
if(InsideRect(rect, pt))
1157
return (style & wxFNB_NO_NAV_BUTTONS) ? wxFNB_NOWHERE : wxFNB_LEFT_ARROW;
1160
// Test whether a left click was made on a tab
1161
bool bFoundMatch = false;
1162
for(size_t cur=m_nFrom; cur<m_pagesInfoVec.GetCount(); cur++)
1164
wxPageInfo pgInfo = m_pagesInfoVec[cur];
1165
if(pgInfo.GetPosition() == wxPoint(-1, -1))
1168
// check for mouse over tab's x button
1169
if(style & wxFNB_X_ON_TAB && (int)cur == GetSelection())
1171
// 'x' button exists on a tab
1172
if(InsideRect(m_pagesInfoVec[cur].GetXRect(), pt))
1180
if(style & wxFNB_VC8)
1182
if(m_pagesInfoVec[cur].GetRegion().Contains(pt) == wxInRegion)
1184
if(bFoundMatch || (int)cur == GetSelection())
1198
wxRect tabRect = wxRect(pgInfo.GetPosition().x, pgInfo.GetPosition().y,
1199
pgInfo.GetSize().x, pgInfo.GetSize().y);
1201
if(InsideRect(tabRect, pt))
1215
return wxFNB_NOWHERE;
1218
void wxPageContainer::SetSelection(size_t page)
1220
wxFlatNotebook* book = (wxFlatNotebook*)GetParent();
1221
book->SetSelection(page);
1222
DoSetSelection(page);
1225
void wxPageContainer::DoSetSelection(size_t page)
1227
// Make sure that the selection is visible
1228
if(page < m_pagesInfoVec.GetCount())
1230
//! fix for tabfocus
1231
wxWindow* da_page = ((wxFlatNotebook *)m_pParent)->GetPage(page);
1232
if ( da_page!=NULL )
1233
da_page->SetFocus();
1236
if( !IsTabVisible(page) )
1238
FNB_LOG_MSG( wxT("Tab ") << (int)page << wxT(" is not visible"));
1239
FNB_LOG_MSG( wxT("m_nFrom=") << m_nFrom << wxT(", Selection=") << (int)page );
1241
// Try to remove one tab from start and try again
1242
if( !CanFitToScreen(page) )
1244
if( m_nFrom > (int)page )
1245
m_nFrom = (int)page;
1248
while( m_nFrom < (int)page )
1251
if( CanFitToScreen(page) )
1255
FNB_LOG_MSG( wxT("Adjusting m_nFrom to=") << m_nFrom);
1260
FNB_LOG_MSG( wxT("Tab ") << (int)page << wxT(" is visible"));
1262
PushPageHistory((int)page);
1266
void wxPageContainer::DeletePage(size_t page)
1268
wxFlatNotebook* book = (wxFlatNotebook*)GetParent();
1269
book->DeletePage(page);
1273
bool wxPageContainer::IsTabVisible(size_t page)
1275
int iPage = (int)page;
1276
int iLastVisiblePage = GetLastVisibleTab();
1278
return iPage <= iLastVisiblePage && iPage >= m_nFrom;
1281
int wxPageContainer::GetPreviousSelection() const
1283
if(m_history.empty()){
1286
//return the top of the heap
1287
return m_history.Item(0);
1290
void wxPageContainer::DoDeletePage(size_t page)
1292
// Remove the page from the vector
1293
wxFlatNotebook* book = (wxFlatNotebook*)GetParent();
1295
PopPageHistory((int)page);
1297
// same thing with the active page
1298
if (m_iActivePage > (int)page || (int)page >= (int)(m_pagesInfoVec.Count())){
1300
}else if (m_iActivePage == (int)page){
1301
m_iActivePage = GetPreviousSelection();
1302
//PopPageHistory(m_iActivePage);
1305
m_pagesInfoVec.RemoveAt(page);
1307
if(m_iActivePage == wxNOT_FOUND && m_pagesInfoVec.Count() > 0){
1312
book->SetForceSelection(true);
1313
book->SetSelection(m_iActivePage);
1314
book->SetForceSelection(false);
1316
if(m_pagesInfoVec.empty())
1318
// Erase the page container drawings
1319
wxClientDC dc(this);
1324
void wxPageContainer::DeleteAllPages()
1329
m_pagesInfoVec.Clear();
1331
// Erase the page container drawings
1332
wxClientDC dc(this);
1336
void wxPageContainer::OnMouseMove(wxMouseEvent& event)
1338
if (!m_pagesInfoVec.empty() && IsShown())
1340
const int xButtonStatus = m_nXButtonStatus;
1341
const int xTabButtonStatus = m_nTabXButtonStatus;
1342
const int rightButtonStatus = m_nRightButtonStatus;
1343
const int leftButtonStatus = m_nLeftButtonStatus;
1344
const int dropDownButtonStatus = m_nArrowDownButtonStatus;
1346
long style = GetParent()->GetWindowStyleFlag();
1348
m_nXButtonStatus = wxFNB_BTN_NONE;
1349
m_nRightButtonStatus = wxFNB_BTN_NONE;
1350
m_nLeftButtonStatus = wxFNB_BTN_NONE;
1351
m_nTabXButtonStatus = wxFNB_BTN_NONE;
1352
m_nArrowDownButtonStatus = wxFNB_BTN_NONE;
1357
int where = HitTest(event.GetPosition(), pgInfo, tabIdx);
1361
if (event.LeftIsDown())
1363
m_nXButtonStatus = (m_nLeftClickZone==wxFNB_X) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
1367
m_nXButtonStatus = wxFNB_BTN_HOVER;
1370
case wxFNB_DROP_DOWN_ARROW:
1371
if (event.LeftIsDown())
1373
m_nArrowDownButtonStatus = (m_nLeftClickZone == wxFNB_DROP_DOWN_ARROW) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
1377
m_nArrowDownButtonStatus = wxFNB_BTN_HOVER;
1381
if (event.LeftIsDown())
1383
m_nTabXButtonStatus = (m_nLeftClickZone==wxFNB_TAB_X) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
1387
m_nTabXButtonStatus = wxFNB_BTN_HOVER;
1390
case wxFNB_RIGHT_ARROW:
1391
if (event.LeftIsDown())
1393
m_nRightButtonStatus = (m_nLeftClickZone==wxFNB_RIGHT_ARROW) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
1397
m_nRightButtonStatus = wxFNB_BTN_HOVER;
1401
case wxFNB_LEFT_ARROW:
1402
if (event.LeftIsDown())
1404
m_nLeftButtonStatus = (m_nLeftClickZone==wxFNB_LEFT_ARROW) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
1408
m_nLeftButtonStatus = wxFNB_BTN_HOVER;
1413
// Call virtual method for showing tooltip
1414
ShowTabTooltip(tabIdx);
1415
if(!GetEnabled((size_t)tabIdx))
1417
// Set the cursor to be 'No-entry'
1418
::wxSetCursor(wxCURSOR_NO_ENTRY);
1421
// Support for drag and drop
1422
if(event.Dragging() && !(style & wxFNB_NODRAG))
1424
wxFNBDragInfo draginfo(this, tabIdx);
1425
wxFNBDragInfoDataObject dataobject(wxDataFormat(wxT("wxFNB")));
1426
dataobject.SetData(sizeof(wxFNBDragInfo), &draginfo);
1427
wxFNBDropSource dragSource(this);
1428
dragSource.SetData(dataobject);
1429
dragSource.DoDragDrop(wxDrag_DefaultMove);
1433
m_nTabXButtonStatus = wxFNB_BTN_NONE;
1437
const bool bRedrawX = m_nXButtonStatus != xButtonStatus;
1438
const bool bRedrawDropArrow = m_nArrowDownButtonStatus != dropDownButtonStatus;
1439
const bool bRedrawRight = m_nRightButtonStatus != rightButtonStatus;
1440
const bool bRedrawLeft = m_nLeftButtonStatus != leftButtonStatus;
1441
const bool bRedrawTabX = m_nTabXButtonStatus != xTabButtonStatus;
1443
wxFNBRendererPtr render = wxFNBRendererMgrST::Get()->GetRenderer( GetParent()->GetWindowStyleFlag() );
1445
if (bRedrawX || bRedrawRight || bRedrawLeft || bRedrawTabX || bRedrawDropArrow)
1447
wxClientDC dc(this);
1450
render->DrawX(this, dc);
1454
render->DrawLeftArrow(this, dc);
1458
render->DrawRightArrow(this, dc);
1462
render->DrawTabX(this, dc, pgInfo.GetXRect(), tabIdx, m_nTabXButtonStatus);
1464
if (bRedrawDropArrow)
1466
render->DrawDropDownArrow(this, dc);
1473
int wxPageContainer::GetLastVisibleTab()
1479
for(i=m_nFrom; i<(int)m_pagesInfoVec.GetCount(); i++)
1481
if(m_pagesInfoVec[i].GetPosition() == wxPoint(-1, -1))
1487
int wxPageContainer::GetNumTabsCanScrollLeft()
1489
if( m_nFrom - 1 >= 0){
1496
bool wxPageContainer::IsDefaultTabs()
1498
long style = GetParent()->GetWindowStyleFlag();
1499
bool res = (style & wxFNB_VC71) || (style & wxFNB_FANCY_TABS) || (style & wxFNB_VC8);
1503
void wxPageContainer::AdvanceSelection(bool bForward)
1505
int nSel = GetSelection();
1510
int nMax = (int)GetPageCount() - 1;
1512
SetSelection(nSel == nMax ? 0 : nSel + 1);
1514
SetSelection(nSel == 0 ? nMax : nSel - 1);
1518
void wxPageContainer::OnMouseLeave(wxMouseEvent& event)
1520
m_nLeftButtonStatus = wxFNB_BTN_NONE;
1521
m_nXButtonStatus = wxFNB_BTN_NONE;
1522
m_nRightButtonStatus = wxFNB_BTN_NONE;
1523
m_nTabXButtonStatus = wxFNB_BTN_NONE;
1524
m_nArrowDownButtonStatus = wxFNB_BTN_NONE;
1526
long style = GetParent()->GetWindowStyleFlag();
1527
wxFNBRendererPtr render = wxFNBRendererMgrST::Get()->GetRenderer(style);
1529
wxClientDC dc(this);
1530
render->DrawX(this, dc);
1531
render->DrawLeftArrow(this, dc);
1532
render->DrawRightArrow(this, dc);
1533
if(GetSelection() != -1 && IsTabVisible((size_t)GetSelection()))
1535
render->DrawTabX(this, dc, m_pagesInfoVec[GetSelection()].GetXRect(), GetSelection(), m_nTabXButtonStatus);
1541
void wxPageContainer::OnMouseEnterWindow(wxMouseEvent& event)
1543
m_nLeftButtonStatus = wxFNB_BTN_NONE;
1544
m_nXButtonStatus = wxFNB_BTN_NONE;
1545
m_nRightButtonStatus = wxFNB_BTN_NONE;
1546
m_nLeftClickZone = wxFNB_BTN_NONE;
1547
m_nArrowDownButtonStatus = wxFNB_BTN_NONE;
1552
void wxPageContainer::ShowTabTooltip(int tabIdx)
1554
wxWindow *pWindow = ((wxFlatNotebook *)m_pParent)->GetPage(tabIdx);
1557
wxToolTip *pToolTip = pWindow->GetToolTip();
1558
if(pToolTip && pToolTip->GetWindow() == pWindow)
1559
SetToolTip(pToolTip->GetTip());
1563
void wxPageContainer::SetPageImageIndex(size_t page, int imgindex)
1565
if(page < m_pagesInfoVec.GetCount())
1567
m_pagesInfoVec[page].SetImageIndex(imgindex);
1572
int wxPageContainer::GetPageImageIndex(size_t page)
1574
if(page < m_pagesInfoVec.GetCount())
1576
return m_pagesInfoVec[page].GetImageIndex();
1581
wxDragResult wxPageContainer::OnDropTarget(wxCoord x, wxCoord y, int nTabPage, wxWindow * wnd_oldContainer)
1583
// Disable drag'n'drop for disabled tab
1584
if(!((wxPageContainer *)wnd_oldContainer)->m_pagesInfoVec[nTabPage].GetEnabled())
1585
return wxDragCancel;
1587
wxLogTrace(wxTraceMask(), _("Old Page Index = %i"), nTabPage);
1588
wxPageContainer * oldContainer = (wxPageContainer *)wnd_oldContainer;
1591
int where = HitTest(wxPoint(x, y), pgInfo, nIndex);
1592
wxLogTrace(wxTraceMask(), _("OnDropTarget: index by HitTest = %i"), nIndex);
1593
wxFlatNotebook * oldNotebook = (wxFlatNotebook *)oldContainer->GetParent();
1594
wxFlatNotebook * newNotebook = (wxFlatNotebook *)GetParent();
1596
if(oldNotebook == newNotebook)
1603
MoveTabPage(nTabPage, nIndex);
1614
else if ( GetParent()->GetWindowStyleFlag() & wxFNB_ALLOW_FOREIGN_DND )
1616
#if defined(__WXMSW__) || defined(__WXGTK__)
1619
wxWindow * window = oldNotebook->GetPage(nTabPage);
1622
wxString caption = oldContainer->GetPageText(nTabPage);
1624
// Pass the image to the new container
1625
// incase that the new container (this) does not have image list we dont pass the image
1626
// to the new notebook
1627
int newIndx( wxNOT_FOUND );
1631
int imageindex = oldContainer->GetPageImageIndex(nTabPage);
1632
if( imageindex >= 0 )
1634
wxBitmap bmp( (*oldContainer->GetImageList())[imageindex] );
1635
m_ImageList->Add( bmp );
1636
newIndx = static_cast<int>(m_ImageList->GetCount() - 1);
1640
oldNotebook->RemovePage( nTabPage );
1641
window->Reparent( newNotebook );
1642
newNotebook->InsertPage(nIndex, window, caption, true, newIndx);
1650
void wxPageContainer::MoveTabPage(int nMove, int nMoveTo)
1652
if(nMove == nMoveTo)
1655
else if(nMoveTo < (int)((wxFlatNotebook *)m_pParent)->GetWindows().GetCount())
1658
m_pParent->Freeze();
1659
// Remove the window from the main sizer
1660
int nCurSel = ((wxFlatNotebook *)m_pParent)->GetPages()->GetSelection();
1661
((wxFlatNotebook *)m_pParent)->GetMainSizer()->Detach(((wxFlatNotebook *)m_pParent)->GetWindows().Item(nCurSel));
1662
((wxFlatNotebook *)m_pParent)->GetWindows().Item(nCurSel)->Hide();
1664
wxWindow *pWindow = ((wxFlatNotebook *)m_pParent)->GetWindows().Item(nMove);
1665
((wxFlatNotebook *)m_pParent)->GetWindows().RemoveAt(nMove);
1666
((wxFlatNotebook *)m_pParent)->GetWindows().Insert(pWindow, nMoveTo-1);
1668
wxPageInfo pgInfo = m_pagesInfoVec[nMove];
1670
m_pagesInfoVec.RemoveAt( nMove );
1671
m_pagesInfoVec.Insert(pgInfo, nMoveTo - 1);
1673
// Add the page according to the style
1674
wxBoxSizer* pSizer = ((wxFlatNotebook *)m_pParent)->GetMainSizer();
1675
long style = GetParent()->GetWindowStyleFlag();
1678
if(style & wxFNB_BOTTOM)
1680
pSizer->Insert(0, pWindow, 1, wxEXPAND);
1684
// We leave a space of 1 pixel around the window
1685
pSizer->Add(pWindow, 1, wxEXPAND);
1690
m_iActivePage = nMoveTo-1;
1692
DoSetSelection(m_iActivePage);
1696
bool wxPageContainer::CanFitToScreen(size_t page)
1698
// Incase the from is greater than page,
1699
// we need to reset the m_nFrom, so in order
1700
// to force the caller to do so, we return false
1701
if(m_nFrom > (int)page)
1704
long style = GetParent()->GetWindowStyleFlag();
1705
wxFNBRendererPtr render = wxFNBRendererMgrST::Get()->GetRenderer(style);
1706
std::vector<wxRect> vTabInfo;
1707
render->NumberTabsCanFit( this, vTabInfo );
1709
if(static_cast<int>(page) - m_nFrom >= static_cast<int>( vTabInfo.size() ))
1714
int wxPageContainer::GetNumOfVisibleTabs()
1718
for(; i<(int)m_pagesInfoVec.GetCount(); i++, ++counter)
1720
if(m_pagesInfoVec[i].GetPosition() == wxPoint(-1, -1))
1726
bool wxPageContainer::GetEnabled(size_t page)
1728
if(page >= m_pagesInfoVec.GetCount())
1729
return true; // Seems strange, but this is the default
1730
return m_pagesInfoVec[page].GetEnabled();
1733
void wxPageContainer::Enable(size_t page, bool enabled)
1735
if(page >= m_pagesInfoVec.GetCount())
1737
m_pagesInfoVec[page].Enable(enabled);
1741
wxColor wxPageContainer::GetSingleLineBorderColor()
1743
if(HasFlag(wxFNB_FANCY_TABS))
1748
bool wxPageContainer::HasFlag(int flag)
1750
long style = GetParent()->GetWindowStyleFlag();
1751
bool res = style & flag ? true : false;
1755
void wxPageContainer::ClearFlag(int flag)
1757
long style = GetParent()->GetWindowStyleFlag();
1759
wxWindowBase::SetWindowStyleFlag(style);
1762
bool wxPageContainer::TabHasImage(int tabIdx)
1765
return m_pagesInfoVec[tabIdx].GetImageIndex() != -1;
1769
void wxPageContainer::OnLeftDClick(wxMouseEvent& event)
1773
int where = HitTest(event.GetPosition(), pgInfo, tabIdx);
1776
case wxFNB_RIGHT_ARROW:
1779
case wxFNB_LEFT_ARROW:
1783
if(HasFlag(wxFNB_DCLICK_CLOSES_TABS))
1785
DeletePage((size_t)tabIdx);
1799
void wxPageContainer::PopupTabsMenu()
1803
for(size_t i=0; i<m_pagesInfoVec.GetCount(); i++)
1805
wxPageInfo pi = m_pagesInfoVec[i];
1806
wxMenuItem *item = new wxMenuItem(&popupMenu, static_cast<int>(i), pi.GetCaption(), pi.GetCaption(), wxITEM_NORMAL);
1808
// This code is commented, since there is an alignment problem with wx2.6.3 & Menus
1809
// if( TabHasImage(static_cast<int>(i)) )
1810
// item->SetBitmaps( (*m_ImageList)[pi.GetImageIndex()] );
1812
popupMenu.Append( item );
1815
// connect an event handler to our menu
1816
popupMenu.Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(wxPageContainer::OnTabMenuSelection), NULL, this);
1817
PopupMenu( &popupMenu );
1820
void wxPageContainer::OnTabMenuSelection(wxCommandEvent &event)
1822
int selection = event.GetId();
1823
static_cast<wxFlatNotebook*>(m_pParent)->SetSelection( (size_t)selection );
1826
// Draw small arrow at the place that the tab will be placed
1827
void wxPageContainer::DrawDragHint()
1829
// get the index of tab that will be replaced with the dragged tab
1832
wxPoint pt = ::wxGetMousePosition();
1833
wxPoint client_pt = ScreenToClient(pt);
1834
HitTest(client_pt, info, tabIdx);
1835
wxFNBRendererMgrST::Get()->GetRenderer( GetParent()->GetWindowStyleFlag() )->DrawDragHint(this, tabIdx);
1838
void wxPageContainer::SetCustomizeOptions(long options)
1840
m_customizeOptions = options;
1843
long wxPageContainer::GetCustomizeOptions() const
1845
return m_customizeOptions;