projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wxhtml.rc no longer needed
[wxWidgets.git]
/
src
/
generic
/
notebook.cpp
diff --git
a/src/generic/notebook.cpp
b/src/generic/notebook.cpp
index cced371845ef035489a48a284af27651eab531f9..5cb54f9c67cf4179267703dfd363146f32fd4968 100644
(file)
--- a/
src/generic/notebook.cpp
+++ b/
src/generic/notebook.cpp
@@
-27,11
+27,12
@@
#pragma hdrstop
#endif
#pragma hdrstop
#endif
-#include <wx/string.h>
-#include <wx/log.h>
-#include <wx/imaglist.h>
-#include <wx/generic/notebook.h>
-#include <wx/dcclient.h>
+#include "wx/string.h"
+#include "wx/log.h"
+#include "wx/settings.h"
+#include "wx/generic/imaglist.h"
+#include "wx/notebook.h"
+#include "wx/dcclient.h"
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// macros
@@
-44,7
+45,9
@@
// event table
// ----------------------------------------------------------------------------
// event table
// ----------------------------------------------------------------------------
-#if !USE_SHARED_LIBRARIES
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
+
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize)
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize)
@@
-52,12
+55,11
@@
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_MOUSE_EVENTS(wxNotebook::OnMouseEvent)
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
EVT_MOUSE_EVENTS(wxNotebook::OnMouseEvent)
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
- EVT_IDLE(wxNotebook::OnIdle)
+
//
EVT_IDLE(wxNotebook::OnIdle)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
-#endif
// ============================================================================
// implementation
// ============================================================================
// implementation
@@
-71,7
+73,6
@@
IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
void wxNotebook::Init()
{
m_tabView = (wxNotebookTabView*) NULL;
void wxNotebook::Init()
{
m_tabView = (wxNotebookTabView*) NULL;
- m_pImageList = NULL;
m_nSelection = -1;
}
m_nSelection = -1;
}
@@
-108,9
+109,11
@@
bool wxNotebook::Create(wxWindow *parent,
m_windowId = id == -1 ? NewControlId() : id;
// It's like a normal window...
m_windowId = id == -1 ? NewControlId() : id;
// It's like a normal window...
- if (!wxWindow::Create(parent, id, pos, size, style, name))
+ if (!wxWindow::Create(parent, id, pos, size, style
|wxNO_BORDER
, name))
return FALSE;
return FALSE;
+ SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
+
SetTabView(new wxNotebookTabView(this));
return TRUE;
SetTabView(new wxNotebookTabView(this));
return TRUE;
@@
-125,11
+128,6
@@
wxNotebook::~wxNotebook()
// ----------------------------------------------------------------------------
// wxNotebook accessors
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxNotebook accessors
// ----------------------------------------------------------------------------
-int wxNotebook::GetPageCount() const
-{
- return m_aPages.Count();
-}
-
int wxNotebook::GetRowCount() const
{
// TODO
int wxNotebook::GetRowCount() const
{
// TODO
@@
-143,14
+141,18
@@
int wxNotebook::SetSelection(int nPage)
wxASSERT( IS_VALID_PAGE(nPage) );
wxASSERT( IS_VALID_PAGE(nPage) );
+#if defined (__WIN16__)
+ m_tabView->SetTabSelection(nPage);
+#else
wxNotebookPage* pPage = GetPage(nPage);
m_tabView->SetTabSelection((int) (long) pPage);
wxNotebookPage* pPage = GetPage(nPage);
m_tabView->SetTabSelection((int) (long) pPage);
-
+#endif
// TODO
return 0;
}
// TODO
return 0;
}
+#if 0
void wxNotebook::AdvanceSelection(bool bForward)
{
int nSel = GetSelection();
void wxNotebook::AdvanceSelection(bool bForward)
{
int nSel = GetSelection();
@@
-160,11
+162,16
@@
void wxNotebook::AdvanceSelection(bool bForward)
else
SetSelection(nSel == 0 ? nMax : nSel - 1);
}
else
SetSelection(nSel == 0 ? nMax : nSel - 1);
}
+#endif
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
{
wxASSERT( IS_VALID_PAGE(nPage) );
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
{
wxASSERT( IS_VALID_PAGE(nPage) );
-
+#if defined (__WIN16__)
+ m_tabView->SetTabText(nPage, strText);
+ Refresh();
+ return TRUE;
+#else
wxNotebookPage* page = GetPage(nPage);
if (page)
{
wxNotebookPage* page = GetPage(nPage);
if (page)
{
@@
-172,7
+179,7
@@
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
Refresh();
return TRUE;
}
Refresh();
return TRUE;
}
-
+#endif
return FALSE;
}
return FALSE;
}
@@
-180,11
+187,15
@@
wxString wxNotebook::GetPageText(int nPage) const
{
wxASSERT( IS_VALID_PAGE(nPage) );
{
wxASSERT( IS_VALID_PAGE(nPage) );
+#if defined (__WIN16__)
+ return m_tabView->GetTabText(nPage);
+#else
wxNotebookPage* page = ((wxNotebook*)this)->GetPage(nPage);
if (page)
return m_tabView->GetTabText((int) (long) page);
else
return wxEmptyString;
wxNotebookPage* page = ((wxNotebook*)this)->GetPage(nPage);
if (page)
return m_tabView->GetTabText((int) (long) page);
else
return wxEmptyString;
+#endif
}
int wxNotebook::GetPageImage(int nPage) const
}
int wxNotebook::GetPageImage(int nPage) const
@@
-203,9
+214,21
@@
bool wxNotebook::SetPageImage(int nPage, int nImage)
return FALSE;
}
return FALSE;
}
-void wxNotebook::SetImageList(wxImageList* imageList)
-{
- m_pImageList = imageList;
+// set the size (the same for all pages)
+void wxNotebook::SetPageSize(const wxSize& size)
+{
+ // TODO
+}
+
+// set the padding between tabs (in pixels)
+void wxNotebook::SetPadding(const wxSize& padding)
+{
+ // TODO
+}
+
+// set the size of the tabs for wxNB_FIXEDWIDTH controls
+void wxNotebook::SetTabSize(const wxSize& sz)
+{
// TODO
}
// TODO
}
@@
-220,17
+243,21
@@
bool wxNotebook::DeletePage(int nPage)
if (m_nSelection != -1)
{
if (m_nSelection != -1)
{
- m_
aP
ages[m_nSelection]->Show(FALSE);
- m_
aP
ages[m_nSelection]->Lower();
+ m_
p
ages[m_nSelection]->Show(FALSE);
+ m_
p
ages[m_nSelection]->Lower();
}
wxNotebookPage* pPage = GetPage(nPage);
}
wxNotebookPage* pPage = GetPage(nPage);
+#if defined (__WIN16__)
+ m_tabView->RemoveTab(nPage);
+#else
m_tabView->RemoveTab((int) (long) pPage);
m_tabView->RemoveTab((int) (long) pPage);
+#endif
-
delete m_aPages[nPage]
;
-
m_aPages.Remove(nPage)
;
+
m_pages.Remove(pPage)
;
+
delete pPage
;
- if (m_
aP
ages.GetCount() == 0)
+ if (m_
p
ages.GetCount() == 0)
{
m_nSelection = -1;
m_tabView->SetTabSelection(-1, FALSE);
{
m_nSelection = -1;
m_tabView->SetTabSelection(-1, FALSE);
@@
-238,7
+265,11
@@
bool wxNotebook::DeletePage(int nPage)
else if (m_nSelection > -1)
{
m_nSelection = -1;
else if (m_nSelection > -1)
{
m_nSelection = -1;
+#if defined (__WIN16__)
+ m_tabView->SetTabSelection(0, FALSE);
+#else
m_tabView->SetTabSelection((int) (long) GetPage(0), FALSE);
m_tabView->SetTabSelection((int) (long) GetPage(0), FALSE);
+#endif
if (m_nSelection != 0)
ChangePage(-1, 0);
}
if (m_nSelection != 0)
ChangePage(-1, 0);
}
@@
-262,15
+293,19
@@
bool wxNotebook::RemovePage(int nPage)
{
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
{
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
- m_
aP
ages[nPage]->Show(FALSE);
- // m_
aP
ages[nPage]->Lower();
+ m_
p
ages[nPage]->Show(FALSE);
+ // m_
p
ages[nPage]->Lower();
wxNotebookPage* pPage = GetPage(nPage);
wxNotebookPage* pPage = GetPage(nPage);
+#if defined (__WIN16__)
+ m_tabView->RemoveTab(nPage);
+#else
m_tabView->RemoveTab((int) (long) pPage);
m_tabView->RemoveTab((int) (long) pPage);
+#endif
- m_
aPages.Remove(n
Page);
+ m_
pages.Remove(p
Page);
- if (m_
aP
ages.GetCount() == 0)
+ if (m_
p
ages.GetCount() == 0)
{
m_nSelection = -1;
m_tabView->SetTabSelection(-1, TRUE);
{
m_nSelection = -1;
m_tabView->SetTabSelection(-1, TRUE);
@@
-315,7
+350,7
@@
int wxNotebook::FindPagePosition(wxNotebookPage* page) const
int nPageCount = GetPageCount();
int nPage;
for ( nPage = 0; nPage < nPageCount; nPage++ )
int nPageCount = GetPageCount();
int nPage;
for ( nPage = 0; nPage < nPageCount; nPage++ )
- if (m_
aP
ages[nPage] == page)
+ if (m_
p
ages[nPage] == page)
return nPage;
return -1;
}
return nPage;
return -1;
}
@@
-328,22
+363,13
@@
bool wxNotebook::DeleteAllPages()
int nPageCount = GetPageCount();
int nPage;
for ( nPage = 0; nPage < nPageCount; nPage++ )
int nPageCount = GetPageCount();
int nPage;
for ( nPage = 0; nPage < nPageCount; nPage++ )
- delete m_
aP
ages[nPage];
+ delete m_
p
ages[nPage];
- m_
aP
ages.Clear();
+ m_
p
ages.Clear();
return TRUE;
}
return TRUE;
}
-// add a page to the notebook
-bool wxNotebook::AddPage(wxNotebookPage *pPage,
- const wxString& strText,
- bool bSelect,
- int imageId)
-{
- return InsertPage(GetPageCount(), pPage, strText, bSelect, imageId);
-}
-
// same as AddPage() but does it at given position
bool wxNotebook::InsertPage(int nPage,
wxNotebookPage *pPage,
// same as AddPage() but does it at given position
bool wxNotebook::InsertPage(int nPage,
wxNotebookPage *pPage,
@@
-354,17
+380,26
@@
bool wxNotebook::InsertPage(int nPage,
wxASSERT( pPage != NULL );
wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
wxASSERT( pPage != NULL );
wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
+// For 16 bit integers (tabs limited to 32768)
+#if defined (__WIN16__)
+ m_tabView->AddTab(nPage, strText);
+#else
m_tabView->AddTab((int) (long) pPage, strText);
m_tabView->AddTab((int) (long) pPage, strText);
+#endif
if (!bSelect)
pPage->Show(FALSE);
// save the pointer to the page
if (!bSelect)
pPage->Show(FALSE);
// save the pointer to the page
- m_
aP
ages.Insert(pPage, nPage);
+ m_
p
ages.Insert(pPage, nPage);
if (bSelect)
{
// This will cause ChangePage to be called, via OnSelPage
if (bSelect)
{
// This will cause ChangePage to be called, via OnSelPage
+#if defined (__WIN16__)
+ m_tabView->SetTabSelection(nPage, TRUE);
+#else
m_tabView->SetTabSelection((int) (long) pPage, TRUE);
m_tabView->SetTabSelection((int) (long) pPage, TRUE);
+#endif
}
// some page must be selected: either this one or the first one if there is
}
// some page must be selected: either this one or the first one if there is
@@
-441,10
+476,10
@@
bool wxNotebook::RefreshLayout(bool force)
rect.y = tabHeight + 4;
rect.width = cw - 8;
rect.height = ch - 4 - rect.y ;
rect.y = tabHeight + 4;
rect.width = cw - 8;
rect.height = ch - 4 - rect.y ;
-
+
m_tabView->SetViewRect(rect);
m_tabView->SetViewRect(rect);
- m_tabView->Layout();
+ m_tabView->Layout
Tabs
();
// Need to do it a 2nd time to get the tab height with
// the new view width, since changing the view width changes the
// Need to do it a 2nd time to get the tab height with
// the new view width, since changing the view width changes the
@@
-454,19
+489,19
@@
bool wxNotebook::RefreshLayout(bool force)
rect.y = tabHeight + 4;
rect.width = cw - 8;
rect.height = ch - 4 - rect.y ;
rect.y = tabHeight + 4;
rect.width = cw - 8;
rect.height = ch - 4 - rect.y ;
-
+
m_tabView->SetViewRect(rect);
m_tabView->SetViewRect(rect);
- m_tabView->Layout();
+ m_tabView->Layout
Tabs
();
if (!force && (rect == oldRect))
return FALSE;
// fit the notebook page to the tab control's display area
if (!force && (rect == oldRect))
return FALSE;
// fit the notebook page to the tab control's display area
- unsigned int nCount = m_
aP
ages.Count();
+ unsigned int nCount = m_
p
ages.Count();
for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
- wxNotebookPage *pPage = m_
aP
ages[nPage];
+ wxNotebookPage *pPage = m_
p
ages[nPage];
if (pPage->IsShown())
{
wxRect clientRect = GetAvailableClientSize();
if (pPage->IsShown())
{
wxRect clientRect = GetAvailableClientSize();
@@
-497,7
+532,7
@@
void wxNotebook::OnSetFocus(wxFocusEvent& event)
{
// set focus to the currently selected page if any
if ( m_nSelection != -1 )
{
// set focus to the currently selected page if any
if ( m_nSelection != -1 )
- m_
aP
ages[m_nSelection]->SetFocus();
+ m_
p
ages[m_nSelection]->SetFocus();
event.Skip();
}
event.Skip();
}
@@
-534,7
+569,7
@@
bool wxNotebook::DoPhase(int /* nPhase */)
return TRUE;
}
return TRUE;
}
-void wxNotebook::Command(wxCommandEvent&
event
)
+void wxNotebook::Command(wxCommandEvent&
WXUNUSED(event)
)
{
wxFAIL_MSG("wxNotebook::Command not implemented");
}
{
wxFAIL_MSG("wxNotebook::Command not implemented");
}
@@
-550,21
+585,21
@@
void wxNotebook::ChangePage(int nOldSel, int nSel)
wxASSERT( nOldSel != nSel ); // impossible
if ( nOldSel != -1 ) {
wxASSERT( nOldSel != nSel ); // impossible
if ( nOldSel != -1 ) {
- m_
aP
ages[nOldSel]->Show(FALSE);
- m_
aP
ages[nOldSel]->Lower();
+ m_
p
ages[nOldSel]->Show(FALSE);
+ m_
p
ages[nOldSel]->Lower();
}
}
- wxNotebookPage *pPage = m_
aP
ages[nSel];
+ wxNotebookPage *pPage = m_
p
ages[nSel];
wxRect clientRect = GetAvailableClientSize();
pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height);
wxRect clientRect = GetAvailableClientSize();
pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height);
+ Refresh();
+
pPage->Show(TRUE);
pPage->Raise();
pPage->SetFocus();
pPage->Show(TRUE);
pPage->Raise();
pPage->SetFocus();
- Refresh();
-
m_nSelection = nSel;
}
m_nSelection = nSel;
}
@@
-601,7
+636,7
@@
wxRect wxNotebook::GetAvailableClientSize()
/*
* wxNotebookTabView
*/
/*
* wxNotebookTabView
*/
-
+
IMPLEMENT_CLASS(wxNotebookTabView, wxTabView)
wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style): wxTabView(style)
IMPLEMENT_CLASS(wxNotebookTabView, wxTabView)
wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style): wxTabView(style)
@@
-625,6
+660,10
@@
void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId)
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId());
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId());
+#if defined (__WIN16__)
+ int activatePos = activateId;
+ int deactivatePos = deactivateId;
+#else
// Translate from wxTabView's ids (which aren't position-dependent)
// to wxNotebook's (which are).
wxNotebookPage* pActive = (wxNotebookPage*) activateId;
// Translate from wxTabView's ids (which aren't position-dependent)
// to wxNotebook's (which are).
wxNotebookPage* pActive = (wxNotebookPage*) activateId;
@@
-633,6
+672,7
@@
void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId)
int activatePos = m_notebook->FindPagePosition(pActive);
int deactivatePos = m_notebook->FindPagePosition(pDeactive);
int activatePos = m_notebook->FindPagePosition(pActive);
int deactivatePos = m_notebook->FindPagePosition(pDeactive);
+#endif
event.SetEventObject(m_notebook);
event.SetSelection(activatePos);
event.SetOldSelection(deactivatePos);
event.SetEventObject(m_notebook);
event.SetSelection(activatePos);
event.SetOldSelection(deactivatePos);