From e40298d54ecd5b109222a7c60aa2ef084a304d69 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 28 Feb 2003 23:48:13 +0000 Subject: [PATCH] Tidied space and tabs in wxMac files git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19397 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/gauge.h | 2 +- include/wx/mac/gdiobj.h | 6 +- include/wx/mac/glcanvas.h | 14 +- include/wx/mac/gsockmac.h | 4 +- include/wx/mac/helpxxxx.h | 2 +- include/wx/mac/icon.h | 16 +- include/wx/mac/imaglist.h | 2 +- include/wx/mac/joystick.h | 2 +- include/wx/mac/listbox.h | 10 +- include/wx/mac/listctrl.h | 2 +- include/wx/mac/mdi.h | 2 +- include/wx/mac/menu.h | 24 +- include/wx/mac/menuitem.h | 8 +- include/wx/mac/metafile.h | 2 +- include/wx/mac/mimetype.h | 10 +- include/wx/mac/minifram.h | 2 +- include/wx/mac/msgdlg.h | 2 +- include/wx/mac/notebook.h | 4 +- include/wx/mac/palette.h | 2 +- include/wx/mac/pen.h | 2 +- include/wx/mac/pnghand.h | 8 +- include/wx/mac/pngread.h | 116 +- include/wx/mac/print.h | 2 +- include/wx/mac/printdlg.h | 2 +- include/wx/mac/printmac.h | 2 +- include/wx/mac/private.h | 28 +- include/wx/mac/radiobox.h | 66 +- include/wx/mac/radiobut.h | 4 +- include/wx/mac/region.h | 8 +- include/wx/mac/scrolbar.h | 4 +- include/wx/mac/setup0.h | 4 +- include/wx/mac/slider.h | 12 +- include/wx/mac/spinbutt.h | 2 +- include/wx/mac/statbmp.h | 8 +- include/wx/mac/statbox.h | 2 +- include/wx/mac/stattext.h | 4 +- include/wx/mac/tabctrl.h | 2 +- include/wx/mac/taskbar.h | 8 +- include/wx/mac/textctrl.h | 8 +- include/wx/mac/timer.h | 8 +- include/wx/mac/toolbar.h | 16 +- include/wx/mac/toplevel.h | 4 +- include/wx/mac/treectrl.h | 2 +- include/wx/mac/uma.h | 72 +- include/wx/mac/wave.h | 2 +- include/wx/mac/window.h | 12 +- src/mac/app.cpp | 440 +++---- src/mac/bitmap.cpp | 234 ++-- src/mac/bmpbuttn.cpp | 48 +- src/mac/brush.cpp | 40 +- src/mac/button.cpp | 54 +- src/mac/carbon/app.cpp | 440 +++---- src/mac/carbon/bitmap.cpp | 234 ++-- src/mac/carbon/bmpbuttn.cpp | 48 +- src/mac/carbon/brush.cpp | 40 +- src/mac/carbon/button.cpp | 54 +- src/mac/carbon/checkbox.cpp | 20 +- src/mac/carbon/checklst.cpp | 124 +- src/mac/carbon/choice.cpp | 145 ++- src/mac/carbon/clipbrd.cpp | 126 +- src/mac/carbon/colordlg.cpp | 28 +- src/mac/carbon/colour.cpp | 38 +- src/mac/carbon/combobox.cpp | 6 +- src/mac/carbon/control.cpp | 249 ++-- src/mac/carbon/cursor.cpp | 360 +++--- src/mac/carbon/data.cpp | 4 +- src/mac/carbon/dataobj.cpp | 36 +- src/mac/carbon/dc.cpp | 2445 ++++++++++++++++++----------------- src/mac/carbon/dcclient.cpp | 132 +- src/mac/carbon/dcmemory.cpp | 94 +- src/mac/carbon/dcprint.cpp | 400 +++--- src/mac/carbon/dcscreen.cpp | 52 +- src/mac/carbon/dialog.cpp | 101 +- src/mac/carbon/dirdlg.cpp | 186 +-- src/mac/carbon/dirmac.cpp | 32 +- src/mac/carbon/display.cpp | 2 +- src/mac/carbon/dnd.cpp | 344 ++--- src/mac/carbon/filedlg.cpp | 398 +++--- src/mac/carbon/font.cpp | 134 +- src/mac/carbon/fontdlg.cpp | 2 +- src/mac/carbon/fontenum.cpp | 80 +- src/mac/carbon/frame.cpp | 157 ++- src/mac/carbon/gauge.cpp | 42 +- src/mac/carbon/gdiobj.cpp | 2 +- src/mac/carbon/glcanvas.cpp | 260 ++-- src/mac/carbon/helpxxxx.cpp | 4 +- src/mac/carbon/icon.cpp | 96 +- src/mac/carbon/joystick.cpp | 4 +- src/mac/carbon/listbox.cpp | 532 ++++---- src/mac/carbon/macnotfy.cpp | 186 +-- src/mac/carbon/main.cpp | 4 +- src/mac/carbon/mdi.cpp | 136 +- src/mac/carbon/menu.cpp | 475 ++++--- src/mac/carbon/menuitem.cpp | 228 ++-- src/mac/carbon/metafile.cpp | 118 +- src/mac/carbon/mimetmac.cpp | 2 +- src/mac/carbon/minifram.cpp | 2 +- src/mac/carbon/msgdlg.cpp | 540 ++++---- src/mac/carbon/notebmac.cpp | 338 ++--- src/mac/carbon/palette.cpp | 62 +- src/mac/carbon/pen.cpp | 62 +- src/mac/carbon/pnghand.cpp | 1196 ++++++++--------- src/mac/carbon/printdlg.cpp | 164 +-- src/mac/carbon/printmac.cpp | 372 +++--- src/mac/carbon/radiobox.cpp | 354 ++--- src/mac/carbon/radiobut.cpp | 92 +- src/mac/carbon/region.cpp | 130 +- src/mac/carbon/scrolbar.cpp | 136 +- src/mac/carbon/slider.cpp | 535 ++++---- src/mac/carbon/spinbutt.cpp | 116 +- src/mac/carbon/statbmp.cpp | 22 +- src/mac/carbon/statbox.cpp | 26 +- src/mac/carbon/statbrma.cpp | 118 +- src/mac/carbon/statlmac.cpp | 18 +- src/mac/carbon/stattext.cpp | 66 +- src/mac/carbon/tabctrl.cpp | 26 +- src/mac/carbon/taskbar.cpp | 4 +- src/mac/carbon/textctrl.cpp | 210 +-- src/mac/carbon/thread.cpp | 2 - src/mac/carbon/timer.cpp | 52 +- src/mac/carbon/toolbar.cpp | 287 ++-- src/mac/carbon/tooltip.cpp | 640 ++++----- src/mac/carbon/toplevel.cpp | 520 ++++---- src/mac/carbon/treectrl.cpp | 94 +- src/mac/carbon/uma.cpp | 1002 +++++++------- src/mac/carbon/utils.cpp | 316 ++--- src/mac/carbon/utilsexc.cpp | 2 +- src/mac/carbon/wave.cpp | 320 ++--- src/mac/carbon/window.cpp | 719 +++++----- src/mac/checkbox.cpp | 20 +- src/mac/checklst.cpp | 124 +- src/mac/choice.cpp | 145 ++- src/mac/clipbrd.cpp | 126 +- src/mac/colordlg.cpp | 28 +- src/mac/colour.cpp | 38 +- src/mac/combobox.cpp | 6 +- src/mac/control.cpp | 249 ++-- src/mac/cursor.cpp | 360 +++--- src/mac/data.cpp | 4 +- src/mac/dataobj.cpp | 36 +- src/mac/dc.cpp | 2445 ++++++++++++++++++----------------- src/mac/dcclient.cpp | 132 +- src/mac/dcmemory.cpp | 94 +- src/mac/dcprint.cpp | 400 +++--- src/mac/dcscreen.cpp | 52 +- src/mac/dialog.cpp | 101 +- src/mac/dirdlg.cpp | 186 +-- src/mac/dirmac.cpp | 32 +- src/mac/display.cpp | 2 +- src/mac/dnd.cpp | 344 ++--- src/mac/filedlg.cpp | 398 +++--- src/mac/font.cpp | 134 +- src/mac/fontdlg.cpp | 2 +- src/mac/fontenum.cpp | 80 +- src/mac/frame.cpp | 157 ++- src/mac/gauge.cpp | 42 +- src/mac/gdiobj.cpp | 2 +- src/mac/glcanvas.cpp | 260 ++-- src/mac/helpxxxx.cpp | 4 +- src/mac/icon.cpp | 96 +- src/mac/joystick.cpp | 4 +- src/mac/listbox.cpp | 532 ++++---- src/mac/macnotfy.cpp | 186 +-- src/mac/main.cpp | 4 +- src/mac/mdi.cpp | 136 +- src/mac/menu.cpp | 475 ++++--- src/mac/menuitem.cpp | 228 ++-- src/mac/metafile.cpp | 118 +- src/mac/mimetmac.cpp | 2 +- src/mac/minifram.cpp | 2 +- src/mac/msgdlg.cpp | 540 ++++---- src/mac/notebmac.cpp | 338 ++--- src/mac/palette.cpp | 62 +- src/mac/pen.cpp | 62 +- src/mac/pnghand.cpp | 1196 ++++++++--------- src/mac/printdlg.cpp | 164 +-- src/mac/printmac.cpp | 372 +++--- src/mac/radiobox.cpp | 354 ++--- src/mac/radiobut.cpp | 92 +- src/mac/region.cpp | 130 +- src/mac/scrolbar.cpp | 136 +- src/mac/slider.cpp | 535 ++++---- src/mac/spinbutt.cpp | 116 +- src/mac/statbmp.cpp | 22 +- src/mac/statbox.cpp | 26 +- src/mac/statbrma.cpp | 118 +- src/mac/statlmac.cpp | 18 +- src/mac/stattext.cpp | 66 +- src/mac/tabctrl.cpp | 26 +- src/mac/taskbar.cpp | 4 +- src/mac/textctrl.cpp | 210 +-- src/mac/thread.cpp | 2 - src/mac/timer.cpp | 52 +- src/mac/toolbar.cpp | 287 ++-- src/mac/tooltip.cpp | 640 ++++----- src/mac/toplevel.cpp | 520 ++++---- src/mac/treectrl.cpp | 94 +- src/mac/uma.cpp | 1002 +++++++------- src/mac/utils.cpp | 316 ++--- src/mac/utilsexc.cpp | 2 +- src/mac/wave.cpp | 320 ++--- src/mac/window.cpp | 719 +++++----- 202 files changed, 17494 insertions(+), 17316 deletions(-) diff --git a/include/wx/mac/gauge.h b/include/wx/mac/gauge.h index 849532b453..29a8b71a53 100644 --- a/include/wx/mac/gauge.h +++ b/include/wx/mac/gauge.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_GAUGE_H_ diff --git a/include/wx/mac/gdiobj.h b/include/wx/mac/gdiobj.h index 33905be318..4030aa8d41 100644 --- a/include/wx/mac/gdiobj.h +++ b/include/wx/mac/gdiobj.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_GDIOBJ_H_ @@ -21,8 +21,8 @@ class WXDLLEXPORT wxGDIRefData: public wxObjectRefData { public: inline wxGDIRefData() - { - } + { + } }; #define M_GDIDATA ((wxGDIRefData *)m_refData) diff --git a/include/wx/mac/glcanvas.h b/include/wx/mac/glcanvas.h index db2d418854..dae7bff782 100644 --- a/include/wx/mac/glcanvas.h +++ b/include/wx/mac/glcanvas.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(__APPLE__) @@ -92,17 +92,17 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas", - int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); + int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, - const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette ); + const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette ); ~wxGLCanvas(); bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette); + int *attribList, const wxPalette& palette); void SetCurrent(); void SetColour(const char *colour); @@ -115,9 +115,9 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow // You shouldn't call glViewport yourself either (use SetViewport if you must reset it.) void OnSize(wxSizeEvent& event); - virtual void MacSuperChangedPosition() ; - virtual void MacTopLevelWindowChangedPosition() ; - void MacUpdateView() ; + virtual void MacSuperChangedPosition() ; + virtual void MacTopLevelWindowChangedPosition() ; + void MacUpdateView() ; inline wxGLContext* GetContext() const { return m_glContext; } diff --git a/include/wx/mac/gsockmac.h b/include/wx/mac/gsockmac.h index 4ffdc1266a..6bb4a2aa71 100644 --- a/include/wx/mac/gsockmac.h +++ b/include/wx/mac/gsockmac.h @@ -54,8 +54,8 @@ struct _GSocket struct _GAddress { - UInt32 m_host ; - UInt16 m_port ; + UInt32 m_host ; + UInt16 m_port ; GAddressType m_family; GSocketError m_error; }; diff --git a/include/wx/mac/helpxxxx.h b/include/wx/mac/helpxxxx.h index 188eb37306..9351360ce3 100644 --- a/include/wx/mac/helpxxxx.h +++ b/include/wx/mac/helpxxxx.h @@ -7,7 +7,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_HELPXXXX_H_ diff --git a/include/wx/mac/icon.h b/include/wx/mac/icon.h index 93c2665d7a..aa5db567ab 100644 --- a/include/wx/mac/icon.h +++ b/include/wx/mac/icon.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_ICON_H_ @@ -41,7 +41,7 @@ public: bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ , int desiredWidth /* = -1 */ , int desiredHeight = -1); bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE ) - { return LoadFile( name , flags , -1 , -1 ) ; } + { return LoadFile( name , flags , -1 , -1 ) ; } inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; } inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; } @@ -60,9 +60,9 @@ class WXDLLEXPORT wxICONFileHandler: public wxBitmapHandler public: inline wxICONFileHandler() { - m_name = "ICO icon file"; - m_extension = "ico"; - m_type = wxBITMAP_TYPE_ICO; + m_name = "ICO icon file"; + m_extension = "ico"; + m_type = wxBITMAP_TYPE_ICO; }; virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, @@ -76,9 +76,9 @@ class WXDLLEXPORT wxICONResourceHandler: public wxBitmapHandler public: inline wxICONResourceHandler() { - m_name = "ICON resource"; - m_extension = ""; - m_type = wxBITMAP_TYPE_ICON_RESOURCE; + m_name = "ICON resource"; + m_extension = ""; + m_type = wxBITMAP_TYPE_ICON_RESOURCE; }; virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, diff --git a/include/wx/mac/imaglist.h b/include/wx/mac/imaglist.h index 6be49880d6..c8fd746177 100644 --- a/include/wx/mac/imaglist.h +++ b/include/wx/mac/imaglist.h @@ -8,7 +8,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_IMAGLIST_H_ diff --git a/include/wx/mac/joystick.h b/include/wx/mac/joystick.h index bc284dd200..e1138391be 100644 --- a/include/wx/mac/joystick.h +++ b/include/wx/mac/joystick.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_JOYSTICK_H_ diff --git a/include/wx/mac/listbox.h b/include/wx/mac/listbox.h index 3608f7eb32..0d8f38b53e 100644 --- a/include/wx/mac/listbox.h +++ b/include/wx/mac/listbox.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -94,7 +94,7 @@ public: virtual void* DoGetItemClientData(int n) const; virtual void DoSetItemClientObject(int n, wxClientData* clientData); virtual wxClientData* DoGetItemClientObject(int n) const; - virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags = wxSIZE_AUTO ) ; + virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags = wxSIZE_AUTO ) ; // wxCheckListBox support #if wxUSE_OWNER_DRAWN @@ -112,7 +112,7 @@ public: virtual void SetupColours(); virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ; - virtual bool MacCanFocus() const { return true ; } + virtual bool MacCanFocus() const { return true ; } void OnChar(wxKeyEvent& event); void* m_macList ; @@ -145,8 +145,8 @@ protected: int m_noItems; int m_selected; - wxString m_typeIn ; - long m_lastTypeIn ; + wxString m_typeIn ; + long m_lastTypeIn ; virtual wxSize DoGetBestSize() const; diff --git a/include/wx/mac/listctrl.h b/include/wx/mac/listctrl.h index 2171e0fcf1..ee6f1e3df9 100644 --- a/include/wx/mac/listctrl.h +++ b/include/wx/mac/listctrl.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_LISTCTRL_H_ diff --git a/include/wx/mac/mdi.h b/include/wx/mac/mdi.h index 3888272686..a9be83cc8a 100644 --- a/include/wx/mac/mdi.h +++ b/include/wx/mac/mdi.h @@ -8,7 +8,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_MDI_H_ diff --git a/include/wx/mac/menu.h b/include/wx/mac/menu.h index ea1159e932..ed73c5ed3e 100644 --- a/include/wx/mac/menu.h +++ b/include/wx/mac/menu.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_MENU_H_ @@ -57,9 +57,9 @@ public: // implementation only from now on // ------------------------------- - int MacGetIndexFromId( int id ) ; - int MacGetIndexFromItem( wxMenuItem *pItem ) ; - void MacEnableMenu( bool bDoEnable ) ; + int MacGetIndexFromId( int id ) ; + int MacGetIndexFromItem( wxMenuItem *pItem ) ; + void MacEnableMenu( bool bDoEnable ) ; // semi-private accessors // get the window which contains this menu @@ -67,7 +67,7 @@ public: // get the menu handle WXHMENU GetHMenu() const { return m_hMenu; } - short MacGetMenuId() { return m_macMenuId ; } + short MacGetMenuId() { return m_macMenuId ; } private: // common part of all ctors @@ -88,9 +88,9 @@ private: // the menu handle of this menu WXHMENU m_hMenu; - short m_macMenuId; + short m_macMenuId; - static short s_macNextMenuId ; + static short s_macNextMenuId ; DECLARE_DYNAMIC_CLASS(wxMenu) }; @@ -146,11 +146,11 @@ public: // attach to a frame void Attach(wxFrame *frame); - // clear the invoking window for all menus and submenus - void UnsetInvokingWindow() ; + // clear the invoking window for all menus and submenus + void UnsetInvokingWindow() ; - // set the invoking window for all menus and submenus - void SetInvokingWindow( wxFrame* frame ) ; + // set the invoking window for all menus and submenus + void SetInvokingWindow( wxFrame* frame ) ; // if the menubar is modified, the display is not updated automatically, // call this function to update it (m_menuBarFrame should be !NULL) @@ -171,7 +171,7 @@ protected: wxArrayString m_titles; private: - static wxMenuBar* s_macInstalledMenuBar ; + static wxMenuBar* s_macInstalledMenuBar ; DECLARE_DYNAMIC_CLASS(wxMenuBar) }; diff --git a/include/wx/mac/menuitem.h b/include/wx/mac/menuitem.h index 92c5f8d5ec..1b79af6591 100644 --- a/include/wx/mac/menuitem.h +++ b/include/wx/mac/menuitem.h @@ -46,10 +46,10 @@ public: virtual void SetBitmap(const wxBitmap& bitmap) ; virtual const wxBitmap& GetBitmap() const { return m_bitmap; } - // update the os specific representation - void UpdateItemBitmap() ; - void UpdateItemText() ; - void UpdateItemStatus() ; + // update the os specific representation + void UpdateItemBitmap() ; + void UpdateItemText() ; + void UpdateItemStatus() ; // mark item as belonging to the given radio group void SetAsRadioGroupStart(); diff --git a/include/wx/mac/metafile.h b/include/wx/mac/metafile.h index b2468e42d1..7184a9c79b 100644 --- a/include/wx/mac/metafile.h +++ b/include/wx/mac/metafile.h @@ -8,7 +8,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// diff --git a/include/wx/mac/mimetype.h b/include/wx/mac/mimetype.h index 475267c7ba..021d360a6e 100644 --- a/include/wx/mac/mimetype.h +++ b/include/wx/mac/mimetype.h @@ -71,7 +71,7 @@ public: // the first extension found, index 1 for the second and so on void Init(wxMimeTypesManagerImpl *manager, size_t index) - { m_manager = manager; m_index.Add(index); } + { m_manager = manager; m_index.Add(index); } // initialize us with our file type name void SetFileType(const wxString& strFileType) @@ -98,10 +98,10 @@ public: // remove the record for this file type // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead bool Unassociate(wxFileType *ft) - { - return m_manager->Unassociate(ft); - } - + { + return m_manager->Unassociate(ft); + } + // set an arbitrary command, ask confirmation if it already exists and // overwriteprompt is TRUE bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE); diff --git a/include/wx/mac/minifram.h b/include/wx/mac/minifram.h index 448e40f75a..6f606cd82f 100644 --- a/include/wx/mac/minifram.h +++ b/include/wx/mac/minifram.h @@ -8,7 +8,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_MINIFRAM_H_ diff --git a/include/wx/mac/msgdlg.h b/include/wx/mac/msgdlg.h index 833d3c4442..1acd4b3ad6 100644 --- a/include/wx/mac/msgdlg.h +++ b/include/wx/mac/msgdlg.h @@ -7,7 +7,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_MSGBOXDLG_H_ diff --git a/include/wx/mac/notebook.h b/include/wx/mac/notebook.h index c1bf4c42d4..316cb94f1b 100644 --- a/include/wx/mac/notebook.h +++ b/include/wx/mac/notebook.h @@ -5,7 +5,7 @@ // Modified by: // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_NOTEBOOK_H_ @@ -135,7 +135,7 @@ public: virtual void Command(wxCommandEvent& event); protected: virtual wxNotebookPage *DoRemovePage(int page) ; - virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ; + virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ; // common part of all ctors void Init(); diff --git a/include/wx/mac/palette.h b/include/wx/mac/palette.h index b3508ee090..56962e91f3 100644 --- a/include/wx/mac/palette.h +++ b/include/wx/mac/palette.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PALETTE_H_ diff --git a/include/wx/mac/pen.h b/include/wx/mac/pen.h index 037493abbb..ca48f977ac 100644 --- a/include/wx/mac/pen.h +++ b/include/wx/mac/pen.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PEN_H_ diff --git a/include/wx/mac/pnghand.h b/include/wx/mac/pnghand.h index 426b0c4483..4fa01a942b 100644 --- a/include/wx/mac/pnghand.h +++ b/include/wx/mac/pnghand.h @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Microsoft, Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(__APPLE__) @@ -22,9 +22,9 @@ class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler public: inline wxPNGFileHandler(void) { - m_name = "PNG bitmap file"; - m_extension = "bmp"; - m_type = wxBITMAP_TYPE_PNG; + m_name = "PNG bitmap file"; + m_extension = "bmp"; + m_type = wxBITMAP_TYPE_PNG; }; virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, diff --git a/include/wx/mac/pngread.h b/include/wx/mac/pngread.h index 8aa50a09d4..a761a8470e 100644 --- a/include/wx/mac/pngread.h +++ b/include/wx/mac/pngread.h @@ -1,9 +1,9 @@ /* - * File: pngread.h - * Purpose: PNG file reader - * Author: Alejandro Aguilar Sierra/Julian Smart - * Created: 1995 - * Copyright: (c) 1995, Alejandro Aguilar Sierra + * File: pngread.h + * Purpose: PNG file reader + * Author: Alejandro Aguilar Sierra/Julian Smart + * Created: 1995 + * Copyright: (c) 1995, Alejandro Aguilar Sierra * * */ @@ -25,30 +25,30 @@ typedef byte * ImagePointerType; typedef struct { - byte red; - byte green; + byte red; + byte green; byte blue; } rgb_color_struct; -#define COLORTYPE_PALETTE 1 -#define COLORTYPE_COLOR 2 -#define COLORTYPE_ALPHA 4 +#define COLORTYPE_PALETTE 1 +#define COLORTYPE_COLOR 2 +#define COLORTYPE_ALPHA 4 class wxPNGReader { protected: int filetype; char filename[255]; - ImagePointerType RawImage; // Image data + ImagePointerType RawImage; // Image data - int Width, Height; // Dimensions - int Depth; // (bits x pixel) - int ColorType; // Bit 1 = Palette used - // Bit 2 = Color used - // Bit 3 = Alpha used + int Width, Height; // Dimensions + int Depth; // (bits x pixel) + int ColorType; // Bit 1 = Palette used + // Bit 2 = Color used + // Bit 3 = Alpha used - long EfeWidth; // Efective Width + long EfeWidth; // Efective Width void *lpbi; int bgindex; @@ -98,9 +98,9 @@ public: class wxPNGReaderIter { protected: - int Itx, Ity; // Counters + int Itx, Ity; // Counters int Stepx, Stepy; - ImagePointerType IterImage; // Image pointer + ImagePointerType IterImage; // Image pointer wxPNGReader *ima; public: // Constructors @@ -146,7 +146,7 @@ inline wxPNGReaderIter::wxPNGReaderIter(wxPNGReader *imax): ima(imax) { if (ima) - IterImage = ima->RawImage; + IterImage = ima->RawImage; Itx = Ity = 0; Stepx = Stepy = 0; } @@ -161,9 +161,9 @@ inline bool wxPNGReaderIter::ItOK () { if (ima) - return ima->Inside(Itx, Ity); + return ima->Inside(Itx, Ity); else - return FALSE; + return FALSE; } @@ -209,7 +209,7 @@ inline void wxPNGReaderIter::SetRow(byte *buf, int n) // Here should be bcopy or memcpy //_fmemcpy(IterImage, (void far *)buf, n); if (n<0) - n = ima->GetWidth(); + n = ima->GetWidth(); for (int i=0; iEfeWidth) - return 1; + return 1; else - if (++Ity < ima->Height) - { - IterImage += ima->EfeWidth; - Itx = 0; - return 1; - } else - return 0; + if (++Ity < ima->Height) + { + IterImage += ima->EfeWidth; + Itx = 0; + return 1; + } else + return 0; } inline bool wxPNGReaderIter::PrevByte() { if (--Itx >= 0) - return 1; + return 1; else - if (--Ity >= 0) - { - IterImage -= ima->EfeWidth; - Itx = 0; - return 1; - } else - return 0; + if (--Ity >= 0) + { + IterImage -= ima->EfeWidth; + Itx = 0; + return 1; + } else + return 0; } inline bool wxPNGReaderIter::NextStep() { Itx += Stepx; if (Itx < ima->EfeWidth) - return 1; + return 1; else { - Ity += Stepy; - if (Ity < ima->Height) - { - IterImage += ima->EfeWidth; - Itx = 0; - return 1; - } else - return 0; + Ity += Stepy; + if (Ity < ima->Height) + { + IterImage += ima->EfeWidth; + Itx = 0; + return 1; + } else + return 0; } } @@ -273,16 +273,16 @@ inline bool wxPNGReaderIter::PrevStep() { Itx -= Stepx; if (Itx >= 0) - return 1; - else { - Ity -= Stepy; - if (Ity >= 0 && Ity < ima->Height) - { - IterImage -= ima->EfeWidth; - Itx = 0; - return 1; - } else - return 0; + return 1; + else { + Ity -= Stepy; + if (Ity >= 0 && Ity < ima->Height) + { + IterImage -= ima->EfeWidth; + Itx = 0; + return 1; + } else + return 0; } } diff --git a/include/wx/mac/print.h b/include/wx/mac/print.h index 5a7d5f1c43..fdaef23006 100644 --- a/include/wx/mac/print.h +++ b/include/wx/mac/print.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PRINT_H_ diff --git a/include/wx/mac/printdlg.h b/include/wx/mac/printdlg.h index bb0806af2e..28d3581946 100644 --- a/include/wx/mac/printdlg.h +++ b/include/wx/mac/printdlg.h @@ -8,7 +8,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PRINTDLG_H_ diff --git a/include/wx/mac/printmac.h b/include/wx/mac/printmac.h index 6e155b9470..388f4dc796 100644 --- a/include/wx/mac/printmac.h +++ b/include/wx/mac/printmac.h @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PRINTWIN_H_ diff --git a/include/wx/mac/private.h b/include/wx/mac/private.h index c9315e988d..b69f507586 100644 --- a/include/wx/mac/private.h +++ b/include/wx/mac/private.h @@ -8,7 +8,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_PRIVATE_H_ @@ -50,14 +50,14 @@ public: GrafPtr GetCurrentPort() { return m_currentPort ; } private: - GrafPtr m_currentPort ; - GrafPtr m_oldPort ; - RgnHandle m_clip ; + GrafPtr m_currentPort ; + GrafPtr m_oldPort ; + RgnHandle m_clip ; ThemeDrawingState m_drawingState ; - short m_textFont ; - short m_textSize ; - short m_textStyle ; - short m_textMode ; + short m_textFont ; + short m_textSize ; + short m_textStyle ; + short m_textMode ; } ; class WXDLLEXPORT wxMacPortSetter @@ -123,12 +123,12 @@ WXDLLEXPORT wxString wxMacFindFolder(short vRefNum, OSType folderType, Boolean createFolder); -GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; -void wxMacDestroyGWorld( GWorldPtr gw ) ; -PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; +GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; +void wxMacDestroyGWorld( GWorldPtr gw ) ; +PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ; -void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; -CTabHandle wxMacCreateColorTable( int numColors ) ; +void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; +CTabHandle wxMacCreateColorTable( int numColors ) ; void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ; #define MAC_WXCOLORREF(a) (*((RGBColor*)&(a))) @@ -165,7 +165,7 @@ inline wxString wxMacMakeStringFromMacString( const char* from ) // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC inline wxString wxMacMakeStringFromMacString( const wxString& from ) { return wxApp::s_macDefaultEncodingIsPC ? - wxMacMakeStringFromMacString( from.c_str() , true ) : from ; } + wxMacMakeStringFromMacString( from.c_str() , true ) : from ; } // // Pascal Strings diff --git a/include/wx/mac/radiobox.h b/include/wx/mac/radiobox.h index 531ba62a01..f2262eea38 100644 --- a/include/wx/mac/radiobox.h +++ b/include/wx/mac/radiobox.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_RADIOBOX_H_ @@ -23,65 +23,65 @@ class WXDLLEXPORT wxRadioButton ; class WXDLLEXPORT wxRadioBox: public wxControl, public wxRadioBoxBase { - DECLARE_DYNAMIC_CLASS(wxRadioBox) + DECLARE_DYNAMIC_CLASS(wxRadioBox) public: // Constructors & destructor - wxRadioBox(); - inline wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title, + wxRadioBox(); + inline wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n = 0, const wxString choices[] = NULL, int majorDim = 0, long style = wxRA_HORIZONTAL, const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr) - { - Create(parent, id, title, pos, size, n, choices, majorDim, style, val, name); - } - ~wxRadioBox(); - bool Create(wxWindow *parent, wxWindowID id, const wxString& title, + { + Create(parent, id, title, pos, size, n, choices, majorDim, style, val, name); + } + ~wxRadioBox(); + bool Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n = 0, const wxString choices[] = NULL, int majorDim = 0, long style = wxRA_HORIZONTAL, const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr); // Specific functions (in wxWindows2 reference) - virtual void SetSelection(int item); - virtual int GetSelection() const; - - inline virtual int GetCount() const { return m_noItems; } ; + virtual void SetSelection(int item); + virtual int GetSelection() const; - virtual wxString GetString(int item) const; - virtual void SetString(int item, const wxString& label) ; - - virtual void Enable(int item, bool enable); - virtual void Show(int item, bool show) ; + inline virtual int GetCount() const { return m_noItems; } ; + + virtual wxString GetString(int item) const; + virtual void SetString(int item, const wxString& label) ; + + virtual void Enable(int item, bool enable); + virtual void Show(int item, bool show) ; virtual int GetColumnCount() const ; virtual int GetRowCount() const ; - virtual bool Enable(bool enable = TRUE); - virtual wxString GetLabel() const; - virtual void SetLabel(const wxString& label) ; - virtual bool Show(bool show = TRUE); + virtual bool Enable(bool enable = TRUE); + virtual wxString GetLabel() const; + virtual void SetLabel(const wxString& label) ; + virtual bool Show(bool show = TRUE); // Other external functions - void Command(wxCommandEvent& event); - void SetFocus(); + void Command(wxCommandEvent& event); + void SetFocus(); // Other variable access functions - inline int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; } - inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; } + inline int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; } + inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; } - void OnRadioButton( wxCommandEvent& event ) ; + void OnRadioButton( wxCommandEvent& event ) ; protected: - wxRadioButton *m_radioButtonCycle; - - int m_majorDim ; - int m_noItems; - int m_noRowsOrCols; + wxRadioButton *m_radioButtonCycle; + + int m_majorDim ; + int m_noItems; + int m_noRowsOrCols; // Internal functions virtual wxSize DoGetBestSize() const ; - virtual void DoSetSize(int x, int y, + virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); diff --git a/include/wx/mac/radiobut.h b/include/wx/mac/radiobut.h index 23da10736b..74dfccde46 100644 --- a/include/wx/mac/radiobut.h +++ b/include/wx/mac/radiobut.h @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_RADIOBUT_H_ @@ -44,7 +44,7 @@ public: // implementation - virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart ); + virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart ); void Command(wxCommandEvent& event); wxRadioButton *AddInCycle(wxRadioButton *cycle); inline wxRadioButton *NextInCycle() {return m_cycle;} diff --git a/include/wx/mac/region.h b/include/wx/mac/region.h index 98c8107550..e91e4ab36d 100644 --- a/include/wx/mac/region.h +++ b/include/wx/mac/region.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_REGION_H_ @@ -24,7 +24,7 @@ class WXDLLEXPORT wxRect; class WXDLLEXPORT wxPoint; enum wxRegionContain { - wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2 + wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2 }; // So far, for internal use only @@ -38,7 +38,7 @@ wxRGN_XOR // Creates the union of two combined regions except for any class WXDLLEXPORT wxRegion : public wxGDIObject { DECLARE_DYNAMIC_CLASS(wxRegion); - friend class WXDLLEXPORT wxRegionIterator; + friend class WXDLLEXPORT wxRegionIterator; public: wxRegion(long x, long y, long w, long h); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); @@ -155,4 +155,4 @@ private: }; #endif - // _WX_REGION_H_ + // _WX_REGION_H_ diff --git a/include/wx/mac/scrolbar.h b/include/wx/mac/scrolbar.h index 90e46d698c..0709b7e6c0 100644 --- a/include/wx/mac/scrolbar.h +++ b/include/wx/mac/scrolbar.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_SCROLBAR_H_ @@ -57,7 +57,7 @@ public: bool refresh = TRUE); void Command(wxCommandEvent& event); - virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ; + virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ; protected: int m_pageSize; diff --git a/include/wx/mac/setup0.h b/include/wx/mac/setup0.h index c030b6d36d..360e356636 100644 --- a/include/wx/mac/setup0.h +++ b/include/wx/mac/setup0.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_SETUP_H_ @@ -855,7 +855,7 @@ // that use the connection) should support forward only scrolling of cursors, // or both forward and backward support for backward scrolling cursors is // dependent on the data source as well as the ODBC driver being used. -#define wxODBC_FWD_ONLY_CURSORS 1 +#define wxODBC_FWD_ONLY_CURSORS 1 // Default is 0. Set to 1 to use the deprecated classes, enum types, function, // member variables. With a setting of 1, full backward compatability with the diff --git a/include/wx/mac/slider.h b/include/wx/mac/slider.h index 7c52c5a54a..caf89d1842 100644 --- a/include/wx/mac/slider.h +++ b/include/wx/mac/slider.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_SLIDER_H_ @@ -87,12 +87,12 @@ public: virtual void DoMoveWindow(int x, int y, int w, int h); void Command(wxCommandEvent& event); - void MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ; - virtual void MacUpdateDimensions() ; + void MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ; + virtual void MacUpdateDimensions() ; - wxStaticText* m_macMinimumStatic ; - wxStaticText* m_macMaximumStatic ; - wxStaticText* m_macValueStatic ; + wxStaticText* m_macMinimumStatic ; + wxStaticText* m_macMaximumStatic ; + wxStaticText* m_macValueStatic ; int m_rangeMin; int m_rangeMax; diff --git a/include/wx/mac/spinbutt.h b/include/wx/mac/spinbutt.h index f11a058b47..fb0bc70b3c 100644 --- a/include/wx/mac/spinbutt.h +++ b/include/wx/mac/spinbutt.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_SPINBUTT_H_ diff --git a/include/wx/mac/statbmp.h b/include/wx/mac/statbmp.h index 858c6da40b..55879e17fb 100644 --- a/include/wx/mac/statbmp.h +++ b/include/wx/mac/statbmp.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_STATBMP_H_ @@ -50,8 +50,8 @@ class WXDLLEXPORT wxStaticBitmap: public wxStaticBitmapBase wxBitmap GetBitmap() const { return m_bitmap; } wxIcon GetIcon() const { - // icons and bitmaps are really the same thing in wxMac - return (const wxIcon &)m_bitmap; + // icons and bitmaps are really the same thing in wxMac + return (const wxIcon &)m_bitmap; } void SetIcon(const wxIcon& icon) { SetBitmap( (const wxBitmap &)icon ) ; } @@ -61,7 +61,7 @@ class WXDLLEXPORT wxStaticBitmap: public wxStaticBitmapBase protected: wxBitmap m_bitmap; - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/mac/statbox.h b/include/wx/mac/statbox.h index 4ea33efdcc..f3a68c5fcd 100644 --- a/include/wx/mac/statbox.h +++ b/include/wx/mac/statbox.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_STATBOX_H_ diff --git a/include/wx/mac/stattext.h b/include/wx/mac/stattext.h index fdd889d90d..2105314cb8 100644 --- a/include/wx/mac/stattext.h +++ b/include/wx/mac/stattext.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_STATTEXT_H_ @@ -53,7 +53,7 @@ class WXDLLEXPORT wxStaticText: public wxStaticTextBase virtual wxSize DoGetBestSize() const ; virtual bool AcceptsFocus() const { return FALSE; } private : - wxString m_label ; + wxString m_label ; DECLARE_EVENT_TABLE() }; diff --git a/include/wx/mac/tabctrl.h b/include/wx/mac/tabctrl.h index dae86ff145..7def1aa183 100644 --- a/include/wx/mac/tabctrl.h +++ b/include/wx/mac/tabctrl.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_TABCTRL_H_ diff --git a/include/wx/mac/taskbar.h b/include/wx/mac/taskbar.h index 64487aadac..d896d3dfa2 100644 --- a/include/wx/mac/taskbar.h +++ b/include/wx/mac/taskbar.h @@ -1,13 +1,13 @@ ///////////////////////////////////////////////////////////////////////// // File: taskbar.h -// Purpose: Defines wxTaskBarIcon class for manipulating icons on the +// Purpose: Defines wxTaskBarIcon class for manipulating icons on the // task bar. Optional. // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////// #ifndef _WX_TASKBAR_H_ @@ -23,8 +23,8 @@ class wxTaskBarIcon: public wxObject { public: - wxTaskBarIcon(); - virtual ~wxTaskBarIcon(); + wxTaskBarIcon(); + virtual ~wxTaskBarIcon(); // Accessors diff --git a/include/wx/mac/textctrl.h b/include/wx/mac/textctrl.h index 4ef850483b..df241fbdcf 100644 --- a/include/wx/mac/textctrl.h +++ b/include/wx/mac/textctrl.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_TEXTCTRL_H_ @@ -151,11 +151,11 @@ public: void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event); - virtual bool MacCanFocus() const { return true ; } + virtual bool MacCanFocus() const { return true ; } virtual bool MacSetupCursor( const wxPoint& pt ) ; - virtual void MacSuperShown( bool show ) ; - virtual bool Show(bool show = TRUE) ; + virtual void MacSuperShown( bool show ) ; + virtual bool Show(bool show = TRUE) ; protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/mac/timer.h b/include/wx/mac/timer.h index dd3f5fd511..3cc7bcd76d 100644 --- a/include/wx/mac/timer.h +++ b/include/wx/mac/timer.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_TIMER_H_ @@ -26,8 +26,8 @@ struct MacTimerInfo ; class WXDLLEXPORT wxTimer: public wxTimerBase { public: - wxTimer() { Init(); } - wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id) { Init(); } + wxTimer() { Init(); } + wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id) { Init(); } ~wxTimer(); virtual bool Start(int milliseconds = -1, @@ -38,7 +38,7 @@ public: MacTimerInfo* m_info; protected : - void Init(); + void Init(); private: DECLARE_ABSTRACT_CLASS(wxTimer) diff --git a/include/wx/mac/toolbar.h b/include/wx/mac/toolbar.h index 5ee32cf551..fd64e322f5 100644 --- a/include/wx/mac/toolbar.h +++ b/include/wx/mac/toolbar.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_TOOLBAR_H_ @@ -61,11 +61,11 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase // Add all the buttons - virtual void MacHandleControlClick( WXWidget control , short controlpart ) ; - virtual wxString MacGetToolTipString( wxPoint &where ) ; - void OnPaint(wxPaintEvent& event) ; - void OnMouse(wxMouseEvent& event) ; - virtual void MacSuperChangedPosition() ; + virtual void MacHandleControlClick( WXWidget control , short controlpart ) ; + virtual wxString MacGetToolTipString( wxPoint &where ) ; + void OnPaint(wxPaintEvent& event) ; + void OnMouse(wxMouseEvent& event) ; + virtual void MacSuperChangedPosition() ; protected: // common part of all ctors void Init(); @@ -88,9 +88,9 @@ protected: const wxString& longHelp); virtual wxToolBarToolBase *CreateTool(wxControl *control); - wxArrayPtrVoid m_macToolHandles ; + wxArrayPtrVoid m_macToolHandles ; - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; #endif // wxUSE_TOOLBAR diff --git a/include/wx/mac/toplevel.h b/include/wx/mac/toplevel.h index f101e5626d..d6aea4496c 100644 --- a/include/wx/mac/toplevel.h +++ b/include/wx/mac/toplevel.h @@ -93,7 +93,7 @@ public: short MacGetWindowBackgroundTheme() const { return m_macWindowBackgroundTheme ; } #if TARGET_CARBON - WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; } + WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; } #endif protected: // common part of all ctors @@ -116,7 +116,7 @@ protected: static WXWindow s_macWindowInUpdate ; private : #if TARGET_CARBON - WXEVENTHANDLERREF m_macEventHandler ; + WXEVENTHANDLERREF m_macEventHandler ; #endif }; diff --git a/include/wx/mac/treectrl.h b/include/wx/mac/treectrl.h index 3ef738e5cc..058b5653e5 100644 --- a/include/wx/mac/treectrl.h +++ b/include/wx/mac/treectrl.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_TREECTRL_H_ diff --git a/include/wx/mac/uma.h b/include/wx/mac/uma.h index 676c3736d1..f96f5d42a5 100644 --- a/include/wx/mac/uma.h +++ b/include/wx/mac/uma.h @@ -6,7 +6,7 @@ // Created: 03/02/99 // RCS-ID: $Id: // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef H_UMA @@ -31,59 +31,59 @@ bool UMAGetProcessModeDoesActivateOnFGSwitch() ; // menu manager -MenuRef UMANewMenu( SInt16 id , const wxString& title ) ; -void UMASetMenuTitle( MenuRef menu , const wxString& title ) ; -UInt32 UMAMenuEvent( EventRecord *inEvent ) ; -void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex item , bool enable ) ; +MenuRef UMANewMenu( SInt16 id , const wxString& title ) ; +void UMASetMenuTitle( MenuRef menu , const wxString& title ) ; +UInt32 UMAMenuEvent( EventRecord *inEvent ) ; +void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex item , bool enable ) ; -void UMAAppendSubMenuItem( MenuRef menu , const wxString& title , SInt16 submenuid ) ; -void UMAInsertSubMenuItem( MenuRef menu , const wxString& title , MenuItemIndex item , SInt16 submenuid ) ; -void UMAAppendMenuItem( MenuRef menu , const wxString& title , wxAcceleratorEntry *entry = NULL ) ; -void UMAInsertMenuItem( MenuRef menu , const wxString& title , MenuItemIndex item , wxAcceleratorEntry *entry = NULL ) ; -void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEntry *entry ) ; +void UMAAppendSubMenuItem( MenuRef menu , const wxString& title , SInt16 submenuid ) ; +void UMAInsertSubMenuItem( MenuRef menu , const wxString& title , MenuItemIndex item , SInt16 submenuid ) ; +void UMAAppendMenuItem( MenuRef menu , const wxString& title , wxAcceleratorEntry *entry = NULL ) ; +void UMAInsertMenuItem( MenuRef menu , const wxString& title , MenuItemIndex item , wxAcceleratorEntry *entry = NULL ) ; +void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEntry *entry ) ; -void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title ) ; +void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title ) ; // quickdraw -void UMAShowWatchCursor() ; -void UMAShowArrowCursor() ; +void UMAShowWatchCursor() ; +void UMAShowArrowCursor() ; -OSStatus UMAPrOpen(void *macPrintSession) ; -OSStatus UMAPrClose(void *macPrintSession) ; +OSStatus UMAPrOpen(void *macPrintSession) ; +OSStatus UMAPrClose(void *macPrintSession) ; // window manager -GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) ; -void UMADisposeWindow( WindowRef inWindowRef ) ; -void UMASetWTitleC( WindowRef inWindowRef , const char *title ) ; -void UMAGetWTitleC( WindowRef inWindowRef , char *title ) ; +GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) ; +void UMADisposeWindow( WindowRef inWindowRef ) ; +void UMASetWTitleC( WindowRef inWindowRef , const char *title ) ; +void UMAGetWTitleC( WindowRef inWindowRef , char *title ) ; -void UMADrawGrowIcon( WindowRef inWindowRef ) ; -void UMAShowHide( WindowRef inWindowRef , Boolean show) ; +void UMADrawGrowIcon( WindowRef inWindowRef ) ; +void UMAShowHide( WindowRef inWindowRef , Boolean show) ; // appearance manager -void UMADrawControl( ControlHandle inControl ) ; +void UMADrawControl( ControlHandle inControl ) ; -void UMAEnableControl( ControlHandle inControl ) ; -void UMADisableControl( ControlHandle inControl ) ; -void UMAActivateControl( ControlHandle inControl ) ; -void UMADeactivateControl( ControlHandle inControl ) ; -// ControlPartCode hiliteState) ; -void UMAShowControl (ControlHandle theControl) ; -void UMAHideControl (ControlHandle theControl); -void UMAActivateControl (ControlHandle inControl); -void UMADeactivateControl (ControlHandle inControl); +void UMAEnableControl( ControlHandle inControl ) ; +void UMADisableControl( ControlHandle inControl ) ; +void UMAActivateControl( ControlHandle inControl ) ; +void UMADeactivateControl( ControlHandle inControl ) ; +// ControlPartCode hiliteState) ; +void UMAShowControl (ControlHandle theControl) ; +void UMAHideControl (ControlHandle theControl); +void UMAActivateControl (ControlHandle inControl); +void UMADeactivateControl (ControlHandle inControl); void UMAMoveControl( ControlHandle inControl , short x , short y ) ; void UMASizeControl( ControlHandle inControl , short x , short y ) ; // control hierarchy // keyboard focus -OSErr UMASetKeyboardFocus (WindowPtr inWindow, - ControlHandle inControl, - ControlFocusPart inPart) ; +OSErr UMASetKeyboardFocus (WindowPtr inWindow, + ControlHandle inControl, + ControlFocusPart inPart) ; // events @@ -91,8 +91,8 @@ void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) ; OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) ; // handling control data -bool UMAIsWindowFloating( WindowRef inWindow ) ; -bool UMAIsWindowModal( WindowRef inWindow ) ; +bool UMAIsWindowFloating( WindowRef inWindow ) ; +bool UMAIsWindowModal( WindowRef inWindow ) ; void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) ; diff --git a/include/wx/mac/wave.h b/include/wx/mac/wave.h index bdf3062040..9a9c17ca5f 100644 --- a/include/wx/mac/wave.h +++ b/include/wx/mac/wave.h @@ -7,7 +7,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_WAVE_H_ diff --git a/include/wx/mac/window.h b/include/wx/mac/window.h index ec8e81943b..86096d5948 100644 --- a/include/wx/mac/window.h +++ b/include/wx/mac/window.h @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_WINDOW_H_ @@ -38,7 +38,7 @@ class WXDLLEXPORT wxWindowMac: public wxWindowBase friend class wxPaintDC; public: - + wxWindowMac() : m_macBackgroundBrush() , m_macVisibleRegion() @@ -155,7 +155,7 @@ public: void MacRootWindowToClient( int *x , int *y ) const ; void MacWindowToRootWindow( int *x , int *y ) const ; void MacRootWindowToWindow( int *x , int *y ) const ; - + virtual wxString MacGetToolTipString( wxPoint &where ) ; // simple accessors @@ -163,7 +163,7 @@ public: // WXHWND GetHWND() const { return m_hWnd; } // void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } - virtual WXWidget GetHandle() const { return (WXWidget) NULL ; } + virtual WXWidget GetHandle() const { return (WXWidget) NULL ; } bool GetUseCtl3D() const { return m_useCtl3D; } bool GetTransparentBackground() const { return m_backgroundTransparent; } @@ -171,7 +171,7 @@ public: // event handlers // -------------- - void OnSetFocus(wxFocusEvent& event) ; + void OnSetFocus(wxFocusEvent& event) ; void OnNcPaint(wxNcPaintEvent& event); void OnEraseBackground(wxEraseEvent& event); void OnIdle(wxIdleEvent& event); @@ -233,7 +233,7 @@ public: static long MacRemoveBordersFromStyle( long style ) ; virtual void MacSuperChangedPosition() ; // the absolute coordinates of this item within the toplevel window may have changed - virtual void MacUpdateDimensions() {} + virtual void MacUpdateDimensions() {} // the absolute coortinates of this window's root have changed virtual void MacTopLevelWindowChangedPosition() ; virtual void MacSuperShown( bool show ) ; diff --git a/src/mac/app.cpp b/src/mac/app.cpp index fcc04b18cb..48b2c379c8 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -289,21 +289,21 @@ void wxApp::MacNewFile() #if TARGET_CARBON - static const EventTypeSpec eventList[] = - { - { kEventClassCommand, kEventProcessCommand } , - { kEventClassCommand, kEventCommandUpdateStatus } , - - { kEventClassApplication , kEventAppActivated } , - { kEventClassApplication , kEventAppDeactivated } , - // handling the quit event is not recommended by apple - // rather using the quit apple event - which we do - - { kEventClassAppleEvent , kEventAppleEvent } , - - { kEventClassMouse , kEventMouseDown } , - { 'WXMC' , 'WXMC' } - } ; + static const EventTypeSpec eventList[] = + { + { kEventClassCommand, kEventProcessCommand } , + { kEventClassCommand, kEventCommandUpdateStatus } , + + { kEventClassApplication , kEventAppActivated } , + { kEventClassApplication , kEventAppDeactivated } , + // handling the quit event is not recommended by apple + // rather using the quit apple event - which we do + + { kEventClassAppleEvent , kEventAppleEvent } , + + { kEventClassMouse , kEventMouseDown } , + { 'WXMC' , 'WXMC' } + } ; static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { @@ -323,23 +323,23 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef switch( GetEventKind(event) ) { - case kEventMouseDown : - { - Point point ; - WindowRef window ; - - GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof( Point ), NULL, &point ); - short windowPart = ::FindWindow(point, &window); - - if ( windowPart == inMenuBar ) - { - MenuSelect( point ) ; - result = noErr ; - } - } - break ; - } + case kEventMouseDown : + { + Point point ; + WindowRef window ; + + GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, + sizeof( Point ), NULL, &point ); + short windowPart = ::FindWindow(point, &window); + + if ( windowPart == inMenuBar ) + { + MenuSelect( point ) ; + result = noErr ; + } + } + break ; + } return result ; } @@ -348,15 +348,15 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR { OSStatus result = eventNotHandledErr ; - HICommand command ; - - GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, - sizeof( HICommand ), NULL, &command ); + HICommand command ; + + GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, + sizeof( HICommand ), NULL, &command ); - MenuCommand id = command.commandID ; - if ( id == kHICommandPreferences ) - id = wxApp::s_macPreferencesMenuItemId ; - + MenuCommand id = command.commandID ; + if ( id == kHICommandPreferences ) + id = wxApp::s_macPreferencesMenuItemId ; + wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ; wxMenu* menu = NULL ; wxMenuItem* item = NULL ; @@ -365,28 +365,28 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR item = mbar->FindItem( id , &menu ) ; if ( item == NULL || menu == NULL || mbar == NULL ) - return result ; - - switch( GetEventKind( event ) ) - { - case kEventProcessCommand : - { - if (item->IsCheckable()) - { - item->Check( !item->IsChecked() ) ; - } - - menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; - result = noErr ; - } - break ; - case kEventCommandUpdateStatus: - // eventually trigger an updateui round - result = noErr ; - break ; - default : - break ; - } + return result ; + + switch( GetEventKind( event ) ) + { + case kEventProcessCommand : + { + if (item->IsCheckable()) + { + item->Check( !item->IsChecked() ) ; + } + + menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; + result = noErr ; + } + break ; + case kEventCommandUpdateStatus: + // eventually trigger an updateui round + result = noErr ; + break ; + default : + break ; + } return result ; } @@ -394,23 +394,23 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR static pascal OSStatus ApplicationEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; - switch ( GetEventKind( event ) ) - { - case kEventAppActivated : - { - wxTheApp->MacResume( true ) ; - result = noErr ; - } - break ; - case kEventAppDeactivated : - { - wxTheApp->MacSuspend( true ) ; - result = noErr ; - } - break ; - default : - break ; - } + switch ( GetEventKind( event ) ) + { + case kEventAppActivated : + { + wxTheApp->MacResume( true ) ; + result = noErr ; + } + break ; + case kEventAppDeactivated : + { + wxTheApp->MacSuspend( true ) ; + result = noErr ; + } + break ; + default : + break ; + } return result ; } @@ -419,27 +419,27 @@ pascal OSStatus wxAppEventHandler( EventHandlerCallRef handler , EventRef event OSStatus result = eventNotHandledErr ; switch( GetEventClass( event ) ) { - case kEventClassCommand : - result = CommandEventHandler( handler , event , data ) ; - break ; - case kEventClassApplication : - result = ApplicationEventHandler( handler , event , data ) ; - break ; - case kEventClassMenu : - result = MenuEventHandler( handler , event , data ) ; - break ; - case kEventClassMouse : - result = MouseEventHandler( handler , event , data ) ; - break ; - case kEventClassAppleEvent : - { - EventRecord rec ; - wxMacConvertEventToRecord( event , &rec ) ; - result = AEProcessAppleEvent( &rec ) ; - } - break ; - default : - break ; + case kEventClassCommand : + result = CommandEventHandler( handler , event , data ) ; + break ; + case kEventClassApplication : + result = ApplicationEventHandler( handler , event , data ) ; + break ; + case kEventClassMenu : + result = MenuEventHandler( handler , event , data ) ; + break ; + case kEventClassMouse : + result = MouseEventHandler( handler , event , data ) ; + break ; + case kEventClassAppleEvent : + { + EventRecord rec ; + wxMacConvertEventToRecord( event , &rec ) ; + result = AEProcessAppleEvent( &rec ) ; + } + break ; + default : + break ; } return result ; @@ -532,7 +532,7 @@ bool wxApp::Initialize() #ifndef __DARWIN__ // now avoid exceptions thrown for new (bad_alloc) - // FIXME CS for some changes outside wxMac does not compile anymore + // FIXME CS for some changes outside wxMac does not compile anymore #if 0 std::__throws_bad_alloc = 0 ; #endif @@ -593,17 +593,17 @@ bool wxApp::Initialize() bool wxApp::OnInitGui() { - if( !wxAppBase::OnInitGui() ) - return false ; - -#if TARGET_CARBON - InstallStandardEventHandler( GetApplicationEventTarget() ) ; - - InstallApplicationEventHandler( - GetwxAppEventHandlerUPP(), - GetEventTypeCount(eventList), eventList, wxTheApp, &((EventHandlerRef)wxTheApp->m_macEventHandler)); + if( !wxAppBase::OnInitGui() ) + return false ; + +#if TARGET_CARBON + InstallStandardEventHandler( GetApplicationEventTarget() ) ; + + InstallApplicationEventHandler( + GetwxAppEventHandlerUPP(), + GetEventTypeCount(eventList), eventList, wxTheApp, &((EventHandlerRef)wxTheApp->m_macEventHandler)); #endif - + #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerUPP(AEHandleODoc) , @@ -632,7 +632,7 @@ bool wxApp::OnInitGui() 0 , FALSE ) ; #endif - return TRUE ; + return TRUE ; } void wxApp::CleanUp() @@ -879,7 +879,7 @@ void wxStAppResource::CloseSharedLibraryResource() // the __wxinitialize and __wxterminate must be used extern "C" { - void __sinit(void); /* (generated by linker) */ + void __sinit(void); /* (generated by linker) */ pascal OSErr __initialize(const CFragInitBlock *theInitBlock); pascal void __terminate(void); } @@ -1149,14 +1149,14 @@ bool wxApp::Initialized() int wxApp::MainLoop() { - m_keepGoing = TRUE; + m_keepGoing = TRUE; - while (m_keepGoing) - { - MacDoOneEvent() ; - } + while (m_keepGoing) + { + MacDoOneEvent() ; + } - return 0; + return 0; } // Returns TRUE if more time is needed. @@ -1171,18 +1171,18 @@ bool wxApp::ProcessIdle() void wxApp::ExitMainLoop() { - m_keepGoing = FALSE; + m_keepGoing = FALSE; } // Is a message/event pending? bool wxApp::Pending() { #if TARGET_CARBON - return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ; + return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ; #else EventRecord event ; - return EventAvail( everyEvent , &event ) ; + return EventAvail( everyEvent , &event ) ; #endif } @@ -1336,39 +1336,39 @@ bool wxApp::Yield(bool onlyIfNeeded) #if wxUSE_THREADS YieldToAnyThread() ; #endif - // by definition yield should handle all non-processed events + // by definition yield should handle all non-processed events #if TARGET_CARBON - EventRef theEvent; - - OSStatus status = noErr ; - do - { - s_inReceiveEvent = true ; - status = ReceiveNextEvent(0, NULL,kEventDurationNoWait,true,&theEvent) ; - s_inReceiveEvent = false ; - - if ( status == eventLoopTimedOutErr ) - { - // make sure next time the event loop will trigger idle events - sleepTime = kEventDurationNoWait ; - } - else if ( status == eventLoopQuitErr ) - { - // according to QA1061 this may also occur when a WakeUp Process - // is executed - } - else - { - MacHandleOneEvent( theEvent ) ; - ReleaseEvent(theEvent); - } - } while( status == noErr ) ; + EventRef theEvent; + + OSStatus status = noErr ; + do + { + s_inReceiveEvent = true ; + status = ReceiveNextEvent(0, NULL,kEventDurationNoWait,true,&theEvent) ; + s_inReceiveEvent = false ; + + if ( status == eventLoopTimedOutErr ) + { + // make sure next time the event loop will trigger idle events + sleepTime = kEventDurationNoWait ; + } + else if ( status == eventLoopQuitErr ) + { + // according to QA1061 this may also occur when a WakeUp Process + // is executed + } + else + { + MacHandleOneEvent( theEvent ) ; + ReleaseEvent(theEvent); + } + } while( status == noErr ) ; #else EventRecord event ; - // having a larger value here leads to large performance slowdowns - // so we cannot give background apps more processor time here - // we do so however having a large sleep value in the main event loop + // having a larger value here leads to large performance slowdowns + // so we cannot give background apps more processor time here + // we do so however having a large sleep value in the main event loop sleepTime = 0 ; while ( !IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, (RgnHandle) wxApp::s_macCursorRgn)) @@ -1449,32 +1449,32 @@ void wxApp::MacConvertPublicToPrivateScrap() void wxApp::MacDoOneEvent() { #if TARGET_CARBON - EventRef theEvent; + EventRef theEvent; - s_inReceiveEvent = true ; - OSStatus status = ReceiveNextEvent(0, NULL,sleepTime,true,&theEvent) ; - s_inReceiveEvent = false ; - if ( status == eventLoopTimedOutErr ) - { + s_inReceiveEvent = true ; + OSStatus status = ReceiveNextEvent(0, NULL,sleepTime,true,&theEvent) ; + s_inReceiveEvent = false ; + if ( status == eventLoopTimedOutErr ) + { if ( wxTheApp->ProcessIdle() ) - sleepTime = kEventDurationNoWait ; + sleepTime = kEventDurationNoWait ; else - sleepTime = kEventDurationForever ; - } - else if ( status == eventLoopQuitErr ) - { - // according to QA1061 this may also occur when a WakeUp Process - // is executed - } - else - { - MacHandleOneEvent( theEvent ) ; - ReleaseEvent(theEvent); - } + sleepTime = kEventDurationForever ; + } + else if ( status == eventLoopQuitErr ) + { + // according to QA1061 this may also occur when a WakeUp Process + // is executed + } + else + { + MacHandleOneEvent( theEvent ) ; + ReleaseEvent(theEvent); + } #else - EventRecord event ; + EventRecord event ; - EventMask eventMask = everyEvent ; + EventMask eventMask = everyEvent ; if (WaitNextEvent(eventMask, &event, sleepTime, (RgnHandle) s_macCursorRgn)) { @@ -1490,9 +1490,9 @@ void wxApp::MacDoOneEvent() ::IdleControls( window ) ; if ( wxTheApp->ProcessIdle() ) - sleepTime = 0 ; + sleepTime = 0 ; else - sleepTime = GetCaretTime() / 2 ; + sleepTime = GetCaretTime() / 2 ; } if ( event.what != kHighLevelEvent ) SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ; @@ -1506,10 +1506,10 @@ void wxApp::MacDoOneEvent() void wxApp::MacHandleOneEvent( WXEVENTREF evr ) { #if TARGET_CARBON - EventTargetRef theTarget; - theTarget = GetEventDispatcherTarget(); + EventTargetRef theTarget; + theTarget = GetEventDispatcherTarget(); m_macCurrentEvent = evr ; - SendEventToEventTarget ((EventRef) evr , theTarget); + SendEventToEventTarget ((EventRef) evr , theTarget); #else EventRecord* ev = (EventRecord*) evr ; m_macCurrentEvent = ev ; @@ -1784,15 +1784,15 @@ void wxApp::MacHandleMouseUpEvent( WXEVENTREF evr ) WindowRef window; short windowPart = inNoWindow ; - if ( wxTheApp->s_captureWindow ) - { - window = (WindowRef) s_captureWindow->MacGetRootWindow() ; - windowPart = inContent ; - } - else - { - windowPart = ::FindWindow(ev->where, &window) ; - } + if ( wxTheApp->s_captureWindow ) + { + window = (WindowRef) s_captureWindow->MacGetRootWindow() ; + windowPart = inContent ; + } + else + { + windowPart = ::FindWindow(ev->where, &window) ; + } switch (windowPart) { @@ -1990,14 +1990,14 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi keycode = short(keyInfo & keyCodeMask) >> 8 ; } long keyval = wxMacTranslateKey(keychar, keycode) ; - long realkeyval = keyval ; - if ( keyval == keychar ) - { - // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY (make upper first) - realkeyval = short(keymessage & charCodeMask) ; - keyval = wxToupper( keyval ) ; - } - + long realkeyval = keyval ; + if ( keyval == keychar ) + { + // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY (make upper first) + realkeyval = short(keymessage & charCodeMask) ; + keyval = wxToupper( keyval ) ; + } + wxKeyEvent event(wxEVT_KEY_DOWN); bool handled = false ; event.m_shiftDown = modifiers & shiftKey; @@ -2120,10 +2120,10 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier } long keyval = wxMacTranslateKey(keychar, keycode) ; - if ( keyval == keychar ) - { - keyval = wxToupper( keyval ) ; - } + if ( keyval == keychar ) + { + keyval = wxToupper( keyval ) ; + } bool handled = false ; wxKeyEvent event(wxEVT_KEY_UP); @@ -2248,15 +2248,15 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr ) wxWindow* currentMouseWindow = NULL ; - if (s_captureWindow ) - { - currentMouseWindow = s_captureWindow ; - } - else - { - wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , - ¤tMouseWindow ) ; - } + if (s_captureWindow ) + { + currentMouseWindow = s_captureWindow ; + } + else + { + wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , + ¤tMouseWindow ) ; + } if ( currentMouseWindow != wxWindow::s_lastMouseWindow ) { @@ -2299,16 +2299,16 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr ) short windowPart = inNoWindow ; - if ( s_captureWindow ) - { - window = (WindowRef) s_captureWindow->MacGetRootWindow() ; - windowPart = inContent ; - } - else - { - windowPart = ::FindWindow(ev->where, &window); - } - + if ( s_captureWindow ) + { + window = (WindowRef) s_captureWindow->MacGetRootWindow() ; + windowPart = inContent ; + } + else + { + windowPart = ::FindWindow(ev->where, &window); + } + switch (windowPart) { case inContent : @@ -2358,8 +2358,8 @@ void wxApp::MacHandleMenuCommand( wxUint32 id ) { item->Check( !item->IsChecked() ) ; } - - menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; + + menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; } #if !TARGET_CARBON @@ -2384,7 +2384,7 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum ) { MenuCommand id ; GetMenuItemCommandID( GetMenuHandle(macMenuId) , macMenuItemNum , &id ) ; - MacHandleMenuCommand( id ) ; + MacHandleMenuCommand( id ) ; } HiliteMenu(0); } diff --git a/src/mac/bitmap.cpp b/src/mac/bitmap.cpp index 212114ed9a..a60d47d2ed 100644 --- a/src/mac/bitmap.cpp +++ b/src/mac/bitmap.cpp @@ -218,8 +218,8 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , if ( mask ) { - Rect r ; - GetPortBounds( image , &r ) ; + Rect r ; + GetPortBounds( image , &r ) ; LockPixels(GetGWorldPixMap(mask) ) ; CopyBits(GetPortBitMapForCopyBits(mask) , &(**icon).iconBMap , &r , &r, srcCopy , nil ) ; @@ -229,8 +229,8 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , } else { - Rect r ; - GetPortBounds( image , &r ) ; + Rect r ; + GetPortBounds( image , &r ) ; LockPixels(GetGWorldPixMap(image)); CopyBits(GetPortBitMapForCopyBits(image) , &(**icon).iconBMap , &r , &r, srcCopy , nil ) ; @@ -275,7 +275,7 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask) if ( clipRgn ) GetRegionBounds( clipRgn , &portRect ) ; else - GetPortBounds( wp , &portRect ) ; + GetPortBounds( wp , &portRect ) ; pict = OpenPicture(&portRect); if(pict) { @@ -283,7 +283,7 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask) RGBBackColor( &white ) ; if ( clipRgn ) - SetClip( clipRgn ) ; + SetClip( clipRgn ) ; LockPixels( GetGWorldPixMap( wp ) ) ; CopyBits(GetPortBitMapForCopyBits(wp), @@ -296,7 +296,7 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask) } SetGWorld( origPort , origDev ) ; if ( clipRgn ) - DisposeRgn( clipRgn ) ; + DisposeRgn( clipRgn ) ; return pict; } @@ -335,19 +335,19 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi info->contentType = kControlContentPictHandle ; if ( bitmap.GetMask() ) { - info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap() ) ) ; + info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap() ) ) ; } else { - info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ) ; + info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ) ; } } } - else if ( bmap->m_bitmapType == kMacBitmapTypeIcon ) - { - info->contentType = kControlContentCIconHandle ; - info->u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ; - } + else if ( bmap->m_bitmapType == kMacBitmapTypeIcon ) + { + info->contentType = kControlContentCIconHandle ; + info->u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ; + } } } @@ -369,46 +369,46 @@ wxBitmapRefData::wxBitmapRefData() // TODO move this to a public function of Bitmap Ref static void DisposeBitmapRefData(wxBitmapRefData *data) { - if ( !data ) - return ; - - switch (data->m_bitmapType) - { - case kMacBitmapTypePict : - { - if ( data->m_hPict ) - { - KillPicture( MAC_WXHMETAFILE( data->m_hPict ) ) ; - data->m_hPict = NULL ; - } - } - break ; - case kMacBitmapTypeGrafWorld : - { - if ( data->m_hBitmap ) - { - wxMacDestroyGWorld( MAC_WXHBITMAP(data->m_hBitmap) ) ; - data->m_hBitmap = NULL ; - } - } - break ; - case kMacBitmapTypeIcon : - if ( data->m_hIcon ) - { - DisposeCIcon( MAC_WXHICON(data->m_hIcon) ) ; - data->m_hIcon = NULL ; - } - - default : - // unkown type ? - break ; - } + if ( !data ) + return ; + + switch (data->m_bitmapType) + { + case kMacBitmapTypePict : + { + if ( data->m_hPict ) + { + KillPicture( MAC_WXHMETAFILE( data->m_hPict ) ) ; + data->m_hPict = NULL ; + } + } + break ; + case kMacBitmapTypeGrafWorld : + { + if ( data->m_hBitmap ) + { + wxMacDestroyGWorld( MAC_WXHBITMAP(data->m_hBitmap) ) ; + data->m_hBitmap = NULL ; + } + } + break ; + case kMacBitmapTypeIcon : + if ( data->m_hIcon ) + { + DisposeCIcon( MAC_WXHICON(data->m_hIcon) ) ; + data->m_hIcon = NULL ; + } + + default : + // unkown type ? + break ; + } - if (data->m_bitmapMask) - { - delete data->m_bitmapMask; - data->m_bitmapMask = NULL; - } + if (data->m_bitmapMask) + { + delete data->m_bitmapMask; + data->m_bitmapMask = NULL; + } } wxBitmapRefData::~wxBitmapRefData() @@ -642,8 +642,8 @@ void wxBitmap::SetHBITMAP(WXHBITMAP bmp) { if (!M_BITMAPDATA) m_refData = new wxBitmapRefData; - else - DisposeBitmapRefData( M_BITMAPDATA ) ; + else + DisposeBitmapRefData( M_BITMAPDATA ) ; M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; M_BITMAPDATA->m_hBitmap = bmp ; @@ -654,8 +654,8 @@ void wxBitmap::SetHICON(WXHICON ico) { if (!M_BITMAPDATA) m_refData = new wxBitmapRefData; - else - DisposeBitmapRefData( M_BITMAPDATA ) ; + else + DisposeBitmapRefData( M_BITMAPDATA ) ; M_BITMAPDATA->m_bitmapType = kMacBitmapTypeIcon ; M_BITMAPDATA->m_hIcon = ico ; @@ -666,8 +666,8 @@ void wxBitmap::SetPict(WXHMETAFILE pict) { if (!M_BITMAPDATA) m_refData = new wxBitmapRefData; - else - DisposeBitmapRefData( M_BITMAPDATA ) ; + else + DisposeBitmapRefData( M_BITMAPDATA ) ; M_BITMAPDATA->m_bitmapType = kMacBitmapTypePict ; M_BITMAPDATA->m_hPict = pict ; @@ -820,26 +820,26 @@ wxImage wxBitmap::ConvertToImage() const GetGWorld( &origPort, &origDevice ); if ( GetBitmapType() != kMacBitmapTypeGrafWorld ) { - tempPort = wxMacCreateGWorld( width , height , -1) ; + tempPort = wxMacCreateGWorld( width , height , -1) ; } else { - tempPort = (GWorldPtr) GetHBITMAP() ; - } - LockPixels(GetGWorldPixMap(tempPort)); - SetGWorld( tempPort, NULL); - if ( GetBitmapType() == kMacBitmapTypePict || GetBitmapType() == kMacBitmapTypeIcon ) - { + tempPort = (GWorldPtr) GetHBITMAP() ; + } + LockPixels(GetGWorldPixMap(tempPort)); + SetGWorld( tempPort, NULL); + if ( GetBitmapType() == kMacBitmapTypePict || GetBitmapType() == kMacBitmapTypeIcon ) + { Rect bitmaprect = { 0 , 0 , height, width }; - if ( GetBitmapType() == kMacBitmapTypeIcon ) - { - ::PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(GetHICON()) ) ; - maskRgn = NewRgn() ; - BitMapToRegion( maskRgn , &(**(MAC_WXHICON(GetHICON()))).iconMask ) ; + if ( GetBitmapType() == kMacBitmapTypeIcon ) + { + ::PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(GetHICON()) ) ; + maskRgn = NewRgn() ; + BitMapToRegion( maskRgn , &(**(MAC_WXHICON(GetHICON()))).iconMask ) ; } - else - ::DrawPicture( (PicHandle) GetPict(), &bitmaprect ) ; - } + else + ::DrawPicture( (PicHandle) GetPict(), &bitmaprect ) ; + } // Copy data into image index = 0; for (int yy = 0; yy < height; yy++) @@ -854,28 +854,28 @@ wxImage wxBitmap::ConvertToImage() const data[index + 1] = g; data[index + 2] = b; if ( maskRgn ) - { - Point pt ; - pt.h = xx ; - pt.v = yy ; - if ( !PtInRgn( pt , maskRgn ) ) - { + { + Point pt ; + pt.h = xx ; + pt.v = yy ; + if ( !PtInRgn( pt , maskRgn ) ) + { data[index ] = mask_r; data[index + 1] = mask_g; data[index + 2] = mask_b; - } + } } else { - if (mask) - { - if (mask->PointMasked(xx,yy)) - { - data[index ] = mask_r; - data[index + 1] = mask_g; - data[index + 2] = mask_b; - } - } + if (mask) + { + if (mask->PointMasked(xx,yy)) + { + data[index ] = mask_r; + data[index + 1] = mask_g; + data[index + 2] = mask_b; + } + } } index += 3; } @@ -891,11 +891,11 @@ wxImage wxBitmap::ConvertToImage() const SetGWorld(origPort, origDevice); if ( GetBitmapType() != kMacBitmapTypeGrafWorld ) { - wxMacDestroyGWorld( tempPort ) ; + wxMacDestroyGWorld( tempPort ) ; } if ( maskRgn ) { - DisposeRgn( maskRgn ) ; + DisposeRgn( maskRgn ) ; } return image; @@ -1038,33 +1038,33 @@ WXHBITMAP wxBitmap::GetHBITMAP() const WXHMETAFILE wxBitmap::GetPict( bool *created ) const { - wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ); + wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ); - PicHandle picture = NULL ; // This is the returned picture - if ( created ) - (*created) = false ; - // If bitmap already in Pict format return pointer - if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) { - return M_BITMAPDATA->m_hPict; - } - else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) { - // Invalid bitmap - return NULL; - } - else - { - if ( GetMask() ) - { - picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , MAC_WXHBITMAP(GetMask()->GetMaskBitmap() ) ) ; - } - else - { - picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , NULL ) ; - } - if ( created && picture ) - (*created) = true ; + PicHandle picture = NULL ; // This is the returned picture + if ( created ) + (*created) = false ; + // If bitmap already in Pict format return pointer + if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) { + return M_BITMAPDATA->m_hPict; + } + else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) { + // Invalid bitmap + return NULL; + } + else + { + if ( GetMask() ) + { + picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , MAC_WXHBITMAP(GetMask()->GetMaskBitmap() ) ) ; + } + else + { + picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , NULL ) ; + } + if ( created && picture ) + (*created) = true ; } - return picture ; + return picture ; } /* diff --git a/src/mac/bmpbuttn.cpp b/src/mac/bmpbuttn.cpp index a98ad95896..ebf8021262 100644 --- a/src/mac/bmpbuttn.cpp +++ b/src/mac/bmpbuttn.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -45,35 +45,35 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit m_windowId = id; if ( width == -1 && bitmap.Ok()) - width = bitmap.GetWidth() + 2*m_marginX; + width = bitmap.GetWidth() + 2*m_marginX; if ( height == -1 && bitmap.Ok()) - height = bitmap.GetHeight() + 2*m_marginY; + height = bitmap.GetHeight() + 2*m_marginY; - Rect bounds ; - Str255 title ; + Rect bounds ; + Str255 title ; m_bmpNormal = bitmap; - wxBitmapRefData * bmap = NULL ; - - if ( m_bmpNormal.Ok() ) - bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ; - - MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; + wxBitmapRefData * bmap = NULL ; + + if ( m_bmpNormal.Ok() ) + bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ; + + MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , - kControlBehaviorOffsetContents + - ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ? - kControlContentCIconHandle : kControlContentPictHandle ) , 0, - (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - - ControlButtonContentInfo info ; - wxMacCreateBitmapButton( &info , m_bmpNormal ) ; - if ( info.contentType != kControlNoContent ) - { - ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , + kControlBehaviorOffsetContents + + ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ? + kControlContentCIconHandle : kControlContentPictHandle ) , 0, + (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + + ControlButtonContentInfo info ; + wxMacCreateBitmapButton( &info , m_bmpNormal ) ; + if ( info.contentType != kControlNoContent ) + { + ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; } - MacPostControlCreate() ; + MacPostControlCreate() ; return TRUE; } diff --git a/src/mac/brush.cpp b/src/mac/brush.cpp index 5589004fbe..d484314a2c 100644 --- a/src/mac/brush.cpp +++ b/src/mac/brush.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -112,17 +112,17 @@ wxBrush::wxBrush(ThemeBrush macThemeBrush ) } void wxBrush::Unshare() { - // Don't change shared data - if (!m_refData) + // Don't change shared data + if (!m_refData) { - m_refData = new wxBrushRefData(); - } + m_refData = new wxBrushRefData(); + } else { - wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData); - UnRef(); - m_refData = ref; - } + wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData); + UnRef(); + m_refData = ref; + } } void wxBrush::SetColour(const wxColour& col) @@ -203,25 +203,27 @@ unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const } } -short wxBrush::GetMacTheme() const +short wxBrush::GetMacTheme() const { - return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack); -}; + return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack); +} wxColour& wxBrush::GetColour() const -{ return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); }; +{ + return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); +} int wxBrush::GetStyle() const { - return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); -}; + return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); +} wxBitmap *wxBrush::GetStipple() const { - return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); -}; + return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); +} wxMacBrushKind wxBrush::MacGetBrushKind() const { - return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour); -}; + return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour); +} \ No newline at end of file diff --git a/src/mac/button.cpp b/src/mac/button.cpp index ca997d6926..763048808e 100644 --- a/src/mac/button.cpp +++ b/src/mac/button.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -34,23 +34,23 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxValidator& validator, const wxString& name) { - Rect bounds ; - Str255 title ; + Rect bounds ; + Str255 title ; if ( UMAHasAquaLayout() ) { m_macHorizontalBorder = kMacOSXHorizontalBorder; m_macVerticalBorder = kMacOSXVerticalBorder; } - - MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlPushButtonProc , (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - - MacPostControlCreate() ; - + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlPushButtonProc , (long) this ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + + MacPostControlCreate() ; + return TRUE; } @@ -65,19 +65,19 @@ void wxButton::SetDefault() parent->SetDefaultItem(this); } - Boolean inData; - if ( btnOldDefault && btnOldDefault->m_macControl ) - { - inData = 0; - ::SetControlData( (ControlHandle) btnOldDefault->m_macControl , kControlButtonPart , - kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; - } - if ( (ControlHandle) m_macControl ) - { - inData = 1; - ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , - kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; - } + Boolean inData; + if ( btnOldDefault && btnOldDefault->m_macControl ) + { + inData = 0; + ::SetControlData( (ControlHandle) btnOldDefault->m_macControl , kControlButtonPart , + kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; + } + if ( (ControlHandle) m_macControl ) + { + inData = 1; + ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , + kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; + } } wxSize wxButton::DoGetBestSize() const @@ -85,7 +85,7 @@ wxSize wxButton::DoGetBestSize() const wxSize sz = GetDefaultSize() ; int wBtn = m_label.Length() * 8 + 12 + 2 * kMacOSXHorizontalBorder ; - + if (wBtn > sz.x) sz.x = wBtn; return sz ; @@ -94,7 +94,7 @@ wxSize wxButton::DoGetBestSize() const wxSize wxButton::GetDefaultSize() { int wBtn = 70 ; - int hBtn = 20 ; + int hBtn = 20 ; if ( UMAHasAquaLayout() ) { diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index fcc04b18cb..48b2c379c8 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -289,21 +289,21 @@ void wxApp::MacNewFile() #if TARGET_CARBON - static const EventTypeSpec eventList[] = - { - { kEventClassCommand, kEventProcessCommand } , - { kEventClassCommand, kEventCommandUpdateStatus } , - - { kEventClassApplication , kEventAppActivated } , - { kEventClassApplication , kEventAppDeactivated } , - // handling the quit event is not recommended by apple - // rather using the quit apple event - which we do - - { kEventClassAppleEvent , kEventAppleEvent } , - - { kEventClassMouse , kEventMouseDown } , - { 'WXMC' , 'WXMC' } - } ; + static const EventTypeSpec eventList[] = + { + { kEventClassCommand, kEventProcessCommand } , + { kEventClassCommand, kEventCommandUpdateStatus } , + + { kEventClassApplication , kEventAppActivated } , + { kEventClassApplication , kEventAppDeactivated } , + // handling the quit event is not recommended by apple + // rather using the quit apple event - which we do + + { kEventClassAppleEvent , kEventAppleEvent } , + + { kEventClassMouse , kEventMouseDown } , + { 'WXMC' , 'WXMC' } + } ; static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { @@ -323,23 +323,23 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef switch( GetEventKind(event) ) { - case kEventMouseDown : - { - Point point ; - WindowRef window ; - - GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof( Point ), NULL, &point ); - short windowPart = ::FindWindow(point, &window); - - if ( windowPart == inMenuBar ) - { - MenuSelect( point ) ; - result = noErr ; - } - } - break ; - } + case kEventMouseDown : + { + Point point ; + WindowRef window ; + + GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, + sizeof( Point ), NULL, &point ); + short windowPart = ::FindWindow(point, &window); + + if ( windowPart == inMenuBar ) + { + MenuSelect( point ) ; + result = noErr ; + } + } + break ; + } return result ; } @@ -348,15 +348,15 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR { OSStatus result = eventNotHandledErr ; - HICommand command ; - - GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, - sizeof( HICommand ), NULL, &command ); + HICommand command ; + + GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, + sizeof( HICommand ), NULL, &command ); - MenuCommand id = command.commandID ; - if ( id == kHICommandPreferences ) - id = wxApp::s_macPreferencesMenuItemId ; - + MenuCommand id = command.commandID ; + if ( id == kHICommandPreferences ) + id = wxApp::s_macPreferencesMenuItemId ; + wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ; wxMenu* menu = NULL ; wxMenuItem* item = NULL ; @@ -365,28 +365,28 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR item = mbar->FindItem( id , &menu ) ; if ( item == NULL || menu == NULL || mbar == NULL ) - return result ; - - switch( GetEventKind( event ) ) - { - case kEventProcessCommand : - { - if (item->IsCheckable()) - { - item->Check( !item->IsChecked() ) ; - } - - menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; - result = noErr ; - } - break ; - case kEventCommandUpdateStatus: - // eventually trigger an updateui round - result = noErr ; - break ; - default : - break ; - } + return result ; + + switch( GetEventKind( event ) ) + { + case kEventProcessCommand : + { + if (item->IsCheckable()) + { + item->Check( !item->IsChecked() ) ; + } + + menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; + result = noErr ; + } + break ; + case kEventCommandUpdateStatus: + // eventually trigger an updateui round + result = noErr ; + break ; + default : + break ; + } return result ; } @@ -394,23 +394,23 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR static pascal OSStatus ApplicationEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; - switch ( GetEventKind( event ) ) - { - case kEventAppActivated : - { - wxTheApp->MacResume( true ) ; - result = noErr ; - } - break ; - case kEventAppDeactivated : - { - wxTheApp->MacSuspend( true ) ; - result = noErr ; - } - break ; - default : - break ; - } + switch ( GetEventKind( event ) ) + { + case kEventAppActivated : + { + wxTheApp->MacResume( true ) ; + result = noErr ; + } + break ; + case kEventAppDeactivated : + { + wxTheApp->MacSuspend( true ) ; + result = noErr ; + } + break ; + default : + break ; + } return result ; } @@ -419,27 +419,27 @@ pascal OSStatus wxAppEventHandler( EventHandlerCallRef handler , EventRef event OSStatus result = eventNotHandledErr ; switch( GetEventClass( event ) ) { - case kEventClassCommand : - result = CommandEventHandler( handler , event , data ) ; - break ; - case kEventClassApplication : - result = ApplicationEventHandler( handler , event , data ) ; - break ; - case kEventClassMenu : - result = MenuEventHandler( handler , event , data ) ; - break ; - case kEventClassMouse : - result = MouseEventHandler( handler , event , data ) ; - break ; - case kEventClassAppleEvent : - { - EventRecord rec ; - wxMacConvertEventToRecord( event , &rec ) ; - result = AEProcessAppleEvent( &rec ) ; - } - break ; - default : - break ; + case kEventClassCommand : + result = CommandEventHandler( handler , event , data ) ; + break ; + case kEventClassApplication : + result = ApplicationEventHandler( handler , event , data ) ; + break ; + case kEventClassMenu : + result = MenuEventHandler( handler , event , data ) ; + break ; + case kEventClassMouse : + result = MouseEventHandler( handler , event , data ) ; + break ; + case kEventClassAppleEvent : + { + EventRecord rec ; + wxMacConvertEventToRecord( event , &rec ) ; + result = AEProcessAppleEvent( &rec ) ; + } + break ; + default : + break ; } return result ; @@ -532,7 +532,7 @@ bool wxApp::Initialize() #ifndef __DARWIN__ // now avoid exceptions thrown for new (bad_alloc) - // FIXME CS for some changes outside wxMac does not compile anymore + // FIXME CS for some changes outside wxMac does not compile anymore #if 0 std::__throws_bad_alloc = 0 ; #endif @@ -593,17 +593,17 @@ bool wxApp::Initialize() bool wxApp::OnInitGui() { - if( !wxAppBase::OnInitGui() ) - return false ; - -#if TARGET_CARBON - InstallStandardEventHandler( GetApplicationEventTarget() ) ; - - InstallApplicationEventHandler( - GetwxAppEventHandlerUPP(), - GetEventTypeCount(eventList), eventList, wxTheApp, &((EventHandlerRef)wxTheApp->m_macEventHandler)); + if( !wxAppBase::OnInitGui() ) + return false ; + +#if TARGET_CARBON + InstallStandardEventHandler( GetApplicationEventTarget() ) ; + + InstallApplicationEventHandler( + GetwxAppEventHandlerUPP(), + GetEventTypeCount(eventList), eventList, wxTheApp, &((EventHandlerRef)wxTheApp->m_macEventHandler)); #endif - + #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerUPP(AEHandleODoc) , @@ -632,7 +632,7 @@ bool wxApp::OnInitGui() 0 , FALSE ) ; #endif - return TRUE ; + return TRUE ; } void wxApp::CleanUp() @@ -879,7 +879,7 @@ void wxStAppResource::CloseSharedLibraryResource() // the __wxinitialize and __wxterminate must be used extern "C" { - void __sinit(void); /* (generated by linker) */ + void __sinit(void); /* (generated by linker) */ pascal OSErr __initialize(const CFragInitBlock *theInitBlock); pascal void __terminate(void); } @@ -1149,14 +1149,14 @@ bool wxApp::Initialized() int wxApp::MainLoop() { - m_keepGoing = TRUE; + m_keepGoing = TRUE; - while (m_keepGoing) - { - MacDoOneEvent() ; - } + while (m_keepGoing) + { + MacDoOneEvent() ; + } - return 0; + return 0; } // Returns TRUE if more time is needed. @@ -1171,18 +1171,18 @@ bool wxApp::ProcessIdle() void wxApp::ExitMainLoop() { - m_keepGoing = FALSE; + m_keepGoing = FALSE; } // Is a message/event pending? bool wxApp::Pending() { #if TARGET_CARBON - return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ; + return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ; #else EventRecord event ; - return EventAvail( everyEvent , &event ) ; + return EventAvail( everyEvent , &event ) ; #endif } @@ -1336,39 +1336,39 @@ bool wxApp::Yield(bool onlyIfNeeded) #if wxUSE_THREADS YieldToAnyThread() ; #endif - // by definition yield should handle all non-processed events + // by definition yield should handle all non-processed events #if TARGET_CARBON - EventRef theEvent; - - OSStatus status = noErr ; - do - { - s_inReceiveEvent = true ; - status = ReceiveNextEvent(0, NULL,kEventDurationNoWait,true,&theEvent) ; - s_inReceiveEvent = false ; - - if ( status == eventLoopTimedOutErr ) - { - // make sure next time the event loop will trigger idle events - sleepTime = kEventDurationNoWait ; - } - else if ( status == eventLoopQuitErr ) - { - // according to QA1061 this may also occur when a WakeUp Process - // is executed - } - else - { - MacHandleOneEvent( theEvent ) ; - ReleaseEvent(theEvent); - } - } while( status == noErr ) ; + EventRef theEvent; + + OSStatus status = noErr ; + do + { + s_inReceiveEvent = true ; + status = ReceiveNextEvent(0, NULL,kEventDurationNoWait,true,&theEvent) ; + s_inReceiveEvent = false ; + + if ( status == eventLoopTimedOutErr ) + { + // make sure next time the event loop will trigger idle events + sleepTime = kEventDurationNoWait ; + } + else if ( status == eventLoopQuitErr ) + { + // according to QA1061 this may also occur when a WakeUp Process + // is executed + } + else + { + MacHandleOneEvent( theEvent ) ; + ReleaseEvent(theEvent); + } + } while( status == noErr ) ; #else EventRecord event ; - // having a larger value here leads to large performance slowdowns - // so we cannot give background apps more processor time here - // we do so however having a large sleep value in the main event loop + // having a larger value here leads to large performance slowdowns + // so we cannot give background apps more processor time here + // we do so however having a large sleep value in the main event loop sleepTime = 0 ; while ( !IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, (RgnHandle) wxApp::s_macCursorRgn)) @@ -1449,32 +1449,32 @@ void wxApp::MacConvertPublicToPrivateScrap() void wxApp::MacDoOneEvent() { #if TARGET_CARBON - EventRef theEvent; + EventRef theEvent; - s_inReceiveEvent = true ; - OSStatus status = ReceiveNextEvent(0, NULL,sleepTime,true,&theEvent) ; - s_inReceiveEvent = false ; - if ( status == eventLoopTimedOutErr ) - { + s_inReceiveEvent = true ; + OSStatus status = ReceiveNextEvent(0, NULL,sleepTime,true,&theEvent) ; + s_inReceiveEvent = false ; + if ( status == eventLoopTimedOutErr ) + { if ( wxTheApp->ProcessIdle() ) - sleepTime = kEventDurationNoWait ; + sleepTime = kEventDurationNoWait ; else - sleepTime = kEventDurationForever ; - } - else if ( status == eventLoopQuitErr ) - { - // according to QA1061 this may also occur when a WakeUp Process - // is executed - } - else - { - MacHandleOneEvent( theEvent ) ; - ReleaseEvent(theEvent); - } + sleepTime = kEventDurationForever ; + } + else if ( status == eventLoopQuitErr ) + { + // according to QA1061 this may also occur when a WakeUp Process + // is executed + } + else + { + MacHandleOneEvent( theEvent ) ; + ReleaseEvent(theEvent); + } #else - EventRecord event ; + EventRecord event ; - EventMask eventMask = everyEvent ; + EventMask eventMask = everyEvent ; if (WaitNextEvent(eventMask, &event, sleepTime, (RgnHandle) s_macCursorRgn)) { @@ -1490,9 +1490,9 @@ void wxApp::MacDoOneEvent() ::IdleControls( window ) ; if ( wxTheApp->ProcessIdle() ) - sleepTime = 0 ; + sleepTime = 0 ; else - sleepTime = GetCaretTime() / 2 ; + sleepTime = GetCaretTime() / 2 ; } if ( event.what != kHighLevelEvent ) SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ; @@ -1506,10 +1506,10 @@ void wxApp::MacDoOneEvent() void wxApp::MacHandleOneEvent( WXEVENTREF evr ) { #if TARGET_CARBON - EventTargetRef theTarget; - theTarget = GetEventDispatcherTarget(); + EventTargetRef theTarget; + theTarget = GetEventDispatcherTarget(); m_macCurrentEvent = evr ; - SendEventToEventTarget ((EventRef) evr , theTarget); + SendEventToEventTarget ((EventRef) evr , theTarget); #else EventRecord* ev = (EventRecord*) evr ; m_macCurrentEvent = ev ; @@ -1784,15 +1784,15 @@ void wxApp::MacHandleMouseUpEvent( WXEVENTREF evr ) WindowRef window; short windowPart = inNoWindow ; - if ( wxTheApp->s_captureWindow ) - { - window = (WindowRef) s_captureWindow->MacGetRootWindow() ; - windowPart = inContent ; - } - else - { - windowPart = ::FindWindow(ev->where, &window) ; - } + if ( wxTheApp->s_captureWindow ) + { + window = (WindowRef) s_captureWindow->MacGetRootWindow() ; + windowPart = inContent ; + } + else + { + windowPart = ::FindWindow(ev->where, &window) ; + } switch (windowPart) { @@ -1990,14 +1990,14 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi keycode = short(keyInfo & keyCodeMask) >> 8 ; } long keyval = wxMacTranslateKey(keychar, keycode) ; - long realkeyval = keyval ; - if ( keyval == keychar ) - { - // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY (make upper first) - realkeyval = short(keymessage & charCodeMask) ; - keyval = wxToupper( keyval ) ; - } - + long realkeyval = keyval ; + if ( keyval == keychar ) + { + // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY (make upper first) + realkeyval = short(keymessage & charCodeMask) ; + keyval = wxToupper( keyval ) ; + } + wxKeyEvent event(wxEVT_KEY_DOWN); bool handled = false ; event.m_shiftDown = modifiers & shiftKey; @@ -2120,10 +2120,10 @@ bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifier } long keyval = wxMacTranslateKey(keychar, keycode) ; - if ( keyval == keychar ) - { - keyval = wxToupper( keyval ) ; - } + if ( keyval == keychar ) + { + keyval = wxToupper( keyval ) ; + } bool handled = false ; wxKeyEvent event(wxEVT_KEY_UP); @@ -2248,15 +2248,15 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr ) wxWindow* currentMouseWindow = NULL ; - if (s_captureWindow ) - { - currentMouseWindow = s_captureWindow ; - } - else - { - wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , - ¤tMouseWindow ) ; - } + if (s_captureWindow ) + { + currentMouseWindow = s_captureWindow ; + } + else + { + wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , + ¤tMouseWindow ) ; + } if ( currentMouseWindow != wxWindow::s_lastMouseWindow ) { @@ -2299,16 +2299,16 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr ) short windowPart = inNoWindow ; - if ( s_captureWindow ) - { - window = (WindowRef) s_captureWindow->MacGetRootWindow() ; - windowPart = inContent ; - } - else - { - windowPart = ::FindWindow(ev->where, &window); - } - + if ( s_captureWindow ) + { + window = (WindowRef) s_captureWindow->MacGetRootWindow() ; + windowPart = inContent ; + } + else + { + windowPart = ::FindWindow(ev->where, &window); + } + switch (windowPart) { case inContent : @@ -2358,8 +2358,8 @@ void wxApp::MacHandleMenuCommand( wxUint32 id ) { item->Check( !item->IsChecked() ) ; } - - menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; + + menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ; } #if !TARGET_CARBON @@ -2384,7 +2384,7 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum ) { MenuCommand id ; GetMenuItemCommandID( GetMenuHandle(macMenuId) , macMenuItemNum , &id ) ; - MacHandleMenuCommand( id ) ; + MacHandleMenuCommand( id ) ; } HiliteMenu(0); } diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index 212114ed9a..a60d47d2ed 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -218,8 +218,8 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , if ( mask ) { - Rect r ; - GetPortBounds( image , &r ) ; + Rect r ; + GetPortBounds( image , &r ) ; LockPixels(GetGWorldPixMap(mask) ) ; CopyBits(GetPortBitMapForCopyBits(mask) , &(**icon).iconBMap , &r , &r, srcCopy , nil ) ; @@ -229,8 +229,8 @@ CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , } else { - Rect r ; - GetPortBounds( image , &r ) ; + Rect r ; + GetPortBounds( image , &r ) ; LockPixels(GetGWorldPixMap(image)); CopyBits(GetPortBitMapForCopyBits(image) , &(**icon).iconBMap , &r , &r, srcCopy , nil ) ; @@ -275,7 +275,7 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask) if ( clipRgn ) GetRegionBounds( clipRgn , &portRect ) ; else - GetPortBounds( wp , &portRect ) ; + GetPortBounds( wp , &portRect ) ; pict = OpenPicture(&portRect); if(pict) { @@ -283,7 +283,7 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask) RGBBackColor( &white ) ; if ( clipRgn ) - SetClip( clipRgn ) ; + SetClip( clipRgn ) ; LockPixels( GetGWorldPixMap( wp ) ) ; CopyBits(GetPortBitMapForCopyBits(wp), @@ -296,7 +296,7 @@ PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask) } SetGWorld( origPort , origDev ) ; if ( clipRgn ) - DisposeRgn( clipRgn ) ; + DisposeRgn( clipRgn ) ; return pict; } @@ -335,19 +335,19 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi info->contentType = kControlContentPictHandle ; if ( bitmap.GetMask() ) { - info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap() ) ) ; + info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap() ) ) ; } else { - info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ) ; + info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ) ; } } } - else if ( bmap->m_bitmapType == kMacBitmapTypeIcon ) - { - info->contentType = kControlContentCIconHandle ; - info->u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ; - } + else if ( bmap->m_bitmapType == kMacBitmapTypeIcon ) + { + info->contentType = kControlContentCIconHandle ; + info->u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ; + } } } @@ -369,46 +369,46 @@ wxBitmapRefData::wxBitmapRefData() // TODO move this to a public function of Bitmap Ref static void DisposeBitmapRefData(wxBitmapRefData *data) { - if ( !data ) - return ; - - switch (data->m_bitmapType) - { - case kMacBitmapTypePict : - { - if ( data->m_hPict ) - { - KillPicture( MAC_WXHMETAFILE( data->m_hPict ) ) ; - data->m_hPict = NULL ; - } - } - break ; - case kMacBitmapTypeGrafWorld : - { - if ( data->m_hBitmap ) - { - wxMacDestroyGWorld( MAC_WXHBITMAP(data->m_hBitmap) ) ; - data->m_hBitmap = NULL ; - } - } - break ; - case kMacBitmapTypeIcon : - if ( data->m_hIcon ) - { - DisposeCIcon( MAC_WXHICON(data->m_hIcon) ) ; - data->m_hIcon = NULL ; - } - - default : - // unkown type ? - break ; - } + if ( !data ) + return ; + + switch (data->m_bitmapType) + { + case kMacBitmapTypePict : + { + if ( data->m_hPict ) + { + KillPicture( MAC_WXHMETAFILE( data->m_hPict ) ) ; + data->m_hPict = NULL ; + } + } + break ; + case kMacBitmapTypeGrafWorld : + { + if ( data->m_hBitmap ) + { + wxMacDestroyGWorld( MAC_WXHBITMAP(data->m_hBitmap) ) ; + data->m_hBitmap = NULL ; + } + } + break ; + case kMacBitmapTypeIcon : + if ( data->m_hIcon ) + { + DisposeCIcon( MAC_WXHICON(data->m_hIcon) ) ; + data->m_hIcon = NULL ; + } + + default : + // unkown type ? + break ; + } - if (data->m_bitmapMask) - { - delete data->m_bitmapMask; - data->m_bitmapMask = NULL; - } + if (data->m_bitmapMask) + { + delete data->m_bitmapMask; + data->m_bitmapMask = NULL; + } } wxBitmapRefData::~wxBitmapRefData() @@ -642,8 +642,8 @@ void wxBitmap::SetHBITMAP(WXHBITMAP bmp) { if (!M_BITMAPDATA) m_refData = new wxBitmapRefData; - else - DisposeBitmapRefData( M_BITMAPDATA ) ; + else + DisposeBitmapRefData( M_BITMAPDATA ) ; M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; M_BITMAPDATA->m_hBitmap = bmp ; @@ -654,8 +654,8 @@ void wxBitmap::SetHICON(WXHICON ico) { if (!M_BITMAPDATA) m_refData = new wxBitmapRefData; - else - DisposeBitmapRefData( M_BITMAPDATA ) ; + else + DisposeBitmapRefData( M_BITMAPDATA ) ; M_BITMAPDATA->m_bitmapType = kMacBitmapTypeIcon ; M_BITMAPDATA->m_hIcon = ico ; @@ -666,8 +666,8 @@ void wxBitmap::SetPict(WXHMETAFILE pict) { if (!M_BITMAPDATA) m_refData = new wxBitmapRefData; - else - DisposeBitmapRefData( M_BITMAPDATA ) ; + else + DisposeBitmapRefData( M_BITMAPDATA ) ; M_BITMAPDATA->m_bitmapType = kMacBitmapTypePict ; M_BITMAPDATA->m_hPict = pict ; @@ -820,26 +820,26 @@ wxImage wxBitmap::ConvertToImage() const GetGWorld( &origPort, &origDevice ); if ( GetBitmapType() != kMacBitmapTypeGrafWorld ) { - tempPort = wxMacCreateGWorld( width , height , -1) ; + tempPort = wxMacCreateGWorld( width , height , -1) ; } else { - tempPort = (GWorldPtr) GetHBITMAP() ; - } - LockPixels(GetGWorldPixMap(tempPort)); - SetGWorld( tempPort, NULL); - if ( GetBitmapType() == kMacBitmapTypePict || GetBitmapType() == kMacBitmapTypeIcon ) - { + tempPort = (GWorldPtr) GetHBITMAP() ; + } + LockPixels(GetGWorldPixMap(tempPort)); + SetGWorld( tempPort, NULL); + if ( GetBitmapType() == kMacBitmapTypePict || GetBitmapType() == kMacBitmapTypeIcon ) + { Rect bitmaprect = { 0 , 0 , height, width }; - if ( GetBitmapType() == kMacBitmapTypeIcon ) - { - ::PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(GetHICON()) ) ; - maskRgn = NewRgn() ; - BitMapToRegion( maskRgn , &(**(MAC_WXHICON(GetHICON()))).iconMask ) ; + if ( GetBitmapType() == kMacBitmapTypeIcon ) + { + ::PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(GetHICON()) ) ; + maskRgn = NewRgn() ; + BitMapToRegion( maskRgn , &(**(MAC_WXHICON(GetHICON()))).iconMask ) ; } - else - ::DrawPicture( (PicHandle) GetPict(), &bitmaprect ) ; - } + else + ::DrawPicture( (PicHandle) GetPict(), &bitmaprect ) ; + } // Copy data into image index = 0; for (int yy = 0; yy < height; yy++) @@ -854,28 +854,28 @@ wxImage wxBitmap::ConvertToImage() const data[index + 1] = g; data[index + 2] = b; if ( maskRgn ) - { - Point pt ; - pt.h = xx ; - pt.v = yy ; - if ( !PtInRgn( pt , maskRgn ) ) - { + { + Point pt ; + pt.h = xx ; + pt.v = yy ; + if ( !PtInRgn( pt , maskRgn ) ) + { data[index ] = mask_r; data[index + 1] = mask_g; data[index + 2] = mask_b; - } + } } else { - if (mask) - { - if (mask->PointMasked(xx,yy)) - { - data[index ] = mask_r; - data[index + 1] = mask_g; - data[index + 2] = mask_b; - } - } + if (mask) + { + if (mask->PointMasked(xx,yy)) + { + data[index ] = mask_r; + data[index + 1] = mask_g; + data[index + 2] = mask_b; + } + } } index += 3; } @@ -891,11 +891,11 @@ wxImage wxBitmap::ConvertToImage() const SetGWorld(origPort, origDevice); if ( GetBitmapType() != kMacBitmapTypeGrafWorld ) { - wxMacDestroyGWorld( tempPort ) ; + wxMacDestroyGWorld( tempPort ) ; } if ( maskRgn ) { - DisposeRgn( maskRgn ) ; + DisposeRgn( maskRgn ) ; } return image; @@ -1038,33 +1038,33 @@ WXHBITMAP wxBitmap::GetHBITMAP() const WXHMETAFILE wxBitmap::GetPict( bool *created ) const { - wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ); + wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ); - PicHandle picture = NULL ; // This is the returned picture - if ( created ) - (*created) = false ; - // If bitmap already in Pict format return pointer - if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) { - return M_BITMAPDATA->m_hPict; - } - else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) { - // Invalid bitmap - return NULL; - } - else - { - if ( GetMask() ) - { - picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , MAC_WXHBITMAP(GetMask()->GetMaskBitmap() ) ) ; - } - else - { - picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , NULL ) ; - } - if ( created && picture ) - (*created) = true ; + PicHandle picture = NULL ; // This is the returned picture + if ( created ) + (*created) = false ; + // If bitmap already in Pict format return pointer + if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) { + return M_BITMAPDATA->m_hPict; + } + else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) { + // Invalid bitmap + return NULL; + } + else + { + if ( GetMask() ) + { + picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , MAC_WXHBITMAP(GetMask()->GetMaskBitmap() ) ) ; + } + else + { + picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , NULL ) ; + } + if ( created && picture ) + (*created) = true ; } - return picture ; + return picture ; } /* diff --git a/src/mac/carbon/bmpbuttn.cpp b/src/mac/carbon/bmpbuttn.cpp index a98ad95896..ebf8021262 100644 --- a/src/mac/carbon/bmpbuttn.cpp +++ b/src/mac/carbon/bmpbuttn.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -45,35 +45,35 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit m_windowId = id; if ( width == -1 && bitmap.Ok()) - width = bitmap.GetWidth() + 2*m_marginX; + width = bitmap.GetWidth() + 2*m_marginX; if ( height == -1 && bitmap.Ok()) - height = bitmap.GetHeight() + 2*m_marginY; + height = bitmap.GetHeight() + 2*m_marginY; - Rect bounds ; - Str255 title ; + Rect bounds ; + Str255 title ; m_bmpNormal = bitmap; - wxBitmapRefData * bmap = NULL ; - - if ( m_bmpNormal.Ok() ) - bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ; - - MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; + wxBitmapRefData * bmap = NULL ; + + if ( m_bmpNormal.Ok() ) + bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ; + + MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , - kControlBehaviorOffsetContents + - ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ? - kControlContentCIconHandle : kControlContentPictHandle ) , 0, - (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - - ControlButtonContentInfo info ; - wxMacCreateBitmapButton( &info , m_bmpNormal ) ; - if ( info.contentType != kControlNoContent ) - { - ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , + kControlBehaviorOffsetContents + + ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ? + kControlContentCIconHandle : kControlContentPictHandle ) , 0, + (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + + ControlButtonContentInfo info ; + wxMacCreateBitmapButton( &info , m_bmpNormal ) ; + if ( info.contentType != kControlNoContent ) + { + ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; } - MacPostControlCreate() ; + MacPostControlCreate() ; return TRUE; } diff --git a/src/mac/carbon/brush.cpp b/src/mac/carbon/brush.cpp index 5589004fbe..d484314a2c 100644 --- a/src/mac/carbon/brush.cpp +++ b/src/mac/carbon/brush.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -112,17 +112,17 @@ wxBrush::wxBrush(ThemeBrush macThemeBrush ) } void wxBrush::Unshare() { - // Don't change shared data - if (!m_refData) + // Don't change shared data + if (!m_refData) { - m_refData = new wxBrushRefData(); - } + m_refData = new wxBrushRefData(); + } else { - wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData); - UnRef(); - m_refData = ref; - } + wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData); + UnRef(); + m_refData = ref; + } } void wxBrush::SetColour(const wxColour& col) @@ -203,25 +203,27 @@ unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const } } -short wxBrush::GetMacTheme() const +short wxBrush::GetMacTheme() const { - return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack); -}; + return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack); +} wxColour& wxBrush::GetColour() const -{ return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); }; +{ + return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); +} int wxBrush::GetStyle() const { - return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); -}; + return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); +} wxBitmap *wxBrush::GetStipple() const { - return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); -}; + return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); +} wxMacBrushKind wxBrush::MacGetBrushKind() const { - return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour); -}; + return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour); +} \ No newline at end of file diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index ca997d6926..763048808e 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -34,23 +34,23 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxValidator& validator, const wxString& name) { - Rect bounds ; - Str255 title ; + Rect bounds ; + Str255 title ; if ( UMAHasAquaLayout() ) { m_macHorizontalBorder = kMacOSXHorizontalBorder; m_macVerticalBorder = kMacOSXVerticalBorder; } - - MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlPushButtonProc , (long) this ) ; - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - - MacPostControlCreate() ; - + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlPushButtonProc , (long) this ) ; + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + + MacPostControlCreate() ; + return TRUE; } @@ -65,19 +65,19 @@ void wxButton::SetDefault() parent->SetDefaultItem(this); } - Boolean inData; - if ( btnOldDefault && btnOldDefault->m_macControl ) - { - inData = 0; - ::SetControlData( (ControlHandle) btnOldDefault->m_macControl , kControlButtonPart , - kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; - } - if ( (ControlHandle) m_macControl ) - { - inData = 1; - ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , - kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; - } + Boolean inData; + if ( btnOldDefault && btnOldDefault->m_macControl ) + { + inData = 0; + ::SetControlData( (ControlHandle) btnOldDefault->m_macControl , kControlButtonPart , + kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; + } + if ( (ControlHandle) m_macControl ) + { + inData = 1; + ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , + kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ; + } } wxSize wxButton::DoGetBestSize() const @@ -85,7 +85,7 @@ wxSize wxButton::DoGetBestSize() const wxSize sz = GetDefaultSize() ; int wBtn = m_label.Length() * 8 + 12 + 2 * kMacOSXHorizontalBorder ; - + if (wBtn > sz.x) sz.x = wBtn; return sz ; @@ -94,7 +94,7 @@ wxSize wxButton::DoGetBestSize() const wxSize wxButton::GetDefaultSize() { int wBtn = 70 ; - int hBtn = 20 ; + int hBtn = 20 ; if ( UMAHasAquaLayout() ) { diff --git a/src/mac/carbon/checkbox.cpp b/src/mac/carbon/checkbox.cpp index 60035000dd..f1bc26ccc6 100644 --- a/src/mac/carbon/checkbox.cpp +++ b/src/mac/carbon/checkbox.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -31,15 +31,15 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxValidator& validator, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlCheckBoxProc , (long) this ) ; - - MacPostControlCreate() ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlCheckBoxProc , (long) this ) ; + + MacPostControlCreate() ; return TRUE; } @@ -63,7 +63,7 @@ void wxCheckBox::Command (wxCommandEvent & event) void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) ) { - SetValue( !GetValue() ) ; + SetValue( !GetValue() ) ; wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); event.SetInt(GetValue()); event.SetEventObject(this); diff --git a/src/mac/carbon/checklst.cpp b/src/mac/carbon/checklst.cpp index 33dba7507c..c50773b137 100644 --- a/src/mac/carbon/checklst.cpp +++ b/src/mac/carbon/checklst.cpp @@ -73,9 +73,9 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, RgnHandle savedClipRegion; SInt32 savedPenMode; wxCheckListBox* list; - GetPort(&savePort); - SetPort((**listHandle).port); - grafPtr = (**listHandle).port ; + GetPort(&savePort); + SetPort((**listHandle).port); + grafPtr = (**listHandle).port ; // typecast our refCon list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); @@ -102,13 +102,13 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, ClipRect( drawRect ); EraseRect( drawRect ); - wxFontRefData * font = (wxFontRefData*) (list->GetFont().GetRefData()) ; + wxFontRefData * font = (wxFontRefData*) (list->GetFont().GetRefData()) ; - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( font->m_macFontSize) ; - ::TextFace( font->m_macFontStyle ) ; + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( font->m_macFontSize) ; + ::TextFace( font->m_macFontStyle ) ; } ThemeButtonDrawInfo info ; @@ -123,11 +123,11 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, checkRect.right = checkRect.left + list->m_checkBoxWidth ; checkRect.bottom = checkRect.top + list->m_checkBoxHeight ; DrawThemeButton(&checkRect,kThemeCheckBox, - &info,NULL,NULL, NULL,0); - - MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset ); - - DrawText(text, 0 , text.Length()); + &info,NULL,NULL, NULL,0); + + MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset ); + + DrawText(text, 0 , text.Length()); // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. @@ -142,8 +142,8 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, SetClip( savedClipRegion ); DisposeRgn( savedClipRegion ); - } - break; + } + break; case lHiliteMsg: // Hilite or unhilite the cell. Paint the cell contents with the @@ -194,7 +194,7 @@ bool wxCheckListBox::Create(wxWindow *parent, GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth); GetThemeMetric(kThemeMetricCheckBoxHeight,&h); #endif - wxFontRefData * font = (wxFontRefData*) (GetFont().GetRefData()) ; + wxFontRefData * font = (wxFontRefData*) (GetFont().GetRefData()) ; FontInfo finfo; FetchFontInfo(font->m_macFontNum,short(font->m_macFontSize),font->m_macFontStyle,&finfo); @@ -202,12 +202,12 @@ bool wxCheckListBox::Create(wxWindow *parent, m_TextBaseLineOffset= finfo.leading+finfo.ascent; m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent; - if (m_checkBoxHeight= 0 ) + if ( event.GetKeyCode() == WXK_SPACE ) { - Check(index, !IsChecked(index) ) ; - wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); - event.SetInt(index); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + int index = GetSelection() ; + if ( index >= 0 ) + { + Check(index, !IsChecked(index) ) ; + wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); + event.SetInt(index); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } } - } - else - event.Skip(); + else + event.Skip(); } void wxCheckListBox::OnLeftClick(wxMouseEvent& event) { - // clicking on the item selects it, clicking on the checkmark toggles - if ( event.GetX() <= 20 /*check width*/ ) { - int lineheight ; - int topcell ; + // clicking on the item selects it, clicking on the checkmark toggles + if ( event.GetX() <= 20 /*check width*/ ) { + int lineheight ; + int topcell ; #if TARGET_CARBON - Point pt ; - GetListCellSize( (ListHandle)m_macList , &pt ) ; - lineheight = pt.v ; - ListBounds visible ; - GetListVisibleCells( (ListHandle)m_macList , &visible ) ; - topcell = visible.top ; + Point pt ; + GetListCellSize( (ListHandle)m_macList , &pt ) ; + lineheight = pt.v ; + ListBounds visible ; + GetListVisibleCells( (ListHandle)m_macList , &visible ) ; + topcell = visible.top ; #else - lineheight = (**(ListHandle)m_macList).cellSize.v ; - topcell = (**(ListHandle)m_macList).visible.top ; + lineheight = (**(ListHandle)m_macList).cellSize.v ; + topcell = (**(ListHandle)m_macList).visible.top ; #endif - size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ; - - if ( nItem < (size_t)m_noItems ) - { - Check(nItem, !IsChecked(nItem) ) ; - wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); - event.SetInt(nItem); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ; + + if ( nItem < (size_t)m_noItems ) + { + Check(nItem, !IsChecked(nItem) ) ; + wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); + event.SetInt(nItem); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + //else: it's not an error, just click outside of client zone + } + else { + // implement default behaviour: clicking on the item selects it + event.Skip(); } - //else: it's not an error, just click outside of client zone - } - else { - // implement default behaviour: clicking on the item selects it - event.Skip(); - } } #endif // wxUSE_CHECKLISTBOX diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 4074699ed5..a53b5715ce 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -6,19 +6,24 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// + #ifdef __GNUG__ #pragma implementation "choice.h" #endif + #include "wx/defs.h" #include "wx/choice.h" #include "wx/menu.h" #include "wx/mac/uma.h" + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) #endif + extern MenuHandle NewUniqueMenu() ; + wxChoice::~wxChoice() { if ( HasClientObjectData() ) @@ -30,49 +35,52 @@ wxChoice::~wxChoice() } // DeleteMenu( m_macPopUpMenuId ) ; - // DisposeMenu( m_macPopUpMenuHandle ) ; + // DisposeMenu( m_macPopUpMenuHandle ) ; } + bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - int n, const wxString choices[], - long style, + int n, const wxString choices[], + long style, const wxValidator& validator, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 , - kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; - - m_macPopUpMenuHandle = NewUniqueMenu() ; - SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; - SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; - SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ; - if ( n > 0 ) - SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ; - MacPostControlCreate() ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 , + kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; + + m_macPopUpMenuHandle = NewUniqueMenu() ; + SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; + SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ; + if ( n > 0 ) + SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ; + MacPostControlCreate() ; for ( int i = 0; i < n; i++ ) { Append(choices[i]); } - return TRUE; + return TRUE; } + // ---------------------------------------------------------------------------- // adding/deleting items to/from the list // ---------------------------------------------------------------------------- int wxChoice::DoAppend(const wxString& item) { - UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item); - m_strings.Add( item ) ; - m_datas.Add( NULL ) ; - int index = m_strings.GetCount() - 1 ; - DoSetItemClientData( index , NULL ) ; - SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; - return index ; + UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item); + m_strings.Add( item ) ; + m_datas.Add( NULL ) ; + int index = m_strings.GetCount() - 1 ; + DoSetItemClientData( index , NULL ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; + return index ; } + void wxChoice::Delete(int n) { wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") ); @@ -83,19 +91,21 @@ void wxChoice::Delete(int n) ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ; m_strings.Remove( n ) ; m_datas.RemoveAt( n ) ; - SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; } + void wxChoice::Clear() { FreeData(); for ( int i = 0 ; i < GetCount() ; i++ ) { - ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , 1 ) ; + ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , 1 ) ; } m_strings.Empty() ; m_datas.Empty() ; SetControl32BitMaximum( (ControlHandle) m_macControl , 0 ) ; } + void wxChoice::FreeData() { if ( HasClientObjectData() ) @@ -107,6 +117,7 @@ void wxChoice::FreeData() } } } + // ---------------------------------------------------------------------------- // selection // ---------------------------------------------------------------------------- @@ -114,26 +125,31 @@ int wxChoice::GetSelection() const { return GetControl32BitValue( (ControlHandle) m_macControl ) -1 ; } + void wxChoice::SetSelection(int n) { SetControl32BitValue( (ControlHandle) m_macControl , n + 1 ) ; } + // ---------------------------------------------------------------------------- // string list functions // ---------------------------------------------------------------------------- + int wxChoice::GetCount() const { return m_strings.GetCount() ; } + int wxChoice::FindString(const wxString& s) const { for( int i = 0 ; i < GetCount() ; i++ ) { - if ( GetString( i ).IsSameAs(s, FALSE) ) - return i ; + if ( GetString( i ).IsSameAs(s, FALSE) ) + return i ; } return wxNOT_FOUND ; } + void wxChoice::SetString(int n, const wxString& s) { wxFAIL_MSG(wxT("wxChoice::SetString() not yet implemented")); @@ -145,7 +161,7 @@ void wxChoice::SetString(int n, const wxString& s) wxString wxChoice::GetString(int n) const { - return m_strings[n] ; + return m_strings[n] ; } // ---------------------------------------------------------------------------- // client data @@ -154,23 +170,27 @@ void wxChoice::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( n >= 0 && (size_t)n < m_datas.GetCount(), "invalid index in wxChoice::SetClientData" ); - + m_datas[n] = (char*) clientData ; } + void *wxChoice::DoGetItemClientData(int n) const { wxCHECK_MSG( n >= 0 && (size_t)n < m_datas.GetCount(), NULL, "invalid index in wxChoice::GetClientData" ); return (void *)m_datas[n]; } + void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData ) { DoSetItemClientData(n, clientData); } + wxClientData* wxChoice::DoGetItemClientObject( int n ) const { return (wxClientData *)DoGetItemClientData(n); } + void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); @@ -188,6 +208,7 @@ void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ProcessCommand(event); } } + wxSize wxChoice::DoGetBestSize() const { int lbWidth = 100; // some defaults @@ -198,35 +219,35 @@ wxSize wxChoice::DoGetBestSize() const GetThemeMetric(kThemeMetricPopupButtonHeight , &metric ); lbHeight = metric ; #endif - { - wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; - Rect drawRect ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - } - else - { - ::TextFont( kFontIDMonaco ) ; - ::TextSize( 9 ); - ::TextFace( 0 ) ; - } - // Find the widest line - for(int i = 0; i < GetCount(); i++) { - wxString str(GetString(i)); - wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; - lbWidth = wxMax(lbWidth, wLine); - } - // Add room for the popup arrow - lbWidth += 2 * lbHeight ; - // And just a bit more - int cy = 12 ; - int cx = ::TextWidth( "X" , 0 , 1 ) ; - lbWidth += cx ; - - } + { + wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; + Rect drawRect ; + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( short(font->m_macFontSize) ) ; + ::TextFace( font->m_macFontStyle ) ; + } + else + { + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + } + // Find the widest line + for(int i = 0; i < GetCount(); i++) { + wxString str(GetString(i)); + wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; + lbWidth = wxMax(lbWidth, wLine); + } + // Add room for the popup arrow + lbWidth += 2 * lbHeight ; + // And just a bit more + int cy = 12 ; + int cx = ::TextWidth( "X" , 0 , 1 ) ; + lbWidth += cx ; + + } return wxSize(lbWidth, lbHeight); } diff --git a/src/mac/carbon/clipbrd.cpp b/src/mac/carbon/clipbrd.cpp index 7854006d09..47a2b428f9 100644 --- a/src/mac/carbon/clipbrd.cpp +++ b/src/mac/carbon/clipbrd.cpp @@ -44,27 +44,27 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) #else OSStatus err = noErr ; #endif - void * data = NULL ; - Size byteCount; + void * data = NULL ; + Size byteCount; switch (dataFormat.GetType()) { - case wxDF_OEMTEXT: - dataFormat = wxDF_TEXT; - // fall through - - case wxDF_TEXT: - break; - case wxDF_BITMAP : - case wxDF_METAFILE : - break ; - default: - { - wxLogError(_("Unsupported clipboard format.")); - return NULL; - } + case wxDF_OEMTEXT: + dataFormat = wxDF_TEXT; + // fall through + + case wxDF_TEXT: + break; + case wxDF_BITMAP : + case wxDF_METAFILE : + break ; + default: + { + wxLogError(_("Unsupported clipboard format.")); + return NULL; + } } - + #if TARGET_CARBON ScrapRef scrapRef; @@ -77,21 +77,21 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) { if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr) { - if ( dataFormat.GetType() == wxDF_TEXT ) - byteCount++ ; + if ( dataFormat.GetType() == wxDF_TEXT ) + byteCount++ ; - data = new char[ byteCount ] ; - if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr ) - { - *len = byteCount ; - if ( dataFormat.GetType() == wxDF_TEXT ) - ((char*)data)[byteCount] = 0 ; - } - else - { - delete[] ((char *)data) ; - data = NULL ; - } + data = new char[ byteCount ] ; + if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr ) + { + *len = byteCount ; + if ( dataFormat.GetType() == wxDF_TEXT ) + ((char*)data)[byteCount] = 0 ; + } + else + { + delete[] ((char *)data) ; + data = NULL ; + } } } } @@ -104,28 +104,28 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) HUnlock( datahandle ) ; if ( GetHandleSize( datahandle ) > 0 ) { - byteCount = GetHandleSize( datahandle ) ; - if ( dataFormat.GetType() == wxDF_TEXT ) - data = new char[ byteCount + 1] ; - else - data = new char[ byteCount ] ; - - memcpy( (char*) data , (char*) *datahandle , byteCount ) ; - if ( dataFormat.GetType() == wxDF_TEXT ) - ((char*)data)[byteCount] = 0 ; - *len = byteCount ; + byteCount = GetHandleSize( datahandle ) ; + if ( dataFormat.GetType() == wxDF_TEXT ) + data = new char[ byteCount + 1] ; + else + data = new char[ byteCount ] ; + + memcpy( (char*) data , (char*) *datahandle , byteCount ) ; + if ( dataFormat.GetType() == wxDF_TEXT ) + ((char*)data)[byteCount] = 0 ; + *len = byteCount ; } DisposeHandle( datahandle ) ; #endif if ( err ) { wxLogSysError(_("Failed to get clipboard data.")); - + return NULL ; } if ( dataFormat.GetType() == wxDF_TEXT && wxApp::s_macDefaultEncodingIsPC ) { - wxMacConvertToPC((char*)data,(char*)data,byteCount) ; + wxMacConvertToPC((char*)data,(char*)data,byteCount) ; } return data; } @@ -139,8 +139,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject) wxClipboard::wxClipboard() { - m_open = false ; - m_data = NULL ; + m_open = false ; + m_data = NULL ; } wxClipboard::~wxClipboard() @@ -250,30 +250,30 @@ bool wxClipboard::AddData( wxDataObject *data ) #if wxUSE_DRAG_AND_DROP case wxDF_METAFILE: { - wxMetafileDataObject* metaFileDataObject = + wxMetafileDataObject* metaFileDataObject = (wxMetafileDataObject*) data; - wxMetafile metaFile = metaFileDataObject->GetMetafile(); - PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; - HLock( (Handle) pict ) ; - err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; - HUnlock( (Handle) pict ) ; + wxMetafile metaFile = metaFileDataObject->GetMetafile(); + PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; + HLock( (Handle) pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + HUnlock( (Handle) pict ) ; } break ; #endif case wxDF_BITMAP: case wxDF_DIB: { - bool created = false ; - PicHandle pict = NULL ; - - wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data ; - pict = (PicHandle) bitmapDataObject->GetBitmap().GetPict( &created ) ; - - HLock( (Handle) pict ) ; - err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; - HUnlock( (Handle) pict ) ; - if ( created ) - KillPicture( pict ) ; + bool created = false ; + PicHandle pict = NULL ; + + wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data ; + pict = (PicHandle) bitmapDataObject->GetBitmap().GetPict( &created ) ; + + HLock( (Handle) pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + HUnlock( (Handle) pict ) ; + if ( created ) + KillPicture( pict ) ; } default: break ; @@ -388,7 +388,7 @@ bool wxClipboard::GetData( wxDataObject& data ) transferred = true ; } } - break ; + break ; default : break ; diff --git a/src/mac/carbon/colordlg.cpp b/src/mac/carbon/colordlg.cpp index bb2361b3ff..134e40f445 100644 --- a/src/mac/carbon/colordlg.cpp +++ b/src/mac/carbon/colordlg.cpp @@ -7,7 +7,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -50,20 +50,20 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) int wxColourDialog::ShowModal() { - Point where ; - RGBColor currentColor = *((RGBColor*)m_colourData.dataColour.GetPixel()) , newColor ; - - where.h = where.v = -1; + Point where ; + RGBColor currentColor = *((RGBColor*)m_colourData.dataColour.GetPixel()) , newColor ; + + where.h = where.v = -1; - if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor )) - { - m_colourData.dataColour.Set( (WXCOLORREF*) &newColor ) ; - return wxID_OK; - } - else - { - return wxID_CANCEL; - } + if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor )) + { + m_colourData.dataColour.Set( (WXCOLORREF*) &newColor ) ; + return wxID_OK; + } + else + { + return wxID_CANCEL; + } return wxID_CANCEL; } diff --git a/src/mac/carbon/colour.cpp b/src/mac/carbon/colour.cpp index b9a18e9ca9..12a65e02a5 100644 --- a/src/mac/carbon/colour.cpp +++ b/src/mac/carbon/colour.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -28,17 +28,17 @@ static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) { RGBColor* col = (RGBColor*) color ; - col->red = (red << 8) + red; - col->blue = (blue << 8) + blue; - col->green = (green << 8) + green; + col->red = (red << 8) + red; + col->blue = (blue << 8) + blue; + col->green = (green << 8) + green; } wxColour::wxColour () { - m_isInit = FALSE; - m_red = m_blue = m_green = 0; - - wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; + m_isInit = FALSE; + m_red = m_blue = m_green = 0; + + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) @@ -48,7 +48,7 @@ wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) m_blue = b; m_isInit = TRUE; - wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::wxColour (const wxColour& col) @@ -74,14 +74,14 @@ wxColour::wxColour (const wxColour* col) wxColour& wxColour::operator =(const wxColour& col) { - m_red = col.m_red; - m_green = col.m_green; - m_blue = col.m_blue; - m_isInit = col.m_isInit; - - memcpy( &m_pixel , &col.m_pixel , 6 ) ; - - return *this; + m_red = col.m_red; + m_green = col.m_green; + m_blue = col.m_blue; + m_isInit = col.m_isInit; + + memcpy( &m_pixel , &col.m_pixel , 6 ) ; + + return *this; } void wxColour::InitFromName(const wxString& col) @@ -102,7 +102,7 @@ void wxColour::InitFromName(const wxString& col) m_isInit = FALSE; } - wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::~wxColour () @@ -116,7 +116,7 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) m_blue = b; m_isInit = TRUE; - wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } void wxColour::Set( const WXCOLORREF* color ) diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 2c000f3b0b..7d2a6819ea 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -96,7 +96,7 @@ protected: wxWindow *parent = GetParent(); while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) { - parent = parent->GetParent() ; + parent = parent->GetParent() ; } if ( parent && parent->GetDefaultItem() ) { @@ -314,9 +314,9 @@ void wxComboBox::SetValue(const wxString& value) int s = FindString (value); if (s == wxNOT_FOUND && !HasFlag(wxCB_READONLY) ) { - m_choice->Append(value) ; + m_choice->Append(value) ; } - SetStringSelection( value ) ; + SetStringSelection( value ) ; } // Clipboard operations diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index 0ba0c06521..2dd89c2b55 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -89,54 +89,54 @@ ControlDefUPP wxMacControlActionUPP = NULL ; pascal SInt32 wxMacControlDefinition(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param) { - wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ; - if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) - { - if( message == drawCntl ) - { - wxMacWindowClipper clip( wx ) ; - return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; - } - else - return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; - } - return NULL ; + wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ; + if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) + { + if( message == drawCntl ) + { + wxMacWindowClipper clip( wx ) ; + return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; + } + else + return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; + } + return NULL ; } pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) { - OSStatus status = noErr ; - switch( iMessage ) - { - case kControlMsgSetUpBackground : - { - wxControl* wx = (wxControl*) GetControlReference( iControl ) ; - if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) - { - wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ; + OSStatus status = noErr ; + switch( iMessage ) + { + case kControlMsgSetUpBackground : + { + wxControl* wx = (wxControl*) GetControlReference( iControl ) ; + if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) + { + wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ; #if TARGET_CARBON - // under classic this would lead to partial redraws - RgnHandle clip = NewRgn() ; - int x = 0 , y = 0; - - wx->MacWindowToRootWindow( &x,&y ) ; - CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ; - OffsetRgn( clip , x , y ) ; - SetClip( clip ) ; - DisposeRgn( clip ) ; + // under classic this would lead to partial redraws + RgnHandle clip = NewRgn() ; + int x = 0 , y = 0; + + wx->MacWindowToRootWindow( &x,&y ) ; + CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ; + OffsetRgn( clip , x , y ) ; + SetClip( clip ) ; + DisposeRgn( clip ) ; #endif - } - else - { - status = paramErr ; - } - } - break ; - default : - status = paramErr ; - break ; - } - return status ; + } + else + { + status = paramErr ; + } + } + break ; + default : + status = paramErr ; + break ; + } + return status ; } wxControl::wxControl() @@ -389,14 +389,14 @@ void wxControl::MacPostControlCreate() m_macControlIsShown = true ; wxAssociateControlWithMacControl( (ControlHandle) m_macControl , this ) ; - if ( wxMacSetupControlBackgroundUPP == NULL ) - { - wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ; - } - if ( wxMacControlActionUPP == NULL ) - { - wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefinition ) ; - } + if ( wxMacSetupControlBackgroundUPP == NULL ) + { + wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ; + } + if ( wxMacControlActionUPP == NULL ) + { + wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefinition ) ; + } // The following block of code is responsible for crashes when switching // back to windows, which can be seen in the dialogs sample. // It is disabled until a proper solution can be found. @@ -414,35 +414,35 @@ void wxControl::MacPostControlCreate() cdef = (cdefHandle) NewHandle( sizeof(cdefRec) ) ; if ( (**(ControlHandle)m_macControl).contrlDefProc != NULL ) { - (**cdef).instruction = 0x4EF9; /* JMP instruction */ - (**cdef).function = (void(*)()) wxMacControlActionUPP; - (**(ControlHandle)m_macControl).contrlDefProc = (Handle) cdef ; + (**cdef).instruction = 0x4EF9; /* JMP instruction */ + (**cdef).function = (void(*)()) wxMacControlActionUPP; + (**(ControlHandle)m_macControl).contrlDefProc = (Handle) cdef ; } #endif #endif - SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ; - - // Adjust the controls size and position - wxPoint pos(m_x, m_y); - wxSize best_size( DoGetBestSize() ); - wxSize new_size( m_width, m_height ); - - m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control - - if (new_size.x == -1) { + SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ; + + // Adjust the controls size and position + wxPoint pos(m_x, m_y); + wxSize best_size( DoGetBestSize() ); + wxSize new_size( m_width, m_height ); + + m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control + + if (new_size.x == -1) { new_size.x = best_size.x; - } - if (new_size.y == -1) { - new_size.y = best_size.y; - } - - SetSize(pos.x, pos.y, new_size.x, new_size.y); - - UMAShowControl( (ControlHandle) m_macControl ) ; - - SetCursor( *wxSTANDARD_CURSOR ) ; - - Refresh() ; + } + if (new_size.y == -1) { + new_size.y = best_size.y; + } + + SetSize(pos.x, pos.y, new_size.x, new_size.y); + + UMAShowControl( (ControlHandle) m_macControl ) ; + + SetCursor( *wxSTANDARD_CURSOR ) ; + + Refresh() ; } void wxControl::MacAdjustControlRect() @@ -496,7 +496,7 @@ void wxControl::MacAdjustControlRect() m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ; } - MacUpdateDimensions() ; + MacUpdateDimensions() ; // UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; } } @@ -511,19 +511,19 @@ WXWidget wxControl::MacGetContainerForEmbedding() void wxControl::MacUpdateDimensions() { - // actually in the current systems this should never be possible, but later reparenting - // may become a reality - - if ( (ControlHandle) m_macControl == NULL ) - return ; - - if ( GetParent() == NULL ) - return ; - + // actually in the current systems this should never be possible, but later reparenting + // may become a reality + + if ( (ControlHandle) m_macControl == NULL ) + return ; + + if ( GetParent() == NULL ) + return ; + WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; if ( rootwindow == NULL ) - return ; - + return ; + Rect oldBounds ; GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; @@ -535,23 +535,23 @@ void wxControl::MacUpdateDimensions() GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ; bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ; bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ; - if ( doMove || doResize ) - { - InvalWindowRect( rootwindow, &oldBounds ) ; - if ( doMove ) - { - UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; - } - if ( doResize ) - { - UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; - } - } + if ( doMove || doResize ) + { + InvalWindowRect( rootwindow, &oldBounds ) ; + if ( doMove ) + { + UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; + } + if ( doResize ) + { + UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; + } + } } void wxControl::MacSuperChangedPosition() { - MacUpdateDimensions() ; + MacUpdateDimensions() ; wxWindow::MacSuperChangedPosition() ; } @@ -561,7 +561,7 @@ void wxControl::MacSuperEnabled( bool enabled ) wxWindow::MacSuperEnabled( enabled ) ; } -void wxControl::MacSuperShown( bool show ) +void wxControl::MacSuperShown( bool show ) { if ( (ControlHandle) m_macControl ) { @@ -593,19 +593,19 @@ void wxControl::DoSetSize(int x, int y, wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ; #if 0 { - Rect meta , control ; - GetControlBounds( (ControlHandle) m_macControl , &control ) ; - RgnHandle rgn = NewRgn() ; - GetControlRegion( (ControlHandle) m_macControl , kControlStructureMetaPart , rgn ) ; - GetRegionBounds( rgn , &meta ) ; - if ( !EmptyRect( &meta ) ) - { - wxASSERT( meta.left >= control.left - m_macHorizontalBorder ) ; - wxASSERT( meta.right <= control.right + m_macHorizontalBorder ) ; - wxASSERT( meta.top >= control.top - m_macVerticalBorder ) ; - wxASSERT( meta.bottom <= control.bottom + m_macVerticalBorder ) ; - } - DisposeRgn( rgn ) ; + Rect meta , control ; + GetControlBounds( (ControlHandle) m_macControl , &control ) ; + RgnHandle rgn = NewRgn() ; + GetControlRegion( (ControlHandle) m_macControl , kControlStructureMetaPart , rgn ) ; + GetRegionBounds( rgn , &meta ) ; + if ( !EmptyRect( &meta ) ) + { + wxASSERT( meta.left >= control.left - m_macHorizontalBorder ) ; + wxASSERT( meta.right <= control.right + m_macHorizontalBorder ) ; + wxASSERT( meta.top >= control.top - m_macVerticalBorder ) ; + wxASSERT( meta.bottom <= control.bottom + m_macVerticalBorder ) ; + } + DisposeRgn( rgn ) ; } #endif return ; @@ -814,16 +814,16 @@ void wxControl::OnKeyDown( wxKeyEvent &event ) #if TARGET_CARBON - char charCode ; - UInt32 keyCode ; + char charCode ; + UInt32 keyCode ; UInt32 modifiers ; - GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); - GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); - GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); + GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); + GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); ::HandleControlKey( (ControlHandle) m_macControl , keyCode , charCode , modifiers ) ; - + #else EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; short keycode ; @@ -895,11 +895,10 @@ void wxControl::OnMouseEvent( wxMouseEvent &event ) bool wxControl::MacCanFocus() const { - { if ( (ControlHandle) m_macControl == NULL ) - return true ; - else - return false ; - } + if ( (ControlHandle) m_macControl == NULL ) + return true ; + else + return false ; } void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) diff --git a/src/mac/carbon/cursor.cpp b/src/mac/carbon/cursor.cpp index df3f6dd7cb..79633bf14d 100644 --- a/src/mac/carbon/cursor.cpp +++ b/src/mac/carbon/cursor.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -41,7 +41,7 @@ const short kwxCursorSizeNESW = 22 ; const short kwxCursorSizeNWSE = 23 ; const short kwxCursorRoller = 24 ; -wxCursor gMacCurrentCursor ; +wxCursor gMacCurrentCursor ; wxCursorRefData::wxCursorRefData() { @@ -60,15 +60,15 @@ wxCursorRefData::~wxCursorRefData() { ::DisposeCCursor( (CCrsrHandle) m_hCursor ) ; } - else if ( m_disposeHandle ) - { - ::DisposeHandle( (Handle ) m_hCursor ) ; - } - else if ( m_releaseHandle ) - { - // we don't release the resource since it may already - // be in use again - } + else if ( m_disposeHandle ) + { + ::DisposeHandle( (Handle ) m_hCursor ) ; + } + else if ( m_releaseHandle ) + { + // we don't release the resource since it may already + // be in use again + } } // Cursors @@ -91,14 +91,14 @@ void wxCursor::CreateFromImage(const wxImage & image) m_refData = new wxCursorRefData; wxImage image16 = image.Scale(16,16) ; - unsigned char * rgbBits = image16.GetData(); + unsigned char * rgbBits = image16.GetData(); - + int w = image16.GetWidth() ; int h = image16.GetHeight() ; bool bHasMask = image16.HasMask() ; - int hotSpotX = image16.GetOptionInt(wxCUR_HOTSPOT_X); + int hotSpotX = image16.GetOptionInt(wxCUR_HOTSPOT_X); int hotSpotY = image16.GetOptionInt(wxCUR_HOTSPOT_Y); if (hotSpotX < 0 || hotSpotX >= w) hotSpotX = 0; @@ -112,40 +112,40 @@ void wxCursor::CreateFromImage(const wxImage & image) memset( cp->data , 0 , sizeof( Bits16 ) ) ; memset( cp->mask , 0 , sizeof( Bits16 ) ) ; - unsigned char mr = image16.GetMaskRed() ; - unsigned char mg = image16.GetMaskGreen() ; - unsigned char mb = image16.GetMaskBlue() ; + unsigned char mr = image16.GetMaskRed() ; + unsigned char mg = image16.GetMaskGreen() ; + unsigned char mb = image16.GetMaskBlue() ; for ( int y = 0 ; y < h ; ++y ) { - short rowbits = 0 ; - short maskbits = 0 ; - - for ( int x = 0 ; x < w ; ++x ) - { - long pos = (y * w + x) * 3; + short rowbits = 0 ; + short maskbits = 0 ; + + for ( int x = 0 ; x < w ; ++x ) + { + long pos = (y * w + x) * 3; - unsigned char r = rgbBits[pos] ; - unsigned char g = rgbBits[pos+1] ; - unsigned char b = rgbBits[pos+2] ; - if ( bHasMask && r==mr && g==mg && b==mb ) - { - // masked area, does not appear anywhere - } - else - { - if ( (int)r + (int)g + (int)b < 0x60 ) - { - rowbits |= ( 1 << (15-x) ) ; - } - maskbits |= ( 1 << (15-x) ) ; - } - } - cp->data[y] = rowbits ; - cp->mask[y] = maskbits ; + unsigned char r = rgbBits[pos] ; + unsigned char g = rgbBits[pos+1] ; + unsigned char b = rgbBits[pos+2] ; + if ( bHasMask && r==mr && g==mg && b==mb ) + { + // masked area, does not appear anywhere + } + else + { + if ( (int)r + (int)g + (int)b < 0x60 ) + { + rowbits |= ( 1 << (15-x) ) ; + } + maskbits |= ( 1 << (15-x) ) ; + } + } + cp->data[y] = rowbits ; + cp->mask[y] = maskbits ; } if ( !bHasMask ) { - memcpy( cp->mask , cp->data , sizeof( Bits16) ) ; + memcpy( cp->mask , cp->data , sizeof( Bits16) ) ; } cp->hotSpot.h = hotSpotX ; @@ -158,40 +158,40 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho m_refData = new wxCursorRefData; if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE ) { - Str255 theName ; + Str255 theName ; #if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , cursor_file ) ; + c2pstrcpy( (StringPtr) theName , cursor_file ) ; #else - strcpy( (char *) theName , cursor_file ) ; - c2pstr( (char *) theName ) ; + strcpy( (char *) theName , cursor_file ) ; + c2pstr( (char *) theName ) ; #endif - + wxStAppResource resload ; - Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; - if ( resHandle ) - { - short theId = -1 ; - OSType theType ; - GetResInfo( resHandle , &theId , &theType , theName ) ; - ReleaseResource( resHandle ) ; - M_CURSORDATA->m_hCursor = GetCCursor( theId ) ; - if ( M_CURSORDATA->m_hCursor ) - M_CURSORDATA->m_isColorCursor = true ; - } - else - { - Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ; - if ( resHandle ) - { - short theId = -1 ; - OSType theType ; - GetResInfo( resHandle , &theId , &theType , theName ) ; - ReleaseResource( resHandle ) ; - M_CURSORDATA->m_hCursor = GetCursor( theId ) ; - if ( M_CURSORDATA->m_hCursor ) - M_CURSORDATA->m_releaseHandle = true ; - } + Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; + if ( resHandle ) + { + short theId = -1 ; + OSType theType ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + M_CURSORDATA->m_hCursor = GetCCursor( theId ) ; + if ( M_CURSORDATA->m_hCursor ) + M_CURSORDATA->m_isColorCursor = true ; + } + else + { + Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ; + if ( resHandle ) + { + short theId = -1 ; + OSType theType ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + M_CURSORDATA->m_hCursor = GetCursor( theId ) ; + if ( M_CURSORDATA->m_hCursor ) + M_CURSORDATA->m_releaseHandle = true ; + } } } else @@ -211,155 +211,155 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho // Cursors by stock number wxCursor::wxCursor(int cursor_type) { - m_refData = new wxCursorRefData; - - switch (cursor_type) - { + m_refData = new wxCursorRefData; + + switch (cursor_type) + { case wxCURSOR_WAIT: - M_CURSORDATA->m_themeCursor = kThemeWatchCursor ; - break; + M_CURSORDATA->m_themeCursor = kThemeWatchCursor ; + break; case wxCURSOR_IBEAM: - M_CURSORDATA->m_themeCursor = kThemeIBeamCursor ; - break; + M_CURSORDATA->m_themeCursor = kThemeIBeamCursor ; + break; case wxCURSOR_CROSS: - M_CURSORDATA->m_themeCursor = kThemeCrossCursor; - break; + M_CURSORDATA->m_themeCursor = kThemeCrossCursor; + break; case wxCURSOR_SIZENWSE: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNWSE); - } - break; + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNWSE); + } + break; case wxCURSOR_SIZENESW: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNESW); - } - break; + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNESW); + } + break; case wxCURSOR_SIZEWE: - { - M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor; - } - break; + { + M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor; + } + break; case wxCURSOR_SIZENS: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNS); - } - break; - case wxCURSOR_SIZING: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSize); - } - break; + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNS); + } + break; + case wxCURSOR_SIZING: + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSize); + } + break; case wxCURSOR_HAND: - { - M_CURSORDATA->m_themeCursor = kThemePointingHandCursor; - } - break; + { + M_CURSORDATA->m_themeCursor = kThemePointingHandCursor; + } + break; case wxCURSOR_BULLSEYE: { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBullseye); + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBullseye); } break; case wxCURSOR_PENCIL: { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPencil); + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPencil); } break; case wxCURSOR_MAGNIFIER: { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorMagnifier); + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorMagnifier); } break; case wxCURSOR_NO_ENTRY: { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorNoEntry); + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorNoEntry); } break; case wxCURSOR_WATCH: - { - M_CURSORDATA->m_themeCursor = kThemeWatchCursor; - break; - } + { + M_CURSORDATA->m_themeCursor = kThemeWatchCursor; + break; + } case wxCURSOR_PAINT_BRUSH: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPaintBrush); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPaintBrush); + break; + } case wxCURSOR_POINT_LEFT: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointLeft); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointLeft); + break; + } case wxCURSOR_POINT_RIGHT: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointRight); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointRight); + break; + } case wxCURSOR_QUESTION_ARROW: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorQuestionArrow); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorQuestionArrow); + break; + } case wxCURSOR_BLANK: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBlank); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBlank); + break; + } case wxCURSOR_RIGHT_ARROW: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRightArrow); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRightArrow); + break; + } case wxCURSOR_SPRAYCAN: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRoller); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRoller); + break; + } case wxCURSOR_CHAR: case wxCURSOR_ARROW: case wxCURSOR_LEFT_BUTTON: case wxCURSOR_RIGHT_BUTTON: case wxCURSOR_MIDDLE_BUTTON: - default: - M_CURSORDATA->m_themeCursor = kThemeArrowCursor ; - break; - } - if ( M_CURSORDATA->m_themeCursor == -1 ) - M_CURSORDATA->m_releaseHandle = true ; + default: + M_CURSORDATA->m_themeCursor = kThemeArrowCursor ; + break; + } + if ( M_CURSORDATA->m_themeCursor == -1 ) + M_CURSORDATA->m_releaseHandle = true ; } void wxCursor::MacInstall() const { - gMacCurrentCursor = *this ; - if ( m_refData && M_CURSORDATA->m_themeCursor != -1 ) - { - SetThemeCursor( M_CURSORDATA->m_themeCursor ) ; - } - else if ( m_refData && M_CURSORDATA->m_hCursor ) - { - if ( M_CURSORDATA->m_isColorCursor ) - ::SetCCursor( (CCrsrHandle) M_CURSORDATA->m_hCursor ) ; - else - ::SetCursor( * (CursHandle) M_CURSORDATA->m_hCursor ) ; - } - else - { - SetThemeCursor( kThemeArrowCursor ) ; - } + gMacCurrentCursor = *this ; + if ( m_refData && M_CURSORDATA->m_themeCursor != -1 ) + { + SetThemeCursor( M_CURSORDATA->m_themeCursor ) ; + } + else if ( m_refData && M_CURSORDATA->m_hCursor ) + { + if ( M_CURSORDATA->m_isColorCursor ) + ::SetCCursor( (CCrsrHandle) M_CURSORDATA->m_hCursor ) ; + else + ::SetCursor( * (CursHandle) M_CURSORDATA->m_hCursor ) ; + } + else + { + SetThemeCursor( kThemeArrowCursor ) ; + } } wxCursor::~wxCursor() @@ -369,7 +369,7 @@ wxCursor::~wxCursor() // Global cursor setting void wxSetCursor(const wxCursor& cursor) { - cursor.MacInstall() ; + cursor.MacInstall() ; } diff --git a/src/mac/carbon/data.cpp b/src/mac/carbon/data.cpp index c6471c8b0b..6b56b896dc 100644 --- a/src/mac/carbon/data.cpp +++ b/src/mac/carbon/data.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -137,7 +137,7 @@ const wxChar *wxDoubleToStringStr = wxT("%.2f"); const wxEventTable *wxEvtHandler::GetEventTable() const { return &wxEvtHandler::sm_eventTable; } const wxEventTable wxEvtHandler::sm_eventTable = - { NULL, &wxEvtHandler::sm_eventTableEntries[0] }; + { NULL, &wxEvtHandler::sm_eventTableEntries[0] }; const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = { { 0, 0, 0, NULL } }; #endif diff --git a/src/mac/carbon/dataobj.cpp b/src/mac/carbon/dataobj.cpp index 3d6437c7b7..15377f7f5b 100644 --- a/src/mac/carbon/dataobj.cpp +++ b/src/mac/carbon/dataobj.cpp @@ -141,7 +141,7 @@ bool wxDataObject::IsSupportedFormat( } else { - wxDataFormat* pFormats = new wxDataFormat[nFormatCount]; + wxDataFormat* pFormats = new wxDataFormat[nFormatCount]; GetAllFormats( pFormats ,vDir ); @@ -183,7 +183,7 @@ bool wxFileDataObject::GetDataHere( size_t wxFileDataObject::GetDataSize() const { - size_t nRes = 0; + size_t nRes = 0; for (size_t i = 0; i < m_filenames.GetCount(); i++) { @@ -201,7 +201,7 @@ bool wxFileDataObject::SetData( { m_filenames.Empty(); - wxString sFile( (const char *)pBuf); /* char, not wxChar */ + wxString sFile( (const char *)pBuf); /* char, not wxChar */ AddFile(sFile); @@ -225,15 +225,15 @@ wxBitmapDataObject::wxBitmapDataObject() } wxBitmapDataObject::wxBitmapDataObject( - const wxBitmap& rBitmap + const wxBitmap& rBitmap ) : wxBitmapDataObjectBase(rBitmap) { Init(); if ( m_bitmap.Ok() ) { - m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; - } + m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; + } } wxBitmapDataObject::~wxBitmapDataObject() @@ -249,23 +249,23 @@ void wxBitmapDataObject::SetBitmap( wxBitmapDataObjectBase::SetBitmap(rBitmap); if ( m_bitmap.Ok() ) { - m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; - } + m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; + } } void wxBitmapDataObject::Init() { - m_pictHandle = NULL ; - m_pictCreated = false ; + m_pictHandle = NULL ; + m_pictCreated = false ; } void wxBitmapDataObject::Clear() { - if ( m_pictCreated && m_pictHandle ) - { - KillPicture( (PicHandle) m_pictHandle ) ; - } - m_pictHandle = NULL ; + if ( m_pictCreated && m_pictHandle ) + { + KillPicture( (PicHandle) m_pictHandle ) ; + } + m_pictHandle = NULL ; } bool wxBitmapDataObject::GetDataHere( @@ -283,7 +283,7 @@ bool wxBitmapDataObject::GetDataHere( size_t wxBitmapDataObject::GetDataSize() const { - return GetHandleSize((Handle)m_pictHandle) ; + return GetHandleSize((Handle)m_pictHandle) ; } bool wxBitmapDataObject::SetData( @@ -299,7 +299,7 @@ bool wxBitmapDataObject::SetData( Rect frame = (**picHandle).picFrame ; m_bitmap.SetPict( picHandle ) ; - m_bitmap.SetWidth( frame.right - frame.left ) ; - m_bitmap.SetHeight( frame.bottom - frame.top ) ; + m_bitmap.SetWidth( frame.right - frame.left ) ; + m_bitmap.SetHeight( frame.bottom - frame.top ) ; return m_bitmap.Ok(); } diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 9e84d5f4aa..9dff84e4d3 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -6,11 +6,13 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// + #ifdef __GNUG__ #pragma implementation "dc.h" #endif + #include "wx/dc.h" #include "wx/app.h" #include "wx/mac/uma.h" @@ -30,32 +32,37 @@ using namespace std ; #if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) #endif + //----------------------------------------------------------------------------- // constants //----------------------------------------------------------------------------- -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 + +#define mm2inches 0.0393700787402 +#define inches2mm 25.4 +#define mm2twips 56.6929133859 +#define twips2mm 0.0176388888889 +#define mm2pt 2.83464566929 +#define pt2mm 0.352777777778 #ifndef __DARWIN__ const double M_PI = 3.14159265358979 ; #endif const double RAD2DEG = 180.0 / M_PI; const short kEmulatedMode = -1 ; const short kUnsupportedMode = -2 ; + wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) : - m_ph( (GrafPtr) dc->m_macPort ) + m_ph( (GrafPtr) dc->m_macPort ) { - wxASSERT( dc->Ok() ) ; - m_dc = dc ; - dc->MacSetupPort(&m_ph) ; + wxASSERT( dc->Ok() ) ; + m_dc = dc ; + dc->MacSetupPort(&m_ph) ; } + wxMacPortSetter::~wxMacPortSetter() { - m_dc->MacCleanupPort(&m_ph) ; + m_dc->MacCleanupPort(&m_ph) ; } + wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) { m_formerClip = NewRgn() ; @@ -65,21 +72,21 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) if ( win ) { #if 0 - // this clipping area was set to the parent window's drawing area, lead to problems - // with MacOSX controls drawing outside their wx' rectangle + // this clipping area was set to the parent window's drawing area, lead to problems + // with MacOSX controls drawing outside their wx' rectangle RgnHandle insidergn = NewRgn() ; int x = 0 , y = 0; wxWindow *parent = win->GetParent() ; parent->MacWindowToRootWindow( &x,&y ) ; wxSize size = parent->GetSize() ; SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() , - size.x - parent->MacGetRightBorderSize(), - size.y - parent->MacGetBottomBorderSize()) ; + size.x - parent->MacGetRightBorderSize(), + size.y - parent->MacGetBottomBorderSize()) ; CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip ) ; - SectRgn( m_newClip , insidergn , m_newClip ) ; + SectRgn( m_newClip , insidergn , m_newClip ) ; OffsetRgn( m_newClip , x , y ) ; SetClip( m_newClip ) ; - DisposeRgn( insidergn ) ; + DisposeRgn( insidergn ) ; #endif RgnHandle insidergn = NewRgn() ; int x = 0 , y = 0; @@ -87,138 +94,143 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion().GetWXHRGN() , m_newClip ) ; OffsetRgn( m_newClip , x , y ) ; SetClip( m_newClip ) ; - } + } } + wxMacWindowClipper::~wxMacWindowClipper() { SetClip( m_formerClip ) ; - DisposeRgn( m_newClip ) ; - DisposeRgn( m_formerClip ) ; + DisposeRgn( m_newClip ) ; + DisposeRgn( m_formerClip ) ; } + //----------------------------------------------------------------------------- // Local functions //----------------------------------------------------------------------------- static inline double dmin(double a, double b) { return a < b ? a : b; } static inline double dmax(double a, double b) { return a > b ? a : b; } static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } + //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- // this function emulates all wx colour manipulations, used to verify the implementation // by setting the mode in the blitting functions to kEmulatedMode void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) ; + void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) { switch ( logical_func ) { - case wxAND: // src AND dst - dstColor.red = dstColor.red & srcColor.red ; - dstColor.green = dstColor.green & srcColor.green ; - dstColor.blue = dstColor.blue & srcColor.blue ; - break ; - case wxAND_INVERT: // (NOT src) AND dst - dstColor.red = dstColor.red & ~srcColor.red ; - dstColor.green = dstColor.green & ~srcColor.green ; - dstColor.blue = dstColor.blue & ~srcColor.blue ; - break ; - case wxAND_REVERSE:// src AND (NOT dst) - dstColor.red = ~dstColor.red & srcColor.red ; - dstColor.green = ~dstColor.green & srcColor.green ; - dstColor.blue = ~dstColor.blue & srcColor.blue ; - break ; - case wxCLEAR: // 0 - dstColor.red = 0 ; - dstColor.green = 0 ; - dstColor.blue = 0 ; - break ; + case wxAND: // src AND dst + dstColor.red = dstColor.red & srcColor.red ; + dstColor.green = dstColor.green & srcColor.green ; + dstColor.blue = dstColor.blue & srcColor.blue ; + break ; + case wxAND_INVERT: // (NOT src) AND dst + dstColor.red = dstColor.red & ~srcColor.red ; + dstColor.green = dstColor.green & ~srcColor.green ; + dstColor.blue = dstColor.blue & ~srcColor.blue ; + break ; + case wxAND_REVERSE:// src AND (NOT dst) + dstColor.red = ~dstColor.red & srcColor.red ; + dstColor.green = ~dstColor.green & srcColor.green ; + dstColor.blue = ~dstColor.blue & srcColor.blue ; + break ; + case wxCLEAR: // 0 + dstColor.red = 0 ; + dstColor.green = 0 ; + dstColor.blue = 0 ; + break ; case wxCOPY: // src - dstColor.red = srcColor.red ; - dstColor.green = srcColor.green ; - dstColor.blue = srcColor.blue ; - break ; - case wxEQUIV: // (NOT src) XOR dst - dstColor.red = dstColor.red ^ ~srcColor.red ; - dstColor.green = dstColor.green ^ ~srcColor.green ; - dstColor.blue = dstColor.blue ^ ~srcColor.blue ; - break ; - case wxINVERT: // NOT dst - dstColor.red = ~dstColor.red ; - dstColor.green = ~dstColor.green ; - dstColor.blue = ~dstColor.blue ; - break ; - case wxNAND: // (NOT src) OR (NOT dst) - dstColor.red = ~dstColor.red | ~srcColor.red ; - dstColor.green = ~dstColor.green | ~srcColor.green ; - dstColor.blue = ~dstColor.blue | ~srcColor.blue ; - break ; - case wxNOR: // (NOT src) AND (NOT dst) - dstColor.red = ~dstColor.red & ~srcColor.red ; - dstColor.green = ~dstColor.green & ~srcColor.green ; - dstColor.blue = ~dstColor.blue & ~srcColor.blue ; - break ; - case wxNO_OP: // dst - break ; - case wxOR: // src OR dst - dstColor.red = dstColor.red | srcColor.red ; - dstColor.green = dstColor.green | srcColor.green ; - dstColor.blue = dstColor.blue | srcColor.blue ; - break ; - case wxOR_INVERT: // (NOT src) OR dst - dstColor.red = dstColor.red | ~srcColor.red ; - dstColor.green = dstColor.green | ~srcColor.green ; - dstColor.blue = dstColor.blue | ~srcColor.blue ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - dstColor.red = ~dstColor.red | srcColor.red ; - dstColor.green = ~dstColor.green | srcColor.green ; - dstColor.blue = ~dstColor.blue | srcColor.blue ; - break ; - case wxSET: // 1 - dstColor.red = 0xFFFF ; - dstColor.green = 0xFFFF ; - dstColor.blue = 0xFFFF ; - break ; - case wxSRC_INVERT: // (NOT src) - dstColor.red = ~srcColor.red ; - dstColor.green = ~srcColor.green ; - dstColor.blue = ~srcColor.blue ; - break ; - case wxXOR: // src XOR dst - dstColor.red = dstColor.red ^ srcColor.red ; - dstColor.green = dstColor.green ^ srcColor.green ; - dstColor.blue = dstColor.blue ^ srcColor.blue ; - break ; + dstColor.red = srcColor.red ; + dstColor.green = srcColor.green ; + dstColor.blue = srcColor.blue ; + break ; + case wxEQUIV: // (NOT src) XOR dst + dstColor.red = dstColor.red ^ ~srcColor.red ; + dstColor.green = dstColor.green ^ ~srcColor.green ; + dstColor.blue = dstColor.blue ^ ~srcColor.blue ; + break ; + case wxINVERT: // NOT dst + dstColor.red = ~dstColor.red ; + dstColor.green = ~dstColor.green ; + dstColor.blue = ~dstColor.blue ; + break ; + case wxNAND: // (NOT src) OR (NOT dst) + dstColor.red = ~dstColor.red | ~srcColor.red ; + dstColor.green = ~dstColor.green | ~srcColor.green ; + dstColor.blue = ~dstColor.blue | ~srcColor.blue ; + break ; + case wxNOR: // (NOT src) AND (NOT dst) + dstColor.red = ~dstColor.red & ~srcColor.red ; + dstColor.green = ~dstColor.green & ~srcColor.green ; + dstColor.blue = ~dstColor.blue & ~srcColor.blue ; + break ; + case wxNO_OP: // dst + break ; + case wxOR: // src OR dst + dstColor.red = dstColor.red | srcColor.red ; + dstColor.green = dstColor.green | srcColor.green ; + dstColor.blue = dstColor.blue | srcColor.blue ; + break ; + case wxOR_INVERT: // (NOT src) OR dst + dstColor.red = dstColor.red | ~srcColor.red ; + dstColor.green = dstColor.green | ~srcColor.green ; + dstColor.blue = dstColor.blue | ~srcColor.blue ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + dstColor.red = ~dstColor.red | srcColor.red ; + dstColor.green = ~dstColor.green | srcColor.green ; + dstColor.blue = ~dstColor.blue | srcColor.blue ; + break ; + case wxSET: // 1 + dstColor.red = 0xFFFF ; + dstColor.green = 0xFFFF ; + dstColor.blue = 0xFFFF ; + break ; + case wxSRC_INVERT: // (NOT src) + dstColor.red = ~srcColor.red ; + dstColor.green = ~srcColor.green ; + dstColor.blue = ~srcColor.blue ; + break ; + case wxXOR: // src XOR dst + dstColor.red = dstColor.red ^ srcColor.red ; + dstColor.green = dstColor.green ^ srcColor.green ; + dstColor.blue = dstColor.blue ^ srcColor.blue ; + break ; } } + wxDC::wxDC() { - m_ok = FALSE; - m_colour = TRUE; - m_mm_to_pix_x = mm2pt; - m_mm_to_pix_y = mm2pt; - m_internalDeviceOriginX = 0; - m_internalDeviceOriginY = 0; - m_externalDeviceOriginX = 0; - m_externalDeviceOriginY = 0; - m_logicalScaleX = 1.0; - m_logicalScaleY = 1.0; - m_userScaleX = 1.0; - m_userScaleY = 1.0; - m_scaleX = 1.0; - m_scaleY = 1.0; - m_needComputeScaleX = FALSE; - m_needComputeScaleY = FALSE; - m_macPort = NULL ; - m_macMask = NULL ; - m_ok = FALSE ; - m_macFontInstalled = false ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; - m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ; - m_macBoundaryClipRgn = NewRgn() ; - m_macCurrentClipRgn = NewRgn() ; - SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , -32000 , -32000 , 32000 , 32000 ) ; - SetRectRgn( (RgnHandle) m_macCurrentClipRgn , -32000 , -32000 , 32000 , 32000 ) ; + m_ok = FALSE; + m_colour = TRUE; + m_mm_to_pix_x = mm2pt; + m_mm_to_pix_y = mm2pt; + m_internalDeviceOriginX = 0; + m_internalDeviceOriginY = 0; + m_externalDeviceOriginX = 0; + m_externalDeviceOriginY = 0; + m_logicalScaleX = 1.0; + m_logicalScaleY = 1.0; + m_userScaleX = 1.0; + m_userScaleY = 1.0; + m_scaleX = 1.0; + m_scaleY = 1.0; + m_needComputeScaleX = FALSE; + m_needComputeScaleY = FALSE; + m_macPort = NULL ; + m_macMask = NULL ; + m_ok = FALSE ; + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ; + m_macBoundaryClipRgn = NewRgn() ; + m_macCurrentClipRgn = NewRgn() ; + SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , -32000 , -32000 , 32000 , 32000 ) ; + SetRectRgn( (RgnHandle) m_macCurrentClipRgn , -32000 , -32000 , 32000 , 32000 ) ; m_pen = *wxBLACK_PEN; m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; @@ -228,20 +240,23 @@ wxDC::wxDC() m_macForegroundPixMap = NULL ; m_macBackgroundPixMap = NULL ; } + wxDC::~wxDC(void) { DisposeRgn( (RgnHandle) m_macBoundaryClipRgn ) ; DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ; } + void wxDC::MacSetupPort(wxMacPortStateHelper* help) const { wxASSERT( m_macCurrentPortStateHelper == NULL ) ; m_macCurrentPortStateHelper = help ; - SetClip( (RgnHandle) m_macCurrentClipRgn); - m_macFontInstalled = false ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; + SetClip( (RgnHandle) m_macCurrentClipRgn); + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; } + void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const { wxASSERT( m_macCurrentPortStateHelper == help ) ; @@ -271,6 +286,7 @@ void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const m_macBackgroundPixMap = NULL ; } } + void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) { wxCHECK_RET( Ok(), wxT("invalid window dc") ); @@ -356,12 +372,14 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask m_macBrushInstalled = false ; m_macFontInstalled = false ; } + void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) { - wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon")); - wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon")); + wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon")); + wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon")); DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ; } + void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC")); @@ -388,10 +406,11 @@ void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord hei m_clipY2 = yy + hh; } } + void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) { wxCHECK_RET( Ok(), wxT("invalid window dc") ) ; - wxMacPortSetter helper(this) ; + wxMacPortSetter helper(this) ; if (region.Empty()) { DestroyClippingRegion(); @@ -435,113 +454,127 @@ void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) } } } + void wxDC::DestroyClippingRegion() { - wxMacPortSetter helper(this) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; - m_clipping = FALSE; + wxMacPortSetter helper(this) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; + m_clipping = FALSE; } + void wxDC::DoGetSize( int* width, int* height ) const { - *width = m_maxX-m_minX; - *height = m_maxY-m_minY; + *width = m_maxX-m_minX; + *height = m_maxY-m_minY; } + void wxDC::DoGetSizeMM( int* width, int* height ) const { - int w = 0; - int h = 0; - GetSize( &w, &h ); - *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); - *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); + int w = 0; + int h = 0; + GetSize( &w, &h ); + *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); + *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); } + void wxDC::SetTextForeground( const wxColour &col ) { wxCHECK_RET(Ok(), wxT("Invalid DC")); m_textForegroundColour = col; m_macFontInstalled = false ; } + void wxDC::SetTextBackground( const wxColour &col ) { wxCHECK_RET(Ok(), wxT("Invalid DC")); m_textBackgroundColour = col; m_macFontInstalled = false ; } + void wxDC::SetMapMode( int mode ) { - switch (mode) - { + switch (mode) + { case wxMM_TWIPS: - SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); - break; + SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); + break; case wxMM_POINTS: - SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); - break; + SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); + break; case wxMM_METRIC: - SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); - break; + SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); + break; case wxMM_LOMETRIC: - SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); - break; + SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); + break; default: case wxMM_TEXT: - SetLogicalScale( 1.0, 1.0 ); - break; - } - if (mode != wxMM_TEXT) - { - m_needComputeScaleX = TRUE; - m_needComputeScaleY = TRUE; - } + SetLogicalScale( 1.0, 1.0 ); + break; + } + if (mode != wxMM_TEXT) + { + m_needComputeScaleX = TRUE; + m_needComputeScaleY = TRUE; + } } + void wxDC::SetUserScale( double x, double y ) { - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); + // allow negative ? -> no + m_userScaleX = x; + m_userScaleY = y; + ComputeScaleAndOrigin(); } + void wxDC::SetLogicalScale( double x, double y ) { - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); + // allow negative ? + m_logicalScaleX = x; + m_logicalScaleY = y; + ComputeScaleAndOrigin(); } + void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) { - m_logicalOriginX = x * m_signX; // is this still correct ? - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); + m_logicalOriginX = x * m_signX; // is this still correct ? + m_logicalOriginY = y * m_signY; + ComputeScaleAndOrigin(); } + void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) { - m_externalDeviceOriginX = x; - m_externalDeviceOriginY = y; - ComputeScaleAndOrigin(); + m_externalDeviceOriginX = x; + m_externalDeviceOriginY = y; + ComputeScaleAndOrigin(); } + #if 0 void wxDC::SetInternalDeviceOrigin( long x, long y ) { - m_internalDeviceOriginX = x; - m_internalDeviceOriginY = y; - ComputeScaleAndOrigin(); + m_internalDeviceOriginX = x; + m_internalDeviceOriginY = y; + ComputeScaleAndOrigin(); } void wxDC::GetInternalDeviceOrigin( long *x, long *y ) { - if (x) *x = m_internalDeviceOriginX; - if (y) *y = m_internalDeviceOriginY; + if (x) *x = m_internalDeviceOriginX; + if (y) *y = m_internalDeviceOriginY; } #endif + void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); + m_signX = (xLeftRight ? 1 : -1); + m_signY = (yBottomUp ? -1 : 1); + ComputeScaleAndOrigin(); } + wxSize wxDC::GetPPI() const { return wxSize(72, 72); } + int wxDC::GetDepth() const { if ( IsPortColor( (CGrafPtr) m_macPort ) ) @@ -550,77 +583,88 @@ int wxDC::GetDepth() const } return 1 ; } + void wxDC::ComputeScaleAndOrigin() { - // CMB: copy scale to see if it changes - double origScaleX = m_scaleX; - double origScaleY = m_scaleY; - m_scaleX = m_logicalScaleX * m_userScaleX; - m_scaleY = m_logicalScaleY * m_userScaleY; - m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; - m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; - // CMB: if scale has changed call SetPen to recalulate the line width - if (m_scaleX != origScaleX || m_scaleY != origScaleY) - { - // this is a bit artificial, but we need to force wxDC to think - // the pen has changed - wxPen* pen = & GetPen(); - wxPen tempPen; - m_pen = tempPen; - SetPen(* pen); - } + // CMB: copy scale to see if it changes + double origScaleX = m_scaleX; + double origScaleY = m_scaleY; + m_scaleX = m_logicalScaleX * m_userScaleX; + m_scaleY = m_logicalScaleY * m_userScaleY; + m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; + m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; + // CMB: if scale has changed call SetPen to recalulate the line width + if (m_scaleX != origScaleX || m_scaleY != origScaleY) + { + // this is a bit artificial, but we need to force wxDC to think + // the pen has changed + wxPen* pen = & GetPen(); + wxPen tempPen; + m_pen = tempPen; + SetPen(* pen); + } } + void wxDC::SetPalette( const wxPalette& palette ) { } + void wxDC::SetBackgroundMode( int mode ) { - m_backgroundMode = mode ; + m_backgroundMode = mode ; } + void wxDC::SetFont( const wxFont &font ) { m_font = font; m_macFontInstalled = false ; } + void wxDC::SetPen( const wxPen &pen ) { - if ( m_pen == pen ) - return ; - m_pen = pen; - m_macPenInstalled = false ; + if ( m_pen == pen ) + return ; + m_pen = pen; + m_macPenInstalled = false ; } + void wxDC::SetBrush( const wxBrush &brush ) { - if (m_brush == brush) - return; - m_brush = brush; - m_macBrushInstalled = false ; + if (m_brush == brush) + return; + m_brush = brush; + m_macBrushInstalled = false ; } + void wxDC::SetBackground( const wxBrush &brush ) { - if (m_backgroundBrush == brush) - return; - m_backgroundBrush = brush; - if (!m_backgroundBrush.Ok()) - return; - m_macBrushInstalled = false ; + if (m_backgroundBrush == brush) + return; + m_backgroundBrush = brush; + if (!m_backgroundBrush.Ok()) + return; + m_macBrushInstalled = false ; } + void wxDC::SetLogicalFunction( int function ) { - if (m_logicalFunction == function) - return; - m_logicalFunction = function ; - m_macFontInstalled = false ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; + if (m_logicalFunction == function) + return; + m_logicalFunction = function ; + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; } + extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); + bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { return wxDoFloodFill(this, x, y, col, style); } + bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const { wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") ); @@ -629,47 +673,49 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour ); // Convert from Mac colour to wx col->Set( colour.red >> 8, - colour.green >> 8, - colour.blue >> 8); + colour.green >> 8, + colour.blue >> 8); return true ; } + void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) { - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : - m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2; + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : + m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2; wxCoord xx1 = XLOG2DEVMAC(x1) - offset; wxCoord yy1 = YLOG2DEVMAC(y1) - offset; wxCoord xx2 = XLOG2DEVMAC(x2) - offset; wxCoord yy2 = YLOG2DEVMAC(y2) - offset; if ((m_pen.GetCap() == wxCAP_ROUND) && (m_pen.GetWidth() <= 1)) - { - // Implement LAST_NOT for MAC at least for - // orthogonal lines. RR. - if (xx1 == xx2) - { - if (yy1 < yy2) - yy2--; - if (yy1 > yy2) - yy2++; - } - if (yy1 == yy2) - { - if (xx1 < xx2) - xx2--; - if (xx1 > xx2) - xx2++; - } - } - ::MoveTo(xx1, yy1); - ::LineTo(xx2, yy2); - } + { + // Implement LAST_NOT for MAC at least for + // orthogonal lines. RR. + if (xx1 == xx2) + { + if (yy1 < yy2) + yy2--; + if (yy1 > yy2) + yy2++; + } + if (yy1 == yy2) + { + if (xx1 < xx2) + xx2--; + if (xx1 > xx2) + xx2++; + } + } + ::MoveTo(xx1, yy1); + ::LineTo(xx2, yy2); + } } + void wxDC::DoCrossHair( wxCoord x, wxCoord y ) { wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") ); @@ -690,14 +736,16 @@ void wxDC::DoCrossHair( wxCoord x, wxCoord y ) CalcBoundingBox(x+w, y+h); } } + /* - * To draw arcs properly the angles need to be converted from the WX style: - * Angles start on the +ve X axis and go anti-clockwise (As you would draw on - * a normal axis on paper). - * TO - * the Mac style: - * Angles start on the +ve y axis and go clockwise. - */ +* To draw arcs properly the angles need to be converted from the WX style: +* Angles start on the +ve X axis and go anti-clockwise (As you would draw on +* a normal axis on paper). +* TO +* the Mac style: +* Angles start on the +ve y axis and go clockwise. +*/ + static double wxConvertWXangleToMACangle(double angle) { double newAngle = 90 - angle ; @@ -705,9 +753,10 @@ static double wxConvertWXangleToMACangle(double angle) newAngle += 360 ; return newAngle ; } + void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc ) + wxCoord x2, wxCoord y2, + wxCoord xc, wxCoord yc ) { wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC")); wxMacPortSetter helper(this) ; @@ -735,14 +784,14 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, { radius1 = (xx1 - xxc == 0) ? (yy1 - yyc < 0) ? 90.0 : -90.0 : - -atan2(double(yy1-yyc), double(xx1-xxc)) * RAD2DEG; - radius2 = (xx2 - xxc == 0) ? + -atan2(double(yy1-yyc), double(xx1-xxc)) * RAD2DEG; + radius2 = (xx2 - xxc == 0) ? (yy2 - yyc < 0) ? 90.0 : -90.0 : - -atan2(double(yy2-yyc), double(xx2-xxc)) * RAD2DEG; - } - wxCoord alpha2 = wxCoord(radius2 - radius1); + -atan2(double(yy2-yyc), double(xx2-xxc)) * RAD2DEG; + } + wxCoord alpha2 = wxCoord(radius2 - radius1); wxCoord alpha1 = wxCoord(wxConvertWXangleToMACangle(radius1)); - if( (xx1 > xx2) || (yy1 > yy2) ) { + if( (xx1 > xx2) || (yy1 > yy2) ) { alpha2 *= -1; } Rect r = { yyc - rad, xxc - rad, yyc + rad, xxc + rad }; @@ -755,8 +804,9 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, FrameArc(&r, alpha1, alpha2); } } + void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, - double sa, double ea ) + double sa, double ea ) { wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC")); wxMacPortSetter helper(this) ; @@ -786,193 +836,198 @@ void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, FrameArc(&r, (short)sa, (short)angle); } } + void wxDC::DoDrawPoint( wxCoord x, wxCoord y ) { - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - if (m_pen.GetStyle() != wxTRANSPARENT) - { + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + if (m_pen.GetStyle() != wxTRANSPARENT) + { wxCoord xx1 = XLOG2DEVMAC(x); wxCoord yy1 = YLOG2DEVMAC(y); RGBColor pencolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); ::SetCPixel( xx1,yy1,&pencolor) ; CalcBoundingBox(x, y); - } + } } + void wxDC::DoDrawLines(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset) -{ - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - if (m_pen.GetStyle() == wxTRANSPARENT) - return; - MacInstallPen() ; - wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : - m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2 ; - wxCoord x1, x2 , y1 , y2 ; - x1 = XLOG2DEVMAC(points[0].x + xoffset); - y1 = YLOG2DEVMAC(points[0].y + yoffset); - ::MoveTo(x1 - offset, y1 - offset ); - for (int i = 0; i < n-1; i++) - { - x2 = XLOG2DEVMAC(points[i+1].x + xoffset); - y2 = YLOG2DEVMAC(points[i+1].y + yoffset); - ::LineTo( x2 - offset, y2 - offset ); - } + wxCoord xoffset, wxCoord yoffset) +{ + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + if (m_pen.GetStyle() == wxTRANSPARENT) + return; + MacInstallPen() ; + wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : + m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2 ; + wxCoord x1, x2 , y1 , y2 ; + x1 = XLOG2DEVMAC(points[0].x + xoffset); + y1 = YLOG2DEVMAC(points[0].y + yoffset); + ::MoveTo(x1 - offset, y1 - offset ); + for (int i = 0; i < n-1; i++) + { + x2 = XLOG2DEVMAC(points[i+1].x + xoffset); + y2 = YLOG2DEVMAC(points[i+1].y + yoffset); + ::LineTo( x2 - offset, y2 - offset ); + } } + void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle ) { - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - wxCoord x1, x2 , y1 , y2 ; + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + wxCoord x1, x2 , y1 , y2 ; if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) return ; - PolyHandle polygon = OpenPoly(); - x2 = x1 = XLOG2DEVMAC(points[0].x + xoffset); - y2 = y1 = YLOG2DEVMAC(points[0].y + yoffset); - ::MoveTo(x1,y1); - for (int i = 1; i < n; i++) - { - x2 = XLOG2DEVMAC(points[i].x + xoffset); - y2 = YLOG2DEVMAC(points[i].y + yoffset); - ::LineTo(x2, y2); - } + PolyHandle polygon = OpenPoly(); + x2 = x1 = XLOG2DEVMAC(points[0].x + xoffset); + y2 = y1 = YLOG2DEVMAC(points[0].y + yoffset); + ::MoveTo(x1,y1); + for (int i = 1; i < n; i++) + { + x2 = XLOG2DEVMAC(points[i].x + xoffset); + y2 = YLOG2DEVMAC(points[i].y + yoffset); + ::LineTo(x2, y2); + } // close the polyline if necessary if ( x1 != x2 || y1 != y2 ) { ::LineTo(x1,y1 ) ; } - ClosePoly(); - if (m_brush.GetStyle() != wxTRANSPARENT) - { - MacInstallBrush(); - ::PaintPoly( polygon ); - } - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - ::FramePoly( polygon ) ; - } - KillPoly( polygon ); + ClosePoly(); + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush(); + ::PaintPoly( polygon ); + } + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FramePoly( polygon ) ; + } + KillPoly( polygon ); } + void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { wxCHECK_RET(Ok(), wxT("Invalid DC")); wxMacPortSetter helper(this) ; - wxCoord xx = XLOG2DEVMAC(x); - wxCoord yy = YLOG2DEVMAC(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) - return; - // CMB: handle -ve width and/or height - if (ww < 0) - { - ww = -ww; - xx = xx - ww; - } - if (hh < 0) - { - hh = -hh; - yy = yy - hh; - } - Rect rect = { yy , xx , yy + hh , xx + ww } ; - if (m_brush.GetStyle() != wxTRANSPARENT) - { - MacInstallBrush() ; - ::PaintRect( &rect ) ; - } - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - ::FrameRect( &rect ) ; - } + wxCoord xx = XLOG2DEVMAC(x); + wxCoord yy = YLOG2DEVMAC(y); + wxCoord ww = m_signX * XLOG2DEVREL(width); + wxCoord hh = m_signY * YLOG2DEVREL(height); + // CMB: draw nothing if transformed w or h is 0 + if (ww == 0 || hh == 0) + return; + // CMB: handle -ve width and/or height + if (ww < 0) + { + ww = -ww; + xx = xx - ww; + } + if (hh < 0) + { + hh = -hh; + yy = yy - hh; + } + Rect rect = { yy , xx , yy + hh , xx + ww } ; + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::PaintRect( &rect ) ; + } + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FrameRect( &rect ) ; + } } + void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, - wxCoord width, wxCoord height, - double radius) + wxCoord width, wxCoord height, + double radius) { wxCHECK_RET(Ok(), wxT("Invalid DC")); wxMacPortSetter helper(this) ; if (radius < 0.0) - radius = - radius * ((width < height) ? width : height); - wxCoord xx = XLOG2DEVMAC(x); - wxCoord yy = YLOG2DEVMAC(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) - return; - // CMB: handle -ve width and/or height - if (ww < 0) - { - ww = -ww; - xx = xx - ww; - } - if (hh < 0) - { - hh = -hh; - yy = yy - hh; - } - Rect rect = { yy , xx , yy + hh , xx + ww } ; - if (m_brush.GetStyle() != wxTRANSPARENT) - { - MacInstallBrush() ; - ::PaintRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; - } - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - ::FrameRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; - } + radius = - radius * ((width < height) ? width : height); + wxCoord xx = XLOG2DEVMAC(x); + wxCoord yy = YLOG2DEVMAC(y); + wxCoord ww = m_signX * XLOG2DEVREL(width); + wxCoord hh = m_signY * YLOG2DEVREL(height); + // CMB: draw nothing if transformed w or h is 0 + if (ww == 0 || hh == 0) + return; + // CMB: handle -ve width and/or height + if (ww < 0) + { + ww = -ww; + xx = xx - ww; + } + if (hh < 0) + { + hh = -hh; + yy = yy - hh; + } + Rect rect = { yy , xx , yy + hh , xx + ww } ; + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::PaintRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; + } + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FrameRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; + } } + void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { wxCHECK_RET(Ok(), wxT("Invalid DC")); wxMacPortSetter helper(this) ; - wxCoord xx = XLOG2DEVMAC(x); - wxCoord yy = YLOG2DEVMAC(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) - return; - // CMB: handle -ve width and/or height - if (ww < 0) - { - ww = -ww; - xx = xx - ww; - } - if (hh < 0) - { - hh = -hh; - yy = yy - hh; - } - Rect rect = { yy , xx , yy + hh , xx + ww } ; - if (m_brush.GetStyle() != wxTRANSPARENT) - { - MacInstallBrush() ; - ::PaintOval( &rect ) ; - } - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - ::FrameOval( &rect ) ; - } + wxCoord xx = XLOG2DEVMAC(x); + wxCoord yy = YLOG2DEVMAC(y); + wxCoord ww = m_signX * XLOG2DEVREL(width); + wxCoord hh = m_signY * YLOG2DEVREL(height); + // CMB: draw nothing if transformed w or h is 0 + if (ww == 0 || hh == 0) + return; + // CMB: handle -ve width and/or height + if (ww < 0) + { + ww = -ww; + xx = xx - ww; + } + if (hh < 0) + { + hh = -hh; + yy = yy - hh; + } + Rect rect = { yy , xx , yy + hh , xx + ww } ; + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::PaintOval( &rect ) ; + } + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FrameOval( &rect ) ; + } } - bool wxDC::CanDrawBitmap(void) const { - return true ; + return true ; } bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, - wxCoord xsrcMask, wxCoord ysrcMask ) + wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, + wxCoord xsrcMask, wxCoord ysrcMask ) { wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc")); wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit Illegal source DC")); @@ -985,112 +1040,112 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, // correct the parameter in case this dc does not have a mask at all if ( useMask && !source->m_macMask ) useMask = false ; - Rect srcrect , dstrect ; - srcrect.top = source->YLOG2DEVMAC(ysrc) ; - srcrect.left = source->XLOG2DEVMAC(xsrc) ; - srcrect.right = source->XLOG2DEVMAC(xsrc + width ) ; - srcrect.bottom = source->YLOG2DEVMAC(ysrc + height) ; - dstrect.top = YLOG2DEVMAC(ydest) ; - dstrect.left = XLOG2DEVMAC(xdest) ; - dstrect.bottom = YLOG2DEVMAC(ydest + height ) ; - dstrect.right = XLOG2DEVMAC(xdest + width ) ; + Rect srcrect , dstrect ; + srcrect.top = source->YLOG2DEVMAC(ysrc) ; + srcrect.left = source->XLOG2DEVMAC(xsrc) ; + srcrect.right = source->XLOG2DEVMAC(xsrc + width ) ; + srcrect.bottom = source->YLOG2DEVMAC(ysrc + height) ; + dstrect.top = YLOG2DEVMAC(ydest) ; + dstrect.left = XLOG2DEVMAC(xdest) ; + dstrect.bottom = YLOG2DEVMAC(ydest + height ) ; + dstrect.right = XLOG2DEVMAC(xdest + width ) ; short mode = kUnsupportedMode ; bool invertDestinationFirst = false ; switch ( logical_func ) { - case wxAND: // src AND dst - mode = srcOr ; // ok - break ; - case wxAND_INVERT: // (NOT src) AND dst - mode = notSrcOr ; // ok - break ; - case wxAND_REVERSE:// src AND (NOT dst) - invertDestinationFirst = true ; - mode = srcOr ; - break ; - case wxCLEAR: // 0 - mode = kEmulatedMode ; - break ; - case wxCOPY: // src - mode = srcCopy ; // ok - break ; - case wxEQUIV: // (NOT src) XOR dst - mode = srcXor ; // ok - break ; - case wxINVERT: // NOT dst - mode = kEmulatedMode ; //or hilite ; - break ; - case wxNAND: // (NOT src) OR (NOT dst) - invertDestinationFirst = true ; - mode = srcBic ; - break ; - case wxNOR: // (NOT src) AND (NOT dst) - invertDestinationFirst = true ; - mode = notSrcOr ; - break ; - case wxNO_OP: // dst - mode = kEmulatedMode ; // this has already been handled upon entry - break ; - case wxOR: // src OR dst - mode = notSrcBic ; - break ; - case wxOR_INVERT: // (NOT src) OR dst - mode = srcBic ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - invertDestinationFirst = true ; - mode = notSrcBic ; - break ; - case wxSET: // 1 - mode = kEmulatedMode ; - break ; - case wxSRC_INVERT: // (NOT src) - mode = notSrcCopy ; // ok - break ; - case wxXOR: // src XOR dst - mode = notSrcXor ; // ok - break ; - default : - break ; + case wxAND: // src AND dst + mode = srcOr ; // ok + break ; + case wxAND_INVERT: // (NOT src) AND dst + mode = notSrcOr ; // ok + break ; + case wxAND_REVERSE:// src AND (NOT dst) + invertDestinationFirst = true ; + mode = srcOr ; + break ; + case wxCLEAR: // 0 + mode = kEmulatedMode ; + break ; + case wxCOPY: // src + mode = srcCopy ; // ok + break ; + case wxEQUIV: // (NOT src) XOR dst + mode = srcXor ; // ok + break ; + case wxINVERT: // NOT dst + mode = kEmulatedMode ; //or hilite ; + break ; + case wxNAND: // (NOT src) OR (NOT dst) + invertDestinationFirst = true ; + mode = srcBic ; + break ; + case wxNOR: // (NOT src) AND (NOT dst) + invertDestinationFirst = true ; + mode = notSrcOr ; + break ; + case wxNO_OP: // dst + mode = kEmulatedMode ; // this has already been handled upon entry + break ; + case wxOR: // src OR dst + mode = notSrcBic ; + break ; + case wxOR_INVERT: // (NOT src) OR dst + mode = srcBic ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + invertDestinationFirst = true ; + mode = notSrcBic ; + break ; + case wxSET: // 1 + mode = kEmulatedMode ; + break ; + case wxSRC_INVERT: // (NOT src) + mode = notSrcCopy ; // ok + break ; + case wxXOR: // src XOR dst + mode = notSrcXor ; // ok + break ; + default : + break ; } if ( mode == kUnsupportedMode ) { wxFAIL_MSG("unsupported blitting mode" ); return FALSE ; } - CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; - PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; - if ( LockPixels(bmappixels) ) - { + CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; + PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; + if ( LockPixels(bmappixels) ) + { wxMacPortSetter helper(this) ; - if ( source->GetDepth() == 1 ) - { - RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ; - RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()) ) ; + if ( source->GetDepth() == 1 ) + { + RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ; + RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()) ) ; } else { // the modes need this, otherwise we'll end up having really nice colors... - RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; - RGBColor black = { 0,0,0} ; - RGBForeColor( &black ) ; - RGBBackColor( &white ) ; + RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; + RGBColor black = { 0,0,0} ; + RGBForeColor( &black ) ; + RGBBackColor( &white ) ; } - if ( useMask && source->m_macMask ) - { - if ( mode == srcCopy ) - { - if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ) - { - CopyMask( GetPortBitMapForCopyBits( sourcePort ) , - GetPortBitMapForCopyBits( MAC_WXHBITMAP(source->m_macMask) ) , - GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , - &srcrect, &srcrect , &dstrect ) ; - UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; - } - } - else - { + if ( useMask && source->m_macMask ) + { + if ( mode == srcCopy ) + { + if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ) + { + CopyMask( GetPortBitMapForCopyBits( sourcePort ) , + GetPortBitMapForCopyBits( MAC_WXHBITMAP(source->m_macMask) ) , + GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , + &srcrect, &srcrect , &dstrect ) ; + UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; + } + } + else + { RgnHandle clipRgn = NewRgn() ; LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; @@ -1099,17 +1154,17 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, if ( mode == kEmulatedMode ) { Pattern pat ; - ::PenPat(GetQDGlobalsBlack(&pat)); + ::PenPat(GetQDGlobalsBlack(&pat)); if ( logical_func == wxSET ) { RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ; - ::RGBForeColor( &col ) ; + ::RGBForeColor( &col ) ; ::PaintRgn( clipRgn ) ; } else if ( logical_func == wxCLEAR ) { RGBColor col= { 0x0000, 0x0000, 0x0000 } ; - ::RGBForeColor( &col ) ; + ::RGBForeColor( &col ) ; ::PaintRgn( clipRgn ) ; } else if ( logical_func == wxINVERT ) @@ -1145,31 +1200,31 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, { MacInvertRgn( clipRgn ) ; } - CopyBits( GetPortBitMapForCopyBits( sourcePort ) , - GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , - &srcrect, &dstrect, mode, clipRgn ) ; - } - DisposeRgn( clipRgn ) ; - } - } - else - { + CopyBits( GetPortBitMapForCopyBits( sourcePort ) , + GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , + &srcrect, &dstrect, mode, clipRgn ) ; + } + DisposeRgn( clipRgn ) ; + } + } + else + { RgnHandle clipRgn = NewRgn() ; SetRectRgn( clipRgn , dstrect.left , dstrect.top , dstrect.right , dstrect.bottom ) ; - if ( mode == kEmulatedMode ) - { + if ( mode == kEmulatedMode ) + { Pattern pat ; - ::PenPat(GetQDGlobalsBlack(&pat)); + ::PenPat(GetQDGlobalsBlack(&pat)); if ( logical_func == wxSET ) { RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ; - ::RGBForeColor( &col ) ; + ::RGBForeColor( &col ) ; ::PaintRgn( clipRgn ) ; } else if ( logical_func == wxCLEAR ) { RGBColor col= { 0x0000, 0x0000, 0x0000 } ; - ::RGBForeColor( &col ) ; + ::RGBForeColor( &col ) ; ::PaintRgn( clipRgn ) ; } else if ( logical_func == wxINVERT ) @@ -1197,34 +1252,36 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, } } } - } - else - { + } + else + { if ( invertDestinationFirst ) { MacInvertRgn( clipRgn ) ; } - CopyBits( GetPortBitMapForCopyBits( sourcePort ) , - GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , - &srcrect, &dstrect, mode, NULL ) ; - } - DisposeRgn( clipRgn ) ; - } - UnlockPixels( bmappixels ) ; - } - m_macPenInstalled = false ; - m_macBrushInstalled = false ; - m_macFontInstalled = false ; - return TRUE; -} -inline Fixed IntToFixed( int inInt ) - { - return (((SInt32) inInt) << 16); - } -inline int FixedToInt( Fixed inFixed ) - { - return (((SInt32) inFixed) >> 16); - } + CopyBits( GetPortBitMapForCopyBits( sourcePort ) , + GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , + &srcrect, &dstrect, mode, NULL ) ; + } + DisposeRgn( clipRgn ) ; + } + UnlockPixels( bmappixels ) ; + } + m_macPenInstalled = false ; + m_macBrushInstalled = false ; + m_macFontInstalled = false ; + return TRUE; +} + +inline Fixed IntToFixed( int inInt ) +{ + return (((SInt32) inInt) << 16); +} + +inline int FixedToInt( Fixed inFixed ) +{ + return (((SInt32) inFixed) >> 16); +} void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, double angle) @@ -1239,16 +1296,16 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, return ; wxMacPortSetter helper(this) ; MacInstallFont() ; - wxString text ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - text = wxMacMakeMacStringFromPC( str ) ; - } - else - { - text = str ; - } - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + wxString text ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + text = wxMacMakeMacStringFromPC( str ) ; + } + else + { + text = str ; + } + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( 0 ) { m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); @@ -1256,23 +1313,23 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, m_macAliasWasEnabled = true ; } OSStatus status = noErr ; - TECObjectRef ec; - status = TECCreateConverter(&ec, kTextEncodingMacRoman, kTextEncodingUnicodeDefault); - wxASSERT_MSG( status == noErr , "couldn't start converter" ) ; + TECObjectRef ec; + status = TECCreateConverter(&ec, kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + wxASSERT_MSG( status == noErr , "couldn't start converter" ) ; ByteCount byteOutLen ; ByteCount byteInLen = text.Length() ; ByteCount byteBufferLen = byteInLen *2 ; char* buf = new char[byteBufferLen] ; - status = TECConvertText(ec, (ConstTextPtr)text.c_str() , byteInLen, &byteInLen, - (TextPtr)buf, byteBufferLen, &byteOutLen); - wxASSERT_MSG( status == noErr , "couldn't convert text" ) ; - status = TECDisposeConverter(ec); - wxASSERT_MSG( status == noErr , "couldn't dispose converter" ) ; - ATSUTextLayout atsuLayout ; - UniCharCount chars = byteOutLen / 2 ; + status = TECConvertText(ec, (ConstTextPtr)text.c_str() , byteInLen, &byteInLen, + (TextPtr)buf, byteBufferLen, &byteOutLen); + wxASSERT_MSG( status == noErr , "couldn't convert text" ) ; + status = TECDisposeConverter(ec); + wxASSERT_MSG( status == noErr , "couldn't dispose converter" ) ; + ATSUTextLayout atsuLayout ; + UniCharCount chars = byteOutLen / 2 ; status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 , &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; - wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" ); + wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" ); int iAngle = int( angle ); int drawX = XLOG2DEVMAC(x) ; int drawY = YLOG2DEVMAC(y) ; @@ -1286,708 +1343,720 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, if ( abs(iAngle) > 0 ) { Fixed atsuAngle = IntToFixed( iAngle ) ; - ATSUAttributeTag atsuTags[] = - { - kATSULineRotationTag , - } ; - ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = - { - sizeof( Fixed ) , - } ; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = - { - &atsuAngle , - } ; - status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag), - atsuTags, atsuSizes, atsuValues ) ; - } - status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, - &textBefore , &textAfter, &ascent , &descent ); + ATSUAttributeTag atsuTags[] = + { + kATSULineRotationTag , + } ; + ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + sizeof( Fixed ) , + } ; + ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + &atsuAngle , + } ; + status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag), + atsuTags, atsuSizes, atsuValues ) ; + } + status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, + &textBefore , &textAfter, &ascent , &descent ); drawX += sin(angle/RAD2DEG) * FixedToInt(ascent) ; drawY += cos(angle/RAD2DEG) * FixedToInt(ascent) ; status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, - IntToFixed(drawX) , IntToFixed(drawY) ); - wxASSERT_MSG( status == noErr , "couldn't draw the rotated text" ); + IntToFixed(drawX) , IntToFixed(drawY) ); + wxASSERT_MSG( status == noErr , "couldn't draw the rotated text" ); Rect rect ; - status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, - IntToFixed(drawX) , IntToFixed(drawY) , &rect ); - wxASSERT_MSG( status == noErr , "couldn't measure the rotated text" ); + status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, + IntToFixed(drawX) , IntToFixed(drawY) , &rect ); + wxASSERT_MSG( status == noErr , "couldn't measure the rotated text" ); OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ; CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); ::ATSUDisposeTextLayout(atsuLayout); delete[] buf ; } + void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC")); wxMacPortSetter helper(this) ; - long xx = XLOG2DEVMAC(x); - long yy = YLOG2DEVMAC(y); + long xx = XLOG2DEVMAC(x); + long yy = YLOG2DEVMAC(y); #if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( m_font.GetNoAntiAliasing() ) - useDrawThemeText = false ; + bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; + if ( m_font.GetNoAntiAliasing() ) + useDrawThemeText = false ; #endif - MacInstallFont() ; + MacInstallFont() ; if ( 0 ) { m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); SetAntiAliasedTextEnabled(true, 8); m_macAliasWasEnabled = true ; } - FontInfo fi ; - ::GetFontInfo( &fi ) ; + FontInfo fi ; + ::GetFontInfo( &fi ) ; #if TARGET_CARBON - if ( !useDrawThemeText ) + if ( !useDrawThemeText ) #endif - yy += fi.ascent ; - ::MoveTo( xx , yy ); - if ( m_backgroundMode == wxTRANSPARENT ) - { - ::TextMode( srcOr) ; - } - else - { - ::TextMode( srcCopy ) ; - } - const char *text = NULL ; - int length = 0 ; - wxString macText ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - macText = wxMacMakeMacStringFromPC( strtext ) ; - text = macText ; - length = macText.Length() ; - } - else - { - text = strtext ; - length = strtext.Length() ; - } - int laststop = 0 ; - int i = 0 ; - int line = 0 ; - { - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { + yy += fi.ascent ; + ::MoveTo( xx , yy ); + if ( m_backgroundMode == wxTRANSPARENT ) + { + ::TextMode( srcOr) ; + } + else + { + ::TextMode( srcCopy ) ; + } + const char *text = NULL ; + int length = 0 ; + wxString macText ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + macText = wxMacMakeMacStringFromPC( strtext ) ; + text = macText ; + length = macText.Length() ; + } + else + { + text = strtext ; + length = strtext.Length() ; + } + int laststop = 0 ; + int i = 0 ; + int line = 0 ; + { + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { #if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; + if ( useDrawThemeText ) + { + Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - if ( m_backgroundMode != wxTRANSPARENT ) - { - Point bounds={0,0} ; - Rect background = frame ; - SInt16 baseline ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - background.right = background.left + bounds.h ; - background.bottom = background.top + bounds.v ; - ::EraseRect( &background ) ; - } - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - line++ ; + if ( m_backgroundMode != wxTRANSPARENT ) + { + Point bounds={0,0} ; + Rect background = frame ; + SInt16 baseline ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + background.right = background.left + bounds.h ; + background.bottom = background.top + bounds.v ; + ::EraseRect( &background ) ; + } + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + line++ ; } - else + else #endif - { - ::DrawText( text , laststop , i - laststop ) ; - line++ ; - ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); - } - laststop = i+1 ; - } - i++ ; - } + { + ::DrawText( text , laststop , i - laststop ) ; + line++ ; + ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); + } + laststop = i+1 ; + } + i++ ; + } #if TARGET_CARBON if ( useDrawThemeText ) - { - Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; + { + Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; if ( m_backgroundMode != wxTRANSPARENT ) { - Point bounds={0,0} ; - Rect background = frame ; - SInt16 baseline ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - background.right = background.left + bounds.h ; - background.bottom = background.top + bounds.v ; - ::EraseRect( &background ) ; + Point bounds={0,0} ; + Rect background = frame ; + SInt16 baseline ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + background.right = background.left + bounds.h ; + background.bottom = background.top + bounds.v ; + ::EraseRect( &background ) ; } - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &frame, - teJustLeft, - nil ); + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); CFRelease( mString ) ; } else #endif { - ::DrawText( text , laststop , i - laststop ) ; + ::DrawText( text , laststop , i - laststop ) ; } - } - ::TextMode( srcOr ) ; + } + ::TextMode( srcOr ) ; } + bool wxDC::CanGetTextExtent() const { - wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); - return true ; + wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); + return true ; } + void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, - wxCoord *descent, wxCoord *externalLeading , - wxFont *theFont ) const -{ - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - wxFont formerFont = m_font ; - if ( theFont ) - { - // work around the constness - *((wxFont*)(&m_font)) = *theFont ; - } - MacInstallFont() ; - FontInfo fi ; - ::GetFontInfo( &fi ) ; -#if TARGET_CARBON - bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) - useGetThemeText = false ; + wxCoord *descent, wxCoord *externalLeading , + wxFont *theFont ) const +{ + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + wxFont formerFont = m_font ; + if ( theFont ) + { + // work around the constness + *((wxFont*)(&m_font)) = *theFont ; + } + MacInstallFont() ; + FontInfo fi ; + ::GetFontInfo( &fi ) ; +#if TARGET_CARBON + bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; + if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) + useGetThemeText = false ; #endif - if ( height ) - *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; - if ( descent ) - *descent =YDEV2LOGREL( fi.descent ); - if ( externalLeading ) - *externalLeading = YDEV2LOGREL( fi.leading ) ; - const char *text = NULL ; - int length = 0 ; - wxString macText ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - macText = wxMacMakeMacStringFromPC( string ) ; - text = macText ; - length = macText.Length() ; - } - else - { - text = string ; - length = string.Length() ; - } - int laststop = 0 ; - int i = 0 ; - int curwidth = 0 ; - if ( width ) - { - *width = 0 ; - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { - if ( height ) - *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; + if ( height ) + *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; + if ( descent ) + *descent =YDEV2LOGREL( fi.descent ); + if ( externalLeading ) + *externalLeading = YDEV2LOGREL( fi.leading ) ; + const char *text = NULL ; + int length = 0 ; + wxString macText ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + macText = wxMacMakeMacStringFromPC( string ) ; + text = macText ; + length = macText.Length() ; + } + else + { + text = string ; + length = string.Length() ; + } + int laststop = 0 ; + int i = 0 ; + int curwidth = 0 ; + if ( width ) + { + *width = 0 ; + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { + if ( height ) + *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; #if TARGET_CARBON if ( useGetThemeText ) { Point bounds={0,0} ; SInt16 baseline ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - CFRelease( mString ) ; - curwidth = bounds.h ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + curwidth = bounds.h ; } else #endif { - curwidth = ::TextWidth( text , laststop , i - laststop ) ; - } - if ( curwidth > *width ) - *width = XDEV2LOGREL( curwidth ) ; - laststop = i+1 ; - } - i++ ; - } - + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + } + if ( curwidth > *width ) + *width = XDEV2LOGREL( curwidth ) ; + laststop = i+1 ; + } + i++ ; + } + #if TARGET_CARBON if ( useGetThemeText ) { Point bounds={0,0} ; SInt16 baseline ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - CFRelease( mString ) ; - curwidth = bounds.h ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + curwidth = bounds.h ; } else #endif { - curwidth = ::TextWidth( text , laststop , i - laststop ) ; - } - if ( curwidth > *width ) - *width = XDEV2LOGREL( curwidth ) ; - } - if ( theFont ) - { - // work around the constness - *((wxFont*)(&m_font)) = formerFont ; - m_macFontInstalled = false ; - } + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + } + if ( curwidth > *width ) + *width = XDEV2LOGREL( curwidth ) ; + } + if ( theFont ) + { + // work around the constness + *((wxFont*)(&m_font)) = formerFont ; + m_macFontInstalled = false ; + } } + wxCoord wxDC::GetCharWidth(void) const { wxCHECK_MSG(Ok(), 1, wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - MacInstallFont() ; + wxMacPortSetter helper(this) ; + MacInstallFont() ; int width = 0 ; #if TARGET_CARBON - bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) - useGetThemeText = false ; + bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; + if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) + useGetThemeText = false ; #endif - char text[] = "H" ; + char text[] = "H" ; #if TARGET_CARBON if ( useGetThemeText ) { Point bounds={0,0} ; SInt16 baseline ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - CFRelease( mString ) ; - width = bounds.h ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + width = bounds.h ; } else #endif { - width = ::TextWidth( text , 0 , 1 ) ; - } - return YDEV2LOGREL(width) ; + width = ::TextWidth( text , 0 , 1 ) ; + } + return YDEV2LOGREL(width) ; } + wxCoord wxDC::GetCharHeight(void) const { wxCHECK_MSG(Ok(), 1, wxT("Invalid DC")); wxMacPortSetter helper(this) ; - MacInstallFont() ; - FontInfo fi ; - ::GetFontInfo( &fi ) ; - return YDEV2LOGREL( fi.descent + fi.ascent ); + MacInstallFont() ; + FontInfo fi ; + ::GetFontInfo( &fi ) ; + return YDEV2LOGREL( fi.descent + fi.ascent ); } + void wxDC::Clear(void) { wxCHECK_RET(Ok(), wxT("Invalid DC")); wxMacPortSetter helper(this) ; - Rect rect = { -31000 , -31000 , 31000 , 31000 } ; - if (m_backgroundBrush.GetStyle() != wxTRANSPARENT) - { - ::PenNormal() ; - //MacInstallBrush() ; + Rect rect = { -31000 , -31000 , 31000 , 31000 } ; + if (m_backgroundBrush.GetStyle() != wxTRANSPARENT) + { + ::PenNormal() ; + //MacInstallBrush() ; MacSetupBackgroundForCurrentPort( m_backgroundBrush ) ; - ::EraseRect( &rect ) ; - } + ::EraseRect( &rect ) ; + } } + void wxDC::MacInstallFont() const { wxCHECK_RET(Ok(), wxT("Invalid DC")); -// if ( m_macFontInstalled ) -// return ; - Pattern blackColor ; - MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(m_scaleY * font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - m_macFontInstalled = true ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; - RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); - RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); - ::RGBForeColor( &forecolor ); - ::RGBBackColor( &backcolor ); - } - else - { + // if ( m_macFontInstalled ) + // return ; + Pattern blackColor ; + MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( short(m_scaleY * font->m_macFontSize) ) ; + ::TextFace( font->m_macFontStyle ) ; + m_macFontInstalled = true ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); + RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); + ::RGBForeColor( &forecolor ); + ::RGBBackColor( &backcolor ); + } + else + { FontFamilyID fontId ; - Str255 fontName ; - SInt16 fontSize ; - Style fontStyle ; - GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetFNum( fontName, &fontId ); - ::TextFont( fontId ) ; - ::TextSize( short(m_scaleY * fontSize) ) ; - ::TextFace( fontStyle ) ; - // todo reset after spacing changes - or store the current spacing somewhere - m_macFontInstalled = true ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; - RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); - RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); - ::RGBForeColor( &forecolor ); - ::RGBBackColor( &backcolor ); - } - short mode = patCopy ; - // todo : - switch( m_logicalFunction ) - { - case wxCOPY: // src - mode = patCopy ; - break ; - case wxINVERT: // NOT dst - ::PenPat(GetQDGlobalsBlack(&blackColor)); - mode = patXor ; - break ; - case wxXOR: // src XOR dst - mode = patXor ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - mode = notPatOr ; - break ; - case wxSRC_INVERT: // (NOT src) - mode = notPatCopy ; - break ; - // unsupported TODO - case wxCLEAR: // 0 - case wxAND_REVERSE:// src AND (NOT dst) - case wxAND: // src AND dst - case wxAND_INVERT: // (NOT src) AND dst - case wxNO_OP: // dst - case wxNOR: // (NOT src) AND (NOT dst) - case wxEQUIV: // (NOT src) XOR dst - case wxOR_INVERT: // (NOT src) OR dst - case wxNAND: // (NOT src) OR (NOT dst) - case wxOR: // src OR dst - case wxSET: // 1 -// case wxSRC_OR: // source _bitmap_ OR destination -// case wxSRC_AND: // source _bitmap_ AND destination - break ; - } - ::PenMode( mode ) ; + ::TextFont( fontId ) ; + ::TextSize( short(m_scaleY * fontSize) ) ; + ::TextFace( fontStyle ) ; + // todo reset after spacing changes - or store the current spacing somewhere + m_macFontInstalled = true ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); + RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); + ::RGBForeColor( &forecolor ); + ::RGBBackColor( &backcolor ); + } + short mode = patCopy ; + // todo : + switch( m_logicalFunction ) + { + case wxCOPY: // src + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + ::PenPat(GetQDGlobalsBlack(&blackColor)); + mode = patXor ; + break ; + case wxXOR: // src XOR dst + mode = patXor ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + mode = notPatOr ; + break ; + case wxSRC_INVERT: // (NOT src) + mode = notPatCopy ; + break ; + // unsupported TODO + case wxCLEAR: // 0 + case wxAND_REVERSE:// src AND (NOT dst) + case wxAND: // src AND dst + case wxAND_INVERT: // (NOT src) AND dst + case wxNO_OP: // dst + case wxNOR: // (NOT src) AND (NOT dst) + case wxEQUIV: // (NOT src) XOR dst + case wxOR_INVERT: // (NOT src) OR dst + case wxNAND: // (NOT src) OR (NOT dst) + case wxOR: // src OR dst + case wxSET: // 1 + // case wxSRC_OR: // source _bitmap_ OR destination + // case wxSRC_AND: // source _bitmap_ AND destination + break ; + } + ::PenMode( mode ) ; OSStatus status = noErr ; Fixed atsuSize = IntToFixed( int(m_scaleY * font->m_macFontSize) ) ; Style qdStyle = font->m_macFontStyle ; - ATSUFontID atsuFont = font->m_macATSUFontID ; + ATSUFontID atsuFont = font->m_macATSUFontID ; status = ::ATSUCreateStyle(&(ATSUStyle)m_macATSUIStyle) ; - wxASSERT_MSG( status == noErr , "couldn't create ATSU style" ) ; - ATSUAttributeTag atsuTags[] = - { - kATSUFontTag , - kATSUSizeTag , -// kATSUColorTag , -// kATSUBaselineClassTag , - kATSUVerticalCharacterTag, - kATSUQDBoldfaceTag , - kATSUQDItalicTag , - kATSUQDUnderlineTag , - kATSUQDCondensedTag , - kATSUQDExtendedTag , - } ; + wxASSERT_MSG( status == noErr , "couldn't create ATSU style" ) ; + ATSUAttributeTag atsuTags[] = + { + kATSUFontTag , + kATSUSizeTag , + // kATSUColorTag , + // kATSUBaselineClassTag , + kATSUVerticalCharacterTag, + kATSUQDBoldfaceTag , + kATSUQDItalicTag , + kATSUQDUnderlineTag , + kATSUQDCondensedTag , + kATSUQDExtendedTag , + } ; ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = { sizeof( ATSUFontID ) , - sizeof( Fixed ) , -// sizeof( RGBColor ) , -// sizeof( BslnBaselineClass ) , - sizeof( ATSUVerticalCharacterType), - sizeof( Boolean ) , - sizeof( Boolean ) , - sizeof( Boolean ) , - sizeof( Boolean ) , - sizeof( Boolean ) , + sizeof( Fixed ) , + // sizeof( RGBColor ) , + // sizeof( BslnBaselineClass ) , + sizeof( ATSUVerticalCharacterType), + sizeof( Boolean ) , + sizeof( Boolean ) , + sizeof( Boolean ) , + sizeof( Boolean ) , + sizeof( Boolean ) , } ; Boolean kTrue = true ; Boolean kFalse = false ; BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ; ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = - { - &atsuFont , - &atsuSize , -// &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) , -// &kBaselineDefault , - &kHorizontal, - (qdStyle & bold) ? &kTrue : &kFalse , - (qdStyle & italic) ? &kTrue : &kFalse , - (qdStyle & underline) ? &kTrue : &kFalse , - (qdStyle & condense) ? &kTrue : &kFalse , - (qdStyle & extend) ? &kTrue : &kFalse , - } ; - status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag), - atsuTags, atsuSizes, atsuValues); - wxASSERT_MSG( status == noErr , "couldn't set create ATSU style" ) ; + ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + &atsuFont , + &atsuSize , + // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) , + // &kBaselineDefault , + &kHorizontal, + (qdStyle & bold) ? &kTrue : &kFalse , + (qdStyle & italic) ? &kTrue : &kFalse , + (qdStyle & underline) ? &kTrue : &kFalse , + (qdStyle & condense) ? &kTrue : &kFalse , + (qdStyle & extend) ? &kTrue : &kFalse , + } ; + status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag), + atsuTags, atsuSizes, atsuValues); + wxASSERT_MSG( status == noErr , "couldn't set create ATSU style" ) ; } + Pattern gHatchPatterns[] = { - { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } }, - { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } }, - { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } }, - { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } }, - { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } }, - { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } }, - { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } + { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } }, + { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } }, + { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } }, + { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } }, + { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } }, + { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } }, + { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } } ; + static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern) { - int theIndex = 1 ; - switch(hatchStyle) - { - case wxBDIAGONAL_HATCH: - theIndex = 2; - break; - case wxFDIAGONAL_HATCH: - theIndex = 3; - break; - case wxCROSS_HATCH: - theIndex = 4; - break; - case wxHORIZONTAL_HATCH: - theIndex = 5; - break; - case wxVERTICAL_HATCH: - theIndex = 6; - break; - case wxCROSSDIAG_HATCH: - theIndex = 7; - break; - default: - theIndex = 1; // solid pattern - break; - } - *pattern = gHatchPatterns[theIndex-1] ; + int theIndex = 1 ; + switch(hatchStyle) + { + case wxBDIAGONAL_HATCH: + theIndex = 2; + break; + case wxFDIAGONAL_HATCH: + theIndex = 3; + break; + case wxCROSS_HATCH: + theIndex = 4; + break; + case wxHORIZONTAL_HATCH: + theIndex = 5; + break; + case wxVERTICAL_HATCH: + theIndex = 6; + break; + case wxCROSSDIAG_HATCH: + theIndex = 7; + break; + default: + theIndex = 1; // solid pattern + break; + } + *pattern = gHatchPatterns[theIndex-1] ; } + void wxDC::MacInstallPen() const { wxCHECK_RET(Ok(), wxT("Invalid DC")); - Pattern blackColor; -// if ( m_macPenInstalled ) -// return ; - RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); - RGBColor backcolor = MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()); - ::RGBForeColor( &forecolor ); - ::RGBBackColor( &backcolor ); - ::PenNormal() ; - int penWidth = m_pen.GetWidth() * (int) m_scaleX ; - // null means only one pixel, at whatever resolution - if ( penWidth == 0 ) - penWidth = 1 ; - ::PenSize(penWidth, penWidth); - int penStyle = m_pen.GetStyle(); - if (penStyle == wxSOLID) - { - ::PenPat(GetQDGlobalsBlack(&blackColor)); - } - else if (IS_HATCH(penStyle)) - { - Pattern pat ; - wxMacGetHatchPattern(penStyle, &pat); - ::PenPat(&pat); - } - else - { - Pattern pat = *GetQDGlobalsBlack(&blackColor) ; - switch( penStyle ) - { - case wxDOT : - for ( int i = 0 ; i < 8 ; ++i ) - { - pat.pat[i] = 0xCC ; - } - break ; - case wxLONG_DASH : - for ( int i = 0 ; i < 8 ; ++i ) - { - pat.pat[i] = 0xFE ; - } - break ; - case wxSHORT_DASH : - for ( int i = 0 ; i < 8 ; ++i ) - { - pat.pat[i] = 0xEE ; - } - break ; - case wxDOT_DASH : + Pattern blackColor; + // if ( m_macPenInstalled ) + // return ; + RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); + RGBColor backcolor = MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()); + ::RGBForeColor( &forecolor ); + ::RGBBackColor( &backcolor ); + ::PenNormal() ; + int penWidth = m_pen.GetWidth() * (int) m_scaleX ; + // null means only one pixel, at whatever resolution + if ( penWidth == 0 ) + penWidth = 1 ; + ::PenSize(penWidth, penWidth); + int penStyle = m_pen.GetStyle(); + if (penStyle == wxSOLID) + { + ::PenPat(GetQDGlobalsBlack(&blackColor)); + } + else if (IS_HATCH(penStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(penStyle, &pat); + ::PenPat(&pat); + } + else + { + Pattern pat = *GetQDGlobalsBlack(&blackColor) ; + switch( penStyle ) + { + case wxDOT : + for ( int i = 0 ; i < 8 ; ++i ) + { + pat.pat[i] = 0xCC ; + } + break ; + case wxLONG_DASH : + for ( int i = 0 ; i < 8 ; ++i ) + { + pat.pat[i] = 0xFE ; + } + break ; + case wxSHORT_DASH : + for ( int i = 0 ; i < 8 ; ++i ) + { + pat.pat[i] = 0xEE ; + } + break ; + case wxDOT_DASH : + for ( int i = 0 ; i < 8 ; ++i ) + { + pat.pat[i] = 0x6F ; + } + break ; + case wxUSER_DASH : + { + wxDash* dash ; + m_pen.GetDashes(&dash) ; + // right now we don't allocate larger pixmaps + // int number = + m_pen.GetDashes(&dash) ; for ( int i = 0 ; i < 8 ; ++i ) { - pat.pat[i] = 0x6F ; + pat.pat[i] = dash[0] ; } - break ; - case wxUSER_DASH : - { - wxDash* dash ; - m_pen.GetDashes(&dash) ; - // right now we don't allocate larger pixmaps - // int number = - m_pen.GetDashes(&dash) ; - for ( int i = 0 ; i < 8 ; ++i ) - { - pat.pat[i] = dash[0] ; - } - } - break ; - } - ::PenPat(&pat); - } - short mode = patCopy ; - // todo : - switch( m_logicalFunction ) - { - case wxCOPY: // only foreground color, leave background (thus not patCopy) - mode = patOr ; - break ; - case wxINVERT: // NOT dst -// ::PenPat(GetQDGlobalsBlack(&blackColor)); - mode = patXor ; - break ; - case wxXOR: // src XOR dst - mode = patXor ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - mode = notPatOr ; - break ; - case wxSRC_INVERT: // (NOT src) - mode = notPatCopy ; - break ; - // unsupported TODO - case wxCLEAR: // 0 - case wxAND_REVERSE:// src AND (NOT dst) - case wxAND: // src AND dst - case wxAND_INVERT: // (NOT src) AND dst - case wxNO_OP: // dst - case wxNOR: // (NOT src) AND (NOT dst) - case wxEQUIV: // (NOT src) XOR dst - case wxOR_INVERT: // (NOT src) OR dst - case wxNAND: // (NOT src) OR (NOT dst) - case wxOR: // src OR dst - case wxSET: // 1 -// case wxSRC_OR: // source _bitmap_ OR destination -// case wxSRC_AND: // source _bitmap_ AND destination - break ; - } - ::PenMode( mode ) ; - m_macPenInstalled = true ; - m_macBrushInstalled = false ; - m_macFontInstalled = false ; + } + break ; + } + ::PenPat(&pat); + } + short mode = patCopy ; + // todo : + switch( m_logicalFunction ) + { + case wxCOPY: // only foreground color, leave background (thus not patCopy) + mode = patOr ; + break ; + case wxINVERT: // NOT dst + // ::PenPat(GetQDGlobalsBlack(&blackColor)); + mode = patXor ; + break ; + case wxXOR: // src XOR dst + mode = patXor ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + mode = notPatOr ; + break ; + case wxSRC_INVERT: // (NOT src) + mode = notPatCopy ; + break ; + // unsupported TODO + case wxCLEAR: // 0 + case wxAND_REVERSE:// src AND (NOT dst) + case wxAND: // src AND dst + case wxAND_INVERT: // (NOT src) AND dst + case wxNO_OP: // dst + case wxNOR: // (NOT src) AND (NOT dst) + case wxEQUIV: // (NOT src) XOR dst + case wxOR_INVERT: // (NOT src) OR dst + case wxNAND: // (NOT src) OR (NOT dst) + case wxOR: // src OR dst + case wxSET: // 1 + // case wxSRC_OR: // source _bitmap_ OR destination + // case wxSRC_AND: // source _bitmap_ AND destination + break ; + } + ::PenMode( mode ) ; + m_macPenInstalled = true ; + m_macBrushInstalled = false ; + m_macFontInstalled = false ; } + void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background ) { Pattern whiteColor ; switch( background.MacGetBrushKind() ) { - case kwxMacBrushTheme : + case kwxMacBrushTheme : { - ::SetThemeBackground( background.GetMacTheme() , wxDisplayDepth() , true ) ; - break ; + ::SetThemeBackground( background.GetMacTheme() , wxDisplayDepth() , true ) ; + break ; } - case kwxMacBrushThemeBackground : + case kwxMacBrushThemeBackground : { - Rect extent ; - ThemeBackgroundKind bg = background.GetMacThemeBackground( &extent ) ; - ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ; - break ; + Rect extent ; + ThemeBackgroundKind bg = background.GetMacThemeBackground( &extent ) ; + ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ; + break ; } - case kwxMacBrushColour : + case kwxMacBrushColour : { - ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) ); - int brushStyle = background.GetStyle(); - if (brushStyle == wxSOLID) - ::BackPat(GetQDGlobalsWhite(&whiteColor)); - else if (IS_HATCH(brushStyle)) - { - Pattern pat ; - wxMacGetHatchPattern(brushStyle, &pat); - ::BackPat(&pat); - } - else - { - ::BackPat(GetQDGlobalsWhite(&whiteColor)); - } - break ; + ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) ); + int brushStyle = background.GetStyle(); + if (brushStyle == wxSOLID) + ::BackPat(GetQDGlobalsWhite(&whiteColor)); + else if (IS_HATCH(brushStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(brushStyle, &pat); + ::BackPat(&pat); + } + else + { + ::BackPat(GetQDGlobalsWhite(&whiteColor)); + } + break ; } } } + void wxDC::MacInstallBrush() const { wxCHECK_RET(Ok(), wxT("Invalid DC")); - Pattern blackColor ; -// if ( m_macBrushInstalled ) -// return ; - // foreground - bool backgroundTransparent = (GetBackgroundMode() == wxTRANSPARENT) ; - ::RGBForeColor( &MAC_WXCOLORREF( m_brush.GetColour().GetPixel()) ); - ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()) ); - int brushStyle = m_brush.GetStyle(); - if (brushStyle == wxSOLID) - { - ::PenPat(GetQDGlobalsBlack(&blackColor)); - } - else if (IS_HATCH(brushStyle)) - { - Pattern pat ; - wxMacGetHatchPattern(brushStyle, &pat); - ::PenPat(&pat); - } - else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) - { - // we force this in order to be compliant with wxMSW - backgroundTransparent = false ; - // for these the text fore (and back for MASK_OPAQUE) colors are used - wxBitmap* bitmap = m_brush.GetStipple() ; - int width = bitmap->GetWidth() ; - int height = bitmap->GetHeight() ; + Pattern blackColor ; + // if ( m_macBrushInstalled ) + // return ; + // foreground + bool backgroundTransparent = (GetBackgroundMode() == wxTRANSPARENT) ; + ::RGBForeColor( &MAC_WXCOLORREF( m_brush.GetColour().GetPixel()) ); + ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()) ); + int brushStyle = m_brush.GetStyle(); + if (brushStyle == wxSOLID) + { + ::PenPat(GetQDGlobalsBlack(&blackColor)); + } + else if (IS_HATCH(brushStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(brushStyle, &pat); + ::PenPat(&pat); + } + else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) + { + // we force this in order to be compliant with wxMSW + backgroundTransparent = false ; + // for these the text fore (and back for MASK_OPAQUE) colors are used + wxBitmap* bitmap = m_brush.GetStipple() ; + int width = bitmap->GetWidth() ; + int height = bitmap->GetHeight() ; GWorldPtr gw = NULL ; - if ( m_brush.GetStyle() == wxSTIPPLE ) - gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ; - else - gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ; + if ( m_brush.GetStyle() == wxSTIPPLE ) + gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ; + else + gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ; PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ; LockPixels( gwpixmaphandle ) ; - bool isMonochrome = !IsPortColor( gw ) ; + bool isMonochrome = !IsPortColor( gw ) ; if ( !isMonochrome ) { if ( (**gwpixmaphandle).pixelSize == 1 ) isMonochrome = true ; } if ( isMonochrome && width == 8 && height == 8 ) - { - ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ); - ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ); + { + ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ); + ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ); BitMap* gwbitmap = (BitMap*) *gwpixmaphandle ; // since the color depth is 1 it is a BitMap UInt8 *gwbits = (UInt8*) gwbitmap->baseAddr ; int alignment = gwbitmap->rowBytes & 0x7FFF ; @@ -1998,91 +2067,92 @@ void wxDC::MacInstallBrush() const } UnlockPixels( GetGWorldPixMap( gw ) ) ; ::PenPat( &pat ) ; - } - else - { - // this will be the code to handle power of 2 patterns, we will have to arrive at a nice - // caching scheme before putting this into production - Handle image; - long imageSize; - PixPatHandle pixpat = NewPixPat() ; - CopyPixMap(gwpixmaphandle, (**pixpat).patMap); + } + else + { + // this will be the code to handle power of 2 patterns, we will have to arrive at a nice + // caching scheme before putting this into production + Handle image; + long imageSize; + PixPatHandle pixpat = NewPixPat() ; + CopyPixMap(gwpixmaphandle, (**pixpat).patMap); imageSize = GetPixRowBytes((**pixpat).patMap) * - ((**(**pixpat).patMap).bounds.bottom - - (**(**pixpat).patMap).bounds.top); + ((**(**pixpat).patMap).bounds.bottom - + (**(**pixpat).patMap).bounds.top); PtrToHand( (**gwpixmaphandle).baseAddr, &image, imageSize ); (**pixpat).patData = image; if ( isMonochrome ) { - CTabHandle ctable = ((**((**pixpat).patMap)).pmTable) ; - ColorSpecPtr ctspec = (ColorSpecPtr) &(**ctable).ctTable ; - if ( ctspec[0].rgb.red == 0x0000 ) - { - ctspec[1].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; - ctspec[0].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; - } - else - { - ctspec[0].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; - ctspec[1].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; - } - ::CTabChanged( ctable ) ; + CTabHandle ctable = ((**((**pixpat).patMap)).pmTable) ; + ColorSpecPtr ctspec = (ColorSpecPtr) &(**ctable).ctTable ; + if ( ctspec[0].rgb.red == 0x0000 ) + { + ctspec[1].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; + ctspec[0].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; + } + else + { + ctspec[0].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; + ctspec[1].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; + } + ::CTabChanged( ctable ) ; } ::PenPixPat(pixpat); m_macForegroundPixMap = pixpat ; - } - UnlockPixels( gwpixmaphandle ) ; - } + } + UnlockPixels( gwpixmaphandle ) ; + } else { - ::PenPat(GetQDGlobalsBlack(&blackColor)); - } - short mode = patCopy ; - switch( m_logicalFunction ) - { - case wxCOPY: // src - if ( backgroundTransparent ) - mode = patOr ; - else - mode = patCopy ; - break ; - case wxINVERT: // NOT dst - if ( !backgroundTransparent ) - { - ::PenPat(GetQDGlobalsBlack(&blackColor)); - } - mode = patXor ; - break ; - case wxXOR: // src XOR dst - mode = patXor ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - mode = notPatOr ; - break ; - case wxSRC_INVERT: // (NOT src) - mode = notPatCopy ; - break ; - // unsupported TODO - case wxCLEAR: // 0 - case wxAND_REVERSE:// src AND (NOT dst) - case wxAND: // src AND dst - case wxAND_INVERT: // (NOT src) AND dst - case wxNO_OP: // dst - case wxNOR: // (NOT src) AND (NOT dst) - case wxEQUIV: // (NOT src) XOR dst - case wxOR_INVERT: // (NOT src) OR dst - case wxNAND: // (NOT src) OR (NOT dst) - case wxOR: // src OR dst - case wxSET: // 1 -// case wxSRC_OR: // source _bitmap_ OR destination -// case wxSRC_AND: // source _bitmap_ AND destination - break ; - } - ::PenMode( mode ) ; - m_macBrushInstalled = true ; - m_macPenInstalled = false ; - m_macFontInstalled = false ; + ::PenPat(GetQDGlobalsBlack(&blackColor)); + } + short mode = patCopy ; + switch( m_logicalFunction ) + { + case wxCOPY: // src + if ( backgroundTransparent ) + mode = patOr ; + else + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + if ( !backgroundTransparent ) + { + ::PenPat(GetQDGlobalsBlack(&blackColor)); + } + mode = patXor ; + break ; + case wxXOR: // src XOR dst + mode = patXor ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + mode = notPatOr ; + break ; + case wxSRC_INVERT: // (NOT src) + mode = notPatCopy ; + break ; + // unsupported TODO + case wxCLEAR: // 0 + case wxAND_REVERSE:// src AND (NOT dst) + case wxAND: // src AND dst + case wxAND_INVERT: // (NOT src) AND dst + case wxNO_OP: // dst + case wxNOR: // (NOT src) AND (NOT dst) + case wxEQUIV: // (NOT src) XOR dst + case wxOR_INVERT: // (NOT src) OR dst + case wxNAND: // (NOT src) OR (NOT dst) + case wxOR: // src OR dst + case wxSET: // 1 + // case wxSRC_OR: // source _bitmap_ OR destination + // case wxSRC_AND: // source _bitmap_ AND destination + break ; + } + ::PenMode( mode ) ; + m_macBrushInstalled = true ; + m_macPenInstalled = false ; + m_macFontInstalled = false ; } + // --------------------------------------------------------------------------- // coordinates transformations // --------------------------------------------------------------------------- @@ -2091,30 +2161,37 @@ wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const { return ((wxDC *)this)->XDEV2LOG(x); } + wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const { return ((wxDC *)this)->YDEV2LOG(y); } + wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const { return ((wxDC *)this)->XDEV2LOGREL(x); } + wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const { return ((wxDC *)this)->YDEV2LOGREL(y); } + wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const { return ((wxDC *)this)->XLOG2DEV(x); } + wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const { return ((wxDC *)this)->YLOG2DEV(y); } + wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const { return ((wxDC *)this)->XLOG2DEVREL(x); } + wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const { return ((wxDC *)this)->YLOG2DEVREL(y); diff --git a/src/mac/carbon/dcclient.cpp b/src/mac/carbon/dcclient.cpp index 1a878857f7..8e85da2cf5 100644 --- a/src/mac/carbon/dcclient.cpp +++ b/src/mac/carbon/dcclient.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -49,24 +49,24 @@ wxWindowDC::wxWindowDC() wxWindowDC::wxWindowDC(wxWindow *the_canvas) { - wxTopLevelWindowMac* rootwindow = the_canvas->MacGetTopLevelWindow() ; - WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; - - int x , y ; - x = y = 0 ; - the_canvas->MacWindowToRootWindow( &x , &y ) ; - m_macLocalOrigin.x = x ; - m_macLocalOrigin.y = y ; - CopyRgn( (RgnHandle) the_canvas->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; - m_macPort = UMAGetWindowPort( windowref ) ; - m_minY = m_minX = 0; - wxSize size = the_canvas->GetSize() ; - m_maxX = size.x ; - m_maxY = size.y ; - - m_ok = TRUE ; + wxTopLevelWindowMac* rootwindow = the_canvas->MacGetTopLevelWindow() ; + WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; + + int x , y ; + x = y = 0 ; + the_canvas->MacWindowToRootWindow( &x , &y ) ; + m_macLocalOrigin.x = x ; + m_macLocalOrigin.y = y ; + CopyRgn( (RgnHandle) the_canvas->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; + m_macPort = UMAGetWindowPort( windowref ) ; + m_minY = m_minX = 0; + wxSize size = the_canvas->GetSize() ; + m_maxX = size.x ; + m_maxY = size.y ; + + m_ok = TRUE ; SetBackground(the_canvas->MacGetBackgroundBrush()); } @@ -84,30 +84,30 @@ wxClientDC::wxClientDC() wxClientDC::wxClientDC(wxWindow *window) { - wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; - if (!rootwindow) - return; - WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; - wxPoint origin = window->GetClientAreaOrigin() ; - wxSize size = window->GetClientSize() ; - int x , y ; - x = origin.x ; - y = origin.y ; - window->MacWindowToRootWindow( &x , &y ) ; - m_macLocalOrigin.x = x ; - m_macLocalOrigin.y = y ; - SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; - SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; - m_macPort = UMAGetWindowPort( windowref ) ; - m_minY = m_minX = 0; - m_maxX = size.x ; - m_maxY = size.y ; - m_ok = TRUE ; - SetBackground(window->MacGetBackgroundBrush()); - SetFont( window->GetFont() ) ; + wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; + if (!rootwindow) + return; + WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; + wxPoint origin = window->GetClientAreaOrigin() ; + wxSize size = window->GetClientSize() ; + int x , y ; + x = origin.x ; + y = origin.y ; + window->MacWindowToRootWindow( &x , &y ) ; + m_macLocalOrigin.x = x ; + m_macLocalOrigin.y = y ; + SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; + SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; + m_macPort = UMAGetWindowPort( windowref ) ; + m_minY = m_minX = 0; + m_maxX = size.x ; + m_maxY = size.y ; + m_ok = TRUE ; + SetBackground(window->MacGetBackgroundBrush()); + SetFont( window->GetFont() ) ; } wxClientDC::~wxClientDC() @@ -124,29 +124,29 @@ wxPaintDC::wxPaintDC() wxPaintDC::wxPaintDC(wxWindow *window) { - wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; - WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; - wxPoint origin = window->GetClientAreaOrigin() ; - wxSize size = window->GetClientSize() ; - int x , y ; - x = origin.x ; - y = origin.y ; - window->MacWindowToRootWindow( &x , &y ) ; - m_macLocalOrigin.x = x ; - m_macLocalOrigin.y = y ; - SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; - SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; - SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; - m_macPort = UMAGetWindowPort( windowref ) ; - m_minY = m_minX = 0; - m_maxX = size.x ; - m_maxY = size.y ; - m_ok = TRUE ; - SetBackground(window->MacGetBackgroundBrush()); - SetFont( window->GetFont() ) ; + wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; + WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; + wxPoint origin = window->GetClientAreaOrigin() ; + wxSize size = window->GetClientSize() ; + int x , y ; + x = origin.x ; + y = origin.y ; + window->MacWindowToRootWindow( &x , &y ) ; + m_macLocalOrigin.x = x ; + m_macLocalOrigin.y = y ; + SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; + SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; + SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; + m_macPort = UMAGetWindowPort( windowref ) ; + m_minY = m_minX = 0; + m_maxX = size.x ; + m_maxY = size.y ; + m_ok = TRUE ; + SetBackground(window->MacGetBackgroundBrush()); + SetFont( window->GetFont() ) ; } wxPaintDC::~wxPaintDC() diff --git a/src/mac/carbon/dcmemory.cpp b/src/mac/carbon/dcmemory.cpp index d4db46174e..e850a59e4d 100644 --- a/src/mac/carbon/dcmemory.cpp +++ b/src/mac/carbon/dcmemory.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -23,78 +23,78 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) wxMemoryDC::wxMemoryDC(void) - : m_selected() +: m_selected() { - m_ok = TRUE; + m_ok = TRUE; SetBackground(*wxWHITE_BRUSH); SetBrush(*wxWHITE_BRUSH); SetPen(*wxBLACK_PEN); - m_ok = FALSE; + m_ok = FALSE; }; wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) - : m_selected() +: m_selected() { - m_ok = TRUE; + m_ok = TRUE; SetBackground(*wxWHITE_BRUSH); SetBrush(*wxWHITE_BRUSH); SetPen(*wxBLACK_PEN); - m_ok = FALSE; + m_ok = FALSE; }; wxMemoryDC::~wxMemoryDC() { - if ( m_selected.Ok() ) - { - UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); - } + if ( m_selected.Ok() ) + { + UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); + } }; void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) { - if ( m_selected.Ok() ) - { - UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); - } + if ( m_selected.Ok() ) + { + UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); + } m_selected = bitmap; if (m_selected.Ok()) { - if ( m_selected.GetHBITMAP() ) - { - m_macPort = (GrafPtr) m_selected.GetHBITMAP() ; - LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ; - wxMask * mask = bitmap.GetMask() ; - if ( mask ) - { - m_macMask = mask->GetMaskBitmap() ; - } - SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; - m_ok = TRUE ; - } - else - { - m_ok = FALSE; - } - } - else - { - m_ok = FALSE; - } + if ( m_selected.GetHBITMAP() ) + { + m_macPort = (GrafPtr) m_selected.GetHBITMAP() ; + LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ; + wxMask * mask = bitmap.GetMask() ; + if ( mask ) + { + m_macMask = mask->GetMaskBitmap() ; + } + SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; + m_ok = TRUE ; + } + else + { + m_ok = FALSE; + } + } + else + { + m_ok = FALSE; + } } void wxMemoryDC::DoGetSize( int *width, int *height ) const { - if (m_selected.Ok()) - { - if (width) (*width) = m_selected.GetWidth(); - if (height) (*height) = m_selected.GetHeight(); - } - else - { - if (width) (*width) = 0; - if (height) (*height) = 0; - } + if (m_selected.Ok()) + { + if (width) (*width) = m_selected.GetWidth(); + if (height) (*height) = m_selected.GetHeight(); + } + else + { + if (width) (*width) = 0; + if (height) (*height) = 0; + } } diff --git a/src/mac/carbon/dcprint.cpp b/src/mac/carbon/dcprint.cpp index 6c32de8ad0..2e82243834 100644 --- a/src/mac/carbon/dcprint.cpp +++ b/src/mac/carbon/dcprint.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -46,172 +46,172 @@ GrafPtr macPrintFormerPort = NULL ; wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) { - OSStatus err ; - wxString message ; - - m_printData = printdata ; - m_printData.ConvertToNative() ; + OSStatus err ; + wxString message ; + + m_printData = printdata ; + m_printData.ConvertToNative() ; #if TARGET_CARBON && PM_USE_SESSION_APIS - err = UMAPrOpen(&m_macPrintSessionPort) ; - if ( err != noErr || m_macPrintSessionPort == kPMNoData ) + err = UMAPrOpen(&m_macPrintSessionPort) ; + if ( err != noErr || m_macPrintSessionPort == kPMNoData ) #else - err = UMAPrOpen(NULL) ; - if ( err != noErr ) + err = UMAPrOpen(NULL) ; + if ( err != noErr ) #endif - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose(&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose(NULL) ; + UMAPrClose(NULL) ; #endif - m_ok = FALSE; - return; - } - + m_ok = FALSE; + return; + } + #if !TARGET_CARBON - if ( ::PrValidate( (THPrint) m_printData.m_macPrintSettings ) ) - { - ::PrStlDialog( (THPrint) m_printData.m_macPrintSettings ) ; - // the driver has changed in the mean time, should we pop up a page setup dialog ? - } - err = PrError() ; - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - UMAPrClose(NULL) ; - m_ok = FALSE; - return; - } - ::GetPort( &macPrintFormerPort ) ; - m_macPrintSessionPort = ::PrOpenDoc( (THPrint) m_printData.m_macPrintSettings , NULL , NULL ) ; - err = PrError() ; - if ( err ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - UMAPrClose(NULL) ; - m_ok = FALSE; - return; - } - // sets current port - m_macPort = (GrafPtr ) m_macPrintSessionPort ; + if ( ::PrValidate( (THPrint) m_printData.m_macPrintSettings ) ) + { + ::PrStlDialog( (THPrint) m_printData.m_macPrintSettings ) ; + // the driver has changed in the mean time, should we pop up a page setup dialog ? + } + err = PrError() ; + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + UMAPrClose(NULL) ; + m_ok = FALSE; + return; + } + ::GetPort( &macPrintFormerPort ) ; + m_macPrintSessionPort = ::PrOpenDoc( (THPrint) m_printData.m_macPrintSettings , NULL , NULL ) ; + err = PrError() ; + if ( err ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + UMAPrClose(NULL) ; + m_ok = FALSE; + return; + } + // sets current port + m_macPort = (GrafPtr ) m_macPrintSessionPort ; #else #if PM_USE_SESSION_APIS err = PMSessionBeginDocument((PMPrintSession)m_macPrintSessionPort, (PMPrintSettings)m_printData.m_macPrintSettings, - (PMPageFormat)m_printData.m_macPageFormat); + (PMPageFormat)m_printData.m_macPageFormat); if ( err != noErr ) #else - m_macPrintSessionPort = kPMNoReference ; + m_macPrintSessionPort = kPMNoReference ; err = PMBeginDocument( - m_printData.m_macPrintSettings, - m_printData.m_macPageFormat, - &m_macPrintSessionPort); + m_printData.m_macPrintSettings, + m_printData.m_macPageFormat, + &m_macPrintSessionPort); if ( err != noErr || m_macPrintSessionPort == kPMNoReference ) #endif { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose(&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose(NULL) ; + UMAPrClose(NULL) ; #endif - m_ok = FALSE; - return; + m_ok = FALSE; + return; } - // sets current port - ::GetPort( (GrafPtr *)&m_macPort ) ; + // sets current port + ::GetPort( (GrafPtr *)&m_macPort ) ; #endif - m_ok = TRUE ; - m_minY = m_minX = 0 ; + m_ok = TRUE ; + m_minY = m_minX = 0 ; #if TARGET_CARBON - PMRect rPaper; - - err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper); + PMRect rPaper; + + err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper); if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose(&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose(NULL) ; + UMAPrClose(NULL) ; #endif - m_ok = FALSE; - return; + m_ok = FALSE; + return; } - m_maxX = wxCoord(rPaper.right - rPaper.left) ; - m_maxY = wxCoord(rPaper.bottom - rPaper.top); + m_maxX = wxCoord(rPaper.right - rPaper.left) ; + m_maxY = wxCoord(rPaper.bottom - rPaper.top); #else - m_maxX = (**(THPrint)m_printData.m_macPrintSettings).rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ; - m_maxY = (**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ; + m_maxX = (**(THPrint)m_printData.m_macPrintSettings).rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ; + m_maxY = (**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ; #endif } wxPrinterDC::~wxPrinterDC(void) { - OSStatus err ; - wxString message ; + OSStatus err ; + wxString message ; #if !TARGET_CARBON - if ( m_ok ) - { - ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - err = PrError() ; - - if ( err == noErr ) - { - if ( (**(THPrint)m_printData.m_macPrintSettings).prJob.bJDocLoop == bSpoolLoop ) - { - TPrStatus status ; - ::PrPicFile( (THPrint) m_printData.m_macPrintSettings , NULL , NULL , NULL , &status ) ; - } - } - else - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - } - ::UMAPrClose(NULL) ; -// ::SetPort( macPrintFormerPort ) ; - ::SetPort( LMGetWMgrPort() ) ; - } + if ( m_ok ) + { + ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; + err = PrError() ; + + if ( err == noErr ) + { + if ( (**(THPrint)m_printData.m_macPrintSettings).prJob.bJDocLoop == bSpoolLoop ) + { + TPrStatus status ; + ::PrPicFile( (THPrint) m_printData.m_macPrintSettings , NULL , NULL , NULL , &status ) ; + } + } + else + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + } + ::UMAPrClose(NULL) ; +// ::SetPort( macPrintFormerPort ) ; + ::SetPort( LMGetWMgrPort() ) ; + } #else - if ( m_ok ) - { + if ( m_ok ) + { #if PM_USE_SESSION_APIS - err = PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); + err = PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); #else - err = PMEndDocument(m_macPrintSessionPort); + err = PMEndDocument(m_macPrintSessionPort); #endif - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - } + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + } #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose(&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose(NULL) ; + UMAPrClose(NULL) ; #endif - } + } #endif } bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) { - return m_ok ; + return m_ok ; } void wxPrinterDC::EndDoc(void) @@ -220,117 +220,117 @@ void wxPrinterDC::EndDoc(void) void wxPrinterDC::StartPage(void) { - if ( !m_ok ) - return ; + if ( !m_ok ) + return ; - m_logicalFunction = wxCOPY; + m_logicalFunction = wxCOPY; // m_textAlignment = wxALIGN_TOP_LEFT; - m_backgroundMode = wxTRANSPARENT; + m_backgroundMode = wxTRANSPARENT; - m_textForegroundColour = *wxBLACK; - m_textBackgroundColour = *wxWHITE; - m_pen = *wxBLACK_PEN; - m_font = *wxNORMAL_FONT; - m_brush = *wxTRANSPARENT_BRUSH; - m_backgroundBrush = *wxWHITE_BRUSH; + m_textForegroundColour = *wxBLACK; + m_textBackgroundColour = *wxWHITE; + m_pen = *wxBLACK_PEN; + m_font = *wxNORMAL_FONT; + m_brush = *wxTRANSPARENT_BRUSH; + m_backgroundBrush = *wxWHITE_BRUSH; - m_macFontInstalled = false ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; - - OSStatus err ; - wxString message ; + + OSStatus err ; + wxString message ; #if !TARGET_CARBON - PrOpenPage( (TPPrPort) m_macPrintSessionPort , NULL ) ; - m_macLocalOrigin.x = (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ; - m_macLocalOrigin.y = (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ; - - Rect clip = { -32000 , -32000 , 32000 , 32000 } ; - ::ClipRect( &clip ) ; - err = PrError() ; - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - ::PrClosePage( (TPPrPort) m_macPrintSessionPort ) ; - ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - ::UMAPrClose(NULL) ; - ::SetPort( macPrintFormerPort ) ; - m_ok = FALSE ; - } + PrOpenPage( (TPPrPort) m_macPrintSessionPort , NULL ) ; + m_macLocalOrigin.x = (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ; + m_macLocalOrigin.y = (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ; + + Rect clip = { -32000 , -32000 , 32000 , 32000 } ; + ::ClipRect( &clip ) ; + err = PrError() ; + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + ::PrClosePage( (TPPrPort) m_macPrintSessionPort ) ; + ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; + ::UMAPrClose(NULL) ; + ::SetPort( macPrintFormerPort ) ; + m_ok = FALSE ; + } #else #if PM_USE_SESSION_APIS - err = PMSessionBeginPage((PMPrintSession)m_macPrintSessionPort, - (PMPageFormat)m_printData.m_macPageFormat, - nil); + err = PMSessionBeginPage((PMPrintSession)m_macPrintSessionPort, + (PMPageFormat)m_printData.m_macPageFormat, + nil); #else - err = PMBeginPage(m_macPrintSessionPort, nil); + err = PMBeginPage(m_macPrintSessionPort, nil); #endif - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if PM_USE_SESSION_APIS - PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); - PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); - UMAPrClose(&m_macPrintSessionPort) ; + PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); + PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); + UMAPrClose(&m_macPrintSessionPort) ; #else - PMEndPage(m_macPrintSessionPort); - PMEndDocument(m_macPrintSessionPort); - UMAPrClose(NULL) ; + PMEndPage(m_macPrintSessionPort); + PMEndDocument(m_macPrintSessionPort); + UMAPrClose(NULL) ; #endif - ::SetPort( macPrintFormerPort ) ; - m_ok = FALSE ; - } + ::SetPort( macPrintFormerPort ) ; + m_ok = FALSE ; + } #endif } void wxPrinterDC::EndPage(void) { - if ( !m_ok ) - return ; + if ( !m_ok ) + return ; - OSStatus err ; - wxString message ; + OSStatus err ; + wxString message ; #if !TARGET_CARBON - PrClosePage( (TPPrPort) m_macPort ) ; - err = PrError() ; - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - ::UMAPrClose(NULL) ; - ::SetPort( macPrintFormerPort ) ; - m_ok = FALSE ; - } + PrClosePage( (TPPrPort) m_macPort ) ; + err = PrError() ; + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; + ::UMAPrClose(NULL) ; + ::SetPort( macPrintFormerPort ) ; + m_ok = FALSE ; + } #else #if PM_USE_SESSION_APIS - err = PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); + err = PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); #else - err = PMEndPage(m_macPrintSessionPort); + err = PMEndPage(m_macPrintSessionPort); #endif - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if PM_USE_SESSION_APIS - PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); - UMAPrClose(&m_macPrintSessionPort) ; + PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); + UMAPrClose(&m_macPrintSessionPort) ; #else - PMEndDocument(m_macPrintSessionPort); - UMAPrClose(NULL) ; + PMEndDocument(m_macPrintSessionPort); + UMAPrClose(NULL) ; #endif - ::SetPort( macPrintFormerPort ) ; - m_ok = FALSE ; - } + ::SetPort( macPrintFormerPort ) ; + m_ok = FALSE ; + } #endif } diff --git a/src/mac/carbon/dcscreen.cpp b/src/mac/carbon/dcscreen.cpp index 0e12102f6f..03d769a05b 100644 --- a/src/mac/carbon/dcscreen.cpp +++ b/src/mac/carbon/dcscreen.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,36 +24,36 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) wxScreenDC::wxScreenDC() { #if TARGET_CARBON - m_macPort = GetQDGlobalsThePort() ; - GrafPtr port ; - GetPort( &port ) ; - SetPort( (GrafPtr) m_macPort ) ; - Point pt = { 0,0 } ; - LocalToGlobal( &pt ) ; - SetPort( port ) ; - m_macLocalOrigin.x = -pt.h ; - m_macLocalOrigin.y = -pt.v ; + m_macPort = GetQDGlobalsThePort() ; + GrafPtr port ; + GetPort( &port ) ; + SetPort( (GrafPtr) m_macPort ) ; + Point pt = { 0,0 } ; + LocalToGlobal( &pt ) ; + SetPort( port ) ; + m_macLocalOrigin.x = -pt.h ; + m_macLocalOrigin.y = -pt.v ; #else - m_macPort = LMGetWMgrPort() ; - m_macLocalOrigin.x = 0 ; - m_macLocalOrigin.y = 0 ; + m_macPort = LMGetWMgrPort() ; + m_macLocalOrigin.x = 0 ; + m_macLocalOrigin.y = 0 ; #endif - m_ok = TRUE ; - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); - m_minX = screenBits.bounds.left ; + m_ok = TRUE ; + BitMap screenBits; + GetQDGlobalsScreenBits( &screenBits ); + m_minX = screenBits.bounds.left ; #if TARGET_CARBON - SInt16 height ; - GetThemeMenuBarHeight( &height ) ; - m_minY = screenBits.bounds.top + height ; + SInt16 height ; + GetThemeMenuBarHeight( &height ) ; + m_minY = screenBits.bounds.top + height ; #else - m_minY = screenBits.bounds.top + LMGetMBarHeight() ; + m_minY = screenBits.bounds.top + LMGetMBarHeight() ; #endif - m_maxX = screenBits.bounds.right ; - m_maxY = screenBits.bounds.bottom ; - MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; + m_maxX = screenBits.bounds.right ; + m_maxY = screenBits.bounds.bottom ; + MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; } wxScreenDC::~wxScreenDC() diff --git a/src/mac/carbon/dialog.cpp b/src/mac/carbon/dialog.cpp index 506e3399ad..7b7bfc024b 100644 --- a/src/mac/carbon/dialog.cpp +++ b/src/mac/carbon/dialog.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -46,7 +46,7 @@ END_EVENT_TABLE() wxDialog::wxDialog() { - m_isShown = FALSE; + m_isShown = FALSE; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); } @@ -57,60 +57,59 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); - - - if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); + + + if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) return FALSE; + + MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) , name ) ; + + m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; + SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; - MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) , name ) ; - - m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; - SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; - return TRUE; + return TRUE; } void wxDialog::SetModal(bool flag) { - if ( flag ) + if ( flag ) { m_windowStyle |= wxDIALOG_MODAL; - + wxModelessWindows.DeleteObject(this); } else { m_windowStyle &= ~wxDIALOG_MODAL; - + wxModelessWindows.Append(this); } } wxDialog::~wxDialog() { - m_isBeingDeleted = TRUE ; - Show(FALSE); + m_isBeingDeleted = TRUE ; + Show(FALSE); } // By default, pressing escape cancels the dialog , on mac command-stop does the same thing void wxDialog::OnCharHook(wxKeyEvent& event) { - if ( - ( event.m_keyCode == WXK_ESCAPE || - ( event.m_keyCode == '.' && event.MetaDown() ) ) - && FindWindow(wxID_CANCEL) ) - { - // Behaviour changed in 2.0: we'll send a Cancel message - // to the dialog instead of Close. - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); - - return; - } - // We didn't process this event. - event.Skip(); + if (( event.m_keyCode == WXK_ESCAPE || + ( event.m_keyCode == '.' && event.MetaDown() ) ) + && FindWindow(wxID_CANCEL) ) + { + // Behaviour changed in 2.0: we'll send a Cancel message + // to the dialog instead of Close. + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); + + return; + } + // We didn't process this event. + event.Skip(); } bool wxDialog::IsModal() const @@ -165,7 +164,7 @@ void wxDialog::DoShowModal() wxModalDialogs.Append(this); - wxWindow *parent = GetParent(); + wxWindow *parent = GetParent(); // remember where the focus was wxWindow *winFocus = FindFocus(); @@ -178,23 +177,23 @@ void wxDialog::DoShowModal() winFocus = wxTheApp->GetTopWindow(); } #if TARGET_CARBON - BeginAppModalStateForWindow( (WindowRef) MacGetWindowRef()) ; + BeginAppModalStateForWindow( (WindowRef) MacGetWindowRef()) ; #else - // TODO : test whether parent gets disabled - bool formerModal = s_macIsInModalLoop ; - s_macIsInModalLoop = true ; + // TODO : test whether parent gets disabled + bool formerModal = s_macIsInModalLoop ; + s_macIsInModalLoop = true ; #endif - while ( IsModalShowing() ) - { - wxTheApp->MacDoOneEvent() ; - // calls process idle itself - } - + while ( IsModalShowing() ) + { + wxTheApp->MacDoOneEvent() ; + // calls process idle itself + } + #if TARGET_CARBON - EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ; + EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ; #else // TODO probably reenable the parent window if any - s_macIsInModalLoop = formerModal ; + s_macIsInModalLoop = formerModal ; #endif @@ -209,13 +208,13 @@ void wxDialog::DoShowModal() // Replacement for Show(TRUE) for modal dialogs - returns return code int wxDialog::ShowModal() { - if ( !IsModal() ) - { - SetModal(TRUE); - } + if ( !IsModal() ) + { + SetModal(TRUE); + } - Show(TRUE); - return GetReturnCode(); + Show(TRUE); + return GetReturnCode(); } // NB: this function (surprizingly) may be called for both modal and modeless diff --git a/src/mac/carbon/dirdlg.cpp b/src/mac/carbon/dirdlg.cpp index 9c6c131e68..6864054234 100644 --- a/src/mac/carbon/dirdlg.cpp +++ b/src/mac/carbon/dirdlg.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -40,107 +40,107 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxSize& WXUNUSED(size), const wxString& WXUNUSED(name)) { - wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; + wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; m_message = message; m_dialogStyle = style; m_parent = parent; - m_path = defaultPath; + m_path = defaultPath; } int wxDirDialog::ShowModal() { - NavDialogOptions mNavOptions; - NavObjectFilterUPP mNavFilterUPP = NULL; - NavPreviewUPP mNavPreviewUPP = NULL ; - NavReplyRecord mNavReply; - AEDesc* mDefaultLocation = NULL ; - bool mSelectDefault = false ; - - ::NavGetDefaultDialogOptions(&mNavOptions); + NavDialogOptions mNavOptions; + NavObjectFilterUPP mNavFilterUPP = NULL; + NavPreviewUPP mNavPreviewUPP = NULL ; + NavReplyRecord mNavReply; + AEDesc* mDefaultLocation = NULL ; + bool mSelectDefault = false ; + + ::NavGetDefaultDialogOptions(&mNavOptions); - mNavFilterUPP = nil; - mNavPreviewUPP = nil; - mSelectDefault = false; - mNavReply.validRecord = false; - mNavReply.replacing = false; - mNavReply.isStationery = false; - mNavReply.translationNeeded = false; - mNavReply.selection.descriptorType = typeNull; - mNavReply.selection.dataHandle = nil; - mNavReply.keyScript = smSystemScript; - mNavReply.fileTranslation = nil; - - // Set default location, the location - // that's displayed when the dialog - // first appears - - if ( mDefaultLocation ) { - - if (mSelectDefault) { - mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation; - } else { - mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; - } - } - - OSErr err = ::NavChooseFolder( - mDefaultLocation, - &mNavReply, - &mNavOptions, - NULL, - mNavFilterUPP, - 0L); // User Data - - if ( (err != noErr) && (err != userCanceledErr) ) { - m_path = "" ; - return wxID_CANCEL ; - } + mNavFilterUPP = nil; + mNavPreviewUPP = nil; + mSelectDefault = false; + mNavReply.validRecord = false; + mNavReply.replacing = false; + mNavReply.isStationery = false; + mNavReply.translationNeeded = false; + mNavReply.selection.descriptorType = typeNull; + mNavReply.selection.dataHandle = nil; + mNavReply.keyScript = smSystemScript; + mNavReply.fileTranslation = nil; + + // Set default location, the location + // that's displayed when the dialog + // first appears + + if ( mDefaultLocation ) { + + if (mSelectDefault) { + mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation; + } else { + mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; + } + } + + OSErr err = ::NavChooseFolder( + mDefaultLocation, + &mNavReply, + &mNavOptions, + NULL, + mNavFilterUPP, + 0L); // User Data + + if ( (err != noErr) && (err != userCanceledErr) ) { + m_path = "" ; + return wxID_CANCEL ; + } - if (mNavReply.validRecord) { // User chose a folder - - FSSpec folderInfo; - FSSpec outFileSpec ; - AEDesc specDesc ; - - OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc); - if ( err != noErr ) { - m_path = "" ; - return wxID_CANCEL ; - } - folderInfo = **(FSSpec**) specDesc.dataHandle; - if (specDesc.dataHandle != nil) { - ::AEDisposeDesc(&specDesc); - } + if (mNavReply.validRecord) { // User chose a folder + + FSSpec folderInfo; + FSSpec outFileSpec ; + AEDesc specDesc ; + + OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc); + if ( err != noErr ) { + m_path = "" ; + return wxID_CANCEL ; + } + folderInfo = **(FSSpec**) specDesc.dataHandle; + if (specDesc.dataHandle != nil) { + ::AEDisposeDesc(&specDesc); + } -// mNavReply.GetFileSpec(folderInfo); - - // The FSSpec from NavChooseFolder is NOT the file spec - // for the folder. The parID field is actually the DirID - // of the folder itself, not the folder's parent, and - // the name field is empty. We must call PBGetCatInfo - // to get the parent DirID and folder name - - Str255 name; - CInfoPBRec thePB; // Directory Info Parameter Block - thePB.dirInfo.ioCompletion = nil; - thePB.dirInfo.ioVRefNum = folderInfo.vRefNum; // Volume is right - thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID - thePB.dirInfo.ioNamePtr = name; - thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID - - err = ::PBGetCatInfoSync(&thePB); - if ( err != noErr ) { - m_path = "" ; - return wxID_CANCEL ; - } - // Create cannonical FSSpec - ::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID, - name, &outFileSpec); - - // outFolderDirID = thePB.dirInfo.ioDrDirID; - m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ; - return wxID_OK ; - } - return wxID_CANCEL; +// mNavReply.GetFileSpec(folderInfo); + + // The FSSpec from NavChooseFolder is NOT the file spec + // for the folder. The parID field is actually the DirID + // of the folder itself, not the folder's parent, and + // the name field is empty. We must call PBGetCatInfo + // to get the parent DirID and folder name + + Str255 name; + CInfoPBRec thePB; // Directory Info Parameter Block + thePB.dirInfo.ioCompletion = nil; + thePB.dirInfo.ioVRefNum = folderInfo.vRefNum; // Volume is right + thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID + thePB.dirInfo.ioNamePtr = name; + thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID + + err = ::PBGetCatInfoSync(&thePB); + if ( err != noErr ) { + m_path = "" ; + return wxID_CANCEL ; + } + // Create cannonical FSSpec + ::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID, + name, &outFileSpec); + + // outFolderDirID = thePB.dirInfo.ioDrDirID; + m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ; + return wxID_OK ; + } + return wxID_CANCEL; } diff --git a/src/mac/carbon/dirmac.cpp b/src/mac/carbon/dirmac.cpp index 0f250ccd5e..53e9dcbd68 100644 --- a/src/mac/carbon/dirmac.cpp +++ b/src/mac/carbon/dirmac.cpp @@ -83,11 +83,11 @@ public: const wxString& GetName() const { return m_dirname; } private: - CInfoPBRec m_CPB ; - wxInt16 m_index ; - long m_dirId ; - Str255 m_name ; - Boolean m_isDir ; + CInfoPBRec m_CPB ; + wxInt16 m_index ; + long m_dirId ; + Str255 m_name ; + Boolean m_isDir ; wxString m_dirname; wxString m_filespec; @@ -145,26 +145,26 @@ wxDirData::~wxDirData() void wxDirData::Rewind() { - m_index = 0 ; + m_index = 0 ; } bool wxDirData::Read(wxString *filename) { if ( !m_isDir ) return FALSE ; - + #if TARGET_CARBON - char c_name[256] ; + char c_name[256] ; #endif wxString result; short err = noErr ; - + while ( err == noErr ) { m_index++ ; m_CPB.dirInfo.ioFDirIndex = m_index; - m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */ + m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */ err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB); if ( err != noErr ) break ; @@ -270,12 +270,12 @@ wxString wxDir::GetName() const wxString name; if ( m_data ) { - name = M_DIR->GetName(); - if ( !name.empty() && (name.Last() == _T('/')) ) - { - // chop off the last (back)slash - name.Truncate(name.length() - 1); - } + name = M_DIR->GetName(); + if ( !name.empty() && (name.Last() == _T('/')) ) + { + // chop off the last (back)slash + name.Truncate(name.length() - 1); + } } return name; diff --git a/src/mac/carbon/display.cpp b/src/mac/carbon/display.cpp index e25b2486e3..3502ac55f5 100644 --- a/src/mac/carbon/display.cpp +++ b/src/mac/carbon/display.cpp @@ -44,7 +44,7 @@ class wxDisplayMacPriv { public: - GDHandle m_hndl; + GDHandle m_hndl; }; size_t wxDisplayBase::GetCount() diff --git a/src/mac/carbon/dnd.cpp b/src/mac/carbon/dnd.cpp index 68b372cb85..b9df2ac004 100644 --- a/src/mac/carbon/dnd.cpp +++ b/src/mac/carbon/dnd.cpp @@ -82,47 +82,47 @@ bool wxDropTarget::CurrentDragHasSupportedFormat() bool supported = false ; if ( gTrackingGlobals.m_currentSource != NULL ) { - wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; - - if ( data ) - { - size_t formatcount = data->GetFormatCount() ; - wxDataFormat *array = new wxDataFormat[ formatcount ]; - data->GetAllFormats( array ); - for (size_t i = 0; !supported && i < formatcount ; i++) + wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; + + if ( data ) { - wxDataFormat format = array[i] ; - if ( m_dataObject->IsSupported( format ) ) + size_t formatcount = data->GetFormatCount() ; + wxDataFormat *array = new wxDataFormat[ formatcount ]; + data->GetAllFormats( array ); + for (size_t i = 0; !supported && i < formatcount ; i++) { - supported = true ; - break ; + wxDataFormat format = array[i] ; + if ( m_dataObject->IsSupported( format ) ) + { + supported = true ; + break ; + } } + delete[] array ; } - delete[] array ; - } } if ( !supported ) { - UInt16 items ; - OSErr result; - CountDragItems((DragReference)m_currentDrag, &items); - for (UInt16 index = 1; index <= items && supported == false ; ++index) - { - ItemReference theItem; - FlavorType theType ; - UInt16 flavors = 0 ; - GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); - CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ; - for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor ) - { - result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType); - if ( m_dataObject->IsSupportedFormat( wxDataFormat( theType ) ) ) + UInt16 items ; + OSErr result; + CountDragItems((DragReference)m_currentDrag, &items); + for (UInt16 index = 1; index <= items && supported == false ; ++index) + { + ItemReference theItem; + FlavorType theType ; + UInt16 flavors = 0 ; + GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); + CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ; + for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor ) { - supported = true ; - break ; + result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType); + if ( m_dataObject->IsSupportedFormat( wxDataFormat( theType ) ) ) + { + supported = true ; + break ; + } } - } - } + } } return supported ; } @@ -131,109 +131,109 @@ bool wxDropTarget::GetData() { if (!m_dataObject) return FALSE; - + if ( !CurrentDragHasSupportedFormat() ) return FALSE ; - + bool transferred = false ; if ( gTrackingGlobals.m_currentSource != NULL ) { - wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; - - if ( data ) - { - size_t formatcount = data->GetFormatCount() ; - wxDataFormat *array = new wxDataFormat[ formatcount ]; - data->GetAllFormats( array ); - for (size_t i = 0; !transferred && i < formatcount ; i++) + wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; + + if ( data ) { - wxDataFormat format = array[i] ; - if ( m_dataObject->IsSupported( format ) ) + size_t formatcount = data->GetFormatCount() ; + wxDataFormat *array = new wxDataFormat[ formatcount ]; + data->GetAllFormats( array ); + for (size_t i = 0; !transferred && i < formatcount ; i++) { - int size = data->GetDataSize( format ); - transferred = true ; - - if (size == 0) - { - m_dataObject->SetData(format , 0 , 0 ) ; - } - else - { - char *d = new char[size]; - data->GetDataHere( format , (void*) d ); - m_dataObject->SetData( format , size , d ) ; - delete[] d ; - } + wxDataFormat format = array[i] ; + if ( m_dataObject->IsSupported( format ) ) + { + int size = data->GetDataSize( format ); + transferred = true ; + + if (size == 0) + { + m_dataObject->SetData(format , 0 , 0 ) ; + } + else + { + char *d = new char[size]; + data->GetDataHere( format , (void*) d ); + m_dataObject->SetData( format , size , d ) ; + delete[] d ; + } + } } - } - delete[] array ; - } + delete[] array ; + } } if ( !transferred ) { - UInt16 items ; - OSErr result; - bool firstFileAdded = false ; - CountDragItems((DragReference)m_currentDrag, &items); - for (UInt16 index = 1; index <= items; ++index) - { - ItemReference theItem; - FlavorType theType ; - UInt16 flavors = 0 ; - GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); - CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ; - for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor ) - { - result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType); - wxDataFormat format(theType) ; - if ( m_dataObject->IsSupportedFormat( format ) ) + UInt16 items ; + OSErr result; + bool firstFileAdded = false ; + CountDragItems((DragReference)m_currentDrag, &items); + for (UInt16 index = 1; index <= items; ++index) + { + ItemReference theItem; + FlavorType theType ; + UInt16 flavors = 0 ; + GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); + CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ; + for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor ) { - FlavorFlags theFlags; - result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags); - if (result == noErr) - { - Size dataSize ; - Ptr theData ; - GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize); - if ( theType == 'TEXT' ) - { - // this increment is only valid for allocating, on the next GetFlavorData - // call it is reset again to the original value - dataSize++ ; - } - theData = new char[dataSize]; - GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); - if( theType == 'TEXT' ) - { - theData[dataSize]=0 ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertToPC((char*)theData,(char*)theData,dataSize) ; - } - m_dataObject->SetData( format, dataSize, theData ); - } - else if ( theType == kDragFlavorTypeHFS ) - { - HFSFlavor* theFile = (HFSFlavor*) theData ; - wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ; - if ( firstFileAdded ) - ((wxFileDataObject*)m_dataObject)->AddFile( name ) ; - else + result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType); + wxDataFormat format(theType) ; + if ( m_dataObject->IsSupportedFormat( format ) ) + { + FlavorFlags theFlags; + result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags); + if (result == noErr) { - ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ; - firstFileAdded = true ; + Size dataSize ; + Ptr theData ; + GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize); + if ( theType == 'TEXT' ) + { + // this increment is only valid for allocating, on the next GetFlavorData + // call it is reset again to the original value + dataSize++ ; + } + theData = new char[dataSize]; + GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); + if( theType == 'TEXT' ) + { + theData[dataSize]=0 ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + wxMacConvertToPC((char*)theData,(char*)theData,dataSize) ; + } + m_dataObject->SetData( format, dataSize, theData ); + } + else if ( theType == kDragFlavorTypeHFS ) + { + HFSFlavor* theFile = (HFSFlavor*) theData ; + wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ; + if ( firstFileAdded ) + ((wxFileDataObject*)m_dataObject)->AddFile( name ) ; + else + { + ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ; + firstFileAdded = true ; + } + } + else + { + m_dataObject->SetData( format, dataSize, theData ); + } + delete[] theData; } - } - else - { - m_dataObject->SetData( format, dataSize, theData ); - } - delete[] theData; - } - break ; + break ; + } } - } - } + } } return TRUE ; } @@ -273,13 +273,13 @@ wxDropSource::~wxDropSource() wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) { wxASSERT_MSG( m_data, wxT("Drop source: no data") ); - + if (!m_data) return (wxDragResult) wxDragNone; - + if (m_data->GetFormatCount() == 0) return (wxDragResult) wxDragNone; - + OSErr result; DragReference theDrag; RgnHandle dragRegion; @@ -300,45 +300,45 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) OSType type = formats[i].GetFormatId() ; if ( type == 'TEXT' ) { - dataSize-- ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertFromPC((char*)dataPtr,(char*)dataPtr,dataSize) ; - } - AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); + dataSize-- ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + wxMacConvertFromPC((char*)dataPtr,(char*)dataPtr,dataSize) ; + } + AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); } else if (type == kDragFlavorTypeHFS ) { - HFSFlavor theFlavor ; - OSErr err = noErr; - CInfoPBRec cat; - - wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ; - - cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name; - cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum; - cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID; - cat.hFileInfo.ioFDirIndex = 0; - err = PBGetCatInfoSync(&cat); - if (err == noErr ) - { - theFlavor.fdFlags = cat.hFileInfo.ioFlFndrInfo.fdFlags; - if (theFlavor.fileSpec.parID == fsRtParID) { - theFlavor.fileCreator = 'MACS'; - theFlavor.fileType = 'disk'; - } else if ((cat.hFileInfo.ioFlAttrib & ioDirMask) != 0) { - theFlavor.fileCreator = 'MACS'; - theFlavor.fileType = 'fold'; - } else { - theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator; - theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType; - } - AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0); - } + HFSFlavor theFlavor ; + OSErr err = noErr; + CInfoPBRec cat; + + wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ; + + cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name; + cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum; + cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID; + cat.hFileInfo.ioFDirIndex = 0; + err = PBGetCatInfoSync(&cat); + if (err == noErr ) + { + theFlavor.fdFlags = cat.hFileInfo.ioFlFndrInfo.fdFlags; + if (theFlavor.fileSpec.parID == fsRtParID) { + theFlavor.fileCreator = 'MACS'; + theFlavor.fileType = 'disk'; + } else if ((cat.hFileInfo.ioFlAttrib & ioDirMask) != 0) { + theFlavor.fileCreator = 'MACS'; + theFlavor.fileType = 'fold'; + } else { + theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator; + theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType; + } + AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0); + } } else { - AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); + AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); } delete[] dataPtr ; } @@ -349,37 +349,37 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) EventRecord* ev = NULL ; #if !TARGET_CARBON // TODO - ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; + ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; #else - EventRecord rec ; - ev = &rec ; - wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; + EventRecord rec ; + ev = &rec ; + wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; #endif const short dragRegionOuterBoundary = 10 ; const short dragRegionInnerBoundary = 9 ; SetRectRgn( dragRegion , ev->where.h - dragRegionOuterBoundary , - ev->where.v - dragRegionOuterBoundary , - ev->where.h + dragRegionOuterBoundary , - ev->where.v + dragRegionOuterBoundary ) ; - + ev->where.v - dragRegionOuterBoundary , + ev->where.h + dragRegionOuterBoundary , + ev->where.v + dragRegionOuterBoundary ) ; + SetRectRgn( tempRgn , ev->where.h - dragRegionInnerBoundary , - ev->where.v - dragRegionInnerBoundary , - ev->where.h + dragRegionInnerBoundary , - ev->where.v + dragRegionInnerBoundary ) ; - + ev->where.v - dragRegionInnerBoundary , + ev->where.h + dragRegionInnerBoundary , + ev->where.v + dragRegionInnerBoundary ) ; + DiffRgn( dragRegion , tempRgn , dragRegion ) ; DisposeRgn( tempRgn ) ; - + // TODO:work with promises in order to return data only when drag // was successfully completed - + gTrackingGlobals.m_currentSource = this ; result = TrackDrag(theDrag, ev , dragRegion); DisposeRgn(dragRegion); DisposeDrag(theDrag); gTrackingGlobals.m_currentSource = NULL ; - + return wxDragCopy ; } @@ -423,7 +423,7 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind case kDragTrackingLeaveHandler: break; case kDragTrackingEnterWindow: - trackingGlobals->m_currentTargetWindow = NULL ; + trackingGlobals->m_currentTargetWindow = NULL ; trackingGlobals->m_currentTarget = NULL ; break; case kDragTrackingInWindow: diff --git a/src/mac/carbon/filedlg.cpp b/src/mac/carbon/filedlg.cpp index 841dc9936a..b2a2cb2406 100644 --- a/src/mac/carbon/filedlg.cpp +++ b/src/mac/carbon/filedlg.cpp @@ -52,160 +52,160 @@ extern bool gUseNavServices ; struct OpenUserDataRec { int currentfilter ; - bool saveMode ; + bool saveMode ; wxArrayString name ; wxArrayString extensions ; - wxArrayLong filtermactypes ; + wxArrayLong filtermactypes ; NavMenuItemSpecArrayHandle menuitems ; }; typedef struct OpenUserDataRec - OpenUserDataRec, *OpenUserDataRecPtr; + OpenUserDataRec, *OpenUserDataRecPtr; -static pascal void NavEventProc( - NavEventCallbackMessage inSelector, - NavCBRecPtr ioParams, - NavCallBackUserData ioUserData); +static pascal void NavEventProc( + NavEventCallbackMessage inSelector, + NavCBRecPtr ioParams, + NavCallBackUserData ioUserData); #if TARGET_CARBON - static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc); + static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc); #else - static NavEventUPP sStandardNavEventFilter = NewNavEventProc(NavEventProc); + static NavEventUPP sStandardNavEventFilter = NewNavEventProc(NavEventProc); #endif static pascal void NavEventProc( - NavEventCallbackMessage inSelector, - NavCBRecPtr ioParams, - NavCallBackUserData ioUserData ) + NavEventCallbackMessage inSelector, + NavCBRecPtr ioParams, + NavCallBackUserData ioUserData ) { - OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ; - if (inSelector == kNavCBEvent) { + OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ; + if (inSelector == kNavCBEvent) { #if !TARGET_CARBON wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event); #endif - } - else if ( inSelector == kNavCBStart ) - { - if ( data->menuitems ) - NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &(*data->menuitems)[data->currentfilter]); - } - else if ( inSelector == kNavCBPopupMenuSelect ) - { - NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ; - if ( menu->menuCreator == 'WXNG' ) - { - data->currentfilter = menu->menuType ; - if ( data->saveMode ) - { - int i = menu->menuType ; - wxString extension = data->extensions[i].AfterLast('.') ; - extension.MakeLower() ; - Str255 filename ; - // get the current filename - NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename); - CopyPascalStringToC( filename , (char*) filename ) ; - wxString sfilename( filename ) ; - int pos = sfilename.Find('.',TRUE) ; - if ( pos != wxNOT_FOUND ) - { - sfilename = sfilename.Left(pos+1)+extension ; - CopyCStringToPascal( sfilename.c_str() , filename ) ; - NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename); - } - } - } - } + } + else if ( inSelector == kNavCBStart ) + { + if ( data->menuitems ) + NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &(*data->menuitems)[data->currentfilter]); + } + else if ( inSelector == kNavCBPopupMenuSelect ) + { + NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ; + if ( menu->menuCreator == 'WXNG' ) + { + data->currentfilter = menu->menuType ; + if ( data->saveMode ) + { + int i = menu->menuType ; + wxString extension = data->extensions[i].AfterLast('.') ; + extension.MakeLower() ; + Str255 filename ; + // get the current filename + NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename); + CopyPascalStringToC( filename , (char*) filename ) ; + wxString sfilename( filename ) ; + int pos = sfilename.Find('.',TRUE) ; + if ( pos != wxNOT_FOUND ) + { + sfilename = sfilename.Left(pos+1)+extension ; + CopyCStringToPascal( sfilename.c_str() , filename ) ; + NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename); + } + } + } + } } const char * gfilters[] = { - "*.TXT" , - "*.TIF" , - "*.JPG" , - - NULL + "*.TXT" , + "*.TIF" , + "*.JPG" , + + NULL } ; OSType gfiltersmac[] = { - 'TEXT' , - 'TIFF' , - 'JPEG' , - - '****' + 'TEXT' , + 'TIFF' , + 'JPEG' , + + '****' } ; -void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) +void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) { - myData->menuitems = NULL ; - myData->currentfilter = 0 ; - myData->saveMode = FALSE ; - - if ( filter && filter[0] ) - { - wxString filter2(filter) ; - int filterIndex = 0; - bool isName = true ; - wxString current ; - for( unsigned int i = 0; i < filter2.Len() ; i++ ) + myData->menuitems = NULL ; + myData->currentfilter = 0 ; + myData->saveMode = FALSE ; + + if ( filter && filter[0] ) { - if( filter2.GetChar(i) == wxT('|') ) - { - if( isName ) { - myData->name.Add( current ) ; - } - else { - myData->extensions.Add( current.MakeUpper() ) ; - ++filterIndex ; + wxString filter2(filter) ; + int filterIndex = 0; + bool isName = true ; + wxString current ; + for( unsigned int i = 0; i < filter2.Len() ; i++ ) + { + if( filter2.GetChar(i) == wxT('|') ) + { + if( isName ) { + myData->name.Add( current ) ; + } + else { + myData->extensions.Add( current.MakeUpper() ) ; + ++filterIndex ; + } + isName = !isName ; + current = "" ; + } + else + { + current += filter2.GetChar(i) ; + } } - isName = !isName ; - current = "" ; - } - else - { - current += filter2.GetChar(i) ; - } - } - // we allow for compatibility reason to have a single filter expression (like *.*) without - // an explanatory text, in that case the first part is name and extension at the same time - - wxASSERT_MSG( filterIndex == 0 || !isName , "incorrect format of format string" ) ; - if ( current.IsEmpty() ) - myData->extensions.Add( myData->name[filterIndex] ) ; - else - myData->extensions.Add( current.MakeUpper() ) ; - if ( filterIndex == 0 || isName ) - myData->name.Add( current.MakeUpper() ) ; + // we allow for compatibility reason to have a single filter expression (like *.*) without + // an explanatory text, in that case the first part is name and extension at the same time + + wxASSERT_MSG( filterIndex == 0 || !isName , "incorrect format of format string" ) ; + if ( current.IsEmpty() ) + myData->extensions.Add( myData->name[filterIndex] ) ; + else + myData->extensions.Add( current.MakeUpper() ) ; + if ( filterIndex == 0 || isName ) + myData->name.Add( current.MakeUpper() ) ; + + ++filterIndex ; + - ++filterIndex ; - - const size_t extCount = myData->extensions.GetCount(); - for ( size_t i = 0 ; i < extCount; i++ ) - { - int j ; - for ( j = 0 ; gfilters[j] ; j++ ) - { - if ( strcmp( myData->extensions[i] , gfilters[j] ) == 0 ) - { - myData->filtermactypes.Add( gfiltersmac[j] ) ; - break ; - } - } - if( gfilters[j] == NULL ) - { - myData->filtermactypes.Add( '****' ) ; - } - } - } + for ( size_t i = 0 ; i < extCount; i++ ) + { + int j ; + for ( j = 0 ; gfilters[j] ; j++ ) + { + if ( strcmp( myData->extensions[i] , gfilters[j] ) == 0 ) + { + myData->filtermactypes.Add( gfiltersmac[j] ) ; + break ; + } + } + if( gfilters[j] == NULL ) + { + myData->filtermactypes.Add( '****' ) ; + } + } + } } static Boolean CheckFile( ConstStr255Param name , OSType type , OpenUserDataRecPtr data) { - Str255 filename ; + Str255 filename ; #if TARGET_CARBON p2cstrcpy((char *)filename, name) ; @@ -218,55 +218,55 @@ static Boolean CheckFile( ConstStr255Param name , OSType type , OpenUserDataRecP if ( data->extensions.GetCount() > 0 ) { - //for ( int i = 0 ; i < data->numfilters ; ++i ) - int i = data->currentfilter ; - if ( data->extensions[i].Right(2) == ".*" ) - return true ; - - { - if ( type == (OSType)data->filtermactypes[i] ) - return true ; - - wxStringTokenizer tokenizer( data->extensions[i] , ";" ) ; - while( tokenizer.HasMoreTokens() ) - { - wxString extension = tokenizer.GetNextToken() ; - if ( extension.GetChar(0) == '*' ) - extension = extension.Mid(1) ; - - if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) ) - return true ; - } - } - return false ; + //for ( int i = 0 ; i < data->numfilters ; ++i ) + int i = data->currentfilter ; + if ( data->extensions[i].Right(2) == ".*" ) + return true ; + + { + if ( type == (OSType)data->filtermactypes[i] ) + return true ; + + wxStringTokenizer tokenizer( data->extensions[i] , ";" ) ; + while( tokenizer.HasMoreTokens() ) + { + wxString extension = tokenizer.GetNextToken() ; + if ( extension.GetChar(0) == '*' ) + extension = extension.Mid(1) ; + + if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) ) + return true ; + } + } + return false ; } return true ; } #ifndef __DARWIN__ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr) -{ - OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ; - // return true if this item is invisible or a file - - Boolean visibleFlag; - Boolean folderFlag; - - visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible); - folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10); - - // because the semantics of the filter proc are "true means don't show - // it" we need to invert the result that we return - - if ( !visibleFlag ) - return true ; - - if ( !folderFlag ) - { - return !CheckFile( myCInfoPBPtr->hFileInfo.ioNamePtr , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ; - } - - return false ; +{ + OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ; + // return true if this item is invisible or a file + + Boolean visibleFlag; + Boolean folderFlag; + + visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible); + folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10); + + // because the semantics of the filter proc are "true means don't show + // it" we need to invert the result that we return + + if ( !visibleFlag ) + return true ; + + if ( !folderFlag ) + { + return !CheckFile( myCInfoPBPtr->hFileInfo.ioNamePtr , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ; + } + + return false ; } #endif @@ -335,7 +335,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, long style, const wxPoint& pos) { - wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; + wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; m_message = message; m_dialogStyle = style; m_parent = parent; @@ -362,7 +362,7 @@ pascal Boolean CrossPlatformFilterCallback ( NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ; if (theItem->descriptorType == typeFSS && !theInfo->isFolder) { - FSSpec spec; + FSSpec spec; memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ; display = CheckFile( spec.name , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ; } @@ -373,58 +373,58 @@ pascal Boolean CrossPlatformFilterCallback ( int wxFileDialog::ShowModal() { - NavDialogOptions mNavOptions; - NavObjectFilterUPP mNavFilterUPP = NULL; - NavPreviewUPP mNavPreviewUPP = NULL ; - NavReplyRecord mNavReply; - AEDesc mDefaultLocation ; - bool mSelectDefault = false ; - - // zero all data - - m_path = wxEmptyString ; - m_fileName = wxEmptyString ; - m_paths.Empty(); - m_fileNames.Empty(); - - // setup dialog - + NavDialogOptions mNavOptions; + NavObjectFilterUPP mNavFilterUPP = NULL; + NavPreviewUPP mNavPreviewUPP = NULL ; + NavReplyRecord mNavReply; + AEDesc mDefaultLocation ; + bool mSelectDefault = false ; + + // zero all data + + m_path = wxEmptyString ; + m_fileName = wxEmptyString ; + m_paths.Empty(); + m_fileNames.Empty(); + + // setup dialog + ::NavGetDefaultDialogOptions(&mNavOptions); - - mNavFilterUPP = nil; - mNavPreviewUPP = nil; - mSelectDefault = false; + + mNavFilterUPP = nil; + mNavPreviewUPP = nil; + mSelectDefault = false; mNavReply.validRecord = false; - mNavReply.replacing = false; + mNavReply.replacing = false; mNavReply.isStationery = false; - mNavReply.translationNeeded = false; + mNavReply.translationNeeded = false; mNavReply.selection.descriptorType = typeNull; mNavReply.selection.dataHandle = nil; - mNavReply.keyScript = smSystemScript; + mNavReply.keyScript = smSystemScript; mNavReply.fileTranslation = nil; - + // Set default location, the location // that's displayed when the dialog // first appears - + FSSpec location ; wxMacFilename2FSSpec( m_dir , &location ) ; OSErr err = noErr ; - + mDefaultLocation.descriptorType = typeNull; mDefaultLocation.dataHandle = nil; err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation ); if ( mDefaultLocation.dataHandle ) { - + if (mSelectDefault) { mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation; } else { mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; } } - + #if TARGET_CARBON c2pstrcpy((StringPtr)mNavOptions.message, m_message) ; #else @@ -438,7 +438,7 @@ int wxFileDialog::ShowModal() c2pstr((char *)mNavOptions.savedFileName ) ; #endif - OpenUserDataRec myData; + OpenUserDataRec myData; MakeUserDataRec( &myData , m_wildCard ) ; myData.currentfilter = m_filterIndex ; if ( myData.extensions.GetCount() > 0 ) @@ -464,7 +464,7 @@ int wxFileDialog::ShowModal() mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ; mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ; - + err = ::NavPutFile( &mDefaultLocation, &mNavReply, @@ -472,7 +472,7 @@ int wxFileDialog::ShowModal() sStandardNavEventFilter , NULL, kNavGenericSignature, - &myData); // User Data + &myData); // User Data m_filterIndex = myData.currentfilter ; } else @@ -484,7 +484,7 @@ int wxFileDialog::ShowModal() mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ; else mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ; - + err = ::NavGetFile( &mDefaultLocation, &mNavReply, @@ -496,23 +496,23 @@ int wxFileDialog::ShowModal() &myData); m_filterIndex = myData.currentfilter ; } - + DisposeNavObjectFilterUPP(mNavFilterUPP); if ( mDefaultLocation.dataHandle != nil ) { ::AEDisposeDesc(&mDefaultLocation); } - + if ( (err != noErr) && (err != userCanceledErr) ) { return wxID_CANCEL ; } if (mNavReply.validRecord) { - + FSSpec outFileSpec ; AEDesc specDesc ; AEKeyword keyWord ; - + long count ; ::AECountItems( &mNavReply.selection , &count ) ; for ( long i = 1 ; i <= count ; ++i ) @@ -521,7 +521,7 @@ int wxFileDialog::ShowModal() if ( err != noErr ) { m_path = "" ; return wxID_CANCEL ; - } + } outFileSpec = **(FSSpec**) specDesc.dataHandle; if (specDesc.dataHandle != nil) { ::AEDisposeDesc(&specDesc); @@ -566,7 +566,7 @@ wxDefaultFileSelector(bool load, const char *what, const char *extension, const wxString wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) { - return wxDefaultFileSelector(TRUE, what, extension, default_name, parent); + return wxDefaultFileSelector(TRUE, what, extension, default_name, parent); } @@ -574,7 +574,7 @@ wxLoadFileSelector(const char *what, const char *extension, const char *default_ wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) { - return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); + return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); } diff --git a/src/mac/carbon/font.cpp b/src/mac/carbon/font.cpp index 1c6b6518bb..e134003482 100644 --- a/src/mac/carbon/font.cpp +++ b/src/mac/carbon/font.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -67,66 +67,66 @@ wxFontRefData::~wxFontRefData() void wxFontRefData::MacFindFont() { - if( m_faceName == "" ) - { - switch( m_family ) - { - case wxDEFAULT : - m_macFontNum = ::GetAppFont() ; - break ; - case wxDECORATIVE : - ::GetFNum( "\pTimes" , &m_macFontNum) ; - break ; - case wxROMAN : - ::GetFNum( "\pTimes" , &m_macFontNum) ; - break ; - case wxSCRIPT : - ::GetFNum( "\pTimes" , &m_macFontNum) ; - break ; - case wxSWISS : - ::GetFNum( "\pGeneva" , &m_macFontNum) ; - break ; - case wxMODERN : - ::GetFNum( "\pMonaco" , &m_macFontNum) ; - break ; - } - Str255 name ; - GetFontName( m_macFontNum , name ) ; - CopyPascalStringToC( name , (char*) name ) ; - m_faceName = (char*) name ; - } - else - { - if ( m_faceName == "systemfont" ) - m_macFontNum = ::GetSysFont() ; - else if ( m_faceName == "applicationfont" ) - m_macFontNum = ::GetAppFont() ; - else - { - Str255 fontname ; - wxMacStringToPascal( m_faceName , fontname ) ; - ::GetFNum( fontname, &m_macFontNum); - } - } - - m_macFontStyle = 0; - if (m_weight == wxBOLD) - m_macFontStyle |= bold; - if (m_style == wxITALIC || m_style == wxSLANT) - m_macFontStyle |= italic; - if (m_underlined) - m_macFontStyle |= underline; - m_macFontSize = m_pointSize ; - - //TODO:if we supply the style as an additional parameter we must make a testing - //sequence in order to degrade gracefully while trying to maintain most of the style - //information, meanwhile we just take the normal font and apply the features after - OSStatus status = ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID); + if( m_faceName == "" ) + { + switch( m_family ) + { + case wxDEFAULT : + m_macFontNum = ::GetAppFont() ; + break ; + case wxDECORATIVE : + ::GetFNum( "\pTimes" , &m_macFontNum) ; + break ; + case wxROMAN : + ::GetFNum( "\pTimes" , &m_macFontNum) ; + break ; + case wxSCRIPT : + ::GetFNum( "\pTimes" , &m_macFontNum) ; + break ; + case wxSWISS : + ::GetFNum( "\pGeneva" , &m_macFontNum) ; + break ; + case wxMODERN : + ::GetFNum( "\pMonaco" , &m_macFontNum) ; + break ; + } + Str255 name ; + GetFontName( m_macFontNum , name ) ; + CopyPascalStringToC( name , (char*) name ) ; + m_faceName = (char*) name ; + } + else + { + if ( m_faceName == "systemfont" ) + m_macFontNum = ::GetSysFont() ; + else if ( m_faceName == "applicationfont" ) + m_macFontNum = ::GetAppFont() ; + else + { + Str255 fontname ; + wxMacStringToPascal( m_faceName , fontname ) ; + ::GetFNum( fontname, &m_macFontNum); + } + } + + m_macFontStyle = 0; + if (m_weight == wxBOLD) + m_macFontStyle |= bold; + if (m_style == wxITALIC || m_style == wxSLANT) + m_macFontStyle |= italic; + if (m_underlined) + m_macFontStyle |= underline; + m_macFontSize = m_pointSize ; + + //TODO:if we supply the style as an additional parameter we must make a testing + //sequence in order to degrade gracefully while trying to maintain most of the style + //information, meanwhile we just take the normal font and apply the features after + OSStatus status = ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID); /* status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) , - kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; + kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; */ - wxASSERT_MSG( status == noErr , "couldn't retrieve font identifier" ) ; + wxASSERT_MSG( status == noErr , "couldn't retrieve font identifier" ) ; } // ---------------------------------------------------------------------------- @@ -173,7 +173,7 @@ wxFont::~wxFont() bool wxFont::RealizeResource() { - M_FONTDATA->MacFindFont() ; + M_FONTDATA->MacFindFont() ; return TRUE; } @@ -188,17 +188,17 @@ void wxFont::SetEncoding(wxFontEncoding encoding) void wxFont::Unshare() { - // Don't change shared data - if (!m_refData) + // Don't change shared data + if (!m_refData) { - m_refData = new wxFontRefData(); - } + m_refData = new wxFontRefData(); + } else { - wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); - UnRef(); - m_refData = ref; - } + wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); + UnRef(); + m_refData = ref; + } } void wxFont::SetPointSize(int pointSize) diff --git a/src/mac/carbon/fontdlg.cpp b/src/mac/carbon/fontdlg.cpp index 5924ed4a9e..03c894c553 100644 --- a/src/mac/carbon/fontdlg.cpp +++ b/src/mac/carbon/fontdlg.cpp @@ -7,7 +7,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/carbon/fontenum.cpp b/src/mac/carbon/fontenum.cpp index 4a91e5703f..5e9987348e 100644 --- a/src/mac/carbon/fontenum.cpp +++ b/src/mac/carbon/fontenum.cpp @@ -103,46 +103,46 @@ bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding) void wxFontEnumeratorHelper::DoEnumerate() { - MenuHandle menu ; - Str255 p_name ; - - short lines ; - - menu = NewMenu( 32000 , "\pFont" ) ; - AppendResMenu( menu , 'FONT' ) ; - lines = CountMenuItems( menu ) ; - - for ( int i = 1 ; i < lines+1 ; i ++ ) - { - GetMenuItemText( menu , i , p_name ) ; - wxString c_name = wxMacMakeStringFromPascal(p_name) ; - - /* - - if ( m_fixedOnly ) - { - // check that it's a fixed pitch font (there is *no* error here, the - // flag name is misleading!) - if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH ) - { - // not a fixed pitch font - return TRUE; - } - } - - if ( m_charset != -1 ) - { - // check that we have the right encoding - if ( lf->lfCharSet != m_charset ) - { - return TRUE; - } - } - - */ - m_fontEnum->OnFacename( c_name ) ; - } - DisposeMenu( menu ) ; + MenuHandle menu ; + Str255 p_name ; + + short lines ; + + menu = NewMenu( 32000 , "\pFont" ) ; + AppendResMenu( menu , 'FONT' ) ; + lines = CountMenuItems( menu ) ; + + for ( int i = 1 ; i < lines+1 ; i ++ ) + { + GetMenuItemText( menu , i , p_name ) ; + wxString c_name = wxMacMakeStringFromPascal(p_name) ; + + /* + + if ( m_fixedOnly ) + { + // check that it's a fixed pitch font (there is *no* error here, the + // flag name is misleading!) + if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH ) + { + // not a fixed pitch font + return TRUE; + } + } + + if ( m_charset != -1 ) + { + // check that we have the right encoding + if ( lf->lfCharSet != m_charset ) + { + return TRUE; + } + } + + */ + m_fontEnum->OnFacename( c_name ) ; + } + DisposeMenu( menu ) ; } // ---------------------------------------------------------------------------- diff --git a/src/mac/carbon/frame.cpp b/src/mac/carbon/frame.cpp index f8347b5ddd..e3824f30bb 100644 --- a/src/mac/carbon/frame.cpp +++ b/src/mac/carbon/frame.cpp @@ -53,16 +53,16 @@ bool wxFrame::m_useNativeStatusBar = FALSE; void wxFrame::Init() { - m_frameMenuBar = NULL; - + m_frameMenuBar = NULL; + #if wxUSE_TOOLBAR - m_frameToolBar = NULL ; + m_frameToolBar = NULL ; #endif - m_frameStatusBar = NULL; - m_winLastFocused = NULL ; - + m_frameStatusBar = NULL; + m_winLastFocused = NULL ; + m_iconized = FALSE; - + #if wxUSE_TOOLTIPS m_hwndToolTip = 0; #endif @@ -70,7 +70,7 @@ void wxFrame::Init() wxPoint wxFrame::GetClientAreaOrigin() const { - // on mac we are at position -1,-1 with the control + // on mac we are at position -1,-1 with the control wxPoint pt(0, 0); #if wxUSE_TOOLBAR @@ -101,27 +101,26 @@ bool wxFrame::Create(wxWindow *parent, long style, const wxString& name) { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); - + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); + if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) return FALSE; - - MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; - - m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; - SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; - - wxModelessWindows.Append(this); - - return TRUE; + + MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; + + m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; + SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; + + wxModelessWindows.Append(this); + + return TRUE; } wxFrame::~wxFrame() { - m_isBeingDeleted = TRUE; - - DeleteAllBars(); - + m_isBeingDeleted = TRUE; + + DeleteAllBars(); } @@ -130,14 +129,14 @@ bool wxFrame::Enable(bool enable) if ( !wxWindow::Enable(enable) ) return FALSE; - if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() ) - { - int iMaxMenu = m_frameMenuBar->GetMenuCount(); - for ( int i = 0 ; i < iMaxMenu ; ++ i ) - { - m_frameMenuBar->EnableTop( i , enable ) ; - } - } + if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() ) + { + int iMaxMenu = m_frameMenuBar->GetMenuCount(); + for ( int i = 0 ; i < iMaxMenu ; ++ i ) + { + m_frameMenuBar->EnableTop( i , enable ) ; + } + } return TRUE; } @@ -149,24 +148,24 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, statusBar = new wxStatusBar(this, id, style, name); - statusBar->SetSize( 100 , 15 ) ; + statusBar->SetSize( 100 , 15 ) ; statusBar->SetFieldsCount(number); return statusBar; } void wxFrame::PositionStatusBar() { - if (m_frameStatusBar ) - { - int w, h; - GetClientSize(&w, &h); - int sw, sh; - m_frameStatusBar->GetSize(&sw, &sh); - - // Since we wish the status bar to be directly under the client area, - // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. - m_frameStatusBar->SetSize(0, h, w, sh); - } + if (m_frameStatusBar ) + { + int w, h; + GetClientSize(&w, &h); + int sw, sh; + m_frameStatusBar->GetSize(&sw, &sh); + + // Since we wish the status bar to be directly under the client area, + // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. + m_frameStatusBar->SetSize(0, h, w, sh); + } } // Responds to colour changes, and passes event on to children. @@ -215,8 +214,8 @@ void wxFrame::OnActivate(wxActivateEvent& event) event.Skip(); } - else - { + else + { // restore focus to the child which was last focused wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent() : NULL; @@ -225,19 +224,19 @@ void wxFrame::OnActivate(wxActivateEvent& event) parent = this; } - wxSetFocusToChild(parent, &m_winLastFocused); + wxSetFocusToChild(parent, &m_winLastFocused); - if ( m_frameMenuBar != NULL ) - { - m_frameMenuBar->MacInstallMenuBar() ; - } - else if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame))) + if ( m_frameMenuBar != NULL ) + { + m_frameMenuBar->MacInstallMenuBar() ; + } + else if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame))) { // Trying toplevel frame menbar if( ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar() ) - ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar()->MacInstallMenuBar(); - } - } + ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar()->MacInstallMenuBar(); + } + } } void wxFrame::DetachMenuBar() @@ -262,40 +261,40 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) void wxFrame::DoGetClientSize(int *x, int *y) const { - wxWindow::DoGetClientSize( x , y ) ; - + wxWindow::DoGetClientSize( x , y ) ; + #if wxUSE_STATUSBAR - if ( GetStatusBar() && y ) - { - int statusX, statusY; - GetStatusBar()->GetClientSize(&statusX, &statusY); - *y -= statusY; - } + if ( GetStatusBar() && y ) + { + int statusX, statusY; + GetStatusBar()->GetClientSize(&statusX, &statusY); + *y -= statusY; + } #endif // wxUSE_STATUSBAR - - wxPoint pt(GetClientAreaOrigin()); - if ( y ) - *y -= pt.y; - if ( x ) - *x -= pt.x; + + wxPoint pt(GetClientAreaOrigin()); + if ( y ) + *y -= pt.y; + if ( x ) + *x -= pt.x; } void wxFrame::DoSetClientSize(int clientwidth, int clientheight) { - int currentclientwidth , currentclientheight ; - int currentwidth , currentheight ; - - GetClientSize( ¤tclientwidth , ¤tclientheight ) ; - GetSize( ¤twidth , ¤theight ) ; - - // find the current client size + int currentclientwidth , currentclientheight ; + int currentwidth , currentheight ; + + GetClientSize( ¤tclientwidth , ¤tclientheight ) ; + GetSize( ¤twidth , ¤theight ) ; + + // find the current client size // Find the difference between the entire window (title bar and all) // and the client area; add this to the new client size to move the // window - DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth , - currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ; + DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth , + currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ; } @@ -314,8 +313,8 @@ void wxFrame::PositionToolBar() { int cw, ch; - cw = m_width ; - ch = m_height ; + cw = m_width ; + ch = m_height ; if ( GetStatusBar() ) { diff --git a/src/mac/carbon/gauge.cpp b/src/mac/carbon/gauge.cpp index 4757f6ca43..1a61e4f723 100644 --- a/src/mac/carbon/gauge.cpp +++ b/src/mac/carbon/gauge.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -29,25 +29,25 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - wxSize size = s ; - Rect bounds ; - Str255 title ; - m_rangeMax = range ; - m_gaugePos = 0 ; - - if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y) - { - size = wxSize( 200 , 16 ) ; - } - - MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range, - kControlProgressBarProc , (long) this ) ; - - MacPostControlCreate() ; - - return TRUE; + wxSize size = s ; + Rect bounds ; + Str255 title ; + m_rangeMax = range ; + m_gaugePos = 0 ; + + if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y) + { + size = wxSize( 200 , 16 ) ; + } + + MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range, + kControlProgressBarProc , (long) this ) ; + + MacPostControlCreate() ; + + return TRUE; } void wxGauge::SetShadowWidth(int w) @@ -67,7 +67,7 @@ void wxGauge::SetRange(int r) void wxGauge::SetValue(int pos) { m_gaugePos = pos; - ::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ; } int wxGauge::GetShadowWidth() const diff --git a/src/mac/carbon/gdiobj.cpp b/src/mac/carbon/gdiobj.cpp index 76bc6a264e..528c5a7efe 100644 --- a/src/mac/carbon/gdiobj.cpp +++ b/src/mac/carbon/gdiobj.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/carbon/glcanvas.cpp b/src/mac/carbon/glcanvas.cpp index 027bc28a8a..345fc2aeaf 100644 --- a/src/mac/carbon/glcanvas.cpp +++ b/src/mac/carbon/glcanvas.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -34,82 +34,82 @@ #include "wx/mac/uma.h" /* - * GLContext implementation - */ +* GLContext implementation +*/ wxGLContext::wxGLContext( - AGLPixelFormat fmt, wxGLCanvas *win, - const wxPalette& palette, - const wxGLContext *other /* for sharing display lists */ -) + AGLPixelFormat fmt, wxGLCanvas *win, + const wxPalette& palette, + const wxGLContext *other /* for sharing display lists */ + ) { m_window = win; - + m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetRootWindow())); - + m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL); wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") ); - - GLboolean b; + + GLboolean b; b = aglSetDrawable(m_glContext, m_drawable); wxCHECK_RET( b, wxT("Couldn't bind OpenGl context") ); - aglEnable(m_glContext , AGL_BUFFER_RECT ) ; + aglEnable(m_glContext , AGL_BUFFER_RECT ) ; b = aglSetCurrentContext(m_glContext); wxCHECK_RET( b, wxT("Couldn't activate OpenGl context") ); } wxGLContext::~wxGLContext() { - if (m_glContext) - { - aglSetCurrentContext(NULL); - aglDestroyContext(m_glContext); - } + if (m_glContext) + { + aglSetCurrentContext(NULL); + aglDestroyContext(m_glContext); + } } void wxGLContext::SwapBuffers() { - if (m_glContext) - { - aglSwapBuffers(m_glContext); - } + if (m_glContext) + { + aglSwapBuffers(m_glContext); + } } void wxGLContext::SetCurrent() { - if (m_glContext) - { - aglSetCurrentContext(m_glContext); - } + if (m_glContext) + { + aglSetCurrentContext(m_glContext); + } } void wxGLContext::Update() { - if (m_glContext) - { - aglUpdateContext(m_glContext); - } + if (m_glContext) + { + aglUpdateContext(m_glContext); + } } void wxGLContext::SetColour(const char *colour) { - float r = 0.0; - float g = 0.0; - float b = 0.0; - wxColour *col = wxTheColourDatabase->FindColour(colour); - if (col) - { - r = (float)(col->Red()/256.0); - g = (float)(col->Green()/256.0); - b = (float)(col->Blue()/256.0); - glColor3f( r, g, b); - } + float r = 0.0; + float g = 0.0; + float b = 0.0; + wxColour *col = wxTheColourDatabase->FindColour(colour); + if (col) + { + r = (float)(col->Red()/256.0); + g = (float)(col->Green()/256.0); + b = (float)(col->Blue()/256.0); + glColor3f( r, g, b); + } } /* - * wxGLCanvas implementation - */ +* wxGLCanvas implementation +*/ IMPLEMENT_CLASS(wxGLCanvas, wxWindow) @@ -118,23 +118,23 @@ BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow) END_EVENT_TABLE() wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette) + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette) { Create(parent, NULL, id, pos, size, style, name, attribList, palette); } wxGLCanvas::wxGLCanvas( wxWindow *parent, - const wxGLContext *shared, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette ) + const wxGLContext *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette ) { Create(parent, shared, id, pos, size, style, name, attribList, palette); } wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette ) + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette ) { Create(parent, shared ? shared->GetContext() : NULL, id, pos, size, style, name, attribList, palette); } @@ -151,80 +151,80 @@ static AGLPixelFormat ChoosePixelFormat(const int *attribList) { GLint data[512]; GLint defaultAttribs[] = { AGL_RGBA, - AGL_DOUBLEBUFFER, - AGL_MINIMUM_POLICY, - AGL_DEPTH_SIZE, 1, // use largest available depth buffer - AGL_RED_SIZE, 1, - AGL_GREEN_SIZE, 1, - AGL_BLUE_SIZE, 1, - AGL_ALPHA_SIZE, 0, - AGL_NONE }; + AGL_DOUBLEBUFFER, + AGL_MINIMUM_POLICY, + AGL_DEPTH_SIZE, 1, // use largest available depth buffer + AGL_RED_SIZE, 1, + AGL_GREEN_SIZE, 1, + AGL_BLUE_SIZE, 1, + AGL_ALPHA_SIZE, 0, + AGL_NONE }; GLint *attribs; if (!attribList) { - attribs = defaultAttribs; + attribs = defaultAttribs; } else { - int arg=0, p=0; - - data[p++] = AGL_MINIMUM_POLICY; // make _SIZE tags behave more like GLX - while( (attribList[arg]!=0) && (p<512) ) - { - switch( attribList[arg++] ) + int arg=0, p=0; + + data[p++] = AGL_MINIMUM_POLICY; // make _SIZE tags behave more like GLX + while( (attribList[arg]!=0) && (p<512) ) { - case WX_GL_RGBA: data[p++] = AGL_RGBA; break; - case WX_GL_BUFFER_SIZE: - data[p++]=AGL_BUFFER_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_LEVEL: - data[p++]=AGL_LEVEL; data[p++]=attribList[arg++]; break; - case WX_GL_DOUBLEBUFFER: data[p++] = AGL_DOUBLEBUFFER; break; - case WX_GL_STEREO: data[p++] = AGL_STEREO; break; - case WX_GL_AUX_BUFFERS: - data[p++]=AGL_AUX_BUFFERS; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_RED: - data[p++]=AGL_RED_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_GREEN: - data[p++]=AGL_GREEN_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_BLUE: - data[p++]=AGL_BLUE_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ALPHA: - data[p++]=AGL_ALPHA_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_DEPTH_SIZE: - data[p++]=AGL_DEPTH_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_STENCIL_SIZE: - data[p++]=AGL_STENCIL_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_RED: - data[p++]=AGL_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_GREEN: - data[p++]=AGL_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_BLUE: - data[p++]=AGL_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_ALPHA: - data[p++]=AGL_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break; - default: - break; - } - } - data[p] = 0; - - attribs = data; + switch( attribList[arg++] ) + { + case WX_GL_RGBA: data[p++] = AGL_RGBA; break; + case WX_GL_BUFFER_SIZE: + data[p++]=AGL_BUFFER_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_LEVEL: + data[p++]=AGL_LEVEL; data[p++]=attribList[arg++]; break; + case WX_GL_DOUBLEBUFFER: data[p++] = AGL_DOUBLEBUFFER; break; + case WX_GL_STEREO: data[p++] = AGL_STEREO; break; + case WX_GL_AUX_BUFFERS: + data[p++]=AGL_AUX_BUFFERS; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_RED: + data[p++]=AGL_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_GREEN: + data[p++]=AGL_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_BLUE: + data[p++]=AGL_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ALPHA: + data[p++]=AGL_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_DEPTH_SIZE: + data[p++]=AGL_DEPTH_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_STENCIL_SIZE: + data[p++]=AGL_STENCIL_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_RED: + data[p++]=AGL_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_GREEN: + data[p++]=AGL_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_BLUE: + data[p++]=AGL_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_ALPHA: + data[p++]=AGL_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + default: + break; + } + } + data[p] = 0; + + attribs = data; } return aglChoosePixelFormat(NULL, 0, attribs); } bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette) + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette) { wxWindow::Create( parent, id, pos, size, style, name ); - + AGLPixelFormat fmt = ChoosePixelFormat(attribList); wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); - + m_glContext = new wxGLContext(fmt, this, palette, shared); - + aglDestroyPixelFormat(fmt); return true; @@ -232,20 +232,20 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID void wxGLCanvas::SwapBuffers() { - if (m_glContext) - m_glContext->SwapBuffers(); + if (m_glContext) + m_glContext->SwapBuffers(); } void wxGLCanvas::UpdateContext() { - if (m_glContext) - m_glContext->Update(); + if (m_glContext) + m_glContext->Update(); } void wxGLCanvas::SetViewport() { - // viewport is initially set to entire port - // adjust glViewport to just this window + // viewport is initially set to entire port + // adjust glViewport to just this window int x = 0 ; int y = 0 ; @@ -259,49 +259,49 @@ void wxGLCanvas::SetViewport() parms[1] = bounds.bottom - bounds.top - ( y + height ) ; parms[2] = width ; parms[3] = height ; - - aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; + + aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; } void wxGLCanvas::OnSize(wxSizeEvent& event) { - MacUpdateView() ; + MacUpdateView() ; } void wxGLCanvas::MacUpdateView() { - if (m_glContext) - { - UpdateContext(); - m_glContext->SetCurrent(); - SetViewport(); - } + if (m_glContext) + { + UpdateContext(); + m_glContext->SetCurrent(); + SetViewport(); + } } void wxGLCanvas::MacSuperChangedPosition() { - MacUpdateView() ; - wxWindow::MacSuperChangedPosition() ; + MacUpdateView() ; + wxWindow::MacSuperChangedPosition() ; } void wxGLCanvas::MacTopLevelWindowChangedPosition() { - MacUpdateView() ; - wxWindow::MacTopLevelWindowChangedPosition() ; + MacUpdateView() ; + wxWindow::MacTopLevelWindowChangedPosition() ; } void wxGLCanvas::SetCurrent() { - if (m_glContext) - { - m_glContext->SetCurrent(); - } + if (m_glContext) + { + m_glContext->SetCurrent(); + } } void wxGLCanvas::SetColour(const char *colour) { - if (m_glContext) - m_glContext->SetColour(colour); + if (m_glContext) + m_glContext->SetColour(colour); } diff --git a/src/mac/carbon/helpxxxx.cpp b/src/mac/carbon/helpxxxx.cpp index 8428f4fa7b..f41727e61b 100644 --- a/src/mac/carbon/helpxxxx.cpp +++ b/src/mac/carbon/helpxxxx.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -47,7 +47,7 @@ bool wxXXXXHelpController::LoadFile(const wxString& file) bool wxXXXXHelpController::DisplayContents() { // TODO - return FALSE; + return FALSE; } bool wxXXXXHelpController::DisplaySection(int section) diff --git a/src/mac/carbon/icon.cpp b/src/mac/carbon/icon.cpp index df10cf7b45..ef4526a670 100644 --- a/src/mac/carbon/icon.cpp +++ b/src/mac/carbon/icon.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -59,16 +59,16 @@ wxIcon::~wxIcon() bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, int desiredWidth, int desiredHeight) { - UnRef(); - - m_refData = new wxBitmapRefData; - - wxBitmapHandler *handler = FindHandler((wxBitmapType)type); - - if ( handler ) - return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); - else - return FALSE; + UnRef(); + + m_refData = new wxBitmapRefData; + + wxBitmapHandler *handler = FindHandler((wxBitmapType)type); + + if ( handler ) + return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); + else + return FALSE; } void wxIcon::CopyFromBitmap(const wxBitmap& bmp) @@ -80,9 +80,9 @@ void wxIcon::CopyFromBitmap(const wxBitmap& bmp) IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler) bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) + int desiredWidth, int desiredHeight) { - short theId = -1 ; + short theId = -1 ; if ( name == "wxICON_INFORMATION" ) { theId = kNoteIcon ; @@ -93,46 +93,46 @@ bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo } else if ( name == "wxICON_WARNING" ) { - theId = kCautionIcon ; - } + theId = kCautionIcon ; + } else if ( name == "wxICON_ERROR" ) { theId = kStopIcon ; } else { - Str255 theName ; - OSType theType ; - - #if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , name ) ; - #else - strcpy( (char *) theName , name ) ; - c2pstr( (char *) theName ) ; - #endif - - Handle resHandle = GetNamedResource( 'cicn' , theName ) ; - if ( resHandle != 0L ) - { - GetResInfo( resHandle , &theId , &theType , theName ) ; - ReleaseResource( resHandle ) ; - } + Str255 theName ; + OSType theType ; + +#if TARGET_CARBON + c2pstrcpy( (StringPtr) theName , name ) ; +#else + strcpy( (char *) theName , name ) ; + c2pstr( (char *) theName ) ; +#endif + + Handle resHandle = GetNamedResource( 'cicn' , theName ) ; + if ( resHandle != 0L ) + { + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + } + } + if ( theId != -1 ) + { + CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ; + if ( theIcon ) + { + M_BITMAPHANDLERDATA->m_hIcon = theIcon ; + M_BITMAPHANDLERDATA->m_width = 32 ; + M_BITMAPHANDLERDATA->m_height = 32 ; + + M_BITMAPHANDLERDATA->m_depth = 8 ; + M_BITMAPHANDLERDATA->m_ok = true ; + M_BITMAPHANDLERDATA->m_numColors = 256 ; + M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ; + return TRUE ; + } } - if ( theId != -1 ) - { - CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ; - if ( theIcon ) - { - M_BITMAPHANDLERDATA->m_hIcon = theIcon ; - M_BITMAPHANDLERDATA->m_width = 32 ; - M_BITMAPHANDLERDATA->m_height = 32 ; - - M_BITMAPHANDLERDATA->m_depth = 8 ; - M_BITMAPHANDLERDATA->m_ok = true ; - M_BITMAPHANDLERDATA->m_numColors = 256 ; - M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ; - return TRUE ; - } - } - return FALSE ; + return FALSE ; } diff --git a/src/mac/carbon/joystick.cpp b/src/mac/carbon/joystick.cpp index 5a39ba118b..6a45f419fd 100644 --- a/src/mac/carbon/joystick.cpp +++ b/src/mac/carbon/joystick.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -282,5 +282,5 @@ bool wxJoystick::ReleaseCapture() } #endif - // wxUSE_JOYSTICK + // wxUSE_JOYSTICK diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 67704b9660..2d7dff4fbc 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -24,11 +24,11 @@ #include "wx/utils.h" #if !USE_SHARED_LIBRARY - IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) BEGIN_EVENT_TABLE(wxListBox, wxControl) - EVT_SIZE( wxListBox::OnSize ) - EVT_CHAR( wxListBox::OnChar ) + EVT_SIZE( wxListBox::OnSize ) + EVT_CHAR( wxListBox::OnChar ) END_EVENT_TABLE() #endif @@ -43,8 +43,8 @@ END_EVENT_TABLE() #endif typedef struct { - unsigned short instruction; - void (*function)(); + unsigned short instruction; + void (*function)(); } ldefRec, *ldefPtr, **ldefHandle; #if PRAGMA_STRUCT_ALIGN @@ -77,105 +77,105 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect RgnHandle savedClipRegion; SInt32 savedPenMode; wxListBox* list; - GetPort(&savePort); - SetPort((**listHandle).port); - grafPtr = (**listHandle).port ; + GetPort(&savePort); + SetPort((**listHandle).port); + grafPtr = (**listHandle).port ; // typecast our refCon list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); - + // Calculate the cell rect. - + switch( message ) { - case lInitMsg: - break; - - case lCloseMsg: - break; - - case lDrawMsg: + case lInitMsg: + break; + + case lCloseMsg: + break; + + case lDrawMsg: { const wxString text = list->m_stringArray[cell.v] ; - + // Save the current clip region, and set the clip region to the area we are about // to draw. - + savedClipRegion = NewRgn(); GetClip( savedClipRegion ); - + ClipRect( drawRect ); EraseRect( drawRect ); - - wxFontRefData * font = (wxFontRefData*) list->GetFont().GetRefData() ; - - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - } - else - { - ::TextFont( kFontIDMonaco ) ; - ::TextSize( 9 ); - ::TextFace( 0 ) ; - } - + + wxFontRefData * font = (wxFontRefData*) list->GetFont().GetRefData() ; + + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( short(font->m_macFontSize) ) ; + ::TextFace( font->m_macFontStyle ) ; + } + else + { + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + } + #if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; - - if ( useDrawThemeText ) - { - Rect frame = { drawRect->top, drawRect->left + 4, - drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; + bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; + + if ( useDrawThemeText ) + { + Rect frame = { drawRect->top, drawRect->left + 4, + drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; CFStringRef sString = CFStringCreateWithBytes( NULL , (UInt8*) text.c_str(), text.Length(), CFStringGetSystemEncoding(), false ) ; CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , sString ) ; - CFRelease( sString ) ; - ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; + CFRelease( sString ) ; + ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; } - else + else #endif - { - MoveTo(drawRect->left + 4 , drawRect->top + 10 ); - DrawText(text, 0 , text.Length()); - } - + { + MoveTo(drawRect->left + 4 , drawRect->top + 10 ); + DrawText(text, 0 , text.Length()); + } + // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. - + if( isSelected ) { savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr ); SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode ); PaintRect( drawRect ); SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode ); } - + // Restore the saved clip region. - + SetClip( savedClipRegion ); DisposeRgn( savedClipRegion ); - } - break; - case lHiliteMsg: - - // Hilite or unhilite the cell. Paint the cell contents with the - // appropriate QuickDraw transform mode. - - GetPort( &grafPtr ); - savedPenMode = GetPortPenMode( (CGrafPtr)grafPtr ); - SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode ); - PaintRect( drawRect ); - SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode ); - break; - default : - break ; + } + break; + case lHiliteMsg: + + // Hilite or unhilite the cell. Paint the cell contents with the + // appropriate QuickDraw transform mode. + + GetPort( &grafPtr ); + savedPenMode = GetPortPenMode( (CGrafPtr)grafPtr ); + SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode ); + PaintRect( drawRect ); + SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode ); + break; + default : + break ; } SetPort(savePort); } @@ -212,27 +212,27 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - + ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macListDefUPP == NULL ) { - macListDefUPP = NewListDefUPP( wxMacListDefinition ); + macListDefUPP = NewListDefUPP( wxMacListDefinition ); } - listDef.u.userProc = macListDefUPP ; - + listDef.u.userProc = macListDefUPP ; + Str255 fontName ; SInt16 fontSize ; Style fontStyle ; - SInt16 fontNum ; + SInt16 fontNum ; #if TARGET_CARBON - GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; #else - GetFontName( kFontIDMonaco , fontName ) ; - fontSize = 9 ; - fontStyle = normal ; + GetFontName( kFontIDMonaco , fontName ) ; + fontSize = 9 ; + fontStyle = normal ; #endif CopyPascalStringToC( fontName , (char*) fontName ) ; SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , fontName ) ) ; @@ -307,8 +307,8 @@ wxListBox::~wxListBox() if ( m_macList ) { #if !TARGET_CARBON - DisposeHandle( (**(ListHandle)m_macList).listDefProc ) ; - (**(ListHandle)m_macList).listDefProc = NULL ; + DisposeHandle( (**(ListHandle)m_macList).listDefProc ) ; + (**(ListHandle)m_macList).listDefProc = NULL ; #endif m_macList = NULL ; } @@ -406,25 +406,25 @@ int wxListBox::DoAppend(const wxString& item) void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) { - MacSetRedraw( false ) ; - Clear() ; - int n = choices.GetCount(); - - for( int i = 0 ; i < n ; ++i ) - { - if ( clientData ) + MacSetRedraw( false ) ; + Clear() ; + int n = choices.GetCount(); + + for( int i = 0 ; i < n ; ++i ) { + if ( clientData ) + { #if wxUSE_OWNER_DRAWN wxASSERT_MSG(clientData[i] == NULL, - wxT("Can't use client data with owner-drawn listboxes")); + wxT("Can't use client data with owner-drawn listboxes")); #else // !wxUSE_OWNER_DRAWN - Append( choices[i] , clientData[i] ) ; - #endif + Append( choices[i] , clientData[i] ) ; +#endif + } + else + Append( choices[i] ) ; } - else - Append( choices[i] ) ; - } - + #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { // first delete old items @@ -434,7 +434,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) m_aItems[ui] = NULL; } m_aItems.Empty(); - + // then create new ones for ( ui = 0; ui < (size_t)m_noItems; ui++ ) { wxOwnerDrawn *pNewItem = CreateItem(ui); @@ -443,7 +443,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) } } #endif // wxUSE_OWNER_DRAWN - MacSetRedraw( true ) ; + MacSetRedraw( true ) ; } bool wxListBox::HasMultipleSelection() const @@ -460,20 +460,20 @@ int wxListBox::FindString(const wxString& st) const } else s = st ; - + if ( s.Right(1) == "*" ) { wxString search = s.Left( s.Length() - 1 ) ; int len = search.Length() ; Str255 s1 , s2 ; - + #if TARGET_CARBON c2pstrcpy( (StringPtr) s2 , search.c_str() ) ; #else strcpy( (char *) s2 , search.c_str() ) ; c2pstr( (char *) s2 ) ; #endif - + for ( int i = 0 ; i < m_noItems ; ++ i ) { #if TARGET_CARBON @@ -495,19 +495,19 @@ int wxListBox::FindString(const wxString& st) const return i ; } } - + } else { Str255 s1 , s2 ; - + #if TARGET_CARBON c2pstrcpy( (StringPtr) s2 , s.c_str() ) ; #else strcpy( (char *) s2 , s.c_str() ) ; c2pstr( (char *) s2 ) ; #endif - + for ( int i = 0 ; i < m_noItems ; ++ i ) { #if TARGET_CARBON @@ -519,40 +519,40 @@ int wxListBox::FindString(const wxString& st) const if ( EqualString( s1 , s2 , false , false ) ) return i ; } - } - return -1; + } + return -1; } void wxListBox::Clear() { - FreeData(); - m_noItems = 0; - m_stringArray.Empty() ; - m_dataArray.Empty() ; - MacClear() ; + FreeData(); + m_noItems = 0; + m_stringArray.Empty() ; + m_dataArray.Empty() ; + MacClear() ; } void wxListBox::SetSelection(int N, bool select) { wxCHECK_RET( N >= 0 && N < m_noItems, - "invalid index in wxListBox::SetSelection" ); - MacSetSelection( N , select ) ; - GetSelections( m_selectionPreImage ) ; + "invalid index in wxListBox::SetSelection" ); + MacSetSelection( N , select ) ; + GetSelections( m_selectionPreImage ) ; } bool wxListBox::IsSelected(int N) const { wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE, - "invalid index in wxListBox::Selected" ); - - return MacIsSelected( N ) ; + "invalid index in wxListBox::Selected" ); + + return MacIsSelected( N ) ; } void *wxListBox::DoGetItemClientData(int N) const { wxCHECK_MSG( N >= 0 && N < m_noItems, NULL, - wxT("invalid index in wxListBox::GetClientData")); - + wxT("invalid index in wxListBox::GetClientData")); + return (void *)m_dataArray[N]; } @@ -564,8 +564,8 @@ wxClientData *wxListBox::DoGetItemClientObject(int N) const void wxListBox::DoSetItemClientData(int N, void *Client_data) { wxCHECK_RET( N >= 0 && N < m_noItems, - "invalid index in wxListBox::SetClientData" ); - + "invalid index in wxListBox::SetClientData" ); + #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { @@ -575,7 +575,7 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data) } #endif // wxUSE_OWNER_DRAWN wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , "invalid client_data array" ) ; - + if ( m_dataArray.GetCount() > (size_t) N ) { m_dataArray[N] = (char*) Client_data ; @@ -617,17 +617,17 @@ wxString wxListBox::GetString(int N) const void wxListBox::DoInsertItems(const wxArrayString& items, int pos) { wxCHECK_RET( pos >= 0 && pos <= m_noItems, - wxT("invalid index in wxListBox::InsertItems") ); - + wxT("invalid index in wxListBox::InsertItems") ); + int nItems = items.GetCount(); - + for ( int i = 0 ; i < nItems ; i++ ) { m_stringArray.Insert( items[i] , pos + i ) ; m_dataArray.Insert( NULL , pos + i ) ; MacInsert( pos + i , items[i] ) ; } - + m_noItems += nItems; } @@ -649,44 +649,44 @@ wxSize wxListBox::DoGetBestSize() const int lbWidth = 100; // some defaults int lbHeight = 110; int wLine; - - { - wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; - - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - } - else - { - ::TextFont( kFontIDMonaco ) ; - ::TextSize( 9 ); - ::TextFace( 0 ) ; - } - - // Find the widest line - for(int i = 0; i < GetCount(); i++) { - wxString str(GetString(i)); - wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; - lbWidth = wxMax(lbWidth, wLine); - } - - // Add room for the scrollbar - lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - - // And just a bit more - int cy = 12 ; - int cx = ::TextWidth( "X" , 0 , 1 ) ; - lbWidth += cx ; - - // don't make the listbox too tall (limit height to around 10 items) but don't - // make it too small neither - lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10); - } + + { + wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; + + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( short(font->m_macFontSize) ) ; + ::TextFace( font->m_macFontStyle ) ; + } + else + { + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + } + + // Find the widest line + for(int i = 0; i < GetCount(); i++) { + wxString str(GetString(i)); + wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; + lbWidth = wxMax(lbWidth, wLine); + } + + // Add room for the scrollbar + lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); + + // And just a bit more + int cy = 12 ; + int cx = ::TextWidth( "X" , 0 , 1 ) ; + lbWidth += cx ; + + // don't make the listbox too tall (limit height to around 10 items) but don't + // make it too small neither + lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10); + } return wxSize(lbWidth, lbHeight); } @@ -704,7 +704,7 @@ void wxListBox::SetupColours() void wxListBox::Refresh(bool eraseBack, const wxRect *rect) { wxControl::Refresh( eraseBack , rect ) ; -// MacRedrawControl() ; + // MacRedrawControl() ; } #if wxUSE_OWNER_DRAWN @@ -735,18 +735,18 @@ wxOwnerDrawn *wxListBox::CreateItem(size_t n) /* void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) { - wxListBox* list; - // typecast our refCon - list = (wxListBox*)refCon; - - MoveTo(cellRect->left + 4 , cellRect->top + 10 ); - const wxString text = list->m_stringArray[lCell.v] ; - ::TextFont( kFontIDMonaco ) ; - ::TextSize( 9 ); - ::TextFace( 0 ) ; - DrawText(text, 0 , text.Length()); - -} +wxListBox* list; +// typecast our refCon +list = (wxListBox*)refCon; + + MoveTo(cellRect->left + 4 , cellRect->top + 10 ); + const wxString text = list->m_stringArray[lCell.v] ; + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + DrawText(text, 0 , text.Length()); + + } */ void wxListBox::MacDelete( int N ) { @@ -759,7 +759,7 @@ void wxListBox::MacInsert( int n , const char * text) Cell cell = { 0 , 0 } ; cell.v = n ; LAddRow( 1 , cell.v , (ListHandle)m_macList ) ; -// LSetCell(text, strlen(text), cell, m_macList); + // LSetCell(text, strlen(text), cell, m_macList); Refresh(); } @@ -768,7 +768,7 @@ void wxListBox::MacAppend( const char * text) Cell cell = { 0 , 0 } ; cell.v = (**(ListHandle)m_macList).dataBounds.bottom ; LAddRow( 1 , cell.v , (ListHandle)m_macList ) ; - // LSetCell(text, strlen(text), cell, m_macList); + // LSetCell(text, strlen(text), cell, m_macList); Refresh(); } @@ -788,7 +788,7 @@ void wxListBox::MacSetSelection( int n , bool select ) LSetSelect( false , cell , (ListHandle)m_macList ) ; } } - + cell.v = n ; LSetSelect( select , cell , (ListHandle)m_macList ) ; LAutoScroll( (ListHandle)m_macList ) ; @@ -804,7 +804,7 @@ bool wxListBox::MacIsSelected( int n ) const void wxListBox::MacDestroy() { -// DisposeExtLDEFInfo( m_macList ) ; + // DisposeExtLDEFInfo( m_macList ) ; } int wxListBox::MacGetSelection() const @@ -819,12 +819,12 @@ int wxListBox::MacGetSelection() const int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const { int no_sel = 0 ; - + aSelections.Empty(); - + Cell cell = { 0 , 0 } ; cell.v = 0 ; - + while ( LGetSelect( true , &cell ,(ListHandle) m_macList ) ) { aSelections.Add( cell.v ) ; @@ -840,7 +840,7 @@ void wxListBox::MacSet( int n , const char * text ) // so we just have to redraw Cell cell = { 0 , 0 } ; cell.v = n ; -// LSetCell(text, strlen(text), cell, m_macList); + // LSetCell(text, strlen(text), cell, m_macList); Refresh(); } @@ -852,7 +852,7 @@ void wxListBox::MacScrollTo( int n ) void wxListBox::OnSize( const wxSizeEvent &event) { Point pt; - + #if TARGET_CARBON GetListCellSize((ListHandle)m_macList, &pt); #else @@ -866,7 +866,7 @@ void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { Boolean wasDoubleClick = false ; long result ; - + ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ; if ( !wasDoubleClick ) { @@ -881,7 +881,7 @@ void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) void wxListBox::MacSetRedraw( bool doDraw ) { LSetDrawingMode( doDraw , (ListHandle)m_macList ) ; - + } void wxListBox::MacDoClick() @@ -889,7 +889,7 @@ void wxListBox::MacDoClick() wxArrayInt aSelections; int n ; size_t count = GetSelections(aSelections); - + if ( count == m_selectionPreImage.GetCount() ) { bool hasChanged = false ; @@ -906,12 +906,12 @@ void wxListBox::MacDoClick() return ; } } - + m_selectionPreImage = aSelections; - + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); event.SetEventObject( this ); - + if ( count > 0 ) { n = aSelections[0]; @@ -923,11 +923,11 @@ void wxListBox::MacDoClick() } else { - n = -1; + n = -1; } - + event.m_commandInt = n; - + GetEventHandler()->ProcessEvent(event); } @@ -935,35 +935,35 @@ void wxListBox::MacDoDoubleClick() { wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId); event.SetEventObject( this ); - GetEventHandler()->ProcessEvent(event) ; + GetEventHandler()->ProcessEvent(event) ; } void wxListBox::OnChar(wxKeyEvent& event) { if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER) { - wxWindow* parent = GetParent() ; - while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) - parent = parent->GetParent() ; - - if ( parent && parent->GetDefaultItem() ) - { - wxButton *def = wxDynamicCast(parent->GetDefaultItem(), - wxButton); - if ( def && def->IsEnabled() ) - { - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); - event.SetEventObject(def); - def->Command(event); - return ; - } - } - event.Skip() ; + wxWindow* parent = GetParent() ; + while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) + parent = parent->GetParent() ; + + if ( parent && parent->GetDefaultItem() ) + { + wxButton *def = wxDynamicCast(parent->GetDefaultItem(), + wxButton); + if ( def && def->IsEnabled() ) + { + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); + event.SetEventObject(def); + def->Command(event); + return ; + } + } + event.Skip() ; } /* generate wxID_CANCEL if command-. or has been pressed (typically in dialogs) */ else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) ) { - wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ; + wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ; wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); new_event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( new_event ); @@ -977,64 +977,64 @@ void wxListBox::OnChar(wxKeyEvent& event) new_event.SetWindowChange( event.ControlDown() ); new_event.SetCurrentFocus( this ); if ( !GetEventHandler()->ProcessEvent( new_event ) ) - event.Skip() ; + event.Skip() ; } - else if ( event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_UP ) - { - // perform the default key handling first - wxControl::OnKeyDown( event ) ; - + else if ( event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_UP ) + { + // perform the default key handling first + wxControl::OnKeyDown( event ) ; + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); event.SetEventObject( this ); - + wxArrayInt aSelections; int n, count = GetSelections(aSelections); if ( count > 0 ) { - n = aSelections[0]; - if ( HasClientObjectData() ) - event.SetClientObject( GetClientObject(n) ); - else if ( HasClientUntypedData() ) - event.SetClientData( GetClientData(n) ); - event.SetString( GetString(n) ); + n = aSelections[0]; + if ( HasClientObjectData() ) + event.SetClientObject( GetClientObject(n) ); + else if ( HasClientUntypedData() ) + event.SetClientData( GetClientData(n) ); + event.SetString( GetString(n) ); } else { - n = -1; + n = -1; } - + event.m_commandInt = n; - + GetEventHandler()->ProcessEvent(event); - } - else - { - if ( event.GetTimestamp() > m_lastTypeIn + 60 ) - { - m_typeIn = "" ; - } - m_lastTypeIn = event.GetTimestamp() ; - m_typeIn += (char) event.GetKeyCode() ; - int line = FindString("*"+m_typeIn+"*") ; - if ( line >= 0 ) - { - if ( GetSelection() != line ) - { - SetSelection(line) ; - wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); - event.SetEventObject( this ); - - if ( HasClientObjectData() ) - event.SetClientObject( GetClientObject( line ) ); - else if ( HasClientUntypedData() ) - event.SetClientData( GetClientData(line) ); - event.SetString( GetString(line) ); - - event.m_commandInt = line ; - - GetEventHandler()->ProcessEvent(event); - } - } - } + } + else + { + if ( event.GetTimestamp() > m_lastTypeIn + 60 ) + { + m_typeIn = "" ; + } + m_lastTypeIn = event.GetTimestamp() ; + m_typeIn += (char) event.GetKeyCode() ; + int line = FindString("*"+m_typeIn+"*") ; + if ( line >= 0 ) + { + if ( GetSelection() != line ) + { + SetSelection(line) ; + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); + event.SetEventObject( this ); + + if ( HasClientObjectData() ) + event.SetClientObject( GetClientObject( line ) ); + else if ( HasClientUntypedData() ) + event.SetClientData( GetClientData(line) ); + event.SetString( GetString(line) ); + + event.m_commandInt = line ; + + GetEventHandler()->ProcessEvent(event); + } + } + } } diff --git a/src/mac/carbon/macnotfy.cpp b/src/mac/carbon/macnotfy.cpp index c01f4deaf0..b6a170c8ee 100644 --- a/src/mac/carbon/macnotfy.cpp +++ b/src/mac/carbon/macnotfy.cpp @@ -17,12 +17,12 @@ const short kMaxEvents = 1000 ; struct wxMacNotificationEvents { - short top ; - short bottom ; - - wxMacNotificationProcPtr proc[kMaxEvents] ; - unsigned long events[kMaxEvents] ; - void* data[kMaxEvents] ; + short top ; + short bottom ; + + wxMacNotificationProcPtr proc[kMaxEvents] ; + unsigned long events[kMaxEvents] ; + void* data[kMaxEvents] ; } ; typedef struct wxMacNotificationEvents wxMacNotificationEvents ; @@ -32,43 +32,43 @@ ProcessSerialNumber gAppProcess ; void wxMacWakeUp() { - ProcessSerialNumber psn ; - Boolean isSame ; - psn.highLongOfPSN = 0 ; - psn.lowLongOfPSN = kCurrentProcess ; - SameProcess( &gAppProcess , &psn , &isSame ) ; - if ( isSame ) - { + ProcessSerialNumber psn ; + Boolean isSame ; + psn.highLongOfPSN = 0 ; + psn.lowLongOfPSN = kCurrentProcess ; + SameProcess( &gAppProcess , &psn , &isSame ) ; + if ( isSame ) + { #if TARGET_CARBON - EventRef dummyEvent ; - OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(), + EventRef dummyEvent ; + OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(), kEventAttributeNone, &dummyEvent); if (err == noErr) { - err = PostEventToQueue(GetMainEventQueue(), dummyEvent, + err = PostEventToQueue(GetMainEventQueue(), dummyEvent, kEventPriorityHigh); } #else - PostEvent( nullEvent , 0 ) ; + PostEvent( nullEvent , 0 ) ; #endif - } - else - { - WakeUpProcess( &gAppProcess ) ; - } + } + else + { + WakeUpProcess( &gAppProcess ) ; + } } void wxMacCreateNotifierTable() { - GetCurrentProcess(&gAppProcess); - gMacNotificationEvents.top = 0 ; - gMacNotificationEvents.bottom = 0 ; - for ( int i = 0 ; i < kMaxEvents ; ++i ) - { - gMacNotificationEvents.proc[i] = NULL ; - gMacNotificationEvents.events[i] = NULL ; - gMacNotificationEvents.data[i] = NULL ; - } + GetCurrentProcess(&gAppProcess); + gMacNotificationEvents.top = 0 ; + gMacNotificationEvents.bottom = 0 ; + for ( int i = 0 ; i < kMaxEvents ; ++i ) + { + gMacNotificationEvents.proc[i] = NULL ; + gMacNotificationEvents.events[i] = NULL ; + gMacNotificationEvents.data[i] = NULL ; + } } void wxMacDestroyNotifierTable() @@ -77,86 +77,86 @@ void wxMacDestroyNotifierTable() wxMacNotifierTableRef wxMacGetNotifierTable() { - return (wxMacNotifierTableRef) &gMacNotificationEvents ; + return (wxMacNotifierTableRef) &gMacNotificationEvents ; } void wxMacAddEvent( - wxMacNotifierTableRef table , - wxMacNotificationProcPtr handler , - unsigned long event , - void* data , - short wakeUp ) + wxMacNotifierTableRef table , + wxMacNotificationProcPtr handler , + unsigned long event , + void* data , + short wakeUp ) { - wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; - wxASSERT_MSG( handler != NULL , "illegal notification proc ptr" ) ; - /* this should be protected eventually */ - short index = e->top++ ; - - if ( e->top == kMaxEvents ) - e->top = 0 ; - - e->proc[index] = handler ; - e->events[index] = event ; - e->data[index] = data ; - if ( wakeUp ) - wxMacWakeUp() ; + wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; + wxASSERT_MSG( handler != NULL , "illegal notification proc ptr" ) ; + /* this should be protected eventually */ + short index = e->top++ ; + + if ( e->top == kMaxEvents ) + e->top = 0 ; + + e->proc[index] = handler ; + e->events[index] = event ; + e->data[index] = data ; + if ( wakeUp ) + wxMacWakeUp() ; } bool gInProcessing = false ; void wxMacRemoveAllNotifiersForData( wxMacNotifierTableRef table , void* data ) { - wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; - /* this should be protected eventually */ - short index = e->bottom ; - - while ( e->top != index ) - { - if ( index == kMaxEvents ) - index = 0 ; - if ( e->data[index] == data ) - e->data[index] = NULL ; - index++ ; - } + wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; + /* this should be protected eventually */ + short index = e->bottom ; + + while ( e->top != index ) + { + if ( index == kMaxEvents ) + index = 0 ; + if ( e->data[index] == data ) + e->data[index] = NULL ; + index++ ; + } } void wxMacProcessNotifierEvents() { -// if ( gInProcessing ) -// return ; - - gInProcessing = true ; - if ( gMacNotificationEvents.top != gMacNotificationEvents.bottom ) - { - // we only should process the notifiers that were here when we entered it - // otherwise we might never get out... - short count = gMacNotificationEvents.top - gMacNotificationEvents.bottom ; - if ( count < 0 ) - count += kMaxEvents ; - - while ( count-- ) + // if ( gInProcessing ) + // return ; + + gInProcessing = true ; + if ( gMacNotificationEvents.top != gMacNotificationEvents.bottom ) { - // consume event at bottom - short index = gMacNotificationEvents.bottom++ ; - if ( gMacNotificationEvents.bottom == kMaxEvents ) - gMacNotificationEvents.bottom = 0 ; - void* data = gMacNotificationEvents.data[index] ; - unsigned long event = gMacNotificationEvents.events[index] ; - wxMacNotificationProcPtr handler = gMacNotificationEvents.proc[index] ; - - gMacNotificationEvents.data[index] = NULL ; - gMacNotificationEvents.events[index] = NULL ; - gMacNotificationEvents.proc[index] = NULL ; + // we only should process the notifiers that were here when we entered it + // otherwise we might never get out... + short count = gMacNotificationEvents.top - gMacNotificationEvents.bottom ; + if ( count < 0 ) + count += kMaxEvents ; - if ( handler ) - handler( event , data ) ; - } - } - gInProcessing = false ; + while ( count-- ) + { + // consume event at bottom + short index = gMacNotificationEvents.bottom++ ; + if ( gMacNotificationEvents.bottom == kMaxEvents ) + gMacNotificationEvents.bottom = 0 ; + void* data = gMacNotificationEvents.data[index] ; + unsigned long event = gMacNotificationEvents.events[index] ; + wxMacNotificationProcPtr handler = gMacNotificationEvents.proc[index] ; + + gMacNotificationEvents.data[index] = NULL ; + gMacNotificationEvents.events[index] = NULL ; + gMacNotificationEvents.proc[index] = NULL ; + + if ( handler ) + handler( event , data ) ; + } + } + gInProcessing = false ; } void wxMacProcessNotifierAndPendingEvents() { - wxMacProcessNotifierEvents() ; - wxTheApp->ProcessPendingEvents() ; + wxMacProcessNotifierEvents() ; + wxTheApp->ProcessPendingEvents() ; } diff --git a/src/mac/carbon/main.cpp b/src/mac/carbon/main.cpp index e2cb64e8f5..724d53723d 100644 --- a/src/mac/carbon/main.cpp +++ b/src/mac/carbon/main.cpp @@ -6,13 +6,13 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/app.h" WXDLLEXPORT int main(int argc, char* argv[]) { - return wxEntry(argc, argv); + return wxEntry(argc, argv); } diff --git a/src/mac/carbon/mdi.cpp b/src/mac/carbon/mdi.cpp index 9c9a725b48..1d9e43f170 100644 --- a/src/mac/carbon/mdi.cpp +++ b/src/mac/carbon/mdi.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -71,33 +71,33 @@ bool wxMDIParentFrame::Create(wxWindow *parent, long style, const wxString& name) { - m_clientWindow = NULL; - m_currentChild = NULL; - - // this style can be used to prevent a window from having the standard MDI - // "Window" menu - if ( style & wxFRAME_NO_WINDOW_MENU ) - { - m_windowMenu = (wxMenu *)NULL; - style -= wxFRAME_NO_WINDOW_MENU ; - } - else // normal case: we have the window menu, so construct it - { - m_windowMenu = new wxMenu; - - m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade")); - m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally")); - m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically")); - m_windowMenu->AppendSeparator(); - m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons")); - m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next")); - } - - wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ; - m_parentFrameActive = TRUE; + m_clientWindow = NULL; + m_currentChild = NULL; + + // this style can be used to prevent a window from having the standard MDI + // "Window" menu + if ( style & wxFRAME_NO_WINDOW_MENU ) + { + m_windowMenu = (wxMenu *)NULL; + style -= wxFRAME_NO_WINDOW_MENU ; + } + else // normal case: we have the window menu, so construct it + { + m_windowMenu = new wxMenu; - OnCreateClient(); - + m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade")); + m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally")); + m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically")); + m_windowMenu->AppendSeparator(); + m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons")); + m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next")); + } + + wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ; + m_parentFrameActive = TRUE; + + OnCreateClient(); + return TRUE; } @@ -108,13 +108,13 @@ wxMDIParentFrame::~wxMDIParentFrame() m_frameToolBar = NULL; m_frameStatusBar = NULL; m_clientWindow = NULL ; - + if (m_windowMenu) { delete m_windowMenu; m_windowMenu = (wxMenu*) NULL; } - + if ( m_clientWindow ) { delete m_clientWindow; @@ -126,51 +126,51 @@ wxMDIParentFrame::~wxMDIParentFrame() // Get size *available for subwindows* i.e. excluding menu bar. void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const { - wxDisplaySize( x , y ) ; + wxDisplaySize( x , y ) ; } void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar) { - wxFrame::SetMenuBar( menu_bar ) ; + wxFrame::SetMenuBar( menu_bar ) ; } void wxMDIParentFrame::OnSize(wxSizeEvent& event) { #if wxUSE_CONSTRAINTS if (GetAutoLayout()) - Layout(); + Layout(); #endif int x = 0; int y = 0; int width, height; GetClientSize(&width, &height); - + if ( GetClientWindow() ) GetClientWindow()->SetSize(x, y, width, height); } void wxMDIParentFrame::OnActivate(wxActivateEvent& event) { - if ( m_currentChild && event.GetActive() ) - { - wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); - event.SetEventObject( m_currentChild ); - m_currentChild->GetEventHandler()->ProcessEvent(event) ; - } - else if ( event.GetActive() ) - { - if ( m_frameMenuBar != NULL ) - { - m_frameMenuBar->MacInstallMenuBar() ; - } - - } + if ( m_currentChild && event.GetActive() ) + { + wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); + event.SetEventObject( m_currentChild ); + m_currentChild->GetEventHandler()->ProcessEvent(event) ; + } + else if ( event.GetActive() ) + { + if ( m_frameMenuBar != NULL ) + { + m_frameMenuBar->MacInstallMenuBar() ; + } + + } } // Returns the active MDI child window wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { - return m_currentChild ; + return m_currentChild ; } // Create the client window class (don't Create the window, @@ -185,7 +185,7 @@ wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) { // TODO - + // Propagate the event to the non-top-level children wxFrame::OnSysColourChanged(event); } @@ -227,27 +227,27 @@ void wxMDIChildFrame::Init() } bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) + wxWindowID id, + const wxString& title, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) { SetName(name); - + if ( id > -1 ) m_windowId = id; else m_windowId = (int)NewControlId(); - + if (parent) parent->AddChild(this); - - MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; - - m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; - SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; - + + MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; + + m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; + SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; + wxModelessWindows.Append(this); return FALSE; } @@ -262,7 +262,7 @@ wxMDIChildFrame::~wxMDIChildFrame() void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) { - return wxFrame::SetMenuBar( menu_bar ) ; + return wxFrame::SetMenuBar( menu_bar ) ; } // MDI operations @@ -295,15 +295,15 @@ wxMDIClientWindow::~wxMDIClientWindow() bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) { - + m_windowId = (int)NewControlId(); - + if ( parent ) { - parent->AddChild(this); + parent->AddChild(this); } m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); - + wxModelessWindows.Append(this); return TRUE; } diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index a5fe24d23b..1d3195a6a7 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -6,10 +6,9 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// - #ifdef __GNUG__ #pragma implementation "menu.h" #pragma implementation "menuitem.h" @@ -70,8 +69,8 @@ void wxMenu::Init() m_startRadioGroup = -1; // create the menu - m_macMenuId = s_macNextMenuId++; - m_hMenu = UMANewMenu(m_macMenuId, m_title); + m_macMenuId = s_macNextMenuId++; + m_hMenu = UMANewMenu(m_macMenuId, m_title); if ( !m_hMenu ) { @@ -88,13 +87,13 @@ void wxMenu::Init() wxMenu::~wxMenu() { - if (MAC_WXHMENU(m_hMenu)) - ::DisposeMenu(MAC_WXHMENU(m_hMenu)); + if (MAC_WXHMENU(m_hMenu)) + ::DisposeMenu(MAC_WXHMENU(m_hMenu)); } void wxMenu::Break() { - // not available on the mac platform + // not available on the mac platform } void wxMenu::Attach(wxMenuBarBase *menubar) @@ -110,60 +109,60 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) { wxASSERT_MSG( pItem != NULL, "can't append NULL item to the menu" ); - if ( pItem->IsSeparator() ) - { - if ( pos == (size_t)-1 ) - MacAppendMenu(MAC_WXHMENU(m_hMenu), "\p-"); - else - MacInsertMenuItem(MAC_WXHMENU(m_hMenu), "\p-" , pos); - } - else - { - wxMenu *pSubMenu = pItem->GetSubMenu() ; - if ( pSubMenu != NULL ) - { - wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added"); - pSubMenu->m_menuParent = this ; - - if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar) - ::InsertMenu( MAC_WXHMENU( pSubMenu->m_hMenu ) , -1 ) ; - - if ( pos == (size_t)-1 ) - UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), pSubMenu->m_macMenuId); - else - UMAInsertSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText() , pos, pSubMenu->m_macMenuId); - pItem->UpdateItemBitmap() ; - pItem->UpdateItemStatus() ; - } - else - { - if ( pos == (size_t)-1 ) - { - UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), "a" ); - pos = CountMenuItems(MAC_WXHMENU(m_hMenu)) ; - } - else - { - UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), "a" , pos); - } - - SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , pItem->GetId() ) ; - pItem->UpdateItemText() ; - pItem->UpdateItemBitmap() ; - pItem->UpdateItemStatus() ; - - if ( pItem->GetId() == idMenuTitle ) - { - UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , pos , false ) ; - } - } - } + if ( pItem->IsSeparator() ) + { + if ( pos == (size_t)-1 ) + MacAppendMenu(MAC_WXHMENU(m_hMenu), "\p-"); + else + MacInsertMenuItem(MAC_WXHMENU(m_hMenu), "\p-" , pos); + } + else + { + wxMenu *pSubMenu = pItem->GetSubMenu() ; + if ( pSubMenu != NULL ) + { + wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added"); + pSubMenu->m_menuParent = this ; + + if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar) + ::InsertMenu( MAC_WXHMENU( pSubMenu->m_hMenu ) , -1 ) ; + + if ( pos == (size_t)-1 ) + UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), pSubMenu->m_macMenuId); + else + UMAInsertSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText() , pos, pSubMenu->m_macMenuId); + pItem->UpdateItemBitmap() ; + pItem->UpdateItemStatus() ; + } + else + { + if ( pos == (size_t)-1 ) + { + UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), "a" ); + pos = CountMenuItems(MAC_WXHMENU(m_hMenu)) ; + } + else + { + UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), "a" , pos); + } + + SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , pItem->GetId() ) ; + pItem->UpdateItemText() ; + pItem->UpdateItemBitmap() ; + pItem->UpdateItemStatus() ; + + if ( pItem->GetId() == idMenuTitle ) + { + UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , pos , false ) ; + } + } + } // if we're already attached to the menubar, we must update it if ( IsAttached() ) { m_menuBar->Refresh(); } - return TRUE ; + return TRUE ; } void wxMenu::EndRadioGroup() @@ -250,7 +249,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) // DoRemove() (unlike Remove) can only be called for existing item! wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") ); - ::DeleteMenuItem(MAC_WXHMENU(m_hMenu) , pos + 1); + ::DeleteMenuItem(MAC_WXHMENU(m_hMenu) , pos + 1); if ( IsAttached() ) { @@ -264,8 +263,8 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) void wxMenu::SetTitle(const wxString& label) { - m_title = label ; - UMASetMenuTitle(MAC_WXHMENU(m_hMenu) , label ) ; + m_title = label ; + UMASetMenuTitle(MAC_WXHMENU(m_hMenu) , label ) ; } bool wxMenu::ProcessCommand(wxCommandEvent & event) { @@ -324,11 +323,11 @@ int wxMenu::MacGetIndexFromId( int id ) node = node->GetNext(); } - + if (!node) - return 0; - - return pos + 1 ; + return 0; + + return pos + 1 ; } int wxMenu::MacGetIndexFromItem( wxMenuItem *pItem ) @@ -344,16 +343,16 @@ int wxMenu::MacGetIndexFromItem( wxMenuItem *pItem ) } if (!node) - return 0; - - return pos + 1 ; + return 0; + + return pos + 1 ; } void wxMenu::MacEnableMenu( bool bDoEnable ) { - UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , 0 , bDoEnable ) ; - - ::DrawMenuBar() ; + UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , 0 , bDoEnable ) ; + + ::DrawMenuBar() ; } // Menu Bar @@ -412,11 +411,11 @@ wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[]) wxMenuBar::~wxMenuBar() { - if (s_macInstalledMenuBar == this) - { - ::ClearMenuBar(); - s_macInstalledMenuBar = NULL; - } + if (s_macInstalledMenuBar == this) + { + ::ClearMenuBar(); + s_macInstalledMenuBar = NULL; + } } @@ -431,9 +430,9 @@ void wxMenuBar::MacInstallMenuBar() { if ( s_macInstalledMenuBar == this ) return ; - + wxStAppResource resload ; - + Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ; wxString message ; wxCHECK_RET( menubar != NULL, "can't read MBAR resource" ); @@ -453,142 +452,142 @@ void wxMenuBar::MacInstallMenuBar() #endif // clean-up the help menu before adding new items - MenuHandle mh = NULL ; - if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr ) - { - for ( int i = CountMenuItems( mh ) ; i >= firstUserHelpMenuItem ; --i ) - { - DeleteMenuItem( mh , i ) ; - } - } - else - { - mh = NULL ; - } + MenuHandle mh = NULL ; + if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr ) + { + for ( int i = CountMenuItems( mh ) ; i >= firstUserHelpMenuItem ; --i ) + { + DeleteMenuItem( mh , i ) ; + } + } + else + { + mh = NULL ; + } #if TARGET_CARBON - if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId) - { - wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ; - if ( item == NULL || !(item->IsEnabled()) ) - DisableMenuCommand( NULL , kHICommandPreferences ) ; - else - EnableMenuCommand( NULL , kHICommandPreferences ) ; - } + if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId) + { + wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ; + if ( item == NULL || !(item->IsEnabled()) ) + DisableMenuCommand( NULL , kHICommandPreferences ) ; + else + EnableMenuCommand( NULL , kHICommandPreferences ) ; + } #endif - for (size_t i = 0; i < m_menus.GetCount(); i++) - { - Str255 label; + for (size_t i = 0; i < m_menus.GetCount(); i++) + { + Str255 label; wxMenuItemList::Node *node; wxMenuItem *item; int pos ; - wxMenu* menu = m_menus[i] , *subMenu = NULL ; - - if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) - { - if ( mh == NULL ) - { - continue ; - } - - for (pos = 0 , node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) - { - item = (wxMenuItem *)node->GetData(); - subMenu = item->GetSubMenu() ; - if (subMenu) - { - // we don't support hierarchical menus in the help menu yet - } - else - { - if ( item->IsSeparator() ) - { - if ( mh ) - MacAppendMenu(mh, "\p-" ); - } - else - { - wxAcceleratorEntry* entry = wxGetAccelFromString( item->GetText() ) ; - - if ( item->GetId() == wxApp::s_macAboutMenuItemId ) - { - UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetText() ); - UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true ); - SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetId() ) ; - UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ; - } - else - { - if ( mh ) - { - UMAAppendMenuItem(mh, item->GetText() , entry ); - SetMenuItemCommandID( mh , CountMenuItems(mh) , item->GetId() ) ; - } - } - - delete entry ; - } - } - } - } - else - { - UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ; - wxArrayPtrVoid submenus ; - wxMenuItem* previousItem = NULL ; - for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) - { - item = (wxMenuItem *)node->GetData(); - subMenu = item->GetSubMenu() ; - if (subMenu) - { - submenus.Add(subMenu) ; - } - else - { + wxMenu* menu = m_menus[i] , *subMenu = NULL ; + + if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) + { + if ( mh == NULL ) + { + continue ; + } + + for (pos = 0 , node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) + { + item = (wxMenuItem *)node->GetData(); + subMenu = item->GetSubMenu() ; + if (subMenu) + { + // we don't support hierarchical menus in the help menu yet + } + else + { + if ( item->IsSeparator() ) + { + if ( mh ) + MacAppendMenu(mh, "\p-" ); + } + else + { + wxAcceleratorEntry* entry = wxGetAccelFromString( item->GetText() ) ; + + if ( item->GetId() == wxApp::s_macAboutMenuItemId ) + { + UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetText() ); + UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true ); + SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetId() ) ; + UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ; + } + else + { + if ( mh ) + { + UMAAppendMenuItem(mh, item->GetText() , entry ); + SetMenuItemCommandID( mh , CountMenuItems(mh) , item->GetId() ) ; + } + } + + delete entry ; + } + } + } + } + else + { + UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ; + wxArrayPtrVoid submenus ; + wxMenuItem* previousItem = NULL ; + for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) + { + item = (wxMenuItem *)node->GetData(); + subMenu = item->GetSubMenu() ; + if (subMenu) + { + submenus.Add(subMenu) ; + } + else + { #if TARGET_CARBON - if ( UMAGetSystemVersion() >= 0x1000 ) - { - if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId) - { - ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 ); - if ( menu->GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() ) - { - ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos , kMenuItemAttrHidden, 0 ); - } - } - } -#endif - } - previousItem = item ; - } - ::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0); - for ( size_t i = 0 ; i < submenus.GetCount() ; ++i ) - { - wxMenu* submenu = (wxMenu*) submenus[i] ; - wxMenuItemList::Node *subnode; - wxMenuItem *subitem; - int subpos ; + if ( UMAGetSystemVersion() >= 0x1000 ) + { + if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId) + { + ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 ); + if ( menu->GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() ) + { + ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos , kMenuItemAttrHidden, 0 ); + } + } + } +#endif + } + previousItem = item ; + } + ::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0); + for ( size_t i = 0 ; i < submenus.GetCount() ; ++i ) + { + wxMenu* submenu = (wxMenu*) submenus[i] ; + wxMenuItemList::Node *subnode; + wxMenuItem *subitem; + int subpos ; for ( subpos = 0 , subnode = submenu->GetMenuItems().GetFirst(); subnode; subnode = subnode->GetNext(), subpos++) - { - subitem = (wxMenuItem *)subnode->GetData(); - wxMenu* itsSubMenu = subitem->GetSubMenu() ; - if (itsSubMenu) - { - submenus.Add(itsSubMenu) ; - } - } - ::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ; - } - } - } - ::DrawMenuBar() ; - s_macInstalledMenuBar = this; + { + subitem = (wxMenuItem *)subnode->GetData(); + wxMenu* itsSubMenu = subitem->GetSubMenu() ; + if (itsSubMenu) + { + submenus.Add(itsSubMenu) ; + } + } + ::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ; + } + } + } + ::DrawMenuBar() ; + s_macInstalledMenuBar = this; } void wxMenuBar::EnableTop(size_t pos, bool enable) { wxCHECK_RET( IsAttached(), wxT("doesn't work with unattached menubars") ); - m_menus[pos]->MacEnableMenu( enable ) ; + m_menus[pos]->MacEnableMenu( enable ) ; Refresh(); } @@ -604,11 +603,11 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) } m_menus[pos]->SetTitle( label ) ; - if (wxMenuBar::s_macInstalledMenuBar == this) // are we currently installed ? - { - ::SetMenuBar( GetMenuBar() ) ; - ::InvalMenuBar() ; - } + if (wxMenuBar::s_macInstalledMenuBar == this) // are we currently installed ? + { + ::SetMenuBar( GetMenuBar() ) ; + ::InvalMenuBar() ; + } } wxString wxMenuBar::GetLabelTop(size_t pos) const @@ -653,21 +652,21 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) if ( IsAttached() ) { - if (s_macInstalledMenuBar == this) - { - ::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; - { - UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; - if ( pos == m_menus.GetCount() - 1) - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; - } - else - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ; - } - } - } + if (s_macInstalledMenuBar == this) + { + ::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; + { + UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; + if ( pos == m_menus.GetCount() - 1) + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; + } + else + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ; + } + } + } Refresh(); } @@ -682,18 +681,18 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) m_titles.Insert(title, pos); - UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; + UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; if ( IsAttached() ) { - if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() ) - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; - } - else - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ; - } + if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() ) + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; + } + else + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ; + } Refresh(); } @@ -708,10 +707,10 @@ wxMenu *wxMenuBar::Remove(size_t pos) if ( IsAttached() ) { - if (s_macInstalledMenuBar == this) - { - ::DeleteMenu( menu->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; - } + if (s_macInstalledMenuBar == this) + { + ::DeleteMenu( menu->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; + } menu->Detach(); @@ -733,14 +732,14 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) m_titles.Add(title); - UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; + UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; if ( IsAttached() ) { - if (s_macInstalledMenuBar == this) - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; - } + if (s_macInstalledMenuBar == this) + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; + } Refresh(); } diff --git a/src/mac/carbon/menuitem.cpp b/src/mac/carbon/menuitem.cpp index 423440458c..ce04c08eda 100644 --- a/src/mac/carbon/menuitem.cpp +++ b/src/mac/carbon/menuitem.cpp @@ -66,144 +66,144 @@ wxMenuItem::~wxMenuItem() void wxMenuItem::SetBitmap(const wxBitmap& bitmap) { - m_bitmap = bitmap; - UpdateItemBitmap() ; + m_bitmap = bitmap; + UpdateItemBitmap() ; } void wxMenuItem::UpdateItemBitmap() { - if ( !m_parentMenu ) - return ; - - MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; - MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; - if( mhandle == NULL || index == 0) - return ; - - if ( m_bitmap.Ok() ) - { - ControlButtonContentInfo info ; - wxMacCreateBitmapButton( &info , m_bitmap , kControlContentCIconHandle ) ; - if ( info.contentType != kControlNoContent ) - { - if ( info.contentType == kControlContentCIconHandle ) - SetMenuItemIconHandle( mhandle , index , - kMenuColorIconType , (Handle) info.u.cIconHandle ) ; - } - - } + if ( !m_parentMenu ) + return ; + + MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; + MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; + if( mhandle == NULL || index == 0) + return ; + + if ( m_bitmap.Ok() ) + { + ControlButtonContentInfo info ; + wxMacCreateBitmapButton( &info , m_bitmap , kControlContentCIconHandle ) ; + if ( info.contentType != kControlNoContent ) + { + if ( info.contentType == kControlContentCIconHandle ) + SetMenuItemIconHandle( mhandle , index , + kMenuColorIconType , (Handle) info.u.cIconHandle ) ; + } + + } } void wxMenuItem::UpdateItemStatus() { - if ( !m_parentMenu ) - return ; - - MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; - MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; - if( mhandle == NULL || index == 0) - return ; - - UMAEnableMenuItem( mhandle , index , m_isEnabled ) ; - if ( IsCheckable() && IsChecked() ) - ::SetItemMark( mhandle , index , 0x12 ) ; // checkmark - else - ::SetItemMark( mhandle , index , 0 ) ; // no mark - - UMASetMenuItemText( mhandle , index , m_text ) ; - wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; - UMASetMenuItemShortcut( mhandle , index , entry ) ; - delete entry ; + if ( !m_parentMenu ) + return ; + + MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; + MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; + if( mhandle == NULL || index == 0) + return ; + + UMAEnableMenuItem( mhandle , index , m_isEnabled ) ; + if ( IsCheckable() && IsChecked() ) + ::SetItemMark( mhandle , index , 0x12 ) ; // checkmark + else + ::SetItemMark( mhandle , index , 0 ) ; // no mark + + UMASetMenuItemText( mhandle , index , m_text ) ; + wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; + UMASetMenuItemShortcut( mhandle , index , entry ) ; + delete entry ; } void wxMenuItem::UpdateItemText() { - if ( !m_parentMenu ) - return ; - - MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; - MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; - if( mhandle == NULL || index == 0) - return ; - - UMASetMenuItemText( mhandle , index , m_text ) ; - wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; - UMASetMenuItemShortcut( mhandle , index , entry ) ; - delete entry ; + if ( !m_parentMenu ) + return ; + + MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; + MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; + if( mhandle == NULL || index == 0) + return ; + + UMASetMenuItemText( mhandle , index , m_text ) ; + wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; + UMASetMenuItemShortcut( mhandle , index , entry ) ; + delete entry ; } void wxMenuItem::Enable(bool bDoEnable) { - if ( m_isEnabled != bDoEnable ) - { - wxMenuItemBase::Enable( bDoEnable ) ; - UpdateItemStatus() ; - } + if ( m_isEnabled != bDoEnable ) + { + wxMenuItemBase::Enable( bDoEnable ) ; + UpdateItemStatus() ; + } } void wxMenuItem::UncheckRadio() { - if ( m_isChecked ) - { - wxMenuItemBase::Check( false ) ; - UpdateItemStatus() ; - } + if ( m_isChecked ) + { + wxMenuItemBase::Check( false ) ; + UpdateItemStatus() ; + } } void wxMenuItem::Check(bool bDoCheck) { - wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); - - if ( m_isChecked != bDoCheck ) - { - if ( GetKind() == wxITEM_RADIO ) - { - if ( bDoCheck ) - { - wxMenuItemBase::Check( bDoCheck ) ; - UpdateItemStatus() ; - - // get the index of this item in the menu - const wxMenuItemList& items = m_parentMenu->GetMenuItems(); - int pos = items.IndexOf(this); - wxCHECK_RET( pos != wxNOT_FOUND, - _T("menuitem not found in the menu items list?") ); - - // get the radio group range - int start, - end; - - if ( m_isRadioGroupStart ) - { - // we already have all information we need - start = pos; - end = m_radioGroup.end; - } - else // next radio group item - { - // get the radio group end from the start item - start = m_radioGroup.start; - end = items.Item(start)->GetData()->m_radioGroup.end; - } - - // also uncheck all the other items in this radio group - wxMenuItemList::Node *node = items.Item(start); - for ( int n = start; n <= end && node; n++ ) - { - if ( n != pos ) - { - ((wxMenuItem*)node->GetData())->UncheckRadio(); - } - node = node->GetNext(); - } - } - } - else - { - wxMenuItemBase::Check( bDoCheck ) ; - UpdateItemStatus() ; - } - } + wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); + + if ( m_isChecked != bDoCheck ) + { + if ( GetKind() == wxITEM_RADIO ) + { + if ( bDoCheck ) + { + wxMenuItemBase::Check( bDoCheck ) ; + UpdateItemStatus() ; + + // get the index of this item in the menu + const wxMenuItemList& items = m_parentMenu->GetMenuItems(); + int pos = items.IndexOf(this); + wxCHECK_RET( pos != wxNOT_FOUND, + _T("menuitem not found in the menu items list?") ); + + // get the radio group range + int start, + end; + + if ( m_isRadioGroupStart ) + { + // we already have all information we need + start = pos; + end = m_radioGroup.end; + } + else // next radio group item + { + // get the radio group end from the start item + start = m_radioGroup.start; + end = items.Item(start)->GetData()->m_radioGroup.end; + } + + // also uncheck all the other items in this radio group + wxMenuItemList::Node *node = items.Item(start); + for ( int n = start; n <= end && node; n++ ) + { + if ( n != pos ) + { + ((wxMenuItem*)node->GetData())->UncheckRadio(); + } + node = node->GetNext(); + } + } + } + else + { + wxMenuItemBase::Check( bDoCheck ) ; + UpdateItemStatus() ; + } + } } void wxMenuItem::SetText(const wxString& text) diff --git a/src/mac/carbon/metafile.cpp b/src/mac/carbon/metafile.cpp index 1d38499628..1f87cb9f4a 100644 --- a/src/mac/carbon/metafile.cpp +++ b/src/mac/carbon/metafile.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -61,7 +61,7 @@ wxMetafileRefData::~wxMetafileRefData(void) { if (m_metafile) { - KillPicture( (PicHandle) m_metafile ) ; + KillPicture( (PicHandle) m_metafile ) ; m_metafile = 0; } } @@ -86,10 +86,10 @@ wxMetaFile::~wxMetaFile() bool wxMetaFile::SetClipboard(int width, int height) { #if wxUSE_DRAG_AND_DROP -//TODO finishi this port , we need the data obj first + //TODO finishi this port , we need the data obj first if (!m_refData) return FALSE; - + bool alreadyOpen=wxTheClipboard->IsOpened() ; if (!alreadyOpen) { @@ -97,11 +97,11 @@ bool wxMetaFile::SetClipboard(int width, int height) wxTheClipboard->Clear(); } wxDataObject *data = - new wxMetafileDataObject( *this) ; + new wxMetafileDataObject( *this) ; bool success = wxTheClipboard->SetData(data); if (!alreadyOpen) - wxTheClipboard->Close(); - return (bool) success; + wxTheClipboard->Close(); + return (bool) success; #endif return TRUE ; } @@ -116,17 +116,17 @@ void wxMetafile::SetHMETAFILE(WXHMETAFILE mf) bool wxMetaFile::Play(wxDC *dc) { - if (!m_refData) - return FALSE; - - if (!dc->Ok() ) - return FALSE; - - { - wxMacPortSetter helper( dc ) ; - PicHandle pict = (PicHandle) GetHMETAFILE() ; - DrawPicture( pict , &(**pict).picFrame ) ; - } + if (!m_refData) + return FALSE; + + if (!dc->Ok() ) + return FALSE; + + { + wxMacPortSetter helper( dc ) ; + PicHandle pict = (PicHandle) GetHMETAFILE() ; + DrawPicture( pict , &(**pict).picFrame ) ; + } return TRUE; } @@ -139,22 +139,22 @@ bool wxMetaFile::Play(wxDC *dc) // *DO* give origin/extent arguments to wxMakeMetaFilePlaceable. wxMetaFileDC::wxMetaFileDC(const wxString& file) { - m_metaFile = NULL; - m_minX = 10000; - m_minY = 10000; - m_maxX = -10000; - m_maxY = -10000; - - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; - - m_metaFile = new wxMetaFile("") ; - Rect r={0,0,1000,1000} ; - - m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; - ::GetPort( (GrafPtr*) &m_macPort ) ; - m_ok = TRUE ; - - SetMapMode(wxMM_TEXT); + m_metaFile = NULL; + m_minX = 10000; + m_minY = 10000; + m_maxX = -10000; + m_maxY = -10000; + + wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + + m_metaFile = new wxMetaFile("") ; + Rect r={0,0,1000,1000} ; + + m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; + ::GetPort( (GrafPtr*) &m_macPort ) ; + m_ok = TRUE ; + + SetMapMode(wxMM_TEXT); } // New constructor that takes origin and extent. If you use this, don't @@ -162,21 +162,21 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file) wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg) { - m_minX = 10000; - m_minY = 10000; - m_maxX = -10000; - m_maxY = -10000; - - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; - - m_metaFile = new wxMetaFile("") ; - Rect r={yorg,xorg,yorg+yext,xorg+xext} ; - - m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; - ::GetPort( (GrafPtr*) &m_macPort ) ; - m_ok = TRUE ; - - SetMapMode(wxMM_TEXT); + m_minX = 10000; + m_minY = 10000; + m_maxX = -10000; + m_maxY = -10000; + + wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + + m_metaFile = new wxMetaFile("") ; + Rect r={yorg,xorg,yorg+yext,xorg+xext} ; + + m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; + ::GetPort( (GrafPtr*) &m_macPort ) ; + m_ok = TRUE ; + + SetMapMode(wxMM_TEXT); } wxMetaFileDC::~wxMetaFileDC() @@ -185,29 +185,29 @@ wxMetaFileDC::~wxMetaFileDC() wxMetaFile *wxMetaFileDC::Close() { - ClosePicture() ; - return m_metaFile; + ClosePicture() ; + return m_metaFile; } #if wxUSE_DATAOBJ size_t wxMetafileDataObject::GetDataSize() const { - return GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ; + return GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ; } bool wxMetafileDataObject::GetDataHere(void *buf) const { - memcpy( buf , (*(PicHandle)(*((wxMetafile*)&m_metafile)).GetHMETAFILE()) , - GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ) ; - return true ; + memcpy( buf , (*(PicHandle)(*((wxMetafile*)&m_metafile)).GetHMETAFILE()) , + GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ) ; + return true ; } bool wxMetafileDataObject::SetData(size_t len, const void *buf) { - Handle handle = (Handle) m_metafile.GetHMETAFILE() ; - SetHandleSize( handle , len ) ; - memcpy( *handle , buf , len ) ; - return true ; + Handle handle = (Handle) m_metafile.GetHMETAFILE() ; + SetHandleSize( handle , len ) ; + memcpy( *handle , buf , len ) ; + return true ; } #endif diff --git a/src/mac/carbon/mimetmac.cpp b/src/mac/carbon/mimetmac.cpp index 0306d07f2c..de41b17423 100644 --- a/src/mac/carbon/mimetmac.cpp +++ b/src/mac/carbon/mimetmac.cpp @@ -105,7 +105,7 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const size_t wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands, - const wxFileType::MessageParameters& params) const + const wxFileType::MessageParameters& params) const { wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") ); return 0; diff --git a/src/mac/carbon/minifram.cpp b/src/mac/carbon/minifram.cpp index 4cd78d7100..6b49b9bdc7 100644 --- a/src/mac/carbon/minifram.cpp +++ b/src/mac/carbon/minifram.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/carbon/msgdlg.cpp b/src/mac/carbon/msgdlg.cpp index c7f38f17b7..f7a4a0a724 100644 --- a/src/mac/carbon/msgdlg.cpp +++ b/src/mac/carbon/msgdlg.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -27,33 +27,33 @@ short language = 0 ; void wxMacConvertNewlines( const char *source , char * destination ) ; void wxMacConvertNewlines( const char *source , char * destination ) { - const char *s = source ; - char *d = destination ; - - while( *s ) - { - switch( *s ) - { - case 0x0a : - *d++ = 0x0d ; - ++s ; - break ; - case 0x0d : - *d++ = 0x0d ; - ++s ; - if ( *s == 0x0a ) - ++s ; - break ; - default : - *d++ = *s++ ; - break ; - } - } - *d = 0 ; + const char *s = source ; + char *d = destination ; + + while( *s ) + { + switch( *s ) + { + case 0x0a : + *d++ = 0x0d ; + ++s ; + break ; + case 0x0d : + *d++ = 0x0d ; + ++s ; + if ( *s == 0x0a ) + ++s ; + break ; + default : + *d++ = *s++ ; + break ; + } + } + *d = 0 ; } wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, - long style, const wxPoint& pos) + long style, const wxPoint& pos) { m_caption = caption; m_message = message; @@ -63,252 +63,252 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, cons int wxMessageDialog::ShowModal() { - int resultbutton = wxID_CANCEL ; - - short result ; - - wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ; - - AlertType alertType = kAlertPlainAlert ; - if (m_dialogStyle & wxICON_EXCLAMATION) - alertType = kAlertNoteAlert ; - else if (m_dialogStyle & wxICON_HAND) - alertType = kAlertStopAlert ; - else if (m_dialogStyle & wxICON_INFORMATION) - alertType = kAlertNoteAlert ; - else if (m_dialogStyle & wxICON_QUESTION) - alertType = kAlertCautionAlert ; - + int resultbutton = wxID_CANCEL ; + + short result ; + + wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ; + + AlertType alertType = kAlertPlainAlert ; + if (m_dialogStyle & wxICON_EXCLAMATION) + alertType = kAlertNoteAlert ; + else if (m_dialogStyle & wxICON_HAND) + alertType = kAlertStopAlert ; + else if (m_dialogStyle & wxICON_INFORMATION) + alertType = kAlertNoteAlert ; + else if (m_dialogStyle & wxICON_QUESTION) + alertType = kAlertCautionAlert ; + #if TARGET_CARBON - if ( UMAGetSystemVersion() >= 0x1000 ) - { - AlertStdCFStringAlertParamRec param ; - CFStringRef cfNoString = NULL ; - CFStringRef cfYesString = NULL ; - - CFStringRef cfTitle = NULL; - CFStringRef cfText = NULL; - - cfTitle = wxMacCreateCFString( m_caption ) ; - cfText = wxMacCreateCFString( m_message ) ; - cfNoString = wxMacCreateCFString( _("No") ) ; - cfYesString = wxMacCreateCFString( _("Yes") ) ; - - param.movable = true; - param.flags = 0 ; - - bool skipDialog = false ; - - if (m_dialogStyle & wxYES_NO) - { - if (m_dialogStyle & wxCANCEL) - { - param.defaultText = cfYesString ; - param.cancelText = (CFStringRef) kAlertDefaultCancelText; - param.otherText = cfNoString ; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = kAlertStdAlertCancelButton; - } - else - { - param.defaultText = cfYesString ; - param.cancelText = NULL; - param.otherText = cfNoString ; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - } - else if (m_dialogStyle & wxOK) - { - if (m_dialogStyle & wxCANCEL) - { - // thats a cancel missing - param.defaultText = (CFStringRef) kAlertDefaultOKText ; - param.cancelText = NULL; - param.otherText = NULL; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - else - { - param.defaultText = (CFStringRef) kAlertDefaultOKText ; - param.cancelText = NULL; - param.otherText = NULL; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - } - else - { - skipDialog = true ; - } - - param.position = kWindowDefaultPosition; - if ( !skipDialog ) - { - DialogRef alertRef ; - CreateStandardAlert( alertType , cfTitle , cfText , ¶m , &alertRef ) ; - RunStandardAlert( alertRef , NULL , &result ) ; - } - if(cfTitle != NULL) - CFRelease(cfTitle); - if(cfText != NULL) - CFRelease(cfText); - if(cfNoString != NULL) - CFRelease(cfNoString); - if(cfYesString != NULL) - CFRelease(cfYesString); - if ( skipDialog ) - return wxID_CANCEL ; - } - else + if ( UMAGetSystemVersion() >= 0x1000 ) + { + AlertStdCFStringAlertParamRec param ; + CFStringRef cfNoString = NULL ; + CFStringRef cfYesString = NULL ; + + CFStringRef cfTitle = NULL; + CFStringRef cfText = NULL; + + cfTitle = wxMacCreateCFString( m_caption ) ; + cfText = wxMacCreateCFString( m_message ) ; + cfNoString = wxMacCreateCFString( _("No") ) ; + cfYesString = wxMacCreateCFString( _("Yes") ) ; + + param.movable = true; + param.flags = 0 ; + + bool skipDialog = false ; + + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + param.defaultText = cfYesString ; + param.cancelText = (CFStringRef) kAlertDefaultCancelText; + param.otherText = cfNoString ; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = kAlertStdAlertCancelButton; + } + else + { + param.defaultText = cfYesString ; + param.cancelText = NULL; + param.otherText = cfNoString ; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + } + else if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + { + // thats a cancel missing + param.defaultText = (CFStringRef) kAlertDefaultOKText ; + param.cancelText = NULL; + param.otherText = NULL; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + else + { + param.defaultText = (CFStringRef) kAlertDefaultOKText ; + param.cancelText = NULL; + param.otherText = NULL; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + } + else + { + skipDialog = true ; + } + + param.position = kWindowDefaultPosition; + if ( !skipDialog ) + { + DialogRef alertRef ; + CreateStandardAlert( alertType , cfTitle , cfText , ¶m , &alertRef ) ; + RunStandardAlert( alertRef , NULL , &result ) ; + } + if(cfTitle != NULL) + CFRelease(cfTitle); + if(cfText != NULL) + CFRelease(cfText); + if(cfNoString != NULL) + CFRelease(cfNoString); + if(cfYesString != NULL) + CFRelease(cfYesString); + if ( skipDialog ) + return wxID_CANCEL ; + } + else #endif - { - AlertStdAlertParamRec param; - char cText[2048] ; - - if (wxApp::s_macDefaultEncodingIsPC) - { - strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ; - } - else - { - strcpy( cText , m_message ) ; - } - wxMacConvertNewlines( cText , cText ) ; - - Str255 yesPString ; - Str255 noPString ; - - Str255 pascalTitle ; - Str255 pascalText ; - wxMacStringToPascal( m_caption , pascalTitle ) ; - wxMacStringToPascal( _("Yes") , yesPString ) ; - wxMacStringToPascal( _("No") , noPString ) ; - CopyCStringToPascal( cText , pascalText ) ; - - param.movable = true; - param.filterProc = NULL ; - if (m_dialogStyle & wxYES_NO) - { - if (m_dialogStyle & wxCANCEL) - { - param.defaultText = yesPString ; - param.cancelText = (StringPtr) kAlertDefaultCancelText; - param.otherText = noPString ; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = kAlertStdAlertCancelButton; - } - else - { - param.defaultText = yesPString ; - param.cancelText = NULL; - param.otherText = noPString ; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - } - else if (m_dialogStyle & wxOK) - { - if (m_dialogStyle & wxCANCEL) - { - // thats a cancel missing - param.defaultText = (StringPtr) kAlertDefaultOKText ; - param.cancelText = NULL; - param.otherText = NULL; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - else - { - param.defaultText = (StringPtr) kAlertDefaultOKText ; - param.cancelText = NULL; - param.otherText = NULL; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - } - else - { - return resultbutton ; - } - - param.position = 0; - - StandardAlert( alertType, pascalTitle, pascalText, ¶m, &result ); - } - - if (m_dialogStyle & wxOK) - { - if (m_dialogStyle & wxCANCEL) - { - //TODO add Cancelbutton - switch( result ) - { - case 1 : - resultbutton = wxID_OK ; - break ; - case 2 : - break ; - case 3 : - break ; - } - } - else - { - switch( result ) - { - case 1 : - resultbutton = wxID_OK ; - break ; - case 2 : - break ; - case 3 : - break ; - } - } - } - else if (m_dialogStyle & wxYES_NO) - { - if (m_dialogStyle & wxCANCEL) - { - switch( result ) - { - case 1 : - resultbutton = wxID_YES ; - break ; - case 2 : - resultbutton = wxID_CANCEL ; - break ; - case 3 : - resultbutton = wxID_NO ; - break ; - } - } - else - { - switch( result ) - { - case 1 : - resultbutton = wxID_YES ; - break ; - case 2 : - break ; - case 3 : - resultbutton = wxID_NO ; - break ; - } - } - } - - return resultbutton ; + { + AlertStdAlertParamRec param; + char cText[2048] ; + + if (wxApp::s_macDefaultEncodingIsPC) + { + strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ; + } + else + { + strcpy( cText , m_message ) ; + } + wxMacConvertNewlines( cText , cText ) ; + + Str255 yesPString ; + Str255 noPString ; + + Str255 pascalTitle ; + Str255 pascalText ; + wxMacStringToPascal( m_caption , pascalTitle ) ; + wxMacStringToPascal( _("Yes") , yesPString ) ; + wxMacStringToPascal( _("No") , noPString ) ; + CopyCStringToPascal( cText , pascalText ) ; + + param.movable = true; + param.filterProc = NULL ; + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + param.defaultText = yesPString ; + param.cancelText = (StringPtr) kAlertDefaultCancelText; + param.otherText = noPString ; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = kAlertStdAlertCancelButton; + } + else + { + param.defaultText = yesPString ; + param.cancelText = NULL; + param.otherText = noPString ; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + } + else if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + { + // thats a cancel missing + param.defaultText = (StringPtr) kAlertDefaultOKText ; + param.cancelText = NULL; + param.otherText = NULL; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + else + { + param.defaultText = (StringPtr) kAlertDefaultOKText ; + param.cancelText = NULL; + param.otherText = NULL; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + } + else + { + return resultbutton ; + } + + param.position = 0; + + StandardAlert( alertType, pascalTitle, pascalText, ¶m, &result ); + } + + if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + { + //TODO add Cancelbutton + switch( result ) + { + case 1 : + resultbutton = wxID_OK ; + break ; + case 2 : + break ; + case 3 : + break ; + } + } + else + { + switch( result ) + { + case 1 : + resultbutton = wxID_OK ; + break ; + case 2 : + break ; + case 3 : + break ; + } + } + } + else if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + switch( result ) + { + case 1 : + resultbutton = wxID_YES ; + break ; + case 2 : + resultbutton = wxID_CANCEL ; + break ; + case 3 : + resultbutton = wxID_NO ; + break ; + } + } + else + { + switch( result ) + { + case 1 : + resultbutton = wxID_YES ; + break ; + case 2 : + break ; + case 3 : + resultbutton = wxID_NO ; + break ; + } + } + } + + return resultbutton ; } diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index 6ba640fe91..33c40fe448 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -10,7 +10,7 @@ /////////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ - #pragma implementation "notebook.h" +#pragma implementation "notebook.h" #endif // ============================================================================ @@ -35,10 +35,10 @@ static bool constantsSet = false ; - short kwxMacTabLeftMargin = 0 ; - short kwxMacTabTopMargin = 0 ; - short kwxMacTabRightMargin = 0 ; - short kwxMacTabBottomMargin = 0 ; +short kwxMacTabLeftMargin = 0 ; +short kwxMacTabTopMargin = 0 ; +short kwxMacTabRightMargin = 0 ; +short kwxMacTabBottomMargin = 0 ; // ---------------------------------------------------------------------------- // event table @@ -49,12 +49,12 @@ 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_MOUSE_EVENTS(wxNotebook::OnMouse) - - EVT_SIZE(wxNotebook::OnSize) - EVT_SET_FOCUS(wxNotebook::OnSetFocus) - EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) +EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) +EVT_MOUSE_EVENTS(wxNotebook::OnMouse) + +EVT_SIZE(wxNotebook::OnSize) +EVT_SET_FOCUS(wxNotebook::OnSetFocus) +EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) @@ -76,7 +76,7 @@ void wxNotebook::Init() { if ( UMAHasAquaLayout() ) { - // I got these values for Mac OS X from the Appearance mgr docs. (Mark Newsam) + // I got these values for Mac OS X from the Appearance mgr docs. (Mark Newsam) kwxMacTabLeftMargin = 20 ; kwxMacTabTopMargin = 38 ; kwxMacTabRightMargin = 20 ; @@ -96,7 +96,7 @@ void wxNotebook::Init() m_macHorizontalBorder = 7; m_macVerticalBorder = 8; } - + m_nSelection = -1; } @@ -115,7 +115,7 @@ wxNotebook::wxNotebook(wxWindow *parent, const wxString& name) { Init(); - + Create(parent, id, pos, size, style, name); } @@ -127,31 +127,31 @@ bool wxNotebook::Create(wxWindow *parent, long style, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - - int tabstyle = kControlTabSmallNorthProc ; - if ( HasFlag(wxNB_LEFT) ) - tabstyle = kControlTabSmallWestProc ; - else if ( HasFlag( wxNB_RIGHT ) ) - tabstyle = kControlTabSmallEastProc ; - else if ( HasFlag( wxNB_BOTTOM ) ) - tabstyle = kControlTabSmallSouthProc ; - - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - tabstyle , (long) this ) ; - - MacPostControlCreate() ; - return TRUE ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + + int tabstyle = kControlTabSmallNorthProc ; + if ( HasFlag(wxNB_LEFT) ) + tabstyle = kControlTabSmallWestProc ; + else if ( HasFlag( wxNB_RIGHT ) ) + tabstyle = kControlTabSmallEastProc ; + else if ( HasFlag( wxNB_BOTTOM ) ) + tabstyle = kControlTabSmallSouthProc ; + + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + tabstyle , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } // dtor wxNotebook::~wxNotebook() { - m_macControl = NULL ; + m_macControl = NULL ; } wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) @@ -162,7 +162,7 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) wxGetOsVersion( &major, &minor ); // Mac has large notebook borders. Aqua even more so. - + if ( HasFlag(wxNB_LEFT) || HasFlag(wxNB_RIGHT) ) { sizeTotal.x += 90; @@ -185,7 +185,7 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) sizeTotal.y += 44; } } - + return sizeTotal; } @@ -195,7 +195,7 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) void wxNotebook::SetPadding(const wxSize& padding) { - wxFAIL_MSG( wxT("wxNotebook::SetPadding not implemented") ); + wxFAIL_MSG( wxT("wxNotebook::SetPadding not implemented") ); } void wxNotebook::SetTabSize(const wxSize& sz) @@ -210,12 +210,12 @@ void wxNotebook::SetPageSize(const wxSize& size) int wxNotebook::SetSelection(int nPage) { - if( !IS_VALID_PAGE(nPage) ) - return m_nSelection ; - + if( !IS_VALID_PAGE(nPage) ) + return m_nSelection ; + ChangePage(m_nSelection, nPage); - SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; - + SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; + Refresh(); return m_nSelection; } @@ -223,18 +223,18 @@ int wxNotebook::SetSelection(int nPage) bool wxNotebook::SetPageText(int nPage, const wxString& strText) { wxASSERT( IS_VALID_PAGE(nPage) ); - + wxNotebookPage *page = m_pages[nPage]; page->SetLabel(strText); MacSetupTabs(); - + return true; } wxString wxNotebook::GetPageText(int nPage) const { wxASSERT( IS_VALID_PAGE(nPage) ); - + wxNotebookPage *page = m_pages[nPage]; return page->GetLabel(); } @@ -242,27 +242,27 @@ wxString wxNotebook::GetPageText(int nPage) const int wxNotebook::GetPageImage(int nPage) const { wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") ); - + return m_images[nPage]; } bool wxNotebook::SetPageImage(int nPage, int nImage) { wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("invalid notebook page") ); - + wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), FALSE, - _T("invalid image index in SetPageImage()") ); - + _T("invalid image index in SetPageImage()") ); + if ( nImage != m_images[nPage] ) { // if the item didn't have an icon before or, on the contrary, did have // it but has lost it now, its size will change - but if the icon just // changes, it won't m_images[nPage] = nImage; - - MacSetupTabs() ; + + MacSetupTabs() ; } - + return TRUE; } @@ -276,9 +276,9 @@ wxNotebookPage* wxNotebook::DoRemovePage(int nPage) wxCHECK( IS_VALID_PAGE(nPage), NULL ); wxNotebookPage* page = m_pages[nPage] ; m_pages.RemoveAt(nPage); - + MacSetupTabs(); - + if(m_nSelection >= GetPageCount()) { m_nSelection = GetPageCount() - 1; } @@ -292,10 +292,10 @@ wxNotebookPage* wxNotebook::DoRemovePage(int nPage) bool wxNotebook::DeleteAllPages() { // TODO: delete native widget pages - + WX_CLEAR_ARRAY(m_pages) ; MacSetupTabs(); - + return TRUE; } @@ -309,16 +309,16 @@ bool wxNotebook::InsertPage(int nPage, { wxASSERT( pPage != NULL ); wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE ); - + pPage->SetLabel(strText); - + // save the pointer to the page m_pages.Insert(pPage, nPage); - + m_images.Insert(imageId, nPage); - + MacSetupTabs(); - + if ( bSelect ) { m_nSelection = nPage; } @@ -330,69 +330,69 @@ bool wxNotebook::InsertPage(int nPage, } // don't show pages by default (we'll need to adjust their size first) pPage->Show( false ) ; - + int h, w; GetSize(&w, &h); pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin, - w - kwxMacTabLeftMargin - kwxMacTabRightMargin, - h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); + w - kwxMacTabLeftMargin - kwxMacTabRightMargin, + h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); if ( pPage->GetAutoLayout() ) { pPage->Layout(); } - + return true; } /* Added by Mark Newsam - * When a page is added or deleted to the notebook this function updates - * information held in the m_macControl so that it matches the order - * the user would expect. - */ +* When a page is added or deleted to the notebook this function updates +* information held in the m_macControl so that it matches the order +* the user would expect. +*/ void wxNotebook::MacSetupTabs() { SetControl32BitMaximum( (ControlHandle) m_macControl , GetPageCount() ) ; - + wxNotebookPage *page; ControlTabInfoRec info; - + for(int ii = 0; ii < GetPageCount(); ii++) { page = m_pages[ii]; info.version = 0; info.iconSuiteID = 0; #if TARGET_CARBON - c2pstrcpy( (StringPtr) info.name , page->GetLabel() ) ; + c2pstrcpy( (StringPtr) info.name , page->GetLabel() ) ; #else - strcpy( (char *) info.name , page->GetLabel() ) ; - c2pstr( (char *) info.name ) ; + strcpy( (char *) info.name , page->GetLabel() ) ; + c2pstr( (char *) info.name ) ; #endif SetControlData( (ControlHandle) m_macControl, ii+1, kControlTabInfoTag, - sizeof( ControlTabInfoRec) , (char*) &info ) ; + sizeof( ControlTabInfoRec) , (char*) &info ) ; SetTabEnabled( (ControlHandle) m_macControl , ii+1 , true ) ; - + #if TARGET_CARBON if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 ) { - // tab controls only support very specific types of images, therefore we are doing an odyssee - // accross the icon worlds (even Apple DTS did not find a shorter path) - // in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately - // afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we - // unregister it) in case this will ever lead to having the same icon everywhere add some kind - // of static counter - ControlButtonContentInfo info ; - wxMacCreateBitmapButton( &info , *GetImageList()->GetBitmap( GetPageImage(ii ) ) , kControlContentPictHandle) ; - IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ; - OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ; + // tab controls only support very specific types of images, therefore we are doing an odyssee + // accross the icon worlds (even Apple DTS did not find a shorter path) + // in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately + // afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we + // unregister it) in case this will ever lead to having the same icon everywhere add some kind + // of static counter + ControlButtonContentInfo info ; + wxMacCreateBitmapButton( &info , *GetImageList()->GetBitmap( GetPageImage(ii ) ) , kControlContentPictHandle) ; + IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ; + OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ; wxASSERT_MSG( err == noErr , "Error when adding bitmap" ) ; - IconRef iconRef ; - err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1 , iconFamily, &iconRef ) ; + IconRef iconRef ; + err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1 , iconFamily, &iconRef ) ; wxASSERT_MSG( err == noErr , "Error when adding bitmap" ) ; - info.contentType = kControlContentIconRef ; - info.u.iconRef = iconRef ; - SetControlData( (ControlHandle) m_macControl, ii+1,kControlTabImageContentTag, - sizeof( info ), (Ptr)&info ); + info.contentType = kControlContentIconRef ; + info.u.iconRef = iconRef ; + SetControlData( (ControlHandle) m_macControl, ii+1,kControlTabImageContentTag, + sizeof( info ), (Ptr)&info ); wxASSERT_MSG( err == noErr , "Error when setting icon on tab" ) ; - UnregisterIconRef( 'WXNG' , (OSType) 1 ) ; + UnregisterIconRef( 'WXNG' , (OSType) 1 ) ; ReleaseIconRef( iconRef ) ; DisposeHandle( (Handle) iconFamily ) ; } @@ -416,22 +416,22 @@ void wxNotebook::OnSize(wxSizeEvent& event) int nSel = m_nSelection; m_nSelection = -1; SetSelection(nSel); - + // fit the notebook page to the tab control's display area int w, h; GetSize(&w, &h); - + unsigned int nCount = m_pages.Count(); for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) { wxNotebookPage *pPage = m_pages[nPage]; pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin, - w - kwxMacTabLeftMargin - kwxMacTabRightMargin, - h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); + w - kwxMacTabLeftMargin - kwxMacTabRightMargin, + h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); if ( pPage->GetAutoLayout() ) { pPage->Layout(); } } - + // Processing continues to next OnSize event.Skip(); } @@ -441,7 +441,7 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event) // is it our tab control? if ( event.GetEventObject() == this ) ChangePage(event.GetOldSelection(), event.GetSelection()); - + // we want to give others a chance to process this message as well event.Skip(); } @@ -451,7 +451,7 @@ void wxNotebook::OnSetFocus(wxFocusEvent& event) // set focus to the currently selected page if any if ( m_nSelection != -1 ) m_pages[m_nSelection]->SetFocus(); - + event.Skip(); } @@ -509,93 +509,93 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) pPage->SetFocus(); return; } - + // Hide previous page if ( nOldSel != -1 ) { m_pages[nOldSel]->Show(FALSE); } - + wxNotebookPage *pPage = m_pages[nSel]; pPage->Show(TRUE); pPage->SetFocus(); - + m_nSelection = nSel; } void wxNotebook::OnMouse( wxMouseEvent &event ) { - if ( (ControlHandle) m_macControl == NULL ) - { - event.Skip() ; - return ; - } - - if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK ) - { - int x = event.m_x ; - int y = event.m_y ; - - MacClientToRootWindow( &x , &y ) ; - - ControlHandle control ; - Point localwhere ; - SInt16 controlpart ; - - localwhere.h = x ; - localwhere.v = y ; - - short modifiers = 0; - - if ( !event.m_leftDown && !event.m_rightDown ) - modifiers |= btnState ; - - if ( event.m_shiftDown ) - modifiers |= shiftKey ; - - if ( event.m_controlDown ) - modifiers |= controlKey ; - - if ( event.m_altDown ) - modifiers |= optionKey ; - - if ( event.m_metaDown ) - modifiers |= cmdKey ; - - control = (ControlHandle) m_macControl ; - if ( control && ::IsControlActive( control ) ) - { - { - wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId, - ::GetControl32BitValue(control) - 1, m_nSelection); - changing.SetEventObject(this); - ProcessEvent(changing); - - if(changing.IsAllowed()) - { - controlpart = ::HandleControlClick(control, localwhere, modifiers, - (ControlActionUPP) -1); - wxTheApp->s_lastMouseDown = 0 ; - - wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId, - ::GetControl32BitValue(control) - 1, m_nSelection); - event.SetEventObject(this); - - ProcessEvent(event); - } - } - } - } + if ( (ControlHandle) m_macControl == NULL ) + { + event.Skip() ; + return ; + } + + if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK ) + { + int x = event.m_x ; + int y = event.m_y ; + + MacClientToRootWindow( &x , &y ) ; + + ControlHandle control ; + Point localwhere ; + SInt16 controlpart ; + + localwhere.h = x ; + localwhere.v = y ; + + short modifiers = 0; + + if ( !event.m_leftDown && !event.m_rightDown ) + modifiers |= btnState ; + + if ( event.m_shiftDown ) + modifiers |= shiftKey ; + + if ( event.m_controlDown ) + modifiers |= controlKey ; + + if ( event.m_altDown ) + modifiers |= optionKey ; + + if ( event.m_metaDown ) + modifiers |= cmdKey ; + + control = (ControlHandle) m_macControl ; + if ( control && ::IsControlActive( control ) ) + { + { + wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId, + ::GetControl32BitValue(control) - 1, m_nSelection); + changing.SetEventObject(this); + ProcessEvent(changing); + + if(changing.IsAllowed()) + { + controlpart = ::HandleControlClick(control, localwhere, modifiers, + (ControlActionUPP) -1); + wxTheApp->s_lastMouseDown = 0 ; + + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId, + ::GetControl32BitValue(control) - 1, m_nSelection); + event.SetEventObject(this); + + ProcessEvent(event); + } + } + } + } } - + void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { #if 0 - wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); - event.SetEventObject(this); - - ProcessEvent(event); + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); + event.SetEventObject(this); + + ProcessEvent(event); #endif } diff --git a/src/mac/carbon/palette.cpp b/src/mac/carbon/palette.cpp index 5fd459da77..60a0de6a8a 100644 --- a/src/mac/carbon/palette.cpp +++ b/src/mac/carbon/palette.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -30,8 +30,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) wxPaletteRefData::wxPaletteRefData() { - m_palette = NULL ; - m_count = 0 ; + m_palette = NULL ; + m_count = 0 ; } wxPaletteRefData::~wxPaletteRefData() @@ -57,41 +57,41 @@ wxPalette::~wxPalette() bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) { - UnRef(); - - m_refData = new wxPaletteRefData; - - M_PALETTEDATA->m_count = n ; - M_PALETTEDATA->m_palette = new wxColour[n] ; - - for ( int i = 0 ; i < n ; ++i) - { - M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ; - } - - return FALSE; + UnRef(); + + m_refData = new wxPaletteRefData; + + M_PALETTEDATA->m_count = n ; + M_PALETTEDATA->m_palette = new wxColour[n] ; + + for ( int i = 0 ; i < n ; ++i) + { + M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ; + } + + return FALSE; } int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const { if ( !m_refData ) - return -1; - + return -1; + long bestdiff = 3 * 256 ; long bestpos = 0 ; long currentdiff ; for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i ) { - const wxColour& col = &M_PALETTEDATA->m_palette[i] ; - currentdiff = abs ( col.Red() - red ) + abs( col.Green() - green ) + abs ( col.Blue() - blue ) ; - if ( currentdiff < bestdiff ) - { - bestdiff = currentdiff ; - bestpos = i ; - if ( bestdiff == 0 ) - break ; - } + const wxColour& col = &M_PALETTEDATA->m_palette[i] ; + currentdiff = abs ( col.Red() - red ) + abs( col.Green() - green ) + abs ( col.Blue() - blue ) ; + if ( currentdiff < bestdiff ) + { + bestdiff = currentdiff ; + bestpos = i ; + if ( bestdiff == 0 ) + break ; + } } return bestpos; @@ -100,11 +100,11 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const { if ( !m_refData ) - return FALSE; - + return FALSE; + if (index < 0 || index >= M_PALETTEDATA->m_count) return FALSE; - + const wxColour& col = &M_PALETTEDATA->m_palette[index] ; *red = col.Red() ; *green = col.Green() ; @@ -114,5 +114,5 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi } #endif - // wxUSE_PALETTE +// wxUSE_PALETTE diff --git a/src/mac/carbon/pen.cpp b/src/mac/carbon/pen.cpp index 3c3d9f033b..fea55ab34e 100644 --- a/src/mac/carbon/pen.cpp +++ b/src/mac/carbon/pen.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -32,7 +32,7 @@ wxPenRefData::wxPenRefData() } wxPenRefData::wxPenRefData(const wxPenRefData& data) - : wxGDIRefData() +: wxGDIRefData() { m_style = data.m_style; m_width = data.m_width; @@ -61,7 +61,7 @@ wxPen::~wxPen() wxPen::wxPen(const wxColour& col, int Width, int Style) { m_refData = new wxPenRefData; - + M_PENDATA->m_colour = col; M_PENDATA->m_width = Width; M_PENDATA->m_style = Style; @@ -69,14 +69,14 @@ wxPen::wxPen(const wxColour& col, int Width, int Style) M_PENDATA->m_cap = wxCAP_ROUND ; M_PENDATA->m_nbDash = 0 ; M_PENDATA->m_dash = 0 ; - + RealizeResource(); } wxPen::wxPen(const wxBitmap& stipple, int Width) { m_refData = new wxPenRefData; - + M_PENDATA->m_stipple = stipple; M_PENDATA->m_width = Width; M_PENDATA->m_style = wxSTIPPLE; @@ -84,102 +84,102 @@ wxPen::wxPen(const wxBitmap& stipple, int Width) M_PENDATA->m_cap = wxCAP_ROUND ; M_PENDATA->m_nbDash = 0 ; M_PENDATA->m_dash = 0 ; - + RealizeResource(); } void wxPen::Unshare() { - // Don't change shared data - if (!m_refData) + // Don't change shared data + if (!m_refData) { - m_refData = new wxPenRefData(); - } + m_refData = new wxPenRefData(); + } else { - wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); - UnRef(); - m_refData = ref; - } + wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); + UnRef(); + m_refData = ref; + } } void wxPen::SetColour(const wxColour& col) { Unshare(); - + M_PENDATA->m_colour = col; - + RealizeResource(); } void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) { Unshare(); - + M_PENDATA->m_colour.Set(r, g, b); - + RealizeResource(); } void wxPen::SetWidth(int Width) { Unshare(); - + M_PENDATA->m_width = Width; - + RealizeResource(); } void wxPen::SetStyle(int Style) { Unshare(); - + M_PENDATA->m_style = Style; - + RealizeResource(); } void wxPen::SetStipple(const wxBitmap& Stipple) { Unshare(); - + M_PENDATA->m_stipple = Stipple; M_PENDATA->m_style = wxSTIPPLE; - + RealizeResource(); } void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) { Unshare(); - + M_PENDATA->m_nbDash = nb_dashes; M_PENDATA->m_dash = (wxDash *)Dash; - + RealizeResource(); } void wxPen::SetJoin(int Join) { Unshare(); - + M_PENDATA->m_join = Join; - + RealizeResource(); } void wxPen::SetCap(int Cap) { Unshare(); - + M_PENDATA->m_cap = Cap; - + RealizeResource(); } bool wxPen::RealizeResource() { - // nothing to do here for mac + // nothing to do here for mac return TRUE; } diff --git a/src/mac/carbon/pnghand.cpp b/src/mac/carbon/pnghand.cpp index 52b07f6e60..4f33c04b1e 100644 --- a/src/mac/carbon/pnghand.cpp +++ b/src/mac/carbon/pnghand.cpp @@ -57,8 +57,8 @@ extern void wxMacDestroyGWorld( GWorldPtr gw ) ; void ima_png_error(png_struct *png_ptr, char *message) { - wxMessageBox(message, "PNG error"); - longjmp(png_ptr->jmpbuf, 1); + wxMessageBox(message, "PNG error"); + longjmp(png_ptr->jmpbuf, 1); } @@ -67,68 +67,68 @@ wxPalette *wxCopyPalette(const wxPalette *cmap); wxPNGReader::wxPNGReader(void) { - filetype = 0; - RawImage = NULL; // Image data - - Width = 0; Height = 0; // Dimensions - Depth = 0; // (bits x pixel) - ColorType = 0; // Bit 1 = Palette used - // Bit 2 = Color used - // Bit 3 = Alpha used - - EfeWidth = 0; // Efective Width - - lpbi = NULL; - bgindex = -1; - m_palette = 0; - imageOK = FALSE; + filetype = 0; + RawImage = NULL; // Image data + + Width = 0; Height = 0; // Dimensions + Depth = 0; // (bits x pixel) + ColorType = 0; // Bit 1 = Palette used + // Bit 2 = Color used + // Bit 3 = Alpha used + + EfeWidth = 0; // Efective Width + + lpbi = NULL; + bgindex = -1; + m_palette = 0; + imageOK = FALSE; } wxPNGReader::wxPNGReader ( char* ImageFileName ) { - imageOK = FALSE; - filetype = 0; - RawImage = NULL; // Image data - - Width = 0; Height = 0; // Dimensions - Depth = 0; // (bits x pixel) - ColorType = 0; // Bit 1 = m_palette used - // Bit 2 = Color used - // Bit 3 = Alpha used - - EfeWidth = 0; // Efective Width - - lpbi = NULL; - bgindex = -1; - m_palette = 0; - - imageOK = ReadFile (ImageFileName); + imageOK = FALSE; + filetype = 0; + RawImage = NULL; // Image data + + Width = 0; Height = 0; // Dimensions + Depth = 0; // (bits x pixel) + ColorType = 0; // Bit 1 = m_palette used + // Bit 2 = Color used + // Bit 3 = Alpha used + + EfeWidth = 0; // Efective Width + + lpbi = NULL; + bgindex = -1; + m_palette = 0; + + imageOK = ReadFile (ImageFileName); } void wxPNGReader::Create(int width, int height, int depth, int colortype) { - Width = width; Height = height; Depth = depth; - ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0); - delete m_palette; - m_palette = NULL; - delete[] RawImage; - RawImage = NULL; - - if (lpbi) { - wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; - } - lpbi = wxMacCreateGWorld( Width , Height , Depth); - if (lpbi) - { - EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4; - int bitwidth = width ; - if ( EfeWidth > bitwidth ) - bitwidth = EfeWidth ; - - RawImage = (byte*) new char[ ( bitwidth * Height * ((Depth+7)>>3) ) ]; - imageOK = TRUE; - } + Width = width; Height = height; Depth = depth; + ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0); + delete m_palette; + m_palette = NULL; + delete[] RawImage; + RawImage = NULL; + + if (lpbi) { + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + } + lpbi = wxMacCreateGWorld( Width , Height , Depth); + if (lpbi) + { + EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4; + int bitwidth = width ; + if ( EfeWidth > bitwidth ) + bitwidth = EfeWidth ; + + RawImage = (byte*) new char[ ( bitwidth * Height * ((Depth+7)>>3) ) ]; + imageOK = TRUE; + } } wxPNGReader::~wxPNGReader ( ) @@ -138,7 +138,7 @@ wxPNGReader::~wxPNGReader ( ) RawImage = NULL; } if (lpbi) { - wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; lpbi = NULL; } if (m_palette != NULL) { @@ -150,128 +150,128 @@ wxPNGReader::~wxPNGReader ( ) int wxPNGReader::GetIndex(int x, int y) { - if (!Inside(x, y) || (Depth>8)) return -1; - - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - int index = (int)(*ImagePointer); - return index; + if (!Inside(x, y) || (Depth>8)) return -1; + + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + int index = (int)(*ImagePointer); + return index; } bool wxPNGReader::GetRGB(int x, int y, byte* r, byte* g, byte* b) { - if (!Inside(x, y)) return FALSE; - - if (m_palette) { - return m_palette->GetRGB(GetIndex(x, y), r, g, b); -/* PALETTEENTRY entry; - ::GetPaletteEntries((HPALETTE) m_palette->GetHPALETTE(), GetIndex(x, y), 1, &entry); - *r = entry.peRed; - *g = entry.peGreen; - *b = entry.peBlue; */ - } else { - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - *b = ImagePointer[0]; - *g = ImagePointer[1]; - *r = ImagePointer[2]; - } - return TRUE; + if (!Inside(x, y)) return FALSE; + + if (m_palette) { + return m_palette->GetRGB(GetIndex(x, y), r, g, b); + /* PALETTEENTRY entry; + ::GetPaletteEntries((HPALETTE) m_palette->GetHPALETTE(), GetIndex(x, y), 1, &entry); + *r = entry.peRed; + *g = entry.peGreen; + *b = entry.peBlue; */ + } else { + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + *b = ImagePointer[0]; + *g = ImagePointer[1]; + *r = ImagePointer[2]; + } + return TRUE; } bool wxPNGReader::SetIndex(int x, int y, int index) { - if (!Inside(x, y) || (Depth>8)) return FALSE; - - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - *ImagePointer = index; - - return TRUE; + if (!Inside(x, y) || (Depth>8)) return FALSE; + + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + *ImagePointer = index; + + return TRUE; } bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b) { - if (!Inside(x, y)) return FALSE; - - if (ColorType & COLORTYPE_PALETTE) - { - if (!m_palette) return FALSE; - SetIndex(x, y, m_palette->GetPixel(r, g, b)); - - } else { - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - ImagePointer[0] = b; - ImagePointer[1] = g; - ImagePointer[2] = r; - } - - return TRUE; + if (!Inside(x, y)) return FALSE; + + if (ColorType & COLORTYPE_PALETTE) + { + if (!m_palette) return FALSE; + SetIndex(x, y, m_palette->GetPixel(r, g, b)); + + } else { + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + ImagePointer[0] = b; + ImagePointer[1] = g; + ImagePointer[2] = r; + } + + return TRUE; } bool wxPNGReader::SetPalette(wxPalette* colourmap) { - delete m_palette ; - if (!colourmap) - return FALSE; - ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); - m_palette = new wxPalette( *colourmap ); - return true ; -// return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + delete m_palette ; + if (!colourmap) + return FALSE; + ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); + m_palette = new wxPalette( *colourmap ); + return true ; + // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } bool wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b) { - delete m_palette ; - m_palette = new wxPalette(); - if (!m_palette) - return FALSE; - - if (!g) g = r; - if (!b) b = g; - m_palette->Create(n, r, g, b); - ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); - return true ; -// return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + delete m_palette ; + m_palette = new wxPalette(); + if (!m_palette) + return FALSE; + + if (!g) g = r; + if (!b) b = g; + m_palette->Create(n, r, g, b); + ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); + return true ; + // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } bool wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct) { - delete m_palette ; - m_palette = new wxPalette(); - if (!m_palette) - return FALSE; - - byte r[256], g[256], b[256]; - - for(int i=0; iCreate(n, r, g, b); - ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); - return true ; -// return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + delete m_palette ; + m_palette = new wxPalette(); + if (!m_palette) + return FALSE; + + byte r[256], g[256], b[256]; + + for(int i=0; iCreate(n, r, g, b); + ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); + return true ; + // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } void wxPNGReader::NullData() { - if (lpbi) { - wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + if (lpbi) { + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; lpbi = NULL; - } - if (m_palette != NULL) { - delete m_palette; - m_palette = NULL; - } + } + if (m_palette != NULL) { + delete m_palette; + m_palette = NULL; + } } wxBitmap* wxPNGReader::GetBitmap(void) @@ -290,353 +290,353 @@ bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap) { if ( lpbi ) { - bitmap->SetHBITMAP((WXHBITMAP) lpbi); - bitmap->SetWidth(GetWidth()); - bitmap->SetHeight(GetHeight()); - bitmap->SetDepth(GetDepth()); - if ( GetDepth() > 1 && m_palette ) - bitmap->SetPalette(*m_palette); - bitmap->SetOk(TRUE); - - - // Make a mask if appropriate - /* - if ( bgindex > -1 ) - { + bitmap->SetHBITMAP((WXHBITMAP) lpbi); + bitmap->SetWidth(GetWidth()); + bitmap->SetHeight(GetHeight()); + bitmap->SetDepth(GetDepth()); + if ( GetDepth() > 1 && m_palette ) + bitmap->SetPalette(*m_palette); + bitmap->SetOk(TRUE); + + + // Make a mask if appropriate + /* + if ( bgindex > -1 ) + { wxMask *mask = CreateMask(); bitmap->SetMask(mask); - } - */ - lpbi = NULL ; // bitmap has taken over ownership - return TRUE; + } + */ + lpbi = NULL ; // bitmap has taken over ownership + return TRUE; } else { - return FALSE; + return FALSE; } -/* - HDC dc = ::CreateCompatibleDC(NULL); - - if (dc) - { - // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it - // is a memory dc that must have a bitmap selected into it) - HDC dc2 = GetDC(NULL); - HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight()); - ReleaseDC(NULL, dc2); - HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, tmpBitmap); - + /* + HDC dc = ::CreateCompatibleDC(NULL); + + if (dc) + { + // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it + // is a memory dc that must have a bitmap selected into it) + HDC dc2 = GetDC(NULL); + HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight()); + ReleaseDC(NULL, dc2); + HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, tmpBitmap); + if ( m_palette ) { - HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) m_palette->GetHPALETTE(), FALSE); + HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) m_palette->GetHPALETTE(), FALSE); ::RealizePalette(dc); } - - HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi, - CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS); - - ::SelectPalette(dc, NULL, TRUE); - ::SelectObject(dc, oldBitmap); - ::DeleteObject(tmpBitmap); - ::DeleteDC(dc); - - if ( hBitmap ) - { - bitmap->SetHBITMAP((WXHBITMAP) hBitmap); - bitmap->SetWidth(GetWidth()); - bitmap->SetHeight(GetHeight()); - bitmap->SetDepth(GetDepth()); - if ( GetDepth() > 1 && m_palette ) - bitmap->SetPalette(*m_palette); - bitmap->SetOk(TRUE); - - - // Make a mask if appropriate - if ( bgindex > -1 ) - { - wxMask *mask = CreateMask(); - bitmap->SetMask(mask); - } - return TRUE; - } - else - { - return FALSE; - } - } - else - { - return FALSE; - } - */ - return false ; + + HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi, + CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS); + + ::SelectPalette(dc, NULL, TRUE); + ::SelectObject(dc, oldBitmap); + ::DeleteObject(tmpBitmap); + ::DeleteDC(dc); + + if ( hBitmap ) + { + bitmap->SetHBITMAP((WXHBITMAP) hBitmap); + bitmap->SetWidth(GetWidth()); + bitmap->SetHeight(GetHeight()); + bitmap->SetDepth(GetDepth()); + if ( GetDepth() > 1 && m_palette ) + bitmap->SetPalette(*m_palette); + bitmap->SetOk(TRUE); + + + // Make a mask if appropriate + if ( bgindex > -1 ) + { + wxMask *mask = CreateMask(); + bitmap->SetMask(mask); + } + return TRUE; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } + */ + return false ; } wxPalette *wxCopyPalette(const wxPalette *cmap) { - wxPalette *newCmap = new wxPalette( *cmap ) ; - return newCmap; + wxPalette *newCmap = new wxPalette( *cmap ) ; + return newCmap; } wxMask *wxPNGReader::CreateMask(void) { /* - HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL); +HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL); HDC dc = ::CreateCompatibleDC(NULL); - HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap); - + HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap); + int bgIndex = GetBGIndex(); - - int x,y; - - for (x=0; xSetMaskBitmap((WXHBITMAP) hBitmap); - return mask; - */ - return NULL ; + int index = GetIndex(x, y); + if ( index == bgIndex ) + ::SetPixel(dc, x, GetHeight() - y - 1, RGB(0, 0, 0)); + else + ::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255)); + + } + } + ::SelectObject(dc, oldBitmap); + wxMask *mask = new wxMask; + mask->SetMaskBitmap((WXHBITMAP) hBitmap); + return mask; + */ + return NULL ; } bool wxPNGReader::ReadFile(char * ImageFileName) { - int number_passes; - - if (ImageFileName) - strcpy(filename, ImageFileName); - - FILE *fp; - png_struct *png_ptr; - png_info *info_ptr; - wxPNGReaderIter iter(this); - - /* open the file */ - fp = fopen( ImageFileName , "rb" ); - - if (!fp) - return FALSE; - - /* allocate the necessary structures */ - png_ptr = new (png_struct); - if (!png_ptr) - { - fclose(fp); - return FALSE; - } - - info_ptr = new (png_info); - if (!info_ptr) - { - fclose(fp); - delete png_ptr; - return FALSE; - } - /* set error handling */ - if (setjmp(png_ptr->jmpbuf)) - { - png_read_destroy(png_ptr, info_ptr, (png_info *)0); - fclose(fp); - delete png_ptr; - delete info_ptr; - - /* If we get here, we had a problem reading the file */ - return FALSE; - } - //png_set_error(ima_png_error, NULL); - - /* initialize the structures, info first for error handling */ - png_info_init(info_ptr); - png_read_init(png_ptr); - - /* set up the input control */ - png_init_io(png_ptr, fp); - - /* read the file information */ - png_read_info(png_ptr, info_ptr); - - /* allocate the memory to hold the image using the fields + int number_passes; + + if (ImageFileName) + strcpy(filename, ImageFileName); + + FILE *fp; + png_struct *png_ptr; + png_info *info_ptr; + wxPNGReaderIter iter(this); + + /* open the file */ + fp = fopen( ImageFileName , "rb" ); + + if (!fp) + return FALSE; + + /* allocate the necessary structures */ + png_ptr = new (png_struct); + if (!png_ptr) + { + fclose(fp); + return FALSE; + } + + info_ptr = new (png_info); + if (!info_ptr) + { + fclose(fp); + delete png_ptr; + return FALSE; + } + /* set error handling */ + if (setjmp(png_ptr->jmpbuf)) + { + png_read_destroy(png_ptr, info_ptr, (png_info *)0); + fclose(fp); + delete png_ptr; + delete info_ptr; + + /* If we get here, we had a problem reading the file */ + return FALSE; + } + //png_set_error(ima_png_error, NULL); + + /* initialize the structures, info first for error handling */ + png_info_init(info_ptr); + png_read_init(png_ptr); + + /* set up the input control */ + png_init_io(png_ptr, fp); + + /* read the file information */ + png_read_info(png_ptr, info_ptr); + + /* allocate the memory to hold the image using the fields of png_info. */ - png_color_16 my_background={ 0, 31, 127, 255, 0 }; - - if (info_ptr->valid & PNG_INFO_bKGD) + png_color_16 my_background={ 0, 31, 127, 255, 0 }; + + if (info_ptr->valid & PNG_INFO_bKGD) { - png_set_background(png_ptr, &(info_ptr->background), - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + png_set_background(png_ptr, &(info_ptr->background), + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); if ( info_ptr->num_palette > 0 ) bgindex = info_ptr->background.index; } - else { - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - + else { + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + // Added by JACS: guesswork! if ( info_ptr->num_trans != 0 ) bgindex = info_ptr->num_trans - 1 ; - } - - /* tell libpng to strip 16 bit depth files down to 8 bits */ - if (info_ptr->bit_depth == 16) - png_set_strip_16(png_ptr); - - int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24; - Create(info_ptr->width, info_ptr->height, pixel_depth, - info_ptr->color_type); - - if (info_ptr->num_palette>0) + } + + /* tell libpng to strip 16 bit depth files down to 8 bits */ + if (info_ptr->bit_depth == 16) + png_set_strip_16(png_ptr); + + int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24; + Create(info_ptr->width, info_ptr->height, pixel_depth, + info_ptr->color_type); + + if (info_ptr->num_palette>0) { - SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette); + SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette); } - - int row_stride = info_ptr->width * ((pixel_depth+7)>>3); - // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride); -// printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth); - - byte *row_pointers = new byte[row_stride]; - - /* turn on interlace handling */ - if (info_ptr->interlace_type) - number_passes = png_set_interlace_handling(png_ptr); - else - number_passes = 1; -// printf("NP = %d ", number_passes); - - for (int pass=0; pass< number_passes; pass++) - { - iter.upset(); - int y=0; - CGrafPtr origPort ; - GDHandle origDevice ; - - GetGWorld( &origPort , &origDevice ) ; - // ignore shapedc - SetGWorld( (GWorldPtr) lpbi , NULL ) ; - do - { - // (unsigned char *)iter.GetRow(); - if (info_ptr->interlace_type) - { - if (pass>0) - iter.GetRow(row_pointers, row_stride); - png_read_row(png_ptr, row_pointers, NULL); - } - else - png_read_row(png_ptr, row_pointers, NULL); - - if ( info_ptr->palette ) - { - if ( pixel_depth == 8 ) - { - for ( size_t i = 0 ; i < info_ptr->width ; ++i ) - { - png_color_struct* color ; - RGBColor col ; - - int index = row_pointers[i] ; - color = &info_ptr->palette[index] ; - col.red = (((int)color->red) << 8) | ((int)color->red) ; - col.green = (((int)color->green) << 8) | ((int)color->green) ; - col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; - SetCPixel( i, y, &col); - } - /* - png_color_struct* color ; - RGBColor col ; - unsigned char* p = &row_pointers[0] ; - PenNormal() ; - MoveTo( 0 , y ) ; - int index = *p ; - color = &info_ptr->palette[index] ; - col.red = (color->red << 8) | color->red ; - col.green = (color->green << 8) | color->green ; - col.blue = (color->blue << 8) | color->blue ; - RGBForeColor( &col ) ; - col.red = col.green = col.blue = 0xFFFF ; - RGBBackColor( &col ) ; - for ( int i = 0 ; i < info_ptr->width ; ++i , ++p) - { - if ( *p != index ) - { - LineTo( i , y ) ; - index = *p ; - color = &info_ptr->palette[index] ; - col.red = (((int)color->red) << 8) | ((int)color->red) ; - col.green = (((int)color->green) << 8) | ((int)color->green) ; - col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; - RGBForeColor( &col ) ; - } - } - LineTo( info_ptr->width , y ) ; - */ - } - else - { - for ( size_t i = 0 ; i < info_ptr->width ; ++i ) - { - png_color_struct* color ; - RGBColor col ; - - int byte = ( i * pixel_depth ) / 8 ; - int offset = ( 8 - pixel_depth ) - ( i * pixel_depth ) % 8 ; - - int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) ); - color = &info_ptr->palette[index] ; - col.red = (((int)color->red) << 8) | ((int)color->red) ; - col.green = (((int)color->green) << 8) | ((int)color->green) ; - col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; - SetCPixel( i, y, &col); - } - } - } - else - { - for ( size_t i = 0 ; i < info_ptr->width ; ++i ) - { - png_color_struct* color ; - RGBColor col ; - color =(png_color_struct*) (&row_pointers[i*3]) ; - col.red = (((int)color->red) << 8) | ((int)color->red) ; - col.green = (((int)color->green) << 8) | ((int)color->green) ; - col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; - SetCPixel( i, y, &col); - } - } - if (number_passes) - iter.SetRow(row_pointers, row_stride); - y++; - } - while(iter.PrevRow()); - SetGWorld( origPort , origDevice ) ; - -// printf("Y=%d ",y); + + int row_stride = info_ptr->width * ((pixel_depth+7)>>3); + // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride); + // printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth); + + byte *row_pointers = new byte[row_stride]; + + /* turn on interlace handling */ + if (info_ptr->interlace_type) + number_passes = png_set_interlace_handling(png_ptr); + else + number_passes = 1; + // printf("NP = %d ", number_passes); + + for (int pass=0; pass< number_passes; pass++) + { + iter.upset(); + int y=0; + CGrafPtr origPort ; + GDHandle origDevice ; + + GetGWorld( &origPort , &origDevice ) ; + // ignore shapedc + SetGWorld( (GWorldPtr) lpbi , NULL ) ; + do + { + // (unsigned char *)iter.GetRow(); + if (info_ptr->interlace_type) + { + if (pass>0) + iter.GetRow(row_pointers, row_stride); + png_read_row(png_ptr, row_pointers, NULL); + } + else + png_read_row(png_ptr, row_pointers, NULL); + + if ( info_ptr->palette ) + { + if ( pixel_depth == 8 ) + { + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) + { + png_color_struct* color ; + RGBColor col ; + + int index = row_pointers[i] ; + color = &info_ptr->palette[index] ; + col.red = (((int)color->red) << 8) | ((int)color->red) ; + col.green = (((int)color->green) << 8) | ((int)color->green) ; + col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; + SetCPixel( i, y, &col); + } + /* + png_color_struct* color ; + RGBColor col ; + unsigned char* p = &row_pointers[0] ; + PenNormal() ; + MoveTo( 0 , y ) ; + int index = *p ; + color = &info_ptr->palette[index] ; + col.red = (color->red << 8) | color->red ; + col.green = (color->green << 8) | color->green ; + col.blue = (color->blue << 8) | color->blue ; + RGBForeColor( &col ) ; + col.red = col.green = col.blue = 0xFFFF ; + RGBBackColor( &col ) ; + for ( int i = 0 ; i < info_ptr->width ; ++i , ++p) + { + if ( *p != index ) + { + LineTo( i , y ) ; + index = *p ; + color = &info_ptr->palette[index] ; + col.red = (((int)color->red) << 8) | ((int)color->red) ; + col.green = (((int)color->green) << 8) | ((int)color->green) ; + col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; + RGBForeColor( &col ) ; + } + } + LineTo( info_ptr->width , y ) ; + */ + } + else + { + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) + { + png_color_struct* color ; + RGBColor col ; + + int byte = ( i * pixel_depth ) / 8 ; + int offset = ( 8 - pixel_depth ) - ( i * pixel_depth ) % 8 ; + + int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) ); + color = &info_ptr->palette[index] ; + col.red = (((int)color->red) << 8) | ((int)color->red) ; + col.green = (((int)color->green) << 8) | ((int)color->green) ; + col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; + SetCPixel( i, y, &col); + } + } + } + else + { + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) + { + png_color_struct* color ; + RGBColor col ; + color =(png_color_struct*) (&row_pointers[i*3]) ; + col.red = (((int)color->red) << 8) | ((int)color->red) ; + col.green = (((int)color->green) << 8) | ((int)color->green) ; + col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; + SetCPixel( i, y, &col); + } + } + if (number_passes) + iter.SetRow(row_pointers, row_stride); + y++; + } + while(iter.PrevRow()); + SetGWorld( origPort , origDevice ) ; + + // printf("Y=%d ",y); } delete[] row_pointers; - + /* read the rest of the file, getting any additional chunks - in info_ptr */ + in info_ptr */ png_read_end(png_ptr, info_ptr); - + /* clean up after the read, and free any memory allocated */ png_read_destroy(png_ptr, info_ptr, (png_info *)0); - + /* free the structures */ delete png_ptr; delete info_ptr; - + /* close the file */ fclose(fp); - + /* that's it */ return TRUE; } @@ -646,146 +646,146 @@ bool wxPNGReader::ReadFile(char * ImageFileName) bool wxPNGReader::SaveFile(char * ImageFileName) { - if (ImageFileName) - strcpy(filename, ImageFileName); - - wxPNGReaderIter iter(this); - FILE *fp; - png_struct *png_ptr; - png_info *info_ptr; - - /* open the file */ - fp = fopen(filename, "wb"); - if (!fp) - return FALSE; - - /* allocate the necessary structures */ - png_ptr = new (png_struct); - if (!png_ptr) - { - fclose(fp); - return FALSE; - } - - info_ptr = new (png_info); - if (!info_ptr) - { - fclose(fp); - delete png_ptr; - return FALSE; - } - - /* set error handling */ - if (setjmp(png_ptr->jmpbuf)) - { + if (ImageFileName) + strcpy(filename, ImageFileName); + + wxPNGReaderIter iter(this); + FILE *fp; + png_struct *png_ptr; + png_info *info_ptr; + + /* open the file */ + fp = fopen(filename, "wb"); + if (!fp) + return FALSE; + + /* allocate the necessary structures */ + png_ptr = new (png_struct); + if (!png_ptr) + { + fclose(fp); + return FALSE; + } + + info_ptr = new (png_info); + if (!info_ptr) + { + fclose(fp); + delete png_ptr; + return FALSE; + } + + /* set error handling */ + if (setjmp(png_ptr->jmpbuf)) + { + png_write_destroy(png_ptr); + fclose(fp); + delete png_ptr; + delete info_ptr; + + /* If we get here, we had a problem reading the file */ + return FALSE; + } + //png_set_error(ima_png_error, NULL); + + // printf("writig pg %s ", filename); + /* initialize the structures */ + png_info_init(info_ptr); + png_write_init(png_ptr); + + int row_stride = GetWidth() * ((GetDepth()+7)>>3); + /* set up the output control */ + png_init_io(png_ptr, fp); + + /* set the file information here */ + info_ptr->width = GetWidth(); + info_ptr->height = GetHeight(); + info_ptr->pixel_depth = GetDepth(); + info_ptr->channels = (GetDepth()>8) ? 3: 1; + info_ptr->bit_depth = GetDepth()/info_ptr->channels; + info_ptr->color_type = GetColorType(); + info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0; + info_ptr->valid = 0; + info_ptr->rowbytes = row_stride; + + + // printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels); + /* set the palette if there is one */ + if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette()) + { + // printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); + info_ptr->valid |= PNG_INFO_PLTE; + info_ptr->palette = new png_color[256]; + info_ptr->num_palette = 256; + for (int i=0; i<256; i++) + GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); + } + // printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); + + + /* optional significant bit chunk */ + // info_ptr->valid |= PNG_INFO_sBIT; + // info_ptr->sig_bit = true_bit_depth; + + /* optional gamma chunk */ + // info_ptr->valid |= PNG_INFO_gAMA; + // info_ptr->gamma = gamma; + + /* other optional chunks */ + + /* write the file information */ + png_write_info(png_ptr, info_ptr); + + /* set up the transformations you want. Note that these are + all optional. Only call them if you want them */ + + /* shift the pixels up to a legal bit depth and fill in + as appropriate to correctly scale the image */ + // png_set_shift(png_ptr, &(info_ptr->sig_bit)); + + /* pack pixels into bytes */ + // png_set_packing(png_ptr); + + /* flip bgr pixels to rgb */ + // png_set_bgr(png_ptr); + + /* swap bytes of 16 bit files to most significant bit first */ + // png_set_swap(png_ptr); + + /* get rid of filler bytes, pack rgb into 3 bytes */ + // png_set_rgbx(png_ptr); + + /* If you are only writing one row at a time, this works */ + + byte *row_pointers = new byte[row_stride]; + iter.upset(); + do { + // (unsigned char *)iter.GetRow(); + iter.GetRow(row_pointers, row_stride); + png_write_row(png_ptr, row_pointers); + } while(iter.PrevRow()); + + delete[] row_pointers; + + /* write the rest of the file */ + png_write_end(png_ptr, info_ptr); + + /* clean up after the write, and free any memory allocated */ png_write_destroy(png_ptr); - fclose(fp); + + /* if you malloced the palette, free it here */ + if (info_ptr->palette) + delete[] (info_ptr->palette); + + /* free the structures */ delete png_ptr; delete info_ptr; - - /* If we get here, we had a problem reading the file */ - return FALSE; - } - //png_set_error(ima_png_error, NULL); - -// printf("writig pg %s ", filename); - /* initialize the structures */ - png_info_init(info_ptr); - png_write_init(png_ptr); - - int row_stride = GetWidth() * ((GetDepth()+7)>>3); - /* set up the output control */ - png_init_io(png_ptr, fp); - - /* set the file information here */ - info_ptr->width = GetWidth(); - info_ptr->height = GetHeight(); - info_ptr->pixel_depth = GetDepth(); - info_ptr->channels = (GetDepth()>8) ? 3: 1; - info_ptr->bit_depth = GetDepth()/info_ptr->channels; - info_ptr->color_type = GetColorType(); - info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0; - info_ptr->valid = 0; - info_ptr->rowbytes = row_stride; - - -// printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels); - /* set the palette if there is one */ - if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette()) - { -// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); - info_ptr->valid |= PNG_INFO_PLTE; - info_ptr->palette = new png_color[256]; - info_ptr->num_palette = 256; - for (int i=0; i<256; i++) - GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); - } -// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); - - - /* optional significant bit chunk */ -// info_ptr->valid |= PNG_INFO_sBIT; -// info_ptr->sig_bit = true_bit_depth; - - /* optional gamma chunk */ -// info_ptr->valid |= PNG_INFO_gAMA; -// info_ptr->gamma = gamma; - - /* other optional chunks */ - - /* write the file information */ - png_write_info(png_ptr, info_ptr); - - /* set up the transformations you want. Note that these are - all optional. Only call them if you want them */ - - /* shift the pixels up to a legal bit depth and fill in - as appropriate to correctly scale the image */ -// png_set_shift(png_ptr, &(info_ptr->sig_bit)); - - /* pack pixels into bytes */ -// png_set_packing(png_ptr); - - /* flip bgr pixels to rgb */ -// png_set_bgr(png_ptr); - - /* swap bytes of 16 bit files to most significant bit first */ -// png_set_swap(png_ptr); - - /* get rid of filler bytes, pack rgb into 3 bytes */ -// png_set_rgbx(png_ptr); - -/* If you are only writing one row at a time, this works */ - - byte *row_pointers = new byte[row_stride]; - iter.upset(); - do { -// (unsigned char *)iter.GetRow(); - iter.GetRow(row_pointers, row_stride); - png_write_row(png_ptr, row_pointers); - } while(iter.PrevRow()); - - delete[] row_pointers; - -/* write the rest of the file */ - png_write_end(png_ptr, info_ptr); - - /* clean up after the write, and free any memory allocated */ - png_write_destroy(png_ptr); - - /* if you malloced the palette, free it here */ - if (info_ptr->palette) - delete[] (info_ptr->palette); - - /* free the structures */ - delete png_ptr; - delete info_ptr; - - /* close the file */ - fclose(fp); - - /* that's it */ - return TRUE; + + /* close the file */ + fclose(fp); + + /* that's it */ + return TRUE; } static int Power(int x, int y) @@ -800,15 +800,15 @@ static int Power(int x, int y) } static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', - 'C', 'D', 'E', 'F' }; +'C', 'D', 'E', 'F' }; static void DecToHex(int dec, char *buf) { - int firstDigit = (int)(dec/16.0); - int secondDigit = (int)(dec - (firstDigit*16.0)); - buf[0] = hexArray[firstDigit]; - buf[1] = hexArray[secondDigit]; - buf[2] = 0; + int firstDigit = (int)(dec/16.0); + int secondDigit = (int)(dec - (firstDigit*16.0)); + buf[0] = hexArray[firstDigit]; + buf[1] = hexArray[secondDigit]; + buf[2] = 0; } @@ -822,30 +822,30 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) strcpy(nameStr, filename); wxStripExtension(nameStr); } - + if ( GetDepth() > 4 ) { // Only a depth of 4 and below allowed return FALSE; } - + if ( !GetPalette() ) return FALSE; - + wxSTD ofstream str(filename); if ( str.bad() ) return FALSE; - + int noColours = Power(2, GetDepth()); - + // Output header str << "/* XPM */\n"; str << "static char * " << nameStr << "_xpm[] = {\n"; str << "\"" << GetWidth() << " " << GetHeight() << " " << noColours << " 1\",\n"; - + // Output colourmap int base = 97 ; // start from 'a' - + unsigned char red, green, blue; char hexBuf[4]; int i; @@ -861,7 +861,7 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) str << hexBuf; str << "\",\n"; } - + // Output the data int x, y; for ( y = 0; y < GetHeight(); y++) @@ -874,10 +874,10 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) } str << "\",\n"; } - + str << "};\n"; str.flush(); - + return TRUE; } @@ -885,7 +885,7 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) IMPLEMENT_DYNAMIC_CLASS(wxPNGFileHandler, wxBitmapHandler) bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) + int desiredWidth, int desiredHeight) { wxPNGReader reader; if (reader.ReadFile((char*) (const char*) name)) diff --git a/src/mac/carbon/printdlg.cpp b/src/mac/carbon/printdlg.cpp index 7261f5576f..779ee74edd 100644 --- a/src/mac/carbon/printdlg.cpp +++ b/src/mac/carbon/printdlg.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -19,7 +19,7 @@ #include "wx/msgdlg.h" #include "wx/mac/uma.h" #ifndef __DARWIN__ - #include "Printing.h" +#include "Printing.h" #endif #if defined(TARGET_CARBON) && !defined(__DARWIN__) @@ -53,7 +53,7 @@ wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data) wxPrintDialogData data2; if ( data ) data2 = *data; - + Create(p, &data2); } @@ -62,10 +62,10 @@ bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data) m_dialogParent = p; m_printerDC = NULL; m_destroyDC = TRUE; - + if ( data ) m_printDialogData = *data; - + return TRUE; } @@ -79,31 +79,31 @@ wxPrintDialog::~wxPrintDialog() int wxPrintDialog::ShowModal() { - int result = wxID_CANCEL ; - OSErr err ; - wxString message ; - -#if !TARGET_CARBON - err = ::UMAPrOpen(NULL) ; - if ( err == noErr ) - { - m_printDialogData.ConvertToNative() ; - if ( ::PrJobDialog( (THPrint) m_printDialogData.GetPrintData().m_macPrintSettings ) ) - { - m_printDialogData.ConvertFromNative() ; - result = wxID_OK ; - } - - } - else - { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - } - ::UMAPrClose(NULL) ; + int result = wxID_CANCEL ; + OSErr err ; + wxString message ; + +#if !TARGET_CARBON + err = ::UMAPrOpen(NULL) ; + if ( err == noErr ) + { + m_printDialogData.ConvertToNative() ; + if ( ::PrJobDialog( (THPrint) m_printDialogData.GetPrintData().m_macPrintSettings ) ) + { + m_printDialogData.ConvertFromNative() ; + result = wxID_OK ; + } + + } + else + { + message.Printf( "Print Error %d", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + } + ::UMAPrClose(NULL) ; #else - #if PM_USE_SESSION_APIS +#if PM_USE_SESSION_APIS Boolean accepted; { @@ -121,16 +121,16 @@ int wxPrintDialog::ShowModal() (m_printDialogData.GetPrintData().m_macPageFormat != kPMNoPageFormat)) { err = PMSessionDefaultPageFormat((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat); + (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat); } } else { err = PMSessionValidatePageFormat((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat, - kPMDontWantBoolean); + (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat, + kPMDontWantBoolean); } - + // Set up a valid PrintSettings object. if (m_printDialogData.GetPrintData().m_macPrintSettings == kPMNoPrintSettings) { @@ -143,14 +143,14 @@ int wxPrintDialog::ShowModal() (m_printDialogData.GetPrintData().m_macPrintSettings != kPMNoPrintSettings)) { err = PMSessionDefaultPrintSettings((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings); + (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings); } } else { err = PMSessionValidatePrintSettings((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings, - kPMDontWantBoolean); + (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings, + kPMDontWantBoolean); } // Set a valid page range before displaying the Print dialog if (err == noErr) @@ -163,9 +163,9 @@ int wxPrintDialog::ShowModal() if (err == noErr) { err = PMSessionPrintDialog((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings, - (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat, - &accepted); + (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings, + (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat, + &accepted); if ((err == noErr) && !accepted) { err = kPMCancel; // user clicked Cancel button @@ -183,11 +183,11 @@ int wxPrintDialog::ShowModal() wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - #else - #pragma warning "TODO: Printing for carbon without session apis" - #endif +#else +#pragma warning "TODO: Printing for carbon without session apis" #endif - return result ; +#endif + return result ; } wxDC *wxPrintDialog::GetPrintDC() @@ -196,17 +196,17 @@ wxDC *wxPrintDialog::GetPrintDC() } /* - * wxPageSetupDialog - */ +* wxPageSetupDialog +*/ wxPageSetupDialog::wxPageSetupDialog(): - wxDialog() +wxDialog() { - m_dialogParent = NULL; + m_dialogParent = NULL; } wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data): - wxDialog() +wxDialog() { Create(p, data); } @@ -214,10 +214,10 @@ wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data): bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data) { m_dialogParent = p; - + if (data) m_pageSetupData = (*data); - + return TRUE; } @@ -227,31 +227,31 @@ wxPageSetupDialog::~wxPageSetupDialog() int wxPageSetupDialog::ShowModal() { - int result = wxID_CANCEL ; - OSErr err ; - wxString message ; - + int result = wxID_CANCEL ; + OSErr err ; + wxString message ; + #if !TARGET_CARBON - err = ::UMAPrOpen(NULL) ; - if ( err == noErr ) - { - m_pageSetupData.ConvertToNative() ; - if ( ::PrStlDialog( (THPrint) m_pageSetupData.GetPrintData().m_macPrintSettings ) ) - { - m_pageSetupData.ConvertFromNative() ; - result = wxID_OK ; - } - - } - else - { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - } - ::UMAPrClose(NULL) ; + err = ::UMAPrOpen(NULL) ; + if ( err == noErr ) + { + m_pageSetupData.ConvertToNative() ; + if ( ::PrStlDialog( (THPrint) m_pageSetupData.GetPrintData().m_macPrintSettings ) ) + { + m_pageSetupData.ConvertFromNative() ; + result = wxID_OK ; + } + + } + else + { + message.Printf( "Print Error %d", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + } + ::UMAPrClose(NULL) ; #else - #if PM_USE_SESSION_APIS +#if PM_USE_SESSION_APIS Boolean accepted; { @@ -269,22 +269,22 @@ int wxPageSetupDialog::ShowModal() (m_pageSetupData.GetPrintData().m_macPageFormat != kPMNoPageFormat)) { err = PMSessionDefaultPageFormat((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat); + (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat); } } else { err = PMSessionValidatePageFormat((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat, - kPMDontWantBoolean); + (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat, + kPMDontWantBoolean); } // Display the Page Setup dialog. if (err == noErr) { err = PMSessionPageSetupDialog((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat, - &accepted); + (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat, + &accepted); if ((err == noErr) && !accepted) { err = kPMCancel; // user clicked Cancel button @@ -305,10 +305,10 @@ int wxPageSetupDialog::ShowModal() wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - #else - #pragma warning "TODO: Printing for carbon without session apis" - #endif +#else +#pragma warning "TODO: Printing for carbon without session apis" +#endif #endif - return result ; + return result ; } diff --git a/src/mac/carbon/printmac.cpp b/src/mac/carbon/printmac.cpp index 60d15137cf..20ea496801 100644 --- a/src/mac/carbon/printmac.cpp +++ b/src/mac/carbon/printmac.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -43,11 +43,11 @@ IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase) #endif /* - * Printer - */ - +* Printer +*/ + wxMacPrinter::wxMacPrinter(wxPrintDialogData *data): - wxPrinterBase(data) +wxPrinterBase(data) { } @@ -57,170 +57,170 @@ wxMacPrinter::~wxMacPrinter(void) bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { - sm_abortIt = FALSE; - sm_abortWindow = NULL; - - if (!printout) - return FALSE; + sm_abortIt = FALSE; + sm_abortWindow = NULL; - printout->SetIsPreview(FALSE); - printout->OnPreparePrinting(); - - // Get some parameters from the printout, if defined - int fromPage, toPage; - int minPage, maxPage; - printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); - - if (maxPage == 0) - return FALSE; - - m_printDialogData.SetMinPage(minPage); - m_printDialogData.SetMaxPage(maxPage); - if (fromPage != 0) - m_printDialogData.SetFromPage(fromPage); - if (toPage != 0) - m_printDialogData.SetToPage(toPage); - - if (minPage != 0) - { - m_printDialogData.EnablePageNumbers(TRUE); - if (m_printDialogData.GetFromPage() < m_printDialogData.GetMinPage()) - m_printDialogData.SetFromPage(m_printDialogData.GetMinPage()); - else if (m_printDialogData.GetFromPage() > m_printDialogData.GetMaxPage()) - m_printDialogData.SetFromPage(m_printDialogData.GetMaxPage()); - if (m_printDialogData.GetToPage() > m_printDialogData.GetMaxPage()) - m_printDialogData.SetToPage(m_printDialogData.GetMaxPage()); - else if (m_printDialogData.GetToPage() < m_printDialogData.GetMinPage()) - m_printDialogData.SetToPage(m_printDialogData.GetMinPage()); - } - else - m_printDialogData.EnablePageNumbers(FALSE); - - // Create a suitable device context - wxDC *dc = NULL; - if (prompt) - { + if (!printout) + return FALSE; + + printout->SetIsPreview(FALSE); + printout->OnPreparePrinting(); + + // Get some parameters from the printout, if defined + int fromPage, toPage; + int minPage, maxPage; + printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); + + if (maxPage == 0) + return FALSE; + + m_printDialogData.SetMinPage(minPage); + m_printDialogData.SetMaxPage(maxPage); + if (fromPage != 0) + m_printDialogData.SetFromPage(fromPage); + if (toPage != 0) + m_printDialogData.SetToPage(toPage); + + if (minPage != 0) + { + m_printDialogData.EnablePageNumbers(TRUE); + if (m_printDialogData.GetFromPage() < m_printDialogData.GetMinPage()) + m_printDialogData.SetFromPage(m_printDialogData.GetMinPage()); + else if (m_printDialogData.GetFromPage() > m_printDialogData.GetMaxPage()) + m_printDialogData.SetFromPage(m_printDialogData.GetMaxPage()); + if (m_printDialogData.GetToPage() > m_printDialogData.GetMaxPage()) + m_printDialogData.SetToPage(m_printDialogData.GetMaxPage()); + else if (m_printDialogData.GetToPage() < m_printDialogData.GetMinPage()) + m_printDialogData.SetToPage(m_printDialogData.GetMinPage()); + } + else + m_printDialogData.EnablePageNumbers(FALSE); + + // Create a suitable device context + wxDC *dc = NULL; + if (prompt) + { wxPrintDialog dialog(parent, & m_printDialogData); if (dialog.ShowModal() == wxID_OK) - { - dc = dialog.GetPrintDC(); - m_printDialogData = dialog.GetPrintData(); - } - } - else - { - dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; - } - - - // May have pressed cancel. - if (!dc || !dc->Ok()) - { - if (dc) delete dc; - return FALSE; - } - - // on the mac we have always pixels as addressing mode with 72 dpi - - printout->SetPPIScreen(72, 72); - printout->SetPPIPrinter(72, 72); - - // Set printout parameters - printout->SetDC(dc); - - int w, h; - wxCoord ww, hh; - dc->GetSize(&w, &h); - printout->SetPageSizePixels((int)w, (int)h); - dc->GetSizeMM(&ww, &hh); - printout->SetPageSizeMM((int)ww, (int)hh); - - // Create an abort window - wxBeginBusyCursor(); - - wxWindow *win = CreateAbortWindow(parent, printout); - wxSafeYield(win,true); - - if (!win) - { - wxEndBusyCursor(); - wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent); - delete dc; - return FALSE; - } - sm_abortWindow = win; - sm_abortWindow->Show(TRUE); - wxSafeYield(win,true); - - printout->OnBeginPrinting(); - - bool keepGoing = TRUE; - - int copyCount; - for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++) - { - if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) + { + dc = dialog.GetPrintDC(); + m_printDialogData = dialog.GetPrintData(); + } + } + else { - wxEndBusyCursor(); - wxMessageBox("Could not start printing.", "Print Error", wxOK, parent); - break; + dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; } - if (sm_abortIt) - break; - - int pn; - for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); - pn++) + + + // May have pressed cancel. + if (!dc || !dc->Ok()) { - if (sm_abortIt) - { - keepGoing = FALSE; - break; - } - else - { - GrafPtr thePort ; - GetPort( &thePort ) ; - wxSafeYield(win,true); - SetPort( thePort ) ; - - dc->StartPage(); - keepGoing = printout->OnPrintPage(pn); - dc->EndPage(); - } + if (dc) delete dc; + return FALSE; } - printout->OnEndDocument(); - } - - printout->OnEndPrinting(); - - if (sm_abortWindow) - { - sm_abortWindow->Show(FALSE); - delete sm_abortWindow; - sm_abortWindow = NULL; - } - - wxEndBusyCursor(); - - delete dc; - - return TRUE; + + // on the mac we have always pixels as addressing mode with 72 dpi + + printout->SetPPIScreen(72, 72); + printout->SetPPIPrinter(72, 72); + + // Set printout parameters + printout->SetDC(dc); + + int w, h; + wxCoord ww, hh; + dc->GetSize(&w, &h); + printout->SetPageSizePixels((int)w, (int)h); + dc->GetSizeMM(&ww, &hh); + printout->SetPageSizeMM((int)ww, (int)hh); + + // Create an abort window + wxBeginBusyCursor(); + + wxWindow *win = CreateAbortWindow(parent, printout); + wxSafeYield(win,true); + + if (!win) + { + wxEndBusyCursor(); + wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent); + delete dc; + return FALSE; + } + sm_abortWindow = win; + sm_abortWindow->Show(TRUE); + wxSafeYield(win,true); + + printout->OnBeginPrinting(); + + bool keepGoing = TRUE; + + int copyCount; + for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++) + { + if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) + { + wxEndBusyCursor(); + wxMessageBox("Could not start printing.", "Print Error", wxOK, parent); + break; + } + if (sm_abortIt) + break; + + int pn; + for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); + pn++) + { + if (sm_abortIt) + { + keepGoing = FALSE; + break; + } + else + { + GrafPtr thePort ; + GetPort( &thePort ) ; + wxSafeYield(win,true); + SetPort( thePort ) ; + + dc->StartPage(); + keepGoing = printout->OnPrintPage(pn); + dc->EndPage(); + } + } + printout->OnEndDocument(); + } + + printout->OnEndPrinting(); + + if (sm_abortWindow) + { + sm_abortWindow->Show(FALSE); + delete sm_abortWindow; + sm_abortWindow = NULL; + } + + wxEndBusyCursor(); + + delete dc; + + return TRUE; } wxDC* wxMacPrinter::PrintDialog(wxWindow *parent) { wxDC* dc = (wxDC*) NULL; - + wxPrintDialog dialog(parent, & m_printDialogData); int ret = dialog.ShowModal(); - + if (ret == wxID_OK) { dc = dialog.GetPrintDC(); m_printDialogData = dialog.GetPrintDialogData(); } - + return dc; } @@ -228,33 +228,33 @@ bool wxMacPrinter::Setup(wxWindow *parent) { wxPrintDialog dialog(parent, & m_printDialogData); dialog.GetPrintDialogData().SetSetupDialog(TRUE); - + int ret = dialog.ShowModal(); - + if (ret == wxID_OK) { m_printDialogData = dialog.GetPrintDialogData(); } - + return (ret == wxID_OK); } /* - * Print preview - */ +* Print preview +*/ wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, - wxPrintout *printoutForPrinting, - wxPrintDialogData *data) - : wxPrintPreviewBase(printout, printoutForPrinting, data) + wxPrintout *printoutForPrinting, + wxPrintDialogData *data) + : wxPrintPreviewBase(printout, printoutForPrinting, data) { DetermineScaling(); } wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data): - wxPrintPreviewBase(printout, printoutForPrinting, data) +wxPrintPreviewBase(printout, printoutForPrinting, data) { - DetermineScaling(); + DetermineScaling(); } wxMacPrintPreview::~wxMacPrintPreview(void) @@ -263,43 +263,43 @@ wxMacPrintPreview::~wxMacPrintPreview(void) bool wxMacPrintPreview::Print(bool interactive) { - if (!m_printPrintout) - return FALSE; - wxMacPrinter printer(&m_printDialogData); - return printer.Print(m_previewFrame, m_printPrintout, interactive); + if (!m_printPrintout) + return FALSE; + wxMacPrinter printer(&m_printDialogData); + return printer.Print(m_previewFrame, m_printPrintout, interactive); } void wxMacPrintPreview::DetermineScaling(void) { - int screenWidth , screenHeight ; - wxDisplaySize( &screenWidth , &screenHeight ) ; - - m_previewPrintout->SetPPIScreen( 72 , 72 ) ; - m_previewPrintout->SetPPIPrinter( 72 , 72 ) ; - m_previewPrintout->SetPageSizeMM( (int) (8.0 * 25.6), (int) (11.0 * 25.6) ); - m_previewPrintout->SetPageSizePixels( 8 * 72 , 11 * 72 ) ; + int screenWidth , screenHeight ; + wxDisplaySize( &screenWidth , &screenHeight ) ; + + m_previewPrintout->SetPPIScreen( 72 , 72 ) ; + m_previewPrintout->SetPPIPrinter( 72 , 72 ) ; + m_previewPrintout->SetPageSizeMM( (int) (8.0 * 25.6), (int) (11.0 * 25.6) ); + m_previewPrintout->SetPageSizePixels( 8 * 72 , 11 * 72 ) ; m_pageWidth = 8 * 72 ; m_pageHeight = 11 * 72 ; m_previewScale = 1 ; - + // Get a device context for the currently selected printer wxPrinterDC printerDC(m_printDialogData.GetPrintData()); if (printerDC.Ok()) { - int x , y ; - wxCoord ww, hh; - printerDC.GetSizeMM(&ww, &hh); - printerDC.GetSize( &x , &y ) ; - m_previewPrintout->SetPageSizeMM((int)ww, (int)hh); - m_previewPrintout->SetPageSizePixels( x , y) ; - m_pageWidth = x ; - m_pageHeight = y ; - m_isOk = true ; - } - else - { - m_isOk = false ; - } + int x , y ; + wxCoord ww, hh; + printerDC.GetSizeMM(&ww, &hh); + printerDC.GetSize( &x , &y ) ; + m_previewPrintout->SetPageSizeMM((int)ww, (int)hh); + m_previewPrintout->SetPageSizePixels( x , y) ; + m_pageWidth = x ; + m_pageHeight = y ; + m_isOk = true ; + } + else + { + m_isOk = false ; + } // At 100%, the page should look about page-size on the screen. // m_previewScale = (float)((float)screenWidth/(float)printerWidth); // m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerXRes); diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index 61e8561c28..15ac067af7 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -6,16 +6,16 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ - #pragma implementation "radioboxbase.h" - #pragma implementation "radiobox.h" +#pragma implementation "radioboxbase.h" +#pragma implementation "radiobox.h" #endif //------------------------------------------------------------------------------------- -// headers +// headers //------------------------------------------------------------------------------------- #include "wx/defs.h" @@ -32,7 +32,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) #pragma mark ### Constructors & destructor ### //------------------------------------------------------------------------------------- -// Â¥ wxRadioBox() +// Â¥ wxRadioBox() //------------------------------------------------------------------------------------- // Default constructor BEGIN_EVENT_TABLE(wxRadioBox, wxControl) @@ -41,15 +41,15 @@ END_EVENT_TABLE() void wxRadioBox::OnRadioButton( wxCommandEvent &outer ) { - if ( outer.IsChecked() ) - { - wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId); - int i = GetSelection() ; - event.SetInt( i ); - event.SetString( GetString( i ) ); - event.SetEventObject( this ); - ProcessCommand(event); - } + if ( outer.IsChecked() ) + { + wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId); + int i = GetSelection() ; + event.SetInt( i ); + event.SetString( GetString( i ) ); + event.SetEventObject( this ); + ProcessCommand(event); + } } wxRadioBox::wxRadioBox() @@ -61,9 +61,9 @@ wxRadioBox::wxRadioBox() } //------------------------------------------------------------------------------------- -// Â¥ wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&, -// const wxSize&, int, const wxString[], int, long, -// const wxValidator&, const wxString&) +// Â¥ wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&, +// const wxSize&, int, const wxString[], int, long, +// const wxValidator&, const wxString&) //------------------------------------------------------------------------------------- // Contructor, creating and showing a radiobox // @@ -71,67 +71,67 @@ wxRadioBox::wxRadioBox() // //------------------------------------------------------------------------------------- -// Â¥ ~wxRadioBox +// Â¥ ~wxRadioBox //------------------------------------------------------------------------------------- // Destructor, destroying the radiobox item wxRadioBox::~wxRadioBox() { - wxRadioButton *next,*current; - + wxRadioButton *next,*current; + current=m_radioButtonCycle->NextInCycle(); next=current->NextInCycle(); while (current!=m_radioButtonCycle) { - delete current; - current=next; - next=current->NextInCycle(); - } + delete current; + current=next; + next=current->NextInCycle(); + } delete current; } //------------------------------------------------------------------------------------- -// Â¥ Create +// Â¥ Create //------------------------------------------------------------------------------------- // Create the radiobox for two-step construction bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, - const wxPoint& pos, const wxSize& size, - int n, const wxString choices[], - int majorDim, long style, - const wxValidator& val, const wxString& name) + const wxPoint& pos, const wxSize& size, + int n, const wxString choices[], + int majorDim, long style, + const wxValidator& val, const wxString& name) { int i; m_noItems = n; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; - + if (majorDim==0) m_majorDim = n ; else m_majorDim = majorDim ; - - + + Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlGroupBoxTextTitleProc , (long) this ) ; + kControlGroupBoxTextTitleProc , (long) this ) ; for (i = 0; i < n; i++) { wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(), wxStripMenuCodes(choices[i]),wxPoint(5,20*i+10), - wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ; + wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ; if ( i == 0 ) - m_radioButtonCycle = radBtn ; -// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); + m_radioButtonCycle = radBtn ; + // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } - + SetSelection(0); MacPostControlCreate() ; - + return TRUE; } @@ -140,7 +140,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, #pragma mark ### Specific functions (reference v2) ### //------------------------------------------------------------------------------------- -// Â¥ Enable(bool) +// Â¥ Enable(bool) //------------------------------------------------------------------------------------- // Enables or disables the entire radiobox @@ -150,18 +150,18 @@ bool wxRadioBox::Enable(bool enable) wxRadioButton *current; if (!wxControl::Enable(enable)) - return false; + return false; current = m_radioButtonCycle; for (i = 0; i < m_noItems; i++) { - current->Enable(enable); - current = current->NextInCycle(); + current->Enable(enable); + current = current->NextInCycle(); } return true; } //------------------------------------------------------------------------------------- -// Â¥ Enable(int, bool) +// Â¥ Enable(int, bool) //------------------------------------------------------------------------------------- // Enables or disables an given button @@ -176,14 +176,14 @@ void wxRadioBox::Enable(int item, bool enable) i = 0; current = m_radioButtonCycle; while (i != item) { - i++; - current = current->NextInCycle(); + i++; + current = current->NextInCycle(); } current->Enable(enable); } //------------------------------------------------------------------------------------- -// Â¥ GetLabel() +// Â¥ GetLabel() //------------------------------------------------------------------------------------- // Returns the radiobox label @@ -193,7 +193,7 @@ wxString wxRadioBox::GetLabel() const } //------------------------------------------------------------------------------------- -// Â¥ GetLabel(int) +// Â¥ GetLabel(int) //------------------------------------------------------------------------------------- // Returns the label for the given button @@ -208,14 +208,14 @@ wxString wxRadioBox::GetString(int item) const i = 0; current = m_radioButtonCycle; while (i != item) { - i++; - current = current->NextInCycle(); + i++; + current = current->NextInCycle(); } return current->GetLabel(); } //------------------------------------------------------------------------------------- -// Â¥ GetSelection +// Â¥ GetSelection //------------------------------------------------------------------------------------- // Returns the zero-based position of the selected button @@ -227,15 +227,15 @@ int wxRadioBox::GetSelection() const i=0; current=m_radioButtonCycle; while (!current->GetValue()) { - i++; - current=current->NextInCycle(); - } - + i++; + current=current->NextInCycle(); + } + return i; } //------------------------------------------------------------------------------------- -// Â¥ Number +// Â¥ Number //------------------------------------------------------------------------------------- // Returns the number of buttons in the radiobox // @@ -243,7 +243,7 @@ int wxRadioBox::GetSelection() const // //------------------------------------------------------------------------------------- -// Â¥ SetLabel(const wxString&) +// Â¥ SetLabel(const wxString&) //------------------------------------------------------------------------------------- // Sets the radiobox label @@ -253,28 +253,28 @@ void wxRadioBox::SetLabel(const wxString& label) } //------------------------------------------------------------------------------------- -// Â¥ SetLabel(int, const wxString&) +// Â¥ SetLabel(int, const wxString&) //------------------------------------------------------------------------------------- // Sets the label of a given button void wxRadioBox::SetString(int item,const wxString& label) { - int i; + int i; wxRadioButton *current; if ((item < 0) || (item >= m_noItems)) return; - i=0; + i=0; current=m_radioButtonCycle; while (i!=item) { - i++; - current=current->NextInCycle(); - } + i++; + current=current->NextInCycle(); + } return current->SetLabel(label); } //------------------------------------------------------------------------------------- -// Â¥ SetSelection +// Â¥ SetSelection //------------------------------------------------------------------------------------- // Sets a button by passing the desired position. This does not cause // wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted @@ -289,15 +289,15 @@ void wxRadioBox::SetSelection(int item) i=0; current=m_radioButtonCycle; while (i!=item) { - i++; - current=current->NextInCycle(); - } + i++; + current=current->NextInCycle(); + } current->SetValue(true); } //------------------------------------------------------------------------------------- -// Â¥ Show(bool) +// Â¥ Show(bool) //------------------------------------------------------------------------------------- // Shows or hides the entire radiobox @@ -307,23 +307,23 @@ bool wxRadioBox::Show(bool show) wxRadioButton *current; wxControl::Show(show); - + current=m_radioButtonCycle; - for (i=0;iShow(show); - current=current->NextInCycle(); - } + for (i=0;iShow(show); + current=current->NextInCycle(); + } return true; } //------------------------------------------------------------------------------------- -// Â¥ Show(int, bool) +// Â¥ Show(int, bool) //------------------------------------------------------------------------------------- // Shows or hides the given button void wxRadioBox::Show(int item, bool show) { - int i; + int i; wxRadioButton *current; if ((item < 0) || (item >= m_noItems)) @@ -331,9 +331,9 @@ void wxRadioBox::Show(int item, bool show) i=0; current=m_radioButtonCycle; while (i!=item) { - i++; - current=current->NextInCycle(); - } + i++; + current=current->NextInCycle(); + } current->Show(show); } @@ -341,7 +341,7 @@ void wxRadioBox::Show(int item, bool show) #pragma mark ### Other external functions ### //------------------------------------------------------------------------------------- -// Â¥ Command +// Â¥ Command //------------------------------------------------------------------------------------- // Simulates the effect of the user issuing a command to the item @@ -352,7 +352,7 @@ void wxRadioBox::Command (wxCommandEvent & event) } //------------------------------------------------------------------------------------- -// Â¥ SetFocus +// Â¥ SetFocus //------------------------------------------------------------------------------------- // Sets the selected button to receive keyboard input @@ -364,10 +364,10 @@ void wxRadioBox::SetFocus() i=0; current=m_radioButtonCycle; while (!current->GetValue()) { - i++; - current=current->NextInCycle(); - } - current->SetFocus(); + i++; + current=current->NextInCycle(); + } + current->SetFocus(); } @@ -375,7 +375,7 @@ void wxRadioBox::SetFocus() #pragma mark ### Internal functions ### //------------------------------------------------------------------------------------- -// Â¥ DoSetSize +// Â¥ DoSetSize //------------------------------------------------------------------------------------- // Simulates the effect of the user issuing a command to the item @@ -383,49 +383,49 @@ void wxRadioBox::SetFocus() void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - int i; - wxRadioButton *current; - -// define the position - - int x_current, y_current; - int x_offset,y_offset; + int i; + wxRadioButton *current; + + // define the position + + int x_current, y_current; + int x_offset,y_offset; int widthOld, heightOld; GetSize(&widthOld, &heightOld); - - x_offset = x; - y_offset = y; - GetPosition(&x_current, &y_current); - if ((x == -1) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - x_offset = x_current; - if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - y_offset = y_current; - -// define size - - int charWidth,charHeight; - int maxWidth,maxHeight; - int eachWidth[128],eachHeight[128]; + + x_offset = x; + y_offset = y; + GetPosition(&x_current, &y_current); + if ((x == -1) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + x_offset = x_current; + if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + y_offset = y_current; + + // define size + + int charWidth,charHeight; + int maxWidth,maxHeight; + int eachWidth[128],eachHeight[128]; int totWidth,totHeight; - - SetFont(GetParent()->GetFont()); - GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); - charWidth/=52; - - maxWidth=-1; - maxHeight=-1; - for (i = 0 ; i < m_noItems; i++) - { - GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i]); - eachWidth[i] = (int)(eachWidth[i] + RADIO_SIZE); - eachHeight[i] = (int)((3*eachHeight[i])/2); - if (maxWidthGetFont()); + GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); + charWidth/=52; + + maxWidth=-1; + maxHeight=-1; + for (i = 0 ; i < m_noItems; i++) + { + GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i]); + eachWidth[i] = (int)(eachWidth[i] + RADIO_SIZE); + eachHeight[i] = (int)((3*eachHeight[i])/2); + if (maxWidthSetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]); - current=current->NextInCycle(); - - if (m_windowStyle & wxRA_SPECIFY_ROWS) - y_offset += maxHeight ; /*+ charHeight/2;*/ - else - x_offset += maxWidth + charWidth; - } + + wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO); + + // arrange radiobuttons + + int x_start,y_start; + + + x_start = charWidth; + y_start = 15 ; + x_offset = x_start; + y_offset = y_start; + + current=m_radioButtonCycle; + for ( i = 0 ; i < m_noItems; i++) + { + if (i&&((i%m_majorDim)==0)) // not to do for the zero button! + { + if (m_windowStyle & wxRA_VERTICAL) + { + x_offset += maxWidth + charWidth; + y_offset = y_start; + } + else + { + x_offset = x_start; + y_offset += maxHeight ; /*+ charHeight/2;*/ + } + } + + current->SetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]); + current=current->NextInCycle(); + + if (m_windowStyle & wxRA_SPECIFY_ROWS) + y_offset += maxHeight ; /*+ charHeight/2;*/ + else + x_offset += maxWidth + charWidth; + } } wxSize wxRadioBox::DoGetBestSize() const @@ -488,37 +488,37 @@ wxSize wxRadioBox::DoGetBestSize() const int maxWidth, maxHeight; int eachWidth, eachHeight; int totWidth, totHeight; - + wxFont font = GetParent()->GetFont(); GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), - &charWidth, &charHeight, NULL, NULL, &font); + &charWidth, &charHeight, NULL, NULL, &font); charWidth /= 52; - - maxWidth = -1; - maxHeight = -1; - - for (int i = 0 ; i < m_noItems; i++) - { + + maxWidth = -1; + maxHeight = -1; + + for (int i = 0 ; i < m_noItems; i++) + { GetTextExtent(GetString(i), &eachWidth, &eachHeight); eachWidth = (int)(eachWidth + RADIO_SIZE) ; eachHeight = (int)((3 * eachHeight) / 2); if (maxWidth < eachWidth) maxWidth = eachWidth; if (maxHeight < eachHeight) maxHeight = eachHeight; } - + totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight * 3/2; totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth; - + // handle radio box title as well GetTextExtent(GetTitle(), &eachWidth, NULL); eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ; if (totWidth < eachWidth) totWidth = eachWidth; - - return wxSize(totWidth, totHeight); + + return wxSize(totWidth, totHeight); } //------------------------------------------------------------------------------------- -// Â¥ GetNumVer +// Â¥ GetNumVer //------------------------------------------------------------------------------------- // return the number of buttons in the vertical direction @@ -535,7 +535,7 @@ int wxRadioBox::GetRowCount() const } //------------------------------------------------------------------------------------- -// Â¥ GetNumHor +// Â¥ GetNumHor //------------------------------------------------------------------------------------- // return the number of buttons in the horizontal direction diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index e94c762f1d..46014e4576 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -6,7 +6,7 @@ // Created: ??/??/98 // RCS-ID: $Id$ // Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,27 +24,27 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) #include "wx/mac/uma.h" bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, - const wxString& label, + const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlRadioButtonProc , (long) this ) ; - - MacPostControlCreate() ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlRadioButtonProc , (long) this ) ; + + MacPostControlCreate() ; m_cycle = this ; if (HasFlag(wxRB_GROUP)) { - AddInCycle( NULL ) ; + AddInCycle( NULL ) ; } else { @@ -68,21 +68,21 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, void wxRadioButton::SetValue(bool val) { - wxRadioButton *cycle; - if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val ) - return ; - + wxRadioButton *cycle; + if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val ) + return ; + ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; if (val) { - cycle=this->NextInCycle(); - if (cycle!=NULL) { - while (cycle!=this) { - cycle->SetValue(false); - cycle=cycle->NextInCycle(); - } - } - } + cycle=this->NextInCycle(); + if (cycle!=NULL) { + while (cycle!=this) { + cycle->SetValue(false); + cycle=cycle->NextInCycle(); + } + } + } MacRedrawControl() ; } @@ -102,19 +102,19 @@ void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpar if ( GetValue() ) return ; - wxRadioButton *cycle, *old = NULL ; + wxRadioButton *cycle, *old = NULL ; cycle=this->NextInCycle(); if (cycle!=NULL) { - while (cycle!=this) { - if ( cycle->GetValue() ) { - old = cycle ; - cycle->SetValue(false); - } - cycle=cycle->NextInCycle(); - } + while (cycle!=this) { + if ( cycle->GetValue() ) { + old = cycle ; + cycle->SetValue(false); + } + cycle=cycle->NextInCycle(); + } } - SetValue(true) ; + SetValue(true) ; if ( old ) { wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, old->m_windowId ); @@ -130,18 +130,18 @@ void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpar wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle) { - wxRadioButton *next,*current; - - if (cycle==NULL) { - m_cycle=this; - return(this); - } - else { - current=cycle; - while ((next=current->m_cycle)!=cycle) - current=current->m_cycle; - m_cycle=cycle; - current->m_cycle=this; - return(cycle); - } + wxRadioButton *next,*current; + + if (cycle==NULL) { + m_cycle=this; + return(this); + } + else { + current=cycle; + while ((next=current->m_cycle)!=cycle) + current=current->m_cycle; + m_cycle=cycle; + current->m_cycle=this; + return(cycle); + } } diff --git a/src/mac/carbon/region.cpp b/src/mac/carbon/region.cpp index 6c1ef13da2..b151987990 100644 --- a/src/mac/carbon/region.cpp +++ b/src/mac/carbon/region.cpp @@ -3,7 +3,7 @@ // Purpose: Region class // Author: Markus Holzem/Julian Smart/Stefan Csomor // Created: Fri Oct 24 10:46:34 MET 1997 -// RCS-ID: $Id$ +// RCS-ID: $Id$ // Copyright: (c) 1997 Markus Holzem/Julian Smart/Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,8 +17,8 @@ #include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY - IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) - IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject) + IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) + IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject) #endif //----------------------------------------------------------------------------- @@ -43,7 +43,7 @@ public: { DisposeRgn( m_macRgn ) ; } - RgnHandle m_macRgn ; + RgnHandle m_macRgn ; }; #define M_REGION (((wxRegionRefData*)m_refData)->m_macRgn) @@ -106,20 +106,20 @@ void wxRegion::Clear() //! Combine rectangle (x, y, w, h) with this. bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) { - // Don't change shared data - if (!m_refData) - { - m_refData = new wxRegionRefData(); - } - else if (m_refData->GetRefCount() > 1) - { - wxRegionRefData* ref = (wxRegionRefData*)m_refData; - UnRef(); - m_refData = new wxRegionRefData(*ref); - } + // Don't change shared data + if (!m_refData) + { + m_refData = new wxRegionRefData(); + } + else if (m_refData->GetRefCount() > 1) + { + wxRegionRefData* ref = (wxRegionRefData*)m_refData; + UnRef(); + m_refData = new wxRegionRefData(*ref); + } RgnHandle rgn = NewRgn() ; - SetRectRgn( rgn , x , y, x+width,y + height ) ; - + SetRectRgn( rgn , x , y, x+width,y + height ) ; + switch (op) { case wxRGN_AND: @@ -136,11 +136,11 @@ bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) break ; case wxRGN_COPY: default: - CopyRgn( rgn ,M_REGION ) ; + CopyRgn( rgn ,M_REGION ) ; break ; } - DisposeRgn( rgn ) ; + DisposeRgn( rgn ) ; return TRUE; } @@ -148,19 +148,19 @@ bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) //! Union /e region with this. bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) { - if (region.Empty()) - return FALSE; - - // Don't change shared data - if (!m_refData) { - m_refData = new wxRegionRefData(); - } - else if (m_refData->GetRefCount() > 1) - { - wxRegionRefData* ref = (wxRegionRefData*)m_refData; - UnRef(); - m_refData = new wxRegionRefData(*ref); - } + if (region.Empty()) + return FALSE; + + // Don't change shared data + if (!m_refData) { + m_refData = new wxRegionRefData(); + } + else if (m_refData->GetRefCount() > 1) + { + wxRegionRefData* ref = (wxRegionRefData*)m_refData; + UnRef(); + m_refData = new wxRegionRefData(*ref); + } switch (op) { @@ -178,11 +178,11 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) break ; case wxRGN_COPY: default: - CopyRgn( OTHER_M_REGION(region) ,M_REGION ) ; + CopyRgn( OTHER_M_REGION(region) ,M_REGION ) ; break ; } - return TRUE; + return TRUE; } bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) @@ -197,19 +197,19 @@ bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) // Outer bounds of region void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const { - if (m_refData) - { - Rect box ; - GetRegionBounds( M_REGION , &box ) ; + if (m_refData) + { + Rect box ; + GetRegionBounds( M_REGION , &box ) ; x = box.left ; y = box.top ; w = box.right - box.left ; h = box.bottom - box.top ; - } - else - { - x = y = w = h = 0; - } + } + else + { + x = y = w = h = 0; + } } wxRect wxRegion::GetBox() const @@ -227,7 +227,7 @@ bool wxRegion::Empty() const const WXHRGN wxRegion::GetWXHRGN() const { - return M_REGION ; + return M_REGION ; } //----------------------------------------------------------------------------- @@ -237,8 +237,8 @@ const WXHRGN wxRegion::GetWXHRGN() const // Does the region contain the point (x,y)? wxRegionContain wxRegion::Contains(long x, long y) const { - if (!m_refData) - return wxOutRegion; + if (!m_refData) + return wxOutRegion; // TODO. Return wxInRegion if within region. if (0) @@ -249,8 +249,8 @@ wxRegionContain wxRegion::Contains(long x, long y) const // Does the region contain the point pt? wxRegionContain wxRegion::Contains(const wxPoint& pt) const { - if (!m_refData) - return wxOutRegion; + if (!m_refData) + return wxOutRegion; Point p = { pt.y , pt.x } ; if (PtInRgn( p , M_REGION ) ) @@ -262,8 +262,8 @@ wxRegionContain wxRegion::Contains(const wxPoint& pt) const // Does the region contain the rectangle (x, y, w, h)? wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const { - if (!m_refData) - return wxOutRegion; + if (!m_refData) + return wxOutRegion; Rect rect = { y , x , y + h , x + w } ; if (RectInRgn( &rect , M_REGION ) ) @@ -275,8 +275,8 @@ wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const // Does the region contain the rectangle rect wxRegionContain wxRegion::Contains(const wxRect& rect) const { - if (!m_refData) - return wxOutRegion; + if (!m_refData) + return wxOutRegion; long x, y, w, h; x = rect.x; @@ -370,7 +370,7 @@ void wxRegionIterator::Reset(const wxRegion& region) m_numRects = 0; else { - // we cannot dissolve it into rects on mac + // we cannot dissolve it into rects on mac m_rects = new wxRect[1]; Rect rect ; GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ; @@ -409,29 +409,29 @@ wxRegionIterator wxRegionIterator::operator ++ (int) long wxRegionIterator::GetX() const { - if (m_current < m_numRects) - return m_rects[m_current].x; - return 0; + if (m_current < m_numRects) + return m_rects[m_current].x; + return 0; } long wxRegionIterator::GetY() const { - if (m_current < m_numRects) - return m_rects[m_current].y; - return 0; + if (m_current < m_numRects) + return m_rects[m_current].y; + return 0; } long wxRegionIterator::GetW() const { - if (m_current < m_numRects) - return m_rects[m_current].width ; - return 0; + if (m_current < m_numRects) + return m_rects[m_current].width ; + return 0; } long wxRegionIterator::GetH() const { - if (m_current < m_numRects) - return m_rects[m_current].height; - return 0; + if (m_current < m_numRects) + return m_rects[m_current].height; + return 0; } diff --git a/src/mac/carbon/scrolbar.cpp b/src/mac/carbon/scrolbar.cpp index d341b03c4a..6f57b2c40d 100644 --- a/src/mac/carbon/scrolbar.cpp +++ b/src/mac/carbon/scrolbar.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -43,19 +43,19 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, if (!parent) return FALSE; - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , true , 0 , 0 , 100, - kControlScrollBarLiveProc , (long) this ) ; - - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , true , 0 , 0 , 100, + kControlScrollBarLiveProc , (long) this ) ; + + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; + ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; - MacPostControlCreate() ; + MacPostControlCreate() ; return TRUE; } @@ -81,7 +81,7 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS m_viewSize = thumbSize; m_objectSize = range; - int range1 = wxMax((m_objectSize - m_viewSize), 0) ; + int range1 = wxMax((m_objectSize - m_viewSize), 0) ; SetControl32BitMaximum( (ControlHandle) m_macControl , range1 ) ; SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; @@ -91,7 +91,7 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS { if ( SetControlViewSize != (void*) kUnresolvedCFragSymbolAddress ) { - SetControlViewSize( (ControlHandle) m_macControl , m_viewSize ) ; + SetControlViewSize( (ControlHandle) m_macControl , m_viewSize ) ; } } if ( refresh ) @@ -107,70 +107,70 @@ void wxScrollBar::Command(wxCommandEvent& event) void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - if ( (ControlHandle) m_macControl == NULL ) - return ; - - int position = GetControl32BitValue( (ControlHandle) m_macControl) ; - int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ; - int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ; - - wxEventType scrollEvent = wxEVT_NULL; - int nScrollInc; - - switch( controlpart ) - { - case kControlUpButtonPart : + if ( (ControlHandle) m_macControl == NULL ) + return ; + + int position = GetControl32BitValue( (ControlHandle) m_macControl) ; + int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ; + int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ; + + wxEventType scrollEvent = wxEVT_NULL; + int nScrollInc; + + switch( controlpart ) + { + case kControlUpButtonPart : nScrollInc = -1; scrollEvent = wxEVT_SCROLL_LINEUP; - break ; - case kControlDownButtonPart : + break ; + case kControlDownButtonPart : nScrollInc = 1; scrollEvent = wxEVT_SCROLL_LINEDOWN; - break ; - case kControlPageUpPart : + break ; + case kControlPageUpPart : nScrollInc = -m_pageSize; scrollEvent = wxEVT_SCROLL_PAGEUP; - break ; - case kControlPageDownPart : + break ; + case kControlPageDownPart : nScrollInc = m_pageSize; scrollEvent = wxEVT_SCROLL_PAGEDOWN; - break ; - case kControlIndicatorPart : + break ; + case kControlIndicatorPart : nScrollInc = 0 ; scrollEvent = wxEVT_SCROLL_THUMBTRACK; - break ; - default : - wxFAIL_MSG(wxT("illegal scrollbar selector")); - break ; - } - - int new_pos = position + nScrollInc; - - if (new_pos < minPos) - new_pos = minPos; - if (new_pos > maxPos) - new_pos = maxPos; - if ( nScrollInc ) - SetThumbPosition(new_pos); - - wxScrollEvent event(scrollEvent, m_windowId); - if ( m_windowStyle & wxHORIZONTAL ) - { - event.SetOrientation( wxHORIZONTAL ) ; - } - else - { - event.SetOrientation( wxVERTICAL ) ; - } - event.SetPosition(new_pos); - event.SetEventObject( this ); - wxWindow* window = GetParent() ; - if (window && window->MacIsWindowScrollbar(this) ) - { - // this is hardcoded - window->MacOnScroll(event); - } - else - GetEventHandler()->ProcessEvent(event); + break ; + default : + wxFAIL_MSG(wxT("illegal scrollbar selector")); + break ; + } + + int new_pos = position + nScrollInc; + + if (new_pos < minPos) + new_pos = minPos; + if (new_pos > maxPos) + new_pos = maxPos; + if ( nScrollInc ) + SetThumbPosition(new_pos); + + wxScrollEvent event(scrollEvent, m_windowId); + if ( m_windowStyle & wxHORIZONTAL ) + { + event.SetOrientation( wxHORIZONTAL ) ; + } + else + { + event.SetOrientation( wxVERTICAL ) ; + } + event.SetPosition(new_pos); + event.SetEventObject( this ); + wxWindow* window = GetParent() ; + if (window && window->MacIsWindowScrollbar(this) ) + { + // this is hardcoded + window->MacOnScroll(event); + } + else + GetEventHandler()->ProcessEvent(event); } diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index f27d107c83..2a95191da2 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,101 +24,100 @@ END_EVENT_TABLE() #endif // The dimensions of the different styles of sliders (From Aqua document) - #define wxSLIDER_DIMENSIONACROSS 15 - #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24 - #define wxSLIDER_DIMENSIONACROSS_ARROW 18 +#define wxSLIDER_DIMENSIONACROSS 15 +#define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24 +#define wxSLIDER_DIMENSIONACROSS_ARROW 18 - // Distance between slider and text - #define wxSLIDER_BORDERTEXT 5 +// Distance between slider and text +#define wxSLIDER_BORDERTEXT 5 - /* NB! The default orientation for a slider is horizontal however if the user specifies - * some slider styles but dosen't specify the orientation we have to assume he wants a - * horizontal one. Therefore in this file when testing for the sliders orientation - * vertical is tested for if this is not set then we use the horizontal one - * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }> - */ - - -// Slider -wxSlider::wxSlider() +/* NB! The default orientation for a slider is horizontal however if the user specifies + * some slider styles but dosen't specify the orientation we have to assume he wants a + * horizontal one. Therefore in this file when testing for the sliders orientation + * vertical is tested for if this is not set then we use the horizontal one + * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }> + */ + + // Slider + wxSlider::wxSlider() { - m_pageSize = 1; - m_lineSize = 1; - m_rangeMax = 0; - m_rangeMin = 0; - m_tickFreq = 0; + m_pageSize = 1; + m_lineSize = 1; + m_rangeMax = 0; + m_rangeMin = 0; + m_tickFreq = 0; } extern ControlActionUPP wxMacLiveScrollbarActionUPP ; bool wxSlider::Create(wxWindow *parent, wxWindowID id, - int value, int minValue, int maxValue, - const wxPoint& pos, - const wxSize& size, long style, - const wxValidator& validator, - const wxString& name) + int value, int minValue, int maxValue, + const wxPoint& pos, + const wxSize& size, long style, + const wxValidator& validator, + const wxString& name) { - Rect bounds ; - Str255 title ; - SInt16 procID; - - m_macMinimumStatic = NULL ; - m_macMaximumStatic = NULL ; - m_macValueStatic = NULL ; - - - m_lineSize = 1; - m_tickFreq = 0; - - m_rangeMax = maxValue; - m_rangeMin = minValue; - - m_pageSize = (int)((maxValue-minValue)/10); - - MacPreControlCreate( parent, id, "", pos, size, style, - validator, name, &bounds, title ); - - procID = kControlSliderProc + kControlSliderLiveFeedback; - if(style & wxSL_AUTOTICKS) { - procID += kControlSliderHasTickMarks; + Rect bounds ; + Str255 title ; + SInt16 procID; + + m_macMinimumStatic = NULL ; + m_macMaximumStatic = NULL ; + m_macValueStatic = NULL ; + + + m_lineSize = 1; + m_tickFreq = 0; + + m_rangeMax = maxValue; + m_rangeMin = minValue; + + m_pageSize = (int)((maxValue-minValue)/10); + + MacPreControlCreate( parent, id, "", pos, size, style, + validator, name, &bounds, title ); + + procID = kControlSliderProc + kControlSliderLiveFeedback; + if(style & wxSL_AUTOTICKS) { + procID += kControlSliderHasTickMarks; } - - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, - value, minValue, maxValue, procID, (long) this); - - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - - ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; - - if(style & wxSL_LABELS) - { - m_macMinimumStatic = new wxStaticText( this, -1, "" ); - m_macMaximumStatic = new wxStaticText( this, -1, "" ); - m_macValueStatic = new wxStaticText( this, -1, "" ); - SetRange(minValue, maxValue); - SetValue(value); + + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, + value, minValue, maxValue, procID, (long) this); + + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + + ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; + + if(style & wxSL_LABELS) + { + m_macMinimumStatic = new wxStaticText( this, -1, "" ); + m_macMaximumStatic = new wxStaticText( this, -1, "" ); + m_macValueStatic = new wxStaticText( this, -1, "" ); + SetRange(minValue, maxValue); + SetValue(value); } - - else { - m_macMinimumStatic = NULL ; - m_macMaximumStatic = NULL ; - m_macValueStatic = NULL ; - } - - if(style & wxSL_VERTICAL) { - SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width - } - else { - SetSizeHints(-1, 10, -1, 10); // Forces SetSize to use the proper height - } - // NB! SetSizeHints is overloaded by wxSlider and will substitute 10 with the - // proper dimensions, it also means other people cannot bugger the slider with - // other values - - MacPostControlCreate() ; - - return true; + + else { + m_macMinimumStatic = NULL ; + m_macMaximumStatic = NULL ; + m_macValueStatic = NULL ; + } + + if(style & wxSL_VERTICAL) { + SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width + } + else { + SetSizeHints(-1, 10, -1, 10); // Forces SetSize to use the proper height + } + // NB! SetSizeHints is overloaded by wxSlider and will substitute 10 with the + // proper dimensions, it also means other people cannot bugger the slider with + // other values + + MacPostControlCreate() ; + + return true; } wxSlider::~wxSlider() @@ -127,37 +126,37 @@ wxSlider::~wxSlider() int wxSlider::GetValue() const { - return GetControl32BitValue( (ControlHandle) m_macControl) ; + return GetControl32BitValue( (ControlHandle) m_macControl) ; } void wxSlider::SetValue(int value) { - wxString valuestring ; - valuestring.Printf( "%d" , value ) ; - if ( m_macValueStatic ) - m_macValueStatic->SetLabel( valuestring ) ; - SetControl32BitValue( (ControlHandle) m_macControl , value ) ; + wxString valuestring ; + valuestring.Printf( "%d" , value ) ; + if ( m_macValueStatic ) + m_macValueStatic->SetLabel( valuestring ) ; + SetControl32BitValue( (ControlHandle) m_macControl , value ) ; } void wxSlider::SetRange(int minValue, int maxValue) { - wxString value; - - m_rangeMin = minValue; - m_rangeMax = maxValue; - - SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); - SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); - - if(m_macMinimumStatic) { - value.Printf("%d", m_rangeMin); - m_macMinimumStatic->SetLabel(value); - } - if(m_macMaximumStatic) { - value.Printf("%d", m_rangeMax); - m_macMaximumStatic->SetLabel(value); - } - SetValue(m_rangeMin); + wxString value; + + m_rangeMin = minValue; + m_rangeMax = maxValue; + + SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); + SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); + + if(m_macMinimumStatic) { + value.Printf("%d", m_rangeMin); + m_macMinimumStatic->SetLabel(value); + } + if(m_macMaximumStatic) { + value.Printf("%d", m_rangeMax); + m_macMaximumStatic->SetLabel(value); + } + SetValue(m_rangeMin); } // For trackbars only @@ -235,164 +234,164 @@ void wxSlider::SetTick(int tickPos) void wxSlider::Command (wxCommandEvent & event) { - SetValue (event.GetInt()); - ProcessCommand (event); + SetValue (event.GetInt()); + ProcessCommand (event); } void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; - - SetValue( value ) ; - - wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); - event.SetPosition(value); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent(event); - - wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); - cevent.SetInt( value ); - cevent.SetEventObject( this ); - - GetEventHandler()->ProcessEvent( cevent ); + SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; + + SetValue( value ) ; + + wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); + event.SetPosition(value); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); + + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); + cevent.SetInt( value ); + cevent.SetEventObject( this ); + + GetEventHandler()->ProcessEvent( cevent ); +} + +/* This is overloaded in wxSlider so that the proper width/height will always be used +* for the slider different values would cause redrawing and mouse detection problems */ +void wxSlider::SetSizeHints( int minW, int minH, + int maxW , int maxH , + int incW , int incH ) +{ + wxSize size = GetBestSize(); + + if(GetWindowStyle() & wxSL_VERTICAL) { + wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH); + } + else { + wxWindow::SetSizeHints(minW, size.y, maxW, size.y, incW, incH); + } } - /* This is overloaded in wxSlider so that the proper width/height will always be used - * for the slider different values would cause redrawing and mouse detection problems */ - void wxSlider::SetSizeHints( int minW, int minH, - int maxW , int maxH , - int incW , int incH ) - { - wxSize size = GetBestSize(); - - if(GetWindowStyle() & wxSL_VERTICAL) { - wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH); - } - else { - wxWindow::SetSizeHints(minW, size.y, maxW, size.y, incW, incH); - } - } - - wxSize wxSlider::DoGetBestSize() const - { - wxSize size; - int textwidth, textheight; - - if(GetWindowStyle() & wxSL_LABELS) - { - wxString text; - int ht, wd; - - // Get maximum text label width and height - text.Printf("%d", m_rangeMin); - GetTextExtent(text, &textwidth, &textheight); - text.Printf("%d", m_rangeMax); - GetTextExtent(text, &wd, &ht); - if(ht > textheight) { - textheight = ht; - } - if (wd > textwidth) { - textwidth = wd; - } - } - - if(GetWindowStyle() & wxSL_VERTICAL) - { - if(GetWindowStyle() & wxSL_AUTOTICKS) { - size.x = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; - } - else { - size.x = wxSLIDER_DIMENSIONACROSS_ARROW; - } - if(GetWindowStyle() & wxSL_LABELS) { - size.x += textwidth + wxSLIDER_BORDERTEXT; - } - size.y = 150; - } - else - { - if(GetWindowStyle() & wxSL_AUTOTICKS) { - size.y = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; - } - else { - size.y = wxSLIDER_DIMENSIONACROSS_ARROW; - } - if(GetWindowStyle() & wxSL_LABELS) { - size.y += textheight + wxSLIDER_BORDERTEXT; - } - size.x = 150; - } - return size; - } - - void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags) - { +wxSize wxSlider::DoGetBestSize() const +{ + wxSize size; + int textwidth, textheight; + + if(GetWindowStyle() & wxSL_LABELS) + { + wxString text; + int ht, wd; + + // Get maximum text label width and height + text.Printf("%d", m_rangeMin); + GetTextExtent(text, &textwidth, &textheight); + text.Printf("%d", m_rangeMax); + GetTextExtent(text, &wd, &ht); + if(ht > textheight) { + textheight = ht; + } + if (wd > textwidth) { + textwidth = wd; + } + } + + if(GetWindowStyle() & wxSL_VERTICAL) + { + if(GetWindowStyle() & wxSL_AUTOTICKS) { + size.x = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; + } + else { + size.x = wxSLIDER_DIMENSIONACROSS_ARROW; + } + if(GetWindowStyle() & wxSL_LABELS) { + size.x += textwidth + wxSLIDER_BORDERTEXT; + } + size.y = 150; + } + else + { + if(GetWindowStyle() & wxSL_AUTOTICKS) { + size.y = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; + } + else { + size.y = wxSLIDER_DIMENSIONACROSS_ARROW; + } + if(GetWindowStyle() & wxSL_LABELS) { + size.y += textheight + wxSLIDER_BORDERTEXT; + } + size.x = 150; + } + return size; +} + +void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags) +{ wxControl::DoSetSize( x, y , width , height ,sizeFlags ) ; - } - - void wxSlider::MacUpdateDimensions() +} + +void wxSlider::MacUpdateDimensions() { - // actually in the current systems this should never be possible, but later reparenting - // may become a reality - - if ( (ControlHandle) m_macControl == NULL ) - return ; - - if ( GetParent() == NULL ) - return ; - + // actually in the current systems this should never be possible, but later reparenting + // may become a reality + + if ( (ControlHandle) m_macControl == NULL ) + return ; + + if ( GetParent() == NULL ) + return ; + WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; if ( rootwindow == NULL ) - return ; - - int xborder, yborder; - int minValWidth, maxValWidth, textwidth, textheight; - int sliderBreadth; - - xborder = yborder = 0; - - if (GetWindowStyle() & wxSL_LABELS) - { - wxString text; - int ht; - - // Get maximum text label width and height - text.Printf("%d", m_rangeMin); - GetTextExtent(text, &minValWidth, &textheight); - text.Printf("%d", m_rangeMax); - GetTextExtent(text, &maxValWidth, &ht); - if(ht > textheight) { - textheight = ht; - } - textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); - - xborder = textwidth + wxSLIDER_BORDERTEXT; - yborder = textheight + wxSLIDER_BORDERTEXT; - - // Get slider breadth - if(GetWindowStyle() & wxSL_AUTOTICKS) { - sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; - } - else { - sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; - } - - if(GetWindowStyle() & wxSL_VERTICAL) - { - m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, - m_height - yborder - textheight); - m_macMaximumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, 0); - m_macValueStatic->Move(0, m_height - textheight); - } - else - { - m_macMinimumStatic->Move(0, sliderBreadth + wxSLIDER_BORDERTEXT); - m_macMaximumStatic->Move(m_width - xborder - maxValWidth / 2, - sliderBreadth + wxSLIDER_BORDERTEXT); - m_macValueStatic->Move(m_width - textwidth, 0); - } - } - + return ; + + int xborder, yborder; + int minValWidth, maxValWidth, textwidth, textheight; + int sliderBreadth; + + xborder = yborder = 0; + + if (GetWindowStyle() & wxSL_LABELS) + { + wxString text; + int ht; + + // Get maximum text label width and height + text.Printf("%d", m_rangeMin); + GetTextExtent(text, &minValWidth, &textheight); + text.Printf("%d", m_rangeMax); + GetTextExtent(text, &maxValWidth, &ht); + if(ht > textheight) { + textheight = ht; + } + textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); + + xborder = textwidth + wxSLIDER_BORDERTEXT; + yborder = textheight + wxSLIDER_BORDERTEXT; + + // Get slider breadth + if(GetWindowStyle() & wxSL_AUTOTICKS) { + sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; + } + else { + sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; + } + + if(GetWindowStyle() & wxSL_VERTICAL) + { + m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, + m_height - yborder - textheight); + m_macMaximumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, 0); + m_macValueStatic->Move(0, m_height - textheight); + } + else + { + m_macMinimumStatic->Move(0, sliderBreadth + wxSLIDER_BORDERTEXT); + m_macMaximumStatic->Move(m_width - xborder - maxValWidth / 2, + sliderBreadth + wxSLIDER_BORDERTEXT); + m_macValueStatic->Move(m_width - textwidth, 0); + } + } + Rect oldBounds ; GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; @@ -404,18 +403,18 @@ void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ; bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ; bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ; - if ( doMove || doResize ) - { - InvalWindowRect( rootwindow, &oldBounds ) ; - if ( doMove ) - { - UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; - } - if ( doResize ) - { - UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; - } - } + if ( doMove || doResize ) + { + InvalWindowRect( rootwindow, &oldBounds ) ; + if ( doMove ) + { + UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; + } + if ( doResize ) + { + UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; + } + } } void wxSlider::DoMoveWindow(int x, int y, int width, int height) diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index 85fd2d0b08..b36c755f7e 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -36,29 +36,29 @@ wxSpinButton::wxSpinButton() } bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - long style, const wxString& name) + long style, const wxString& name) { m_min = 0; m_max = 100; - - if (!parent) - return FALSE; - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, - kControlLittleArrowsProc , (long) this ) ; - - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - - MacPostControlCreate() ; - - return TRUE; + if (!parent) + return FALSE; + + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, + kControlLittleArrowsProc , (long) this ) ; + + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + + MacPostControlCreate() ; + + return TRUE; } - + wxSpinButton::~wxSpinButton() { } @@ -68,12 +68,12 @@ wxSpinButton::~wxSpinButton() int wxSpinButton::GetMin() const { - return m_min; + return m_min; } int wxSpinButton::GetMax() const { - return m_max; + return m_max; } int wxSpinButton::GetValue() const @@ -83,50 +83,50 @@ int wxSpinButton::GetValue() const void wxSpinButton::SetValue(int val) { - m_value = val ; + m_value = val ; } void wxSpinButton::SetRange(int minVal, int maxVal) { - m_min = minVal; - m_max = maxVal; + m_min = minVal; + m_max = maxVal; SetControl32BitMaximum( (ControlHandle) m_macControl , maxVal ) ; SetControl32BitMinimum((ControlHandle) m_macControl , minVal ) ; } void wxSpinButton::MacHandleValueChanged( int inc ) { - + wxEventType scrollEvent = wxEVT_NULL; - int oldValue = m_value ; - + int oldValue = m_value ; + m_value = oldValue + inc; - + if (m_value < m_min) { - if ( m_windowStyle & wxSP_WRAP ) - m_value = m_max; - else - m_value = m_min; + if ( m_windowStyle & wxSP_WRAP ) + m_value = m_max; + else + m_value = m_min; } - + if (m_value > m_max) { - if ( m_windowStyle & wxSP_WRAP ) - m_value = m_min; - else - m_value = m_max; + if ( m_windowStyle & wxSP_WRAP ) + m_value = m_min; + else + m_value = m_max; } - + if ( m_value - oldValue == -1 ) scrollEvent = wxEVT_SCROLL_LINEDOWN ; else if ( m_value - oldValue == 1 ) scrollEvent = wxEVT_SCROLL_LINEUP ; else scrollEvent = wxEVT_SCROLL_THUMBTRACK ; - + wxSpinEvent event(scrollEvent, m_windowId); - + event.SetPosition(m_value); event.SetEventObject( this ); if ((GetEventHandler()->ProcessEvent( event )) && @@ -135,7 +135,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) m_value = oldValue ; } SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ; - + /* always send a thumbtrack event */ if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) { @@ -149,22 +149,22 @@ void wxSpinButton::MacHandleValueChanged( int inc ) void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - if ( (ControlHandle) m_macControl == NULL ) - return ; - - int nScrollInc = 0; - - switch( controlpart ) - { - case kControlUpButtonPart : - nScrollInc = 1; - break ; - case kControlDownButtonPart : - nScrollInc = -1; - break ; - } - MacHandleValueChanged( nScrollInc ) ; - + if ( (ControlHandle) m_macControl == NULL ) + return ; + + int nScrollInc = 0; + + switch( controlpart ) + { + case kControlUpButtonPart : + nScrollInc = 1; + break ; + case kControlDownButtonPart : + nScrollInc = -1; + break ; + } + MacHandleValueChanged( nScrollInc ) ; + } // ---------------------------------------------------------------------------- @@ -173,6 +173,6 @@ void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart wxSize wxSpinButton::DoGetBestSize() const { - return wxSize(16,24); + return wxSize(16,24); } diff --git a/src/mac/carbon/statbmp.cpp b/src/mac/carbon/statbmp.cpp index ab37567e88..68bc4efa6a 100644 --- a/src/mac/carbon/statbmp.cpp +++ b/src/mac/carbon/statbmp.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -38,13 +38,13 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, const wxString& name) { SetName(name); - wxSize size = s ; - if ( bitmap.Ok() ) - { - if ( size.x == -1 ) - size.x = bitmap.GetWidth() ; - if ( size.y == -1 ) - size.y = bitmap.GetHeight() ; + wxSize size = s ; + if ( bitmap.Ok() ) + { + if ( size.x == -1 ) + size.x = bitmap.GetWidth() ; + if ( size.y == -1 ) + size.y = bitmap.GetHeight() ; } m_backgroundColour = parent->GetBackgroundColour() ; @@ -52,14 +52,14 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, m_bitmap = bitmap; if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; m_windowStyle = style; bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); - SetBestSize( size ) ; + SetBestSize( size ) ; return ret; } diff --git a/src/mac/carbon/statbox.cpp b/src/mac/carbon/statbox.cpp index cef41efca7..e494e9e709 100644 --- a/src/mac/carbon/statbox.cpp +++ b/src/mac/carbon/statbox.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -22,7 +22,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) BEGIN_EVENT_TABLE(wxStaticBox, wxControl) - EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground) + EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground) END_EVENT_TABLE() #endif @@ -38,15 +38,15 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlGroupBoxTextTitleProc , (long) this ) ; - - MacPostControlCreate() ; - - return TRUE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlGroupBoxTextTitleProc , (long) this ) ; + + MacPostControlCreate() ; + + return TRUE; } diff --git a/src/mac/carbon/statbrma.cpp b/src/mac/carbon/statbrma.cpp index d3fef290a3..e39e83bb81 100644 --- a/src/mac/carbon/statbrma.cpp +++ b/src/mac/carbon/statbrma.cpp @@ -22,7 +22,7 @@ #include "wx/dcclient.h" BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) - EVT_PAINT(wxStatusBarMac::OnPaint) + EVT_PAINT(wxStatusBarMac::OnPaint) END_EVENT_TABLE() #ifdef __WXMAC__ @@ -47,38 +47,38 @@ wxStatusBarMac::~wxStatusBarMac() } bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, - long style , - const wxString& name) + long style , + const wxString& name) { - return wxStatusBarGeneric::Create( parent , id , style , name ) ; + return wxStatusBarGeneric::Create( parent , id , style , name ) ; } void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) { - int leftMargin = 2; - - wxRect rect; - GetFieldRect(i, rect); - - if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) - { - dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; - } - - wxString text(GetStatusText(i)); - - long x, y; - - dc.GetTextExtent(text, &x, &y); - - int xpos = rect.x + leftMargin + 1 ; - int ypos = 2 ; - - dc.SetClippingRegion(rect.x, 0, rect.width, m_height); - - dc.DrawText(text, xpos, ypos); - - dc.DestroyClippingRegion(); + int leftMargin = 2; + + wxRect rect; + GetFieldRect(i, rect); + + if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) + { + dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; + } + + wxString text(GetStatusText(i)); + + long x, y; + + dc.GetTextExtent(text, &x, &y); + + int xpos = rect.x + leftMargin + 1 ; + int ypos = 2 ; + + dc.SetClippingRegion(rect.x, 0, rect.width, m_height); + + dc.DrawText(text, xpos, ypos); + + dc.DestroyClippingRegion(); } void wxStatusBarMac::DrawField(wxDC& dc, int i) @@ -89,8 +89,8 @@ void wxStatusBarMac::DrawField(wxDC& dc, int i) void wxStatusBarMac::SetStatusText(const wxString& text, int number) { wxCHECK_RET( (number >= 0) && (number < m_nFields), - _T("invalid status bar field index") ); - + _T("invalid status bar field index") ); + m_statusStrings[number] = text; wxRect rect; GetFieldRect(number, rect); @@ -101,35 +101,35 @@ void wxStatusBarMac::SetStatusText(const wxString& text, int number) void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) { - wxPaintDC dc(this); - dc.Clear() ; - - if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) - { - wxPen black( wxBLACK , 1 , wxSOLID ) ; - wxPen white( wxWHITE , 1 , wxSOLID ) ; - - dc.SetPen(black); - dc.DrawLine(0, 0 , - m_width , 0); - dc.SetPen(white); - dc.DrawLine(0, 1 , - m_width , 1); - } - else - { - dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); - dc.DrawLine(0, 0 , - m_width , 0); - } - - int i; - if ( GetFont().Ok() ) - dc.SetFont(GetFont()); - dc.SetBackgroundMode(wxTRANSPARENT); - - for ( i = 0; i < m_nFields; i ++ ) - DrawField(dc, i); + wxPaintDC dc(this); + dc.Clear() ; + + if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) + { + wxPen black( wxBLACK , 1 , wxSOLID ) ; + wxPen white( wxWHITE , 1 , wxSOLID ) ; + + dc.SetPen(black); + dc.DrawLine(0, 0 , + m_width , 0); + dc.SetPen(white); + dc.DrawLine(0, 1 , + m_width , 1); + } + else + { + dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); + dc.DrawLine(0, 0 , + m_width , 0); + } + + int i; + if ( GetFont().Ok() ) + dc.SetFont(GetFont()); + dc.SetBackgroundMode(wxTRANSPARENT); + + for ( i = 0; i < m_nFields; i ++ ) + DrawField(dc, i); } void wxStatusBarMac::MacSuperEnabled( bool enabled ) diff --git a/src/mac/carbon/statlmac.cpp b/src/mac/carbon/statlmac.cpp index 2c01893e84..dc00dcca0f 100644 --- a/src/mac/carbon/statlmac.cpp +++ b/src/mac/carbon/statlmac.cpp @@ -49,15 +49,15 @@ bool wxStaticLine::Create( wxWindow *parent, long style, const wxString &name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlSeparatorLineProc , (long) this ) ; - - MacPostControlCreate() ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlSeparatorLineProc , (long) this ) ; + + MacPostControlCreate() ; return TRUE; } diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index f0175deaf3..fc0a5726f9 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -137,44 +137,44 @@ void wxStaticText::OnDraw( wxDC &dc ) { if (m_width <= 0 || m_height <= 0) return; -/* - dc.Clear() ; - wxRect rect(0,0,m_width,m_height) ; - dc.SetFont(*wxSMALL_FONT) ; - - dc.DrawRectangle(rect) ; -*/ - if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) && - ( GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) - || GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) ) - { - dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; - } - else - { - dc.SetTextForeground( GetForegroundColour() ) ; - } - - wxString paragraph; - size_t i = 0 ; - wxString text = m_label; - int y = 0 ; - while (i < text.Length()) - { - - if (text[i] == 13 || text[i] == 10) + /* + dc.Clear() ; + wxRect rect(0,0,m_width,m_height) ; + dc.SetFont(*wxSMALL_FONT) ; + + dc.DrawRectangle(rect) ; + */ + if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) && + ( GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) + || GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) ) { - DrawParagraph(dc, paragraph,y); - paragraph = "" ; + dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; } else { - paragraph += text[i]; + dc.SetTextForeground( GetForegroundColour() ) ; + } + + wxString paragraph; + size_t i = 0 ; + wxString text = m_label; + int y = 0 ; + while (i < text.Length()) + { + + if (text[i] == 13 || text[i] == 10) + { + DrawParagraph(dc, paragraph,y); + paragraph = "" ; + } + else + { + paragraph += text[i]; + } + ++i; } - ++i; - } - if (paragraph.Length() > 0) - DrawParagraph(dc, paragraph,y); + if (paragraph.Length() > 0) + DrawParagraph(dc, paragraph,y); } void wxStaticText::OnPaint( wxPaintEvent & WXUNUSED(event) ) diff --git a/src/mac/carbon/tabctrl.cpp b/src/mac/carbon/tabctrl.cpp index 08b7204373..6e79c88386 100644 --- a/src/mac/carbon/tabctrl.cpp +++ b/src/mac/carbon/tabctrl.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -34,18 +34,18 @@ wxTabCtrl::wxTabCtrl() bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - Rect bounds ; - Str255 title ; - - m_imageList = NULL; - - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlTabSmallProc , (long) this ) ; - - MacPostControlCreate() ; - return TRUE ; + Rect bounds ; + Str255 title ; + + m_imageList = NULL; + + MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlTabSmallProc , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } wxTabCtrl::~wxTabCtrl() diff --git a/src/mac/carbon/taskbar.cpp b/src/mac/carbon/taskbar.cpp index 7213103b04..df0eb5a9b7 100644 --- a/src/mac/carbon/taskbar.cpp +++ b/src/mac/carbon/taskbar.cpp @@ -1,13 +1,13 @@ ///////////////////////////////////////////////////////////////////////// // File: taskbar.cpp -// Purpose: Implements wxTaskBarIcon class for manipulating icons on +// Purpose: Implements wxTaskBarIcon class for manipulating icons on // the task bar. Optional. // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index a6eb64f05c..ae6063d20c 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -299,8 +299,8 @@ static pascal ControlPartCode TPPaneTrackingProc(ControlHandle theControl, Point #if !TARGET_CARBON TXNClick( varsp->fTXNRec, (const EventRecord*) wxTheApp->MacGetCurrentEvent()); #else - EventRecord rec ; - ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; + EventRecord rec ; + ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; TXNClick( varsp->fTXNRec, &rec ); #endif } @@ -662,15 +662,15 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_macTE = NULL ; - m_macTXN = NULL ; - m_macTXNvars = NULL ; - m_macUsesTXN = false ; - m_editable = true ; - - m_macUsesTXN = ! (style & wxTE_PASSWORD ) ; - - m_macUsesTXN &= (TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress) ; + m_macTE = NULL ; + m_macTXN = NULL ; + m_macTXNvars = NULL ; + m_macUsesTXN = false ; + m_editable = true ; + + m_macUsesTXN = ! (style & wxTE_PASSWORD ) ; + + m_macUsesTXN &= (TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress) ; // base initialization if ( !CreateBase(parent, id, pos, size, style, validator, name) ) @@ -764,7 +764,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); } - return TRUE; + return TRUE; } wxString wxTextCtrl::GetValue() const @@ -774,21 +774,21 @@ wxString wxTextCtrl::GetValue() const OSStatus err ; if ( !m_macUsesTXN ) { - err = ::GetControlDataSize((ControlHandle) m_macControl, 0, + err = ::GetControlDataSize((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, &actualSize ) ; - if ( err ) - return wxEmptyString ; - - if ( actualSize > 0 ) - { - wxChar *ptr = result.GetWriteBuf(actualSize) ; - - ::GetControlData( (ControlHandle) m_macControl, 0, - ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, - actualSize , ptr , &actualSize ) ; - ptr[actualSize] = 0 ; - result.UngetWriteBuf(actualSize) ; + if ( err ) + return wxEmptyString ; + + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize) ; + + ::GetControlData( (ControlHandle) m_macControl, 0, + ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, + actualSize , ptr , &actualSize ) ; + ptr[actualSize] = 0 ; + result.UngetWriteBuf(actualSize) ; } } @@ -804,14 +804,14 @@ wxString wxTextCtrl::GetValue() const else { actualSize = GetHandleSize( theText ) ; - if ( actualSize > 0 ) - { - wxChar *ptr = result.GetWriteBuf(actualSize) ; - strncpy( ptr , *theText , actualSize ) ; - ptr[actualSize] = 0 ; - result.UngetWriteBuf( actualSize ) ; - } - DisposeHandle( theText ) ; + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize) ; + strncpy( ptr , *theText , actualSize ) ; + ptr[actualSize] = 0 ; + result.UngetWriteBuf( actualSize ) ; + } + DisposeHandle( theText ) ; } } @@ -1090,42 +1090,42 @@ void wxTextCtrl::SetInsertionPointEnd() long wxTextCtrl::GetInsertionPoint() const { - long begin,end ; - GetSelection( &begin , &end ) ; - return begin ; + long begin,end ; + GetSelection( &begin , &end ) ; + return begin ; } long wxTextCtrl::GetLastPosition() const { if ( !m_macUsesTXN ) - { - return (**((TEHandle) m_macTE)).teLength ; - } - else - { - Handle theText ; - long actualsize ; - OSErr err = TXNGetDataEncoded( (TXNObject) m_macTXN, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); - /* all done */ - if ( err ) { - actualsize = 0 ; + return (**((TEHandle) m_macTE)).teLength ; } else { - actualsize = GetHandleSize( theText ) ; - DisposeHandle( theText ) ; + Handle theText ; + long actualsize ; + OSErr err = TXNGetDataEncoded( (TXNObject) m_macTXN, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); + /* all done */ + if ( err ) + { + actualsize = 0 ; + } + else + { + actualsize = GetHandleSize( theText ) ; + DisposeHandle( theText ) ; + } + return actualsize ; } - return actualsize ; - } } void wxTextCtrl::Replace(long from, long to, const wxString& value) { - if ( !m_macUsesTXN ) - { + if ( !m_macUsesTXN ) + { ControlEditTextSelectionRec selection ; - + selection.selStart = from ; selection.selEnd = to ; ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; @@ -1141,7 +1141,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ; TXNClear( ((TXNObject) m_macTXN) ) ; TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(), - kTXNUseCurrentSelection, kTXNUseCurrentSelection); + kTXNUseCurrentSelection, kTXNUseCurrentSelection); if ( !formerEditable ) SetEditable( formerEditable ) ; } @@ -1150,52 +1150,52 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) void wxTextCtrl::Remove(long from, long to) { - if ( !m_macUsesTXN ) - { - ControlEditTextSelectionRec selection ; - - selection.selStart = from ; - selection.selEnd = to ; - ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; - TEDelete( ((TEHandle) m_macTE) ) ; - } - else - { - bool formerEditable = IsEditable() ; - if ( !formerEditable ) - SetEditable(true) ; - TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ; - TXNClear( ((TXNObject) m_macTXN) ) ; - if ( !formerEditable ) - SetEditable( formerEditable ) ; - } + if ( !m_macUsesTXN ) + { + ControlEditTextSelectionRec selection ; + + selection.selStart = from ; + selection.selEnd = to ; + ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + TEDelete( ((TEHandle) m_macTE) ) ; + } + else + { + bool formerEditable = IsEditable() ; + if ( !formerEditable ) + SetEditable(true) ; + TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ; + TXNClear( ((TXNObject) m_macTXN) ) ; + if ( !formerEditable ) + SetEditable( formerEditable ) ; + } Refresh() ; } void wxTextCtrl::SetSelection(long from, long to) { - - if ( !m_macUsesTXN ) - { - ControlEditTextSelectionRec selection ; - selection.selStart = from ; - selection.selEnd = to ; - - TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ; - ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; - } - else - { - STPTextPaneVars **tpvars; + + if ( !m_macUsesTXN ) + { + ControlEditTextSelectionRec selection ; + selection.selStart = from ; + selection.selEnd = to ; + + TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ; + ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + } + else + { + STPTextPaneVars **tpvars; /* set up our locals */ - tpvars = (STPTextPaneVars **) GetControlReference((ControlHandle) m_macControl); + tpvars = (STPTextPaneVars **) GetControlReference((ControlHandle) m_macControl); /* and our drawing environment as the operation may force a redraw in the text area. */ - SetPort((**tpvars).fDrawingEnvironment); + SetPort((**tpvars).fDrawingEnvironment); /* change the selection */ - TXNSetSelection( (**tpvars).fTXNRec, from, to); - TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); - } + TXNSetSelection( (**tpvars).fTXNRec, from, to); + TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); + } } bool wxTextCtrl::LoadFile(const wxString& file) @@ -1252,15 +1252,15 @@ void wxTextCtrl::Clear() { return ; } - if ( !m_macUsesTXN ) - { - ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ; - } - else - { + if ( !m_macUsesTXN ) + { + ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ; + } + else + { TXNSetSelection( (TXNObject)m_macTXN , kTXNStartOffset , kTXNEndOffset ) ; TXNClear((TXNObject)m_macTXN); - } + } Refresh() ; } @@ -1349,8 +1349,8 @@ void wxTextCtrl::DiscardEdits() int wxTextCtrl::GetNumberOfLines() const { - // TODO change this if possible to reflect real lines - wxString content = GetValue() ; + // TODO change this if possible to reflect real lines + wxString content = GetValue() ; int count = 1; for (size_t i = 0; i < content.Length() ; i++) @@ -1379,8 +1379,8 @@ void wxTextCtrl::ShowPosition(long pos) int wxTextCtrl::GetLineLength(long lineNo) const { - // TODO change this if possible to reflect real lines - wxString content = GetValue() ; + // TODO change this if possible to reflect real lines + wxString content = GetValue() ; // Find line first int count = 0; @@ -1405,8 +1405,8 @@ int wxTextCtrl::GetLineLength(long lineNo) const wxString wxTextCtrl::GetLineText(long lineNo) const { - // TODO change this if possible to reflect real lines - wxString content = GetValue() ; + // TODO change this if possible to reflect real lines + wxString content = GetValue() ; // Find line first int count = 0; diff --git a/src/mac/carbon/thread.cpp b/src/mac/carbon/thread.cpp index 474b92a22f..23a7203752 100644 --- a/src/mac/carbon/thread.cpp +++ b/src/mac/carbon/thread.cpp @@ -902,5 +902,3 @@ bool WXDLLEXPORT wxIsWaitingForThread() #include "wx/thrimpl.cpp" #endif // wxUSE_THREADS - -// vi:sts=4:sw=4:et diff --git a/src/mac/carbon/timer.cpp b/src/mac/carbon/timer.cpp index 4d96abef87..3d43a7ca27 100644 --- a/src/mac/carbon/timer.cpp +++ b/src/mac/carbon/timer.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -39,24 +39,24 @@ static void wxProcessTimer( unsigned long event , void *data ) ; static pascal void MacTimerProc( TMTask * t ) { - MacTimerInfo * tm = (MacTimerInfo*) t ; - wxMacAddEvent( tm->m_table , wxProcessTimer, 0 , (void*) tm->m_timer , TRUE ) ; + MacTimerInfo * tm = (MacTimerInfo*) t ; + wxMacAddEvent( tm->m_table , wxProcessTimer, 0 , (void*) tm->m_timer , TRUE ) ; } wxArrayPtrVoid gTimersInProcess ; static void wxProcessTimer( unsigned long event , void *data ) { - if ( !data ) - return ; - - wxTimer* timer = (wxTimer*) data ; - - if ( timer->IsOneShot() ) - timer->Stop() ; - - gTimersInProcess.Add( timer ) ; - + if ( !data ) + return ; + + wxTimer* timer = (wxTimer*) data ; + + if ( timer->IsOneShot() ) + timer->Stop() ; + + gTimersInProcess.Add( timer ) ; + timer->Notify(); int index = gTimersInProcess.Index( timer ) ; @@ -67,7 +67,7 @@ static void wxProcessTimer( unsigned long event , void *data ) if ( !timer->IsOneShot() && timer->m_info->m_task.tmAddr ) { - PrimeTime( (QElemPtr) &timer->m_info->m_task , timer->GetInterval() ) ; + PrimeTime( (QElemPtr) &timer->m_info->m_task , timer->GetInterval() ) ; } } @@ -76,17 +76,17 @@ static void wxProcessTimer( unsigned long event , void *data ) void wxTimer::Init() { m_info = new MacTimerInfo() ; - m_info->m_task.tmAddr = NULL ; - m_info->m_task.tmWakeUp = 0 ; - m_info->m_task.tmReserved = 0 ; - m_info->m_task.qType = 0 ; - m_info->m_table = wxMacGetNotifierTable() ; - m_info->m_timer = this ; + m_info->m_task.tmAddr = NULL ; + m_info->m_task.tmWakeUp = 0 ; + m_info->m_task.tmReserved = 0 ; + m_info->m_task.qType = 0 ; + m_info->m_table = wxMacGetNotifierTable() ; + m_info->m_timer = this ; } bool wxTimer::IsRunning() const { - return ( m_info->m_task.qType & kTMTaskActive ) ; + return ( m_info->m_task.qType & kTMTaskActive ) ; } wxTimer::~wxTimer() @@ -116,8 +116,8 @@ bool wxTimer::Start(int milliseconds,bool mode) #endif m_info->m_task.tmWakeUp = 0 ; m_info->m_task.tmReserved = 0 ; - m_info->m_task.qType = 0 ; - m_info->m_timer = this ; + m_info->m_task.qType = 0 ; + m_info->m_timer = this ; InsXTime((QElemPtr) &m_info->m_task ) ; PrimeTime( (QElemPtr) &m_info->m_task , m_milli ) ; return FALSE; @@ -128,9 +128,9 @@ void wxTimer::Stop() m_milli = 0 ; if ( m_info->m_task.tmAddr ) { - RmvTime( (QElemPtr) &m_info->m_task ) ; - DisposeTimerUPP(m_info->m_task.tmAddr) ; - m_info->m_task.tmAddr = NULL ; + RmvTime( (QElemPtr) &m_info->m_task ) ; + DisposeTimerUPP(m_info->m_task.tmAddr) ; + m_info->m_task.tmAddr = NULL ; } wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ; } diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 8b8d56b70a..33da0a2d4b 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -107,54 +107,53 @@ wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control) void wxToolBar::Init() { - m_maxWidth = -1; - m_maxHeight = -1; - m_defaultWidth = kwxMacToolBarToolDefaultWidth; - m_defaultHeight = kwxMacToolBarToolDefaultHeight; + m_maxWidth = -1; + m_maxHeight = -1; + m_defaultWidth = kwxMacToolBarToolDefaultWidth; + m_defaultHeight = kwxMacToolBarToolDefaultHeight; } bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) -{ - - int x = pos.x; - int y = pos.y; - int width = size.x; - int height = size.y; - - if (width <= 0) - width = 100; - if (height <= 0) - height = 30; - if (x < 0) - x = 0; - if (y < 0) - y = 0; - - SetName(name); - - m_windowStyle = style; - parent->AddChild(this); - - m_backgroundColour = parent->GetBackgroundColour() ; - m_foregroundColour = parent->GetForegroundColour() ; - - if (id == -1) - m_windowId = NewControlId(); - else - m_windowId = id; - - { - m_width = size.x ; - m_height = size.y ; - int x = pos.x ; - int y = pos.y ; - AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING); - m_x = x ; - m_y = y ; - } - - return TRUE; +{ + int x = pos.x; + int y = pos.y; + int width = size.x; + int height = size.y; + + if (width <= 0) + width = 100; + if (height <= 0) + height = 30; + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + SetName(name); + + m_windowStyle = style; + parent->AddChild(this); + + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; + + if (id == -1) + m_windowId = NewControlId(); + else + m_windowId = id; + + { + m_width = size.x ; + m_height = size.y ; + int x = pos.x ; + int y = pos.y ; + AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING); + m_x = x ; + m_y = y ; + } + + return TRUE; } wxToolBar::~wxToolBar() @@ -363,119 +362,119 @@ void wxToolBar::SetRows(int nRows) void wxToolBar::MacSuperChangedPosition() { - if (m_tools.GetCount() > 0) - { - - Point localOrigin ; - // Rect clipRect ; - // WindowRef window ; - // wxWindow *win ; - int lx , ly ; - lx = ly = 0 ; - MacWindowToRootWindow( &lx , &ly ) ; - localOrigin.v = ly ; - localOrigin.h = lx ; - -// GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ; - - Rect toolbarrect = { localOrigin.v ,localOrigin.h , - m_height + localOrigin.v , m_width + localOrigin.h} ; - ControlFontStyleRec controlstyle ; - - controlstyle.flags = kControlUseFontMask ; - controlstyle.font = kControlFontSmallSystemFont ; - - wxToolBarToolsList::Node *node = m_tools.GetFirst(); - int noButtons = 0; - int x = 0 ; - wxSize toolSize = GetToolSize() ; - int tw, th; - GetSize(& tw, & th); - - int maxWidth = 0 ; - int maxHeight = 0 ; - int toolcount = 0 ; + if (m_tools.GetCount() > 0) { - WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; - while (node) + + Point localOrigin ; + // Rect clipRect ; + // WindowRef window ; + // wxWindow *win ; + int lx , ly ; + lx = ly = 0 ; + MacWindowToRootWindow( &lx , &ly ) ; + localOrigin.v = ly ; + localOrigin.h = lx ; + + // GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ; + + Rect toolbarrect = { localOrigin.v ,localOrigin.h , + m_height + localOrigin.v , m_width + localOrigin.h} ; + ControlFontStyleRec controlstyle ; + + controlstyle.flags = kControlUseFontMask ; + controlstyle.font = kControlFontSmallSystemFont ; + + wxToolBarToolsList::Node *node = m_tools.GetFirst(); + int noButtons = 0; + int x = 0 ; + wxSize toolSize = GetToolSize() ; + int tw, th; + GetSize(& tw, & th); + + int maxWidth = 0 ; + int maxHeight = 0 ; + int toolcount = 0 ; { - wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); - - if( !tool->IsSeparator() ) + WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; + while (node) { - Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ; - toolrect.right = toolrect.left + toolSize.x ; - toolrect.bottom = toolrect.top + toolSize.y ; - - ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ; + wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); + if( !tool->IsSeparator() ) { - Rect contrlRect ; - GetControlBounds( m_macToolHandle , &contrlRect ) ; - int former_mac_x = contrlRect.left ; - int former_mac_y = contrlRect.top ; - int mac_x = toolrect.left ; - int mac_y = toolrect.top ; - - if ( mac_x != former_mac_x || mac_y != former_mac_y ) + Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ; + toolrect.right = toolrect.left + toolSize.x ; + toolrect.bottom = toolrect.top + toolSize.y ; + + ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ; + { + Rect contrlRect ; + GetControlBounds( m_macToolHandle , &contrlRect ) ; + int former_mac_x = contrlRect.left ; + int former_mac_y = contrlRect.top ; + int mac_x = toolrect.left ; + int mac_y = toolrect.top ; + + if ( mac_x != former_mac_x || mac_y != former_mac_y ) { - Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ; - InvalWindowRect( rootwindow , &inval ) ; - } - UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ; - { - Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ; - InvalWindowRect( rootwindow , &inval ) ; + { + Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ; + InvalWindowRect( rootwindow , &inval ) ; + } + UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ; + { + Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ; + InvalWindowRect( rootwindow , &inval ) ; + } } } + + x += (int)toolSize.x; + noButtons ++; + } + else + { + toolcount++ ; + x += (int)toolSize.x / 4; } + if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth) + maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h; + if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight) + maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ; - x += (int)toolSize.x; - noButtons ++; + node = node->GetNext(); } - else + } + + if ( GetWindowStyleFlag() & wxTB_HORIZONTAL ) + { + if ( m_maxRows == 0 ) { - toolcount++ ; - x += (int)toolSize.x / 4; + // if not set yet, only one row + SetRows(1); } - if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth) - maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h; - if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight) - maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ; - - node = node->GetNext(); + maxWidth = tw ; + maxHeight += toolSize.y; + maxHeight += m_yMargin + kwxMacToolBarTopMargin; + m_maxHeight = maxHeight ; } + else + { + if ( noButtons > 0 && m_maxRows == 0 ) + { + // if not set yet, have one column + SetRows(noButtons); + } + maxHeight = th ; + maxWidth += toolSize.x; + maxWidth += m_xMargin + kwxMacToolBarLeftMargin; + m_maxWidth = maxWidth ; + } + + SetSize(maxWidth, maxHeight); } - - if ( GetWindowStyleFlag() & wxTB_HORIZONTAL ) - { - if ( m_maxRows == 0 ) - { - // if not set yet, only one row - SetRows(1); - } - maxWidth = tw ; - maxHeight += toolSize.y; - maxHeight += m_yMargin + kwxMacToolBarTopMargin; - m_maxHeight = maxHeight ; - } - else - { - if ( noButtons > 0 && m_maxRows == 0 ) - { - // if not set yet, have one column - SetRows(noButtons); - } - maxHeight = th ; - maxWidth += toolSize.x; - maxWidth += m_xMargin + kwxMacToolBarLeftMargin; - m_maxWidth = maxWidth ; - } - - SetSize(maxWidth, maxHeight); - } - + wxWindow::MacSuperChangedPosition() ; } @@ -564,9 +563,9 @@ bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *WXUNUSED(t void wxToolBar::OnPaint(wxPaintEvent& event) { - wxPaintDC dc(this) ; - wxMacPortSetter helper(&dc) ; - + wxPaintDC dc(this) ; + wxMacPortSetter helper(&dc) ; + Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) , dc.YLOG2DEVMAC(m_height) , dc.XLOG2DEVMAC(m_width) } ; UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; diff --git a/src/mac/carbon/tooltip.cpp b/src/mac/carbon/tooltip.cpp index 5d072cb098..4b00c6f750 100644 --- a/src/mac/carbon/tooltip.cpp +++ b/src/mac/carbon/tooltip.cpp @@ -31,27 +31,27 @@ class wxMacToolTipTimer ; class wxMacToolTip { - public : - wxMacToolTip( ) ; - ~wxMacToolTip() ; - - void Setup( WindowRef window , wxString text , wxPoint localPosition ) ; - long GetMark() { return m_mark ; } - void Draw() ; - void Clear() ; - bool IsShown() { return m_shown ; } - private : - - wxString m_label ; - wxPoint m_position ; - Rect m_rect ; - WindowRef m_window ; - PicHandle m_backpict ; - bool m_shown ; - long m_mark ; - wxMacToolTipTimer* m_timer ; + public : + wxMacToolTip( ) ; + ~wxMacToolTip() ; + + void Setup( WindowRef window , wxString text , wxPoint localPosition ) ; + long GetMark() { return m_mark ; } + void Draw() ; + void Clear() ; + bool IsShown() { return m_shown ; } + private : + + wxString m_label ; + wxPoint m_position ; + Rect m_rect ; + WindowRef m_window ; + PicHandle m_backpict ; + bool m_shown ; + long m_mark ; + wxMacToolTipTimer* m_timer ; #ifdef TARGET_CARBON - CFStringRef m_helpTextRef ; + CFStringRef m_helpTextRef ; #endif } ; @@ -67,8 +67,8 @@ public: m_tip->Draw() ; } protected: - wxMacToolTip* m_tip; - long m_mark ; + wxMacToolTip* m_tip; + long m_mark ; }; //----------------------------------------------------------------------------- @@ -95,16 +95,16 @@ wxToolTip::~wxToolTip() void wxToolTip::SetTip( const wxString &tip ) { - m_text = tip; - + m_text = tip; + if ( m_window ) { - /* - // update it immediately - wxToolInfo ti(GetHwndOf(m_window)); - ti.lpszText = (wxChar *)m_text.c_str(); - - (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti); + /* + // update it immediately + wxToolInfo ti(GetHwndOf(m_window)); + ti.lpszText = (wxChar *)m_text.c_str(); + + (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti); */ } } @@ -116,94 +116,94 @@ void wxToolTip::SetWindow( wxWindow *win ) void wxToolTip::Enable( bool flag ) { - if ( s_ShowToolTips != flag ) - { - s_ShowToolTips = flag ; - if ( s_ShowToolTips ) - { - } - else - { - s_ToolTip.Clear() ; - } - } + if ( s_ShowToolTips != flag ) + { + s_ShowToolTips = flag ; + if ( s_ShowToolTips ) + { + } + else + { + s_ToolTip.Clear() ; + } + } } void wxToolTip::SetDelay( long msecs ) { - s_ToolTipDelay = msecs ; + s_ToolTipDelay = msecs ; } void wxToolTip::RelayEvent( wxWindow *win , wxMouseEvent &event ) { - if ( s_ShowToolTips ) - { - if ( event.GetEventType() == wxEVT_LEAVE_WINDOW ) - { - s_ToolTip.Clear() ; - } - else if (event.GetEventType() == wxEVT_ENTER_WINDOW || event.GetEventType() == wxEVT_MOTION ) - { - wxPoint2DInt where( event.m_x , event.m_y ) ; - if ( s_LastWindowEntered == win && s_ToolTipArea.Contains( where ) ) - { - } - else - { - s_ToolTip.Clear() ; - s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ; - s_LastWindowEntered = win ; - - WindowRef window = MAC_WXHWND( win->MacGetRootWindow() ) ; - int x = event.m_x ; - int y = event.m_y ; - wxPoint local( x , y ) ; - win->MacClientToRootWindow( &x, &y ) ; - wxPoint windowlocal( x , y ) ; - s_ToolTip.Setup( window , win->MacGetToolTipString( local ) , windowlocal ) ; - } - } - } + if ( s_ShowToolTips ) + { + if ( event.GetEventType() == wxEVT_LEAVE_WINDOW ) + { + s_ToolTip.Clear() ; + } + else if (event.GetEventType() == wxEVT_ENTER_WINDOW || event.GetEventType() == wxEVT_MOTION ) + { + wxPoint2DInt where( event.m_x , event.m_y ) ; + if ( s_LastWindowEntered == win && s_ToolTipArea.Contains( where ) ) + { + } + else + { + s_ToolTip.Clear() ; + s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ; + s_LastWindowEntered = win ; + + WindowRef window = MAC_WXHWND( win->MacGetRootWindow() ) ; + int x = event.m_x ; + int y = event.m_y ; + wxPoint local( x , y ) ; + win->MacClientToRootWindow( &x, &y ) ; + wxPoint windowlocal( x , y ) ; + s_ToolTip.Setup( window , win->MacGetToolTipString( local ) , windowlocal ) ; + } + } + } } void wxToolTip::RemoveToolTips() { - s_ToolTip.Clear() ; + s_ToolTip.Clear() ; } // --- mac specific wxMacToolTipTimer::wxMacToolTipTimer( wxMacToolTip *tip , int msec ) { - m_tip = tip; - m_mark = tip->GetMark() ; - Start(msec, true); + m_tip = tip; + m_mark = tip->GetMark() ; + Start(msec, true); } wxMacToolTip::wxMacToolTip() { - m_window = NULL ; - m_backpict = NULL ; - m_mark = 0 ; - m_shown = false ; + m_window = NULL ; + m_backpict = NULL ; + m_mark = 0 ; + m_shown = false ; m_timer = NULL ; m_helpTextRef = NULL ; } void wxMacToolTip::Setup( WindowRef win , wxString text , wxPoint localPosition ) { - m_mark++ ; - Clear() ; - m_position = localPosition ; + m_mark++ ; + Clear() ; + m_position = localPosition ; if( wxApp::s_macDefaultEncodingIsPC ) m_label = wxMacMakeMacStringFromPC( text ) ; - else + else m_label = text ; m_window =win; - s_ToolTipWindowRef = m_window ; - m_backpict = NULL ; - if ( m_timer ) - delete m_timer ; - m_timer = new wxMacToolTipTimer( this , s_ToolTipDelay ) ; + s_ToolTipWindowRef = m_window ; + m_backpict = NULL ; + if ( m_timer ) + delete m_timer ; + m_timer = new wxMacToolTipTimer( this , s_ToolTipDelay ) ; } wxMacToolTip::~wxMacToolTip() @@ -221,257 +221,257 @@ const short kTipOffset = 5 ; void wxMacToolTip::Draw() { - if ( m_label.Length() == 0 ) - return ; - - if ( m_window == s_ToolTipWindowRef ) - { - m_shown = true ; + if ( m_label.Length() == 0 ) + return ; + + if ( m_window == s_ToolTipWindowRef ) + { + m_shown = true ; #if TARGET_CARBON - if ( HMDisplayTag != (void*) kUnresolvedCFragSymbolAddress ) - { - HMHelpContentRec tag ; - tag.version = kMacHelpVersion; - SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; - GrafPtr port ; - GetPort( &port ) ; - SetPortWindowPort(m_window) ; - LocalToGlobal( (Point *) &tag.absHotRect.top ); - LocalToGlobal( (Point *) &tag.absHotRect.bottom ); - SetPort( port ); - if( m_helpTextRef ) - { - CFRelease( m_helpTextRef ) ; - m_helpTextRef = NULL ; - } - m_helpTextRef = wxMacCreateCFString(m_label) ; - tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; - tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; - tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; - tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; - tag.tagSide = kHMDefaultSide; - HMDisplayTag( &tag ); - } - else + if ( HMDisplayTag != (void*) kUnresolvedCFragSymbolAddress ) + { + HMHelpContentRec tag ; + tag.version = kMacHelpVersion; + SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; + GrafPtr port ; + GetPort( &port ) ; + SetPortWindowPort(m_window) ; + LocalToGlobal( (Point *) &tag.absHotRect.top ); + LocalToGlobal( (Point *) &tag.absHotRect.bottom ); + SetPort( port ); + if( m_helpTextRef ) + { + CFRelease( m_helpTextRef ) ; + m_helpTextRef = NULL ; + } + m_helpTextRef = wxMacCreateCFString(m_label) ; + tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; + tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; + tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; + tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; + tag.tagSide = kHMDefaultSide; + HMDisplayTag( &tag ); + } + else #endif - { - wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); -#if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; -#endif - - FontFamilyID fontId ; - Str255 fontName ; - SInt16 fontSize ; - Style fontStyle ; - GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; - GetFNum( fontName, &fontId ); - - TextFont( fontId ) ; - TextSize( fontSize ) ; - TextFace( fontStyle ) ; - FontInfo fontInfo; - ::GetFontInfo(&fontInfo); - short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; - short height = 0 ; - // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; - - int i = 0 ; - int length = m_label.Length() ; - int width = 0 ; - int thiswidth = 0 ; - int laststop = 0 ; - const char *text = m_label ; - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { - thiswidth = ::TextWidth( text , laststop , i - laststop ) ; - if ( thiswidth > width ) - width = thiswidth ; - - height += lineh ; - laststop = i+1 ; - } - i++ ; - } - if ( i - laststop > 0 ) - { - thiswidth = ::TextWidth( text , laststop , i - laststop ) ; - if ( thiswidth > width ) - width = thiswidth ; - height += lineh ; - } - - - m_rect.left = m_position.x + kTipOffset; - m_rect.top = m_position.y + kTipOffset; - m_rect.right = m_rect.left + width + 2 * kTipBorder; -#if TARGET_CARBON - if ( useDrawThemeText ) - m_rect.right += kTipBorder ; + { + wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); +#if TARGET_CARBON + bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; +#endif + + FontFamilyID fontId ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + GetFNum( fontName, &fontId ); + + TextFont( fontId ) ; + TextSize( fontSize ) ; + TextFace( fontStyle ) ; + FontInfo fontInfo; + ::GetFontInfo(&fontInfo); + short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; + short height = 0 ; + // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; + + int i = 0 ; + int length = m_label.Length() ; + int width = 0 ; + int thiswidth = 0 ; + int laststop = 0 ; + const char *text = m_label ; + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { + thiswidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( thiswidth > width ) + width = thiswidth ; + + height += lineh ; + laststop = i+1 ; + } + i++ ; + } + if ( i - laststop > 0 ) + { + thiswidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( thiswidth > width ) + width = thiswidth ; + height += lineh ; + } + + + m_rect.left = m_position.x + kTipOffset; + m_rect.top = m_position.y + kTipOffset; + m_rect.right = m_rect.left + width + 2 * kTipBorder; +#if TARGET_CARBON + if ( useDrawThemeText ) + m_rect.right += kTipBorder ; #endif - m_rect.bottom = m_rect.top + height + 2 * kTipBorder; - Rect r ; - GetPortBounds( GetWindowPort( m_window ) , &r ) ; - if ( m_rect.top < 0 ) - { - m_rect.bottom += -m_rect.top ; - m_rect.top = 0 ; - } - if ( m_rect.left < 0 ) - { - m_rect.right += -m_rect.left ; - m_rect.left = 0 ; - } - if ( m_rect.right > r.right ) - { - m_rect.left -= (m_rect.right - r.right ) ; - m_rect.right = r.right ; - } - if ( m_rect.bottom > r.bottom ) - { - m_rect.top -= (m_rect.bottom - r.bottom) ; - m_rect.bottom = r.bottom ; - } - ClipRect( &m_rect ) ; - BackColor( whiteColor ) ; - ForeColor(blackColor ) ; - GWorldPtr port ; - NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; - CGrafPtr origPort ; - GDHandle origDevice ; - - GetGWorld( &origPort , &origDevice ) ; - SetGWorld( port , NULL ) ; - - m_backpict = OpenPicture(&m_rect); - - CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), - GetPortBitMapForCopyBits(port), - &m_rect, - &m_rect, - srcCopy, - NULL); - ClosePicture(); - SetGWorld( origPort , origDevice ) ; - DisposeGWorld( port ) ; - PenNormal() ; - - RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; - BackColor( whiteColor ) ; - RGBForeColor( &tooltipbackground ) ; - - PaintRect( &m_rect ) ; - ForeColor(blackColor ) ; - FrameRect( &m_rect ) ; - SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; - ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); - - i = 0 ; - laststop = 0 ; - height = 0 ; - - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { + m_rect.bottom = m_rect.top + height + 2 * kTipBorder; + Rect r ; + GetPortBounds( GetWindowPort( m_window ) , &r ) ; + if ( m_rect.top < 0 ) + { + m_rect.bottom += -m_rect.top ; + m_rect.top = 0 ; + } + if ( m_rect.left < 0 ) + { + m_rect.right += -m_rect.left ; + m_rect.left = 0 ; + } + if ( m_rect.right > r.right ) + { + m_rect.left -= (m_rect.right - r.right ) ; + m_rect.right = r.right ; + } + if ( m_rect.bottom > r.bottom ) + { + m_rect.top -= (m_rect.bottom - r.bottom) ; + m_rect.bottom = r.bottom ; + } + ClipRect( &m_rect ) ; + BackColor( whiteColor ) ; + ForeColor(blackColor ) ; + GWorldPtr port ; + NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; + CGrafPtr origPort ; + GDHandle origDevice ; + + GetGWorld( &origPort , &origDevice ) ; + SetGWorld( port , NULL ) ; + + m_backpict = OpenPicture(&m_rect); + + CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), + GetPortBitMapForCopyBits(port), + &m_rect, + &m_rect, + srcCopy, + NULL); + ClosePicture(); + SetGWorld( origPort , origDevice ) ; + DisposeGWorld( port ) ; + PenNormal() ; + + RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; + BackColor( whiteColor ) ; + RGBForeColor( &tooltipbackground ) ; + + PaintRect( &m_rect ) ; + ForeColor(blackColor ) ; + FrameRect( &m_rect ) ; + SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; + ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); + + i = 0 ; + laststop = 0 ; + height = 0 ; + + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { #if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame ; - frame.top = m_rect.top + kTipBorder + height ; - frame.left = m_rect.left + kTipBorder ; - frame.bottom = frame.top + 1000 ; - frame.right = frame.left + 1000 ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - true, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - height += lineh ; - } - else + if ( useDrawThemeText ) + { + Rect frame ; + frame.top = m_rect.top + kTipBorder + height ; + frame.left = m_rect.left + kTipBorder ; + frame.bottom = frame.top + 1000 ; + frame.right = frame.left + 1000 ; + CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + true, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + height += lineh ; + } + else #endif - { - ::DrawText( text , laststop , i - laststop ) ; - height += lineh ; - ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); - } - laststop = i+1 ; - } - i++ ; - } + { + ::DrawText( text , laststop , i - laststop ) ; + height += lineh ; + ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); + } + laststop = i+1 ; + } + i++ ; + } #if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame ; - frame.top = m_rect.top + kTipBorder + height ; - frame.left = m_rect.left + kTipBorder ; - frame.bottom = frame.top + 1000 ; - frame.right = frame.left + 1000 ; - CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - true, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - } - else + if ( useDrawThemeText ) + { + Rect frame ; + frame.top = m_rect.top + kTipBorder + height ; + frame.left = m_rect.left + kTipBorder ; + frame.bottom = frame.top + 1000 ; + frame.right = frame.left + 1000 ; + CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + true, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + } + else #endif - { - ::DrawText( text , laststop , i - laststop ) ; - } - ::TextMode( srcOr ) ; - } - } + { + ::DrawText( text , laststop , i - laststop ) ; + } + ::TextMode( srcOr ) ; + } + } } void wxToolTip::NotifyWindowDelete( WXHWND win ) { - if ( win == s_ToolTipWindowRef ) - { - s_ToolTipWindowRef = NULL ; - } + if ( win == s_ToolTipWindowRef ) + { + s_ToolTipWindowRef = NULL ; + } } void wxMacToolTip::Clear() { - m_mark++ ; - if ( m_timer ) - { - delete m_timer ; - m_timer = NULL ; - } - if ( !m_shown ) - return ; + m_mark++ ; + if ( m_timer ) + { + delete m_timer ; + m_timer = NULL ; + } + if ( !m_shown ) + return ; #if TARGET_CARBON - HMHideTag() ; - if( m_helpTextRef ) - { - CFRelease( m_helpTextRef ) ; - m_helpTextRef = NULL ; - } -#else - if ( m_window == s_ToolTipWindowRef && m_backpict ) - { - wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ; + HMHideTag() ; + if( m_helpTextRef ) + { + CFRelease( m_helpTextRef ) ; + m_helpTextRef = NULL ; + } +#else + if ( m_window == s_ToolTipWindowRef && m_backpict ) + { + wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ; - m_shown = false ; + m_shown = false ; - BackColor( whiteColor ) ; - ForeColor(blackColor ) ; - DrawPicture(m_backpict, &m_rect); - KillPicture(m_backpict); - m_backpict = NULL ; - } + BackColor( whiteColor ) ; + ForeColor(blackColor ) ; + DrawPicture(m_backpict, &m_rect); + KillPicture(m_backpict); + m_backpict = NULL ; + } #endif } diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index d053a98ab1..76051b7079 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -75,7 +75,7 @@ static const EventTypeSpec eventList[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } , - { kEventClassKeyboard, kEventRawKeyDown } , + { kEventClassKeyboard, kEventRawKeyDown } , { kEventClassKeyboard, kEventRawKeyRepeat } , { kEventClassKeyboard, kEventRawKeyUp } , { kEventClassKeyboard, kEventRawKeyModifiersChanged } , @@ -99,34 +99,34 @@ static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , Even OSStatus result = eventNotHandledErr ; wxWindow* focus = wxWindow::FindFocus() ; - char charCode ; - UInt32 keyCode ; + char charCode ; + UInt32 keyCode ; UInt32 modifiers ; - Point point ; - UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; + Point point ; + UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; EventRef rawEvent ; GetEventParameter( event , kEventParamTextInputSendKeyboardEvent ,typeEventRef,NULL,sizeof(rawEvent),NULL,&rawEvent ) ; - GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); - GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); - GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); - GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof( Point ), NULL, &point ); - - UInt32 message = (keyCode << 8) + charCode; - - switch ( GetEventKind( event ) ) - { - case kEventTextInputUnicodeForKeyEvent : - if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent( - focus , message , modifiers , when , point.h , point.v ) ) - { - result = noErr ; - } - break ; - } + GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); + GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); + GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL, + sizeof( Point ), NULL, &point ); + + UInt32 message = (keyCode << 8) + charCode; + + switch ( GetEventKind( event ) ) + { + case kEventTextInputUnicodeForKeyEvent : + if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent( + focus , message , modifiers , when , point.h , point.v ) ) + { + result = noErr ; + } + break ; + } return result ; } @@ -136,73 +136,73 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event OSStatus result = eventNotHandledErr ; wxWindow* focus = wxWindow::FindFocus() ; - char charCode ; - UInt32 keyCode ; + char charCode ; + UInt32 keyCode ; UInt32 modifiers ; - Point point ; - UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; - - GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); - GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); - GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); - GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof( Point ), NULL, &point ); - - UInt32 message = (keyCode << 8) + charCode; - switch( GetEventKind( event ) ) - { - case kEventRawKeyRepeat : - case kEventRawKeyDown : - if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent( - focus , message , modifiers , when , point.h , point.v ) ) - { - result = noErr ; - } - break ; - case kEventRawKeyUp : - if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent( - focus , message , modifiers , when , point.h , point.v ) ) - { - result = noErr ; - } - break ; - case kEventRawKeyModifiersChanged : - { - wxKeyEvent event(wxEVT_KEY_DOWN); - - event.m_shiftDown = modifiers & shiftKey; - event.m_controlDown = modifiers & controlKey; - event.m_altDown = modifiers & optionKey; - event.m_metaDown = modifiers & cmdKey; - - event.m_x = point.h; - event.m_y = point.v; - event.m_timeStamp = when; - wxWindow* focus = wxWindow::FindFocus() ; - event.SetEventObject(focus); - - if ( (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey ) - { - event.m_keyCode = WXK_CONTROL ; - event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; - focus->GetEventHandler()->ProcessEvent( event ) ; - } - if ( (modifiers ^ wxTheApp->s_lastModifiers ) & shiftKey ) - { - event.m_keyCode = WXK_SHIFT ; - event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; - focus->GetEventHandler()->ProcessEvent( event ) ; - } - if ( (modifiers ^ wxTheApp->s_lastModifiers ) & optionKey ) - { - event.m_keyCode = WXK_ALT ; - event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; - focus->GetEventHandler()->ProcessEvent( event ) ; - } - wxTheApp->s_lastModifiers = modifiers ; - } - break ; - } + Point point ; + UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; + + GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); + GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); + GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, + sizeof( Point ), NULL, &point ); + + UInt32 message = (keyCode << 8) + charCode; + switch( GetEventKind( event ) ) + { + case kEventRawKeyRepeat : + case kEventRawKeyDown : + if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent( + focus , message , modifiers , when , point.h , point.v ) ) + { + result = noErr ; + } + break ; + case kEventRawKeyUp : + if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent( + focus , message , modifiers , when , point.h , point.v ) ) + { + result = noErr ; + } + break ; + case kEventRawKeyModifiersChanged : + { + wxKeyEvent event(wxEVT_KEY_DOWN); + + event.m_shiftDown = modifiers & shiftKey; + event.m_controlDown = modifiers & controlKey; + event.m_altDown = modifiers & optionKey; + event.m_metaDown = modifiers & cmdKey; + + event.m_x = point.h; + event.m_y = point.v; + event.m_timeStamp = when; + wxWindow* focus = wxWindow::FindFocus() ; + event.SetEventObject(focus); + + if ( (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey ) + { + event.m_keyCode = WXK_CONTROL ; + event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; + focus->GetEventHandler()->ProcessEvent( event ) ; + } + if ( (modifiers ^ wxTheApp->s_lastModifiers ) & shiftKey ) + { + event.m_keyCode = WXK_SHIFT ; + event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; + focus->GetEventHandler()->ProcessEvent( event ) ; + } + if ( (modifiers ^ wxTheApp->s_lastModifiers ) & optionKey ) + { + event.m_keyCode = WXK_ALT ; + event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; + focus->GetEventHandler()->ProcessEvent( event ) ; + } + wxTheApp->s_lastModifiers = modifiers ; + } + break ; + } return result ; } @@ -211,54 +211,54 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef { OSStatus result = eventNotHandledErr ; - wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; - Point point ; - UInt32 modifiers = 0; - EventMouseButton button = 0 ; - UInt32 click = 0 ; - - GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof( Point ), NULL, &point ); - GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, - sizeof( UInt32 ), NULL, &modifiers ); - GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL, - sizeof( EventMouseButton ), NULL, &button ); - GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL, - sizeof( UInt32 ), NULL, &click ); - - if ( button == 0 || GetEventKind( event ) == kEventMouseUp ) - modifiers += btnState ; - - WindowRef window ; + wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; + Point point ; + UInt32 modifiers = 0; + EventMouseButton button = 0 ; + UInt32 click = 0 ; + + GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, + sizeof( Point ), NULL, &point ); + GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, + sizeof( UInt32 ), NULL, &modifiers ); + GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL, + sizeof( EventMouseButton ), NULL, &button ); + GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL, + sizeof( UInt32 ), NULL, &click ); + + if ( button == 0 || GetEventKind( event ) == kEventMouseUp ) + modifiers += btnState ; + + WindowRef window ; short windowPart = ::FindWindow(point, &window); - if ( IsWindowActive(window) && windowPart == inContent ) + if ( IsWindowActive(window) && windowPart == inContent ) { - switch ( GetEventKind( event ) ) - { - case kEventMouseDown : - toplevelWindow->MacFireMouseEvent( mouseDown , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - case kEventMouseUp : - toplevelWindow->MacFireMouseEvent( mouseUp , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - case kEventMouseMoved : - toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - case kEventMouseDragged : - toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - default : - break ; - } - } - - return result ; - + switch ( GetEventKind( event ) ) + { + case kEventMouseDown : + toplevelWindow->MacFireMouseEvent( mouseDown , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + case kEventMouseUp : + toplevelWindow->MacFireMouseEvent( mouseUp , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + case kEventMouseMoved : + toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + case kEventMouseDragged : + toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + default : + break ; + } + } + + return result ; + } static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) @@ -266,53 +266,53 @@ static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRe OSStatus result = eventNotHandledErr ; OSStatus err = noErr ; - UInt32 attributes; - WindowRef windowRef ; - wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; - - GetEventParameter( event, kEventParamDirectObject, typeWindowRef, NULL, - sizeof( WindowRef ), NULL, &windowRef ); - - switch( GetEventKind( event ) ) - { - case kEventWindowUpdate : - if ( !wxPendingDelete.Member(toplevelWindow) ) - toplevelWindow->MacUpdate( EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - case kEventWindowActivated : - toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , true) ; - result = noErr ; - break ; - case kEventWindowDeactivated : - toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , false) ; - result = noErr ; - break ; - case kEventWindowClose : - toplevelWindow->Close() ; - result = noErr ; - break ; - case kEventWindowBoundsChanged : - err = GetEventParameter( event, kEventParamAttributes, typeUInt32, - NULL, sizeof( UInt32 ), NULL, &attributes ); - if ( err == noErr ) - { - Rect newContentRect ; - - GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL, - sizeof( newContentRect ), NULL, &newContentRect ); - + UInt32 attributes; + WindowRef windowRef ; + wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; + + GetEventParameter( event, kEventParamDirectObject, typeWindowRef, NULL, + sizeof( WindowRef ), NULL, &windowRef ); + + switch( GetEventKind( event ) ) + { + case kEventWindowUpdate : + if ( !wxPendingDelete.Member(toplevelWindow) ) + toplevelWindow->MacUpdate( EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + case kEventWindowActivated : + toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , true) ; + result = noErr ; + break ; + case kEventWindowDeactivated : + toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , false) ; + result = noErr ; + break ; + case kEventWindowClose : + toplevelWindow->Close() ; + result = noErr ; + break ; + case kEventWindowBoundsChanged : + err = GetEventParameter( event, kEventParamAttributes, typeUInt32, + NULL, sizeof( UInt32 ), NULL, &attributes ); + if ( err == noErr ) + { + Rect newContentRect ; + + GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL, + sizeof( newContentRect ), NULL, &newContentRect ); + toplevelWindow->SetSize( newContentRect.left , newContentRect.top , newContentRect.right - newContentRect.left , newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING); - result = noErr; - } - break ; - default : - break ; - } - return result ; + result = noErr; + } + break ; + default : + break ; + } + return result ; } pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) @@ -322,17 +322,17 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef switch ( GetEventClass( event ) ) { case kEventClassKeyboard : - result = KeyboardEventHandler( handler, event , data ) ; + result = KeyboardEventHandler( handler, event , data ) ; break ; case kEventClassTextInput : - result = TextInputEventHandler( handler, event , data ) ; + result = TextInputEventHandler( handler, event , data ) ; break ; case kEventClassWindow : - result = WindowEventHandler( handler, event , data ) ; - break ; + result = WindowEventHandler( handler, event , data ) ; + break ; case kEventClassMouse : - result = MouseEventHandler( handler, event , data ) ; - break ; + result = MouseEventHandler( handler, event , data ) ; + break ; default : break ; } @@ -503,32 +503,32 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, long style, const wxString& name ) { - SetName(name); - m_windowStyle = style; - m_isShown = FALSE; - - // create frame. - + SetName(name); + m_windowStyle = style; + m_isShown = FALSE; + + // create frame. + Rect theBoundsRect; - - m_x = (int)pos.x; - m_y = (int)pos.y; - if ( m_y < 50 ) - m_y = 50 ; - if ( m_x < 20 ) - m_x = 20 ; - m_width = size.x; + m_x = (int)pos.x; + m_y = (int)pos.y; + if ( m_y < 50 ) + m_y = 50 ; + if ( m_x < 20 ) + m_x = 20 ; + + m_width = size.x; if (m_width == -1) m_width = 20; - m_height = size.y; + m_height = size.y; if (m_height == -1) m_height = 20; - + ::SetRect(&theBoundsRect, m_x, m_y , m_x + m_width, m_y + m_height); - + // translate the window attributes in the appropriate window class and attributes - + WindowClass wclass = 0; WindowAttributes attr = kWindowNoAttributes ; @@ -538,7 +538,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) || HasFlag( wxSYSTEM_MENU ) || HasFlag( wxCAPTION ) || HasFlag(wxTINY_CAPTION_HORIZ) || HasFlag(wxTINY_CAPTION_VERT) - ) + ) { wclass = kFloatingWindowClass ; if ( HasFlag(wxTINY_CAPTION_VERT) ) @@ -557,12 +557,12 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, } else if ( HasFlag( wxCAPTION ) ) { - wclass = kDocumentWindowClass ; + wclass = kDocumentWindowClass ; } else { if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) || - HasFlag( wxSYSTEM_MENU ) ) + HasFlag( wxSYSTEM_MENU ) ) { wclass = kDocumentWindowClass ; } @@ -600,9 +600,9 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, UMASetWTitleC( (WindowRef)m_macWindow , label ) ; ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ; #if TARGET_CARBON - InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; - InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(), - GetEventTypeCount(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler)); + InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; + InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(), + GetEventTypeCount(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler)); #endif m_macFocus = NULL ; } @@ -621,7 +621,7 @@ void wxTopLevelWindowMac::MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR cli void wxTopLevelWindowMac::Clear() { - wxWindow::Clear() ; + wxWindow::Clear() ; } WXWidget wxTopLevelWindowMac::MacGetContainerForEmbedding() @@ -632,7 +632,6 @@ WXWidget wxTopLevelWindowMac::MacGetContainerForEmbedding() void wxTopLevelWindowMac::MacUpdate( long timestamp) { - wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ; BeginUpdate( (WindowRef)m_macWindow ) ; @@ -671,7 +670,7 @@ void wxTopLevelWindowMac::Lower() } void wxTopLevelWindowMac::MacFireMouseEvent( - wxUint16 kind , wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp ) + wxUint16 kind , wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp ) { wxMouseEvent event(wxEVT_LEFT_DOWN); bool isDown = !(modifiers & btnState) ; // 1 is for up @@ -770,12 +769,13 @@ void wxTopLevelWindowMac::MacFireMouseEvent( MacDispatchMouseEvent( event ) ; } } + #if !TARGET_CARBON void wxTopLevelWindowMac::MacMouseDown( WXEVENTREF ev , short part) { MacFireMouseEvent( mouseDown , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , - ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; + ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; } void wxTopLevelWindowMac::MacMouseUp( WXEVENTREF ev , short part) @@ -784,8 +784,8 @@ void wxTopLevelWindowMac::MacMouseUp( WXEVENTREF ev , short part) { case inContent: { - MacFireMouseEvent( mouseUp , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , - ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; + MacFireMouseEvent( mouseUp , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , + ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; } break ; } @@ -797,8 +797,8 @@ void wxTopLevelWindowMac::MacMouseMoved( WXEVENTREF ev , short part) { case inContent: { - MacFireMouseEvent( nullEvent /*moved*/ , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , - ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; + MacFireMouseEvent( nullEvent /*moved*/ , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , + ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; } break ; } @@ -886,11 +886,11 @@ void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) int former_w = m_width ; int former_h = m_height ; - int actualWidth = width; - int actualHeight = height; - int actualX = x; - int actualY = y; - + int actualWidth = width; + int actualHeight = height; + int actualX = x; + int actualY = y; + if ((m_minWidth != -1) && (actualWidth < m_minWidth)) actualWidth = m_minWidth; if ((m_minHeight != -1) && (actualHeight < m_minHeight)) @@ -977,51 +977,51 @@ void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackground ) { - GrafPtr formerPort ; - GetPort( &formerPort ) ; - SetPortWindowPort( (WindowRef)m_macWindow ) ; - - m_macNeedsErasing |= eraseBackground ; - - // if we already know that we will have to erase, there's no need to track the rest - if ( !m_macNeedsErasing) - { - // we end only here if eraseBackground is false - // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn - // we will have to erase anyway - - RgnHandle updateRgn = NewRgn(); - RgnHandle diffRgn = NewRgn() ; - if ( updateRgn && diffRgn ) + GrafPtr formerPort ; + GetPort( &formerPort ) ; + SetPortWindowPort( (WindowRef)m_macWindow ) ; + + m_macNeedsErasing |= eraseBackground ; + + // if we already know that we will have to erase, there's no need to track the rest + if ( !m_macNeedsErasing) { - GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn ); - Point pt = {0,0} ; - LocalToGlobal( &pt ) ; - OffsetRgn( updateRgn , -pt.h , -pt.v ) ; - DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ; - if ( !EmptyRgn( diffRgn ) ) + // we end only here if eraseBackground is false + // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn + // we will have to erase anyway + + RgnHandle updateRgn = NewRgn(); + RgnHandle diffRgn = NewRgn() ; + if ( updateRgn && diffRgn ) + { + GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn ); + Point pt = {0,0} ; + LocalToGlobal( &pt ) ; + OffsetRgn( updateRgn , -pt.h , -pt.v ) ; + DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ; + if ( !EmptyRgn( diffRgn ) ) + { + m_macNeedsErasing = true ; + } + } + if ( updateRgn ) + DisposeRgn( updateRgn ); + if ( diffRgn ) + DisposeRgn( diffRgn ); + + if ( !m_macNeedsErasing ) { - m_macNeedsErasing = true ; + RgnHandle rectRgn = NewRgn() ; + SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ; + UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ; + DisposeRgn( rectRgn ) ; } } - if ( updateRgn ) - DisposeRgn( updateRgn ); - if ( diffRgn ) - DisposeRgn( diffRgn ); - - if ( !m_macNeedsErasing ) - { - RgnHandle rectRgn = NewRgn() ; - SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ; - UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ; - DisposeRgn( rectRgn ) ; - } - } - InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ; - // turn this on to debug the refreshing cycle + InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ; + // turn this on to debug the refreshing cycle #if wxMAC_DEBUG_REDRAW - PaintRect( rect ) ; + PaintRect( rect ) ; #endif - SetPort( formerPort ) ; + SetPort( formerPort ) ; } diff --git a/src/mac/carbon/treectrl.cpp b/src/mac/carbon/treectrl.cpp index 2677a1efde..7a548a7436 100644 --- a/src/mac/carbon/treectrl.cpp +++ b/src/mac/carbon/treectrl.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -81,15 +81,15 @@ void wxTreeCtrl::SetIndent(int indent) wxImageList *wxTreeCtrl::GetImageList(int which) const { - if ( which == wxIMAGE_LIST_NORMAL ) + if ( which == wxIMAGE_LIST_NORMAL ) { - return m_imageListNormal; - } - else if ( which == wxIMAGE_LIST_STATE ) + return m_imageListNormal; + } + else if ( which == wxIMAGE_LIST_STATE ) { - return m_imageListState; - } - return NULL; + return m_imageListState; + } + return NULL; } void wxTreeCtrl::SetImageList(wxImageList *imageList, int which) @@ -274,50 +274,50 @@ bool wxTreeCtrl::DeleteItem(long item) bool wxTreeCtrl::ExpandItem(long item, int action) { // TODO - switch ( action ) - { + switch ( action ) + { case wxTREE_EXPAND_EXPAND: - break; - + break; + case wxTREE_EXPAND_COLLAPSE: - break; - + break; + case wxTREE_EXPAND_COLLAPSE_RESET: - break; - + break; + case wxTREE_EXPAND_TOGGLE: - break; - + break; + default: - wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem"); - } - - bool bOk = FALSE; // TODO expand item - - // May not send messages, so emulate them - if ( bOk ) { - wxTreeEvent event(wxEVT_NULL, m_windowId); - event.m_item.m_itemId = item; - event.m_item.m_mask = - event.m_item.m_stateMask = 0xffff; // get all - GetItem(event.m_item); - - bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0; - - event.m_code = action; - event.SetEventObject(this); - - // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded - event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDING - : wxEVT_COMMAND_TREE_ITEM_COLLAPSING); - GetEventHandler()->ProcessEvent(event); - - event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDED - : wxEVT_COMMAND_TREE_ITEM_COLLAPSED); - GetEventHandler()->ProcessEvent(event); - } - - return bOk; + wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem"); + } + + bool bOk = FALSE; // TODO expand item + + // May not send messages, so emulate them + if ( bOk ) { + wxTreeEvent event(wxEVT_NULL, m_windowId); + event.m_item.m_itemId = item; + event.m_item.m_mask = + event.m_item.m_stateMask = 0xffff; // get all + GetItem(event.m_item); + + bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0; + + event.m_code = action; + event.SetEventObject(this); + + // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded + event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDING + : wxEVT_COMMAND_TREE_ITEM_COLLAPSING); + GetEventHandler()->ProcessEvent(event); + + event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDED + : wxEVT_COMMAND_TREE_ITEM_COLLAPSED); + GetEventHandler()->ProcessEvent(event); + } + + return bOk; } long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) diff --git a/src/mac/carbon/uma.cpp b/src/mac/carbon/uma.cpp index 43e9cf7e44..59daa769db 100644 --- a/src/mac/carbon/uma.cpp +++ b/src/mac/carbon/uma.cpp @@ -25,7 +25,7 @@ // windows manager, control manager, navigation services etc. are // present -static bool sUMAHasAppearance = false ; +static bool sUMAHasAppearance = false ; static long sUMAAppearanceVersion = 0 ; static long sUMASystemVersion = 0 ; static bool sUMAHasAquaLayout = false ; @@ -36,7 +36,7 @@ bool UMAHasAppearance() { return sUMAHasAppearance ; } long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; } long UMAGetSystemVersion() { return sUMASystemVersion ; } -static bool sUMAHasWindowManager = false ; +static bool sUMAHasWindowManager = false ; static long sUMAWindowManagerAttr = 0 ; bool UMAHasWindowManager() { return sUMAHasWindowManager ; } @@ -46,72 +46,72 @@ bool UMASystemIsInitialized() { return sUMASystemInitialized ; } void UMACleanupToolbox() { - if ( sUMAHasAppearance ) - { - UnregisterAppearanceClient() ; - } - if ( NavServicesAvailable() ) - { - NavUnload() ; - } + if ( sUMAHasAppearance ) + { + UnregisterAppearanceClient() ; + } + if ( NavServicesAvailable() ) + { + NavUnload() ; + } if ( TXNTerminateTextension != (void*) kUnresolvedCFragSymbolAddress ) - TXNTerminateTextension( ) ; + TXNTerminateTextension( ) ; } void UMAInitToolbox( UInt16 inMoreMastersCalls ) { #if !TARGET_CARBON - ::MaxApplZone(); - for (long i = 1; i <= inMoreMastersCalls; i++) - ::MoreMasters(); - - ::InitGraf(&qd.thePort); - ::InitFonts(); - ::InitMenus(); - ::TEInit(); - ::InitDialogs(0L); - ::FlushEvents(everyEvent, 0); - ::InitCursor(); - long total,contig; - PurgeSpace(&total, &contig); + ::MaxApplZone(); + for (long i = 1; i <= inMoreMastersCalls; i++) + ::MoreMasters(); + + ::InitGraf(&qd.thePort); + ::InitFonts(); + ::InitMenus(); + ::TEInit(); + ::InitDialogs(0L); + ::FlushEvents(everyEvent, 0); + ::InitCursor(); + long total,contig; + PurgeSpace(&total, &contig); #else - InitCursor(); + InitCursor(); #endif if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr) - sUMASystemVersion = 0x0000 ; - - long theAppearance ; - if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) - { - sUMAHasAppearance = true ; - RegisterAppearanceClient(); - if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) - { - sUMAAppearanceVersion = theAppearance ; - } - else - { - sUMAAppearanceVersion = 0x0100 ; - } - } - if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr ) - { - sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ; - } - + sUMASystemVersion = 0x0000 ; + + long theAppearance ; + if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) + { + sUMAHasAppearance = true ; + RegisterAppearanceClient(); + if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) + { + sUMAAppearanceVersion = theAppearance ; + } + else + { + sUMAAppearanceVersion = 0x0100 ; + } + } + if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr ) + { + sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ; + } + #if TARGET_CARBON -// Call currently implicitely done : InitFloatingWindows() ; +// Call currently implicitely done : InitFloatingWindows() ; #else - if ( sUMAHasWindowManager ) - InitFloatingWindows() ; - else - InitWindows(); + if ( sUMAHasWindowManager ) + InitFloatingWindows() ; + else + InitWindows(); #endif - if ( NavServicesAvailable() ) - { - NavLoad() ; - } + if ( NavServicesAvailable() ) + { + NavLoad() ; + } long menuMgrAttr ; Gestalt( gestaltMenuMgrAttr , &menuMgrAttr ) ; @@ -121,10 +121,10 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) if ( TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress ) { FontFamilyID fontId ; - Str255 fontName ; - SInt16 fontSize ; - Style fontStyle ; - GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetFNum( fontName, &fontId ); TXNMacOSPreferredFontDescription fontDescriptions[] = @@ -135,15 +135,15 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) #if 0 // TARGET_CARBON --noOfFontDescriptions ; #endif - // kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke - OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ; + // kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke + OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ; #if TARGET_CARBON if ( !UMAHasAquaLayout() ) #endif { options |= kTXNAlwaysUseQuickDrawTextMask ; } - TXNInitTextension(fontDescriptions, noOfFontDescriptions, options ); + TXNInitTextension(fontDescriptions, noOfFontDescriptions, options ); } @@ -153,286 +153,286 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) /* Boolean CanUseATSUI() - { - long result; - OSErr err = Gestalt(gestaltATSUVersion, &result); - return (err == noErr); - } + { + long result; + OSErr err = Gestalt(gestaltATSUVersion, &result); + return (err == noErr); + } */ // process manager long UMAGetProcessMode() { - OSErr err ; - ProcessInfoRec processinfo; - ProcessSerialNumber procno ; - - procno.highLongOfPSN = NULL ; - procno.lowLongOfPSN = kCurrentProcess ; - processinfo.processInfoLength = sizeof(ProcessInfoRec); - processinfo.processName = NULL; - processinfo.processAppSpec = NULL; + OSErr err ; + ProcessInfoRec processinfo; + ProcessSerialNumber procno ; + + procno.highLongOfPSN = NULL ; + procno.lowLongOfPSN = kCurrentProcess ; + processinfo.processInfoLength = sizeof(ProcessInfoRec); + processinfo.processName = NULL; + processinfo.processAppSpec = NULL; - err = ::GetProcessInformation( &procno , &processinfo ) ; - wxASSERT( err == noErr ) ; - return processinfo.processMode ; + err = ::GetProcessInformation( &procno , &processinfo ) ; + wxASSERT( err == noErr ) ; + return processinfo.processMode ; } bool UMAGetProcessModeDoesActivateOnFGSwitch() { - return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ; + return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ; } // menu manager MenuRef UMANewMenu( SInt16 id , const wxString& title ) { - wxString str = wxStripMenuCodes( title ) ; - MenuRef menu ; + wxString str = wxStripMenuCodes( title ) ; + MenuRef menu ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - CreateNewMenu( id , 0 , &menu ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + CFStringRef cfs = wxMacCreateCFString( str ) ; + CreateNewMenu( id , 0 , &menu ) ; + SetMenuTitleWithCFString( menu , cfs ) ; + CFRelease( cfs ) ; #else - Str255 ptitle ; - wxMacStringToPascal( str , ptitle ) ; - menu = ::NewMenu( id , ptitle ) ; + Str255 ptitle ; + wxMacStringToPascal( str , ptitle ) ; + menu = ::NewMenu( id , ptitle ) ; #endif - return menu ; + return menu ; } void UMASetMenuTitle( MenuRef menu , const wxString& title ) { - wxString str = wxStripMenuCodes( title ) ; + wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + CFStringRef cfs = wxMacCreateCFString( str ) ; + SetMenuTitleWithCFString( menu , cfs ) ; + CFRelease( cfs ) ; #else - Str255 ptitle ; - wxMacStringToPascal( str , ptitle ) ; - SetMenuTitle( menu , ptitle ) ; + Str255 ptitle ; + wxMacStringToPascal( str , ptitle ) ; + SetMenuTitle( menu , ptitle ) ; #endif } void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title ) { - wxString str = wxStripMenuCodes( title ) ; + wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuItemTextWithCFString( menu , item , cfs ) ; - CFRelease( cfs ) ; + CFStringRef cfs = wxMacCreateCFString( str ) ; + SetMenuItemTextWithCFString( menu , item , cfs ) ; + CFRelease( cfs ) ; #else - Str255 ptitle ; - wxMacStringToPascal( str , ptitle ) ; - SetMenuItemText( menu , item , ptitle ) ; + Str255 ptitle ; + wxMacStringToPascal( str , ptitle ) ; + SetMenuItemText( menu , item , ptitle ) ; #endif } UInt32 UMAMenuEvent( EventRecord *inEvent ) { - return MenuEvent( inEvent ) ; + return MenuEvent( inEvent ) ; } void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem , bool enable) { - if ( enable ) - EnableMenuItem( inMenu , inItem ) ; - else - DisableMenuItem( inMenu , inItem ) ; + if ( enable ) + EnableMenuItem( inMenu , inItem ) ; + else + DisableMenuItem( inMenu , inItem ) ; } void UMAAppendSubMenuItem( MenuRef menu , const wxString& title , SInt16 id ) { - MacAppendMenu(menu, "\pA"); - UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title ); - SetMenuItemHierarchicalID( menu , CountMenuItems( menu ) , id ) ; + MacAppendMenu(menu, "\pA"); + UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title ); + SetMenuItemHierarchicalID( menu , CountMenuItems( menu ) , id ) ; } void UMAInsertSubMenuItem( MenuRef menu , const wxString& title , MenuItemIndex item , SInt16 id ) { - MacInsertMenuItem(menu, "\pA" , item); - UMASetMenuItemText(menu, item , title ); - SetMenuItemHierarchicalID( menu , item , id ) ; + MacInsertMenuItem(menu, "\pA" , item); + UMASetMenuItemText(menu, item , title ); + SetMenuItemHierarchicalID( menu , item , id ) ; } void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEntry *entry ) { - if ( !entry ) - return ; - - UInt8 modifiers = 0 ; - SInt16 key = entry->GetKeyCode() ; - if ( key ) - { - bool explicitCommandKey = false ; - - if ( entry->GetFlags() & wxACCEL_CTRL ) - { - explicitCommandKey = true ; - } - - if (entry->GetFlags() & wxACCEL_ALT ) - { - modifiers |= kMenuOptionModifier ; - } - - if (entry->GetFlags() & wxACCEL_SHIFT) - { - modifiers |= kMenuShiftModifier ; - } - - SInt16 glyph = 0 ; - SInt16 macKey = key ; - if ( key >= WXK_F1 && key <= WXK_F15 ) - { - macKey = kFunctionKeyCharCode ; - glyph = kMenuF1Glyph + ( key - WXK_F1 ) ; - if ( key >= WXK_F13 ) - glyph += 13 ; + if ( !entry ) + return ; + + UInt8 modifiers = 0 ; + SInt16 key = entry->GetKeyCode() ; + if ( key ) + { + bool explicitCommandKey = false ; + + if ( entry->GetFlags() & wxACCEL_CTRL ) + { + explicitCommandKey = true ; + } + + if (entry->GetFlags() & wxACCEL_ALT ) + { + modifiers |= kMenuOptionModifier ; + } + + if (entry->GetFlags() & wxACCEL_SHIFT) + { + modifiers |= kMenuShiftModifier ; + } + + SInt16 glyph = 0 ; + SInt16 macKey = key ; + if ( key >= WXK_F1 && key <= WXK_F15 ) + { + macKey = kFunctionKeyCharCode ; + glyph = kMenuF1Glyph + ( key - WXK_F1 ) ; + if ( key >= WXK_F13 ) + glyph += 13 ; if ( !explicitCommandKey ) - modifiers |= kMenuNoCommandModifier ; - - switch( key ) - { - case WXK_F1 : - macKey += ( 0x7a << 8 ) ; - break ; - case WXK_F2 : - macKey += ( 0x78 << 8 ) ; - break ; - case WXK_F3 : - macKey += ( 0x63 << 8 ) ; - break ; - case WXK_F4 : - macKey += ( 0x76 << 8 ) ; - break ; - case WXK_F5 : - macKey += ( 0x60 << 8 ) ; - break ; - case WXK_F6 : - macKey += ( 0x61 << 8 ) ; - break ; - case WXK_F7 : - macKey += ( 0x62 << 8 ) ; - break ; - case WXK_F8 : - macKey += ( 0x64 << 8 ) ; - break ; - case WXK_F9 : - macKey += ( 0x65 << 8 ) ; - break ; - case WXK_F10 : - macKey += ( 0x6D << 8 ) ; - break ; - case WXK_F11 : - macKey += ( 0x67 << 8 ) ; - break ; - case WXK_F12 : - macKey += ( 0x6F << 8 ) ; - break ; - case WXK_F13 : - macKey += ( 0x69 << 8 ) ; - break ; - case WXK_F14 : - macKey += ( 0x6B << 8 ) ; - break ; - case WXK_F15 : - macKey += ( 0x71 << 8 ) ; - break ; - default : - break ; - } ; - // unfortunately this does not yet trigger the right key , - // for some reason mac justs picks the first function key menu - // defined, so we turn this off - macKey = 0 ; - glyph = 0 ; - } - else - { - switch( key ) - { - case WXK_BACK : - macKey = kBackspaceCharCode ; - glyph = kMenuDeleteLeftGlyph ; - break ; - case WXK_TAB : - macKey = kTabCharCode ; - glyph = kMenuTabRightGlyph ; - break ; - case kEnterCharCode : - macKey = kEnterCharCode ; - glyph = kMenuEnterGlyph ; - break ; - case WXK_RETURN : - macKey = kReturnCharCode ; - glyph = kMenuReturnGlyph ; - break ; - case WXK_ESCAPE : - macKey = kEscapeCharCode ; - glyph = kMenuEscapeGlyph ; - break ; - case WXK_SPACE : - macKey = ' ' ; - glyph = kMenuSpaceGlyph ; - break ; - case WXK_DELETE : - macKey = kDeleteCharCode ; - glyph = kMenuDeleteRightGlyph ; - break ; - case WXK_CLEAR : - macKey = kClearCharCode ; - glyph = kMenuClearGlyph ; - break ; - case WXK_PRIOR : // PAGE UP - macKey = kPageUpCharCode ; - glyph = kMenuPageUpGlyph ; - break ; - case WXK_NEXT : - macKey = kPageDownCharCode ; - glyph = kMenuPageDownGlyph ; - break ; - case WXK_LEFT : - macKey = kLeftArrowCharCode ; - glyph = kMenuLeftArrowGlyph ; - break ; - case WXK_UP : - macKey = kUpArrowCharCode ; - glyph = kMenuUpArrowGlyph ; - break ; - case WXK_RIGHT : - macKey = kRightArrowCharCode ; - glyph = kMenuRightArrowGlyph ; - break ; - case WXK_DOWN : - macKey = kDownArrowCharCode ; - glyph = kMenuDownArrowGlyph ; - break ; + modifiers |= kMenuNoCommandModifier ; + + switch( key ) + { + case WXK_F1 : + macKey += ( 0x7a << 8 ) ; + break ; + case WXK_F2 : + macKey += ( 0x78 << 8 ) ; + break ; + case WXK_F3 : + macKey += ( 0x63 << 8 ) ; + break ; + case WXK_F4 : + macKey += ( 0x76 << 8 ) ; + break ; + case WXK_F5 : + macKey += ( 0x60 << 8 ) ; + break ; + case WXK_F6 : + macKey += ( 0x61 << 8 ) ; + break ; + case WXK_F7 : + macKey += ( 0x62 << 8 ) ; + break ; + case WXK_F8 : + macKey += ( 0x64 << 8 ) ; + break ; + case WXK_F9 : + macKey += ( 0x65 << 8 ) ; + break ; + case WXK_F10 : + macKey += ( 0x6D << 8 ) ; + break ; + case WXK_F11 : + macKey += ( 0x67 << 8 ) ; + break ; + case WXK_F12 : + macKey += ( 0x6F << 8 ) ; + break ; + case WXK_F13 : + macKey += ( 0x69 << 8 ) ; + break ; + case WXK_F14 : + macKey += ( 0x6B << 8 ) ; + break ; + case WXK_F15 : + macKey += ( 0x71 << 8 ) ; + break ; + default : + break ; + } ; + // unfortunately this does not yet trigger the right key , + // for some reason mac justs picks the first function key menu + // defined, so we turn this off + macKey = 0 ; + glyph = 0 ; + } + else + { + switch( key ) + { + case WXK_BACK : + macKey = kBackspaceCharCode ; + glyph = kMenuDeleteLeftGlyph ; + break ; + case WXK_TAB : + macKey = kTabCharCode ; + glyph = kMenuTabRightGlyph ; + break ; + case kEnterCharCode : + macKey = kEnterCharCode ; + glyph = kMenuEnterGlyph ; + break ; + case WXK_RETURN : + macKey = kReturnCharCode ; + glyph = kMenuReturnGlyph ; + break ; + case WXK_ESCAPE : + macKey = kEscapeCharCode ; + glyph = kMenuEscapeGlyph ; + break ; + case WXK_SPACE : + macKey = ' ' ; + glyph = kMenuSpaceGlyph ; + break ; + case WXK_DELETE : + macKey = kDeleteCharCode ; + glyph = kMenuDeleteRightGlyph ; + break ; + case WXK_CLEAR : + macKey = kClearCharCode ; + glyph = kMenuClearGlyph ; + break ; + case WXK_PRIOR : // PAGE UP + macKey = kPageUpCharCode ; + glyph = kMenuPageUpGlyph ; + break ; + case WXK_NEXT : + macKey = kPageDownCharCode ; + glyph = kMenuPageDownGlyph ; + break ; + case WXK_LEFT : + macKey = kLeftArrowCharCode ; + glyph = kMenuLeftArrowGlyph ; + break ; + case WXK_UP : + macKey = kUpArrowCharCode ; + glyph = kMenuUpArrowGlyph ; + break ; + case WXK_RIGHT : + macKey = kRightArrowCharCode ; + glyph = kMenuRightArrowGlyph ; + break ; + case WXK_DOWN : + macKey = kDownArrowCharCode ; + glyph = kMenuDownArrowGlyph ; + break ; } } - SetItemCmd( menu, item , macKey ); - SetMenuItemModifiers(menu, item , modifiers ) ; + SetItemCmd( menu, item , macKey ); + SetMenuItemModifiers(menu, item , modifiers ) ; if ( glyph ) SetMenuItemKeyGlyph(menu, item , glyph ) ; - } + } } void UMAAppendMenuItem( MenuRef menu , const wxString& title , wxAcceleratorEntry *entry ) { - MacAppendMenu(menu, "\pA"); - UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title ); - UMASetMenuItemShortcut( menu , (SInt16) ::CountMenuItems(menu), entry ) ; + MacAppendMenu(menu, "\pA"); + UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title ); + UMASetMenuItemShortcut( menu , (SInt16) ::CountMenuItems(menu), entry ) ; } void UMAInsertMenuItem( MenuRef menu , const wxString& title , MenuItemIndex item , wxAcceleratorEntry *entry ) { - MacInsertMenuItem( menu , "\p" , item) ; - UMASetMenuItemText(menu, item , title ); - UMASetMenuItemShortcut( menu , item , entry ) ; + MacInsertMenuItem( menu , "\p" , item) ; + UMASetMenuItemText(menu, item , title ); + UMASetMenuItemShortcut( menu , item , entry ) ; } // quickdraw @@ -442,58 +442,58 @@ int gPrOpenCounter = 0 ; OSStatus UMAPrOpen(void *macPrintSession) { #if !TARGET_CARBON - OSErr err = noErr ; - ++gPrOpenCounter ; - if ( gPrOpenCounter == 1 ) - { - PrOpen() ; - err = PrError() ; - wxASSERT( err == noErr ) ; - } - return err ; + OSErr err = noErr ; + ++gPrOpenCounter ; + if ( gPrOpenCounter == 1 ) + { + PrOpen() ; + err = PrError() ; + wxASSERT( err == noErr ) ; + } + return err ; #else - OSStatus err = noErr ; - ++gPrOpenCounter ; - if ( gPrOpenCounter == 1 ) - { + OSStatus err = noErr ; + ++gPrOpenCounter ; + if ( gPrOpenCounter == 1 ) + { #if PM_USE_SESSION_APIS - err = PMCreateSession((PMPrintSession *)macPrintSession) ; + err = PMCreateSession((PMPrintSession *)macPrintSession) ; #else - err = PMBegin() ; + err = PMBegin() ; #endif - wxASSERT( err == noErr ) ; - } - return err ; + wxASSERT( err == noErr ) ; + } + return err ; #endif } OSStatus UMAPrClose(void *macPrintSession) { #if !TARGET_CARBON - OSErr err = noErr ; - wxASSERT( gPrOpenCounter >= 1 ) ; - if ( gPrOpenCounter == 1 ) - { - PrClose() ; - err = PrError() ; - wxASSERT( err == noErr ) ; - } - --gPrOpenCounter ; - return err ; + OSErr err = noErr ; + wxASSERT( gPrOpenCounter >= 1 ) ; + if ( gPrOpenCounter == 1 ) + { + PrClose() ; + err = PrError() ; + wxASSERT( err == noErr ) ; + } + --gPrOpenCounter ; + return err ; #else - OSStatus err = noErr ; - wxASSERT( gPrOpenCounter >= 1 ) ; - if ( gPrOpenCounter == 1 ) - { + OSStatus err = noErr ; + wxASSERT( gPrOpenCounter >= 1 ) ; + if ( gPrOpenCounter == 1 ) + { #if PM_USE_SESSION_APIS - err = PMRelease(*(PMPrintSession *)macPrintSession) ; - *(PMPrintSession *)macPrintSession = kPMNoReference; + err = PMRelease(*(PMPrintSession *)macPrintSession) ; + *(PMPrintSession *)macPrintSession = kPMNoReference; #else - err = PMEnd() ; + err = PMEnd() ; #endif - } - --gPrOpenCounter ; - return err ; + } + --gPrOpenCounter ; + return err ; #endif } @@ -502,82 +502,82 @@ OSStatus UMAPrClose(void *macPrintSession) pascal QDGlobalsPtr GetQDGlobalsPtr (void) ; pascal QDGlobalsPtr GetQDGlobalsPtr (void) { - return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA); + return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA); } #endif void UMAShowWatchCursor() { - OSErr err = noErr; + OSErr err = noErr; - CursHandle watchFob = GetCursor (watchCursor); + CursHandle watchFob = GetCursor (watchCursor); - if (!watchFob) - err = nilHandleErr; - else - { - #if TARGET_CARBON -// Cursor preservedArrow; -// GetQDGlobalsArrow (&preservedArrow); -// SetQDGlobalsArrow (*watchFob); -// InitCursor ( ); -// SetQDGlobalsArrow (&preservedArrow); - SetCursor (*watchFob); - #else - SetCursor (*watchFob); - #endif - } + if (!watchFob) + err = nilHandleErr; + else + { + #if TARGET_CARBON +// Cursor preservedArrow; +// GetQDGlobalsArrow (&preservedArrow); +// SetQDGlobalsArrow (*watchFob); +// InitCursor ( ); +// SetQDGlobalsArrow (&preservedArrow); + SetCursor (*watchFob); + #else + SetCursor (*watchFob); + #endif + } } -void UMAShowArrowCursor() +void UMAShowArrowCursor() { #if TARGET_CARBON - Cursor arrow; - SetCursor (GetQDGlobalsArrow (&arrow)); + Cursor arrow; + SetCursor (GetQDGlobalsArrow (&arrow)); #else - SetCursor (&(qd.arrow)); + SetCursor (&(qd.arrow)); #endif } // window manager -GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) +GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) { - wxASSERT( inWindowRef != NULL ) ; + wxASSERT( inWindowRef != NULL ) ; #if TARGET_CARBON - return (GrafPtr) GetWindowPort( inWindowRef ) ; + return (GrafPtr) GetWindowPort( inWindowRef ) ; #else - return (GrafPtr) inWindowRef ; + return (GrafPtr) inWindowRef ; #endif } -void UMADisposeWindow( WindowRef inWindowRef ) +void UMADisposeWindow( WindowRef inWindowRef ) { - wxASSERT( inWindowRef != NULL ) ; - DisposeWindow( inWindowRef ) ; + wxASSERT( inWindowRef != NULL ) ; + DisposeWindow( inWindowRef ) ; } -void UMASetWTitleC( WindowRef inWindowRef , const char *title ) +void UMASetWTitleC( WindowRef inWindowRef , const char *title ) { - Str255 ptitle ; - strncpy( (char*)ptitle , title , 96 ) ; - ptitle[96] = 0 ; + Str255 ptitle ; + strncpy( (char*)ptitle , title , 96 ) ; + ptitle[96] = 0 ; #if TARGET_CARBON - c2pstrcpy( ptitle, (char *)ptitle ) ; + c2pstrcpy( ptitle, (char *)ptitle ) ; #else - c2pstr( (char*)ptitle ) ; + c2pstr( (char*)ptitle ) ; #endif - SetWTitle( inWindowRef , ptitle ) ; + SetWTitle( inWindowRef , ptitle ) ; } -void UMAGetWTitleC( WindowRef inWindowRef , char *title ) +void UMAGetWTitleC( WindowRef inWindowRef , char *title ) { - GetWTitle( inWindowRef , (unsigned char*)title ) ; + GetWTitle( inWindowRef , (unsigned char*)title ) ; #if TARGET_CARBON - p2cstrcpy( title, (unsigned char *)title ) ; + p2cstrcpy( title, (unsigned char *)title ) ; #else - p2cstr( (unsigned char*)title ) ; + p2cstr( (unsigned char*)title ) ; #endif } @@ -587,18 +587,18 @@ void UMAActivateControl( ControlHandle inControl ) { // we have to add the control after again to the update rgn // otherwise updates get lost - if ( !IsControlActive( inControl ) ) - { + if ( !IsControlActive( inControl ) ) + { bool visible = IsControlVisible( inControl ) ; if ( visible ) - SetControlVisibility( inControl , false , false ) ; + SetControlVisibility( inControl , false , false ) ; ::ActivateControl( inControl ) ; if ( visible ) { - SetControlVisibility( inControl , true , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } - } + } } void UMADrawControl( ControlHandle inControl ) @@ -606,153 +606,151 @@ void UMADrawControl( ControlHandle inControl ) WindowRef theWindow = GetControlOwner(inControl) ; RgnHandle updateRgn = NewRgn() ; GetWindowUpdateRgn( theWindow , updateRgn ) ; - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; + Point zero = { 0 , 0 } ; + LocalToGlobal( &zero ) ; + OffsetRgn( updateRgn , -zero.h , -zero.v ) ; ::DrawControlInCurrentPort( inControl ) ; InvalWindowRgn( theWindow, updateRgn) ; - DisposeRgn( updateRgn ) ; + DisposeRgn( updateRgn ) ; } void UMAMoveControl( ControlHandle inControl , short x , short y ) { - bool visible = IsControlVisible( inControl ) ; - if ( visible ) { - SetControlVisibility( inControl , false , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } - ::MoveControl( inControl , x , y ) ; - if ( visible ) { - SetControlVisibility( inControl , true , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } + bool visible = IsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } + ::MoveControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } } void UMASizeControl( ControlHandle inControl , short x , short y ) { - bool visible = IsControlVisible( inControl ) ; - if ( visible ) { - SetControlVisibility( inControl , false , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } - ::SizeControl( inControl , x , y ) ; - if ( visible ) { - SetControlVisibility( inControl , true , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } + bool visible = IsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } + ::SizeControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } } void UMADeactivateControl( ControlHandle inControl ) { // we have to add the control after again to the update rgn // otherwise updates get lost - bool visible = IsControlVisible( inControl ) ; - if ( visible ) - SetControlVisibility( inControl , false , false ) ; - ::DeactivateControl( inControl ) ; - if ( visible ) { - SetControlVisibility( inControl , true , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } -} -// shows the control and adds the region to the update region -void UMAShowControl (ControlHandle inControl) -{ + bool visible = IsControlVisible( inControl ) ; + if ( visible ) + SetControlVisibility( inControl , false , false ) ; + ::DeactivateControl( inControl ) ; + if ( visible ) { SetControlVisibility( inControl , true , false ) ; Rect ctrlBounds ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } +} +// shows the control and adds the region to the update region +void UMAShowControl (ControlHandle inControl) +{ + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } // shows the control and adds the region to the update region -void UMAHideControl (ControlHandle inControl) +void UMAHideControl (ControlHandle inControl) { - SetControlVisibility( inControl , false , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + SetControlVisibility( inControl , false , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } // keyboard focus -OSErr UMASetKeyboardFocus (WindowPtr inWindow, - ControlHandle inControl, - ControlFocusPart inPart) +OSErr UMASetKeyboardFocus (WindowPtr inWindow, + ControlHandle inControl, + ControlFocusPart inPart) { - OSErr err = noErr; - GrafPtr port ; - GetPort( &port ) ; + OSErr err = noErr; + GrafPtr port ; + GetPort( &port ) ; - SetPortWindowPort( inWindow ) ; + SetPortWindowPort( inWindow ) ; - err = SetKeyboardFocus( inWindow , inControl , inPart ) ; - SetPort( port ) ; - return err ; + err = SetKeyboardFocus( inWindow , inControl , inPart ) ; + SetPort( port ) ; + return err ; } - - // events void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( inWindow , updateRgn ) ; - - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; - - UpdateControls( inWindow , inRgn ) ; - InvalWindowRgn( inWindow, updateRgn) ; - DisposeRgn( updateRgn ) ; - + RgnHandle updateRgn = NewRgn() ; + GetWindowUpdateRgn( inWindow , updateRgn ) ; + + Point zero = { 0 , 0 } ; + LocalToGlobal( &zero ) ; + OffsetRgn( updateRgn , -zero.h , -zero.v ) ; + + UpdateControls( inWindow , inRgn ) ; + InvalWindowRgn( inWindow, updateRgn) ; + DisposeRgn( updateRgn ) ; } bool UMAIsWindowFloating( WindowRef inWindow ) { - WindowClass cl ; - - GetWindowClass( inWindow , &cl ) ; - return cl == kFloatingWindowClass ; + WindowClass cl ; + + GetWindowClass( inWindow , &cl ) ; + return cl == kFloatingWindowClass ; } bool UMAIsWindowModal( WindowRef inWindow ) { - WindowClass cl ; - - GetWindowClass( inWindow , &cl ) ; - return cl < kFloatingWindowClass ; + WindowClass cl ; + + GetWindowClass( inWindow , &cl ) ; + return cl < kFloatingWindowClass ; } // others void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) { - if ( inWindowRef ) - { -// bool isHighlighted = IsWindowHighlited( inWindowRef ) ; -// if ( inActivate != isHightlited ) - GrafPtr port ; - GetPort( &port ) ; - SetPortWindowPort( inWindowRef ) ; - HiliteWindow( inWindowRef , inActivate ) ; - ControlHandle control = NULL ; - ::GetRootControl( inWindowRef , & control ) ; - if ( control ) - { - if ( inActivate ) - UMAActivateControl( control ) ; - else - UMADeactivateControl( control ) ; - } - SetPort( port ) ; - } + if ( inWindowRef ) + { +// bool isHighlighted = IsWindowHighlited( inWindowRef ) ; +// if ( inActivate != isHightlited ) + GrafPtr port ; + GetPort( &port ) ; + SetPortWindowPort( inWindowRef ) ; + HiliteWindow( inWindowRef , inActivate ) ; + ControlHandle control = NULL ; + ::GetRootControl( inWindowRef , & control ) ; + if ( control ) + { + if ( inActivate ) + UMAActivateControl( control ) ; + else + UMADeactivateControl( control ) ; + } + SetPort( port ) ; + } } + OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) { - return ::DrawThemePlacard( inRect , inState ) ; + return ::DrawThemePlacard( inRect , inState ) ; } #if !TARGET_CARBON @@ -765,77 +763,77 @@ OSStatus UMAGetHelpMenu( MenuItemIndex * outFirstCustomItemIndex) { #if TARGET_CARBON - return HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ; + return HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ; #else - MenuRef helpMenuHandle ; - helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ; - if ( firstCustomItemIndex == 0 && helpMenuStatus == noErr ) - { - firstCustomItemIndex = CountMenuItems( helpMenuHandle ) + 1 ; - } - if ( outFirstCustomItemIndex ) - { - *outFirstCustomItemIndex = firstCustomItemIndex ; - } - *outHelpMenu = helpMenuHandle ; - return helpMenuStatus ; + MenuRef helpMenuHandle ; + helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ; + if ( firstCustomItemIndex == 0 && helpMenuStatus == noErr ) + { + firstCustomItemIndex = CountMenuItems( helpMenuHandle ) + 1 ; + } + if ( outFirstCustomItemIndex ) + { + *outFirstCustomItemIndex = firstCustomItemIndex ; + } + *outHelpMenu = helpMenuHandle ; + return helpMenuStatus ; #endif } wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport) { - m_clip = NULL ; - Setup( newport ) ; + m_clip = NULL ; + Setup( newport ) ; } wxMacPortStateHelper::wxMacPortStateHelper() { - m_clip = NULL ; + m_clip = NULL ; } void wxMacPortStateHelper::Setup( GrafPtr newport ) { - GetPort( &m_oldPort ) ; - SetPort( newport ) ; - wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ; - m_clip = NewRgn() ; - GetClip( m_clip ); - m_textFont = GetPortTextFont( (CGrafPtr) newport); - m_textSize = GetPortTextSize( (CGrafPtr) newport); - m_textStyle = GetPortTextFace( (CGrafPtr) newport); - m_textMode = GetPortTextMode( (CGrafPtr) newport); - GetThemeDrawingState( &m_drawingState ) ; - m_currentPort = newport ; + GetPort( &m_oldPort ) ; + SetPort( newport ) ; + wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ; + m_clip = NewRgn() ; + GetClip( m_clip ); + m_textFont = GetPortTextFont( (CGrafPtr) newport); + m_textSize = GetPortTextSize( (CGrafPtr) newport); + m_textStyle = GetPortTextFace( (CGrafPtr) newport); + m_textMode = GetPortTextMode( (CGrafPtr) newport); + GetThemeDrawingState( &m_drawingState ) ; + m_currentPort = newport ; } void wxMacPortStateHelper::Clear() { - if ( m_clip ) - { - DisposeRgn( m_clip ) ; - DisposeThemeDrawingState( m_drawingState ) ; - m_clip = NULL ; - } + if ( m_clip ) + { + DisposeRgn( m_clip ) ; + DisposeThemeDrawingState( m_drawingState ) ; + m_clip = NULL ; + } } wxMacPortStateHelper::~wxMacPortStateHelper() { - if ( m_clip ) - { - SetPort( m_currentPort ) ; - SetClip( m_clip ) ; - DisposeRgn( m_clip ) ; - TextFont( m_textFont ); - TextSize( m_textSize ); - TextFace( m_textStyle ); - TextMode( m_textMode ); - SetThemeDrawingState( m_drawingState , true ) ; - SetPort( m_oldPort ) ; - } + if ( m_clip ) + { + SetPort( m_currentPort ) ; + SetClip( m_clip ) ; + DisposeRgn( m_clip ) ; + TextFont( m_textFont ); + TextSize( m_textSize ); + TextFace( m_textStyle ); + TextMode( m_textMode ); + SetThemeDrawingState( m_drawingState , true ) ; + SetPort( m_oldPort ) ; + } } OSStatus UMAPutScrap( Size size , OSType type , void *data ) { - OSStatus err = noErr ; + OSStatus err = noErr ; #if !TARGET_CARBON err = PutScrap( size , type , data ) ; #else @@ -846,6 +844,6 @@ OSStatus UMAPutScrap( Size size , OSType type , void *data ) err = PutScrapFlavor (scrap, type , 0, size, data); } #endif - return err ; + return err ; } diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index f308faf2df..a3f95679a9 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -50,27 +50,27 @@ bool wxGetFullHostName(wxChar *buf, int maxSize) // Get hostname only (without domain name) bool wxGetHostName(char *buf, int maxSize) { - // Gets Chooser name of user by examining a System resource. - - const short kComputerNameID = -16413; - - short oldResFile = CurResFile() ; - UseResFile(0); - StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); - UseResFile(oldResFile); - - if (chooserName && *chooserName) - { - int length = (*chooserName)[0] ; - if ( length + 1 > maxSize ) - { - length = maxSize - 1 ; - } - strncpy( buf , (char*) &(*chooserName)[1] , length ) ; - buf[length] = 0 ; - } - else - buf[0] = 0 ; + // Gets Chooser name of user by examining a System resource. + + const short kComputerNameID = -16413; + + short oldResFile = CurResFile() ; + UseResFile(0); + StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); + UseResFile(oldResFile); + + if (chooserName && *chooserName) + { + int length = (*chooserName)[0] ; + if ( length + 1 > maxSize ) + { + length = maxSize - 1 ; + } + strncpy( buf , (char*) &(*chooserName)[1] , length ) ; + buf[length] = 0 ; + } + else + buf[0] = 0 ; return TRUE; } @@ -83,34 +83,34 @@ bool wxGetUserId(char *buf, int maxSize) const wxChar* wxGetHomeDir(wxString *pstr) { - *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ; - return pstr->c_str() ; + *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ; + return pstr->c_str() ; } // Get user name e.g. Stefan Csomor bool wxGetUserName(char *buf, int maxSize) { - // Gets Chooser name of user by examining a System resource. - - const short kChooserNameID = -16096; - - short oldResFile = CurResFile() ; - UseResFile(0); - StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); - UseResFile(oldResFile); - - if (chooserName && *chooserName) - { - int length = (*chooserName)[0] ; - if ( length + 1 > maxSize ) - { - length = maxSize - 1 ; - } - strncpy( buf , (char*) &(*chooserName)[1] , length ) ; - buf[length] = 0 ; - } - else - buf[0] = 0 ; + // Gets Chooser name of user by examining a System resource. + + const short kChooserNameID = -16096; + + short oldResFile = CurResFile() ; + UseResFile(0); + StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); + UseResFile(oldResFile); + + if (chooserName && *chooserName) + { + int length = (*chooserName)[0] ; + if ( length + 1 > maxSize ) + { + length = maxSize - 1 ; + } + strncpy( buf , (char*) &(*chooserName)[1] , length ) ; + buf[length] = 0 ; + } + else + buf[0] = 0 ; return TRUE; } @@ -123,15 +123,15 @@ int wxKill(long pid, wxSignal sig , wxKillError *rc ) WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value) { - // TODO : under classic there is no environement support, under X yes - return false ; + // TODO : under classic there is no environement support, under X yes + return false ; } // set the env var name to the given value, return TRUE on success WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value) { - // TODO : under classic there is no environement support, under X yes - return false ; + // TODO : under classic there is no environement support, under X yes + return false ; } // @@ -161,7 +161,7 @@ void wxUsleep(unsigned long milliseconds) clock_t start = clock() ; do { - YieldToAnyThread() ; + YieldToAnyThread() ; } while( clock() - start < milliseconds / CLOCKS_PER_SEC ) ; } @@ -180,34 +180,34 @@ void wxFlushEvents() // Output a debug message, in a system dependent fashion. void wxDebugMsg(const char *fmt ...) { - va_list ap; - static char buffer[512]; - - if (!wxTheApp->GetWantDebugOutput()) - return ; - - va_start(ap, fmt); - - vsprintf(buffer,fmt,ap) ; - strcat(buffer,";g") ; - c2pstr(buffer) ; - DebugStr((unsigned char*) buffer) ; - - va_end(ap); + va_list ap; + static char buffer[512]; + + if (!wxTheApp->GetWantDebugOutput()) + return ; + + va_start(ap, fmt); + + vsprintf(buffer,fmt,ap) ; + strcat(buffer,";g") ; + c2pstr(buffer) ; + DebugStr((unsigned char*) buffer) ; + + va_end(ap); } // Non-fatal error: pop up message box and (possibly) continue void wxError(const wxString& msg, const wxString& title) { - if (wxMessageBox(wxString::Format(wxT("%s\nContinue?"),msg), title, wxYES_NO) == wxID_NO ) - wxExit(); + if (wxMessageBox(wxString::Format(wxT("%s\nContinue?"),msg), title, wxYES_NO) == wxID_NO ) + wxExit(); } // Fatal error: pop up message box and abort void wxFatalError(const wxString& msg, const wxString& title) { - wxMessageBox(wxString::Format(wxT("%s: %s"),title,msg)); - wxExit(); + wxMessageBox(wxString::Format(wxT("%s: %s"),title,msg)); + wxExit(); } #endif // WXWIN_COMPATIBILITY_2_2 @@ -225,13 +225,13 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn) long theSystem ; // are there x-platform conventions ? - + Gestalt(gestaltSystemVersion, &theSystem) ; if (minorVsn != NULL) { - *minorVsn = (theSystem & 0xFF ) ; + *minorVsn = (theSystem & 0xFF ) ; } if (majorVsn != NULL) { - *majorVsn = (theSystem >> 8 ) ; + *majorVsn = (theSystem >> 8 ) ; } #ifdef __DARWIN__ return wxMAC_DARWIN; @@ -250,23 +250,23 @@ bool wxWriteResource(const wxString& section, const wxString& entry, const wxStr bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) { - char buf[50]; - sprintf(buf, "%.4f", value); - return wxWriteResource(section, entry, buf, file); + char buf[50]; + sprintf(buf, "%.4f", value); + return wxWriteResource(section, entry, buf, file); } bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) { - char buf[50]; - sprintf(buf, "%ld", value); - return wxWriteResource(section, entry, buf, file); + char buf[50]; + sprintf(buf, "%ld", value); + return wxWriteResource(section, entry, buf, file); } bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file) { - char buf[50]; - sprintf(buf, "%d", value); - return wxWriteResource(section, entry, buf, file); + char buf[50]; + sprintf(buf, "%d", value); + return wxWriteResource(section, entry, buf, file); } bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file) @@ -277,81 +277,81 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file) { - char *s = NULL; - bool succ = wxGetResource(section, entry, (char **)&s, file); - if (succ) - { - *value = (float)strtod(s, NULL); - delete[] s; - return TRUE; - } - else return FALSE; + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = (float)strtod(s, NULL); + delete[] s; + return TRUE; + } + else return FALSE; } bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file) { - char *s = NULL; - bool succ = wxGetResource(section, entry, (char **)&s, file); - if (succ) - { - *value = strtol(s, NULL, 10); - delete[] s; - return TRUE; - } - else return FALSE; + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = strtol(s, NULL, 10); + delete[] s; + return TRUE; + } + else return FALSE; } bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file) { - char *s = NULL; - bool succ = wxGetResource(section, entry, (char **)&s, file); - if (succ) - { - *value = (int)strtol(s, NULL, 10); - delete[] s; - return TRUE; - } - else return FALSE; + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = (int)strtol(s, NULL, 10); + delete[] s; + return TRUE; + } + else return FALSE; } #endif // wxUSE_RESOURCES int gs_wxBusyCursorCount = 0; -extern wxCursor gMacCurrentCursor ; -wxCursor gMacStoredActiveCursor ; +extern wxCursor gMacCurrentCursor ; +wxCursor gMacStoredActiveCursor ; // Set the cursor to the busy cursor for all windows void wxBeginBusyCursor(wxCursor *cursor) { - if (gs_wxBusyCursorCount++ == 0) - { - gMacStoredActiveCursor = gMacCurrentCursor ; - cursor->MacInstall() ; - } - //else: nothing to do, already set + if (gs_wxBusyCursorCount++ == 0) + { + gMacStoredActiveCursor = gMacCurrentCursor ; + cursor->MacInstall() ; + } + //else: nothing to do, already set } // Restore cursor to normal void wxEndBusyCursor() { wxCHECK_RET( gs_wxBusyCursorCount > 0, - wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") ); - - if (--gs_wxBusyCursorCount == 0) - { - gMacStoredActiveCursor.MacInstall() ; - gMacStoredActiveCursor = wxNullCursor ; - } + wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") ); + + if (--gs_wxBusyCursorCount == 0) + { + gMacStoredActiveCursor.MacInstall() ; + gMacStoredActiveCursor = wxNullCursor ; + } } // TRUE if we're between the above two calls bool wxIsBusy() { - return (gs_wxBusyCursorCount > 0); + return (gs_wxBusyCursorCount > 0); } wxString wxMacFindFolder( short vol, - OSType folderType, - Boolean createFolder) + OSType folderType, + Boolean createFolder) { short vRefNum ; long dirID ; @@ -437,24 +437,24 @@ bool wxColourDisplay() // Returns depth of screen int wxDisplayDepth() { - Rect globRect ; - SetRect(&globRect, -32760, -32760, 32760, 32760); - GDHandle theMaxDevice; + Rect globRect ; + SetRect(&globRect, -32760, -32760, 32760, 32760); + GDHandle theMaxDevice; - int theDepth = 8; - theMaxDevice = GetMaxDevice(&globRect); - if (theMaxDevice != nil) - theDepth = (**(**theMaxDevice).gdPMap).pixelSize; + int theDepth = 8; + theMaxDevice = GetMaxDevice(&globRect); + if (theMaxDevice != nil) + theDepth = (**(**theMaxDevice).gdPMap).pixelSize; - return theDepth ; + return theDepth ; } // Get size of display void wxDisplaySize(int *width, int *height) { - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); - + BitMap screenBits; + GetQDGlobalsScreenBits( &screenBits ); + *width = screenBits.bounds.right - screenBits.bounds.left ; *height = screenBits.bounds.bottom - screenBits.bounds.top ; } @@ -595,29 +595,29 @@ void wxMacConvertToPC( const char *from , char *to , int len ) wxString wxMacMakeMacStringFromPC( const char * p ) { - wxString result ; + wxString result ; int len = strlen ( p ) ; - if ( len > 0 ) - { - wxChar* ptr = result.GetWriteBuf(len) ; - wxMacConvertFromPC( p , ptr , len ) ; - ptr[len] = 0 ; - result.UngetWriteBuf( len ) ; - } + if ( len > 0 ) + { + wxChar* ptr = result.GetWriteBuf(len) ; + wxMacConvertFromPC( p , ptr , len ) ; + ptr[len] = 0 ; + result.UngetWriteBuf( len ) ; + } return result ; } wxString wxMacMakePCStringFromMac( const char * p ) { - wxString result ; + wxString result ; int len = strlen ( p ) ; - if ( len > 0 ) - { - wxChar* ptr = result.GetWriteBuf(len) ; - wxMacConvertToPC( p , ptr , len ) ; - ptr[len] = 0 ; - result.UngetWriteBuf( len ) ; - } + if ( len > 0 ) + { + wxChar* ptr = result.GetWriteBuf(len) ; + wxMacConvertToPC( p , ptr , len ) ; + ptr[len] = 0 ; + result.UngetWriteBuf( len ) ; + } return result ; } @@ -639,9 +639,9 @@ wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) { - // this is safe since a pascal string can never be larger than 256 bytes - char s[256] ; - CopyPascalStringToC( from , s ) ; + // this is safe since a pascal string can never be larger than 256 bytes + char s[256] ; + CopyPascalStringToC( from , s ) ; if (mac2pcEncoding) { return wxMacMakePCStringFromMac( s ) ; @@ -672,9 +672,9 @@ void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding // converts this string into a carbon foundation string with optional pc 2 mac encoding CFStringRef wxMacCreateCFString( const wxString &str , bool pc2macEncoding ) { - return CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , - pc2macEncoding ? - kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; + return CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , + pc2macEncoding ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; } #endif //TARGET_CARBON diff --git a/src/mac/carbon/utilsexc.cpp b/src/mac/carbon/utilsexc.cpp index a9e84f42ed..229ad654f7 100644 --- a/src/mac/carbon/utilsexc.cpp +++ b/src/mac/carbon/utilsexc.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/carbon/wave.cpp b/src/mac/carbon/wave.cpp index c325db04c6..0c5aac8bfc 100644 --- a/src/mac/carbon/wave.cpp +++ b/src/mac/carbon/wave.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -51,128 +51,128 @@ wxWave::wxWave(int size, const wxByte* data) bool wxWave::Create(const wxString& fileName, bool isResource) { - bool ret = false; - m_sndname = fileName; - m_isResource = isResource; - - if (m_isResource) - ret = true; - else - { /* - if (sndChan) - { // we're playing - FSClose(SndRefNum); - SndRefNum = 0; - SndDisposeChannel(sndChan, TRUE); - free(sndChan); - sndChan = 0; - KillTimer(0,timerID); - } - - if (!lpSnd) - return true; - - if (_access(lpSnd,0)) // no file, no service - return false; - - // Allocate SndChannel - sndChan = (SndChannelPtr) malloc (sizeof(SndChannel)); - - if (!sndChan) - return false; - - sndChan->qLength = 128; - - if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0)) - { - free(sndChan); - sndChan = 0; - return false; - } - - if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd))) - { - SndDisposeChannel(sndChan, TRUE); - free(sndChan); - sndChan = 0; - - return false; - } - - bool async = false; - - if (fdwSound & SND_ASYNC) - async = true; - - if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr) - { - FSClose (SndRefNum); - SndRefNum = 0; - SndDisposeChannel (sndChan, TRUE); - free (sndChan); - sndChan = 0; - return false; - } - - if (async) - { // haven't finish yet - timerID = SetTimer(0, 0, 250, TimerCallBack); - } - else - { - FSClose (SndRefNum); - SndRefNum = 0; - SndDisposeChannel (sndChan, TRUE); - free (sndChan); - sndChan = 0; - }*/ - } - - return ret; + bool ret = false; + m_sndname = fileName; + m_isResource = isResource; + + if (m_isResource) + ret = true; + else + { /* + if (sndChan) + { // we're playing + FSClose(SndRefNum); + SndRefNum = 0; + SndDisposeChannel(sndChan, TRUE); + free(sndChan); + sndChan = 0; + KillTimer(0,timerID); + } + + if (!lpSnd) + return true; + + if (_access(lpSnd,0)) // no file, no service + return false; + + // Allocate SndChannel + sndChan = (SndChannelPtr) malloc (sizeof(SndChannel)); + + if (!sndChan) + return false; + + sndChan->qLength = 128; + + if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0)) + { + free(sndChan); + sndChan = 0; + return false; + } + + if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd))) + { + SndDisposeChannel(sndChan, TRUE); + free(sndChan); + sndChan = 0; + + return false; + } + + bool async = false; + + if (fdwSound & SND_ASYNC) + async = true; + + if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr) + { + FSClose (SndRefNum); + SndRefNum = 0; + SndDisposeChannel (sndChan, TRUE); + free (sndChan); + sndChan = 0; + return false; + } + + if (async) + { // haven't finish yet + timerID = SetTimer(0, 0, 250, TimerCallBack); + } + else + { + FSClose (SndRefNum); + SndRefNum = 0; + SndDisposeChannel (sndChan, TRUE); + free (sndChan); + sndChan = 0; + }*/ + } + + return ret; } //don't know what to do with looped, wth bool wxWave::Play(bool async, bool looped) const { - char lpSnd[32]; - bool ret = false; + char lpSnd[32]; + bool ret = false; - if (m_isResource) - { + if (m_isResource) + { #if TARGET_CARBON - c2pstrcpy((unsigned char *)lpSnd, m_sndname); + c2pstrcpy((unsigned char *)lpSnd, m_sndname); #else - strcpy(lpSnd, m_sndname); - c2pstr((char *) lpSnd); + strcpy(lpSnd, m_sndname); + c2pstr((char *) lpSnd); #endif - SndListHandle hSnd; + SndListHandle hSnd; - hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); + hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); - if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) - ret = true; - } + if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) + ret = true; + } - return ret; + return ret; } bool wxWave::FreeData() { - bool ret = false; - - if (m_isResource) - { - m_sndname.Empty(); - ret = true; - } - else - { - //TODO, - } - - return ret; + bool ret = false; + + if (m_isResource) + { + m_sndname.Empty(); + ret = true; + } + else + { + //TODO, + } + + return ret; } @@ -182,66 +182,66 @@ bool wxWave::FreeData() /*static short MacOpenSndFile (char * path) { - VolumeParam vp; - FSSpec fspec; - Str255 name; - char *c; - - // first, get the volume reference number for the file. Start by - // making a Pstring with just the volume name - strcpy ((char *) name, path); - if (c = strchr ((char *) name, ':')) - { - c++; - *c = '\0'; - } - - c2pstr ((char *) name); - vp.ioCompletion = 0; - vp.ioVolIndex = -1; - vp.ioNamePtr = name; - vp.ioVRefNum = 0; - - if (PBGetVInfo((ParamBlockRec *)&vp, 0) != noErr) - return 0; - - // next, buld an FSSpec for the file - strcpy ((char *) name, path); - c2pstr ((char *) name); - if (FSMakeFSSpec (vp.ioVRefNum, 0, name, &fspec) != noErr) - return 0; - - short frefnum; - // now open the file, and return it's reference number - if (FSpOpenDF(&fspec, fsRdPerm, &frefnum) != noErr) - return 0; - - return frefnum; + VolumeParam vp; + FSSpec fspec; + Str255 name; + char *c; + + // first, get the volume reference number for the file. Start by + // making a Pstring with just the volume name + strcpy ((char *) name, path); + if (c = strchr ((char *) name, ':')) + { + c++; + *c = '\0'; + } + + c2pstr ((char *) name); + vp.ioCompletion = 0; + vp.ioVolIndex = -1; + vp.ioNamePtr = name; + vp.ioVRefNum = 0; + + if (PBGetVInfo((ParamBlockRec *)&vp, 0) != noErr) + return 0; + + // next, buld an FSSpec for the file + strcpy ((char *) name, path); + c2pstr ((char *) name); + if (FSMakeFSSpec (vp.ioVRefNum, 0, name, &fspec) != noErr) + return 0; + + short frefnum; + // now open the file, and return it's reference number + if (FSpOpenDF(&fspec, fsRdPerm, &frefnum) != noErr) + return 0; + + return frefnum; } void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime) { - if(!sndChan) - { - KillTimer(0,timerID); - return; - } - - SCStatus scstat; - - if (noErr == SndChannelStatus (sndChan, sizeof (SCStatus), &scstat)) { - if (scstat.scChannelPaused || scstat.scChannelBusy) - return; // not done yet - } - - // either error or done. - FSClose (SndRefNum); - SndRefNum = 0; - SndDisposeChannel (sndChan, TRUE); - free (sndChan); - sndChan = 0; - KillTimer(0,timerID); + if(!sndChan) + { + KillTimer(0,timerID); + return; + } + + SCStatus scstat; + + if (noErr == SndChannelStatus (sndChan, sizeof (SCStatus), &scstat)) { + if (scstat.scChannelPaused || scstat.scChannelBusy) + return; // not done yet + } + + // either error or done. + FSClose (SndRefNum); + SndRefNum = 0; + SndDisposeChannel (sndChan, TRUE); + free (sndChan); + sndChan = 0; + KillTimer(0,timerID); }*/ diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 9eded8e45a..4592280816 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -175,8 +175,8 @@ wxWindowMac::~wxWindowMac() wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ; if ( frame ) { - if ( frame->GetLastFocus() == this ) - frame->SetLastFocus( NULL ) ; + if ( frame->GetLastFocus() == this ) + frame->SetLastFocus( NULL ) ; } if ( gFocusWindow == this ) @@ -323,15 +323,15 @@ void wxWindowMac::DoReleaseMouse() void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget) { - if ( m_dropTarget != 0 ) { - delete m_dropTarget; - } - - m_dropTarget = pDropTarget; - if ( m_dropTarget != 0 ) - { - // TODO - } + if ( m_dropTarget != 0 ) { + delete m_dropTarget; + } + + m_dropTarget = pDropTarget; + if ( m_dropTarget != 0 ) + { + // TODO + } } #endif @@ -409,12 +409,12 @@ void wxWindowMac::DoScreenToClient(int *x, int *y) const if(x) *x = localwhere.h ; if(y) *y = localwhere.v ; - + MacRootWindowToWindow( x , y ) ; if ( x ) - *x -= MacGetLeftBorderSize() ; + *x -= MacGetLeftBorderSize() ; if ( y ) - *y -= MacGetTopBorderSize() ; + *y -= MacGetTopBorderSize() ; } void wxWindowMac::DoClientToScreen(int *x, int *y) const @@ -422,9 +422,9 @@ void wxWindowMac::DoClientToScreen(int *x, int *y) const WindowRef window = (WindowRef) MacGetRootWindow() ; if ( x ) - *x += MacGetLeftBorderSize() ; + *x += MacGetLeftBorderSize() ; if ( y ) - *y += MacGetTopBorderSize() ; + *y += MacGetTopBorderSize() ; MacWindowToRootWindow( x , y ) ; @@ -482,37 +482,37 @@ void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const bool wxWindowMac::SetCursor(const wxCursor& cursor) { if (m_cursor == cursor) - return FALSE; - + return FALSE; + if (wxNullCursor == cursor) { - if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) ) - return FALSE ; + if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) ) + return FALSE ; } else { - if ( ! wxWindowBase::SetCursor( cursor ) ) - return FALSE ; - } - - wxASSERT_MSG( m_cursor.Ok(), - wxT("cursor must be valid after call to the base version")); - - Point pt ; - wxWindowMac *mouseWin ; - GetMouse( &pt ) ; - - // Change the cursor NOW if we're within the correct window - - if ( MacGetWindowFromPoint( wxPoint( pt.h , pt.v ) , &mouseWin ) ) - { - if ( mouseWin == this && !wxIsBusy() ) - { - m_cursor.MacInstall() ; + if ( ! wxWindowBase::SetCursor( cursor ) ) + return FALSE ; + } + + wxASSERT_MSG( m_cursor.Ok(), + wxT("cursor must be valid after call to the base version")); + + Point pt ; + wxWindowMac *mouseWin ; + GetMouse( &pt ) ; + + // Change the cursor NOW if we're within the correct window + + if ( MacGetWindowFromPoint( wxPoint( pt.h , pt.v ) , &mouseWin ) ) + { + if ( mouseWin == this && !wxIsBusy() ) + { + m_cursor.MacInstall() ; + } } - } - - return TRUE ; + + return TRUE ; } @@ -522,54 +522,54 @@ void wxWindowMac::DoGetClientSize(int *x, int *y) const int ww, hh; ww = m_width ; hh = m_height ; - + ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ; hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ); - - if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) ) - { - int x1 = 0 ; - int y1 = 0 ; - int w = m_width ; - int h = m_height ; - - MacClientToRootWindow( &x1 , &y1 ) ; - MacClientToRootWindow( &w , &h ) ; - - wxWindowMac *iter = (wxWindowMac*)this ; - - int totW = 10000 , totH = 10000; - while( iter ) - { - if ( iter->IsTopLevel() ) + + if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) ) + { + int x1 = 0 ; + int y1 = 0 ; + int w = m_width ; + int h = m_height ; + + MacClientToRootWindow( &x1 , &y1 ) ; + MacClientToRootWindow( &w , &h ) ; + + wxWindowMac *iter = (wxWindowMac*)this ; + + int totW = 10000 , totH = 10000; + while( iter ) { - totW = iter->m_width ; - totH = iter->m_height ; - break ; + if ( iter->IsTopLevel() ) + { + totW = iter->m_width ; + totH = iter->m_height ; + break ; + } + + iter = iter->GetParent() ; } - - iter = iter->GetParent() ; - } - - if (m_hScrollBar && m_hScrollBar->IsShown() ) - { - hh -= MAC_SCROLLBAR_SIZE; - if ( h-y1 >= totH ) + + if (m_hScrollBar && m_hScrollBar->IsShown() ) { - hh += 1 ; + hh -= MAC_SCROLLBAR_SIZE; + if ( h-y1 >= totH ) + { + hh += 1 ; + } } - } - if (m_vScrollBar && m_vScrollBar->IsShown() ) - { - ww -= MAC_SCROLLBAR_SIZE; - if ( w-x1 >= totW ) + if (m_vScrollBar && m_vScrollBar->IsShown() ) { - ww += 1 ; + ww -= MAC_SCROLLBAR_SIZE; + if ( w-x1 >= totW ) + { + ww += 1 ; + } } } - } - if(x) *x = ww; - if(y) *y = hh; + if(x) *x = ww; + if(y) *y = hh; } @@ -582,7 +582,7 @@ void wxWindowMac::DoGetClientSize(int *x, int *y) const void wxWindowMac::DoSetToolTip(wxToolTip *tooltip) { wxWindowBase::DoSetToolTip(tooltip); - + if ( m_tooltip ) m_tooltip->SetWindow(this); } @@ -595,12 +595,12 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) int former_y = m_y ; int former_w = m_width ; int former_h = m_height ; - - int actualWidth = width; - int actualHeight = height; - int actualX = x; - int actualY = y; - + + int actualWidth = width; + int actualHeight = height; + int actualX = x; + int actualY = y; + if ((m_minWidth != -1) && (actualWidth < m_minWidth)) actualWidth = m_minWidth; if ((m_minHeight != -1) && (actualHeight < m_minHeight)) @@ -609,10 +609,10 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) actualWidth = m_maxWidth; if ((m_maxHeight != -1) && (actualHeight > m_maxHeight)) actualHeight = m_maxHeight; - + bool doMove = false ; bool doResize = false ; - + if ( actualX != former_x || actualY != former_y ) { doMove = true ; @@ -621,13 +621,13 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) { doResize = true ; } - + if ( doMove || doResize ) { // erase former position - + bool partialRepaint = false ; - + if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) ) { wxPoint oldPos( m_x , m_y ) ; @@ -652,25 +652,25 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) DisposeRgn(diffRgn) ; } } - + if ( !partialRepaint ) Refresh() ; - + m_x = actualX ; m_y = actualY ; m_width = actualWidth ; m_height = actualHeight ; - - // update any low-level frame-relative positions - - MacUpdateDimensions() ; + + // update any low-level frame-relative positions + + MacUpdateDimensions() ; // erase new position - + if ( !partialRepaint ) Refresh() ; if ( doMove ) wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified - + MacRepositionScrollBars() ; if ( doMove ) { @@ -681,14 +681,14 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) } if ( doResize ) { - MacRepositionScrollBars() ; - wxSize size(m_width, m_height); - wxSizeEvent event(size, m_windowId); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + MacRepositionScrollBars() ; + wxSize size(m_width, m_height); + wxSizeEvent event(size, m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); } } - + } // set the size of the window: if the dimensions are positive, just use them, @@ -704,25 +704,25 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) // get the current size and position... int currentX, currentY; GetPosition(¤tX, ¤tY); - + int currentW,currentH; GetSize(¤tW, ¤tH); - + // ... and don't do anything (avoiding flicker) if it's already ok if ( x == currentX && y == currentY && - width == currentW && height == currentH ) + width == currentW && height == currentH ) { MacRepositionScrollBars() ; // we might have a real position shift return; } - + if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) x = currentX; if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) y = currentY; - + AdjustForParentClientOrigin(x, y, sizeFlags); - + wxSize size(-1, -1); if ( width == -1 ) { @@ -737,7 +737,7 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) width = currentW; } } - + if ( height == -1 ) { if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) @@ -747,7 +747,7 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) size = DoGetBestSize(); } //else: already called DoGetBestSize() above - + height = size.y; } else @@ -756,9 +756,9 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) height = currentH; } } - + DoMoveWindow(x, y, width, height); - + } // For implementation purposes - sometimes decorations make the client area // smaller @@ -980,7 +980,7 @@ wxWindowMac *wxGetActiveWindow() // Coordinates relative to the window void wxWindowMac::WarpPointer (int x_pos, int y_pos) { - // We really dont move the mouse programmatically under mac + // We really don't move the mouse programmatically under Mac. } const wxBrush& wxWindowMac::MacGetBackgroundBrush() @@ -994,58 +994,57 @@ const wxBrush& wxWindowMac::MacGetBackgroundBrush() // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have // either a non gray background color or a non control window - - WindowRef window = (WindowRef) MacGetRootWindow() ; - - wxWindowMac* parent = GetParent() ; - while( parent ) + + WindowRef window = (WindowRef) MacGetRootWindow() ; + + wxWindowMac* parent = GetParent() ; + while( parent ) + { + if ( parent->MacGetRootWindow() != window ) + { + // we are in a different window on the mac system + parent = NULL ; + break ; + } + { - if ( parent->MacGetRootWindow() != window ) + if ( parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) + && parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) { - // we are in a different window on the mac system - parent = NULL ; + // if we have any other colours in the hierarchy + m_macBackgroundBrush.SetColour( parent->m_backgroundColour ) ; break ; } - + // if we have the normal colours in the hierarchy but another control etc. -> use it's background + if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) { - if ( parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) - && parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) - { - // if we have any other colours in the hierarchy - m_macBackgroundBrush.SetColour( parent->m_backgroundColour ) ; - break ; - } - // if we have the normal colours in the hierarchy but another control etc. -> use it's background - if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) - { - Rect extent = { 0 , 0 , 0 , 0 } ; - int x , y ; - x = y = 0 ; - wxSize size = parent->GetSize() ; - parent->MacClientToRootWindow( &x , &y ) ; - extent.left = x ; - extent.top = y ; - extent.top-- ; - extent.right = x + size.x ; - extent.bottom = y + size.y ; - m_macBackgroundBrush.SetMacThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ; // todo eventually change for inactive - break ; - } + Rect extent = { 0 , 0 , 0 , 0 } ; + int x , y ; + x = y = 0 ; + wxSize size = parent->GetSize() ; + parent->MacClientToRootWindow( &x , &y ) ; + extent.left = x ; + extent.top = y ; + extent.top-- ; + extent.right = x + size.x ; + extent.bottom = y + size.y ; + m_macBackgroundBrush.SetMacThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ; // todo eventually change for inactive + break ; } - parent = parent->GetParent() ; - } - if ( !parent ) - { - m_macBackgroundBrush.SetMacTheme( kThemeBrushDialogBackgroundActive ) ; // todo eventually change for inactive } + parent = parent->GetParent() ; + } + if ( !parent ) + { + m_macBackgroundBrush.SetMacTheme( kThemeBrushDialogBackgroundActive ) ; // todo eventually change for inactive + } } else { m_macBackgroundBrush.SetColour( m_backgroundColour ) ; } - - return m_macBackgroundBrush ; - + + return m_macBackgroundBrush ; } void wxWindowMac::OnEraseBackground(wxEraseEvent& event) @@ -1199,41 +1198,41 @@ void wxWindowMac::RemoveChild( wxWindowBase *child ) void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible, int range, bool refresh) { - if ( orient == wxHORIZONTAL ) + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) { - if ( m_hScrollBar ) + if ( range == 0 || thumbVisible >= range ) { - if ( range == 0 || thumbVisible >= range ) - { - if ( m_hScrollBar->IsShown() ) - m_hScrollBar->Show(false) ; - } - else - { - if ( !m_hScrollBar->IsShown() ) - m_hScrollBar->Show(true) ; - m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; - } + if ( m_hScrollBar->IsShown() ) + m_hScrollBar->Show(false) ; + } + else + { + if ( !m_hScrollBar->IsShown() ) + m_hScrollBar->Show(true) ; + m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; } } - else + } + else + { + if ( m_vScrollBar ) { - if ( m_vScrollBar ) + if ( range == 0 || thumbVisible >= range ) { - if ( range == 0 || thumbVisible >= range ) - { - if ( m_vScrollBar->IsShown() ) - m_vScrollBar->Show(false) ; - } - else - { - if ( !m_vScrollBar->IsShown() ) - m_vScrollBar->Show(true) ; - m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; - } + if ( m_vScrollBar->IsShown() ) + m_vScrollBar->Show(false) ; + } + else + { + if ( !m_vScrollBar->IsShown() ) + m_vScrollBar->Show(true) ; + m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; } } - MacRepositionScrollBars() ; + } + MacRepositionScrollBars() ; } // Does a physical scroll @@ -1241,39 +1240,39 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) { wxClientDC dc(this) ; wxMacPortSetter helper(&dc) ; - + { int width , height ; GetClientSize( &width , &height ) ; - + Rect scrollrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) , dc.YLOG2DEVMAC(height) , dc.XLOG2DEVMAC(width) } ; RgnHandle updateRgn = NewRgn() ; ClipRect( &scrollrect ) ; if ( rect ) { Rect r = { dc.YLOG2DEVMAC(rect->y) , dc.XLOG2DEVMAC(rect->x) , dc.YLOG2DEVMAC(rect->y + rect->height) , - dc.XLOG2DEVMAC(rect->x + rect->width) } ; + dc.XLOG2DEVMAC(rect->x + rect->width) } ; SectRect( &scrollrect , &r , &scrollrect ) ; } ScrollRect( &scrollrect , dx , dy , updateRgn ) ; InvalWindowRgn( (WindowRef) MacGetRootWindow() , updateRgn ) ; DisposeRgn( updateRgn ) ; } - + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { wxWindowMac *child = (wxWindowMac*)node->GetData(); if (child == m_vScrollBar) continue; if (child == m_hScrollBar) continue; if (child->IsTopLevel()) continue; - + int x,y; child->GetPosition( &x, &y ); int w,h; child->GetSize( &w, &h ); child->SetSize( x+dx, y+dy, w, h ); } - + } void wxWindowMac::MacOnScroll(wxScrollEvent &event ) @@ -1284,30 +1283,30 @@ void wxWindowMac::MacOnScroll(wxScrollEvent &event ) wevent.SetPosition(event.GetPosition()); wevent.SetOrientation(event.GetOrientation()); wevent.m_eventObject = this; - + if (event.m_eventType == wxEVT_SCROLL_TOP) { wevent.m_eventType = wxEVT_SCROLLWIN_TOP; } else - if (event.m_eventType == wxEVT_SCROLL_BOTTOM) { - wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM; - } else - if (event.m_eventType == wxEVT_SCROLL_LINEUP) { - wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP; - } else - if (event.m_eventType == wxEVT_SCROLL_LINEDOWN) { - wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; - } else - if (event.m_eventType == wxEVT_SCROLL_PAGEUP) { - wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; - } else - if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN) { - wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; - } else - if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK) { - wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; - } - - GetEventHandler()->ProcessEvent(wevent); + if (event.m_eventType == wxEVT_SCROLL_BOTTOM) { + wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM; + } else + if (event.m_eventType == wxEVT_SCROLL_LINEUP) { + wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP; + } else + if (event.m_eventType == wxEVT_SCROLL_LINEDOWN) { + wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; + } else + if (event.m_eventType == wxEVT_SCROLL_PAGEUP) { + wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; + } else + if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN) { + wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; + } else + if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK) { + wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; + } + + GetEventHandler()->ProcessEvent(wevent); } } @@ -1356,7 +1355,7 @@ void wxWindowMac::OnSetFocus(wxFocusEvent& event) // notice that it's also important to do it upwards the tree becaus // otherwise when the top level panel gets focus, it won't set it back to // us, but to some other sibling - + // CS:don't know if this is still needed: //wxChildFocusEvent eventFocus(this); //(void)GetEventHandler()->ProcessEvent(eventFocus); @@ -1435,27 +1434,27 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** { if ( IsTopLevel() ) { - if ((point.x < 0) || (point.y < 0) || - (point.x > (m_width)) || (point.y > (m_height))) - return FALSE; + if ((point.x < 0) || (point.y < 0) || + (point.x > (m_width)) || (point.y > (m_height))) + return FALSE; } else { - if ((point.x < m_x) || (point.y < m_y) || - (point.x > (m_x + m_width)) || (point.y > (m_y + m_height))) - return FALSE; + if ((point.x < m_x) || (point.y < m_y) || + (point.x > (m_x + m_width)) || (point.y > (m_y + m_height))) + return FALSE; } - + WindowRef window = (WindowRef) MacGetRootWindow() ; - + wxPoint newPoint( point ) ; - + if ( !IsTopLevel() ) { - newPoint.x -= m_x; - newPoint.y -= m_y; + newPoint.x -= m_x; + newPoint.y -= m_y; } - + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { wxWindowMac *child = (wxWindowMac*)node->GetData(); @@ -1466,7 +1465,7 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** return TRUE; } } - + *outWin = this ; return TRUE; } @@ -1474,25 +1473,25 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMac** outWin ) { WindowRef window ; - + Point pt = { screenpoint.y , screenpoint.x } ; if ( ::FindWindow( pt , &window ) == 3 ) { - + wxWindowMac* win = wxFindWinFromMacWindow( window ) ; if ( win ) { // No, this yields the CLIENT are, we need the whole frame. RR. // point = win->ScreenToClient( point ) ; - + GrafPtr port; ::GetPort( &port ) ; ::SetPort( UMAGetWindowPort( window ) ) ; ::GlobalToLocal( &pt ) ; ::SetPort( port ) ; - + wxPoint point( pt.h, pt.v ) ; - + return win->MacGetWindowFromPointSub( point , outWin ) ; } } @@ -1504,22 +1503,22 @@ static wxWindow *gs_lastWhich = NULL; bool wxWindowMac::MacSetupCursor( const wxPoint& pt) { // first trigger a set cursor event - + wxPoint clientorigin = GetClientAreaOrigin() ; wxSize clientsize = GetClientSize() ; wxCursor cursor ; if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) { wxSetCursorEvent event( pt.x , pt.y ); - + bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); if ( processedEvtSetCursor && event.HasCursor() ) { - cursor = event.GetCursor() ; + cursor = event.GetCursor() ; } else { - + // the test for processedEvtSetCursor is here to prevent using m_cursor // if the user code caught EVT_SET_CURSOR() and returned nothing from // it - this is a way to say that our cursor shouldn't be used for this @@ -1548,19 +1547,19 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) if ((event.m_x < m_x) || (event.m_y < m_y) || (event.m_x > (m_x + m_width)) || (event.m_y > (m_y + m_height))) return FALSE; - - + + if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) /* || IsKindOf( CLASSINFO( wxSpinCtrl ) ) */) return FALSE ; - + WindowRef window = (WindowRef) MacGetRootWindow() ; - + event.m_x -= m_x; event.m_y -= m_y; - + int x = event.m_x ; int y = event.m_y ; - + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { wxWindowMac *child = (wxWindowMac*)node->GetData(); @@ -1570,10 +1569,10 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) return TRUE; } } - + wxWindow* cursorTarget = this ; wxPoint cursorPoint( x , y ) ; - + while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) ) { cursorTarget = cursorTarget->GetParent() ; @@ -1583,40 +1582,40 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) event.m_x = x ; event.m_y = y ; event.SetEventObject( this ) ; - + if ( event.GetEventType() == wxEVT_LEFT_DOWN ) { // set focus to this window if (AcceptsFocus() && FindFocus()!=this) SetFocus(); } - + #if wxUSE_TOOLTIPS if ( event.GetEventType() == wxEVT_MOTION - || event.GetEventType() == wxEVT_ENTER_WINDOW - || event.GetEventType() == wxEVT_LEAVE_WINDOW ) + || event.GetEventType() == wxEVT_ENTER_WINDOW + || event.GetEventType() == wxEVT_LEAVE_WINDOW ) wxToolTip::RelayEvent( this , event); #endif // wxUSE_TOOLTIPS - + if (gs_lastWhich != this) { gs_lastWhich = this; - + // Double clicks must always occur on the same window if (event.GetEventType() == wxEVT_LEFT_DCLICK) event.SetEventType( wxEVT_LEFT_DOWN ); if (event.GetEventType() == wxEVT_RIGHT_DCLICK) event.SetEventType( wxEVT_RIGHT_DOWN ); - + // Same for mouse up events if (event.GetEventType() == wxEVT_LEFT_UP) return TRUE; if (event.GetEventType() == wxEVT_RIGHT_UP) return TRUE; } - + GetEventHandler()->ProcessEvent( event ) ; - + return TRUE; } @@ -1657,105 +1656,105 @@ wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSiblings ) { - RgnHandle visRgn = NewRgn() ; - RgnHandle tempRgn = NewRgn() ; - RgnHandle tempStaticBoxRgn = NewRgn() ; - - SetRectRgn( visRgn , 0 , 0 , m_width , m_height ) ; - - //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox - if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) - { - int borderTop = 14 ; - int borderOther = 4 ; - - SetRectRgn( tempStaticBoxRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ; - DiffRgn( visRgn , tempStaticBoxRgn , visRgn ) ; - } - - if ( !IsTopLevel() ) - { - wxWindow* parent = GetParent() ; - while( parent ) - { - wxSize size = parent->GetSize() ; - int x , y ; - x = y = 0 ; - parent->MacWindowToRootWindow( &x, &y ) ; - MacRootWindowToWindow( &x , &y ) ; - - SetRectRgn( tempRgn , - x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , - x + size.x - parent->MacGetRightBorderSize(), - y + size.y - parent->MacGetBottomBorderSize()) ; - - SectRgn( visRgn , tempRgn , visRgn ) ; - if ( parent->IsTopLevel() ) - break ; - parent = parent->GetParent() ; - } - } - if ( respectChildrenAndSiblings ) - { - if ( GetWindowStyle() & wxCLIP_CHILDREN ) - { - for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) + RgnHandle visRgn = NewRgn() ; + RgnHandle tempRgn = NewRgn() ; + RgnHandle tempStaticBoxRgn = NewRgn() ; + + SetRectRgn( visRgn , 0 , 0 , m_width , m_height ) ; + + //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox + if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) + { + int borderTop = 14 ; + int borderOther = 4 ; + + SetRectRgn( tempStaticBoxRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ; + DiffRgn( visRgn , tempStaticBoxRgn , visRgn ) ; + } + + if ( !IsTopLevel() ) + { + wxWindow* parent = GetParent() ; + while( parent ) { - wxWindowMac *child = (wxWindowMac*)node->GetData(); - - if ( !child->IsTopLevel() && child->IsShown() ) + wxSize size = parent->GetSize() ; + int x , y ; + x = y = 0 ; + parent->MacWindowToRootWindow( &x, &y ) ; + MacRootWindowToWindow( &x , &y ) ; + + SetRectRgn( tempRgn , + x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , + x + size.x - parent->MacGetRightBorderSize(), + y + size.y - parent->MacGetBottomBorderSize()) ; + + SectRgn( visRgn , tempRgn , visRgn ) ; + if ( parent->IsTopLevel() ) + break ; + parent = parent->GetParent() ; + } + } + if ( respectChildrenAndSiblings ) + { + if ( GetWindowStyle() & wxCLIP_CHILDREN ) + { + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; - if ( child->IsKindOf( CLASSINFO( wxStaticBox ) ) ) + wxWindowMac *child = (wxWindowMac*)node->GetData(); + + if ( !child->IsTopLevel() && child->IsShown() ) { - int borderTop = 14 ; - int borderOther = 4 ; - - SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ; - DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; + SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; + if ( child->IsKindOf( CLASSINFO( wxStaticBox ) ) ) + { + int borderTop = 14 ; + int borderOther = 4 ; + + SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ; + DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; + } + DiffRgn( visRgn , tempRgn , visRgn ) ; } - DiffRgn( visRgn , tempRgn , visRgn ) ; } } - } - - if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) - { - bool thisWindowThrough = false ; - for (wxWindowListNode *node = GetParent()->GetChildren().GetFirst(); node; node = node->GetNext()) + + if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) { - wxWindowMac *sibling = (wxWindowMac*)node->GetData(); - if ( sibling == this ) - { - thisWindowThrough = true ; - continue ; - } - if( !thisWindowThrough ) - { - continue ; - } - - if ( !sibling->IsTopLevel() && sibling->IsShown() ) + bool thisWindowThrough = false ; + for (wxWindowListNode *node = GetParent()->GetChildren().GetFirst(); node; node = node->GetNext()) { - SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; - if ( sibling->IsKindOf( CLASSINFO( wxStaticBox ) ) ) + wxWindowMac *sibling = (wxWindowMac*)node->GetData(); + if ( sibling == this ) { - int borderTop = 14 ; - int borderOther = 4 ; - - SetRectRgn( tempStaticBoxRgn , sibling->m_x - m_x + borderOther , sibling->m_y - m_y + borderTop , sibling->m_x + sibling->m_width - m_x - borderOther , sibling->m_y + sibling->m_height - m_y - borderOther ) ; - DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; + thisWindowThrough = true ; + continue ; + } + if( !thisWindowThrough ) + { + continue ; + } + + if ( !sibling->IsTopLevel() && sibling->IsShown() ) + { + SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; + if ( sibling->IsKindOf( CLASSINFO( wxStaticBox ) ) ) + { + int borderTop = 14 ; + int borderOther = 4 ; + + SetRectRgn( tempStaticBoxRgn , sibling->m_x - m_x + borderOther , sibling->m_y - m_y + borderTop , sibling->m_x + sibling->m_width - m_x - borderOther , sibling->m_y + sibling->m_height - m_y - borderOther ) ; + DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; + } + DiffRgn( visRgn , tempRgn , visRgn ) ; } - DiffRgn( visRgn , tempRgn , visRgn ) ; } } - } - } - m_macVisibleRegion = visRgn ; - DisposeRgn( visRgn ) ; - DisposeRgn( tempRgn ) ; - DisposeRgn( tempStaticBoxRgn ) ; - return m_macVisibleRegion ; + } + m_macVisibleRegion = visRgn ; + DisposeRgn( visRgn ) ; + DisposeRgn( tempRgn ) ; + DisposeRgn( tempStaticBoxRgn ) ; + return m_macVisibleRegion ; } void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) @@ -1763,16 +1762,16 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) RgnHandle updatergn = (RgnHandle) updatergnr ; // updatergn is always already clipped to our boundaries // it is in window coordinates, not in client coordinates - + WindowRef window = (WindowRef) MacGetRootWindow() ; - + { // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates RgnHandle ownUpdateRgn = NewRgn() ; CopyRgn( updatergn , ownUpdateRgn ) ; - + SectRgn( ownUpdateRgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn ) ; - + // newupdate is the update region in client coordinates RgnHandle newupdate = NewRgn() ; wxSize point = GetClientSize() ; @@ -1782,32 +1781,32 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) OffsetRgn( newupdate , -origin.x , -origin.y ) ; m_updateRegion = newupdate ; DisposeRgn( newupdate ) ; // it's been cloned to m_updateRegion - + if ( erase && !EmptyRgn(ownUpdateRgn) ) { - wxWindowDC dc(this); - if (!EmptyRgn(ownUpdateRgn)) - dc.SetClippingRegion(wxRegion(ownUpdateRgn)); - wxEraseEvent eevent( GetId(), &dc ); - eevent.SetEventObject( this ); - GetEventHandler()->ProcessEvent( eevent ); - - wxNcPaintEvent eventNc( GetId() ); - eventNc.SetEventObject( this ); - GetEventHandler()->ProcessEvent( eventNc ); + wxWindowDC dc(this); + if (!EmptyRgn(ownUpdateRgn)) + dc.SetClippingRegion(wxRegion(ownUpdateRgn)); + wxEraseEvent eevent( GetId(), &dc ); + eevent.SetEventObject( this ); + GetEventHandler()->ProcessEvent( eevent ); + + wxNcPaintEvent eventNc( GetId() ); + eventNc.SetEventObject( this ); + GetEventHandler()->ProcessEvent( eventNc ); } DisposeRgn( ownUpdateRgn ) ; if ( !m_updateRegion.Empty() ) { - wxPaintEvent event; - event.m_timeStamp = time ; - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + wxPaintEvent event; + event.m_timeStamp = time ; + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); } } - + // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively - + RgnHandle childupdate = NewRgn() ; for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { @@ -1825,7 +1824,7 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) } DisposeRgn( childupdate ) ; // eventually a draw grow box here - + } WXHWND wxWindowMac::MacGetRootWindow() const diff --git a/src/mac/checkbox.cpp b/src/mac/checkbox.cpp index 60035000dd..f1bc26ccc6 100644 --- a/src/mac/checkbox.cpp +++ b/src/mac/checkbox.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -31,15 +31,15 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxValidator& validator, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlCheckBoxProc , (long) this ) ; - - MacPostControlCreate() ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlCheckBoxProc , (long) this ) ; + + MacPostControlCreate() ; return TRUE; } @@ -63,7 +63,7 @@ void wxCheckBox::Command (wxCommandEvent & event) void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) ) { - SetValue( !GetValue() ) ; + SetValue( !GetValue() ) ; wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); event.SetInt(GetValue()); event.SetEventObject(this); diff --git a/src/mac/checklst.cpp b/src/mac/checklst.cpp index 33dba7507c..c50773b137 100644 --- a/src/mac/checklst.cpp +++ b/src/mac/checklst.cpp @@ -73,9 +73,9 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, RgnHandle savedClipRegion; SInt32 savedPenMode; wxCheckListBox* list; - GetPort(&savePort); - SetPort((**listHandle).port); - grafPtr = (**listHandle).port ; + GetPort(&savePort); + SetPort((**listHandle).port); + grafPtr = (**listHandle).port ; // typecast our refCon list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); @@ -102,13 +102,13 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, ClipRect( drawRect ); EraseRect( drawRect ); - wxFontRefData * font = (wxFontRefData*) (list->GetFont().GetRefData()) ; + wxFontRefData * font = (wxFontRefData*) (list->GetFont().GetRefData()) ; - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( font->m_macFontSize) ; - ::TextFace( font->m_macFontStyle ) ; + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( font->m_macFontSize) ; + ::TextFace( font->m_macFontStyle ) ; } ThemeButtonDrawInfo info ; @@ -123,11 +123,11 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, checkRect.right = checkRect.left + list->m_checkBoxWidth ; checkRect.bottom = checkRect.top + list->m_checkBoxHeight ; DrawThemeButton(&checkRect,kThemeCheckBox, - &info,NULL,NULL, NULL,0); - - MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset ); - - DrawText(text, 0 , text.Length()); + &info,NULL,NULL, NULL,0); + + MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset ); + + DrawText(text, 0 , text.Length()); // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. @@ -142,8 +142,8 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, SetClip( savedClipRegion ); DisposeRgn( savedClipRegion ); - } - break; + } + break; case lHiliteMsg: // Hilite or unhilite the cell. Paint the cell contents with the @@ -194,7 +194,7 @@ bool wxCheckListBox::Create(wxWindow *parent, GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth); GetThemeMetric(kThemeMetricCheckBoxHeight,&h); #endif - wxFontRefData * font = (wxFontRefData*) (GetFont().GetRefData()) ; + wxFontRefData * font = (wxFontRefData*) (GetFont().GetRefData()) ; FontInfo finfo; FetchFontInfo(font->m_macFontNum,short(font->m_macFontSize),font->m_macFontStyle,&finfo); @@ -202,12 +202,12 @@ bool wxCheckListBox::Create(wxWindow *parent, m_TextBaseLineOffset= finfo.leading+finfo.ascent; m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent; - if (m_checkBoxHeight= 0 ) + if ( event.GetKeyCode() == WXK_SPACE ) { - Check(index, !IsChecked(index) ) ; - wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); - event.SetInt(index); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + int index = GetSelection() ; + if ( index >= 0 ) + { + Check(index, !IsChecked(index) ) ; + wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); + event.SetInt(index); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } } - } - else - event.Skip(); + else + event.Skip(); } void wxCheckListBox::OnLeftClick(wxMouseEvent& event) { - // clicking on the item selects it, clicking on the checkmark toggles - if ( event.GetX() <= 20 /*check width*/ ) { - int lineheight ; - int topcell ; + // clicking on the item selects it, clicking on the checkmark toggles + if ( event.GetX() <= 20 /*check width*/ ) { + int lineheight ; + int topcell ; #if TARGET_CARBON - Point pt ; - GetListCellSize( (ListHandle)m_macList , &pt ) ; - lineheight = pt.v ; - ListBounds visible ; - GetListVisibleCells( (ListHandle)m_macList , &visible ) ; - topcell = visible.top ; + Point pt ; + GetListCellSize( (ListHandle)m_macList , &pt ) ; + lineheight = pt.v ; + ListBounds visible ; + GetListVisibleCells( (ListHandle)m_macList , &visible ) ; + topcell = visible.top ; #else - lineheight = (**(ListHandle)m_macList).cellSize.v ; - topcell = (**(ListHandle)m_macList).visible.top ; + lineheight = (**(ListHandle)m_macList).cellSize.v ; + topcell = (**(ListHandle)m_macList).visible.top ; #endif - size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ; - - if ( nItem < (size_t)m_noItems ) - { - Check(nItem, !IsChecked(nItem) ) ; - wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); - event.SetInt(nItem); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ; + + if ( nItem < (size_t)m_noItems ) + { + Check(nItem, !IsChecked(nItem) ) ; + wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId()); + event.SetInt(nItem); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + //else: it's not an error, just click outside of client zone + } + else { + // implement default behaviour: clicking on the item selects it + event.Skip(); } - //else: it's not an error, just click outside of client zone - } - else { - // implement default behaviour: clicking on the item selects it - event.Skip(); - } } #endif // wxUSE_CHECKLISTBOX diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 4074699ed5..a53b5715ce 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -6,19 +6,24 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// + #ifdef __GNUG__ #pragma implementation "choice.h" #endif + #include "wx/defs.h" #include "wx/choice.h" #include "wx/menu.h" #include "wx/mac/uma.h" + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) #endif + extern MenuHandle NewUniqueMenu() ; + wxChoice::~wxChoice() { if ( HasClientObjectData() ) @@ -30,49 +35,52 @@ wxChoice::~wxChoice() } // DeleteMenu( m_macPopUpMenuId ) ; - // DisposeMenu( m_macPopUpMenuHandle ) ; + // DisposeMenu( m_macPopUpMenuHandle ) ; } + bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - int n, const wxString choices[], - long style, + int n, const wxString choices[], + long style, const wxValidator& validator, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 , - kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; - - m_macPopUpMenuHandle = NewUniqueMenu() ; - SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; - SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; - SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ; - if ( n > 0 ) - SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ; - MacPostControlCreate() ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 , + kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; + + m_macPopUpMenuHandle = NewUniqueMenu() ; + SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; + SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ; + if ( n > 0 ) + SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ; + MacPostControlCreate() ; for ( int i = 0; i < n; i++ ) { Append(choices[i]); } - return TRUE; + return TRUE; } + // ---------------------------------------------------------------------------- // adding/deleting items to/from the list // ---------------------------------------------------------------------------- int wxChoice::DoAppend(const wxString& item) { - UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item); - m_strings.Add( item ) ; - m_datas.Add( NULL ) ; - int index = m_strings.GetCount() - 1 ; - DoSetItemClientData( index , NULL ) ; - SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; - return index ; + UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item); + m_strings.Add( item ) ; + m_datas.Add( NULL ) ; + int index = m_strings.GetCount() - 1 ; + DoSetItemClientData( index , NULL ) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; + return index ; } + void wxChoice::Delete(int n) { wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") ); @@ -83,19 +91,21 @@ void wxChoice::Delete(int n) ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ; m_strings.Remove( n ) ; m_datas.RemoveAt( n ) ; - SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; + SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; } + void wxChoice::Clear() { FreeData(); for ( int i = 0 ; i < GetCount() ; i++ ) { - ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , 1 ) ; + ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , 1 ) ; } m_strings.Empty() ; m_datas.Empty() ; SetControl32BitMaximum( (ControlHandle) m_macControl , 0 ) ; } + void wxChoice::FreeData() { if ( HasClientObjectData() ) @@ -107,6 +117,7 @@ void wxChoice::FreeData() } } } + // ---------------------------------------------------------------------------- // selection // ---------------------------------------------------------------------------- @@ -114,26 +125,31 @@ int wxChoice::GetSelection() const { return GetControl32BitValue( (ControlHandle) m_macControl ) -1 ; } + void wxChoice::SetSelection(int n) { SetControl32BitValue( (ControlHandle) m_macControl , n + 1 ) ; } + // ---------------------------------------------------------------------------- // string list functions // ---------------------------------------------------------------------------- + int wxChoice::GetCount() const { return m_strings.GetCount() ; } + int wxChoice::FindString(const wxString& s) const { for( int i = 0 ; i < GetCount() ; i++ ) { - if ( GetString( i ).IsSameAs(s, FALSE) ) - return i ; + if ( GetString( i ).IsSameAs(s, FALSE) ) + return i ; } return wxNOT_FOUND ; } + void wxChoice::SetString(int n, const wxString& s) { wxFAIL_MSG(wxT("wxChoice::SetString() not yet implemented")); @@ -145,7 +161,7 @@ void wxChoice::SetString(int n, const wxString& s) wxString wxChoice::GetString(int n) const { - return m_strings[n] ; + return m_strings[n] ; } // ---------------------------------------------------------------------------- // client data @@ -154,23 +170,27 @@ void wxChoice::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( n >= 0 && (size_t)n < m_datas.GetCount(), "invalid index in wxChoice::SetClientData" ); - + m_datas[n] = (char*) clientData ; } + void *wxChoice::DoGetItemClientData(int n) const { wxCHECK_MSG( n >= 0 && (size_t)n < m_datas.GetCount(), NULL, "invalid index in wxChoice::GetClientData" ); return (void *)m_datas[n]; } + void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData ) { DoSetItemClientData(n, clientData); } + wxClientData* wxChoice::DoGetItemClientObject( int n ) const { return (wxClientData *)DoGetItemClientData(n); } + void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); @@ -188,6 +208,7 @@ void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) ProcessCommand(event); } } + wxSize wxChoice::DoGetBestSize() const { int lbWidth = 100; // some defaults @@ -198,35 +219,35 @@ wxSize wxChoice::DoGetBestSize() const GetThemeMetric(kThemeMetricPopupButtonHeight , &metric ); lbHeight = metric ; #endif - { - wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; - Rect drawRect ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - } - else - { - ::TextFont( kFontIDMonaco ) ; - ::TextSize( 9 ); - ::TextFace( 0 ) ; - } - // Find the widest line - for(int i = 0; i < GetCount(); i++) { - wxString str(GetString(i)); - wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; - lbWidth = wxMax(lbWidth, wLine); - } - // Add room for the popup arrow - lbWidth += 2 * lbHeight ; - // And just a bit more - int cy = 12 ; - int cx = ::TextWidth( "X" , 0 , 1 ) ; - lbWidth += cx ; - - } + { + wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; + Rect drawRect ; + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( short(font->m_macFontSize) ) ; + ::TextFace( font->m_macFontStyle ) ; + } + else + { + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + } + // Find the widest line + for(int i = 0; i < GetCount(); i++) { + wxString str(GetString(i)); + wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; + lbWidth = wxMax(lbWidth, wLine); + } + // Add room for the popup arrow + lbWidth += 2 * lbHeight ; + // And just a bit more + int cy = 12 ; + int cx = ::TextWidth( "X" , 0 , 1 ) ; + lbWidth += cx ; + + } return wxSize(lbWidth, lbHeight); } diff --git a/src/mac/clipbrd.cpp b/src/mac/clipbrd.cpp index 7854006d09..47a2b428f9 100644 --- a/src/mac/clipbrd.cpp +++ b/src/mac/clipbrd.cpp @@ -44,27 +44,27 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) #else OSStatus err = noErr ; #endif - void * data = NULL ; - Size byteCount; + void * data = NULL ; + Size byteCount; switch (dataFormat.GetType()) { - case wxDF_OEMTEXT: - dataFormat = wxDF_TEXT; - // fall through - - case wxDF_TEXT: - break; - case wxDF_BITMAP : - case wxDF_METAFILE : - break ; - default: - { - wxLogError(_("Unsupported clipboard format.")); - return NULL; - } + case wxDF_OEMTEXT: + dataFormat = wxDF_TEXT; + // fall through + + case wxDF_TEXT: + break; + case wxDF_BITMAP : + case wxDF_METAFILE : + break ; + default: + { + wxLogError(_("Unsupported clipboard format.")); + return NULL; + } } - + #if TARGET_CARBON ScrapRef scrapRef; @@ -77,21 +77,21 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) { if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr) { - if ( dataFormat.GetType() == wxDF_TEXT ) - byteCount++ ; + if ( dataFormat.GetType() == wxDF_TEXT ) + byteCount++ ; - data = new char[ byteCount ] ; - if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr ) - { - *len = byteCount ; - if ( dataFormat.GetType() == wxDF_TEXT ) - ((char*)data)[byteCount] = 0 ; - } - else - { - delete[] ((char *)data) ; - data = NULL ; - } + data = new char[ byteCount ] ; + if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr ) + { + *len = byteCount ; + if ( dataFormat.GetType() == wxDF_TEXT ) + ((char*)data)[byteCount] = 0 ; + } + else + { + delete[] ((char *)data) ; + data = NULL ; + } } } } @@ -104,28 +104,28 @@ void *wxGetClipboardData(wxDataFormat dataFormat, long *len) HUnlock( datahandle ) ; if ( GetHandleSize( datahandle ) > 0 ) { - byteCount = GetHandleSize( datahandle ) ; - if ( dataFormat.GetType() == wxDF_TEXT ) - data = new char[ byteCount + 1] ; - else - data = new char[ byteCount ] ; - - memcpy( (char*) data , (char*) *datahandle , byteCount ) ; - if ( dataFormat.GetType() == wxDF_TEXT ) - ((char*)data)[byteCount] = 0 ; - *len = byteCount ; + byteCount = GetHandleSize( datahandle ) ; + if ( dataFormat.GetType() == wxDF_TEXT ) + data = new char[ byteCount + 1] ; + else + data = new char[ byteCount ] ; + + memcpy( (char*) data , (char*) *datahandle , byteCount ) ; + if ( dataFormat.GetType() == wxDF_TEXT ) + ((char*)data)[byteCount] = 0 ; + *len = byteCount ; } DisposeHandle( datahandle ) ; #endif if ( err ) { wxLogSysError(_("Failed to get clipboard data.")); - + return NULL ; } if ( dataFormat.GetType() == wxDF_TEXT && wxApp::s_macDefaultEncodingIsPC ) { - wxMacConvertToPC((char*)data,(char*)data,byteCount) ; + wxMacConvertToPC((char*)data,(char*)data,byteCount) ; } return data; } @@ -139,8 +139,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject) wxClipboard::wxClipboard() { - m_open = false ; - m_data = NULL ; + m_open = false ; + m_data = NULL ; } wxClipboard::~wxClipboard() @@ -250,30 +250,30 @@ bool wxClipboard::AddData( wxDataObject *data ) #if wxUSE_DRAG_AND_DROP case wxDF_METAFILE: { - wxMetafileDataObject* metaFileDataObject = + wxMetafileDataObject* metaFileDataObject = (wxMetafileDataObject*) data; - wxMetafile metaFile = metaFileDataObject->GetMetafile(); - PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; - HLock( (Handle) pict ) ; - err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; - HUnlock( (Handle) pict ) ; + wxMetafile metaFile = metaFileDataObject->GetMetafile(); + PicHandle pict = (PicHandle) metaFile.GetHMETAFILE() ; + HLock( (Handle) pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + HUnlock( (Handle) pict ) ; } break ; #endif case wxDF_BITMAP: case wxDF_DIB: { - bool created = false ; - PicHandle pict = NULL ; - - wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data ; - pict = (PicHandle) bitmapDataObject->GetBitmap().GetPict( &created ) ; - - HLock( (Handle) pict ) ; - err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; - HUnlock( (Handle) pict ) ; - if ( created ) - KillPicture( pict ) ; + bool created = false ; + PicHandle pict = NULL ; + + wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data ; + pict = (PicHandle) bitmapDataObject->GetBitmap().GetPict( &created ) ; + + HLock( (Handle) pict ) ; + err = UMAPutScrap( GetHandleSize( (Handle) pict ) , 'PICT' , *pict ) ; + HUnlock( (Handle) pict ) ; + if ( created ) + KillPicture( pict ) ; } default: break ; @@ -388,7 +388,7 @@ bool wxClipboard::GetData( wxDataObject& data ) transferred = true ; } } - break ; + break ; default : break ; diff --git a/src/mac/colordlg.cpp b/src/mac/colordlg.cpp index bb2361b3ff..134e40f445 100644 --- a/src/mac/colordlg.cpp +++ b/src/mac/colordlg.cpp @@ -7,7 +7,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -50,20 +50,20 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) int wxColourDialog::ShowModal() { - Point where ; - RGBColor currentColor = *((RGBColor*)m_colourData.dataColour.GetPixel()) , newColor ; - - where.h = where.v = -1; + Point where ; + RGBColor currentColor = *((RGBColor*)m_colourData.dataColour.GetPixel()) , newColor ; + + where.h = where.v = -1; - if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor )) - { - m_colourData.dataColour.Set( (WXCOLORREF*) &newColor ) ; - return wxID_OK; - } - else - { - return wxID_CANCEL; - } + if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor )) + { + m_colourData.dataColour.Set( (WXCOLORREF*) &newColor ) ; + return wxID_OK; + } + else + { + return wxID_CANCEL; + } return wxID_CANCEL; } diff --git a/src/mac/colour.cpp b/src/mac/colour.cpp index b9a18e9ca9..12a65e02a5 100644 --- a/src/mac/colour.cpp +++ b/src/mac/colour.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -28,17 +28,17 @@ static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) { RGBColor* col = (RGBColor*) color ; - col->red = (red << 8) + red; - col->blue = (blue << 8) + blue; - col->green = (green << 8) + green; + col->red = (red << 8) + red; + col->blue = (blue << 8) + blue; + col->green = (green << 8) + green; } wxColour::wxColour () { - m_isInit = FALSE; - m_red = m_blue = m_green = 0; - - wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; + m_isInit = FALSE; + m_red = m_blue = m_green = 0; + + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) @@ -48,7 +48,7 @@ wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) m_blue = b; m_isInit = TRUE; - wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::wxColour (const wxColour& col) @@ -74,14 +74,14 @@ wxColour::wxColour (const wxColour* col) wxColour& wxColour::operator =(const wxColour& col) { - m_red = col.m_red; - m_green = col.m_green; - m_blue = col.m_blue; - m_isInit = col.m_isInit; - - memcpy( &m_pixel , &col.m_pixel , 6 ) ; - - return *this; + m_red = col.m_red; + m_green = col.m_green; + m_blue = col.m_blue; + m_isInit = col.m_isInit; + + memcpy( &m_pixel , &col.m_pixel , 6 ) ; + + return *this; } void wxColour::InitFromName(const wxString& col) @@ -102,7 +102,7 @@ void wxColour::InitFromName(const wxString& col) m_isInit = FALSE; } - wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::~wxColour () @@ -116,7 +116,7 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) m_blue = b; m_isInit = TRUE; - wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } void wxColour::Set( const WXCOLORREF* color ) diff --git a/src/mac/combobox.cpp b/src/mac/combobox.cpp index 2c000f3b0b..7d2a6819ea 100644 --- a/src/mac/combobox.cpp +++ b/src/mac/combobox.cpp @@ -96,7 +96,7 @@ protected: wxWindow *parent = GetParent(); while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) { - parent = parent->GetParent() ; + parent = parent->GetParent() ; } if ( parent && parent->GetDefaultItem() ) { @@ -314,9 +314,9 @@ void wxComboBox::SetValue(const wxString& value) int s = FindString (value); if (s == wxNOT_FOUND && !HasFlag(wxCB_READONLY) ) { - m_choice->Append(value) ; + m_choice->Append(value) ; } - SetStringSelection( value ) ; + SetStringSelection( value ) ; } // Clipboard operations diff --git a/src/mac/control.cpp b/src/mac/control.cpp index 0ba0c06521..2dd89c2b55 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -89,54 +89,54 @@ ControlDefUPP wxMacControlActionUPP = NULL ; pascal SInt32 wxMacControlDefinition(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param) { - wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ; - if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) - { - if( message == drawCntl ) - { - wxMacWindowClipper clip( wx ) ; - return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; - } - else - return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; - } - return NULL ; + wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ; + if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) + { + if( message == drawCntl ) + { + wxMacWindowClipper clip( wx ) ; + return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; + } + else + return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; + } + return NULL ; } pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor ) { - OSStatus status = noErr ; - switch( iMessage ) - { - case kControlMsgSetUpBackground : - { - wxControl* wx = (wxControl*) GetControlReference( iControl ) ; - if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) - { - wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ; + OSStatus status = noErr ; + switch( iMessage ) + { + case kControlMsgSetUpBackground : + { + wxControl* wx = (wxControl*) GetControlReference( iControl ) ; + if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) + { + wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ; #if TARGET_CARBON - // under classic this would lead to partial redraws - RgnHandle clip = NewRgn() ; - int x = 0 , y = 0; - - wx->MacWindowToRootWindow( &x,&y ) ; - CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ; - OffsetRgn( clip , x , y ) ; - SetClip( clip ) ; - DisposeRgn( clip ) ; + // under classic this would lead to partial redraws + RgnHandle clip = NewRgn() ; + int x = 0 , y = 0; + + wx->MacWindowToRootWindow( &x,&y ) ; + CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ; + OffsetRgn( clip , x , y ) ; + SetClip( clip ) ; + DisposeRgn( clip ) ; #endif - } - else - { - status = paramErr ; - } - } - break ; - default : - status = paramErr ; - break ; - } - return status ; + } + else + { + status = paramErr ; + } + } + break ; + default : + status = paramErr ; + break ; + } + return status ; } wxControl::wxControl() @@ -389,14 +389,14 @@ void wxControl::MacPostControlCreate() m_macControlIsShown = true ; wxAssociateControlWithMacControl( (ControlHandle) m_macControl , this ) ; - if ( wxMacSetupControlBackgroundUPP == NULL ) - { - wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ; - } - if ( wxMacControlActionUPP == NULL ) - { - wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefinition ) ; - } + if ( wxMacSetupControlBackgroundUPP == NULL ) + { + wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ; + } + if ( wxMacControlActionUPP == NULL ) + { + wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefinition ) ; + } // The following block of code is responsible for crashes when switching // back to windows, which can be seen in the dialogs sample. // It is disabled until a proper solution can be found. @@ -414,35 +414,35 @@ void wxControl::MacPostControlCreate() cdef = (cdefHandle) NewHandle( sizeof(cdefRec) ) ; if ( (**(ControlHandle)m_macControl).contrlDefProc != NULL ) { - (**cdef).instruction = 0x4EF9; /* JMP instruction */ - (**cdef).function = (void(*)()) wxMacControlActionUPP; - (**(ControlHandle)m_macControl).contrlDefProc = (Handle) cdef ; + (**cdef).instruction = 0x4EF9; /* JMP instruction */ + (**cdef).function = (void(*)()) wxMacControlActionUPP; + (**(ControlHandle)m_macControl).contrlDefProc = (Handle) cdef ; } #endif #endif - SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ; - - // Adjust the controls size and position - wxPoint pos(m_x, m_y); - wxSize best_size( DoGetBestSize() ); - wxSize new_size( m_width, m_height ); - - m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control - - if (new_size.x == -1) { + SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ; + + // Adjust the controls size and position + wxPoint pos(m_x, m_y); + wxSize best_size( DoGetBestSize() ); + wxSize new_size( m_width, m_height ); + + m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control + + if (new_size.x == -1) { new_size.x = best_size.x; - } - if (new_size.y == -1) { - new_size.y = best_size.y; - } - - SetSize(pos.x, pos.y, new_size.x, new_size.y); - - UMAShowControl( (ControlHandle) m_macControl ) ; - - SetCursor( *wxSTANDARD_CURSOR ) ; - - Refresh() ; + } + if (new_size.y == -1) { + new_size.y = best_size.y; + } + + SetSize(pos.x, pos.y, new_size.x, new_size.y); + + UMAShowControl( (ControlHandle) m_macControl ) ; + + SetCursor( *wxSTANDARD_CURSOR ) ; + + Refresh() ; } void wxControl::MacAdjustControlRect() @@ -496,7 +496,7 @@ void wxControl::MacAdjustControlRect() m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ; } - MacUpdateDimensions() ; + MacUpdateDimensions() ; // UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; } } @@ -511,19 +511,19 @@ WXWidget wxControl::MacGetContainerForEmbedding() void wxControl::MacUpdateDimensions() { - // actually in the current systems this should never be possible, but later reparenting - // may become a reality - - if ( (ControlHandle) m_macControl == NULL ) - return ; - - if ( GetParent() == NULL ) - return ; - + // actually in the current systems this should never be possible, but later reparenting + // may become a reality + + if ( (ControlHandle) m_macControl == NULL ) + return ; + + if ( GetParent() == NULL ) + return ; + WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; if ( rootwindow == NULL ) - return ; - + return ; + Rect oldBounds ; GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; @@ -535,23 +535,23 @@ void wxControl::MacUpdateDimensions() GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ; bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ; bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ; - if ( doMove || doResize ) - { - InvalWindowRect( rootwindow, &oldBounds ) ; - if ( doMove ) - { - UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; - } - if ( doResize ) - { - UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; - } - } + if ( doMove || doResize ) + { + InvalWindowRect( rootwindow, &oldBounds ) ; + if ( doMove ) + { + UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; + } + if ( doResize ) + { + UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; + } + } } void wxControl::MacSuperChangedPosition() { - MacUpdateDimensions() ; + MacUpdateDimensions() ; wxWindow::MacSuperChangedPosition() ; } @@ -561,7 +561,7 @@ void wxControl::MacSuperEnabled( bool enabled ) wxWindow::MacSuperEnabled( enabled ) ; } -void wxControl::MacSuperShown( bool show ) +void wxControl::MacSuperShown( bool show ) { if ( (ControlHandle) m_macControl ) { @@ -593,19 +593,19 @@ void wxControl::DoSetSize(int x, int y, wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ; #if 0 { - Rect meta , control ; - GetControlBounds( (ControlHandle) m_macControl , &control ) ; - RgnHandle rgn = NewRgn() ; - GetControlRegion( (ControlHandle) m_macControl , kControlStructureMetaPart , rgn ) ; - GetRegionBounds( rgn , &meta ) ; - if ( !EmptyRect( &meta ) ) - { - wxASSERT( meta.left >= control.left - m_macHorizontalBorder ) ; - wxASSERT( meta.right <= control.right + m_macHorizontalBorder ) ; - wxASSERT( meta.top >= control.top - m_macVerticalBorder ) ; - wxASSERT( meta.bottom <= control.bottom + m_macVerticalBorder ) ; - } - DisposeRgn( rgn ) ; + Rect meta , control ; + GetControlBounds( (ControlHandle) m_macControl , &control ) ; + RgnHandle rgn = NewRgn() ; + GetControlRegion( (ControlHandle) m_macControl , kControlStructureMetaPart , rgn ) ; + GetRegionBounds( rgn , &meta ) ; + if ( !EmptyRect( &meta ) ) + { + wxASSERT( meta.left >= control.left - m_macHorizontalBorder ) ; + wxASSERT( meta.right <= control.right + m_macHorizontalBorder ) ; + wxASSERT( meta.top >= control.top - m_macVerticalBorder ) ; + wxASSERT( meta.bottom <= control.bottom + m_macVerticalBorder ) ; + } + DisposeRgn( rgn ) ; } #endif return ; @@ -814,16 +814,16 @@ void wxControl::OnKeyDown( wxKeyEvent &event ) #if TARGET_CARBON - char charCode ; - UInt32 keyCode ; + char charCode ; + UInt32 keyCode ; UInt32 modifiers ; - GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); - GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); - GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); + GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); + GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); ::HandleControlKey( (ControlHandle) m_macControl , keyCode , charCode , modifiers ) ; - + #else EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; short keycode ; @@ -895,11 +895,10 @@ void wxControl::OnMouseEvent( wxMouseEvent &event ) bool wxControl::MacCanFocus() const { - { if ( (ControlHandle) m_macControl == NULL ) - return true ; - else - return false ; - } + if ( (ControlHandle) m_macControl == NULL ) + return true ; + else + return false ; } void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) diff --git a/src/mac/cursor.cpp b/src/mac/cursor.cpp index df3f6dd7cb..79633bf14d 100644 --- a/src/mac/cursor.cpp +++ b/src/mac/cursor.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -41,7 +41,7 @@ const short kwxCursorSizeNESW = 22 ; const short kwxCursorSizeNWSE = 23 ; const short kwxCursorRoller = 24 ; -wxCursor gMacCurrentCursor ; +wxCursor gMacCurrentCursor ; wxCursorRefData::wxCursorRefData() { @@ -60,15 +60,15 @@ wxCursorRefData::~wxCursorRefData() { ::DisposeCCursor( (CCrsrHandle) m_hCursor ) ; } - else if ( m_disposeHandle ) - { - ::DisposeHandle( (Handle ) m_hCursor ) ; - } - else if ( m_releaseHandle ) - { - // we don't release the resource since it may already - // be in use again - } + else if ( m_disposeHandle ) + { + ::DisposeHandle( (Handle ) m_hCursor ) ; + } + else if ( m_releaseHandle ) + { + // we don't release the resource since it may already + // be in use again + } } // Cursors @@ -91,14 +91,14 @@ void wxCursor::CreateFromImage(const wxImage & image) m_refData = new wxCursorRefData; wxImage image16 = image.Scale(16,16) ; - unsigned char * rgbBits = image16.GetData(); + unsigned char * rgbBits = image16.GetData(); - + int w = image16.GetWidth() ; int h = image16.GetHeight() ; bool bHasMask = image16.HasMask() ; - int hotSpotX = image16.GetOptionInt(wxCUR_HOTSPOT_X); + int hotSpotX = image16.GetOptionInt(wxCUR_HOTSPOT_X); int hotSpotY = image16.GetOptionInt(wxCUR_HOTSPOT_Y); if (hotSpotX < 0 || hotSpotX >= w) hotSpotX = 0; @@ -112,40 +112,40 @@ void wxCursor::CreateFromImage(const wxImage & image) memset( cp->data , 0 , sizeof( Bits16 ) ) ; memset( cp->mask , 0 , sizeof( Bits16 ) ) ; - unsigned char mr = image16.GetMaskRed() ; - unsigned char mg = image16.GetMaskGreen() ; - unsigned char mb = image16.GetMaskBlue() ; + unsigned char mr = image16.GetMaskRed() ; + unsigned char mg = image16.GetMaskGreen() ; + unsigned char mb = image16.GetMaskBlue() ; for ( int y = 0 ; y < h ; ++y ) { - short rowbits = 0 ; - short maskbits = 0 ; - - for ( int x = 0 ; x < w ; ++x ) - { - long pos = (y * w + x) * 3; + short rowbits = 0 ; + short maskbits = 0 ; + + for ( int x = 0 ; x < w ; ++x ) + { + long pos = (y * w + x) * 3; - unsigned char r = rgbBits[pos] ; - unsigned char g = rgbBits[pos+1] ; - unsigned char b = rgbBits[pos+2] ; - if ( bHasMask && r==mr && g==mg && b==mb ) - { - // masked area, does not appear anywhere - } - else - { - if ( (int)r + (int)g + (int)b < 0x60 ) - { - rowbits |= ( 1 << (15-x) ) ; - } - maskbits |= ( 1 << (15-x) ) ; - } - } - cp->data[y] = rowbits ; - cp->mask[y] = maskbits ; + unsigned char r = rgbBits[pos] ; + unsigned char g = rgbBits[pos+1] ; + unsigned char b = rgbBits[pos+2] ; + if ( bHasMask && r==mr && g==mg && b==mb ) + { + // masked area, does not appear anywhere + } + else + { + if ( (int)r + (int)g + (int)b < 0x60 ) + { + rowbits |= ( 1 << (15-x) ) ; + } + maskbits |= ( 1 << (15-x) ) ; + } + } + cp->data[y] = rowbits ; + cp->mask[y] = maskbits ; } if ( !bHasMask ) { - memcpy( cp->mask , cp->data , sizeof( Bits16) ) ; + memcpy( cp->mask , cp->data , sizeof( Bits16) ) ; } cp->hotSpot.h = hotSpotX ; @@ -158,40 +158,40 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho m_refData = new wxCursorRefData; if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE ) { - Str255 theName ; + Str255 theName ; #if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , cursor_file ) ; + c2pstrcpy( (StringPtr) theName , cursor_file ) ; #else - strcpy( (char *) theName , cursor_file ) ; - c2pstr( (char *) theName ) ; + strcpy( (char *) theName , cursor_file ) ; + c2pstr( (char *) theName ) ; #endif - + wxStAppResource resload ; - Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; - if ( resHandle ) - { - short theId = -1 ; - OSType theType ; - GetResInfo( resHandle , &theId , &theType , theName ) ; - ReleaseResource( resHandle ) ; - M_CURSORDATA->m_hCursor = GetCCursor( theId ) ; - if ( M_CURSORDATA->m_hCursor ) - M_CURSORDATA->m_isColorCursor = true ; - } - else - { - Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ; - if ( resHandle ) - { - short theId = -1 ; - OSType theType ; - GetResInfo( resHandle , &theId , &theType , theName ) ; - ReleaseResource( resHandle ) ; - M_CURSORDATA->m_hCursor = GetCursor( theId ) ; - if ( M_CURSORDATA->m_hCursor ) - M_CURSORDATA->m_releaseHandle = true ; - } + Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; + if ( resHandle ) + { + short theId = -1 ; + OSType theType ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + M_CURSORDATA->m_hCursor = GetCCursor( theId ) ; + if ( M_CURSORDATA->m_hCursor ) + M_CURSORDATA->m_isColorCursor = true ; + } + else + { + Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ; + if ( resHandle ) + { + short theId = -1 ; + OSType theType ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + M_CURSORDATA->m_hCursor = GetCursor( theId ) ; + if ( M_CURSORDATA->m_hCursor ) + M_CURSORDATA->m_releaseHandle = true ; + } } } else @@ -211,155 +211,155 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho // Cursors by stock number wxCursor::wxCursor(int cursor_type) { - m_refData = new wxCursorRefData; - - switch (cursor_type) - { + m_refData = new wxCursorRefData; + + switch (cursor_type) + { case wxCURSOR_WAIT: - M_CURSORDATA->m_themeCursor = kThemeWatchCursor ; - break; + M_CURSORDATA->m_themeCursor = kThemeWatchCursor ; + break; case wxCURSOR_IBEAM: - M_CURSORDATA->m_themeCursor = kThemeIBeamCursor ; - break; + M_CURSORDATA->m_themeCursor = kThemeIBeamCursor ; + break; case wxCURSOR_CROSS: - M_CURSORDATA->m_themeCursor = kThemeCrossCursor; - break; + M_CURSORDATA->m_themeCursor = kThemeCrossCursor; + break; case wxCURSOR_SIZENWSE: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNWSE); - } - break; + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNWSE); + } + break; case wxCURSOR_SIZENESW: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNESW); - } - break; + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNESW); + } + break; case wxCURSOR_SIZEWE: - { - M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor; - } - break; + { + M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor; + } + break; case wxCURSOR_SIZENS: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNS); - } - break; - case wxCURSOR_SIZING: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSize); - } - break; + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNS); + } + break; + case wxCURSOR_SIZING: + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSize); + } + break; case wxCURSOR_HAND: - { - M_CURSORDATA->m_themeCursor = kThemePointingHandCursor; - } - break; + { + M_CURSORDATA->m_themeCursor = kThemePointingHandCursor; + } + break; case wxCURSOR_BULLSEYE: { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBullseye); + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBullseye); } break; case wxCURSOR_PENCIL: { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPencil); + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPencil); } break; case wxCURSOR_MAGNIFIER: { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorMagnifier); + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorMagnifier); } break; case wxCURSOR_NO_ENTRY: { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorNoEntry); + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorNoEntry); } break; case wxCURSOR_WATCH: - { - M_CURSORDATA->m_themeCursor = kThemeWatchCursor; - break; - } + { + M_CURSORDATA->m_themeCursor = kThemeWatchCursor; + break; + } case wxCURSOR_PAINT_BRUSH: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPaintBrush); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPaintBrush); + break; + } case wxCURSOR_POINT_LEFT: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointLeft); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointLeft); + break; + } case wxCURSOR_POINT_RIGHT: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointRight); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointRight); + break; + } case wxCURSOR_QUESTION_ARROW: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorQuestionArrow); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorQuestionArrow); + break; + } case wxCURSOR_BLANK: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBlank); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBlank); + break; + } case wxCURSOR_RIGHT_ARROW: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRightArrow); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRightArrow); + break; + } case wxCURSOR_SPRAYCAN: - { - wxStAppResource resload ; - M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRoller); - break; - } + { + wxStAppResource resload ; + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRoller); + break; + } case wxCURSOR_CHAR: case wxCURSOR_ARROW: case wxCURSOR_LEFT_BUTTON: case wxCURSOR_RIGHT_BUTTON: case wxCURSOR_MIDDLE_BUTTON: - default: - M_CURSORDATA->m_themeCursor = kThemeArrowCursor ; - break; - } - if ( M_CURSORDATA->m_themeCursor == -1 ) - M_CURSORDATA->m_releaseHandle = true ; + default: + M_CURSORDATA->m_themeCursor = kThemeArrowCursor ; + break; + } + if ( M_CURSORDATA->m_themeCursor == -1 ) + M_CURSORDATA->m_releaseHandle = true ; } void wxCursor::MacInstall() const { - gMacCurrentCursor = *this ; - if ( m_refData && M_CURSORDATA->m_themeCursor != -1 ) - { - SetThemeCursor( M_CURSORDATA->m_themeCursor ) ; - } - else if ( m_refData && M_CURSORDATA->m_hCursor ) - { - if ( M_CURSORDATA->m_isColorCursor ) - ::SetCCursor( (CCrsrHandle) M_CURSORDATA->m_hCursor ) ; - else - ::SetCursor( * (CursHandle) M_CURSORDATA->m_hCursor ) ; - } - else - { - SetThemeCursor( kThemeArrowCursor ) ; - } + gMacCurrentCursor = *this ; + if ( m_refData && M_CURSORDATA->m_themeCursor != -1 ) + { + SetThemeCursor( M_CURSORDATA->m_themeCursor ) ; + } + else if ( m_refData && M_CURSORDATA->m_hCursor ) + { + if ( M_CURSORDATA->m_isColorCursor ) + ::SetCCursor( (CCrsrHandle) M_CURSORDATA->m_hCursor ) ; + else + ::SetCursor( * (CursHandle) M_CURSORDATA->m_hCursor ) ; + } + else + { + SetThemeCursor( kThemeArrowCursor ) ; + } } wxCursor::~wxCursor() @@ -369,7 +369,7 @@ wxCursor::~wxCursor() // Global cursor setting void wxSetCursor(const wxCursor& cursor) { - cursor.MacInstall() ; + cursor.MacInstall() ; } diff --git a/src/mac/data.cpp b/src/mac/data.cpp index c6471c8b0b..6b56b896dc 100644 --- a/src/mac/data.cpp +++ b/src/mac/data.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -137,7 +137,7 @@ const wxChar *wxDoubleToStringStr = wxT("%.2f"); const wxEventTable *wxEvtHandler::GetEventTable() const { return &wxEvtHandler::sm_eventTable; } const wxEventTable wxEvtHandler::sm_eventTable = - { NULL, &wxEvtHandler::sm_eventTableEntries[0] }; + { NULL, &wxEvtHandler::sm_eventTableEntries[0] }; const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = { { 0, 0, 0, NULL } }; #endif diff --git a/src/mac/dataobj.cpp b/src/mac/dataobj.cpp index 3d6437c7b7..15377f7f5b 100644 --- a/src/mac/dataobj.cpp +++ b/src/mac/dataobj.cpp @@ -141,7 +141,7 @@ bool wxDataObject::IsSupportedFormat( } else { - wxDataFormat* pFormats = new wxDataFormat[nFormatCount]; + wxDataFormat* pFormats = new wxDataFormat[nFormatCount]; GetAllFormats( pFormats ,vDir ); @@ -183,7 +183,7 @@ bool wxFileDataObject::GetDataHere( size_t wxFileDataObject::GetDataSize() const { - size_t nRes = 0; + size_t nRes = 0; for (size_t i = 0; i < m_filenames.GetCount(); i++) { @@ -201,7 +201,7 @@ bool wxFileDataObject::SetData( { m_filenames.Empty(); - wxString sFile( (const char *)pBuf); /* char, not wxChar */ + wxString sFile( (const char *)pBuf); /* char, not wxChar */ AddFile(sFile); @@ -225,15 +225,15 @@ wxBitmapDataObject::wxBitmapDataObject() } wxBitmapDataObject::wxBitmapDataObject( - const wxBitmap& rBitmap + const wxBitmap& rBitmap ) : wxBitmapDataObjectBase(rBitmap) { Init(); if ( m_bitmap.Ok() ) { - m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; - } + m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; + } } wxBitmapDataObject::~wxBitmapDataObject() @@ -249,23 +249,23 @@ void wxBitmapDataObject::SetBitmap( wxBitmapDataObjectBase::SetBitmap(rBitmap); if ( m_bitmap.Ok() ) { - m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; - } + m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ; + } } void wxBitmapDataObject::Init() { - m_pictHandle = NULL ; - m_pictCreated = false ; + m_pictHandle = NULL ; + m_pictCreated = false ; } void wxBitmapDataObject::Clear() { - if ( m_pictCreated && m_pictHandle ) - { - KillPicture( (PicHandle) m_pictHandle ) ; - } - m_pictHandle = NULL ; + if ( m_pictCreated && m_pictHandle ) + { + KillPicture( (PicHandle) m_pictHandle ) ; + } + m_pictHandle = NULL ; } bool wxBitmapDataObject::GetDataHere( @@ -283,7 +283,7 @@ bool wxBitmapDataObject::GetDataHere( size_t wxBitmapDataObject::GetDataSize() const { - return GetHandleSize((Handle)m_pictHandle) ; + return GetHandleSize((Handle)m_pictHandle) ; } bool wxBitmapDataObject::SetData( @@ -299,7 +299,7 @@ bool wxBitmapDataObject::SetData( Rect frame = (**picHandle).picFrame ; m_bitmap.SetPict( picHandle ) ; - m_bitmap.SetWidth( frame.right - frame.left ) ; - m_bitmap.SetHeight( frame.bottom - frame.top ) ; + m_bitmap.SetWidth( frame.right - frame.left ) ; + m_bitmap.SetHeight( frame.bottom - frame.top ) ; return m_bitmap.Ok(); } diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index 9e84d5f4aa..9dff84e4d3 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -6,11 +6,13 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// + #ifdef __GNUG__ #pragma implementation "dc.h" #endif + #include "wx/dc.h" #include "wx/app.h" #include "wx/mac/uma.h" @@ -30,32 +32,37 @@ using namespace std ; #if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) #endif + //----------------------------------------------------------------------------- // constants //----------------------------------------------------------------------------- -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 + +#define mm2inches 0.0393700787402 +#define inches2mm 25.4 +#define mm2twips 56.6929133859 +#define twips2mm 0.0176388888889 +#define mm2pt 2.83464566929 +#define pt2mm 0.352777777778 #ifndef __DARWIN__ const double M_PI = 3.14159265358979 ; #endif const double RAD2DEG = 180.0 / M_PI; const short kEmulatedMode = -1 ; const short kUnsupportedMode = -2 ; + wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) : - m_ph( (GrafPtr) dc->m_macPort ) + m_ph( (GrafPtr) dc->m_macPort ) { - wxASSERT( dc->Ok() ) ; - m_dc = dc ; - dc->MacSetupPort(&m_ph) ; + wxASSERT( dc->Ok() ) ; + m_dc = dc ; + dc->MacSetupPort(&m_ph) ; } + wxMacPortSetter::~wxMacPortSetter() { - m_dc->MacCleanupPort(&m_ph) ; + m_dc->MacCleanupPort(&m_ph) ; } + wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) { m_formerClip = NewRgn() ; @@ -65,21 +72,21 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) if ( win ) { #if 0 - // this clipping area was set to the parent window's drawing area, lead to problems - // with MacOSX controls drawing outside their wx' rectangle + // this clipping area was set to the parent window's drawing area, lead to problems + // with MacOSX controls drawing outside their wx' rectangle RgnHandle insidergn = NewRgn() ; int x = 0 , y = 0; wxWindow *parent = win->GetParent() ; parent->MacWindowToRootWindow( &x,&y ) ; wxSize size = parent->GetSize() ; SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() , - size.x - parent->MacGetRightBorderSize(), - size.y - parent->MacGetBottomBorderSize()) ; + size.x - parent->MacGetRightBorderSize(), + size.y - parent->MacGetBottomBorderSize()) ; CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip ) ; - SectRgn( m_newClip , insidergn , m_newClip ) ; + SectRgn( m_newClip , insidergn , m_newClip ) ; OffsetRgn( m_newClip , x , y ) ; SetClip( m_newClip ) ; - DisposeRgn( insidergn ) ; + DisposeRgn( insidergn ) ; #endif RgnHandle insidergn = NewRgn() ; int x = 0 , y = 0; @@ -87,138 +94,143 @@ wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion().GetWXHRGN() , m_newClip ) ; OffsetRgn( m_newClip , x , y ) ; SetClip( m_newClip ) ; - } + } } + wxMacWindowClipper::~wxMacWindowClipper() { SetClip( m_formerClip ) ; - DisposeRgn( m_newClip ) ; - DisposeRgn( m_formerClip ) ; + DisposeRgn( m_newClip ) ; + DisposeRgn( m_formerClip ) ; } + //----------------------------------------------------------------------------- // Local functions //----------------------------------------------------------------------------- static inline double dmin(double a, double b) { return a < b ? a : b; } static inline double dmax(double a, double b) { return a > b ? a : b; } static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } + //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- // this function emulates all wx colour manipulations, used to verify the implementation // by setting the mode in the blitting functions to kEmulatedMode void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) ; + void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) { switch ( logical_func ) { - case wxAND: // src AND dst - dstColor.red = dstColor.red & srcColor.red ; - dstColor.green = dstColor.green & srcColor.green ; - dstColor.blue = dstColor.blue & srcColor.blue ; - break ; - case wxAND_INVERT: // (NOT src) AND dst - dstColor.red = dstColor.red & ~srcColor.red ; - dstColor.green = dstColor.green & ~srcColor.green ; - dstColor.blue = dstColor.blue & ~srcColor.blue ; - break ; - case wxAND_REVERSE:// src AND (NOT dst) - dstColor.red = ~dstColor.red & srcColor.red ; - dstColor.green = ~dstColor.green & srcColor.green ; - dstColor.blue = ~dstColor.blue & srcColor.blue ; - break ; - case wxCLEAR: // 0 - dstColor.red = 0 ; - dstColor.green = 0 ; - dstColor.blue = 0 ; - break ; + case wxAND: // src AND dst + dstColor.red = dstColor.red & srcColor.red ; + dstColor.green = dstColor.green & srcColor.green ; + dstColor.blue = dstColor.blue & srcColor.blue ; + break ; + case wxAND_INVERT: // (NOT src) AND dst + dstColor.red = dstColor.red & ~srcColor.red ; + dstColor.green = dstColor.green & ~srcColor.green ; + dstColor.blue = dstColor.blue & ~srcColor.blue ; + break ; + case wxAND_REVERSE:// src AND (NOT dst) + dstColor.red = ~dstColor.red & srcColor.red ; + dstColor.green = ~dstColor.green & srcColor.green ; + dstColor.blue = ~dstColor.blue & srcColor.blue ; + break ; + case wxCLEAR: // 0 + dstColor.red = 0 ; + dstColor.green = 0 ; + dstColor.blue = 0 ; + break ; case wxCOPY: // src - dstColor.red = srcColor.red ; - dstColor.green = srcColor.green ; - dstColor.blue = srcColor.blue ; - break ; - case wxEQUIV: // (NOT src) XOR dst - dstColor.red = dstColor.red ^ ~srcColor.red ; - dstColor.green = dstColor.green ^ ~srcColor.green ; - dstColor.blue = dstColor.blue ^ ~srcColor.blue ; - break ; - case wxINVERT: // NOT dst - dstColor.red = ~dstColor.red ; - dstColor.green = ~dstColor.green ; - dstColor.blue = ~dstColor.blue ; - break ; - case wxNAND: // (NOT src) OR (NOT dst) - dstColor.red = ~dstColor.red | ~srcColor.red ; - dstColor.green = ~dstColor.green | ~srcColor.green ; - dstColor.blue = ~dstColor.blue | ~srcColor.blue ; - break ; - case wxNOR: // (NOT src) AND (NOT dst) - dstColor.red = ~dstColor.red & ~srcColor.red ; - dstColor.green = ~dstColor.green & ~srcColor.green ; - dstColor.blue = ~dstColor.blue & ~srcColor.blue ; - break ; - case wxNO_OP: // dst - break ; - case wxOR: // src OR dst - dstColor.red = dstColor.red | srcColor.red ; - dstColor.green = dstColor.green | srcColor.green ; - dstColor.blue = dstColor.blue | srcColor.blue ; - break ; - case wxOR_INVERT: // (NOT src) OR dst - dstColor.red = dstColor.red | ~srcColor.red ; - dstColor.green = dstColor.green | ~srcColor.green ; - dstColor.blue = dstColor.blue | ~srcColor.blue ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - dstColor.red = ~dstColor.red | srcColor.red ; - dstColor.green = ~dstColor.green | srcColor.green ; - dstColor.blue = ~dstColor.blue | srcColor.blue ; - break ; - case wxSET: // 1 - dstColor.red = 0xFFFF ; - dstColor.green = 0xFFFF ; - dstColor.blue = 0xFFFF ; - break ; - case wxSRC_INVERT: // (NOT src) - dstColor.red = ~srcColor.red ; - dstColor.green = ~srcColor.green ; - dstColor.blue = ~srcColor.blue ; - break ; - case wxXOR: // src XOR dst - dstColor.red = dstColor.red ^ srcColor.red ; - dstColor.green = dstColor.green ^ srcColor.green ; - dstColor.blue = dstColor.blue ^ srcColor.blue ; - break ; + dstColor.red = srcColor.red ; + dstColor.green = srcColor.green ; + dstColor.blue = srcColor.blue ; + break ; + case wxEQUIV: // (NOT src) XOR dst + dstColor.red = dstColor.red ^ ~srcColor.red ; + dstColor.green = dstColor.green ^ ~srcColor.green ; + dstColor.blue = dstColor.blue ^ ~srcColor.blue ; + break ; + case wxINVERT: // NOT dst + dstColor.red = ~dstColor.red ; + dstColor.green = ~dstColor.green ; + dstColor.blue = ~dstColor.blue ; + break ; + case wxNAND: // (NOT src) OR (NOT dst) + dstColor.red = ~dstColor.red | ~srcColor.red ; + dstColor.green = ~dstColor.green | ~srcColor.green ; + dstColor.blue = ~dstColor.blue | ~srcColor.blue ; + break ; + case wxNOR: // (NOT src) AND (NOT dst) + dstColor.red = ~dstColor.red & ~srcColor.red ; + dstColor.green = ~dstColor.green & ~srcColor.green ; + dstColor.blue = ~dstColor.blue & ~srcColor.blue ; + break ; + case wxNO_OP: // dst + break ; + case wxOR: // src OR dst + dstColor.red = dstColor.red | srcColor.red ; + dstColor.green = dstColor.green | srcColor.green ; + dstColor.blue = dstColor.blue | srcColor.blue ; + break ; + case wxOR_INVERT: // (NOT src) OR dst + dstColor.red = dstColor.red | ~srcColor.red ; + dstColor.green = dstColor.green | ~srcColor.green ; + dstColor.blue = dstColor.blue | ~srcColor.blue ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + dstColor.red = ~dstColor.red | srcColor.red ; + dstColor.green = ~dstColor.green | srcColor.green ; + dstColor.blue = ~dstColor.blue | srcColor.blue ; + break ; + case wxSET: // 1 + dstColor.red = 0xFFFF ; + dstColor.green = 0xFFFF ; + dstColor.blue = 0xFFFF ; + break ; + case wxSRC_INVERT: // (NOT src) + dstColor.red = ~srcColor.red ; + dstColor.green = ~srcColor.green ; + dstColor.blue = ~srcColor.blue ; + break ; + case wxXOR: // src XOR dst + dstColor.red = dstColor.red ^ srcColor.red ; + dstColor.green = dstColor.green ^ srcColor.green ; + dstColor.blue = dstColor.blue ^ srcColor.blue ; + break ; } } + wxDC::wxDC() { - m_ok = FALSE; - m_colour = TRUE; - m_mm_to_pix_x = mm2pt; - m_mm_to_pix_y = mm2pt; - m_internalDeviceOriginX = 0; - m_internalDeviceOriginY = 0; - m_externalDeviceOriginX = 0; - m_externalDeviceOriginY = 0; - m_logicalScaleX = 1.0; - m_logicalScaleY = 1.0; - m_userScaleX = 1.0; - m_userScaleY = 1.0; - m_scaleX = 1.0; - m_scaleY = 1.0; - m_needComputeScaleX = FALSE; - m_needComputeScaleY = FALSE; - m_macPort = NULL ; - m_macMask = NULL ; - m_ok = FALSE ; - m_macFontInstalled = false ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; - m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ; - m_macBoundaryClipRgn = NewRgn() ; - m_macCurrentClipRgn = NewRgn() ; - SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , -32000 , -32000 , 32000 , 32000 ) ; - SetRectRgn( (RgnHandle) m_macCurrentClipRgn , -32000 , -32000 , 32000 , 32000 ) ; + m_ok = FALSE; + m_colour = TRUE; + m_mm_to_pix_x = mm2pt; + m_mm_to_pix_y = mm2pt; + m_internalDeviceOriginX = 0; + m_internalDeviceOriginY = 0; + m_externalDeviceOriginX = 0; + m_externalDeviceOriginY = 0; + m_logicalScaleX = 1.0; + m_logicalScaleY = 1.0; + m_userScaleX = 1.0; + m_userScaleY = 1.0; + m_scaleX = 1.0; + m_scaleY = 1.0; + m_needComputeScaleX = FALSE; + m_needComputeScaleY = FALSE; + m_macPort = NULL ; + m_macMask = NULL ; + m_ok = FALSE ; + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ; + m_macBoundaryClipRgn = NewRgn() ; + m_macCurrentClipRgn = NewRgn() ; + SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , -32000 , -32000 , 32000 , 32000 ) ; + SetRectRgn( (RgnHandle) m_macCurrentClipRgn , -32000 , -32000 , 32000 , 32000 ) ; m_pen = *wxBLACK_PEN; m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; @@ -228,20 +240,23 @@ wxDC::wxDC() m_macForegroundPixMap = NULL ; m_macBackgroundPixMap = NULL ; } + wxDC::~wxDC(void) { DisposeRgn( (RgnHandle) m_macBoundaryClipRgn ) ; DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ; } + void wxDC::MacSetupPort(wxMacPortStateHelper* help) const { wxASSERT( m_macCurrentPortStateHelper == NULL ) ; m_macCurrentPortStateHelper = help ; - SetClip( (RgnHandle) m_macCurrentClipRgn); - m_macFontInstalled = false ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; + SetClip( (RgnHandle) m_macCurrentClipRgn); + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; } + void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const { wxASSERT( m_macCurrentPortStateHelper == help ) ; @@ -271,6 +286,7 @@ void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const m_macBackgroundPixMap = NULL ; } } + void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) { wxCHECK_RET( Ok(), wxT("invalid window dc") ); @@ -356,12 +372,14 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask m_macBrushInstalled = false ; m_macFontInstalled = false ; } + void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) { - wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon")); - wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon")); + wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon")); + wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon")); DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ; } + void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC")); @@ -388,10 +406,11 @@ void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord hei m_clipY2 = yy + hh; } } + void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) { wxCHECK_RET( Ok(), wxT("invalid window dc") ) ; - wxMacPortSetter helper(this) ; + wxMacPortSetter helper(this) ; if (region.Empty()) { DestroyClippingRegion(); @@ -435,113 +454,127 @@ void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) } } } + void wxDC::DestroyClippingRegion() { - wxMacPortSetter helper(this) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; - m_clipping = FALSE; + wxMacPortSetter helper(this) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; + m_clipping = FALSE; } + void wxDC::DoGetSize( int* width, int* height ) const { - *width = m_maxX-m_minX; - *height = m_maxY-m_minY; + *width = m_maxX-m_minX; + *height = m_maxY-m_minY; } + void wxDC::DoGetSizeMM( int* width, int* height ) const { - int w = 0; - int h = 0; - GetSize( &w, &h ); - *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); - *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); + int w = 0; + int h = 0; + GetSize( &w, &h ); + *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); + *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); } + void wxDC::SetTextForeground( const wxColour &col ) { wxCHECK_RET(Ok(), wxT("Invalid DC")); m_textForegroundColour = col; m_macFontInstalled = false ; } + void wxDC::SetTextBackground( const wxColour &col ) { wxCHECK_RET(Ok(), wxT("Invalid DC")); m_textBackgroundColour = col; m_macFontInstalled = false ; } + void wxDC::SetMapMode( int mode ) { - switch (mode) - { + switch (mode) + { case wxMM_TWIPS: - SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); - break; + SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); + break; case wxMM_POINTS: - SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); - break; + SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); + break; case wxMM_METRIC: - SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); - break; + SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); + break; case wxMM_LOMETRIC: - SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); - break; + SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); + break; default: case wxMM_TEXT: - SetLogicalScale( 1.0, 1.0 ); - break; - } - if (mode != wxMM_TEXT) - { - m_needComputeScaleX = TRUE; - m_needComputeScaleY = TRUE; - } + SetLogicalScale( 1.0, 1.0 ); + break; + } + if (mode != wxMM_TEXT) + { + m_needComputeScaleX = TRUE; + m_needComputeScaleY = TRUE; + } } + void wxDC::SetUserScale( double x, double y ) { - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); + // allow negative ? -> no + m_userScaleX = x; + m_userScaleY = y; + ComputeScaleAndOrigin(); } + void wxDC::SetLogicalScale( double x, double y ) { - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); + // allow negative ? + m_logicalScaleX = x; + m_logicalScaleY = y; + ComputeScaleAndOrigin(); } + void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) { - m_logicalOriginX = x * m_signX; // is this still correct ? - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); + m_logicalOriginX = x * m_signX; // is this still correct ? + m_logicalOriginY = y * m_signY; + ComputeScaleAndOrigin(); } + void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) { - m_externalDeviceOriginX = x; - m_externalDeviceOriginY = y; - ComputeScaleAndOrigin(); + m_externalDeviceOriginX = x; + m_externalDeviceOriginY = y; + ComputeScaleAndOrigin(); } + #if 0 void wxDC::SetInternalDeviceOrigin( long x, long y ) { - m_internalDeviceOriginX = x; - m_internalDeviceOriginY = y; - ComputeScaleAndOrigin(); + m_internalDeviceOriginX = x; + m_internalDeviceOriginY = y; + ComputeScaleAndOrigin(); } void wxDC::GetInternalDeviceOrigin( long *x, long *y ) { - if (x) *x = m_internalDeviceOriginX; - if (y) *y = m_internalDeviceOriginY; + if (x) *x = m_internalDeviceOriginX; + if (y) *y = m_internalDeviceOriginY; } #endif + void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) { - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); + m_signX = (xLeftRight ? 1 : -1); + m_signY = (yBottomUp ? -1 : 1); + ComputeScaleAndOrigin(); } + wxSize wxDC::GetPPI() const { return wxSize(72, 72); } + int wxDC::GetDepth() const { if ( IsPortColor( (CGrafPtr) m_macPort ) ) @@ -550,77 +583,88 @@ int wxDC::GetDepth() const } return 1 ; } + void wxDC::ComputeScaleAndOrigin() { - // CMB: copy scale to see if it changes - double origScaleX = m_scaleX; - double origScaleY = m_scaleY; - m_scaleX = m_logicalScaleX * m_userScaleX; - m_scaleY = m_logicalScaleY * m_userScaleY; - m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; - m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; - // CMB: if scale has changed call SetPen to recalulate the line width - if (m_scaleX != origScaleX || m_scaleY != origScaleY) - { - // this is a bit artificial, but we need to force wxDC to think - // the pen has changed - wxPen* pen = & GetPen(); - wxPen tempPen; - m_pen = tempPen; - SetPen(* pen); - } + // CMB: copy scale to see if it changes + double origScaleX = m_scaleX; + double origScaleY = m_scaleY; + m_scaleX = m_logicalScaleX * m_userScaleX; + m_scaleY = m_logicalScaleY * m_userScaleY; + m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; + m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; + // CMB: if scale has changed call SetPen to recalulate the line width + if (m_scaleX != origScaleX || m_scaleY != origScaleY) + { + // this is a bit artificial, but we need to force wxDC to think + // the pen has changed + wxPen* pen = & GetPen(); + wxPen tempPen; + m_pen = tempPen; + SetPen(* pen); + } } + void wxDC::SetPalette( const wxPalette& palette ) { } + void wxDC::SetBackgroundMode( int mode ) { - m_backgroundMode = mode ; + m_backgroundMode = mode ; } + void wxDC::SetFont( const wxFont &font ) { m_font = font; m_macFontInstalled = false ; } + void wxDC::SetPen( const wxPen &pen ) { - if ( m_pen == pen ) - return ; - m_pen = pen; - m_macPenInstalled = false ; + if ( m_pen == pen ) + return ; + m_pen = pen; + m_macPenInstalled = false ; } + void wxDC::SetBrush( const wxBrush &brush ) { - if (m_brush == brush) - return; - m_brush = brush; - m_macBrushInstalled = false ; + if (m_brush == brush) + return; + m_brush = brush; + m_macBrushInstalled = false ; } + void wxDC::SetBackground( const wxBrush &brush ) { - if (m_backgroundBrush == brush) - return; - m_backgroundBrush = brush; - if (!m_backgroundBrush.Ok()) - return; - m_macBrushInstalled = false ; + if (m_backgroundBrush == brush) + return; + m_backgroundBrush = brush; + if (!m_backgroundBrush.Ok()) + return; + m_macBrushInstalled = false ; } + void wxDC::SetLogicalFunction( int function ) { - if (m_logicalFunction == function) - return; - m_logicalFunction = function ; - m_macFontInstalled = false ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; + if (m_logicalFunction == function) + return; + m_logicalFunction = function ; + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; } + extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); + bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { return wxDoFloodFill(this, x, y, col, style); } + bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const { wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") ); @@ -629,47 +673,49 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour ); // Convert from Mac colour to wx col->Set( colour.red >> 8, - colour.green >> 8, - colour.blue >> 8); + colour.green >> 8, + colour.blue >> 8); return true ; } + void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) { - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : - m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2; + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : + m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2; wxCoord xx1 = XLOG2DEVMAC(x1) - offset; wxCoord yy1 = YLOG2DEVMAC(y1) - offset; wxCoord xx2 = XLOG2DEVMAC(x2) - offset; wxCoord yy2 = YLOG2DEVMAC(y2) - offset; if ((m_pen.GetCap() == wxCAP_ROUND) && (m_pen.GetWidth() <= 1)) - { - // Implement LAST_NOT for MAC at least for - // orthogonal lines. RR. - if (xx1 == xx2) - { - if (yy1 < yy2) - yy2--; - if (yy1 > yy2) - yy2++; - } - if (yy1 == yy2) - { - if (xx1 < xx2) - xx2--; - if (xx1 > xx2) - xx2++; - } - } - ::MoveTo(xx1, yy1); - ::LineTo(xx2, yy2); - } + { + // Implement LAST_NOT for MAC at least for + // orthogonal lines. RR. + if (xx1 == xx2) + { + if (yy1 < yy2) + yy2--; + if (yy1 > yy2) + yy2++; + } + if (yy1 == yy2) + { + if (xx1 < xx2) + xx2--; + if (xx1 > xx2) + xx2++; + } + } + ::MoveTo(xx1, yy1); + ::LineTo(xx2, yy2); + } } + void wxDC::DoCrossHair( wxCoord x, wxCoord y ) { wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") ); @@ -690,14 +736,16 @@ void wxDC::DoCrossHair( wxCoord x, wxCoord y ) CalcBoundingBox(x+w, y+h); } } + /* - * To draw arcs properly the angles need to be converted from the WX style: - * Angles start on the +ve X axis and go anti-clockwise (As you would draw on - * a normal axis on paper). - * TO - * the Mac style: - * Angles start on the +ve y axis and go clockwise. - */ +* To draw arcs properly the angles need to be converted from the WX style: +* Angles start on the +ve X axis and go anti-clockwise (As you would draw on +* a normal axis on paper). +* TO +* the Mac style: +* Angles start on the +ve y axis and go clockwise. +*/ + static double wxConvertWXangleToMACangle(double angle) { double newAngle = 90 - angle ; @@ -705,9 +753,10 @@ static double wxConvertWXangleToMACangle(double angle) newAngle += 360 ; return newAngle ; } + void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, - wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc ) + wxCoord x2, wxCoord y2, + wxCoord xc, wxCoord yc ) { wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC")); wxMacPortSetter helper(this) ; @@ -735,14 +784,14 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, { radius1 = (xx1 - xxc == 0) ? (yy1 - yyc < 0) ? 90.0 : -90.0 : - -atan2(double(yy1-yyc), double(xx1-xxc)) * RAD2DEG; - radius2 = (xx2 - xxc == 0) ? + -atan2(double(yy1-yyc), double(xx1-xxc)) * RAD2DEG; + radius2 = (xx2 - xxc == 0) ? (yy2 - yyc < 0) ? 90.0 : -90.0 : - -atan2(double(yy2-yyc), double(xx2-xxc)) * RAD2DEG; - } - wxCoord alpha2 = wxCoord(radius2 - radius1); + -atan2(double(yy2-yyc), double(xx2-xxc)) * RAD2DEG; + } + wxCoord alpha2 = wxCoord(radius2 - radius1); wxCoord alpha1 = wxCoord(wxConvertWXangleToMACangle(radius1)); - if( (xx1 > xx2) || (yy1 > yy2) ) { + if( (xx1 > xx2) || (yy1 > yy2) ) { alpha2 *= -1; } Rect r = { yyc - rad, xxc - rad, yyc + rad, xxc + rad }; @@ -755,8 +804,9 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, FrameArc(&r, alpha1, alpha2); } } + void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, - double sa, double ea ) + double sa, double ea ) { wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC")); wxMacPortSetter helper(this) ; @@ -786,193 +836,198 @@ void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, FrameArc(&r, (short)sa, (short)angle); } } + void wxDC::DoDrawPoint( wxCoord x, wxCoord y ) { - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - if (m_pen.GetStyle() != wxTRANSPARENT) - { + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + if (m_pen.GetStyle() != wxTRANSPARENT) + { wxCoord xx1 = XLOG2DEVMAC(x); wxCoord yy1 = YLOG2DEVMAC(y); RGBColor pencolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); ::SetCPixel( xx1,yy1,&pencolor) ; CalcBoundingBox(x, y); - } + } } + void wxDC::DoDrawLines(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset) -{ - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - if (m_pen.GetStyle() == wxTRANSPARENT) - return; - MacInstallPen() ; - wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : - m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2 ; - wxCoord x1, x2 , y1 , y2 ; - x1 = XLOG2DEVMAC(points[0].x + xoffset); - y1 = YLOG2DEVMAC(points[0].y + yoffset); - ::MoveTo(x1 - offset, y1 - offset ); - for (int i = 0; i < n-1; i++) - { - x2 = XLOG2DEVMAC(points[i+1].x + xoffset); - y2 = YLOG2DEVMAC(points[i+1].y + yoffset); - ::LineTo( x2 - offset, y2 - offset ); - } + wxCoord xoffset, wxCoord yoffset) +{ + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + if (m_pen.GetStyle() == wxTRANSPARENT) + return; + MacInstallPen() ; + wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 : + m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2 ; + wxCoord x1, x2 , y1 , y2 ; + x1 = XLOG2DEVMAC(points[0].x + xoffset); + y1 = YLOG2DEVMAC(points[0].y + yoffset); + ::MoveTo(x1 - offset, y1 - offset ); + for (int i = 0; i < n-1; i++) + { + x2 = XLOG2DEVMAC(points[i+1].x + xoffset); + y2 = YLOG2DEVMAC(points[i+1].y + yoffset); + ::LineTo( x2 - offset, y2 - offset ); + } } + void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle ) { - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - wxCoord x1, x2 , y1 , y2 ; + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + wxCoord x1, x2 , y1 , y2 ; if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) return ; - PolyHandle polygon = OpenPoly(); - x2 = x1 = XLOG2DEVMAC(points[0].x + xoffset); - y2 = y1 = YLOG2DEVMAC(points[0].y + yoffset); - ::MoveTo(x1,y1); - for (int i = 1; i < n; i++) - { - x2 = XLOG2DEVMAC(points[i].x + xoffset); - y2 = YLOG2DEVMAC(points[i].y + yoffset); - ::LineTo(x2, y2); - } + PolyHandle polygon = OpenPoly(); + x2 = x1 = XLOG2DEVMAC(points[0].x + xoffset); + y2 = y1 = YLOG2DEVMAC(points[0].y + yoffset); + ::MoveTo(x1,y1); + for (int i = 1; i < n; i++) + { + x2 = XLOG2DEVMAC(points[i].x + xoffset); + y2 = YLOG2DEVMAC(points[i].y + yoffset); + ::LineTo(x2, y2); + } // close the polyline if necessary if ( x1 != x2 || y1 != y2 ) { ::LineTo(x1,y1 ) ; } - ClosePoly(); - if (m_brush.GetStyle() != wxTRANSPARENT) - { - MacInstallBrush(); - ::PaintPoly( polygon ); - } - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - ::FramePoly( polygon ) ; - } - KillPoly( polygon ); + ClosePoly(); + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush(); + ::PaintPoly( polygon ); + } + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FramePoly( polygon ) ; + } + KillPoly( polygon ); } + void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { wxCHECK_RET(Ok(), wxT("Invalid DC")); wxMacPortSetter helper(this) ; - wxCoord xx = XLOG2DEVMAC(x); - wxCoord yy = YLOG2DEVMAC(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) - return; - // CMB: handle -ve width and/or height - if (ww < 0) - { - ww = -ww; - xx = xx - ww; - } - if (hh < 0) - { - hh = -hh; - yy = yy - hh; - } - Rect rect = { yy , xx , yy + hh , xx + ww } ; - if (m_brush.GetStyle() != wxTRANSPARENT) - { - MacInstallBrush() ; - ::PaintRect( &rect ) ; - } - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - ::FrameRect( &rect ) ; - } + wxCoord xx = XLOG2DEVMAC(x); + wxCoord yy = YLOG2DEVMAC(y); + wxCoord ww = m_signX * XLOG2DEVREL(width); + wxCoord hh = m_signY * YLOG2DEVREL(height); + // CMB: draw nothing if transformed w or h is 0 + if (ww == 0 || hh == 0) + return; + // CMB: handle -ve width and/or height + if (ww < 0) + { + ww = -ww; + xx = xx - ww; + } + if (hh < 0) + { + hh = -hh; + yy = yy - hh; + } + Rect rect = { yy , xx , yy + hh , xx + ww } ; + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::PaintRect( &rect ) ; + } + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FrameRect( &rect ) ; + } } + void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, - wxCoord width, wxCoord height, - double radius) + wxCoord width, wxCoord height, + double radius) { wxCHECK_RET(Ok(), wxT("Invalid DC")); wxMacPortSetter helper(this) ; if (radius < 0.0) - radius = - radius * ((width < height) ? width : height); - wxCoord xx = XLOG2DEVMAC(x); - wxCoord yy = YLOG2DEVMAC(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) - return; - // CMB: handle -ve width and/or height - if (ww < 0) - { - ww = -ww; - xx = xx - ww; - } - if (hh < 0) - { - hh = -hh; - yy = yy - hh; - } - Rect rect = { yy , xx , yy + hh , xx + ww } ; - if (m_brush.GetStyle() != wxTRANSPARENT) - { - MacInstallBrush() ; - ::PaintRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; - } - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - ::FrameRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; - } + radius = - radius * ((width < height) ? width : height); + wxCoord xx = XLOG2DEVMAC(x); + wxCoord yy = YLOG2DEVMAC(y); + wxCoord ww = m_signX * XLOG2DEVREL(width); + wxCoord hh = m_signY * YLOG2DEVREL(height); + // CMB: draw nothing if transformed w or h is 0 + if (ww == 0 || hh == 0) + return; + // CMB: handle -ve width and/or height + if (ww < 0) + { + ww = -ww; + xx = xx - ww; + } + if (hh < 0) + { + hh = -hh; + yy = yy - hh; + } + Rect rect = { yy , xx , yy + hh , xx + ww } ; + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::PaintRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; + } + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FrameRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ; + } } + void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { wxCHECK_RET(Ok(), wxT("Invalid DC")); wxMacPortSetter helper(this) ; - wxCoord xx = XLOG2DEVMAC(x); - wxCoord yy = YLOG2DEVMAC(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) - return; - // CMB: handle -ve width and/or height - if (ww < 0) - { - ww = -ww; - xx = xx - ww; - } - if (hh < 0) - { - hh = -hh; - yy = yy - hh; - } - Rect rect = { yy , xx , yy + hh , xx + ww } ; - if (m_brush.GetStyle() != wxTRANSPARENT) - { - MacInstallBrush() ; - ::PaintOval( &rect ) ; - } - if (m_pen.GetStyle() != wxTRANSPARENT) - { - MacInstallPen() ; - ::FrameOval( &rect ) ; - } + wxCoord xx = XLOG2DEVMAC(x); + wxCoord yy = YLOG2DEVMAC(y); + wxCoord ww = m_signX * XLOG2DEVREL(width); + wxCoord hh = m_signY * YLOG2DEVREL(height); + // CMB: draw nothing if transformed w or h is 0 + if (ww == 0 || hh == 0) + return; + // CMB: handle -ve width and/or height + if (ww < 0) + { + ww = -ww; + xx = xx - ww; + } + if (hh < 0) + { + hh = -hh; + yy = yy - hh; + } + Rect rect = { yy , xx , yy + hh , xx + ww } ; + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::PaintOval( &rect ) ; + } + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FrameOval( &rect ) ; + } } - bool wxDC::CanDrawBitmap(void) const { - return true ; + return true ; } bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, - wxCoord xsrcMask, wxCoord ysrcMask ) + wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, + wxCoord xsrcMask, wxCoord ysrcMask ) { wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc")); wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit Illegal source DC")); @@ -985,112 +1040,112 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, // correct the parameter in case this dc does not have a mask at all if ( useMask && !source->m_macMask ) useMask = false ; - Rect srcrect , dstrect ; - srcrect.top = source->YLOG2DEVMAC(ysrc) ; - srcrect.left = source->XLOG2DEVMAC(xsrc) ; - srcrect.right = source->XLOG2DEVMAC(xsrc + width ) ; - srcrect.bottom = source->YLOG2DEVMAC(ysrc + height) ; - dstrect.top = YLOG2DEVMAC(ydest) ; - dstrect.left = XLOG2DEVMAC(xdest) ; - dstrect.bottom = YLOG2DEVMAC(ydest + height ) ; - dstrect.right = XLOG2DEVMAC(xdest + width ) ; + Rect srcrect , dstrect ; + srcrect.top = source->YLOG2DEVMAC(ysrc) ; + srcrect.left = source->XLOG2DEVMAC(xsrc) ; + srcrect.right = source->XLOG2DEVMAC(xsrc + width ) ; + srcrect.bottom = source->YLOG2DEVMAC(ysrc + height) ; + dstrect.top = YLOG2DEVMAC(ydest) ; + dstrect.left = XLOG2DEVMAC(xdest) ; + dstrect.bottom = YLOG2DEVMAC(ydest + height ) ; + dstrect.right = XLOG2DEVMAC(xdest + width ) ; short mode = kUnsupportedMode ; bool invertDestinationFirst = false ; switch ( logical_func ) { - case wxAND: // src AND dst - mode = srcOr ; // ok - break ; - case wxAND_INVERT: // (NOT src) AND dst - mode = notSrcOr ; // ok - break ; - case wxAND_REVERSE:// src AND (NOT dst) - invertDestinationFirst = true ; - mode = srcOr ; - break ; - case wxCLEAR: // 0 - mode = kEmulatedMode ; - break ; - case wxCOPY: // src - mode = srcCopy ; // ok - break ; - case wxEQUIV: // (NOT src) XOR dst - mode = srcXor ; // ok - break ; - case wxINVERT: // NOT dst - mode = kEmulatedMode ; //or hilite ; - break ; - case wxNAND: // (NOT src) OR (NOT dst) - invertDestinationFirst = true ; - mode = srcBic ; - break ; - case wxNOR: // (NOT src) AND (NOT dst) - invertDestinationFirst = true ; - mode = notSrcOr ; - break ; - case wxNO_OP: // dst - mode = kEmulatedMode ; // this has already been handled upon entry - break ; - case wxOR: // src OR dst - mode = notSrcBic ; - break ; - case wxOR_INVERT: // (NOT src) OR dst - mode = srcBic ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - invertDestinationFirst = true ; - mode = notSrcBic ; - break ; - case wxSET: // 1 - mode = kEmulatedMode ; - break ; - case wxSRC_INVERT: // (NOT src) - mode = notSrcCopy ; // ok - break ; - case wxXOR: // src XOR dst - mode = notSrcXor ; // ok - break ; - default : - break ; + case wxAND: // src AND dst + mode = srcOr ; // ok + break ; + case wxAND_INVERT: // (NOT src) AND dst + mode = notSrcOr ; // ok + break ; + case wxAND_REVERSE:// src AND (NOT dst) + invertDestinationFirst = true ; + mode = srcOr ; + break ; + case wxCLEAR: // 0 + mode = kEmulatedMode ; + break ; + case wxCOPY: // src + mode = srcCopy ; // ok + break ; + case wxEQUIV: // (NOT src) XOR dst + mode = srcXor ; // ok + break ; + case wxINVERT: // NOT dst + mode = kEmulatedMode ; //or hilite ; + break ; + case wxNAND: // (NOT src) OR (NOT dst) + invertDestinationFirst = true ; + mode = srcBic ; + break ; + case wxNOR: // (NOT src) AND (NOT dst) + invertDestinationFirst = true ; + mode = notSrcOr ; + break ; + case wxNO_OP: // dst + mode = kEmulatedMode ; // this has already been handled upon entry + break ; + case wxOR: // src OR dst + mode = notSrcBic ; + break ; + case wxOR_INVERT: // (NOT src) OR dst + mode = srcBic ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + invertDestinationFirst = true ; + mode = notSrcBic ; + break ; + case wxSET: // 1 + mode = kEmulatedMode ; + break ; + case wxSRC_INVERT: // (NOT src) + mode = notSrcCopy ; // ok + break ; + case wxXOR: // src XOR dst + mode = notSrcXor ; // ok + break ; + default : + break ; } if ( mode == kUnsupportedMode ) { wxFAIL_MSG("unsupported blitting mode" ); return FALSE ; } - CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; - PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; - if ( LockPixels(bmappixels) ) - { + CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; + PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; + if ( LockPixels(bmappixels) ) + { wxMacPortSetter helper(this) ; - if ( source->GetDepth() == 1 ) - { - RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ; - RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()) ) ; + if ( source->GetDepth() == 1 ) + { + RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ; + RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()) ) ; } else { // the modes need this, otherwise we'll end up having really nice colors... - RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; - RGBColor black = { 0,0,0} ; - RGBForeColor( &black ) ; - RGBBackColor( &white ) ; + RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; + RGBColor black = { 0,0,0} ; + RGBForeColor( &black ) ; + RGBBackColor( &white ) ; } - if ( useMask && source->m_macMask ) - { - if ( mode == srcCopy ) - { - if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ) - { - CopyMask( GetPortBitMapForCopyBits( sourcePort ) , - GetPortBitMapForCopyBits( MAC_WXHBITMAP(source->m_macMask) ) , - GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , - &srcrect, &srcrect , &dstrect ) ; - UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; - } - } - else - { + if ( useMask && source->m_macMask ) + { + if ( mode == srcCopy ) + { + if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ) + { + CopyMask( GetPortBitMapForCopyBits( sourcePort ) , + GetPortBitMapForCopyBits( MAC_WXHBITMAP(source->m_macMask) ) , + GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , + &srcrect, &srcrect , &dstrect ) ; + UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; + } + } + else + { RgnHandle clipRgn = NewRgn() ; LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ; @@ -1099,17 +1154,17 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, if ( mode == kEmulatedMode ) { Pattern pat ; - ::PenPat(GetQDGlobalsBlack(&pat)); + ::PenPat(GetQDGlobalsBlack(&pat)); if ( logical_func == wxSET ) { RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ; - ::RGBForeColor( &col ) ; + ::RGBForeColor( &col ) ; ::PaintRgn( clipRgn ) ; } else if ( logical_func == wxCLEAR ) { RGBColor col= { 0x0000, 0x0000, 0x0000 } ; - ::RGBForeColor( &col ) ; + ::RGBForeColor( &col ) ; ::PaintRgn( clipRgn ) ; } else if ( logical_func == wxINVERT ) @@ -1145,31 +1200,31 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, { MacInvertRgn( clipRgn ) ; } - CopyBits( GetPortBitMapForCopyBits( sourcePort ) , - GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , - &srcrect, &dstrect, mode, clipRgn ) ; - } - DisposeRgn( clipRgn ) ; - } - } - else - { + CopyBits( GetPortBitMapForCopyBits( sourcePort ) , + GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , + &srcrect, &dstrect, mode, clipRgn ) ; + } + DisposeRgn( clipRgn ) ; + } + } + else + { RgnHandle clipRgn = NewRgn() ; SetRectRgn( clipRgn , dstrect.left , dstrect.top , dstrect.right , dstrect.bottom ) ; - if ( mode == kEmulatedMode ) - { + if ( mode == kEmulatedMode ) + { Pattern pat ; - ::PenPat(GetQDGlobalsBlack(&pat)); + ::PenPat(GetQDGlobalsBlack(&pat)); if ( logical_func == wxSET ) { RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ; - ::RGBForeColor( &col ) ; + ::RGBForeColor( &col ) ; ::PaintRgn( clipRgn ) ; } else if ( logical_func == wxCLEAR ) { RGBColor col= { 0x0000, 0x0000, 0x0000 } ; - ::RGBForeColor( &col ) ; + ::RGBForeColor( &col ) ; ::PaintRgn( clipRgn ) ; } else if ( logical_func == wxINVERT ) @@ -1197,34 +1252,36 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, } } } - } - else - { + } + else + { if ( invertDestinationFirst ) { MacInvertRgn( clipRgn ) ; } - CopyBits( GetPortBitMapForCopyBits( sourcePort ) , - GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , - &srcrect, &dstrect, mode, NULL ) ; - } - DisposeRgn( clipRgn ) ; - } - UnlockPixels( bmappixels ) ; - } - m_macPenInstalled = false ; - m_macBrushInstalled = false ; - m_macFontInstalled = false ; - return TRUE; -} -inline Fixed IntToFixed( int inInt ) - { - return (((SInt32) inInt) << 16); - } -inline int FixedToInt( Fixed inFixed ) - { - return (((SInt32) inFixed) >> 16); - } + CopyBits( GetPortBitMapForCopyBits( sourcePort ) , + GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) , + &srcrect, &dstrect, mode, NULL ) ; + } + DisposeRgn( clipRgn ) ; + } + UnlockPixels( bmappixels ) ; + } + m_macPenInstalled = false ; + m_macBrushInstalled = false ; + m_macFontInstalled = false ; + return TRUE; +} + +inline Fixed IntToFixed( int inInt ) +{ + return (((SInt32) inInt) << 16); +} + +inline int FixedToInt( Fixed inFixed ) +{ + return (((SInt32) inFixed) >> 16); +} void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, double angle) @@ -1239,16 +1296,16 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, return ; wxMacPortSetter helper(this) ; MacInstallFont() ; - wxString text ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - text = wxMacMakeMacStringFromPC( str ) ; - } - else - { - text = str ; - } - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + wxString text ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + text = wxMacMakeMacStringFromPC( str ) ; + } + else + { + text = str ; + } + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( 0 ) { m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); @@ -1256,23 +1313,23 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, m_macAliasWasEnabled = true ; } OSStatus status = noErr ; - TECObjectRef ec; - status = TECCreateConverter(&ec, kTextEncodingMacRoman, kTextEncodingUnicodeDefault); - wxASSERT_MSG( status == noErr , "couldn't start converter" ) ; + TECObjectRef ec; + status = TECCreateConverter(&ec, kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + wxASSERT_MSG( status == noErr , "couldn't start converter" ) ; ByteCount byteOutLen ; ByteCount byteInLen = text.Length() ; ByteCount byteBufferLen = byteInLen *2 ; char* buf = new char[byteBufferLen] ; - status = TECConvertText(ec, (ConstTextPtr)text.c_str() , byteInLen, &byteInLen, - (TextPtr)buf, byteBufferLen, &byteOutLen); - wxASSERT_MSG( status == noErr , "couldn't convert text" ) ; - status = TECDisposeConverter(ec); - wxASSERT_MSG( status == noErr , "couldn't dispose converter" ) ; - ATSUTextLayout atsuLayout ; - UniCharCount chars = byteOutLen / 2 ; + status = TECConvertText(ec, (ConstTextPtr)text.c_str() , byteInLen, &byteInLen, + (TextPtr)buf, byteBufferLen, &byteOutLen); + wxASSERT_MSG( status == noErr , "couldn't convert text" ) ; + status = TECDisposeConverter(ec); + wxASSERT_MSG( status == noErr , "couldn't dispose converter" ) ; + ATSUTextLayout atsuLayout ; + UniCharCount chars = byteOutLen / 2 ; status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 , &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; - wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" ); + wxASSERT_MSG( status == noErr , "couldn't create the layout of the rotated text" ); int iAngle = int( angle ); int drawX = XLOG2DEVMAC(x) ; int drawY = YLOG2DEVMAC(y) ; @@ -1286,708 +1343,720 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, if ( abs(iAngle) > 0 ) { Fixed atsuAngle = IntToFixed( iAngle ) ; - ATSUAttributeTag atsuTags[] = - { - kATSULineRotationTag , - } ; - ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = - { - sizeof( Fixed ) , - } ; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = - { - &atsuAngle , - } ; - status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag), - atsuTags, atsuSizes, atsuValues ) ; - } - status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, - &textBefore , &textAfter, &ascent , &descent ); + ATSUAttributeTag atsuTags[] = + { + kATSULineRotationTag , + } ; + ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + sizeof( Fixed ) , + } ; + ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + &atsuAngle , + } ; + status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag), + atsuTags, atsuSizes, atsuValues ) ; + } + status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, + &textBefore , &textAfter, &ascent , &descent ); drawX += sin(angle/RAD2DEG) * FixedToInt(ascent) ; drawY += cos(angle/RAD2DEG) * FixedToInt(ascent) ; status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, - IntToFixed(drawX) , IntToFixed(drawY) ); - wxASSERT_MSG( status == noErr , "couldn't draw the rotated text" ); + IntToFixed(drawX) , IntToFixed(drawY) ); + wxASSERT_MSG( status == noErr , "couldn't draw the rotated text" ); Rect rect ; - status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, - IntToFixed(drawX) , IntToFixed(drawY) , &rect ); - wxASSERT_MSG( status == noErr , "couldn't measure the rotated text" ); + status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, + IntToFixed(drawX) , IntToFixed(drawY) , &rect ); + wxASSERT_MSG( status == noErr , "couldn't measure the rotated text" ); OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ; CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) ); CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) ); ::ATSUDisposeTextLayout(atsuLayout); delete[] buf ; } + void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) { wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC")); wxMacPortSetter helper(this) ; - long xx = XLOG2DEVMAC(x); - long yy = YLOG2DEVMAC(y); + long xx = XLOG2DEVMAC(x); + long yy = YLOG2DEVMAC(y); #if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( m_font.GetNoAntiAliasing() ) - useDrawThemeText = false ; + bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; + if ( m_font.GetNoAntiAliasing() ) + useDrawThemeText = false ; #endif - MacInstallFont() ; + MacInstallFont() ; if ( 0 ) { m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); SetAntiAliasedTextEnabled(true, 8); m_macAliasWasEnabled = true ; } - FontInfo fi ; - ::GetFontInfo( &fi ) ; + FontInfo fi ; + ::GetFontInfo( &fi ) ; #if TARGET_CARBON - if ( !useDrawThemeText ) + if ( !useDrawThemeText ) #endif - yy += fi.ascent ; - ::MoveTo( xx , yy ); - if ( m_backgroundMode == wxTRANSPARENT ) - { - ::TextMode( srcOr) ; - } - else - { - ::TextMode( srcCopy ) ; - } - const char *text = NULL ; - int length = 0 ; - wxString macText ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - macText = wxMacMakeMacStringFromPC( strtext ) ; - text = macText ; - length = macText.Length() ; - } - else - { - text = strtext ; - length = strtext.Length() ; - } - int laststop = 0 ; - int i = 0 ; - int line = 0 ; - { - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { + yy += fi.ascent ; + ::MoveTo( xx , yy ); + if ( m_backgroundMode == wxTRANSPARENT ) + { + ::TextMode( srcOr) ; + } + else + { + ::TextMode( srcCopy ) ; + } + const char *text = NULL ; + int length = 0 ; + wxString macText ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + macText = wxMacMakeMacStringFromPC( strtext ) ; + text = macText ; + length = macText.Length() ; + } + else + { + text = strtext ; + length = strtext.Length() ; + } + int laststop = 0 ; + int i = 0 ; + int line = 0 ; + { + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { #if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; + if ( useDrawThemeText ) + { + Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - if ( m_backgroundMode != wxTRANSPARENT ) - { - Point bounds={0,0} ; - Rect background = frame ; - SInt16 baseline ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - background.right = background.left + bounds.h ; - background.bottom = background.top + bounds.v ; - ::EraseRect( &background ) ; - } - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - line++ ; + if ( m_backgroundMode != wxTRANSPARENT ) + { + Point bounds={0,0} ; + Rect background = frame ; + SInt16 baseline ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + background.right = background.left + bounds.h ; + background.bottom = background.top + bounds.v ; + ::EraseRect( &background ) ; + } + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + line++ ; } - else + else #endif - { - ::DrawText( text , laststop , i - laststop ) ; - line++ ; - ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); - } - laststop = i+1 ; - } - i++ ; - } + { + ::DrawText( text , laststop , i - laststop ) ; + line++ ; + ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) ); + } + laststop = i+1 ; + } + i++ ; + } #if TARGET_CARBON if ( useDrawThemeText ) - { - Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; + { + Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; if ( m_backgroundMode != wxTRANSPARENT ) { - Point bounds={0,0} ; - Rect background = frame ; - SInt16 baseline ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - background.right = background.left + bounds.h ; - background.bottom = background.top + bounds.v ; - ::EraseRect( &background ) ; + Point bounds={0,0} ; + Rect background = frame ; + SInt16 baseline ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + background.right = background.left + bounds.h ; + background.bottom = background.top + bounds.v ; + ::EraseRect( &background ) ; } - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &frame, - teJustLeft, - nil ); + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); CFRelease( mString ) ; } else #endif { - ::DrawText( text , laststop , i - laststop ) ; + ::DrawText( text , laststop , i - laststop ) ; } - } - ::TextMode( srcOr ) ; + } + ::TextMode( srcOr ) ; } + bool wxDC::CanGetTextExtent() const { - wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); - return true ; + wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); + return true ; } + void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height, - wxCoord *descent, wxCoord *externalLeading , - wxFont *theFont ) const -{ - wxCHECK_RET(Ok(), wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - wxFont formerFont = m_font ; - if ( theFont ) - { - // work around the constness - *((wxFont*)(&m_font)) = *theFont ; - } - MacInstallFont() ; - FontInfo fi ; - ::GetFontInfo( &fi ) ; -#if TARGET_CARBON - bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) - useGetThemeText = false ; + wxCoord *descent, wxCoord *externalLeading , + wxFont *theFont ) const +{ + wxCHECK_RET(Ok(), wxT("Invalid DC")); + wxMacPortSetter helper(this) ; + wxFont formerFont = m_font ; + if ( theFont ) + { + // work around the constness + *((wxFont*)(&m_font)) = *theFont ; + } + MacInstallFont() ; + FontInfo fi ; + ::GetFontInfo( &fi ) ; +#if TARGET_CARBON + bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; + if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) + useGetThemeText = false ; #endif - if ( height ) - *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; - if ( descent ) - *descent =YDEV2LOGREL( fi.descent ); - if ( externalLeading ) - *externalLeading = YDEV2LOGREL( fi.leading ) ; - const char *text = NULL ; - int length = 0 ; - wxString macText ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - macText = wxMacMakeMacStringFromPC( string ) ; - text = macText ; - length = macText.Length() ; - } - else - { - text = string ; - length = string.Length() ; - } - int laststop = 0 ; - int i = 0 ; - int curwidth = 0 ; - if ( width ) - { - *width = 0 ; - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { - if ( height ) - *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; + if ( height ) + *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; + if ( descent ) + *descent =YDEV2LOGREL( fi.descent ); + if ( externalLeading ) + *externalLeading = YDEV2LOGREL( fi.leading ) ; + const char *text = NULL ; + int length = 0 ; + wxString macText ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + macText = wxMacMakeMacStringFromPC( string ) ; + text = macText ; + length = macText.Length() ; + } + else + { + text = string ; + length = string.Length() ; + } + int laststop = 0 ; + int i = 0 ; + int curwidth = 0 ; + if ( width ) + { + *width = 0 ; + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { + if ( height ) + *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; #if TARGET_CARBON if ( useGetThemeText ) { Point bounds={0,0} ; SInt16 baseline ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - CFRelease( mString ) ; - curwidth = bounds.h ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + curwidth = bounds.h ; } else #endif { - curwidth = ::TextWidth( text , laststop , i - laststop ) ; - } - if ( curwidth > *width ) - *width = XDEV2LOGREL( curwidth ) ; - laststop = i+1 ; - } - i++ ; - } - + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + } + if ( curwidth > *width ) + *width = XDEV2LOGREL( curwidth ) ; + laststop = i+1 ; + } + i++ ; + } + #if TARGET_CARBON if ( useGetThemeText ) { Point bounds={0,0} ; SInt16 baseline ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - CFRelease( mString ) ; - curwidth = bounds.h ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + curwidth = bounds.h ; } else #endif { - curwidth = ::TextWidth( text , laststop , i - laststop ) ; - } - if ( curwidth > *width ) - *width = XDEV2LOGREL( curwidth ) ; - } - if ( theFont ) - { - // work around the constness - *((wxFont*)(&m_font)) = formerFont ; - m_macFontInstalled = false ; - } + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + } + if ( curwidth > *width ) + *width = XDEV2LOGREL( curwidth ) ; + } + if ( theFont ) + { + // work around the constness + *((wxFont*)(&m_font)) = formerFont ; + m_macFontInstalled = false ; + } } + wxCoord wxDC::GetCharWidth(void) const { wxCHECK_MSG(Ok(), 1, wxT("Invalid DC")); - wxMacPortSetter helper(this) ; - MacInstallFont() ; + wxMacPortSetter helper(this) ; + MacInstallFont() ; int width = 0 ; #if TARGET_CARBON - bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; - if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) - useGetThemeText = false ; + bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; + if ( ((wxFont*)&m_font)->GetNoAntiAliasing() ) + useGetThemeText = false ; #endif - char text[] = "H" ; + char text[] = "H" ; #if TARGET_CARBON if ( useGetThemeText ) { Point bounds={0,0} ; SInt16 baseline ; CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ; - ::GetThemeTextDimensions( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &bounds, - &baseline ); - CFRelease( mString ) ; - width = bounds.h ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + width = bounds.h ; } else #endif { - width = ::TextWidth( text , 0 , 1 ) ; - } - return YDEV2LOGREL(width) ; + width = ::TextWidth( text , 0 , 1 ) ; + } + return YDEV2LOGREL(width) ; } + wxCoord wxDC::GetCharHeight(void) const { wxCHECK_MSG(Ok(), 1, wxT("Invalid DC")); wxMacPortSetter helper(this) ; - MacInstallFont() ; - FontInfo fi ; - ::GetFontInfo( &fi ) ; - return YDEV2LOGREL( fi.descent + fi.ascent ); + MacInstallFont() ; + FontInfo fi ; + ::GetFontInfo( &fi ) ; + return YDEV2LOGREL( fi.descent + fi.ascent ); } + void wxDC::Clear(void) { wxCHECK_RET(Ok(), wxT("Invalid DC")); wxMacPortSetter helper(this) ; - Rect rect = { -31000 , -31000 , 31000 , 31000 } ; - if (m_backgroundBrush.GetStyle() != wxTRANSPARENT) - { - ::PenNormal() ; - //MacInstallBrush() ; + Rect rect = { -31000 , -31000 , 31000 , 31000 } ; + if (m_backgroundBrush.GetStyle() != wxTRANSPARENT) + { + ::PenNormal() ; + //MacInstallBrush() ; MacSetupBackgroundForCurrentPort( m_backgroundBrush ) ; - ::EraseRect( &rect ) ; - } + ::EraseRect( &rect ) ; + } } + void wxDC::MacInstallFont() const { wxCHECK_RET(Ok(), wxT("Invalid DC")); -// if ( m_macFontInstalled ) -// return ; - Pattern blackColor ; - MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(m_scaleY * font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - m_macFontInstalled = true ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; - RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); - RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); - ::RGBForeColor( &forecolor ); - ::RGBBackColor( &backcolor ); - } - else - { + // if ( m_macFontInstalled ) + // return ; + Pattern blackColor ; + MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( short(m_scaleY * font->m_macFontSize) ) ; + ::TextFace( font->m_macFontStyle ) ; + m_macFontInstalled = true ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); + RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); + ::RGBForeColor( &forecolor ); + ::RGBBackColor( &backcolor ); + } + else + { FontFamilyID fontId ; - Str255 fontName ; - SInt16 fontSize ; - Style fontStyle ; - GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetFNum( fontName, &fontId ); - ::TextFont( fontId ) ; - ::TextSize( short(m_scaleY * fontSize) ) ; - ::TextFace( fontStyle ) ; - // todo reset after spacing changes - or store the current spacing somewhere - m_macFontInstalled = true ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; - RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); - RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); - ::RGBForeColor( &forecolor ); - ::RGBBackColor( &backcolor ); - } - short mode = patCopy ; - // todo : - switch( m_logicalFunction ) - { - case wxCOPY: // src - mode = patCopy ; - break ; - case wxINVERT: // NOT dst - ::PenPat(GetQDGlobalsBlack(&blackColor)); - mode = patXor ; - break ; - case wxXOR: // src XOR dst - mode = patXor ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - mode = notPatOr ; - break ; - case wxSRC_INVERT: // (NOT src) - mode = notPatCopy ; - break ; - // unsupported TODO - case wxCLEAR: // 0 - case wxAND_REVERSE:// src AND (NOT dst) - case wxAND: // src AND dst - case wxAND_INVERT: // (NOT src) AND dst - case wxNO_OP: // dst - case wxNOR: // (NOT src) AND (NOT dst) - case wxEQUIV: // (NOT src) XOR dst - case wxOR_INVERT: // (NOT src) OR dst - case wxNAND: // (NOT src) OR (NOT dst) - case wxOR: // src OR dst - case wxSET: // 1 -// case wxSRC_OR: // source _bitmap_ OR destination -// case wxSRC_AND: // source _bitmap_ AND destination - break ; - } - ::PenMode( mode ) ; + ::TextFont( fontId ) ; + ::TextSize( short(m_scaleY * fontSize) ) ; + ::TextFace( fontStyle ) ; + // todo reset after spacing changes - or store the current spacing somewhere + m_macFontInstalled = true ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); + RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); + ::RGBForeColor( &forecolor ); + ::RGBBackColor( &backcolor ); + } + short mode = patCopy ; + // todo : + switch( m_logicalFunction ) + { + case wxCOPY: // src + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + ::PenPat(GetQDGlobalsBlack(&blackColor)); + mode = patXor ; + break ; + case wxXOR: // src XOR dst + mode = patXor ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + mode = notPatOr ; + break ; + case wxSRC_INVERT: // (NOT src) + mode = notPatCopy ; + break ; + // unsupported TODO + case wxCLEAR: // 0 + case wxAND_REVERSE:// src AND (NOT dst) + case wxAND: // src AND dst + case wxAND_INVERT: // (NOT src) AND dst + case wxNO_OP: // dst + case wxNOR: // (NOT src) AND (NOT dst) + case wxEQUIV: // (NOT src) XOR dst + case wxOR_INVERT: // (NOT src) OR dst + case wxNAND: // (NOT src) OR (NOT dst) + case wxOR: // src OR dst + case wxSET: // 1 + // case wxSRC_OR: // source _bitmap_ OR destination + // case wxSRC_AND: // source _bitmap_ AND destination + break ; + } + ::PenMode( mode ) ; OSStatus status = noErr ; Fixed atsuSize = IntToFixed( int(m_scaleY * font->m_macFontSize) ) ; Style qdStyle = font->m_macFontStyle ; - ATSUFontID atsuFont = font->m_macATSUFontID ; + ATSUFontID atsuFont = font->m_macATSUFontID ; status = ::ATSUCreateStyle(&(ATSUStyle)m_macATSUIStyle) ; - wxASSERT_MSG( status == noErr , "couldn't create ATSU style" ) ; - ATSUAttributeTag atsuTags[] = - { - kATSUFontTag , - kATSUSizeTag , -// kATSUColorTag , -// kATSUBaselineClassTag , - kATSUVerticalCharacterTag, - kATSUQDBoldfaceTag , - kATSUQDItalicTag , - kATSUQDUnderlineTag , - kATSUQDCondensedTag , - kATSUQDExtendedTag , - } ; + wxASSERT_MSG( status == noErr , "couldn't create ATSU style" ) ; + ATSUAttributeTag atsuTags[] = + { + kATSUFontTag , + kATSUSizeTag , + // kATSUColorTag , + // kATSUBaselineClassTag , + kATSUVerticalCharacterTag, + kATSUQDBoldfaceTag , + kATSUQDItalicTag , + kATSUQDUnderlineTag , + kATSUQDCondensedTag , + kATSUQDExtendedTag , + } ; ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = { sizeof( ATSUFontID ) , - sizeof( Fixed ) , -// sizeof( RGBColor ) , -// sizeof( BslnBaselineClass ) , - sizeof( ATSUVerticalCharacterType), - sizeof( Boolean ) , - sizeof( Boolean ) , - sizeof( Boolean ) , - sizeof( Boolean ) , - sizeof( Boolean ) , + sizeof( Fixed ) , + // sizeof( RGBColor ) , + // sizeof( BslnBaselineClass ) , + sizeof( ATSUVerticalCharacterType), + sizeof( Boolean ) , + sizeof( Boolean ) , + sizeof( Boolean ) , + sizeof( Boolean ) , + sizeof( Boolean ) , } ; Boolean kTrue = true ; Boolean kFalse = false ; BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ; ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; - ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = - { - &atsuFont , - &atsuSize , -// &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) , -// &kBaselineDefault , - &kHorizontal, - (qdStyle & bold) ? &kTrue : &kFalse , - (qdStyle & italic) ? &kTrue : &kFalse , - (qdStyle & underline) ? &kTrue : &kFalse , - (qdStyle & condense) ? &kTrue : &kFalse , - (qdStyle & extend) ? &kTrue : &kFalse , - } ; - status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag), - atsuTags, atsuSizes, atsuValues); - wxASSERT_MSG( status == noErr , "couldn't set create ATSU style" ) ; + ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = + { + &atsuFont , + &atsuSize , + // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) , + // &kBaselineDefault , + &kHorizontal, + (qdStyle & bold) ? &kTrue : &kFalse , + (qdStyle & italic) ? &kTrue : &kFalse , + (qdStyle & underline) ? &kTrue : &kFalse , + (qdStyle & condense) ? &kTrue : &kFalse , + (qdStyle & extend) ? &kTrue : &kFalse , + } ; + status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag), + atsuTags, atsuSizes, atsuValues); + wxASSERT_MSG( status == noErr , "couldn't set create ATSU style" ) ; } + Pattern gHatchPatterns[] = { - { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } }, - { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } }, - { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } }, - { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } }, - { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } }, - { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } }, - { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } + { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } }, + { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } }, + { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } }, + { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } }, + { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } }, + { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } }, + { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } } ; + static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern) { - int theIndex = 1 ; - switch(hatchStyle) - { - case wxBDIAGONAL_HATCH: - theIndex = 2; - break; - case wxFDIAGONAL_HATCH: - theIndex = 3; - break; - case wxCROSS_HATCH: - theIndex = 4; - break; - case wxHORIZONTAL_HATCH: - theIndex = 5; - break; - case wxVERTICAL_HATCH: - theIndex = 6; - break; - case wxCROSSDIAG_HATCH: - theIndex = 7; - break; - default: - theIndex = 1; // solid pattern - break; - } - *pattern = gHatchPatterns[theIndex-1] ; + int theIndex = 1 ; + switch(hatchStyle) + { + case wxBDIAGONAL_HATCH: + theIndex = 2; + break; + case wxFDIAGONAL_HATCH: + theIndex = 3; + break; + case wxCROSS_HATCH: + theIndex = 4; + break; + case wxHORIZONTAL_HATCH: + theIndex = 5; + break; + case wxVERTICAL_HATCH: + theIndex = 6; + break; + case wxCROSSDIAG_HATCH: + theIndex = 7; + break; + default: + theIndex = 1; // solid pattern + break; + } + *pattern = gHatchPatterns[theIndex-1] ; } + void wxDC::MacInstallPen() const { wxCHECK_RET(Ok(), wxT("Invalid DC")); - Pattern blackColor; -// if ( m_macPenInstalled ) -// return ; - RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); - RGBColor backcolor = MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()); - ::RGBForeColor( &forecolor ); - ::RGBBackColor( &backcolor ); - ::PenNormal() ; - int penWidth = m_pen.GetWidth() * (int) m_scaleX ; - // null means only one pixel, at whatever resolution - if ( penWidth == 0 ) - penWidth = 1 ; - ::PenSize(penWidth, penWidth); - int penStyle = m_pen.GetStyle(); - if (penStyle == wxSOLID) - { - ::PenPat(GetQDGlobalsBlack(&blackColor)); - } - else if (IS_HATCH(penStyle)) - { - Pattern pat ; - wxMacGetHatchPattern(penStyle, &pat); - ::PenPat(&pat); - } - else - { - Pattern pat = *GetQDGlobalsBlack(&blackColor) ; - switch( penStyle ) - { - case wxDOT : - for ( int i = 0 ; i < 8 ; ++i ) - { - pat.pat[i] = 0xCC ; - } - break ; - case wxLONG_DASH : - for ( int i = 0 ; i < 8 ; ++i ) - { - pat.pat[i] = 0xFE ; - } - break ; - case wxSHORT_DASH : - for ( int i = 0 ; i < 8 ; ++i ) - { - pat.pat[i] = 0xEE ; - } - break ; - case wxDOT_DASH : + Pattern blackColor; + // if ( m_macPenInstalled ) + // return ; + RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel()); + RGBColor backcolor = MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()); + ::RGBForeColor( &forecolor ); + ::RGBBackColor( &backcolor ); + ::PenNormal() ; + int penWidth = m_pen.GetWidth() * (int) m_scaleX ; + // null means only one pixel, at whatever resolution + if ( penWidth == 0 ) + penWidth = 1 ; + ::PenSize(penWidth, penWidth); + int penStyle = m_pen.GetStyle(); + if (penStyle == wxSOLID) + { + ::PenPat(GetQDGlobalsBlack(&blackColor)); + } + else if (IS_HATCH(penStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(penStyle, &pat); + ::PenPat(&pat); + } + else + { + Pattern pat = *GetQDGlobalsBlack(&blackColor) ; + switch( penStyle ) + { + case wxDOT : + for ( int i = 0 ; i < 8 ; ++i ) + { + pat.pat[i] = 0xCC ; + } + break ; + case wxLONG_DASH : + for ( int i = 0 ; i < 8 ; ++i ) + { + pat.pat[i] = 0xFE ; + } + break ; + case wxSHORT_DASH : + for ( int i = 0 ; i < 8 ; ++i ) + { + pat.pat[i] = 0xEE ; + } + break ; + case wxDOT_DASH : + for ( int i = 0 ; i < 8 ; ++i ) + { + pat.pat[i] = 0x6F ; + } + break ; + case wxUSER_DASH : + { + wxDash* dash ; + m_pen.GetDashes(&dash) ; + // right now we don't allocate larger pixmaps + // int number = + m_pen.GetDashes(&dash) ; for ( int i = 0 ; i < 8 ; ++i ) { - pat.pat[i] = 0x6F ; + pat.pat[i] = dash[0] ; } - break ; - case wxUSER_DASH : - { - wxDash* dash ; - m_pen.GetDashes(&dash) ; - // right now we don't allocate larger pixmaps - // int number = - m_pen.GetDashes(&dash) ; - for ( int i = 0 ; i < 8 ; ++i ) - { - pat.pat[i] = dash[0] ; - } - } - break ; - } - ::PenPat(&pat); - } - short mode = patCopy ; - // todo : - switch( m_logicalFunction ) - { - case wxCOPY: // only foreground color, leave background (thus not patCopy) - mode = patOr ; - break ; - case wxINVERT: // NOT dst -// ::PenPat(GetQDGlobalsBlack(&blackColor)); - mode = patXor ; - break ; - case wxXOR: // src XOR dst - mode = patXor ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - mode = notPatOr ; - break ; - case wxSRC_INVERT: // (NOT src) - mode = notPatCopy ; - break ; - // unsupported TODO - case wxCLEAR: // 0 - case wxAND_REVERSE:// src AND (NOT dst) - case wxAND: // src AND dst - case wxAND_INVERT: // (NOT src) AND dst - case wxNO_OP: // dst - case wxNOR: // (NOT src) AND (NOT dst) - case wxEQUIV: // (NOT src) XOR dst - case wxOR_INVERT: // (NOT src) OR dst - case wxNAND: // (NOT src) OR (NOT dst) - case wxOR: // src OR dst - case wxSET: // 1 -// case wxSRC_OR: // source _bitmap_ OR destination -// case wxSRC_AND: // source _bitmap_ AND destination - break ; - } - ::PenMode( mode ) ; - m_macPenInstalled = true ; - m_macBrushInstalled = false ; - m_macFontInstalled = false ; + } + break ; + } + ::PenPat(&pat); + } + short mode = patCopy ; + // todo : + switch( m_logicalFunction ) + { + case wxCOPY: // only foreground color, leave background (thus not patCopy) + mode = patOr ; + break ; + case wxINVERT: // NOT dst + // ::PenPat(GetQDGlobalsBlack(&blackColor)); + mode = patXor ; + break ; + case wxXOR: // src XOR dst + mode = patXor ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + mode = notPatOr ; + break ; + case wxSRC_INVERT: // (NOT src) + mode = notPatCopy ; + break ; + // unsupported TODO + case wxCLEAR: // 0 + case wxAND_REVERSE:// src AND (NOT dst) + case wxAND: // src AND dst + case wxAND_INVERT: // (NOT src) AND dst + case wxNO_OP: // dst + case wxNOR: // (NOT src) AND (NOT dst) + case wxEQUIV: // (NOT src) XOR dst + case wxOR_INVERT: // (NOT src) OR dst + case wxNAND: // (NOT src) OR (NOT dst) + case wxOR: // src OR dst + case wxSET: // 1 + // case wxSRC_OR: // source _bitmap_ OR destination + // case wxSRC_AND: // source _bitmap_ AND destination + break ; + } + ::PenMode( mode ) ; + m_macPenInstalled = true ; + m_macBrushInstalled = false ; + m_macFontInstalled = false ; } + void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background ) { Pattern whiteColor ; switch( background.MacGetBrushKind() ) { - case kwxMacBrushTheme : + case kwxMacBrushTheme : { - ::SetThemeBackground( background.GetMacTheme() , wxDisplayDepth() , true ) ; - break ; + ::SetThemeBackground( background.GetMacTheme() , wxDisplayDepth() , true ) ; + break ; } - case kwxMacBrushThemeBackground : + case kwxMacBrushThemeBackground : { - Rect extent ; - ThemeBackgroundKind bg = background.GetMacThemeBackground( &extent ) ; - ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ; - break ; + Rect extent ; + ThemeBackgroundKind bg = background.GetMacThemeBackground( &extent ) ; + ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ; + break ; } - case kwxMacBrushColour : + case kwxMacBrushColour : { - ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) ); - int brushStyle = background.GetStyle(); - if (brushStyle == wxSOLID) - ::BackPat(GetQDGlobalsWhite(&whiteColor)); - else if (IS_HATCH(brushStyle)) - { - Pattern pat ; - wxMacGetHatchPattern(brushStyle, &pat); - ::BackPat(&pat); - } - else - { - ::BackPat(GetQDGlobalsWhite(&whiteColor)); - } - break ; + ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) ); + int brushStyle = background.GetStyle(); + if (brushStyle == wxSOLID) + ::BackPat(GetQDGlobalsWhite(&whiteColor)); + else if (IS_HATCH(brushStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(brushStyle, &pat); + ::BackPat(&pat); + } + else + { + ::BackPat(GetQDGlobalsWhite(&whiteColor)); + } + break ; } } } + void wxDC::MacInstallBrush() const { wxCHECK_RET(Ok(), wxT("Invalid DC")); - Pattern blackColor ; -// if ( m_macBrushInstalled ) -// return ; - // foreground - bool backgroundTransparent = (GetBackgroundMode() == wxTRANSPARENT) ; - ::RGBForeColor( &MAC_WXCOLORREF( m_brush.GetColour().GetPixel()) ); - ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()) ); - int brushStyle = m_brush.GetStyle(); - if (brushStyle == wxSOLID) - { - ::PenPat(GetQDGlobalsBlack(&blackColor)); - } - else if (IS_HATCH(brushStyle)) - { - Pattern pat ; - wxMacGetHatchPattern(brushStyle, &pat); - ::PenPat(&pat); - } - else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) - { - // we force this in order to be compliant with wxMSW - backgroundTransparent = false ; - // for these the text fore (and back for MASK_OPAQUE) colors are used - wxBitmap* bitmap = m_brush.GetStipple() ; - int width = bitmap->GetWidth() ; - int height = bitmap->GetHeight() ; + Pattern blackColor ; + // if ( m_macBrushInstalled ) + // return ; + // foreground + bool backgroundTransparent = (GetBackgroundMode() == wxTRANSPARENT) ; + ::RGBForeColor( &MAC_WXCOLORREF( m_brush.GetColour().GetPixel()) ); + ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()) ); + int brushStyle = m_brush.GetStyle(); + if (brushStyle == wxSOLID) + { + ::PenPat(GetQDGlobalsBlack(&blackColor)); + } + else if (IS_HATCH(brushStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(brushStyle, &pat); + ::PenPat(&pat); + } + else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE ) + { + // we force this in order to be compliant with wxMSW + backgroundTransparent = false ; + // for these the text fore (and back for MASK_OPAQUE) colors are used + wxBitmap* bitmap = m_brush.GetStipple() ; + int width = bitmap->GetWidth() ; + int height = bitmap->GetHeight() ; GWorldPtr gw = NULL ; - if ( m_brush.GetStyle() == wxSTIPPLE ) - gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ; - else - gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ; + if ( m_brush.GetStyle() == wxSTIPPLE ) + gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ; + else + gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ; PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ; LockPixels( gwpixmaphandle ) ; - bool isMonochrome = !IsPortColor( gw ) ; + bool isMonochrome = !IsPortColor( gw ) ; if ( !isMonochrome ) { if ( (**gwpixmaphandle).pixelSize == 1 ) isMonochrome = true ; } if ( isMonochrome && width == 8 && height == 8 ) - { - ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ); - ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ); + { + ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ); + ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ); BitMap* gwbitmap = (BitMap*) *gwpixmaphandle ; // since the color depth is 1 it is a BitMap UInt8 *gwbits = (UInt8*) gwbitmap->baseAddr ; int alignment = gwbitmap->rowBytes & 0x7FFF ; @@ -1998,91 +2067,92 @@ void wxDC::MacInstallBrush() const } UnlockPixels( GetGWorldPixMap( gw ) ) ; ::PenPat( &pat ) ; - } - else - { - // this will be the code to handle power of 2 patterns, we will have to arrive at a nice - // caching scheme before putting this into production - Handle image; - long imageSize; - PixPatHandle pixpat = NewPixPat() ; - CopyPixMap(gwpixmaphandle, (**pixpat).patMap); + } + else + { + // this will be the code to handle power of 2 patterns, we will have to arrive at a nice + // caching scheme before putting this into production + Handle image; + long imageSize; + PixPatHandle pixpat = NewPixPat() ; + CopyPixMap(gwpixmaphandle, (**pixpat).patMap); imageSize = GetPixRowBytes((**pixpat).patMap) * - ((**(**pixpat).patMap).bounds.bottom - - (**(**pixpat).patMap).bounds.top); + ((**(**pixpat).patMap).bounds.bottom - + (**(**pixpat).patMap).bounds.top); PtrToHand( (**gwpixmaphandle).baseAddr, &image, imageSize ); (**pixpat).patData = image; if ( isMonochrome ) { - CTabHandle ctable = ((**((**pixpat).patMap)).pmTable) ; - ColorSpecPtr ctspec = (ColorSpecPtr) &(**ctable).ctTable ; - if ( ctspec[0].rgb.red == 0x0000 ) - { - ctspec[1].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; - ctspec[0].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; - } - else - { - ctspec[0].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; - ctspec[1].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; - } - ::CTabChanged( ctable ) ; + CTabHandle ctable = ((**((**pixpat).patMap)).pmTable) ; + ColorSpecPtr ctspec = (ColorSpecPtr) &(**ctable).ctTable ; + if ( ctspec[0].rgb.red == 0x0000 ) + { + ctspec[1].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; + ctspec[0].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; + } + else + { + ctspec[0].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ; + ctspec[1].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ; + } + ::CTabChanged( ctable ) ; } ::PenPixPat(pixpat); m_macForegroundPixMap = pixpat ; - } - UnlockPixels( gwpixmaphandle ) ; - } + } + UnlockPixels( gwpixmaphandle ) ; + } else { - ::PenPat(GetQDGlobalsBlack(&blackColor)); - } - short mode = patCopy ; - switch( m_logicalFunction ) - { - case wxCOPY: // src - if ( backgroundTransparent ) - mode = patOr ; - else - mode = patCopy ; - break ; - case wxINVERT: // NOT dst - if ( !backgroundTransparent ) - { - ::PenPat(GetQDGlobalsBlack(&blackColor)); - } - mode = patXor ; - break ; - case wxXOR: // src XOR dst - mode = patXor ; - break ; - case wxOR_REVERSE: // src OR (NOT dst) - mode = notPatOr ; - break ; - case wxSRC_INVERT: // (NOT src) - mode = notPatCopy ; - break ; - // unsupported TODO - case wxCLEAR: // 0 - case wxAND_REVERSE:// src AND (NOT dst) - case wxAND: // src AND dst - case wxAND_INVERT: // (NOT src) AND dst - case wxNO_OP: // dst - case wxNOR: // (NOT src) AND (NOT dst) - case wxEQUIV: // (NOT src) XOR dst - case wxOR_INVERT: // (NOT src) OR dst - case wxNAND: // (NOT src) OR (NOT dst) - case wxOR: // src OR dst - case wxSET: // 1 -// case wxSRC_OR: // source _bitmap_ OR destination -// case wxSRC_AND: // source _bitmap_ AND destination - break ; - } - ::PenMode( mode ) ; - m_macBrushInstalled = true ; - m_macPenInstalled = false ; - m_macFontInstalled = false ; + ::PenPat(GetQDGlobalsBlack(&blackColor)); + } + short mode = patCopy ; + switch( m_logicalFunction ) + { + case wxCOPY: // src + if ( backgroundTransparent ) + mode = patOr ; + else + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + if ( !backgroundTransparent ) + { + ::PenPat(GetQDGlobalsBlack(&blackColor)); + } + mode = patXor ; + break ; + case wxXOR: // src XOR dst + mode = patXor ; + break ; + case wxOR_REVERSE: // src OR (NOT dst) + mode = notPatOr ; + break ; + case wxSRC_INVERT: // (NOT src) + mode = notPatCopy ; + break ; + // unsupported TODO + case wxCLEAR: // 0 + case wxAND_REVERSE:// src AND (NOT dst) + case wxAND: // src AND dst + case wxAND_INVERT: // (NOT src) AND dst + case wxNO_OP: // dst + case wxNOR: // (NOT src) AND (NOT dst) + case wxEQUIV: // (NOT src) XOR dst + case wxOR_INVERT: // (NOT src) OR dst + case wxNAND: // (NOT src) OR (NOT dst) + case wxOR: // src OR dst + case wxSET: // 1 + // case wxSRC_OR: // source _bitmap_ OR destination + // case wxSRC_AND: // source _bitmap_ AND destination + break ; + } + ::PenMode( mode ) ; + m_macBrushInstalled = true ; + m_macPenInstalled = false ; + m_macFontInstalled = false ; } + // --------------------------------------------------------------------------- // coordinates transformations // --------------------------------------------------------------------------- @@ -2091,30 +2161,37 @@ wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const { return ((wxDC *)this)->XDEV2LOG(x); } + wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const { return ((wxDC *)this)->YDEV2LOG(y); } + wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const { return ((wxDC *)this)->XDEV2LOGREL(x); } + wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const { return ((wxDC *)this)->YDEV2LOGREL(y); } + wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const { return ((wxDC *)this)->XLOG2DEV(x); } + wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const { return ((wxDC *)this)->YLOG2DEV(y); } + wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const { return ((wxDC *)this)->XLOG2DEVREL(x); } + wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const { return ((wxDC *)this)->YLOG2DEVREL(y); diff --git a/src/mac/dcclient.cpp b/src/mac/dcclient.cpp index 1a878857f7..8e85da2cf5 100644 --- a/src/mac/dcclient.cpp +++ b/src/mac/dcclient.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -49,24 +49,24 @@ wxWindowDC::wxWindowDC() wxWindowDC::wxWindowDC(wxWindow *the_canvas) { - wxTopLevelWindowMac* rootwindow = the_canvas->MacGetTopLevelWindow() ; - WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; - - int x , y ; - x = y = 0 ; - the_canvas->MacWindowToRootWindow( &x , &y ) ; - m_macLocalOrigin.x = x ; - m_macLocalOrigin.y = y ; - CopyRgn( (RgnHandle) the_canvas->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; - m_macPort = UMAGetWindowPort( windowref ) ; - m_minY = m_minX = 0; - wxSize size = the_canvas->GetSize() ; - m_maxX = size.x ; - m_maxY = size.y ; - - m_ok = TRUE ; + wxTopLevelWindowMac* rootwindow = the_canvas->MacGetTopLevelWindow() ; + WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; + + int x , y ; + x = y = 0 ; + the_canvas->MacWindowToRootWindow( &x , &y ) ; + m_macLocalOrigin.x = x ; + m_macLocalOrigin.y = y ; + CopyRgn( (RgnHandle) the_canvas->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; + m_macPort = UMAGetWindowPort( windowref ) ; + m_minY = m_minX = 0; + wxSize size = the_canvas->GetSize() ; + m_maxX = size.x ; + m_maxY = size.y ; + + m_ok = TRUE ; SetBackground(the_canvas->MacGetBackgroundBrush()); } @@ -84,30 +84,30 @@ wxClientDC::wxClientDC() wxClientDC::wxClientDC(wxWindow *window) { - wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; - if (!rootwindow) - return; - WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; - wxPoint origin = window->GetClientAreaOrigin() ; - wxSize size = window->GetClientSize() ; - int x , y ; - x = origin.x ; - y = origin.y ; - window->MacWindowToRootWindow( &x , &y ) ; - m_macLocalOrigin.x = x ; - m_macLocalOrigin.y = y ; - SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; - SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; - m_macPort = UMAGetWindowPort( windowref ) ; - m_minY = m_minX = 0; - m_maxX = size.x ; - m_maxY = size.y ; - m_ok = TRUE ; - SetBackground(window->MacGetBackgroundBrush()); - SetFont( window->GetFont() ) ; + wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; + if (!rootwindow) + return; + WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; + wxPoint origin = window->GetClientAreaOrigin() ; + wxSize size = window->GetClientSize() ; + int x , y ; + x = origin.x ; + y = origin.y ; + window->MacWindowToRootWindow( &x , &y ) ; + m_macLocalOrigin.x = x ; + m_macLocalOrigin.y = y ; + SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; + SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; + m_macPort = UMAGetWindowPort( windowref ) ; + m_minY = m_minX = 0; + m_maxX = size.x ; + m_maxY = size.y ; + m_ok = TRUE ; + SetBackground(window->MacGetBackgroundBrush()); + SetFont( window->GetFont() ) ; } wxClientDC::~wxClientDC() @@ -124,29 +124,29 @@ wxPaintDC::wxPaintDC() wxPaintDC::wxPaintDC(wxWindow *window) { - wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; - WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; - wxPoint origin = window->GetClientAreaOrigin() ; - wxSize size = window->GetClientSize() ; - int x , y ; - x = origin.x ; - y = origin.y ; - window->MacWindowToRootWindow( &x , &y ) ; - m_macLocalOrigin.x = x ; - m_macLocalOrigin.y = y ; - SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; - SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; - SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; - m_macPort = UMAGetWindowPort( windowref ) ; - m_minY = m_minX = 0; - m_maxX = size.x ; - m_maxY = size.y ; - m_ok = TRUE ; - SetBackground(window->MacGetBackgroundBrush()); - SetFont( window->GetFont() ) ; + wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ; + WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ; + wxPoint origin = window->GetClientAreaOrigin() ; + wxSize size = window->GetClientSize() ; + int x , y ; + x = origin.x ; + y = origin.y ; + window->MacWindowToRootWindow( &x , &y ) ; + m_macLocalOrigin.x = x ; + m_macLocalOrigin.y = y ; + SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ; + SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ; + SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; + m_macPort = UMAGetWindowPort( windowref ) ; + m_minY = m_minX = 0; + m_maxX = size.x ; + m_maxY = size.y ; + m_ok = TRUE ; + SetBackground(window->MacGetBackgroundBrush()); + SetFont( window->GetFont() ) ; } wxPaintDC::~wxPaintDC() diff --git a/src/mac/dcmemory.cpp b/src/mac/dcmemory.cpp index d4db46174e..e850a59e4d 100644 --- a/src/mac/dcmemory.cpp +++ b/src/mac/dcmemory.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -23,78 +23,78 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) wxMemoryDC::wxMemoryDC(void) - : m_selected() +: m_selected() { - m_ok = TRUE; + m_ok = TRUE; SetBackground(*wxWHITE_BRUSH); SetBrush(*wxWHITE_BRUSH); SetPen(*wxBLACK_PEN); - m_ok = FALSE; + m_ok = FALSE; }; wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) - : m_selected() +: m_selected() { - m_ok = TRUE; + m_ok = TRUE; SetBackground(*wxWHITE_BRUSH); SetBrush(*wxWHITE_BRUSH); SetPen(*wxBLACK_PEN); - m_ok = FALSE; + m_ok = FALSE; }; wxMemoryDC::~wxMemoryDC() { - if ( m_selected.Ok() ) - { - UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); - } + if ( m_selected.Ok() ) + { + UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); + } }; void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) { - if ( m_selected.Ok() ) - { - UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); - } + if ( m_selected.Ok() ) + { + UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); + } m_selected = bitmap; if (m_selected.Ok()) { - if ( m_selected.GetHBITMAP() ) - { - m_macPort = (GrafPtr) m_selected.GetHBITMAP() ; - LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ; - wxMask * mask = bitmap.GetMask() ; - if ( mask ) - { - m_macMask = mask->GetMaskBitmap() ; - } - SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; - m_ok = TRUE ; - } - else - { - m_ok = FALSE; - } - } - else - { - m_ok = FALSE; - } + if ( m_selected.GetHBITMAP() ) + { + m_macPort = (GrafPtr) m_selected.GetHBITMAP() ; + LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ; + wxMask * mask = bitmap.GetMask() ; + if ( mask ) + { + m_macMask = mask->GetMaskBitmap() ; + } + SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; + m_ok = TRUE ; + } + else + { + m_ok = FALSE; + } + } + else + { + m_ok = FALSE; + } } void wxMemoryDC::DoGetSize( int *width, int *height ) const { - if (m_selected.Ok()) - { - if (width) (*width) = m_selected.GetWidth(); - if (height) (*height) = m_selected.GetHeight(); - } - else - { - if (width) (*width) = 0; - if (height) (*height) = 0; - } + if (m_selected.Ok()) + { + if (width) (*width) = m_selected.GetWidth(); + if (height) (*height) = m_selected.GetHeight(); + } + else + { + if (width) (*width) = 0; + if (height) (*height) = 0; + } } diff --git a/src/mac/dcprint.cpp b/src/mac/dcprint.cpp index 6c32de8ad0..2e82243834 100644 --- a/src/mac/dcprint.cpp +++ b/src/mac/dcprint.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -46,172 +46,172 @@ GrafPtr macPrintFormerPort = NULL ; wxPrinterDC::wxPrinterDC(const wxPrintData& printdata) { - OSStatus err ; - wxString message ; - - m_printData = printdata ; - m_printData.ConvertToNative() ; + OSStatus err ; + wxString message ; + + m_printData = printdata ; + m_printData.ConvertToNative() ; #if TARGET_CARBON && PM_USE_SESSION_APIS - err = UMAPrOpen(&m_macPrintSessionPort) ; - if ( err != noErr || m_macPrintSessionPort == kPMNoData ) + err = UMAPrOpen(&m_macPrintSessionPort) ; + if ( err != noErr || m_macPrintSessionPort == kPMNoData ) #else - err = UMAPrOpen(NULL) ; - if ( err != noErr ) + err = UMAPrOpen(NULL) ; + if ( err != noErr ) #endif - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose(&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose(NULL) ; + UMAPrClose(NULL) ; #endif - m_ok = FALSE; - return; - } - + m_ok = FALSE; + return; + } + #if !TARGET_CARBON - if ( ::PrValidate( (THPrint) m_printData.m_macPrintSettings ) ) - { - ::PrStlDialog( (THPrint) m_printData.m_macPrintSettings ) ; - // the driver has changed in the mean time, should we pop up a page setup dialog ? - } - err = PrError() ; - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - UMAPrClose(NULL) ; - m_ok = FALSE; - return; - } - ::GetPort( &macPrintFormerPort ) ; - m_macPrintSessionPort = ::PrOpenDoc( (THPrint) m_printData.m_macPrintSettings , NULL , NULL ) ; - err = PrError() ; - if ( err ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - UMAPrClose(NULL) ; - m_ok = FALSE; - return; - } - // sets current port - m_macPort = (GrafPtr ) m_macPrintSessionPort ; + if ( ::PrValidate( (THPrint) m_printData.m_macPrintSettings ) ) + { + ::PrStlDialog( (THPrint) m_printData.m_macPrintSettings ) ; + // the driver has changed in the mean time, should we pop up a page setup dialog ? + } + err = PrError() ; + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + UMAPrClose(NULL) ; + m_ok = FALSE; + return; + } + ::GetPort( &macPrintFormerPort ) ; + m_macPrintSessionPort = ::PrOpenDoc( (THPrint) m_printData.m_macPrintSettings , NULL , NULL ) ; + err = PrError() ; + if ( err ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + UMAPrClose(NULL) ; + m_ok = FALSE; + return; + } + // sets current port + m_macPort = (GrafPtr ) m_macPrintSessionPort ; #else #if PM_USE_SESSION_APIS err = PMSessionBeginDocument((PMPrintSession)m_macPrintSessionPort, (PMPrintSettings)m_printData.m_macPrintSettings, - (PMPageFormat)m_printData.m_macPageFormat); + (PMPageFormat)m_printData.m_macPageFormat); if ( err != noErr ) #else - m_macPrintSessionPort = kPMNoReference ; + m_macPrintSessionPort = kPMNoReference ; err = PMBeginDocument( - m_printData.m_macPrintSettings, - m_printData.m_macPageFormat, - &m_macPrintSessionPort); + m_printData.m_macPrintSettings, + m_printData.m_macPageFormat, + &m_macPrintSessionPort); if ( err != noErr || m_macPrintSessionPort == kPMNoReference ) #endif { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose(&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose(NULL) ; + UMAPrClose(NULL) ; #endif - m_ok = FALSE; - return; + m_ok = FALSE; + return; } - // sets current port - ::GetPort( (GrafPtr *)&m_macPort ) ; + // sets current port + ::GetPort( (GrafPtr *)&m_macPort ) ; #endif - m_ok = TRUE ; - m_minY = m_minX = 0 ; + m_ok = TRUE ; + m_minY = m_minX = 0 ; #if TARGET_CARBON - PMRect rPaper; - - err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper); + PMRect rPaper; + + err = PMGetAdjustedPaperRect((PMPageFormat)m_printData.m_macPageFormat, &rPaper); if ( err != noErr ) { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose(&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose(NULL) ; + UMAPrClose(NULL) ; #endif - m_ok = FALSE; - return; + m_ok = FALSE; + return; } - m_maxX = wxCoord(rPaper.right - rPaper.left) ; - m_maxY = wxCoord(rPaper.bottom - rPaper.top); + m_maxX = wxCoord(rPaper.right - rPaper.left) ; + m_maxY = wxCoord(rPaper.bottom - rPaper.top); #else - m_maxX = (**(THPrint)m_printData.m_macPrintSettings).rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ; - m_maxY = (**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ; + m_maxX = (**(THPrint)m_printData.m_macPrintSettings).rPaper.right - (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ; + m_maxY = (**(THPrint)m_printData.m_macPrintSettings).rPaper.bottom - (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ; #endif } wxPrinterDC::~wxPrinterDC(void) { - OSStatus err ; - wxString message ; + OSStatus err ; + wxString message ; #if !TARGET_CARBON - if ( m_ok ) - { - ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - err = PrError() ; - - if ( err == noErr ) - { - if ( (**(THPrint)m_printData.m_macPrintSettings).prJob.bJDocLoop == bSpoolLoop ) - { - TPrStatus status ; - ::PrPicFile( (THPrint) m_printData.m_macPrintSettings , NULL , NULL , NULL , &status ) ; - } - } - else - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - } - ::UMAPrClose(NULL) ; -// ::SetPort( macPrintFormerPort ) ; - ::SetPort( LMGetWMgrPort() ) ; - } + if ( m_ok ) + { + ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; + err = PrError() ; + + if ( err == noErr ) + { + if ( (**(THPrint)m_printData.m_macPrintSettings).prJob.bJDocLoop == bSpoolLoop ) + { + TPrStatus status ; + ::PrPicFile( (THPrint) m_printData.m_macPrintSettings , NULL , NULL , NULL , &status ) ; + } + } + else + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + } + ::UMAPrClose(NULL) ; +// ::SetPort( macPrintFormerPort ) ; + ::SetPort( LMGetWMgrPort() ) ; + } #else - if ( m_ok ) - { + if ( m_ok ) + { #if PM_USE_SESSION_APIS - err = PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); + err = PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); #else - err = PMEndDocument(m_macPrintSessionPort); + err = PMEndDocument(m_macPrintSessionPort); #endif - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - } + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + } #if TARGET_CARBON && PM_USE_SESSION_APIS - UMAPrClose(&m_macPrintSessionPort) ; + UMAPrClose(&m_macPrintSessionPort) ; #else - UMAPrClose(NULL) ; + UMAPrClose(NULL) ; #endif - } + } #endif } bool wxPrinterDC::StartDoc( const wxString& WXUNUSED(message) ) { - return m_ok ; + return m_ok ; } void wxPrinterDC::EndDoc(void) @@ -220,117 +220,117 @@ void wxPrinterDC::EndDoc(void) void wxPrinterDC::StartPage(void) { - if ( !m_ok ) - return ; + if ( !m_ok ) + return ; - m_logicalFunction = wxCOPY; + m_logicalFunction = wxCOPY; // m_textAlignment = wxALIGN_TOP_LEFT; - m_backgroundMode = wxTRANSPARENT; + m_backgroundMode = wxTRANSPARENT; - m_textForegroundColour = *wxBLACK; - m_textBackgroundColour = *wxWHITE; - m_pen = *wxBLACK_PEN; - m_font = *wxNORMAL_FONT; - m_brush = *wxTRANSPARENT_BRUSH; - m_backgroundBrush = *wxWHITE_BRUSH; + m_textForegroundColour = *wxBLACK; + m_textBackgroundColour = *wxWHITE; + m_pen = *wxBLACK_PEN; + m_font = *wxNORMAL_FONT; + m_brush = *wxTRANSPARENT_BRUSH; + m_backgroundBrush = *wxWHITE_BRUSH; - m_macFontInstalled = false ; - m_macBrushInstalled = false ; - m_macPenInstalled = false ; + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; - - OSStatus err ; - wxString message ; + + OSStatus err ; + wxString message ; #if !TARGET_CARBON - PrOpenPage( (TPPrPort) m_macPrintSessionPort , NULL ) ; - m_macLocalOrigin.x = (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ; - m_macLocalOrigin.y = (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ; - - Rect clip = { -32000 , -32000 , 32000 , 32000 } ; - ::ClipRect( &clip ) ; - err = PrError() ; - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - ::PrClosePage( (TPPrPort) m_macPrintSessionPort ) ; - ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - ::UMAPrClose(NULL) ; - ::SetPort( macPrintFormerPort ) ; - m_ok = FALSE ; - } + PrOpenPage( (TPPrPort) m_macPrintSessionPort , NULL ) ; + m_macLocalOrigin.x = (**(THPrint)m_printData.m_macPrintSettings).rPaper.left ; + m_macLocalOrigin.y = (**(THPrint)m_printData.m_macPrintSettings).rPaper.top ; + + Rect clip = { -32000 , -32000 , 32000 , 32000 } ; + ::ClipRect( &clip ) ; + err = PrError() ; + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + ::PrClosePage( (TPPrPort) m_macPrintSessionPort ) ; + ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; + ::UMAPrClose(NULL) ; + ::SetPort( macPrintFormerPort ) ; + m_ok = FALSE ; + } #else #if PM_USE_SESSION_APIS - err = PMSessionBeginPage((PMPrintSession)m_macPrintSessionPort, - (PMPageFormat)m_printData.m_macPageFormat, - nil); + err = PMSessionBeginPage((PMPrintSession)m_macPrintSessionPort, + (PMPageFormat)m_printData.m_macPageFormat, + nil); #else - err = PMBeginPage(m_macPrintSessionPort, nil); + err = PMBeginPage(m_macPrintSessionPort, nil); #endif - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if PM_USE_SESSION_APIS - PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); - PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); - UMAPrClose(&m_macPrintSessionPort) ; + PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); + PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); + UMAPrClose(&m_macPrintSessionPort) ; #else - PMEndPage(m_macPrintSessionPort); - PMEndDocument(m_macPrintSessionPort); - UMAPrClose(NULL) ; + PMEndPage(m_macPrintSessionPort); + PMEndDocument(m_macPrintSessionPort); + UMAPrClose(NULL) ; #endif - ::SetPort( macPrintFormerPort ) ; - m_ok = FALSE ; - } + ::SetPort( macPrintFormerPort ) ; + m_ok = FALSE ; + } #endif } void wxPrinterDC::EndPage(void) { - if ( !m_ok ) - return ; + if ( !m_ok ) + return ; - OSStatus err ; - wxString message ; + OSStatus err ; + wxString message ; #if !TARGET_CARBON - PrClosePage( (TPPrPort) m_macPort ) ; - err = PrError() ; - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; - ::UMAPrClose(NULL) ; - ::SetPort( macPrintFormerPort ) ; - m_ok = FALSE ; - } + PrClosePage( (TPPrPort) m_macPort ) ; + err = PrError() ; + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + ::PrCloseDoc( (TPPrPort) m_macPrintSessionPort ) ; + ::UMAPrClose(NULL) ; + ::SetPort( macPrintFormerPort ) ; + m_ok = FALSE ; + } #else #if PM_USE_SESSION_APIS - err = PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); + err = PMSessionEndPage((PMPrintSession)m_macPrintSessionPort); #else - err = PMEndPage(m_macPrintSessionPort); + err = PMEndPage(m_macPrintSessionPort); #endif - if ( err != noErr ) - { - message.Printf( "Print Error %ld", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); + if ( err != noErr ) + { + message.Printf( "Print Error %ld", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); #if PM_USE_SESSION_APIS - PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); - UMAPrClose(&m_macPrintSessionPort) ; + PMSessionEndDocument((PMPrintSession)m_macPrintSessionPort); + UMAPrClose(&m_macPrintSessionPort) ; #else - PMEndDocument(m_macPrintSessionPort); - UMAPrClose(NULL) ; + PMEndDocument(m_macPrintSessionPort); + UMAPrClose(NULL) ; #endif - ::SetPort( macPrintFormerPort ) ; - m_ok = FALSE ; - } + ::SetPort( macPrintFormerPort ) ; + m_ok = FALSE ; + } #endif } diff --git a/src/mac/dcscreen.cpp b/src/mac/dcscreen.cpp index 0e12102f6f..03d769a05b 100644 --- a/src/mac/dcscreen.cpp +++ b/src/mac/dcscreen.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,36 +24,36 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) wxScreenDC::wxScreenDC() { #if TARGET_CARBON - m_macPort = GetQDGlobalsThePort() ; - GrafPtr port ; - GetPort( &port ) ; - SetPort( (GrafPtr) m_macPort ) ; - Point pt = { 0,0 } ; - LocalToGlobal( &pt ) ; - SetPort( port ) ; - m_macLocalOrigin.x = -pt.h ; - m_macLocalOrigin.y = -pt.v ; + m_macPort = GetQDGlobalsThePort() ; + GrafPtr port ; + GetPort( &port ) ; + SetPort( (GrafPtr) m_macPort ) ; + Point pt = { 0,0 } ; + LocalToGlobal( &pt ) ; + SetPort( port ) ; + m_macLocalOrigin.x = -pt.h ; + m_macLocalOrigin.y = -pt.v ; #else - m_macPort = LMGetWMgrPort() ; - m_macLocalOrigin.x = 0 ; - m_macLocalOrigin.y = 0 ; + m_macPort = LMGetWMgrPort() ; + m_macLocalOrigin.x = 0 ; + m_macLocalOrigin.y = 0 ; #endif - m_ok = TRUE ; - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); - m_minX = screenBits.bounds.left ; + m_ok = TRUE ; + BitMap screenBits; + GetQDGlobalsScreenBits( &screenBits ); + m_minX = screenBits.bounds.left ; #if TARGET_CARBON - SInt16 height ; - GetThemeMenuBarHeight( &height ) ; - m_minY = screenBits.bounds.top + height ; + SInt16 height ; + GetThemeMenuBarHeight( &height ) ; + m_minY = screenBits.bounds.top + height ; #else - m_minY = screenBits.bounds.top + LMGetMBarHeight() ; + m_minY = screenBits.bounds.top + LMGetMBarHeight() ; #endif - m_maxX = screenBits.bounds.right ; - m_maxY = screenBits.bounds.bottom ; - MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ; - OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; - CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; + m_maxX = screenBits.bounds.right ; + m_maxY = screenBits.bounds.bottom ; + MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ; + OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ; + CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; } wxScreenDC::~wxScreenDC() diff --git a/src/mac/dialog.cpp b/src/mac/dialog.cpp index 506e3399ad..7b7bfc024b 100644 --- a/src/mac/dialog.cpp +++ b/src/mac/dialog.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -46,7 +46,7 @@ END_EVENT_TABLE() wxDialog::wxDialog() { - m_isShown = FALSE; + m_isShown = FALSE; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); } @@ -57,60 +57,59 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); - - - if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); + + + if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) return FALSE; + + MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) , name ) ; + + m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; + SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; - MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) , name ) ; - - m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; - SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; - return TRUE; + return TRUE; } void wxDialog::SetModal(bool flag) { - if ( flag ) + if ( flag ) { m_windowStyle |= wxDIALOG_MODAL; - + wxModelessWindows.DeleteObject(this); } else { m_windowStyle &= ~wxDIALOG_MODAL; - + wxModelessWindows.Append(this); } } wxDialog::~wxDialog() { - m_isBeingDeleted = TRUE ; - Show(FALSE); + m_isBeingDeleted = TRUE ; + Show(FALSE); } // By default, pressing escape cancels the dialog , on mac command-stop does the same thing void wxDialog::OnCharHook(wxKeyEvent& event) { - if ( - ( event.m_keyCode == WXK_ESCAPE || - ( event.m_keyCode == '.' && event.MetaDown() ) ) - && FindWindow(wxID_CANCEL) ) - { - // Behaviour changed in 2.0: we'll send a Cancel message - // to the dialog instead of Close. - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); - - return; - } - // We didn't process this event. - event.Skip(); + if (( event.m_keyCode == WXK_ESCAPE || + ( event.m_keyCode == '.' && event.MetaDown() ) ) + && FindWindow(wxID_CANCEL) ) + { + // Behaviour changed in 2.0: we'll send a Cancel message + // to the dialog instead of Close. + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); + + return; + } + // We didn't process this event. + event.Skip(); } bool wxDialog::IsModal() const @@ -165,7 +164,7 @@ void wxDialog::DoShowModal() wxModalDialogs.Append(this); - wxWindow *parent = GetParent(); + wxWindow *parent = GetParent(); // remember where the focus was wxWindow *winFocus = FindFocus(); @@ -178,23 +177,23 @@ void wxDialog::DoShowModal() winFocus = wxTheApp->GetTopWindow(); } #if TARGET_CARBON - BeginAppModalStateForWindow( (WindowRef) MacGetWindowRef()) ; + BeginAppModalStateForWindow( (WindowRef) MacGetWindowRef()) ; #else - // TODO : test whether parent gets disabled - bool formerModal = s_macIsInModalLoop ; - s_macIsInModalLoop = true ; + // TODO : test whether parent gets disabled + bool formerModal = s_macIsInModalLoop ; + s_macIsInModalLoop = true ; #endif - while ( IsModalShowing() ) - { - wxTheApp->MacDoOneEvent() ; - // calls process idle itself - } - + while ( IsModalShowing() ) + { + wxTheApp->MacDoOneEvent() ; + // calls process idle itself + } + #if TARGET_CARBON - EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ; + EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ; #else // TODO probably reenable the parent window if any - s_macIsInModalLoop = formerModal ; + s_macIsInModalLoop = formerModal ; #endif @@ -209,13 +208,13 @@ void wxDialog::DoShowModal() // Replacement for Show(TRUE) for modal dialogs - returns return code int wxDialog::ShowModal() { - if ( !IsModal() ) - { - SetModal(TRUE); - } + if ( !IsModal() ) + { + SetModal(TRUE); + } - Show(TRUE); - return GetReturnCode(); + Show(TRUE); + return GetReturnCode(); } // NB: this function (surprizingly) may be called for both modal and modeless diff --git a/src/mac/dirdlg.cpp b/src/mac/dirdlg.cpp index 9c6c131e68..6864054234 100644 --- a/src/mac/dirdlg.cpp +++ b/src/mac/dirdlg.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -40,107 +40,107 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxSize& WXUNUSED(size), const wxString& WXUNUSED(name)) { - wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; + wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; m_message = message; m_dialogStyle = style; m_parent = parent; - m_path = defaultPath; + m_path = defaultPath; } int wxDirDialog::ShowModal() { - NavDialogOptions mNavOptions; - NavObjectFilterUPP mNavFilterUPP = NULL; - NavPreviewUPP mNavPreviewUPP = NULL ; - NavReplyRecord mNavReply; - AEDesc* mDefaultLocation = NULL ; - bool mSelectDefault = false ; - - ::NavGetDefaultDialogOptions(&mNavOptions); + NavDialogOptions mNavOptions; + NavObjectFilterUPP mNavFilterUPP = NULL; + NavPreviewUPP mNavPreviewUPP = NULL ; + NavReplyRecord mNavReply; + AEDesc* mDefaultLocation = NULL ; + bool mSelectDefault = false ; + + ::NavGetDefaultDialogOptions(&mNavOptions); - mNavFilterUPP = nil; - mNavPreviewUPP = nil; - mSelectDefault = false; - mNavReply.validRecord = false; - mNavReply.replacing = false; - mNavReply.isStationery = false; - mNavReply.translationNeeded = false; - mNavReply.selection.descriptorType = typeNull; - mNavReply.selection.dataHandle = nil; - mNavReply.keyScript = smSystemScript; - mNavReply.fileTranslation = nil; - - // Set default location, the location - // that's displayed when the dialog - // first appears - - if ( mDefaultLocation ) { - - if (mSelectDefault) { - mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation; - } else { - mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; - } - } - - OSErr err = ::NavChooseFolder( - mDefaultLocation, - &mNavReply, - &mNavOptions, - NULL, - mNavFilterUPP, - 0L); // User Data - - if ( (err != noErr) && (err != userCanceledErr) ) { - m_path = "" ; - return wxID_CANCEL ; - } + mNavFilterUPP = nil; + mNavPreviewUPP = nil; + mSelectDefault = false; + mNavReply.validRecord = false; + mNavReply.replacing = false; + mNavReply.isStationery = false; + mNavReply.translationNeeded = false; + mNavReply.selection.descriptorType = typeNull; + mNavReply.selection.dataHandle = nil; + mNavReply.keyScript = smSystemScript; + mNavReply.fileTranslation = nil; + + // Set default location, the location + // that's displayed when the dialog + // first appears + + if ( mDefaultLocation ) { + + if (mSelectDefault) { + mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation; + } else { + mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; + } + } + + OSErr err = ::NavChooseFolder( + mDefaultLocation, + &mNavReply, + &mNavOptions, + NULL, + mNavFilterUPP, + 0L); // User Data + + if ( (err != noErr) && (err != userCanceledErr) ) { + m_path = "" ; + return wxID_CANCEL ; + } - if (mNavReply.validRecord) { // User chose a folder - - FSSpec folderInfo; - FSSpec outFileSpec ; - AEDesc specDesc ; - - OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc); - if ( err != noErr ) { - m_path = "" ; - return wxID_CANCEL ; - } - folderInfo = **(FSSpec**) specDesc.dataHandle; - if (specDesc.dataHandle != nil) { - ::AEDisposeDesc(&specDesc); - } + if (mNavReply.validRecord) { // User chose a folder + + FSSpec folderInfo; + FSSpec outFileSpec ; + AEDesc specDesc ; + + OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc); + if ( err != noErr ) { + m_path = "" ; + return wxID_CANCEL ; + } + folderInfo = **(FSSpec**) specDesc.dataHandle; + if (specDesc.dataHandle != nil) { + ::AEDisposeDesc(&specDesc); + } -// mNavReply.GetFileSpec(folderInfo); - - // The FSSpec from NavChooseFolder is NOT the file spec - // for the folder. The parID field is actually the DirID - // of the folder itself, not the folder's parent, and - // the name field is empty. We must call PBGetCatInfo - // to get the parent DirID and folder name - - Str255 name; - CInfoPBRec thePB; // Directory Info Parameter Block - thePB.dirInfo.ioCompletion = nil; - thePB.dirInfo.ioVRefNum = folderInfo.vRefNum; // Volume is right - thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID - thePB.dirInfo.ioNamePtr = name; - thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID - - err = ::PBGetCatInfoSync(&thePB); - if ( err != noErr ) { - m_path = "" ; - return wxID_CANCEL ; - } - // Create cannonical FSSpec - ::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID, - name, &outFileSpec); - - // outFolderDirID = thePB.dirInfo.ioDrDirID; - m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ; - return wxID_OK ; - } - return wxID_CANCEL; +// mNavReply.GetFileSpec(folderInfo); + + // The FSSpec from NavChooseFolder is NOT the file spec + // for the folder. The parID field is actually the DirID + // of the folder itself, not the folder's parent, and + // the name field is empty. We must call PBGetCatInfo + // to get the parent DirID and folder name + + Str255 name; + CInfoPBRec thePB; // Directory Info Parameter Block + thePB.dirInfo.ioCompletion = nil; + thePB.dirInfo.ioVRefNum = folderInfo.vRefNum; // Volume is right + thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID + thePB.dirInfo.ioNamePtr = name; + thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID + + err = ::PBGetCatInfoSync(&thePB); + if ( err != noErr ) { + m_path = "" ; + return wxID_CANCEL ; + } + // Create cannonical FSSpec + ::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID, + name, &outFileSpec); + + // outFolderDirID = thePB.dirInfo.ioDrDirID; + m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ; + return wxID_OK ; + } + return wxID_CANCEL; } diff --git a/src/mac/dirmac.cpp b/src/mac/dirmac.cpp index 0f250ccd5e..53e9dcbd68 100644 --- a/src/mac/dirmac.cpp +++ b/src/mac/dirmac.cpp @@ -83,11 +83,11 @@ public: const wxString& GetName() const { return m_dirname; } private: - CInfoPBRec m_CPB ; - wxInt16 m_index ; - long m_dirId ; - Str255 m_name ; - Boolean m_isDir ; + CInfoPBRec m_CPB ; + wxInt16 m_index ; + long m_dirId ; + Str255 m_name ; + Boolean m_isDir ; wxString m_dirname; wxString m_filespec; @@ -145,26 +145,26 @@ wxDirData::~wxDirData() void wxDirData::Rewind() { - m_index = 0 ; + m_index = 0 ; } bool wxDirData::Read(wxString *filename) { if ( !m_isDir ) return FALSE ; - + #if TARGET_CARBON - char c_name[256] ; + char c_name[256] ; #endif wxString result; short err = noErr ; - + while ( err == noErr ) { m_index++ ; m_CPB.dirInfo.ioFDirIndex = m_index; - m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */ + m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */ err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB); if ( err != noErr ) break ; @@ -270,12 +270,12 @@ wxString wxDir::GetName() const wxString name; if ( m_data ) { - name = M_DIR->GetName(); - if ( !name.empty() && (name.Last() == _T('/')) ) - { - // chop off the last (back)slash - name.Truncate(name.length() - 1); - } + name = M_DIR->GetName(); + if ( !name.empty() && (name.Last() == _T('/')) ) + { + // chop off the last (back)slash + name.Truncate(name.length() - 1); + } } return name; diff --git a/src/mac/display.cpp b/src/mac/display.cpp index e25b2486e3..3502ac55f5 100644 --- a/src/mac/display.cpp +++ b/src/mac/display.cpp @@ -44,7 +44,7 @@ class wxDisplayMacPriv { public: - GDHandle m_hndl; + GDHandle m_hndl; }; size_t wxDisplayBase::GetCount() diff --git a/src/mac/dnd.cpp b/src/mac/dnd.cpp index 68b372cb85..b9df2ac004 100644 --- a/src/mac/dnd.cpp +++ b/src/mac/dnd.cpp @@ -82,47 +82,47 @@ bool wxDropTarget::CurrentDragHasSupportedFormat() bool supported = false ; if ( gTrackingGlobals.m_currentSource != NULL ) { - wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; - - if ( data ) - { - size_t formatcount = data->GetFormatCount() ; - wxDataFormat *array = new wxDataFormat[ formatcount ]; - data->GetAllFormats( array ); - for (size_t i = 0; !supported && i < formatcount ; i++) + wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; + + if ( data ) { - wxDataFormat format = array[i] ; - if ( m_dataObject->IsSupported( format ) ) + size_t formatcount = data->GetFormatCount() ; + wxDataFormat *array = new wxDataFormat[ formatcount ]; + data->GetAllFormats( array ); + for (size_t i = 0; !supported && i < formatcount ; i++) { - supported = true ; - break ; + wxDataFormat format = array[i] ; + if ( m_dataObject->IsSupported( format ) ) + { + supported = true ; + break ; + } } + delete[] array ; } - delete[] array ; - } } if ( !supported ) { - UInt16 items ; - OSErr result; - CountDragItems((DragReference)m_currentDrag, &items); - for (UInt16 index = 1; index <= items && supported == false ; ++index) - { - ItemReference theItem; - FlavorType theType ; - UInt16 flavors = 0 ; - GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); - CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ; - for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor ) - { - result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType); - if ( m_dataObject->IsSupportedFormat( wxDataFormat( theType ) ) ) + UInt16 items ; + OSErr result; + CountDragItems((DragReference)m_currentDrag, &items); + for (UInt16 index = 1; index <= items && supported == false ; ++index) + { + ItemReference theItem; + FlavorType theType ; + UInt16 flavors = 0 ; + GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); + CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ; + for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor ) { - supported = true ; - break ; + result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType); + if ( m_dataObject->IsSupportedFormat( wxDataFormat( theType ) ) ) + { + supported = true ; + break ; + } } - } - } + } } return supported ; } @@ -131,109 +131,109 @@ bool wxDropTarget::GetData() { if (!m_dataObject) return FALSE; - + if ( !CurrentDragHasSupportedFormat() ) return FALSE ; - + bool transferred = false ; if ( gTrackingGlobals.m_currentSource != NULL ) { - wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; - - if ( data ) - { - size_t formatcount = data->GetFormatCount() ; - wxDataFormat *array = new wxDataFormat[ formatcount ]; - data->GetAllFormats( array ); - for (size_t i = 0; !transferred && i < formatcount ; i++) + wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; + + if ( data ) { - wxDataFormat format = array[i] ; - if ( m_dataObject->IsSupported( format ) ) + size_t formatcount = data->GetFormatCount() ; + wxDataFormat *array = new wxDataFormat[ formatcount ]; + data->GetAllFormats( array ); + for (size_t i = 0; !transferred && i < formatcount ; i++) { - int size = data->GetDataSize( format ); - transferred = true ; - - if (size == 0) - { - m_dataObject->SetData(format , 0 , 0 ) ; - } - else - { - char *d = new char[size]; - data->GetDataHere( format , (void*) d ); - m_dataObject->SetData( format , size , d ) ; - delete[] d ; - } + wxDataFormat format = array[i] ; + if ( m_dataObject->IsSupported( format ) ) + { + int size = data->GetDataSize( format ); + transferred = true ; + + if (size == 0) + { + m_dataObject->SetData(format , 0 , 0 ) ; + } + else + { + char *d = new char[size]; + data->GetDataHere( format , (void*) d ); + m_dataObject->SetData( format , size , d ) ; + delete[] d ; + } + } } - } - delete[] array ; - } + delete[] array ; + } } if ( !transferred ) { - UInt16 items ; - OSErr result; - bool firstFileAdded = false ; - CountDragItems((DragReference)m_currentDrag, &items); - for (UInt16 index = 1; index <= items; ++index) - { - ItemReference theItem; - FlavorType theType ; - UInt16 flavors = 0 ; - GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); - CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ; - for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor ) - { - result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType); - wxDataFormat format(theType) ; - if ( m_dataObject->IsSupportedFormat( format ) ) + UInt16 items ; + OSErr result; + bool firstFileAdded = false ; + CountDragItems((DragReference)m_currentDrag, &items); + for (UInt16 index = 1; index <= items; ++index) + { + ItemReference theItem; + FlavorType theType ; + UInt16 flavors = 0 ; + GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem); + CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ; + for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor ) { - FlavorFlags theFlags; - result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags); - if (result == noErr) - { - Size dataSize ; - Ptr theData ; - GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize); - if ( theType == 'TEXT' ) - { - // this increment is only valid for allocating, on the next GetFlavorData - // call it is reset again to the original value - dataSize++ ; - } - theData = new char[dataSize]; - GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); - if( theType == 'TEXT' ) - { - theData[dataSize]=0 ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertToPC((char*)theData,(char*)theData,dataSize) ; - } - m_dataObject->SetData( format, dataSize, theData ); - } - else if ( theType == kDragFlavorTypeHFS ) - { - HFSFlavor* theFile = (HFSFlavor*) theData ; - wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ; - if ( firstFileAdded ) - ((wxFileDataObject*)m_dataObject)->AddFile( name ) ; - else + result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType); + wxDataFormat format(theType) ; + if ( m_dataObject->IsSupportedFormat( format ) ) + { + FlavorFlags theFlags; + result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags); + if (result == noErr) { - ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ; - firstFileAdded = true ; + Size dataSize ; + Ptr theData ; + GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize); + if ( theType == 'TEXT' ) + { + // this increment is only valid for allocating, on the next GetFlavorData + // call it is reset again to the original value + dataSize++ ; + } + theData = new char[dataSize]; + GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); + if( theType == 'TEXT' ) + { + theData[dataSize]=0 ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + wxMacConvertToPC((char*)theData,(char*)theData,dataSize) ; + } + m_dataObject->SetData( format, dataSize, theData ); + } + else if ( theType == kDragFlavorTypeHFS ) + { + HFSFlavor* theFile = (HFSFlavor*) theData ; + wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ; + if ( firstFileAdded ) + ((wxFileDataObject*)m_dataObject)->AddFile( name ) ; + else + { + ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ; + firstFileAdded = true ; + } + } + else + { + m_dataObject->SetData( format, dataSize, theData ); + } + delete[] theData; } - } - else - { - m_dataObject->SetData( format, dataSize, theData ); - } - delete[] theData; - } - break ; + break ; + } } - } - } + } } return TRUE ; } @@ -273,13 +273,13 @@ wxDropSource::~wxDropSource() wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) { wxASSERT_MSG( m_data, wxT("Drop source: no data") ); - + if (!m_data) return (wxDragResult) wxDragNone; - + if (m_data->GetFormatCount() == 0) return (wxDragResult) wxDragNone; - + OSErr result; DragReference theDrag; RgnHandle dragRegion; @@ -300,45 +300,45 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) OSType type = formats[i].GetFormatId() ; if ( type == 'TEXT' ) { - dataSize-- ; - if ( wxApp::s_macDefaultEncodingIsPC ) - { - wxMacConvertFromPC((char*)dataPtr,(char*)dataPtr,dataSize) ; - } - AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); + dataSize-- ; + if ( wxApp::s_macDefaultEncodingIsPC ) + { + wxMacConvertFromPC((char*)dataPtr,(char*)dataPtr,dataSize) ; + } + AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); } else if (type == kDragFlavorTypeHFS ) { - HFSFlavor theFlavor ; - OSErr err = noErr; - CInfoPBRec cat; - - wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ; - - cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name; - cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum; - cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID; - cat.hFileInfo.ioFDirIndex = 0; - err = PBGetCatInfoSync(&cat); - if (err == noErr ) - { - theFlavor.fdFlags = cat.hFileInfo.ioFlFndrInfo.fdFlags; - if (theFlavor.fileSpec.parID == fsRtParID) { - theFlavor.fileCreator = 'MACS'; - theFlavor.fileType = 'disk'; - } else if ((cat.hFileInfo.ioFlAttrib & ioDirMask) != 0) { - theFlavor.fileCreator = 'MACS'; - theFlavor.fileType = 'fold'; - } else { - theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator; - theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType; - } - AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0); - } + HFSFlavor theFlavor ; + OSErr err = noErr; + CInfoPBRec cat; + + wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ; + + cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name; + cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum; + cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID; + cat.hFileInfo.ioFDirIndex = 0; + err = PBGetCatInfoSync(&cat); + if (err == noErr ) + { + theFlavor.fdFlags = cat.hFileInfo.ioFlFndrInfo.fdFlags; + if (theFlavor.fileSpec.parID == fsRtParID) { + theFlavor.fileCreator = 'MACS'; + theFlavor.fileType = 'disk'; + } else if ((cat.hFileInfo.ioFlAttrib & ioDirMask) != 0) { + theFlavor.fileCreator = 'MACS'; + theFlavor.fileType = 'fold'; + } else { + theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator; + theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType; + } + AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0); + } } else { - AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); + AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); } delete[] dataPtr ; } @@ -349,37 +349,37 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) EventRecord* ev = NULL ; #if !TARGET_CARBON // TODO - ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; + ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; #else - EventRecord rec ; - ev = &rec ; - wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; + EventRecord rec ; + ev = &rec ; + wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; #endif const short dragRegionOuterBoundary = 10 ; const short dragRegionInnerBoundary = 9 ; SetRectRgn( dragRegion , ev->where.h - dragRegionOuterBoundary , - ev->where.v - dragRegionOuterBoundary , - ev->where.h + dragRegionOuterBoundary , - ev->where.v + dragRegionOuterBoundary ) ; - + ev->where.v - dragRegionOuterBoundary , + ev->where.h + dragRegionOuterBoundary , + ev->where.v + dragRegionOuterBoundary ) ; + SetRectRgn( tempRgn , ev->where.h - dragRegionInnerBoundary , - ev->where.v - dragRegionInnerBoundary , - ev->where.h + dragRegionInnerBoundary , - ev->where.v + dragRegionInnerBoundary ) ; - + ev->where.v - dragRegionInnerBoundary , + ev->where.h + dragRegionInnerBoundary , + ev->where.v + dragRegionInnerBoundary ) ; + DiffRgn( dragRegion , tempRgn , dragRegion ) ; DisposeRgn( tempRgn ) ; - + // TODO:work with promises in order to return data only when drag // was successfully completed - + gTrackingGlobals.m_currentSource = this ; result = TrackDrag(theDrag, ev , dragRegion); DisposeRgn(dragRegion); DisposeDrag(theDrag); gTrackingGlobals.m_currentSource = NULL ; - + return wxDragCopy ; } @@ -423,7 +423,7 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind case kDragTrackingLeaveHandler: break; case kDragTrackingEnterWindow: - trackingGlobals->m_currentTargetWindow = NULL ; + trackingGlobals->m_currentTargetWindow = NULL ; trackingGlobals->m_currentTarget = NULL ; break; case kDragTrackingInWindow: diff --git a/src/mac/filedlg.cpp b/src/mac/filedlg.cpp index 841dc9936a..b2a2cb2406 100644 --- a/src/mac/filedlg.cpp +++ b/src/mac/filedlg.cpp @@ -52,160 +52,160 @@ extern bool gUseNavServices ; struct OpenUserDataRec { int currentfilter ; - bool saveMode ; + bool saveMode ; wxArrayString name ; wxArrayString extensions ; - wxArrayLong filtermactypes ; + wxArrayLong filtermactypes ; NavMenuItemSpecArrayHandle menuitems ; }; typedef struct OpenUserDataRec - OpenUserDataRec, *OpenUserDataRecPtr; + OpenUserDataRec, *OpenUserDataRecPtr; -static pascal void NavEventProc( - NavEventCallbackMessage inSelector, - NavCBRecPtr ioParams, - NavCallBackUserData ioUserData); +static pascal void NavEventProc( + NavEventCallbackMessage inSelector, + NavCBRecPtr ioParams, + NavCallBackUserData ioUserData); #if TARGET_CARBON - static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc); + static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc); #else - static NavEventUPP sStandardNavEventFilter = NewNavEventProc(NavEventProc); + static NavEventUPP sStandardNavEventFilter = NewNavEventProc(NavEventProc); #endif static pascal void NavEventProc( - NavEventCallbackMessage inSelector, - NavCBRecPtr ioParams, - NavCallBackUserData ioUserData ) + NavEventCallbackMessage inSelector, + NavCBRecPtr ioParams, + NavCallBackUserData ioUserData ) { - OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ; - if (inSelector == kNavCBEvent) { + OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ; + if (inSelector == kNavCBEvent) { #if !TARGET_CARBON wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event); #endif - } - else if ( inSelector == kNavCBStart ) - { - if ( data->menuitems ) - NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &(*data->menuitems)[data->currentfilter]); - } - else if ( inSelector == kNavCBPopupMenuSelect ) - { - NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ; - if ( menu->menuCreator == 'WXNG' ) - { - data->currentfilter = menu->menuType ; - if ( data->saveMode ) - { - int i = menu->menuType ; - wxString extension = data->extensions[i].AfterLast('.') ; - extension.MakeLower() ; - Str255 filename ; - // get the current filename - NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename); - CopyPascalStringToC( filename , (char*) filename ) ; - wxString sfilename( filename ) ; - int pos = sfilename.Find('.',TRUE) ; - if ( pos != wxNOT_FOUND ) - { - sfilename = sfilename.Left(pos+1)+extension ; - CopyCStringToPascal( sfilename.c_str() , filename ) ; - NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename); - } - } - } - } + } + else if ( inSelector == kNavCBStart ) + { + if ( data->menuitems ) + NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &(*data->menuitems)[data->currentfilter]); + } + else if ( inSelector == kNavCBPopupMenuSelect ) + { + NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ; + if ( menu->menuCreator == 'WXNG' ) + { + data->currentfilter = menu->menuType ; + if ( data->saveMode ) + { + int i = menu->menuType ; + wxString extension = data->extensions[i].AfterLast('.') ; + extension.MakeLower() ; + Str255 filename ; + // get the current filename + NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename); + CopyPascalStringToC( filename , (char*) filename ) ; + wxString sfilename( filename ) ; + int pos = sfilename.Find('.',TRUE) ; + if ( pos != wxNOT_FOUND ) + { + sfilename = sfilename.Left(pos+1)+extension ; + CopyCStringToPascal( sfilename.c_str() , filename ) ; + NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename); + } + } + } + } } const char * gfilters[] = { - "*.TXT" , - "*.TIF" , - "*.JPG" , - - NULL + "*.TXT" , + "*.TIF" , + "*.JPG" , + + NULL } ; OSType gfiltersmac[] = { - 'TEXT' , - 'TIFF' , - 'JPEG' , - - '****' + 'TEXT' , + 'TIFF' , + 'JPEG' , + + '****' } ; -void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) +void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) { - myData->menuitems = NULL ; - myData->currentfilter = 0 ; - myData->saveMode = FALSE ; - - if ( filter && filter[0] ) - { - wxString filter2(filter) ; - int filterIndex = 0; - bool isName = true ; - wxString current ; - for( unsigned int i = 0; i < filter2.Len() ; i++ ) + myData->menuitems = NULL ; + myData->currentfilter = 0 ; + myData->saveMode = FALSE ; + + if ( filter && filter[0] ) { - if( filter2.GetChar(i) == wxT('|') ) - { - if( isName ) { - myData->name.Add( current ) ; - } - else { - myData->extensions.Add( current.MakeUpper() ) ; - ++filterIndex ; + wxString filter2(filter) ; + int filterIndex = 0; + bool isName = true ; + wxString current ; + for( unsigned int i = 0; i < filter2.Len() ; i++ ) + { + if( filter2.GetChar(i) == wxT('|') ) + { + if( isName ) { + myData->name.Add( current ) ; + } + else { + myData->extensions.Add( current.MakeUpper() ) ; + ++filterIndex ; + } + isName = !isName ; + current = "" ; + } + else + { + current += filter2.GetChar(i) ; + } } - isName = !isName ; - current = "" ; - } - else - { - current += filter2.GetChar(i) ; - } - } - // we allow for compatibility reason to have a single filter expression (like *.*) without - // an explanatory text, in that case the first part is name and extension at the same time - - wxASSERT_MSG( filterIndex == 0 || !isName , "incorrect format of format string" ) ; - if ( current.IsEmpty() ) - myData->extensions.Add( myData->name[filterIndex] ) ; - else - myData->extensions.Add( current.MakeUpper() ) ; - if ( filterIndex == 0 || isName ) - myData->name.Add( current.MakeUpper() ) ; + // we allow for compatibility reason to have a single filter expression (like *.*) without + // an explanatory text, in that case the first part is name and extension at the same time + + wxASSERT_MSG( filterIndex == 0 || !isName , "incorrect format of format string" ) ; + if ( current.IsEmpty() ) + myData->extensions.Add( myData->name[filterIndex] ) ; + else + myData->extensions.Add( current.MakeUpper() ) ; + if ( filterIndex == 0 || isName ) + myData->name.Add( current.MakeUpper() ) ; + + ++filterIndex ; + - ++filterIndex ; - - const size_t extCount = myData->extensions.GetCount(); - for ( size_t i = 0 ; i < extCount; i++ ) - { - int j ; - for ( j = 0 ; gfilters[j] ; j++ ) - { - if ( strcmp( myData->extensions[i] , gfilters[j] ) == 0 ) - { - myData->filtermactypes.Add( gfiltersmac[j] ) ; - break ; - } - } - if( gfilters[j] == NULL ) - { - myData->filtermactypes.Add( '****' ) ; - } - } - } + for ( size_t i = 0 ; i < extCount; i++ ) + { + int j ; + for ( j = 0 ; gfilters[j] ; j++ ) + { + if ( strcmp( myData->extensions[i] , gfilters[j] ) == 0 ) + { + myData->filtermactypes.Add( gfiltersmac[j] ) ; + break ; + } + } + if( gfilters[j] == NULL ) + { + myData->filtermactypes.Add( '****' ) ; + } + } + } } static Boolean CheckFile( ConstStr255Param name , OSType type , OpenUserDataRecPtr data) { - Str255 filename ; + Str255 filename ; #if TARGET_CARBON p2cstrcpy((char *)filename, name) ; @@ -218,55 +218,55 @@ static Boolean CheckFile( ConstStr255Param name , OSType type , OpenUserDataRecP if ( data->extensions.GetCount() > 0 ) { - //for ( int i = 0 ; i < data->numfilters ; ++i ) - int i = data->currentfilter ; - if ( data->extensions[i].Right(2) == ".*" ) - return true ; - - { - if ( type == (OSType)data->filtermactypes[i] ) - return true ; - - wxStringTokenizer tokenizer( data->extensions[i] , ";" ) ; - while( tokenizer.HasMoreTokens() ) - { - wxString extension = tokenizer.GetNextToken() ; - if ( extension.GetChar(0) == '*' ) - extension = extension.Mid(1) ; - - if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) ) - return true ; - } - } - return false ; + //for ( int i = 0 ; i < data->numfilters ; ++i ) + int i = data->currentfilter ; + if ( data->extensions[i].Right(2) == ".*" ) + return true ; + + { + if ( type == (OSType)data->filtermactypes[i] ) + return true ; + + wxStringTokenizer tokenizer( data->extensions[i] , ";" ) ; + while( tokenizer.HasMoreTokens() ) + { + wxString extension = tokenizer.GetNextToken() ; + if ( extension.GetChar(0) == '*' ) + extension = extension.Mid(1) ; + + if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) ) + return true ; + } + } + return false ; } return true ; } #ifndef __DARWIN__ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr) -{ - OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ; - // return true if this item is invisible or a file - - Boolean visibleFlag; - Boolean folderFlag; - - visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible); - folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10); - - // because the semantics of the filter proc are "true means don't show - // it" we need to invert the result that we return - - if ( !visibleFlag ) - return true ; - - if ( !folderFlag ) - { - return !CheckFile( myCInfoPBPtr->hFileInfo.ioNamePtr , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ; - } - - return false ; +{ + OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ; + // return true if this item is invisible or a file + + Boolean visibleFlag; + Boolean folderFlag; + + visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible); + folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10); + + // because the semantics of the filter proc are "true means don't show + // it" we need to invert the result that we return + + if ( !visibleFlag ) + return true ; + + if ( !folderFlag ) + { + return !CheckFile( myCInfoPBPtr->hFileInfo.ioNamePtr , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ; + } + + return false ; } #endif @@ -335,7 +335,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, long style, const wxPoint& pos) { - wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; + wxASSERT_MSG( NavServicesAvailable() , "Navigation Services are not running" ) ; m_message = message; m_dialogStyle = style; m_parent = parent; @@ -362,7 +362,7 @@ pascal Boolean CrossPlatformFilterCallback ( NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ; if (theItem->descriptorType == typeFSS && !theInfo->isFolder) { - FSSpec spec; + FSSpec spec; memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ; display = CheckFile( spec.name , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ; } @@ -373,58 +373,58 @@ pascal Boolean CrossPlatformFilterCallback ( int wxFileDialog::ShowModal() { - NavDialogOptions mNavOptions; - NavObjectFilterUPP mNavFilterUPP = NULL; - NavPreviewUPP mNavPreviewUPP = NULL ; - NavReplyRecord mNavReply; - AEDesc mDefaultLocation ; - bool mSelectDefault = false ; - - // zero all data - - m_path = wxEmptyString ; - m_fileName = wxEmptyString ; - m_paths.Empty(); - m_fileNames.Empty(); - - // setup dialog - + NavDialogOptions mNavOptions; + NavObjectFilterUPP mNavFilterUPP = NULL; + NavPreviewUPP mNavPreviewUPP = NULL ; + NavReplyRecord mNavReply; + AEDesc mDefaultLocation ; + bool mSelectDefault = false ; + + // zero all data + + m_path = wxEmptyString ; + m_fileName = wxEmptyString ; + m_paths.Empty(); + m_fileNames.Empty(); + + // setup dialog + ::NavGetDefaultDialogOptions(&mNavOptions); - - mNavFilterUPP = nil; - mNavPreviewUPP = nil; - mSelectDefault = false; + + mNavFilterUPP = nil; + mNavPreviewUPP = nil; + mSelectDefault = false; mNavReply.validRecord = false; - mNavReply.replacing = false; + mNavReply.replacing = false; mNavReply.isStationery = false; - mNavReply.translationNeeded = false; + mNavReply.translationNeeded = false; mNavReply.selection.descriptorType = typeNull; mNavReply.selection.dataHandle = nil; - mNavReply.keyScript = smSystemScript; + mNavReply.keyScript = smSystemScript; mNavReply.fileTranslation = nil; - + // Set default location, the location // that's displayed when the dialog // first appears - + FSSpec location ; wxMacFilename2FSSpec( m_dir , &location ) ; OSErr err = noErr ; - + mDefaultLocation.descriptorType = typeNull; mDefaultLocation.dataHandle = nil; err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation ); if ( mDefaultLocation.dataHandle ) { - + if (mSelectDefault) { mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation; } else { mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; } } - + #if TARGET_CARBON c2pstrcpy((StringPtr)mNavOptions.message, m_message) ; #else @@ -438,7 +438,7 @@ int wxFileDialog::ShowModal() c2pstr((char *)mNavOptions.savedFileName ) ; #endif - OpenUserDataRec myData; + OpenUserDataRec myData; MakeUserDataRec( &myData , m_wildCard ) ; myData.currentfilter = m_filterIndex ; if ( myData.extensions.GetCount() > 0 ) @@ -464,7 +464,7 @@ int wxFileDialog::ShowModal() mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ; mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ; - + err = ::NavPutFile( &mDefaultLocation, &mNavReply, @@ -472,7 +472,7 @@ int wxFileDialog::ShowModal() sStandardNavEventFilter , NULL, kNavGenericSignature, - &myData); // User Data + &myData); // User Data m_filterIndex = myData.currentfilter ; } else @@ -484,7 +484,7 @@ int wxFileDialog::ShowModal() mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ; else mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ; - + err = ::NavGetFile( &mDefaultLocation, &mNavReply, @@ -496,23 +496,23 @@ int wxFileDialog::ShowModal() &myData); m_filterIndex = myData.currentfilter ; } - + DisposeNavObjectFilterUPP(mNavFilterUPP); if ( mDefaultLocation.dataHandle != nil ) { ::AEDisposeDesc(&mDefaultLocation); } - + if ( (err != noErr) && (err != userCanceledErr) ) { return wxID_CANCEL ; } if (mNavReply.validRecord) { - + FSSpec outFileSpec ; AEDesc specDesc ; AEKeyword keyWord ; - + long count ; ::AECountItems( &mNavReply.selection , &count ) ; for ( long i = 1 ; i <= count ; ++i ) @@ -521,7 +521,7 @@ int wxFileDialog::ShowModal() if ( err != noErr ) { m_path = "" ; return wxID_CANCEL ; - } + } outFileSpec = **(FSSpec**) specDesc.dataHandle; if (specDesc.dataHandle != nil) { ::AEDisposeDesc(&specDesc); @@ -566,7 +566,7 @@ wxDefaultFileSelector(bool load, const char *what, const char *extension, const wxString wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) { - return wxDefaultFileSelector(TRUE, what, extension, default_name, parent); + return wxDefaultFileSelector(TRUE, what, extension, default_name, parent); } @@ -574,7 +574,7 @@ wxLoadFileSelector(const char *what, const char *extension, const char *default_ wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) { - return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); + return wxDefaultFileSelector(FALSE, what, extension, default_name, parent); } diff --git a/src/mac/font.cpp b/src/mac/font.cpp index 1c6b6518bb..e134003482 100644 --- a/src/mac/font.cpp +++ b/src/mac/font.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -67,66 +67,66 @@ wxFontRefData::~wxFontRefData() void wxFontRefData::MacFindFont() { - if( m_faceName == "" ) - { - switch( m_family ) - { - case wxDEFAULT : - m_macFontNum = ::GetAppFont() ; - break ; - case wxDECORATIVE : - ::GetFNum( "\pTimes" , &m_macFontNum) ; - break ; - case wxROMAN : - ::GetFNum( "\pTimes" , &m_macFontNum) ; - break ; - case wxSCRIPT : - ::GetFNum( "\pTimes" , &m_macFontNum) ; - break ; - case wxSWISS : - ::GetFNum( "\pGeneva" , &m_macFontNum) ; - break ; - case wxMODERN : - ::GetFNum( "\pMonaco" , &m_macFontNum) ; - break ; - } - Str255 name ; - GetFontName( m_macFontNum , name ) ; - CopyPascalStringToC( name , (char*) name ) ; - m_faceName = (char*) name ; - } - else - { - if ( m_faceName == "systemfont" ) - m_macFontNum = ::GetSysFont() ; - else if ( m_faceName == "applicationfont" ) - m_macFontNum = ::GetAppFont() ; - else - { - Str255 fontname ; - wxMacStringToPascal( m_faceName , fontname ) ; - ::GetFNum( fontname, &m_macFontNum); - } - } - - m_macFontStyle = 0; - if (m_weight == wxBOLD) - m_macFontStyle |= bold; - if (m_style == wxITALIC || m_style == wxSLANT) - m_macFontStyle |= italic; - if (m_underlined) - m_macFontStyle |= underline; - m_macFontSize = m_pointSize ; - - //TODO:if we supply the style as an additional parameter we must make a testing - //sequence in order to degrade gracefully while trying to maintain most of the style - //information, meanwhile we just take the normal font and apply the features after - OSStatus status = ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID); + if( m_faceName == "" ) + { + switch( m_family ) + { + case wxDEFAULT : + m_macFontNum = ::GetAppFont() ; + break ; + case wxDECORATIVE : + ::GetFNum( "\pTimes" , &m_macFontNum) ; + break ; + case wxROMAN : + ::GetFNum( "\pTimes" , &m_macFontNum) ; + break ; + case wxSCRIPT : + ::GetFNum( "\pTimes" , &m_macFontNum) ; + break ; + case wxSWISS : + ::GetFNum( "\pGeneva" , &m_macFontNum) ; + break ; + case wxMODERN : + ::GetFNum( "\pMonaco" , &m_macFontNum) ; + break ; + } + Str255 name ; + GetFontName( m_macFontNum , name ) ; + CopyPascalStringToC( name , (char*) name ) ; + m_faceName = (char*) name ; + } + else + { + if ( m_faceName == "systemfont" ) + m_macFontNum = ::GetSysFont() ; + else if ( m_faceName == "applicationfont" ) + m_macFontNum = ::GetAppFont() ; + else + { + Str255 fontname ; + wxMacStringToPascal( m_faceName , fontname ) ; + ::GetFNum( fontname, &m_macFontNum); + } + } + + m_macFontStyle = 0; + if (m_weight == wxBOLD) + m_macFontStyle |= bold; + if (m_style == wxITALIC || m_style == wxSLANT) + m_macFontStyle |= italic; + if (m_underlined) + m_macFontStyle |= underline; + m_macFontSize = m_pointSize ; + + //TODO:if we supply the style as an additional parameter we must make a testing + //sequence in order to degrade gracefully while trying to maintain most of the style + //information, meanwhile we just take the normal font and apply the features after + OSStatus status = ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID); /* status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) , - kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; + kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; */ - wxASSERT_MSG( status == noErr , "couldn't retrieve font identifier" ) ; + wxASSERT_MSG( status == noErr , "couldn't retrieve font identifier" ) ; } // ---------------------------------------------------------------------------- @@ -173,7 +173,7 @@ wxFont::~wxFont() bool wxFont::RealizeResource() { - M_FONTDATA->MacFindFont() ; + M_FONTDATA->MacFindFont() ; return TRUE; } @@ -188,17 +188,17 @@ void wxFont::SetEncoding(wxFontEncoding encoding) void wxFont::Unshare() { - // Don't change shared data - if (!m_refData) + // Don't change shared data + if (!m_refData) { - m_refData = new wxFontRefData(); - } + m_refData = new wxFontRefData(); + } else { - wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); - UnRef(); - m_refData = ref; - } + wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); + UnRef(); + m_refData = ref; + } } void wxFont::SetPointSize(int pointSize) diff --git a/src/mac/fontdlg.cpp b/src/mac/fontdlg.cpp index 5924ed4a9e..03c894c553 100644 --- a/src/mac/fontdlg.cpp +++ b/src/mac/fontdlg.cpp @@ -7,7 +7,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/fontenum.cpp b/src/mac/fontenum.cpp index 4a91e5703f..5e9987348e 100644 --- a/src/mac/fontenum.cpp +++ b/src/mac/fontenum.cpp @@ -103,46 +103,46 @@ bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding) void wxFontEnumeratorHelper::DoEnumerate() { - MenuHandle menu ; - Str255 p_name ; - - short lines ; - - menu = NewMenu( 32000 , "\pFont" ) ; - AppendResMenu( menu , 'FONT' ) ; - lines = CountMenuItems( menu ) ; - - for ( int i = 1 ; i < lines+1 ; i ++ ) - { - GetMenuItemText( menu , i , p_name ) ; - wxString c_name = wxMacMakeStringFromPascal(p_name) ; - - /* - - if ( m_fixedOnly ) - { - // check that it's a fixed pitch font (there is *no* error here, the - // flag name is misleading!) - if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH ) - { - // not a fixed pitch font - return TRUE; - } - } - - if ( m_charset != -1 ) - { - // check that we have the right encoding - if ( lf->lfCharSet != m_charset ) - { - return TRUE; - } - } - - */ - m_fontEnum->OnFacename( c_name ) ; - } - DisposeMenu( menu ) ; + MenuHandle menu ; + Str255 p_name ; + + short lines ; + + menu = NewMenu( 32000 , "\pFont" ) ; + AppendResMenu( menu , 'FONT' ) ; + lines = CountMenuItems( menu ) ; + + for ( int i = 1 ; i < lines+1 ; i ++ ) + { + GetMenuItemText( menu , i , p_name ) ; + wxString c_name = wxMacMakeStringFromPascal(p_name) ; + + /* + + if ( m_fixedOnly ) + { + // check that it's a fixed pitch font (there is *no* error here, the + // flag name is misleading!) + if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH ) + { + // not a fixed pitch font + return TRUE; + } + } + + if ( m_charset != -1 ) + { + // check that we have the right encoding + if ( lf->lfCharSet != m_charset ) + { + return TRUE; + } + } + + */ + m_fontEnum->OnFacename( c_name ) ; + } + DisposeMenu( menu ) ; } // ---------------------------------------------------------------------------- diff --git a/src/mac/frame.cpp b/src/mac/frame.cpp index f8347b5ddd..e3824f30bb 100644 --- a/src/mac/frame.cpp +++ b/src/mac/frame.cpp @@ -53,16 +53,16 @@ bool wxFrame::m_useNativeStatusBar = FALSE; void wxFrame::Init() { - m_frameMenuBar = NULL; - + m_frameMenuBar = NULL; + #if wxUSE_TOOLBAR - m_frameToolBar = NULL ; + m_frameToolBar = NULL ; #endif - m_frameStatusBar = NULL; - m_winLastFocused = NULL ; - + m_frameStatusBar = NULL; + m_winLastFocused = NULL ; + m_iconized = FALSE; - + #if wxUSE_TOOLTIPS m_hwndToolTip = 0; #endif @@ -70,7 +70,7 @@ void wxFrame::Init() wxPoint wxFrame::GetClientAreaOrigin() const { - // on mac we are at position -1,-1 with the control + // on mac we are at position -1,-1 with the control wxPoint pt(0, 0); #if wxUSE_TOOLBAR @@ -101,27 +101,26 @@ bool wxFrame::Create(wxWindow *parent, long style, const wxString& name) { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); - + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); + if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) return FALSE; - - MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; - - m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; - SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; - - wxModelessWindows.Append(this); - - return TRUE; + + MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; + + m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; + SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; + + wxModelessWindows.Append(this); + + return TRUE; } wxFrame::~wxFrame() { - m_isBeingDeleted = TRUE; - - DeleteAllBars(); - + m_isBeingDeleted = TRUE; + + DeleteAllBars(); } @@ -130,14 +129,14 @@ bool wxFrame::Enable(bool enable) if ( !wxWindow::Enable(enable) ) return FALSE; - if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() ) - { - int iMaxMenu = m_frameMenuBar->GetMenuCount(); - for ( int i = 0 ; i < iMaxMenu ; ++ i ) - { - m_frameMenuBar->EnableTop( i , enable ) ; - } - } + if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() ) + { + int iMaxMenu = m_frameMenuBar->GetMenuCount(); + for ( int i = 0 ; i < iMaxMenu ; ++ i ) + { + m_frameMenuBar->EnableTop( i , enable ) ; + } + } return TRUE; } @@ -149,24 +148,24 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, statusBar = new wxStatusBar(this, id, style, name); - statusBar->SetSize( 100 , 15 ) ; + statusBar->SetSize( 100 , 15 ) ; statusBar->SetFieldsCount(number); return statusBar; } void wxFrame::PositionStatusBar() { - if (m_frameStatusBar ) - { - int w, h; - GetClientSize(&w, &h); - int sw, sh; - m_frameStatusBar->GetSize(&sw, &sh); - - // Since we wish the status bar to be directly under the client area, - // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. - m_frameStatusBar->SetSize(0, h, w, sh); - } + if (m_frameStatusBar ) + { + int w, h; + GetClientSize(&w, &h); + int sw, sh; + m_frameStatusBar->GetSize(&sw, &sh); + + // Since we wish the status bar to be directly under the client area, + // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. + m_frameStatusBar->SetSize(0, h, w, sh); + } } // Responds to colour changes, and passes event on to children. @@ -215,8 +214,8 @@ void wxFrame::OnActivate(wxActivateEvent& event) event.Skip(); } - else - { + else + { // restore focus to the child which was last focused wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent() : NULL; @@ -225,19 +224,19 @@ void wxFrame::OnActivate(wxActivateEvent& event) parent = this; } - wxSetFocusToChild(parent, &m_winLastFocused); + wxSetFocusToChild(parent, &m_winLastFocused); - if ( m_frameMenuBar != NULL ) - { - m_frameMenuBar->MacInstallMenuBar() ; - } - else if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame))) + if ( m_frameMenuBar != NULL ) + { + m_frameMenuBar->MacInstallMenuBar() ; + } + else if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame))) { // Trying toplevel frame menbar if( ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar() ) - ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar()->MacInstallMenuBar(); - } - } + ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar()->MacInstallMenuBar(); + } + } } void wxFrame::DetachMenuBar() @@ -262,40 +261,40 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) void wxFrame::DoGetClientSize(int *x, int *y) const { - wxWindow::DoGetClientSize( x , y ) ; - + wxWindow::DoGetClientSize( x , y ) ; + #if wxUSE_STATUSBAR - if ( GetStatusBar() && y ) - { - int statusX, statusY; - GetStatusBar()->GetClientSize(&statusX, &statusY); - *y -= statusY; - } + if ( GetStatusBar() && y ) + { + int statusX, statusY; + GetStatusBar()->GetClientSize(&statusX, &statusY); + *y -= statusY; + } #endif // wxUSE_STATUSBAR - - wxPoint pt(GetClientAreaOrigin()); - if ( y ) - *y -= pt.y; - if ( x ) - *x -= pt.x; + + wxPoint pt(GetClientAreaOrigin()); + if ( y ) + *y -= pt.y; + if ( x ) + *x -= pt.x; } void wxFrame::DoSetClientSize(int clientwidth, int clientheight) { - int currentclientwidth , currentclientheight ; - int currentwidth , currentheight ; - - GetClientSize( ¤tclientwidth , ¤tclientheight ) ; - GetSize( ¤twidth , ¤theight ) ; - - // find the current client size + int currentclientwidth , currentclientheight ; + int currentwidth , currentheight ; + + GetClientSize( ¤tclientwidth , ¤tclientheight ) ; + GetSize( ¤twidth , ¤theight ) ; + + // find the current client size // Find the difference between the entire window (title bar and all) // and the client area; add this to the new client size to move the // window - DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth , - currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ; + DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth , + currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ; } @@ -314,8 +313,8 @@ void wxFrame::PositionToolBar() { int cw, ch; - cw = m_width ; - ch = m_height ; + cw = m_width ; + ch = m_height ; if ( GetStatusBar() ) { diff --git a/src/mac/gauge.cpp b/src/mac/gauge.cpp index 4757f6ca43..1a61e4f723 100644 --- a/src/mac/gauge.cpp +++ b/src/mac/gauge.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -29,25 +29,25 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - wxSize size = s ; - Rect bounds ; - Str255 title ; - m_rangeMax = range ; - m_gaugePos = 0 ; - - if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y) - { - size = wxSize( 200 , 16 ) ; - } - - MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range, - kControlProgressBarProc , (long) this ) ; - - MacPostControlCreate() ; - - return TRUE; + wxSize size = s ; + Rect bounds ; + Str255 title ; + m_rangeMax = range ; + m_gaugePos = 0 ; + + if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y) + { + size = wxSize( 200 , 16 ) ; + } + + MacPreControlCreate( parent , id , "" , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range, + kControlProgressBarProc , (long) this ) ; + + MacPostControlCreate() ; + + return TRUE; } void wxGauge::SetShadowWidth(int w) @@ -67,7 +67,7 @@ void wxGauge::SetRange(int r) void wxGauge::SetValue(int pos) { m_gaugePos = pos; - ::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ; + ::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ; } int wxGauge::GetShadowWidth() const diff --git a/src/mac/gdiobj.cpp b/src/mac/gdiobj.cpp index 76bc6a264e..528c5a7efe 100644 --- a/src/mac/gdiobj.cpp +++ b/src/mac/gdiobj.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/glcanvas.cpp b/src/mac/glcanvas.cpp index 027bc28a8a..345fc2aeaf 100644 --- a/src/mac/glcanvas.cpp +++ b/src/mac/glcanvas.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -34,82 +34,82 @@ #include "wx/mac/uma.h" /* - * GLContext implementation - */ +* GLContext implementation +*/ wxGLContext::wxGLContext( - AGLPixelFormat fmt, wxGLCanvas *win, - const wxPalette& palette, - const wxGLContext *other /* for sharing display lists */ -) + AGLPixelFormat fmt, wxGLCanvas *win, + const wxPalette& palette, + const wxGLContext *other /* for sharing display lists */ + ) { m_window = win; - + m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetRootWindow())); - + m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL); wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") ); - - GLboolean b; + + GLboolean b; b = aglSetDrawable(m_glContext, m_drawable); wxCHECK_RET( b, wxT("Couldn't bind OpenGl context") ); - aglEnable(m_glContext , AGL_BUFFER_RECT ) ; + aglEnable(m_glContext , AGL_BUFFER_RECT ) ; b = aglSetCurrentContext(m_glContext); wxCHECK_RET( b, wxT("Couldn't activate OpenGl context") ); } wxGLContext::~wxGLContext() { - if (m_glContext) - { - aglSetCurrentContext(NULL); - aglDestroyContext(m_glContext); - } + if (m_glContext) + { + aglSetCurrentContext(NULL); + aglDestroyContext(m_glContext); + } } void wxGLContext::SwapBuffers() { - if (m_glContext) - { - aglSwapBuffers(m_glContext); - } + if (m_glContext) + { + aglSwapBuffers(m_glContext); + } } void wxGLContext::SetCurrent() { - if (m_glContext) - { - aglSetCurrentContext(m_glContext); - } + if (m_glContext) + { + aglSetCurrentContext(m_glContext); + } } void wxGLContext::Update() { - if (m_glContext) - { - aglUpdateContext(m_glContext); - } + if (m_glContext) + { + aglUpdateContext(m_glContext); + } } void wxGLContext::SetColour(const char *colour) { - float r = 0.0; - float g = 0.0; - float b = 0.0; - wxColour *col = wxTheColourDatabase->FindColour(colour); - if (col) - { - r = (float)(col->Red()/256.0); - g = (float)(col->Green()/256.0); - b = (float)(col->Blue()/256.0); - glColor3f( r, g, b); - } + float r = 0.0; + float g = 0.0; + float b = 0.0; + wxColour *col = wxTheColourDatabase->FindColour(colour); + if (col) + { + r = (float)(col->Red()/256.0); + g = (float)(col->Green()/256.0); + b = (float)(col->Blue()/256.0); + glColor3f( r, g, b); + } } /* - * wxGLCanvas implementation - */ +* wxGLCanvas implementation +*/ IMPLEMENT_CLASS(wxGLCanvas, wxWindow) @@ -118,23 +118,23 @@ BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow) END_EVENT_TABLE() wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette) + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette) { Create(parent, NULL, id, pos, size, style, name, attribList, palette); } wxGLCanvas::wxGLCanvas( wxWindow *parent, - const wxGLContext *shared, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette ) + const wxGLContext *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette ) { Create(parent, shared, id, pos, size, style, name, attribList, palette); } wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette ) + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette ) { Create(parent, shared ? shared->GetContext() : NULL, id, pos, size, style, name, attribList, palette); } @@ -151,80 +151,80 @@ static AGLPixelFormat ChoosePixelFormat(const int *attribList) { GLint data[512]; GLint defaultAttribs[] = { AGL_RGBA, - AGL_DOUBLEBUFFER, - AGL_MINIMUM_POLICY, - AGL_DEPTH_SIZE, 1, // use largest available depth buffer - AGL_RED_SIZE, 1, - AGL_GREEN_SIZE, 1, - AGL_BLUE_SIZE, 1, - AGL_ALPHA_SIZE, 0, - AGL_NONE }; + AGL_DOUBLEBUFFER, + AGL_MINIMUM_POLICY, + AGL_DEPTH_SIZE, 1, // use largest available depth buffer + AGL_RED_SIZE, 1, + AGL_GREEN_SIZE, 1, + AGL_BLUE_SIZE, 1, + AGL_ALPHA_SIZE, 0, + AGL_NONE }; GLint *attribs; if (!attribList) { - attribs = defaultAttribs; + attribs = defaultAttribs; } else { - int arg=0, p=0; - - data[p++] = AGL_MINIMUM_POLICY; // make _SIZE tags behave more like GLX - while( (attribList[arg]!=0) && (p<512) ) - { - switch( attribList[arg++] ) + int arg=0, p=0; + + data[p++] = AGL_MINIMUM_POLICY; // make _SIZE tags behave more like GLX + while( (attribList[arg]!=0) && (p<512) ) { - case WX_GL_RGBA: data[p++] = AGL_RGBA; break; - case WX_GL_BUFFER_SIZE: - data[p++]=AGL_BUFFER_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_LEVEL: - data[p++]=AGL_LEVEL; data[p++]=attribList[arg++]; break; - case WX_GL_DOUBLEBUFFER: data[p++] = AGL_DOUBLEBUFFER; break; - case WX_GL_STEREO: data[p++] = AGL_STEREO; break; - case WX_GL_AUX_BUFFERS: - data[p++]=AGL_AUX_BUFFERS; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_RED: - data[p++]=AGL_RED_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_GREEN: - data[p++]=AGL_GREEN_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_BLUE: - data[p++]=AGL_BLUE_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ALPHA: - data[p++]=AGL_ALPHA_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_DEPTH_SIZE: - data[p++]=AGL_DEPTH_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_STENCIL_SIZE: - data[p++]=AGL_STENCIL_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_RED: - data[p++]=AGL_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_GREEN: - data[p++]=AGL_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_BLUE: - data[p++]=AGL_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_ALPHA: - data[p++]=AGL_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break; - default: - break; - } - } - data[p] = 0; - - attribs = data; + switch( attribList[arg++] ) + { + case WX_GL_RGBA: data[p++] = AGL_RGBA; break; + case WX_GL_BUFFER_SIZE: + data[p++]=AGL_BUFFER_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_LEVEL: + data[p++]=AGL_LEVEL; data[p++]=attribList[arg++]; break; + case WX_GL_DOUBLEBUFFER: data[p++] = AGL_DOUBLEBUFFER; break; + case WX_GL_STEREO: data[p++] = AGL_STEREO; break; + case WX_GL_AUX_BUFFERS: + data[p++]=AGL_AUX_BUFFERS; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_RED: + data[p++]=AGL_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_GREEN: + data[p++]=AGL_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_BLUE: + data[p++]=AGL_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ALPHA: + data[p++]=AGL_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_DEPTH_SIZE: + data[p++]=AGL_DEPTH_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_STENCIL_SIZE: + data[p++]=AGL_STENCIL_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_RED: + data[p++]=AGL_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_GREEN: + data[p++]=AGL_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_BLUE: + data[p++]=AGL_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_ALPHA: + data[p++]=AGL_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + default: + break; + } + } + data[p] = 0; + + attribs = data; } return aglChoosePixelFormat(NULL, 0, attribs); } bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, const wxString& name, - int *attribList, const wxPalette& palette) + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette) { wxWindow::Create( parent, id, pos, size, style, name ); - + AGLPixelFormat fmt = ChoosePixelFormat(attribList); wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); - + m_glContext = new wxGLContext(fmt, this, palette, shared); - + aglDestroyPixelFormat(fmt); return true; @@ -232,20 +232,20 @@ bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID void wxGLCanvas::SwapBuffers() { - if (m_glContext) - m_glContext->SwapBuffers(); + if (m_glContext) + m_glContext->SwapBuffers(); } void wxGLCanvas::UpdateContext() { - if (m_glContext) - m_glContext->Update(); + if (m_glContext) + m_glContext->Update(); } void wxGLCanvas::SetViewport() { - // viewport is initially set to entire port - // adjust glViewport to just this window + // viewport is initially set to entire port + // adjust glViewport to just this window int x = 0 ; int y = 0 ; @@ -259,49 +259,49 @@ void wxGLCanvas::SetViewport() parms[1] = bounds.bottom - bounds.top - ( y + height ) ; parms[2] = width ; parms[3] = height ; - - aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; + + aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; } void wxGLCanvas::OnSize(wxSizeEvent& event) { - MacUpdateView() ; + MacUpdateView() ; } void wxGLCanvas::MacUpdateView() { - if (m_glContext) - { - UpdateContext(); - m_glContext->SetCurrent(); - SetViewport(); - } + if (m_glContext) + { + UpdateContext(); + m_glContext->SetCurrent(); + SetViewport(); + } } void wxGLCanvas::MacSuperChangedPosition() { - MacUpdateView() ; - wxWindow::MacSuperChangedPosition() ; + MacUpdateView() ; + wxWindow::MacSuperChangedPosition() ; } void wxGLCanvas::MacTopLevelWindowChangedPosition() { - MacUpdateView() ; - wxWindow::MacTopLevelWindowChangedPosition() ; + MacUpdateView() ; + wxWindow::MacTopLevelWindowChangedPosition() ; } void wxGLCanvas::SetCurrent() { - if (m_glContext) - { - m_glContext->SetCurrent(); - } + if (m_glContext) + { + m_glContext->SetCurrent(); + } } void wxGLCanvas::SetColour(const char *colour) { - if (m_glContext) - m_glContext->SetColour(colour); + if (m_glContext) + m_glContext->SetColour(colour); } diff --git a/src/mac/helpxxxx.cpp b/src/mac/helpxxxx.cpp index 8428f4fa7b..f41727e61b 100644 --- a/src/mac/helpxxxx.cpp +++ b/src/mac/helpxxxx.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -47,7 +47,7 @@ bool wxXXXXHelpController::LoadFile(const wxString& file) bool wxXXXXHelpController::DisplayContents() { // TODO - return FALSE; + return FALSE; } bool wxXXXXHelpController::DisplaySection(int section) diff --git a/src/mac/icon.cpp b/src/mac/icon.cpp index df10cf7b45..ef4526a670 100644 --- a/src/mac/icon.cpp +++ b/src/mac/icon.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -59,16 +59,16 @@ wxIcon::~wxIcon() bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, int desiredWidth, int desiredHeight) { - UnRef(); - - m_refData = new wxBitmapRefData; - - wxBitmapHandler *handler = FindHandler((wxBitmapType)type); - - if ( handler ) - return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); - else - return FALSE; + UnRef(); + + m_refData = new wxBitmapRefData; + + wxBitmapHandler *handler = FindHandler((wxBitmapType)type); + + if ( handler ) + return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); + else + return FALSE; } void wxIcon::CopyFromBitmap(const wxBitmap& bmp) @@ -80,9 +80,9 @@ void wxIcon::CopyFromBitmap(const wxBitmap& bmp) IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler) bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) + int desiredWidth, int desiredHeight) { - short theId = -1 ; + short theId = -1 ; if ( name == "wxICON_INFORMATION" ) { theId = kNoteIcon ; @@ -93,46 +93,46 @@ bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo } else if ( name == "wxICON_WARNING" ) { - theId = kCautionIcon ; - } + theId = kCautionIcon ; + } else if ( name == "wxICON_ERROR" ) { theId = kStopIcon ; } else { - Str255 theName ; - OSType theType ; - - #if TARGET_CARBON - c2pstrcpy( (StringPtr) theName , name ) ; - #else - strcpy( (char *) theName , name ) ; - c2pstr( (char *) theName ) ; - #endif - - Handle resHandle = GetNamedResource( 'cicn' , theName ) ; - if ( resHandle != 0L ) - { - GetResInfo( resHandle , &theId , &theType , theName ) ; - ReleaseResource( resHandle ) ; - } + Str255 theName ; + OSType theType ; + +#if TARGET_CARBON + c2pstrcpy( (StringPtr) theName , name ) ; +#else + strcpy( (char *) theName , name ) ; + c2pstr( (char *) theName ) ; +#endif + + Handle resHandle = GetNamedResource( 'cicn' , theName ) ; + if ( resHandle != 0L ) + { + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + } + } + if ( theId != -1 ) + { + CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ; + if ( theIcon ) + { + M_BITMAPHANDLERDATA->m_hIcon = theIcon ; + M_BITMAPHANDLERDATA->m_width = 32 ; + M_BITMAPHANDLERDATA->m_height = 32 ; + + M_BITMAPHANDLERDATA->m_depth = 8 ; + M_BITMAPHANDLERDATA->m_ok = true ; + M_BITMAPHANDLERDATA->m_numColors = 256 ; + M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ; + return TRUE ; + } } - if ( theId != -1 ) - { - CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ; - if ( theIcon ) - { - M_BITMAPHANDLERDATA->m_hIcon = theIcon ; - M_BITMAPHANDLERDATA->m_width = 32 ; - M_BITMAPHANDLERDATA->m_height = 32 ; - - M_BITMAPHANDLERDATA->m_depth = 8 ; - M_BITMAPHANDLERDATA->m_ok = true ; - M_BITMAPHANDLERDATA->m_numColors = 256 ; - M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ; - return TRUE ; - } - } - return FALSE ; + return FALSE ; } diff --git a/src/mac/joystick.cpp b/src/mac/joystick.cpp index 5a39ba118b..6a45f419fd 100644 --- a/src/mac/joystick.cpp +++ b/src/mac/joystick.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -282,5 +282,5 @@ bool wxJoystick::ReleaseCapture() } #endif - // wxUSE_JOYSTICK + // wxUSE_JOYSTICK diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 67704b9660..2d7dff4fbc 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -24,11 +24,11 @@ #include "wx/utils.h" #if !USE_SHARED_LIBRARY - IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) BEGIN_EVENT_TABLE(wxListBox, wxControl) - EVT_SIZE( wxListBox::OnSize ) - EVT_CHAR( wxListBox::OnChar ) + EVT_SIZE( wxListBox::OnSize ) + EVT_CHAR( wxListBox::OnChar ) END_EVENT_TABLE() #endif @@ -43,8 +43,8 @@ END_EVENT_TABLE() #endif typedef struct { - unsigned short instruction; - void (*function)(); + unsigned short instruction; + void (*function)(); } ldefRec, *ldefPtr, **ldefHandle; #if PRAGMA_STRUCT_ALIGN @@ -77,105 +77,105 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect RgnHandle savedClipRegion; SInt32 savedPenMode; wxListBox* list; - GetPort(&savePort); - SetPort((**listHandle).port); - grafPtr = (**listHandle).port ; + GetPort(&savePort); + SetPort((**listHandle).port); + grafPtr = (**listHandle).port ; // typecast our refCon list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); - + // Calculate the cell rect. - + switch( message ) { - case lInitMsg: - break; - - case lCloseMsg: - break; - - case lDrawMsg: + case lInitMsg: + break; + + case lCloseMsg: + break; + + case lDrawMsg: { const wxString text = list->m_stringArray[cell.v] ; - + // Save the current clip region, and set the clip region to the area we are about // to draw. - + savedClipRegion = NewRgn(); GetClip( savedClipRegion ); - + ClipRect( drawRect ); EraseRect( drawRect ); - - wxFontRefData * font = (wxFontRefData*) list->GetFont().GetRefData() ; - - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - } - else - { - ::TextFont( kFontIDMonaco ) ; - ::TextSize( 9 ); - ::TextFace( 0 ) ; - } - + + wxFontRefData * font = (wxFontRefData*) list->GetFont().GetRefData() ; + + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( short(font->m_macFontSize) ) ; + ::TextFace( font->m_macFontStyle ) ; + } + else + { + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + } + #if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; - - if ( useDrawThemeText ) - { - Rect frame = { drawRect->top, drawRect->left + 4, - drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; + bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; + + if ( useDrawThemeText ) + { + Rect frame = { drawRect->top, drawRect->left + 4, + drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ; CFStringRef sString = CFStringCreateWithBytes( NULL , (UInt8*) text.c_str(), text.Length(), CFStringGetSystemEncoding(), false ) ; CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , sString ) ; - CFRelease( sString ) ; - ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - false, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; + CFRelease( sString ) ; + ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ; + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; } - else + else #endif - { - MoveTo(drawRect->left + 4 , drawRect->top + 10 ); - DrawText(text, 0 , text.Length()); - } - + { + MoveTo(drawRect->left + 4 , drawRect->top + 10 ); + DrawText(text, 0 , text.Length()); + } + // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. - + if( isSelected ) { savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr ); SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode ); PaintRect( drawRect ); SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode ); } - + // Restore the saved clip region. - + SetClip( savedClipRegion ); DisposeRgn( savedClipRegion ); - } - break; - case lHiliteMsg: - - // Hilite or unhilite the cell. Paint the cell contents with the - // appropriate QuickDraw transform mode. - - GetPort( &grafPtr ); - savedPenMode = GetPortPenMode( (CGrafPtr)grafPtr ); - SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode ); - PaintRect( drawRect ); - SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode ); - break; - default : - break ; + } + break; + case lHiliteMsg: + + // Hilite or unhilite the cell. Paint the cell contents with the + // appropriate QuickDraw transform mode. + + GetPort( &grafPtr ); + savedPenMode = GetPortPenMode( (CGrafPtr)grafPtr ); + SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode ); + PaintRect( drawRect ); + SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode ); + break; + default : + break ; } SetPort(savePort); } @@ -212,27 +212,27 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - + ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macListDefUPP == NULL ) { - macListDefUPP = NewListDefUPP( wxMacListDefinition ); + macListDefUPP = NewListDefUPP( wxMacListDefinition ); } - listDef.u.userProc = macListDefUPP ; - + listDef.u.userProc = macListDefUPP ; + Str255 fontName ; SInt16 fontSize ; Style fontStyle ; - SInt16 fontNum ; + SInt16 fontNum ; #if TARGET_CARBON - GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; #else - GetFontName( kFontIDMonaco , fontName ) ; - fontSize = 9 ; - fontStyle = normal ; + GetFontName( kFontIDMonaco , fontName ) ; + fontSize = 9 ; + fontStyle = normal ; #endif CopyPascalStringToC( fontName , (char*) fontName ) ; SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , fontName ) ) ; @@ -307,8 +307,8 @@ wxListBox::~wxListBox() if ( m_macList ) { #if !TARGET_CARBON - DisposeHandle( (**(ListHandle)m_macList).listDefProc ) ; - (**(ListHandle)m_macList).listDefProc = NULL ; + DisposeHandle( (**(ListHandle)m_macList).listDefProc ) ; + (**(ListHandle)m_macList).listDefProc = NULL ; #endif m_macList = NULL ; } @@ -406,25 +406,25 @@ int wxListBox::DoAppend(const wxString& item) void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) { - MacSetRedraw( false ) ; - Clear() ; - int n = choices.GetCount(); - - for( int i = 0 ; i < n ; ++i ) - { - if ( clientData ) + MacSetRedraw( false ) ; + Clear() ; + int n = choices.GetCount(); + + for( int i = 0 ; i < n ; ++i ) { + if ( clientData ) + { #if wxUSE_OWNER_DRAWN wxASSERT_MSG(clientData[i] == NULL, - wxT("Can't use client data with owner-drawn listboxes")); + wxT("Can't use client data with owner-drawn listboxes")); #else // !wxUSE_OWNER_DRAWN - Append( choices[i] , clientData[i] ) ; - #endif + Append( choices[i] , clientData[i] ) ; +#endif + } + else + Append( choices[i] ) ; } - else - Append( choices[i] ) ; - } - + #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { // first delete old items @@ -434,7 +434,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) m_aItems[ui] = NULL; } m_aItems.Empty(); - + // then create new ones for ( ui = 0; ui < (size_t)m_noItems; ui++ ) { wxOwnerDrawn *pNewItem = CreateItem(ui); @@ -443,7 +443,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) } } #endif // wxUSE_OWNER_DRAWN - MacSetRedraw( true ) ; + MacSetRedraw( true ) ; } bool wxListBox::HasMultipleSelection() const @@ -460,20 +460,20 @@ int wxListBox::FindString(const wxString& st) const } else s = st ; - + if ( s.Right(1) == "*" ) { wxString search = s.Left( s.Length() - 1 ) ; int len = search.Length() ; Str255 s1 , s2 ; - + #if TARGET_CARBON c2pstrcpy( (StringPtr) s2 , search.c_str() ) ; #else strcpy( (char *) s2 , search.c_str() ) ; c2pstr( (char *) s2 ) ; #endif - + for ( int i = 0 ; i < m_noItems ; ++ i ) { #if TARGET_CARBON @@ -495,19 +495,19 @@ int wxListBox::FindString(const wxString& st) const return i ; } } - + } else { Str255 s1 , s2 ; - + #if TARGET_CARBON c2pstrcpy( (StringPtr) s2 , s.c_str() ) ; #else strcpy( (char *) s2 , s.c_str() ) ; c2pstr( (char *) s2 ) ; #endif - + for ( int i = 0 ; i < m_noItems ; ++ i ) { #if TARGET_CARBON @@ -519,40 +519,40 @@ int wxListBox::FindString(const wxString& st) const if ( EqualString( s1 , s2 , false , false ) ) return i ; } - } - return -1; + } + return -1; } void wxListBox::Clear() { - FreeData(); - m_noItems = 0; - m_stringArray.Empty() ; - m_dataArray.Empty() ; - MacClear() ; + FreeData(); + m_noItems = 0; + m_stringArray.Empty() ; + m_dataArray.Empty() ; + MacClear() ; } void wxListBox::SetSelection(int N, bool select) { wxCHECK_RET( N >= 0 && N < m_noItems, - "invalid index in wxListBox::SetSelection" ); - MacSetSelection( N , select ) ; - GetSelections( m_selectionPreImage ) ; + "invalid index in wxListBox::SetSelection" ); + MacSetSelection( N , select ) ; + GetSelections( m_selectionPreImage ) ; } bool wxListBox::IsSelected(int N) const { wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE, - "invalid index in wxListBox::Selected" ); - - return MacIsSelected( N ) ; + "invalid index in wxListBox::Selected" ); + + return MacIsSelected( N ) ; } void *wxListBox::DoGetItemClientData(int N) const { wxCHECK_MSG( N >= 0 && N < m_noItems, NULL, - wxT("invalid index in wxListBox::GetClientData")); - + wxT("invalid index in wxListBox::GetClientData")); + return (void *)m_dataArray[N]; } @@ -564,8 +564,8 @@ wxClientData *wxListBox::DoGetItemClientObject(int N) const void wxListBox::DoSetItemClientData(int N, void *Client_data) { wxCHECK_RET( N >= 0 && N < m_noItems, - "invalid index in wxListBox::SetClientData" ); - + "invalid index in wxListBox::SetClientData" ); + #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) { @@ -575,7 +575,7 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data) } #endif // wxUSE_OWNER_DRAWN wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , "invalid client_data array" ) ; - + if ( m_dataArray.GetCount() > (size_t) N ) { m_dataArray[N] = (char*) Client_data ; @@ -617,17 +617,17 @@ wxString wxListBox::GetString(int N) const void wxListBox::DoInsertItems(const wxArrayString& items, int pos) { wxCHECK_RET( pos >= 0 && pos <= m_noItems, - wxT("invalid index in wxListBox::InsertItems") ); - + wxT("invalid index in wxListBox::InsertItems") ); + int nItems = items.GetCount(); - + for ( int i = 0 ; i < nItems ; i++ ) { m_stringArray.Insert( items[i] , pos + i ) ; m_dataArray.Insert( NULL , pos + i ) ; MacInsert( pos + i , items[i] ) ; } - + m_noItems += nItems; } @@ -649,44 +649,44 @@ wxSize wxListBox::DoGetBestSize() const int lbWidth = 100; // some defaults int lbHeight = 110; int wLine; - - { - wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; - - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - } - else - { - ::TextFont( kFontIDMonaco ) ; - ::TextSize( 9 ); - ::TextFace( 0 ) ; - } - - // Find the widest line - for(int i = 0; i < GetCount(); i++) { - wxString str(GetString(i)); - wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; - lbWidth = wxMax(lbWidth, wLine); - } - - // Add room for the scrollbar - lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - - // And just a bit more - int cy = 12 ; - int cx = ::TextWidth( "X" , 0 , 1 ) ; - lbWidth += cx ; - - // don't make the listbox too tall (limit height to around 10 items) but don't - // make it too small neither - lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10); - } + + { + wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; + + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( short(font->m_macFontSize) ) ; + ::TextFace( font->m_macFontStyle ) ; + } + else + { + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + } + + // Find the widest line + for(int i = 0; i < GetCount(); i++) { + wxString str(GetString(i)); + wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; + lbWidth = wxMax(lbWidth, wLine); + } + + // Add room for the scrollbar + lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); + + // And just a bit more + int cy = 12 ; + int cx = ::TextWidth( "X" , 0 , 1 ) ; + lbWidth += cx ; + + // don't make the listbox too tall (limit height to around 10 items) but don't + // make it too small neither + lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10); + } return wxSize(lbWidth, lbHeight); } @@ -704,7 +704,7 @@ void wxListBox::SetupColours() void wxListBox::Refresh(bool eraseBack, const wxRect *rect) { wxControl::Refresh( eraseBack , rect ) ; -// MacRedrawControl() ; + // MacRedrawControl() ; } #if wxUSE_OWNER_DRAWN @@ -735,18 +735,18 @@ wxOwnerDrawn *wxListBox::CreateItem(size_t n) /* void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) { - wxListBox* list; - // typecast our refCon - list = (wxListBox*)refCon; - - MoveTo(cellRect->left + 4 , cellRect->top + 10 ); - const wxString text = list->m_stringArray[lCell.v] ; - ::TextFont( kFontIDMonaco ) ; - ::TextSize( 9 ); - ::TextFace( 0 ) ; - DrawText(text, 0 , text.Length()); - -} +wxListBox* list; +// typecast our refCon +list = (wxListBox*)refCon; + + MoveTo(cellRect->left + 4 , cellRect->top + 10 ); + const wxString text = list->m_stringArray[lCell.v] ; + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + DrawText(text, 0 , text.Length()); + + } */ void wxListBox::MacDelete( int N ) { @@ -759,7 +759,7 @@ void wxListBox::MacInsert( int n , const char * text) Cell cell = { 0 , 0 } ; cell.v = n ; LAddRow( 1 , cell.v , (ListHandle)m_macList ) ; -// LSetCell(text, strlen(text), cell, m_macList); + // LSetCell(text, strlen(text), cell, m_macList); Refresh(); } @@ -768,7 +768,7 @@ void wxListBox::MacAppend( const char * text) Cell cell = { 0 , 0 } ; cell.v = (**(ListHandle)m_macList).dataBounds.bottom ; LAddRow( 1 , cell.v , (ListHandle)m_macList ) ; - // LSetCell(text, strlen(text), cell, m_macList); + // LSetCell(text, strlen(text), cell, m_macList); Refresh(); } @@ -788,7 +788,7 @@ void wxListBox::MacSetSelection( int n , bool select ) LSetSelect( false , cell , (ListHandle)m_macList ) ; } } - + cell.v = n ; LSetSelect( select , cell , (ListHandle)m_macList ) ; LAutoScroll( (ListHandle)m_macList ) ; @@ -804,7 +804,7 @@ bool wxListBox::MacIsSelected( int n ) const void wxListBox::MacDestroy() { -// DisposeExtLDEFInfo( m_macList ) ; + // DisposeExtLDEFInfo( m_macList ) ; } int wxListBox::MacGetSelection() const @@ -819,12 +819,12 @@ int wxListBox::MacGetSelection() const int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const { int no_sel = 0 ; - + aSelections.Empty(); - + Cell cell = { 0 , 0 } ; cell.v = 0 ; - + while ( LGetSelect( true , &cell ,(ListHandle) m_macList ) ) { aSelections.Add( cell.v ) ; @@ -840,7 +840,7 @@ void wxListBox::MacSet( int n , const char * text ) // so we just have to redraw Cell cell = { 0 , 0 } ; cell.v = n ; -// LSetCell(text, strlen(text), cell, m_macList); + // LSetCell(text, strlen(text), cell, m_macList); Refresh(); } @@ -852,7 +852,7 @@ void wxListBox::MacScrollTo( int n ) void wxListBox::OnSize( const wxSizeEvent &event) { Point pt; - + #if TARGET_CARBON GetListCellSize((ListHandle)m_macList, &pt); #else @@ -866,7 +866,7 @@ void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { Boolean wasDoubleClick = false ; long result ; - + ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ; if ( !wasDoubleClick ) { @@ -881,7 +881,7 @@ void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) void wxListBox::MacSetRedraw( bool doDraw ) { LSetDrawingMode( doDraw , (ListHandle)m_macList ) ; - + } void wxListBox::MacDoClick() @@ -889,7 +889,7 @@ void wxListBox::MacDoClick() wxArrayInt aSelections; int n ; size_t count = GetSelections(aSelections); - + if ( count == m_selectionPreImage.GetCount() ) { bool hasChanged = false ; @@ -906,12 +906,12 @@ void wxListBox::MacDoClick() return ; } } - + m_selectionPreImage = aSelections; - + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); event.SetEventObject( this ); - + if ( count > 0 ) { n = aSelections[0]; @@ -923,11 +923,11 @@ void wxListBox::MacDoClick() } else { - n = -1; + n = -1; } - + event.m_commandInt = n; - + GetEventHandler()->ProcessEvent(event); } @@ -935,35 +935,35 @@ void wxListBox::MacDoDoubleClick() { wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId); event.SetEventObject( this ); - GetEventHandler()->ProcessEvent(event) ; + GetEventHandler()->ProcessEvent(event) ; } void wxListBox::OnChar(wxKeyEvent& event) { if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER) { - wxWindow* parent = GetParent() ; - while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) - parent = parent->GetParent() ; - - if ( parent && parent->GetDefaultItem() ) - { - wxButton *def = wxDynamicCast(parent->GetDefaultItem(), - wxButton); - if ( def && def->IsEnabled() ) - { - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); - event.SetEventObject(def); - def->Command(event); - return ; - } - } - event.Skip() ; + wxWindow* parent = GetParent() ; + while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) + parent = parent->GetParent() ; + + if ( parent && parent->GetDefaultItem() ) + { + wxButton *def = wxDynamicCast(parent->GetDefaultItem(), + wxButton); + if ( def && def->IsEnabled() ) + { + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); + event.SetEventObject(def); + def->Command(event); + return ; + } + } + event.Skip() ; } /* generate wxID_CANCEL if command-. or has been pressed (typically in dialogs) */ else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) ) { - wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ; + wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ; wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); new_event.SetEventObject( win ); win->GetEventHandler()->ProcessEvent( new_event ); @@ -977,64 +977,64 @@ void wxListBox::OnChar(wxKeyEvent& event) new_event.SetWindowChange( event.ControlDown() ); new_event.SetCurrentFocus( this ); if ( !GetEventHandler()->ProcessEvent( new_event ) ) - event.Skip() ; + event.Skip() ; } - else if ( event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_UP ) - { - // perform the default key handling first - wxControl::OnKeyDown( event ) ; - + else if ( event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_UP ) + { + // perform the default key handling first + wxControl::OnKeyDown( event ) ; + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); event.SetEventObject( this ); - + wxArrayInt aSelections; int n, count = GetSelections(aSelections); if ( count > 0 ) { - n = aSelections[0]; - if ( HasClientObjectData() ) - event.SetClientObject( GetClientObject(n) ); - else if ( HasClientUntypedData() ) - event.SetClientData( GetClientData(n) ); - event.SetString( GetString(n) ); + n = aSelections[0]; + if ( HasClientObjectData() ) + event.SetClientObject( GetClientObject(n) ); + else if ( HasClientUntypedData() ) + event.SetClientData( GetClientData(n) ); + event.SetString( GetString(n) ); } else { - n = -1; + n = -1; } - + event.m_commandInt = n; - + GetEventHandler()->ProcessEvent(event); - } - else - { - if ( event.GetTimestamp() > m_lastTypeIn + 60 ) - { - m_typeIn = "" ; - } - m_lastTypeIn = event.GetTimestamp() ; - m_typeIn += (char) event.GetKeyCode() ; - int line = FindString("*"+m_typeIn+"*") ; - if ( line >= 0 ) - { - if ( GetSelection() != line ) - { - SetSelection(line) ; - wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); - event.SetEventObject( this ); - - if ( HasClientObjectData() ) - event.SetClientObject( GetClientObject( line ) ); - else if ( HasClientUntypedData() ) - event.SetClientData( GetClientData(line) ); - event.SetString( GetString(line) ); - - event.m_commandInt = line ; - - GetEventHandler()->ProcessEvent(event); - } - } - } + } + else + { + if ( event.GetTimestamp() > m_lastTypeIn + 60 ) + { + m_typeIn = "" ; + } + m_lastTypeIn = event.GetTimestamp() ; + m_typeIn += (char) event.GetKeyCode() ; + int line = FindString("*"+m_typeIn+"*") ; + if ( line >= 0 ) + { + if ( GetSelection() != line ) + { + SetSelection(line) ; + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); + event.SetEventObject( this ); + + if ( HasClientObjectData() ) + event.SetClientObject( GetClientObject( line ) ); + else if ( HasClientUntypedData() ) + event.SetClientData( GetClientData(line) ); + event.SetString( GetString(line) ); + + event.m_commandInt = line ; + + GetEventHandler()->ProcessEvent(event); + } + } + } } diff --git a/src/mac/macnotfy.cpp b/src/mac/macnotfy.cpp index c01f4deaf0..b6a170c8ee 100644 --- a/src/mac/macnotfy.cpp +++ b/src/mac/macnotfy.cpp @@ -17,12 +17,12 @@ const short kMaxEvents = 1000 ; struct wxMacNotificationEvents { - short top ; - short bottom ; - - wxMacNotificationProcPtr proc[kMaxEvents] ; - unsigned long events[kMaxEvents] ; - void* data[kMaxEvents] ; + short top ; + short bottom ; + + wxMacNotificationProcPtr proc[kMaxEvents] ; + unsigned long events[kMaxEvents] ; + void* data[kMaxEvents] ; } ; typedef struct wxMacNotificationEvents wxMacNotificationEvents ; @@ -32,43 +32,43 @@ ProcessSerialNumber gAppProcess ; void wxMacWakeUp() { - ProcessSerialNumber psn ; - Boolean isSame ; - psn.highLongOfPSN = 0 ; - psn.lowLongOfPSN = kCurrentProcess ; - SameProcess( &gAppProcess , &psn , &isSame ) ; - if ( isSame ) - { + ProcessSerialNumber psn ; + Boolean isSame ; + psn.highLongOfPSN = 0 ; + psn.lowLongOfPSN = kCurrentProcess ; + SameProcess( &gAppProcess , &psn , &isSame ) ; + if ( isSame ) + { #if TARGET_CARBON - EventRef dummyEvent ; - OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(), + EventRef dummyEvent ; + OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(), kEventAttributeNone, &dummyEvent); if (err == noErr) { - err = PostEventToQueue(GetMainEventQueue(), dummyEvent, + err = PostEventToQueue(GetMainEventQueue(), dummyEvent, kEventPriorityHigh); } #else - PostEvent( nullEvent , 0 ) ; + PostEvent( nullEvent , 0 ) ; #endif - } - else - { - WakeUpProcess( &gAppProcess ) ; - } + } + else + { + WakeUpProcess( &gAppProcess ) ; + } } void wxMacCreateNotifierTable() { - GetCurrentProcess(&gAppProcess); - gMacNotificationEvents.top = 0 ; - gMacNotificationEvents.bottom = 0 ; - for ( int i = 0 ; i < kMaxEvents ; ++i ) - { - gMacNotificationEvents.proc[i] = NULL ; - gMacNotificationEvents.events[i] = NULL ; - gMacNotificationEvents.data[i] = NULL ; - } + GetCurrentProcess(&gAppProcess); + gMacNotificationEvents.top = 0 ; + gMacNotificationEvents.bottom = 0 ; + for ( int i = 0 ; i < kMaxEvents ; ++i ) + { + gMacNotificationEvents.proc[i] = NULL ; + gMacNotificationEvents.events[i] = NULL ; + gMacNotificationEvents.data[i] = NULL ; + } } void wxMacDestroyNotifierTable() @@ -77,86 +77,86 @@ void wxMacDestroyNotifierTable() wxMacNotifierTableRef wxMacGetNotifierTable() { - return (wxMacNotifierTableRef) &gMacNotificationEvents ; + return (wxMacNotifierTableRef) &gMacNotificationEvents ; } void wxMacAddEvent( - wxMacNotifierTableRef table , - wxMacNotificationProcPtr handler , - unsigned long event , - void* data , - short wakeUp ) + wxMacNotifierTableRef table , + wxMacNotificationProcPtr handler , + unsigned long event , + void* data , + short wakeUp ) { - wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; - wxASSERT_MSG( handler != NULL , "illegal notification proc ptr" ) ; - /* this should be protected eventually */ - short index = e->top++ ; - - if ( e->top == kMaxEvents ) - e->top = 0 ; - - e->proc[index] = handler ; - e->events[index] = event ; - e->data[index] = data ; - if ( wakeUp ) - wxMacWakeUp() ; + wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; + wxASSERT_MSG( handler != NULL , "illegal notification proc ptr" ) ; + /* this should be protected eventually */ + short index = e->top++ ; + + if ( e->top == kMaxEvents ) + e->top = 0 ; + + e->proc[index] = handler ; + e->events[index] = event ; + e->data[index] = data ; + if ( wakeUp ) + wxMacWakeUp() ; } bool gInProcessing = false ; void wxMacRemoveAllNotifiersForData( wxMacNotifierTableRef table , void* data ) { - wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; - /* this should be protected eventually */ - short index = e->bottom ; - - while ( e->top != index ) - { - if ( index == kMaxEvents ) - index = 0 ; - if ( e->data[index] == data ) - e->data[index] = NULL ; - index++ ; - } + wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ; + /* this should be protected eventually */ + short index = e->bottom ; + + while ( e->top != index ) + { + if ( index == kMaxEvents ) + index = 0 ; + if ( e->data[index] == data ) + e->data[index] = NULL ; + index++ ; + } } void wxMacProcessNotifierEvents() { -// if ( gInProcessing ) -// return ; - - gInProcessing = true ; - if ( gMacNotificationEvents.top != gMacNotificationEvents.bottom ) - { - // we only should process the notifiers that were here when we entered it - // otherwise we might never get out... - short count = gMacNotificationEvents.top - gMacNotificationEvents.bottom ; - if ( count < 0 ) - count += kMaxEvents ; - - while ( count-- ) + // if ( gInProcessing ) + // return ; + + gInProcessing = true ; + if ( gMacNotificationEvents.top != gMacNotificationEvents.bottom ) { - // consume event at bottom - short index = gMacNotificationEvents.bottom++ ; - if ( gMacNotificationEvents.bottom == kMaxEvents ) - gMacNotificationEvents.bottom = 0 ; - void* data = gMacNotificationEvents.data[index] ; - unsigned long event = gMacNotificationEvents.events[index] ; - wxMacNotificationProcPtr handler = gMacNotificationEvents.proc[index] ; - - gMacNotificationEvents.data[index] = NULL ; - gMacNotificationEvents.events[index] = NULL ; - gMacNotificationEvents.proc[index] = NULL ; + // we only should process the notifiers that were here when we entered it + // otherwise we might never get out... + short count = gMacNotificationEvents.top - gMacNotificationEvents.bottom ; + if ( count < 0 ) + count += kMaxEvents ; - if ( handler ) - handler( event , data ) ; - } - } - gInProcessing = false ; + while ( count-- ) + { + // consume event at bottom + short index = gMacNotificationEvents.bottom++ ; + if ( gMacNotificationEvents.bottom == kMaxEvents ) + gMacNotificationEvents.bottom = 0 ; + void* data = gMacNotificationEvents.data[index] ; + unsigned long event = gMacNotificationEvents.events[index] ; + wxMacNotificationProcPtr handler = gMacNotificationEvents.proc[index] ; + + gMacNotificationEvents.data[index] = NULL ; + gMacNotificationEvents.events[index] = NULL ; + gMacNotificationEvents.proc[index] = NULL ; + + if ( handler ) + handler( event , data ) ; + } + } + gInProcessing = false ; } void wxMacProcessNotifierAndPendingEvents() { - wxMacProcessNotifierEvents() ; - wxTheApp->ProcessPendingEvents() ; + wxMacProcessNotifierEvents() ; + wxTheApp->ProcessPendingEvents() ; } diff --git a/src/mac/main.cpp b/src/mac/main.cpp index e2cb64e8f5..724d53723d 100644 --- a/src/mac/main.cpp +++ b/src/mac/main.cpp @@ -6,13 +6,13 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/app.h" WXDLLEXPORT int main(int argc, char* argv[]) { - return wxEntry(argc, argv); + return wxEntry(argc, argv); } diff --git a/src/mac/mdi.cpp b/src/mac/mdi.cpp index 9c9a725b48..1d9e43f170 100644 --- a/src/mac/mdi.cpp +++ b/src/mac/mdi.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -71,33 +71,33 @@ bool wxMDIParentFrame::Create(wxWindow *parent, long style, const wxString& name) { - m_clientWindow = NULL; - m_currentChild = NULL; - - // this style can be used to prevent a window from having the standard MDI - // "Window" menu - if ( style & wxFRAME_NO_WINDOW_MENU ) - { - m_windowMenu = (wxMenu *)NULL; - style -= wxFRAME_NO_WINDOW_MENU ; - } - else // normal case: we have the window menu, so construct it - { - m_windowMenu = new wxMenu; - - m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade")); - m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally")); - m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically")); - m_windowMenu->AppendSeparator(); - m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons")); - m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next")); - } - - wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ; - m_parentFrameActive = TRUE; + m_clientWindow = NULL; + m_currentChild = NULL; + + // this style can be used to prevent a window from having the standard MDI + // "Window" menu + if ( style & wxFRAME_NO_WINDOW_MENU ) + { + m_windowMenu = (wxMenu *)NULL; + style -= wxFRAME_NO_WINDOW_MENU ; + } + else // normal case: we have the window menu, so construct it + { + m_windowMenu = new wxMenu; - OnCreateClient(); - + m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade")); + m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally")); + m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically")); + m_windowMenu->AppendSeparator(); + m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons")); + m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next")); + } + + wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ; + m_parentFrameActive = TRUE; + + OnCreateClient(); + return TRUE; } @@ -108,13 +108,13 @@ wxMDIParentFrame::~wxMDIParentFrame() m_frameToolBar = NULL; m_frameStatusBar = NULL; m_clientWindow = NULL ; - + if (m_windowMenu) { delete m_windowMenu; m_windowMenu = (wxMenu*) NULL; } - + if ( m_clientWindow ) { delete m_clientWindow; @@ -126,51 +126,51 @@ wxMDIParentFrame::~wxMDIParentFrame() // Get size *available for subwindows* i.e. excluding menu bar. void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const { - wxDisplaySize( x , y ) ; + wxDisplaySize( x , y ) ; } void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar) { - wxFrame::SetMenuBar( menu_bar ) ; + wxFrame::SetMenuBar( menu_bar ) ; } void wxMDIParentFrame::OnSize(wxSizeEvent& event) { #if wxUSE_CONSTRAINTS if (GetAutoLayout()) - Layout(); + Layout(); #endif int x = 0; int y = 0; int width, height; GetClientSize(&width, &height); - + if ( GetClientWindow() ) GetClientWindow()->SetSize(x, y, width, height); } void wxMDIParentFrame::OnActivate(wxActivateEvent& event) { - if ( m_currentChild && event.GetActive() ) - { - wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); - event.SetEventObject( m_currentChild ); - m_currentChild->GetEventHandler()->ProcessEvent(event) ; - } - else if ( event.GetActive() ) - { - if ( m_frameMenuBar != NULL ) - { - m_frameMenuBar->MacInstallMenuBar() ; - } - - } + if ( m_currentChild && event.GetActive() ) + { + wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); + event.SetEventObject( m_currentChild ); + m_currentChild->GetEventHandler()->ProcessEvent(event) ; + } + else if ( event.GetActive() ) + { + if ( m_frameMenuBar != NULL ) + { + m_frameMenuBar->MacInstallMenuBar() ; + } + + } } // Returns the active MDI child window wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { - return m_currentChild ; + return m_currentChild ; } // Create the client window class (don't Create the window, @@ -185,7 +185,7 @@ wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) { // TODO - + // Propagate the event to the non-top-level children wxFrame::OnSysColourChanged(event); } @@ -227,27 +227,27 @@ void wxMDIChildFrame::Init() } bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) + wxWindowID id, + const wxString& title, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) { SetName(name); - + if ( id > -1 ) m_windowId = id; else m_windowId = (int)NewControlId(); - + if (parent) parent->AddChild(this); - - MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; - - m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; - SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; - + + MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; + + m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; + SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; + wxModelessWindows.Append(this); return FALSE; } @@ -262,7 +262,7 @@ wxMDIChildFrame::~wxMDIChildFrame() void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) { - return wxFrame::SetMenuBar( menu_bar ) ; + return wxFrame::SetMenuBar( menu_bar ) ; } // MDI operations @@ -295,15 +295,15 @@ wxMDIClientWindow::~wxMDIClientWindow() bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) { - + m_windowId = (int)NewControlId(); - + if ( parent ) { - parent->AddChild(this); + parent->AddChild(this); } m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); - + wxModelessWindows.Append(this); return TRUE; } diff --git a/src/mac/menu.cpp b/src/mac/menu.cpp index a5fe24d23b..1d3195a6a7 100644 --- a/src/mac/menu.cpp +++ b/src/mac/menu.cpp @@ -6,10 +6,9 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// - #ifdef __GNUG__ #pragma implementation "menu.h" #pragma implementation "menuitem.h" @@ -70,8 +69,8 @@ void wxMenu::Init() m_startRadioGroup = -1; // create the menu - m_macMenuId = s_macNextMenuId++; - m_hMenu = UMANewMenu(m_macMenuId, m_title); + m_macMenuId = s_macNextMenuId++; + m_hMenu = UMANewMenu(m_macMenuId, m_title); if ( !m_hMenu ) { @@ -88,13 +87,13 @@ void wxMenu::Init() wxMenu::~wxMenu() { - if (MAC_WXHMENU(m_hMenu)) - ::DisposeMenu(MAC_WXHMENU(m_hMenu)); + if (MAC_WXHMENU(m_hMenu)) + ::DisposeMenu(MAC_WXHMENU(m_hMenu)); } void wxMenu::Break() { - // not available on the mac platform + // not available on the mac platform } void wxMenu::Attach(wxMenuBarBase *menubar) @@ -110,60 +109,60 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) { wxASSERT_MSG( pItem != NULL, "can't append NULL item to the menu" ); - if ( pItem->IsSeparator() ) - { - if ( pos == (size_t)-1 ) - MacAppendMenu(MAC_WXHMENU(m_hMenu), "\p-"); - else - MacInsertMenuItem(MAC_WXHMENU(m_hMenu), "\p-" , pos); - } - else - { - wxMenu *pSubMenu = pItem->GetSubMenu() ; - if ( pSubMenu != NULL ) - { - wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added"); - pSubMenu->m_menuParent = this ; - - if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar) - ::InsertMenu( MAC_WXHMENU( pSubMenu->m_hMenu ) , -1 ) ; - - if ( pos == (size_t)-1 ) - UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), pSubMenu->m_macMenuId); - else - UMAInsertSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText() , pos, pSubMenu->m_macMenuId); - pItem->UpdateItemBitmap() ; - pItem->UpdateItemStatus() ; - } - else - { - if ( pos == (size_t)-1 ) - { - UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), "a" ); - pos = CountMenuItems(MAC_WXHMENU(m_hMenu)) ; - } - else - { - UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), "a" , pos); - } - - SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , pItem->GetId() ) ; - pItem->UpdateItemText() ; - pItem->UpdateItemBitmap() ; - pItem->UpdateItemStatus() ; - - if ( pItem->GetId() == idMenuTitle ) - { - UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , pos , false ) ; - } - } - } + if ( pItem->IsSeparator() ) + { + if ( pos == (size_t)-1 ) + MacAppendMenu(MAC_WXHMENU(m_hMenu), "\p-"); + else + MacInsertMenuItem(MAC_WXHMENU(m_hMenu), "\p-" , pos); + } + else + { + wxMenu *pSubMenu = pItem->GetSubMenu() ; + if ( pSubMenu != NULL ) + { + wxASSERT_MSG( pSubMenu->m_hMenu != NULL , "invalid submenu added"); + pSubMenu->m_menuParent = this ; + + if (wxMenuBar::MacGetInstalledMenuBar() == m_menuBar) + ::InsertMenu( MAC_WXHMENU( pSubMenu->m_hMenu ) , -1 ) ; + + if ( pos == (size_t)-1 ) + UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), pSubMenu->m_macMenuId); + else + UMAInsertSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText() , pos, pSubMenu->m_macMenuId); + pItem->UpdateItemBitmap() ; + pItem->UpdateItemStatus() ; + } + else + { + if ( pos == (size_t)-1 ) + { + UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), "a" ); + pos = CountMenuItems(MAC_WXHMENU(m_hMenu)) ; + } + else + { + UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), "a" , pos); + } + + SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , pItem->GetId() ) ; + pItem->UpdateItemText() ; + pItem->UpdateItemBitmap() ; + pItem->UpdateItemStatus() ; + + if ( pItem->GetId() == idMenuTitle ) + { + UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , pos , false ) ; + } + } + } // if we're already attached to the menubar, we must update it if ( IsAttached() ) { m_menuBar->Refresh(); } - return TRUE ; + return TRUE ; } void wxMenu::EndRadioGroup() @@ -250,7 +249,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) // DoRemove() (unlike Remove) can only be called for existing item! wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") ); - ::DeleteMenuItem(MAC_WXHMENU(m_hMenu) , pos + 1); + ::DeleteMenuItem(MAC_WXHMENU(m_hMenu) , pos + 1); if ( IsAttached() ) { @@ -264,8 +263,8 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) void wxMenu::SetTitle(const wxString& label) { - m_title = label ; - UMASetMenuTitle(MAC_WXHMENU(m_hMenu) , label ) ; + m_title = label ; + UMASetMenuTitle(MAC_WXHMENU(m_hMenu) , label ) ; } bool wxMenu::ProcessCommand(wxCommandEvent & event) { @@ -324,11 +323,11 @@ int wxMenu::MacGetIndexFromId( int id ) node = node->GetNext(); } - + if (!node) - return 0; - - return pos + 1 ; + return 0; + + return pos + 1 ; } int wxMenu::MacGetIndexFromItem( wxMenuItem *pItem ) @@ -344,16 +343,16 @@ int wxMenu::MacGetIndexFromItem( wxMenuItem *pItem ) } if (!node) - return 0; - - return pos + 1 ; + return 0; + + return pos + 1 ; } void wxMenu::MacEnableMenu( bool bDoEnable ) { - UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , 0 , bDoEnable ) ; - - ::DrawMenuBar() ; + UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , 0 , bDoEnable ) ; + + ::DrawMenuBar() ; } // Menu Bar @@ -412,11 +411,11 @@ wxMenuBar::wxMenuBar(int count, wxMenu *menus[], const wxString titles[]) wxMenuBar::~wxMenuBar() { - if (s_macInstalledMenuBar == this) - { - ::ClearMenuBar(); - s_macInstalledMenuBar = NULL; - } + if (s_macInstalledMenuBar == this) + { + ::ClearMenuBar(); + s_macInstalledMenuBar = NULL; + } } @@ -431,9 +430,9 @@ void wxMenuBar::MacInstallMenuBar() { if ( s_macInstalledMenuBar == this ) return ; - + wxStAppResource resload ; - + Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ; wxString message ; wxCHECK_RET( menubar != NULL, "can't read MBAR resource" ); @@ -453,142 +452,142 @@ void wxMenuBar::MacInstallMenuBar() #endif // clean-up the help menu before adding new items - MenuHandle mh = NULL ; - if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr ) - { - for ( int i = CountMenuItems( mh ) ; i >= firstUserHelpMenuItem ; --i ) - { - DeleteMenuItem( mh , i ) ; - } - } - else - { - mh = NULL ; - } + MenuHandle mh = NULL ; + if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr ) + { + for ( int i = CountMenuItems( mh ) ; i >= firstUserHelpMenuItem ; --i ) + { + DeleteMenuItem( mh , i ) ; + } + } + else + { + mh = NULL ; + } #if TARGET_CARBON - if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId) - { - wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ; - if ( item == NULL || !(item->IsEnabled()) ) - DisableMenuCommand( NULL , kHICommandPreferences ) ; - else - EnableMenuCommand( NULL , kHICommandPreferences ) ; - } + if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId) + { + wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ; + if ( item == NULL || !(item->IsEnabled()) ) + DisableMenuCommand( NULL , kHICommandPreferences ) ; + else + EnableMenuCommand( NULL , kHICommandPreferences ) ; + } #endif - for (size_t i = 0; i < m_menus.GetCount(); i++) - { - Str255 label; + for (size_t i = 0; i < m_menus.GetCount(); i++) + { + Str255 label; wxMenuItemList::Node *node; wxMenuItem *item; int pos ; - wxMenu* menu = m_menus[i] , *subMenu = NULL ; - - if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) - { - if ( mh == NULL ) - { - continue ; - } - - for (pos = 0 , node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) - { - item = (wxMenuItem *)node->GetData(); - subMenu = item->GetSubMenu() ; - if (subMenu) - { - // we don't support hierarchical menus in the help menu yet - } - else - { - if ( item->IsSeparator() ) - { - if ( mh ) - MacAppendMenu(mh, "\p-" ); - } - else - { - wxAcceleratorEntry* entry = wxGetAccelFromString( item->GetText() ) ; - - if ( item->GetId() == wxApp::s_macAboutMenuItemId ) - { - UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetText() ); - UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true ); - SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetId() ) ; - UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ; - } - else - { - if ( mh ) - { - UMAAppendMenuItem(mh, item->GetText() , entry ); - SetMenuItemCommandID( mh , CountMenuItems(mh) , item->GetId() ) ; - } - } - - delete entry ; - } - } - } - } - else - { - UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ; - wxArrayPtrVoid submenus ; - wxMenuItem* previousItem = NULL ; - for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) - { - item = (wxMenuItem *)node->GetData(); - subMenu = item->GetSubMenu() ; - if (subMenu) - { - submenus.Add(subMenu) ; - } - else - { + wxMenu* menu = m_menus[i] , *subMenu = NULL ; + + if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) + { + if ( mh == NULL ) + { + continue ; + } + + for (pos = 0 , node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) + { + item = (wxMenuItem *)node->GetData(); + subMenu = item->GetSubMenu() ; + if (subMenu) + { + // we don't support hierarchical menus in the help menu yet + } + else + { + if ( item->IsSeparator() ) + { + if ( mh ) + MacAppendMenu(mh, "\p-" ); + } + else + { + wxAcceleratorEntry* entry = wxGetAccelFromString( item->GetText() ) ; + + if ( item->GetId() == wxApp::s_macAboutMenuItemId ) + { + UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetText() ); + UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true ); + SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetId() ) ; + UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ; + } + else + { + if ( mh ) + { + UMAAppendMenuItem(mh, item->GetText() , entry ); + SetMenuItemCommandID( mh , CountMenuItems(mh) , item->GetId() ) ; + } + } + + delete entry ; + } + } + } + } + else + { + UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i] ) ; + wxArrayPtrVoid submenus ; + wxMenuItem* previousItem = NULL ; + for (pos = 0, node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) + { + item = (wxMenuItem *)node->GetData(); + subMenu = item->GetSubMenu() ; + if (subMenu) + { + submenus.Add(subMenu) ; + } + else + { #if TARGET_CARBON - if ( UMAGetSystemVersion() >= 0x1000 ) - { - if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId) - { - ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 ); - if ( menu->GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() ) - { - ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos , kMenuItemAttrHidden, 0 ); - } - } - } -#endif - } - previousItem = item ; - } - ::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0); - for ( size_t i = 0 ; i < submenus.GetCount() ; ++i ) - { - wxMenu* submenu = (wxMenu*) submenus[i] ; - wxMenuItemList::Node *subnode; - wxMenuItem *subitem; - int subpos ; + if ( UMAGetSystemVersion() >= 0x1000 ) + { + if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId) + { + ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 ); + if ( menu->GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() ) + { + ChangeMenuItemAttributes( MAC_WXHMENU( menu->GetHMenu() ) , pos , kMenuItemAttrHidden, 0 ); + } + } + } +#endif + } + previousItem = item ; + } + ::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0); + for ( size_t i = 0 ; i < submenus.GetCount() ; ++i ) + { + wxMenu* submenu = (wxMenu*) submenus[i] ; + wxMenuItemList::Node *subnode; + wxMenuItem *subitem; + int subpos ; for ( subpos = 0 , subnode = submenu->GetMenuItems().GetFirst(); subnode; subnode = subnode->GetNext(), subpos++) - { - subitem = (wxMenuItem *)subnode->GetData(); - wxMenu* itsSubMenu = subitem->GetSubMenu() ; - if (itsSubMenu) - { - submenus.Add(itsSubMenu) ; - } - } - ::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ; - } - } - } - ::DrawMenuBar() ; - s_macInstalledMenuBar = this; + { + subitem = (wxMenuItem *)subnode->GetData(); + wxMenu* itsSubMenu = subitem->GetSubMenu() ; + if (itsSubMenu) + { + submenus.Add(itsSubMenu) ; + } + } + ::InsertMenu( MAC_WXHMENU(submenu->GetHMenu()) , -1 ) ; + } + } + } + ::DrawMenuBar() ; + s_macInstalledMenuBar = this; } void wxMenuBar::EnableTop(size_t pos, bool enable) { wxCHECK_RET( IsAttached(), wxT("doesn't work with unattached menubars") ); - m_menus[pos]->MacEnableMenu( enable ) ; + m_menus[pos]->MacEnableMenu( enable ) ; Refresh(); } @@ -604,11 +603,11 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) } m_menus[pos]->SetTitle( label ) ; - if (wxMenuBar::s_macInstalledMenuBar == this) // are we currently installed ? - { - ::SetMenuBar( GetMenuBar() ) ; - ::InvalMenuBar() ; - } + if (wxMenuBar::s_macInstalledMenuBar == this) // are we currently installed ? + { + ::SetMenuBar( GetMenuBar() ) ; + ::InvalMenuBar() ; + } } wxString wxMenuBar::GetLabelTop(size_t pos) const @@ -653,21 +652,21 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) if ( IsAttached() ) { - if (s_macInstalledMenuBar == this) - { - ::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; - { - UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; - if ( pos == m_menus.GetCount() - 1) - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; - } - else - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ; - } - } - } + if (s_macInstalledMenuBar == this) + { + ::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; + { + UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; + if ( pos == m_menus.GetCount() - 1) + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; + } + else + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ; + } + } + } Refresh(); } @@ -682,18 +681,18 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) m_titles.Insert(title, pos); - UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; + UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; if ( IsAttached() ) { - if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() ) - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; - } - else - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ; - } + if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() ) + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; + } + else + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ; + } Refresh(); } @@ -708,10 +707,10 @@ wxMenu *wxMenuBar::Remove(size_t pos) if ( IsAttached() ) { - if (s_macInstalledMenuBar == this) - { - ::DeleteMenu( menu->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; - } + if (s_macInstalledMenuBar == this) + { + ::DeleteMenu( menu->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ; + } menu->Detach(); @@ -733,14 +732,14 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) m_titles.Add(title); - UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; + UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title ) ; if ( IsAttached() ) { - if (s_macInstalledMenuBar == this) - { - ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; - } + if (s_macInstalledMenuBar == this) + { + ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; + } Refresh(); } diff --git a/src/mac/menuitem.cpp b/src/mac/menuitem.cpp index 423440458c..ce04c08eda 100644 --- a/src/mac/menuitem.cpp +++ b/src/mac/menuitem.cpp @@ -66,144 +66,144 @@ wxMenuItem::~wxMenuItem() void wxMenuItem::SetBitmap(const wxBitmap& bitmap) { - m_bitmap = bitmap; - UpdateItemBitmap() ; + m_bitmap = bitmap; + UpdateItemBitmap() ; } void wxMenuItem::UpdateItemBitmap() { - if ( !m_parentMenu ) - return ; - - MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; - MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; - if( mhandle == NULL || index == 0) - return ; - - if ( m_bitmap.Ok() ) - { - ControlButtonContentInfo info ; - wxMacCreateBitmapButton( &info , m_bitmap , kControlContentCIconHandle ) ; - if ( info.contentType != kControlNoContent ) - { - if ( info.contentType == kControlContentCIconHandle ) - SetMenuItemIconHandle( mhandle , index , - kMenuColorIconType , (Handle) info.u.cIconHandle ) ; - } - - } + if ( !m_parentMenu ) + return ; + + MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; + MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; + if( mhandle == NULL || index == 0) + return ; + + if ( m_bitmap.Ok() ) + { + ControlButtonContentInfo info ; + wxMacCreateBitmapButton( &info , m_bitmap , kControlContentCIconHandle ) ; + if ( info.contentType != kControlNoContent ) + { + if ( info.contentType == kControlContentCIconHandle ) + SetMenuItemIconHandle( mhandle , index , + kMenuColorIconType , (Handle) info.u.cIconHandle ) ; + } + + } } void wxMenuItem::UpdateItemStatus() { - if ( !m_parentMenu ) - return ; - - MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; - MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; - if( mhandle == NULL || index == 0) - return ; - - UMAEnableMenuItem( mhandle , index , m_isEnabled ) ; - if ( IsCheckable() && IsChecked() ) - ::SetItemMark( mhandle , index , 0x12 ) ; // checkmark - else - ::SetItemMark( mhandle , index , 0 ) ; // no mark - - UMASetMenuItemText( mhandle , index , m_text ) ; - wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; - UMASetMenuItemShortcut( mhandle , index , entry ) ; - delete entry ; + if ( !m_parentMenu ) + return ; + + MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; + MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; + if( mhandle == NULL || index == 0) + return ; + + UMAEnableMenuItem( mhandle , index , m_isEnabled ) ; + if ( IsCheckable() && IsChecked() ) + ::SetItemMark( mhandle , index , 0x12 ) ; // checkmark + else + ::SetItemMark( mhandle , index , 0 ) ; // no mark + + UMASetMenuItemText( mhandle , index , m_text ) ; + wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; + UMASetMenuItemShortcut( mhandle , index , entry ) ; + delete entry ; } void wxMenuItem::UpdateItemText() { - if ( !m_parentMenu ) - return ; - - MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; - MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; - if( mhandle == NULL || index == 0) - return ; - - UMASetMenuItemText( mhandle , index , m_text ) ; - wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; - UMASetMenuItemShortcut( mhandle , index , entry ) ; - delete entry ; + if ( !m_parentMenu ) + return ; + + MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ; + MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ; + if( mhandle == NULL || index == 0) + return ; + + UMASetMenuItemText( mhandle , index , m_text ) ; + wxAcceleratorEntry *entry = wxGetAccelFromString( m_text ) ; + UMASetMenuItemShortcut( mhandle , index , entry ) ; + delete entry ; } void wxMenuItem::Enable(bool bDoEnable) { - if ( m_isEnabled != bDoEnable ) - { - wxMenuItemBase::Enable( bDoEnable ) ; - UpdateItemStatus() ; - } + if ( m_isEnabled != bDoEnable ) + { + wxMenuItemBase::Enable( bDoEnable ) ; + UpdateItemStatus() ; + } } void wxMenuItem::UncheckRadio() { - if ( m_isChecked ) - { - wxMenuItemBase::Check( false ) ; - UpdateItemStatus() ; - } + if ( m_isChecked ) + { + wxMenuItemBase::Check( false ) ; + UpdateItemStatus() ; + } } void wxMenuItem::Check(bool bDoCheck) { - wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); - - if ( m_isChecked != bDoCheck ) - { - if ( GetKind() == wxITEM_RADIO ) - { - if ( bDoCheck ) - { - wxMenuItemBase::Check( bDoCheck ) ; - UpdateItemStatus() ; - - // get the index of this item in the menu - const wxMenuItemList& items = m_parentMenu->GetMenuItems(); - int pos = items.IndexOf(this); - wxCHECK_RET( pos != wxNOT_FOUND, - _T("menuitem not found in the menu items list?") ); - - // get the radio group range - int start, - end; - - if ( m_isRadioGroupStart ) - { - // we already have all information we need - start = pos; - end = m_radioGroup.end; - } - else // next radio group item - { - // get the radio group end from the start item - start = m_radioGroup.start; - end = items.Item(start)->GetData()->m_radioGroup.end; - } - - // also uncheck all the other items in this radio group - wxMenuItemList::Node *node = items.Item(start); - for ( int n = start; n <= end && node; n++ ) - { - if ( n != pos ) - { - ((wxMenuItem*)node->GetData())->UncheckRadio(); - } - node = node->GetNext(); - } - } - } - else - { - wxMenuItemBase::Check( bDoCheck ) ; - UpdateItemStatus() ; - } - } + wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); + + if ( m_isChecked != bDoCheck ) + { + if ( GetKind() == wxITEM_RADIO ) + { + if ( bDoCheck ) + { + wxMenuItemBase::Check( bDoCheck ) ; + UpdateItemStatus() ; + + // get the index of this item in the menu + const wxMenuItemList& items = m_parentMenu->GetMenuItems(); + int pos = items.IndexOf(this); + wxCHECK_RET( pos != wxNOT_FOUND, + _T("menuitem not found in the menu items list?") ); + + // get the radio group range + int start, + end; + + if ( m_isRadioGroupStart ) + { + // we already have all information we need + start = pos; + end = m_radioGroup.end; + } + else // next radio group item + { + // get the radio group end from the start item + start = m_radioGroup.start; + end = items.Item(start)->GetData()->m_radioGroup.end; + } + + // also uncheck all the other items in this radio group + wxMenuItemList::Node *node = items.Item(start); + for ( int n = start; n <= end && node; n++ ) + { + if ( n != pos ) + { + ((wxMenuItem*)node->GetData())->UncheckRadio(); + } + node = node->GetNext(); + } + } + } + else + { + wxMenuItemBase::Check( bDoCheck ) ; + UpdateItemStatus() ; + } + } } void wxMenuItem::SetText(const wxString& text) diff --git a/src/mac/metafile.cpp b/src/mac/metafile.cpp index 1d38499628..1f87cb9f4a 100644 --- a/src/mac/metafile.cpp +++ b/src/mac/metafile.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -61,7 +61,7 @@ wxMetafileRefData::~wxMetafileRefData(void) { if (m_metafile) { - KillPicture( (PicHandle) m_metafile ) ; + KillPicture( (PicHandle) m_metafile ) ; m_metafile = 0; } } @@ -86,10 +86,10 @@ wxMetaFile::~wxMetaFile() bool wxMetaFile::SetClipboard(int width, int height) { #if wxUSE_DRAG_AND_DROP -//TODO finishi this port , we need the data obj first + //TODO finishi this port , we need the data obj first if (!m_refData) return FALSE; - + bool alreadyOpen=wxTheClipboard->IsOpened() ; if (!alreadyOpen) { @@ -97,11 +97,11 @@ bool wxMetaFile::SetClipboard(int width, int height) wxTheClipboard->Clear(); } wxDataObject *data = - new wxMetafileDataObject( *this) ; + new wxMetafileDataObject( *this) ; bool success = wxTheClipboard->SetData(data); if (!alreadyOpen) - wxTheClipboard->Close(); - return (bool) success; + wxTheClipboard->Close(); + return (bool) success; #endif return TRUE ; } @@ -116,17 +116,17 @@ void wxMetafile::SetHMETAFILE(WXHMETAFILE mf) bool wxMetaFile::Play(wxDC *dc) { - if (!m_refData) - return FALSE; - - if (!dc->Ok() ) - return FALSE; - - { - wxMacPortSetter helper( dc ) ; - PicHandle pict = (PicHandle) GetHMETAFILE() ; - DrawPicture( pict , &(**pict).picFrame ) ; - } + if (!m_refData) + return FALSE; + + if (!dc->Ok() ) + return FALSE; + + { + wxMacPortSetter helper( dc ) ; + PicHandle pict = (PicHandle) GetHMETAFILE() ; + DrawPicture( pict , &(**pict).picFrame ) ; + } return TRUE; } @@ -139,22 +139,22 @@ bool wxMetaFile::Play(wxDC *dc) // *DO* give origin/extent arguments to wxMakeMetaFilePlaceable. wxMetaFileDC::wxMetaFileDC(const wxString& file) { - m_metaFile = NULL; - m_minX = 10000; - m_minY = 10000; - m_maxX = -10000; - m_maxY = -10000; - - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; - - m_metaFile = new wxMetaFile("") ; - Rect r={0,0,1000,1000} ; - - m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; - ::GetPort( (GrafPtr*) &m_macPort ) ; - m_ok = TRUE ; - - SetMapMode(wxMM_TEXT); + m_metaFile = NULL; + m_minX = 10000; + m_minY = 10000; + m_maxX = -10000; + m_maxY = -10000; + + wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + + m_metaFile = new wxMetaFile("") ; + Rect r={0,0,1000,1000} ; + + m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; + ::GetPort( (GrafPtr*) &m_macPort ) ; + m_ok = TRUE ; + + SetMapMode(wxMM_TEXT); } // New constructor that takes origin and extent. If you use this, don't @@ -162,21 +162,21 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file) wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg) { - m_minX = 10000; - m_minY = 10000; - m_maxX = -10000; - m_maxY = -10000; - - wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; - - m_metaFile = new wxMetaFile("") ; - Rect r={yorg,xorg,yorg+yext,xorg+xext} ; - - m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; - ::GetPort( (GrafPtr*) &m_macPort ) ; - m_ok = TRUE ; - - SetMapMode(wxMM_TEXT); + m_minX = 10000; + m_minY = 10000; + m_maxX = -10000; + m_maxY = -10000; + + wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; + + m_metaFile = new wxMetaFile("") ; + Rect r={yorg,xorg,yorg+yext,xorg+xext} ; + + m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; + ::GetPort( (GrafPtr*) &m_macPort ) ; + m_ok = TRUE ; + + SetMapMode(wxMM_TEXT); } wxMetaFileDC::~wxMetaFileDC() @@ -185,29 +185,29 @@ wxMetaFileDC::~wxMetaFileDC() wxMetaFile *wxMetaFileDC::Close() { - ClosePicture() ; - return m_metaFile; + ClosePicture() ; + return m_metaFile; } #if wxUSE_DATAOBJ size_t wxMetafileDataObject::GetDataSize() const { - return GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ; + return GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ; } bool wxMetafileDataObject::GetDataHere(void *buf) const { - memcpy( buf , (*(PicHandle)(*((wxMetafile*)&m_metafile)).GetHMETAFILE()) , - GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ) ; - return true ; + memcpy( buf , (*(PicHandle)(*((wxMetafile*)&m_metafile)).GetHMETAFILE()) , + GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ) ; + return true ; } bool wxMetafileDataObject::SetData(size_t len, const void *buf) { - Handle handle = (Handle) m_metafile.GetHMETAFILE() ; - SetHandleSize( handle , len ) ; - memcpy( *handle , buf , len ) ; - return true ; + Handle handle = (Handle) m_metafile.GetHMETAFILE() ; + SetHandleSize( handle , len ) ; + memcpy( *handle , buf , len ) ; + return true ; } #endif diff --git a/src/mac/mimetmac.cpp b/src/mac/mimetmac.cpp index 0306d07f2c..de41b17423 100644 --- a/src/mac/mimetmac.cpp +++ b/src/mac/mimetmac.cpp @@ -105,7 +105,7 @@ bool wxFileTypeImpl::GetDescription(wxString *desc) const size_t wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands, - const wxFileType::MessageParameters& params) const + const wxFileType::MessageParameters& params) const { wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") ); return 0; diff --git a/src/mac/minifram.cpp b/src/mac/minifram.cpp index 4cd78d7100..6b49b9bdc7 100644 --- a/src/mac/minifram.cpp +++ b/src/mac/minifram.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/msgdlg.cpp b/src/mac/msgdlg.cpp index c7f38f17b7..f7a4a0a724 100644 --- a/src/mac/msgdlg.cpp +++ b/src/mac/msgdlg.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -27,33 +27,33 @@ short language = 0 ; void wxMacConvertNewlines( const char *source , char * destination ) ; void wxMacConvertNewlines( const char *source , char * destination ) { - const char *s = source ; - char *d = destination ; - - while( *s ) - { - switch( *s ) - { - case 0x0a : - *d++ = 0x0d ; - ++s ; - break ; - case 0x0d : - *d++ = 0x0d ; - ++s ; - if ( *s == 0x0a ) - ++s ; - break ; - default : - *d++ = *s++ ; - break ; - } - } - *d = 0 ; + const char *s = source ; + char *d = destination ; + + while( *s ) + { + switch( *s ) + { + case 0x0a : + *d++ = 0x0d ; + ++s ; + break ; + case 0x0d : + *d++ = 0x0d ; + ++s ; + if ( *s == 0x0a ) + ++s ; + break ; + default : + *d++ = *s++ ; + break ; + } + } + *d = 0 ; } wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, - long style, const wxPoint& pos) + long style, const wxPoint& pos) { m_caption = caption; m_message = message; @@ -63,252 +63,252 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, cons int wxMessageDialog::ShowModal() { - int resultbutton = wxID_CANCEL ; - - short result ; - - wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ; - - AlertType alertType = kAlertPlainAlert ; - if (m_dialogStyle & wxICON_EXCLAMATION) - alertType = kAlertNoteAlert ; - else if (m_dialogStyle & wxICON_HAND) - alertType = kAlertStopAlert ; - else if (m_dialogStyle & wxICON_INFORMATION) - alertType = kAlertNoteAlert ; - else if (m_dialogStyle & wxICON_QUESTION) - alertType = kAlertCautionAlert ; - + int resultbutton = wxID_CANCEL ; + + short result ; + + wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ; + + AlertType alertType = kAlertPlainAlert ; + if (m_dialogStyle & wxICON_EXCLAMATION) + alertType = kAlertNoteAlert ; + else if (m_dialogStyle & wxICON_HAND) + alertType = kAlertStopAlert ; + else if (m_dialogStyle & wxICON_INFORMATION) + alertType = kAlertNoteAlert ; + else if (m_dialogStyle & wxICON_QUESTION) + alertType = kAlertCautionAlert ; + #if TARGET_CARBON - if ( UMAGetSystemVersion() >= 0x1000 ) - { - AlertStdCFStringAlertParamRec param ; - CFStringRef cfNoString = NULL ; - CFStringRef cfYesString = NULL ; - - CFStringRef cfTitle = NULL; - CFStringRef cfText = NULL; - - cfTitle = wxMacCreateCFString( m_caption ) ; - cfText = wxMacCreateCFString( m_message ) ; - cfNoString = wxMacCreateCFString( _("No") ) ; - cfYesString = wxMacCreateCFString( _("Yes") ) ; - - param.movable = true; - param.flags = 0 ; - - bool skipDialog = false ; - - if (m_dialogStyle & wxYES_NO) - { - if (m_dialogStyle & wxCANCEL) - { - param.defaultText = cfYesString ; - param.cancelText = (CFStringRef) kAlertDefaultCancelText; - param.otherText = cfNoString ; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = kAlertStdAlertCancelButton; - } - else - { - param.defaultText = cfYesString ; - param.cancelText = NULL; - param.otherText = cfNoString ; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - } - else if (m_dialogStyle & wxOK) - { - if (m_dialogStyle & wxCANCEL) - { - // thats a cancel missing - param.defaultText = (CFStringRef) kAlertDefaultOKText ; - param.cancelText = NULL; - param.otherText = NULL; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - else - { - param.defaultText = (CFStringRef) kAlertDefaultOKText ; - param.cancelText = NULL; - param.otherText = NULL; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - } - else - { - skipDialog = true ; - } - - param.position = kWindowDefaultPosition; - if ( !skipDialog ) - { - DialogRef alertRef ; - CreateStandardAlert( alertType , cfTitle , cfText , ¶m , &alertRef ) ; - RunStandardAlert( alertRef , NULL , &result ) ; - } - if(cfTitle != NULL) - CFRelease(cfTitle); - if(cfText != NULL) - CFRelease(cfText); - if(cfNoString != NULL) - CFRelease(cfNoString); - if(cfYesString != NULL) - CFRelease(cfYesString); - if ( skipDialog ) - return wxID_CANCEL ; - } - else + if ( UMAGetSystemVersion() >= 0x1000 ) + { + AlertStdCFStringAlertParamRec param ; + CFStringRef cfNoString = NULL ; + CFStringRef cfYesString = NULL ; + + CFStringRef cfTitle = NULL; + CFStringRef cfText = NULL; + + cfTitle = wxMacCreateCFString( m_caption ) ; + cfText = wxMacCreateCFString( m_message ) ; + cfNoString = wxMacCreateCFString( _("No") ) ; + cfYesString = wxMacCreateCFString( _("Yes") ) ; + + param.movable = true; + param.flags = 0 ; + + bool skipDialog = false ; + + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + param.defaultText = cfYesString ; + param.cancelText = (CFStringRef) kAlertDefaultCancelText; + param.otherText = cfNoString ; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = kAlertStdAlertCancelButton; + } + else + { + param.defaultText = cfYesString ; + param.cancelText = NULL; + param.otherText = cfNoString ; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + } + else if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + { + // thats a cancel missing + param.defaultText = (CFStringRef) kAlertDefaultOKText ; + param.cancelText = NULL; + param.otherText = NULL; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + else + { + param.defaultText = (CFStringRef) kAlertDefaultOKText ; + param.cancelText = NULL; + param.otherText = NULL; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + } + else + { + skipDialog = true ; + } + + param.position = kWindowDefaultPosition; + if ( !skipDialog ) + { + DialogRef alertRef ; + CreateStandardAlert( alertType , cfTitle , cfText , ¶m , &alertRef ) ; + RunStandardAlert( alertRef , NULL , &result ) ; + } + if(cfTitle != NULL) + CFRelease(cfTitle); + if(cfText != NULL) + CFRelease(cfText); + if(cfNoString != NULL) + CFRelease(cfNoString); + if(cfYesString != NULL) + CFRelease(cfYesString); + if ( skipDialog ) + return wxID_CANCEL ; + } + else #endif - { - AlertStdAlertParamRec param; - char cText[2048] ; - - if (wxApp::s_macDefaultEncodingIsPC) - { - strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ; - } - else - { - strcpy( cText , m_message ) ; - } - wxMacConvertNewlines( cText , cText ) ; - - Str255 yesPString ; - Str255 noPString ; - - Str255 pascalTitle ; - Str255 pascalText ; - wxMacStringToPascal( m_caption , pascalTitle ) ; - wxMacStringToPascal( _("Yes") , yesPString ) ; - wxMacStringToPascal( _("No") , noPString ) ; - CopyCStringToPascal( cText , pascalText ) ; - - param.movable = true; - param.filterProc = NULL ; - if (m_dialogStyle & wxYES_NO) - { - if (m_dialogStyle & wxCANCEL) - { - param.defaultText = yesPString ; - param.cancelText = (StringPtr) kAlertDefaultCancelText; - param.otherText = noPString ; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = kAlertStdAlertCancelButton; - } - else - { - param.defaultText = yesPString ; - param.cancelText = NULL; - param.otherText = noPString ; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - } - else if (m_dialogStyle & wxOK) - { - if (m_dialogStyle & wxCANCEL) - { - // thats a cancel missing - param.defaultText = (StringPtr) kAlertDefaultOKText ; - param.cancelText = NULL; - param.otherText = NULL; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - else - { - param.defaultText = (StringPtr) kAlertDefaultOKText ; - param.cancelText = NULL; - param.otherText = NULL; - param.helpButton = false ; - param.defaultButton = kAlertStdAlertOKButton; - param.cancelButton = 0; - } - } - else - { - return resultbutton ; - } - - param.position = 0; - - StandardAlert( alertType, pascalTitle, pascalText, ¶m, &result ); - } - - if (m_dialogStyle & wxOK) - { - if (m_dialogStyle & wxCANCEL) - { - //TODO add Cancelbutton - switch( result ) - { - case 1 : - resultbutton = wxID_OK ; - break ; - case 2 : - break ; - case 3 : - break ; - } - } - else - { - switch( result ) - { - case 1 : - resultbutton = wxID_OK ; - break ; - case 2 : - break ; - case 3 : - break ; - } - } - } - else if (m_dialogStyle & wxYES_NO) - { - if (m_dialogStyle & wxCANCEL) - { - switch( result ) - { - case 1 : - resultbutton = wxID_YES ; - break ; - case 2 : - resultbutton = wxID_CANCEL ; - break ; - case 3 : - resultbutton = wxID_NO ; - break ; - } - } - else - { - switch( result ) - { - case 1 : - resultbutton = wxID_YES ; - break ; - case 2 : - break ; - case 3 : - resultbutton = wxID_NO ; - break ; - } - } - } - - return resultbutton ; + { + AlertStdAlertParamRec param; + char cText[2048] ; + + if (wxApp::s_macDefaultEncodingIsPC) + { + strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ; + } + else + { + strcpy( cText , m_message ) ; + } + wxMacConvertNewlines( cText , cText ) ; + + Str255 yesPString ; + Str255 noPString ; + + Str255 pascalTitle ; + Str255 pascalText ; + wxMacStringToPascal( m_caption , pascalTitle ) ; + wxMacStringToPascal( _("Yes") , yesPString ) ; + wxMacStringToPascal( _("No") , noPString ) ; + CopyCStringToPascal( cText , pascalText ) ; + + param.movable = true; + param.filterProc = NULL ; + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + param.defaultText = yesPString ; + param.cancelText = (StringPtr) kAlertDefaultCancelText; + param.otherText = noPString ; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = kAlertStdAlertCancelButton; + } + else + { + param.defaultText = yesPString ; + param.cancelText = NULL; + param.otherText = noPString ; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + } + else if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + { + // thats a cancel missing + param.defaultText = (StringPtr) kAlertDefaultOKText ; + param.cancelText = NULL; + param.otherText = NULL; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + else + { + param.defaultText = (StringPtr) kAlertDefaultOKText ; + param.cancelText = NULL; + param.otherText = NULL; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = 0; + } + } + else + { + return resultbutton ; + } + + param.position = 0; + + StandardAlert( alertType, pascalTitle, pascalText, ¶m, &result ); + } + + if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + { + //TODO add Cancelbutton + switch( result ) + { + case 1 : + resultbutton = wxID_OK ; + break ; + case 2 : + break ; + case 3 : + break ; + } + } + else + { + switch( result ) + { + case 1 : + resultbutton = wxID_OK ; + break ; + case 2 : + break ; + case 3 : + break ; + } + } + } + else if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + switch( result ) + { + case 1 : + resultbutton = wxID_YES ; + break ; + case 2 : + resultbutton = wxID_CANCEL ; + break ; + case 3 : + resultbutton = wxID_NO ; + break ; + } + } + else + { + switch( result ) + { + case 1 : + resultbutton = wxID_YES ; + break ; + case 2 : + break ; + case 3 : + resultbutton = wxID_NO ; + break ; + } + } + } + + return resultbutton ; } diff --git a/src/mac/notebmac.cpp b/src/mac/notebmac.cpp index 6ba640fe91..33c40fe448 100644 --- a/src/mac/notebmac.cpp +++ b/src/mac/notebmac.cpp @@ -10,7 +10,7 @@ /////////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ - #pragma implementation "notebook.h" +#pragma implementation "notebook.h" #endif // ============================================================================ @@ -35,10 +35,10 @@ static bool constantsSet = false ; - short kwxMacTabLeftMargin = 0 ; - short kwxMacTabTopMargin = 0 ; - short kwxMacTabRightMargin = 0 ; - short kwxMacTabBottomMargin = 0 ; +short kwxMacTabLeftMargin = 0 ; +short kwxMacTabTopMargin = 0 ; +short kwxMacTabRightMargin = 0 ; +short kwxMacTabBottomMargin = 0 ; // ---------------------------------------------------------------------------- // event table @@ -49,12 +49,12 @@ 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_MOUSE_EVENTS(wxNotebook::OnMouse) - - EVT_SIZE(wxNotebook::OnSize) - EVT_SET_FOCUS(wxNotebook::OnSetFocus) - EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) +EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) +EVT_MOUSE_EVENTS(wxNotebook::OnMouse) + +EVT_SIZE(wxNotebook::OnSize) +EVT_SET_FOCUS(wxNotebook::OnSetFocus) +EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) @@ -76,7 +76,7 @@ void wxNotebook::Init() { if ( UMAHasAquaLayout() ) { - // I got these values for Mac OS X from the Appearance mgr docs. (Mark Newsam) + // I got these values for Mac OS X from the Appearance mgr docs. (Mark Newsam) kwxMacTabLeftMargin = 20 ; kwxMacTabTopMargin = 38 ; kwxMacTabRightMargin = 20 ; @@ -96,7 +96,7 @@ void wxNotebook::Init() m_macHorizontalBorder = 7; m_macVerticalBorder = 8; } - + m_nSelection = -1; } @@ -115,7 +115,7 @@ wxNotebook::wxNotebook(wxWindow *parent, const wxString& name) { Init(); - + Create(parent, id, pos, size, style, name); } @@ -127,31 +127,31 @@ bool wxNotebook::Create(wxWindow *parent, long style, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - - int tabstyle = kControlTabSmallNorthProc ; - if ( HasFlag(wxNB_LEFT) ) - tabstyle = kControlTabSmallWestProc ; - else if ( HasFlag( wxNB_RIGHT ) ) - tabstyle = kControlTabSmallEastProc ; - else if ( HasFlag( wxNB_BOTTOM ) ) - tabstyle = kControlTabSmallSouthProc ; - - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - tabstyle , (long) this ) ; - - MacPostControlCreate() ; - return TRUE ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + + int tabstyle = kControlTabSmallNorthProc ; + if ( HasFlag(wxNB_LEFT) ) + tabstyle = kControlTabSmallWestProc ; + else if ( HasFlag( wxNB_RIGHT ) ) + tabstyle = kControlTabSmallEastProc ; + else if ( HasFlag( wxNB_BOTTOM ) ) + tabstyle = kControlTabSmallSouthProc ; + + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + tabstyle , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } // dtor wxNotebook::~wxNotebook() { - m_macControl = NULL ; + m_macControl = NULL ; } wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) @@ -162,7 +162,7 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) wxGetOsVersion( &major, &minor ); // Mac has large notebook borders. Aqua even more so. - + if ( HasFlag(wxNB_LEFT) || HasFlag(wxNB_RIGHT) ) { sizeTotal.x += 90; @@ -185,7 +185,7 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) sizeTotal.y += 44; } } - + return sizeTotal; } @@ -195,7 +195,7 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) void wxNotebook::SetPadding(const wxSize& padding) { - wxFAIL_MSG( wxT("wxNotebook::SetPadding not implemented") ); + wxFAIL_MSG( wxT("wxNotebook::SetPadding not implemented") ); } void wxNotebook::SetTabSize(const wxSize& sz) @@ -210,12 +210,12 @@ void wxNotebook::SetPageSize(const wxSize& size) int wxNotebook::SetSelection(int nPage) { - if( !IS_VALID_PAGE(nPage) ) - return m_nSelection ; - + if( !IS_VALID_PAGE(nPage) ) + return m_nSelection ; + ChangePage(m_nSelection, nPage); - SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; - + SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ; + Refresh(); return m_nSelection; } @@ -223,18 +223,18 @@ int wxNotebook::SetSelection(int nPage) bool wxNotebook::SetPageText(int nPage, const wxString& strText) { wxASSERT( IS_VALID_PAGE(nPage) ); - + wxNotebookPage *page = m_pages[nPage]; page->SetLabel(strText); MacSetupTabs(); - + return true; } wxString wxNotebook::GetPageText(int nPage) const { wxASSERT( IS_VALID_PAGE(nPage) ); - + wxNotebookPage *page = m_pages[nPage]; return page->GetLabel(); } @@ -242,27 +242,27 @@ wxString wxNotebook::GetPageText(int nPage) const int wxNotebook::GetPageImage(int nPage) const { wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") ); - + return m_images[nPage]; } bool wxNotebook::SetPageImage(int nPage, int nImage) { wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("invalid notebook page") ); - + wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), FALSE, - _T("invalid image index in SetPageImage()") ); - + _T("invalid image index in SetPageImage()") ); + if ( nImage != m_images[nPage] ) { // if the item didn't have an icon before or, on the contrary, did have // it but has lost it now, its size will change - but if the icon just // changes, it won't m_images[nPage] = nImage; - - MacSetupTabs() ; + + MacSetupTabs() ; } - + return TRUE; } @@ -276,9 +276,9 @@ wxNotebookPage* wxNotebook::DoRemovePage(int nPage) wxCHECK( IS_VALID_PAGE(nPage), NULL ); wxNotebookPage* page = m_pages[nPage] ; m_pages.RemoveAt(nPage); - + MacSetupTabs(); - + if(m_nSelection >= GetPageCount()) { m_nSelection = GetPageCount() - 1; } @@ -292,10 +292,10 @@ wxNotebookPage* wxNotebook::DoRemovePage(int nPage) bool wxNotebook::DeleteAllPages() { // TODO: delete native widget pages - + WX_CLEAR_ARRAY(m_pages) ; MacSetupTabs(); - + return TRUE; } @@ -309,16 +309,16 @@ bool wxNotebook::InsertPage(int nPage, { wxASSERT( pPage != NULL ); wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE ); - + pPage->SetLabel(strText); - + // save the pointer to the page m_pages.Insert(pPage, nPage); - + m_images.Insert(imageId, nPage); - + MacSetupTabs(); - + if ( bSelect ) { m_nSelection = nPage; } @@ -330,69 +330,69 @@ bool wxNotebook::InsertPage(int nPage, } // don't show pages by default (we'll need to adjust their size first) pPage->Show( false ) ; - + int h, w; GetSize(&w, &h); pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin, - w - kwxMacTabLeftMargin - kwxMacTabRightMargin, - h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); + w - kwxMacTabLeftMargin - kwxMacTabRightMargin, + h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); if ( pPage->GetAutoLayout() ) { pPage->Layout(); } - + return true; } /* Added by Mark Newsam - * When a page is added or deleted to the notebook this function updates - * information held in the m_macControl so that it matches the order - * the user would expect. - */ +* When a page is added or deleted to the notebook this function updates +* information held in the m_macControl so that it matches the order +* the user would expect. +*/ void wxNotebook::MacSetupTabs() { SetControl32BitMaximum( (ControlHandle) m_macControl , GetPageCount() ) ; - + wxNotebookPage *page; ControlTabInfoRec info; - + for(int ii = 0; ii < GetPageCount(); ii++) { page = m_pages[ii]; info.version = 0; info.iconSuiteID = 0; #if TARGET_CARBON - c2pstrcpy( (StringPtr) info.name , page->GetLabel() ) ; + c2pstrcpy( (StringPtr) info.name , page->GetLabel() ) ; #else - strcpy( (char *) info.name , page->GetLabel() ) ; - c2pstr( (char *) info.name ) ; + strcpy( (char *) info.name , page->GetLabel() ) ; + c2pstr( (char *) info.name ) ; #endif SetControlData( (ControlHandle) m_macControl, ii+1, kControlTabInfoTag, - sizeof( ControlTabInfoRec) , (char*) &info ) ; + sizeof( ControlTabInfoRec) , (char*) &info ) ; SetTabEnabled( (ControlHandle) m_macControl , ii+1 , true ) ; - + #if TARGET_CARBON if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 ) { - // tab controls only support very specific types of images, therefore we are doing an odyssee - // accross the icon worlds (even Apple DTS did not find a shorter path) - // in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately - // afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we - // unregister it) in case this will ever lead to having the same icon everywhere add some kind - // of static counter - ControlButtonContentInfo info ; - wxMacCreateBitmapButton( &info , *GetImageList()->GetBitmap( GetPageImage(ii ) ) , kControlContentPictHandle) ; - IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ; - OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ; + // tab controls only support very specific types of images, therefore we are doing an odyssee + // accross the icon worlds (even Apple DTS did not find a shorter path) + // in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately + // afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we + // unregister it) in case this will ever lead to having the same icon everywhere add some kind + // of static counter + ControlButtonContentInfo info ; + wxMacCreateBitmapButton( &info , *GetImageList()->GetBitmap( GetPageImage(ii ) ) , kControlContentPictHandle) ; + IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ; + OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ; wxASSERT_MSG( err == noErr , "Error when adding bitmap" ) ; - IconRef iconRef ; - err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1 , iconFamily, &iconRef ) ; + IconRef iconRef ; + err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1 , iconFamily, &iconRef ) ; wxASSERT_MSG( err == noErr , "Error when adding bitmap" ) ; - info.contentType = kControlContentIconRef ; - info.u.iconRef = iconRef ; - SetControlData( (ControlHandle) m_macControl, ii+1,kControlTabImageContentTag, - sizeof( info ), (Ptr)&info ); + info.contentType = kControlContentIconRef ; + info.u.iconRef = iconRef ; + SetControlData( (ControlHandle) m_macControl, ii+1,kControlTabImageContentTag, + sizeof( info ), (Ptr)&info ); wxASSERT_MSG( err == noErr , "Error when setting icon on tab" ) ; - UnregisterIconRef( 'WXNG' , (OSType) 1 ) ; + UnregisterIconRef( 'WXNG' , (OSType) 1 ) ; ReleaseIconRef( iconRef ) ; DisposeHandle( (Handle) iconFamily ) ; } @@ -416,22 +416,22 @@ void wxNotebook::OnSize(wxSizeEvent& event) int nSel = m_nSelection; m_nSelection = -1; SetSelection(nSel); - + // fit the notebook page to the tab control's display area int w, h; GetSize(&w, &h); - + unsigned int nCount = m_pages.Count(); for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) { wxNotebookPage *pPage = m_pages[nPage]; pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin, - w - kwxMacTabLeftMargin - kwxMacTabRightMargin, - h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); + w - kwxMacTabLeftMargin - kwxMacTabRightMargin, + h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); if ( pPage->GetAutoLayout() ) { pPage->Layout(); } } - + // Processing continues to next OnSize event.Skip(); } @@ -441,7 +441,7 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event) // is it our tab control? if ( event.GetEventObject() == this ) ChangePage(event.GetOldSelection(), event.GetSelection()); - + // we want to give others a chance to process this message as well event.Skip(); } @@ -451,7 +451,7 @@ void wxNotebook::OnSetFocus(wxFocusEvent& event) // set focus to the currently selected page if any if ( m_nSelection != -1 ) m_pages[m_nSelection]->SetFocus(); - + event.Skip(); } @@ -509,93 +509,93 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) pPage->SetFocus(); return; } - + // Hide previous page if ( nOldSel != -1 ) { m_pages[nOldSel]->Show(FALSE); } - + wxNotebookPage *pPage = m_pages[nSel]; pPage->Show(TRUE); pPage->SetFocus(); - + m_nSelection = nSel; } void wxNotebook::OnMouse( wxMouseEvent &event ) { - if ( (ControlHandle) m_macControl == NULL ) - { - event.Skip() ; - return ; - } - - if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK ) - { - int x = event.m_x ; - int y = event.m_y ; - - MacClientToRootWindow( &x , &y ) ; - - ControlHandle control ; - Point localwhere ; - SInt16 controlpart ; - - localwhere.h = x ; - localwhere.v = y ; - - short modifiers = 0; - - if ( !event.m_leftDown && !event.m_rightDown ) - modifiers |= btnState ; - - if ( event.m_shiftDown ) - modifiers |= shiftKey ; - - if ( event.m_controlDown ) - modifiers |= controlKey ; - - if ( event.m_altDown ) - modifiers |= optionKey ; - - if ( event.m_metaDown ) - modifiers |= cmdKey ; - - control = (ControlHandle) m_macControl ; - if ( control && ::IsControlActive( control ) ) - { - { - wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId, - ::GetControl32BitValue(control) - 1, m_nSelection); - changing.SetEventObject(this); - ProcessEvent(changing); - - if(changing.IsAllowed()) - { - controlpart = ::HandleControlClick(control, localwhere, modifiers, - (ControlActionUPP) -1); - wxTheApp->s_lastMouseDown = 0 ; - - wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId, - ::GetControl32BitValue(control) - 1, m_nSelection); - event.SetEventObject(this); - - ProcessEvent(event); - } - } - } - } + if ( (ControlHandle) m_macControl == NULL ) + { + event.Skip() ; + return ; + } + + if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK ) + { + int x = event.m_x ; + int y = event.m_y ; + + MacClientToRootWindow( &x , &y ) ; + + ControlHandle control ; + Point localwhere ; + SInt16 controlpart ; + + localwhere.h = x ; + localwhere.v = y ; + + short modifiers = 0; + + if ( !event.m_leftDown && !event.m_rightDown ) + modifiers |= btnState ; + + if ( event.m_shiftDown ) + modifiers |= shiftKey ; + + if ( event.m_controlDown ) + modifiers |= controlKey ; + + if ( event.m_altDown ) + modifiers |= optionKey ; + + if ( event.m_metaDown ) + modifiers |= cmdKey ; + + control = (ControlHandle) m_macControl ; + if ( control && ::IsControlActive( control ) ) + { + { + wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId, + ::GetControl32BitValue(control) - 1, m_nSelection); + changing.SetEventObject(this); + ProcessEvent(changing); + + if(changing.IsAllowed()) + { + controlpart = ::HandleControlClick(control, localwhere, modifiers, + (ControlActionUPP) -1); + wxTheApp->s_lastMouseDown = 0 ; + + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId, + ::GetControl32BitValue(control) - 1, m_nSelection); + event.SetEventObject(this); + + ProcessEvent(event); + } + } + } + } } - + void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { #if 0 - wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); - event.SetEventObject(this); - - ProcessEvent(event); + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection); + event.SetEventObject(this); + + ProcessEvent(event); #endif } diff --git a/src/mac/palette.cpp b/src/mac/palette.cpp index 5fd459da77..60a0de6a8a 100644 --- a/src/mac/palette.cpp +++ b/src/mac/palette.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -30,8 +30,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) wxPaletteRefData::wxPaletteRefData() { - m_palette = NULL ; - m_count = 0 ; + m_palette = NULL ; + m_count = 0 ; } wxPaletteRefData::~wxPaletteRefData() @@ -57,41 +57,41 @@ wxPalette::~wxPalette() bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) { - UnRef(); - - m_refData = new wxPaletteRefData; - - M_PALETTEDATA->m_count = n ; - M_PALETTEDATA->m_palette = new wxColour[n] ; - - for ( int i = 0 ; i < n ; ++i) - { - M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ; - } - - return FALSE; + UnRef(); + + m_refData = new wxPaletteRefData; + + M_PALETTEDATA->m_count = n ; + M_PALETTEDATA->m_palette = new wxColour[n] ; + + for ( int i = 0 ; i < n ; ++i) + { + M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ; + } + + return FALSE; } int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const { if ( !m_refData ) - return -1; - + return -1; + long bestdiff = 3 * 256 ; long bestpos = 0 ; long currentdiff ; for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i ) { - const wxColour& col = &M_PALETTEDATA->m_palette[i] ; - currentdiff = abs ( col.Red() - red ) + abs( col.Green() - green ) + abs ( col.Blue() - blue ) ; - if ( currentdiff < bestdiff ) - { - bestdiff = currentdiff ; - bestpos = i ; - if ( bestdiff == 0 ) - break ; - } + const wxColour& col = &M_PALETTEDATA->m_palette[i] ; + currentdiff = abs ( col.Red() - red ) + abs( col.Green() - green ) + abs ( col.Blue() - blue ) ; + if ( currentdiff < bestdiff ) + { + bestdiff = currentdiff ; + bestpos = i ; + if ( bestdiff == 0 ) + break ; + } } return bestpos; @@ -100,11 +100,11 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const { if ( !m_refData ) - return FALSE; - + return FALSE; + if (index < 0 || index >= M_PALETTEDATA->m_count) return FALSE; - + const wxColour& col = &M_PALETTEDATA->m_palette[index] ; *red = col.Red() ; *green = col.Green() ; @@ -114,5 +114,5 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi } #endif - // wxUSE_PALETTE +// wxUSE_PALETTE diff --git a/src/mac/pen.cpp b/src/mac/pen.cpp index 3c3d9f033b..fea55ab34e 100644 --- a/src/mac/pen.cpp +++ b/src/mac/pen.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -32,7 +32,7 @@ wxPenRefData::wxPenRefData() } wxPenRefData::wxPenRefData(const wxPenRefData& data) - : wxGDIRefData() +: wxGDIRefData() { m_style = data.m_style; m_width = data.m_width; @@ -61,7 +61,7 @@ wxPen::~wxPen() wxPen::wxPen(const wxColour& col, int Width, int Style) { m_refData = new wxPenRefData; - + M_PENDATA->m_colour = col; M_PENDATA->m_width = Width; M_PENDATA->m_style = Style; @@ -69,14 +69,14 @@ wxPen::wxPen(const wxColour& col, int Width, int Style) M_PENDATA->m_cap = wxCAP_ROUND ; M_PENDATA->m_nbDash = 0 ; M_PENDATA->m_dash = 0 ; - + RealizeResource(); } wxPen::wxPen(const wxBitmap& stipple, int Width) { m_refData = new wxPenRefData; - + M_PENDATA->m_stipple = stipple; M_PENDATA->m_width = Width; M_PENDATA->m_style = wxSTIPPLE; @@ -84,102 +84,102 @@ wxPen::wxPen(const wxBitmap& stipple, int Width) M_PENDATA->m_cap = wxCAP_ROUND ; M_PENDATA->m_nbDash = 0 ; M_PENDATA->m_dash = 0 ; - + RealizeResource(); } void wxPen::Unshare() { - // Don't change shared data - if (!m_refData) + // Don't change shared data + if (!m_refData) { - m_refData = new wxPenRefData(); - } + m_refData = new wxPenRefData(); + } else { - wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); - UnRef(); - m_refData = ref; - } + wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); + UnRef(); + m_refData = ref; + } } void wxPen::SetColour(const wxColour& col) { Unshare(); - + M_PENDATA->m_colour = col; - + RealizeResource(); } void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) { Unshare(); - + M_PENDATA->m_colour.Set(r, g, b); - + RealizeResource(); } void wxPen::SetWidth(int Width) { Unshare(); - + M_PENDATA->m_width = Width; - + RealizeResource(); } void wxPen::SetStyle(int Style) { Unshare(); - + M_PENDATA->m_style = Style; - + RealizeResource(); } void wxPen::SetStipple(const wxBitmap& Stipple) { Unshare(); - + M_PENDATA->m_stipple = Stipple; M_PENDATA->m_style = wxSTIPPLE; - + RealizeResource(); } void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) { Unshare(); - + M_PENDATA->m_nbDash = nb_dashes; M_PENDATA->m_dash = (wxDash *)Dash; - + RealizeResource(); } void wxPen::SetJoin(int Join) { Unshare(); - + M_PENDATA->m_join = Join; - + RealizeResource(); } void wxPen::SetCap(int Cap) { Unshare(); - + M_PENDATA->m_cap = Cap; - + RealizeResource(); } bool wxPen::RealizeResource() { - // nothing to do here for mac + // nothing to do here for mac return TRUE; } diff --git a/src/mac/pnghand.cpp b/src/mac/pnghand.cpp index 52b07f6e60..4f33c04b1e 100644 --- a/src/mac/pnghand.cpp +++ b/src/mac/pnghand.cpp @@ -57,8 +57,8 @@ extern void wxMacDestroyGWorld( GWorldPtr gw ) ; void ima_png_error(png_struct *png_ptr, char *message) { - wxMessageBox(message, "PNG error"); - longjmp(png_ptr->jmpbuf, 1); + wxMessageBox(message, "PNG error"); + longjmp(png_ptr->jmpbuf, 1); } @@ -67,68 +67,68 @@ wxPalette *wxCopyPalette(const wxPalette *cmap); wxPNGReader::wxPNGReader(void) { - filetype = 0; - RawImage = NULL; // Image data - - Width = 0; Height = 0; // Dimensions - Depth = 0; // (bits x pixel) - ColorType = 0; // Bit 1 = Palette used - // Bit 2 = Color used - // Bit 3 = Alpha used - - EfeWidth = 0; // Efective Width - - lpbi = NULL; - bgindex = -1; - m_palette = 0; - imageOK = FALSE; + filetype = 0; + RawImage = NULL; // Image data + + Width = 0; Height = 0; // Dimensions + Depth = 0; // (bits x pixel) + ColorType = 0; // Bit 1 = Palette used + // Bit 2 = Color used + // Bit 3 = Alpha used + + EfeWidth = 0; // Efective Width + + lpbi = NULL; + bgindex = -1; + m_palette = 0; + imageOK = FALSE; } wxPNGReader::wxPNGReader ( char* ImageFileName ) { - imageOK = FALSE; - filetype = 0; - RawImage = NULL; // Image data - - Width = 0; Height = 0; // Dimensions - Depth = 0; // (bits x pixel) - ColorType = 0; // Bit 1 = m_palette used - // Bit 2 = Color used - // Bit 3 = Alpha used - - EfeWidth = 0; // Efective Width - - lpbi = NULL; - bgindex = -1; - m_palette = 0; - - imageOK = ReadFile (ImageFileName); + imageOK = FALSE; + filetype = 0; + RawImage = NULL; // Image data + + Width = 0; Height = 0; // Dimensions + Depth = 0; // (bits x pixel) + ColorType = 0; // Bit 1 = m_palette used + // Bit 2 = Color used + // Bit 3 = Alpha used + + EfeWidth = 0; // Efective Width + + lpbi = NULL; + bgindex = -1; + m_palette = 0; + + imageOK = ReadFile (ImageFileName); } void wxPNGReader::Create(int width, int height, int depth, int colortype) { - Width = width; Height = height; Depth = depth; - ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0); - delete m_palette; - m_palette = NULL; - delete[] RawImage; - RawImage = NULL; - - if (lpbi) { - wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; - } - lpbi = wxMacCreateGWorld( Width , Height , Depth); - if (lpbi) - { - EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4; - int bitwidth = width ; - if ( EfeWidth > bitwidth ) - bitwidth = EfeWidth ; - - RawImage = (byte*) new char[ ( bitwidth * Height * ((Depth+7)>>3) ) ]; - imageOK = TRUE; - } + Width = width; Height = height; Depth = depth; + ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0); + delete m_palette; + m_palette = NULL; + delete[] RawImage; + RawImage = NULL; + + if (lpbi) { + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + } + lpbi = wxMacCreateGWorld( Width , Height , Depth); + if (lpbi) + { + EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4; + int bitwidth = width ; + if ( EfeWidth > bitwidth ) + bitwidth = EfeWidth ; + + RawImage = (byte*) new char[ ( bitwidth * Height * ((Depth+7)>>3) ) ]; + imageOK = TRUE; + } } wxPNGReader::~wxPNGReader ( ) @@ -138,7 +138,7 @@ wxPNGReader::~wxPNGReader ( ) RawImage = NULL; } if (lpbi) { - wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; lpbi = NULL; } if (m_palette != NULL) { @@ -150,128 +150,128 @@ wxPNGReader::~wxPNGReader ( ) int wxPNGReader::GetIndex(int x, int y) { - if (!Inside(x, y) || (Depth>8)) return -1; - - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - int index = (int)(*ImagePointer); - return index; + if (!Inside(x, y) || (Depth>8)) return -1; + + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + int index = (int)(*ImagePointer); + return index; } bool wxPNGReader::GetRGB(int x, int y, byte* r, byte* g, byte* b) { - if (!Inside(x, y)) return FALSE; - - if (m_palette) { - return m_palette->GetRGB(GetIndex(x, y), r, g, b); -/* PALETTEENTRY entry; - ::GetPaletteEntries((HPALETTE) m_palette->GetHPALETTE(), GetIndex(x, y), 1, &entry); - *r = entry.peRed; - *g = entry.peGreen; - *b = entry.peBlue; */ - } else { - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - *b = ImagePointer[0]; - *g = ImagePointer[1]; - *r = ImagePointer[2]; - } - return TRUE; + if (!Inside(x, y)) return FALSE; + + if (m_palette) { + return m_palette->GetRGB(GetIndex(x, y), r, g, b); + /* PALETTEENTRY entry; + ::GetPaletteEntries((HPALETTE) m_palette->GetHPALETTE(), GetIndex(x, y), 1, &entry); + *r = entry.peRed; + *g = entry.peGreen; + *b = entry.peBlue; */ + } else { + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + *b = ImagePointer[0]; + *g = ImagePointer[1]; + *r = ImagePointer[2]; + } + return TRUE; } bool wxPNGReader::SetIndex(int x, int y, int index) { - if (!Inside(x, y) || (Depth>8)) return FALSE; - - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - *ImagePointer = index; - - return TRUE; + if (!Inside(x, y) || (Depth>8)) return FALSE; + + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + *ImagePointer = index; + + return TRUE; } bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b) { - if (!Inside(x, y)) return FALSE; - - if (ColorType & COLORTYPE_PALETTE) - { - if (!m_palette) return FALSE; - SetIndex(x, y, m_palette->GetPixel(r, g, b)); - - } else { - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - ImagePointer[0] = b; - ImagePointer[1] = g; - ImagePointer[2] = r; - } - - return TRUE; + if (!Inside(x, y)) return FALSE; + + if (ColorType & COLORTYPE_PALETTE) + { + if (!m_palette) return FALSE; + SetIndex(x, y, m_palette->GetPixel(r, g, b)); + + } else { + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + ImagePointer[0] = b; + ImagePointer[1] = g; + ImagePointer[2] = r; + } + + return TRUE; } bool wxPNGReader::SetPalette(wxPalette* colourmap) { - delete m_palette ; - if (!colourmap) - return FALSE; - ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); - m_palette = new wxPalette( *colourmap ); - return true ; -// return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + delete m_palette ; + if (!colourmap) + return FALSE; + ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); + m_palette = new wxPalette( *colourmap ); + return true ; + // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } bool wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b) { - delete m_palette ; - m_palette = new wxPalette(); - if (!m_palette) - return FALSE; - - if (!g) g = r; - if (!b) b = g; - m_palette->Create(n, r, g, b); - ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); - return true ; -// return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + delete m_palette ; + m_palette = new wxPalette(); + if (!m_palette) + return FALSE; + + if (!g) g = r; + if (!b) b = g; + m_palette->Create(n, r, g, b); + ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); + return true ; + // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } bool wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct) { - delete m_palette ; - m_palette = new wxPalette(); - if (!m_palette) - return FALSE; - - byte r[256], g[256], b[256]; - - for(int i=0; iCreate(n, r, g, b); - ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); - return true ; -// return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); + delete m_palette ; + m_palette = new wxPalette(); + if (!m_palette) + return FALSE; + + byte r[256], g[256], b[256]; + + for(int i=0; iCreate(n, r, g, b); + ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); + return true ; + // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0); } void wxPNGReader::NullData() { - if (lpbi) { - wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; + if (lpbi) { + wxMacDestroyGWorld( (GWorldPtr) lpbi ) ; lpbi = NULL; - } - if (m_palette != NULL) { - delete m_palette; - m_palette = NULL; - } + } + if (m_palette != NULL) { + delete m_palette; + m_palette = NULL; + } } wxBitmap* wxPNGReader::GetBitmap(void) @@ -290,353 +290,353 @@ bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap) { if ( lpbi ) { - bitmap->SetHBITMAP((WXHBITMAP) lpbi); - bitmap->SetWidth(GetWidth()); - bitmap->SetHeight(GetHeight()); - bitmap->SetDepth(GetDepth()); - if ( GetDepth() > 1 && m_palette ) - bitmap->SetPalette(*m_palette); - bitmap->SetOk(TRUE); - - - // Make a mask if appropriate - /* - if ( bgindex > -1 ) - { + bitmap->SetHBITMAP((WXHBITMAP) lpbi); + bitmap->SetWidth(GetWidth()); + bitmap->SetHeight(GetHeight()); + bitmap->SetDepth(GetDepth()); + if ( GetDepth() > 1 && m_palette ) + bitmap->SetPalette(*m_palette); + bitmap->SetOk(TRUE); + + + // Make a mask if appropriate + /* + if ( bgindex > -1 ) + { wxMask *mask = CreateMask(); bitmap->SetMask(mask); - } - */ - lpbi = NULL ; // bitmap has taken over ownership - return TRUE; + } + */ + lpbi = NULL ; // bitmap has taken over ownership + return TRUE; } else { - return FALSE; + return FALSE; } -/* - HDC dc = ::CreateCompatibleDC(NULL); - - if (dc) - { - // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it - // is a memory dc that must have a bitmap selected into it) - HDC dc2 = GetDC(NULL); - HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight()); - ReleaseDC(NULL, dc2); - HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, tmpBitmap); - + /* + HDC dc = ::CreateCompatibleDC(NULL); + + if (dc) + { + // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it + // is a memory dc that must have a bitmap selected into it) + HDC dc2 = GetDC(NULL); + HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight()); + ReleaseDC(NULL, dc2); + HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, tmpBitmap); + if ( m_palette ) { - HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) m_palette->GetHPALETTE(), FALSE); + HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) m_palette->GetHPALETTE(), FALSE); ::RealizePalette(dc); } - - HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi, - CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS); - - ::SelectPalette(dc, NULL, TRUE); - ::SelectObject(dc, oldBitmap); - ::DeleteObject(tmpBitmap); - ::DeleteDC(dc); - - if ( hBitmap ) - { - bitmap->SetHBITMAP((WXHBITMAP) hBitmap); - bitmap->SetWidth(GetWidth()); - bitmap->SetHeight(GetHeight()); - bitmap->SetDepth(GetDepth()); - if ( GetDepth() > 1 && m_palette ) - bitmap->SetPalette(*m_palette); - bitmap->SetOk(TRUE); - - - // Make a mask if appropriate - if ( bgindex > -1 ) - { - wxMask *mask = CreateMask(); - bitmap->SetMask(mask); - } - return TRUE; - } - else - { - return FALSE; - } - } - else - { - return FALSE; - } - */ - return false ; + + HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi, + CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS); + + ::SelectPalette(dc, NULL, TRUE); + ::SelectObject(dc, oldBitmap); + ::DeleteObject(tmpBitmap); + ::DeleteDC(dc); + + if ( hBitmap ) + { + bitmap->SetHBITMAP((WXHBITMAP) hBitmap); + bitmap->SetWidth(GetWidth()); + bitmap->SetHeight(GetHeight()); + bitmap->SetDepth(GetDepth()); + if ( GetDepth() > 1 && m_palette ) + bitmap->SetPalette(*m_palette); + bitmap->SetOk(TRUE); + + + // Make a mask if appropriate + if ( bgindex > -1 ) + { + wxMask *mask = CreateMask(); + bitmap->SetMask(mask); + } + return TRUE; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } + */ + return false ; } wxPalette *wxCopyPalette(const wxPalette *cmap) { - wxPalette *newCmap = new wxPalette( *cmap ) ; - return newCmap; + wxPalette *newCmap = new wxPalette( *cmap ) ; + return newCmap; } wxMask *wxPNGReader::CreateMask(void) { /* - HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL); +HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL); HDC dc = ::CreateCompatibleDC(NULL); - HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap); - + HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap); + int bgIndex = GetBGIndex(); - - int x,y; - - for (x=0; xSetMaskBitmap((WXHBITMAP) hBitmap); - return mask; - */ - return NULL ; + int index = GetIndex(x, y); + if ( index == bgIndex ) + ::SetPixel(dc, x, GetHeight() - y - 1, RGB(0, 0, 0)); + else + ::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255)); + + } + } + ::SelectObject(dc, oldBitmap); + wxMask *mask = new wxMask; + mask->SetMaskBitmap((WXHBITMAP) hBitmap); + return mask; + */ + return NULL ; } bool wxPNGReader::ReadFile(char * ImageFileName) { - int number_passes; - - if (ImageFileName) - strcpy(filename, ImageFileName); - - FILE *fp; - png_struct *png_ptr; - png_info *info_ptr; - wxPNGReaderIter iter(this); - - /* open the file */ - fp = fopen( ImageFileName , "rb" ); - - if (!fp) - return FALSE; - - /* allocate the necessary structures */ - png_ptr = new (png_struct); - if (!png_ptr) - { - fclose(fp); - return FALSE; - } - - info_ptr = new (png_info); - if (!info_ptr) - { - fclose(fp); - delete png_ptr; - return FALSE; - } - /* set error handling */ - if (setjmp(png_ptr->jmpbuf)) - { - png_read_destroy(png_ptr, info_ptr, (png_info *)0); - fclose(fp); - delete png_ptr; - delete info_ptr; - - /* If we get here, we had a problem reading the file */ - return FALSE; - } - //png_set_error(ima_png_error, NULL); - - /* initialize the structures, info first for error handling */ - png_info_init(info_ptr); - png_read_init(png_ptr); - - /* set up the input control */ - png_init_io(png_ptr, fp); - - /* read the file information */ - png_read_info(png_ptr, info_ptr); - - /* allocate the memory to hold the image using the fields + int number_passes; + + if (ImageFileName) + strcpy(filename, ImageFileName); + + FILE *fp; + png_struct *png_ptr; + png_info *info_ptr; + wxPNGReaderIter iter(this); + + /* open the file */ + fp = fopen( ImageFileName , "rb" ); + + if (!fp) + return FALSE; + + /* allocate the necessary structures */ + png_ptr = new (png_struct); + if (!png_ptr) + { + fclose(fp); + return FALSE; + } + + info_ptr = new (png_info); + if (!info_ptr) + { + fclose(fp); + delete png_ptr; + return FALSE; + } + /* set error handling */ + if (setjmp(png_ptr->jmpbuf)) + { + png_read_destroy(png_ptr, info_ptr, (png_info *)0); + fclose(fp); + delete png_ptr; + delete info_ptr; + + /* If we get here, we had a problem reading the file */ + return FALSE; + } + //png_set_error(ima_png_error, NULL); + + /* initialize the structures, info first for error handling */ + png_info_init(info_ptr); + png_read_init(png_ptr); + + /* set up the input control */ + png_init_io(png_ptr, fp); + + /* read the file information */ + png_read_info(png_ptr, info_ptr); + + /* allocate the memory to hold the image using the fields of png_info. */ - png_color_16 my_background={ 0, 31, 127, 255, 0 }; - - if (info_ptr->valid & PNG_INFO_bKGD) + png_color_16 my_background={ 0, 31, 127, 255, 0 }; + + if (info_ptr->valid & PNG_INFO_bKGD) { - png_set_background(png_ptr, &(info_ptr->background), - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + png_set_background(png_ptr, &(info_ptr->background), + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); if ( info_ptr->num_palette > 0 ) bgindex = info_ptr->background.index; } - else { - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - + else { + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + // Added by JACS: guesswork! if ( info_ptr->num_trans != 0 ) bgindex = info_ptr->num_trans - 1 ; - } - - /* tell libpng to strip 16 bit depth files down to 8 bits */ - if (info_ptr->bit_depth == 16) - png_set_strip_16(png_ptr); - - int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24; - Create(info_ptr->width, info_ptr->height, pixel_depth, - info_ptr->color_type); - - if (info_ptr->num_palette>0) + } + + /* tell libpng to strip 16 bit depth files down to 8 bits */ + if (info_ptr->bit_depth == 16) + png_set_strip_16(png_ptr); + + int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24; + Create(info_ptr->width, info_ptr->height, pixel_depth, + info_ptr->color_type); + + if (info_ptr->num_palette>0) { - SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette); + SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette); } - - int row_stride = info_ptr->width * ((pixel_depth+7)>>3); - // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride); -// printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth); - - byte *row_pointers = new byte[row_stride]; - - /* turn on interlace handling */ - if (info_ptr->interlace_type) - number_passes = png_set_interlace_handling(png_ptr); - else - number_passes = 1; -// printf("NP = %d ", number_passes); - - for (int pass=0; pass< number_passes; pass++) - { - iter.upset(); - int y=0; - CGrafPtr origPort ; - GDHandle origDevice ; - - GetGWorld( &origPort , &origDevice ) ; - // ignore shapedc - SetGWorld( (GWorldPtr) lpbi , NULL ) ; - do - { - // (unsigned char *)iter.GetRow(); - if (info_ptr->interlace_type) - { - if (pass>0) - iter.GetRow(row_pointers, row_stride); - png_read_row(png_ptr, row_pointers, NULL); - } - else - png_read_row(png_ptr, row_pointers, NULL); - - if ( info_ptr->palette ) - { - if ( pixel_depth == 8 ) - { - for ( size_t i = 0 ; i < info_ptr->width ; ++i ) - { - png_color_struct* color ; - RGBColor col ; - - int index = row_pointers[i] ; - color = &info_ptr->palette[index] ; - col.red = (((int)color->red) << 8) | ((int)color->red) ; - col.green = (((int)color->green) << 8) | ((int)color->green) ; - col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; - SetCPixel( i, y, &col); - } - /* - png_color_struct* color ; - RGBColor col ; - unsigned char* p = &row_pointers[0] ; - PenNormal() ; - MoveTo( 0 , y ) ; - int index = *p ; - color = &info_ptr->palette[index] ; - col.red = (color->red << 8) | color->red ; - col.green = (color->green << 8) | color->green ; - col.blue = (color->blue << 8) | color->blue ; - RGBForeColor( &col ) ; - col.red = col.green = col.blue = 0xFFFF ; - RGBBackColor( &col ) ; - for ( int i = 0 ; i < info_ptr->width ; ++i , ++p) - { - if ( *p != index ) - { - LineTo( i , y ) ; - index = *p ; - color = &info_ptr->palette[index] ; - col.red = (((int)color->red) << 8) | ((int)color->red) ; - col.green = (((int)color->green) << 8) | ((int)color->green) ; - col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; - RGBForeColor( &col ) ; - } - } - LineTo( info_ptr->width , y ) ; - */ - } - else - { - for ( size_t i = 0 ; i < info_ptr->width ; ++i ) - { - png_color_struct* color ; - RGBColor col ; - - int byte = ( i * pixel_depth ) / 8 ; - int offset = ( 8 - pixel_depth ) - ( i * pixel_depth ) % 8 ; - - int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) ); - color = &info_ptr->palette[index] ; - col.red = (((int)color->red) << 8) | ((int)color->red) ; - col.green = (((int)color->green) << 8) | ((int)color->green) ; - col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; - SetCPixel( i, y, &col); - } - } - } - else - { - for ( size_t i = 0 ; i < info_ptr->width ; ++i ) - { - png_color_struct* color ; - RGBColor col ; - color =(png_color_struct*) (&row_pointers[i*3]) ; - col.red = (((int)color->red) << 8) | ((int)color->red) ; - col.green = (((int)color->green) << 8) | ((int)color->green) ; - col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; - SetCPixel( i, y, &col); - } - } - if (number_passes) - iter.SetRow(row_pointers, row_stride); - y++; - } - while(iter.PrevRow()); - SetGWorld( origPort , origDevice ) ; - -// printf("Y=%d ",y); + + int row_stride = info_ptr->width * ((pixel_depth+7)>>3); + // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride); + // printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth); + + byte *row_pointers = new byte[row_stride]; + + /* turn on interlace handling */ + if (info_ptr->interlace_type) + number_passes = png_set_interlace_handling(png_ptr); + else + number_passes = 1; + // printf("NP = %d ", number_passes); + + for (int pass=0; pass< number_passes; pass++) + { + iter.upset(); + int y=0; + CGrafPtr origPort ; + GDHandle origDevice ; + + GetGWorld( &origPort , &origDevice ) ; + // ignore shapedc + SetGWorld( (GWorldPtr) lpbi , NULL ) ; + do + { + // (unsigned char *)iter.GetRow(); + if (info_ptr->interlace_type) + { + if (pass>0) + iter.GetRow(row_pointers, row_stride); + png_read_row(png_ptr, row_pointers, NULL); + } + else + png_read_row(png_ptr, row_pointers, NULL); + + if ( info_ptr->palette ) + { + if ( pixel_depth == 8 ) + { + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) + { + png_color_struct* color ; + RGBColor col ; + + int index = row_pointers[i] ; + color = &info_ptr->palette[index] ; + col.red = (((int)color->red) << 8) | ((int)color->red) ; + col.green = (((int)color->green) << 8) | ((int)color->green) ; + col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; + SetCPixel( i, y, &col); + } + /* + png_color_struct* color ; + RGBColor col ; + unsigned char* p = &row_pointers[0] ; + PenNormal() ; + MoveTo( 0 , y ) ; + int index = *p ; + color = &info_ptr->palette[index] ; + col.red = (color->red << 8) | color->red ; + col.green = (color->green << 8) | color->green ; + col.blue = (color->blue << 8) | color->blue ; + RGBForeColor( &col ) ; + col.red = col.green = col.blue = 0xFFFF ; + RGBBackColor( &col ) ; + for ( int i = 0 ; i < info_ptr->width ; ++i , ++p) + { + if ( *p != index ) + { + LineTo( i , y ) ; + index = *p ; + color = &info_ptr->palette[index] ; + col.red = (((int)color->red) << 8) | ((int)color->red) ; + col.green = (((int)color->green) << 8) | ((int)color->green) ; + col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; + RGBForeColor( &col ) ; + } + } + LineTo( info_ptr->width , y ) ; + */ + } + else + { + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) + { + png_color_struct* color ; + RGBColor col ; + + int byte = ( i * pixel_depth ) / 8 ; + int offset = ( 8 - pixel_depth ) - ( i * pixel_depth ) % 8 ; + + int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) ); + color = &info_ptr->palette[index] ; + col.red = (((int)color->red) << 8) | ((int)color->red) ; + col.green = (((int)color->green) << 8) | ((int)color->green) ; + col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; + SetCPixel( i, y, &col); + } + } + } + else + { + for ( size_t i = 0 ; i < info_ptr->width ; ++i ) + { + png_color_struct* color ; + RGBColor col ; + color =(png_color_struct*) (&row_pointers[i*3]) ; + col.red = (((int)color->red) << 8) | ((int)color->red) ; + col.green = (((int)color->green) << 8) | ((int)color->green) ; + col.blue = (((int)color->blue) << 8) | ((int)color->blue) ; + SetCPixel( i, y, &col); + } + } + if (number_passes) + iter.SetRow(row_pointers, row_stride); + y++; + } + while(iter.PrevRow()); + SetGWorld( origPort , origDevice ) ; + + // printf("Y=%d ",y); } delete[] row_pointers; - + /* read the rest of the file, getting any additional chunks - in info_ptr */ + in info_ptr */ png_read_end(png_ptr, info_ptr); - + /* clean up after the read, and free any memory allocated */ png_read_destroy(png_ptr, info_ptr, (png_info *)0); - + /* free the structures */ delete png_ptr; delete info_ptr; - + /* close the file */ fclose(fp); - + /* that's it */ return TRUE; } @@ -646,146 +646,146 @@ bool wxPNGReader::ReadFile(char * ImageFileName) bool wxPNGReader::SaveFile(char * ImageFileName) { - if (ImageFileName) - strcpy(filename, ImageFileName); - - wxPNGReaderIter iter(this); - FILE *fp; - png_struct *png_ptr; - png_info *info_ptr; - - /* open the file */ - fp = fopen(filename, "wb"); - if (!fp) - return FALSE; - - /* allocate the necessary structures */ - png_ptr = new (png_struct); - if (!png_ptr) - { - fclose(fp); - return FALSE; - } - - info_ptr = new (png_info); - if (!info_ptr) - { - fclose(fp); - delete png_ptr; - return FALSE; - } - - /* set error handling */ - if (setjmp(png_ptr->jmpbuf)) - { + if (ImageFileName) + strcpy(filename, ImageFileName); + + wxPNGReaderIter iter(this); + FILE *fp; + png_struct *png_ptr; + png_info *info_ptr; + + /* open the file */ + fp = fopen(filename, "wb"); + if (!fp) + return FALSE; + + /* allocate the necessary structures */ + png_ptr = new (png_struct); + if (!png_ptr) + { + fclose(fp); + return FALSE; + } + + info_ptr = new (png_info); + if (!info_ptr) + { + fclose(fp); + delete png_ptr; + return FALSE; + } + + /* set error handling */ + if (setjmp(png_ptr->jmpbuf)) + { + png_write_destroy(png_ptr); + fclose(fp); + delete png_ptr; + delete info_ptr; + + /* If we get here, we had a problem reading the file */ + return FALSE; + } + //png_set_error(ima_png_error, NULL); + + // printf("writig pg %s ", filename); + /* initialize the structures */ + png_info_init(info_ptr); + png_write_init(png_ptr); + + int row_stride = GetWidth() * ((GetDepth()+7)>>3); + /* set up the output control */ + png_init_io(png_ptr, fp); + + /* set the file information here */ + info_ptr->width = GetWidth(); + info_ptr->height = GetHeight(); + info_ptr->pixel_depth = GetDepth(); + info_ptr->channels = (GetDepth()>8) ? 3: 1; + info_ptr->bit_depth = GetDepth()/info_ptr->channels; + info_ptr->color_type = GetColorType(); + info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0; + info_ptr->valid = 0; + info_ptr->rowbytes = row_stride; + + + // printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels); + /* set the palette if there is one */ + if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette()) + { + // printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); + info_ptr->valid |= PNG_INFO_PLTE; + info_ptr->palette = new png_color[256]; + info_ptr->num_palette = 256; + for (int i=0; i<256; i++) + GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); + } + // printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); + + + /* optional significant bit chunk */ + // info_ptr->valid |= PNG_INFO_sBIT; + // info_ptr->sig_bit = true_bit_depth; + + /* optional gamma chunk */ + // info_ptr->valid |= PNG_INFO_gAMA; + // info_ptr->gamma = gamma; + + /* other optional chunks */ + + /* write the file information */ + png_write_info(png_ptr, info_ptr); + + /* set up the transformations you want. Note that these are + all optional. Only call them if you want them */ + + /* shift the pixels up to a legal bit depth and fill in + as appropriate to correctly scale the image */ + // png_set_shift(png_ptr, &(info_ptr->sig_bit)); + + /* pack pixels into bytes */ + // png_set_packing(png_ptr); + + /* flip bgr pixels to rgb */ + // png_set_bgr(png_ptr); + + /* swap bytes of 16 bit files to most significant bit first */ + // png_set_swap(png_ptr); + + /* get rid of filler bytes, pack rgb into 3 bytes */ + // png_set_rgbx(png_ptr); + + /* If you are only writing one row at a time, this works */ + + byte *row_pointers = new byte[row_stride]; + iter.upset(); + do { + // (unsigned char *)iter.GetRow(); + iter.GetRow(row_pointers, row_stride); + png_write_row(png_ptr, row_pointers); + } while(iter.PrevRow()); + + delete[] row_pointers; + + /* write the rest of the file */ + png_write_end(png_ptr, info_ptr); + + /* clean up after the write, and free any memory allocated */ png_write_destroy(png_ptr); - fclose(fp); + + /* if you malloced the palette, free it here */ + if (info_ptr->palette) + delete[] (info_ptr->palette); + + /* free the structures */ delete png_ptr; delete info_ptr; - - /* If we get here, we had a problem reading the file */ - return FALSE; - } - //png_set_error(ima_png_error, NULL); - -// printf("writig pg %s ", filename); - /* initialize the structures */ - png_info_init(info_ptr); - png_write_init(png_ptr); - - int row_stride = GetWidth() * ((GetDepth()+7)>>3); - /* set up the output control */ - png_init_io(png_ptr, fp); - - /* set the file information here */ - info_ptr->width = GetWidth(); - info_ptr->height = GetHeight(); - info_ptr->pixel_depth = GetDepth(); - info_ptr->channels = (GetDepth()>8) ? 3: 1; - info_ptr->bit_depth = GetDepth()/info_ptr->channels; - info_ptr->color_type = GetColorType(); - info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0; - info_ptr->valid = 0; - info_ptr->rowbytes = row_stride; - - -// printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels); - /* set the palette if there is one */ - if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette()) - { -// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); - info_ptr->valid |= PNG_INFO_PLTE; - info_ptr->palette = new png_color[256]; - info_ptr->num_palette = 256; - for (int i=0; i<256; i++) - GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); - } -// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); - - - /* optional significant bit chunk */ -// info_ptr->valid |= PNG_INFO_sBIT; -// info_ptr->sig_bit = true_bit_depth; - - /* optional gamma chunk */ -// info_ptr->valid |= PNG_INFO_gAMA; -// info_ptr->gamma = gamma; - - /* other optional chunks */ - - /* write the file information */ - png_write_info(png_ptr, info_ptr); - - /* set up the transformations you want. Note that these are - all optional. Only call them if you want them */ - - /* shift the pixels up to a legal bit depth and fill in - as appropriate to correctly scale the image */ -// png_set_shift(png_ptr, &(info_ptr->sig_bit)); - - /* pack pixels into bytes */ -// png_set_packing(png_ptr); - - /* flip bgr pixels to rgb */ -// png_set_bgr(png_ptr); - - /* swap bytes of 16 bit files to most significant bit first */ -// png_set_swap(png_ptr); - - /* get rid of filler bytes, pack rgb into 3 bytes */ -// png_set_rgbx(png_ptr); - -/* If you are only writing one row at a time, this works */ - - byte *row_pointers = new byte[row_stride]; - iter.upset(); - do { -// (unsigned char *)iter.GetRow(); - iter.GetRow(row_pointers, row_stride); - png_write_row(png_ptr, row_pointers); - } while(iter.PrevRow()); - - delete[] row_pointers; - -/* write the rest of the file */ - png_write_end(png_ptr, info_ptr); - - /* clean up after the write, and free any memory allocated */ - png_write_destroy(png_ptr); - - /* if you malloced the palette, free it here */ - if (info_ptr->palette) - delete[] (info_ptr->palette); - - /* free the structures */ - delete png_ptr; - delete info_ptr; - - /* close the file */ - fclose(fp); - - /* that's it */ - return TRUE; + + /* close the file */ + fclose(fp); + + /* that's it */ + return TRUE; } static int Power(int x, int y) @@ -800,15 +800,15 @@ static int Power(int x, int y) } static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', - 'C', 'D', 'E', 'F' }; +'C', 'D', 'E', 'F' }; static void DecToHex(int dec, char *buf) { - int firstDigit = (int)(dec/16.0); - int secondDigit = (int)(dec - (firstDigit*16.0)); - buf[0] = hexArray[firstDigit]; - buf[1] = hexArray[secondDigit]; - buf[2] = 0; + int firstDigit = (int)(dec/16.0); + int secondDigit = (int)(dec - (firstDigit*16.0)); + buf[0] = hexArray[firstDigit]; + buf[1] = hexArray[secondDigit]; + buf[2] = 0; } @@ -822,30 +822,30 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) strcpy(nameStr, filename); wxStripExtension(nameStr); } - + if ( GetDepth() > 4 ) { // Only a depth of 4 and below allowed return FALSE; } - + if ( !GetPalette() ) return FALSE; - + wxSTD ofstream str(filename); if ( str.bad() ) return FALSE; - + int noColours = Power(2, GetDepth()); - + // Output header str << "/* XPM */\n"; str << "static char * " << nameStr << "_xpm[] = {\n"; str << "\"" << GetWidth() << " " << GetHeight() << " " << noColours << " 1\",\n"; - + // Output colourmap int base = 97 ; // start from 'a' - + unsigned char red, green, blue; char hexBuf[4]; int i; @@ -861,7 +861,7 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) str << hexBuf; str << "\",\n"; } - + // Output the data int x, y; for ( y = 0; y < GetHeight(); y++) @@ -874,10 +874,10 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) } str << "\",\n"; } - + str << "};\n"; str.flush(); - + return TRUE; } @@ -885,7 +885,7 @@ bool wxPNGReader::SaveXPM(char *filename, char *name) IMPLEMENT_DYNAMIC_CLASS(wxPNGFileHandler, wxBitmapHandler) bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, - int desiredWidth, int desiredHeight) + int desiredWidth, int desiredHeight) { wxPNGReader reader; if (reader.ReadFile((char*) (const char*) name)) diff --git a/src/mac/printdlg.cpp b/src/mac/printdlg.cpp index 7261f5576f..779ee74edd 100644 --- a/src/mac/printdlg.cpp +++ b/src/mac/printdlg.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -19,7 +19,7 @@ #include "wx/msgdlg.h" #include "wx/mac/uma.h" #ifndef __DARWIN__ - #include "Printing.h" +#include "Printing.h" #endif #if defined(TARGET_CARBON) && !defined(__DARWIN__) @@ -53,7 +53,7 @@ wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data) wxPrintDialogData data2; if ( data ) data2 = *data; - + Create(p, &data2); } @@ -62,10 +62,10 @@ bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data) m_dialogParent = p; m_printerDC = NULL; m_destroyDC = TRUE; - + if ( data ) m_printDialogData = *data; - + return TRUE; } @@ -79,31 +79,31 @@ wxPrintDialog::~wxPrintDialog() int wxPrintDialog::ShowModal() { - int result = wxID_CANCEL ; - OSErr err ; - wxString message ; - -#if !TARGET_CARBON - err = ::UMAPrOpen(NULL) ; - if ( err == noErr ) - { - m_printDialogData.ConvertToNative() ; - if ( ::PrJobDialog( (THPrint) m_printDialogData.GetPrintData().m_macPrintSettings ) ) - { - m_printDialogData.ConvertFromNative() ; - result = wxID_OK ; - } - - } - else - { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - } - ::UMAPrClose(NULL) ; + int result = wxID_CANCEL ; + OSErr err ; + wxString message ; + +#if !TARGET_CARBON + err = ::UMAPrOpen(NULL) ; + if ( err == noErr ) + { + m_printDialogData.ConvertToNative() ; + if ( ::PrJobDialog( (THPrint) m_printDialogData.GetPrintData().m_macPrintSettings ) ) + { + m_printDialogData.ConvertFromNative() ; + result = wxID_OK ; + } + + } + else + { + message.Printf( "Print Error %d", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + } + ::UMAPrClose(NULL) ; #else - #if PM_USE_SESSION_APIS +#if PM_USE_SESSION_APIS Boolean accepted; { @@ -121,16 +121,16 @@ int wxPrintDialog::ShowModal() (m_printDialogData.GetPrintData().m_macPageFormat != kPMNoPageFormat)) { err = PMSessionDefaultPageFormat((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat); + (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat); } } else { err = PMSessionValidatePageFormat((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat, - kPMDontWantBoolean); + (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat, + kPMDontWantBoolean); } - + // Set up a valid PrintSettings object. if (m_printDialogData.GetPrintData().m_macPrintSettings == kPMNoPrintSettings) { @@ -143,14 +143,14 @@ int wxPrintDialog::ShowModal() (m_printDialogData.GetPrintData().m_macPrintSettings != kPMNoPrintSettings)) { err = PMSessionDefaultPrintSettings((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings); + (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings); } } else { err = PMSessionValidatePrintSettings((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings, - kPMDontWantBoolean); + (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings, + kPMDontWantBoolean); } // Set a valid page range before displaying the Print dialog if (err == noErr) @@ -163,9 +163,9 @@ int wxPrintDialog::ShowModal() if (err == noErr) { err = PMSessionPrintDialog((PMPrintSession)m_printDialogData.GetPrintData().m_macPrintSession, - (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings, - (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat, - &accepted); + (PMPrintSettings)m_printDialogData.GetPrintData().m_macPrintSettings, + (PMPageFormat)m_printDialogData.GetPrintData().m_macPageFormat, + &accepted); if ((err == noErr) && !accepted) { err = kPMCancel; // user clicked Cancel button @@ -183,11 +183,11 @@ int wxPrintDialog::ShowModal() wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - #else - #pragma warning "TODO: Printing for carbon without session apis" - #endif +#else +#pragma warning "TODO: Printing for carbon without session apis" #endif - return result ; +#endif + return result ; } wxDC *wxPrintDialog::GetPrintDC() @@ -196,17 +196,17 @@ wxDC *wxPrintDialog::GetPrintDC() } /* - * wxPageSetupDialog - */ +* wxPageSetupDialog +*/ wxPageSetupDialog::wxPageSetupDialog(): - wxDialog() +wxDialog() { - m_dialogParent = NULL; + m_dialogParent = NULL; } wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data): - wxDialog() +wxDialog() { Create(p, data); } @@ -214,10 +214,10 @@ wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data): bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data) { m_dialogParent = p; - + if (data) m_pageSetupData = (*data); - + return TRUE; } @@ -227,31 +227,31 @@ wxPageSetupDialog::~wxPageSetupDialog() int wxPageSetupDialog::ShowModal() { - int result = wxID_CANCEL ; - OSErr err ; - wxString message ; - + int result = wxID_CANCEL ; + OSErr err ; + wxString message ; + #if !TARGET_CARBON - err = ::UMAPrOpen(NULL) ; - if ( err == noErr ) - { - m_pageSetupData.ConvertToNative() ; - if ( ::PrStlDialog( (THPrint) m_pageSetupData.GetPrintData().m_macPrintSettings ) ) - { - m_pageSetupData.ConvertFromNative() ; - result = wxID_OK ; - } - - } - else - { - message.Printf( "Print Error %d", err ) ; - wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; - dialog.ShowModal(); - } - ::UMAPrClose(NULL) ; + err = ::UMAPrOpen(NULL) ; + if ( err == noErr ) + { + m_pageSetupData.ConvertToNative() ; + if ( ::PrStlDialog( (THPrint) m_pageSetupData.GetPrintData().m_macPrintSettings ) ) + { + m_pageSetupData.ConvertFromNative() ; + result = wxID_OK ; + } + + } + else + { + message.Printf( "Print Error %d", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + dialog.ShowModal(); + } + ::UMAPrClose(NULL) ; #else - #if PM_USE_SESSION_APIS +#if PM_USE_SESSION_APIS Boolean accepted; { @@ -269,22 +269,22 @@ int wxPageSetupDialog::ShowModal() (m_pageSetupData.GetPrintData().m_macPageFormat != kPMNoPageFormat)) { err = PMSessionDefaultPageFormat((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat); + (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat); } } else { err = PMSessionValidatePageFormat((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat, - kPMDontWantBoolean); + (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat, + kPMDontWantBoolean); } // Display the Page Setup dialog. if (err == noErr) { err = PMSessionPageSetupDialog((PMPrintSession)m_pageSetupData.GetPrintData().m_macPrintSession, - (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat, - &accepted); + (PMPageFormat)m_pageSetupData.GetPrintData().m_macPageFormat, + &accepted); if ((err == noErr) && !accepted) { err = kPMCancel; // user clicked Cancel button @@ -305,10 +305,10 @@ int wxPageSetupDialog::ShowModal() wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; dialog.ShowModal(); } - #else - #pragma warning "TODO: Printing for carbon without session apis" - #endif +#else +#pragma warning "TODO: Printing for carbon without session apis" +#endif #endif - return result ; + return result ; } diff --git a/src/mac/printmac.cpp b/src/mac/printmac.cpp index 60d15137cf..20ea496801 100644 --- a/src/mac/printmac.cpp +++ b/src/mac/printmac.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -43,11 +43,11 @@ IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase) #endif /* - * Printer - */ - +* Printer +*/ + wxMacPrinter::wxMacPrinter(wxPrintDialogData *data): - wxPrinterBase(data) +wxPrinterBase(data) { } @@ -57,170 +57,170 @@ wxMacPrinter::~wxMacPrinter(void) bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { - sm_abortIt = FALSE; - sm_abortWindow = NULL; - - if (!printout) - return FALSE; + sm_abortIt = FALSE; + sm_abortWindow = NULL; - printout->SetIsPreview(FALSE); - printout->OnPreparePrinting(); - - // Get some parameters from the printout, if defined - int fromPage, toPage; - int minPage, maxPage; - printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); - - if (maxPage == 0) - return FALSE; - - m_printDialogData.SetMinPage(minPage); - m_printDialogData.SetMaxPage(maxPage); - if (fromPage != 0) - m_printDialogData.SetFromPage(fromPage); - if (toPage != 0) - m_printDialogData.SetToPage(toPage); - - if (minPage != 0) - { - m_printDialogData.EnablePageNumbers(TRUE); - if (m_printDialogData.GetFromPage() < m_printDialogData.GetMinPage()) - m_printDialogData.SetFromPage(m_printDialogData.GetMinPage()); - else if (m_printDialogData.GetFromPage() > m_printDialogData.GetMaxPage()) - m_printDialogData.SetFromPage(m_printDialogData.GetMaxPage()); - if (m_printDialogData.GetToPage() > m_printDialogData.GetMaxPage()) - m_printDialogData.SetToPage(m_printDialogData.GetMaxPage()); - else if (m_printDialogData.GetToPage() < m_printDialogData.GetMinPage()) - m_printDialogData.SetToPage(m_printDialogData.GetMinPage()); - } - else - m_printDialogData.EnablePageNumbers(FALSE); - - // Create a suitable device context - wxDC *dc = NULL; - if (prompt) - { + if (!printout) + return FALSE; + + printout->SetIsPreview(FALSE); + printout->OnPreparePrinting(); + + // Get some parameters from the printout, if defined + int fromPage, toPage; + int minPage, maxPage; + printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); + + if (maxPage == 0) + return FALSE; + + m_printDialogData.SetMinPage(minPage); + m_printDialogData.SetMaxPage(maxPage); + if (fromPage != 0) + m_printDialogData.SetFromPage(fromPage); + if (toPage != 0) + m_printDialogData.SetToPage(toPage); + + if (minPage != 0) + { + m_printDialogData.EnablePageNumbers(TRUE); + if (m_printDialogData.GetFromPage() < m_printDialogData.GetMinPage()) + m_printDialogData.SetFromPage(m_printDialogData.GetMinPage()); + else if (m_printDialogData.GetFromPage() > m_printDialogData.GetMaxPage()) + m_printDialogData.SetFromPage(m_printDialogData.GetMaxPage()); + if (m_printDialogData.GetToPage() > m_printDialogData.GetMaxPage()) + m_printDialogData.SetToPage(m_printDialogData.GetMaxPage()); + else if (m_printDialogData.GetToPage() < m_printDialogData.GetMinPage()) + m_printDialogData.SetToPage(m_printDialogData.GetMinPage()); + } + else + m_printDialogData.EnablePageNumbers(FALSE); + + // Create a suitable device context + wxDC *dc = NULL; + if (prompt) + { wxPrintDialog dialog(parent, & m_printDialogData); if (dialog.ShowModal() == wxID_OK) - { - dc = dialog.GetPrintDC(); - m_printDialogData = dialog.GetPrintData(); - } - } - else - { - dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; - } - - - // May have pressed cancel. - if (!dc || !dc->Ok()) - { - if (dc) delete dc; - return FALSE; - } - - // on the mac we have always pixels as addressing mode with 72 dpi - - printout->SetPPIScreen(72, 72); - printout->SetPPIPrinter(72, 72); - - // Set printout parameters - printout->SetDC(dc); - - int w, h; - wxCoord ww, hh; - dc->GetSize(&w, &h); - printout->SetPageSizePixels((int)w, (int)h); - dc->GetSizeMM(&ww, &hh); - printout->SetPageSizeMM((int)ww, (int)hh); - - // Create an abort window - wxBeginBusyCursor(); - - wxWindow *win = CreateAbortWindow(parent, printout); - wxSafeYield(win,true); - - if (!win) - { - wxEndBusyCursor(); - wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent); - delete dc; - return FALSE; - } - sm_abortWindow = win; - sm_abortWindow->Show(TRUE); - wxSafeYield(win,true); - - printout->OnBeginPrinting(); - - bool keepGoing = TRUE; - - int copyCount; - for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++) - { - if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) + { + dc = dialog.GetPrintDC(); + m_printDialogData = dialog.GetPrintData(); + } + } + else { - wxEndBusyCursor(); - wxMessageBox("Could not start printing.", "Print Error", wxOK, parent); - break; + dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; } - if (sm_abortIt) - break; - - int pn; - for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); - pn++) + + + // May have pressed cancel. + if (!dc || !dc->Ok()) { - if (sm_abortIt) - { - keepGoing = FALSE; - break; - } - else - { - GrafPtr thePort ; - GetPort( &thePort ) ; - wxSafeYield(win,true); - SetPort( thePort ) ; - - dc->StartPage(); - keepGoing = printout->OnPrintPage(pn); - dc->EndPage(); - } + if (dc) delete dc; + return FALSE; } - printout->OnEndDocument(); - } - - printout->OnEndPrinting(); - - if (sm_abortWindow) - { - sm_abortWindow->Show(FALSE); - delete sm_abortWindow; - sm_abortWindow = NULL; - } - - wxEndBusyCursor(); - - delete dc; - - return TRUE; + + // on the mac we have always pixels as addressing mode with 72 dpi + + printout->SetPPIScreen(72, 72); + printout->SetPPIPrinter(72, 72); + + // Set printout parameters + printout->SetDC(dc); + + int w, h; + wxCoord ww, hh; + dc->GetSize(&w, &h); + printout->SetPageSizePixels((int)w, (int)h); + dc->GetSizeMM(&ww, &hh); + printout->SetPageSizeMM((int)ww, (int)hh); + + // Create an abort window + wxBeginBusyCursor(); + + wxWindow *win = CreateAbortWindow(parent, printout); + wxSafeYield(win,true); + + if (!win) + { + wxEndBusyCursor(); + wxMessageBox("Sorry, could not create an abort dialog.", "Print Error", wxOK, parent); + delete dc; + return FALSE; + } + sm_abortWindow = win; + sm_abortWindow->Show(TRUE); + wxSafeYield(win,true); + + printout->OnBeginPrinting(); + + bool keepGoing = TRUE; + + int copyCount; + for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++) + { + if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) + { + wxEndBusyCursor(); + wxMessageBox("Could not start printing.", "Print Error", wxOK, parent); + break; + } + if (sm_abortIt) + break; + + int pn; + for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); + pn++) + { + if (sm_abortIt) + { + keepGoing = FALSE; + break; + } + else + { + GrafPtr thePort ; + GetPort( &thePort ) ; + wxSafeYield(win,true); + SetPort( thePort ) ; + + dc->StartPage(); + keepGoing = printout->OnPrintPage(pn); + dc->EndPage(); + } + } + printout->OnEndDocument(); + } + + printout->OnEndPrinting(); + + if (sm_abortWindow) + { + sm_abortWindow->Show(FALSE); + delete sm_abortWindow; + sm_abortWindow = NULL; + } + + wxEndBusyCursor(); + + delete dc; + + return TRUE; } wxDC* wxMacPrinter::PrintDialog(wxWindow *parent) { wxDC* dc = (wxDC*) NULL; - + wxPrintDialog dialog(parent, & m_printDialogData); int ret = dialog.ShowModal(); - + if (ret == wxID_OK) { dc = dialog.GetPrintDC(); m_printDialogData = dialog.GetPrintDialogData(); } - + return dc; } @@ -228,33 +228,33 @@ bool wxMacPrinter::Setup(wxWindow *parent) { wxPrintDialog dialog(parent, & m_printDialogData); dialog.GetPrintDialogData().SetSetupDialog(TRUE); - + int ret = dialog.ShowModal(); - + if (ret == wxID_OK) { m_printDialogData = dialog.GetPrintDialogData(); } - + return (ret == wxID_OK); } /* - * Print preview - */ +* Print preview +*/ wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, - wxPrintout *printoutForPrinting, - wxPrintDialogData *data) - : wxPrintPreviewBase(printout, printoutForPrinting, data) + wxPrintout *printoutForPrinting, + wxPrintDialogData *data) + : wxPrintPreviewBase(printout, printoutForPrinting, data) { DetermineScaling(); } wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data): - wxPrintPreviewBase(printout, printoutForPrinting, data) +wxPrintPreviewBase(printout, printoutForPrinting, data) { - DetermineScaling(); + DetermineScaling(); } wxMacPrintPreview::~wxMacPrintPreview(void) @@ -263,43 +263,43 @@ wxMacPrintPreview::~wxMacPrintPreview(void) bool wxMacPrintPreview::Print(bool interactive) { - if (!m_printPrintout) - return FALSE; - wxMacPrinter printer(&m_printDialogData); - return printer.Print(m_previewFrame, m_printPrintout, interactive); + if (!m_printPrintout) + return FALSE; + wxMacPrinter printer(&m_printDialogData); + return printer.Print(m_previewFrame, m_printPrintout, interactive); } void wxMacPrintPreview::DetermineScaling(void) { - int screenWidth , screenHeight ; - wxDisplaySize( &screenWidth , &screenHeight ) ; - - m_previewPrintout->SetPPIScreen( 72 , 72 ) ; - m_previewPrintout->SetPPIPrinter( 72 , 72 ) ; - m_previewPrintout->SetPageSizeMM( (int) (8.0 * 25.6), (int) (11.0 * 25.6) ); - m_previewPrintout->SetPageSizePixels( 8 * 72 , 11 * 72 ) ; + int screenWidth , screenHeight ; + wxDisplaySize( &screenWidth , &screenHeight ) ; + + m_previewPrintout->SetPPIScreen( 72 , 72 ) ; + m_previewPrintout->SetPPIPrinter( 72 , 72 ) ; + m_previewPrintout->SetPageSizeMM( (int) (8.0 * 25.6), (int) (11.0 * 25.6) ); + m_previewPrintout->SetPageSizePixels( 8 * 72 , 11 * 72 ) ; m_pageWidth = 8 * 72 ; m_pageHeight = 11 * 72 ; m_previewScale = 1 ; - + // Get a device context for the currently selected printer wxPrinterDC printerDC(m_printDialogData.GetPrintData()); if (printerDC.Ok()) { - int x , y ; - wxCoord ww, hh; - printerDC.GetSizeMM(&ww, &hh); - printerDC.GetSize( &x , &y ) ; - m_previewPrintout->SetPageSizeMM((int)ww, (int)hh); - m_previewPrintout->SetPageSizePixels( x , y) ; - m_pageWidth = x ; - m_pageHeight = y ; - m_isOk = true ; - } - else - { - m_isOk = false ; - } + int x , y ; + wxCoord ww, hh; + printerDC.GetSizeMM(&ww, &hh); + printerDC.GetSize( &x , &y ) ; + m_previewPrintout->SetPageSizeMM((int)ww, (int)hh); + m_previewPrintout->SetPageSizePixels( x , y) ; + m_pageWidth = x ; + m_pageHeight = y ; + m_isOk = true ; + } + else + { + m_isOk = false ; + } // At 100%, the page should look about page-size on the screen. // m_previewScale = (float)((float)screenWidth/(float)printerWidth); // m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerXRes); diff --git a/src/mac/radiobox.cpp b/src/mac/radiobox.cpp index 61e8561c28..15ac067af7 100644 --- a/src/mac/radiobox.cpp +++ b/src/mac/radiobox.cpp @@ -6,16 +6,16 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ - #pragma implementation "radioboxbase.h" - #pragma implementation "radiobox.h" +#pragma implementation "radioboxbase.h" +#pragma implementation "radiobox.h" #endif //------------------------------------------------------------------------------------- -// headers +// headers //------------------------------------------------------------------------------------- #include "wx/defs.h" @@ -32,7 +32,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) #pragma mark ### Constructors & destructor ### //------------------------------------------------------------------------------------- -// Â¥ wxRadioBox() +// Â¥ wxRadioBox() //------------------------------------------------------------------------------------- // Default constructor BEGIN_EVENT_TABLE(wxRadioBox, wxControl) @@ -41,15 +41,15 @@ END_EVENT_TABLE() void wxRadioBox::OnRadioButton( wxCommandEvent &outer ) { - if ( outer.IsChecked() ) - { - wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId); - int i = GetSelection() ; - event.SetInt( i ); - event.SetString( GetString( i ) ); - event.SetEventObject( this ); - ProcessCommand(event); - } + if ( outer.IsChecked() ) + { + wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId); + int i = GetSelection() ; + event.SetInt( i ); + event.SetString( GetString( i ) ); + event.SetEventObject( this ); + ProcessCommand(event); + } } wxRadioBox::wxRadioBox() @@ -61,9 +61,9 @@ wxRadioBox::wxRadioBox() } //------------------------------------------------------------------------------------- -// Â¥ wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&, -// const wxSize&, int, const wxString[], int, long, -// const wxValidator&, const wxString&) +// Â¥ wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&, +// const wxSize&, int, const wxString[], int, long, +// const wxValidator&, const wxString&) //------------------------------------------------------------------------------------- // Contructor, creating and showing a radiobox // @@ -71,67 +71,67 @@ wxRadioBox::wxRadioBox() // //------------------------------------------------------------------------------------- -// Â¥ ~wxRadioBox +// Â¥ ~wxRadioBox //------------------------------------------------------------------------------------- // Destructor, destroying the radiobox item wxRadioBox::~wxRadioBox() { - wxRadioButton *next,*current; - + wxRadioButton *next,*current; + current=m_radioButtonCycle->NextInCycle(); next=current->NextInCycle(); while (current!=m_radioButtonCycle) { - delete current; - current=next; - next=current->NextInCycle(); - } + delete current; + current=next; + next=current->NextInCycle(); + } delete current; } //------------------------------------------------------------------------------------- -// Â¥ Create +// Â¥ Create //------------------------------------------------------------------------------------- // Create the radiobox for two-step construction bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, - const wxPoint& pos, const wxSize& size, - int n, const wxString choices[], - int majorDim, long style, - const wxValidator& val, const wxString& name) + const wxPoint& pos, const wxSize& size, + int n, const wxString choices[], + int majorDim, long style, + const wxValidator& val, const wxString& name) { int i; m_noItems = n; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; - + if (majorDim==0) m_majorDim = n ; else m_majorDim = majorDim ; - - + + Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ; m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlGroupBoxTextTitleProc , (long) this ) ; + kControlGroupBoxTextTitleProc , (long) this ) ; for (i = 0; i < n; i++) { wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(), wxStripMenuCodes(choices[i]),wxPoint(5,20*i+10), - wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ; + wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ; if ( i == 0 ) - m_radioButtonCycle = radBtn ; -// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); + m_radioButtonCycle = radBtn ; + // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } - + SetSelection(0); MacPostControlCreate() ; - + return TRUE; } @@ -140,7 +140,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, #pragma mark ### Specific functions (reference v2) ### //------------------------------------------------------------------------------------- -// Â¥ Enable(bool) +// Â¥ Enable(bool) //------------------------------------------------------------------------------------- // Enables or disables the entire radiobox @@ -150,18 +150,18 @@ bool wxRadioBox::Enable(bool enable) wxRadioButton *current; if (!wxControl::Enable(enable)) - return false; + return false; current = m_radioButtonCycle; for (i = 0; i < m_noItems; i++) { - current->Enable(enable); - current = current->NextInCycle(); + current->Enable(enable); + current = current->NextInCycle(); } return true; } //------------------------------------------------------------------------------------- -// Â¥ Enable(int, bool) +// Â¥ Enable(int, bool) //------------------------------------------------------------------------------------- // Enables or disables an given button @@ -176,14 +176,14 @@ void wxRadioBox::Enable(int item, bool enable) i = 0; current = m_radioButtonCycle; while (i != item) { - i++; - current = current->NextInCycle(); + i++; + current = current->NextInCycle(); } current->Enable(enable); } //------------------------------------------------------------------------------------- -// Â¥ GetLabel() +// Â¥ GetLabel() //------------------------------------------------------------------------------------- // Returns the radiobox label @@ -193,7 +193,7 @@ wxString wxRadioBox::GetLabel() const } //------------------------------------------------------------------------------------- -// Â¥ GetLabel(int) +// Â¥ GetLabel(int) //------------------------------------------------------------------------------------- // Returns the label for the given button @@ -208,14 +208,14 @@ wxString wxRadioBox::GetString(int item) const i = 0; current = m_radioButtonCycle; while (i != item) { - i++; - current = current->NextInCycle(); + i++; + current = current->NextInCycle(); } return current->GetLabel(); } //------------------------------------------------------------------------------------- -// Â¥ GetSelection +// Â¥ GetSelection //------------------------------------------------------------------------------------- // Returns the zero-based position of the selected button @@ -227,15 +227,15 @@ int wxRadioBox::GetSelection() const i=0; current=m_radioButtonCycle; while (!current->GetValue()) { - i++; - current=current->NextInCycle(); - } - + i++; + current=current->NextInCycle(); + } + return i; } //------------------------------------------------------------------------------------- -// Â¥ Number +// Â¥ Number //------------------------------------------------------------------------------------- // Returns the number of buttons in the radiobox // @@ -243,7 +243,7 @@ int wxRadioBox::GetSelection() const // //------------------------------------------------------------------------------------- -// Â¥ SetLabel(const wxString&) +// Â¥ SetLabel(const wxString&) //------------------------------------------------------------------------------------- // Sets the radiobox label @@ -253,28 +253,28 @@ void wxRadioBox::SetLabel(const wxString& label) } //------------------------------------------------------------------------------------- -// Â¥ SetLabel(int, const wxString&) +// Â¥ SetLabel(int, const wxString&) //------------------------------------------------------------------------------------- // Sets the label of a given button void wxRadioBox::SetString(int item,const wxString& label) { - int i; + int i; wxRadioButton *current; if ((item < 0) || (item >= m_noItems)) return; - i=0; + i=0; current=m_radioButtonCycle; while (i!=item) { - i++; - current=current->NextInCycle(); - } + i++; + current=current->NextInCycle(); + } return current->SetLabel(label); } //------------------------------------------------------------------------------------- -// Â¥ SetSelection +// Â¥ SetSelection //------------------------------------------------------------------------------------- // Sets a button by passing the desired position. This does not cause // wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted @@ -289,15 +289,15 @@ void wxRadioBox::SetSelection(int item) i=0; current=m_radioButtonCycle; while (i!=item) { - i++; - current=current->NextInCycle(); - } + i++; + current=current->NextInCycle(); + } current->SetValue(true); } //------------------------------------------------------------------------------------- -// Â¥ Show(bool) +// Â¥ Show(bool) //------------------------------------------------------------------------------------- // Shows or hides the entire radiobox @@ -307,23 +307,23 @@ bool wxRadioBox::Show(bool show) wxRadioButton *current; wxControl::Show(show); - + current=m_radioButtonCycle; - for (i=0;iShow(show); - current=current->NextInCycle(); - } + for (i=0;iShow(show); + current=current->NextInCycle(); + } return true; } //------------------------------------------------------------------------------------- -// Â¥ Show(int, bool) +// Â¥ Show(int, bool) //------------------------------------------------------------------------------------- // Shows or hides the given button void wxRadioBox::Show(int item, bool show) { - int i; + int i; wxRadioButton *current; if ((item < 0) || (item >= m_noItems)) @@ -331,9 +331,9 @@ void wxRadioBox::Show(int item, bool show) i=0; current=m_radioButtonCycle; while (i!=item) { - i++; - current=current->NextInCycle(); - } + i++; + current=current->NextInCycle(); + } current->Show(show); } @@ -341,7 +341,7 @@ void wxRadioBox::Show(int item, bool show) #pragma mark ### Other external functions ### //------------------------------------------------------------------------------------- -// Â¥ Command +// Â¥ Command //------------------------------------------------------------------------------------- // Simulates the effect of the user issuing a command to the item @@ -352,7 +352,7 @@ void wxRadioBox::Command (wxCommandEvent & event) } //------------------------------------------------------------------------------------- -// Â¥ SetFocus +// Â¥ SetFocus //------------------------------------------------------------------------------------- // Sets the selected button to receive keyboard input @@ -364,10 +364,10 @@ void wxRadioBox::SetFocus() i=0; current=m_radioButtonCycle; while (!current->GetValue()) { - i++; - current=current->NextInCycle(); - } - current->SetFocus(); + i++; + current=current->NextInCycle(); + } + current->SetFocus(); } @@ -375,7 +375,7 @@ void wxRadioBox::SetFocus() #pragma mark ### Internal functions ### //------------------------------------------------------------------------------------- -// Â¥ DoSetSize +// Â¥ DoSetSize //------------------------------------------------------------------------------------- // Simulates the effect of the user issuing a command to the item @@ -383,49 +383,49 @@ void wxRadioBox::SetFocus() void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - int i; - wxRadioButton *current; - -// define the position - - int x_current, y_current; - int x_offset,y_offset; + int i; + wxRadioButton *current; + + // define the position + + int x_current, y_current; + int x_offset,y_offset; int widthOld, heightOld; GetSize(&widthOld, &heightOld); - - x_offset = x; - y_offset = y; - GetPosition(&x_current, &y_current); - if ((x == -1) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - x_offset = x_current; - if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - y_offset = y_current; - -// define size - - int charWidth,charHeight; - int maxWidth,maxHeight; - int eachWidth[128],eachHeight[128]; + + x_offset = x; + y_offset = y; + GetPosition(&x_current, &y_current); + if ((x == -1) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + x_offset = x_current; + if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + y_offset = y_current; + + // define size + + int charWidth,charHeight; + int maxWidth,maxHeight; + int eachWidth[128],eachHeight[128]; int totWidth,totHeight; - - SetFont(GetParent()->GetFont()); - GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); - charWidth/=52; - - maxWidth=-1; - maxHeight=-1; - for (i = 0 ; i < m_noItems; i++) - { - GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i]); - eachWidth[i] = (int)(eachWidth[i] + RADIO_SIZE); - eachHeight[i] = (int)((3*eachHeight[i])/2); - if (maxWidthGetFont()); + GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); + charWidth/=52; + + maxWidth=-1; + maxHeight=-1; + for (i = 0 ; i < m_noItems; i++) + { + GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i]); + eachWidth[i] = (int)(eachWidth[i] + RADIO_SIZE); + eachHeight[i] = (int)((3*eachHeight[i])/2); + if (maxWidthSetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]); - current=current->NextInCycle(); - - if (m_windowStyle & wxRA_SPECIFY_ROWS) - y_offset += maxHeight ; /*+ charHeight/2;*/ - else - x_offset += maxWidth + charWidth; - } + + wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO); + + // arrange radiobuttons + + int x_start,y_start; + + + x_start = charWidth; + y_start = 15 ; + x_offset = x_start; + y_offset = y_start; + + current=m_radioButtonCycle; + for ( i = 0 ; i < m_noItems; i++) + { + if (i&&((i%m_majorDim)==0)) // not to do for the zero button! + { + if (m_windowStyle & wxRA_VERTICAL) + { + x_offset += maxWidth + charWidth; + y_offset = y_start; + } + else + { + x_offset = x_start; + y_offset += maxHeight ; /*+ charHeight/2;*/ + } + } + + current->SetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]); + current=current->NextInCycle(); + + if (m_windowStyle & wxRA_SPECIFY_ROWS) + y_offset += maxHeight ; /*+ charHeight/2;*/ + else + x_offset += maxWidth + charWidth; + } } wxSize wxRadioBox::DoGetBestSize() const @@ -488,37 +488,37 @@ wxSize wxRadioBox::DoGetBestSize() const int maxWidth, maxHeight; int eachWidth, eachHeight; int totWidth, totHeight; - + wxFont font = GetParent()->GetFont(); GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), - &charWidth, &charHeight, NULL, NULL, &font); + &charWidth, &charHeight, NULL, NULL, &font); charWidth /= 52; - - maxWidth = -1; - maxHeight = -1; - - for (int i = 0 ; i < m_noItems; i++) - { + + maxWidth = -1; + maxHeight = -1; + + for (int i = 0 ; i < m_noItems; i++) + { GetTextExtent(GetString(i), &eachWidth, &eachHeight); eachWidth = (int)(eachWidth + RADIO_SIZE) ; eachHeight = (int)((3 * eachHeight) / 2); if (maxWidth < eachWidth) maxWidth = eachWidth; if (maxHeight < eachHeight) maxHeight = eachHeight; } - + totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight * 3/2; totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth; - + // handle radio box title as well GetTextExtent(GetTitle(), &eachWidth, NULL); eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ; if (totWidth < eachWidth) totWidth = eachWidth; - - return wxSize(totWidth, totHeight); + + return wxSize(totWidth, totHeight); } //------------------------------------------------------------------------------------- -// Â¥ GetNumVer +// Â¥ GetNumVer //------------------------------------------------------------------------------------- // return the number of buttons in the vertical direction @@ -535,7 +535,7 @@ int wxRadioBox::GetRowCount() const } //------------------------------------------------------------------------------------- -// Â¥ GetNumHor +// Â¥ GetNumHor //------------------------------------------------------------------------------------- // return the number of buttons in the horizontal direction diff --git a/src/mac/radiobut.cpp b/src/mac/radiobut.cpp index e94c762f1d..46014e4576 100644 --- a/src/mac/radiobut.cpp +++ b/src/mac/radiobut.cpp @@ -6,7 +6,7 @@ // Created: ??/??/98 // RCS-ID: $Id$ // Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,27 +24,27 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) #include "wx/mac/uma.h" bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, - const wxString& label, + const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlRadioButtonProc , (long) this ) ; - - MacPostControlCreate() ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlRadioButtonProc , (long) this ) ; + + MacPostControlCreate() ; m_cycle = this ; if (HasFlag(wxRB_GROUP)) { - AddInCycle( NULL ) ; + AddInCycle( NULL ) ; } else { @@ -68,21 +68,21 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, void wxRadioButton::SetValue(bool val) { - wxRadioButton *cycle; - if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val ) - return ; - + wxRadioButton *cycle; + if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val ) + return ; + ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; if (val) { - cycle=this->NextInCycle(); - if (cycle!=NULL) { - while (cycle!=this) { - cycle->SetValue(false); - cycle=cycle->NextInCycle(); - } - } - } + cycle=this->NextInCycle(); + if (cycle!=NULL) { + while (cycle!=this) { + cycle->SetValue(false); + cycle=cycle->NextInCycle(); + } + } + } MacRedrawControl() ; } @@ -102,19 +102,19 @@ void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpar if ( GetValue() ) return ; - wxRadioButton *cycle, *old = NULL ; + wxRadioButton *cycle, *old = NULL ; cycle=this->NextInCycle(); if (cycle!=NULL) { - while (cycle!=this) { - if ( cycle->GetValue() ) { - old = cycle ; - cycle->SetValue(false); - } - cycle=cycle->NextInCycle(); - } + while (cycle!=this) { + if ( cycle->GetValue() ) { + old = cycle ; + cycle->SetValue(false); + } + cycle=cycle->NextInCycle(); + } } - SetValue(true) ; + SetValue(true) ; if ( old ) { wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, old->m_windowId ); @@ -130,18 +130,18 @@ void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpar wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle) { - wxRadioButton *next,*current; - - if (cycle==NULL) { - m_cycle=this; - return(this); - } - else { - current=cycle; - while ((next=current->m_cycle)!=cycle) - current=current->m_cycle; - m_cycle=cycle; - current->m_cycle=this; - return(cycle); - } + wxRadioButton *next,*current; + + if (cycle==NULL) { + m_cycle=this; + return(this); + } + else { + current=cycle; + while ((next=current->m_cycle)!=cycle) + current=current->m_cycle; + m_cycle=cycle; + current->m_cycle=this; + return(cycle); + } } diff --git a/src/mac/region.cpp b/src/mac/region.cpp index 6c1ef13da2..b151987990 100644 --- a/src/mac/region.cpp +++ b/src/mac/region.cpp @@ -3,7 +3,7 @@ // Purpose: Region class // Author: Markus Holzem/Julian Smart/Stefan Csomor // Created: Fri Oct 24 10:46:34 MET 1997 -// RCS-ID: $Id$ +// RCS-ID: $Id$ // Copyright: (c) 1997 Markus Holzem/Julian Smart/Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -17,8 +17,8 @@ #include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY - IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) - IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject) + IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) + IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject) #endif //----------------------------------------------------------------------------- @@ -43,7 +43,7 @@ public: { DisposeRgn( m_macRgn ) ; } - RgnHandle m_macRgn ; + RgnHandle m_macRgn ; }; #define M_REGION (((wxRegionRefData*)m_refData)->m_macRgn) @@ -106,20 +106,20 @@ void wxRegion::Clear() //! Combine rectangle (x, y, w, h) with this. bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) { - // Don't change shared data - if (!m_refData) - { - m_refData = new wxRegionRefData(); - } - else if (m_refData->GetRefCount() > 1) - { - wxRegionRefData* ref = (wxRegionRefData*)m_refData; - UnRef(); - m_refData = new wxRegionRefData(*ref); - } + // Don't change shared data + if (!m_refData) + { + m_refData = new wxRegionRefData(); + } + else if (m_refData->GetRefCount() > 1) + { + wxRegionRefData* ref = (wxRegionRefData*)m_refData; + UnRef(); + m_refData = new wxRegionRefData(*ref); + } RgnHandle rgn = NewRgn() ; - SetRectRgn( rgn , x , y, x+width,y + height ) ; - + SetRectRgn( rgn , x , y, x+width,y + height ) ; + switch (op) { case wxRGN_AND: @@ -136,11 +136,11 @@ bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) break ; case wxRGN_COPY: default: - CopyRgn( rgn ,M_REGION ) ; + CopyRgn( rgn ,M_REGION ) ; break ; } - DisposeRgn( rgn ) ; + DisposeRgn( rgn ) ; return TRUE; } @@ -148,19 +148,19 @@ bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) //! Union /e region with this. bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) { - if (region.Empty()) - return FALSE; - - // Don't change shared data - if (!m_refData) { - m_refData = new wxRegionRefData(); - } - else if (m_refData->GetRefCount() > 1) - { - wxRegionRefData* ref = (wxRegionRefData*)m_refData; - UnRef(); - m_refData = new wxRegionRefData(*ref); - } + if (region.Empty()) + return FALSE; + + // Don't change shared data + if (!m_refData) { + m_refData = new wxRegionRefData(); + } + else if (m_refData->GetRefCount() > 1) + { + wxRegionRefData* ref = (wxRegionRefData*)m_refData; + UnRef(); + m_refData = new wxRegionRefData(*ref); + } switch (op) { @@ -178,11 +178,11 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) break ; case wxRGN_COPY: default: - CopyRgn( OTHER_M_REGION(region) ,M_REGION ) ; + CopyRgn( OTHER_M_REGION(region) ,M_REGION ) ; break ; } - return TRUE; + return TRUE; } bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) @@ -197,19 +197,19 @@ bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) // Outer bounds of region void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const { - if (m_refData) - { - Rect box ; - GetRegionBounds( M_REGION , &box ) ; + if (m_refData) + { + Rect box ; + GetRegionBounds( M_REGION , &box ) ; x = box.left ; y = box.top ; w = box.right - box.left ; h = box.bottom - box.top ; - } - else - { - x = y = w = h = 0; - } + } + else + { + x = y = w = h = 0; + } } wxRect wxRegion::GetBox() const @@ -227,7 +227,7 @@ bool wxRegion::Empty() const const WXHRGN wxRegion::GetWXHRGN() const { - return M_REGION ; + return M_REGION ; } //----------------------------------------------------------------------------- @@ -237,8 +237,8 @@ const WXHRGN wxRegion::GetWXHRGN() const // Does the region contain the point (x,y)? wxRegionContain wxRegion::Contains(long x, long y) const { - if (!m_refData) - return wxOutRegion; + if (!m_refData) + return wxOutRegion; // TODO. Return wxInRegion if within region. if (0) @@ -249,8 +249,8 @@ wxRegionContain wxRegion::Contains(long x, long y) const // Does the region contain the point pt? wxRegionContain wxRegion::Contains(const wxPoint& pt) const { - if (!m_refData) - return wxOutRegion; + if (!m_refData) + return wxOutRegion; Point p = { pt.y , pt.x } ; if (PtInRgn( p , M_REGION ) ) @@ -262,8 +262,8 @@ wxRegionContain wxRegion::Contains(const wxPoint& pt) const // Does the region contain the rectangle (x, y, w, h)? wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const { - if (!m_refData) - return wxOutRegion; + if (!m_refData) + return wxOutRegion; Rect rect = { y , x , y + h , x + w } ; if (RectInRgn( &rect , M_REGION ) ) @@ -275,8 +275,8 @@ wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const // Does the region contain the rectangle rect wxRegionContain wxRegion::Contains(const wxRect& rect) const { - if (!m_refData) - return wxOutRegion; + if (!m_refData) + return wxOutRegion; long x, y, w, h; x = rect.x; @@ -370,7 +370,7 @@ void wxRegionIterator::Reset(const wxRegion& region) m_numRects = 0; else { - // we cannot dissolve it into rects on mac + // we cannot dissolve it into rects on mac m_rects = new wxRect[1]; Rect rect ; GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ; @@ -409,29 +409,29 @@ wxRegionIterator wxRegionIterator::operator ++ (int) long wxRegionIterator::GetX() const { - if (m_current < m_numRects) - return m_rects[m_current].x; - return 0; + if (m_current < m_numRects) + return m_rects[m_current].x; + return 0; } long wxRegionIterator::GetY() const { - if (m_current < m_numRects) - return m_rects[m_current].y; - return 0; + if (m_current < m_numRects) + return m_rects[m_current].y; + return 0; } long wxRegionIterator::GetW() const { - if (m_current < m_numRects) - return m_rects[m_current].width ; - return 0; + if (m_current < m_numRects) + return m_rects[m_current].width ; + return 0; } long wxRegionIterator::GetH() const { - if (m_current < m_numRects) - return m_rects[m_current].height; - return 0; + if (m_current < m_numRects) + return m_rects[m_current].height; + return 0; } diff --git a/src/mac/scrolbar.cpp b/src/mac/scrolbar.cpp index d341b03c4a..6f57b2c40d 100644 --- a/src/mac/scrolbar.cpp +++ b/src/mac/scrolbar.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -43,19 +43,19 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, if (!parent) return FALSE; - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , true , 0 , 0 , 100, - kControlScrollBarLiveProc , (long) this ) ; - - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , true , 0 , 0 , 100, + kControlScrollBarLiveProc , (long) this ) ; + + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; + ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; - MacPostControlCreate() ; + MacPostControlCreate() ; return TRUE; } @@ -81,7 +81,7 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS m_viewSize = thumbSize; m_objectSize = range; - int range1 = wxMax((m_objectSize - m_viewSize), 0) ; + int range1 = wxMax((m_objectSize - m_viewSize), 0) ; SetControl32BitMaximum( (ControlHandle) m_macControl , range1 ) ; SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ; @@ -91,7 +91,7 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS { if ( SetControlViewSize != (void*) kUnresolvedCFragSymbolAddress ) { - SetControlViewSize( (ControlHandle) m_macControl , m_viewSize ) ; + SetControlViewSize( (ControlHandle) m_macControl , m_viewSize ) ; } } if ( refresh ) @@ -107,70 +107,70 @@ void wxScrollBar::Command(wxCommandEvent& event) void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - if ( (ControlHandle) m_macControl == NULL ) - return ; - - int position = GetControl32BitValue( (ControlHandle) m_macControl) ; - int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ; - int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ; - - wxEventType scrollEvent = wxEVT_NULL; - int nScrollInc; - - switch( controlpart ) - { - case kControlUpButtonPart : + if ( (ControlHandle) m_macControl == NULL ) + return ; + + int position = GetControl32BitValue( (ControlHandle) m_macControl) ; + int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ; + int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ; + + wxEventType scrollEvent = wxEVT_NULL; + int nScrollInc; + + switch( controlpart ) + { + case kControlUpButtonPart : nScrollInc = -1; scrollEvent = wxEVT_SCROLL_LINEUP; - break ; - case kControlDownButtonPart : + break ; + case kControlDownButtonPart : nScrollInc = 1; scrollEvent = wxEVT_SCROLL_LINEDOWN; - break ; - case kControlPageUpPart : + break ; + case kControlPageUpPart : nScrollInc = -m_pageSize; scrollEvent = wxEVT_SCROLL_PAGEUP; - break ; - case kControlPageDownPart : + break ; + case kControlPageDownPart : nScrollInc = m_pageSize; scrollEvent = wxEVT_SCROLL_PAGEDOWN; - break ; - case kControlIndicatorPart : + break ; + case kControlIndicatorPart : nScrollInc = 0 ; scrollEvent = wxEVT_SCROLL_THUMBTRACK; - break ; - default : - wxFAIL_MSG(wxT("illegal scrollbar selector")); - break ; - } - - int new_pos = position + nScrollInc; - - if (new_pos < minPos) - new_pos = minPos; - if (new_pos > maxPos) - new_pos = maxPos; - if ( nScrollInc ) - SetThumbPosition(new_pos); - - wxScrollEvent event(scrollEvent, m_windowId); - if ( m_windowStyle & wxHORIZONTAL ) - { - event.SetOrientation( wxHORIZONTAL ) ; - } - else - { - event.SetOrientation( wxVERTICAL ) ; - } - event.SetPosition(new_pos); - event.SetEventObject( this ); - wxWindow* window = GetParent() ; - if (window && window->MacIsWindowScrollbar(this) ) - { - // this is hardcoded - window->MacOnScroll(event); - } - else - GetEventHandler()->ProcessEvent(event); + break ; + default : + wxFAIL_MSG(wxT("illegal scrollbar selector")); + break ; + } + + int new_pos = position + nScrollInc; + + if (new_pos < minPos) + new_pos = minPos; + if (new_pos > maxPos) + new_pos = maxPos; + if ( nScrollInc ) + SetThumbPosition(new_pos); + + wxScrollEvent event(scrollEvent, m_windowId); + if ( m_windowStyle & wxHORIZONTAL ) + { + event.SetOrientation( wxHORIZONTAL ) ; + } + else + { + event.SetOrientation( wxVERTICAL ) ; + } + event.SetPosition(new_pos); + event.SetEventObject( this ); + wxWindow* window = GetParent() ; + if (window && window->MacIsWindowScrollbar(this) ) + { + // this is hardcoded + window->MacOnScroll(event); + } + else + GetEventHandler()->ProcessEvent(event); } diff --git a/src/mac/slider.cpp b/src/mac/slider.cpp index f27d107c83..2a95191da2 100644 --- a/src/mac/slider.cpp +++ b/src/mac/slider.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,101 +24,100 @@ END_EVENT_TABLE() #endif // The dimensions of the different styles of sliders (From Aqua document) - #define wxSLIDER_DIMENSIONACROSS 15 - #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24 - #define wxSLIDER_DIMENSIONACROSS_ARROW 18 +#define wxSLIDER_DIMENSIONACROSS 15 +#define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24 +#define wxSLIDER_DIMENSIONACROSS_ARROW 18 - // Distance between slider and text - #define wxSLIDER_BORDERTEXT 5 +// Distance between slider and text +#define wxSLIDER_BORDERTEXT 5 - /* NB! The default orientation for a slider is horizontal however if the user specifies - * some slider styles but dosen't specify the orientation we have to assume he wants a - * horizontal one. Therefore in this file when testing for the sliders orientation - * vertical is tested for if this is not set then we use the horizontal one - * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }> - */ - - -// Slider -wxSlider::wxSlider() +/* NB! The default orientation for a slider is horizontal however if the user specifies + * some slider styles but dosen't specify the orientation we have to assume he wants a + * horizontal one. Therefore in this file when testing for the sliders orientation + * vertical is tested for if this is not set then we use the horizontal one + * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }> + */ + + // Slider + wxSlider::wxSlider() { - m_pageSize = 1; - m_lineSize = 1; - m_rangeMax = 0; - m_rangeMin = 0; - m_tickFreq = 0; + m_pageSize = 1; + m_lineSize = 1; + m_rangeMax = 0; + m_rangeMin = 0; + m_tickFreq = 0; } extern ControlActionUPP wxMacLiveScrollbarActionUPP ; bool wxSlider::Create(wxWindow *parent, wxWindowID id, - int value, int minValue, int maxValue, - const wxPoint& pos, - const wxSize& size, long style, - const wxValidator& validator, - const wxString& name) + int value, int minValue, int maxValue, + const wxPoint& pos, + const wxSize& size, long style, + const wxValidator& validator, + const wxString& name) { - Rect bounds ; - Str255 title ; - SInt16 procID; - - m_macMinimumStatic = NULL ; - m_macMaximumStatic = NULL ; - m_macValueStatic = NULL ; - - - m_lineSize = 1; - m_tickFreq = 0; - - m_rangeMax = maxValue; - m_rangeMin = minValue; - - m_pageSize = (int)((maxValue-minValue)/10); - - MacPreControlCreate( parent, id, "", pos, size, style, - validator, name, &bounds, title ); - - procID = kControlSliderProc + kControlSliderLiveFeedback; - if(style & wxSL_AUTOTICKS) { - procID += kControlSliderHasTickMarks; + Rect bounds ; + Str255 title ; + SInt16 procID; + + m_macMinimumStatic = NULL ; + m_macMaximumStatic = NULL ; + m_macValueStatic = NULL ; + + + m_lineSize = 1; + m_tickFreq = 0; + + m_rangeMax = maxValue; + m_rangeMin = minValue; + + m_pageSize = (int)((maxValue-minValue)/10); + + MacPreControlCreate( parent, id, "", pos, size, style, + validator, name, &bounds, title ); + + procID = kControlSliderProc + kControlSliderLiveFeedback; + if(style & wxSL_AUTOTICKS) { + procID += kControlSliderHasTickMarks; } - - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, - value, minValue, maxValue, procID, (long) this); - - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - - ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; - - if(style & wxSL_LABELS) - { - m_macMinimumStatic = new wxStaticText( this, -1, "" ); - m_macMaximumStatic = new wxStaticText( this, -1, "" ); - m_macValueStatic = new wxStaticText( this, -1, "" ); - SetRange(minValue, maxValue); - SetValue(value); + + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false, + value, minValue, maxValue, procID, (long) this); + + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + + ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ; + + if(style & wxSL_LABELS) + { + m_macMinimumStatic = new wxStaticText( this, -1, "" ); + m_macMaximumStatic = new wxStaticText( this, -1, "" ); + m_macValueStatic = new wxStaticText( this, -1, "" ); + SetRange(minValue, maxValue); + SetValue(value); } - - else { - m_macMinimumStatic = NULL ; - m_macMaximumStatic = NULL ; - m_macValueStatic = NULL ; - } - - if(style & wxSL_VERTICAL) { - SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width - } - else { - SetSizeHints(-1, 10, -1, 10); // Forces SetSize to use the proper height - } - // NB! SetSizeHints is overloaded by wxSlider and will substitute 10 with the - // proper dimensions, it also means other people cannot bugger the slider with - // other values - - MacPostControlCreate() ; - - return true; + + else { + m_macMinimumStatic = NULL ; + m_macMaximumStatic = NULL ; + m_macValueStatic = NULL ; + } + + if(style & wxSL_VERTICAL) { + SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width + } + else { + SetSizeHints(-1, 10, -1, 10); // Forces SetSize to use the proper height + } + // NB! SetSizeHints is overloaded by wxSlider and will substitute 10 with the + // proper dimensions, it also means other people cannot bugger the slider with + // other values + + MacPostControlCreate() ; + + return true; } wxSlider::~wxSlider() @@ -127,37 +126,37 @@ wxSlider::~wxSlider() int wxSlider::GetValue() const { - return GetControl32BitValue( (ControlHandle) m_macControl) ; + return GetControl32BitValue( (ControlHandle) m_macControl) ; } void wxSlider::SetValue(int value) { - wxString valuestring ; - valuestring.Printf( "%d" , value ) ; - if ( m_macValueStatic ) - m_macValueStatic->SetLabel( valuestring ) ; - SetControl32BitValue( (ControlHandle) m_macControl , value ) ; + wxString valuestring ; + valuestring.Printf( "%d" , value ) ; + if ( m_macValueStatic ) + m_macValueStatic->SetLabel( valuestring ) ; + SetControl32BitValue( (ControlHandle) m_macControl , value ) ; } void wxSlider::SetRange(int minValue, int maxValue) { - wxString value; - - m_rangeMin = minValue; - m_rangeMax = maxValue; - - SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); - SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); - - if(m_macMinimumStatic) { - value.Printf("%d", m_rangeMin); - m_macMinimumStatic->SetLabel(value); - } - if(m_macMaximumStatic) { - value.Printf("%d", m_rangeMax); - m_macMaximumStatic->SetLabel(value); - } - SetValue(m_rangeMin); + wxString value; + + m_rangeMin = minValue; + m_rangeMax = maxValue; + + SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin); + SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax); + + if(m_macMinimumStatic) { + value.Printf("%d", m_rangeMin); + m_macMinimumStatic->SetLabel(value); + } + if(m_macMaximumStatic) { + value.Printf("%d", m_rangeMax); + m_macMaximumStatic->SetLabel(value); + } + SetValue(m_rangeMin); } // For trackbars only @@ -235,164 +234,164 @@ void wxSlider::SetTick(int tickPos) void wxSlider::Command (wxCommandEvent & event) { - SetValue (event.GetInt()); - ProcessCommand (event); + SetValue (event.GetInt()); + ProcessCommand (event); } void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; - - SetValue( value ) ; - - wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); - event.SetPosition(value); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent(event); - - wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); - cevent.SetInt( value ); - cevent.SetEventObject( this ); - - GetEventHandler()->ProcessEvent( cevent ); + SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ; + + SetValue( value ) ; + + wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); + event.SetPosition(value); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); + + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); + cevent.SetInt( value ); + cevent.SetEventObject( this ); + + GetEventHandler()->ProcessEvent( cevent ); +} + +/* This is overloaded in wxSlider so that the proper width/height will always be used +* for the slider different values would cause redrawing and mouse detection problems */ +void wxSlider::SetSizeHints( int minW, int minH, + int maxW , int maxH , + int incW , int incH ) +{ + wxSize size = GetBestSize(); + + if(GetWindowStyle() & wxSL_VERTICAL) { + wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH); + } + else { + wxWindow::SetSizeHints(minW, size.y, maxW, size.y, incW, incH); + } } - /* This is overloaded in wxSlider so that the proper width/height will always be used - * for the slider different values would cause redrawing and mouse detection problems */ - void wxSlider::SetSizeHints( int minW, int minH, - int maxW , int maxH , - int incW , int incH ) - { - wxSize size = GetBestSize(); - - if(GetWindowStyle() & wxSL_VERTICAL) { - wxWindow::SetSizeHints(size.x, minH, size.x, maxH, incW, incH); - } - else { - wxWindow::SetSizeHints(minW, size.y, maxW, size.y, incW, incH); - } - } - - wxSize wxSlider::DoGetBestSize() const - { - wxSize size; - int textwidth, textheight; - - if(GetWindowStyle() & wxSL_LABELS) - { - wxString text; - int ht, wd; - - // Get maximum text label width and height - text.Printf("%d", m_rangeMin); - GetTextExtent(text, &textwidth, &textheight); - text.Printf("%d", m_rangeMax); - GetTextExtent(text, &wd, &ht); - if(ht > textheight) { - textheight = ht; - } - if (wd > textwidth) { - textwidth = wd; - } - } - - if(GetWindowStyle() & wxSL_VERTICAL) - { - if(GetWindowStyle() & wxSL_AUTOTICKS) { - size.x = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; - } - else { - size.x = wxSLIDER_DIMENSIONACROSS_ARROW; - } - if(GetWindowStyle() & wxSL_LABELS) { - size.x += textwidth + wxSLIDER_BORDERTEXT; - } - size.y = 150; - } - else - { - if(GetWindowStyle() & wxSL_AUTOTICKS) { - size.y = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; - } - else { - size.y = wxSLIDER_DIMENSIONACROSS_ARROW; - } - if(GetWindowStyle() & wxSL_LABELS) { - size.y += textheight + wxSLIDER_BORDERTEXT; - } - size.x = 150; - } - return size; - } - - void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags) - { +wxSize wxSlider::DoGetBestSize() const +{ + wxSize size; + int textwidth, textheight; + + if(GetWindowStyle() & wxSL_LABELS) + { + wxString text; + int ht, wd; + + // Get maximum text label width and height + text.Printf("%d", m_rangeMin); + GetTextExtent(text, &textwidth, &textheight); + text.Printf("%d", m_rangeMax); + GetTextExtent(text, &wd, &ht); + if(ht > textheight) { + textheight = ht; + } + if (wd > textwidth) { + textwidth = wd; + } + } + + if(GetWindowStyle() & wxSL_VERTICAL) + { + if(GetWindowStyle() & wxSL_AUTOTICKS) { + size.x = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; + } + else { + size.x = wxSLIDER_DIMENSIONACROSS_ARROW; + } + if(GetWindowStyle() & wxSL_LABELS) { + size.x += textwidth + wxSLIDER_BORDERTEXT; + } + size.y = 150; + } + else + { + if(GetWindowStyle() & wxSL_AUTOTICKS) { + size.y = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; + } + else { + size.y = wxSLIDER_DIMENSIONACROSS_ARROW; + } + if(GetWindowStyle() & wxSL_LABELS) { + size.y += textheight + wxSLIDER_BORDERTEXT; + } + size.x = 150; + } + return size; +} + +void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags) +{ wxControl::DoSetSize( x, y , width , height ,sizeFlags ) ; - } - - void wxSlider::MacUpdateDimensions() +} + +void wxSlider::MacUpdateDimensions() { - // actually in the current systems this should never be possible, but later reparenting - // may become a reality - - if ( (ControlHandle) m_macControl == NULL ) - return ; - - if ( GetParent() == NULL ) - return ; - + // actually in the current systems this should never be possible, but later reparenting + // may become a reality + + if ( (ControlHandle) m_macControl == NULL ) + return ; + + if ( GetParent() == NULL ) + return ; + WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; if ( rootwindow == NULL ) - return ; - - int xborder, yborder; - int minValWidth, maxValWidth, textwidth, textheight; - int sliderBreadth; - - xborder = yborder = 0; - - if (GetWindowStyle() & wxSL_LABELS) - { - wxString text; - int ht; - - // Get maximum text label width and height - text.Printf("%d", m_rangeMin); - GetTextExtent(text, &minValWidth, &textheight); - text.Printf("%d", m_rangeMax); - GetTextExtent(text, &maxValWidth, &ht); - if(ht > textheight) { - textheight = ht; - } - textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); - - xborder = textwidth + wxSLIDER_BORDERTEXT; - yborder = textheight + wxSLIDER_BORDERTEXT; - - // Get slider breadth - if(GetWindowStyle() & wxSL_AUTOTICKS) { - sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; - } - else { - sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; - } - - if(GetWindowStyle() & wxSL_VERTICAL) - { - m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, - m_height - yborder - textheight); - m_macMaximumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, 0); - m_macValueStatic->Move(0, m_height - textheight); - } - else - { - m_macMinimumStatic->Move(0, sliderBreadth + wxSLIDER_BORDERTEXT); - m_macMaximumStatic->Move(m_width - xborder - maxValWidth / 2, - sliderBreadth + wxSLIDER_BORDERTEXT); - m_macValueStatic->Move(m_width - textwidth, 0); - } - } - + return ; + + int xborder, yborder; + int minValWidth, maxValWidth, textwidth, textheight; + int sliderBreadth; + + xborder = yborder = 0; + + if (GetWindowStyle() & wxSL_LABELS) + { + wxString text; + int ht; + + // Get maximum text label width and height + text.Printf("%d", m_rangeMin); + GetTextExtent(text, &minValWidth, &textheight); + text.Printf("%d", m_rangeMax); + GetTextExtent(text, &maxValWidth, &ht); + if(ht > textheight) { + textheight = ht; + } + textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth); + + xborder = textwidth + wxSLIDER_BORDERTEXT; + yborder = textheight + wxSLIDER_BORDERTEXT; + + // Get slider breadth + if(GetWindowStyle() & wxSL_AUTOTICKS) { + sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS; + } + else { + sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW; + } + + if(GetWindowStyle() & wxSL_VERTICAL) + { + m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, + m_height - yborder - textheight); + m_macMaximumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, 0); + m_macValueStatic->Move(0, m_height - textheight); + } + else + { + m_macMinimumStatic->Move(0, sliderBreadth + wxSLIDER_BORDERTEXT); + m_macMaximumStatic->Move(m_width - xborder - maxValWidth / 2, + sliderBreadth + wxSLIDER_BORDERTEXT); + m_macValueStatic->Move(m_width - textwidth, 0); + } + } + Rect oldBounds ; GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; @@ -404,18 +403,18 @@ void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ; bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ; bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ; - if ( doMove || doResize ) - { - InvalWindowRect( rootwindow, &oldBounds ) ; - if ( doMove ) - { - UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; - } - if ( doResize ) - { - UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; - } - } + if ( doMove || doResize ) + { + InvalWindowRect( rootwindow, &oldBounds ) ; + if ( doMove ) + { + UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ; + } + if ( doResize ) + { + UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ; + } + } } void wxSlider::DoMoveWindow(int x, int y, int width, int height) diff --git a/src/mac/spinbutt.cpp b/src/mac/spinbutt.cpp index 85fd2d0b08..b36c755f7e 100644 --- a/src/mac/spinbutt.cpp +++ b/src/mac/spinbutt.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -36,29 +36,29 @@ wxSpinButton::wxSpinButton() } bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - long style, const wxString& name) + long style, const wxString& name) { m_min = 0; m_max = 100; - - if (!parent) - return FALSE; - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, - kControlLittleArrowsProc , (long) this ) ; - - wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; - - MacPostControlCreate() ; - - return TRUE; + if (!parent) + return FALSE; + + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100, + kControlLittleArrowsProc , (long) this ) ; + + wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ; + + MacPostControlCreate() ; + + return TRUE; } - + wxSpinButton::~wxSpinButton() { } @@ -68,12 +68,12 @@ wxSpinButton::~wxSpinButton() int wxSpinButton::GetMin() const { - return m_min; + return m_min; } int wxSpinButton::GetMax() const { - return m_max; + return m_max; } int wxSpinButton::GetValue() const @@ -83,50 +83,50 @@ int wxSpinButton::GetValue() const void wxSpinButton::SetValue(int val) { - m_value = val ; + m_value = val ; } void wxSpinButton::SetRange(int minVal, int maxVal) { - m_min = minVal; - m_max = maxVal; + m_min = minVal; + m_max = maxVal; SetControl32BitMaximum( (ControlHandle) m_macControl , maxVal ) ; SetControl32BitMinimum((ControlHandle) m_macControl , minVal ) ; } void wxSpinButton::MacHandleValueChanged( int inc ) { - + wxEventType scrollEvent = wxEVT_NULL; - int oldValue = m_value ; - + int oldValue = m_value ; + m_value = oldValue + inc; - + if (m_value < m_min) { - if ( m_windowStyle & wxSP_WRAP ) - m_value = m_max; - else - m_value = m_min; + if ( m_windowStyle & wxSP_WRAP ) + m_value = m_max; + else + m_value = m_min; } - + if (m_value > m_max) { - if ( m_windowStyle & wxSP_WRAP ) - m_value = m_min; - else - m_value = m_max; + if ( m_windowStyle & wxSP_WRAP ) + m_value = m_min; + else + m_value = m_max; } - + if ( m_value - oldValue == -1 ) scrollEvent = wxEVT_SCROLL_LINEDOWN ; else if ( m_value - oldValue == 1 ) scrollEvent = wxEVT_SCROLL_LINEUP ; else scrollEvent = wxEVT_SCROLL_THUMBTRACK ; - + wxSpinEvent event(scrollEvent, m_windowId); - + event.SetPosition(m_value); event.SetEventObject( this ); if ((GetEventHandler()->ProcessEvent( event )) && @@ -135,7 +135,7 @@ void wxSpinButton::MacHandleValueChanged( int inc ) m_value = oldValue ; } SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ; - + /* always send a thumbtrack event */ if (scrollEvent != wxEVT_SCROLL_THUMBTRACK) { @@ -149,22 +149,22 @@ void wxSpinButton::MacHandleValueChanged( int inc ) void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - if ( (ControlHandle) m_macControl == NULL ) - return ; - - int nScrollInc = 0; - - switch( controlpart ) - { - case kControlUpButtonPart : - nScrollInc = 1; - break ; - case kControlDownButtonPart : - nScrollInc = -1; - break ; - } - MacHandleValueChanged( nScrollInc ) ; - + if ( (ControlHandle) m_macControl == NULL ) + return ; + + int nScrollInc = 0; + + switch( controlpart ) + { + case kControlUpButtonPart : + nScrollInc = 1; + break ; + case kControlDownButtonPart : + nScrollInc = -1; + break ; + } + MacHandleValueChanged( nScrollInc ) ; + } // ---------------------------------------------------------------------------- @@ -173,6 +173,6 @@ void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart wxSize wxSpinButton::DoGetBestSize() const { - return wxSize(16,24); + return wxSize(16,24); } diff --git a/src/mac/statbmp.cpp b/src/mac/statbmp.cpp index ab37567e88..68bc4efa6a 100644 --- a/src/mac/statbmp.cpp +++ b/src/mac/statbmp.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -38,13 +38,13 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, const wxString& name) { SetName(name); - wxSize size = s ; - if ( bitmap.Ok() ) - { - if ( size.x == -1 ) - size.x = bitmap.GetWidth() ; - if ( size.y == -1 ) - size.y = bitmap.GetHeight() ; + wxSize size = s ; + if ( bitmap.Ok() ) + { + if ( size.x == -1 ) + size.x = bitmap.GetWidth() ; + if ( size.y == -1 ) + size.y = bitmap.GetHeight() ; } m_backgroundColour = parent->GetBackgroundColour() ; @@ -52,14 +52,14 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, m_bitmap = bitmap; if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; m_windowStyle = style; bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); - SetBestSize( size ) ; + SetBestSize( size ) ; return ret; } diff --git a/src/mac/statbox.cpp b/src/mac/statbox.cpp index cef41efca7..e494e9e709 100644 --- a/src/mac/statbox.cpp +++ b/src/mac/statbox.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -22,7 +22,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) BEGIN_EVENT_TABLE(wxStaticBox, wxControl) - EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground) + EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground) END_EVENT_TABLE() #endif @@ -38,15 +38,15 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlGroupBoxTextTitleProc , (long) this ) ; - - MacPostControlCreate() ; - - return TRUE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlGroupBoxTextTitleProc , (long) this ) ; + + MacPostControlCreate() ; + + return TRUE; } diff --git a/src/mac/statbrma.cpp b/src/mac/statbrma.cpp index d3fef290a3..e39e83bb81 100644 --- a/src/mac/statbrma.cpp +++ b/src/mac/statbrma.cpp @@ -22,7 +22,7 @@ #include "wx/dcclient.h" BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) - EVT_PAINT(wxStatusBarMac::OnPaint) + EVT_PAINT(wxStatusBarMac::OnPaint) END_EVENT_TABLE() #ifdef __WXMAC__ @@ -47,38 +47,38 @@ wxStatusBarMac::~wxStatusBarMac() } bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, - long style , - const wxString& name) + long style , + const wxString& name) { - return wxStatusBarGeneric::Create( parent , id , style , name ) ; + return wxStatusBarGeneric::Create( parent , id , style , name ) ; } void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) { - int leftMargin = 2; - - wxRect rect; - GetFieldRect(i, rect); - - if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) - { - dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; - } - - wxString text(GetStatusText(i)); - - long x, y; - - dc.GetTextExtent(text, &x, &y); - - int xpos = rect.x + leftMargin + 1 ; - int ypos = 2 ; - - dc.SetClippingRegion(rect.x, 0, rect.width, m_height); - - dc.DrawText(text, xpos, ypos); - - dc.DestroyClippingRegion(); + int leftMargin = 2; + + wxRect rect; + GetFieldRect(i, rect); + + if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) + { + dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; + } + + wxString text(GetStatusText(i)); + + long x, y; + + dc.GetTextExtent(text, &x, &y); + + int xpos = rect.x + leftMargin + 1 ; + int ypos = 2 ; + + dc.SetClippingRegion(rect.x, 0, rect.width, m_height); + + dc.DrawText(text, xpos, ypos); + + dc.DestroyClippingRegion(); } void wxStatusBarMac::DrawField(wxDC& dc, int i) @@ -89,8 +89,8 @@ void wxStatusBarMac::DrawField(wxDC& dc, int i) void wxStatusBarMac::SetStatusText(const wxString& text, int number) { wxCHECK_RET( (number >= 0) && (number < m_nFields), - _T("invalid status bar field index") ); - + _T("invalid status bar field index") ); + m_statusStrings[number] = text; wxRect rect; GetFieldRect(number, rect); @@ -101,35 +101,35 @@ void wxStatusBarMac::SetStatusText(const wxString& text, int number) void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) { - wxPaintDC dc(this); - dc.Clear() ; - - if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) - { - wxPen black( wxBLACK , 1 , wxSOLID ) ; - wxPen white( wxWHITE , 1 , wxSOLID ) ; - - dc.SetPen(black); - dc.DrawLine(0, 0 , - m_width , 0); - dc.SetPen(white); - dc.DrawLine(0, 1 , - m_width , 1); - } - else - { - dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); - dc.DrawLine(0, 0 , - m_width , 0); - } - - int i; - if ( GetFont().Ok() ) - dc.SetFont(GetFont()); - dc.SetBackgroundMode(wxTRANSPARENT); - - for ( i = 0; i < m_nFields; i ++ ) - DrawField(dc, i); + wxPaintDC dc(this); + dc.Clear() ; + + if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) + { + wxPen black( wxBLACK , 1 , wxSOLID ) ; + wxPen white( wxWHITE , 1 , wxSOLID ) ; + + dc.SetPen(black); + dc.DrawLine(0, 0 , + m_width , 0); + dc.SetPen(white); + dc.DrawLine(0, 1 , + m_width , 1); + } + else + { + dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); + dc.DrawLine(0, 0 , + m_width , 0); + } + + int i; + if ( GetFont().Ok() ) + dc.SetFont(GetFont()); + dc.SetBackgroundMode(wxTRANSPARENT); + + for ( i = 0; i < m_nFields; i ++ ) + DrawField(dc, i); } void wxStatusBarMac::MacSuperEnabled( bool enabled ) diff --git a/src/mac/statlmac.cpp b/src/mac/statlmac.cpp index 2c01893e84..dc00dcca0f 100644 --- a/src/mac/statlmac.cpp +++ b/src/mac/statlmac.cpp @@ -49,15 +49,15 @@ bool wxStaticLine::Create( wxWindow *parent, long style, const wxString &name) { - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlSeparatorLineProc , (long) this ) ; - - MacPostControlCreate() ; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlSeparatorLineProc , (long) this ) ; + + MacPostControlCreate() ; return TRUE; } diff --git a/src/mac/stattext.cpp b/src/mac/stattext.cpp index f0175deaf3..fc0a5726f9 100644 --- a/src/mac/stattext.cpp +++ b/src/mac/stattext.cpp @@ -137,44 +137,44 @@ void wxStaticText::OnDraw( wxDC &dc ) { if (m_width <= 0 || m_height <= 0) return; -/* - dc.Clear() ; - wxRect rect(0,0,m_width,m_height) ; - dc.SetFont(*wxSMALL_FONT) ; - - dc.DrawRectangle(rect) ; -*/ - if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) && - ( GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) - || GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) ) - { - dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; - } - else - { - dc.SetTextForeground( GetForegroundColour() ) ; - } - - wxString paragraph; - size_t i = 0 ; - wxString text = m_label; - int y = 0 ; - while (i < text.Length()) - { - - if (text[i] == 13 || text[i] == 10) + /* + dc.Clear() ; + wxRect rect(0,0,m_width,m_height) ; + dc.SetFont(*wxSMALL_FONT) ; + + dc.DrawRectangle(rect) ; + */ + if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) && + ( GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) + || GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) ) { - DrawParagraph(dc, paragraph,y); - paragraph = "" ; + dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; } else { - paragraph += text[i]; + dc.SetTextForeground( GetForegroundColour() ) ; + } + + wxString paragraph; + size_t i = 0 ; + wxString text = m_label; + int y = 0 ; + while (i < text.Length()) + { + + if (text[i] == 13 || text[i] == 10) + { + DrawParagraph(dc, paragraph,y); + paragraph = "" ; + } + else + { + paragraph += text[i]; + } + ++i; } - ++i; - } - if (paragraph.Length() > 0) - DrawParagraph(dc, paragraph,y); + if (paragraph.Length() > 0) + DrawParagraph(dc, paragraph,y); } void wxStaticText::OnPaint( wxPaintEvent & WXUNUSED(event) ) diff --git a/src/mac/tabctrl.cpp b/src/mac/tabctrl.cpp index 08b7204373..6e79c88386 100644 --- a/src/mac/tabctrl.cpp +++ b/src/mac/tabctrl.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -34,18 +34,18 @@ wxTabCtrl::wxTabCtrl() bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - Rect bounds ; - Str255 title ; - - m_imageList = NULL; - - MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, - kControlTabSmallProc , (long) this ) ; - - MacPostControlCreate() ; - return TRUE ; + Rect bounds ; + Str255 title ; + + m_imageList = NULL; + + MacPreControlCreate( parent , id , "" , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; + + m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + kControlTabSmallProc , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } wxTabCtrl::~wxTabCtrl() diff --git a/src/mac/taskbar.cpp b/src/mac/taskbar.cpp index 7213103b04..df0eb5a9b7 100644 --- a/src/mac/taskbar.cpp +++ b/src/mac/taskbar.cpp @@ -1,13 +1,13 @@ ///////////////////////////////////////////////////////////////////////// // File: taskbar.cpp -// Purpose: Implements wxTaskBarIcon class for manipulating icons on +// Purpose: Implements wxTaskBarIcon class for manipulating icons on // the task bar. Optional. // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index a6eb64f05c..ae6063d20c 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -299,8 +299,8 @@ static pascal ControlPartCode TPPaneTrackingProc(ControlHandle theControl, Point #if !TARGET_CARBON TXNClick( varsp->fTXNRec, (const EventRecord*) wxTheApp->MacGetCurrentEvent()); #else - EventRecord rec ; - ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; + EventRecord rec ; + ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; TXNClick( varsp->fTXNRec, &rec ); #endif } @@ -662,15 +662,15 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_macTE = NULL ; - m_macTXN = NULL ; - m_macTXNvars = NULL ; - m_macUsesTXN = false ; - m_editable = true ; - - m_macUsesTXN = ! (style & wxTE_PASSWORD ) ; - - m_macUsesTXN &= (TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress) ; + m_macTE = NULL ; + m_macTXN = NULL ; + m_macTXNvars = NULL ; + m_macUsesTXN = false ; + m_editable = true ; + + m_macUsesTXN = ! (style & wxTE_PASSWORD ) ; + + m_macUsesTXN &= (TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress) ; // base initialization if ( !CreateBase(parent, id, pos, size, style, validator, name) ) @@ -764,7 +764,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); } - return TRUE; + return TRUE; } wxString wxTextCtrl::GetValue() const @@ -774,21 +774,21 @@ wxString wxTextCtrl::GetValue() const OSStatus err ; if ( !m_macUsesTXN ) { - err = ::GetControlDataSize((ControlHandle) m_macControl, 0, + err = ::GetControlDataSize((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, &actualSize ) ; - if ( err ) - return wxEmptyString ; - - if ( actualSize > 0 ) - { - wxChar *ptr = result.GetWriteBuf(actualSize) ; - - ::GetControlData( (ControlHandle) m_macControl, 0, - ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, - actualSize , ptr , &actualSize ) ; - ptr[actualSize] = 0 ; - result.UngetWriteBuf(actualSize) ; + if ( err ) + return wxEmptyString ; + + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize) ; + + ::GetControlData( (ControlHandle) m_macControl, 0, + ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, + actualSize , ptr , &actualSize ) ; + ptr[actualSize] = 0 ; + result.UngetWriteBuf(actualSize) ; } } @@ -804,14 +804,14 @@ wxString wxTextCtrl::GetValue() const else { actualSize = GetHandleSize( theText ) ; - if ( actualSize > 0 ) - { - wxChar *ptr = result.GetWriteBuf(actualSize) ; - strncpy( ptr , *theText , actualSize ) ; - ptr[actualSize] = 0 ; - result.UngetWriteBuf( actualSize ) ; - } - DisposeHandle( theText ) ; + if ( actualSize > 0 ) + { + wxChar *ptr = result.GetWriteBuf(actualSize) ; + strncpy( ptr , *theText , actualSize ) ; + ptr[actualSize] = 0 ; + result.UngetWriteBuf( actualSize ) ; + } + DisposeHandle( theText ) ; } } @@ -1090,42 +1090,42 @@ void wxTextCtrl::SetInsertionPointEnd() long wxTextCtrl::GetInsertionPoint() const { - long begin,end ; - GetSelection( &begin , &end ) ; - return begin ; + long begin,end ; + GetSelection( &begin , &end ) ; + return begin ; } long wxTextCtrl::GetLastPosition() const { if ( !m_macUsesTXN ) - { - return (**((TEHandle) m_macTE)).teLength ; - } - else - { - Handle theText ; - long actualsize ; - OSErr err = TXNGetDataEncoded( (TXNObject) m_macTXN, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); - /* all done */ - if ( err ) { - actualsize = 0 ; + return (**((TEHandle) m_macTE)).teLength ; } else { - actualsize = GetHandleSize( theText ) ; - DisposeHandle( theText ) ; + Handle theText ; + long actualsize ; + OSErr err = TXNGetDataEncoded( (TXNObject) m_macTXN, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); + /* all done */ + if ( err ) + { + actualsize = 0 ; + } + else + { + actualsize = GetHandleSize( theText ) ; + DisposeHandle( theText ) ; + } + return actualsize ; } - return actualsize ; - } } void wxTextCtrl::Replace(long from, long to, const wxString& value) { - if ( !m_macUsesTXN ) - { + if ( !m_macUsesTXN ) + { ControlEditTextSelectionRec selection ; - + selection.selStart = from ; selection.selEnd = to ; ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; @@ -1141,7 +1141,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ; TXNClear( ((TXNObject) m_macTXN) ) ; TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(), - kTXNUseCurrentSelection, kTXNUseCurrentSelection); + kTXNUseCurrentSelection, kTXNUseCurrentSelection); if ( !formerEditable ) SetEditable( formerEditable ) ; } @@ -1150,52 +1150,52 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) void wxTextCtrl::Remove(long from, long to) { - if ( !m_macUsesTXN ) - { - ControlEditTextSelectionRec selection ; - - selection.selStart = from ; - selection.selEnd = to ; - ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; - TEDelete( ((TEHandle) m_macTE) ) ; - } - else - { - bool formerEditable = IsEditable() ; - if ( !formerEditable ) - SetEditable(true) ; - TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ; - TXNClear( ((TXNObject) m_macTXN) ) ; - if ( !formerEditable ) - SetEditable( formerEditable ) ; - } + if ( !m_macUsesTXN ) + { + ControlEditTextSelectionRec selection ; + + selection.selStart = from ; + selection.selEnd = to ; + ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + TEDelete( ((TEHandle) m_macTE) ) ; + } + else + { + bool formerEditable = IsEditable() ; + if ( !formerEditable ) + SetEditable(true) ; + TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ; + TXNClear( ((TXNObject) m_macTXN) ) ; + if ( !formerEditable ) + SetEditable( formerEditable ) ; + } Refresh() ; } void wxTextCtrl::SetSelection(long from, long to) { - - if ( !m_macUsesTXN ) - { - ControlEditTextSelectionRec selection ; - selection.selStart = from ; - selection.selEnd = to ; - - TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ; - ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; - } - else - { - STPTextPaneVars **tpvars; + + if ( !m_macUsesTXN ) + { + ControlEditTextSelectionRec selection ; + selection.selStart = from ; + selection.selEnd = to ; + + TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ; + ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + } + else + { + STPTextPaneVars **tpvars; /* set up our locals */ - tpvars = (STPTextPaneVars **) GetControlReference((ControlHandle) m_macControl); + tpvars = (STPTextPaneVars **) GetControlReference((ControlHandle) m_macControl); /* and our drawing environment as the operation may force a redraw in the text area. */ - SetPort((**tpvars).fDrawingEnvironment); + SetPort((**tpvars).fDrawingEnvironment); /* change the selection */ - TXNSetSelection( (**tpvars).fTXNRec, from, to); - TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); - } + TXNSetSelection( (**tpvars).fTXNRec, from, to); + TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); + } } bool wxTextCtrl::LoadFile(const wxString& file) @@ -1252,15 +1252,15 @@ void wxTextCtrl::Clear() { return ; } - if ( !m_macUsesTXN ) - { - ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ; - } - else - { + if ( !m_macUsesTXN ) + { + ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ; + } + else + { TXNSetSelection( (TXNObject)m_macTXN , kTXNStartOffset , kTXNEndOffset ) ; TXNClear((TXNObject)m_macTXN); - } + } Refresh() ; } @@ -1349,8 +1349,8 @@ void wxTextCtrl::DiscardEdits() int wxTextCtrl::GetNumberOfLines() const { - // TODO change this if possible to reflect real lines - wxString content = GetValue() ; + // TODO change this if possible to reflect real lines + wxString content = GetValue() ; int count = 1; for (size_t i = 0; i < content.Length() ; i++) @@ -1379,8 +1379,8 @@ void wxTextCtrl::ShowPosition(long pos) int wxTextCtrl::GetLineLength(long lineNo) const { - // TODO change this if possible to reflect real lines - wxString content = GetValue() ; + // TODO change this if possible to reflect real lines + wxString content = GetValue() ; // Find line first int count = 0; @@ -1405,8 +1405,8 @@ int wxTextCtrl::GetLineLength(long lineNo) const wxString wxTextCtrl::GetLineText(long lineNo) const { - // TODO change this if possible to reflect real lines - wxString content = GetValue() ; + // TODO change this if possible to reflect real lines + wxString content = GetValue() ; // Find line first int count = 0; diff --git a/src/mac/thread.cpp b/src/mac/thread.cpp index 474b92a22f..23a7203752 100644 --- a/src/mac/thread.cpp +++ b/src/mac/thread.cpp @@ -902,5 +902,3 @@ bool WXDLLEXPORT wxIsWaitingForThread() #include "wx/thrimpl.cpp" #endif // wxUSE_THREADS - -// vi:sts=4:sw=4:et diff --git a/src/mac/timer.cpp b/src/mac/timer.cpp index 4d96abef87..3d43a7ca27 100644 --- a/src/mac/timer.cpp +++ b/src/mac/timer.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -39,24 +39,24 @@ static void wxProcessTimer( unsigned long event , void *data ) ; static pascal void MacTimerProc( TMTask * t ) { - MacTimerInfo * tm = (MacTimerInfo*) t ; - wxMacAddEvent( tm->m_table , wxProcessTimer, 0 , (void*) tm->m_timer , TRUE ) ; + MacTimerInfo * tm = (MacTimerInfo*) t ; + wxMacAddEvent( tm->m_table , wxProcessTimer, 0 , (void*) tm->m_timer , TRUE ) ; } wxArrayPtrVoid gTimersInProcess ; static void wxProcessTimer( unsigned long event , void *data ) { - if ( !data ) - return ; - - wxTimer* timer = (wxTimer*) data ; - - if ( timer->IsOneShot() ) - timer->Stop() ; - - gTimersInProcess.Add( timer ) ; - + if ( !data ) + return ; + + wxTimer* timer = (wxTimer*) data ; + + if ( timer->IsOneShot() ) + timer->Stop() ; + + gTimersInProcess.Add( timer ) ; + timer->Notify(); int index = gTimersInProcess.Index( timer ) ; @@ -67,7 +67,7 @@ static void wxProcessTimer( unsigned long event , void *data ) if ( !timer->IsOneShot() && timer->m_info->m_task.tmAddr ) { - PrimeTime( (QElemPtr) &timer->m_info->m_task , timer->GetInterval() ) ; + PrimeTime( (QElemPtr) &timer->m_info->m_task , timer->GetInterval() ) ; } } @@ -76,17 +76,17 @@ static void wxProcessTimer( unsigned long event , void *data ) void wxTimer::Init() { m_info = new MacTimerInfo() ; - m_info->m_task.tmAddr = NULL ; - m_info->m_task.tmWakeUp = 0 ; - m_info->m_task.tmReserved = 0 ; - m_info->m_task.qType = 0 ; - m_info->m_table = wxMacGetNotifierTable() ; - m_info->m_timer = this ; + m_info->m_task.tmAddr = NULL ; + m_info->m_task.tmWakeUp = 0 ; + m_info->m_task.tmReserved = 0 ; + m_info->m_task.qType = 0 ; + m_info->m_table = wxMacGetNotifierTable() ; + m_info->m_timer = this ; } bool wxTimer::IsRunning() const { - return ( m_info->m_task.qType & kTMTaskActive ) ; + return ( m_info->m_task.qType & kTMTaskActive ) ; } wxTimer::~wxTimer() @@ -116,8 +116,8 @@ bool wxTimer::Start(int milliseconds,bool mode) #endif m_info->m_task.tmWakeUp = 0 ; m_info->m_task.tmReserved = 0 ; - m_info->m_task.qType = 0 ; - m_info->m_timer = this ; + m_info->m_task.qType = 0 ; + m_info->m_timer = this ; InsXTime((QElemPtr) &m_info->m_task ) ; PrimeTime( (QElemPtr) &m_info->m_task , m_milli ) ; return FALSE; @@ -128,9 +128,9 @@ void wxTimer::Stop() m_milli = 0 ; if ( m_info->m_task.tmAddr ) { - RmvTime( (QElemPtr) &m_info->m_task ) ; - DisposeTimerUPP(m_info->m_task.tmAddr) ; - m_info->m_task.tmAddr = NULL ; + RmvTime( (QElemPtr) &m_info->m_task ) ; + DisposeTimerUPP(m_info->m_task.tmAddr) ; + m_info->m_task.tmAddr = NULL ; } wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ; } diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 8b8d56b70a..33da0a2d4b 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -107,54 +107,53 @@ wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control) void wxToolBar::Init() { - m_maxWidth = -1; - m_maxHeight = -1; - m_defaultWidth = kwxMacToolBarToolDefaultWidth; - m_defaultHeight = kwxMacToolBarToolDefaultHeight; + m_maxWidth = -1; + m_maxHeight = -1; + m_defaultWidth = kwxMacToolBarToolDefaultWidth; + m_defaultHeight = kwxMacToolBarToolDefaultHeight; } bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) -{ - - int x = pos.x; - int y = pos.y; - int width = size.x; - int height = size.y; - - if (width <= 0) - width = 100; - if (height <= 0) - height = 30; - if (x < 0) - x = 0; - if (y < 0) - y = 0; - - SetName(name); - - m_windowStyle = style; - parent->AddChild(this); - - m_backgroundColour = parent->GetBackgroundColour() ; - m_foregroundColour = parent->GetForegroundColour() ; - - if (id == -1) - m_windowId = NewControlId(); - else - m_windowId = id; - - { - m_width = size.x ; - m_height = size.y ; - int x = pos.x ; - int y = pos.y ; - AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING); - m_x = x ; - m_y = y ; - } - - return TRUE; +{ + int x = pos.x; + int y = pos.y; + int width = size.x; + int height = size.y; + + if (width <= 0) + width = 100; + if (height <= 0) + height = 30; + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + SetName(name); + + m_windowStyle = style; + parent->AddChild(this); + + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; + + if (id == -1) + m_windowId = NewControlId(); + else + m_windowId = id; + + { + m_width = size.x ; + m_height = size.y ; + int x = pos.x ; + int y = pos.y ; + AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING); + m_x = x ; + m_y = y ; + } + + return TRUE; } wxToolBar::~wxToolBar() @@ -363,119 +362,119 @@ void wxToolBar::SetRows(int nRows) void wxToolBar::MacSuperChangedPosition() { - if (m_tools.GetCount() > 0) - { - - Point localOrigin ; - // Rect clipRect ; - // WindowRef window ; - // wxWindow *win ; - int lx , ly ; - lx = ly = 0 ; - MacWindowToRootWindow( &lx , &ly ) ; - localOrigin.v = ly ; - localOrigin.h = lx ; - -// GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ; - - Rect toolbarrect = { localOrigin.v ,localOrigin.h , - m_height + localOrigin.v , m_width + localOrigin.h} ; - ControlFontStyleRec controlstyle ; - - controlstyle.flags = kControlUseFontMask ; - controlstyle.font = kControlFontSmallSystemFont ; - - wxToolBarToolsList::Node *node = m_tools.GetFirst(); - int noButtons = 0; - int x = 0 ; - wxSize toolSize = GetToolSize() ; - int tw, th; - GetSize(& tw, & th); - - int maxWidth = 0 ; - int maxHeight = 0 ; - int toolcount = 0 ; + if (m_tools.GetCount() > 0) { - WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; - while (node) + + Point localOrigin ; + // Rect clipRect ; + // WindowRef window ; + // wxWindow *win ; + int lx , ly ; + lx = ly = 0 ; + MacWindowToRootWindow( &lx , &ly ) ; + localOrigin.v = ly ; + localOrigin.h = lx ; + + // GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ; + + Rect toolbarrect = { localOrigin.v ,localOrigin.h , + m_height + localOrigin.v , m_width + localOrigin.h} ; + ControlFontStyleRec controlstyle ; + + controlstyle.flags = kControlUseFontMask ; + controlstyle.font = kControlFontSmallSystemFont ; + + wxToolBarToolsList::Node *node = m_tools.GetFirst(); + int noButtons = 0; + int x = 0 ; + wxSize toolSize = GetToolSize() ; + int tw, th; + GetSize(& tw, & th); + + int maxWidth = 0 ; + int maxHeight = 0 ; + int toolcount = 0 ; { - wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); - - if( !tool->IsSeparator() ) + WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; + while (node) { - Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ; - toolrect.right = toolrect.left + toolSize.x ; - toolrect.bottom = toolrect.top + toolSize.y ; - - ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ; + wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); + if( !tool->IsSeparator() ) { - Rect contrlRect ; - GetControlBounds( m_macToolHandle , &contrlRect ) ; - int former_mac_x = contrlRect.left ; - int former_mac_y = contrlRect.top ; - int mac_x = toolrect.left ; - int mac_y = toolrect.top ; - - if ( mac_x != former_mac_x || mac_y != former_mac_y ) + Rect toolrect = { toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin, toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ; + toolrect.right = toolrect.left + toolSize.x ; + toolrect.bottom = toolrect.top + toolSize.y ; + + ControlHandle m_macToolHandle = (ControlHandle) m_macToolHandles[toolcount++] ; + { + Rect contrlRect ; + GetControlBounds( m_macToolHandle , &contrlRect ) ; + int former_mac_x = contrlRect.left ; + int former_mac_y = contrlRect.top ; + int mac_x = toolrect.left ; + int mac_y = toolrect.top ; + + if ( mac_x != former_mac_x || mac_y != former_mac_y ) { - Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ; - InvalWindowRect( rootwindow , &inval ) ; - } - UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ; - { - Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ; - InvalWindowRect( rootwindow , &inval ) ; + { + Rect inval = { former_mac_y , former_mac_x , former_mac_y + toolSize.y , former_mac_x + toolSize.y } ; + InvalWindowRect( rootwindow , &inval ) ; + } + UMAMoveControl( m_macToolHandle , mac_x , mac_y ) ; + { + Rect inval = { mac_y , mac_x , mac_y + toolSize.y , mac_x + toolSize.y } ; + InvalWindowRect( rootwindow , &inval ) ; + } } } + + x += (int)toolSize.x; + noButtons ++; + } + else + { + toolcount++ ; + x += (int)toolSize.x / 4; } + if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth) + maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h; + if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight) + maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ; - x += (int)toolSize.x; - noButtons ++; + node = node->GetNext(); } - else + } + + if ( GetWindowStyleFlag() & wxTB_HORIZONTAL ) + { + if ( m_maxRows == 0 ) { - toolcount++ ; - x += (int)toolSize.x / 4; + // if not set yet, only one row + SetRows(1); } - if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin- m_x - localOrigin.h > maxWidth) - maxWidth = toolbarrect.left + x + kwxMacToolBarLeftMargin+ m_xMargin - m_x - localOrigin.h; - if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight) - maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ; - - node = node->GetNext(); + maxWidth = tw ; + maxHeight += toolSize.y; + maxHeight += m_yMargin + kwxMacToolBarTopMargin; + m_maxHeight = maxHeight ; } + else + { + if ( noButtons > 0 && m_maxRows == 0 ) + { + // if not set yet, have one column + SetRows(noButtons); + } + maxHeight = th ; + maxWidth += toolSize.x; + maxWidth += m_xMargin + kwxMacToolBarLeftMargin; + m_maxWidth = maxWidth ; + } + + SetSize(maxWidth, maxHeight); } - - if ( GetWindowStyleFlag() & wxTB_HORIZONTAL ) - { - if ( m_maxRows == 0 ) - { - // if not set yet, only one row - SetRows(1); - } - maxWidth = tw ; - maxHeight += toolSize.y; - maxHeight += m_yMargin + kwxMacToolBarTopMargin; - m_maxHeight = maxHeight ; - } - else - { - if ( noButtons > 0 && m_maxRows == 0 ) - { - // if not set yet, have one column - SetRows(noButtons); - } - maxHeight = th ; - maxWidth += toolSize.x; - maxWidth += m_xMargin + kwxMacToolBarLeftMargin; - m_maxWidth = maxWidth ; - } - - SetSize(maxWidth, maxHeight); - } - + wxWindow::MacSuperChangedPosition() ; } @@ -564,9 +563,9 @@ bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *WXUNUSED(t void wxToolBar::OnPaint(wxPaintEvent& event) { - wxPaintDC dc(this) ; - wxMacPortSetter helper(&dc) ; - + wxPaintDC dc(this) ; + wxMacPortSetter helper(&dc) ; + Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) , dc.YLOG2DEVMAC(m_height) , dc.XLOG2DEVMAC(m_width) } ; UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; diff --git a/src/mac/tooltip.cpp b/src/mac/tooltip.cpp index 5d072cb098..4b00c6f750 100644 --- a/src/mac/tooltip.cpp +++ b/src/mac/tooltip.cpp @@ -31,27 +31,27 @@ class wxMacToolTipTimer ; class wxMacToolTip { - public : - wxMacToolTip( ) ; - ~wxMacToolTip() ; - - void Setup( WindowRef window , wxString text , wxPoint localPosition ) ; - long GetMark() { return m_mark ; } - void Draw() ; - void Clear() ; - bool IsShown() { return m_shown ; } - private : - - wxString m_label ; - wxPoint m_position ; - Rect m_rect ; - WindowRef m_window ; - PicHandle m_backpict ; - bool m_shown ; - long m_mark ; - wxMacToolTipTimer* m_timer ; + public : + wxMacToolTip( ) ; + ~wxMacToolTip() ; + + void Setup( WindowRef window , wxString text , wxPoint localPosition ) ; + long GetMark() { return m_mark ; } + void Draw() ; + void Clear() ; + bool IsShown() { return m_shown ; } + private : + + wxString m_label ; + wxPoint m_position ; + Rect m_rect ; + WindowRef m_window ; + PicHandle m_backpict ; + bool m_shown ; + long m_mark ; + wxMacToolTipTimer* m_timer ; #ifdef TARGET_CARBON - CFStringRef m_helpTextRef ; + CFStringRef m_helpTextRef ; #endif } ; @@ -67,8 +67,8 @@ public: m_tip->Draw() ; } protected: - wxMacToolTip* m_tip; - long m_mark ; + wxMacToolTip* m_tip; + long m_mark ; }; //----------------------------------------------------------------------------- @@ -95,16 +95,16 @@ wxToolTip::~wxToolTip() void wxToolTip::SetTip( const wxString &tip ) { - m_text = tip; - + m_text = tip; + if ( m_window ) { - /* - // update it immediately - wxToolInfo ti(GetHwndOf(m_window)); - ti.lpszText = (wxChar *)m_text.c_str(); - - (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti); + /* + // update it immediately + wxToolInfo ti(GetHwndOf(m_window)); + ti.lpszText = (wxChar *)m_text.c_str(); + + (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti); */ } } @@ -116,94 +116,94 @@ void wxToolTip::SetWindow( wxWindow *win ) void wxToolTip::Enable( bool flag ) { - if ( s_ShowToolTips != flag ) - { - s_ShowToolTips = flag ; - if ( s_ShowToolTips ) - { - } - else - { - s_ToolTip.Clear() ; - } - } + if ( s_ShowToolTips != flag ) + { + s_ShowToolTips = flag ; + if ( s_ShowToolTips ) + { + } + else + { + s_ToolTip.Clear() ; + } + } } void wxToolTip::SetDelay( long msecs ) { - s_ToolTipDelay = msecs ; + s_ToolTipDelay = msecs ; } void wxToolTip::RelayEvent( wxWindow *win , wxMouseEvent &event ) { - if ( s_ShowToolTips ) - { - if ( event.GetEventType() == wxEVT_LEAVE_WINDOW ) - { - s_ToolTip.Clear() ; - } - else if (event.GetEventType() == wxEVT_ENTER_WINDOW || event.GetEventType() == wxEVT_MOTION ) - { - wxPoint2DInt where( event.m_x , event.m_y ) ; - if ( s_LastWindowEntered == win && s_ToolTipArea.Contains( where ) ) - { - } - else - { - s_ToolTip.Clear() ; - s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ; - s_LastWindowEntered = win ; - - WindowRef window = MAC_WXHWND( win->MacGetRootWindow() ) ; - int x = event.m_x ; - int y = event.m_y ; - wxPoint local( x , y ) ; - win->MacClientToRootWindow( &x, &y ) ; - wxPoint windowlocal( x , y ) ; - s_ToolTip.Setup( window , win->MacGetToolTipString( local ) , windowlocal ) ; - } - } - } + if ( s_ShowToolTips ) + { + if ( event.GetEventType() == wxEVT_LEAVE_WINDOW ) + { + s_ToolTip.Clear() ; + } + else if (event.GetEventType() == wxEVT_ENTER_WINDOW || event.GetEventType() == wxEVT_MOTION ) + { + wxPoint2DInt where( event.m_x , event.m_y ) ; + if ( s_LastWindowEntered == win && s_ToolTipArea.Contains( where ) ) + { + } + else + { + s_ToolTip.Clear() ; + s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ; + s_LastWindowEntered = win ; + + WindowRef window = MAC_WXHWND( win->MacGetRootWindow() ) ; + int x = event.m_x ; + int y = event.m_y ; + wxPoint local( x , y ) ; + win->MacClientToRootWindow( &x, &y ) ; + wxPoint windowlocal( x , y ) ; + s_ToolTip.Setup( window , win->MacGetToolTipString( local ) , windowlocal ) ; + } + } + } } void wxToolTip::RemoveToolTips() { - s_ToolTip.Clear() ; + s_ToolTip.Clear() ; } // --- mac specific wxMacToolTipTimer::wxMacToolTipTimer( wxMacToolTip *tip , int msec ) { - m_tip = tip; - m_mark = tip->GetMark() ; - Start(msec, true); + m_tip = tip; + m_mark = tip->GetMark() ; + Start(msec, true); } wxMacToolTip::wxMacToolTip() { - m_window = NULL ; - m_backpict = NULL ; - m_mark = 0 ; - m_shown = false ; + m_window = NULL ; + m_backpict = NULL ; + m_mark = 0 ; + m_shown = false ; m_timer = NULL ; m_helpTextRef = NULL ; } void wxMacToolTip::Setup( WindowRef win , wxString text , wxPoint localPosition ) { - m_mark++ ; - Clear() ; - m_position = localPosition ; + m_mark++ ; + Clear() ; + m_position = localPosition ; if( wxApp::s_macDefaultEncodingIsPC ) m_label = wxMacMakeMacStringFromPC( text ) ; - else + else m_label = text ; m_window =win; - s_ToolTipWindowRef = m_window ; - m_backpict = NULL ; - if ( m_timer ) - delete m_timer ; - m_timer = new wxMacToolTipTimer( this , s_ToolTipDelay ) ; + s_ToolTipWindowRef = m_window ; + m_backpict = NULL ; + if ( m_timer ) + delete m_timer ; + m_timer = new wxMacToolTipTimer( this , s_ToolTipDelay ) ; } wxMacToolTip::~wxMacToolTip() @@ -221,257 +221,257 @@ const short kTipOffset = 5 ; void wxMacToolTip::Draw() { - if ( m_label.Length() == 0 ) - return ; - - if ( m_window == s_ToolTipWindowRef ) - { - m_shown = true ; + if ( m_label.Length() == 0 ) + return ; + + if ( m_window == s_ToolTipWindowRef ) + { + m_shown = true ; #if TARGET_CARBON - if ( HMDisplayTag != (void*) kUnresolvedCFragSymbolAddress ) - { - HMHelpContentRec tag ; - tag.version = kMacHelpVersion; - SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; - GrafPtr port ; - GetPort( &port ) ; - SetPortWindowPort(m_window) ; - LocalToGlobal( (Point *) &tag.absHotRect.top ); - LocalToGlobal( (Point *) &tag.absHotRect.bottom ); - SetPort( port ); - if( m_helpTextRef ) - { - CFRelease( m_helpTextRef ) ; - m_helpTextRef = NULL ; - } - m_helpTextRef = wxMacCreateCFString(m_label) ; - tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; - tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; - tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; - tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; - tag.tagSide = kHMDefaultSide; - HMDisplayTag( &tag ); - } - else + if ( HMDisplayTag != (void*) kUnresolvedCFragSymbolAddress ) + { + HMHelpContentRec tag ; + tag.version = kMacHelpVersion; + SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; + GrafPtr port ; + GetPort( &port ) ; + SetPortWindowPort(m_window) ; + LocalToGlobal( (Point *) &tag.absHotRect.top ); + LocalToGlobal( (Point *) &tag.absHotRect.bottom ); + SetPort( port ); + if( m_helpTextRef ) + { + CFRelease( m_helpTextRef ) ; + m_helpTextRef = NULL ; + } + m_helpTextRef = wxMacCreateCFString(m_label) ; + tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; + tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; + tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; + tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; + tag.tagSide = kHMDefaultSide; + HMDisplayTag( &tag ); + } + else #endif - { - wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); -#if TARGET_CARBON - bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; -#endif - - FontFamilyID fontId ; - Str255 fontName ; - SInt16 fontSize ; - Style fontStyle ; - GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; - GetFNum( fontName, &fontId ); - - TextFont( fontId ) ; - TextSize( fontSize ) ; - TextFace( fontStyle ) ; - FontInfo fontInfo; - ::GetFontInfo(&fontInfo); - short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; - short height = 0 ; - // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; - - int i = 0 ; - int length = m_label.Length() ; - int width = 0 ; - int thiswidth = 0 ; - int laststop = 0 ; - const char *text = m_label ; - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { - thiswidth = ::TextWidth( text , laststop , i - laststop ) ; - if ( thiswidth > width ) - width = thiswidth ; - - height += lineh ; - laststop = i+1 ; - } - i++ ; - } - if ( i - laststop > 0 ) - { - thiswidth = ::TextWidth( text , laststop , i - laststop ) ; - if ( thiswidth > width ) - width = thiswidth ; - height += lineh ; - } - - - m_rect.left = m_position.x + kTipOffset; - m_rect.top = m_position.y + kTipOffset; - m_rect.right = m_rect.left + width + 2 * kTipBorder; -#if TARGET_CARBON - if ( useDrawThemeText ) - m_rect.right += kTipBorder ; + { + wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); +#if TARGET_CARBON + bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; +#endif + + FontFamilyID fontId ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + GetFNum( fontName, &fontId ); + + TextFont( fontId ) ; + TextSize( fontSize ) ; + TextFace( fontStyle ) ; + FontInfo fontInfo; + ::GetFontInfo(&fontInfo); + short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; + short height = 0 ; + // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; + + int i = 0 ; + int length = m_label.Length() ; + int width = 0 ; + int thiswidth = 0 ; + int laststop = 0 ; + const char *text = m_label ; + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { + thiswidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( thiswidth > width ) + width = thiswidth ; + + height += lineh ; + laststop = i+1 ; + } + i++ ; + } + if ( i - laststop > 0 ) + { + thiswidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( thiswidth > width ) + width = thiswidth ; + height += lineh ; + } + + + m_rect.left = m_position.x + kTipOffset; + m_rect.top = m_position.y + kTipOffset; + m_rect.right = m_rect.left + width + 2 * kTipBorder; +#if TARGET_CARBON + if ( useDrawThemeText ) + m_rect.right += kTipBorder ; #endif - m_rect.bottom = m_rect.top + height + 2 * kTipBorder; - Rect r ; - GetPortBounds( GetWindowPort( m_window ) , &r ) ; - if ( m_rect.top < 0 ) - { - m_rect.bottom += -m_rect.top ; - m_rect.top = 0 ; - } - if ( m_rect.left < 0 ) - { - m_rect.right += -m_rect.left ; - m_rect.left = 0 ; - } - if ( m_rect.right > r.right ) - { - m_rect.left -= (m_rect.right - r.right ) ; - m_rect.right = r.right ; - } - if ( m_rect.bottom > r.bottom ) - { - m_rect.top -= (m_rect.bottom - r.bottom) ; - m_rect.bottom = r.bottom ; - } - ClipRect( &m_rect ) ; - BackColor( whiteColor ) ; - ForeColor(blackColor ) ; - GWorldPtr port ; - NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; - CGrafPtr origPort ; - GDHandle origDevice ; - - GetGWorld( &origPort , &origDevice ) ; - SetGWorld( port , NULL ) ; - - m_backpict = OpenPicture(&m_rect); - - CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), - GetPortBitMapForCopyBits(port), - &m_rect, - &m_rect, - srcCopy, - NULL); - ClosePicture(); - SetGWorld( origPort , origDevice ) ; - DisposeGWorld( port ) ; - PenNormal() ; - - RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; - BackColor( whiteColor ) ; - RGBForeColor( &tooltipbackground ) ; - - PaintRect( &m_rect ) ; - ForeColor(blackColor ) ; - FrameRect( &m_rect ) ; - SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; - ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); - - i = 0 ; - laststop = 0 ; - height = 0 ; - - while( i < length ) - { - if( text[i] == 13 || text[i] == 10) - { + m_rect.bottom = m_rect.top + height + 2 * kTipBorder; + Rect r ; + GetPortBounds( GetWindowPort( m_window ) , &r ) ; + if ( m_rect.top < 0 ) + { + m_rect.bottom += -m_rect.top ; + m_rect.top = 0 ; + } + if ( m_rect.left < 0 ) + { + m_rect.right += -m_rect.left ; + m_rect.left = 0 ; + } + if ( m_rect.right > r.right ) + { + m_rect.left -= (m_rect.right - r.right ) ; + m_rect.right = r.right ; + } + if ( m_rect.bottom > r.bottom ) + { + m_rect.top -= (m_rect.bottom - r.bottom) ; + m_rect.bottom = r.bottom ; + } + ClipRect( &m_rect ) ; + BackColor( whiteColor ) ; + ForeColor(blackColor ) ; + GWorldPtr port ; + NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; + CGrafPtr origPort ; + GDHandle origDevice ; + + GetGWorld( &origPort , &origDevice ) ; + SetGWorld( port , NULL ) ; + + m_backpict = OpenPicture(&m_rect); + + CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), + GetPortBitMapForCopyBits(port), + &m_rect, + &m_rect, + srcCopy, + NULL); + ClosePicture(); + SetGWorld( origPort , origDevice ) ; + DisposeGWorld( port ) ; + PenNormal() ; + + RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; + BackColor( whiteColor ) ; + RGBForeColor( &tooltipbackground ) ; + + PaintRect( &m_rect ) ; + ForeColor(blackColor ) ; + FrameRect( &m_rect ) ; + SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; + ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); + + i = 0 ; + laststop = 0 ; + height = 0 ; + + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { #if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame ; - frame.top = m_rect.top + kTipBorder + height ; - frame.left = m_rect.left + kTipBorder ; - frame.bottom = frame.top + 1000 ; - frame.right = frame.left + 1000 ; - CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - true, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - height += lineh ; - } - else + if ( useDrawThemeText ) + { + Rect frame ; + frame.top = m_rect.top + kTipBorder + height ; + frame.left = m_rect.left + kTipBorder ; + frame.bottom = frame.top + 1000 ; + frame.right = frame.left + 1000 ; + CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + true, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + height += lineh ; + } + else #endif - { - ::DrawText( text , laststop , i - laststop ) ; - height += lineh ; - ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); - } - laststop = i+1 ; - } - i++ ; - } + { + ::DrawText( text , laststop , i - laststop ) ; + height += lineh ; + ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); + } + laststop = i+1 ; + } + i++ ; + } #if TARGET_CARBON - if ( useDrawThemeText ) - { - Rect frame ; - frame.top = m_rect.top + kTipBorder + height ; - frame.left = m_rect.left + kTipBorder ; - frame.bottom = frame.top + 1000 ; - frame.right = frame.left + 1000 ; - CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; - ::DrawThemeTextBox( mString, - kThemeCurrentPortFont, - kThemeStateActive, - true, - &frame, - teJustLeft, - nil ); - CFRelease( mString ) ; - } - else + if ( useDrawThemeText ) + { + Rect frame ; + frame.top = m_rect.top + kTipBorder + height ; + frame.left = m_rect.left + kTipBorder ; + frame.bottom = frame.top + 1000 ; + frame.right = frame.left + 1000 ; + CFStringRef mString = CFStringCreateWithCString( NULL , text + laststop , kCFStringEncodingMacRoman ) ; + ::DrawThemeTextBox( mString, + kThemeCurrentPortFont, + kThemeStateActive, + true, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + } + else #endif - { - ::DrawText( text , laststop , i - laststop ) ; - } - ::TextMode( srcOr ) ; - } - } + { + ::DrawText( text , laststop , i - laststop ) ; + } + ::TextMode( srcOr ) ; + } + } } void wxToolTip::NotifyWindowDelete( WXHWND win ) { - if ( win == s_ToolTipWindowRef ) - { - s_ToolTipWindowRef = NULL ; - } + if ( win == s_ToolTipWindowRef ) + { + s_ToolTipWindowRef = NULL ; + } } void wxMacToolTip::Clear() { - m_mark++ ; - if ( m_timer ) - { - delete m_timer ; - m_timer = NULL ; - } - if ( !m_shown ) - return ; + m_mark++ ; + if ( m_timer ) + { + delete m_timer ; + m_timer = NULL ; + } + if ( !m_shown ) + return ; #if TARGET_CARBON - HMHideTag() ; - if( m_helpTextRef ) - { - CFRelease( m_helpTextRef ) ; - m_helpTextRef = NULL ; - } -#else - if ( m_window == s_ToolTipWindowRef && m_backpict ) - { - wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ; + HMHideTag() ; + if( m_helpTextRef ) + { + CFRelease( m_helpTextRef ) ; + m_helpTextRef = NULL ; + } +#else + if ( m_window == s_ToolTipWindowRef && m_backpict ) + { + wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ; - m_shown = false ; + m_shown = false ; - BackColor( whiteColor ) ; - ForeColor(blackColor ) ; - DrawPicture(m_backpict, &m_rect); - KillPicture(m_backpict); - m_backpict = NULL ; - } + BackColor( whiteColor ) ; + ForeColor(blackColor ) ; + DrawPicture(m_backpict, &m_rect); + KillPicture(m_backpict); + m_backpict = NULL ; + } #endif } diff --git a/src/mac/toplevel.cpp b/src/mac/toplevel.cpp index d053a98ab1..76051b7079 100644 --- a/src/mac/toplevel.cpp +++ b/src/mac/toplevel.cpp @@ -75,7 +75,7 @@ static const EventTypeSpec eventList[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } , - { kEventClassKeyboard, kEventRawKeyDown } , + { kEventClassKeyboard, kEventRawKeyDown } , { kEventClassKeyboard, kEventRawKeyRepeat } , { kEventClassKeyboard, kEventRawKeyUp } , { kEventClassKeyboard, kEventRawKeyModifiersChanged } , @@ -99,34 +99,34 @@ static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , Even OSStatus result = eventNotHandledErr ; wxWindow* focus = wxWindow::FindFocus() ; - char charCode ; - UInt32 keyCode ; + char charCode ; + UInt32 keyCode ; UInt32 modifiers ; - Point point ; - UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; + Point point ; + UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; EventRef rawEvent ; GetEventParameter( event , kEventParamTextInputSendKeyboardEvent ,typeEventRef,NULL,sizeof(rawEvent),NULL,&rawEvent ) ; - GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); - GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); - GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); - GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof( Point ), NULL, &point ); - - UInt32 message = (keyCode << 8) + charCode; - - switch ( GetEventKind( event ) ) - { - case kEventTextInputUnicodeForKeyEvent : - if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent( - focus , message , modifiers , when , point.h , point.v ) ) - { - result = noErr ; - } - break ; - } + GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); + GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); + GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL, + sizeof( Point ), NULL, &point ); + + UInt32 message = (keyCode << 8) + charCode; + + switch ( GetEventKind( event ) ) + { + case kEventTextInputUnicodeForKeyEvent : + if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent( + focus , message , modifiers , when , point.h , point.v ) ) + { + result = noErr ; + } + break ; + } return result ; } @@ -136,73 +136,73 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event OSStatus result = eventNotHandledErr ; wxWindow* focus = wxWindow::FindFocus() ; - char charCode ; - UInt32 keyCode ; + char charCode ; + UInt32 keyCode ; UInt32 modifiers ; - Point point ; - UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; - - GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); - GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); - GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); - GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof( Point ), NULL, &point ); - - UInt32 message = (keyCode << 8) + charCode; - switch( GetEventKind( event ) ) - { - case kEventRawKeyRepeat : - case kEventRawKeyDown : - if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent( - focus , message , modifiers , when , point.h , point.v ) ) - { - result = noErr ; - } - break ; - case kEventRawKeyUp : - if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent( - focus , message , modifiers , when , point.h , point.v ) ) - { - result = noErr ; - } - break ; - case kEventRawKeyModifiersChanged : - { - wxKeyEvent event(wxEVT_KEY_DOWN); - - event.m_shiftDown = modifiers & shiftKey; - event.m_controlDown = modifiers & controlKey; - event.m_altDown = modifiers & optionKey; - event.m_metaDown = modifiers & cmdKey; - - event.m_x = point.h; - event.m_y = point.v; - event.m_timeStamp = when; - wxWindow* focus = wxWindow::FindFocus() ; - event.SetEventObject(focus); - - if ( (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey ) - { - event.m_keyCode = WXK_CONTROL ; - event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; - focus->GetEventHandler()->ProcessEvent( event ) ; - } - if ( (modifiers ^ wxTheApp->s_lastModifiers ) & shiftKey ) - { - event.m_keyCode = WXK_SHIFT ; - event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; - focus->GetEventHandler()->ProcessEvent( event ) ; - } - if ( (modifiers ^ wxTheApp->s_lastModifiers ) & optionKey ) - { - event.m_keyCode = WXK_ALT ; - event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; - focus->GetEventHandler()->ProcessEvent( event ) ; - } - wxTheApp->s_lastModifiers = modifiers ; - } - break ; - } + Point point ; + UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; + + GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); + GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); + GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, + sizeof( Point ), NULL, &point ); + + UInt32 message = (keyCode << 8) + charCode; + switch( GetEventKind( event ) ) + { + case kEventRawKeyRepeat : + case kEventRawKeyDown : + if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent( + focus , message , modifiers , when , point.h , point.v ) ) + { + result = noErr ; + } + break ; + case kEventRawKeyUp : + if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent( + focus , message , modifiers , when , point.h , point.v ) ) + { + result = noErr ; + } + break ; + case kEventRawKeyModifiersChanged : + { + wxKeyEvent event(wxEVT_KEY_DOWN); + + event.m_shiftDown = modifiers & shiftKey; + event.m_controlDown = modifiers & controlKey; + event.m_altDown = modifiers & optionKey; + event.m_metaDown = modifiers & cmdKey; + + event.m_x = point.h; + event.m_y = point.v; + event.m_timeStamp = when; + wxWindow* focus = wxWindow::FindFocus() ; + event.SetEventObject(focus); + + if ( (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey ) + { + event.m_keyCode = WXK_CONTROL ; + event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; + focus->GetEventHandler()->ProcessEvent( event ) ; + } + if ( (modifiers ^ wxTheApp->s_lastModifiers ) & shiftKey ) + { + event.m_keyCode = WXK_SHIFT ; + event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; + focus->GetEventHandler()->ProcessEvent( event ) ; + } + if ( (modifiers ^ wxTheApp->s_lastModifiers ) & optionKey ) + { + event.m_keyCode = WXK_ALT ; + event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; + focus->GetEventHandler()->ProcessEvent( event ) ; + } + wxTheApp->s_lastModifiers = modifiers ; + } + break ; + } return result ; } @@ -211,54 +211,54 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef { OSStatus result = eventNotHandledErr ; - wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; - Point point ; - UInt32 modifiers = 0; - EventMouseButton button = 0 ; - UInt32 click = 0 ; - - GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof( Point ), NULL, &point ); - GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, - sizeof( UInt32 ), NULL, &modifiers ); - GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL, - sizeof( EventMouseButton ), NULL, &button ); - GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL, - sizeof( UInt32 ), NULL, &click ); - - if ( button == 0 || GetEventKind( event ) == kEventMouseUp ) - modifiers += btnState ; - - WindowRef window ; + wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; + Point point ; + UInt32 modifiers = 0; + EventMouseButton button = 0 ; + UInt32 click = 0 ; + + GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, + sizeof( Point ), NULL, &point ); + GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, + sizeof( UInt32 ), NULL, &modifiers ); + GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL, + sizeof( EventMouseButton ), NULL, &button ); + GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL, + sizeof( UInt32 ), NULL, &click ); + + if ( button == 0 || GetEventKind( event ) == kEventMouseUp ) + modifiers += btnState ; + + WindowRef window ; short windowPart = ::FindWindow(point, &window); - if ( IsWindowActive(window) && windowPart == inContent ) + if ( IsWindowActive(window) && windowPart == inContent ) { - switch ( GetEventKind( event ) ) - { - case kEventMouseDown : - toplevelWindow->MacFireMouseEvent( mouseDown , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - case kEventMouseUp : - toplevelWindow->MacFireMouseEvent( mouseUp , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - case kEventMouseMoved : - toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - case kEventMouseDragged : - toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - default : - break ; - } - } - - return result ; - + switch ( GetEventKind( event ) ) + { + case kEventMouseDown : + toplevelWindow->MacFireMouseEvent( mouseDown , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + case kEventMouseUp : + toplevelWindow->MacFireMouseEvent( mouseUp , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + case kEventMouseMoved : + toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + case kEventMouseDragged : + toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + default : + break ; + } + } + + return result ; + } static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) @@ -266,53 +266,53 @@ static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRe OSStatus result = eventNotHandledErr ; OSStatus err = noErr ; - UInt32 attributes; - WindowRef windowRef ; - wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; - - GetEventParameter( event, kEventParamDirectObject, typeWindowRef, NULL, - sizeof( WindowRef ), NULL, &windowRef ); - - switch( GetEventKind( event ) ) - { - case kEventWindowUpdate : - if ( !wxPendingDelete.Member(toplevelWindow) ) - toplevelWindow->MacUpdate( EventTimeToTicks( GetEventTime( event ) ) ) ; - result = noErr ; - break ; - case kEventWindowActivated : - toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , true) ; - result = noErr ; - break ; - case kEventWindowDeactivated : - toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , false) ; - result = noErr ; - break ; - case kEventWindowClose : - toplevelWindow->Close() ; - result = noErr ; - break ; - case kEventWindowBoundsChanged : - err = GetEventParameter( event, kEventParamAttributes, typeUInt32, - NULL, sizeof( UInt32 ), NULL, &attributes ); - if ( err == noErr ) - { - Rect newContentRect ; - - GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL, - sizeof( newContentRect ), NULL, &newContentRect ); - + UInt32 attributes; + WindowRef windowRef ; + wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; + + GetEventParameter( event, kEventParamDirectObject, typeWindowRef, NULL, + sizeof( WindowRef ), NULL, &windowRef ); + + switch( GetEventKind( event ) ) + { + case kEventWindowUpdate : + if ( !wxPendingDelete.Member(toplevelWindow) ) + toplevelWindow->MacUpdate( EventTimeToTicks( GetEventTime( event ) ) ) ; + result = noErr ; + break ; + case kEventWindowActivated : + toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , true) ; + result = noErr ; + break ; + case kEventWindowDeactivated : + toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , false) ; + result = noErr ; + break ; + case kEventWindowClose : + toplevelWindow->Close() ; + result = noErr ; + break ; + case kEventWindowBoundsChanged : + err = GetEventParameter( event, kEventParamAttributes, typeUInt32, + NULL, sizeof( UInt32 ), NULL, &attributes ); + if ( err == noErr ) + { + Rect newContentRect ; + + GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL, + sizeof( newContentRect ), NULL, &newContentRect ); + toplevelWindow->SetSize( newContentRect.left , newContentRect.top , newContentRect.right - newContentRect.left , newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING); - result = noErr; - } - break ; - default : - break ; - } - return result ; + result = noErr; + } + break ; + default : + break ; + } + return result ; } pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) @@ -322,17 +322,17 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef switch ( GetEventClass( event ) ) { case kEventClassKeyboard : - result = KeyboardEventHandler( handler, event , data ) ; + result = KeyboardEventHandler( handler, event , data ) ; break ; case kEventClassTextInput : - result = TextInputEventHandler( handler, event , data ) ; + result = TextInputEventHandler( handler, event , data ) ; break ; case kEventClassWindow : - result = WindowEventHandler( handler, event , data ) ; - break ; + result = WindowEventHandler( handler, event , data ) ; + break ; case kEventClassMouse : - result = MouseEventHandler( handler, event , data ) ; - break ; + result = MouseEventHandler( handler, event , data ) ; + break ; default : break ; } @@ -503,32 +503,32 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, long style, const wxString& name ) { - SetName(name); - m_windowStyle = style; - m_isShown = FALSE; - - // create frame. - + SetName(name); + m_windowStyle = style; + m_isShown = FALSE; + + // create frame. + Rect theBoundsRect; - - m_x = (int)pos.x; - m_y = (int)pos.y; - if ( m_y < 50 ) - m_y = 50 ; - if ( m_x < 20 ) - m_x = 20 ; - m_width = size.x; + m_x = (int)pos.x; + m_y = (int)pos.y; + if ( m_y < 50 ) + m_y = 50 ; + if ( m_x < 20 ) + m_x = 20 ; + + m_width = size.x; if (m_width == -1) m_width = 20; - m_height = size.y; + m_height = size.y; if (m_height == -1) m_height = 20; - + ::SetRect(&theBoundsRect, m_x, m_y , m_x + m_width, m_y + m_height); - + // translate the window attributes in the appropriate window class and attributes - + WindowClass wclass = 0; WindowAttributes attr = kWindowNoAttributes ; @@ -538,7 +538,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) || HasFlag( wxSYSTEM_MENU ) || HasFlag( wxCAPTION ) || HasFlag(wxTINY_CAPTION_HORIZ) || HasFlag(wxTINY_CAPTION_VERT) - ) + ) { wclass = kFloatingWindowClass ; if ( HasFlag(wxTINY_CAPTION_VERT) ) @@ -557,12 +557,12 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, } else if ( HasFlag( wxCAPTION ) ) { - wclass = kDocumentWindowClass ; + wclass = kDocumentWindowClass ; } else { if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) || - HasFlag( wxSYSTEM_MENU ) ) + HasFlag( wxSYSTEM_MENU ) ) { wclass = kDocumentWindowClass ; } @@ -600,9 +600,9 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, UMASetWTitleC( (WindowRef)m_macWindow , label ) ; ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ; #if TARGET_CARBON - InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; - InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(), - GetEventTypeCount(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler)); + InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; + InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(), + GetEventTypeCount(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler)); #endif m_macFocus = NULL ; } @@ -621,7 +621,7 @@ void wxTopLevelWindowMac::MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR cli void wxTopLevelWindowMac::Clear() { - wxWindow::Clear() ; + wxWindow::Clear() ; } WXWidget wxTopLevelWindowMac::MacGetContainerForEmbedding() @@ -632,7 +632,6 @@ WXWidget wxTopLevelWindowMac::MacGetContainerForEmbedding() void wxTopLevelWindowMac::MacUpdate( long timestamp) { - wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ; BeginUpdate( (WindowRef)m_macWindow ) ; @@ -671,7 +670,7 @@ void wxTopLevelWindowMac::Lower() } void wxTopLevelWindowMac::MacFireMouseEvent( - wxUint16 kind , wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp ) + wxUint16 kind , wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp ) { wxMouseEvent event(wxEVT_LEFT_DOWN); bool isDown = !(modifiers & btnState) ; // 1 is for up @@ -770,12 +769,13 @@ void wxTopLevelWindowMac::MacFireMouseEvent( MacDispatchMouseEvent( event ) ; } } + #if !TARGET_CARBON void wxTopLevelWindowMac::MacMouseDown( WXEVENTREF ev , short part) { MacFireMouseEvent( mouseDown , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , - ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; + ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; } void wxTopLevelWindowMac::MacMouseUp( WXEVENTREF ev , short part) @@ -784,8 +784,8 @@ void wxTopLevelWindowMac::MacMouseUp( WXEVENTREF ev , short part) { case inContent: { - MacFireMouseEvent( mouseUp , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , - ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; + MacFireMouseEvent( mouseUp , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , + ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; } break ; } @@ -797,8 +797,8 @@ void wxTopLevelWindowMac::MacMouseMoved( WXEVENTREF ev , short part) { case inContent: { - MacFireMouseEvent( nullEvent /*moved*/ , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , - ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; + MacFireMouseEvent( nullEvent /*moved*/ , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v , + ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ; } break ; } @@ -886,11 +886,11 @@ void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) int former_w = m_width ; int former_h = m_height ; - int actualWidth = width; - int actualHeight = height; - int actualX = x; - int actualY = y; - + int actualWidth = width; + int actualHeight = height; + int actualX = x; + int actualY = y; + if ((m_minWidth != -1) && (actualWidth < m_minWidth)) actualWidth = m_minWidth; if ((m_minHeight != -1) && (actualHeight < m_minHeight)) @@ -977,51 +977,51 @@ void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackground ) { - GrafPtr formerPort ; - GetPort( &formerPort ) ; - SetPortWindowPort( (WindowRef)m_macWindow ) ; - - m_macNeedsErasing |= eraseBackground ; - - // if we already know that we will have to erase, there's no need to track the rest - if ( !m_macNeedsErasing) - { - // we end only here if eraseBackground is false - // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn - // we will have to erase anyway - - RgnHandle updateRgn = NewRgn(); - RgnHandle diffRgn = NewRgn() ; - if ( updateRgn && diffRgn ) + GrafPtr formerPort ; + GetPort( &formerPort ) ; + SetPortWindowPort( (WindowRef)m_macWindow ) ; + + m_macNeedsErasing |= eraseBackground ; + + // if we already know that we will have to erase, there's no need to track the rest + if ( !m_macNeedsErasing) { - GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn ); - Point pt = {0,0} ; - LocalToGlobal( &pt ) ; - OffsetRgn( updateRgn , -pt.h , -pt.v ) ; - DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ; - if ( !EmptyRgn( diffRgn ) ) + // we end only here if eraseBackground is false + // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn + // we will have to erase anyway + + RgnHandle updateRgn = NewRgn(); + RgnHandle diffRgn = NewRgn() ; + if ( updateRgn && diffRgn ) + { + GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn ); + Point pt = {0,0} ; + LocalToGlobal( &pt ) ; + OffsetRgn( updateRgn , -pt.h , -pt.v ) ; + DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ; + if ( !EmptyRgn( diffRgn ) ) + { + m_macNeedsErasing = true ; + } + } + if ( updateRgn ) + DisposeRgn( updateRgn ); + if ( diffRgn ) + DisposeRgn( diffRgn ); + + if ( !m_macNeedsErasing ) { - m_macNeedsErasing = true ; + RgnHandle rectRgn = NewRgn() ; + SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ; + UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ; + DisposeRgn( rectRgn ) ; } } - if ( updateRgn ) - DisposeRgn( updateRgn ); - if ( diffRgn ) - DisposeRgn( diffRgn ); - - if ( !m_macNeedsErasing ) - { - RgnHandle rectRgn = NewRgn() ; - SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ; - UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ; - DisposeRgn( rectRgn ) ; - } - } - InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ; - // turn this on to debug the refreshing cycle + InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ; + // turn this on to debug the refreshing cycle #if wxMAC_DEBUG_REDRAW - PaintRect( rect ) ; + PaintRect( rect ) ; #endif - SetPort( formerPort ) ; + SetPort( formerPort ) ; } diff --git a/src/mac/treectrl.cpp b/src/mac/treectrl.cpp index 2677a1efde..7a548a7436 100644 --- a/src/mac/treectrl.cpp +++ b/src/mac/treectrl.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -81,15 +81,15 @@ void wxTreeCtrl::SetIndent(int indent) wxImageList *wxTreeCtrl::GetImageList(int which) const { - if ( which == wxIMAGE_LIST_NORMAL ) + if ( which == wxIMAGE_LIST_NORMAL ) { - return m_imageListNormal; - } - else if ( which == wxIMAGE_LIST_STATE ) + return m_imageListNormal; + } + else if ( which == wxIMAGE_LIST_STATE ) { - return m_imageListState; - } - return NULL; + return m_imageListState; + } + return NULL; } void wxTreeCtrl::SetImageList(wxImageList *imageList, int which) @@ -274,50 +274,50 @@ bool wxTreeCtrl::DeleteItem(long item) bool wxTreeCtrl::ExpandItem(long item, int action) { // TODO - switch ( action ) - { + switch ( action ) + { case wxTREE_EXPAND_EXPAND: - break; - + break; + case wxTREE_EXPAND_COLLAPSE: - break; - + break; + case wxTREE_EXPAND_COLLAPSE_RESET: - break; - + break; + case wxTREE_EXPAND_TOGGLE: - break; - + break; + default: - wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem"); - } - - bool bOk = FALSE; // TODO expand item - - // May not send messages, so emulate them - if ( bOk ) { - wxTreeEvent event(wxEVT_NULL, m_windowId); - event.m_item.m_itemId = item; - event.m_item.m_mask = - event.m_item.m_stateMask = 0xffff; // get all - GetItem(event.m_item); - - bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0; - - event.m_code = action; - event.SetEventObject(this); - - // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded - event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDING - : wxEVT_COMMAND_TREE_ITEM_COLLAPSING); - GetEventHandler()->ProcessEvent(event); - - event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDED - : wxEVT_COMMAND_TREE_ITEM_COLLAPSED); - GetEventHandler()->ProcessEvent(event); - } - - return bOk; + wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem"); + } + + bool bOk = FALSE; // TODO expand item + + // May not send messages, so emulate them + if ( bOk ) { + wxTreeEvent event(wxEVT_NULL, m_windowId); + event.m_item.m_itemId = item; + event.m_item.m_mask = + event.m_item.m_stateMask = 0xffff; // get all + GetItem(event.m_item); + + bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0; + + event.m_code = action; + event.SetEventObject(this); + + // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded + event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDING + : wxEVT_COMMAND_TREE_ITEM_COLLAPSING); + GetEventHandler()->ProcessEvent(event); + + event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDED + : wxEVT_COMMAND_TREE_ITEM_COLLAPSED); + GetEventHandler()->ProcessEvent(event); + } + + return bOk; } long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) diff --git a/src/mac/uma.cpp b/src/mac/uma.cpp index 43e9cf7e44..59daa769db 100644 --- a/src/mac/uma.cpp +++ b/src/mac/uma.cpp @@ -25,7 +25,7 @@ // windows manager, control manager, navigation services etc. are // present -static bool sUMAHasAppearance = false ; +static bool sUMAHasAppearance = false ; static long sUMAAppearanceVersion = 0 ; static long sUMASystemVersion = 0 ; static bool sUMAHasAquaLayout = false ; @@ -36,7 +36,7 @@ bool UMAHasAppearance() { return sUMAHasAppearance ; } long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; } long UMAGetSystemVersion() { return sUMASystemVersion ; } -static bool sUMAHasWindowManager = false ; +static bool sUMAHasWindowManager = false ; static long sUMAWindowManagerAttr = 0 ; bool UMAHasWindowManager() { return sUMAHasWindowManager ; } @@ -46,72 +46,72 @@ bool UMASystemIsInitialized() { return sUMASystemInitialized ; } void UMACleanupToolbox() { - if ( sUMAHasAppearance ) - { - UnregisterAppearanceClient() ; - } - if ( NavServicesAvailable() ) - { - NavUnload() ; - } + if ( sUMAHasAppearance ) + { + UnregisterAppearanceClient() ; + } + if ( NavServicesAvailable() ) + { + NavUnload() ; + } if ( TXNTerminateTextension != (void*) kUnresolvedCFragSymbolAddress ) - TXNTerminateTextension( ) ; + TXNTerminateTextension( ) ; } void UMAInitToolbox( UInt16 inMoreMastersCalls ) { #if !TARGET_CARBON - ::MaxApplZone(); - for (long i = 1; i <= inMoreMastersCalls; i++) - ::MoreMasters(); - - ::InitGraf(&qd.thePort); - ::InitFonts(); - ::InitMenus(); - ::TEInit(); - ::InitDialogs(0L); - ::FlushEvents(everyEvent, 0); - ::InitCursor(); - long total,contig; - PurgeSpace(&total, &contig); + ::MaxApplZone(); + for (long i = 1; i <= inMoreMastersCalls; i++) + ::MoreMasters(); + + ::InitGraf(&qd.thePort); + ::InitFonts(); + ::InitMenus(); + ::TEInit(); + ::InitDialogs(0L); + ::FlushEvents(everyEvent, 0); + ::InitCursor(); + long total,contig; + PurgeSpace(&total, &contig); #else - InitCursor(); + InitCursor(); #endif if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr) - sUMASystemVersion = 0x0000 ; - - long theAppearance ; - if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) - { - sUMAHasAppearance = true ; - RegisterAppearanceClient(); - if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) - { - sUMAAppearanceVersion = theAppearance ; - } - else - { - sUMAAppearanceVersion = 0x0100 ; - } - } - if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr ) - { - sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ; - } - + sUMASystemVersion = 0x0000 ; + + long theAppearance ; + if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) + { + sUMAHasAppearance = true ; + RegisterAppearanceClient(); + if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) + { + sUMAAppearanceVersion = theAppearance ; + } + else + { + sUMAAppearanceVersion = 0x0100 ; + } + } + if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr ) + { + sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ; + } + #if TARGET_CARBON -// Call currently implicitely done : InitFloatingWindows() ; +// Call currently implicitely done : InitFloatingWindows() ; #else - if ( sUMAHasWindowManager ) - InitFloatingWindows() ; - else - InitWindows(); + if ( sUMAHasWindowManager ) + InitFloatingWindows() ; + else + InitWindows(); #endif - if ( NavServicesAvailable() ) - { - NavLoad() ; - } + if ( NavServicesAvailable() ) + { + NavLoad() ; + } long menuMgrAttr ; Gestalt( gestaltMenuMgrAttr , &menuMgrAttr ) ; @@ -121,10 +121,10 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) if ( TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress ) { FontFamilyID fontId ; - Str255 fontName ; - SInt16 fontSize ; - Style fontStyle ; - GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; + Str255 fontName ; + SInt16 fontSize ; + Style fontStyle ; + GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetFNum( fontName, &fontId ); TXNMacOSPreferredFontDescription fontDescriptions[] = @@ -135,15 +135,15 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) #if 0 // TARGET_CARBON --noOfFontDescriptions ; #endif - // kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke - OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ; + // kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke + OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ; #if TARGET_CARBON if ( !UMAHasAquaLayout() ) #endif { options |= kTXNAlwaysUseQuickDrawTextMask ; } - TXNInitTextension(fontDescriptions, noOfFontDescriptions, options ); + TXNInitTextension(fontDescriptions, noOfFontDescriptions, options ); } @@ -153,286 +153,286 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls ) /* Boolean CanUseATSUI() - { - long result; - OSErr err = Gestalt(gestaltATSUVersion, &result); - return (err == noErr); - } + { + long result; + OSErr err = Gestalt(gestaltATSUVersion, &result); + return (err == noErr); + } */ // process manager long UMAGetProcessMode() { - OSErr err ; - ProcessInfoRec processinfo; - ProcessSerialNumber procno ; - - procno.highLongOfPSN = NULL ; - procno.lowLongOfPSN = kCurrentProcess ; - processinfo.processInfoLength = sizeof(ProcessInfoRec); - processinfo.processName = NULL; - processinfo.processAppSpec = NULL; + OSErr err ; + ProcessInfoRec processinfo; + ProcessSerialNumber procno ; + + procno.highLongOfPSN = NULL ; + procno.lowLongOfPSN = kCurrentProcess ; + processinfo.processInfoLength = sizeof(ProcessInfoRec); + processinfo.processName = NULL; + processinfo.processAppSpec = NULL; - err = ::GetProcessInformation( &procno , &processinfo ) ; - wxASSERT( err == noErr ) ; - return processinfo.processMode ; + err = ::GetProcessInformation( &procno , &processinfo ) ; + wxASSERT( err == noErr ) ; + return processinfo.processMode ; } bool UMAGetProcessModeDoesActivateOnFGSwitch() { - return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ; + return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ; } // menu manager MenuRef UMANewMenu( SInt16 id , const wxString& title ) { - wxString str = wxStripMenuCodes( title ) ; - MenuRef menu ; + wxString str = wxStripMenuCodes( title ) ; + MenuRef menu ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - CreateNewMenu( id , 0 , &menu ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + CFStringRef cfs = wxMacCreateCFString( str ) ; + CreateNewMenu( id , 0 , &menu ) ; + SetMenuTitleWithCFString( menu , cfs ) ; + CFRelease( cfs ) ; #else - Str255 ptitle ; - wxMacStringToPascal( str , ptitle ) ; - menu = ::NewMenu( id , ptitle ) ; + Str255 ptitle ; + wxMacStringToPascal( str , ptitle ) ; + menu = ::NewMenu( id , ptitle ) ; #endif - return menu ; + return menu ; } void UMASetMenuTitle( MenuRef menu , const wxString& title ) { - wxString str = wxStripMenuCodes( title ) ; + wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuTitleWithCFString( menu , cfs ) ; - CFRelease( cfs ) ; + CFStringRef cfs = wxMacCreateCFString( str ) ; + SetMenuTitleWithCFString( menu , cfs ) ; + CFRelease( cfs ) ; #else - Str255 ptitle ; - wxMacStringToPascal( str , ptitle ) ; - SetMenuTitle( menu , ptitle ) ; + Str255 ptitle ; + wxMacStringToPascal( str , ptitle ) ; + SetMenuTitle( menu , ptitle ) ; #endif } void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title ) { - wxString str = wxStripMenuCodes( title ) ; + wxString str = wxStripMenuCodes( title ) ; #if TARGET_CARBON - CFStringRef cfs = wxMacCreateCFString( str ) ; - SetMenuItemTextWithCFString( menu , item , cfs ) ; - CFRelease( cfs ) ; + CFStringRef cfs = wxMacCreateCFString( str ) ; + SetMenuItemTextWithCFString( menu , item , cfs ) ; + CFRelease( cfs ) ; #else - Str255 ptitle ; - wxMacStringToPascal( str , ptitle ) ; - SetMenuItemText( menu , item , ptitle ) ; + Str255 ptitle ; + wxMacStringToPascal( str , ptitle ) ; + SetMenuItemText( menu , item , ptitle ) ; #endif } UInt32 UMAMenuEvent( EventRecord *inEvent ) { - return MenuEvent( inEvent ) ; + return MenuEvent( inEvent ) ; } void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem , bool enable) { - if ( enable ) - EnableMenuItem( inMenu , inItem ) ; - else - DisableMenuItem( inMenu , inItem ) ; + if ( enable ) + EnableMenuItem( inMenu , inItem ) ; + else + DisableMenuItem( inMenu , inItem ) ; } void UMAAppendSubMenuItem( MenuRef menu , const wxString& title , SInt16 id ) { - MacAppendMenu(menu, "\pA"); - UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title ); - SetMenuItemHierarchicalID( menu , CountMenuItems( menu ) , id ) ; + MacAppendMenu(menu, "\pA"); + UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title ); + SetMenuItemHierarchicalID( menu , CountMenuItems( menu ) , id ) ; } void UMAInsertSubMenuItem( MenuRef menu , const wxString& title , MenuItemIndex item , SInt16 id ) { - MacInsertMenuItem(menu, "\pA" , item); - UMASetMenuItemText(menu, item , title ); - SetMenuItemHierarchicalID( menu , item , id ) ; + MacInsertMenuItem(menu, "\pA" , item); + UMASetMenuItemText(menu, item , title ); + SetMenuItemHierarchicalID( menu , item , id ) ; } void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEntry *entry ) { - if ( !entry ) - return ; - - UInt8 modifiers = 0 ; - SInt16 key = entry->GetKeyCode() ; - if ( key ) - { - bool explicitCommandKey = false ; - - if ( entry->GetFlags() & wxACCEL_CTRL ) - { - explicitCommandKey = true ; - } - - if (entry->GetFlags() & wxACCEL_ALT ) - { - modifiers |= kMenuOptionModifier ; - } - - if (entry->GetFlags() & wxACCEL_SHIFT) - { - modifiers |= kMenuShiftModifier ; - } - - SInt16 glyph = 0 ; - SInt16 macKey = key ; - if ( key >= WXK_F1 && key <= WXK_F15 ) - { - macKey = kFunctionKeyCharCode ; - glyph = kMenuF1Glyph + ( key - WXK_F1 ) ; - if ( key >= WXK_F13 ) - glyph += 13 ; + if ( !entry ) + return ; + + UInt8 modifiers = 0 ; + SInt16 key = entry->GetKeyCode() ; + if ( key ) + { + bool explicitCommandKey = false ; + + if ( entry->GetFlags() & wxACCEL_CTRL ) + { + explicitCommandKey = true ; + } + + if (entry->GetFlags() & wxACCEL_ALT ) + { + modifiers |= kMenuOptionModifier ; + } + + if (entry->GetFlags() & wxACCEL_SHIFT) + { + modifiers |= kMenuShiftModifier ; + } + + SInt16 glyph = 0 ; + SInt16 macKey = key ; + if ( key >= WXK_F1 && key <= WXK_F15 ) + { + macKey = kFunctionKeyCharCode ; + glyph = kMenuF1Glyph + ( key - WXK_F1 ) ; + if ( key >= WXK_F13 ) + glyph += 13 ; if ( !explicitCommandKey ) - modifiers |= kMenuNoCommandModifier ; - - switch( key ) - { - case WXK_F1 : - macKey += ( 0x7a << 8 ) ; - break ; - case WXK_F2 : - macKey += ( 0x78 << 8 ) ; - break ; - case WXK_F3 : - macKey += ( 0x63 << 8 ) ; - break ; - case WXK_F4 : - macKey += ( 0x76 << 8 ) ; - break ; - case WXK_F5 : - macKey += ( 0x60 << 8 ) ; - break ; - case WXK_F6 : - macKey += ( 0x61 << 8 ) ; - break ; - case WXK_F7 : - macKey += ( 0x62 << 8 ) ; - break ; - case WXK_F8 : - macKey += ( 0x64 << 8 ) ; - break ; - case WXK_F9 : - macKey += ( 0x65 << 8 ) ; - break ; - case WXK_F10 : - macKey += ( 0x6D << 8 ) ; - break ; - case WXK_F11 : - macKey += ( 0x67 << 8 ) ; - break ; - case WXK_F12 : - macKey += ( 0x6F << 8 ) ; - break ; - case WXK_F13 : - macKey += ( 0x69 << 8 ) ; - break ; - case WXK_F14 : - macKey += ( 0x6B << 8 ) ; - break ; - case WXK_F15 : - macKey += ( 0x71 << 8 ) ; - break ; - default : - break ; - } ; - // unfortunately this does not yet trigger the right key , - // for some reason mac justs picks the first function key menu - // defined, so we turn this off - macKey = 0 ; - glyph = 0 ; - } - else - { - switch( key ) - { - case WXK_BACK : - macKey = kBackspaceCharCode ; - glyph = kMenuDeleteLeftGlyph ; - break ; - case WXK_TAB : - macKey = kTabCharCode ; - glyph = kMenuTabRightGlyph ; - break ; - case kEnterCharCode : - macKey = kEnterCharCode ; - glyph = kMenuEnterGlyph ; - break ; - case WXK_RETURN : - macKey = kReturnCharCode ; - glyph = kMenuReturnGlyph ; - break ; - case WXK_ESCAPE : - macKey = kEscapeCharCode ; - glyph = kMenuEscapeGlyph ; - break ; - case WXK_SPACE : - macKey = ' ' ; - glyph = kMenuSpaceGlyph ; - break ; - case WXK_DELETE : - macKey = kDeleteCharCode ; - glyph = kMenuDeleteRightGlyph ; - break ; - case WXK_CLEAR : - macKey = kClearCharCode ; - glyph = kMenuClearGlyph ; - break ; - case WXK_PRIOR : // PAGE UP - macKey = kPageUpCharCode ; - glyph = kMenuPageUpGlyph ; - break ; - case WXK_NEXT : - macKey = kPageDownCharCode ; - glyph = kMenuPageDownGlyph ; - break ; - case WXK_LEFT : - macKey = kLeftArrowCharCode ; - glyph = kMenuLeftArrowGlyph ; - break ; - case WXK_UP : - macKey = kUpArrowCharCode ; - glyph = kMenuUpArrowGlyph ; - break ; - case WXK_RIGHT : - macKey = kRightArrowCharCode ; - glyph = kMenuRightArrowGlyph ; - break ; - case WXK_DOWN : - macKey = kDownArrowCharCode ; - glyph = kMenuDownArrowGlyph ; - break ; + modifiers |= kMenuNoCommandModifier ; + + switch( key ) + { + case WXK_F1 : + macKey += ( 0x7a << 8 ) ; + break ; + case WXK_F2 : + macKey += ( 0x78 << 8 ) ; + break ; + case WXK_F3 : + macKey += ( 0x63 << 8 ) ; + break ; + case WXK_F4 : + macKey += ( 0x76 << 8 ) ; + break ; + case WXK_F5 : + macKey += ( 0x60 << 8 ) ; + break ; + case WXK_F6 : + macKey += ( 0x61 << 8 ) ; + break ; + case WXK_F7 : + macKey += ( 0x62 << 8 ) ; + break ; + case WXK_F8 : + macKey += ( 0x64 << 8 ) ; + break ; + case WXK_F9 : + macKey += ( 0x65 << 8 ) ; + break ; + case WXK_F10 : + macKey += ( 0x6D << 8 ) ; + break ; + case WXK_F11 : + macKey += ( 0x67 << 8 ) ; + break ; + case WXK_F12 : + macKey += ( 0x6F << 8 ) ; + break ; + case WXK_F13 : + macKey += ( 0x69 << 8 ) ; + break ; + case WXK_F14 : + macKey += ( 0x6B << 8 ) ; + break ; + case WXK_F15 : + macKey += ( 0x71 << 8 ) ; + break ; + default : + break ; + } ; + // unfortunately this does not yet trigger the right key , + // for some reason mac justs picks the first function key menu + // defined, so we turn this off + macKey = 0 ; + glyph = 0 ; + } + else + { + switch( key ) + { + case WXK_BACK : + macKey = kBackspaceCharCode ; + glyph = kMenuDeleteLeftGlyph ; + break ; + case WXK_TAB : + macKey = kTabCharCode ; + glyph = kMenuTabRightGlyph ; + break ; + case kEnterCharCode : + macKey = kEnterCharCode ; + glyph = kMenuEnterGlyph ; + break ; + case WXK_RETURN : + macKey = kReturnCharCode ; + glyph = kMenuReturnGlyph ; + break ; + case WXK_ESCAPE : + macKey = kEscapeCharCode ; + glyph = kMenuEscapeGlyph ; + break ; + case WXK_SPACE : + macKey = ' ' ; + glyph = kMenuSpaceGlyph ; + break ; + case WXK_DELETE : + macKey = kDeleteCharCode ; + glyph = kMenuDeleteRightGlyph ; + break ; + case WXK_CLEAR : + macKey = kClearCharCode ; + glyph = kMenuClearGlyph ; + break ; + case WXK_PRIOR : // PAGE UP + macKey = kPageUpCharCode ; + glyph = kMenuPageUpGlyph ; + break ; + case WXK_NEXT : + macKey = kPageDownCharCode ; + glyph = kMenuPageDownGlyph ; + break ; + case WXK_LEFT : + macKey = kLeftArrowCharCode ; + glyph = kMenuLeftArrowGlyph ; + break ; + case WXK_UP : + macKey = kUpArrowCharCode ; + glyph = kMenuUpArrowGlyph ; + break ; + case WXK_RIGHT : + macKey = kRightArrowCharCode ; + glyph = kMenuRightArrowGlyph ; + break ; + case WXK_DOWN : + macKey = kDownArrowCharCode ; + glyph = kMenuDownArrowGlyph ; + break ; } } - SetItemCmd( menu, item , macKey ); - SetMenuItemModifiers(menu, item , modifiers ) ; + SetItemCmd( menu, item , macKey ); + SetMenuItemModifiers(menu, item , modifiers ) ; if ( glyph ) SetMenuItemKeyGlyph(menu, item , glyph ) ; - } + } } void UMAAppendMenuItem( MenuRef menu , const wxString& title , wxAcceleratorEntry *entry ) { - MacAppendMenu(menu, "\pA"); - UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title ); - UMASetMenuItemShortcut( menu , (SInt16) ::CountMenuItems(menu), entry ) ; + MacAppendMenu(menu, "\pA"); + UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title ); + UMASetMenuItemShortcut( menu , (SInt16) ::CountMenuItems(menu), entry ) ; } void UMAInsertMenuItem( MenuRef menu , const wxString& title , MenuItemIndex item , wxAcceleratorEntry *entry ) { - MacInsertMenuItem( menu , "\p" , item) ; - UMASetMenuItemText(menu, item , title ); - UMASetMenuItemShortcut( menu , item , entry ) ; + MacInsertMenuItem( menu , "\p" , item) ; + UMASetMenuItemText(menu, item , title ); + UMASetMenuItemShortcut( menu , item , entry ) ; } // quickdraw @@ -442,58 +442,58 @@ int gPrOpenCounter = 0 ; OSStatus UMAPrOpen(void *macPrintSession) { #if !TARGET_CARBON - OSErr err = noErr ; - ++gPrOpenCounter ; - if ( gPrOpenCounter == 1 ) - { - PrOpen() ; - err = PrError() ; - wxASSERT( err == noErr ) ; - } - return err ; + OSErr err = noErr ; + ++gPrOpenCounter ; + if ( gPrOpenCounter == 1 ) + { + PrOpen() ; + err = PrError() ; + wxASSERT( err == noErr ) ; + } + return err ; #else - OSStatus err = noErr ; - ++gPrOpenCounter ; - if ( gPrOpenCounter == 1 ) - { + OSStatus err = noErr ; + ++gPrOpenCounter ; + if ( gPrOpenCounter == 1 ) + { #if PM_USE_SESSION_APIS - err = PMCreateSession((PMPrintSession *)macPrintSession) ; + err = PMCreateSession((PMPrintSession *)macPrintSession) ; #else - err = PMBegin() ; + err = PMBegin() ; #endif - wxASSERT( err == noErr ) ; - } - return err ; + wxASSERT( err == noErr ) ; + } + return err ; #endif } OSStatus UMAPrClose(void *macPrintSession) { #if !TARGET_CARBON - OSErr err = noErr ; - wxASSERT( gPrOpenCounter >= 1 ) ; - if ( gPrOpenCounter == 1 ) - { - PrClose() ; - err = PrError() ; - wxASSERT( err == noErr ) ; - } - --gPrOpenCounter ; - return err ; + OSErr err = noErr ; + wxASSERT( gPrOpenCounter >= 1 ) ; + if ( gPrOpenCounter == 1 ) + { + PrClose() ; + err = PrError() ; + wxASSERT( err == noErr ) ; + } + --gPrOpenCounter ; + return err ; #else - OSStatus err = noErr ; - wxASSERT( gPrOpenCounter >= 1 ) ; - if ( gPrOpenCounter == 1 ) - { + OSStatus err = noErr ; + wxASSERT( gPrOpenCounter >= 1 ) ; + if ( gPrOpenCounter == 1 ) + { #if PM_USE_SESSION_APIS - err = PMRelease(*(PMPrintSession *)macPrintSession) ; - *(PMPrintSession *)macPrintSession = kPMNoReference; + err = PMRelease(*(PMPrintSession *)macPrintSession) ; + *(PMPrintSession *)macPrintSession = kPMNoReference; #else - err = PMEnd() ; + err = PMEnd() ; #endif - } - --gPrOpenCounter ; - return err ; + } + --gPrOpenCounter ; + return err ; #endif } @@ -502,82 +502,82 @@ OSStatus UMAPrClose(void *macPrintSession) pascal QDGlobalsPtr GetQDGlobalsPtr (void) ; pascal QDGlobalsPtr GetQDGlobalsPtr (void) { - return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA); + return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA); } #endif void UMAShowWatchCursor() { - OSErr err = noErr; + OSErr err = noErr; - CursHandle watchFob = GetCursor (watchCursor); + CursHandle watchFob = GetCursor (watchCursor); - if (!watchFob) - err = nilHandleErr; - else - { - #if TARGET_CARBON -// Cursor preservedArrow; -// GetQDGlobalsArrow (&preservedArrow); -// SetQDGlobalsArrow (*watchFob); -// InitCursor ( ); -// SetQDGlobalsArrow (&preservedArrow); - SetCursor (*watchFob); - #else - SetCursor (*watchFob); - #endif - } + if (!watchFob) + err = nilHandleErr; + else + { + #if TARGET_CARBON +// Cursor preservedArrow; +// GetQDGlobalsArrow (&preservedArrow); +// SetQDGlobalsArrow (*watchFob); +// InitCursor ( ); +// SetQDGlobalsArrow (&preservedArrow); + SetCursor (*watchFob); + #else + SetCursor (*watchFob); + #endif + } } -void UMAShowArrowCursor() +void UMAShowArrowCursor() { #if TARGET_CARBON - Cursor arrow; - SetCursor (GetQDGlobalsArrow (&arrow)); + Cursor arrow; + SetCursor (GetQDGlobalsArrow (&arrow)); #else - SetCursor (&(qd.arrow)); + SetCursor (&(qd.arrow)); #endif } // window manager -GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) +GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) { - wxASSERT( inWindowRef != NULL ) ; + wxASSERT( inWindowRef != NULL ) ; #if TARGET_CARBON - return (GrafPtr) GetWindowPort( inWindowRef ) ; + return (GrafPtr) GetWindowPort( inWindowRef ) ; #else - return (GrafPtr) inWindowRef ; + return (GrafPtr) inWindowRef ; #endif } -void UMADisposeWindow( WindowRef inWindowRef ) +void UMADisposeWindow( WindowRef inWindowRef ) { - wxASSERT( inWindowRef != NULL ) ; - DisposeWindow( inWindowRef ) ; + wxASSERT( inWindowRef != NULL ) ; + DisposeWindow( inWindowRef ) ; } -void UMASetWTitleC( WindowRef inWindowRef , const char *title ) +void UMASetWTitleC( WindowRef inWindowRef , const char *title ) { - Str255 ptitle ; - strncpy( (char*)ptitle , title , 96 ) ; - ptitle[96] = 0 ; + Str255 ptitle ; + strncpy( (char*)ptitle , title , 96 ) ; + ptitle[96] = 0 ; #if TARGET_CARBON - c2pstrcpy( ptitle, (char *)ptitle ) ; + c2pstrcpy( ptitle, (char *)ptitle ) ; #else - c2pstr( (char*)ptitle ) ; + c2pstr( (char*)ptitle ) ; #endif - SetWTitle( inWindowRef , ptitle ) ; + SetWTitle( inWindowRef , ptitle ) ; } -void UMAGetWTitleC( WindowRef inWindowRef , char *title ) +void UMAGetWTitleC( WindowRef inWindowRef , char *title ) { - GetWTitle( inWindowRef , (unsigned char*)title ) ; + GetWTitle( inWindowRef , (unsigned char*)title ) ; #if TARGET_CARBON - p2cstrcpy( title, (unsigned char *)title ) ; + p2cstrcpy( title, (unsigned char *)title ) ; #else - p2cstr( (unsigned char*)title ) ; + p2cstr( (unsigned char*)title ) ; #endif } @@ -587,18 +587,18 @@ void UMAActivateControl( ControlHandle inControl ) { // we have to add the control after again to the update rgn // otherwise updates get lost - if ( !IsControlActive( inControl ) ) - { + if ( !IsControlActive( inControl ) ) + { bool visible = IsControlVisible( inControl ) ; if ( visible ) - SetControlVisibility( inControl , false , false ) ; + SetControlVisibility( inControl , false , false ) ; ::ActivateControl( inControl ) ; if ( visible ) { - SetControlVisibility( inControl , true , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } - } + } } void UMADrawControl( ControlHandle inControl ) @@ -606,153 +606,151 @@ void UMADrawControl( ControlHandle inControl ) WindowRef theWindow = GetControlOwner(inControl) ; RgnHandle updateRgn = NewRgn() ; GetWindowUpdateRgn( theWindow , updateRgn ) ; - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; + Point zero = { 0 , 0 } ; + LocalToGlobal( &zero ) ; + OffsetRgn( updateRgn , -zero.h , -zero.v ) ; ::DrawControlInCurrentPort( inControl ) ; InvalWindowRgn( theWindow, updateRgn) ; - DisposeRgn( updateRgn ) ; + DisposeRgn( updateRgn ) ; } void UMAMoveControl( ControlHandle inControl , short x , short y ) { - bool visible = IsControlVisible( inControl ) ; - if ( visible ) { - SetControlVisibility( inControl , false , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } - ::MoveControl( inControl , x , y ) ; - if ( visible ) { - SetControlVisibility( inControl , true , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } + bool visible = IsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } + ::MoveControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } } void UMASizeControl( ControlHandle inControl , short x , short y ) { - bool visible = IsControlVisible( inControl ) ; - if ( visible ) { - SetControlVisibility( inControl , false , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } - ::SizeControl( inControl , x , y ) ; - if ( visible ) { - SetControlVisibility( inControl , true , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } + bool visible = IsControlVisible( inControl ) ; + if ( visible ) { + SetControlVisibility( inControl , false , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } + ::SizeControl( inControl , x , y ) ; + if ( visible ) { + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } } void UMADeactivateControl( ControlHandle inControl ) { // we have to add the control after again to the update rgn // otherwise updates get lost - bool visible = IsControlVisible( inControl ) ; - if ( visible ) - SetControlVisibility( inControl , false , false ) ; - ::DeactivateControl( inControl ) ; - if ( visible ) { - SetControlVisibility( inControl , true , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; - } -} -// shows the control and adds the region to the update region -void UMAShowControl (ControlHandle inControl) -{ + bool visible = IsControlVisible( inControl ) ; + if ( visible ) + SetControlVisibility( inControl , false , false ) ; + ::DeactivateControl( inControl ) ; + if ( visible ) { SetControlVisibility( inControl , true , false ) ; Rect ctrlBounds ; InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + } +} +// shows the control and adds the region to the update region +void UMAShowControl (ControlHandle inControl) +{ + SetControlVisibility( inControl , true , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } // shows the control and adds the region to the update region -void UMAHideControl (ControlHandle inControl) +void UMAHideControl (ControlHandle inControl) { - SetControlVisibility( inControl , false , false ) ; - Rect ctrlBounds ; - InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; + SetControlVisibility( inControl , false , false ) ; + Rect ctrlBounds ; + InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ; } // keyboard focus -OSErr UMASetKeyboardFocus (WindowPtr inWindow, - ControlHandle inControl, - ControlFocusPart inPart) +OSErr UMASetKeyboardFocus (WindowPtr inWindow, + ControlHandle inControl, + ControlFocusPart inPart) { - OSErr err = noErr; - GrafPtr port ; - GetPort( &port ) ; + OSErr err = noErr; + GrafPtr port ; + GetPort( &port ) ; - SetPortWindowPort( inWindow ) ; + SetPortWindowPort( inWindow ) ; - err = SetKeyboardFocus( inWindow , inControl , inPart ) ; - SetPort( port ) ; - return err ; + err = SetKeyboardFocus( inWindow , inControl , inPart ) ; + SetPort( port ) ; + return err ; } - - // events void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) { - RgnHandle updateRgn = NewRgn() ; - GetWindowUpdateRgn( inWindow , updateRgn ) ; - - Point zero = { 0 , 0 } ; - LocalToGlobal( &zero ) ; - OffsetRgn( updateRgn , -zero.h , -zero.v ) ; - - UpdateControls( inWindow , inRgn ) ; - InvalWindowRgn( inWindow, updateRgn) ; - DisposeRgn( updateRgn ) ; - + RgnHandle updateRgn = NewRgn() ; + GetWindowUpdateRgn( inWindow , updateRgn ) ; + + Point zero = { 0 , 0 } ; + LocalToGlobal( &zero ) ; + OffsetRgn( updateRgn , -zero.h , -zero.v ) ; + + UpdateControls( inWindow , inRgn ) ; + InvalWindowRgn( inWindow, updateRgn) ; + DisposeRgn( updateRgn ) ; } bool UMAIsWindowFloating( WindowRef inWindow ) { - WindowClass cl ; - - GetWindowClass( inWindow , &cl ) ; - return cl == kFloatingWindowClass ; + WindowClass cl ; + + GetWindowClass( inWindow , &cl ) ; + return cl == kFloatingWindowClass ; } bool UMAIsWindowModal( WindowRef inWindow ) { - WindowClass cl ; - - GetWindowClass( inWindow , &cl ) ; - return cl < kFloatingWindowClass ; + WindowClass cl ; + + GetWindowClass( inWindow , &cl ) ; + return cl < kFloatingWindowClass ; } // others void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) { - if ( inWindowRef ) - { -// bool isHighlighted = IsWindowHighlited( inWindowRef ) ; -// if ( inActivate != isHightlited ) - GrafPtr port ; - GetPort( &port ) ; - SetPortWindowPort( inWindowRef ) ; - HiliteWindow( inWindowRef , inActivate ) ; - ControlHandle control = NULL ; - ::GetRootControl( inWindowRef , & control ) ; - if ( control ) - { - if ( inActivate ) - UMAActivateControl( control ) ; - else - UMADeactivateControl( control ) ; - } - SetPort( port ) ; - } + if ( inWindowRef ) + { +// bool isHighlighted = IsWindowHighlited( inWindowRef ) ; +// if ( inActivate != isHightlited ) + GrafPtr port ; + GetPort( &port ) ; + SetPortWindowPort( inWindowRef ) ; + HiliteWindow( inWindowRef , inActivate ) ; + ControlHandle control = NULL ; + ::GetRootControl( inWindowRef , & control ) ; + if ( control ) + { + if ( inActivate ) + UMAActivateControl( control ) ; + else + UMADeactivateControl( control ) ; + } + SetPort( port ) ; + } } + OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) { - return ::DrawThemePlacard( inRect , inState ) ; + return ::DrawThemePlacard( inRect , inState ) ; } #if !TARGET_CARBON @@ -765,77 +763,77 @@ OSStatus UMAGetHelpMenu( MenuItemIndex * outFirstCustomItemIndex) { #if TARGET_CARBON - return HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ; + return HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ; #else - MenuRef helpMenuHandle ; - helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ; - if ( firstCustomItemIndex == 0 && helpMenuStatus == noErr ) - { - firstCustomItemIndex = CountMenuItems( helpMenuHandle ) + 1 ; - } - if ( outFirstCustomItemIndex ) - { - *outFirstCustomItemIndex = firstCustomItemIndex ; - } - *outHelpMenu = helpMenuHandle ; - return helpMenuStatus ; + MenuRef helpMenuHandle ; + helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ; + if ( firstCustomItemIndex == 0 && helpMenuStatus == noErr ) + { + firstCustomItemIndex = CountMenuItems( helpMenuHandle ) + 1 ; + } + if ( outFirstCustomItemIndex ) + { + *outFirstCustomItemIndex = firstCustomItemIndex ; + } + *outHelpMenu = helpMenuHandle ; + return helpMenuStatus ; #endif } wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport) { - m_clip = NULL ; - Setup( newport ) ; + m_clip = NULL ; + Setup( newport ) ; } wxMacPortStateHelper::wxMacPortStateHelper() { - m_clip = NULL ; + m_clip = NULL ; } void wxMacPortStateHelper::Setup( GrafPtr newport ) { - GetPort( &m_oldPort ) ; - SetPort( newport ) ; - wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ; - m_clip = NewRgn() ; - GetClip( m_clip ); - m_textFont = GetPortTextFont( (CGrafPtr) newport); - m_textSize = GetPortTextSize( (CGrafPtr) newport); - m_textStyle = GetPortTextFace( (CGrafPtr) newport); - m_textMode = GetPortTextMode( (CGrafPtr) newport); - GetThemeDrawingState( &m_drawingState ) ; - m_currentPort = newport ; + GetPort( &m_oldPort ) ; + SetPort( newport ) ; + wxASSERT_MSG( m_clip == NULL , "Cannot call setup twice" ) ; + m_clip = NewRgn() ; + GetClip( m_clip ); + m_textFont = GetPortTextFont( (CGrafPtr) newport); + m_textSize = GetPortTextSize( (CGrafPtr) newport); + m_textStyle = GetPortTextFace( (CGrafPtr) newport); + m_textMode = GetPortTextMode( (CGrafPtr) newport); + GetThemeDrawingState( &m_drawingState ) ; + m_currentPort = newport ; } void wxMacPortStateHelper::Clear() { - if ( m_clip ) - { - DisposeRgn( m_clip ) ; - DisposeThemeDrawingState( m_drawingState ) ; - m_clip = NULL ; - } + if ( m_clip ) + { + DisposeRgn( m_clip ) ; + DisposeThemeDrawingState( m_drawingState ) ; + m_clip = NULL ; + } } wxMacPortStateHelper::~wxMacPortStateHelper() { - if ( m_clip ) - { - SetPort( m_currentPort ) ; - SetClip( m_clip ) ; - DisposeRgn( m_clip ) ; - TextFont( m_textFont ); - TextSize( m_textSize ); - TextFace( m_textStyle ); - TextMode( m_textMode ); - SetThemeDrawingState( m_drawingState , true ) ; - SetPort( m_oldPort ) ; - } + if ( m_clip ) + { + SetPort( m_currentPort ) ; + SetClip( m_clip ) ; + DisposeRgn( m_clip ) ; + TextFont( m_textFont ); + TextSize( m_textSize ); + TextFace( m_textStyle ); + TextMode( m_textMode ); + SetThemeDrawingState( m_drawingState , true ) ; + SetPort( m_oldPort ) ; + } } OSStatus UMAPutScrap( Size size , OSType type , void *data ) { - OSStatus err = noErr ; + OSStatus err = noErr ; #if !TARGET_CARBON err = PutScrap( size , type , data ) ; #else @@ -846,6 +844,6 @@ OSStatus UMAPutScrap( Size size , OSType type , void *data ) err = PutScrapFlavor (scrap, type , 0, size, data); } #endif - return err ; + return err ; } diff --git a/src/mac/utils.cpp b/src/mac/utils.cpp index f308faf2df..a3f95679a9 100644 --- a/src/mac/utils.cpp +++ b/src/mac/utils.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -50,27 +50,27 @@ bool wxGetFullHostName(wxChar *buf, int maxSize) // Get hostname only (without domain name) bool wxGetHostName(char *buf, int maxSize) { - // Gets Chooser name of user by examining a System resource. - - const short kComputerNameID = -16413; - - short oldResFile = CurResFile() ; - UseResFile(0); - StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); - UseResFile(oldResFile); - - if (chooserName && *chooserName) - { - int length = (*chooserName)[0] ; - if ( length + 1 > maxSize ) - { - length = maxSize - 1 ; - } - strncpy( buf , (char*) &(*chooserName)[1] , length ) ; - buf[length] = 0 ; - } - else - buf[0] = 0 ; + // Gets Chooser name of user by examining a System resource. + + const short kComputerNameID = -16413; + + short oldResFile = CurResFile() ; + UseResFile(0); + StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); + UseResFile(oldResFile); + + if (chooserName && *chooserName) + { + int length = (*chooserName)[0] ; + if ( length + 1 > maxSize ) + { + length = maxSize - 1 ; + } + strncpy( buf , (char*) &(*chooserName)[1] , length ) ; + buf[length] = 0 ; + } + else + buf[0] = 0 ; return TRUE; } @@ -83,34 +83,34 @@ bool wxGetUserId(char *buf, int maxSize) const wxChar* wxGetHomeDir(wxString *pstr) { - *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ; - return pstr->c_str() ; + *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ; + return pstr->c_str() ; } // Get user name e.g. Stefan Csomor bool wxGetUserName(char *buf, int maxSize) { - // Gets Chooser name of user by examining a System resource. - - const short kChooserNameID = -16096; - - short oldResFile = CurResFile() ; - UseResFile(0); - StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); - UseResFile(oldResFile); - - if (chooserName && *chooserName) - { - int length = (*chooserName)[0] ; - if ( length + 1 > maxSize ) - { - length = maxSize - 1 ; - } - strncpy( buf , (char*) &(*chooserName)[1] , length ) ; - buf[length] = 0 ; - } - else - buf[0] = 0 ; + // Gets Chooser name of user by examining a System resource. + + const short kChooserNameID = -16096; + + short oldResFile = CurResFile() ; + UseResFile(0); + StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); + UseResFile(oldResFile); + + if (chooserName && *chooserName) + { + int length = (*chooserName)[0] ; + if ( length + 1 > maxSize ) + { + length = maxSize - 1 ; + } + strncpy( buf , (char*) &(*chooserName)[1] , length ) ; + buf[length] = 0 ; + } + else + buf[0] = 0 ; return TRUE; } @@ -123,15 +123,15 @@ int wxKill(long pid, wxSignal sig , wxKillError *rc ) WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value) { - // TODO : under classic there is no environement support, under X yes - return false ; + // TODO : under classic there is no environement support, under X yes + return false ; } // set the env var name to the given value, return TRUE on success WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value) { - // TODO : under classic there is no environement support, under X yes - return false ; + // TODO : under classic there is no environement support, under X yes + return false ; } // @@ -161,7 +161,7 @@ void wxUsleep(unsigned long milliseconds) clock_t start = clock() ; do { - YieldToAnyThread() ; + YieldToAnyThread() ; } while( clock() - start < milliseconds / CLOCKS_PER_SEC ) ; } @@ -180,34 +180,34 @@ void wxFlushEvents() // Output a debug message, in a system dependent fashion. void wxDebugMsg(const char *fmt ...) { - va_list ap; - static char buffer[512]; - - if (!wxTheApp->GetWantDebugOutput()) - return ; - - va_start(ap, fmt); - - vsprintf(buffer,fmt,ap) ; - strcat(buffer,";g") ; - c2pstr(buffer) ; - DebugStr((unsigned char*) buffer) ; - - va_end(ap); + va_list ap; + static char buffer[512]; + + if (!wxTheApp->GetWantDebugOutput()) + return ; + + va_start(ap, fmt); + + vsprintf(buffer,fmt,ap) ; + strcat(buffer,";g") ; + c2pstr(buffer) ; + DebugStr((unsigned char*) buffer) ; + + va_end(ap); } // Non-fatal error: pop up message box and (possibly) continue void wxError(const wxString& msg, const wxString& title) { - if (wxMessageBox(wxString::Format(wxT("%s\nContinue?"),msg), title, wxYES_NO) == wxID_NO ) - wxExit(); + if (wxMessageBox(wxString::Format(wxT("%s\nContinue?"),msg), title, wxYES_NO) == wxID_NO ) + wxExit(); } // Fatal error: pop up message box and abort void wxFatalError(const wxString& msg, const wxString& title) { - wxMessageBox(wxString::Format(wxT("%s: %s"),title,msg)); - wxExit(); + wxMessageBox(wxString::Format(wxT("%s: %s"),title,msg)); + wxExit(); } #endif // WXWIN_COMPATIBILITY_2_2 @@ -225,13 +225,13 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn) long theSystem ; // are there x-platform conventions ? - + Gestalt(gestaltSystemVersion, &theSystem) ; if (minorVsn != NULL) { - *minorVsn = (theSystem & 0xFF ) ; + *minorVsn = (theSystem & 0xFF ) ; } if (majorVsn != NULL) { - *majorVsn = (theSystem >> 8 ) ; + *majorVsn = (theSystem >> 8 ) ; } #ifdef __DARWIN__ return wxMAC_DARWIN; @@ -250,23 +250,23 @@ bool wxWriteResource(const wxString& section, const wxString& entry, const wxStr bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) { - char buf[50]; - sprintf(buf, "%.4f", value); - return wxWriteResource(section, entry, buf, file); + char buf[50]; + sprintf(buf, "%.4f", value); + return wxWriteResource(section, entry, buf, file); } bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) { - char buf[50]; - sprintf(buf, "%ld", value); - return wxWriteResource(section, entry, buf, file); + char buf[50]; + sprintf(buf, "%ld", value); + return wxWriteResource(section, entry, buf, file); } bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file) { - char buf[50]; - sprintf(buf, "%d", value); - return wxWriteResource(section, entry, buf, file); + char buf[50]; + sprintf(buf, "%d", value); + return wxWriteResource(section, entry, buf, file); } bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file) @@ -277,81 +277,81 @@ bool wxGetResource(const wxString& section, const wxString& entry, char **value, bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file) { - char *s = NULL; - bool succ = wxGetResource(section, entry, (char **)&s, file); - if (succ) - { - *value = (float)strtod(s, NULL); - delete[] s; - return TRUE; - } - else return FALSE; + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = (float)strtod(s, NULL); + delete[] s; + return TRUE; + } + else return FALSE; } bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file) { - char *s = NULL; - bool succ = wxGetResource(section, entry, (char **)&s, file); - if (succ) - { - *value = strtol(s, NULL, 10); - delete[] s; - return TRUE; - } - else return FALSE; + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = strtol(s, NULL, 10); + delete[] s; + return TRUE; + } + else return FALSE; } bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file) { - char *s = NULL; - bool succ = wxGetResource(section, entry, (char **)&s, file); - if (succ) - { - *value = (int)strtol(s, NULL, 10); - delete[] s; - return TRUE; - } - else return FALSE; + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = (int)strtol(s, NULL, 10); + delete[] s; + return TRUE; + } + else return FALSE; } #endif // wxUSE_RESOURCES int gs_wxBusyCursorCount = 0; -extern wxCursor gMacCurrentCursor ; -wxCursor gMacStoredActiveCursor ; +extern wxCursor gMacCurrentCursor ; +wxCursor gMacStoredActiveCursor ; // Set the cursor to the busy cursor for all windows void wxBeginBusyCursor(wxCursor *cursor) { - if (gs_wxBusyCursorCount++ == 0) - { - gMacStoredActiveCursor = gMacCurrentCursor ; - cursor->MacInstall() ; - } - //else: nothing to do, already set + if (gs_wxBusyCursorCount++ == 0) + { + gMacStoredActiveCursor = gMacCurrentCursor ; + cursor->MacInstall() ; + } + //else: nothing to do, already set } // Restore cursor to normal void wxEndBusyCursor() { wxCHECK_RET( gs_wxBusyCursorCount > 0, - wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") ); - - if (--gs_wxBusyCursorCount == 0) - { - gMacStoredActiveCursor.MacInstall() ; - gMacStoredActiveCursor = wxNullCursor ; - } + wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") ); + + if (--gs_wxBusyCursorCount == 0) + { + gMacStoredActiveCursor.MacInstall() ; + gMacStoredActiveCursor = wxNullCursor ; + } } // TRUE if we're between the above two calls bool wxIsBusy() { - return (gs_wxBusyCursorCount > 0); + return (gs_wxBusyCursorCount > 0); } wxString wxMacFindFolder( short vol, - OSType folderType, - Boolean createFolder) + OSType folderType, + Boolean createFolder) { short vRefNum ; long dirID ; @@ -437,24 +437,24 @@ bool wxColourDisplay() // Returns depth of screen int wxDisplayDepth() { - Rect globRect ; - SetRect(&globRect, -32760, -32760, 32760, 32760); - GDHandle theMaxDevice; + Rect globRect ; + SetRect(&globRect, -32760, -32760, 32760, 32760); + GDHandle theMaxDevice; - int theDepth = 8; - theMaxDevice = GetMaxDevice(&globRect); - if (theMaxDevice != nil) - theDepth = (**(**theMaxDevice).gdPMap).pixelSize; + int theDepth = 8; + theMaxDevice = GetMaxDevice(&globRect); + if (theMaxDevice != nil) + theDepth = (**(**theMaxDevice).gdPMap).pixelSize; - return theDepth ; + return theDepth ; } // Get size of display void wxDisplaySize(int *width, int *height) { - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); - + BitMap screenBits; + GetQDGlobalsScreenBits( &screenBits ); + *width = screenBits.bounds.right - screenBits.bounds.left ; *height = screenBits.bounds.bottom - screenBits.bounds.top ; } @@ -595,29 +595,29 @@ void wxMacConvertToPC( const char *from , char *to , int len ) wxString wxMacMakeMacStringFromPC( const char * p ) { - wxString result ; + wxString result ; int len = strlen ( p ) ; - if ( len > 0 ) - { - wxChar* ptr = result.GetWriteBuf(len) ; - wxMacConvertFromPC( p , ptr , len ) ; - ptr[len] = 0 ; - result.UngetWriteBuf( len ) ; - } + if ( len > 0 ) + { + wxChar* ptr = result.GetWriteBuf(len) ; + wxMacConvertFromPC( p , ptr , len ) ; + ptr[len] = 0 ; + result.UngetWriteBuf( len ) ; + } return result ; } wxString wxMacMakePCStringFromMac( const char * p ) { - wxString result ; + wxString result ; int len = strlen ( p ) ; - if ( len > 0 ) - { - wxChar* ptr = result.GetWriteBuf(len) ; - wxMacConvertToPC( p , ptr , len ) ; - ptr[len] = 0 ; - result.UngetWriteBuf( len ) ; - } + if ( len > 0 ) + { + wxChar* ptr = result.GetWriteBuf(len) ; + wxMacConvertToPC( p , ptr , len ) ; + ptr[len] = 0 ; + result.UngetWriteBuf( len ) ; + } return result ; } @@ -639,9 +639,9 @@ wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) wxString wxMacMakeStringFromPascal( ConstStringPtr from , bool mac2pcEncoding ) { - // this is safe since a pascal string can never be larger than 256 bytes - char s[256] ; - CopyPascalStringToC( from , s ) ; + // this is safe since a pascal string can never be larger than 256 bytes + char s[256] ; + CopyPascalStringToC( from , s ) ; if (mac2pcEncoding) { return wxMacMakePCStringFromMac( s ) ; @@ -672,9 +672,9 @@ void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding // converts this string into a carbon foundation string with optional pc 2 mac encoding CFStringRef wxMacCreateCFString( const wxString &str , bool pc2macEncoding ) { - return CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , - pc2macEncoding ? - kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; + return CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , + pc2macEncoding ? + kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; } #endif //TARGET_CARBON diff --git a/src/mac/utilsexc.cpp b/src/mac/utilsexc.cpp index a9e84f42ed..229ad654f7 100644 --- a/src/mac/utilsexc.cpp +++ b/src/mac/utilsexc.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/mac/wave.cpp b/src/mac/wave.cpp index c325db04c6..0c5aac8bfc 100644 --- a/src/mac/wave.cpp +++ b/src/mac/wave.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -51,128 +51,128 @@ wxWave::wxWave(int size, const wxByte* data) bool wxWave::Create(const wxString& fileName, bool isResource) { - bool ret = false; - m_sndname = fileName; - m_isResource = isResource; - - if (m_isResource) - ret = true; - else - { /* - if (sndChan) - { // we're playing - FSClose(SndRefNum); - SndRefNum = 0; - SndDisposeChannel(sndChan, TRUE); - free(sndChan); - sndChan = 0; - KillTimer(0,timerID); - } - - if (!lpSnd) - return true; - - if (_access(lpSnd,0)) // no file, no service - return false; - - // Allocate SndChannel - sndChan = (SndChannelPtr) malloc (sizeof(SndChannel)); - - if (!sndChan) - return false; - - sndChan->qLength = 128; - - if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0)) - { - free(sndChan); - sndChan = 0; - return false; - } - - if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd))) - { - SndDisposeChannel(sndChan, TRUE); - free(sndChan); - sndChan = 0; - - return false; - } - - bool async = false; - - if (fdwSound & SND_ASYNC) - async = true; - - if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr) - { - FSClose (SndRefNum); - SndRefNum = 0; - SndDisposeChannel (sndChan, TRUE); - free (sndChan); - sndChan = 0; - return false; - } - - if (async) - { // haven't finish yet - timerID = SetTimer(0, 0, 250, TimerCallBack); - } - else - { - FSClose (SndRefNum); - SndRefNum = 0; - SndDisposeChannel (sndChan, TRUE); - free (sndChan); - sndChan = 0; - }*/ - } - - return ret; + bool ret = false; + m_sndname = fileName; + m_isResource = isResource; + + if (m_isResource) + ret = true; + else + { /* + if (sndChan) + { // we're playing + FSClose(SndRefNum); + SndRefNum = 0; + SndDisposeChannel(sndChan, TRUE); + free(sndChan); + sndChan = 0; + KillTimer(0,timerID); + } + + if (!lpSnd) + return true; + + if (_access(lpSnd,0)) // no file, no service + return false; + + // Allocate SndChannel + sndChan = (SndChannelPtr) malloc (sizeof(SndChannel)); + + if (!sndChan) + return false; + + sndChan->qLength = 128; + + if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0)) + { + free(sndChan); + sndChan = 0; + return false; + } + + if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd))) + { + SndDisposeChannel(sndChan, TRUE); + free(sndChan); + sndChan = 0; + + return false; + } + + bool async = false; + + if (fdwSound & SND_ASYNC) + async = true; + + if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr) + { + FSClose (SndRefNum); + SndRefNum = 0; + SndDisposeChannel (sndChan, TRUE); + free (sndChan); + sndChan = 0; + return false; + } + + if (async) + { // haven't finish yet + timerID = SetTimer(0, 0, 250, TimerCallBack); + } + else + { + FSClose (SndRefNum); + SndRefNum = 0; + SndDisposeChannel (sndChan, TRUE); + free (sndChan); + sndChan = 0; + }*/ + } + + return ret; } //don't know what to do with looped, wth bool wxWave::Play(bool async, bool looped) const { - char lpSnd[32]; - bool ret = false; + char lpSnd[32]; + bool ret = false; - if (m_isResource) - { + if (m_isResource) + { #if TARGET_CARBON - c2pstrcpy((unsigned char *)lpSnd, m_sndname); + c2pstrcpy((unsigned char *)lpSnd, m_sndname); #else - strcpy(lpSnd, m_sndname); - c2pstr((char *) lpSnd); + strcpy(lpSnd, m_sndname); + c2pstr((char *) lpSnd); #endif - SndListHandle hSnd; + SndListHandle hSnd; - hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); + hSnd = (SndListHandle) GetNamedResource('snd ',(const unsigned char *) lpSnd); - if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) - ret = true; - } + if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, async) == noErr)) + ret = true; + } - return ret; + return ret; } bool wxWave::FreeData() { - bool ret = false; - - if (m_isResource) - { - m_sndname.Empty(); - ret = true; - } - else - { - //TODO, - } - - return ret; + bool ret = false; + + if (m_isResource) + { + m_sndname.Empty(); + ret = true; + } + else + { + //TODO, + } + + return ret; } @@ -182,66 +182,66 @@ bool wxWave::FreeData() /*static short MacOpenSndFile (char * path) { - VolumeParam vp; - FSSpec fspec; - Str255 name; - char *c; - - // first, get the volume reference number for the file. Start by - // making a Pstring with just the volume name - strcpy ((char *) name, path); - if (c = strchr ((char *) name, ':')) - { - c++; - *c = '\0'; - } - - c2pstr ((char *) name); - vp.ioCompletion = 0; - vp.ioVolIndex = -1; - vp.ioNamePtr = name; - vp.ioVRefNum = 0; - - if (PBGetVInfo((ParamBlockRec *)&vp, 0) != noErr) - return 0; - - // next, buld an FSSpec for the file - strcpy ((char *) name, path); - c2pstr ((char *) name); - if (FSMakeFSSpec (vp.ioVRefNum, 0, name, &fspec) != noErr) - return 0; - - short frefnum; - // now open the file, and return it's reference number - if (FSpOpenDF(&fspec, fsRdPerm, &frefnum) != noErr) - return 0; - - return frefnum; + VolumeParam vp; + FSSpec fspec; + Str255 name; + char *c; + + // first, get the volume reference number for the file. Start by + // making a Pstring with just the volume name + strcpy ((char *) name, path); + if (c = strchr ((char *) name, ':')) + { + c++; + *c = '\0'; + } + + c2pstr ((char *) name); + vp.ioCompletion = 0; + vp.ioVolIndex = -1; + vp.ioNamePtr = name; + vp.ioVRefNum = 0; + + if (PBGetVInfo((ParamBlockRec *)&vp, 0) != noErr) + return 0; + + // next, buld an FSSpec for the file + strcpy ((char *) name, path); + c2pstr ((char *) name); + if (FSMakeFSSpec (vp.ioVRefNum, 0, name, &fspec) != noErr) + return 0; + + short frefnum; + // now open the file, and return it's reference number + if (FSpOpenDF(&fspec, fsRdPerm, &frefnum) != noErr) + return 0; + + return frefnum; } void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime) { - if(!sndChan) - { - KillTimer(0,timerID); - return; - } - - SCStatus scstat; - - if (noErr == SndChannelStatus (sndChan, sizeof (SCStatus), &scstat)) { - if (scstat.scChannelPaused || scstat.scChannelBusy) - return; // not done yet - } - - // either error or done. - FSClose (SndRefNum); - SndRefNum = 0; - SndDisposeChannel (sndChan, TRUE); - free (sndChan); - sndChan = 0; - KillTimer(0,timerID); + if(!sndChan) + { + KillTimer(0,timerID); + return; + } + + SCStatus scstat; + + if (noErr == SndChannelStatus (sndChan, sizeof (SCStatus), &scstat)) { + if (scstat.scChannelPaused || scstat.scChannelBusy) + return; // not done yet + } + + // either error or done. + FSClose (SndRefNum); + SndRefNum = 0; + SndDisposeChannel (sndChan, TRUE); + free (sndChan); + sndChan = 0; + KillTimer(0,timerID); }*/ diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 9eded8e45a..4592280816 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -175,8 +175,8 @@ wxWindowMac::~wxWindowMac() wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ; if ( frame ) { - if ( frame->GetLastFocus() == this ) - frame->SetLastFocus( NULL ) ; + if ( frame->GetLastFocus() == this ) + frame->SetLastFocus( NULL ) ; } if ( gFocusWindow == this ) @@ -323,15 +323,15 @@ void wxWindowMac::DoReleaseMouse() void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget) { - if ( m_dropTarget != 0 ) { - delete m_dropTarget; - } - - m_dropTarget = pDropTarget; - if ( m_dropTarget != 0 ) - { - // TODO - } + if ( m_dropTarget != 0 ) { + delete m_dropTarget; + } + + m_dropTarget = pDropTarget; + if ( m_dropTarget != 0 ) + { + // TODO + } } #endif @@ -409,12 +409,12 @@ void wxWindowMac::DoScreenToClient(int *x, int *y) const if(x) *x = localwhere.h ; if(y) *y = localwhere.v ; - + MacRootWindowToWindow( x , y ) ; if ( x ) - *x -= MacGetLeftBorderSize() ; + *x -= MacGetLeftBorderSize() ; if ( y ) - *y -= MacGetTopBorderSize() ; + *y -= MacGetTopBorderSize() ; } void wxWindowMac::DoClientToScreen(int *x, int *y) const @@ -422,9 +422,9 @@ void wxWindowMac::DoClientToScreen(int *x, int *y) const WindowRef window = (WindowRef) MacGetRootWindow() ; if ( x ) - *x += MacGetLeftBorderSize() ; + *x += MacGetLeftBorderSize() ; if ( y ) - *y += MacGetTopBorderSize() ; + *y += MacGetTopBorderSize() ; MacWindowToRootWindow( x , y ) ; @@ -482,37 +482,37 @@ void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const bool wxWindowMac::SetCursor(const wxCursor& cursor) { if (m_cursor == cursor) - return FALSE; - + return FALSE; + if (wxNullCursor == cursor) { - if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) ) - return FALSE ; + if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) ) + return FALSE ; } else { - if ( ! wxWindowBase::SetCursor( cursor ) ) - return FALSE ; - } - - wxASSERT_MSG( m_cursor.Ok(), - wxT("cursor must be valid after call to the base version")); - - Point pt ; - wxWindowMac *mouseWin ; - GetMouse( &pt ) ; - - // Change the cursor NOW if we're within the correct window - - if ( MacGetWindowFromPoint( wxPoint( pt.h , pt.v ) , &mouseWin ) ) - { - if ( mouseWin == this && !wxIsBusy() ) - { - m_cursor.MacInstall() ; + if ( ! wxWindowBase::SetCursor( cursor ) ) + return FALSE ; + } + + wxASSERT_MSG( m_cursor.Ok(), + wxT("cursor must be valid after call to the base version")); + + Point pt ; + wxWindowMac *mouseWin ; + GetMouse( &pt ) ; + + // Change the cursor NOW if we're within the correct window + + if ( MacGetWindowFromPoint( wxPoint( pt.h , pt.v ) , &mouseWin ) ) + { + if ( mouseWin == this && !wxIsBusy() ) + { + m_cursor.MacInstall() ; + } } - } - - return TRUE ; + + return TRUE ; } @@ -522,54 +522,54 @@ void wxWindowMac::DoGetClientSize(int *x, int *y) const int ww, hh; ww = m_width ; hh = m_height ; - + ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ; hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( ); - - if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) ) - { - int x1 = 0 ; - int y1 = 0 ; - int w = m_width ; - int h = m_height ; - - MacClientToRootWindow( &x1 , &y1 ) ; - MacClientToRootWindow( &w , &h ) ; - - wxWindowMac *iter = (wxWindowMac*)this ; - - int totW = 10000 , totH = 10000; - while( iter ) - { - if ( iter->IsTopLevel() ) + + if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) ) + { + int x1 = 0 ; + int y1 = 0 ; + int w = m_width ; + int h = m_height ; + + MacClientToRootWindow( &x1 , &y1 ) ; + MacClientToRootWindow( &w , &h ) ; + + wxWindowMac *iter = (wxWindowMac*)this ; + + int totW = 10000 , totH = 10000; + while( iter ) { - totW = iter->m_width ; - totH = iter->m_height ; - break ; + if ( iter->IsTopLevel() ) + { + totW = iter->m_width ; + totH = iter->m_height ; + break ; + } + + iter = iter->GetParent() ; } - - iter = iter->GetParent() ; - } - - if (m_hScrollBar && m_hScrollBar->IsShown() ) - { - hh -= MAC_SCROLLBAR_SIZE; - if ( h-y1 >= totH ) + + if (m_hScrollBar && m_hScrollBar->IsShown() ) { - hh += 1 ; + hh -= MAC_SCROLLBAR_SIZE; + if ( h-y1 >= totH ) + { + hh += 1 ; + } } - } - if (m_vScrollBar && m_vScrollBar->IsShown() ) - { - ww -= MAC_SCROLLBAR_SIZE; - if ( w-x1 >= totW ) + if (m_vScrollBar && m_vScrollBar->IsShown() ) { - ww += 1 ; + ww -= MAC_SCROLLBAR_SIZE; + if ( w-x1 >= totW ) + { + ww += 1 ; + } } } - } - if(x) *x = ww; - if(y) *y = hh; + if(x) *x = ww; + if(y) *y = hh; } @@ -582,7 +582,7 @@ void wxWindowMac::DoGetClientSize(int *x, int *y) const void wxWindowMac::DoSetToolTip(wxToolTip *tooltip) { wxWindowBase::DoSetToolTip(tooltip); - + if ( m_tooltip ) m_tooltip->SetWindow(this); } @@ -595,12 +595,12 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) int former_y = m_y ; int former_w = m_width ; int former_h = m_height ; - - int actualWidth = width; - int actualHeight = height; - int actualX = x; - int actualY = y; - + + int actualWidth = width; + int actualHeight = height; + int actualX = x; + int actualY = y; + if ((m_minWidth != -1) && (actualWidth < m_minWidth)) actualWidth = m_minWidth; if ((m_minHeight != -1) && (actualHeight < m_minHeight)) @@ -609,10 +609,10 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) actualWidth = m_maxWidth; if ((m_maxHeight != -1) && (actualHeight > m_maxHeight)) actualHeight = m_maxHeight; - + bool doMove = false ; bool doResize = false ; - + if ( actualX != former_x || actualY != former_y ) { doMove = true ; @@ -621,13 +621,13 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) { doResize = true ; } - + if ( doMove || doResize ) { // erase former position - + bool partialRepaint = false ; - + if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) ) { wxPoint oldPos( m_x , m_y ) ; @@ -652,25 +652,25 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) DisposeRgn(diffRgn) ; } } - + if ( !partialRepaint ) Refresh() ; - + m_x = actualX ; m_y = actualY ; m_width = actualWidth ; m_height = actualHeight ; - - // update any low-level frame-relative positions - - MacUpdateDimensions() ; + + // update any low-level frame-relative positions + + MacUpdateDimensions() ; // erase new position - + if ( !partialRepaint ) Refresh() ; if ( doMove ) wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified - + MacRepositionScrollBars() ; if ( doMove ) { @@ -681,14 +681,14 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) } if ( doResize ) { - MacRepositionScrollBars() ; - wxSize size(m_width, m_height); - wxSizeEvent event(size, m_windowId); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + MacRepositionScrollBars() ; + wxSize size(m_width, m_height); + wxSizeEvent event(size, m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); } } - + } // set the size of the window: if the dimensions are positive, just use them, @@ -704,25 +704,25 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) // get the current size and position... int currentX, currentY; GetPosition(¤tX, ¤tY); - + int currentW,currentH; GetSize(¤tW, ¤tH); - + // ... and don't do anything (avoiding flicker) if it's already ok if ( x == currentX && y == currentY && - width == currentW && height == currentH ) + width == currentW && height == currentH ) { MacRepositionScrollBars() ; // we might have a real position shift return; } - + if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) x = currentX; if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) y = currentY; - + AdjustForParentClientOrigin(x, y, sizeFlags); - + wxSize size(-1, -1); if ( width == -1 ) { @@ -737,7 +737,7 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) width = currentW; } } - + if ( height == -1 ) { if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) @@ -747,7 +747,7 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) size = DoGetBestSize(); } //else: already called DoGetBestSize() above - + height = size.y; } else @@ -756,9 +756,9 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) height = currentH; } } - + DoMoveWindow(x, y, width, height); - + } // For implementation purposes - sometimes decorations make the client area // smaller @@ -980,7 +980,7 @@ wxWindowMac *wxGetActiveWindow() // Coordinates relative to the window void wxWindowMac::WarpPointer (int x_pos, int y_pos) { - // We really dont move the mouse programmatically under mac + // We really don't move the mouse programmatically under Mac. } const wxBrush& wxWindowMac::MacGetBackgroundBrush() @@ -994,58 +994,57 @@ const wxBrush& wxWindowMac::MacGetBackgroundBrush() // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have // either a non gray background color or a non control window - - WindowRef window = (WindowRef) MacGetRootWindow() ; - - wxWindowMac* parent = GetParent() ; - while( parent ) + + WindowRef window = (WindowRef) MacGetRootWindow() ; + + wxWindowMac* parent = GetParent() ; + while( parent ) + { + if ( parent->MacGetRootWindow() != window ) + { + // we are in a different window on the mac system + parent = NULL ; + break ; + } + { - if ( parent->MacGetRootWindow() != window ) + if ( parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) + && parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) { - // we are in a different window on the mac system - parent = NULL ; + // if we have any other colours in the hierarchy + m_macBackgroundBrush.SetColour( parent->m_backgroundColour ) ; break ; } - + // if we have the normal colours in the hierarchy but another control etc. -> use it's background + if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) { - if ( parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) - && parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) - { - // if we have any other colours in the hierarchy - m_macBackgroundBrush.SetColour( parent->m_backgroundColour ) ; - break ; - } - // if we have the normal colours in the hierarchy but another control etc. -> use it's background - if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) - { - Rect extent = { 0 , 0 , 0 , 0 } ; - int x , y ; - x = y = 0 ; - wxSize size = parent->GetSize() ; - parent->MacClientToRootWindow( &x , &y ) ; - extent.left = x ; - extent.top = y ; - extent.top-- ; - extent.right = x + size.x ; - extent.bottom = y + size.y ; - m_macBackgroundBrush.SetMacThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ; // todo eventually change for inactive - break ; - } + Rect extent = { 0 , 0 , 0 , 0 } ; + int x , y ; + x = y = 0 ; + wxSize size = parent->GetSize() ; + parent->MacClientToRootWindow( &x , &y ) ; + extent.left = x ; + extent.top = y ; + extent.top-- ; + extent.right = x + size.x ; + extent.bottom = y + size.y ; + m_macBackgroundBrush.SetMacThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ; // todo eventually change for inactive + break ; } - parent = parent->GetParent() ; - } - if ( !parent ) - { - m_macBackgroundBrush.SetMacTheme( kThemeBrushDialogBackgroundActive ) ; // todo eventually change for inactive } + parent = parent->GetParent() ; + } + if ( !parent ) + { + m_macBackgroundBrush.SetMacTheme( kThemeBrushDialogBackgroundActive ) ; // todo eventually change for inactive + } } else { m_macBackgroundBrush.SetColour( m_backgroundColour ) ; } - - return m_macBackgroundBrush ; - + + return m_macBackgroundBrush ; } void wxWindowMac::OnEraseBackground(wxEraseEvent& event) @@ -1199,41 +1198,41 @@ void wxWindowMac::RemoveChild( wxWindowBase *child ) void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible, int range, bool refresh) { - if ( orient == wxHORIZONTAL ) + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) { - if ( m_hScrollBar ) + if ( range == 0 || thumbVisible >= range ) { - if ( range == 0 || thumbVisible >= range ) - { - if ( m_hScrollBar->IsShown() ) - m_hScrollBar->Show(false) ; - } - else - { - if ( !m_hScrollBar->IsShown() ) - m_hScrollBar->Show(true) ; - m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; - } + if ( m_hScrollBar->IsShown() ) + m_hScrollBar->Show(false) ; + } + else + { + if ( !m_hScrollBar->IsShown() ) + m_hScrollBar->Show(true) ; + m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; } } - else + } + else + { + if ( m_vScrollBar ) { - if ( m_vScrollBar ) + if ( range == 0 || thumbVisible >= range ) { - if ( range == 0 || thumbVisible >= range ) - { - if ( m_vScrollBar->IsShown() ) - m_vScrollBar->Show(false) ; - } - else - { - if ( !m_vScrollBar->IsShown() ) - m_vScrollBar->Show(true) ; - m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; - } + if ( m_vScrollBar->IsShown() ) + m_vScrollBar->Show(false) ; + } + else + { + if ( !m_vScrollBar->IsShown() ) + m_vScrollBar->Show(true) ; + m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ; } } - MacRepositionScrollBars() ; + } + MacRepositionScrollBars() ; } // Does a physical scroll @@ -1241,39 +1240,39 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect) { wxClientDC dc(this) ; wxMacPortSetter helper(&dc) ; - + { int width , height ; GetClientSize( &width , &height ) ; - + Rect scrollrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) , dc.YLOG2DEVMAC(height) , dc.XLOG2DEVMAC(width) } ; RgnHandle updateRgn = NewRgn() ; ClipRect( &scrollrect ) ; if ( rect ) { Rect r = { dc.YLOG2DEVMAC(rect->y) , dc.XLOG2DEVMAC(rect->x) , dc.YLOG2DEVMAC(rect->y + rect->height) , - dc.XLOG2DEVMAC(rect->x + rect->width) } ; + dc.XLOG2DEVMAC(rect->x + rect->width) } ; SectRect( &scrollrect , &r , &scrollrect ) ; } ScrollRect( &scrollrect , dx , dy , updateRgn ) ; InvalWindowRgn( (WindowRef) MacGetRootWindow() , updateRgn ) ; DisposeRgn( updateRgn ) ; } - + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { wxWindowMac *child = (wxWindowMac*)node->GetData(); if (child == m_vScrollBar) continue; if (child == m_hScrollBar) continue; if (child->IsTopLevel()) continue; - + int x,y; child->GetPosition( &x, &y ); int w,h; child->GetSize( &w, &h ); child->SetSize( x+dx, y+dy, w, h ); } - + } void wxWindowMac::MacOnScroll(wxScrollEvent &event ) @@ -1284,30 +1283,30 @@ void wxWindowMac::MacOnScroll(wxScrollEvent &event ) wevent.SetPosition(event.GetPosition()); wevent.SetOrientation(event.GetOrientation()); wevent.m_eventObject = this; - + if (event.m_eventType == wxEVT_SCROLL_TOP) { wevent.m_eventType = wxEVT_SCROLLWIN_TOP; } else - if (event.m_eventType == wxEVT_SCROLL_BOTTOM) { - wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM; - } else - if (event.m_eventType == wxEVT_SCROLL_LINEUP) { - wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP; - } else - if (event.m_eventType == wxEVT_SCROLL_LINEDOWN) { - wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; - } else - if (event.m_eventType == wxEVT_SCROLL_PAGEUP) { - wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; - } else - if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN) { - wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; - } else - if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK) { - wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; - } - - GetEventHandler()->ProcessEvent(wevent); + if (event.m_eventType == wxEVT_SCROLL_BOTTOM) { + wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM; + } else + if (event.m_eventType == wxEVT_SCROLL_LINEUP) { + wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP; + } else + if (event.m_eventType == wxEVT_SCROLL_LINEDOWN) { + wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; + } else + if (event.m_eventType == wxEVT_SCROLL_PAGEUP) { + wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; + } else + if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN) { + wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; + } else + if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK) { + wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK; + } + + GetEventHandler()->ProcessEvent(wevent); } } @@ -1356,7 +1355,7 @@ void wxWindowMac::OnSetFocus(wxFocusEvent& event) // notice that it's also important to do it upwards the tree becaus // otherwise when the top level panel gets focus, it won't set it back to // us, but to some other sibling - + // CS:don't know if this is still needed: //wxChildFocusEvent eventFocus(this); //(void)GetEventHandler()->ProcessEvent(eventFocus); @@ -1435,27 +1434,27 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** { if ( IsTopLevel() ) { - if ((point.x < 0) || (point.y < 0) || - (point.x > (m_width)) || (point.y > (m_height))) - return FALSE; + if ((point.x < 0) || (point.y < 0) || + (point.x > (m_width)) || (point.y > (m_height))) + return FALSE; } else { - if ((point.x < m_x) || (point.y < m_y) || - (point.x > (m_x + m_width)) || (point.y > (m_y + m_height))) - return FALSE; + if ((point.x < m_x) || (point.y < m_y) || + (point.x > (m_x + m_width)) || (point.y > (m_y + m_height))) + return FALSE; } - + WindowRef window = (WindowRef) MacGetRootWindow() ; - + wxPoint newPoint( point ) ; - + if ( !IsTopLevel() ) { - newPoint.x -= m_x; - newPoint.y -= m_y; + newPoint.x -= m_x; + newPoint.y -= m_y; } - + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { wxWindowMac *child = (wxWindowMac*)node->GetData(); @@ -1466,7 +1465,7 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** return TRUE; } } - + *outWin = this ; return TRUE; } @@ -1474,25 +1473,25 @@ bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMac** outWin ) { WindowRef window ; - + Point pt = { screenpoint.y , screenpoint.x } ; if ( ::FindWindow( pt , &window ) == 3 ) { - + wxWindowMac* win = wxFindWinFromMacWindow( window ) ; if ( win ) { // No, this yields the CLIENT are, we need the whole frame. RR. // point = win->ScreenToClient( point ) ; - + GrafPtr port; ::GetPort( &port ) ; ::SetPort( UMAGetWindowPort( window ) ) ; ::GlobalToLocal( &pt ) ; ::SetPort( port ) ; - + wxPoint point( pt.h, pt.v ) ; - + return win->MacGetWindowFromPointSub( point , outWin ) ; } } @@ -1504,22 +1503,22 @@ static wxWindow *gs_lastWhich = NULL; bool wxWindowMac::MacSetupCursor( const wxPoint& pt) { // first trigger a set cursor event - + wxPoint clientorigin = GetClientAreaOrigin() ; wxSize clientsize = GetClientSize() ; wxCursor cursor ; if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) ) { wxSetCursorEvent event( pt.x , pt.y ); - + bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); if ( processedEvtSetCursor && event.HasCursor() ) { - cursor = event.GetCursor() ; + cursor = event.GetCursor() ; } else { - + // the test for processedEvtSetCursor is here to prevent using m_cursor // if the user code caught EVT_SET_CURSOR() and returned nothing from // it - this is a way to say that our cursor shouldn't be used for this @@ -1548,19 +1547,19 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) if ((event.m_x < m_x) || (event.m_y < m_y) || (event.m_x > (m_x + m_width)) || (event.m_y > (m_y + m_height))) return FALSE; - - + + if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) /* || IsKindOf( CLASSINFO( wxSpinCtrl ) ) */) return FALSE ; - + WindowRef window = (WindowRef) MacGetRootWindow() ; - + event.m_x -= m_x; event.m_y -= m_y; - + int x = event.m_x ; int y = event.m_y ; - + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { wxWindowMac *child = (wxWindowMac*)node->GetData(); @@ -1570,10 +1569,10 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) return TRUE; } } - + wxWindow* cursorTarget = this ; wxPoint cursorPoint( x , y ) ; - + while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) ) { cursorTarget = cursorTarget->GetParent() ; @@ -1583,40 +1582,40 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) event.m_x = x ; event.m_y = y ; event.SetEventObject( this ) ; - + if ( event.GetEventType() == wxEVT_LEFT_DOWN ) { // set focus to this window if (AcceptsFocus() && FindFocus()!=this) SetFocus(); } - + #if wxUSE_TOOLTIPS if ( event.GetEventType() == wxEVT_MOTION - || event.GetEventType() == wxEVT_ENTER_WINDOW - || event.GetEventType() == wxEVT_LEAVE_WINDOW ) + || event.GetEventType() == wxEVT_ENTER_WINDOW + || event.GetEventType() == wxEVT_LEAVE_WINDOW ) wxToolTip::RelayEvent( this , event); #endif // wxUSE_TOOLTIPS - + if (gs_lastWhich != this) { gs_lastWhich = this; - + // Double clicks must always occur on the same window if (event.GetEventType() == wxEVT_LEFT_DCLICK) event.SetEventType( wxEVT_LEFT_DOWN ); if (event.GetEventType() == wxEVT_RIGHT_DCLICK) event.SetEventType( wxEVT_RIGHT_DOWN ); - + // Same for mouse up events if (event.GetEventType() == wxEVT_LEFT_UP) return TRUE; if (event.GetEventType() == wxEVT_RIGHT_UP) return TRUE; } - + GetEventHandler()->ProcessEvent( event ) ; - + return TRUE; } @@ -1657,105 +1656,105 @@ wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSiblings ) { - RgnHandle visRgn = NewRgn() ; - RgnHandle tempRgn = NewRgn() ; - RgnHandle tempStaticBoxRgn = NewRgn() ; - - SetRectRgn( visRgn , 0 , 0 , m_width , m_height ) ; - - //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox - if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) - { - int borderTop = 14 ; - int borderOther = 4 ; - - SetRectRgn( tempStaticBoxRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ; - DiffRgn( visRgn , tempStaticBoxRgn , visRgn ) ; - } - - if ( !IsTopLevel() ) - { - wxWindow* parent = GetParent() ; - while( parent ) - { - wxSize size = parent->GetSize() ; - int x , y ; - x = y = 0 ; - parent->MacWindowToRootWindow( &x, &y ) ; - MacRootWindowToWindow( &x , &y ) ; - - SetRectRgn( tempRgn , - x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , - x + size.x - parent->MacGetRightBorderSize(), - y + size.y - parent->MacGetBottomBorderSize()) ; - - SectRgn( visRgn , tempRgn , visRgn ) ; - if ( parent->IsTopLevel() ) - break ; - parent = parent->GetParent() ; - } - } - if ( respectChildrenAndSiblings ) - { - if ( GetWindowStyle() & wxCLIP_CHILDREN ) - { - for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) + RgnHandle visRgn = NewRgn() ; + RgnHandle tempRgn = NewRgn() ; + RgnHandle tempStaticBoxRgn = NewRgn() ; + + SetRectRgn( visRgn , 0 , 0 , m_width , m_height ) ; + + //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox + if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) + { + int borderTop = 14 ; + int borderOther = 4 ; + + SetRectRgn( tempStaticBoxRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ; + DiffRgn( visRgn , tempStaticBoxRgn , visRgn ) ; + } + + if ( !IsTopLevel() ) + { + wxWindow* parent = GetParent() ; + while( parent ) { - wxWindowMac *child = (wxWindowMac*)node->GetData(); - - if ( !child->IsTopLevel() && child->IsShown() ) + wxSize size = parent->GetSize() ; + int x , y ; + x = y = 0 ; + parent->MacWindowToRootWindow( &x, &y ) ; + MacRootWindowToWindow( &x , &y ) ; + + SetRectRgn( tempRgn , + x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() , + x + size.x - parent->MacGetRightBorderSize(), + y + size.y - parent->MacGetBottomBorderSize()) ; + + SectRgn( visRgn , tempRgn , visRgn ) ; + if ( parent->IsTopLevel() ) + break ; + parent = parent->GetParent() ; + } + } + if ( respectChildrenAndSiblings ) + { + if ( GetWindowStyle() & wxCLIP_CHILDREN ) + { + for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { - SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; - if ( child->IsKindOf( CLASSINFO( wxStaticBox ) ) ) + wxWindowMac *child = (wxWindowMac*)node->GetData(); + + if ( !child->IsTopLevel() && child->IsShown() ) { - int borderTop = 14 ; - int borderOther = 4 ; - - SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ; - DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; + SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ; + if ( child->IsKindOf( CLASSINFO( wxStaticBox ) ) ) + { + int borderTop = 14 ; + int borderOther = 4 ; + + SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ; + DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; + } + DiffRgn( visRgn , tempRgn , visRgn ) ; } - DiffRgn( visRgn , tempRgn , visRgn ) ; } } - } - - if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) - { - bool thisWindowThrough = false ; - for (wxWindowListNode *node = GetParent()->GetChildren().GetFirst(); node; node = node->GetNext()) + + if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() ) { - wxWindowMac *sibling = (wxWindowMac*)node->GetData(); - if ( sibling == this ) - { - thisWindowThrough = true ; - continue ; - } - if( !thisWindowThrough ) - { - continue ; - } - - if ( !sibling->IsTopLevel() && sibling->IsShown() ) + bool thisWindowThrough = false ; + for (wxWindowListNode *node = GetParent()->GetChildren().GetFirst(); node; node = node->GetNext()) { - SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; - if ( sibling->IsKindOf( CLASSINFO( wxStaticBox ) ) ) + wxWindowMac *sibling = (wxWindowMac*)node->GetData(); + if ( sibling == this ) { - int borderTop = 14 ; - int borderOther = 4 ; - - SetRectRgn( tempStaticBoxRgn , sibling->m_x - m_x + borderOther , sibling->m_y - m_y + borderTop , sibling->m_x + sibling->m_width - m_x - borderOther , sibling->m_y + sibling->m_height - m_y - borderOther ) ; - DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; + thisWindowThrough = true ; + continue ; + } + if( !thisWindowThrough ) + { + continue ; + } + + if ( !sibling->IsTopLevel() && sibling->IsShown() ) + { + SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ; + if ( sibling->IsKindOf( CLASSINFO( wxStaticBox ) ) ) + { + int borderTop = 14 ; + int borderOther = 4 ; + + SetRectRgn( tempStaticBoxRgn , sibling->m_x - m_x + borderOther , sibling->m_y - m_y + borderTop , sibling->m_x + sibling->m_width - m_x - borderOther , sibling->m_y + sibling->m_height - m_y - borderOther ) ; + DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ; + } + DiffRgn( visRgn , tempRgn , visRgn ) ; } - DiffRgn( visRgn , tempRgn , visRgn ) ; } } - } - } - m_macVisibleRegion = visRgn ; - DisposeRgn( visRgn ) ; - DisposeRgn( tempRgn ) ; - DisposeRgn( tempStaticBoxRgn ) ; - return m_macVisibleRegion ; + } + m_macVisibleRegion = visRgn ; + DisposeRgn( visRgn ) ; + DisposeRgn( tempRgn ) ; + DisposeRgn( tempStaticBoxRgn ) ; + return m_macVisibleRegion ; } void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) @@ -1763,16 +1762,16 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) RgnHandle updatergn = (RgnHandle) updatergnr ; // updatergn is always already clipped to our boundaries // it is in window coordinates, not in client coordinates - + WindowRef window = (WindowRef) MacGetRootWindow() ; - + { // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates RgnHandle ownUpdateRgn = NewRgn() ; CopyRgn( updatergn , ownUpdateRgn ) ; - + SectRgn( ownUpdateRgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn ) ; - + // newupdate is the update region in client coordinates RgnHandle newupdate = NewRgn() ; wxSize point = GetClientSize() ; @@ -1782,32 +1781,32 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) OffsetRgn( newupdate , -origin.x , -origin.y ) ; m_updateRegion = newupdate ; DisposeRgn( newupdate ) ; // it's been cloned to m_updateRegion - + if ( erase && !EmptyRgn(ownUpdateRgn) ) { - wxWindowDC dc(this); - if (!EmptyRgn(ownUpdateRgn)) - dc.SetClippingRegion(wxRegion(ownUpdateRgn)); - wxEraseEvent eevent( GetId(), &dc ); - eevent.SetEventObject( this ); - GetEventHandler()->ProcessEvent( eevent ); - - wxNcPaintEvent eventNc( GetId() ); - eventNc.SetEventObject( this ); - GetEventHandler()->ProcessEvent( eventNc ); + wxWindowDC dc(this); + if (!EmptyRgn(ownUpdateRgn)) + dc.SetClippingRegion(wxRegion(ownUpdateRgn)); + wxEraseEvent eevent( GetId(), &dc ); + eevent.SetEventObject( this ); + GetEventHandler()->ProcessEvent( eevent ); + + wxNcPaintEvent eventNc( GetId() ); + eventNc.SetEventObject( this ); + GetEventHandler()->ProcessEvent( eventNc ); } DisposeRgn( ownUpdateRgn ) ; if ( !m_updateRegion.Empty() ) { - wxPaintEvent event; - event.m_timeStamp = time ; - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + wxPaintEvent event; + event.m_timeStamp = time ; + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); } } - + // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively - + RgnHandle childupdate = NewRgn() ; for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext()) { @@ -1825,7 +1824,7 @@ void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase) } DisposeRgn( childupdate ) ; // eventually a draw grow box here - + } WXHWND wxWindowMac::MacGetRootWindow() const -- 2.45.2