wxMac (debug) builds and runs wxMinimal again

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4463 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
1999-11-10 11:32:00 +00:00
parent 944930d5f5
commit 51abe921b8
33 changed files with 1116 additions and 156 deletions

View File

@@ -53,7 +53,7 @@ struct WXDLLEXPORT wxNativeEncodingInfo
{ {
wxString facename; // may be empty meaning "any" wxString facename; // may be empty meaning "any"
#if defined(__WXMSW__) || defined(__WXPM__) #if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__)
wxNativeEncodingInfo() { charset = 0; /* ANSI_CHARSET */ } wxNativeEncodingInfo() { charset = 0; /* ANSI_CHARSET */ }
int charset; int charset;

View File

@@ -133,16 +133,7 @@ public:
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
int GetFontId() const;
virtual bool IsFree() const;
virtual bool RealizeResource(); virtual bool RealizeResource();
virtual WXHANDLE GetResourceHandle();
virtual bool FreeResource(bool force = FALSE);
void MacInstall() const ;
/*
virtual bool UseResource();
virtual bool ReleaseResource();
*/
protected: protected:
// common part of all ctors // common part of all ctors

View File

@@ -104,11 +104,6 @@ public:
int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
#endif // wxUSE_OWNER_DRAWN #endif // wxUSE_OWNER_DRAWN
// Windows-specific code to set the horizontal extent of the listbox, if
// necessary. If s is non-NULL, it's used to calculate the horizontal
// extent. Otherwise, all strings are used.
virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
// Windows callbacks // Windows callbacks
virtual void SetupColours(); virtual void SetupColours();

View File

@@ -22,6 +22,7 @@ WXDLLEXPORT_DATA(extern const char*) wxRadioBoxNameStr;
// List box item // List box item
class WXDLLEXPORT wxBitmap ; class WXDLLEXPORT wxBitmap ;
class WXDLLEXPORT wxRadioButton ;
class WXDLLEXPORT wxRadioBox: public wxControl class WXDLLEXPORT wxRadioBox: public wxControl
{ {
@@ -77,8 +78,7 @@ public:
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
WXHWND *GetRadioButtons() const { return m_radioButtons; } wxRadioButton *GetRadioButtons() const { return m_radioButtons; }
bool ContainsHWND(WXHWND hWnd) const;
void SendNotificationEvent(); void SendNotificationEvent();
// get the number of buttons per column/row // get the number of buttons per column/row
@@ -95,7 +95,7 @@ public:
protected: protected:
void SubclassRadioButton(WXHWND hWndBtn); void SubclassRadioButton(WXHWND hWndBtn);
WXHWND * m_radioButtons; wxRadioButton * m_radioButtons;
int m_majorDim; int m_majorDim;
int * m_radioWidth; // for bitmaps int * m_radioWidth; // for bitmaps
int * m_radioHeight; int * m_radioHeight;

View File

@@ -187,7 +187,7 @@
// if enabled, compiles built-in OS independent wxConfig // if enabled, compiles built-in OS independent wxConfig
// class and it's file (any platform) and registry (Win) // class and it's file (any platform) and registry (Win)
// based implementations // based implementations
#define wxUSE_THREADS 1 #define wxUSE_THREADS 0
// support for multithreaded applications: if // support for multithreaded applications: if
// 1, compile in thread classes (thread.h) // 1, compile in thread classes (thread.h)
// and make the library thread safe // and make the library thread safe
@@ -205,7 +205,7 @@
#define wxUSE_TOOLTIPS 1 #define wxUSE_TOOLTIPS 1
// Define to use wxToolTip class and // Define to use wxToolTip class and
// wxWindow::SetToolTip() method // wxWindow::SetToolTip() method
#define wxUSE_SOCKETS 1 // 0 #define wxUSE_SOCKETS 0 // 0
// Set to 1 to use socket classes // Set to 1 to use socket classes
#define wxUSE_HTML 1 // 0 #define wxUSE_HTML 1 // 0
// Set to 1 to use wxHTML sub-library // Set to 1 to use wxHTML sub-library
@@ -306,7 +306,7 @@
#define wxUSE_PENWINDOWS 0 #define wxUSE_PENWINDOWS 0
// Set to 1 to use PenWindows // Set to 1 to use PenWindows
#define wxUSE_OWNER_DRAWN 1 #define wxUSE_OWNER_DRAWN 0
// Owner-drawn menus and listboxes // Owner-drawn menus and listboxes
#define wxUSE_NATIVE_STATUSBAR 1 #define wxUSE_NATIVE_STATUSBAR 1

View File

@@ -155,8 +155,6 @@ public:
// Native resource loading (implemented in src/msw/nativdlg.cpp) // Native resource loading (implemented in src/msw/nativdlg.cpp)
// FIXME: should they really be all virtual? // FIXME: should they really be all virtual?
virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
wxWindow* GetWindowChild1(wxWindowID id); wxWindow* GetWindowChild1(wxWindowID id);
wxWindow* GetWindowChild(wxWindowID id); wxWindow* GetWindowChild(wxWindowID id);
@@ -209,12 +207,6 @@ public:
virtual void MSWDeviceToLogical(float *x, float *y) const; virtual void MSWDeviceToLogical(float *x, float *y) const;
#endif // WXWIN_COMPATIBILITY #endif // WXWIN_COMPATIBILITY
// Create an appropriate wxWindow from a HWND
virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
// Make sure the window style reflects the HWND style (roughly)
virtual void AdoptAttributesFromHWND();
// Setup background and foreground colours correctly // Setup background and foreground colours correctly
virtual void SetupColours(); virtual void SetupColours();

View File

@@ -66,6 +66,8 @@ protected:
#include "wx/gtk/statline.h" #include "wx/gtk/statline.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/statline.h" #include "wx/os2/statline.h"
#elif defined(__WXMAC__)
#include "wx/mac/statline.h"
#else // use generic implementation for all other platforms #else // use generic implementation for all other platforms
#include "wx/generic/statline.h" #include "wx/generic/statline.h"
#endif #endif

View File

@@ -82,6 +82,11 @@
IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject)
#endif #endif
#ifdef __WXMAC__
#define mm2pt 2.83464566929
#define pt2mm 0.352777777778
#endif
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
@@ -166,6 +171,8 @@ wxPrintData::wxPrintData()
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
m_devMode = NULL; m_devMode = NULL;
#elif defined( __WXMAC__ )
m_macPrintInfo = NULL ;
#endif #endif
m_printOrientation = wxPORTRAIT; m_printOrientation = wxPORTRAIT;
m_printNoCopies = 1; m_printNoCopies = 1;
@@ -207,6 +214,9 @@ wxPrintData::~wxPrintData()
HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode; HGLOBAL hDevMode = (HGLOBAL)(DWORD) m_devMode;
if (hDevMode ) if (hDevMode )
GlobalFree(hDevMode); GlobalFree(hDevMode);
#elif defined(__WXMAC__)
if ( m_macPrintInfo )
::DisposeHandle( (Handle) m_macPrintInfo ) ;
#endif #endif
} }
@@ -593,6 +603,35 @@ void wxPrintData::ConvertFromNative()
#endif #endif
#ifdef __WXMAC__
void wxPrintData::ConvertToNative()
{
if ( !m_macPrintInfo )
{
m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
if ( m_macPrintInfo )
{
::PrintDefault( m_macPrintInfo ) ;
// todo setup the global pagesetup ?
}
}
if ( m_macPrintInfo )
{
(**m_macPrintInfo).prJob.iCopies = m_printNoCopies ;
(**m_macPrintInfo).prJob.iFstPage = 0 ;
(**m_macPrintInfo).prJob.iLstPage = 0 ;
}
}
void wxPrintData::ConvertFromNative()
{
if ( m_macPrintInfo )
{
m_printNoCopies = (**m_macPrintInfo).prJob.iCopies ;
}
}
#endif
void wxPrintData::operator=(const wxPrintData& data) void wxPrintData::operator=(const wxPrintData& data)
{ {
m_printNoCopies = data.m_printNoCopies; m_printNoCopies = data.m_printNoCopies;
@@ -679,6 +718,8 @@ wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData)
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
m_printDlgData = NULL; m_printDlgData = NULL;
#elif defined( __WXMAC__ )
m_macPrintInfo = NULL ;
#endif #endif
m_printFromPage = 0; m_printFromPage = 0;
m_printToPage = 0; m_printToPage = 0;
@@ -706,6 +747,9 @@ wxPrintDialogData::~wxPrintDialogData()
GlobalFree(pd->hDevMode); GlobalFree(pd->hDevMode);
if ( pd ) if ( pd )
delete pd; delete pd;
#elif defined(__WXMAC__)
if ( m_macPrintInfo )
::DisposeHandle( (Handle) m_macPrintInfo ) ;
#endif #endif
} }
@@ -861,6 +905,38 @@ void wxPrintDialogData::SetOwnerWindow(wxWindow* win)
} }
#endif // MSW #endif // MSW
#ifdef __WXMAC__
void wxPrintDialogData::ConvertToNative()
{
if ( !m_macPrintInfo )
{
m_macPrintInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
if ( m_macPrintInfo )
{
::PrintDefault( m_macPrintInfo ) ;
// todo setup the global pagesetup ?
}
}
if ( m_macPrintInfo )
{
(**m_macPrintInfo).prJob.iCopies = m_printNoCopies ;
(**m_macPrintInfo).prJob.iFstPage = m_printFromPage ;
(**m_macPrintInfo).prJob.iLstPage = m_printToPage ;
}
}
void wxPrintDialogData::ConvertFromNative()
{
if ( m_macPrintInfo )
{
m_printNoCopies = (**m_macPrintInfo).prJob.iCopies ;
m_printFromPage = (**m_macPrintInfo).prJob.iFstPage ;
m_printToPage = (**m_macPrintInfo).prJob.iLstPage ;
}
}
#endif
void wxPrintDialogData::operator=(const wxPrintDialogData& data) void wxPrintDialogData::operator=(const wxPrintDialogData& data)
{ {
m_printFromPage = data.m_printFromPage; m_printFromPage = data.m_printFromPage;
@@ -894,6 +970,8 @@ wxPageSetupDialogData::wxPageSetupDialogData()
{ {
#if defined(__WIN95__) #if defined(__WIN95__)
m_pageSetupData = NULL; m_pageSetupData = NULL;
#elif defined( __WXMAC__ )
m_macPageSetupInfo = NULL ;
#endif #endif
m_paperSize = wxSize(0, 0); m_paperSize = wxSize(0, 0);
@@ -923,6 +1001,8 @@ wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData)
{ {
#if defined(__WIN95__) #if defined(__WIN95__)
m_pageSetupData = NULL; m_pageSetupData = NULL;
#elif defined( __WXMAC__ )
m_macPageSetupInfo = NULL ;
#endif #endif
m_paperSize = wxSize(0, 0); m_paperSize = wxSize(0, 0);
m_minMarginTopLeft = wxPoint(0, 0); m_minMarginTopLeft = wxPoint(0, 0);
@@ -954,6 +1034,9 @@ wxPageSetupDialogData::~wxPageSetupDialogData()
GlobalFree(pd->hDevMode); GlobalFree(pd->hDevMode);
if ( pd ) if ( pd )
delete pd; delete pd;
#elif defined( __WXMAC__ )
if( m_macPageSetupInfo )
::DisposeHandle( (Handle) m_macPageSetupInfo ) ;
#endif #endif
} }
@@ -1126,6 +1209,69 @@ void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win)
} }
#endif // Win95 #endif // Win95
#ifdef __WXMAC__
void wxPageSetupData::ConvertToNative()
{
if ( !m_macPageSetupInfo )
{
m_macPageSetupInfo = (THPrint) NewHandleClear( sizeof( TPrint ) ) ;
if ( m_macPageSetupInfo )
{
::PrintDefault( m_macPageSetupInfo ) ;
}
}
if ( m_macPageSetupInfo )
{
// on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
(**m_macPageSetupInfo).rPaper.left = int( ((double) m_minMarginTopLeft.x)*mm2pt ) ;
(**m_macPageSetupInfo).rPaper.top = int( ((double) m_minMarginTopLeft.y)*mm2pt ) ;
(**m_macPageSetupInfo).rPaper.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x)*mm2pt ) ;
(**m_macPageSetupInfo).rPaper.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y)*mm2pt ) ;
(**m_macPageSetupInfo).prInfo.rPage.left = 0 ;
(**m_macPageSetupInfo).prInfo.rPage.top = 0 ;
(**m_macPageSetupInfo).prInfo.rPage.right = int( ((double) m_paperSize.x - m_minMarginTopLeft.x - m_minMarginBottomRight.x)*mm2pt ) ;
(**m_macPageSetupInfo).prInfo.rPage.bottom = int( ((double) m_paperSize.y - m_minMarginTopLeft.y - m_minMarginBottomRight.y)*mm2pt ) ;
//TODO add custom fields in dialog for margins
}
}
void wxPageSetupData::ConvertFromNative()
{
if ( m_macPageSetupInfo )
{
m_paperSize.x = ((double) (**m_macPageSetupInfo).rPaper.right - (**m_macPageSetupInfo).rPaper.left ) * pt2mm ;
m_paperSize.y = ((double) (**m_macPageSetupInfo).rPaper.bottom - (**m_macPageSetupInfo).rPaper.top ) * pt2mm ;
m_minMarginTopLeft.x = ((double) -(**m_macPageSetupInfo).rPaper.left ) * pt2mm ;
m_minMarginTopLeft.y = ((double) -(**m_macPageSetupInfo).rPaper.top ) * pt2mm ;
m_minMarginBottomRight.x = ((double) (**m_macPageSetupInfo).rPaper.right - (**m_macPageSetupInfo).prInfo.rPage.right ) * pt2mm ;
m_minMarginBottomRight.y = ((double)(**m_macPageSetupInfo).rPaper.bottom - (**m_macPageSetupInfo).prInfo.rPage.bottom ) * pt2mm ;
// adjust minimal values
//TODO add custom fields in dialog for margins
if ( m_marginTopLeft.x < m_minMarginTopLeft.x )
m_marginTopLeft.x = m_minMarginTopLeft.x ;
if ( m_marginBottomRight.x < m_minMarginBottomRight.x )
m_marginBottomRight.x = m_minMarginBottomRight.x ;
if ( m_marginTopLeft.y < m_minMarginTopLeft.y )
m_marginTopLeft.y = m_minMarginTopLeft.y ;
if ( m_marginBottomRight.y < m_minMarginBottomRight.y )
m_marginBottomRight.y = m_minMarginBottomRight.y ;
}
}
#endif
// If a corresponding paper type is found in the paper database, will set the m_printData // If a corresponding paper type is found in the paper database, will set the m_printData
// paper size id member as well. // paper size id member as well.
void wxPageSetupDialogData::SetPaperSize(const wxSize& sz) void wxPageSetupDialogData::SetPaperSize(const wxSize& sz)

View File

@@ -26,9 +26,11 @@
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/app.h" #include "wx/app.h"
#include "wx/debug.h" #include "wx/debug.h"
#include "wx/module.h"
#endif #endif
#include "wx/module.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global vars // global vars
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -50,7 +50,7 @@ extern wxList wxPendingDelete;
extern wxList *wxWinMacWindowList; extern wxList *wxWinMacWindowList;
extern wxList *wxWinMacControlList; extern wxList *wxWinMacControlList;
wxApp *wxTheApp = NULL; extern wxApp *wxTheApp ;
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)

View File

@@ -66,6 +66,14 @@ void wxButton::SetDefault()
} }
} }
wxSize wxButton::DoGetBestSize()
{
int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder;
int hBtn = 13 + 2 * m_macVerticalBorder;
return wxSize(wBtn, hBtn);
}
void wxButton::Command (wxCommandEvent & event) void wxButton::Command (wxCommandEvent & event)
{ {
ProcessCommand (event); ProcessCommand (event);

View File

@@ -50,7 +50,7 @@ extern wxList wxPendingDelete;
extern wxList *wxWinMacWindowList; extern wxList *wxWinMacWindowList;
extern wxList *wxWinMacControlList; extern wxList *wxWinMacControlList;
wxApp *wxTheApp = NULL; extern wxApp *wxTheApp ;
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)

View File

@@ -66,6 +66,14 @@ void wxButton::SetDefault()
} }
} }
wxSize wxButton::DoGetBestSize()
{
int wBtn = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder;
int hBtn = 13 + 2 * m_macVerticalBorder;
return wxSize(wBtn, hBtn);
}
void wxButton::Command (wxCommandEvent & event) void wxButton::Command (wxCommandEvent & event)
{ {
ProcessCommand (event); ProcessCommand (event);

View File

@@ -587,6 +587,14 @@ void wxControl::OnPaint(wxPaintEvent& event)
// wxWindow::OnPaint( event ) ; // wxWindow::OnPaint( event ) ;
} }
} }
void wxControl::OnEraseBackground(wxEraseEvent& event)
{
// In general, you don't want to erase the background of a control,
// or you'll get a flicker.
// TODO: move this 'null' function into each control that
// might flicker.
}
void wxControl::OnKeyDown( wxKeyEvent &event ) void wxControl::OnKeyDown( wxKeyEvent &event )
{ {

View File

@@ -119,7 +119,7 @@ const char *wxButtonBarNameStr = "buttonbar";
const char *wxEnhDialogNameStr = "Shell"; const char *wxEnhDialogNameStr = "Shell";
const char *wxToolBarNameStr = "toolbar"; const char *wxToolBarNameStr = "toolbar";
const char *wxStatusLineNameStr = "status_line"; const char *wxStatusLineNameStr = "status_line";
const char *wxEmptyString = "";
const char *wxGetTextFromUserPromptStr = "Input Text"; const char *wxGetTextFromUserPromptStr = "Input Text";
const char *wxMessageBoxCaptionStr = "Message"; const char *wxMessageBoxCaptionStr = "Message";
const char *wxFileSelectorPromptStr = "Select a file"; const char *wxFileSelectorPromptStr = "Select a file";

View File

@@ -44,6 +44,8 @@ END_EVENT_TABLE()
wxDialog::wxDialog() wxDialog::wxDialog()
{ {
m_isShown = FALSE;
m_modalShowing = FALSE;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
} }
@@ -55,7 +57,12 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
const wxString& name) const wxString& name)
{ {
m_windowStyle = style; m_windowStyle = style;
m_isShown = FALSE;
m_modalShowing = FALSE;
#if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
SetName(name); SetName(name);
@@ -165,15 +172,36 @@ void wxDialog::OnCharHook(wxKeyEvent& event)
void wxDialog::Iconize(bool WXUNUSED(iconize)) void wxDialog::Iconize(bool WXUNUSED(iconize))
{ {
// TODO // mac dialogs cannot be iconized
} }
bool wxDialog::IsIconized() const bool wxDialog::IsIconized() const
{ {
// TODO // mac dialogs cannot be iconized
return FALSE; return FALSE;
} }
void wxDialog::DoSetClientSize(int width, int height)
{
wxWindow::DoSetClientSize( width , height ) ;
}
void wxDialog::GetPosition(int *x, int *y) const
{
DoGetPosition( x , y ) ;
}
bool wxDialog::IsShown() const
{
return m_isShown;
}
bool wxDialog::IsModal() const
{
return wxModalDialogs.Find((wxDialog *)this) != 0; // const_cast
}
extern bool s_macIsInModalLoop ; extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show) bool wxDialog::Show(bool show)
@@ -255,6 +283,44 @@ bool wxDialog::Show(bool show)
return TRUE ; return TRUE ;
} }
void wxDialog::SetTitle(const wxString& title)
{
wxWindow::SetTitle( title ) ;
}
wxString wxDialog::GetTitle() const
{
return wxWindow::GetTitle() ;
}
void wxDialog::Centre(int direction)
{
int x_offset,y_offset ;
int display_width, display_height;
int width, height, x, y;
wxWindow *parent = GetParent();
if ((direction & wxCENTER_FRAME) && parent)
{
parent->GetPosition(&x_offset,&y_offset) ;
parent->GetSize(&display_width,&display_height) ;
}
else
{
wxDisplaySize(&display_width, &display_height);
x_offset = 0 ;
y_offset = 0 ;
}
GetSize(&width, &height);
GetPosition(&x, &y);
if (direction & wxHORIZONTAL)
x = (int)((display_width - width)/2);
if (direction & wxVERTICAL)
y = (int)((display_height - height)/2);
SetSize(x+x_offset, y+y_offset, width, height);
}
// Replacement for Show(TRUE) for modal dialogs - returns return code // Replacement for Show(TRUE) for modal dialogs - returns return code
int wxDialog::ShowModal() int wxDialog::ShowModal()
@@ -267,7 +333,6 @@ int wxDialog::ShowModal()
void wxDialog::EndModal(int retCode) void wxDialog::EndModal(int retCode)
{ {
SetReturnCode(retCode); SetReturnCode(retCode);
// TODO modal un-showing
Show(FALSE); Show(FALSE);
} }
@@ -346,7 +411,8 @@ void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event))
{ {
// if we're using constraints - do use them // if we're using constraints - do use them
#if wxUSE_CONSTRAINTS #if wxUSE_CONSTRAINTS
if ( GetAutoLayout() ) { if ( GetAutoLayout() )
{
Layout(); Layout();
} }
#endif #endif

View File

@@ -149,6 +149,15 @@ bool wxFont::RealizeResource()
return TRUE; return TRUE;
} }
void wxFont::SetEncoding(wxFontEncoding encoding)
{
Unshare();
M_FONTDATA->m_encoding = encoding;
RealizeResource();
}
void wxFont::Unshare() void wxFont::Unshare()
{ {
// Don't change shared data // Don't change shared data
@@ -232,11 +241,6 @@ int wxFont::GetFamily() const
return M_FONTDATA->m_family; return M_FONTDATA->m_family;
} }
int wxFont::GetFontId() const
{
return M_FONTDATA->m_fontId;
}
int wxFont::GetStyle() const int wxFont::GetStyle() const
{ {
return M_FONTDATA->m_style; return M_FONTDATA->m_style;

View File

@@ -57,6 +57,7 @@ wxFrame::wxFrame()
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
m_iconized = FALSE; m_iconized = FALSE;
m_isShown = FALSE;
} }
bool wxFrame::Create(wxWindow *parent, bool wxFrame::Create(wxWindow *parent,
@@ -73,6 +74,7 @@ bool wxFrame::Create(wxWindow *parent,
SetName(name); SetName(name);
m_windowStyle = style; m_windowStyle = style;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_isShown = FALSE;
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
m_frameToolBar = NULL ; m_frameToolBar = NULL ;

View File

@@ -156,7 +156,6 @@ void wxListBox::Delete(int N)
m_noItems --; m_noItems --;
MacDelete( N ) ; MacDelete( N ) ;
SetHorizontalExtent("");
} }
int wxListBox::DoAppend(const wxString& item) int wxListBox::DoAppend(const wxString& item)
@@ -171,8 +170,6 @@ int wxListBox::DoAppend(const wxString& item)
m_noItems ++; m_noItems ++;
MacAppend( item ) ; MacAppend( item ) ;
SetHorizontalExtent(item);
return index ; return index ;
} }
@@ -260,7 +257,6 @@ void wxListBox::Clear()
m_stringArray.Empty() ; m_stringArray.Empty() ;
m_dataArray.Empty() ; m_dataArray.Empty() ;
MacClear() ; MacClear() ;
SetHorizontalExtent();
} }
void wxListBox::SetSelection(int N, bool select) void wxListBox::SetSelection(int N, bool select)
@@ -286,6 +282,11 @@ void *wxListBox::DoGetItemClientData(int N) const
return (void *)m_dataArray[N]; return (void *)m_dataArray[N];
} }
wxClientData *wxListBox::DoGetItemClientObject(int N) const
{
return (wxClientData *) DoGetItemClientData( N ) ;
}
void wxListBox::DoSetItemClientData(int N, void *Client_data) void wxListBox::DoSetItemClientData(int N, void *Client_data)
{ {
wxCHECK_RET( N >= 0 && N < m_noItems, wxCHECK_RET( N >= 0 && N < m_noItems,
@@ -375,6 +376,37 @@ wxSize wxListBox::DoGetBestSize()
return wxSize(100, 100); return wxSize(100, 100);
} }
int wxListBox::GetCount() const
{
return m_noItems;
}
void wxListBox::SetupColours()
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
SetForegroundColour(GetParent()->GetForegroundColour());
}
#if wxUSE_OWNER_DRAWN
class wxListBoxItem : public wxOwnerDrawn
{
public:
wxListBoxItem(const wxString& str = "");
};
wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
{
// no bitmaps/checkmarks
SetMarginWidth(0);
}
wxOwnerDrawn *wxListBox::CreateItem(size_t n)
{
return new wxListBoxItem();
}
#endif //USE_OWNER_DRAWN
// ============================================================================ // ============================================================================
// list box control implementation // list box control implementation

View File

@@ -57,7 +57,7 @@ void wxMacCtoPString(const char* theCString, Str255 thePString);
// remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut // remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut
static void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts ) void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts )
{ {
char *p = (char *) &outMacItemText[1] ; char *p = (char *) &outMacItemText[1] ;
short macModifiers = 0 ; short macModifiers = 0 ;
@@ -117,18 +117,18 @@ static void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutC
++inItemName ; ++inItemName ;
while( *inItemName ) while( *inItemName )
{ {
if (strncmp("Ctrl+", inItemName, 5) == 0) if (strncmp("Ctrl", inItemName, 4) == 0)
{ {
inItemName = inItemName + 5; inItemName = inItemName + 5;
macShortCut = *inItemName; macShortCut = *inItemName;
} }
else if (strncmp("Alt+", inItemName, 4) == 0) else if (strncmp("Alt", inItemName, 3) == 0)
{ {
inItemName = inItemName + 4; inItemName = inItemName + 4;
macModifiers |= kMenuOptionModifier ; macModifiers |= kMenuOptionModifier ;
macShortCut = *inItemName ; macShortCut = *inItemName ;
} }
else if (strncmp("Shift+", inItemName, 6) == 0) else if (strncmp("Shift", inItemName, 5) == 0)
{ {
inItemName = inItemName + 6; inItemName = inItemName + 6;
macModifiers |= kMenuShiftModifier ; macModifiers |= kMenuShiftModifier ;
@@ -602,21 +602,7 @@ wxWindow *wxMenu::GetWindow() const
return NULL; return NULL;
} }
/*
bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
{
menu->SetInvokingWindow(this);
ClientToScreen( &x , &y ) ;
::InsertMenu( menu->m_hMenu , -1 ) ;
long menuResult = ::PopUpMenuSelect(menu->m_hMenu ,y,x, 0) ;
menu->MacMenuSelect( this , TickCount() , HiWord(menuResult) , LoWord(menuResult) ) ;
::DeleteMenu( menu->m_macMenuId ) ;
menu->SetInvokingWindow(NULL);
return TRUE;
}
*/
// helper functions returning the mac menu position for a certain item, note that this is // helper functions returning the mac menu position for a certain item, note that this is
// mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0 // mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0
@@ -682,7 +668,28 @@ bool wxMenu::MacMenuSelect( wxEvtHandler* handler, long when , int macMenuId, in
event.m_timeStamp = when; event.m_timeStamp = when;
event.SetEventObject(handler); event.SetEventObject(handler);
event.SetInt( pItem->GetId() ); event.SetInt( pItem->GetId() );
ProcessCommand( event ) ; {
bool processed = false ;
#if WXWIN_COMPATIBILITY
// Try a callback
if (m_callback)
{
(void) (*(m_callback)) (*this, event);
processed = TRUE;
}
#endif
// Try the menu's event handler
if ( !processed && handler)
{
processed = handler->ProcessEvent(event);
}
// Try the window the menu was popped up from (and up
// through the hierarchy)
if ( !processed && GetInvokingWindow())
processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event);
}
return true ; return true ;
} }
} }
@@ -708,7 +715,27 @@ bool wxMenu::MacMenuSelect( wxEvtHandler* handler, long when , int macMenuId, in
event.m_timeStamp = when; event.m_timeStamp = when;
event.SetEventObject(handler); event.SetEventObject(handler);
event.SetInt( pItem->GetId() ); event.SetInt( pItem->GetId() );
ProcessCommand( event ) ; {
bool processed = false ;
#if WXWIN_COMPATIBILITY
// Try a callback
if (m_callback)
{
(void) (*(m_callback)) (*this, event);
processed = TRUE;
}
#endif
// Try the menu's event handler
if ( !processed && handler)
{
processed = handler->ProcessEvent(event);
}
// Try the window the menu was popped up from (and up
// through the hierarchy)
if ( !processed && GetInvokingWindow())
processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event);
}
return true ; return true ;
} }
} }
@@ -757,6 +784,16 @@ void wxMenuBar::Init()
m_menuBarFrame = NULL; m_menuBarFrame = NULL;
} }
wxMenuBar::wxMenuBar()
{
Init();
}
wxMenuBar::wxMenuBar( long WXUNUSED(style) )
{
Init();
}
wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[]) wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[])
{ {
@@ -790,6 +827,37 @@ void wxMenuBar::Refresh()
DrawMenuBar(); DrawMenuBar();
} }
#if wxUSE_ACCEL
void wxMenuBar::RebuildAccelTable()
{
// merge the accelerators of all menus into one accel table
size_t nAccelCount = 0;
size_t i, count = GetMenuCount();
for ( i = 0; i < count; i++ )
{
nAccelCount += m_menus[i]->GetAccelCount();
}
if ( nAccelCount )
{
wxAcceleratorEntry *accelEntries = new wxAcceleratorEntry[nAccelCount];
nAccelCount = 0;
for ( i = 0; i < count; i++ )
{
nAccelCount += m_menus[i]->CopyAccels(&accelEntries[nAccelCount]);
}
m_accelTable = wxAcceleratorTable(nAccelCount, accelEntries);
delete [] accelEntries;
}
}
#endif // wxUSE_ACCEL
void wxMenuBar::MacInstallMenuBar() void wxMenuBar::MacInstallMenuBar()
{ {
Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ; Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ;
@@ -1051,3 +1119,103 @@ void wxMenuBar::MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId,
} }
} }
wxMenu *wxMenuBar::Remove(size_t pos)
{
wxMenu *menu = wxMenuBarBase::Remove(pos);
if ( !menu )
return NULL;
if ( IsAttached() )
{
if (s_macInstalledMenuBar == this)
{
::DeleteMenu( menu->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
}
menu->Detach();
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accell table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
Refresh();
}
m_titles.Remove(pos);
return menu;
}
bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
{
WXHMENU submenu = menu ? menu->GetHMenu() : 0;
wxCHECK_MSG( submenu, FALSE, wxT("can't append invalid menu to menubar") );
if ( !wxMenuBarBase::Append(menu, title) )
return FALSE;
menu->Attach(this);
m_titles.Add(title);
if ( IsAttached() )
{
if (s_macInstalledMenuBar == this)
{
::InsertMenu( menu->GetHMenu() , 0 ) ;
}
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accell table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
Refresh();
}
return TRUE;
}
// ---------------------------------------------------------------------------
// wxMenuBar searching for menu items
// ---------------------------------------------------------------------------
// Find the itemString in menuString, and return the item id or wxNOT_FOUND
int wxMenuBar::FindMenuItem(const wxString& menuString,
const wxString& itemString) const
{
wxString menuLabel = wxStripMenuCodes(menuString);
size_t count = GetMenuCount();
for ( size_t i = 0; i < count; i++ )
{
wxString title = wxStripMenuCodes(m_titles[i]);
if ( menuString == title )
return m_menus[i]->FindItem(itemString);
}
return wxNOT_FOUND;
}
wxMenuItem *wxMenuBar::FindItem(int id, wxMenu **itemMenu) const
{
if ( itemMenu )
*itemMenu = NULL;
wxMenuItem *item = NULL;
size_t count = GetMenuCount();
for ( size_t i = 0; !item && (i < count); i++ )
{
item = m_menus[i]->FindItem(id, itemMenu);
}
return item;
}

View File

@@ -29,6 +29,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
#endif //USE_SHARED_LIBRARY #endif //USE_SHARED_LIBRARY
void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts ) ;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMenuItem // wxMenuItem
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -63,6 +64,28 @@ wxMenuItem::~wxMenuItem()
{ {
} }
bool wxMenuItem::IsChecked() const
{
return wxMenuItemBase::IsChecked() ;
}
wxString wxMenuItem::GetLabel() const
{
return wxStripMenuCodes(m_text);
}
// accelerators
// ------------
#if wxUSE_ACCEL
wxAcceleratorEntry *wxMenuItem::GetAccel() const
{
return wxGetAccelFromString(GetText());
}
#endif // wxUSE_ACCEL
// misc // misc
// ---- // ----
@@ -140,3 +163,49 @@ void wxMenuItem::Check(bool bDoCheck)
} }
} }
} }
void wxMenuItem::SetText(const wxString& text)
{
// don't do anything if label didn't change
if ( m_text == text )
return;
wxMenuItemBase::SetText(text);
// OWNER_DRAWN_ONLY( wxOwnerDrawn::SetName(text) );
wxCHECK_RET( m_parentMenu && m_parentMenu->GetHMenu(), wxT("menuitem without menu") );
if ( m_parentMenu->GetHMenu() )
{
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
if ( index >= 1 )
{
Str255 label;
wxMacBuildMenuString( label , NULL , NULL , text ,false);
::SetMenuItemText( m_parentMenu->GetHMenu() , index , label ) ; // checkmark
}
}
#if wxUSE_ACCEL
m_parentMenu->UpdateAccel(this);
#endif // wxUSE_ACCEL
}
void wxMenuItem::SetCheckable(bool checkable)
{
wxMenuItemBase::SetCheckable(checkable);
// OWNER_DRAWN_ONLY( wxOwnerDrawn::SetCheckable(checkable) );
}
// ----------------------------------------------------------------------------
// wxMenuItemBase
// ----------------------------------------------------------------------------
wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
int id,
const wxString& name,
const wxString& help,
bool isCheckable,
wxMenu *subMenu)
{
return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu);
}

View File

@@ -126,4 +126,23 @@ void wxSpinButton::MacHandleControlClick( ControlHandle control , SInt16 control
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
// ----------------------------------------------------------------------------
// size calculation
// ----------------------------------------------------------------------------
wxSize wxSpinButton::DoGetBestSize()
{
if ( (GetWindowStyle() & wxSP_VERTICAL) != 0 )
{
// vertical control
return wxSize(16,
2*16);
}
else
{
// horizontal control
return wxSize(2*16,
16);
}
}

View File

@@ -295,6 +295,34 @@ void wxWindow::DoGetPosition(int *x, int *y) const
} }
} }
wxSize wxWindow::DoGetBestSize()
{
return wxSize( 0 , 0 ) ;
}
bool wxWindow::Reparent(wxWindow *parent)
{
if ( !wxWindowBase::Reparent(parent) )
return FALSE;
return TRUE;
}
bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
{
menu->SetInvokingWindow(this);
menu->UpdateUI();
ClientToScreen( &x , &y ) ;
::InsertMenu( menu->GetHMenu() , -1 ) ;
long menuResult = ::PopUpMenuSelect(menu->GetHMenu() ,y,x, 0) ;
menu->MacMenuSelect( this , TickCount() , HiWord(menuResult) , LoWord(menuResult) ) ;
::DeleteMenu( menu->MacGetMenuId() ) ;
menu->SetInvokingWindow(NULL);
return TRUE;
}
void wxWindow::DoScreenToClient(int *x, int *y) const void wxWindow::DoScreenToClient(int *x, int *y) const
{ {
WindowRef window = GetMacRootWindow() ; WindowRef window = GetMacRootWindow() ;
@@ -401,6 +429,28 @@ void wxWindow::DoGetClientSize(int *x, int *y) const
(*y) -= MAC_SCROLLBAR_SIZE; (*y) -= MAC_SCROLLBAR_SIZE;
} }
// ----------------------------------------------------------------------------
// tooltips
// ----------------------------------------------------------------------------
#if wxUSE_TOOLTIPS
void wxWindow::DoSetToolTip(wxToolTip *tooltip)
{
wxWindowBase::DoSetToolTip(tooltip);
// if ( m_tooltip )
// m_tooltip->SetWindow(this);
}
#endif // wxUSE_TOOLTIPS
void wxWindow::DoMoveWindow(int x, int y, int width, int height)
{
DoSetSize( x,y, width, height ) ;
}
void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{ {
int former_x = m_x ; int former_x = m_x ;
@@ -1764,13 +1814,3 @@ wxMacDrawingClientHelper::~wxMacDrawingClientHelper()
if ( m_formerPort != m_currentPort ) if ( m_formerPort != m_currentPort )
SetPort( m_formerPort ) ; SetPort( m_formerPort ) ;
} }
// ----------------------------------------------------------------------------
// list classes implementation
// ----------------------------------------------------------------------------
void wxWindowListNode::DeleteData()
{
delete (wxWindow *)GetData();
}

View File

@@ -587,6 +587,14 @@ void wxControl::OnPaint(wxPaintEvent& event)
// wxWindow::OnPaint( event ) ; // wxWindow::OnPaint( event ) ;
} }
} }
void wxControl::OnEraseBackground(wxEraseEvent& event)
{
// In general, you don't want to erase the background of a control,
// or you'll get a flicker.
// TODO: move this 'null' function into each control that
// might flicker.
}
void wxControl::OnKeyDown( wxKeyEvent &event ) void wxControl::OnKeyDown( wxKeyEvent &event )
{ {

View File

@@ -119,7 +119,7 @@ const char *wxButtonBarNameStr = "buttonbar";
const char *wxEnhDialogNameStr = "Shell"; const char *wxEnhDialogNameStr = "Shell";
const char *wxToolBarNameStr = "toolbar"; const char *wxToolBarNameStr = "toolbar";
const char *wxStatusLineNameStr = "status_line"; const char *wxStatusLineNameStr = "status_line";
const char *wxEmptyString = "";
const char *wxGetTextFromUserPromptStr = "Input Text"; const char *wxGetTextFromUserPromptStr = "Input Text";
const char *wxMessageBoxCaptionStr = "Message"; const char *wxMessageBoxCaptionStr = "Message";
const char *wxFileSelectorPromptStr = "Select a file"; const char *wxFileSelectorPromptStr = "Select a file";

View File

@@ -44,6 +44,8 @@ END_EVENT_TABLE()
wxDialog::wxDialog() wxDialog::wxDialog()
{ {
m_isShown = FALSE;
m_modalShowing = FALSE;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
} }
@@ -55,7 +57,12 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
const wxString& name) const wxString& name)
{ {
m_windowStyle = style; m_windowStyle = style;
m_isShown = FALSE;
m_modalShowing = FALSE;
#if wxUSE_TOOLTIPS
m_hwndToolTip = 0;
#endif
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
SetName(name); SetName(name);
@@ -165,15 +172,36 @@ void wxDialog::OnCharHook(wxKeyEvent& event)
void wxDialog::Iconize(bool WXUNUSED(iconize)) void wxDialog::Iconize(bool WXUNUSED(iconize))
{ {
// TODO // mac dialogs cannot be iconized
} }
bool wxDialog::IsIconized() const bool wxDialog::IsIconized() const
{ {
// TODO // mac dialogs cannot be iconized
return FALSE; return FALSE;
} }
void wxDialog::DoSetClientSize(int width, int height)
{
wxWindow::DoSetClientSize( width , height ) ;
}
void wxDialog::GetPosition(int *x, int *y) const
{
DoGetPosition( x , y ) ;
}
bool wxDialog::IsShown() const
{
return m_isShown;
}
bool wxDialog::IsModal() const
{
return wxModalDialogs.Find((wxDialog *)this) != 0; // const_cast
}
extern bool s_macIsInModalLoop ; extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show) bool wxDialog::Show(bool show)
@@ -255,6 +283,44 @@ bool wxDialog::Show(bool show)
return TRUE ; return TRUE ;
} }
void wxDialog::SetTitle(const wxString& title)
{
wxWindow::SetTitle( title ) ;
}
wxString wxDialog::GetTitle() const
{
return wxWindow::GetTitle() ;
}
void wxDialog::Centre(int direction)
{
int x_offset,y_offset ;
int display_width, display_height;
int width, height, x, y;
wxWindow *parent = GetParent();
if ((direction & wxCENTER_FRAME) && parent)
{
parent->GetPosition(&x_offset,&y_offset) ;
parent->GetSize(&display_width,&display_height) ;
}
else
{
wxDisplaySize(&display_width, &display_height);
x_offset = 0 ;
y_offset = 0 ;
}
GetSize(&width, &height);
GetPosition(&x, &y);
if (direction & wxHORIZONTAL)
x = (int)((display_width - width)/2);
if (direction & wxVERTICAL)
y = (int)((display_height - height)/2);
SetSize(x+x_offset, y+y_offset, width, height);
}
// Replacement for Show(TRUE) for modal dialogs - returns return code // Replacement for Show(TRUE) for modal dialogs - returns return code
int wxDialog::ShowModal() int wxDialog::ShowModal()
@@ -267,7 +333,6 @@ int wxDialog::ShowModal()
void wxDialog::EndModal(int retCode) void wxDialog::EndModal(int retCode)
{ {
SetReturnCode(retCode); SetReturnCode(retCode);
// TODO modal un-showing
Show(FALSE); Show(FALSE);
} }
@@ -346,7 +411,8 @@ void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event))
{ {
// if we're using constraints - do use them // if we're using constraints - do use them
#if wxUSE_CONSTRAINTS #if wxUSE_CONSTRAINTS
if ( GetAutoLayout() ) { if ( GetAutoLayout() )
{
Layout(); Layout();
} }
#endif #endif

View File

@@ -149,6 +149,15 @@ bool wxFont::RealizeResource()
return TRUE; return TRUE;
} }
void wxFont::SetEncoding(wxFontEncoding encoding)
{
Unshare();
M_FONTDATA->m_encoding = encoding;
RealizeResource();
}
void wxFont::Unshare() void wxFont::Unshare()
{ {
// Don't change shared data // Don't change shared data
@@ -232,11 +241,6 @@ int wxFont::GetFamily() const
return M_FONTDATA->m_family; return M_FONTDATA->m_family;
} }
int wxFont::GetFontId() const
{
return M_FONTDATA->m_fontId;
}
int wxFont::GetStyle() const int wxFont::GetStyle() const
{ {
return M_FONTDATA->m_style; return M_FONTDATA->m_style;

View File

@@ -57,6 +57,7 @@ wxFrame::wxFrame()
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_frameStatusBar = NULL; m_frameStatusBar = NULL;
m_iconized = FALSE; m_iconized = FALSE;
m_isShown = FALSE;
} }
bool wxFrame::Create(wxWindow *parent, bool wxFrame::Create(wxWindow *parent,
@@ -73,6 +74,7 @@ bool wxFrame::Create(wxWindow *parent,
SetName(name); SetName(name);
m_windowStyle = style; m_windowStyle = style;
m_frameMenuBar = NULL; m_frameMenuBar = NULL;
m_isShown = FALSE;
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
m_frameToolBar = NULL ; m_frameToolBar = NULL ;

View File

@@ -156,7 +156,6 @@ void wxListBox::Delete(int N)
m_noItems --; m_noItems --;
MacDelete( N ) ; MacDelete( N ) ;
SetHorizontalExtent("");
} }
int wxListBox::DoAppend(const wxString& item) int wxListBox::DoAppend(const wxString& item)
@@ -171,8 +170,6 @@ int wxListBox::DoAppend(const wxString& item)
m_noItems ++; m_noItems ++;
MacAppend( item ) ; MacAppend( item ) ;
SetHorizontalExtent(item);
return index ; return index ;
} }
@@ -260,7 +257,6 @@ void wxListBox::Clear()
m_stringArray.Empty() ; m_stringArray.Empty() ;
m_dataArray.Empty() ; m_dataArray.Empty() ;
MacClear() ; MacClear() ;
SetHorizontalExtent();
} }
void wxListBox::SetSelection(int N, bool select) void wxListBox::SetSelection(int N, bool select)
@@ -286,6 +282,11 @@ void *wxListBox::DoGetItemClientData(int N) const
return (void *)m_dataArray[N]; return (void *)m_dataArray[N];
} }
wxClientData *wxListBox::DoGetItemClientObject(int N) const
{
return (wxClientData *) DoGetItemClientData( N ) ;
}
void wxListBox::DoSetItemClientData(int N, void *Client_data) void wxListBox::DoSetItemClientData(int N, void *Client_data)
{ {
wxCHECK_RET( N >= 0 && N < m_noItems, wxCHECK_RET( N >= 0 && N < m_noItems,
@@ -375,6 +376,37 @@ wxSize wxListBox::DoGetBestSize()
return wxSize(100, 100); return wxSize(100, 100);
} }
int wxListBox::GetCount() const
{
return m_noItems;
}
void wxListBox::SetupColours()
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
SetForegroundColour(GetParent()->GetForegroundColour());
}
#if wxUSE_OWNER_DRAWN
class wxListBoxItem : public wxOwnerDrawn
{
public:
wxListBoxItem(const wxString& str = "");
};
wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
{
// no bitmaps/checkmarks
SetMarginWidth(0);
}
wxOwnerDrawn *wxListBox::CreateItem(size_t n)
{
return new wxListBoxItem();
}
#endif //USE_OWNER_DRAWN
// ============================================================================ // ============================================================================
// list box control implementation // list box control implementation

View File

@@ -57,7 +57,7 @@ void wxMacCtoPString(const char* theCString, Str255 thePString);
// remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut // remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut
static void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts ) void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts )
{ {
char *p = (char *) &outMacItemText[1] ; char *p = (char *) &outMacItemText[1] ;
short macModifiers = 0 ; short macModifiers = 0 ;
@@ -117,18 +117,18 @@ static void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutC
++inItemName ; ++inItemName ;
while( *inItemName ) while( *inItemName )
{ {
if (strncmp("Ctrl+", inItemName, 5) == 0) if (strncmp("Ctrl", inItemName, 4) == 0)
{ {
inItemName = inItemName + 5; inItemName = inItemName + 5;
macShortCut = *inItemName; macShortCut = *inItemName;
} }
else if (strncmp("Alt+", inItemName, 4) == 0) else if (strncmp("Alt", inItemName, 3) == 0)
{ {
inItemName = inItemName + 4; inItemName = inItemName + 4;
macModifiers |= kMenuOptionModifier ; macModifiers |= kMenuOptionModifier ;
macShortCut = *inItemName ; macShortCut = *inItemName ;
} }
else if (strncmp("Shift+", inItemName, 6) == 0) else if (strncmp("Shift", inItemName, 5) == 0)
{ {
inItemName = inItemName + 6; inItemName = inItemName + 6;
macModifiers |= kMenuShiftModifier ; macModifiers |= kMenuShiftModifier ;
@@ -602,21 +602,7 @@ wxWindow *wxMenu::GetWindow() const
return NULL; return NULL;
} }
/*
bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
{
menu->SetInvokingWindow(this);
ClientToScreen( &x , &y ) ;
::InsertMenu( menu->m_hMenu , -1 ) ;
long menuResult = ::PopUpMenuSelect(menu->m_hMenu ,y,x, 0) ;
menu->MacMenuSelect( this , TickCount() , HiWord(menuResult) , LoWord(menuResult) ) ;
::DeleteMenu( menu->m_macMenuId ) ;
menu->SetInvokingWindow(NULL);
return TRUE;
}
*/
// helper functions returning the mac menu position for a certain item, note that this is // helper functions returning the mac menu position for a certain item, note that this is
// mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0 // mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0
@@ -682,7 +668,28 @@ bool wxMenu::MacMenuSelect( wxEvtHandler* handler, long when , int macMenuId, in
event.m_timeStamp = when; event.m_timeStamp = when;
event.SetEventObject(handler); event.SetEventObject(handler);
event.SetInt( pItem->GetId() ); event.SetInt( pItem->GetId() );
ProcessCommand( event ) ; {
bool processed = false ;
#if WXWIN_COMPATIBILITY
// Try a callback
if (m_callback)
{
(void) (*(m_callback)) (*this, event);
processed = TRUE;
}
#endif
// Try the menu's event handler
if ( !processed && handler)
{
processed = handler->ProcessEvent(event);
}
// Try the window the menu was popped up from (and up
// through the hierarchy)
if ( !processed && GetInvokingWindow())
processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event);
}
return true ; return true ;
} }
} }
@@ -708,7 +715,27 @@ bool wxMenu::MacMenuSelect( wxEvtHandler* handler, long when , int macMenuId, in
event.m_timeStamp = when; event.m_timeStamp = when;
event.SetEventObject(handler); event.SetEventObject(handler);
event.SetInt( pItem->GetId() ); event.SetInt( pItem->GetId() );
ProcessCommand( event ) ; {
bool processed = false ;
#if WXWIN_COMPATIBILITY
// Try a callback
if (m_callback)
{
(void) (*(m_callback)) (*this, event);
processed = TRUE;
}
#endif
// Try the menu's event handler
if ( !processed && handler)
{
processed = handler->ProcessEvent(event);
}
// Try the window the menu was popped up from (and up
// through the hierarchy)
if ( !processed && GetInvokingWindow())
processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event);
}
return true ; return true ;
} }
} }
@@ -757,6 +784,16 @@ void wxMenuBar::Init()
m_menuBarFrame = NULL; m_menuBarFrame = NULL;
} }
wxMenuBar::wxMenuBar()
{
Init();
}
wxMenuBar::wxMenuBar( long WXUNUSED(style) )
{
Init();
}
wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[]) wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[])
{ {
@@ -790,6 +827,37 @@ void wxMenuBar::Refresh()
DrawMenuBar(); DrawMenuBar();
} }
#if wxUSE_ACCEL
void wxMenuBar::RebuildAccelTable()
{
// merge the accelerators of all menus into one accel table
size_t nAccelCount = 0;
size_t i, count = GetMenuCount();
for ( i = 0; i < count; i++ )
{
nAccelCount += m_menus[i]->GetAccelCount();
}
if ( nAccelCount )
{
wxAcceleratorEntry *accelEntries = new wxAcceleratorEntry[nAccelCount];
nAccelCount = 0;
for ( i = 0; i < count; i++ )
{
nAccelCount += m_menus[i]->CopyAccels(&accelEntries[nAccelCount]);
}
m_accelTable = wxAcceleratorTable(nAccelCount, accelEntries);
delete [] accelEntries;
}
}
#endif // wxUSE_ACCEL
void wxMenuBar::MacInstallMenuBar() void wxMenuBar::MacInstallMenuBar()
{ {
Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ; Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ;
@@ -1051,3 +1119,103 @@ void wxMenuBar::MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId,
} }
} }
wxMenu *wxMenuBar::Remove(size_t pos)
{
wxMenu *menu = wxMenuBarBase::Remove(pos);
if ( !menu )
return NULL;
if ( IsAttached() )
{
if (s_macInstalledMenuBar == this)
{
::DeleteMenu( menu->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
}
menu->Detach();
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accell table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
Refresh();
}
m_titles.Remove(pos);
return menu;
}
bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
{
WXHMENU submenu = menu ? menu->GetHMenu() : 0;
wxCHECK_MSG( submenu, FALSE, wxT("can't append invalid menu to menubar") );
if ( !wxMenuBarBase::Append(menu, title) )
return FALSE;
menu->Attach(this);
m_titles.Add(title);
if ( IsAttached() )
{
if (s_macInstalledMenuBar == this)
{
::InsertMenu( menu->GetHMenu() , 0 ) ;
}
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accell table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
Refresh();
}
return TRUE;
}
// ---------------------------------------------------------------------------
// wxMenuBar searching for menu items
// ---------------------------------------------------------------------------
// Find the itemString in menuString, and return the item id or wxNOT_FOUND
int wxMenuBar::FindMenuItem(const wxString& menuString,
const wxString& itemString) const
{
wxString menuLabel = wxStripMenuCodes(menuString);
size_t count = GetMenuCount();
for ( size_t i = 0; i < count; i++ )
{
wxString title = wxStripMenuCodes(m_titles[i]);
if ( menuString == title )
return m_menus[i]->FindItem(itemString);
}
return wxNOT_FOUND;
}
wxMenuItem *wxMenuBar::FindItem(int id, wxMenu **itemMenu) const
{
if ( itemMenu )
*itemMenu = NULL;
wxMenuItem *item = NULL;
size_t count = GetMenuCount();
for ( size_t i = 0; !item && (i < count); i++ )
{
item = m_menus[i]->FindItem(id, itemMenu);
}
return item;
}

View File

@@ -29,6 +29,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
#endif //USE_SHARED_LIBRARY #endif //USE_SHARED_LIBRARY
void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts ) ;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMenuItem // wxMenuItem
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -63,6 +64,28 @@ wxMenuItem::~wxMenuItem()
{ {
} }
bool wxMenuItem::IsChecked() const
{
return wxMenuItemBase::IsChecked() ;
}
wxString wxMenuItem::GetLabel() const
{
return wxStripMenuCodes(m_text);
}
// accelerators
// ------------
#if wxUSE_ACCEL
wxAcceleratorEntry *wxMenuItem::GetAccel() const
{
return wxGetAccelFromString(GetText());
}
#endif // wxUSE_ACCEL
// misc // misc
// ---- // ----
@@ -140,3 +163,49 @@ void wxMenuItem::Check(bool bDoCheck)
} }
} }
} }
void wxMenuItem::SetText(const wxString& text)
{
// don't do anything if label didn't change
if ( m_text == text )
return;
wxMenuItemBase::SetText(text);
// OWNER_DRAWN_ONLY( wxOwnerDrawn::SetName(text) );
wxCHECK_RET( m_parentMenu && m_parentMenu->GetHMenu(), wxT("menuitem without menu") );
if ( m_parentMenu->GetHMenu() )
{
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
if ( index >= 1 )
{
Str255 label;
wxMacBuildMenuString( label , NULL , NULL , text ,false);
::SetMenuItemText( m_parentMenu->GetHMenu() , index , label ) ; // checkmark
}
}
#if wxUSE_ACCEL
m_parentMenu->UpdateAccel(this);
#endif // wxUSE_ACCEL
}
void wxMenuItem::SetCheckable(bool checkable)
{
wxMenuItemBase::SetCheckable(checkable);
// OWNER_DRAWN_ONLY( wxOwnerDrawn::SetCheckable(checkable) );
}
// ----------------------------------------------------------------------------
// wxMenuItemBase
// ----------------------------------------------------------------------------
wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
int id,
const wxString& name,
const wxString& help,
bool isCheckable,
wxMenu *subMenu)
{
return new wxMenuItem(parentMenu, id, name, help, isCheckable, subMenu);
}

View File

@@ -126,4 +126,23 @@ void wxSpinButton::MacHandleControlClick( ControlHandle control , SInt16 control
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
// ----------------------------------------------------------------------------
// size calculation
// ----------------------------------------------------------------------------
wxSize wxSpinButton::DoGetBestSize()
{
if ( (GetWindowStyle() & wxSP_VERTICAL) != 0 )
{
// vertical control
return wxSize(16,
2*16);
}
else
{
// horizontal control
return wxSize(2*16,
16);
}
}

View File

@@ -295,6 +295,34 @@ void wxWindow::DoGetPosition(int *x, int *y) const
} }
} }
wxSize wxWindow::DoGetBestSize()
{
return wxSize( 0 , 0 ) ;
}
bool wxWindow::Reparent(wxWindow *parent)
{
if ( !wxWindowBase::Reparent(parent) )
return FALSE;
return TRUE;
}
bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
{
menu->SetInvokingWindow(this);
menu->UpdateUI();
ClientToScreen( &x , &y ) ;
::InsertMenu( menu->GetHMenu() , -1 ) ;
long menuResult = ::PopUpMenuSelect(menu->GetHMenu() ,y,x, 0) ;
menu->MacMenuSelect( this , TickCount() , HiWord(menuResult) , LoWord(menuResult) ) ;
::DeleteMenu( menu->MacGetMenuId() ) ;
menu->SetInvokingWindow(NULL);
return TRUE;
}
void wxWindow::DoScreenToClient(int *x, int *y) const void wxWindow::DoScreenToClient(int *x, int *y) const
{ {
WindowRef window = GetMacRootWindow() ; WindowRef window = GetMacRootWindow() ;
@@ -401,6 +429,28 @@ void wxWindow::DoGetClientSize(int *x, int *y) const
(*y) -= MAC_SCROLLBAR_SIZE; (*y) -= MAC_SCROLLBAR_SIZE;
} }
// ----------------------------------------------------------------------------
// tooltips
// ----------------------------------------------------------------------------
#if wxUSE_TOOLTIPS
void wxWindow::DoSetToolTip(wxToolTip *tooltip)
{
wxWindowBase::DoSetToolTip(tooltip);
// if ( m_tooltip )
// m_tooltip->SetWindow(this);
}
#endif // wxUSE_TOOLTIPS
void wxWindow::DoMoveWindow(int x, int y, int width, int height)
{
DoSetSize( x,y, width, height ) ;
}
void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{ {
int former_x = m_x ; int former_x = m_x ;
@@ -1764,13 +1814,3 @@ wxMacDrawingClientHelper::~wxMacDrawingClientHelper()
if ( m_formerPort != m_currentPort ) if ( m_formerPort != m_currentPort )
SetPort( m_formerPort ) ; SetPort( m_formerPort ) ;
} }
// ----------------------------------------------------------------------------
// list classes implementation
// ----------------------------------------------------------------------------
void wxWindowListNode::DeleteData()
{
delete (wxWindow *)GetData();
}