CW5.2 Pro Adaptions, wxMac starting to move in
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4366 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#include <wx/log.h>
|
||||
#include <wx/imaglist.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
#include <wx/mac/uma.h>
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -32,6 +32,11 @@
|
||||
// check that the page index is valid
|
||||
#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
|
||||
|
||||
const short kwxMacTabLeftMargin = 16 ;
|
||||
const short kwxMacTabTopMargin = 30 ;
|
||||
const short kwxMacTabRightMargin = 16 ;
|
||||
const short kwxMacTabBottomMargin = 16 ;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// event table
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -91,21 +96,16 @@ bool wxNotebook::Create(wxWindow *parent,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
// base init
|
||||
SetName(name);
|
||||
SetParent(parent);
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
|
||||
MacPreControlCreate( parent , id , "" , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ;
|
||||
|
||||
m_windowId = id == -1 ? NewControlId() : id;
|
||||
|
||||
// style
|
||||
m_windowStyle = style;
|
||||
|
||||
if ( parent != NULL )
|
||||
parent->AddChild(this);
|
||||
|
||||
// TODO
|
||||
|
||||
return FALSE;
|
||||
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1,
|
||||
kControlTabSmallProc , (long) this ) ;
|
||||
|
||||
MacPostControlCreate() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
// dtor
|
||||
@@ -123,8 +123,7 @@ int wxNotebook::GetPageCount() const
|
||||
|
||||
int wxNotebook::GetRowCount() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int wxNotebook::SetSelection(int nPage)
|
||||
@@ -132,9 +131,11 @@ int wxNotebook::SetSelection(int nPage)
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
|
||||
ChangePage(m_nSelection, nPage);
|
||||
|
||||
// TODO
|
||||
return 0;
|
||||
SetControlValue( m_macControl , m_nSelection + 1 ) ;
|
||||
// Boolean enabled = true ;
|
||||
|
||||
// SetControlData( m_macControl, m_nSelection + 1, kControlTabEnabledFlagTag, sizeof( Boolean ), (Ptr)&enabled );
|
||||
return m_nSelection;
|
||||
}
|
||||
|
||||
void wxNotebook::AdvanceSelection(bool bForward)
|
||||
@@ -246,7 +247,19 @@ bool wxNotebook::InsertPage(int nPage,
|
||||
wxASSERT( pPage != NULL );
|
||||
wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
|
||||
|
||||
// TODO: insert native widget page
|
||||
ControlTabInfoRec tie ;
|
||||
Boolean enabled = true ;
|
||||
if ( nPage + 1 > GetControlMaximum( m_macControl ) )
|
||||
{
|
||||
SetControlMaximum( m_macControl , nPage + 1 ) ;
|
||||
}
|
||||
|
||||
tie.version = 0 ;
|
||||
tie.iconSuiteID = 0 ;
|
||||
strcpy( (char*) tie.name , strText ) ;
|
||||
c2pstr( (char*) tie.name ) ;
|
||||
SetControlData( m_macControl, nPage + 1, kControlTabInfoTag , sizeof( ControlTabInfoRec) , (char*) &tie ) ;
|
||||
SetControlData( m_macControl, m_nSelection + 1, kControlTabEnabledFlagTag, sizeof( Boolean ), (Ptr)&enabled );
|
||||
|
||||
// save the pointer to the page
|
||||
m_aPages.Insert(pPage, nPage);
|
||||
@@ -258,6 +271,9 @@ bool wxNotebook::InsertPage(int nPage,
|
||||
else if ( m_nSelection == -1 )
|
||||
m_nSelection = 0;
|
||||
|
||||
// don't show pages by default (we'll need to adjust their size first)
|
||||
pPage->Show( FALSE ) ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -290,7 +306,9 @@ void wxNotebook::OnSize(wxSizeEvent& event)
|
||||
unsigned int nCount = m_aPages.Count();
|
||||
for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
|
||||
wxNotebookPage *pPage = m_aPages[nPage];
|
||||
pPage->SetSize(0, 0, w, h);
|
||||
pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin, w - kwxMacTabLeftMargin - kwxMacTabRightMargin,
|
||||
h - kwxMacTabTopMargin - kwxMacTabBottomMargin );
|
||||
// pPage->SetSize(0, 0, w, h);
|
||||
if ( pPage->GetAutoLayout() )
|
||||
pPage->Layout();
|
||||
}
|
||||
@@ -362,7 +380,16 @@ void wxNotebook::Command(wxCommandEvent& event)
|
||||
// hide the currently active panel and show the new one
|
||||
void wxNotebook::ChangePage(int nOldSel, int nSel)
|
||||
{
|
||||
wxASSERT( nOldSel != nSel ); // impossible
|
||||
// it's not an error (the message may be generated by the tab control itself)
|
||||
// and it may happen - just do nothing
|
||||
if ( nSel == nOldSel )
|
||||
{
|
||||
wxNotebookPage *pPage = m_aPages[nSel];
|
||||
pPage->Show(FALSE);
|
||||
pPage->Show(TRUE);
|
||||
pPage->SetFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( nOldSel != -1 ) {
|
||||
m_aPages[nOldSel]->Show(FALSE);
|
||||
@@ -375,3 +402,11 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
|
||||
m_nSelection = nSel;
|
||||
}
|
||||
|
||||
void wxNotebook::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||
{
|
||||
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControlValue(m_macControl) - 1, m_nSelection);
|
||||
event.SetEventObject(this);
|
||||
|
||||
ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user