Menu

[r7]: / Plugin / custom_tabcontainer.h  Maximize  Restore  History

Download this file

209 lines (171 with data), 5.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : custom_tabcontainer.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef __wxtabcontainer__
#define __wxtabcontainer__
#include "wx/panel.h"
#include <wx/dynarray.h>
#include "dropbutton.h"
class CustomTab;
class wxMenu;
class wxTabContainer : public wxPanel
{
int m_orientation;
wxSizer* m_tabsSizer;
CustomTab* m_draggedTab;
wxArrayPtrVoid m_history;
wxMenu * m_rightClickMenu;
int m_bmpHeight;
size_t m_fixedTabWidth;
friend class CustomTab;
protected:
void Initialize();
//add page to history
void PushPageHistory(CustomTab *page);
//remove page from the history by its value
//after the page removal, all items in the history
//are updated if needed
void PopPageHistory(CustomTab *page);
bool DoRemoveTab(CustomTab *deleteTab, bool deleteIt, bool notify = false);
void EnsureVisible(CustomTab *tab);
bool IsVisible(CustomTab *tab, bool fullShown = true);
/**
* @brief return the index of the first visible tab
*/
size_t GetFirstVisibleTab();
/**
* @brief return the index of the last visible tab
*/
size_t GetLastVisibleTab();
/**
* @brief show maximum tabs as possible.
*/
void DoShowMaxTabs();
public:
wxTabContainer(wxWindow *win, wxWindowID id = wxID_ANY, int orientation = wxLEFT, long style = 0);
virtual ~wxTabContainer();
void AddTab(CustomTab *tab);
CustomTab *GetSelection();
void SetSelection(CustomTab *tab, bool notify = false);
CustomTab *IndexToTab(size_t page);
size_t TabToIndex(CustomTab *tab);
size_t GetTabsCount();
void SetRightClickMenu(wxMenu* rightClickMenu) {
this->m_rightClickMenu = rightClickMenu;
}
wxMenu* GetRightClickMenu() {
return m_rightClickMenu;
}
void Resize();
/**
* @brief delete tab from the tab container (also destroying it)
* @param deleteTab tab to delete
* @param notify set this to true if you wish to receive wxEVT_COMMAND_BOOK_PAGE_CLOSING & wxEVT_COMMAND_BOOK_PAGE_CLOSED
* @return true if notification sent but vetoed by user, else false
*/
bool DeletePage(CustomTab *deleteTab, bool notify);
/**
* @brief remove tab from the tab container (the tab will *not* be destroyed)
* @param removePage tab to remove
* @param notify set this to true if you wish to receive wxEVT_COMMAND_BOOK_PAGE_CLOSING & wxEVT_COMMAND_BOOK_PAGE_CLOSED
* @return true if notification sent but vetoed by user, else false
*/
bool RemovePage(CustomTab *removePage, bool notify);
/**
* @brief return previous selection
* @return previous selection, or NULL if history list is empty
*/
CustomTab* GetPreviousSelection();
/**
* @brief set tab as being dragged
* @param tab
*/
void SetDraggedTab(CustomTab *tab);
/**
* @brief swap tab with the dragged one
* @param tab swap dragged tab this one
*/
void SwapTabs(CustomTab *tab);
/**
* @brief get tab being dragged, if any
* @return tab being dragged
*/
const CustomTab* GetDraggedTab() const {
return m_draggedTab;
}
/**
* @brief set the fixed tab width
* @param size in pixels
*/
void SetFixedTabWidth(const size_t& fixedTabWidth);
/**
* @brief return the fixed tab width in pixels
*/
size_t GetFixedTabWidth() const {
return m_fixedTabWidth;
}
int GetBookStyle();
void SetOrientation(const int& orientation) ;
const int& GetOrientation() const {
return m_orientation;
}
void ShowPopupMenu();
void SetHistory(const wxArrayPtrVoid& history) {
this->m_history = history;
}
const wxArrayPtrVoid& GetHistory() const {
return m_history;
}
void SetBmpHeight(int height);
int GetBmpHeight() const;
static void DoDrawBackground(wxDC &dc, bool gradient, int orientation, const wxRect &rr);
static void DoDrawMargin(wxDC &dc, int orientation, const wxRect &rr);
DECLARE_EVENT_TABLE()
virtual void OnPaint(wxPaintEvent &e);
virtual void OnEraseBg(wxEraseEvent &e);
virtual void OnSizeEvent(wxSizeEvent &e);
virtual void OnLeaveWindow(wxMouseEvent &e);
virtual void OnLeftUp(wxMouseEvent &e);
virtual void OnDeleteTab(wxCommandEvent &e);
virtual void OnDoubleClick(wxMouseEvent &e);
};
//--------------------------------------------------------------------
// Dropbutton class used for the notebook
//--------------------------------------------------------------------
class DropButton : public DropButtonBase
{
private:
wxTabContainer *m_tabContainer;
protected:
size_t GetItemCount();
wxString GetItem(size_t n);
bool IsItemSelected(size_t n);
public:
DropButton(wxWindow *parent, wxTabContainer *tabContainer);
~DropButton();
virtual void OnMenuSelection(wxCommandEvent &e);
virtual void OnPaint(wxPaintEvent &e);
virtual void OnLeftDown(wxMouseEvent &e);
};
#endif // __wxtabcontainer__
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.