From 519cb848a8f4c91c73421bb75314754284e593a4 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 5 Nov 1999 09:16:09 +0000 Subject: [PATCH] CW5.2 Pro Adaptions, wxMac starting to move in git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4366 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/splitter.gif | Bin 76432 -> 12325 bytes include/wx/defs.h | 38 + include/wx/gdicmn.h | 6 + include/wx/mac/app.h | 81 +- include/wx/mac/bitmap.h | 22 +- include/wx/mac/bmpbuttn.h | 2 + include/wx/mac/button.h | 4 +- include/wx/mac/checkbox.h | 4 +- include/wx/mac/choice.h | 2 + include/wx/mac/clipbrd.h | 11 - include/wx/mac/colour.h | 9 +- include/wx/mac/combobox.h | 4 + include/wx/mac/control.h | 76 +- include/wx/mac/cursor.h | 12 +- include/wx/mac/dc.h | 85 +- include/wx/mac/dcclient.h | 98 +- include/wx/mac/dcmemory.h | 3 +- include/wx/mac/dcprint.h | 12 +- include/wx/mac/dialog.h | 18 +- include/wx/mac/dnd.h | 2 +- include/wx/mac/font.h | 147 +- include/wx/mac/frame.h | 34 +- include/wx/mac/gauge.h | 2 - include/wx/mac/icon.h | 37 +- include/wx/mac/listbox.h | 29 +- include/wx/mac/macsock.h | 1058 ------------ include/wx/mac/mdi.h | 1 + include/wx/mac/menu.h | 25 +- include/wx/mac/menuitem.h | 83 +- include/wx/mac/metafile.h | 133 +- include/wx/mac/notebook.h | 1 + include/wx/mac/palette.h | 5 +- include/wx/mac/radiobox.h | 131 +- include/wx/mac/region.h | 3 +- include/wx/mac/scrolbar.h | 1 + include/wx/mac/setup.h | 77 +- include/wx/mac/slider.h | 8 +- include/wx/mac/spinbutt.h | 2 + include/wx/mac/statbmp.h | 4 +- include/wx/mac/statbox.h | 4 +- include/wx/mac/stattext.h | 5 +- include/wx/mac/statusbr.h | 3 +- include/wx/mac/textctrl.h | 3 +- include/wx/mac/timer.h | 4 - include/wx/mac/toolbar.h | 10 +- include/wx/mac/window.h | 832 ++++----- include/wx/msw/gsockmsw.h | 2 +- include/wx/wx_cw.h | 25 +- include/wx/wx_cw_cm.h | 15 +- include/wx/wx_cw_d.h | 4 + include/wx_cw.pch | 18 +- include/wx_cw.pch++ | 19 +- include/wx_cw_d.pch | 12 +- include/wx_cw_d.pch++ | 17 +- samples/help/doc/ClassGraph.class | Bin 1146 -> 78 bytes samples/help/doc/ClassGraphPanel.class | Bin 4084 -> 142 bytes samples/help/doc/ClassLayout.class | Bin 2412 -> 1659 bytes samples/help/doc/NavigatorButton.class | Bin 1741 -> 1553 bytes src/common/db.cpp | 4 + src/common/dbtable.cpp | 5 + src/common/socket.cpp | 2 +- src/jpeg/jconfig.h | 10 + src/mac/app.cpp | 1652 +++++++++--------- src/mac/apprsrc.r | 604 +------ src/mac/bitmap.cpp | 483 +++++- src/mac/brush.cpp | 8 +- src/mac/button.cpp | 64 +- src/mac/carbon/app.cpp | 1652 +++++++++--------- src/mac/carbon/apprsrc.r | 604 +------ src/mac/carbon/bitmap.cpp | 483 +++++- src/mac/carbon/brush.cpp | 8 +- src/mac/carbon/button.cpp | 64 +- src/mac/carbon/checkbox.cpp | 45 +- src/mac/carbon/choice.cpp | 83 +- src/mac/carbon/clipbrd.cpp | 9 +- src/mac/carbon/colordlg.cpp | 18 +- src/mac/carbon/colour.cpp | 49 +- src/mac/carbon/combobox.cpp | 104 +- src/mac/carbon/control.cpp | 614 ++++++- src/mac/carbon/corersrc.r | 168 +- src/mac/carbon/cursor.cpp | 87 +- src/mac/carbon/data.cpp | 2 +- src/mac/carbon/dc.cpp | 1204 ++++++++++++- src/mac/carbon/dcclient.cpp | 616 +------ src/mac/carbon/dcmemory.cpp | 12 + src/mac/carbon/dcscreen.cpp | 4 +- src/mac/carbon/dialog.cpp | 274 ++- src/mac/carbon/dirdlg.cpp | 431 ++++- src/mac/carbon/filedlg.cpp | 403 ++++- src/mac/carbon/font.cpp | 68 +- src/mac/carbon/fontdlg.cpp | 2 +- src/mac/carbon/frame.cpp | 217 +-- src/mac/carbon/gauge.cpp | 52 +- src/mac/carbon/icon.cpp | 51 +- src/mac/carbon/listbox.cpp | 390 ++++- src/mac/carbon/makefile.unx | 1 - src/mac/carbon/menu.cpp | 668 +++++++- src/mac/carbon/menuitem.cpp | 53 +- src/mac/carbon/metafile.cpp | 279 ++- src/mac/carbon/msgdlg.cpp | 259 ++- src/mac/carbon/notebook.cpp | 83 +- src/mac/carbon/palette.cpp | 47 +- src/mac/carbon/print.cpp | 4 +- src/mac/carbon/printdlg.cpp | 72 +- src/mac/carbon/radiobox.cpp | 5 +- src/mac/carbon/region.cpp | 113 +- src/mac/carbon/scrolbar.cpp | 108 +- src/mac/carbon/settings.cpp | 150 +- src/mac/carbon/slider.cpp | 156 +- src/mac/carbon/spinbutt.cpp | 82 +- src/mac/carbon/statbmp.cpp | 20 +- src/mac/carbon/statbox.cpp | 32 +- src/mac/carbon/stattext.cpp | 49 +- src/mac/carbon/statusbr.cpp | 2 +- src/mac/carbon/tabctrl.cpp | 23 +- src/mac/carbon/textctrl.cpp | 256 ++- src/mac/carbon/toolbar.cpp | 192 ++- src/mac/carbon/utils.cpp | 37 +- src/mac/carbon/wave.cpp | 2 +- src/mac/carbon/window.cpp | 2174 +++++++++++++++++++----- src/mac/checkbox.cpp | 45 +- src/mac/choice.cpp | 83 +- src/mac/clipbrd.cpp | 9 +- src/mac/colordlg.cpp | 18 +- src/mac/colour.cpp | 49 +- src/mac/combobox.cpp | 104 +- src/mac/control.cpp | 614 ++++++- src/mac/corersrc.r | 168 +- src/mac/cursor.cpp | 87 +- src/mac/data.cpp | 2 +- src/mac/dc.cpp | 1204 ++++++++++++- src/mac/dcclient.cpp | 616 +------ src/mac/dcmemory.cpp | 12 + src/mac/dcscreen.cpp | 4 +- src/mac/dialog.cpp | 274 ++- src/mac/dirdlg.cpp | 431 ++++- src/mac/filedlg.cpp | 403 ++++- src/mac/font.cpp | 68 +- src/mac/fontdlg.cpp | 2 +- src/mac/frame.cpp | 217 +-- src/mac/gauge.cpp | 52 +- src/mac/icon.cpp | 51 +- src/mac/listbox.cpp | 390 ++++- src/mac/makefile.unx | 1 - src/mac/menu.cpp | 668 +++++++- src/mac/menuitem.cpp | 53 +- src/mac/metafile.cpp | 279 ++- src/mac/msgdlg.cpp | 259 ++- src/mac/notebook.cpp | 83 +- src/mac/palette.cpp | 47 +- src/mac/print.cpp | 4 +- src/mac/printdlg.cpp | 72 +- src/mac/radiobox.cpp | 5 +- src/mac/region.cpp | 113 +- src/mac/scrolbar.cpp | 108 +- src/mac/settings.cpp | 150 +- src/mac/slider.cpp | 156 +- src/mac/spinbutt.cpp | 82 +- src/mac/statbmp.cpp | 20 +- src/mac/statbox.cpp | 32 +- src/mac/stattext.cpp | 49 +- src/mac/statusbr.cpp | 2 +- src/mac/tabctrl.cpp | 23 +- src/mac/textctrl.cpp | 256 ++- src/mac/toolbar.cpp | 192 ++- src/mac/utils.cpp | 37 +- src/mac/wave.cpp | 2 +- src/mac/window.cpp | 2174 +++++++++++++++++++----- src/msw/iniconf.cpp | 10 +- user/wxTest/horse.png | Bin 68850 -> 5 bytes utils/dialoged/docs/books.gif | Bin 438 -> 243 bytes utils/dialoged/docs/dialog.gif | Bin 233 -> 146 bytes utils/dialoged/docs/forward.gif | Bin 164 -> 109 bytes utils/dialoged/docs/gauge.gif | Bin 212 -> 160 bytes utils/dialoged/docs/tofront.gif | Bin 137 -> 107 bytes utils/dialoged/docs/up.gif | Bin 137 -> 6 bytes 176 files changed, 19299 insertions(+), 9137 deletions(-) diff --git a/docs/latex/wx/splitter.gif b/docs/latex/wx/splitter.gif index 04bfd9fe488d5519e7089a788316be1c84cba60f..53bd095bd0917bb6f1606e9f18363cc91b8d24f5 100644 GIT binary patch delta 8 PcmbPmm1Swd22}$95w-(# literal 76432 zcmdsgO>A6OmfovUQ6MP=AlQ^3I2$ss43U-^GT=o9K>$iI-0qSPP#oH$CbW>E_KYoI z5~I73AiE+V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7YDloFQv;l}R|;AU?Q}2lX9|ga=&|(4i+FL%LY6Nj+6K_RyMV_`(^YrPsI>#?-osDv#8W|7-&;2d=&y6rX5uE9Zmjg=&7WsJSTV3I{#!)+9+ws;^Lz+ zXK9(o;*LcXFrTu40Ai8+hN)LFY?R< z8-C%C&BOWY+Q_l$dPquknnZuS<-Ym-FZO5UnpWHZ!5D_RsJ%4&6|2$j$$zZJ|0?)5 F{~vQNaI^pb diff --git a/include/wx/defs.h b/include/wx/defs.h index 422f97d30a..1cf504cb50 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1534,6 +1534,44 @@ typedef enum { // platform specific (implementation) parts of the headers // --------------------------------------------------------------------------- +#ifdef __WXMAC__ + +typedef WindowPtr WXHWND; +typedef Handle WXHANDLE; +typedef CIconHandle WXHICON; +//typedef unsigned long WXHFONT; +typedef MenuHandle WXHMENU; +//typedef unsigned long WXHPEN; +//typedef unsigned long WXHBRUSH; +//typedef unsigned long WXHPALETTE; +typedef CursHandle WXHCURSOR; +typedef RgnHandle WXHRGN; +//typedef unsigned long WXHACCEL; +//typedef unsigned long WXHINSTANCE; +typedef GWorldPtr WXHBITMAP; +//typedef unsigned long WXHIMAGELIST; +//typedef unsigned long WXHGLOBAL; +typedef GrafPtr WXHDC; +typedef unsigned int WXUINT; +typedef unsigned long WXDWORD; +typedef unsigned short WXWORD; +//typedef unsigned int WXWPARAM; +//typedef long WXLPARAM; +typedef RGBColor WXCOLORREF; +//typedef void * WXRGNDATA; +//typedef void * WXMSG; +//typedef unsigned long WXHCONV; +//typedef unsigned long WXHKEY; +//typedef void * WXDRAWITEMSTRUCT; +//typedef void * WXMEASUREITEMSTRUCT; +//typedef void * WXLPCREATESTRUCT; +typedef int (*WXFARPROC)(); + +typedef WindowPtr WXWindow; +typedef ControlHandle WXWidget; + +#endif + #if defined(__WXMSW__) || defined(__WXPM__) // Stand-ins for Windows types or OS/2, to avoid #including all of windows.h or os2.h typedef unsigned long WXHWND; diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index c1439e0216..0fcea7fdcc 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -72,6 +72,12 @@ enum wxBITMAP_TYPE_PNM_RESOURCE, wxBITMAP_TYPE_PCX, wxBITMAP_TYPE_PCX_RESOURCE, + wxBITMAP_TYPE_PICT, + wxBITMAP_TYPE_PICT_RESOURCE, + wxBITMAP_TYPE_ICON, + wxBITMAP_TYPE_ICON_RESOURCE, + wxBITMAP_TYPE_MACCURSOR , + wxBITMAP_TYPE_MACCURSOR_RESOURCE, wxBITMAP_TYPE_ANY = 50 }; diff --git a/include/wx/mac/app.h b/include/wx/mac/app.h index 7cab45cffa..4d50c75d06 100644 --- a/include/wx/mac/app.h +++ b/include/wx/mac/app.h @@ -67,11 +67,6 @@ class WXDLLEXPORT wxApp: public wxEvtHandler virtual int OnRun() { return MainLoop(); }; virtual int OnExit() { return 0; } - - /** Returns the standard icons for the msg dialogs, implemented in - src/generic/msgdlgg.cpp and src/gtk/app.cpp. */ - virtual wxIcon GetStdIcon(int which) const; - inline void SetPrintMode(int mode) { m_printMode = mode; } inline int GetPrintMode() const { return m_printMode; } @@ -141,6 +136,11 @@ public: public: static long sm_lastMessageTime; + static wxWindow* s_captureWindow ; + static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right + static RgnHandle s_macCursorRgn ; + EventRecord* m_macCurrentEvent ; + int m_nCmdShow; protected: @@ -149,23 +149,54 @@ protected: // mac specifics public : - - void MacDoOneEvent() ; + static bool s_macDefaultEncodingIsPC ; + static bool s_macSupportPCMenuShortcuts ; + static long s_macAboutMenuItemId ; + static wxString s_macHelpMenuTitleName ; + + static bool s_macHasAppearance ; + static long s_macAppearanceVersion ; + static bool s_macHasNavigation ; + static bool s_macNavigationVersion ; + static bool s_macHasWindowManager ; + static long s_macWindowManagerVersion ; + static bool s_macHasMenuManager ; + static long s_macMenuManagerVersion ; + static bool s_macHasDialogManager ; + static long s_macDialogManagerVersion ; + + RgnHandle m_macCursorRgn ; + RgnHandle m_macSleepRgn ; + RgnHandle m_macHelpRgn ; - void MacHandleOneEvent( EventRecord *ev ) ; - void MacHandleNullEvent( EventRecord *ev ) ; - void MacHandleHighLevelEvent( EventRecord *ev ) ; - void MacHandleMouseDownEvent( EventRecord *ev ) ; - void MacHandleMouseUpEvent( EventRecord *ev ) ; - void MacHandleKeyDownEvent( EventRecord *ev ) ; - void MacHandleKeyUpEvent( EventRecord *ev ) ; - void MacHandleAutoKeyEvent( EventRecord *ev ) ; - void MacHandleActivateEvent( EventRecord *ev ) ; - void MacHandleUpdateEvent( EventRecord *ev ) ; - void MacHandleDiskEvent( EventRecord *ev ) ; - void MacHandleOSEvent( EventRecord *ev ) ; + virtual void MacSuspend( bool convertClipboard ) ; + virtual void MacResume( bool convertClipboard ) ; + virtual void MacConvertPrivateToPublicScrap() ; + virtual void MacConvertPublicToPrivateScrap() ; + + // event main methods + + void MacDoOneEvent() ; + void MacHandleOneEvent( EventRecord *ev ) ; + EventRecord* MacGetCurrentEvent() { return m_macCurrentEvent ; } + // primary events + virtual void MacHandleMouseDownEvent( EventRecord *ev ) ; + virtual void MacHandleMouseUpEvent( EventRecord *ev ) ; + virtual void MacHandleActivateEvent( EventRecord *ev ) ; + virtual void MacHandleUpdateEvent( EventRecord *ev ) ; + virtual void MacHandleKeyDownEvent( EventRecord *ev ) ; + virtual void MacHandleKeyUpEvent( EventRecord *ev ) ; + virtual void MacHandleDiskEvent( EventRecord *ev ) ; + virtual void MacHandleOSEvent( EventRecord *ev ) ; + virtual void MacHandleHighLevelEvent( EventRecord *ev ) ; + virtual void MacHandleMenuSelect( int menuid , int menuitem ) ; + + virtual OSErr MacHandleAEODoc(AppleEvent *event , AppleEvent *reply) ; + virtual OSErr MacHandleAEPDoc(AppleEvent *event , AppleEvent *reply) ; + virtual OSErr MacHandleAEOApp(AppleEvent *event , AppleEvent *reply) ; + virtual OSErr MacHandleAEQuit(AppleEvent *event , AppleEvent *reply) ; DECLARE_EVENT_TABLE() }; @@ -173,6 +204,18 @@ DECLARE_EVENT_TABLE() // TODO: add platform-specific arguments int WXDLLEXPORT wxEntry( int argc, char *argv[] ); +void wxMacConvertFromPCForControls( char * p ) ; + +void wxMacConvertToPC( const char *from , char *to , int len ) ; +void wxMacConvertFromPC( const char *from , char *to , int len ) ; +void wxMacConvertToPC( const char *from , char *to , int len ) ; +void wxMacConvertFromPC( char * p ) ; +void wxMacConvertFromPC( unsigned char *p ) ; +wxString wxMacMakeMacStringFromPC( const char * p ) ; +void wxMacConvertToPC( char * p ) ; +void wxMacConvertToPC( unsigned char *p ) ; +wxString wxMacMakePCStringFromMac( const char * p ) ; + #endif // _WX_APP_H_ diff --git a/include/wx/mac/bitmap.h b/include/wx/mac/bitmap.h index 1d2f5417e5..92eda5882d 100644 --- a/include/wx/mac/bitmap.h +++ b/include/wx/mac/bitmap.h @@ -28,6 +28,12 @@ class WXDLLEXPORT wxBitmapHandler; class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxCursor; +GWorldPtr wxMacCreateGWorld( int height , int widtdh , int depth ) ; +void wxMacDestroyGWorld( GWorldPtr gw ) ; +PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ; +void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ; +CTabHandle wxMacCreateColorTable( int numColors ) ; + // A mask is a mono bitmap used for drawing bitmaps // transparently. class WXDLLEXPORT wxMask: public wxObject @@ -54,15 +60,15 @@ public: bool Create(const wxBitmap& bitmap, int paletteIndex); bool Create(const wxBitmap& bitmap); -/* TODO: platform-specific data access // Implementation inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; } inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; } protected: WXHBITMAP m_maskBitmap; -*/ }; +enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict } ; + class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData { friend class WXDLLEXPORT wxBitmap; @@ -81,7 +87,9 @@ public: wxPalette m_bitmapPalette; int m_quality; -/* WXHBITMAP m_hBitmap; TODO: platform-specific handle */ + int m_bitmapType ; + PicHandle m_hPict ; + WXHBITMAP m_hBitmap; wxMask * m_bitmapMask; // Optional mask }; @@ -128,14 +136,11 @@ public: // Initialize with raw data. wxBitmap(const char bits[], int width, int height, int depth = 1); -/* TODO: maybe implement XPM reading // Initialize with XPM data wxBitmap(const char **data); -*/ // Load a file or resource - // TODO: make default type whatever's appropriate for the platform. - wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_BMP_RESOURCE); + wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_PICT_RESOURCE); // Constructor for generalised creation from data wxBitmap(void *data, long type, int width, int height, int depth = 1); @@ -184,14 +189,11 @@ public: protected: static wxList sm_handlers; -/* // TODO: Implementation public: void SetHBITMAP(WXHBITMAP bmp); inline WXHBITMAP GetHBITMAP() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hBitmap : 0); } bool FreeResource(bool force = FALSE); -*/ - }; #endif // _WX_BITMAP_H_ diff --git a/include/wx/mac/bmpbuttn.h b/include/wx/mac/bmpbuttn.h index defe39e438..8c0ec5efae 100644 --- a/include/wx/mac/bmpbuttn.h +++ b/include/wx/mac/bmpbuttn.h @@ -47,6 +47,8 @@ class WXDLLEXPORT wxBitmapButton: public wxButton SetBitmapLabel(bitmap); } + virtual void SetLabel( const wxString &name ) {} + virtual void SetBitmapLabel(const wxBitmap& bitmap); inline wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_buttonBitmap; } diff --git a/include/wx/mac/button.h b/include/wx/mac/button.h index 68b67d8c96..3f4d688452 100644 --- a/include/wx/mac/button.h +++ b/include/wx/mac/button.h @@ -42,10 +42,8 @@ class WXDLLEXPORT wxButton: public wxControl const wxValidator& validator = wxDefaultValidator, const wxString& name = wxButtonNameStr); - virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); + virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; virtual void SetDefault(); - virtual void SetLabel(const wxString& label); - virtual wxString GetLabel() const ; virtual void Command(wxCommandEvent& event); }; diff --git a/include/wx/mac/checkbox.h b/include/wx/mac/checkbox.h index 8bf41d9958..94a2fdceeb 100644 --- a/include/wx/mac/checkbox.h +++ b/include/wx/mac/checkbox.h @@ -44,8 +44,7 @@ class WXDLLEXPORT wxCheckBox: public wxControl const wxString& name = wxCheckBoxNameStr); virtual void SetValue(bool); virtual bool GetValue() const ; - virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - virtual void SetLabel(const wxString& label); + virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; virtual void Command(wxCommandEvent& event); }; @@ -76,6 +75,7 @@ class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox virtual bool GetValue() const ; virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); virtual void SetLabel(const wxBitmap *bitmap); + virtual void SetLabel( const wxString &name ) {} }; #endif // _WX_CHECKBOX_H_ diff --git a/include/wx/mac/choice.h b/include/wx/mac/choice.h index 7f360ed5cc..4682944941 100644 --- a/include/wx/mac/choice.h +++ b/include/wx/mac/choice.h @@ -63,9 +63,11 @@ class WXDLLEXPORT wxChoice: public wxControl virtual inline void SetColumns(int WXUNUSED(n) = 1 ) { /* No effect */ } ; virtual inline int GetColumns() const { return 1 ; }; + void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; protected: int m_noStrings; + MenuHandle m_macPopUpMenuHandle ; }; #endif diff --git a/include/wx/mac/clipbrd.h b/include/wx/mac/clipbrd.h index 697dc9d939..4d3658ed3c 100644 --- a/include/wx/mac/clipbrd.h +++ b/include/wx/mac/clipbrd.h @@ -24,17 +24,6 @@ #include "wx/list.h" -bool WXDLLEXPORT wxOpenClipboard(); -bool WXDLLEXPORT wxClipboardOpen(); -bool WXDLLEXPORT wxCloseClipboard(); -bool WXDLLEXPORT wxEmptyClipboard(); -bool WXDLLEXPORT wxIsClipboardFormatAvailable(int dataFormat); -bool WXDLLEXPORT wxSetClipboardData(int dataFormat, wxObject *obj, int width = 0, int height = 0); -wxObject* WXDLLEXPORT wxGetClipboardData(int dataFormat, long *len = NULL); -int WXDLLEXPORT wxEnumClipboardFormats(int dataFormat); -int WXDLLEXPORT wxRegisterClipboardFormat(char *formatName); -bool WXDLLEXPORT wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount); - /* A clipboard client holds data belonging to the clipboard. For plain text, a client is not necessary. */ class WXDLLEXPORT wxClipboardClient : public wxObject diff --git a/include/wx/mac/colour.h b/include/wx/mac/colour.h index 16ffdac9aa..407c0140ca 100644 --- a/include/wx/mac/colour.h +++ b/include/wx/mac/colour.h @@ -74,9 +74,7 @@ public: void InitFromName(const wxString& col); -/* TODO - WXCOLORREF GetPixel() const { return m_pixel; }; -*/ + const WXCOLORREF GetPixel() const { return m_pixel; }; private: bool m_isInit; @@ -85,9 +83,8 @@ private: unsigned char m_green; public: - /* TODO: implementation - WXCOLORREF m_pixel ; - */ + WXCOLORREF m_pixel ; + void Set( WXCOLORREF color ) { m_pixel = color ; m_red = m_pixel.red>>8 ;m_blue = m_pixel.blue>>8 ;m_green = m_pixel.green>>8 ;} private: DECLARE_DYNAMIC_CLASS(wxColour) diff --git a/include/wx/mac/combobox.h b/include/wx/mac/combobox.h index 07054af74e..6fda37448e 100644 --- a/include/wx/mac/combobox.h +++ b/include/wx/mac/combobox.h @@ -78,6 +78,10 @@ class WXDLLEXPORT wxComboBox: public wxChoice virtual void Remove(long from, long to); virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); + void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; +protected: + int m_noStrings; + MenuHandle m_macPopUpMenuHandle ; }; #endif diff --git a/include/wx/mac/control.h b/include/wx/mac/control.h index c75756a72a..7d8f6d185d 100644 --- a/include/wx/mac/control.h +++ b/include/wx/mac/control.h @@ -16,35 +16,77 @@ #pragma interface "control.h" #endif -#include "wx/window.h" -#include "wx/list.h" -#include "wx/validate.h" - // General item class -class WXDLLEXPORT wxControl: public wxWindow +class WXDLLEXPORT wxControl : public wxControlBase { - DECLARE_ABSTRACT_CLASS(wxControl) + DECLARE_ABSTRACT_CLASS(wxControl) + public: wxControl(); - ~wxControl(); + virtual ~wxControl(); + + // Simulates an event + virtual void Command(wxCommandEvent& event) { ProcessCommand(event); } + + // implementation from now on + // -------------------------- + + // Calls the callback and appropriate event handlers + bool ProcessCommand(wxCommandEvent& event); + + + wxList& GetSubcontrols() { return m_subControls; } + + void OnEraseBackground(wxEraseEvent& event); + +#if WXWIN_COMPATIBILITY + virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { } + wxColour* GetButtonColour() const { return NULL; } - virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; // Simulates an event - virtual void ProcessCommand(wxCommandEvent& event); // Calls the callback and - // appropriate event handlers - virtual void SetLabel(const wxString& label); - virtual wxString GetLabel() const ; + inline virtual void SetLabelFont(const wxFont& font); + inline virtual void SetButtonFont(const wxFont& font); + inline wxFont& GetLabelFont() const; + inline wxFont& GetButtonFont() const; - // Places item in centre of panel - so can't be used BEFORE panel->Fit() - void Centre(int direction = wxHORIZONTAL); - inline void Callback(const wxFunction function) { m_callback = function; }; // Adds callback + // Adds callback + inline void Callback(const wxFunction function); - inline wxFunction GetCallback() { return m_callback; } + wxFunction GetCallback() { return m_callback; } protected: wxFunction m_callback; // Callback associated with the window +#endif // WXWIN_COMPATIBILITY -DECLARE_EVENT_TABLE() +protected: + // For controls like radiobuttons which are really composite + wxList m_subControls; + + virtual wxSize DoGetBestSize(); + + // create the control of the given class with the given style, returns FALSE + // if creation failed + bool MSWCreateControl(const wxChar *classname, WXDWORD style); + + // determine the extended styles combination for this window (may slightly + // modify styl parameter) + WXDWORD GetExStyle(WXDWORD& style) const; + +private: + DECLARE_EVENT_TABLE() }; + +#if WXWIN_COMPATIBILITY + inline void wxControl::Callback(const wxFunction f) { m_callback = f; }; + inline wxFont& wxControl::GetLabelFont() const { return GetFont(); } + inline wxFont& wxControl::GetButtonFont() const { return GetFont(); } + inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); } + inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); } +#endif // WXWIN_COMPATIBILITY + +wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ; +void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control) ; +void wxRemoveMacControlAssociation(wxControl *control) ; + #endif // _WX_CONTROL_H_ diff --git a/include/wx/mac/cursor.h b/include/wx/mac/cursor.h index bc6397069f..2500050091 100644 --- a/include/wx/mac/cursor.h +++ b/include/wx/mac/cursor.h @@ -27,9 +27,7 @@ public: ~wxCursorRefData(); protected: -/* TODO: implementation WXHCURSOR m_hCursor; -*/ }; #define M_CURSORDATA ((wxCursorRefData *)m_refData) @@ -49,24 +47,22 @@ public: wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1, const char maskBits[] = NULL); - /* TODO: make default type suit platform */ - wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_CUR_RESOURCE, + wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_MACCURSOR_RESOURCE, int hotSpotX = 0, int hotSpotY = 0); wxCursor(int cursor_type); ~wxCursor(); - // TODO: also verify the internal cursor handle - virtual bool Ok() const { return (m_refData != NULL) ; } + virtual bool Ok() const { return (m_refData != NULL && M_CURSORDATA->m_hCursor != NULL ) ; } inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; } inline bool operator == (const wxCursor& cursor) { return m_refData == cursor.m_refData; } inline bool operator != (const wxCursor& cursor) { return m_refData != cursor.m_refData; } -/* TODO: implementation + void MacInstall() const ; + void SetHCURSOR(WXHCURSOR cursor); inline WXHCURSOR GetHCURSOR() const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); } -*/ }; extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor); diff --git a/include/wx/mac/dc.h b/include/wx/mac/dc.h index ce3e9998d1..a685c9a576 100644 --- a/include/wx/mac/dc.h +++ b/include/wx/mac/dc.h @@ -61,53 +61,53 @@ class WXDLLEXPORT wxDC: public wxObject virtual bool Ok(void) const { return m_ok; }; - virtual void FloodFill( long x1, long y1, const wxColour& col, int style=wxFLOOD_SURFACE ) = 0; + virtual void FloodFill( long x1, long y1, const wxColour& col, int style=wxFLOOD_SURFACE ); inline void FloodFill(const wxPoint& pt, const wxColour& col, int style=wxFLOOD_SURFACE) { FloodFill(pt.x, pt.y, col, style); } - virtual bool GetPixel( long x1, long y1, wxColour *col ) const = 0; + virtual bool GetPixel( long x1, long y1, wxColour *col ) const ; inline bool GetPixel(const wxPoint& pt, wxColour *col) const { return GetPixel(pt.x, pt.y, col); } - virtual void DrawLine( long x1, long y1, long x2, long y2 ) = 0; + virtual void DrawLine( long x1, long y1, long x2, long y2 ); inline void DrawLine(const wxPoint& pt1, const wxPoint& pt2) { DrawLine(pt1.x, pt1.y, pt2.x, pt2.y); } - virtual void CrossHair( long x, long y ) = 0; + virtual void CrossHair( long x, long y ); inline void CrossHair(const wxPoint& pt) { CrossHair(pt.x, pt.y); } - virtual void DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) = 0; + virtual void DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ); inline void DrawArc(const wxPoint& pt1, const wxPoint& pt2, const wxPoint& centre) { DrawArc(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y); } - virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) = 0; + virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ); virtual void DrawEllipticArc (const wxPoint& pt, const wxSize& sz, double sa, double ea) { DrawEllipticArc(pt.x, pt.y, sz.x, sz.y, sa, ea); } - virtual void DrawPoint( long x, long y ) = 0; + virtual void DrawPoint( long x, long y ); virtual void DrawPoint( wxPoint& point ); - virtual void DrawLines( int n, wxPoint points[], long xoffset = 0, long yoffset = 0 ) = 0; + virtual void DrawLines( int n, wxPoint points[], long xoffset = 0, long yoffset = 0 ); virtual void DrawLines( wxList *points, long xoffset = 0, long yoffset = 0 ); virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, - int fillStyle=wxODDEVEN_RULE ) = 0; + int fillStyle=wxODDEVEN_RULE ); virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, int fillStyle=wxODDEVEN_RULE ); - virtual void DrawRectangle( long x, long y, long width, long height ) = 0; + virtual void DrawRectangle( long x, long y, long width, long height ); inline void DrawRectangle(const wxPoint& pt, const wxSize& sz) { DrawRectangle(pt.x, pt.y, sz.x, sz.y); @@ -116,7 +116,7 @@ class WXDLLEXPORT wxDC: public wxObject { DrawRectangle(rect.x, rect.y, rect.width, rect.height); } - virtual void DrawRoundedRectangle( long x, long y, long width, long height, double radius = 20.0 ) = 0; + virtual void DrawRoundedRectangle( long x, long y, long width, long height, double radius = 20.0 ); inline void DrawRoundedRectangle(const wxPoint& pt, const wxSize& sz, double radius = 20.0) { DrawRoundedRectangle(pt.x, pt.y, sz.x, sz.y, radius); @@ -126,7 +126,7 @@ class WXDLLEXPORT wxDC: public wxObject DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, radius); } - virtual void DrawEllipse( long x, long y, long width, long height ) = 0; + virtual void DrawEllipse( long x, long y, long width, long height ); inline void DrawEllipse(const wxPoint& pt, const wxSize& sz) { DrawEllipse(pt.x, pt.y, sz.x, sz.y); @@ -137,10 +137,10 @@ class WXDLLEXPORT wxDC: public wxObject } virtual void DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 ); - virtual void DrawSpline( wxList *points ) = 0; + virtual void DrawSpline( wxList *points ); virtual void DrawSpline( int n, wxPoint points[] ); - virtual bool CanDrawBitmap(void) const = 0; + virtual bool CanDrawBitmap(void) const ; virtual void DrawIcon( const wxIcon &icon, long x, long y, bool useMask=FALSE ); inline void DrawIcon(const wxIcon& icon, const wxPoint& pt) @@ -148,47 +148,44 @@ class WXDLLEXPORT wxDC: public wxObject DrawIcon(icon, pt.x, pt.y); } - // TODO DrawBitmap is not always the same as DrawIcon, especially if bitmaps and - // icons are implemented differently. - void DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask=FALSE ) - { DrawIcon( *((wxIcon*)(&bmp)), x, y, useMask ); } + void DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask=FALSE ) ; virtual bool Blit( long xdest, long ydest, long width, long height, - wxDC *source, long xsrc, long ysrc, int logical_func = wxCOPY, bool useMask=FALSE ) = 0; + wxDC *source, long xsrc, long ysrc, int logical_func = wxCOPY, bool useMask=FALSE ); inline bool Blit(const wxPoint& destPt, const wxSize& sz, wxDC *source, const wxPoint& srcPt, int rop = wxCOPY, bool useMask = FALSE) { return Blit(destPt.x, destPt.y, sz.x, sz.y, source, srcPt.x, srcPt.y, rop, useMask); } - virtual void DrawText( const wxString &text, long x, long y, bool use16 = FALSE ) = 0; + virtual void DrawText( const wxString &text, long x, long y, bool use16 = FALSE ); inline void DrawText(const wxString& text, const wxPoint& pt, bool use16bit = FALSE) { DrawText(text, pt.x, pt.y, use16bit); } - virtual bool CanGetTextExtent(void) const = 0; + virtual bool CanGetTextExtent(void) const ; virtual void GetTextExtent( const wxString &string, long *width, long *height, long *descent = NULL, long *externalLeading = NULL, - wxFont *theFont = NULL, bool use16 = FALSE ) = 0; - virtual long GetCharWidth(void) = 0; - virtual long GetCharHeight(void) = 0; + wxFont *theFont = NULL, bool use16 = FALSE ) const ; + virtual long GetCharWidth(void); + virtual long GetCharHeight(void); - virtual void Clear(void) = 0; + virtual void Clear(void); - virtual void SetFont( const wxFont &font ) = 0; + virtual void SetFont( const wxFont &font ); virtual wxFont& GetFont(void) const { return (wxFont&) m_font; }; - virtual void SetPen( const wxPen &pen ) = 0; + virtual void SetPen( const wxPen &pen ); virtual wxPen& GetPen(void) const { return (wxPen&) m_pen; }; - virtual void SetBrush( const wxBrush &brush ) = 0; + virtual void SetBrush( const wxBrush &brush ); virtual wxBrush& GetBrush(void) const { return (wxBrush&) m_brush; }; - virtual void SetBackground( const wxBrush &brush ) = 0; + virtual void SetBackground( const wxBrush &brush ); virtual wxBrush& GetBackground(void) const { return (wxBrush&) m_backgroundBrush; }; - virtual void SetLogicalFunction( int function ) = 0; + virtual void SetLogicalFunction( int function ); virtual int GetLogicalFunction(void) const { return m_logicalFunction; }; virtual void SetTextForeground( const wxColour &col ); @@ -196,10 +193,10 @@ class WXDLLEXPORT wxDC: public wxObject virtual wxColour& GetTextBackground(void) const { return (wxColour&)m_textBackgroundColour; }; virtual wxColour& GetTextForeground(void) const { return (wxColour&)m_textForegroundColour; }; - virtual void SetBackgroundMode( int mode ) = 0; + virtual void SetBackgroundMode( int mode ); virtual int GetBackgroundMode(void) const { return m_backgroundMode; }; - virtual void SetPalette( const wxPalette& palette ) = 0; + virtual void SetPalette( const wxPalette& palette ); void SetColourMap( const wxPalette& palette ) { SetPalette(palette); }; // the first two must be overridden and called @@ -368,6 +365,30 @@ class WXDLLEXPORT wxDC: public wxObject long m_clipX1,m_clipY1,m_clipX2,m_clipY2; long m_minX,m_maxX,m_minY,m_maxY; + +//begin wxmac + GrafPtr m_macPort ; + + // in order to preserve the const inheritance of the virtual functions, we have to + // use mutable variables starting from CWPro 5 + + void MacInstallFont() const ; + void MacInstallPen() const ; + void MacInstallBrush() const ; + + mutable bool m_macFontInstalled ; + mutable bool m_macPenInstalled ; + mutable bool m_macBrushInstalled ; + + mutable long m_macPortId ; + GrafPtr m_macOrigPort ; + Rect m_macClipRect ; + Point m_macLocalOrigin ; + + void MacSetupPort() const ; + void MacVerifySetup() const { if ( m_macPortId != m_macCurrentPortId ) MacSetupPort() ; } + + static long m_macCurrentPortId ; }; #endif diff --git a/include/wx/mac/dcclient.h b/include/wx/mac/dcclient.h index 29e4e6f7a0..c2a118c6a1 100644 --- a/include/wx/mac/dcclient.h +++ b/include/wx/mac/dcclient.h @@ -25,100 +25,44 @@ class WXDLLEXPORT wxPaintDC; class WXDLLEXPORT wxWindow; -// Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented differently. -// On many platforms, however, they will be the same. - class WXDLLEXPORT wxWindowDC: public wxDC { DECLARE_DYNAMIC_CLASS(wxWindowDC) - public: - - wxWindowDC(void); - wxWindowDC( wxWindow *win ); - - ~wxWindowDC(void); - - virtual void FloodFill( long x1, long y1, const wxColour& col, int style=wxFLOOD_SURFACE ); - virtual bool GetPixel( long x1, long y1, wxColour *col ) const; - - virtual void DrawLine( long x1, long y1, long x2, long y2 ); - virtual void CrossHair( long x, long y ); - virtual void DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ); - virtual void DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ); - virtual void DrawPoint( long x, long y ); - - virtual void DrawLines( int n, wxPoint points[], long xoffset = 0, long yoffset = 0 ); - virtual void DrawLines( wxList *points, long xoffset = 0, long yoffset = 0 ); - virtual void DrawPolygon( int n, wxPoint points[], long xoffset = 0, long yoffset = 0, - int fillStyle=wxODDEVEN_RULE ); - virtual void DrawPolygon( wxList *lines, long xoffset = 0, long yoffset = 0, - int fillStyle=wxODDEVEN_RULE ); - - virtual void DrawRectangle( long x, long y, long width, long height ); - virtual void DrawRoundedRectangle( long x, long y, long width, long height, double radius = 20.0 ); - virtual void DrawEllipse( long x, long y, long width, long height ); - - virtual bool CanDrawBitmap(void) const; - virtual void DrawIcon( const wxIcon &icon, long x, long y, bool useMask=FALSE ); - virtual bool Blit( long xdest, long ydest, long width, long height, - wxDC *source, long xsrc, long ysrc, int logical_func = wxCOPY, bool useMask=FALSE ); - - virtual void DrawText( const wxString &text, long x, long y, bool use16 = FALSE ); - virtual bool CanGetTextExtent(void) const; - virtual void GetTextExtent( const wxString &string, long *width, long *height, - long *descent = NULL, long *externalLeading = NULL, - wxFont *theFont = NULL, bool use16 = FALSE ); - virtual long GetCharWidth(void); - virtual long GetCharHeight(void); - - virtual void Clear(void); - - virtual void SetFont( const wxFont &font ); - virtual void SetPen( const wxPen &pen ); - virtual void SetBrush( const wxBrush &brush ); - virtual void SetBackground( const wxBrush &brush ); - virtual void SetLogicalFunction( int function ); - virtual void SetTextForeground( const wxColour &col ); - virtual void SetTextBackground( const wxColour &col ); - virtual void SetBackgroundMode( int mode ); - virtual void SetPalette( const wxPalette& palette ); - - virtual void SetClippingRegion( long x, long y, long width, long height ); - virtual void SetClippingRegion( const wxRegion& region ) ; - virtual void DestroyClippingRegion(void); - - virtual void DrawSpline( wxList *points ); + public: + wxWindowDC(void); + + // Create a DC corresponding to a canvas + wxWindowDC(wxWindow *win); + + ~wxWindowDC(void); }; -//----------------------------------------------------------------------------- -// wxPaintDC -//----------------------------------------------------------------------------- -class WXDLLEXPORT wxPaintDC: public wxWindowDC +class WXDLLEXPORT wxClientDC: public wxWindowDC { - DECLARE_DYNAMIC_CLASS(wxPaintDC) + DECLARE_DYNAMIC_CLASS(wxClientDC) - public: + public: + wxClientDC(void); - wxPaintDC(void):wxWindowDC() {}; - wxPaintDC( wxWindow *win ): wxWindowDC(win) {}; + // Create a DC corresponding to a canvas + wxClientDC(wxWindow *win); + ~wxClientDC(void); }; -//----------------------------------------------------------------------------- -// wxClientDC -//----------------------------------------------------------------------------- - -class WXDLLEXPORT wxClientDC: public wxWindowDC +class WXDLLEXPORT wxPaintDC: public wxWindowDC { - DECLARE_DYNAMIC_CLASS(wxClientDC) + DECLARE_DYNAMIC_CLASS(wxPaintDC) - public: + public: + wxPaintDC(void); - wxClientDC(void):wxWindowDC() {}; - wxClientDC( wxWindow *win ): wxWindowDC(win) {}; + // Create a DC corresponding to a canvas + wxPaintDC(wxWindow *win); + ~wxPaintDC(void); }; #endif diff --git a/include/wx/mac/dcmemory.h b/include/wx/mac/dcmemory.h index c6c5737642..642ae88afd 100644 --- a/include/wx/mac/dcmemory.h +++ b/include/wx/mac/dcmemory.h @@ -28,9 +28,8 @@ class WXDLLEXPORT wxMemoryDC: public wxPaintDC ~wxMemoryDC(void); virtual void SelectObject( const wxBitmap& bitmap ); void GetSize( int *width, int *height ) const; - + wxBitmap GetSelectedObject() { return m_selected ; } private: - friend wxPaintDC; wxBitmap m_selected; }; diff --git a/include/wx/mac/dcprint.h b/include/wx/mac/dcprint.h index 2ea66d15bf..07f876fc85 100644 --- a/include/wx/mac/dcprint.h +++ b/include/wx/mac/dcprint.h @@ -17,6 +17,7 @@ #endif #include "wx/dc.h" +#include "wx/cmndata.h" class WXDLLEXPORT wxPrinterDC: public wxDC { @@ -24,9 +25,16 @@ class WXDLLEXPORT wxPrinterDC: public wxDC DECLARE_CLASS(wxPrinterDC) // Create a printer DC - wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT); - + wxPrinterDC(const wxPrintData& printdata ); ~wxPrinterDC(); + + virtual bool StartDoc( const wxString& WXUNUSED(message) ) ; + virtual void EndDoc(void) ; + virtual void StartPage(void) ; + virtual void EndPage(void) ; + protected : + TPPrPort m_macPrintPort ; + wxPrintData m_printData ; }; #endif diff --git a/include/wx/mac/dialog.h b/include/wx/mac/dialog.h index d68cc7c9a0..0b595e9c9d 100644 --- a/include/wx/mac/dialog.h +++ b/include/wx/mac/dialog.h @@ -60,23 +60,17 @@ public: ~wxDialog(); virtual bool Destroy(); - void SetClientSize(int width, int height); - void GetPosition(int *x, int *y) const; bool Show(bool show); - void Iconize(bool iconize); - - virtual bool IsIconized() const; void Fit(); - void SetTitle(const wxString& title); - wxString GetTitle() const ; + void Iconize(bool iconize); + virtual bool IsIconized() const; void OnCharHook(wxKeyEvent& event); void OnCloseWindow(wxCloseEvent& event); void SetModal(bool flag); - virtual void Centre(int direction = wxBOTH); virtual bool IsModal() const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); } virtual int ShowModal(); @@ -87,9 +81,17 @@ public: void OnApply(wxCommandEvent& event); void OnCancel(wxCommandEvent& event); + void OnSize(wxSizeEvent& event) ; // Responds to colour changes void OnSysColourChanged(wxSysColourChangedEvent& event); + // splits text up at newlines and places the + // lines into a vertical wxBoxSizer + wxSizer *CreateTextSizer( const wxString &message ); + + // places buttons into a horizontal wxBoxSizer + wxSizer *CreateButtonSizer( long flags ); + DECLARE_EVENT_TABLE() }; diff --git a/include/wx/mac/dnd.h b/include/wx/mac/dnd.h index 5a7a65335f..e3a149ed85 100644 --- a/include/wx/mac/dnd.h +++ b/include/wx/mac/dnd.h @@ -155,7 +155,7 @@ class WXDLLEXPORT wxDropTarget: public wxObject // protected: - friend wxWindow; + friend class wxWindow; // Override these to indicate what kind of data you support: diff --git a/include/wx/mac/font.h b/include/wx/mac/font.h index aff8fb3a75..f7596f241b 100644 --- a/include/wx/mac/font.h +++ b/include/wx/mac/font.h @@ -1,88 +1,105 @@ ///////////////////////////////////////////////////////////////////////////// // Name: font.h // Purpose: wxFont class -// Author: AUTHOR +// Author: Julian Smart // Modified by: -// Created: ??/??/98 +// Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_FONT_H_ #define _WX_FONT_H_ #ifdef __GNUG__ -#pragma interface "font.h" + #pragma interface "font.h" #endif -#include "wx/gdiobj.h" +// ---------------------------------------------------------------------------- +// public functions +// ---------------------------------------------------------------------------- -class WXDLLEXPORT wxFont; +// convert wxFontEncoding into one of Windows XXX_CHARSET constants (fill exact +// parameter if it's not NULL with TRUE if encoding is realyl supported under +// Windows and FALSE if not and we just chose something close to it) +extern int wxCharsetFromEncoding(wxFontEncoding encoding, bool *exact = NULL); -class WXDLLEXPORT wxFontRefData: public wxGDIRefData +// ---------------------------------------------------------------------------- +// wxFont +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxFont : public wxFontBase { - friend class WXDLLEXPORT wxFont; public: - wxFontRefData(); - wxFontRefData(const wxFontRefData& data); - ~wxFontRefData(); -protected: - int m_pointSize; - int m_family; - int m_style; - int m_weight; - bool m_underlined; - wxString m_faceName; -/* TODO: implementation - WXHFONT m_hFont; -*/ -}; + // ctors and such + wxFont() { Init(); } + wxFont(const wxFont& font) { Init(); Ref(font); } + + wxFont(int size, + int family, + int style, + int weight, + bool underlined = FALSE, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + { + Init(); + + (void)Create(size, family, style, weight, underlined, face, encoding); + } + + bool Create(int size, + int family, + int style, + int weight, + bool underlined = FALSE, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + + virtual ~wxFont(); + + // assignment + wxFont& operator=(const wxFont& font); + + // implement base class pure virtuals + virtual int GetPointSize() const; + virtual int GetFamily() const; + virtual int GetStyle() const; + virtual int GetWeight() const; + virtual bool GetUnderlined() const; + virtual wxString GetFaceName() const; + virtual wxFontEncoding GetEncoding() const; + + virtual void SetPointSize(int pointSize); + virtual void SetFamily(int family); + virtual void SetStyle(int style); + virtual void SetWeight(int weight); + virtual void SetFaceName(const wxString& faceName); + virtual void SetUnderlined(bool underlined); + virtual void SetEncoding(wxFontEncoding encoding); + + // implementation only from now on + // ------------------------------- + + int GetFontId() const; + virtual bool IsFree() const; + virtual bool RealizeResource(); + virtual WXHANDLE GetResourceHandle(); + virtual bool FreeResource(bool force = FALSE); + /* + virtual bool UseResource(); + virtual bool ReleaseResource(); + */ -#define M_FONTDATA ((wxFontRefData *)m_refData) +protected: + // common part of all ctors + void Init(); -WXDLLEXPORT_DATA(extern const char*) wxEmptyString; + void Unshare(); -// Font -class WXDLLEXPORT wxFont: public wxGDIObject -{ - DECLARE_DYNAMIC_CLASS(wxFont) -public: - wxFont(); - wxFont(int pointSize, int family, int style, int weight, bool underlined = FALSE, const wxString& faceName = wxEmptyString); - inline wxFont(const wxFont& font) { Ref(font); } - - ~wxFont(); - - bool Create(int pointSize, int family, int style, int weight, bool underlined = FALSE, const wxString& faceName = wxEmptyString); - - virtual bool Ok() const { return (m_refData != NULL) ; } - - inline int GetPointSize() const { return M_FONTDATA->m_pointSize; } - inline int GetFamily() const { return M_FONTDATA->m_family; } - inline int GetStyle() const { return M_FONTDATA->m_style; } - inline int GetWeight() const { return M_FONTDATA->m_weight; } - wxString GetFamilyString() const ; - wxString GetFaceName() const ; - wxString GetStyleString() const ; - wxString GetWeightString() const ; - inline bool GetUnderlined() const { return M_FONTDATA->m_underlined; } - - void SetPointSize(int pointSize); - void SetFamily(int family); - void SetStyle(int style); - void SetWeight(int weight); - void SetFaceName(const wxString& faceName); - void SetUnderlined(bool underlined); - - inline wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; } - inline bool operator == (const wxFont& font) { return m_refData == font.m_refData; } - inline bool operator != (const wxFont& font) { return m_refData != font.m_refData; } - - // Implementation -protected: - bool RealizeResource(); - void Unshare(); +private: + DECLARE_DYNAMIC_CLASS(wxFont) }; #endif diff --git a/include/wx/mac/frame.h b/include/wx/mac/frame.h index 64ec0d6cd1..ae5e085877 100644 --- a/include/wx/mac/frame.h +++ b/include/wx/mac/frame.h @@ -19,12 +19,14 @@ #include "wx/window.h" #include "wx/toolbar.h" #include "wx/accel.h" +#include "wx/icon.h" WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; class WXDLLEXPORT wxMenuBar; class WXDLLEXPORT wxStatusBar; +class WXDLLEXPORT wxMacToolTip ; class WXDLLEXPORT wxFrame: public wxWindow { @@ -54,14 +56,6 @@ public: const wxString& name = wxFrameNameStr); virtual bool Destroy(); - void SetClientSize(int width, int height); - void GetClientSize(int *width, int *height) const; - - void GetSize(int *width, int *height) const ; - void GetPosition(int *x, int *y) const ; - void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - void ClientToScreen(int *x, int *y) const; - void ScreenToClient(int *x, int *y) const; void OnSize(wxSizeEvent& event); void OnMenuHighlight(wxMenuEvent& event); @@ -69,18 +63,10 @@ public: void OnIdle(wxIdleEvent& event); void OnCloseWindow(wxCloseEvent& event); - bool Show(bool show); - // Set menu bar void SetMenuBar(wxMenuBar *menu_bar); virtual wxMenuBar *GetMenuBar() const ; - // Set title - void SetTitle(const wxString& title); - wxString GetTitle() const ; - - void Centre(int direction = wxBOTH); - // Call this to simulate a menu command virtual void Command(int id); virtual void ProcessCommand(int id); @@ -96,6 +82,8 @@ public: virtual wxStatusBar *OnCreateStatusBar(int number, long style, wxWindowID id, const wxString& name); +#if wxUSE_TOOLBAR + // Create toolbar virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr); virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name); @@ -104,6 +92,8 @@ public: virtual inline wxToolBar *GetToolBar() const { return m_frameToolBar; } virtual void PositionToolBar(); +#endif + // Set status line text virtual void SetStatusText(const wxString& text, int number = 0); @@ -136,10 +126,18 @@ public: // Query app for menu item updates (called from OnIdle) void DoMenuUpdates(); - void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin); + void DoMenuUpdates(wxMenu* menu); // Checks if there is a toolbar, and returns the first free client position virtual wxPoint GetClientAreaOrigin() const; + virtual void GetClientSize(int *x, int *y) const ; + virtual void DoSetClientSize(int clientwidth, int clientheight) ; + + // tooltip management +#if wxUSE_TOOLTIPS + wxMacToolTip* GetToolTipCtrl() const { return m_hwndToolTip; } + void SetToolTipCtrl(wxMacToolTip *tt) { m_hwndToolTip = wxMacToolTip; } +#endif // tooltips protected: wxMenuBar * m_frameMenuBar; @@ -147,7 +145,9 @@ protected: wxIcon m_icon; bool m_iconized; static bool m_useNativeStatusBar; +#if wxUSE_TOOLBAR wxToolBar * m_frameToolBar ; +#endif DECLARE_EVENT_TABLE() }; diff --git a/include/wx/mac/gauge.h b/include/wx/mac/gauge.h index ce19d9ef1f..b88f5187a7 100644 --- a/include/wx/mac/gauge.h +++ b/include/wx/mac/gauge.h @@ -56,8 +56,6 @@ class WXDLLEXPORT wxGauge: public wxControl int GetRange() const ; int GetValue() const ; - void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ; protected: diff --git a/include/wx/mac/icon.h b/include/wx/mac/icon.h index df475672ba..fed25013ff 100644 --- a/include/wx/mac/icon.h +++ b/include/wx/mac/icon.h @@ -27,9 +27,7 @@ public: ~wxIconRefData(); public: -/* TODO: whatever your actual icon handle is WXHICON m_hIcon; -*/ }; #define M_ICONDATA ((wxIconRefData *)m_refData) @@ -47,33 +45,31 @@ public: inline wxIcon(const wxIcon& icon) { Ref(icon); } wxIcon(const char bits[], int width, int height); - wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE, + wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICON_RESOURCE, int desiredWidth = -1, int desiredHeight = -1); ~wxIcon(); - bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_ICO_RESOURCE, - int desiredWidth = -1, int desiredHeight = -1); + bool LoadFile(const wxString& name, long flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ , + int desiredWidth /* = -1 */ , int desiredHeight = -1); + bool LoadFile(const wxString& name ,long flags = wxBITMAP_TYPE_ICON_RESOURCE ) + { 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; } inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; } -/* TODO: implementation void SetHICON(WXHICON ico); inline WXHICON GetHICON() const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); } -*/ -/* TODO */ virtual bool Ok() const { return (m_refData != NULL) ; } }; -/* Example handlers. TODO: write your own handlers for relevant types. - -class WXDLLEXPORT wxICOFileHandler: public wxBitmapHandler +/* +class WXDLLEXPORT wxICONFileHandler: public wxBitmapHandler { - DECLARE_DYNAMIC_CLASS(wxICOFileHandler) + DECLARE_DYNAMIC_CLASS(wxICONFileHandler) public: - inline wxICOFileHandler() + inline wxICONFileHandler() { m_name = "ICO icon file"; m_extension = "ico"; @@ -83,16 +79,17 @@ public: virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, int desiredWidth = -1, int desiredHeight = -1); }; +*/ -class WXDLLEXPORT wxICOResourceHandler: public wxBitmapHandler +class WXDLLEXPORT wxICONResourceHandler: public wxBitmapHandler { - DECLARE_DYNAMIC_CLASS(wxICOResourceHandler) + DECLARE_DYNAMIC_CLASS(wxICONResourceHandler) public: - inline wxICOResourceHandler() + inline wxICONResourceHandler() { - m_name = "ICO resource"; - m_extension = "ico"; - m_type = wxBITMAP_TYPE_ICO_RESOURCE; + m_name = "ICON resource"; + m_extension = ""; + m_type = wxBITMAP_TYPE_ICON_RESOURCE; }; virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, @@ -100,7 +97,5 @@ public: }; -*/ - #endif // _WX_ICON_H_ diff --git a/include/wx/mac/listbox.h b/include/wx/mac/listbox.h index d95db4379b..0ab770ac57 100644 --- a/include/wx/mac/listbox.h +++ b/include/wx/mac/listbox.h @@ -17,6 +17,7 @@ #endif #include "wx/control.h" +#include "wx/dynarray.h" WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr; @@ -26,6 +27,9 @@ class WXDLLEXPORT wxArrayInt; WXDLLEXPORT_DATA(extern const char*) wxEmptyString; // List box item + +WX_DEFINE_ARRAY( char * , wxListDataArray ) ; + class WXDLLEXPORT wxListBox: public wxControl { DECLARE_DYNAMIC_CLASS(wxListBox) @@ -73,7 +77,6 @@ class WXDLLEXPORT wxListBox: public wxControl virtual int GetSelections(wxArrayInt& aSelections) const; virtual bool Selected(int n) const ; virtual wxString GetString(int n) const ; - virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); // Set the specified item at the first visible item // or scroll to max range. @@ -88,9 +91,33 @@ class WXDLLEXPORT wxListBox: public wxControl void Command(wxCommandEvent& event); + void MacSetRedraw( bool doDraw ) ; protected: int m_noItems; int m_selected; + + void MacDestroy() ; + void MacDelete( int n ) ; + void MacInsert( int n , const char * text) ; + void MacAppend( const char * text) ; + void MacSet( int n , const char *text ) ; + void MacClear() ; + void MacSetSelection( int n , bool select ) ; + int MacGetSelection() const ; + int MacGetSelections(wxArrayInt& aSelections) const ; + bool MacIsSelected( int n ) const ; + void MacScrollTo( int n ) ; + void OnSize( const wxSizeEvent &size ) ; + void MacDoClick() ; + void MacDoDoubleClick() ; + + public : + ListHandle m_macList ; + wxArrayString m_stringArray ; + wxListDataArray m_dataArray ; + + virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; +DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/mac/macsock.h b/include/wx/mac/macsock.h index 5703eb5f00..e69de29bb2 100644 --- a/include/wx/mac/macsock.h +++ b/include/wx/mac/macsock.h @@ -1,1058 +0,0 @@ -/********************************************************************* -Project : GUSI - Grand Unified Socket Interface -File : GUSI.h - Socket calls -Author : Matthias Neeracher -Language : MPW C/C++ -*********************************************************************/ - -#ifndef _GUSI_ -#define _GUSI_ - -#ifdef __MWERKS__ - #ifndef macintosh - #define macintosh 1 - #endif -#endif - -#ifdef macintosh -#include -#else -#ifndef KERNEL -extern int errno; /* global error number */ -#endif -#endif - -#define __P(protos) protos /* full-blown ANSI C */ - -#define EPERM 1 /* Operation not permitted */ -/* MSL defines ENOMEM, EACCES, ENOENT, ENOSYS. We give in. */ -#ifndef ENOENT -#define ENOENT 2 /* No such file or directory */ -#endif -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* Input/output error */ -#define ENXIO 6 /* Device not configured */ -#define E2BIG 7 /* Argument list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file descriptor */ -#define ECHILD 10 /* No child processes */ -#define EDEADLK 11 /* Resource deadlock avoided */ - /* 11 was EAGAIN */ -#ifndef ENOMEM -#define ENOMEM 12 /* Cannot allocate memory */ -#define EACCES 13 /* Permission denied */ -#endif -#define EFAULT 14 /* Bad address */ -#ifndef _POSIX_SOURCE -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Device busy */ -#endif -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* Operation not supported by device */ -#define ENOTDIR 20 /* Not a directory */ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* Too many open files in system */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Inappropriate ioctl for device */ -#ifndef _POSIX_SOURCE -#define ETXTBSY 26 /* Text file busy */ -#endif -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read-only file system */ -#define EMLINK 31 /* Too many links */ -#define EPIPE 32 /* Broken pipe */ - -#ifndef __MWERKS__ -/* math software */ -#define EDOM 33 /* Numerical argument out of domain */ -#define ERANGE 34 /* Result too large */ -#endif - -/* non-blocking and interrupt i/o */ -#if defined(macintosh) -#ifndef EAGAIN -#define EAGAIN 11 -#endif -#else -#define EAGAIN 35 /* Resource temporarily unavailable */ -#endif -#define EWOULDBLOCK EAGAIN /* Operation would block */ -#ifndef _POSIX_SOURCE -/* Did I tell that MSL also occupies errnos 33-40? We give in. */ -#if ENOMEM==37 -#define EINPROGRESS 136 /* Operation now in progress */ -#define EALREADY 137 /* Operation already in progress */ - -/* ipc/network software -- argument errors */ -#define ENOTSOCK 138 /* Socket operation on non-socket */ -#define EDESTADDRREQ 139 /* Destination address required */ -#define EMSGSIZE 140 /* Message too long */ -#else -#define EINPROGRESS 36 /* Operation now in progress */ -#define EALREADY 37 /* Operation already in progress */ - -/* ipc/network software -- argument errors */ -#define ENOTSOCK 38 /* Socket operation on non-socket */ -#define EDESTADDRREQ 39 /* Destination address required */ -#define EMSGSIZE 40 /* Message too long */ -#endif -#define EPROTOTYPE 41 /* Protocol wrong type for socket */ -#define ENOPROTOOPT 42 /* Protocol not available */ -#define EPROTONOSUPPORT 43 /* Protocol not supported */ -#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ -#define EOPNOTSUPP 45 /* Operation not supported on socket */ -#define EPFNOSUPPORT 46 /* Protocol family not supported */ -#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ -#define EADDRINUSE 48 /* Address already in use */ -#define EADDRNOTAVAIL 49 /* Can't assign requested address */ - -/* ipc/network software -- operational errors */ -#define ENETDOWN 50 /* Network is down */ -#define ENETUNREACH 51 /* Network is unreachable */ -#define ENETRESET 52 /* Network dropped connection on reset */ -#define ECONNABORTED 53 /* Software caused connection abort */ -#define ECONNRESET 54 /* Connection reset by peer */ -#define ENOBUFS 55 /* No buffer space available */ -#define EISCONN 56 /* Socket is already connected */ -#define ENOTCONN 57 /* Socket is not connected */ -#define ESHUTDOWN 58 /* Can't send after socket shutdown */ -#define ETOOMANYREFS 59 /* Too many references: can't splice */ -#define ETIMEDOUT 60 /* Connection timed out */ -#define ECONNREFUSED 61 /* Connection refused */ - -#define ELOOP 62 /* Too many levels of symbolic links */ -#endif /* _POSIX_SOURCE */ -#define ENAMETOOLONG 63 /* File name too long */ - -/* should be rearranged */ -#ifndef _POSIX_SOURCE -#define EHOSTDOWN 64 /* Host is down */ -#define EHOSTUNREACH 65 /* No route to host */ -#endif /* _POSIX_SOURCE */ -#define ENOTEMPTY 66 /* Directory not empty */ - -/* quotas & mush */ -#ifndef _POSIX_SOURCE -#define EPROCLIM 67 /* Too many processes */ -#define EUSERS 68 /* Too many users */ -#define EDQUOT 69 /* Disc quota exceeded */ - -/* Network File System */ -#define ESTALE 70 /* Stale NFS file handle */ -#define EREMOTE 71 /* Too many levels of remote in path */ -#define EBADRPC 72 /* RPC struct is bad */ -#define ERPCMISMATCH 73 /* RPC version wrong */ -#define EPROGUNAVAIL 74 /* RPC prog. not avail */ -#define EPROGMISMATCH 75 /* Program version wrong */ -#define EPROCUNAVAIL 76 /* Bad procedure for program */ -#endif /* _POSIX_SOURCE */ - -#define ENOLCK 77 /* No locks available */ - -#ifndef ENOSYS -#define ENOSYS 78 /* Function not implemented */ -#endif - -#define EFTYPE 79 /* Inappropriate file type or format */ - -#ifdef KERNEL -/* pseudo-errors returned inside kernel to modify return to process */ -#define ERESTART -1 /* restart syscall */ -#define EJUSTRETURN -2 /* don't modify regs, just return */ -#endif - -#define NBBY 8 /* number of bits in a byte */ - -/* - * Select uses bit masks of file descriptors in longs. These macros - * manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here should - * be enough for most uses. - */ -#ifndef FD_SETSIZE -#ifdef macintosh -#define FD_SETSIZE 64 -#else -#define FD_SETSIZE 256 -#endif -#endif - -typedef long fd_mask; -#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ - -#ifndef howmany -#define howmany(x, y) (((x)+((y)-1))/(y)) -#endif - -typedef struct fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; -} fd_set; - -#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) -#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) - -// #include -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short ushort; /* Sys V compatibility */ - -typedef char * caddr_t; /* core address */ -typedef long daddr_t; /* disk address */ -typedef short dev_t; /* device number */ -typedef u_long ino_t; /* inode number */ -typedef long off_t; /* file offset (should be a quad) */ -typedef u_short nlink_t; /* link count */ -typedef long swblk_t; /* swap offset */ -typedef long segsz_t; /* segment size */ -typedef u_short uid_t; /* user id */ -typedef u_short gid_t; /* group id */ -typedef short pid_t; /* process id */ -typedef u_short mode_t; /* permissions */ -typedef u_long fixpt_t; /* fixed point number */ - - -// Feel free to increase FD_SETSIZE as needed -#define GUSI_MAX_FD FD_SETSIZE - -//#include - -#ifndef macintosh -#ifdef __MWERKS__ -#define macintosh 1 -#endif -#endif - -#if defined(__cplusplus) -#define __BEGIN_DECLS extern "C" { -#define __END_DECLS } -#else -#define __BEGIN_DECLS -#define __END_DECLS -#endif - -//#include -//#include -#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */ -#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) -#define IOCBASECMD(x) ((x) & ~IOCPARM_MASK) -#define IOCGROUP(x) (((x) >> 8) & 0xff) - -#define IOCPARM_MAX NBPG /* max size of ioctl, mult. of NBPG */ -#define IOC_VOID 0x20000000 /* no parameters */ -#define IOC_OUT 0x40000000 /* copy out parameters */ -#define IOC_IN 0x80000000 /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) -#define IOC_DIRMASK 0xe0000000 /* mask for IN/OUT/VOID */ - -#define _IOC(inout,group,num,len) \ - (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)) -#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) -#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) -#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) -/* this should be _IORW, but stdio got there first */ -#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) - -#define FIOCLEX _IO('f', 1) /* set close on exec on fd */ -#define FIONCLEX _IO('f', 2) /* remove close on exec */ -#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ -#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ -#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ -#define FIOSETOWN _IOW('f', 124, int) /* set owner */ -#define FIOGETOWN _IOR('f', 123, int) /* get owner */ - -__BEGIN_DECLS -#ifdef macintosh -int ioctl(int fildes, unsigned int cmd, unsigned long *arg); -#else -int ioctl __P((int, unsigned long, ...)); -#endif -__END_DECLS - -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include - - -/* - * Definitions for byte order, according to byte significance from low - * address to high. - */ -#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ -#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ -#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ - -#define BYTE_ORDER BIG_ENDIAN - -__BEGIN_DECLS -unsigned long htonl (unsigned long); -unsigned short htons (unsigned short); -unsigned long ntohl (unsigned long); -unsigned short ntohs (unsigned short); -__END_DECLS - -/* - * Macros for network/external number representation conversion. - */ -#if BYTE_ORDER == BIG_ENDIAN && !defined(lint) -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) - -#define NTOHL(x) (x) -#define NTOHS(x) (x) -#define HTONL(x) (x) -#define HTONS(x) (x) - -#else - -#define NTOHL(x) (x) = ntohl((u_long)x) -#define NTOHS(x) (x) = ntohs((u_short)x) -#define HTONL(x) (x) = htonl((u_long)x) -#define HTONS(x) (x) = htons((u_short)x) -#endif - - - -/* - * Constants and structures defined by the internet system, - * Per RFC 790, September 1981. - */ - -/* - * Protocols - */ -#define IPPROTO_IP 0 /* dummy for IP */ -#define IPPROTO_ICMP 1 /* control message protocol */ -#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ -#define IPPROTO_TCP 6 /* tcp */ -#define IPPROTO_EGP 8 /* exterior gateway protocol */ -#define IPPROTO_PUP 12 /* pup */ -#define IPPROTO_UDP 17 /* user datagram protocol */ -#define IPPROTO_IDP 22 /* xns idp */ -#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ -#define IPPROTO_EON 80 /* ISO cnlp */ - -#define IPPROTO_RAW 255 /* raw IP packet */ -#define IPPROTO_MAX 256 - - -/* - * Local port number conventions: - * Ports < IPPORT_RESERVED are reserved for - * privileged processes (e.g. root). - * Ports > IPPORT_USERRESERVED are reserved - * for servers, not necessarily privileged. - */ -#define IPPORT_RESERVED 1024 -#define IPPORT_USERRESERVED 5000 - -/* - * Internet address (a structure for historical reasons) - */ -struct in_addr { - u_long s_addr; -}; - -/* - * Definitions of bits in internet address integers. - * On subnets, the decomposition of addresses to host and net parts - * is done according to subnet mask, not the masks here. - */ -#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) -#define IN_CLASSA_NET 0xff000000 -#define IN_CLASSA_NSHIFT 24 -#define IN_CLASSA_HOST 0x00ffffff -#define IN_CLASSA_MAX 128 - -#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) -#define IN_CLASSB_NET 0xffff0000 -#define IN_CLASSB_NSHIFT 16 -#define IN_CLASSB_HOST 0x0000ffff -#define IN_CLASSB_MAX 65536 - -#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) -#define IN_CLASSC_NET 0xffffff00 -#define IN_CLASSC_NSHIFT 8 -#define IN_CLASSC_HOST 0x000000ff - -#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) -#define IN_MULTICAST(i) IN_CLASSD(i) - -#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) -#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) - -#define INADDR_ANY (u_long)0x00000000 -#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ -#ifndef KERNEL -#define INADDR_NONE 0xffffffff /* -1 return */ -#endif - -#define IN_LOOPBACKNET 127 /* official! */ - -/* - * Socket address, internet style. - */ -struct sockaddr_in { - u_char sin_len; - u_char sin_family; - u_short sin_port; - struct in_addr sin_addr; - char sin_zero[8]; -}; - -/* - * Structure used to describe IP options. - * Used to store options internally, to pass them to a process, - * or to restore options retrieved earlier. - * The ip_dst is used for the first-hop gateway when using a source route - * (this gets put into the header proper). - */ -#ifdef __MWERKS__ -#pragma cplusplus off -#endif -struct ip_opts { - struct in_addr ip_dst; /* first hop, 0 w/o src rt */ - char ip_opts[40]; /* actually variable in size */ -}; -#ifdef __MWERKS__ -#pragma cplusplus reset -#endif - -/* - * Options for use with [gs]etsockopt at the IP level. - * First word of comment is data type; bool is stored in int. - */ -#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP per-packet options */ -#define IP_HDRINCL 2 /* int; header is included with data (raw) */ -#define IP_TOS 3 /* int; IP type of service and precedence */ -#define IP_TTL 4 /* int; IP time to live */ -#define IP_RECVOPTS 5 /* bool; receive all IP options w/datagram */ -#define IP_RECVRETOPTS 6 /* bool; receive IP options for response */ -#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/datagram */ -#define IP_RETOPTS 8 /* ip_opts; set/get IP per-packet options */ - -/* - * Structure returned by gettimeofday(2) system call, - * and used in other calls. - */ -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; - -struct timezone { - int tz_minuteswest; /* minutes west of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; -#define DST_NONE 0 /* not on dst */ -#define DST_USA 1 /* USA style dst */ -#define DST_AUST 2 /* Australian style dst */ -#define DST_WET 3 /* Western European dst */ -#define DST_MET 4 /* Middle European dst */ -#define DST_EET 5 /* Eastern European dst */ -#define DST_CAN 6 /* Canada */ -//#include - -/* - * Definitions related to sockets: types, address families, options. - */ - -/* - * Types - */ -#define SOCK_STREAM 1 /* stream socket */ -#define SOCK_DGRAM 2 /* datagram socket */ -#define SOCK_RAW 3 /* raw-protocol interface */ -#define SOCK_RDM 4 /* reliably-delivered message */ -#define SOCK_SEQPACKET 5 /* sequenced packet stream */ - -/* - * Option flags per-socket. - */ -#define SO_DEBUG 0x0001 /* turn on debugging info recording */ -#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ -#define SO_REUSEADDR 0x0004 /* allow local address reuse */ -#define SO_KEEPALIVE 0x0008 /* keep connections alive */ -#define SO_DONTROUTE 0x0010 /* just use interface addresses */ -#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ -#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ -#define SO_LINGER 0x0080 /* linger on close if data present */ -#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ - -/* - * Additional options, not kept in so_options. - */ -#define SO_SNDBUF 0x1001 /* send buffer size */ -#define SO_RCVBUF 0x1002 /* receive buffer size */ -#define SO_SNDLOWAT 0x1003 /* send low-water mark */ -#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ -#define SO_SNDTIMEO 0x1005 /* send timeout */ -#define SO_RCVTIMEO 0x1006 /* receive timeout */ -#define SO_ERROR 0x1007 /* get error status and clear */ -#define SO_TYPE 0x1008 /* get socket type */ - -/* - * Structure used for manipulating linger option. - */ -struct linger { - int l_onoff; /* option on/off */ - int l_linger; /* linger time */ -}; - -/* - * Level number for (get/set)sockopt() to apply to socket itself. - */ -#define SOL_SOCKET 0xffff /* options for socket level */ - -/* - * Address families. - */ -#ifdef macintosh -#define AF_UNSPEC 0 /* unspecified */ -#define AF_UNIX 1 /* local to host (pipes, portals) */ -#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ -#define AF_CTB 3 /* Apple Comm Toolbox (not yet supported) */ -#define AF_FILE 4 /* Normal File I/O (used internally) */ -#define AF_PPC 5 /* PPC Toolbox */ -#define AF_PAP 6 /* Printer Access Protocol (client only) */ -#define AF_APPLETALK 16 /* Apple Talk */ - -#define AF_MAX 20 -#else -#define ATALK_SYMADDR 272 /* Symbolic Address for AppleTalk */ -#define AF_UNSPEC 0 /* unspecified */ -#define AF_UNIX 1 /* local to host (pipes, portals) */ -#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ -#define AF_IMPLINK 3 /* arpanet imp addresses */ -#define AF_PUP 4 /* pup protocols: e.g. BSP */ -#define AF_CHAOS 5 /* mit CHAOS protocols */ -#define AF_NS 6 /* XEROX NS protocols */ -#define AF_ISO 7 /* ISO protocols */ -#define AF_OSI AF_ISO -#define AF_ECMA 8 /* european computer manufacturers */ -#define AF_DATAKIT 9 /* datakit protocols */ -#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ -#define AF_SNA 11 /* IBM SNA */ -#define AF_DECnet 12 /* DECnet */ -#define AF_DLI 13 /* DEC Direct data link interface */ -#define AF_LAT 14 /* LAT */ -#define AF_HYLINK 15 /* NSC Hyperchannel */ -#define AF_APPLETALK16 /* Apple Talk */ -#define AF_ROUTE 17 /* Internal Routing Protocol */ -#define AF_LINK 18 /* Link layer interface */ -#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ - -#define AF_MAX 20 -#endif - -/* - * Structure used by kernel to store most - * addresses. - */ -#if defined(powerc) || defined (__powerc) -#pragma options align=mac68k -#endif -struct sockaddr { - u_char sa_len; /* total length */ - u_char sa_family; /* address family */ - char sa_data[14]; /* actually longer; address value */ -}; -#if defined(powerc) || defined (__powerc) -#pragma options align=reset -#endif - -/* - * Structure used by kernel to pass protocol - * information in raw sockets. - */ -struct sockproto { - u_short sp_family; /* address family */ - u_short sp_protocol; /* protocol */ -}; - -/* - * Protocol families, same as address families for now. - */ -#ifdef macintosh -#define PF_UNSPEC AF_UNSPEC /* unspecified */ -#define PF_UNIX AF_UNIX /* local to host (pipes, portals) */ -#define PF_INET AF_INET /* internetwork: UDP, TCP, etc. */ -#define PF_CTB AF_CTB /* Apple Comm Toolbox (not yet supported) */ -#define PF_FILE AF_FILE /* Normal File I/O (used internally) */ -#define PF_PPC AF_PPC /* PPC Toolbox */ -#define PF_PAP AF_PAP /* Printer Access Protocol (client only) */ -#define PF_APPLETALK AF_APPLETALK /* Apple Talk */ -#else -#define PF_UNSPEC AF_UNSPEC -#define PF_UNIX AF_UNIX -#define PF_INET AF_INET -#define PF_IMPLINK AF_IMPLINK -#define PF_PUP AF_PUP -#define PF_CHAOS AF_CHAOS -#define PF_NS AF_NS -#define PF_ISO AF_ISO -#define PF_OSI AF_ISO -#define PF_ECMA AF_ECMA -#define PF_DATAKIT AF_DATAKIT -#define PF_CCITT AF_CCITT -#define PF_SNA AF_SNA -#define PF_DECnet AF_DECnet -#define PF_DLI AF_DLI -#define PF_LAT AF_LAT -#define PF_HYLINK AF_HYLINK -#define PF_APPLETALK AF_APPLETALK -#define PF_ROUTE AF_ROUTE -#define PF_LINK AF_LINK -#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ -#endif - -#define PF_MAX AF_MAX - -/* - * Maximum queue length specifiable by listen. - */ -#define SOMAXCONN 5 - -/* - * Message header for recvmsg and sendmsg calls. - * Used value-result for recvmsg, value only for sendmsg. - */ -struct msghdr { - caddr_t msg_name; /* optional address */ - u_int msg_namelen; /* size of address */ - struct iovec *msg_iov; /* scatter/gather array */ - u_int msg_iovlen; /* # elements in msg_iov */ - caddr_t msg_control; /* ancillary data, see below */ - u_int msg_controllen; /* ancillary data buffer len */ - int msg_flags; /* flags on received message */ -}; - -#define MSG_OOB 0x1 /* process out-of-band data */ -#define MSG_PEEK 0x2 /* peek at incoming message */ -#define MSG_DONTROUTE 0x4 /* send without using routing tables */ -#define MSG_EOR 0x8 /* data completes record */ -#define MSG_TRUNC 0x10 /* data discarded before delivery */ -#define MSG_CTRUNC 0x20 /* control data lost before delivery */ -#define MSG_WAITALL 0x40 /* wait for full request or error */ - -/* - * Header for ancillary data objects in msg_control buffer. - * Used for additional information with/about a datagram - * not expressible by flags. The format is a sequence - * of message elements headed by cmsghdr structures. - */ -struct cmsghdr { - u_int cmsg_len; /* data byte count, including hdr */ - int cmsg_level; /* originating protocol */ - int cmsg_type; /* protocol-specific type */ -/* followed by u_char cmsg_data[]; */ -}; - -/* given pointer to struct adatahdr, return pointer to data */ -#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1)) - -/* given pointer to struct adatahdr, return pointer to next adatahdr */ -#define CMSG_NXTHDR(mhdr, cmsg) \ - (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \ - (mhdr)->msg_control + (mhdr)->msg_controllen) ? \ - (struct cmsghdr *)NULL : \ - (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len))) - -#define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) - -/* "Socket"-level control message types: */ -#define SCM_RIGHTS 0x01 /* access rights (array of int) */ - -/* - * 4.3 compat sockaddr, move to compat file later - */ -struct osockaddr { - u_short sa_family; /* address family */ - char sa_data[14]; /* up to 14 bytes of direct address */ -}; - -/* - * 4.3-compat message header (move to compat file later). - */ -struct omsghdr { - caddr_t msg_name; /* optional address */ - int msg_namelen; /* size of address */ - struct iovec *msg_iov; /* scatter/gather array */ - int msg_iovlen; /* # elements in msg_iov */ - caddr_t msg_accrights; /* access rights sent/received */ - int msg_accrightslen; -}; - -//#include -//#include -//#include -//#include -//#include -//#include -// - -typedef enum spin_msg { - SP_MISC, /* some weird thing, usually just return immediately if you get this */ - SP_SELECT, /* in a select call */ - SP_NAME, /* getting a host by name */ - SP_ADDR, /* getting a host by address */ - SP_STREAM_READ, /* Stream read call */ - SP_STREAM_WRITE, /* Stream write call */ - SP_DGRAM_READ, /* Datagram read call */ - SP_DGRAM_WRITE, /* Datagram write call */ - SP_SLEEP, /* sleeping, passes ticks left to sleep */ - SP_AUTO_SPIN /* Autospin, passes argument to SpinCursor */ -} spin_msg; - -typedef int (*GUSISpinFn)(spin_msg msg, long param); -typedef void (*GUSIEvtHandler)(EventRecord * ev); -typedef GUSIEvtHandler GUSIEvtTable[24]; - -/* - * Address families, defined in sys/socket.h - * - -#define AF_UNSPEC 0 // unspecified -#define AF_UNIX 1 // local to host (pipes, portals) -#define AF_INET 2 // internetwork: UDP, TCP, etc. -#define AF_CTB 3 // Apple Comm Toolbox (not yet supported) -#define AF_FILE 4 // Normal File I/O (used internally) -#define AF_PPC 5 // PPC Toolbox -#define AF_PAP 6 // Printer Access Protocol (client only) -#define AF_APPLETALK 16 // Apple Talk - -*/ - -#define ATALK_SYMADDR 272 /* Symbolic Address for AppleTalk */ - -/* - * Some Implementations of GUSI require you to call GUSISetup for the - * socket families you'd like to have defined. It's a good idea to call - * this for *all* implementations. - * - * GUSIDefaultSetup() will include all socket families. - * - * Never call any of the GUSIwithXXX routines directly. - */ - -__BEGIN_DECLS -void GUSIwithAppleTalkSockets(); -void GUSIwithInternetSockets(); -void GUSIwithPAPSockets(); -void GUSIwithPPCSockets(); -void GUSIwithUnixSockets(); -void GUSIwithSIOUXSockets(); -void GUSIwithMPWSockets(); - -void GUSISetup(void (*socketfamily)()); -void GUSIDefaultSetup(); -__END_DECLS -/* - * Types, defined in sys/socket.h - * - -#define SOCK_STREAM 1 // stream socket -#define SOCK_DGRAM 2 // datagram socket - -*/ - -/* - * Defined in sys/un.h - * - -struct sockaddr_un { - short sun_family; - char sun_path[108]; -}; - -*/ - -#ifndef PRAGMA_ALIGN_SUPPORTED -#error Apple had some fun with the conditional macros again -#endif - -#if PRAGMA_ALIGN_SUPPORTED -#pragma options align=mac68k -#endif - -/* -struct sockaddr_atlk { - short family; - AddrBlock addr; -}; - -struct sockaddr_atlk_sym { - short family; - EntityName name; -}; - -struct sockaddr_ppc { - short family; - LocationNameRec location; - PPCPortRec port; -}; - -// Definitions for choose() - -#define CHOOSE_DEFAULT 1 -#define CHOOSE_NEW 2 -#define CHOOSE_DIR 4 - -typedef struct { - short numTypes; - SFTypeList types; -} sa_constr_file; - -typedef struct { - short numTypes; - NLType types; -} sa_constr_atlk; - - -// Definitions for sa_constr_ppc - -#define PPC_CON_NEWSTYLE 0x8000 -#define PPC_CON_MATCH_NAME 0x0001 -#define PPC_CON_MATCH_TYPE 0x0002 -#define PPC_CON_MATCH_NBP 0x0004 - -typedef struct { - short flags; - Str32 nbpType; - PPCPortRec match; -} sa_constr_ppc; - -*/ - -#if PRAGMA_ALIGN_SUPPORTED -#pragma options align=reset -#endif - -__BEGIN_DECLS -/* - * IO/Socket stuff, defined elsewhere (unistd.h, sys/socket.h - * -*/ -int socket(int domain, int type, short protocol); -int bind(int s, void *name, int namelen); -int connect(int s, void *addr, int addrlen); -int listen(int s, int qlen); -int accept(int s, void *addr, int *addrlen); -int close(int s); -int read(int s, char *buffer, unsigned buflen); -int readv(int s, struct iovec *iov, int count); -int recv(int s, void *buffer, int buflen, int flags); -int recvfrom(int s, void *buffer, int buflen, int flags, void *from, int *fromlen); -int recvmsg(int s,struct msghdr *msg,int flags); -int write(int s, const char *buffer, unsigned buflen); -int writev(int s, struct iovec *iov, int count); -int send(int s, void *buffer, int buflen, int flags); -int sendto (int s, void *buffer, int buflen, int flags, void *to, int tolen); -int sendmsg(int s,struct msghdr *msg,int flags); -int select(int width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); -int getdtablesize(void); -int getsockname(int s, void *name, int *namelen); -int getpeername(int s, struct sockaddr *name, int *namelen); -int shutdown(int s, int how); -int fcntl(int s, unsigned int cmd, int arg); -int dup(int s); -int dup2(int s, int s1); -//int ioctl(int d, unsigned int request, long *argp); -int getsockopt(int s, int level, int optname, char *optval, int * optlen); -int setsockopt(int s, int level, int optname, char *optval, int optlen); -int isatty(int); -int remove(const char *filename); -int rename(const char *oldname, const char *newname); -int creat(const char*); -int faccess(char*, unsigned int, long*); -long lseek(int, long, int); -int open(const char*, int); -int unlink(char*); -int symlink(char* linkto, char* linkname); -int readlink(char* path, char* buf, int bufsiz); -int truncate(char *path, long length); -int ftruncate(int fd, long length); -int chdir(char * path); -int mkdir(char * path); -int rmdir(char * path); -char * getcwd(char * buf, int size); - - -/* - * Defined in stdio.h - */ - -#ifdef __MWERKS__ -void fsetfileinfo (char *filename, unsigned long newcreator, unsigned long newtype); -#endif - -void fgetfileinfo (char *filename, unsigned long * creator, unsigned long * type); - -#ifdef __MWERKS__ -FILE *fdopen(int fd, const char *mode); -int fwalk(int (*func)(FILE * stream)); -#endif - -int choose( - int domain, - int type, - char * prompt, - void * constraint, - int flags, - void * name, - int * namelen); - -/* - * Hostname routines, defined in netdb.h - * -*/ - -/* - * Structures returned by network data base library. All addresses are - * supplied in host order, and returned in network order (suitable for - * use in system calls). - */ -struct hostent { - char *h_name; /* official name of host */ - char **h_aliases; /* alias list */ - int h_addrtype; /* host address type */ - int h_length; /* length of address */ - char **h_addr_list; /* list of addresses from name server */ -#define h_addr h_addr_list[0] /* address, for backward compatiblity */ -}; - -/* - * Assumption here is that a network number - * fits in 32 bits -- probably a poor one. - */ -struct netent { - char *n_name; /* official name of net */ - char **n_aliases; /* alias list */ - int n_addrtype; /* net address type */ - unsigned long n_net; /* network # */ -}; - -struct servent { - char *s_name; /* official service name */ - char **s_aliases; /* alias list */ - int s_port; /* port # */ - char *s_proto; /* protocol to use */ -}; - -struct protoent { - char *p_name; /* official protocol name */ - char **p_aliases; /* alias list */ - int p_proto; /* protocol # */ -}; - -/* - * Error return codes from gethostbyname() and gethostbyaddr() - * (left in extern int h_errno). - */ - -#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ -#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ -#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ -#define NO_DATA 4 /* Valid name, no data record of requested type */ -#define NO_ADDRESS NO_DATA /* no address, look for MX record */ - -int gethostname(char *machname, long buflen); - -void endhostent __P((void)); -void endnetent __P((void)); -void endprotoent __P((void)); -void endservent __P((void)); -struct hostent *gethostbyaddr __P((const char *, int, int)); -struct hostent *gethostbyname __P((const char *)); -struct hostent *gethostent __P((void)); -struct netent *getnetbyaddr __P((long, int)); /* u_long? */ -struct netent *getnetbyname __P((const char *)); -struct netent *getnetent __P((void)); -struct protoent *getprotobyname __P((const char *)); -struct protoent *getprotobynumber __P((int)); -struct protoent *getprotoent __P((void)); -struct servent *getservbyname __P((const char *, const char *)); -struct servent *getservbyport __P((int, const char *)); -struct servent *getservent __P((void)); -void herror __P((const char *)); -void sethostent __P((int)); -/* void sethostfile __P((const char *)); */ -void setnetent __P((int)); -void setprotoent __P((int)); -void setservent __P((int)); - - -char * inet_ntoa(struct in_addr inaddr); -struct in_addr inet_addr(const char *address); - -/* - * GUSI supports a number of hooks. Every one of them has a different prototype, but needs - * to be passed as a GUSIHook - */ - -typedef enum { - GUSI_SpinHook, /* A GUSISpinFn, to be called when a call blocks */ - GUSI_ExecHook, /* Boolean (*hook)(const GUSIFileRef & ref), decides if file is executable */ - GUSI_FTypeHook,/* Boolean (*hook)(const FSSpec & spec) sets a default file type */ - GUSI_SpeedHook /* A long integer, to be added to the cursor spin variable */ -} GUSIHookCode; - -typedef void (*GUSIHook)(void); -void GUSISetHook(GUSIHookCode code, GUSIHook hook); -GUSIHook GUSIGetHook(GUSIHookCode code); - -/* - * What to do when a routine blocks - */ - -/* Defined for compatibility */ -#define GUSISetSpin(routine) GUSISetHook(GUSI_SpinHook, (GUSIHook)routine) -#define GUSIGetSpin() (GUSISpinFn) GUSIGetHook(GUSI_SpinHook) - -int GUSISetEvents(GUSIEvtTable table); -GUSIEvtHandler * GUSIGetEvents(void); - -extern GUSIEvtHandler GUSISIOWEvents[]; - -#define SIGPIPE 13 -#define SIGALRM 14 - -/* - * BSD memory routines, defined in compat.h - * -*/ -#define index(a, b) strchr(a, b) -#define rindex(a, b) strrchr(a, b) -#define bzero(from, len) memset(from, 0, len) -#define bcopy(from, to, len) memcpy(to, from, len) -#define bcmp(s1, s2, len) memcmp(s1, s2, len) -#define bfill(from, len, x) memset(from, x, len) - - -__END_DECLS - - typedef struct wxSockInternal - { - long nothing ; - } ; - diff --git a/include/wx/mac/mdi.h b/include/wx/mac/mdi.h index 6f9fc294e2..fc3cf94603 100644 --- a/include/wx/mac/mdi.h +++ b/include/wx/mac/mdi.h @@ -125,6 +125,7 @@ public: // MDI operations virtual void Maximize(); + virtual void Maximize( bool ){ Maximize() ; } // this one is inherited from wxFrame virtual void Restore(); virtual void Activate(); }; diff --git a/include/wx/mac/menu.h b/include/wx/mac/menu.h index fa3936557c..3c5634d202 100644 --- a/include/wx/mac/menu.h +++ b/include/wx/mac/menu.h @@ -92,6 +92,10 @@ public: inline wxList& GetItems() const { return (wxList&) m_menuItems; } + void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; } + wxWindow * GetInvokingWindow() const { return m_pInvokingWindow; } + + bool MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ; public: wxFunction m_callback; @@ -101,7 +105,21 @@ public: wxList m_menuItems; wxEvtHandler * m_parent; wxEvtHandler * m_eventHandler; + wxWindow* m_pInvokingWindow; void* m_clientData; + + MenuHandle m_macMenuHandle; + short m_macMenuId; + bool m_macMenuEnabled ; + + // void MacSetTitle(const wxString& title); + int MacGetIndexFromId( int id ) ; + int MacGetIndexFromItem( wxMenuItem *pItem ) ; + void MacEnableMenu( bool bDoEnable ) ; + + static short s_macNextMenuId ; + +protected: }; // ---------------------------------------------------------------------------- @@ -149,14 +167,17 @@ class WXDLLEXPORT wxMenuBar: public wxEvtHandler inline int GetMenuCount() const { return m_menuCount; } inline wxMenu* GetMenu(int i) const { return m_menus[i]; } + void MacInstallMenuBar() ; + void MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ; + public: wxEvtHandler * m_eventHandler; int m_menuCount; wxMenu ** m_menus; wxString * m_titles; wxFrame * m_menuBarFrame; -/* TODO: data that represents the actual menubar when created. - */ + + static wxMenuBar* s_macInstalledMenuBar ; }; #endif // _WX_MENU_H_ diff --git a/include/wx/mac/menuitem.h b/include/wx/mac/menuitem.h index 9c912967f1..97359a102a 100644 --- a/include/wx/mac/menuitem.h +++ b/include/wx/mac/menuitem.h @@ -29,67 +29,48 @@ #include "wx/ownerdrw.h" #endif -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// id for a separator line in the menu (invalid for normal item) -#define ID_SEPARATOR (-1) - // ---------------------------------------------------------------------------- // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxMenuItem: public wxObject +class WXDLLEXPORT wxMenuItem: public wxMenuItemBase #if wxUSE_OWNER_DRAWN , public wxOwnerDrawn #endif { -DECLARE_DYNAMIC_CLASS(wxMenuItem) - public: - // ctor & dtor - wxMenuItem(wxMenu *pParentMenu = NULL, int id = ID_SEPARATOR, - const wxString& strName = "", const wxString& wxHelp = "", - bool bCheckable = FALSE, wxMenu *pSubMenu = NULL); - virtual ~wxMenuItem(); - - // accessors (some more are inherited from wxOwnerDrawn or are below) - bool IsSeparator() const { return m_idItem == ID_SEPARATOR; } - bool IsEnabled() const { return m_bEnabled; } - bool IsChecked() const { return m_bChecked; } - - int GetId() const { return m_idItem; } - const wxString& GetHelp() const { return m_strHelp; } - wxMenu *GetSubMenu() const { return m_pSubMenu; } - - // operations - void SetName(const wxString& strName) { m_strName = strName; } - void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; } - - void Enable(bool bDoEnable = TRUE); - void Check(bool bDoCheck = TRUE); - - void DeleteSubMenu(); + // ctor & dtor + wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL, + int id = wxID_SEPARATOR, + const wxString& name = wxEmptyString, + const wxString& help = wxEmptyString, + bool isCheckable = FALSE, + wxMenu *subMenu = (wxMenu *)NULL); + virtual ~wxMenuItem(); + + // override base class virtuals + virtual void SetText(const wxString& strName); + virtual wxString GetLabel() const; + virtual void SetCheckable(bool checkable); + + virtual void Enable(bool bDoEnable = TRUE); + virtual void Check(bool bDoCheck = TRUE); + virtual bool IsChecked() const; + +#if wxUSE_ACCEL + virtual wxAcceleratorEntry *GetAccel() const; +#endif // wxUSE_ACCEL + + // unfortunately needed to resolve ambiguity between + // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable() + bool IsCheckable() const { return wxMenuItemBase::IsCheckable(); } + + // the id for a popup menu is really its menu handle (as required by + // ::AppendMenu() API), so this function will return either the id or the + // menu handle depending on what we're + int GetRealId() const; private: - int m_idItem; // numeric id of the item - wxString m_strHelp; // associated help string - wxMenu *m_pSubMenu, // may be NULL - *m_pParentMenu; // menu this item is contained in - bool m_bEnabled, // enabled or greyed? - m_bChecked; // checked? (only if checkable) - -#if wxUSE_OWNER_DRAWN - // wxOwnerDrawn base class already has these variables - nothing to do - -#else //!owner drawn - bool m_bCheckable; // can be checked? - wxString m_strName; // name or label of the item - -public: - const wxString& GetName() const { return m_strName; } - bool IsCheckable() const { return m_bCheckable; } -#endif //owner drawn + DECLARE_DYNAMIC_CLASS(wxMenuItem) }; #endif //_MENUITEM_H diff --git a/include/wx/mac/metafile.h b/include/wx/mac/metafile.h index e4be296d92..c65ec89071 100644 --- a/include/wx/mac/metafile.h +++ b/include/wx/mac/metafile.h @@ -15,73 +15,91 @@ #ifndef _WX_METAFIILE_H_ #define _WX_METAFIILE_H_ -#ifdef __GNUG__ -#pragma interface "metafile.h" -#endif +#if wxUSE_METAFILE +#include "wx/dc.h" +#include "wx/gdiobj.h" -#include "wx/setup.h" +#if wxUSE_DRAG_AND_DROP +#include "wx/dataobj.h" wx/defs.h +#endif /* - * Metafile and metafile device context classes - work in Windows 3.1 only + * Metafile and metafile device context classes * */ -class WXDLLEXPORT wxDC; -class WXDLLEXPORT wxMetaFile: public wxObject +#define wxMetaFile wxMetafile +#define wxMetaFileDC wxMetafileDC + +class WXDLLEXPORT wxMetafile; + +class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData +{ + friend class WXDLLEXPORT wxMetafile; +public: + wxMetafileRefData(void); + ~wxMetafileRefData(void); + +public: + PicHandle m_metafile; +}; + +#define M_METAFILEDATA ((wxMetafileRefData *)m_refData) + +class WXDLLEXPORT wxMetafile: public wxGDIObject { - DECLARE_DYNAMIC_CLASS(wxMetaFile) + DECLARE_DYNAMIC_CLASS(wxMetafile) public: - wxMetaFile(const wxString& file = ""); - ~wxMetaFile(); + // Copy constructor + inline wxMetafile(const wxMetafile& metafile) + { Ref(metafile); } + + wxMetafile(const wxString& file = ""); + ~wxMetafile(void); // After this is called, the metafile cannot be used for anything // since it is now owned by the clipboard. virtual bool SetClipboard(int width = 0, int height = 0); virtual bool Play(wxDC *dc); - // TODO - inline bool Ok() { return FALSE; }; + inline bool Ok(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); }; + + // Implementation + inline PicHandle GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; } + void SetHMETAFILE(PicHandle mf) ; -/* TODO: Implementation - inline WXHANDLE GetHMETAFILE() { return m_metaFile; } - inline void SetHMETAFILE(WXHANDLE mf) { m_metaFile = mf; } + // Operators + inline wxMetafile& operator = (const wxMetafile& metafile) { if (*this == metafile) return (*this); Ref(metafile); return *this; } + inline bool operator == (const wxMetafile& metafile) { return m_refData == metafile.m_refData; } + inline bool operator != (const wxMetafile& metafile) { return m_refData != metafile.m_refData; } protected: - WXHANDLE m_metaFile; -*/ }; -class WXDLLEXPORT wxMetaFileDC: public wxDC +class WXDLLEXPORT wxMetafileDC: public wxDC { - DECLARE_DYNAMIC_CLASS(wxMetaFileDC) + DECLARE_DYNAMIC_CLASS(wxMetafileDC) public: // Don't supply origin and extent // Supply them to wxMakeMetaFilePlaceable instead. - wxMetaFileDC(const wxString& file = ""); + wxMetafileDC(const wxString& file = ""); // Supply origin and extent (recommended). // Then don't need to supply them to wxMakeMetaFilePlaceable. - wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg); + wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg); - ~wxMetaFileDC(); + ~wxMetafileDC(void); // Should be called at end of drawing - virtual wxMetaFile *Close(); - virtual void SetMapMode(int mode); - virtual void GetTextExtent(const wxString& string, float *x, float *y, - float *descent = NULL, float *externalLeading = NULL, - wxFont *theFont = NULL, bool use16bit = FALSE); + virtual wxMetafile *Close(void); // Implementation - inline wxMetaFile *GetMetaFile() { return m_metaFile; } - inline void SetMetaFile(wxMetaFile *mf) { m_metaFile = mf; } - inline int GetWindowsMappingMode() { return m_windowsMappingMode; } - inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; } + inline wxMetafile *GetMetaFile(void) const { return m_metaFile; } + inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; } protected: - int m_windowsMappingMode; - wxMetaFile *m_metaFile; + wxMetafile* m_metaFile; }; /* @@ -92,10 +110,57 @@ protected: */ // No origin or extent -bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, float scale = 1.0); +#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable +bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); // Optional origin and extent bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE); +// ---------------------------------------------------------------------------- +// wxMetafileDataObject is a specialization of wxDataObject for metafile data +// ---------------------------------------------------------------------------- + +// TODO: implement OLE side of things. At present, it's just for clipboard +// use. + +#if wxUSE_DRAG_AND_DROP +class WXDLLEXPORT wxMetafileDataObject : public wxDataObject +{ +public: + // ctors + wxMetafileDataObject() { m_width = 0; m_height = 0; }; + wxMetafileDataObject(const wxMetafile& metafile, int width = 0, int height = 0): + m_metafile(metafile), m_width(width), m_height(height) { } + + void SetMetafile(const wxMetafile& metafile, int w = 0, int h = 0) + { m_metafile = metafile; m_width = w; m_height = h; } + wxMetafile GetMetafile() const { return m_metafile; } + int GetWidth() const { return m_width; } + int GetHeight() const { return m_height; } + + virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; } + +/* ?? + // implement base class pure virtuals + virtual wxDataFormat GetPreferredFormat() const + { return (wxDataFormat) wxDataObject::Text; } + virtual bool IsSupportedFormat(wxDataFormat format) const + { return format == wxDataObject::Text || format == wxDataObject::Locale; } + virtual size_t GetDataSize() const + { return m_strText.Len() + 1; } // +1 for trailing '\0'of course + virtual void GetDataHere(void *pBuf) const + { memcpy(pBuf, m_strText.c_str(), GetDataSize()); } +*/ + +private: + wxMetafile m_metafile; + int m_width; + int m_height; +}; +#endif + +#endif // wxUSE_METAFILE + + #endif // _WX_METAFIILE_H_ diff --git a/include/wx/mac/notebook.h b/include/wx/mac/notebook.h index 83f8c1ce4e..0e43da55d8 100644 --- a/include/wx/mac/notebook.h +++ b/include/wx/mac/notebook.h @@ -165,6 +165,7 @@ public: virtual bool DoPhase(int nPhase); protected: + virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; // common part of all ctors void Init(); diff --git a/include/wx/mac/palette.h b/include/wx/mac/palette.h index 3482b33934..c359654e79 100644 --- a/include/wx/mac/palette.h +++ b/include/wx/mac/palette.h @@ -26,10 +26,9 @@ class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData public: wxPaletteRefData(); ~wxPaletteRefData(); -/* TODO: implementation protected: - WXHPALETTE m_hPalette; -*/ + wxColour* m_palette; + wxInt32 m_count ; }; #define M_PALETTEDATA ((wxPaletteRefData *)m_refData) diff --git a/include/wx/mac/radiobox.h b/include/wx/mac/radiobox.h index cb7c5ba405..8a4529edca 100644 --- a/include/wx/mac/radiobox.h +++ b/include/wx/mac/radiobox.h @@ -25,63 +25,88 @@ class WXDLLEXPORT wxBitmap ; class WXDLLEXPORT wxRadioBox: public wxControl { - DECLARE_DYNAMIC_CLASS(wxRadioBox) + DECLARE_DYNAMIC_CLASS(wxRadioBox) + public: - 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, - 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); - - int FindString(const wxString& s) const; - void SetSelection(int N); - int GetSelection() const; - wxString GetString(int N) const; - void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - void GetSize(int *x, int *y) const; - void GetPosition(int *x, int *y) const; - wxString GetLabel() const; - void SetLabel(const wxString& label); - void SetLabel(int item, const wxString& label) ; - wxString GetLabel(int item) const; - bool Show(bool show); - void SetFocus(); - void Enable(bool enable); - void Enable(int item, bool enable); - void Show(int item, bool show) ; - inline void SetLabelFont(const wxFont& WXUNUSED(font)) {}; - inline void SetButtonFont(const wxFont& font) { SetFont(font); } - - virtual wxString GetStringSelection() const; - virtual bool SetStringSelection(const wxString& s); - inline virtual int Number() const { return m_noItems; } ; - void Command(wxCommandEvent& event); - - inline int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; } - inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; } + wxRadioBox(); + + 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, + 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); + + int FindString(const wxString& s) const; + void SetSelection(int N); + int GetSelection() const; + wxString GetString(int N) const; + + void GetSize(int *x, int *y) const; + void GetPosition(int *x, int *y) const; + + void SetLabel(int item, const wxString& label); + void SetLabel(int item, wxBitmap *bitmap); + wxString GetLabel(int item) const; + bool Show(bool show); + void SetFocus(); + bool Enable(bool enable); + void Enable(int item, bool enable); + void Show(int item, bool show); + void SetLabelFont(const wxFont& WXUNUSED(font)) {}; + void SetButtonFont(const wxFont& font) { SetFont(font); } + + virtual wxString GetStringSelection() const; + virtual bool SetStringSelection(const wxString& s); + virtual int Number() const { return m_noItems; }; + void Command(wxCommandEvent& event); + + int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; } + void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; } + + // implementation only from now on + // ------------------------------- + + WXHWND *GetRadioButtons() const { return m_radioButtons; } + bool ContainsHWND(WXHWND hWnd) const; + void SendNotificationEvent(); + + // get the number of buttons per column/row + int GetNumVer() const; + int GetNumHor() const; + +#if WXWIN_COMPATIBILITY + wxRadioBox(wxWindow *parent, wxFunction func, const char *title, + int x = -1, int y = -1, int width = -1, int height = -1, + int n = 0, char **choices = NULL, + int majorDim = 0, long style = wxRA_HORIZONTAL, const char *name = wxRadioBoxNameStr); +#endif // WXWIN_COMPATIBILITY protected: -/* TODO: implementation - WXHWND * m_radioButtons; -*/ - int m_majorDim ; - int m_noItems; - int m_noRowsOrCols; - int m_selectedButton; + void SubclassRadioButton(WXHWND hWndBtn); + + WXHWND * m_radioButtons; + int m_majorDim; + int * m_radioWidth; // for bitmaps + int * m_radioHeight; + + int m_noItems; + int m_noRowsOrCols; + int m_selectedButton; + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); }; #endif diff --git a/include/wx/mac/region.h b/include/wx/mac/region.h index 04d143c2e9..bbe826196d 100644 --- a/include/wx/mac/region.h +++ b/include/wx/mac/region.h @@ -43,6 +43,7 @@ public: wxRegion(long x, long y, long w, long h); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxRect& rect); + wxRegion( WXHRGN hRegion ); wxRegion(); ~wxRegion(); @@ -100,6 +101,7 @@ public: bool Combine(long x, long y, long width, long height, wxRegionOp op); bool Combine(const wxRegion& region, wxRegionOp op); bool Combine(const wxRect& rect, wxRegionOp op); + const WXHRGN GetWXHRGN() const ; }; class WXDLLEXPORT wxRegionIterator : public wxObject { @@ -125,7 +127,6 @@ public: long GetH() const; long GetHeight() const { return GetH(); } wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); } - private: long m_current; long m_numRects; diff --git a/include/wx/mac/scrolbar.h b/include/wx/mac/scrolbar.h index 3ec992e78e..10e80637db 100644 --- a/include/wx/mac/scrolbar.h +++ b/include/wx/mac/scrolbar.h @@ -55,6 +55,7 @@ public: bool refresh = TRUE); void Command(wxCommandEvent& event); + virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; protected: int m_pageSize; diff --git a/include/wx/mac/setup.h b/include/wx/mac/setup.h index 77f7dfa27b..2498112208 100644 --- a/include/wx/mac/setup.h +++ b/include/wx/mac/setup.h @@ -16,6 +16,19 @@ * General features * */ +#define wxUSE_BUSYINFO 1 + +#define WORDS_BIGENDIAN 1 + +#define wxUSE_LIBPNG 1 + // Use PNG bitmap code +#define wxUSE_LIBJPEG 1 + // Use JPEG bitmap code +#define wxUSE_STREAMS 1 + +#define wxUSE_ZLIB 1 +#define wxUSE_ZIPSTREAM 1 +#define wxUSE_SOCKETS 1 #define wxUSE_CONSTRAINTS 1 // Use constraints mechanism @@ -24,7 +37,7 @@ #define _WX_GOODCOMPILER__ // gcc can have problems, but Windows compilers // are generally OK. -#define WXWIN_COMPATIBILITY 1 +#define WXWIN_COMPATIBILITY 0 // Compatibility with 1.66 API. // Level 0: no backward compatibility, all new features // Level 1: wxDC, OnSize (etc.) compatibility, but @@ -36,7 +49,7 @@ // 0 for no PostScript device context #define wxUSE_AFM_FOR_POSTSCRIPT 0 // 1 to use font metric files in GetTextExtent -#define wxUSE_METAFILE 0 +#define wxUSE_METAFILE 1 // 0 for no Metafile and metafile device context #define wxUSE_FORM 0 // 0 for no wxForm @@ -44,9 +57,9 @@ // 0 for no interprocess comms #define wxUSE_HELP 0 // 0 for no help facility -#define wxUSE_RESOURCES 0 +#define wxUSE_RESOURCES 1 // 0 for no wxGetResource/wxWriteResource -#define wxUSE_CLIPBOARD 0 +#define wxUSE_CLIPBOARD 1 // 0 for no clipboard functions #define wxUSE_SPLINES 0 // 0 for no splines @@ -55,17 +68,17 @@ // AIAI spline code is slower, but freer of copyright issues. // 0 for no splines -#define wxUSE_TOOLBAR 0 +#define wxUSE_TOOLBAR 1 // Use toolbars #define wxUSE_DRAG_AND_DROP 0 // 0 for no drag and drop -#define wxUSE_WX_RESOURCES 0 +#define wxUSE_WX_RESOURCES 1 // Use .wxr resource mechanism (requires PrologIO library) #define wxUSE_DOC_VIEW_ARCHITECTURE 1 // Set to 0 to disable document/view architecture -#define wxUSE_PRINTING_ARCHITECTURE 0 +#define wxUSE_PRINTING_ARCHITECTURE 1 // Set to 0 to disable print/preview architecture code #define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 0 // Set to 0 to disable PostScript print/preview architecture code @@ -111,6 +124,18 @@ // but you can't mix them. Set to 1 for , // 0 for +#define wxUSE_ZIPSTREAM 1 + +#define wxUSE_FS_ZIP 1 + +#define wxUSE_FS_INET 1 + +#define wxUSE_STREAMS 1 + // If enabled (1), compiles wxWindows streams classes + +#define wxUSE_STD_IOSTREAM 1 + // Use standard C++ streams if 1. If 0, use wxWin + // streams implementation. #define wxUSE_WXCONFIG 0 // if enabled, compiles built-in OS independent wxConfig // class and it's file (any platform) and registry (Win) @@ -125,5 +150,43 @@ // will be used to write, in a portable way, // float on the disk +// use wxFile class - required by i18n code, wxConfig and others - recommended +#define wxUSE_FILE 1 + +// use wxTextFile class: requires wxFile, required by wxConfig +#define wxUSE_TEXTFILE 1 + +// i18n support: _() macro, wxLocale class. Requires wxFile +#define wxUSE_INTL 1 + +// wxLogXXX functions - highly recommended +#define wxUSE_LOG 1 + +// wxValidator class +#define wxUSE_VALIDATORS 1 + +// wxAcceleratorTable/Entry classes and support for them in wxMenu(Bar) +#define wxUSE_ACCEL 1 + +// wxSashWindow class +#define wxUSE_SASH 1 + +// text entry dialog and wxGetTextFromUser function +#define wxUSE_TEXTDLG 1 + +#define wxUSE_STATLINE 1 + +// wxToolBar class +#define wxUSE_TOOLBAR 1 + +// wxStatusBar class +#define wxUSE_STATUSBAR 1 + +// progress dialog class for lengthy operations +#define wxUSE_PROGRESSDLG 1 + +// wxDirDlg class for getting a directory name from user +#define wxUSE_DIRDLG 1 + #endif // _WX_SETUP_H_ diff --git a/include/wx/mac/slider.h b/include/wx/mac/slider.h index 239e914e5c..e71b62fdb1 100644 --- a/include/wx/mac/slider.h +++ b/include/wx/mac/slider.h @@ -51,9 +51,6 @@ public: virtual int GetValue() const ; virtual void SetValue(int); - void GetSize(int *x, int *y) const ; - void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - void GetPosition(int *x, int *y) const ; bool Show(bool show); void SetRange(int minValue, int maxValue); @@ -78,7 +75,12 @@ public: void SetTick(int tickPos) ; void Command(wxCommandEvent& event); + void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; protected: + wxStaticText* m_macMinimumStatic ; + wxStaticText* m_macMaximumStatic ; + wxStaticText* m_macValueStatic ; + int m_rangeMin; int m_rangeMax; int m_pageSize; diff --git a/include/wx/mac/spinbutt.h b/include/wx/mac/spinbutt.h index afdb978c3f..caa1b77db2 100644 --- a/include/wx/mac/spinbutt.h +++ b/include/wx/mac/spinbutt.h @@ -63,10 +63,12 @@ class WXDLLEXPORT wxSpinButton: public wxControl //////////////////////////////////////////////////////////////////////////// void Command(wxCommandEvent& event) { ProcessCommand(event); }; + virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; protected: int m_min; int m_max; + int m_value ; }; class WXDLLEXPORT wxSpinEvent: public wxScrollEvent diff --git a/include/wx/mac/statbmp.h b/include/wx/mac/statbmp.h index f371fddd2d..f2162aeb10 100644 --- a/include/wx/mac/statbmp.h +++ b/include/wx/mac/statbmp.h @@ -47,7 +47,7 @@ class WXDLLEXPORT wxStaticBitmap: public wxControl virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {}; - + virtual void OnPaint( wxPaintEvent &event ) ; void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_messageBitmap; } @@ -57,7 +57,7 @@ class WXDLLEXPORT wxStaticBitmap: public wxControl protected: wxBitmap m_messageBitmap; - + DECLARE_EVENT_TABLE() }; #endif diff --git a/include/wx/mac/statbox.h b/include/wx/mac/statbox.h index 1aa4a6f88a..a70d8e11c6 100644 --- a/include/wx/mac/statbox.h +++ b/include/wx/mac/statbox.h @@ -47,8 +47,8 @@ class WXDLLEXPORT wxStaticBox: public wxControl virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {}; - void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - void SetLabel(const wxString& label); + +protected: DECLARE_EVENT_TABLE() }; diff --git a/include/wx/mac/stattext.h b/include/wx/mac/stattext.h index aa8eaf229e..1117b6fc9a 100644 --- a/include/wx/mac/stattext.h +++ b/include/wx/mac/stattext.h @@ -44,9 +44,8 @@ class WXDLLEXPORT wxStaticText: public wxControl const wxString& name = wxStaticTextNameStr); // accessors - void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - void SetLabel(const wxString&); - + void SetLabel(const wxString& , bool resize ); + void SetLabel( const wxString &str ) { SetLabel( str , true ) ; } // operations virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {}; diff --git a/include/wx/mac/statusbr.h b/include/wx/mac/statusbr.h index 28567b19e1..a83d84ae33 100644 --- a/include/wx/mac/statusbr.h +++ b/include/wx/mac/statusbr.h @@ -19,7 +19,7 @@ #include "wx/generic/statusbr.h" -class WXDLLEXPORT wxStatusBarXX : public wxStatusBar +class WXDLLEXPORT wxStatusBarMac : public wxStatusBar { DECLARE_DYNAMIC_CLASS(wxStatusBarXX); @@ -51,3 +51,4 @@ protected: }; #endif + // _WX_STATBAR_H_ \ No newline at end of file diff --git a/include/wx/mac/textctrl.h b/include/wx/mac/textctrl.h index 675e21bb3f..da11bfad29 100644 --- a/include/wx/mac/textctrl.h +++ b/include/wx/mac/textctrl.h @@ -119,11 +119,12 @@ public: virtual void PositionToXY(long pos, long *x, long *y) const ; virtual void ShowPosition(long pos); virtual void Clear(); + virtual bool MacCanFocus() const { return true ; } // callbacks // --------- void OnDropFiles(wxDropFilesEvent& event); -// void OnChar(wxKeyEvent& event); // Process 'enter' if required + void OnChar(wxKeyEvent& event); // Process 'enter' if required // void OnEraseBackground(wxEraseEvent& event); // Implementation diff --git a/include/wx/mac/timer.h b/include/wx/mac/timer.h index e668d30bec..0f656dae8f 100644 --- a/include/wx/mac/timer.h +++ b/include/wx/mac/timer.h @@ -45,9 +45,5 @@ private: DECLARE_ABSTRACT_CLASS(wxTimer) }; -/* Note: these are implemented in common/timercmn.cpp, so need to implement them separately. - * But you may need to modify timercmn.cpp. - */ - #endif // _WX_TIMER_H_ diff --git a/include/wx/mac/toolbar.h b/include/wx/mac/toolbar.h index e42c5827ef..6fe126b788 100644 --- a/include/wx/mac/toolbar.h +++ b/include/wx/mac/toolbar.h @@ -16,7 +16,10 @@ #pragma interface "toolbar.h" #endif +#if wxUSE_TOOLBAR + #include "wx/tbarbase.h" +#include "wx/dynarray.h" WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; @@ -62,16 +65,19 @@ class WXDLLEXPORT wxToolBar: public wxToolBarBase // Add all the buttons virtual bool CreateTools(); - virtual void Layout() {} + virtual void LayoutButtons() {} // The post-tool-addition call. TODO: do here whatever's // necessary for completing the toolbar construction. bool Realize() { return CreateTools(); }; - + virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; protected: + wxArrayPtrVoid m_macToolHandles ; DECLARE_EVENT_TABLE() }; +#endif // wxUSE_TOOLBAR + #endif // _WX_TOOLBAR_H_ diff --git a/include/wx/mac/window.h b/include/wx/mac/window.h index 0d37a8b071..7c4bb6b097 100644 --- a/include/wx/mac/window.h +++ b/include/wx/mac/window.h @@ -16,577 +16,331 @@ #pragma interface "window.h" #endif -#include "wx/gdicmn.h" -#include "wx/icon.h" -#include "wx/cursor.h" -#include "wx/pen.h" -#include "wx/font.h" -#include "wx/validate.h" -#include "wx/event.h" -#include "wx/string.h" -#include "wx/list.h" -#include "wx/region.h" -#include "wx/accel.h" - -#define wxKEY_SHIFT 1 -#define wxKEY_CTRL 2 - -/* - * Base class for frame, panel, canvas, panel items, dialog box. - * - */ - -/* - * Event handler: windows have themselves as their event handlers - * by default, but their event handlers could be set to another - * object entirely. This separation can reduce the amount of - * derivation required, and allow alteration of a window's functionality - * (e.g. by a resource editor that temporarily switches event handlers). - */ - -class WXDLLEXPORT wxWindow; -class WXDLLEXPORT wxEvent; -class WXDLLEXPORT wxCommandEvent; -class WXDLLEXPORT wxKeyEvent; -class WXDLLEXPORT wxControl; -class WXDLLEXPORT wxCursor; -class WXDLLEXPORT wxColourMap; -class WXDLLEXPORT wxFont; -class WXDLLEXPORT wxMenu; -class WXDLLEXPORT wxRect; -class WXDLLEXPORT wxBitmap; -class WXDLLEXPORT wxSizer; -class WXDLLEXPORT wxList; -class WXDLLEXPORT wxLayoutConstraints; -class WXDLLEXPORT wxMouseEvent; -class WXDLLEXPORT wxButton; -class WXDLLEXPORT wxColour; -class WXDLLEXPORT wxBrush; -class WXDLLEXPORT wxPen; -class WXDLLEXPORT wxIcon; -class WXDLLEXPORT wxDC; -class WXDLLEXPORT wxValidator; - -#if wxUSE_DRAG_AND_DROP -class WXDLLEXPORT wxDropTarget; -#endif - -#if wxUSE_WX_RESOURCES -class WXDLLEXPORT wxResourceTable; -class WXDLLEXPORT wxItemResource; -#endif - -WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr; +// --------------------------------------------------------------------------- +// forward declarations +// --------------------------------------------------------------------------- -WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize; -WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition; +class WXDLLEXPORT wxButton; -//----------------------------------------------------------------------------- -// wxClientData -//----------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// constants +// --------------------------------------------------------------------------- -class wxClientData +// FIXME does anybody use those? they're unused by wxWindows... +enum { -public: - wxClientData() { } - virtual ~wxClientData() { } + wxKEY_SHIFT = 1, + wxKEY_CTRL = 2 }; -//----------------------------------------------------------------------------- -// wxStringClientData -//----------------------------------------------------------------------------- - -class wxStringClientData: public wxClientData +class WXDLLEXPORT wxWindow: public wxWindowBase { -public: - wxStringClientData() { } - wxStringClientData( wxString &data ) { m_data = data; } - void SetData( wxString &data ) { m_data = data; } - wxString GetData() const { return m_data; } - -private: - wxString m_data; -}; - -class WXDLLEXPORT wxWindow: public wxEvtHandler -{ - DECLARE_ABSTRACT_CLASS(wxWindow) + DECLARE_DYNAMIC_CLASS(wxWindow); friend class wxDC; friend class wxPaintDC; public: - wxWindow(); - inline wxWindow(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr) - { - m_children = new wxList; - Create(parent, id, pos, size, style, name); - } - - virtual ~wxWindow(); - - bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr); - - // Fit the window around the items - virtual void Fit(); - - // Show or hide the window - virtual bool Show(bool show); - - // Is the window shown? - virtual bool IsShown() const; - - // Raise the window to the top of the Z order - virtual void Raise(); - - // Lower the window to the bottom of the Z order - virtual void Lower(); - - // Is the window enabled? - virtual bool IsEnabled() const; - - // For compatibility - inline bool Enabled() const { return IsEnabled(); } - - // Dialog support: override these and call - // base class members to add functionality - // that can't be done using validators. - - // Transfer values to controls. If returns FALSE, - // it's an application error (pops up a dialog) - virtual bool TransferDataToWindow(); - - // Transfer values from controls. If returns FALSE, - // transfer failed: don't quit - virtual bool TransferDataFromWindow(); - - // Validate controls. If returns FALSE, - // validation failed: don't quit - virtual bool Validate(); - - // Return code for dialogs - inline void SetReturnCode(int retCode); - inline int GetReturnCode(); - - // Set the cursor - virtual void SetCursor(const wxCursor& cursor); - inline virtual wxCursor *GetCursor() const { return (wxCursor *)& m_windowCursor; }; - - // Get the window with the focus - static wxWindow *FindFocus(); - - // Get character size - virtual int GetCharHeight() const; - virtual int GetCharWidth() const; - - // Get overall window size - virtual void GetSize(int *width, int *height) const; - wxSize GetSize() const { int w, h; GetSize(& w, & h); return wxSize(w, h); } - - // Get window position, relative to parent (or screen if no parent) - virtual void GetPosition(int *x, int *y) const; - wxPoint GetPosition() const - { int x, y; GetPosition(&x, &y); return wxPoint(x, y); } - - // Get size and position - wxRect GetRect() const - { int x, y, w, h; GetPosition(& x, & y); GetSize(& w, & h); return wxRect(x, y, w, h); } - - // Get client (application-useable) size - virtual void GetClientSize(int *width, int *height) const; - wxSize GetClientSize() const { int w, h; GetClientSize(& w, & h); return wxSize(w, h); } - - // Set overall size and position - virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); - void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) - { SetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); } - - // set size only - void SetSize(int width, int height) - { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); } - void SetSize(const wxSize& size) - { SetSize(-1, -1, size.x, size.y, wxSIZE_USE_EXISTING); } - - // set position only - virtual void Move(int x, int y) { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING); } - void Move(const wxPoint& pt) { SetSize(pt.x, pt.y, -1, -1, wxSIZE_USE_EXISTING); } - - // Set client size - virtual void SetClientSize(int width, int height); - void SetClientSize(const wxSize& sz) { SetClientSize(sz.x, sz.y); } - - // Convert client to screen coordinates - virtual void ClientToScreen(int *x, int *y) const; - wxPoint ClientToScreen(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); } - - // Convert screen to client coordinates - virtual void ScreenToClient(int *x, int *y) const; - wxPoint ScreenToClient(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); } - - // Set the focus to this window - virtual void SetFocus(); - - // Capture/release mouse - virtual void CaptureMouse(); - virtual void ReleaseMouse(); - - // Enable or disable the window - virtual void Enable(bool enable); + typedef struct MacWindowData + { + SInt16 m_macWindowBackgroundTheme ; + WindowRef m_macWindow ; + ControlHandle m_macRootControl ; + wxWindow* m_macFocus ; + } MacWindowData ; + + + wxWindow() { Init(); } + + wxWindow(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr) + { + Init(); + Create(parent, id, pos, size, style, name); + } + + virtual ~wxWindow(); + + bool Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxPanelNameStr); + + + // implement base class pure virtuals + virtual void SetTitle( const wxString& title); + virtual wxString GetTitle() const; + + virtual void Raise(); + virtual void Lower(); + + virtual bool Show( bool show = TRUE ); + virtual bool Enable( bool enable = TRUE ); + + virtual void SetFocus(); + + virtual bool Reparent( wxWindow *newParent ); + + virtual void WarpPointer(int x, int y); + virtual void CaptureMouse(); + virtual void ReleaseMouse(); + + virtual void Refresh( bool eraseBackground = TRUE, + const wxRect *rect = (const wxRect *) NULL ); + virtual void Clear(); + + virtual bool SetCursor( const wxCursor &cursor ); + virtual bool SetFont( const wxFont &font ); + + virtual int GetCharHeight() const; + virtual int GetCharWidth() const; + virtual void GetTextExtent(const wxString& string, + int *x, int *y, + int *descent = (int *) NULL, + int *externalLeading = (int *) NULL, + const wxFont *theFont = (const wxFont *) NULL) + const; + + virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); + + virtual void SetScrollbar( int orient, int pos, int thumbVisible, + int range, bool refresh = TRUE ); + virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); + virtual int GetScrollPos( int orient ) const; + virtual int GetScrollThumb( int orient ) const; + virtual int GetScrollRange( int orient ) const; + virtual void ScrollWindow( int dx, int dy, + const wxRect* rect = (wxRect *) NULL ); #if wxUSE_DRAG_AND_DROP - // Associate a drop target with this window (if the window already had a drop - // target, it's deleted!) and return the current drop target (may be NULL). - void SetDropTarget(wxDropTarget *pDropTarget); - wxDropTarget *GetDropTarget() const { return m_pDropTarget; } -#endif + virtual void SetDropTarget( wxDropTarget *dropTarget ); +#endif // wxUSE_DRAG_AND_DROP + + // Accept files for dragging + virtual void DragAcceptFiles(bool accept); + +#if WXWIN_COMPATIBILITY + // Set/get scroll attributes + virtual void SetScrollRange(int orient, int range, bool refresh = TRUE); + virtual void SetScrollPage(int orient, int page, bool refresh = TRUE); + virtual int OldGetScrollRange(int orient) const; + virtual int GetScrollPage(int orient) const; + + // event handlers + // Handle a control command + virtual void OnCommand(wxWindow& win, wxCommandEvent& event); + + // Override to define new behaviour for default action (e.g. double + // clicking on a listbox) + virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { } +#endif // WXWIN_COMPATIBILITY + +#if wxUSE_CARET && WXWIN_COMPATIBILITY + // caret manipulation (old MSW only functions, see wxCaret class for the + // new API) + void CreateCaret(int w, int h); + void CreateCaret(const wxBitmap *bitmap); + void DestroyCaret(); + void ShowCaret(bool show); + void SetCaretPos(int x, int y); + void GetCaretPos(int *x, int *y) const; +#endif // wxUSE_CARET + + // Native resource loading (implemented in src/msw/nativdlg.cpp) + // FIXME: should they really be all virtual? + virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); + virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); + wxWindow* GetWindowChild1(wxWindowID id); + wxWindow* GetWindowChild(wxWindowID id); + + // implementation from now on + // -------------------------- + + void MacClientToRootWindow( int *x , int *y ) const ; + void MacRootWindowToClient( int *x , int *y ) const ; + + + // simple accessors + // ---------------- + + WXHWND GetHWND() const { return m_hWnd; } + void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; } + virtual WXWidget GetHandle() const { return (WXWidget) GetHWND(); } + + bool GetUseCtl3D() const { return m_useCtl3D; } + bool GetTransparentBackground() const { return m_backgroundTransparent; } + void SetTransparent(bool t = TRUE) { m_backgroundTransparent = t; } + + // event handlers + // -------------- + void OnEraseBackground(wxEraseEvent& event); + void OnIdle(wxIdleEvent& event); - // Accept files for dragging - virtual void DragAcceptFiles(bool accept); - - // Update region access - virtual wxRegion GetUpdateRegion() const; - virtual bool IsExposed(int x, int y, int w, int h) const; - virtual bool IsExposed(const wxPoint& pt) const; - virtual bool IsExposed(const wxRect& rect) const; - - // Set/get the window title - virtual inline void SetTitle(const wxString& WXUNUSED(title)) {}; - inline virtual wxString GetTitle() const { return wxString(""); }; - // Most windows have the concept of a label; for frames, this is the - // title; for items, this is the label or button text. - inline virtual wxString GetLabel() const { return GetTitle(); } - - // Set/get the window name (used for resource setting in X) - inline virtual wxString GetName() const; - inline virtual void SetName(const wxString& name); - - // Centre the window - virtual void Centre(int direction) ; - inline void Center(int direction = wxHORIZONTAL) { Centre(direction); } - - // Popup a menu - virtual bool PopupMenu(wxMenu *menu, int x, int y); - - // Send the window a refresh event - virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL); - - // New functions that will replace the above. - virtual void SetScrollbar(int orient, int pos, int thumbVisible, - int range, bool refresh = TRUE); - - virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE); - virtual int GetScrollPos(int orient) const; - virtual int GetScrollRange(int orient) const; - virtual int GetScrollThumb(int orient) const; - - virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL); - - // Caret manipulation - virtual void CreateCaret(int w, int h); - virtual void CreateCaret(const wxBitmap *bitmap); - virtual void DestroyCaret(); - virtual void ShowCaret(bool show); - virtual void SetCaretPos(int x, int y); - virtual void GetCaretPos(int *x, int *y) const; - - // Tell window how much it can be sized - virtual void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1); - - // Set/get the window's identifier - inline int GetId() const; - inline void SetId(int id); - - virtual void SetAcceleratorTable(const wxAcceleratorTable& accel); - inline virtual wxAcceleratorTable& GetAcceleratorTable() const { return (wxAcceleratorTable&) m_acceleratorTable; } - - // Make the window modal (all other windows unresponsive) - virtual void MakeModal(bool modal); - - // Get the private handle (platform-dependent) - inline void *GetHandle() const; - - // Set/get the window's relatives - inline wxWindow *GetParent() const; - inline void SetParent(wxWindow *p) ; - inline wxWindow *GetGrandParent() const; - inline wxList& GetChildren() const; - - // Set/get the window's font - virtual void SetFont(const wxFont& f); - inline virtual wxFont& GetFont() const; - - // Set/get the window's validator - void SetValidator(const wxValidator& validator); - inline wxValidator *GetValidator() const; - - // Set/get the window's style - inline void SetWindowStyleFlag(long flag); - inline long GetWindowStyleFlag() const; - - // Handle a control command - virtual void OnCommand(wxWindow& win, wxCommandEvent& event); - - // Set/get event handler - inline void SetEventHandler(wxEvtHandler *handler); - inline wxEvtHandler *GetEventHandler() const; - - // Push/pop event handler (i.e. allow a chain of event handlers - // be searched) - void PushEventHandler(wxEvtHandler *handler) ; - wxEvtHandler *PopEventHandler(bool deleteHandler = FALSE) ; - - // Close the window by calling OnClose, posting a deletion - virtual bool Close(bool force = FALSE); - - // Destroy the window (delayed, if a managed window) - virtual bool Destroy() ; - - // Mode for telling default OnSize members to - // call Layout(), if not using Sizers, just top-down constraints - inline void SetAutoLayout(bool a); - inline bool GetAutoLayout() const; - - // Set/get constraints - inline wxLayoutConstraints *GetConstraints() const; - void SetConstraints(wxLayoutConstraints *c); - - // Set/get window background colour - inline virtual void SetBackgroundColour(const wxColour& col); - inline virtual wxColour GetBackgroundColour() const; - - // Set/get window foreground colour - inline virtual void SetForegroundColour(const wxColour& col); - inline virtual wxColour GetForegroundColour() const; - - // Get the default button, if there is one - inline virtual wxButton *GetDefaultItem() const; - inline virtual void SetDefaultItem(wxButton *but); - - // Override to define new behaviour for default action (e.g. double clicking - // on a listbox) - virtual void OnDefaultAction(wxControl *initiatingItem); - - // Resource loading -#if wxUSE_WX_RESOURCES - virtual bool LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table = NULL); - virtual wxControl *CreateItem(const wxItemResource* childResource, const wxItemResource* parentResource, - const wxResourceTable *table = (const wxResourceTable *) NULL); -#endif +public: + // For implementation purposes - sometimes decorations make the client area + // smaller + virtual wxPoint GetClientAreaOrigin() const; - virtual void GetTextExtent(const wxString& string, int *x, int *y, - int *descent = NULL, - int *externalLeading = NULL, - const wxFont *theFont = NULL, bool use16 = FALSE) const; + // Makes an adjustment to the window position (for example, a frame that has + // a toolbar that it manages itself). + virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); - // Is the window retained? - inline bool IsRetained() const; + wxWindow *FindItem(long id) const; + wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; - // Warp the pointer the given position - virtual void WarpPointer(int x_pos, int y_pos) ; + // Make a Windows extended style from the given wxWindows window style + static WXDWORD MakeExtendedStyle(long style, + bool eliminateBorders = TRUE); + // Determine whether 3D effects are wanted + WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const; - // Clear the window - virtual void Clear(); + // MSW only: TRUE if this control is part of the main control + virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; - // Find a window by id or name - virtual wxWindow *FindWindow(long id); - virtual wxWindow *FindWindow(const wxString& name); + #if WXWIN_COMPATIBILITY + wxObject *GetChild(int number) const; + virtual void MSWDeviceToLogical(float *x, float *y) const; +#endif // WXWIN_COMPATIBILITY - // Constraint operations - bool Layout(); - void SetSizer(wxSizer *sizer); // Adds sizer child to this window - inline wxSizer *GetSizer() const ; - inline wxWindow *GetSizerParent() const ; - inline void SetSizerParent(wxWindow *win); + // Create an appropriate wxWindow from a HWND + virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd); - // Do Update UI processing for controls - void UpdateWindowUI(); + // Make sure the window style reflects the HWND style (roughly) + virtual void AdoptAttributesFromHWND(); - void OnEraseBackground(wxEraseEvent& event); - void OnChar(wxKeyEvent& event); - void OnPaint(wxPaintEvent& event); - void OnIdle(wxIdleEvent& event); + // Setup background and foreground colours correctly + virtual void SetupColours(); - // Does this window want to accept keyboard focus? - virtual bool AcceptsFocus() const; - virtual void PrepareDC( wxDC &dc ) {}; +#if WXWIN_COMPATIBILITY + void SetShowing(bool show) { (void)Show(show); } + bool IsUserEnabled() const { return IsEnabled(); } +#endif // WXWIN_COMPATIBILITY + // Responds to colour changes: passes event on to children. + void OnSysColourChanged(wxSysColourChangedEvent& event); -public: - //////////////////////////////////////////////////////////////////////// - //// IMPLEMENTATION - - // For implementation purposes - sometimes decorations make the client area - // smaller - virtual wxPoint GetClientAreaOrigin() const; - - // Makes an adjustment to the window position (for example, a frame that has - // a toolbar that it manages itself). - virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags); - - // Executes the default message - virtual long Default(); - -/* TODO: you may need something like this - // Determine whether 3D effects are wanted - virtual WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D); -*/ - - virtual void AddChild(wxWindow *child); // Adds reference to the child object - virtual void RemoveChild(wxWindow *child); // Removes reference to child - // (but doesn't delete the child object) - virtual void DestroyChildren(); // Removes and destroys all children - - inline bool IsBeingDeleted() const { return FALSE; } // TODO: Should probably eliminate this - - // Constraint implementation - void UnsetConstraints(wxLayoutConstraints *c); - inline wxList *GetConstraintsInvolvedIn() const ; - // Back-pointer to other windows we're involved with, so if we delete - // this window, we must delete any constraints we're involved with. - void AddConstraintReference(wxWindow *otherWin); - void RemoveConstraintReference(wxWindow *otherWin); - void DeleteRelatedConstraints(); - - virtual void ResetConstraints(); - virtual void SetConstraintSizes(bool recurse = TRUE); - virtual bool LayoutPhase1(int *noChanges); - virtual bool LayoutPhase2(int *noChanges); - virtual bool DoPhase(int); - // Transforms from sizer coordinate space to actual - // parent coordinate space - virtual void TransformSizerToActual(int *x, int *y) const ; - - // Set size with transformation to actual coordinates if nec. - virtual void SizerSetSize(int x, int y, int w, int h); - virtual void SizerMove(int x, int y); - - // Only set/get the size/position of the constraint (if any) - virtual void SetSizeConstraint(int x, int y, int w, int h); - virtual void MoveConstraint(int x, int y); - virtual void GetSizeConstraint(int *w, int *h) const ; - virtual void GetClientSizeConstraint(int *w, int *h) const ; - virtual void GetPositionConstraint(int *x, int *y) const ; - - // Dialog units translations. Implemented in wincmn.cpp. - wxPoint ConvertPixelsToDialog(const wxPoint& pt) ; - wxPoint ConvertDialogToPixels(const wxPoint& pt) ; - inline wxSize ConvertPixelsToDialog(const wxSize& sz) - { wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } - inline wxSize ConvertDialogToPixels(const wxSize& sz) - { wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); return wxSize(pt.x, pt.y); } - - wxObject *GetChild(int number) const ; - - // Generates a new id for controls - static int NewControlId(); - - // Responds to colour changes: passes event on to children. - void OnSysColourChanged(wxSysColourChangedEvent& event); - - // Transfers data to any child controls - void OnInitDialog(wxInitDialogEvent& event); - - // Sends an OnInitDialog event, which in turns transfers data to - // to the window via validators. - virtual void InitDialog(); - - //////////////////////////////////////////////////////////////////////// - //// PROTECTED DATA protected: - int m_windowId; - long m_windowStyle; // Store the window's style - wxEvtHandler * m_windowEventHandler; // Usually is 'this' - wxLayoutConstraints * m_constraints; // Constraints for this window - wxList * m_constraintsInvolvedIn; // List of constraints we're involved in - wxSizer * m_windowSizer; // Window's top-level sizer (if any) - wxWindow * m_sizerParent; // Window's parent sizer (if any) - bool m_autoLayout; // Whether to call Layout() in OnSize - wxWindow * m_windowParent; // Each window always knows its parent - wxValidator * m_windowValidator; - int m_minSizeX; - int m_minSizeY; - int m_maxSizeX; - int m_maxSizeY; - - // Caret data - int m_caretWidth; - int m_caretHeight; - bool m_caretEnabled; - bool m_caretShown; - wxFont m_windowFont; // Window's font - wxCursor m_windowCursor; // Window's cursor - wxString m_windowName; // Window name - - wxButton * m_defaultItem; - - wxColour m_backgroundColour ; - wxColour m_foregroundColour ; - wxAcceleratorTable m_acceleratorTable; + // the window handle + WXHWND m_hWnd; + + // the old window proc (we subclass all windows) + WXFARPROC m_oldWndProc; + + // additional (MSW specific) flags + bool m_useCtl3D:1; // Using CTL3D for this control + bool m_backgroundTransparent:1; + bool m_mouseInWindow:1; + bool m_doubleClickAllowed:1; + bool m_winCaptured:1; + + // the size of one page for scrolling + int m_xThumbSize; + int m_yThumbSize; + + WXHMENU m_hMenu; // Menu, if any + + // the return value of WM_GETDLGCODE handler + long m_lDlgCode; + + // implement the base class pure virtuals + virtual void DoClientToScreen( int *x, int *y ) const; + virtual void DoScreenToClient( int *x, int *y ) const; + virtual void DoGetPosition( int *x, int *y ) const; + virtual void DoGetSize( int *width, int *height ) const; + virtual void DoGetClientSize( int *width, int *height ) const; + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO); + virtual void DoSetClientSize(int width, int height); + + // get the size which best suits the window: e.g., for a static text it + // will be the width and height of the text + virtual wxSize DoGetBestSize(); + + // move the window to the specified location and resize it: this is called + // from both DoSetSize() and DoSetClientSize() and would usually just call + // ::MoveWindow() except for composite controls which will want to arrange + // themselves inside the given rectangle + virtual void DoMoveWindow(int x, int y, int width, int height); + +#if wxUSE_TOOLTIPS + virtual void DoSetToolTip( wxToolTip *tip ); +#endif // wxUSE_TOOLTIPS -#if wxUSE_DRAG_AND_DROP - wxDropTarget *m_pDropTarget; // the current drop target or NULL -#endif //USE_DRAG_AND_DROP - -public: - wxRegion m_updateRegion; - wxList * m_children; // Window's children - int m_returnCode; +private: + // common part of all ctors + void Init(); -DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxWindow); + DECLARE_EVENT_TABLE() }; -//////////////////////////////////////////////////////////////////////// -//// INLINES - -inline void *wxWindow::GetHandle() const { return (void *)NULL; } -inline int wxWindow::GetId() const { return m_windowId; } -inline void wxWindow::SetId(int id) { m_windowId = id; } -inline wxWindow *wxWindow::GetParent() const { return m_windowParent; } -inline void wxWindow::SetParent(wxWindow *p) { m_windowParent = p; } -inline wxWindow *wxWindow::GetGrandParent() const { return (m_windowParent ? m_windowParent->m_windowParent : (wxWindow*) NULL); } -inline wxList& wxWindow::GetChildren() const { return (wxList&) * m_children; } -inline wxFont& wxWindow::GetFont() const { return (wxFont&) m_windowFont; } -inline wxString wxWindow::GetName() const { return m_windowName; } -inline void wxWindow::SetName(const wxString& name) { m_windowName = name; } -inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle; } -inline void wxWindow::SetWindowStyleFlag(long flag) { m_windowStyle = flag; } -inline void wxWindow::SetEventHandler(wxEvtHandler *handler) { m_windowEventHandler = handler; } -inline wxEvtHandler *wxWindow::GetEventHandler() const { return m_windowEventHandler; } -inline void wxWindow::SetAutoLayout(bool a) { m_autoLayout = a; } -inline bool wxWindow::GetAutoLayout() const { return m_autoLayout; } -inline wxLayoutConstraints *wxWindow::GetConstraints() const { return m_constraints; } -inline void wxWindow::SetBackgroundColour(const wxColour& col) { m_backgroundColour = col; }; -inline wxColour wxWindow::GetBackgroundColour() const { return m_backgroundColour; }; -inline void wxWindow::SetForegroundColour(const wxColour& col) { m_foregroundColour = col; }; -inline wxColour wxWindow::GetForegroundColour() const { return m_foregroundColour; }; - -inline wxButton *wxWindow::GetDefaultItem() const { return m_defaultItem; } -inline void wxWindow::SetDefaultItem(wxButton *but) { m_defaultItem = but; } -inline bool wxWindow::IsRetained() const { return ((m_windowStyle & wxRETAINED) == wxRETAINED); } - -inline wxList *wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn; } -inline wxSizer *wxWindow::GetSizer() const { return m_windowSizer; } -inline wxWindow *wxWindow::GetSizerParent() const { return m_sizerParent; } -inline void wxWindow::SetSizerParent(wxWindow *win) { m_sizerParent = win; } -inline wxValidator *wxWindow::GetValidator() const { return m_windowValidator; } -inline void wxWindow::SetReturnCode(int retCode) { m_returnCode = retCode; } -inline int wxWindow::GetReturnCode() { return m_returnCode; } - -// Get the active window. -wxWindow* WXDLLEXPORT wxGetActiveWindow(); - -WXDLLEXPORT_DATA(extern wxList) wxTopLevelWindows; +// associate mac windows with wx counterparts + +wxWindow* wxFindWinFromMacWindow( WindowRef inWindow ) ; +void wxAssociateWinWithMacWindow(WindowRef inWindow, wxWindow *win) ; +void wxRemoveMacWindowAssociation(wxWindow *win) ; + +class wxMacFocusHelper +{ +public : + wxMacFocusHelper( wxWindow * theWindow ) ; + ~wxMacFocusHelper() ; + bool Ok() { return m_ok ; } + +private : + GrafPtr m_formerPort ; + GrafPtr m_currentPort ; + bool m_ok ; +} ; + +class wxMacDrawingHelper +{ +public : + wxMacDrawingHelper( wxWindow * theWindow ) ; + ~wxMacDrawingHelper() ; + bool Ok() { return m_ok ; } + +private : + GrafPtr m_formerPort ; + GrafPtr m_currentPort ; + PenState m_savedPenState ; + bool m_ok ; +} ; + +class wxMacFocusClientHelper +{ +public : + wxMacFocusClientHelper( wxWindow * theWindow ) ; + ~wxMacFocusClientHelper() ; + bool Ok() { return m_ok ; } + +private : + GrafPtr m_formerPort ; + GrafPtr m_currentPort ; + bool m_ok ; +} ; + +class wxMacDrawingClientHelper +{ +public : + wxMacDrawingClientHelper( wxWindow * theWindow ) ; + ~wxMacDrawingClientHelper() ; + bool Ok() { return m_ok ; } + +private : + GrafPtr m_formerPort ; + GrafPtr m_currentPort ; + PenState m_savedPenState ; + bool m_ok ; +} ; #endif // _WX_WINDOW_H_ diff --git a/include/wx/msw/gsockmsw.h b/include/wx/msw/gsockmsw.h index e745060b58..6c3befccb5 100644 --- a/include/wx/msw/gsockmsw.h +++ b/include/wx/msw/gsockmsw.h @@ -23,12 +23,12 @@ #include - #ifdef __cplusplus extern "C" { #endif /* Definition of GSocket */ +typedef struct _GSocket { SOCKET m_fd; diff --git a/include/wx/wx_cw.h b/include/wx/wx_cw.h index c8bf670a26..5480949118 100644 --- a/include/wx/wx_cw.h +++ b/include/wx/wx_cw.h @@ -12,6 +12,29 @@ #ifndef _WX_CW__ #define _WX_CW__ +#if __option(profile) +#ifdef __cplusplus + #if __POWERPC__ + #include + #elif __INTEL__ + #include + #elif __CFM68K__ + #include + #else + #include + #endif +#else + #if __POWERPC__ + #include + #elif __INTEL__ + #include + #elif __CFM68K__ + #include + #else + #include + #endif +#endif +#else #ifdef __cplusplus #if __POWERPC__ #include @@ -33,6 +56,6 @@ #include #endif #endif - +#endif #endif // _WX_CW__ diff --git a/include/wx/wx_cw_cm.h b/include/wx/wx_cw_cm.h index dd2c3fa06c..2fe7cf9678 100644 --- a/include/wx/wx_cw_cm.h +++ b/include/wx/wx_cw_cm.h @@ -9,7 +9,16 @@ #if (__MWERKS__ < 0x0900) || macintosh #define __MAC__ #define __WXMAC__ - #define USE_PRECOMPILED_MAC_HEADERS 1 /*Set to 0 if you don't want to use precompiled MacHeaders*/ + #if TARGET_CARBON + #define USE_PRECOMPILED_MAC_HEADERS 0 /*Set to 0 if you don't want to use precompiled MacHeaders*/ + #ifdef __cplusplus + #include + #else + #include + #endif + #else + #define USE_PRECOMPILED_MAC_HEADERS 1 /*Set to 0 if you don't want to use precompiled MacHeaders*/ + #endif // automatically includes MacHeaders #elif (__MWERKS__ >= 0x0900) && __INTEL__ #define __WXMSW__ @@ -27,19 +36,23 @@ #ifdef __WXMSW__ #include #include + #ifdef __MWERKS__ #if defined( __MSL__ ) && __MSL__ >= 0x5012 #define fileno _fileno #define fdopen _fdopen #define tell _tell #endif + #endif #elif defined( __WXMAC__) #include #endif #define USE_DEFINE + // in order to avoid problems further down in wxWindows #ifdef __cplusplus + extern "C" { #endif diff --git a/include/wx/wx_cw_d.h b/include/wx/wx_cw_d.h index f56d8cdc0a..75a2a5ed2e 100644 --- a/include/wx/wx_cw_d.h +++ b/include/wx/wx_cw_d.h @@ -12,6 +12,9 @@ #ifndef _WX_CW__ #define _WX_CW__ +#if __option(profile) +#error "profiling is not supported in debug versions" +#else #ifdef __cplusplus #if __POWERPC__ #include @@ -33,6 +36,7 @@ #include #endif #endif +#endif #endif // _WX_CW__ diff --git a/include/wx_cw.pch b/include/wx_cw.pch index c5efcf3859..8a5a49d142 100644 --- a/include/wx_cw.pch +++ b/include/wx_cw.pch @@ -1,16 +1,26 @@ +#if __option (profile) #if __POWERPC__ - #pragma precompile_target "wx_PPC.mch" - + #pragma precompile_target "wx_PPC_prof.mch" +#elif __INTEL__ + #pragma precompile_target "wx_x86_prof.mch" +#elif __CFM68K__ + #pragma precompile_target "wx_cfm_prof.mch" +#else + #pragma precompile_target "wx_68k_prof.mch" +#endif +#else +#if __POWERPC__ + #pragma precompile_target "wx_PPC.mch" #elif __INTEL__ #pragma precompile_target "wx_x86.mch" - #elif __CFM68K__ #pragma precompile_target "wx_cfm.mch" - #else #pragma precompile_target "wx_68k.mch" #endif +#endif #pragma once on #undef WX_PRECOMP +#define wxUSE_GUI 1 #include "wx/wx_cw_cm.h" diff --git a/include/wx_cw.pch++ b/include/wx_cw.pch++ index 8ff1e4604b..a9f6924473 100644 --- a/include/wx_cw.pch++ +++ b/include/wx_cw.pch++ @@ -1,18 +1,27 @@ +#if __option (profile) +#if __POWERPC__ + #pragma precompile_target "wx_PPC++_prof.mch" +#elif __INTEL_ + #pragma precompile_target "wx_x86Prof++_prof.mch" +#elif __CFM68K__ + #pragma precompile_target "wx_cfmProf++_prof.mch" +#else + #pragma precompile_target "wx_68kProf++_prof.mch" +#endif +#else #if __POWERPC__ #pragma precompile_target "wx_PPC++.mch" - #elif __INTEL__ - #pragma precompile_target "wx_x86++.mch" - - #elif __CFM68K__ #pragma precompile_target "wx_cfm++.mch" - #else #pragma precompile_target "wx_68k++.mch" #endif +#endif #pragma once on #define WX_PRECOMP +#define wxUSE_GUI 1 #include "wx/wx_cw_cm.h" +#include "wx/wxprec.h" \ No newline at end of file diff --git a/include/wx_cw_d.pch b/include/wx_cw_d.pch index 12b3530b86..a38cd139e5 100644 --- a/include/wx_cw_d.pch +++ b/include/wx_cw_d.pch @@ -1,3 +1,6 @@ +#if __option (profile) + #error "profiling is not supported for debug targets" +#else #if __POWERPC__ #pragma precompile_target "wx_PPC_d.mch" @@ -10,8 +13,13 @@ #else #pragma precompile_target "wx_68k_d.mch" #endif - +#endif #pragma once on #undef WX_PRECOMP -#define __WXDEBUG__ +#define __WXDEBUG__ 1 +#define wxUSE_GUI 1 #include "wx/wx_cw_cm.h" +#ifdef __WXMSW__ + #include + #include "wx/msw/winundef.h" +#endif diff --git a/include/wx_cw_d.pch++ b/include/wx_cw_d.pch++ index 4659812a8b..cb5643a468 100644 --- a/include/wx_cw_d.pch++ +++ b/include/wx_cw_d.pch++ @@ -1,19 +1,24 @@ +#if __option (profile) + #error "profiling is not supported for debug targets" +#else #if __POWERPC__ #pragma precompile_target "wx_PPC++_d.mch" - #elif __INTEL__ - #pragma precompile_target "wx_x86++_d.mch" - - #elif __CFM68K__ #pragma precompile_target "wx_cfm++_d.mch" - #else #pragma precompile_target "wx_68k++_d.mch" #endif +#endif #pragma once on #define WX_PRECOMP -#define __WXDEBUG__ +#define __WXDEBUG__ 1 +#define wxUSE_GUI 1 + + #include "wx/wx_cw_cm.h" +#ifdef WX_PRECOMP +#include "wx/wxprec.h" +#endif \ No newline at end of file diff --git a/samples/help/doc/ClassGraph.class b/samples/help/doc/ClassGraph.class index 3c6afea84468c9da332caf0b750afca416c20ed1..2ebf9199b816fbf93a6807749bd2fe37c3213ed8 100644 GIT binary patch delta 5 Mcmeyx;Wxn#00&qEQjcVl$2OJS;OwIM#CgEnFaJ;S?W@y zRsH~flx5Ez5K10=NOz~Fd;06Idw&1<@e3(TVBNxF3lA+kvXHlM-^5cBFHF2Lv0!4x z#Iy;|#H5XG4BN1ANsAF1S=`jtbsH8gXzPmhUCqJ7E9b#Ty(IC=MLtu;@|;p zI~d29gD1G-U>0{BEMnQgOUyecV^jyPX))zs3HJ=xrBK9*3AM?BIyW$qA1!}id#u2s zDB!9v*Hjdw_<<@K$ZqqUP*R}V3JaL16*iRgMU76+tg$`6##AWh>q>>ffR}Gyx33DN za5oAC7pmB)al&aJ#i~_;w0KbAk@5+cf&La43S0`p{WAL$))j?pgmqcrOMXB|296+8 z)PlduMNGMbrmtKISR5})7QJ6*f(PWg)y9*=-A0pi889n4mlK3kest47Z;h)HWDpm= zs8TluEGA{RU-hMd4BJthv>i#l!=>ca4ga&I>!^<-77V0);Zu6@Oep3HeL>rqoC4h* z={6{_6jtfdo^n`W!6uVF+YU6;tmJXCTyKXHK{I^wx~yk&Ova=JW1zd~>2R8hx$4*s zHM`Cv+vUw>h7&_tEv6gBMDm$aepCvByD>^AbPjgp5D?rZ+q@f=Y$u6>sm?HU%{yrjy4C!~C zn`zLld2X82s^=P{);zb1)O6Z&Q>4FQ(EAB{D|HCBfwN>=TVq4%@d>YiA^Of8qW?Pv oJntI@8t8r7HqJEA^My)i5cFi*h5JZrP#NzK=R3y*a&)2e7rP%R2><{9 diff --git a/samples/help/doc/ClassGraphPanel.class b/samples/help/doc/ClassGraphPanel.class index 4e3b5162cb2ae3b64c20d7b16d5e2918121d36df..4c0f4f9e1bf864921b12b0634f8785045566ec6c 100644 GIT binary patch delta 6 Ncmew&-^Vzi4*&{60>J

v2gCo&Fbw7Qy_KwWZ8`z$(R<(f z-gjSbFa7I@rxCzTJQv3A!?-()B?C_x z_@jZZ8Ymn1wSjjSc#DB24gA@_hYftuz+DE;8u+Gx83Ug-u@Og1Y{qF>3K1S}6(}7+ z0w?A8CLtLy@ek7zCa%JrLU&Luih?^V%Lx;kFfO;pBZ$G4V=97nWJFs@NXAUG;SS+_gIpXETuyGM zO0|3D${+S$BAp)D&y_my3@kk`;up4MOv7s|!7b8}X7 z=$XPSFG6F^c%jI%Icb*;61u%`+R2xA9?03Hk}_WWq1yEF>X z$+}h1bfKJg>(RTSZh()0>f<$c754DhDW<%C`zXz_GZ_sVeZf%Wp-Lt)&8)hfgXWOR z%8)%@D7%!mp<&cu-gPD<`L16_t#sCUcKH~4dOGL0J$uzAMdr-8{T_Rs_@hULl$pki zohv(s$C-tklb>)WHC(ffCH^X^nM^+#U9eIw%z2)gR6rS^P8Ft3Nyt^cFnN(UXyna3yOJ%%OKHG$qNQl)s%mVD{ywD4*)%PTDZ_|lM2CYIf7t~QZWZrFpQ zkFE8Vf^zh4Hk%RIn*3Pf+R63nVlBT!tEDl7xNK;fWuk4e1}$KZ$AVD;mEq6Qcy88~WK7-MRNGK4;BZng6cz0(H@8OpF! zWNL|L%qJZg3>373iLIq=^&n`x12sv_Lxr@RJ7yQN_E^r5dDFn+tJYmfeGxYOodlq zb8-RQ{2dTI*9&Txr)>&j`Y_ijOoW(=*i*#~hqb%hMDr3l`&uf{ zj|X~NNv_21B1!O3gmi^cas}nTP6czl8}!~-!irJ;%N|B3&>JH`hp1e}l_Lo=(UJ(p zTjR0#2I7<{-Afo8PL7a5Pc71VI{K=!&&QId zLl8P~9T(6aYf`rB=eydBOnWHP)?USK4^AogykdrYjlDQ~DAR7#*+Z#1TxaJ8-g@j- zLwm}no$zYy{BV46cG2#!bhU~0)$IIs^wl=_#o`Lk@Z>9tx^sIAO$CZ_M{xR~rTFV*K0V!ORLQf=RhM5mt0(16G4h z?ntj_Q|+}AX_FpFO3yTqH`S0e`C`m#DoxK&eL$%nZHQf^oAfG$b=&?cot37OR1i`M zj&`-xt+{LkVyq|>6KKD#P7FQN>Io`6lb5N-@1sw4y_kHcb=1vL9Y-hK znrg)4g=MVr#%bWUo;Y>>U&_~G++IxL5b99Sj=o?bxPY5w*_)D} e2-P-^>Wr?%bsjk-Kz}0PdE44P^*?$A&Cj>|U diff --git a/samples/help/doc/ClassLayout.class b/samples/help/doc/ClassLayout.class index 40eb67e0e98927ee4f295707fa8d0b1dc7888374..46457cfdd1ddf861a6bd933502949490199e45cc 100644 GIT binary patch delta 7 OcmaDO^qXfxH5&jA3IjI) delta 766 zcmYjO%Wl&^6g`e-CUK}xV;GugJAslygB@NAys$+6fF(#Qki4)&g|hB~3S|=(T_b@i zu_=mV!KxtJL1M$6FW?{e0~Y1pNrGZ)?#zA6oO93pyYVMHKUS0NXpSh_>{W;(S)tFy zMxw%lui($aYn+gMN9Q&zpJS`k2aMNJjrG(i-YioUq`Ub!u5sfDncm1xgpEqXhsi|x zi7N0c)~d#}v}u|(OxohDlLjUzF)*zXTbUL!Y_9o~jC|R|5d@kPdByx6`=bIc zVoQvFVj~qsFllK-iLNw~=rT?wa^A+@aX(8GC&N={tti-^VJFgx;(zB%WB^po1HN9j?S{FEoHF0!oi6FC8Mv-!M zLa^>MnhH+~!u{1jz#Jz9zRl;msR?LUTo~F^CE=1Bq=6BHI`QwYD$_9cSRy0@7mJ7=(e8 z@+=5f2FTsW00N8*2@C;1G7ZSqWMBre7#L&`CJHeEP1D-OAis@45n?Dzna zg8>5*P$vU}49LP`3}Qe^1;pIRAkD diff --git a/src/jpeg/jconfig.h b/src/jpeg/jconfig.h index 83d28b7bdb..7367459c4c 100644 --- a/src/jpeg/jconfig.h +++ b/src/jpeg/jconfig.h @@ -11,6 +11,16 @@ /* see jconfig.doc for explanations */ /* use wxWindows' configure */ +#ifdef __MWERKS__ +#if (__MWERKS__ < 0x0900) || macintosh + #define __WXMAC__ + #define USE_MAC_MEMMGR +// automatically includes MacHeaders +#elif (__MWERKS__ >= 0x0900) && __INTEL__ + #define __WXMSW__ +#endif +#endif + #include "wx/setup.h" #define HAVE_PROTOTYPES diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 3061f99aea..fd5a0009b0 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -37,10 +37,18 @@ // mac +#if __option(profile) + #include +#endif + #include "apprsrc.h" +#include + extern char *wxBuffer; extern wxList wxPendingDelete; +extern wxList *wxWinMacWindowList; +extern wxList *wxWinMacControlList; wxApp *wxTheApp = NULL; @@ -51,56 +59,279 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) END_EVENT_TABLE() #endif -long wxApp::sm_lastMessageTime = 0; const short kMacMinHeap = (29 * 1024) ; // platform specific static variables -bool gMacHasAppearance = false ; -long gMacAppearanceVersion = 0 ; -RgnHandle gMacCursorRgn = NULL ; +const short kwxMacMenuBarResource = 1 ; +const short kwxMacAppleMenuId = 1 ; + +RgnHandle wxApp::s_macCursorRgn = NULL; +wxWindow* wxApp::s_captureWindow = NULL ; +int wxApp::s_lastMouseDown = 0 ; +long wxApp::sm_lastMessageTime = 0; + +#ifdef __WXMAC__ + +bool wxApp::s_macDefaultEncodingIsPC = true ; +bool wxApp::s_macSupportPCMenuShortcuts = true ; +long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; +wxString wxApp::s_macHelpMenuTitleName = "&Help" ; + +OSErr AEHandleODoc( AppleEvent *event , AppleEvent *reply , long refcon ) +{ + wxApp* app = (wxApp*) refcon ; + return wxTheApp->MacHandleAEODoc( event , reply) ; +} + +OSErr AEHandleOApp( AppleEvent *event , AppleEvent *reply , long refcon ) +{ + wxApp* app = (wxApp*) refcon ; + return wxTheApp->MacHandleAEOApp( event , reply ) ; +} + +OSErr AEHandlePDoc( AppleEvent *event , AppleEvent *reply , long refcon ) +{ + wxApp* app = (wxApp*) refcon ; + return wxTheApp->MacHandleAEPDoc( event , reply ) ; +} + +OSErr AEHandleQuit( AppleEvent *event , AppleEvent *reply , long refcon ) +{ + wxApp* app = (wxApp*) refcon ; + return wxTheApp->MacHandleAEQuit( event , reply) ; +} + +OSErr wxApp::MacHandleAEODoc(AppleEvent *event , AppleEvent *reply) +{ + ProcessSerialNumber PSN ; + PSN.highLongOfPSN = 0 ; + PSN.lowLongOfPSN = kCurrentProcess ; + SetFrontProcess( &PSN ) ; + return noErr ; +} + +OSErr wxApp::MacHandleAEPDoc(AppleEvent *event , AppleEvent *reply) +{ + return noErr ; +} + +OSErr wxApp::MacHandleAEOApp(AppleEvent *event , AppleEvent *reply) +{ + return noErr ; +} + +OSErr wxApp::MacHandleAEQuit(AppleEvent *event , AppleEvent *reply) +{ + wxWindow* win = GetTopWindow() ; + if ( win ) + { + win->Close(TRUE ) ; + } + else + { + ExitMainLoop() ; + } + return noErr ; +} + +char StringMac[] = "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" + "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" + "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf" + "\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf" + "\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf" + "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ; + +char StringANSI[] = "\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8" + "\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC" + "\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8" + "\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8" + "\xBF\xA1\xAC\x83\xAB\xBB\x85\xC0\xC3\xD5\x8C\x9C" + "\x96\x97\x93\x94\x91\x92\xF7\xFF\xA0\x80" ; + +void wxMacConvertFromPC( const char *from , char *to , int len ) +{ + char *c ; + if ( from == to ) + { + for( int i = 0 ; i < len ; ++ i ) + { + c = strchr( StringANSI , *from ) ; + if ( c != NULL ) + { + *to = StringMac[ c - StringANSI] ; + } + ++to ; + ++from ; + } + } + else + { + for( int i = 0 ; i < len ; ++ i ) + { + c = strchr( StringANSI , *from ) ; + if ( c != NULL ) + { + *to = StringMac[ c - StringANSI] ; + } + else + { + *to = *from ; + } + ++to ; + ++from ; + } + } +} + +void wxMacConvertToPC( const char *from , char *to , int len ) +{ + char *c ; + if ( from == to ) + { + for( int i = 0 ; i < len ; ++ i ) + { + c = strchr( StringMac , *from ) ; + if ( c != NULL ) + { + *to = StringANSI[ c - StringMac] ; + } + ++to ; + ++from ; + } + } + else + { + for( int i = 0 ; i < len ; ++ i ) + { + c = strchr( StringMac , *from ) ; + if ( c != NULL ) + { + *to = StringANSI[ c - StringMac] ; + } + else + { + *to = *from ; + } + ++to ; + ++from ; + } + } +} + +void wxMacConvertFromPC( char * p ) +{ + char *ptr = p ; + int len = strlen ( p ) ; + + wxMacConvertFromPC( ptr , ptr , len ) ; +} + +void wxMacConvertFromPCForControls( char * p ) +{ + char *ptr = p ; + int len = strlen ( p ) ; + + wxMacConvertFromPC( ptr , ptr , len ) ; + for ( int i = 0 ; i < strlen ( ptr ) ; i++ ) + { + if ( ptr[i] == '&' && ptr[i]+1 != ' ' ) + { + memmove( &ptr[i] , &ptr[i+1] , strlen( &ptr[i+1] ) + 1) ; + } + } +} + +void wxMacConvertFromPC( unsigned char *p ) +{ + char *ptr = (char*) p + 1 ; + int len = p[0] ; + + wxMacConvertFromPC( ptr , ptr , len ) ; +} + +extern char *wxBuffer ; + +wxString wxMacMakeMacStringFromPC( const char * p ) +{ + const char *ptr = p ; + int len = strlen ( p ) ; + char *buf = wxBuffer ; + + if ( len >= BUFSIZ + 512 ) + { + buf = new char [len+1] ; + } + + wxMacConvertFromPC( ptr , buf , len ) ; + buf[len] = 0 ; + wxString result( buf ) ; + if ( buf != wxBuffer ) + delete buf ; + return result ; +} + + +void wxMacConvertToPC( char * p ) +{ + char *ptr = p ; + int len = strlen ( p ) ; + + wxMacConvertToPC( ptr , ptr , len ) ; +} + +void wxMacConvertToPC( unsigned char *p ) +{ + char *ptr = (char*) p + 1 ; + int len = p[0] ; + + wxMacConvertToPC( ptr , ptr , len ) ; +} + +wxString wxMacMakePCStringFromMac( const char * p ) +{ + const char *ptr = p ; + int len = strlen ( p ) ; + char *buf = wxBuffer ; + + if ( len >= BUFSIZ + 512 ) + { + buf = new char [len+1] ; + } + + wxMacConvertToPC( ptr , buf , len ) ; + buf[len] = 0 ; + + wxString result( buf ) ; + if ( buf != wxBuffer ) + delete buf ; + return result ; +} +#endif bool wxApp::Initialize() { int error = 0 ; // Mac-specific - long total,contig; - // init all managers - - ::InitGraf(&qd.thePort); - ::InitFonts(); - ::InitWindows(); - ::InitMenus(); - ::TEInit(); - ::InitDialogs(0L); - ::InitCursor(); - CursHandle aCursHandle = ::GetCursor(watchCursor); // Watch should be in system - if (aCursHandle) - ::SetCursor(*aCursHandle); - ::FlushEvents(everyEvent, 0); - - // setup memory of application - - ::MaxApplZone(); - for (long i = 1; i <= 4; i++) - ::MoreMasters(); - PurgeSpace(&total, &contig); - ::SetCursor( &qd.arrow ) ; + UMAInitToolbox( 4 ) ; + UMAShowWatchCursor() ; + AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) , (long) wxTheApp , FALSE ) ; + AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ; + AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ; + AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ; #if 0 - InitAEHandlers(); - InitializeAECore() ; GUSISetup(GUSIwithInternetSockets); #endif + // test the minimal configuration necessary long theSystem ; long theMachine; - long theAppearance ; if (Gestalt(gestaltMachineType, &theMachine) != noErr) { @@ -114,32 +345,25 @@ bool wxApp::Initialize() { error = kMacSTROldSystem ; } - else if ( theSystem < 0x0700 ) + else if ( theSystem < 0x0750 ) { error = kMacSTROldSystem ; } + #if !TARGET_CARBON else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap) { error = kMacSTRSmallSize; } + #endif + /* else { - if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) + if ( !UMAHasAppearance() ) { - gMacHasAppearance = true ; - RegisterAppearanceClient(); - if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) - { - gMacAppearanceVersion = theAppearance ; - } - else - { - gMacAppearanceVersion = 0x0100 ; - } - } - else error = kMacSTRNoPre8Yet ; + } } + */ // if we encountered any problems so far, give the error code and exit immediately @@ -147,19 +371,23 @@ bool wxApp::Initialize() { short itemHit; Str255 message; - - SetCursor(&qd.arrow); + GetIndString(message, 128, error); - ParamText(message, (ConstStr255Param)"\p", (ConstStr255Param)"\p", (ConstStr255Param)"\p"); - itemHit = Alert(129, nil); + UMAShowArrowCursor() ; + ParamText("\pFatal Error", message, (ConstStr255Param)"\p", (ConstStr255Param)"\p"); + itemHit = Alert(128, nil); return FALSE ; } - + +#if __option(profile) + ProfilerInit( collectDetailed, bestTimeBase , 20000 , 30 ) ; +#endif + // now avoid exceptions thrown for new (bad_alloc) std::__throws_bad_alloc = FALSE ; - gMacCursorRgn = ::NewRgn() ; + s_macCursorRgn = ::NewRgn() ; #ifdef __WXMSW__ wxBuffer = new char[1500]; @@ -191,8 +419,14 @@ bool wxApp::Initialize() wxBitmap::InitStandardHandlers(); wxModule::RegisterModules(); - wxASSERT( wxModule::InitializeModules() == TRUE ); + if (!wxModule::InitializeModules()) + return FALSE; + wxWinMacWindowList = new wxList(wxKEY_INTEGER); + wxWinMacControlList = new wxList(wxKEY_INTEGER); + + UMAShowArrowCursor() ; + return TRUE; } @@ -228,8 +462,16 @@ void wxApp::CleanUp() delete[] wxBuffer; wxBuffer = NULL; + if (wxWinMacWindowList) + delete wxWinMacWindowList ; + wxClassInfo::CleanUpClasses(); +#if __option(profile) + ProfilerDump( "\papp.prof" ) ; + ProfilerTerm() ; +#endif + delete wxTheApp; wxTheApp = NULL; @@ -253,8 +495,8 @@ void wxApp::CleanUp() delete wxLog::SetActiveTarget(NULL); ::PrClose() ; - if (gMacCursorRgn) - ::DisposeRgn(gMacCursorRgn); + if (s_macCursorRgn) + ::DisposeRgn(s_macCursorRgn); #if 0 TerminateAE() ; #endif @@ -281,11 +523,18 @@ int wxEntry( int argc, char *argv[] ) return 0; }; +#ifdef __WXMAC__ + argc = 1 ; // currently we don't support files as parameters +#endif + wxTheApp->argc = argc; wxTheApp->argv = argv; // GUI-specific initialization, such as creating an app context. wxTheApp->OnInitGui(); + + // we could try to get the open apple events here to adjust argc and argv better + // Here frames insert themselves automatically // into wxTopLevelWindows by getting created @@ -324,22 +573,19 @@ wxApp::wxApp() m_appName = ""; argc = 0; argv = NULL; -#ifdef __WXMSW__ + m_printMode = wxPRINT_WINDOWS; -#else - m_printMode = wxPRINT_POSTSCRIPT; -#endif + m_exitOnFrameDelete = TRUE; m_auto3D = TRUE; } bool wxApp::Initialized() { + if (GetTopWindow()) return TRUE; -// if (GetTopWindow()) -// return TRUE; -// else -// return FALSE; + else + return FALSE; } int wxApp::MainLoop() @@ -372,16 +618,15 @@ void wxApp::ExitMainLoop() // Is a message/event pending? bool wxApp::Pending() { -/* TODO. - */ - return FALSE; + EventRecord event ; + + return EventAvail( everyEvent , &event ) ; } // Dispatch a message. void wxApp::Dispatch() { -/* TODO. - */ + MacDoOneEvent() ; } void wxApp::OnIdle(wxIdleEvent& event) @@ -493,32 +738,70 @@ void wxExit() // Yield to other processes bool wxYield() { -#if 0 - ::YieldToOtherThreads() ; - ::SystemTime() ; -#endif +// YieldToAnyThread() ; + SystemTask() ; return TRUE; } // platform specifics +void wxApp::MacSuspend( bool convertClipboard ) +{ + s_lastMouseDown = 0 ; + if( convertClipboard ) + { + MacConvertPrivateToPublicScrap() ; + } + + UMAHideFloatingWindows() ; +} + +void wxApp::MacResume( bool convertClipboard ) +{ + s_lastMouseDown = 0 ; + if( convertClipboard ) + { + MacConvertPublicToPrivateScrap() ; + } + + UMAShowFloatingWindows() ; +} + +void wxApp::MacConvertPrivateToPublicScrap() +{ + ::ZeroScrap(); + ::TEToScrap(); +} + +void wxApp::MacConvertPublicToPrivateScrap() +{ + ::TEFromScrap() ; +} + void wxApp::MacDoOneEvent() { EventRecord event ; - long sleepTime = 60; + long sleepTime = ::GetCaretTime(); - if (WaitNextEvent(everyEvent, &event,sleepTime, gMacCursorRgn)) + if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn)) { MacHandleOneEvent( &event ); } else { // idlers + WindowPtr window = UMAFrontWindow() ; + if ( window ) + UMAIdleControls( window ) ; + wxTheApp->ProcessIdle() ; } - + if ( event.what != kHighLevelEvent ) + SetRectRgn( s_macCursorRgn , event.where.h - 1 , event.where.v - 1, event.where.h + 1 , event.where.v + 1 ) ; + // repeaters + #if 0 wxMacProcessSocketEvents() ; #endif @@ -526,29 +809,30 @@ void wxApp::MacDoOneEvent() void wxApp::MacHandleOneEvent( EventRecord *ev ) { + m_macCurrentEvent = ev ; + + wxApp::sm_lastMessageTime = ev->when ; + switch (ev->what) { - case nullEvent: - MacHandleNullEvent( ev ) ; - break ; - case kHighLevelEvent: - MacHandleHighLevelEvent( ev ) ; - break; case mouseDown: MacHandleMouseDownEvent( ev ) ; - wxTheApp->ExitMainLoop() ; + if ( ev->modifiers & controlKey ) + s_lastMouseDown = 2; + else + s_lastMouseDown = 1; break; case mouseUp: + if ( s_lastMouseDown == 2 ) + { + ev->modifiers |= controlKey ; + } + else + { + ev->modifiers &= ~controlKey ; + } MacHandleMouseUpEvent( ev ) ; - break; - case keyDown: - MacHandleKeyDownEvent( ev ) ; - break; - case autoKey: - MacHandleAutoKeyEvent( ev ) ; - break; - case keyUp: - MacHandleKeyUpEvent( ev ) ; + s_lastMouseDown = 0; break; case activateEvt: MacHandleActivateEvent( ev ) ; @@ -556,850 +840,532 @@ void wxApp::MacHandleOneEvent( EventRecord *ev ) case updateEvt: MacHandleUpdateEvent( ev ) ; break; + case keyDown: + case autoKey: + MacHandleKeyDownEvent( ev ) ; + break; + case keyUp: + MacHandleKeyUpEvent( ev ) ; + break; case diskEvt: MacHandleDiskEvent( ev ) ; break; case osEvt: MacHandleOSEvent( ev ) ; break; + case kHighLevelEvent: + MacHandleHighLevelEvent( ev ) ; + break; default: break; } } -void wxApp::MacHandleNullEvent( EventRecord *ev ) -{ -} - void wxApp::MacHandleHighLevelEvent( EventRecord *ev ) { + ::AEProcessAppleEvent( ev ) ; } +bool s_macIsInModalLoop = false ; + void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) { -} + WindowRef window; + WindowRef frontWindow = UMAFrontNonFloatingWindow() ; + WindowAttributes frontWindowAttributes = NULL ; + if ( frontWindow ) + UMAGetWindowAttributes( frontWindow , &frontWindowAttributes ) ; + + short windowPart = ::FindWindow(ev->where, &window); + wxWindow* win = wxFindWinFromMacWindow( window ) ; + + switch (windowPart) + { + case inMenuBar : + if ( s_macIsInModalLoop ) + { + SysBeep ( 30 ) ; + } + else + { + UInt32 menuresult = MenuSelect(ev->where) ; + MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ); + s_lastMouseDown = 0; + } + break ; + case inSysWindow : + SystemClick( ev , window ) ; + s_lastMouseDown = 0; + break ; + case inDrag : + if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) ) + { + SysBeep ( 30 ) ; + } + else + { + DragWindow(window, ev->where, &qd.screenBits.bounds); + if (win) + { + GrafPtr port ; + GetPort( &port ) ; + Point pt = { 0, 0 } ; + SetPort( window ) ; + SetOrigin( 0 , 0 ) ; + LocalToGlobal( &pt ) ; + SetPort( port ) ; + win->SetSize( pt.h , pt.v , -1 , + -1 , wxSIZE_USE_EXISTING); + } + s_lastMouseDown = 0; + } + break ; + case inGoAway: + if (TrackGoAway(window, ev->where)) + { + if ( win ) + win->Close() ; + } + s_lastMouseDown = 0; + break; + case inGrow: + int growResult = GrowWindow(window , ev->where, &qd.screenBits.bounds); + if (growResult != 0) + { + int newWidth = LoWord(growResult); + int newHeight = HiWord(growResult); + int oldWidth, oldHeight; + + win->GetSize(&oldWidth, &oldHeight); + if (newWidth == 0) + newWidth = oldWidth; + if (newHeight == 0) + newHeight = oldHeight; + + if (win) + win->SetSize( -1, -1, newWidth, newHeight, wxSIZE_USE_EXISTING); + } + s_lastMouseDown = 0; + break; + case inZoomIn: + case inZoomOut: + if (TrackBox(window, ev->where, windowPart)) + { + // TODO setup size event + ZoomWindow( window , windowPart , false ) ; + if (win) + win->SetSize( -1, -1, window->portRect.right-window->portRect.left , + window->portRect.bottom-window->portRect.top, wxSIZE_USE_EXISTING); + } + s_lastMouseDown = 0; + break; + case inCollapseBox : + // TODO setup size event + s_lastMouseDown = 0; + break ; -void wxApp::MacHandleMouseUpEvent( EventRecord *ev ) -{ + case inContent : + if ( window != frontWindow ) + { + if ( s_macIsInModalLoop ) + { + SysBeep ( 30 ) ; + } + else if ( UMAIsWindowFloating( window ) ) + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + } + else + { + UMASelectWindow( window ) ; + } + } + else + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + } + break ; + + default: + break; + } } -void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) +void wxApp::MacHandleMouseUpEvent( EventRecord *ev ) { + WindowRef window; + + short windowPart = ::FindWindow(ev->where, &window); + + switch (windowPart) + { + case inMenuBar : + break ; + case inSysWindow : + break ; + default: + { + wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( win ) + win->MacMouseUp( ev , windowPart ) ; + } + break; + } } -void wxApp::MacHandleKeyUpEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleAutoKeyEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleActivateEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleUpdateEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleDiskEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleOSEvent( EventRecord *ev ) -{ -} - - - -/* - -void wxApp::doMacMouseDown(void) -{ - WindowPtr window; - short windowPart = ::FindWindow(m_event.where, &window); - if ( windowPart != inMenuBar ) - { - WindowPtr frontWindow = FrontWindow(); - if (WindowIsModal(frontWindow) && (window != frontWindow)) - SysBeep(1); - else - { - switch (windowPart) +long wxMacTranslateKey(char key, char code) +{ + switch (key) + { + case 0x01 : + key = WXK_HOME; + break; + case 0x03 : + key = WXK_RETURN; + break; + case 0x04 : + key = WXK_END; + break; + case 0x05 : + key = WXK_HELP; + break; + case 0x08 : + key = WXK_BACK; + break; + case 0x09 : + key = WXK_TAB; + break; + case 0x0b : + key = WXK_PAGEUP; + break; + case 0x0c : + key = WXK_PAGEDOWN; + break; + case 0x0d : + key = WXK_RETURN; + break; + case 0x10 : { - case inMenuBar: - break; - case inContent: - doMacInContent(window); break; - case inDrag: - doMacInDrag(window); break; - case inGrow: - doMacInGrow(window); break; - case inGoAway: - doMacInGoAway(window); break; - case inZoomIn: - case inZoomOut: - doMacInZoom(window, windowPart); break; - default: - break; + switch( code ) + { + case 0x7a : + key = WXK_F1 ; + break; + case 0x78 : + key = WXK_F2 ; + break; + case 0x63 : + key = WXK_F3 ; + break; + case 0x76 : + key = WXK_F4 ; + break; + case 0x60 : + key = WXK_F5 ; + break; + case 0x61 : + key = WXK_F6 ; + break; + case 0x62: + key = WXK_F7 ; + break; + case 0x64 : + key = WXK_F8 ; + break; + case 0x65 : + key = WXK_F9 ; + break; + case 0x6D : + key = WXK_F10 ; + break; + case 0x67 : + key = WXK_F11 ; + break; + case 0x6F : + key = WXK_F12 ; + break; + case 0x69 : + key = WXK_F13 ; + break; + case 0x6B : + key = WXK_F14 ; + break; + case 0x71 : + key = WXK_F15 ; + break; + } } + break ; + case 0x1b : + key = WXK_DELETE ; + break ; + case 0x1c : + key = WXK_LEFT ; + break ; + case 0x1d : + key = WXK_RIGHT ; + break ; + case 0x1e : + key = WXK_UP ; + break ; + case 0x1f : + key = WXK_DOWN ; + break ; + default: + break ; + } // end switch - } - } - else - { - doMacInMenuBar(::MenuSelect(m_event.where)); - } -} - -void wxApp::doMacMouseUp(void) -{ - if (m_mouseWindow) - { -#if 0 - int hitX = m_event.where.h; // screen window c.s. - int hitY = m_event.where.v; // screen window c.s. - m_mouseWindow->ScreenToClient(&hitX, &hitY); // mouseWindow client c.s. - m_mouseWindow->ClientToLogical(&hitX, &hitY); // mouseWindow logical c.s. -#endif - - wxMouseEvent event(wxEVT_LEFT_UP); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = FALSE; - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - - m_mouseWindow->ProcessEvent(event); - } - else - { - //??? Can't we just throw away mouse up events without matching mouse down - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { -#if 0 - int hitX = cCurrentEvent.where.h; // screen window c.s. - int hitY = cCurrentEvent.where.v; // screen window c.s. - theMacWxFrame->ScreenToWindow(&hitX, &hitY); -#endif - - wxMouseEvent event(wxEVT_LEFT_UP); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = FALSE; - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - - theMacWxFrame->ProcessEvent(event); - } - } -} - -void wxApp::doMacMouseMotion(void) -{ - if (m_mouseWindow) { - wxMouseEvent event(wxEVT_MOTION); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = !(m_event.modifiers & btnState); - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - - m_mouseWindow->ProcessEvent(event); - } - else - { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { - wxMouseEvent event(wxEVT_MOTION); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = !(m_event.modifiers & btnState); - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - - m_mouseWindow->ProcessEvent(event); - } - } - - //??? Need to work with floating windows... isn't there a toolbox call to find the - // top window intersecting a point is screen coordinates?? -#if 0 - else // will only work for one floating window at the moment... ? - { - WindowPtr frontDocPtr = findFrontNonFloatingWindow(); - WindowPtr frontFloatingPtr = ::FrontWindow(); - - int hitX = cCurrentEvent.where.h; - int hitY = cCurrentEvent.where.v; - - wxFrame* macWxFrame = findMacWxFrame(frontDocPtr); - - if ((frontFloatingPtr != frontDocPtr) & (frontFloatingPtr != NULL)) - { - RgnHandle frontFloatStrRgn = getStructureRegion(frontFloatingPtr); - Rect frontFloatRect = (**frontFloatStrRgn).rgnBBox; - - if ((hitX >= frontFloatRect.left) & - (hitX <= frontFloatRect.right) & - (hitY >= frontFloatRect.top) & - (hitY <= frontFloatRect.bottom)) - { - macWxFrame = findMacWxFrame(frontFloatingPtr); - } - } - } -#endif + return key; } -void wxApp::doMacKeyDown(void) +void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) { - long menuResult = 0 ; - short keycode ; - short keychar ; - keychar = short(m_event.message & charCodeMask); - keycode = short(m_event.message & keyCodeMask) >> 8 ; - - // Handle menu accelerators - if ( gSFMacHasAppearance ) - { - menuResult = MenuEvent( &m_event ) ; - if ( HiWord( menuResult ) ) - { - doMacInMenuBar( menuResult ) ; - } - else - { - ControlHandle control ; - - GetKeyboardFocus( FrontNonFloatingWindow() , &control ) ; - if ( control && keychar != 0x07 ) - HandleControlKey( control , keycode , keychar , m_event.modifiers ) ; - else - { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { - wxKeyEvent event(wxEVT_CHAR); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_keyCode = macTranslateKey(keychar, m_event.modifiers & (shiftKey|optionKey)); - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); - - theMacWxFrame->ProcessEvent(event); - } - } - } - } + UInt32 menuresult = UMAMenuEvent(ev) ; + if ( HiWord( menuresult ) ) + MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ; else { - if (GetMenuHandle( kwxMacAppleMenuId ) ) - { -// menuResult = MDEF_MenuKey(m_event.message, m_event.modifiers , GetMenuHandle( kwxMacAppleMenuId ) ); - } - else - { - if (m_event.modifiers & cmdKey) - { - menuResult = MenuKey( keychar ) ; - } - } - - if ( HiWord( menuResult ) ) - { - doMacInMenuBar( menuResult ) ; - } - else - { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { - wxKeyEvent event(wxEVT_CHAR); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_keyCode = macTranslateKey(keychar, m_event.modifiers & (shiftKey|optionKey)); - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); + short keycode ; + short keychar ; + keychar = short(ev->message & charCodeMask); + keycode = short(ev->message & keyCodeMask) >> 8 ; - theMacWxFrame->ProcessEvent(event); - } + wxWindow* focus = wxWindow::FindFocus() ; + if ( focus ) + { + wxKeyEvent event(wxEVT_CHAR); + event.m_shiftDown = ev->modifiers & shiftKey; + event.m_controlDown = ev->modifiers & controlKey; + event.m_altDown = ev->modifiers & optionKey; + event.m_metaDown = ev->modifiers & cmdKey; + event.m_keyCode = wxMacTranslateKey(keychar, keycode); + event.m_x = ev->where.h; + event.m_y = ev->where.v; + event.m_timeStamp = ev->when; + event.SetEventObject(focus); + focus->GetEventHandler()->ProcessEvent( event ) ; } } } -void wxApp::doMacAutoKey(void) -{ - doMacKeyDown(); -} - -void wxApp::doMacKeyUp(void) -{ -} - -void wxApp::doMacActivateEvt(void) -{ - HighlightAndActivateWindow( (WindowPtr) m_event.message , m_event.modifiers & activeFlag ) ; -} - -void wxApp::doMacUpdateEvt(void) -{ - WindowPtr theMacWindow = (WindowPtr)(m_event.message); - ::BeginUpdate(theMacWindow); - - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(theMacWindow); - if (theMacWxFrame) - { -// if (!::EmptyRgn(theMacWindow->visRgn)) // this doesn't work with windowshade -// { - if ( theMacWxFrame->MacSetupPort() ) - { - // Erase update region - // we must do this, because controls add their former rect to the inval - // rgn and the background might not have been correct at that moment - ::EraseRect(&theMacWindow->portRect); - - // Can't use UpdateControls since each control has it's own coordinate system - // ::UpdateControls(theMacWindow, theMacWindow->visRgn); - - ::UpdateControls( theMacWindow , theMacWindow->visRgn ) ; - #if 0 - // Draw the grow box - if (cStyle & wxRESIZE_BORDER) - MacDrawGrowIcon(); - #endif - - wxPaintEvent event; - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); - - theMacWxFrame->ProcessEvent(event); - // ::SetThemeWindowBackground( theMacWindow , kThemeActiveDialogBackgroundBrush , false ) ; - ::ClipRect( &theMacWindow->portRect ) ; - ::SetOrigin( 0 , 0 ); - } - else - { - wxASSERT_MSG( false , "unabled to setup window mac port") ; - } - -// } - } - - ::EndUpdate(theMacWindow); -} - -void wxApp::doMacDiskEvt(void) -{ // based on "Programming for System 7" by Gary Little and Tim Swihart - if ((m_event.message >> 16) != noErr) - { - const int kDILeft = 0x0050; // top coord for disk init dialog - const int kDITop = 0x0070; // left coord for disk init dialog - Point mountPoint; - mountPoint.h = kDILeft; - mountPoint.v = kDITop; - int myError = DIBadMount(mountPoint, m_event.message); - } -} - -void wxApp::doMacOsEvt(void) -{ // based on "Programming for System 7" by Gary Little and Tim Swihart - switch ((m_event.message >> 24) & 0x0ff) - { - case suspendResumeMessage: - if (m_event.message & resumeFlag) - doMacResumeEvent(); - else - doMacSuspendEvent(); - break; - case mouseMovedMessage: - doMacMouseMovedMessage(); - break; - } -} - -void wxApp::doMacHighLevelEvent(void) +void wxApp::MacHandleKeyUpEvent( EventRecord *ev ) { - ::AEProcessAppleEvent(&m_event); // System 7 or higher + // nothing to do } -void wxApp::doMacResumeEvent(void) +void wxApp::MacHandleActivateEvent( EventRecord *ev ) { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) + WindowRef window = (WindowRef) ev->message ; + if ( window ) { - if (m_event.message & convertClipboardFlag) - ::TEFromScrap(); - - wxActivateEvent event(wxEVT_ACTIVATE, TRUE); - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); - - theMacWxFrame->ProcessEvent(event); + bool activate = (ev->modifiers & activeFlag ) ; + WindowClass wclass ; + UMAGetWindowClass ( window , &wclass ) ; + if ( wclass == kFloatingWindowClass ) + { + // if it is a floater we activate/deactivate the front non-floating window instead + window = UMAFrontNonFloatingWindow() ; + } + wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( win ) + win->MacActivate( ev , activate ) ; } } -void wxApp::doMacSuspendEvent(void) +void wxApp::MacHandleUpdateEvent( EventRecord *ev ) { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) + WindowRef window = (WindowRef) ev->message ; + wxWindow * win = wxFindWinFromMacWindow( window ) ; + if ( win ) { - ::ZeroScrap(); - ::TEToScrap(); - - wxActivateEvent event(wxEVT_ACTIVATE, FALSE); - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); - - theMacWxFrame->ProcessEvent(event); + win->MacUpdate( ev ) ; } } -void wxApp::doMacMouseMovedMessage(void) -{ // based on "Programming for System 7" by Gary Little and Tim Swihart - if (m_cursorRgn) - ::DisposeRgn(m_cursorRgn); - m_cursorRgn = ::NewRgn(); - ::SetRectRgn(m_cursorRgn, -32768, -32768, 32766, 32766); -} - -void wxApp::doMacInMenuBar(long menuResult) +void wxApp::MacHandleDiskEvent( EventRecord *ev ) { - int macMenuId = HiWord(menuResult); - int macMenuItemNum = LoWord(menuResult); // counting from 1 - - if (macMenuId == 0) // no menu item selected; - return; - if (macMenuId == 128) - { - if (macMenuItemNum != 1) - { // if not the "About" entry (or the separator) - Str255 daName; - ::GetMenuItemText(GetMenuHandle(128), macMenuItemNum, daName); - (void)::OpenDeskAcc(daName); - ::HiliteMenu(0); - return; - } - } - - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { - if ( theMacWxFrame->IsKindOf( CLASSINFO( wxDialog ) ) ) - (( wxDialog *) theMacWxFrame)->MacMenuSelect(m_event, macMenuId, macMenuItemNum); - else if ( theMacWxFrame->IsKindOf( CLASSINFO( wxFrame ) ) ) - (( wxFrame *) theMacWxFrame)->MacMenuSelect(m_event, macMenuId, macMenuItemNum); + if ( HiWord( ev->message ) != noErr ) + { + OSErr err ; + Point point ; + SetPt( &point , 100 , 100 ) ; + + err = DIBadMount( point , ev->message ) ; + wxASSERT( err == noErr ) ; } - ::HiliteMenu(0); } -void wxApp::doMacInContent(WindowPtr window) +void wxApp::MacHandleOSEvent( EventRecord *ev ) { - WindowPtr frontWindow = FrontWindow(); - if (window != frontWindow ) - { -// SFSelectWindow( window ) ; - } - else + switch( ( ev->message & osEvtMessageMask ) >> 24 ) { - ControlHandle control ; - Point localwhere = m_event.where ; - GrafPtr port ; - SInt16 controlpart ; - - ::GetPort( &port ) ; - ::SetPort( window ) ; - ::GlobalToLocal( &localwhere ) ; - - ::SetPort( port ) ; - - if ( !gSFMacHasAppearance ) - { - controlpart = FindControl( localwhere , window , &control ) ; - } - else - { - control = FindControlUnderMouse( localwhere , window , &controlpart ) ; - } - - if ( control && IsControlActive( control ) ) - { - wxControl* wxc = (wxControl*) GetControlReference( control ) ; - - if ( wxWindow::FindFocus() != wxc && wxc->AcceptsFocus() ) - { - wxc->SetFocus() ; - if ( wxWindow::FindFocus() != wxc ) - control = NULL ; // we were not able to change focus - } - - if ( control ) + case suspendResumeMessage : { - if ( !gSFMacHasAppearance) + bool isResuming = ev->message & resumeFlag ; + bool convertClipboard = ev->message & convertClipboardFlag ; + bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ; + if ( isResuming ) { - controlpart = TrackControl( control , localwhere , NULL ) ; + WindowRef oldFrontWindow = NULL ; + WindowRef newFrontWindow = NULL ; + + // in case we don't take care of activating ourselves, we have to synchronize + // our idea of the active window with the process manager's - which it already activated + + if ( !doesActivate ) + oldFrontWindow = UMAFrontNonFloatingWindow() ; + + MacResume( convertClipboard ) ; + + newFrontWindow = UMAFrontNonFloatingWindow() ; + + if ( oldFrontWindow ) + { + wxWindow* win = wxFindWinFromMacWindow( oldFrontWindow ) ; + if ( win ) + win->MacActivate( ev , false ) ; + } + if ( newFrontWindow ) + { + wxWindow* win = wxFindWinFromMacWindow( newFrontWindow ) ; + if ( win ) + win->MacActivate( ev , true ) ; + } } else - { - controlpart = HandleControlClick( control , localwhere , m_event.modifiers , (ControlActionUPP) -1 ) ; - } + { + MacSuspend( convertClipboard ) ; - if ( controlpart ) - { - wxControl* wx = (wxControl*) GetControlReference( control ) ; - if ( wx ) - wx->MacHandleControlClick( control , controlpart ) ; + // in case this suspending did close an active window, another one might + // have surfaced -> lets deactivate that one + + WindowRef newActiveWindow = UMAGetActiveNonFloatingWindow() ; + if ( newActiveWindow ) + { + wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ; + if ( win ) + win->MacActivate( ev , false ) ; + } } } - } - else - { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) - { - doMacContentClick((wxFrame*)theMacWxFrame); // todo : this cast is wrong - } - } - } - -#if 0 - wxFrame* theMacWxFrame = findMacWxFrame(window); - if (theMacWxFrame) - { - WindowPtr MacWindow = findFrontNonFloatingWindow(); - if (window != MacWindow) - { - wxFrame* frontFrame = findMacWxFrame(MacWindow); - if (!frontFrame) wxFatalError("No wxFrame for frontnonfloatingWindow."); - if (!frontFrame->IsModal()) + break ; + case mouseMovedMessage : { - frontFrame->SetFocus(); - doMacContentClick(theMacWxFrame); // jonto - to deal with doc windows behind floaters ? - ::newSelectWindow(window); // WCH : should I be calling some wxMethod? - if (!IsFloating(MacWindow)) + WindowRef window; + + wxWindow* currentMouseWindow = NULL ; + + MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , ¤tMouseWindow ) ; + + if ( currentMouseWindow != wxWindow::s_lastMouseWindow ) { - KeyMap keyMap; - GetKeys(keyMap); - if (!(keyMap[1] & 0x8000)) theMacWxFrame->ShowAsActive(true); // temporary measure... + wxMouseEvent event ; + + bool isDown = !(ev->modifiers & btnState) ; // 1 is for up + bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse + + event.m_leftDown = isDown && !controlDown; + event.m_middleDown = FALSE; + event.m_rightDown = isDown && controlDown; + event.m_shiftDown = ev->modifiers & shiftKey; + event.m_controlDown = ev->modifiers & controlKey; + event.m_altDown = ev->modifiers & optionKey; + event.m_metaDown = ev->modifiers & cmdKey; + event.m_x = ev->where.h; + event.m_y = ev->where.v; + event.m_timeStamp = ev->when; + event.SetEventObject(this); + + if ( wxWindow::s_lastMouseWindow ) + { + wxMouseEvent eventleave(event ) ; + eventleave.SetEventType( wxEVT_LEAVE_WINDOW ) ; + wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave); + } + if ( currentMouseWindow ) + { + wxMouseEvent evententer(event ) ; + evententer.SetEventType( wxEVT_ENTER_WINDOW ) ; + currentMouseWindow->GetEventHandler()->ProcessEvent(evententer); + } + wxWindow::s_lastMouseWindow = currentMouseWindow ; } - } // jonto : not sure yet, but let's try this ... - else ::SysBeep(3); - } - else - { - doMacContentClick(theMacWxFrame); - } - } -#endif -} - -void wxApp::doMacContentClick(wxWindow* frame) -{ - m_mouseWindow = frame; - - wxMouseEvent event(wxEVT_LEFT_DOWN); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = FALSE; - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - if ( m_event.modifiers & controlKey ) - { - event.m_rightDown = TRUE; - } - else - { - event.m_leftDown = TRUE; + + short windowPart = ::FindWindow(ev->where, &window); + + switch (windowPart) + { + case inMenuBar : + break ; + case inSysWindow : + break ; + default: + { + if ( s_lastMouseDown == 0 ) + ev->modifiers |= btnState ; + + wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( win ) + win->MacMouseMoved( ev , windowPart ) ; + } + break; + } + } + break ; + } -#if 0 - event.m_leftDown = !(m_event.modifiers & btnState); - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; -#endif - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - -// m_mouseWindow->ProcessEvent(event); - m_mouseWindow->MacDispatchMouseEvent(event); - -#if 0 - // RightButton is cmdKey click on the mac platform for one-button mouse - Bool rightButton = cCurrentEvent.modifiers & cmdKey; - // altKey is optionKey on the mac platform: - Bool isAltKey = cCurrentEvent.modifiers & optionKey; - - WXTYPE mouseEventType = rightButton ? wxEVENT_TYPE_RIGHT_DOWN - : wxEVENT_TYPE_LEFT_DOWN; - wxMouseEvent theMouseEvent(mouseEventType); - theMouseEvent.leftDown = !rightButton; - theMouseEvent.middleDown = FALSE; - theMouseEvent.rightDown = rightButton; - theMouseEvent.shiftDown = cCurrentEvent.modifiers & shiftKey; - theMouseEvent.controlDown = cCurrentEvent.modifiers & controlKey; - theMouseEvent.altDown = isAltKey; - theMouseEvent.metaDown = FALSE; // mflatt - theMouseEvent.timeStamp = cCurrentEvent.when; // mflatt - - int hitX = cCurrentEvent.where.h; // screen window c.s. - int hitY = cCurrentEvent.where.v; // screen window c.s. - - frame->ScreenToWindow(&hitX, &hitY); -// frameParentArea->ScreenToArea(&hitX, &hitY); // tx coords ? - theMouseEvent.x = hitX; // frame parent area c.s. - theMouseEvent.y = hitY; // frame parent area c.s. - - frame->SeekMouseEventArea(theMouseEvent); -#endif } -void wxApp::doMacInDrag(WindowPtr window) +void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum ) { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) + if (macMenuId == 0) + return; // no menu item selected + + if (macMenuId == kwxMacAppleMenuId && macMenuItemNum > 1) { - // should be desktop, not screen - Rect dragBoundsRect = qd.screenBits.bounds; // can't move to a different screen -//xxx ::InsetRect(&dragBoundsRect, 4, ::GetMBarHeight() + 4); // This is not really necessary - Rect oldPos = (**(((WindowPeek)window)->strucRgn)).rgnBBox; - ::DragReferencedWindow(window, m_event.where, &dragBoundsRect); // jonto - #if 0 - theMacWxFrame->m_x += (**(((WindowPeek)window)->strucRgn)).rgnBBox.left - oldPos.left; - theMacWxFrame->m_y += (**(((WindowPeek)window)->strucRgn)).rgnBBox.top - oldPos.top; + #if ! TARGET_CARBON + Str255 deskAccessoryName ; + GrafPtr savedPort ; + + GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId), macMenuItemNum, deskAccessoryName); + GetPort(&savedPort); + OpenDeskAcc(deskAccessoryName); + SetPort(savedPort); #endif - Move( (**(((WindowPeek)window)->strucRgn)).rgnBBox.left , (**(((WindowPeek)window)->strucRgn)).rgnBBox.top ) ; -#if 0 - theMacWxFrame->wxMacRecalcNewSize(); // Actually, recalc new position only -#endif - } - -#if 0 -// if (window != ::FrontWindow()) - if (window != findFrontNonFloatingWindow()) - { -// wxFrame* frontFrame = findMacWxFrame(::FrontWindow()); - wxFrame* frontFrame = findMacWxFrame(findFrontNonFloatingWindow()); - if (!frontFrame) wxFatalError("No wxFrame for frontWindow."); - if (frontFrame->IsModal()) - { - ::SysBeep(3); - return; - } } - - wxFrame* theMacWxFrame = findMacWxFrame(window); - if (theMacWxFrame) - { - Rect dragBoundsRect = qd.screenBits.bounds; // can't move to a different screen - ::InsetRect(&dragBoundsRect, 4, ::GetMBarHeight() + 4); // This is not really necessary - newDragWindow(window, cCurrentEvent.where, &dragBoundsRect); // jonto - theMacWxFrame->wxMacRecalcNewSize(); // Actually, recalc new position only - if (!IsFloating(window)) - { - theMacWxFrame->ShowAsActive(true); // temporary measure... - } - } -#endif -} - -void wxApp::doMacInGrow(WindowPtr window) -{ - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) + else { - Rect growSizeRect; // WCH: growSizeRect should be a member of wxFrame class - growSizeRect.top = 1; // minimum window height - growSizeRect.left = 1; // minimum window width - growSizeRect.bottom = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top; - growSizeRect.right = qd.screenBits.bounds.right - qd.screenBits.bounds.left; - long windSize = ::GrowWindow(window, m_event.where, &growSizeRect); - if (windSize != 0) - { - int nWidth = LoWord(windSize); - int nHeight = HiWord(windSize); - int oWidth, oHeight; - theMacWxFrame->GetSize(&oWidth, &oHeight); - if (nWidth == 0) nWidth = oWidth; - if (nHeight == 0) nHeight = oHeight; - theMacWxFrame->SetSize( -1, -1, nWidth, nHeight, wxSIZE_USE_EXISTING); - } - } + wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ; + if ( frontwindow && wxMenuBar::s_macInstalledMenuBar ) + wxMenuBar::s_macInstalledMenuBar->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ; + } + HiliteMenu(0); } -void wxApp::doMacInGoAway(WindowPtr window) -{ - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) - { - if (TrackGoAway(window, m_event.where)) - { - // TODO: Stefan, I think you need to send a wxCloseEvent to the window - // here. The OnCloseWindow handler will take care of delete the frame - // if it wishes to (there should be a default wxFrame::OnCloseWindow - // that destroys the frame). - if (theMacWxFrame->OnClose()) { -#if WXGARBAGE_COLLECTION_ON - theMacWxFrame->Show(FALSE); -#else - delete theMacWxFrame; -#endif - } - } - } -} - -void wxApp::doMacInZoom(WindowPtr window, short windowPart) +/* +long wxApp::MacTranslateKey(char key, int mods) { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) - { - if (TrackBox(window, m_event.where, windowPart)) - { -#if 0 - theMacWxFrame->Maximize(windowPart == inZoomOut); -#endif - } - } } -long wxApp::macTranslateKey(char key, int mods) +void wxApp::MacAdjustCursor() { - static Handle transH = NULL; - static unsigned long transState = 0; - static Handle ScriptH = NULL; - static short region_code = 1; - - if (!ScriptH) { // tom: don't guess the regioncode!!!! - struct ItlbRecord * r; - ScriptH = GetResource('itlb',0); - if (ScriptH) { - HLock(ScriptH); - r = (ItlbRecord*)*ScriptH; - region_code = r->itlbKeys; - HUnlock(ScriptH); - } - } - - switch (key) { - case 0x7e: - case 0x3e: - key = WXK_UP; - break; - case 0x7d: - case 0x3d: - key = WXK_DOWN; - break; - case 0x7b: - case 0x3b: - key = WXK_LEFT; - break; - case 0x7c: - case 0x3c: - key = WXK_RIGHT; - break; - case 0x24: - case 0x4c: - key = WXK_RETURN; - break; - case 0x30: - key = WXK_TAB; - break; - case 0x33: - key = WXK_BACK; - break; - case 0x75: - key = WXK_DELETE; - break; - case 0x73: - key = WXK_HOME; - break; - case 0x77: - key = WXK_END; - break; - case 0x74: - key = WXK_PAGEUP; - break; - case 0x79: - key = WXK_PAGEDOWN; - break; - default: - if (!transH) { - transH = GetIndResource('KCHR', 1); - HNoPurge(transH); - } -#if 0 //Tom replaces - if (transH) { - // Only let shift & option modify the key: - HLock(transH); - key = KeyTranslate(*transH, (key & 0x7F) | mods, &transState) & charCodeMask; - HUnlock(transH); -#else - if (0) { // tom fettig@dfki.uni-sb.de - // why if(0): - // code is not correct, see inside Macintosh: Text 1-87 - // and 'itlk'-resource!! - // and it is not necessary, as the translated char is in - // cCurrrentEvent.message!! - // Only let shift & option modify the key: - HLock(transH); - key = KeyTranslate(*transH, (key & 0x7F) | mods, &transState) & charCodeMask; - HUnlock(transH); -#endif - } - } // end switch - - return key; } +*/ +/* void wxApp::macAdjustCursor() { - if (m_event.what != kHighLevelEvent) + if (ev->what != kHighLevelEvent) { wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); if (theMacWxFrame) { - if (!theMacWxFrame->MacAdjustCursor(m_event.where)) + if (!theMacWxFrame->MacAdjustCursor(ev->where)) ::SetCursor(&(qd.arrow)); } } } -*/ +*/ \ No newline at end of file diff --git a/src/mac/apprsrc.r b/src/mac/apprsrc.r index 408a135a9f..343157d8d1 100644 --- a/src/mac/apprsrc.r +++ b/src/mac/apprsrc.r @@ -7,611 +7,12 @@ resource 'STR#' ( 128 , "Simple Alert Messages" ) "This application needs at least a MacPlus" , "This application needs more memory" , "This application is out of memory" , - "This application needs at least System 7" , + "This application needs at least System 7.5" , + "About this wxWindows Application" , "This application needs Appearance extension (built in with System 8) - this restriction will be relieved in the final release" } } ; -data 'alis' (128, "Libs alias") { - $"0000 0000 00CE 0002 0001 0A58 5858 5858" - $"5858 5858 5800 0000 0000 0000 0000 0000" - $"0000 0000 0000 AB9F 536B 4244 0000 0002" - $"EE7C 044C 6962 7300 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0003 1F71 AE82 7707 006A 0016 026C" - $"01A3 0001 0001 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0009 5858 5858 5858" - $"5858 5800 0001 0004 0002 EE7C 0002 0019" - $"5858 5858 5858 5858 5858 5858 5858 5858" - $"5858 5858 5858 5858 5800 FFFF 0000" -}; - -data 'CSOR' (0) { - $"1441 6476 616E 6365 6420 436F 6E63 6570" - $"7473 2041 47" -}; - -resource 'FREF' (128) { - 'APPL', - 0, - "" -}; - -resource 'FREF' (129) { - 'shlb', - 1, - "" -}; - -resource 'FREF' (130) { - 'PLPW', - 2, - "" -}; - -resource 'icl4' (128) { - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0666 6666 0000 0000 0000 0006 6666 6660" - $"0666 6666 0000 0000 0000 0006 6666 6660" - $"0666 6660 0000 0000 0000 0000 6666 6660" - $"0666 6660 0000 0006 6000 0000 6666 6660" - $"0666 6660 0000 0666 6600 0000 6666 6660" - $"0666 6660 0000 6606 6600 0000 6666 6660" - $"0666 6660 0000 6606 0000 0000 6666 6660" - $"0666 6600 0000 0666 6000 0000 0666 6660" - $"0666 6600 0000 0006 6600 0000 0666 6660" - $"0666 6600 0000 0006 0060 0000 0666 6660" - $"0666 6660 0000 0006 6600 0000 6666 6660" - $"0666 6660 0000 0666 6000 0000 6666 6660" - $"0666 6666 0000 6606 0000 0006 6666 6660" - $"0666 6666 6000 6606 0000 0066 6666 6660" - $"0666 6666 6000 0666 6600 0066 6666 6660" - $"0666 6666 6600 0006 0600 0666 6666 6660" - $"0666 6666 6600 0006 0000 0666 6666 6660" - $"0666 6666 6660 0006 0000 6666 6666 6660" - $"0666 6666 6666 0006 0006 6666 6666 6660" - $"0666 6666 6666 0006 0006 6666 6666 6660" - $"0666 6666 6666 6006 0066 6666 6666 6660" - $"0666 6666 6666 6006 0066 6666 6666 6660" - $"0666 6666 6666 6006 0066 6666 6666 6660" - $"0666 6666 6666 6606 0666 6666 6666 6660" - $"0666 6666 6666 6606 0666 6666 6666 6660" - $"0666 6666 6666 6606 0666 6666 6666 6660" - $"0666 6666 6666 6606 0666 6666 6666 6660" - $"0666 6666 6666 6660 6666 6666 6666 6660" - $"0666 6666 6666 6666 6666 6666 6666 6660" - $"0666 6666 6666 6666 6666 6666 6666 6660" - $"0666 6666 6666 6666 6666 6666 6666 6660" -}; - -resource 'icl4' (129, "Editor icon-generic ") { - $"0FFF FFFF FFFF FFFF FFFF FFFF FFFF 0000" - $"F000 0000 0000 0000 0000 0000 000C F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCF FFFF FFFF FFFF FFFF CCCC F000" - $"F0CC CCFD DDDD DDDD DDDD DDDD FCCC F000" - $"F0CC CCFD DDDD DDDF FDDD DDDD FCCC F000" - $"F0CC CFDD DDDD DFFF FFDD DDDD DFCC F000" - $"F0FC CFDD DDDD FFCF FFDD DDDD DFCC F000" - $"FF0F 0FDD DDDD FFCF DDDD DDDD DFCC F0F0" - $"F00F 0FFD DDDD DFFF FDDD DDDD FFCC FFCF" - $"000F 0CFD DDDD DDDF FFDD DDDD FCCC F0CF" - $"000F 0CCF DDDD DDDF DDDD DDDF CCCC CCCF" - $"000F 0CCF FDDD DDDF FFDD DDFC CCCC CCCF" - $"000F 0CCC FDDD DFFF FDDD DDFC CCCC CCCF" - $"000F 0CCC CFDD FFCF DDDD DFCC CCCC CCCF" - $"000F 0CCC CFDD FFCF DDDD DFCC CCCC CCCF" - $"000F 0CCC CCFD DFFF FFDD FCCC CCCC CCCF" - $"000F 0CCC CCFF DDDF DFDF CCCC CCCC CCCF" - $"000F 0CCC CCCF DDDF DDDF CCCC CCCC CCCF" - $"000F 0CCC CCCC FDDF DDFC CCCC CCCC FCCF" - $"F00F 0CCC CCCC FDDF DDFC CCCC CCCC FFCF" - $"FF0F 0CCC CCCC FDDF DDFC CCCC CCCC F0F0" - $"F0F0 CCCC CCCC CFDF DFCC CCCC CCCC F000" - $"F00C CCCC CCCC CFDF DFCC CCCC CCCC F000" - $"F0CC CCCC CCCC CFDF DFCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCFF FCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"FCCC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"0FFF FFFF FFFF FFFF FFFF FFFF FFFF" -}; - -resource 'icl4' (130, "Editor icon-generic ") { - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"000F FFFF FFFF FFFF FFFF FFFF FFFF F000" - $"000F 0000 0000 0000 0000 0000 0000 F000" - $"000F 0CCC CCCC CCCC CCCC CCCC CCCC F000" - $"FFFF DDDD DDDD DDDD DDDD DDDD DDDD FFFF" - $"F00D 0000 0000 0000 0000 0000 0000 D00F" - $"F0CD 0CFD DDDD DDDD DDDD DDDD FCCC DCCF" - $"F0CD 0CFD DDDD DDDF FDDD DDDD FCCC DCCF" - $"F0CD 0FDD DDDD DFFF FFDD DDDD DFCC DCCF" - $"F0CD 0FDD DDDD FFCF FFDD DDDD DFCC DCCF" - $"F0CD 0FDD DDDD FFCF DDDD DDDD DFCC DCCF" - $"F0CD 0FFD DDDD DFFF FDDD DDDD FFCC DCCF" - $"F0CD 0CFD DDDD DDDF FFDD DDDD FCCC DCCF" - $"F0CD 0CCF DDDD DDDF DDDD DDDF CCCC DCCF" - $"F0CD 0CCF FDDD DDDF FFDD DDFC CCCC DCCF" - $"F0CD 0CCC FDDD DFFF FDDD DDFC CCCC DCCF" - $"F0CD 0CCC CFDD FFCF DDDD DFCC CCCC DCCF" - $"F0CD 0CCC CFDD FFCF DDDD DFCC CCCC DCCF" - $"F0CD 0CCC CCFD DFFF FFDD FCCC CCCC DCCF" - $"F0CD 0CCC CCFF DDDF DFDF CCCC CCCC DCCF" - $"F0CD 0CCC CCCF DDDF DDDF CCCC CCCC DCCF" - $"F0CD 0CCC CCCC FDDF DDFC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC FDDF DDFC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC FDDF DDFC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC CFDF DFCC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC CFDF DFCC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC CFDF DFCC CCCC CCCC DCCF" - $"F0CD DDDD DDDD DDFF FDDD DDDD DDDD FFFF" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF F0" -}; - -resource 'icl8' (128) { - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"00AB ABAB ABAB ABAB 0000 0000 0000 0000" - $"0000 0000 0000 00AB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB 0000 0000 0000 0000" - $"0000 0000 0000 00AB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 0000 0000" - $"0000 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 0000 00AB" - $"AB00 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 00AB ABAB" - $"ABAB 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 ABAB 00AB" - $"ABAB 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 ABAB 00AB" - $"0000 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB 0000 0000 0000 00AB ABAB" - $"AB00 0000 0000 0000 00AB ABAB ABAB AB00" - $"00AB ABAB ABAB 0000 0000 0000 0000 00AB" - $"ABAB 0000 0000 0000 00AB ABAB ABAB AB00" - $"00AB ABAB ABAB 0000 0000 0000 0000 00AB" - $"0000 AB00 0000 0000 00AB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 0000 00AB" - $"ABAB 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 00AB ABAB" - $"AB00 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB 0000 0000 ABAB 00AB" - $"0000 0000 0000 00AB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB AB00 0000 ABAB 00AB" - $"0000 0000 0000 ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB AB00 0000 00AB ABAB" - $"ABAB 0000 0000 ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB 0000 0000 00AB" - $"00AB 0000 00AB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB 0000 0000 00AB" - $"0000 0000 00AB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB AB00 0000 00AB" - $"0000 0000 ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB 0000 00AB" - $"0000 00AB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB 0000 00AB" - $"0000 00AB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB AB00 00AB" - $"0000 ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB AB00 00AB" - $"0000 ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB AB00 00AB" - $"0000 ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB 00AB" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB 00AB" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB 00AB" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB 00AB" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"ABAB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB ABAB" - $"ABAB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB ABAB" - $"ABAB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB ABAB" - $"ABAB ABAB ABAB ABAB ABAB ABAB ABAB AB" -}; - -resource 'icl8' (130, "Editor icon-generic ") { - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FF00 0000" - $"0000 00FF 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 00F5 FF00 0000" - $"0000 00FF F5F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F8 FF00 0000" - $"FFFF FFFF F9F9 F9F9 F9F9 F9F9 F9F9 F9F9" - $"F9F9 F9F9 F9F9 F9F9 F9F9 F9F9 FFFF FFFF" - $"FF00 F5F9 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 F9F5 00FF" - $"FF00 F6F9 002B FFF9 F9F9 F9F9 F9F9 F9F9" - $"F9F9 F9F9 F9F9 F9F9 FF2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B FFF9 F9F9 F9F9 F9F9 F9FF" - $"FFF9 F9F9 F9F9 F9F9 FF2B 2BF8 F92B F8FF" - $"FF00 F6F9 00FF F9F9 F9F9 F9F9 F9FF FFFF" - $"FFFF F9F9 F9F9 F9F9 F9FF 2BF8 F92B F8FF" - $"FF00 F6F9 00FF F9F9 F9F9 F9F9 FFFF 2BFF" - $"FFFF F9F9 F9F9 F9F9 F9FF 2BF8 F92B F8FF" - $"FF00 F6F9 00FF F9F9 F9F9 F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9F9 F9F9 F9FF 2BF8 F92B F8FF" - $"FF00 F6F9 00FF FFF9 F9F9 F9F9 F9FF FFFF" - $"FFF9 F9F9 F9F9 F9F9 FFFF 2BF8 F92B F8FF" - $"FF00 F6F9 002B FFF9 F9F9 F9F9 F9F9 F9FF" - $"FFFF F9F9 F9F9 F9F9 FF2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2BFF F9F9 F9F9 F9F9 F9FF" - $"F9F9 F9F9 F9F9 F9FF 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2BFF FFF9 F9F9 F9F9 F9FF" - $"FFFF F9F9 F9F9 FF2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B FFF9 F9F9 F9FF FFFF" - $"FFF9 F9F9 F9F9 FF2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2BFF F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9FF 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2BFF F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9FF 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B FFF9 F9FF FFFF" - $"FFFF F9F9 FF2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B FFFF F9F9 F9FF" - $"F9FF F9FF 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2BFF F9F9 F9FF" - $"F9F9 F9FF 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B FFF9 F9FF" - $"F9F9 FF2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B FFF9 F9FF" - $"F9F9 FF2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B FFF9 F9FF" - $"F9F9 FF2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B 2BFF F9FF" - $"F9FF 2B2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B 2BFF F9FF" - $"F9FF 2B2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 00F8 F82B 2B2B 2B2B 2BFF F9FF" - $"F9FF 2B2B 2B2B 2B2B F8F8 F8F8 F9F7 F8FF" - $"FF00 F6F9 F9F9 F9F9 F9F9 F9F9 F9F9 FFFF" - $"FFF9 F9F9 F9F9 F9F9 F9F9 F9F9 FFFF FFFF" - $"FF00 F62B 2B2B 2B2B 2B2B 2B2B 2B2B 2B2B" - $"2B2B 2B2B 2B2B 2B2B 2B2B 2BF8 FF00 0000" - $"FFF5 F8F8 F8F8 F8F8 F8F8 F8F8 F8F8 F8F8" - $"F8F8 F8F8 F8F8 F8F8 F8F8 F8F8 FF00 0000" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FF" -}; - -resource 'icl8' (129) { - $"00FF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF 0000 0000" - $"FF00 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 00F6 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6FF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F62B FFF9 F9F9 F9F9 F9F9 F9F9" - $"F9F9 F9F9 F9F9 F9F9 FF2B F6F7 FF00 0000" - $"FF00 F6F6 F62B FFF9 F9F9 F9F9 F9F9 F9FF" - $"FFF9 F9F9 F9F9 F9F9 FF2B F6F7 FF00 0000" - $"FF00 F7F6 F6FF F9F9 F9F9 F9F9 F9FF FFFF" - $"FFFF F9F9 F9F9 F9F9 F9FF F6F7 FF00 0000" - $"FF00 FFF7 F6FF F9F9 F9F9 F9F9 FFFF 2BFF" - $"FFFF F9F9 F9F9 F9F9 F9FF F6F7 FF00 0000" - $"FFFF 00FF 00FF F9F9 F9F9 F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9F9 F9F9 F9FF F6F7 FF00 FF00" - $"FF00 00FF 00FF FFF9 F9F9 F9F9 F9FF FFFF" - $"FFF9 F9F9 F9F9 F9F9 FFFF F6F7 FFFF F7FF" - $"0000 00FF 00F6 FFF9 F9F9 F9F9 F9F9 F9FF" - $"FFFF F9F9 F9F9 F9F9 FFF6 F6F7 FF00 F7FF" - $"0000 00FF 00F6 F6FF F9F9 F9F9 F9F9 F9FF" - $"F9F9 F9F9 F9F9 F9FF F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6FF FFF9 F9F9 F9F9 F9FF" - $"FFFF F9F9 F9F9 FFF6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 FFF9 F9F9 F9FF FFFF" - $"FFF9 F9F9 F9F9 FFF6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6FF F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9FF F6F6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6FF F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9FF F6F6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6F6 FFF9 F9FF FFFF" - $"FFFF F9F9 FFF6 F6F6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6F6 FFFF F9F9 F9FF" - $"F9FF F9FF F6F6 F6F6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6F6 F6FF F9F9 F9FF" - $"F9F9 F9FF F6F6 F6F6 F6F6 F6F6 F7F6 F7FF" - $"0000 00FF 00F6 F6F6 F6F6 F6F6 FFF9 F9FF" - $"F9F9 FFF6 F6F6 F6F6 F6F6 F6F7 FFF7 F7FF" - $"FF00 00FF 00F6 F6F6 F6F6 F6F6 FFF9 F9FF" - $"F9F9 FFF6 F6F6 F6F6 F6F6 F6F7 FFFF F7FF" - $"FFFF 00FF 00F6 F6F6 F6F6 F6F6 FFF9 F9FF" - $"F9F9 FFF6 F6F6 F6F6 F6F6 F6F7 FF00 FF00" - $"FF00 FF00 F6F6 F6F6 F6F6 F6F6 F6FF F9FF" - $"F9FF F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 00F6 F6F6 F6F6 F6F6 F6F6 F6FF F9FF" - $"F9FF F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6FF F9FF" - $"F9FF F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 FFFF" - $"FFF6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FFF6 F7F7 F7F7 F7F7 F7F7 F7F7 F7F7 F7F7" - $"F7F7 F7F7 F7F7 F7F7 F7F7 F7F7 FF00 0000" - $"00FF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF" -}; - -resource 'icm#' (129) { - { /* array: 2 elements */ - /* [1] */ - $"", - /* [2] */ - $"" - } -}; - -resource 'icm#' (128) { - { /* array: 2 elements */ - /* [1] */ - $"", - /* [2] */ - $"" - } -}; - -resource 'icm#' (130) { - { /* array: 2 elements */ - /* [1] */ - $"", - /* [2] */ - $"" - } -}; - -resource 'icm4' (129) { - $"" -}; - -resource 'icm4' (128) { - $"" -}; - -resource 'icm4' (130) { - $"" -}; - -resource 'icm8' (129) { - $"" -}; - -resource 'icm8' (128) { - $"" -}; - -resource 'icm8' (130) { - $"" -}; - -resource 'ICN#' (128) { - { /* array: 2 elements */ - /* [1] */ - $"0000 0000 7F00 01FE 7F00 01FE 7E00 00FE" - $"7E01 80FE 7E07 C0FE 7E0D C0FE 7E0D 00FE" - $"7C07 807E 7C01 C07E 7C01 207E 7E01 C0FE" - $"7E07 80FE 7F0D 01FE 7F8D 03FE 7F87 C3FE" - $"7FC1 47FE 7FC1 07FE 7FE1 0FFE 7FF1 1FFE" - $"7FF1 1FFE 7FF9 3FFE 7FF9 3FFE 7FF9 3FFE" - $"7FFD 7FFE 7FFD 7FFE 7FFD 7FFE 7FFD 7FFE" - $"7FFE FFFE 7FFF FFFE 7FFF FFFE 7FFF FFFE", - /* [2] */ - $"0000 0000 7F00 01FE 7F00 01FE 7E00 00FE" - $"7E01 80FE 7E07 C0FE 7E0D C0FE 7E0D 00FE" - $"7C07 807E 7C01 C07E 7C01 207E 7E01 C0FE" - $"7E07 80FE 7F0D 01FE 7F8D 03FE 7F87 C3FE" - $"7FC1 47FE 7FC1 07FE 7FE1 0FFE 7FF1 1FFE" - $"7FF1 1FFE 7FF9 3FFE 7FF9 3FFE 7FF9 3FFE" - $"7FFD 7FFE 7FFD 7FFE 7FFD 7FFE 7FFD 7FFE" - $"7FFE FFFE 7FFF FFFE 7FFF FFFE 7FFF FFFE" - } -}; - -resource 'ICN#' (129, "Editor icon-generic ") { - { /* array: 2 elements */ - /* [1] */ - $"7FFF FFF0 8000 0008 8000 0008 8000 0008" - $"82AA AA88 8200 0088 8200 0088 8201 8088" - $"A407 C048 D40D C04A 940D 004D 1607 80C9" - $"1201 C081 1101 0101 1181 C201 1087 8201" - $"104D 0401 104D 0401 1027 C801 1031 5001" - $"1011 1009 9009 200D D009 200A A009 2008" - $"8005 4008 8005 4008 8005 4008 8003 8008" - $"8000 0008 8000 0008 8000 0008 7FFF FFF0", - /* [2] */ - $"0000 0000 1FFF FFF8 1FFF FFF8 1FFF FFF8" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFF8 FFFF FFF8 FFFF FFF8" - } -}; - -resource 'ICN#' (130, "Editor icon-generic ") { - { /* array: 2 elements */ - /* [1] */ - $"0000 0000 1FFF FFF8 1000 0008 1000 0008" - $"FAAA AAAF 9200 00A1 8200 0089 9201 8081" - $"8407 C049 940D C041 840D 0049 9607 80C1" - $"8201 C089 9101 0101 8181 C209 9087 8201" - $"804D 0409 904D 0401 8027 C809 9031 5001" - $"8011 1009 9009 2001 8009 2009 9009 2001" - $"8005 4009 9005 4001 8005 4009 9557 D55F" - $"8000 0008 8000 0008 FFFF FFF8", - /* [2] */ - $"0000 0000 1FFF FFF8 1FFF FFF8 1FFF FFF8" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFF8 FFFF FFF8 FFFF FFF8" - } -}; - -resource 'ics#' (129, "Editor icon-generic ") { - { /* array: 2 elements */ - /* [1] */ - $"3FFC 2004 E007 8001 8001 8001 8001 8001" - $"8001 8001 8001 8001 8001 8007 8004 FFFC", - /* [2] */ - $"3FFC 3FFC FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFC FFFC" - } -}; - -resource 'ics#' (128) { - { /* array: 2 elements */ - /* [1] */ - $"", - /* [2] */ - $"" - } -}; - -resource 'ics#' (130, "Editor icon-generic ") { - { /* array: 2 elements */ - /* [1] */ - $"3FFC 2004 E007 8001 8001 8001 8001 8001" - $"8001 8001 8001 8001 8001 8007 8004 FFFC", - /* [2] */ - $"3FFC 3FFC FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFC FFFC" - } -}; - -resource 'ics4' (129, "Editor icon-generic ") { - $"00FF FFFF FFFF FF00 00F0 0000 0000 CF00" - $"FFFD DDDD DDDD DFFF F0D0 0000 0000 CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0DC CCCC CCCC CDCF F0DD DDDD DDDD DFFF" - $"FCCC CCCC CCCC CF00 FFFF FFFF FFFF FF" -}; - -resource 'ics4' (128) { - $"" -}; - -resource 'ics4' (130, "Editor icon-generic ") { - $"00FF FFFF FFFF FF00 00F0 0000 0000 CF00" - $"FFFD DDDD DDDD DFFF F0D0 0000 0000 CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0DC CCCC CCCC CDCF F0DD DDDD DDDD DFFF" - $"FCCC CCCC CCCC CF00 FFFF FFFF FFFF FF" -}; - -resource 'ics8' (129, "Editor icon-generic ") { - $"0000 FFFF FFFF FFFF FFFF FFFF FFFF 0000" - $"0000 FFF5 F5F5 F5F5 F5F5 F5F5 F6FF 0000" - $"FFFF FFF9 F9F9 F9F9 F9F9 F9F9 F9FF FFFF" - $"FFF5 F9F5 F5F5 F5F5 F5F5 F5F5 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F92B 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F9 F9F9 F9F9 F9F9 F9F9 F9FF FFFF" - $"FFF6 F8F8 F8F8 F8F8 F8F8 F8F8 F8FF 0000" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF" -}; - -resource 'ics8' (128) { - $"" -}; - -resource 'ics8' (130, "Editor icon-generic ") { - $"0000 FFFF FFFF FFFF FFFF FFFF FFFF 0000" - $"0000 FFF5 F5F5 F5F5 F5F5 F5F5 F6FF 0000" - $"FFFF FFF9 F9F9 F9F9 F9F9 F9F9 F9FF FFFF" - $"FFF5 F9F5 F5F5 F5F5 F5F5 F5F5 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F92B 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F9 F9F9 F9F9 F9F9 F9F9 F9FF FFFF" - $"FFF6 F8F8 F8F8 F8F8 F8F8 F8F8 F8FF 0000" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF" -}; - -data 'iSNP' (129) { - $"0000" /* .. */ -}; - -data 'iSNP' (128) { - $"0000" /* .. */ -}; - -data 'iSNP' (130) { - $"0000" /* .. */ -}; - -resource 'BNDL' (128) { - 'CSOR', - 0, - { /* array TypeArray: 2 elements */ - /* [1] */ - 'ICN#', - { /* array IDArray: 3 elements */ - /* [1] */ - 0, 128, - /* [2] */ - 1, 129, - /* [3] */ - 2, 130 - }, - /* [2] */ - 'FREF', - { /* array IDArray: 3 elements */ - /* [1] */ - 0, 128, - /* [2] */ - 1, 129, - /* [3] */ - 2, 130 - } - } -}; - resource 'MENU' (1, preload) { 1, textMenuProc, 0b11111111111111111111111111111110 , enabled, apple , @@ -624,3 +25,4 @@ resource 'MENU' (1, preload) resource 'MBAR' (1,preload) { { 1 } ; +} ; \ No newline at end of file diff --git a/src/mac/bitmap.cpp b/src/mac/bitmap.cpp index 1e6255f551..3a66121d49 100644 --- a/src/mac/bitmap.cpp +++ b/src/mac/bitmap.cpp @@ -20,11 +20,83 @@ #include "wx/icon.h" #include "wx/log.h" +extern "C" +{ + #include "xpm.h" +} ; + #if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) #endif +#include + +CTabHandle wxMacCreateColorTable( int numColors ) +{ + CTabHandle newColors; /* Handle to the new color table */ + short index; /* Index into the table of colors */ + /* Allocate memory for the color table */ + newColors = (CTabHandle)NewHandleClear( sizeof (ColorTable) + + sizeof (ColorSpec) * (numColors - 1) ); + if (newColors != nil) + { + /* Initialize the fields */ + (**newColors).ctSeed = GetCTSeed(); + (**newColors).ctFlags = 0; + (**newColors).ctSize = numColors - 1; + /* Initialize the table of colors */ + } + return newColors ; +} + +void wxMacDestroyColorTable( CTabHandle colors ) +{ + DisposeHandle( (Handle) colors ) ; +} + +void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) +{ + (**newColors).ctTable[index].value = index; + (**newColors).ctTable[index].rgb.red = 0 ;// someRedValue; + (**newColors).ctTable[index].rgb.green = 0 ; // someGreenValue; + (**newColors).ctTable[index].rgb.blue = 0 ; // someBlueValue; +} + +GWorldPtr wxMacCreateGWorld( int height , int width , int depth ) +{ + OSErr err = noErr ; + GWorldPtr port ; + Rect rect = { 0 , 0 , width , height } ; + + if ( depth < 0 ) + { + // get max pixel depth + CGrafPtr port ; + GetCWMgrPort( &port ) ; + GDHandle maxDevice ; + + maxDevice = GetMaxDevice( &port->portRect ) ; + if ( maxDevice ) + depth = (**((**maxDevice).gdPMap)).pixelSize ; + else + depth = 8 ; + } + + err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ; + if ( err == noErr ) + { + return port ; + } + return NULL ; +} + +void wxMacDestroyGWorld( GWorldPtr gw ) +{ + if ( gw ) + DisposeGWorld( gw ) ; +} + wxBitmapRefData::wxBitmapRefData() { m_ok = FALSE; @@ -34,17 +106,43 @@ wxBitmapRefData::wxBitmapRefData() m_quality = 0; m_numColors = 0; m_bitmapMask = NULL; + m_hBitmap = NULL ; + m_hPict = NULL ; + m_bitmapType = kMacBitmapTypeUnknownType ; } wxBitmapRefData::~wxBitmapRefData() { - /* - * TODO: delete the bitmap data here. - */ - - if (m_bitmapMask) - delete m_bitmapMask; + switch (m_bitmapType) + { + case kMacBitmapTypePict : + { + if ( m_hPict ) + { + KillPicture( m_hPict ) ; + m_hPict = NULL ; + } + } + break ; + case kMacBitmapTypeGrafWorld : + { + if ( m_hBitmap ) + { + wxMacDestroyGWorld( m_hBitmap ) ; + m_hBitmap = NULL ; + } + } + break ; + default : + // unkown type ? + break ; + } ; + + if (m_bitmapMask) + { + delete m_bitmapMask; m_bitmapMask = NULL; + } } wxList wxBitmap::sm_handlers; @@ -71,8 +169,57 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits M_BITMAPDATA->m_height = the_height ; M_BITMAPDATA->m_depth = no_bits ; M_BITMAPDATA->m_numColors = 0; - - /* TODO: create the bitmap from data */ + if ( no_bits == 1 ) + { + M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; + M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( the_width , the_height , no_bits ) ; + M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ; + + CGrafPtr origPort ; + GDHandle origDevice ; + + GetGWorld( &origPort , &origDevice ) ; + SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ; + + // bits is a word aligned array + + unsigned char* linestart = (unsigned char*) bits ; + int linesize = ( the_width / 16 ) * 2 ; + if ( the_width % 16 ) + { + linesize += 2 ; + } ; + + RGBColor colors[2] = { + { 0xFFFF , 0xFFFF , 0xFFFF } , + { 0, 0 , 0 } + } ; + + for( int y = 0 ; y < the_height ; ++y , linestart += linesize ) + { + for( int x = 0 ; x < the_width ; ++x ) + { + int index = x / 8 ; + int bit = x % 8 ; + int mask = 1 << bit ; + if ( linestart[index] & mask ) + { + SetCPixel( x , y , &colors[1] ) ; + } + else + { + SetCPixel( x , y , &colors[0] ) ; + } + } + + } + + SetGWorld( origPort , origDevice ) ; + } + else + { + //multicolor BITMAPs not yet implemented + } if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this); @@ -102,13 +249,10 @@ wxBitmap::wxBitmap(const wxString& filename, long type) wxTheBitmapList->AddBitmap(this); } -/* TODO: maybe allow creation from XPM -// Create from data wxBitmap::wxBitmap(const char **data) { (void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); } -*/ bool wxBitmap::Create(int w, int h, int d) { @@ -120,11 +264,19 @@ bool wxBitmap::Create(int w, int h, int d) M_BITMAPDATA->m_height = h; M_BITMAPDATA->m_depth = d; - /* TODO: create new bitmap */ - + M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; + M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( w , h , d ) ; + M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ; return M_BITMAPDATA->m_ok; } +void wxBitmap::SetHBITMAP(WXHBITMAP bmp) +{ + M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; + M_BITMAPDATA->m_hBitmap = bmp ; + M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ; +} + bool wxBitmap::LoadFile(const wxString& filename, long type) { UnRef(); @@ -386,6 +538,52 @@ bool wxBitmapHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, * Standard handlers */ +class WXDLLEXPORT wxPICTResourceHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxPICTResourceHandler) +public: + inline wxPICTResourceHandler() + { + m_name = "Macintosh Pict resource"; + m_extension = ""; + m_type = wxBITMAP_TYPE_PICT_RESOURCE; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); +}; +IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler) + +bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ + Str255 theName ; + + strcpy( (char*) theName , name ) ; + c2pstr( (char*) theName ) ; + + PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ; + if ( thePict ) + { + PictInfo theInfo ; + + GetPictInfo( thePict , &theInfo , 0 , 0 , systemMethod , 0 ) ; + DetachResource( (Handle) thePict ) ; + M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypePict ; + M_BITMAPHANDLERDATA->m_hPict = thePict ; + M_BITMAPHANDLERDATA->m_width = theInfo.sourceRect.right - theInfo.sourceRect.left ; + M_BITMAPHANDLERDATA->m_height = theInfo.sourceRect.bottom - theInfo.sourceRect.top ; + + M_BITMAPHANDLERDATA->m_depth = theInfo.depth ; + M_BITMAPHANDLERDATA->m_ok = true ; + M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ; +// M_BITMAPHANDLERDATA->m_bitmapPalette; +// M_BITMAPHANDLERDATA->m_quality; + return TRUE ; + } + return FALSE ; +} + /* TODO: bitmap handlers, a bit like this: class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler { @@ -404,6 +602,251 @@ public: IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler) */ +class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxXPMFileHandler) +public: + inline wxXPMFileHandler(void) + { + m_name = "XPM bitmap file"; + m_extension = "xpm"; + m_type = wxBITMAP_TYPE_XPM; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth = -1, int desiredHeight = -1); + virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); +}; +IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler) + +bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ +#if USE_XPM_IN_MSW + XImage *ximage; + XpmAttributes xpmAttr; + HDC dc; + + M_BITMAPHANDLERDATA->m_ok = FALSE; + dc = CreateCompatibleDC(NULL); + if (dc) + { + xpmAttr.valuemask = XpmReturnPixels; + int errorStatus = XpmReadFileToImage(&dc, WXSTRINGCAST name, &ximage, (XImage **) NULL, &xpmAttr); + DeleteDC(dc); + if (errorStatus == XpmSuccess) + { + M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap; + + BITMAP bm; + GetObject((HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap, sizeof(bm), (LPSTR) & bm); + + M_BITMAPHANDLERDATA->m_width = (bm.bmWidth); + M_BITMAPHANDLERDATA->m_height = (bm.bmHeight); + M_BITMAPHANDLERDATA->m_depth = (bm.bmPlanes * bm.bmBitsPixel); + M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; + XpmFreeAttributes(&xpmAttr); + XImageFree(ximage); + + M_BITMAPHANDLERDATA->m_ok = TRUE; + return TRUE; + } + else + { + M_BITMAPHANDLERDATA->m_ok = FALSE; + return FALSE; + } + } +#endif + + return FALSE; +} + +bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) +{ +#if USE_XPM_IN_MSW + HDC dc = NULL; + + Visual *visual = NULL; + XImage ximage; + + dc = CreateCompatibleDC(NULL); + if (dc) + { + if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap)) + { /* for following SetPixel */ + /* fill the XImage struct 'by hand' */ + ximage.width = M_BITMAPHANDLERDATA->m_width; + ximage.height = M_BITMAPHANDLERDATA->m_height; + ximage.depth = M_BITMAPHANDLERDATA->m_depth; + ximage.bitmap = (void *)M_BITMAPHANDLERDATA->m_hBitmap; + int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name, + &ximage, (XImage *) NULL, (XpmAttributes *) NULL); + + if (dc) + DeleteDC(dc); + + if (errorStatus == XpmSuccess) + return TRUE; /* no error */ + else + return FALSE; + } else return FALSE; + } else return FALSE; +#else + return FALSE; +#endif +} + + +class WXDLLEXPORT wxXPMDataHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxXPMDataHandler) +public: + inline wxXPMDataHandler(void) + { + m_name = "XPM bitmap data"; + m_extension = "xpm"; + m_type = wxBITMAP_TYPE_XPM_DATA; + }; + + virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); +}; +IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler) + +bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth) +{ + XImage * ximage; + int ErrorStatus; + XpmAttributes xpmAttr; + + xpmAttr.valuemask = XpmReturnInfos; // get infos back + ErrorStatus = XpmCreateImageFromData( GetMainDevice() , (char **)data, + &ximage, (XImage **) NULL, &xpmAttr); + + if (ErrorStatus == XpmSuccess) + { + M_BITMAPHANDLERDATA->m_ok = FALSE; + M_BITMAPHANDLERDATA->m_numColors = 0; + M_BITMAPHANDLERDATA->m_hBitmap = ximage->gworldptr ; + + M_BITMAPHANDLERDATA->m_width = ximage->width; + M_BITMAPHANDLERDATA->m_height = ximage->height; + M_BITMAPHANDLERDATA->m_depth = ximage->depth; + M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; + XpmFreeAttributes(&xpmAttr); + M_BITMAPHANDLERDATA->m_ok = TRUE; + ximage->gworldptr = NULL ; + XImageFree(ximage); // releases the malloc, but does not detroy + // the bitmap + M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; + + return TRUE; + } + else + { + M_BITMAPHANDLERDATA->m_ok = FALSE; + return FALSE; + } + return FALSE; +} + +class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler) +public: + inline wxBMPResourceHandler() + { + m_name = "Windows bitmap resource"; + m_extension = ""; + m_type = wxBITMAP_TYPE_BMP_RESOURCE; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); +}; + +IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler) + +bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ + // TODO: load colourmap. +/* + M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ::LoadBitmap(wxGetInstance(), name); + if (M_BITMAPHANDLERDATA->m_hBitmap) + { + M_BITMAPHANDLERDATA->m_ok = TRUE; + BITMAP bm; + GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(BITMAP), (LPSTR) &bm); + M_BITMAPHANDLERDATA->m_width = bm.bmWidth; + M_BITMAPHANDLERDATA->m_height = bm.bmHeight; + M_BITMAPHANDLERDATA->m_depth = bm.bmBitsPixel; + return TRUE; + } +*/ + // it's probably not found + wxLogError("Can't load bitmap '%s' from resources! Check .rc file.", name.c_str()); + + return FALSE; +} + +class WXDLLEXPORT wxBMPFileHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxBMPFileHandler) +public: + inline wxBMPFileHandler(void) + { + m_name = "Windows bitmap file"; + m_extension = "bmp"; + m_type = wxBITMAP_TYPE_BMP; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); + virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); +}; + +IMPLEMENT_DYNAMIC_CLASS(wxBMPFileHandler, wxBitmapHandler) + +bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ +#if USE_IMAGE_LOADING_IN_MSW + wxPalette *palette = NULL; + bool success = FALSE; +/* + if (type & wxBITMAP_DISCARD_COLOURMAP) + success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap); + else +*/ + success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0); + if (!success && palette) + { + delete palette; + palette = NULL; + } + if (palette) + M_BITMAPHANDLERDATA->m_bitmapPalette = *palette; + return success; +#else + return FALSE; +#endif +} + +bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *pal) +{ +#if USE_IMAGE_LOADING_IN_MSW + wxPalette *actualPalette = (wxPalette *)pal; + if (!actualPalette && (!M_BITMAPHANDLERDATA->m_bitmapPalette.IsNull())) + actualPalette = & (M_BITMAPHANDLERDATA->m_bitmapPalette); + return (wxSaveBitmap(WXSTRINGCAST name, bitmap, actualPalette) != 0); +#else + return FALSE; +#endif +} + + + void wxBitmap::CleanUpHandlers() { wxNode *node = sm_handlers.First(); @@ -419,12 +862,10 @@ void wxBitmap::CleanUpHandlers() void wxBitmap::InitStandardHandlers() { -/* TODO: initialize all standard bitmap or derive class handlers here. - AddHandler(new wxBMPResourceHandler); - AddHandler(new wxBMPFileHandler); - AddHandler(new wxXPMFileHandler); - AddHandler(new wxXPMDataHandler); - AddHandler(new wxICOResourceHandler); - AddHandler(new wxICOFileHandler); -*/ + AddHandler( new wxPICTResourceHandler ) ; + AddHandler( new wxICONResourceHandler ) ; + AddHandler(new wxXPMFileHandler); + AddHandler(new wxXPMDataHandler); + AddHandler(new wxBMPResourceHandler); + AddHandler(new wxBMPFileHandler); } diff --git a/src/mac/brush.cpp b/src/mac/brush.cpp index 4f28e92f53..cb9d76d1ab 100644 --- a/src/mac/brush.cpp +++ b/src/mac/brush.cpp @@ -24,7 +24,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) wxBrushRefData::wxBrushRefData() { m_style = wxSOLID; -// TODO: null data } wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) @@ -32,14 +31,10 @@ wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) m_style = data.m_style; m_stipple = data.m_stipple; m_colour = data.m_colour; -/* TODO: null data - m_hBrush = 0; -*/ } wxBrushRefData::~wxBrushRefData() { -// TODO: delete data } // Brushes @@ -134,7 +129,6 @@ void wxBrush::SetStipple(const wxBitmap& Stipple) bool wxBrush::RealizeResource() { -// TODO: create the brush - return FALSE; + return TRUE; } diff --git a/src/mac/button.cpp b/src/mac/button.cpp index befd0d7156..cb44786443 100644 --- a/src/mac/button.cpp +++ b/src/mac/button.cpp @@ -19,57 +19,53 @@ IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl) #endif +#include // Button + bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - m_windowStyle = style; - - parent->AddChild((wxButton *)this); - - if (id == -1) - m_windowId = NewControlId(); - else - m_windowId = id; - - // TODO: create button - - return FALSE; -} - -void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + Rect bounds ; + Str255 title ; + m_macHorizontalBorder = 2 ; // additional pixels around the real control + m_macVerticalBorder = 2 ; + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlPushButtonProc , (long) this ) ; + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + MacPostControlCreate() ; + + return TRUE; } void wxButton::SetDefault() { - wxWindow *parent = (wxWindow *)GetParent(); - if (parent) - parent->SetDefaultItem(this); - - // TODO: make button the default -} - -wxString wxButton::GetLabel() const -{ - // TODO - return wxString(""); + wxWindow *parent = (wxWindow *)GetParent(); + if (parent) + parent->SetDefaultItem(this); + + if ( m_macControl ) + { + UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ; + } } -void wxButton::SetLabel(const wxString& label) +void wxButton::Command (wxCommandEvent & event) { - // TODO + ProcessCommand (event); } -void wxButton::Command (wxCommandEvent & event) +void wxButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) { - ProcessCommand (event); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId ); + event.SetEventObject(this); + ProcessCommand(event); } diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 3061f99aea..fd5a0009b0 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -37,10 +37,18 @@ // mac +#if __option(profile) + #include +#endif + #include "apprsrc.h" +#include + extern char *wxBuffer; extern wxList wxPendingDelete; +extern wxList *wxWinMacWindowList; +extern wxList *wxWinMacControlList; wxApp *wxTheApp = NULL; @@ -51,56 +59,279 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) END_EVENT_TABLE() #endif -long wxApp::sm_lastMessageTime = 0; const short kMacMinHeap = (29 * 1024) ; // platform specific static variables -bool gMacHasAppearance = false ; -long gMacAppearanceVersion = 0 ; -RgnHandle gMacCursorRgn = NULL ; +const short kwxMacMenuBarResource = 1 ; +const short kwxMacAppleMenuId = 1 ; + +RgnHandle wxApp::s_macCursorRgn = NULL; +wxWindow* wxApp::s_captureWindow = NULL ; +int wxApp::s_lastMouseDown = 0 ; +long wxApp::sm_lastMessageTime = 0; + +#ifdef __WXMAC__ + +bool wxApp::s_macDefaultEncodingIsPC = true ; +bool wxApp::s_macSupportPCMenuShortcuts = true ; +long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; +wxString wxApp::s_macHelpMenuTitleName = "&Help" ; + +OSErr AEHandleODoc( AppleEvent *event , AppleEvent *reply , long refcon ) +{ + wxApp* app = (wxApp*) refcon ; + return wxTheApp->MacHandleAEODoc( event , reply) ; +} + +OSErr AEHandleOApp( AppleEvent *event , AppleEvent *reply , long refcon ) +{ + wxApp* app = (wxApp*) refcon ; + return wxTheApp->MacHandleAEOApp( event , reply ) ; +} + +OSErr AEHandlePDoc( AppleEvent *event , AppleEvent *reply , long refcon ) +{ + wxApp* app = (wxApp*) refcon ; + return wxTheApp->MacHandleAEPDoc( event , reply ) ; +} + +OSErr AEHandleQuit( AppleEvent *event , AppleEvent *reply , long refcon ) +{ + wxApp* app = (wxApp*) refcon ; + return wxTheApp->MacHandleAEQuit( event , reply) ; +} + +OSErr wxApp::MacHandleAEODoc(AppleEvent *event , AppleEvent *reply) +{ + ProcessSerialNumber PSN ; + PSN.highLongOfPSN = 0 ; + PSN.lowLongOfPSN = kCurrentProcess ; + SetFrontProcess( &PSN ) ; + return noErr ; +} + +OSErr wxApp::MacHandleAEPDoc(AppleEvent *event , AppleEvent *reply) +{ + return noErr ; +} + +OSErr wxApp::MacHandleAEOApp(AppleEvent *event , AppleEvent *reply) +{ + return noErr ; +} + +OSErr wxApp::MacHandleAEQuit(AppleEvent *event , AppleEvent *reply) +{ + wxWindow* win = GetTopWindow() ; + if ( win ) + { + win->Close(TRUE ) ; + } + else + { + ExitMainLoop() ; + } + return noErr ; +} + +char StringMac[] = "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" + "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" + "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf" + "\xb1\xb4\xb5\xb6\xbb\xbc\xbe\xbf" + "\xc0\xc1\xc2\xc4\xc7\xc8\xc9\xcb\xcc\xcd\xce\xcf" + "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd8\xca\xdb" ; + +char StringANSI[] = "\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8" + "\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC" + "\x86\xBA\xA2\xA3\xA7\x95\xB6\xDF\xAE\xA9\x99\xB4\xA8\xC6\xD8" + "\xB1\xA5\xB5\xF0\xAA\xBA\xE6\xF8" + "\xBF\xA1\xAC\x83\xAB\xBB\x85\xC0\xC3\xD5\x8C\x9C" + "\x96\x97\x93\x94\x91\x92\xF7\xFF\xA0\x80" ; + +void wxMacConvertFromPC( const char *from , char *to , int len ) +{ + char *c ; + if ( from == to ) + { + for( int i = 0 ; i < len ; ++ i ) + { + c = strchr( StringANSI , *from ) ; + if ( c != NULL ) + { + *to = StringMac[ c - StringANSI] ; + } + ++to ; + ++from ; + } + } + else + { + for( int i = 0 ; i < len ; ++ i ) + { + c = strchr( StringANSI , *from ) ; + if ( c != NULL ) + { + *to = StringMac[ c - StringANSI] ; + } + else + { + *to = *from ; + } + ++to ; + ++from ; + } + } +} + +void wxMacConvertToPC( const char *from , char *to , int len ) +{ + char *c ; + if ( from == to ) + { + for( int i = 0 ; i < len ; ++ i ) + { + c = strchr( StringMac , *from ) ; + if ( c != NULL ) + { + *to = StringANSI[ c - StringMac] ; + } + ++to ; + ++from ; + } + } + else + { + for( int i = 0 ; i < len ; ++ i ) + { + c = strchr( StringMac , *from ) ; + if ( c != NULL ) + { + *to = StringANSI[ c - StringMac] ; + } + else + { + *to = *from ; + } + ++to ; + ++from ; + } + } +} + +void wxMacConvertFromPC( char * p ) +{ + char *ptr = p ; + int len = strlen ( p ) ; + + wxMacConvertFromPC( ptr , ptr , len ) ; +} + +void wxMacConvertFromPCForControls( char * p ) +{ + char *ptr = p ; + int len = strlen ( p ) ; + + wxMacConvertFromPC( ptr , ptr , len ) ; + for ( int i = 0 ; i < strlen ( ptr ) ; i++ ) + { + if ( ptr[i] == '&' && ptr[i]+1 != ' ' ) + { + memmove( &ptr[i] , &ptr[i+1] , strlen( &ptr[i+1] ) + 1) ; + } + } +} + +void wxMacConvertFromPC( unsigned char *p ) +{ + char *ptr = (char*) p + 1 ; + int len = p[0] ; + + wxMacConvertFromPC( ptr , ptr , len ) ; +} + +extern char *wxBuffer ; + +wxString wxMacMakeMacStringFromPC( const char * p ) +{ + const char *ptr = p ; + int len = strlen ( p ) ; + char *buf = wxBuffer ; + + if ( len >= BUFSIZ + 512 ) + { + buf = new char [len+1] ; + } + + wxMacConvertFromPC( ptr , buf , len ) ; + buf[len] = 0 ; + wxString result( buf ) ; + if ( buf != wxBuffer ) + delete buf ; + return result ; +} + + +void wxMacConvertToPC( char * p ) +{ + char *ptr = p ; + int len = strlen ( p ) ; + + wxMacConvertToPC( ptr , ptr , len ) ; +} + +void wxMacConvertToPC( unsigned char *p ) +{ + char *ptr = (char*) p + 1 ; + int len = p[0] ; + + wxMacConvertToPC( ptr , ptr , len ) ; +} + +wxString wxMacMakePCStringFromMac( const char * p ) +{ + const char *ptr = p ; + int len = strlen ( p ) ; + char *buf = wxBuffer ; + + if ( len >= BUFSIZ + 512 ) + { + buf = new char [len+1] ; + } + + wxMacConvertToPC( ptr , buf , len ) ; + buf[len] = 0 ; + + wxString result( buf ) ; + if ( buf != wxBuffer ) + delete buf ; + return result ; +} +#endif bool wxApp::Initialize() { int error = 0 ; // Mac-specific - long total,contig; - // init all managers - - ::InitGraf(&qd.thePort); - ::InitFonts(); - ::InitWindows(); - ::InitMenus(); - ::TEInit(); - ::InitDialogs(0L); - ::InitCursor(); - CursHandle aCursHandle = ::GetCursor(watchCursor); // Watch should be in system - if (aCursHandle) - ::SetCursor(*aCursHandle); - ::FlushEvents(everyEvent, 0); - - // setup memory of application - - ::MaxApplZone(); - for (long i = 1; i <= 4; i++) - ::MoreMasters(); - PurgeSpace(&total, &contig); - ::SetCursor( &qd.arrow ) ; + UMAInitToolbox( 4 ) ; + UMAShowWatchCursor() ; + AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) , (long) wxTheApp , FALSE ) ; + AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ; + AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ; + AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ; #if 0 - InitAEHandlers(); - InitializeAECore() ; GUSISetup(GUSIwithInternetSockets); #endif + // test the minimal configuration necessary long theSystem ; long theMachine; - long theAppearance ; if (Gestalt(gestaltMachineType, &theMachine) != noErr) { @@ -114,32 +345,25 @@ bool wxApp::Initialize() { error = kMacSTROldSystem ; } - else if ( theSystem < 0x0700 ) + else if ( theSystem < 0x0750 ) { error = kMacSTROldSystem ; } + #if !TARGET_CARBON else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap) { error = kMacSTRSmallSize; } + #endif + /* else { - if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) + if ( !UMAHasAppearance() ) { - gMacHasAppearance = true ; - RegisterAppearanceClient(); - if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) - { - gMacAppearanceVersion = theAppearance ; - } - else - { - gMacAppearanceVersion = 0x0100 ; - } - } - else error = kMacSTRNoPre8Yet ; + } } + */ // if we encountered any problems so far, give the error code and exit immediately @@ -147,19 +371,23 @@ bool wxApp::Initialize() { short itemHit; Str255 message; - - SetCursor(&qd.arrow); + GetIndString(message, 128, error); - ParamText(message, (ConstStr255Param)"\p", (ConstStr255Param)"\p", (ConstStr255Param)"\p"); - itemHit = Alert(129, nil); + UMAShowArrowCursor() ; + ParamText("\pFatal Error", message, (ConstStr255Param)"\p", (ConstStr255Param)"\p"); + itemHit = Alert(128, nil); return FALSE ; } - + +#if __option(profile) + ProfilerInit( collectDetailed, bestTimeBase , 20000 , 30 ) ; +#endif + // now avoid exceptions thrown for new (bad_alloc) std::__throws_bad_alloc = FALSE ; - gMacCursorRgn = ::NewRgn() ; + s_macCursorRgn = ::NewRgn() ; #ifdef __WXMSW__ wxBuffer = new char[1500]; @@ -191,8 +419,14 @@ bool wxApp::Initialize() wxBitmap::InitStandardHandlers(); wxModule::RegisterModules(); - wxASSERT( wxModule::InitializeModules() == TRUE ); + if (!wxModule::InitializeModules()) + return FALSE; + wxWinMacWindowList = new wxList(wxKEY_INTEGER); + wxWinMacControlList = new wxList(wxKEY_INTEGER); + + UMAShowArrowCursor() ; + return TRUE; } @@ -228,8 +462,16 @@ void wxApp::CleanUp() delete[] wxBuffer; wxBuffer = NULL; + if (wxWinMacWindowList) + delete wxWinMacWindowList ; + wxClassInfo::CleanUpClasses(); +#if __option(profile) + ProfilerDump( "\papp.prof" ) ; + ProfilerTerm() ; +#endif + delete wxTheApp; wxTheApp = NULL; @@ -253,8 +495,8 @@ void wxApp::CleanUp() delete wxLog::SetActiveTarget(NULL); ::PrClose() ; - if (gMacCursorRgn) - ::DisposeRgn(gMacCursorRgn); + if (s_macCursorRgn) + ::DisposeRgn(s_macCursorRgn); #if 0 TerminateAE() ; #endif @@ -281,11 +523,18 @@ int wxEntry( int argc, char *argv[] ) return 0; }; +#ifdef __WXMAC__ + argc = 1 ; // currently we don't support files as parameters +#endif + wxTheApp->argc = argc; wxTheApp->argv = argv; // GUI-specific initialization, such as creating an app context. wxTheApp->OnInitGui(); + + // we could try to get the open apple events here to adjust argc and argv better + // Here frames insert themselves automatically // into wxTopLevelWindows by getting created @@ -324,22 +573,19 @@ wxApp::wxApp() m_appName = ""; argc = 0; argv = NULL; -#ifdef __WXMSW__ + m_printMode = wxPRINT_WINDOWS; -#else - m_printMode = wxPRINT_POSTSCRIPT; -#endif + m_exitOnFrameDelete = TRUE; m_auto3D = TRUE; } bool wxApp::Initialized() { + if (GetTopWindow()) return TRUE; -// if (GetTopWindow()) -// return TRUE; -// else -// return FALSE; + else + return FALSE; } int wxApp::MainLoop() @@ -372,16 +618,15 @@ void wxApp::ExitMainLoop() // Is a message/event pending? bool wxApp::Pending() { -/* TODO. - */ - return FALSE; + EventRecord event ; + + return EventAvail( everyEvent , &event ) ; } // Dispatch a message. void wxApp::Dispatch() { -/* TODO. - */ + MacDoOneEvent() ; } void wxApp::OnIdle(wxIdleEvent& event) @@ -493,32 +738,70 @@ void wxExit() // Yield to other processes bool wxYield() { -#if 0 - ::YieldToOtherThreads() ; - ::SystemTime() ; -#endif +// YieldToAnyThread() ; + SystemTask() ; return TRUE; } // platform specifics +void wxApp::MacSuspend( bool convertClipboard ) +{ + s_lastMouseDown = 0 ; + if( convertClipboard ) + { + MacConvertPrivateToPublicScrap() ; + } + + UMAHideFloatingWindows() ; +} + +void wxApp::MacResume( bool convertClipboard ) +{ + s_lastMouseDown = 0 ; + if( convertClipboard ) + { + MacConvertPublicToPrivateScrap() ; + } + + UMAShowFloatingWindows() ; +} + +void wxApp::MacConvertPrivateToPublicScrap() +{ + ::ZeroScrap(); + ::TEToScrap(); +} + +void wxApp::MacConvertPublicToPrivateScrap() +{ + ::TEFromScrap() ; +} + void wxApp::MacDoOneEvent() { EventRecord event ; - long sleepTime = 60; + long sleepTime = ::GetCaretTime(); - if (WaitNextEvent(everyEvent, &event,sleepTime, gMacCursorRgn)) + if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn)) { MacHandleOneEvent( &event ); } else { // idlers + WindowPtr window = UMAFrontWindow() ; + if ( window ) + UMAIdleControls( window ) ; + wxTheApp->ProcessIdle() ; } - + if ( event.what != kHighLevelEvent ) + SetRectRgn( s_macCursorRgn , event.where.h - 1 , event.where.v - 1, event.where.h + 1 , event.where.v + 1 ) ; + // repeaters + #if 0 wxMacProcessSocketEvents() ; #endif @@ -526,29 +809,30 @@ void wxApp::MacDoOneEvent() void wxApp::MacHandleOneEvent( EventRecord *ev ) { + m_macCurrentEvent = ev ; + + wxApp::sm_lastMessageTime = ev->when ; + switch (ev->what) { - case nullEvent: - MacHandleNullEvent( ev ) ; - break ; - case kHighLevelEvent: - MacHandleHighLevelEvent( ev ) ; - break; case mouseDown: MacHandleMouseDownEvent( ev ) ; - wxTheApp->ExitMainLoop() ; + if ( ev->modifiers & controlKey ) + s_lastMouseDown = 2; + else + s_lastMouseDown = 1; break; case mouseUp: + if ( s_lastMouseDown == 2 ) + { + ev->modifiers |= controlKey ; + } + else + { + ev->modifiers &= ~controlKey ; + } MacHandleMouseUpEvent( ev ) ; - break; - case keyDown: - MacHandleKeyDownEvent( ev ) ; - break; - case autoKey: - MacHandleAutoKeyEvent( ev ) ; - break; - case keyUp: - MacHandleKeyUpEvent( ev ) ; + s_lastMouseDown = 0; break; case activateEvt: MacHandleActivateEvent( ev ) ; @@ -556,850 +840,532 @@ void wxApp::MacHandleOneEvent( EventRecord *ev ) case updateEvt: MacHandleUpdateEvent( ev ) ; break; + case keyDown: + case autoKey: + MacHandleKeyDownEvent( ev ) ; + break; + case keyUp: + MacHandleKeyUpEvent( ev ) ; + break; case diskEvt: MacHandleDiskEvent( ev ) ; break; case osEvt: MacHandleOSEvent( ev ) ; break; + case kHighLevelEvent: + MacHandleHighLevelEvent( ev ) ; + break; default: break; } } -void wxApp::MacHandleNullEvent( EventRecord *ev ) -{ -} - void wxApp::MacHandleHighLevelEvent( EventRecord *ev ) { + ::AEProcessAppleEvent( ev ) ; } +bool s_macIsInModalLoop = false ; + void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) { -} + WindowRef window; + WindowRef frontWindow = UMAFrontNonFloatingWindow() ; + WindowAttributes frontWindowAttributes = NULL ; + if ( frontWindow ) + UMAGetWindowAttributes( frontWindow , &frontWindowAttributes ) ; + + short windowPart = ::FindWindow(ev->where, &window); + wxWindow* win = wxFindWinFromMacWindow( window ) ; + + switch (windowPart) + { + case inMenuBar : + if ( s_macIsInModalLoop ) + { + SysBeep ( 30 ) ; + } + else + { + UInt32 menuresult = MenuSelect(ev->where) ; + MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ); + s_lastMouseDown = 0; + } + break ; + case inSysWindow : + SystemClick( ev , window ) ; + s_lastMouseDown = 0; + break ; + case inDrag : + if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) ) + { + SysBeep ( 30 ) ; + } + else + { + DragWindow(window, ev->where, &qd.screenBits.bounds); + if (win) + { + GrafPtr port ; + GetPort( &port ) ; + Point pt = { 0, 0 } ; + SetPort( window ) ; + SetOrigin( 0 , 0 ) ; + LocalToGlobal( &pt ) ; + SetPort( port ) ; + win->SetSize( pt.h , pt.v , -1 , + -1 , wxSIZE_USE_EXISTING); + } + s_lastMouseDown = 0; + } + break ; + case inGoAway: + if (TrackGoAway(window, ev->where)) + { + if ( win ) + win->Close() ; + } + s_lastMouseDown = 0; + break; + case inGrow: + int growResult = GrowWindow(window , ev->where, &qd.screenBits.bounds); + if (growResult != 0) + { + int newWidth = LoWord(growResult); + int newHeight = HiWord(growResult); + int oldWidth, oldHeight; + + win->GetSize(&oldWidth, &oldHeight); + if (newWidth == 0) + newWidth = oldWidth; + if (newHeight == 0) + newHeight = oldHeight; + + if (win) + win->SetSize( -1, -1, newWidth, newHeight, wxSIZE_USE_EXISTING); + } + s_lastMouseDown = 0; + break; + case inZoomIn: + case inZoomOut: + if (TrackBox(window, ev->where, windowPart)) + { + // TODO setup size event + ZoomWindow( window , windowPart , false ) ; + if (win) + win->SetSize( -1, -1, window->portRect.right-window->portRect.left , + window->portRect.bottom-window->portRect.top, wxSIZE_USE_EXISTING); + } + s_lastMouseDown = 0; + break; + case inCollapseBox : + // TODO setup size event + s_lastMouseDown = 0; + break ; -void wxApp::MacHandleMouseUpEvent( EventRecord *ev ) -{ + case inContent : + if ( window != frontWindow ) + { + if ( s_macIsInModalLoop ) + { + SysBeep ( 30 ) ; + } + else if ( UMAIsWindowFloating( window ) ) + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + } + else + { + UMASelectWindow( window ) ; + } + } + else + { + if ( win ) + win->MacMouseDown( ev , windowPart ) ; + } + break ; + + default: + break; + } } -void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) +void wxApp::MacHandleMouseUpEvent( EventRecord *ev ) { + WindowRef window; + + short windowPart = ::FindWindow(ev->where, &window); + + switch (windowPart) + { + case inMenuBar : + break ; + case inSysWindow : + break ; + default: + { + wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( win ) + win->MacMouseUp( ev , windowPart ) ; + } + break; + } } -void wxApp::MacHandleKeyUpEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleAutoKeyEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleActivateEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleUpdateEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleDiskEvent( EventRecord *ev ) -{ -} - -void wxApp::MacHandleOSEvent( EventRecord *ev ) -{ -} - - - -/* - -void wxApp::doMacMouseDown(void) -{ - WindowPtr window; - short windowPart = ::FindWindow(m_event.where, &window); - if ( windowPart != inMenuBar ) - { - WindowPtr frontWindow = FrontWindow(); - if (WindowIsModal(frontWindow) && (window != frontWindow)) - SysBeep(1); - else - { - switch (windowPart) +long wxMacTranslateKey(char key, char code) +{ + switch (key) + { + case 0x01 : + key = WXK_HOME; + break; + case 0x03 : + key = WXK_RETURN; + break; + case 0x04 : + key = WXK_END; + break; + case 0x05 : + key = WXK_HELP; + break; + case 0x08 : + key = WXK_BACK; + break; + case 0x09 : + key = WXK_TAB; + break; + case 0x0b : + key = WXK_PAGEUP; + break; + case 0x0c : + key = WXK_PAGEDOWN; + break; + case 0x0d : + key = WXK_RETURN; + break; + case 0x10 : { - case inMenuBar: - break; - case inContent: - doMacInContent(window); break; - case inDrag: - doMacInDrag(window); break; - case inGrow: - doMacInGrow(window); break; - case inGoAway: - doMacInGoAway(window); break; - case inZoomIn: - case inZoomOut: - doMacInZoom(window, windowPart); break; - default: - break; + switch( code ) + { + case 0x7a : + key = WXK_F1 ; + break; + case 0x78 : + key = WXK_F2 ; + break; + case 0x63 : + key = WXK_F3 ; + break; + case 0x76 : + key = WXK_F4 ; + break; + case 0x60 : + key = WXK_F5 ; + break; + case 0x61 : + key = WXK_F6 ; + break; + case 0x62: + key = WXK_F7 ; + break; + case 0x64 : + key = WXK_F8 ; + break; + case 0x65 : + key = WXK_F9 ; + break; + case 0x6D : + key = WXK_F10 ; + break; + case 0x67 : + key = WXK_F11 ; + break; + case 0x6F : + key = WXK_F12 ; + break; + case 0x69 : + key = WXK_F13 ; + break; + case 0x6B : + key = WXK_F14 ; + break; + case 0x71 : + key = WXK_F15 ; + break; + } } + break ; + case 0x1b : + key = WXK_DELETE ; + break ; + case 0x1c : + key = WXK_LEFT ; + break ; + case 0x1d : + key = WXK_RIGHT ; + break ; + case 0x1e : + key = WXK_UP ; + break ; + case 0x1f : + key = WXK_DOWN ; + break ; + default: + break ; + } // end switch - } - } - else - { - doMacInMenuBar(::MenuSelect(m_event.where)); - } -} - -void wxApp::doMacMouseUp(void) -{ - if (m_mouseWindow) - { -#if 0 - int hitX = m_event.where.h; // screen window c.s. - int hitY = m_event.where.v; // screen window c.s. - m_mouseWindow->ScreenToClient(&hitX, &hitY); // mouseWindow client c.s. - m_mouseWindow->ClientToLogical(&hitX, &hitY); // mouseWindow logical c.s. -#endif - - wxMouseEvent event(wxEVT_LEFT_UP); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = FALSE; - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - - m_mouseWindow->ProcessEvent(event); - } - else - { - //??? Can't we just throw away mouse up events without matching mouse down - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { -#if 0 - int hitX = cCurrentEvent.where.h; // screen window c.s. - int hitY = cCurrentEvent.where.v; // screen window c.s. - theMacWxFrame->ScreenToWindow(&hitX, &hitY); -#endif - - wxMouseEvent event(wxEVT_LEFT_UP); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = FALSE; - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - - theMacWxFrame->ProcessEvent(event); - } - } -} - -void wxApp::doMacMouseMotion(void) -{ - if (m_mouseWindow) { - wxMouseEvent event(wxEVT_MOTION); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = !(m_event.modifiers & btnState); - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - - m_mouseWindow->ProcessEvent(event); - } - else - { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { - wxMouseEvent event(wxEVT_MOTION); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = !(m_event.modifiers & btnState); - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - - m_mouseWindow->ProcessEvent(event); - } - } - - //??? Need to work with floating windows... isn't there a toolbox call to find the - // top window intersecting a point is screen coordinates?? -#if 0 - else // will only work for one floating window at the moment... ? - { - WindowPtr frontDocPtr = findFrontNonFloatingWindow(); - WindowPtr frontFloatingPtr = ::FrontWindow(); - - int hitX = cCurrentEvent.where.h; - int hitY = cCurrentEvent.where.v; - - wxFrame* macWxFrame = findMacWxFrame(frontDocPtr); - - if ((frontFloatingPtr != frontDocPtr) & (frontFloatingPtr != NULL)) - { - RgnHandle frontFloatStrRgn = getStructureRegion(frontFloatingPtr); - Rect frontFloatRect = (**frontFloatStrRgn).rgnBBox; - - if ((hitX >= frontFloatRect.left) & - (hitX <= frontFloatRect.right) & - (hitY >= frontFloatRect.top) & - (hitY <= frontFloatRect.bottom)) - { - macWxFrame = findMacWxFrame(frontFloatingPtr); - } - } - } -#endif + return key; } -void wxApp::doMacKeyDown(void) +void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) { - long menuResult = 0 ; - short keycode ; - short keychar ; - keychar = short(m_event.message & charCodeMask); - keycode = short(m_event.message & keyCodeMask) >> 8 ; - - // Handle menu accelerators - if ( gSFMacHasAppearance ) - { - menuResult = MenuEvent( &m_event ) ; - if ( HiWord( menuResult ) ) - { - doMacInMenuBar( menuResult ) ; - } - else - { - ControlHandle control ; - - GetKeyboardFocus( FrontNonFloatingWindow() , &control ) ; - if ( control && keychar != 0x07 ) - HandleControlKey( control , keycode , keychar , m_event.modifiers ) ; - else - { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { - wxKeyEvent event(wxEVT_CHAR); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_keyCode = macTranslateKey(keychar, m_event.modifiers & (shiftKey|optionKey)); - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); - - theMacWxFrame->ProcessEvent(event); - } - } - } - } + UInt32 menuresult = UMAMenuEvent(ev) ; + if ( HiWord( menuresult ) ) + MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ; else { - if (GetMenuHandle( kwxMacAppleMenuId ) ) - { -// menuResult = MDEF_MenuKey(m_event.message, m_event.modifiers , GetMenuHandle( kwxMacAppleMenuId ) ); - } - else - { - if (m_event.modifiers & cmdKey) - { - menuResult = MenuKey( keychar ) ; - } - } - - if ( HiWord( menuResult ) ) - { - doMacInMenuBar( menuResult ) ; - } - else - { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { - wxKeyEvent event(wxEVT_CHAR); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_keyCode = macTranslateKey(keychar, m_event.modifiers & (shiftKey|optionKey)); - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); + short keycode ; + short keychar ; + keychar = short(ev->message & charCodeMask); + keycode = short(ev->message & keyCodeMask) >> 8 ; - theMacWxFrame->ProcessEvent(event); - } + wxWindow* focus = wxWindow::FindFocus() ; + if ( focus ) + { + wxKeyEvent event(wxEVT_CHAR); + event.m_shiftDown = ev->modifiers & shiftKey; + event.m_controlDown = ev->modifiers & controlKey; + event.m_altDown = ev->modifiers & optionKey; + event.m_metaDown = ev->modifiers & cmdKey; + event.m_keyCode = wxMacTranslateKey(keychar, keycode); + event.m_x = ev->where.h; + event.m_y = ev->where.v; + event.m_timeStamp = ev->when; + event.SetEventObject(focus); + focus->GetEventHandler()->ProcessEvent( event ) ; } } } -void wxApp::doMacAutoKey(void) -{ - doMacKeyDown(); -} - -void wxApp::doMacKeyUp(void) -{ -} - -void wxApp::doMacActivateEvt(void) -{ - HighlightAndActivateWindow( (WindowPtr) m_event.message , m_event.modifiers & activeFlag ) ; -} - -void wxApp::doMacUpdateEvt(void) -{ - WindowPtr theMacWindow = (WindowPtr)(m_event.message); - ::BeginUpdate(theMacWindow); - - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(theMacWindow); - if (theMacWxFrame) - { -// if (!::EmptyRgn(theMacWindow->visRgn)) // this doesn't work with windowshade -// { - if ( theMacWxFrame->MacSetupPort() ) - { - // Erase update region - // we must do this, because controls add their former rect to the inval - // rgn and the background might not have been correct at that moment - ::EraseRect(&theMacWindow->portRect); - - // Can't use UpdateControls since each control has it's own coordinate system - // ::UpdateControls(theMacWindow, theMacWindow->visRgn); - - ::UpdateControls( theMacWindow , theMacWindow->visRgn ) ; - #if 0 - // Draw the grow box - if (cStyle & wxRESIZE_BORDER) - MacDrawGrowIcon(); - #endif - - wxPaintEvent event; - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); - - theMacWxFrame->ProcessEvent(event); - // ::SetThemeWindowBackground( theMacWindow , kThemeActiveDialogBackgroundBrush , false ) ; - ::ClipRect( &theMacWindow->portRect ) ; - ::SetOrigin( 0 , 0 ); - } - else - { - wxASSERT_MSG( false , "unabled to setup window mac port") ; - } - -// } - } - - ::EndUpdate(theMacWindow); -} - -void wxApp::doMacDiskEvt(void) -{ // based on "Programming for System 7" by Gary Little and Tim Swihart - if ((m_event.message >> 16) != noErr) - { - const int kDILeft = 0x0050; // top coord for disk init dialog - const int kDITop = 0x0070; // left coord for disk init dialog - Point mountPoint; - mountPoint.h = kDILeft; - mountPoint.v = kDITop; - int myError = DIBadMount(mountPoint, m_event.message); - } -} - -void wxApp::doMacOsEvt(void) -{ // based on "Programming for System 7" by Gary Little and Tim Swihart - switch ((m_event.message >> 24) & 0x0ff) - { - case suspendResumeMessage: - if (m_event.message & resumeFlag) - doMacResumeEvent(); - else - doMacSuspendEvent(); - break; - case mouseMovedMessage: - doMacMouseMovedMessage(); - break; - } -} - -void wxApp::doMacHighLevelEvent(void) +void wxApp::MacHandleKeyUpEvent( EventRecord *ev ) { - ::AEProcessAppleEvent(&m_event); // System 7 or higher + // nothing to do } -void wxApp::doMacResumeEvent(void) +void wxApp::MacHandleActivateEvent( EventRecord *ev ) { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) + WindowRef window = (WindowRef) ev->message ; + if ( window ) { - if (m_event.message & convertClipboardFlag) - ::TEFromScrap(); - - wxActivateEvent event(wxEVT_ACTIVATE, TRUE); - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); - - theMacWxFrame->ProcessEvent(event); + bool activate = (ev->modifiers & activeFlag ) ; + WindowClass wclass ; + UMAGetWindowClass ( window , &wclass ) ; + if ( wclass == kFloatingWindowClass ) + { + // if it is a floater we activate/deactivate the front non-floating window instead + window = UMAFrontNonFloatingWindow() ; + } + wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( win ) + win->MacActivate( ev , activate ) ; } } -void wxApp::doMacSuspendEvent(void) +void wxApp::MacHandleUpdateEvent( EventRecord *ev ) { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) + WindowRef window = (WindowRef) ev->message ; + wxWindow * win = wxFindWinFromMacWindow( window ) ; + if ( win ) { - ::ZeroScrap(); - ::TEToScrap(); - - wxActivateEvent event(wxEVT_ACTIVATE, FALSE); - event.m_timeStamp = m_event.when; - event.SetEventObject(theMacWxFrame); - - theMacWxFrame->ProcessEvent(event); + win->MacUpdate( ev ) ; } } -void wxApp::doMacMouseMovedMessage(void) -{ // based on "Programming for System 7" by Gary Little and Tim Swihart - if (m_cursorRgn) - ::DisposeRgn(m_cursorRgn); - m_cursorRgn = ::NewRgn(); - ::SetRectRgn(m_cursorRgn, -32768, -32768, 32766, 32766); -} - -void wxApp::doMacInMenuBar(long menuResult) +void wxApp::MacHandleDiskEvent( EventRecord *ev ) { - int macMenuId = HiWord(menuResult); - int macMenuItemNum = LoWord(menuResult); // counting from 1 - - if (macMenuId == 0) // no menu item selected; - return; - if (macMenuId == 128) - { - if (macMenuItemNum != 1) - { // if not the "About" entry (or the separator) - Str255 daName; - ::GetMenuItemText(GetMenuHandle(128), macMenuItemNum, daName); - (void)::OpenDeskAcc(daName); - ::HiliteMenu(0); - return; - } - } - - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); - if (theMacWxFrame) - { - if ( theMacWxFrame->IsKindOf( CLASSINFO( wxDialog ) ) ) - (( wxDialog *) theMacWxFrame)->MacMenuSelect(m_event, macMenuId, macMenuItemNum); - else if ( theMacWxFrame->IsKindOf( CLASSINFO( wxFrame ) ) ) - (( wxFrame *) theMacWxFrame)->MacMenuSelect(m_event, macMenuId, macMenuItemNum); + if ( HiWord( ev->message ) != noErr ) + { + OSErr err ; + Point point ; + SetPt( &point , 100 , 100 ) ; + + err = DIBadMount( point , ev->message ) ; + wxASSERT( err == noErr ) ; } - ::HiliteMenu(0); } -void wxApp::doMacInContent(WindowPtr window) +void wxApp::MacHandleOSEvent( EventRecord *ev ) { - WindowPtr frontWindow = FrontWindow(); - if (window != frontWindow ) - { -// SFSelectWindow( window ) ; - } - else + switch( ( ev->message & osEvtMessageMask ) >> 24 ) { - ControlHandle control ; - Point localwhere = m_event.where ; - GrafPtr port ; - SInt16 controlpart ; - - ::GetPort( &port ) ; - ::SetPort( window ) ; - ::GlobalToLocal( &localwhere ) ; - - ::SetPort( port ) ; - - if ( !gSFMacHasAppearance ) - { - controlpart = FindControl( localwhere , window , &control ) ; - } - else - { - control = FindControlUnderMouse( localwhere , window , &controlpart ) ; - } - - if ( control && IsControlActive( control ) ) - { - wxControl* wxc = (wxControl*) GetControlReference( control ) ; - - if ( wxWindow::FindFocus() != wxc && wxc->AcceptsFocus() ) - { - wxc->SetFocus() ; - if ( wxWindow::FindFocus() != wxc ) - control = NULL ; // we were not able to change focus - } - - if ( control ) + case suspendResumeMessage : { - if ( !gSFMacHasAppearance) + bool isResuming = ev->message & resumeFlag ; + bool convertClipboard = ev->message & convertClipboardFlag ; + bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ; + if ( isResuming ) { - controlpart = TrackControl( control , localwhere , NULL ) ; + WindowRef oldFrontWindow = NULL ; + WindowRef newFrontWindow = NULL ; + + // in case we don't take care of activating ourselves, we have to synchronize + // our idea of the active window with the process manager's - which it already activated + + if ( !doesActivate ) + oldFrontWindow = UMAFrontNonFloatingWindow() ; + + MacResume( convertClipboard ) ; + + newFrontWindow = UMAFrontNonFloatingWindow() ; + + if ( oldFrontWindow ) + { + wxWindow* win = wxFindWinFromMacWindow( oldFrontWindow ) ; + if ( win ) + win->MacActivate( ev , false ) ; + } + if ( newFrontWindow ) + { + wxWindow* win = wxFindWinFromMacWindow( newFrontWindow ) ; + if ( win ) + win->MacActivate( ev , true ) ; + } } else - { - controlpart = HandleControlClick( control , localwhere , m_event.modifiers , (ControlActionUPP) -1 ) ; - } + { + MacSuspend( convertClipboard ) ; - if ( controlpart ) - { - wxControl* wx = (wxControl*) GetControlReference( control ) ; - if ( wx ) - wx->MacHandleControlClick( control , controlpart ) ; + // in case this suspending did close an active window, another one might + // have surfaced -> lets deactivate that one + + WindowRef newActiveWindow = UMAGetActiveNonFloatingWindow() ; + if ( newActiveWindow ) + { + wxWindow* win = wxFindWinFromMacWindow( newActiveWindow ) ; + if ( win ) + win->MacActivate( ev , false ) ; + } } } - } - else - { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) - { - doMacContentClick((wxFrame*)theMacWxFrame); // todo : this cast is wrong - } - } - } - -#if 0 - wxFrame* theMacWxFrame = findMacWxFrame(window); - if (theMacWxFrame) - { - WindowPtr MacWindow = findFrontNonFloatingWindow(); - if (window != MacWindow) - { - wxFrame* frontFrame = findMacWxFrame(MacWindow); - if (!frontFrame) wxFatalError("No wxFrame for frontnonfloatingWindow."); - if (!frontFrame->IsModal()) + break ; + case mouseMovedMessage : { - frontFrame->SetFocus(); - doMacContentClick(theMacWxFrame); // jonto - to deal with doc windows behind floaters ? - ::newSelectWindow(window); // WCH : should I be calling some wxMethod? - if (!IsFloating(MacWindow)) + WindowRef window; + + wxWindow* currentMouseWindow = NULL ; + + MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , ¤tMouseWindow ) ; + + if ( currentMouseWindow != wxWindow::s_lastMouseWindow ) { - KeyMap keyMap; - GetKeys(keyMap); - if (!(keyMap[1] & 0x8000)) theMacWxFrame->ShowAsActive(true); // temporary measure... + wxMouseEvent event ; + + bool isDown = !(ev->modifiers & btnState) ; // 1 is for up + bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse + + event.m_leftDown = isDown && !controlDown; + event.m_middleDown = FALSE; + event.m_rightDown = isDown && controlDown; + event.m_shiftDown = ev->modifiers & shiftKey; + event.m_controlDown = ev->modifiers & controlKey; + event.m_altDown = ev->modifiers & optionKey; + event.m_metaDown = ev->modifiers & cmdKey; + event.m_x = ev->where.h; + event.m_y = ev->where.v; + event.m_timeStamp = ev->when; + event.SetEventObject(this); + + if ( wxWindow::s_lastMouseWindow ) + { + wxMouseEvent eventleave(event ) ; + eventleave.SetEventType( wxEVT_LEAVE_WINDOW ) ; + wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave); + } + if ( currentMouseWindow ) + { + wxMouseEvent evententer(event ) ; + evententer.SetEventType( wxEVT_ENTER_WINDOW ) ; + currentMouseWindow->GetEventHandler()->ProcessEvent(evententer); + } + wxWindow::s_lastMouseWindow = currentMouseWindow ; } - } // jonto : not sure yet, but let's try this ... - else ::SysBeep(3); - } - else - { - doMacContentClick(theMacWxFrame); - } - } -#endif -} - -void wxApp::doMacContentClick(wxWindow* frame) -{ - m_mouseWindow = frame; - - wxMouseEvent event(wxEVT_LEFT_DOWN); - event.m_shiftDown = m_event.modifiers & shiftKey; - event.m_controlDown = m_event.modifiers & controlKey; - event.m_altDown = m_event.modifiers & optionKey; - event.m_metaDown = m_event.modifiers & cmdKey; - event.m_leftDown = FALSE; - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; - if ( m_event.modifiers & controlKey ) - { - event.m_rightDown = TRUE; - } - else - { - event.m_leftDown = TRUE; + + short windowPart = ::FindWindow(ev->where, &window); + + switch (windowPart) + { + case inMenuBar : + break ; + case inSysWindow : + break ; + default: + { + if ( s_lastMouseDown == 0 ) + ev->modifiers |= btnState ; + + wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( win ) + win->MacMouseMoved( ev , windowPart ) ; + } + break; + } + } + break ; + } -#if 0 - event.m_leftDown = !(m_event.modifiers & btnState); - event.m_middleDown = FALSE; - event.m_rightDown = FALSE; -#endif - event.m_x = m_event.where.h; - event.m_y = m_event.where.v; - event.m_timeStamp = m_event.when; - event.SetEventObject(m_mouseWindow); - -// m_mouseWindow->ProcessEvent(event); - m_mouseWindow->MacDispatchMouseEvent(event); - -#if 0 - // RightButton is cmdKey click on the mac platform for one-button mouse - Bool rightButton = cCurrentEvent.modifiers & cmdKey; - // altKey is optionKey on the mac platform: - Bool isAltKey = cCurrentEvent.modifiers & optionKey; - - WXTYPE mouseEventType = rightButton ? wxEVENT_TYPE_RIGHT_DOWN - : wxEVENT_TYPE_LEFT_DOWN; - wxMouseEvent theMouseEvent(mouseEventType); - theMouseEvent.leftDown = !rightButton; - theMouseEvent.middleDown = FALSE; - theMouseEvent.rightDown = rightButton; - theMouseEvent.shiftDown = cCurrentEvent.modifiers & shiftKey; - theMouseEvent.controlDown = cCurrentEvent.modifiers & controlKey; - theMouseEvent.altDown = isAltKey; - theMouseEvent.metaDown = FALSE; // mflatt - theMouseEvent.timeStamp = cCurrentEvent.when; // mflatt - - int hitX = cCurrentEvent.where.h; // screen window c.s. - int hitY = cCurrentEvent.where.v; // screen window c.s. - - frame->ScreenToWindow(&hitX, &hitY); -// frameParentArea->ScreenToArea(&hitX, &hitY); // tx coords ? - theMouseEvent.x = hitX; // frame parent area c.s. - theMouseEvent.y = hitY; // frame parent area c.s. - - frame->SeekMouseEventArea(theMouseEvent); -#endif } -void wxApp::doMacInDrag(WindowPtr window) +void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum ) { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) + if (macMenuId == 0) + return; // no menu item selected + + if (macMenuId == kwxMacAppleMenuId && macMenuItemNum > 1) { - // should be desktop, not screen - Rect dragBoundsRect = qd.screenBits.bounds; // can't move to a different screen -//xxx ::InsetRect(&dragBoundsRect, 4, ::GetMBarHeight() + 4); // This is not really necessary - Rect oldPos = (**(((WindowPeek)window)->strucRgn)).rgnBBox; - ::DragReferencedWindow(window, m_event.where, &dragBoundsRect); // jonto - #if 0 - theMacWxFrame->m_x += (**(((WindowPeek)window)->strucRgn)).rgnBBox.left - oldPos.left; - theMacWxFrame->m_y += (**(((WindowPeek)window)->strucRgn)).rgnBBox.top - oldPos.top; + #if ! TARGET_CARBON + Str255 deskAccessoryName ; + GrafPtr savedPort ; + + GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId), macMenuItemNum, deskAccessoryName); + GetPort(&savedPort); + OpenDeskAcc(deskAccessoryName); + SetPort(savedPort); #endif - Move( (**(((WindowPeek)window)->strucRgn)).rgnBBox.left , (**(((WindowPeek)window)->strucRgn)).rgnBBox.top ) ; -#if 0 - theMacWxFrame->wxMacRecalcNewSize(); // Actually, recalc new position only -#endif - } - -#if 0 -// if (window != ::FrontWindow()) - if (window != findFrontNonFloatingWindow()) - { -// wxFrame* frontFrame = findMacWxFrame(::FrontWindow()); - wxFrame* frontFrame = findMacWxFrame(findFrontNonFloatingWindow()); - if (!frontFrame) wxFatalError("No wxFrame for frontWindow."); - if (frontFrame->IsModal()) - { - ::SysBeep(3); - return; - } } - - wxFrame* theMacWxFrame = findMacWxFrame(window); - if (theMacWxFrame) - { - Rect dragBoundsRect = qd.screenBits.bounds; // can't move to a different screen - ::InsetRect(&dragBoundsRect, 4, ::GetMBarHeight() + 4); // This is not really necessary - newDragWindow(window, cCurrentEvent.where, &dragBoundsRect); // jonto - theMacWxFrame->wxMacRecalcNewSize(); // Actually, recalc new position only - if (!IsFloating(window)) - { - theMacWxFrame->ShowAsActive(true); // temporary measure... - } - } -#endif -} - -void wxApp::doMacInGrow(WindowPtr window) -{ - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) + else { - Rect growSizeRect; // WCH: growSizeRect should be a member of wxFrame class - growSizeRect.top = 1; // minimum window height - growSizeRect.left = 1; // minimum window width - growSizeRect.bottom = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top; - growSizeRect.right = qd.screenBits.bounds.right - qd.screenBits.bounds.left; - long windSize = ::GrowWindow(window, m_event.where, &growSizeRect); - if (windSize != 0) - { - int nWidth = LoWord(windSize); - int nHeight = HiWord(windSize); - int oWidth, oHeight; - theMacWxFrame->GetSize(&oWidth, &oHeight); - if (nWidth == 0) nWidth = oWidth; - if (nHeight == 0) nHeight = oHeight; - theMacWxFrame->SetSize( -1, -1, nWidth, nHeight, wxSIZE_USE_EXISTING); - } - } + wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ; + if ( frontwindow && wxMenuBar::s_macInstalledMenuBar ) + wxMenuBar::s_macInstalledMenuBar->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ; + } + HiliteMenu(0); } -void wxApp::doMacInGoAway(WindowPtr window) -{ - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) - { - if (TrackGoAway(window, m_event.where)) - { - // TODO: Stefan, I think you need to send a wxCloseEvent to the window - // here. The OnCloseWindow handler will take care of delete the frame - // if it wishes to (there should be a default wxFrame::OnCloseWindow - // that destroys the frame). - if (theMacWxFrame->OnClose()) { -#if WXGARBAGE_COLLECTION_ON - theMacWxFrame->Show(FALSE); -#else - delete theMacWxFrame; -#endif - } - } - } -} - -void wxApp::doMacInZoom(WindowPtr window, short windowPart) +/* +long wxApp::MacTranslateKey(char key, int mods) { - wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(window); - if (theMacWxFrame) - { - if (TrackBox(window, m_event.where, windowPart)) - { -#if 0 - theMacWxFrame->Maximize(windowPart == inZoomOut); -#endif - } - } } -long wxApp::macTranslateKey(char key, int mods) +void wxApp::MacAdjustCursor() { - static Handle transH = NULL; - static unsigned long transState = 0; - static Handle ScriptH = NULL; - static short region_code = 1; - - if (!ScriptH) { // tom: don't guess the regioncode!!!! - struct ItlbRecord * r; - ScriptH = GetResource('itlb',0); - if (ScriptH) { - HLock(ScriptH); - r = (ItlbRecord*)*ScriptH; - region_code = r->itlbKeys; - HUnlock(ScriptH); - } - } - - switch (key) { - case 0x7e: - case 0x3e: - key = WXK_UP; - break; - case 0x7d: - case 0x3d: - key = WXK_DOWN; - break; - case 0x7b: - case 0x3b: - key = WXK_LEFT; - break; - case 0x7c: - case 0x3c: - key = WXK_RIGHT; - break; - case 0x24: - case 0x4c: - key = WXK_RETURN; - break; - case 0x30: - key = WXK_TAB; - break; - case 0x33: - key = WXK_BACK; - break; - case 0x75: - key = WXK_DELETE; - break; - case 0x73: - key = WXK_HOME; - break; - case 0x77: - key = WXK_END; - break; - case 0x74: - key = WXK_PAGEUP; - break; - case 0x79: - key = WXK_PAGEDOWN; - break; - default: - if (!transH) { - transH = GetIndResource('KCHR', 1); - HNoPurge(transH); - } -#if 0 //Tom replaces - if (transH) { - // Only let shift & option modify the key: - HLock(transH); - key = KeyTranslate(*transH, (key & 0x7F) | mods, &transState) & charCodeMask; - HUnlock(transH); -#else - if (0) { // tom fettig@dfki.uni-sb.de - // why if(0): - // code is not correct, see inside Macintosh: Text 1-87 - // and 'itlk'-resource!! - // and it is not necessary, as the translated char is in - // cCurrrentEvent.message!! - // Only let shift & option modify the key: - HLock(transH); - key = KeyTranslate(*transH, (key & 0x7F) | mods, &transState) & charCodeMask; - HUnlock(transH); -#endif - } - } // end switch - - return key; } +*/ +/* void wxApp::macAdjustCursor() { - if (m_event.what != kHighLevelEvent) + if (ev->what != kHighLevelEvent) { wxWindow* theMacWxFrame = wxFrame::MacFindFrameOrDialog(::FrontWindow()); if (theMacWxFrame) { - if (!theMacWxFrame->MacAdjustCursor(m_event.where)) + if (!theMacWxFrame->MacAdjustCursor(ev->where)) ::SetCursor(&(qd.arrow)); } } } -*/ +*/ \ No newline at end of file diff --git a/src/mac/carbon/apprsrc.r b/src/mac/carbon/apprsrc.r index 408a135a9f..343157d8d1 100644 --- a/src/mac/carbon/apprsrc.r +++ b/src/mac/carbon/apprsrc.r @@ -7,611 +7,12 @@ resource 'STR#' ( 128 , "Simple Alert Messages" ) "This application needs at least a MacPlus" , "This application needs more memory" , "This application is out of memory" , - "This application needs at least System 7" , + "This application needs at least System 7.5" , + "About this wxWindows Application" , "This application needs Appearance extension (built in with System 8) - this restriction will be relieved in the final release" } } ; -data 'alis' (128, "Libs alias") { - $"0000 0000 00CE 0002 0001 0A58 5858 5858" - $"5858 5858 5800 0000 0000 0000 0000 0000" - $"0000 0000 0000 AB9F 536B 4244 0000 0002" - $"EE7C 044C 6962 7300 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0003 1F71 AE82 7707 006A 0016 026C" - $"01A3 0001 0001 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0009 5858 5858 5858" - $"5858 5800 0001 0004 0002 EE7C 0002 0019" - $"5858 5858 5858 5858 5858 5858 5858 5858" - $"5858 5858 5858 5858 5800 FFFF 0000" -}; - -data 'CSOR' (0) { - $"1441 6476 616E 6365 6420 436F 6E63 6570" - $"7473 2041 47" -}; - -resource 'FREF' (128) { - 'APPL', - 0, - "" -}; - -resource 'FREF' (129) { - 'shlb', - 1, - "" -}; - -resource 'FREF' (130) { - 'PLPW', - 2, - "" -}; - -resource 'icl4' (128) { - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0666 6666 0000 0000 0000 0006 6666 6660" - $"0666 6666 0000 0000 0000 0006 6666 6660" - $"0666 6660 0000 0000 0000 0000 6666 6660" - $"0666 6660 0000 0006 6000 0000 6666 6660" - $"0666 6660 0000 0666 6600 0000 6666 6660" - $"0666 6660 0000 6606 6600 0000 6666 6660" - $"0666 6660 0000 6606 0000 0000 6666 6660" - $"0666 6600 0000 0666 6000 0000 0666 6660" - $"0666 6600 0000 0006 6600 0000 0666 6660" - $"0666 6600 0000 0006 0060 0000 0666 6660" - $"0666 6660 0000 0006 6600 0000 6666 6660" - $"0666 6660 0000 0666 6000 0000 6666 6660" - $"0666 6666 0000 6606 0000 0006 6666 6660" - $"0666 6666 6000 6606 0000 0066 6666 6660" - $"0666 6666 6000 0666 6600 0066 6666 6660" - $"0666 6666 6600 0006 0600 0666 6666 6660" - $"0666 6666 6600 0006 0000 0666 6666 6660" - $"0666 6666 6660 0006 0000 6666 6666 6660" - $"0666 6666 6666 0006 0006 6666 6666 6660" - $"0666 6666 6666 0006 0006 6666 6666 6660" - $"0666 6666 6666 6006 0066 6666 6666 6660" - $"0666 6666 6666 6006 0066 6666 6666 6660" - $"0666 6666 6666 6006 0066 6666 6666 6660" - $"0666 6666 6666 6606 0666 6666 6666 6660" - $"0666 6666 6666 6606 0666 6666 6666 6660" - $"0666 6666 6666 6606 0666 6666 6666 6660" - $"0666 6666 6666 6606 0666 6666 6666 6660" - $"0666 6666 6666 6660 6666 6666 6666 6660" - $"0666 6666 6666 6666 6666 6666 6666 6660" - $"0666 6666 6666 6666 6666 6666 6666 6660" - $"0666 6666 6666 6666 6666 6666 6666 6660" -}; - -resource 'icl4' (129, "Editor icon-generic ") { - $"0FFF FFFF FFFF FFFF FFFF FFFF FFFF 0000" - $"F000 0000 0000 0000 0000 0000 000C F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCF FFFF FFFF FFFF FFFF CCCC F000" - $"F0CC CCFD DDDD DDDD DDDD DDDD FCCC F000" - $"F0CC CCFD DDDD DDDF FDDD DDDD FCCC F000" - $"F0CC CFDD DDDD DFFF FFDD DDDD DFCC F000" - $"F0FC CFDD DDDD FFCF FFDD DDDD DFCC F000" - $"FF0F 0FDD DDDD FFCF DDDD DDDD DFCC F0F0" - $"F00F 0FFD DDDD DFFF FDDD DDDD FFCC FFCF" - $"000F 0CFD DDDD DDDF FFDD DDDD FCCC F0CF" - $"000F 0CCF DDDD DDDF DDDD DDDF CCCC CCCF" - $"000F 0CCF FDDD DDDF FFDD DDFC CCCC CCCF" - $"000F 0CCC FDDD DFFF FDDD DDFC CCCC CCCF" - $"000F 0CCC CFDD FFCF DDDD DFCC CCCC CCCF" - $"000F 0CCC CFDD FFCF DDDD DFCC CCCC CCCF" - $"000F 0CCC CCFD DFFF FFDD FCCC CCCC CCCF" - $"000F 0CCC CCFF DDDF DFDF CCCC CCCC CCCF" - $"000F 0CCC CCCF DDDF DDDF CCCC CCCC CCCF" - $"000F 0CCC CCCC FDDF DDFC CCCC CCCC FCCF" - $"F00F 0CCC CCCC FDDF DDFC CCCC CCCC FFCF" - $"FF0F 0CCC CCCC FDDF DDFC CCCC CCCC F0F0" - $"F0F0 CCCC CCCC CFDF DFCC CCCC CCCC F000" - $"F00C CCCC CCCC CFDF DFCC CCCC CCCC F000" - $"F0CC CCCC CCCC CFDF DFCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCFF FCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"FCCC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"0FFF FFFF FFFF FFFF FFFF FFFF FFFF" -}; - -resource 'icl4' (130, "Editor icon-generic ") { - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"000F FFFF FFFF FFFF FFFF FFFF FFFF F000" - $"000F 0000 0000 0000 0000 0000 0000 F000" - $"000F 0CCC CCCC CCCC CCCC CCCC CCCC F000" - $"FFFF DDDD DDDD DDDD DDDD DDDD DDDD FFFF" - $"F00D 0000 0000 0000 0000 0000 0000 D00F" - $"F0CD 0CFD DDDD DDDD DDDD DDDD FCCC DCCF" - $"F0CD 0CFD DDDD DDDF FDDD DDDD FCCC DCCF" - $"F0CD 0FDD DDDD DFFF FFDD DDDD DFCC DCCF" - $"F0CD 0FDD DDDD FFCF FFDD DDDD DFCC DCCF" - $"F0CD 0FDD DDDD FFCF DDDD DDDD DFCC DCCF" - $"F0CD 0FFD DDDD DFFF FDDD DDDD FFCC DCCF" - $"F0CD 0CFD DDDD DDDF FFDD DDDD FCCC DCCF" - $"F0CD 0CCF DDDD DDDF DDDD DDDF CCCC DCCF" - $"F0CD 0CCF FDDD DDDF FFDD DDFC CCCC DCCF" - $"F0CD 0CCC FDDD DFFF FDDD DDFC CCCC DCCF" - $"F0CD 0CCC CFDD FFCF DDDD DFCC CCCC DCCF" - $"F0CD 0CCC CFDD FFCF DDDD DFCC CCCC DCCF" - $"F0CD 0CCC CCFD DFFF FFDD FCCC CCCC DCCF" - $"F0CD 0CCC CCFF DDDF DFDF CCCC CCCC DCCF" - $"F0CD 0CCC CCCF DDDF DDDF CCCC CCCC DCCF" - $"F0CD 0CCC CCCC FDDF DDFC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC FDDF DDFC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC FDDF DDFC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC CFDF DFCC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC CFDF DFCC CCCC CCCC DCCF" - $"F0CD 0CCC CCCC CFDF DFCC CCCC CCCC DCCF" - $"F0CD DDDD DDDD DDFF FDDD DDDD DDDD FFFF" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"F0CC CCCC CCCC CCCC CCCC CCCC CCCC F000" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF F0" -}; - -resource 'icl8' (128) { - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"00AB ABAB ABAB ABAB 0000 0000 0000 0000" - $"0000 0000 0000 00AB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB 0000 0000 0000 0000" - $"0000 0000 0000 00AB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 0000 0000" - $"0000 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 0000 00AB" - $"AB00 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 00AB ABAB" - $"ABAB 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 ABAB 00AB" - $"ABAB 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 ABAB 00AB" - $"0000 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB 0000 0000 0000 00AB ABAB" - $"AB00 0000 0000 0000 00AB ABAB ABAB AB00" - $"00AB ABAB ABAB 0000 0000 0000 0000 00AB" - $"ABAB 0000 0000 0000 00AB ABAB ABAB AB00" - $"00AB ABAB ABAB 0000 0000 0000 0000 00AB" - $"0000 AB00 0000 0000 00AB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 0000 00AB" - $"ABAB 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB AB00 0000 0000 00AB ABAB" - $"AB00 0000 0000 0000 ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB 0000 0000 ABAB 00AB" - $"0000 0000 0000 00AB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB AB00 0000 ABAB 00AB" - $"0000 0000 0000 ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB AB00 0000 00AB ABAB" - $"ABAB 0000 0000 ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB 0000 0000 00AB" - $"00AB 0000 00AB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB 0000 0000 00AB" - $"0000 0000 00AB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB AB00 0000 00AB" - $"0000 0000 ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB 0000 00AB" - $"0000 00AB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB 0000 00AB" - $"0000 00AB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB AB00 00AB" - $"0000 ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB AB00 00AB" - $"0000 ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB AB00 00AB" - $"0000 ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB 00AB" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB 00AB" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB 00AB" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB 00AB" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"ABAB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB ABAB" - $"ABAB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB ABAB" - $"ABAB ABAB ABAB ABAB ABAB ABAB ABAB AB00" - $"00AB ABAB ABAB ABAB ABAB ABAB ABAB ABAB" - $"ABAB ABAB ABAB ABAB ABAB ABAB ABAB AB" -}; - -resource 'icl8' (130, "Editor icon-generic ") { - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 0000 0000" - $"0000 00FF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FF00 0000" - $"0000 00FF 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 00F5 FF00 0000" - $"0000 00FF F5F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F8 FF00 0000" - $"FFFF FFFF F9F9 F9F9 F9F9 F9F9 F9F9 F9F9" - $"F9F9 F9F9 F9F9 F9F9 F9F9 F9F9 FFFF FFFF" - $"FF00 F5F9 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 0000 F9F5 00FF" - $"FF00 F6F9 002B FFF9 F9F9 F9F9 F9F9 F9F9" - $"F9F9 F9F9 F9F9 F9F9 FF2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B FFF9 F9F9 F9F9 F9F9 F9FF" - $"FFF9 F9F9 F9F9 F9F9 FF2B 2BF8 F92B F8FF" - $"FF00 F6F9 00FF F9F9 F9F9 F9F9 F9FF FFFF" - $"FFFF F9F9 F9F9 F9F9 F9FF 2BF8 F92B F8FF" - $"FF00 F6F9 00FF F9F9 F9F9 F9F9 FFFF 2BFF" - $"FFFF F9F9 F9F9 F9F9 F9FF 2BF8 F92B F8FF" - $"FF00 F6F9 00FF F9F9 F9F9 F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9F9 F9F9 F9FF 2BF8 F92B F8FF" - $"FF00 F6F9 00FF FFF9 F9F9 F9F9 F9FF FFFF" - $"FFF9 F9F9 F9F9 F9F9 FFFF 2BF8 F92B F8FF" - $"FF00 F6F9 002B FFF9 F9F9 F9F9 F9F9 F9FF" - $"FFFF F9F9 F9F9 F9F9 FF2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2BFF F9F9 F9F9 F9F9 F9FF" - $"F9F9 F9F9 F9F9 F9FF 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2BFF FFF9 F9F9 F9F9 F9FF" - $"FFFF F9F9 F9F9 FF2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B FFF9 F9F9 F9FF FFFF" - $"FFF9 F9F9 F9F9 FF2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2BFF F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9FF 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2BFF F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9FF 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B FFF9 F9FF FFFF" - $"FFFF F9F9 FF2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B FFFF F9F9 F9FF" - $"F9FF F9FF 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2BFF F9F9 F9FF" - $"F9F9 F9FF 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B FFF9 F9FF" - $"F9F9 FF2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B FFF9 F9FF" - $"F9F9 FF2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B FFF9 F9FF" - $"F9F9 FF2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B 2BFF F9FF" - $"F9FF 2B2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 002B 2B2B 2B2B 2B2B 2BFF F9FF" - $"F9FF 2B2B 2B2B 2B2B 2B2B 2BF8 F92B F8FF" - $"FF00 F6F9 00F8 F82B 2B2B 2B2B 2BFF F9FF" - $"F9FF 2B2B 2B2B 2B2B F8F8 F8F8 F9F7 F8FF" - $"FF00 F6F9 F9F9 F9F9 F9F9 F9F9 F9F9 FFFF" - $"FFF9 F9F9 F9F9 F9F9 F9F9 F9F9 FFFF FFFF" - $"FF00 F62B 2B2B 2B2B 2B2B 2B2B 2B2B 2B2B" - $"2B2B 2B2B 2B2B 2B2B 2B2B 2BF8 FF00 0000" - $"FFF5 F8F8 F8F8 F8F8 F8F8 F8F8 F8F8 F8F8" - $"F8F8 F8F8 F8F8 F8F8 F8F8 F8F8 FF00 0000" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FF" -}; - -resource 'icl8' (129) { - $"00FF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF 0000 0000" - $"FF00 0000 0000 0000 0000 0000 0000 0000" - $"0000 0000 0000 0000 0000 00F6 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6FF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F62B FFF9 F9F9 F9F9 F9F9 F9F9" - $"F9F9 F9F9 F9F9 F9F9 FF2B F6F7 FF00 0000" - $"FF00 F6F6 F62B FFF9 F9F9 F9F9 F9F9 F9FF" - $"FFF9 F9F9 F9F9 F9F9 FF2B F6F7 FF00 0000" - $"FF00 F7F6 F6FF F9F9 F9F9 F9F9 F9FF FFFF" - $"FFFF F9F9 F9F9 F9F9 F9FF F6F7 FF00 0000" - $"FF00 FFF7 F6FF F9F9 F9F9 F9F9 FFFF 2BFF" - $"FFFF F9F9 F9F9 F9F9 F9FF F6F7 FF00 0000" - $"FFFF 00FF 00FF F9F9 F9F9 F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9F9 F9F9 F9FF F6F7 FF00 FF00" - $"FF00 00FF 00FF FFF9 F9F9 F9F9 F9FF FFFF" - $"FFF9 F9F9 F9F9 F9F9 FFFF F6F7 FFFF F7FF" - $"0000 00FF 00F6 FFF9 F9F9 F9F9 F9F9 F9FF" - $"FFFF F9F9 F9F9 F9F9 FFF6 F6F7 FF00 F7FF" - $"0000 00FF 00F6 F6FF F9F9 F9F9 F9F9 F9FF" - $"F9F9 F9F9 F9F9 F9FF F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6FF FFF9 F9F9 F9F9 F9FF" - $"FFFF F9F9 F9F9 FFF6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 FFF9 F9F9 F9FF FFFF" - $"FFF9 F9F9 F9F9 FFF6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6FF F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9FF F6F6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6FF F9F9 FFFF 2BFF" - $"F9F9 F9F9 F9FF F6F6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6F6 FFF9 F9FF FFFF" - $"FFFF F9F9 FFF6 F6F6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6F6 FFFF F9F9 F9FF" - $"F9FF F9FF F6F6 F6F6 F6F6 F6F6 F6F6 F7FF" - $"0000 00FF 00F6 F6F6 F6F6 F6FF F9F9 F9FF" - $"F9F9 F9FF F6F6 F6F6 F6F6 F6F6 F7F6 F7FF" - $"0000 00FF 00F6 F6F6 F6F6 F6F6 FFF9 F9FF" - $"F9F9 FFF6 F6F6 F6F6 F6F6 F6F7 FFF7 F7FF" - $"FF00 00FF 00F6 F6F6 F6F6 F6F6 FFF9 F9FF" - $"F9F9 FFF6 F6F6 F6F6 F6F6 F6F7 FFFF F7FF" - $"FFFF 00FF 00F6 F6F6 F6F6 F6F6 FFF9 F9FF" - $"F9F9 FFF6 F6F6 F6F6 F6F6 F6F7 FF00 FF00" - $"FF00 FF00 F6F6 F6F6 F6F6 F6F6 F6FF F9FF" - $"F9FF F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 00F6 F6F6 F6F6 F6F6 F6F6 F6FF F9FF" - $"F9FF F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6FF F9FF" - $"F9FF F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 FFFF" - $"FFF6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FF00 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6 F6F6" - $"F6F6 F6F6 F6F6 F6F6 F6F6 F6F7 FF00 0000" - $"FFF6 F7F7 F7F7 F7F7 F7F7 F7F7 F7F7 F7F7" - $"F7F7 F7F7 F7F7 F7F7 F7F7 F7F7 FF00 0000" - $"00FF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF" -}; - -resource 'icm#' (129) { - { /* array: 2 elements */ - /* [1] */ - $"", - /* [2] */ - $"" - } -}; - -resource 'icm#' (128) { - { /* array: 2 elements */ - /* [1] */ - $"", - /* [2] */ - $"" - } -}; - -resource 'icm#' (130) { - { /* array: 2 elements */ - /* [1] */ - $"", - /* [2] */ - $"" - } -}; - -resource 'icm4' (129) { - $"" -}; - -resource 'icm4' (128) { - $"" -}; - -resource 'icm4' (130) { - $"" -}; - -resource 'icm8' (129) { - $"" -}; - -resource 'icm8' (128) { - $"" -}; - -resource 'icm8' (130) { - $"" -}; - -resource 'ICN#' (128) { - { /* array: 2 elements */ - /* [1] */ - $"0000 0000 7F00 01FE 7F00 01FE 7E00 00FE" - $"7E01 80FE 7E07 C0FE 7E0D C0FE 7E0D 00FE" - $"7C07 807E 7C01 C07E 7C01 207E 7E01 C0FE" - $"7E07 80FE 7F0D 01FE 7F8D 03FE 7F87 C3FE" - $"7FC1 47FE 7FC1 07FE 7FE1 0FFE 7FF1 1FFE" - $"7FF1 1FFE 7FF9 3FFE 7FF9 3FFE 7FF9 3FFE" - $"7FFD 7FFE 7FFD 7FFE 7FFD 7FFE 7FFD 7FFE" - $"7FFE FFFE 7FFF FFFE 7FFF FFFE 7FFF FFFE", - /* [2] */ - $"0000 0000 7F00 01FE 7F00 01FE 7E00 00FE" - $"7E01 80FE 7E07 C0FE 7E0D C0FE 7E0D 00FE" - $"7C07 807E 7C01 C07E 7C01 207E 7E01 C0FE" - $"7E07 80FE 7F0D 01FE 7F8D 03FE 7F87 C3FE" - $"7FC1 47FE 7FC1 07FE 7FE1 0FFE 7FF1 1FFE" - $"7FF1 1FFE 7FF9 3FFE 7FF9 3FFE 7FF9 3FFE" - $"7FFD 7FFE 7FFD 7FFE 7FFD 7FFE 7FFD 7FFE" - $"7FFE FFFE 7FFF FFFE 7FFF FFFE 7FFF FFFE" - } -}; - -resource 'ICN#' (129, "Editor icon-generic ") { - { /* array: 2 elements */ - /* [1] */ - $"7FFF FFF0 8000 0008 8000 0008 8000 0008" - $"82AA AA88 8200 0088 8200 0088 8201 8088" - $"A407 C048 D40D C04A 940D 004D 1607 80C9" - $"1201 C081 1101 0101 1181 C201 1087 8201" - $"104D 0401 104D 0401 1027 C801 1031 5001" - $"1011 1009 9009 200D D009 200A A009 2008" - $"8005 4008 8005 4008 8005 4008 8003 8008" - $"8000 0008 8000 0008 8000 0008 7FFF FFF0", - /* [2] */ - $"0000 0000 1FFF FFF8 1FFF FFF8 1FFF FFF8" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFF8 FFFF FFF8 FFFF FFF8" - } -}; - -resource 'ICN#' (130, "Editor icon-generic ") { - { /* array: 2 elements */ - /* [1] */ - $"0000 0000 1FFF FFF8 1000 0008 1000 0008" - $"FAAA AAAF 9200 00A1 8200 0089 9201 8081" - $"8407 C049 940D C041 840D 0049 9607 80C1" - $"8201 C089 9101 0101 8181 C209 9087 8201" - $"804D 0409 904D 0401 8027 C809 9031 5001" - $"8011 1009 9009 2001 8009 2009 9009 2001" - $"8005 4009 9005 4001 8005 4009 9557 D55F" - $"8000 0008 8000 0008 FFFF FFF8", - /* [2] */ - $"0000 0000 1FFF FFF8 1FFF FFF8 1FFF FFF8" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFF8 FFFF FFF8 FFFF FFF8" - } -}; - -resource 'ics#' (129, "Editor icon-generic ") { - { /* array: 2 elements */ - /* [1] */ - $"3FFC 2004 E007 8001 8001 8001 8001 8001" - $"8001 8001 8001 8001 8001 8007 8004 FFFC", - /* [2] */ - $"3FFC 3FFC FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFC FFFC" - } -}; - -resource 'ics#' (128) { - { /* array: 2 elements */ - /* [1] */ - $"", - /* [2] */ - $"" - } -}; - -resource 'ics#' (130, "Editor icon-generic ") { - { /* array: 2 elements */ - /* [1] */ - $"3FFC 2004 E007 8001 8001 8001 8001 8001" - $"8001 8001 8001 8001 8001 8007 8004 FFFC", - /* [2] */ - $"3FFC 3FFC FFFF FFFF FFFF FFFF FFFF FFFF" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFC FFFC" - } -}; - -resource 'ics4' (129, "Editor icon-generic ") { - $"00FF FFFF FFFF FF00 00F0 0000 0000 CF00" - $"FFFD DDDD DDDD DFFF F0D0 0000 0000 CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0DC CCCC CCCC CDCF F0DD DDDD DDDD DFFF" - $"FCCC CCCC CCCC CF00 FFFF FFFF FFFF FF" -}; - -resource 'ics4' (128) { - $"" -}; - -resource 'ics4' (130, "Editor icon-generic ") { - $"00FF FFFF FFFF FF00 00F0 0000 0000 CF00" - $"FFFD DDDD DDDD DFFF F0D0 0000 0000 CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0D0 CCCC CCCC CDCF F0D0 CCCC CCCC CDCF" - $"F0DC CCCC CCCC CDCF F0DD DDDD DDDD DFFF" - $"FCCC CCCC CCCC CF00 FFFF FFFF FFFF FF" -}; - -resource 'ics8' (129, "Editor icon-generic ") { - $"0000 FFFF FFFF FFFF FFFF FFFF FFFF 0000" - $"0000 FFF5 F5F5 F5F5 F5F5 F5F5 F6FF 0000" - $"FFFF FFF9 F9F9 F9F9 F9F9 F9F9 F9FF FFFF" - $"FFF5 F9F5 F5F5 F5F5 F5F5 F5F5 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F92B 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F9 F9F9 F9F9 F9F9 F9F9 F9FF FFFF" - $"FFF6 F8F8 F8F8 F8F8 F8F8 F8F8 F8FF 0000" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF" -}; - -resource 'ics8' (128) { - $"" -}; - -resource 'ics8' (130, "Editor icon-generic ") { - $"0000 FFFF FFFF FFFF FFFF FFFF FFFF 0000" - $"0000 FFF5 F5F5 F5F5 F5F5 F5F5 F6FF 0000" - $"FFFF FFF9 F9F9 F9F9 F9F9 F9F9 F9FF FFFF" - $"FFF5 F9F5 F5F5 F5F5 F5F5 F5F5 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F5 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F92B 2B2B 2B2B 2B2B 2B2B 2BF9 F8FF" - $"FFF5 F9F9 F9F9 F9F9 F9F9 F9F9 F9FF FFFF" - $"FFF6 F8F8 F8F8 F8F8 F8F8 F8F8 F8FF 0000" - $"FFFF FFFF FFFF FFFF FFFF FFFF FFFF" -}; - -data 'iSNP' (129) { - $"0000" /* .. */ -}; - -data 'iSNP' (128) { - $"0000" /* .. */ -}; - -data 'iSNP' (130) { - $"0000" /* .. */ -}; - -resource 'BNDL' (128) { - 'CSOR', - 0, - { /* array TypeArray: 2 elements */ - /* [1] */ - 'ICN#', - { /* array IDArray: 3 elements */ - /* [1] */ - 0, 128, - /* [2] */ - 1, 129, - /* [3] */ - 2, 130 - }, - /* [2] */ - 'FREF', - { /* array IDArray: 3 elements */ - /* [1] */ - 0, 128, - /* [2] */ - 1, 129, - /* [3] */ - 2, 130 - } - } -}; - resource 'MENU' (1, preload) { 1, textMenuProc, 0b11111111111111111111111111111110 , enabled, apple , @@ -624,3 +25,4 @@ resource 'MENU' (1, preload) resource 'MBAR' (1,preload) { { 1 } ; +} ; \ No newline at end of file diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index 1e6255f551..3a66121d49 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -20,11 +20,83 @@ #include "wx/icon.h" #include "wx/log.h" +extern "C" +{ + #include "xpm.h" +} ; + #if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) #endif +#include + +CTabHandle wxMacCreateColorTable( int numColors ) +{ + CTabHandle newColors; /* Handle to the new color table */ + short index; /* Index into the table of colors */ + /* Allocate memory for the color table */ + newColors = (CTabHandle)NewHandleClear( sizeof (ColorTable) + + sizeof (ColorSpec) * (numColors - 1) ); + if (newColors != nil) + { + /* Initialize the fields */ + (**newColors).ctSeed = GetCTSeed(); + (**newColors).ctFlags = 0; + (**newColors).ctSize = numColors - 1; + /* Initialize the table of colors */ + } + return newColors ; +} + +void wxMacDestroyColorTable( CTabHandle colors ) +{ + DisposeHandle( (Handle) colors ) ; +} + +void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) +{ + (**newColors).ctTable[index].value = index; + (**newColors).ctTable[index].rgb.red = 0 ;// someRedValue; + (**newColors).ctTable[index].rgb.green = 0 ; // someGreenValue; + (**newColors).ctTable[index].rgb.blue = 0 ; // someBlueValue; +} + +GWorldPtr wxMacCreateGWorld( int height , int width , int depth ) +{ + OSErr err = noErr ; + GWorldPtr port ; + Rect rect = { 0 , 0 , width , height } ; + + if ( depth < 0 ) + { + // get max pixel depth + CGrafPtr port ; + GetCWMgrPort( &port ) ; + GDHandle maxDevice ; + + maxDevice = GetMaxDevice( &port->portRect ) ; + if ( maxDevice ) + depth = (**((**maxDevice).gdPMap)).pixelSize ; + else + depth = 8 ; + } + + err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ; + if ( err == noErr ) + { + return port ; + } + return NULL ; +} + +void wxMacDestroyGWorld( GWorldPtr gw ) +{ + if ( gw ) + DisposeGWorld( gw ) ; +} + wxBitmapRefData::wxBitmapRefData() { m_ok = FALSE; @@ -34,17 +106,43 @@ wxBitmapRefData::wxBitmapRefData() m_quality = 0; m_numColors = 0; m_bitmapMask = NULL; + m_hBitmap = NULL ; + m_hPict = NULL ; + m_bitmapType = kMacBitmapTypeUnknownType ; } wxBitmapRefData::~wxBitmapRefData() { - /* - * TODO: delete the bitmap data here. - */ - - if (m_bitmapMask) - delete m_bitmapMask; + switch (m_bitmapType) + { + case kMacBitmapTypePict : + { + if ( m_hPict ) + { + KillPicture( m_hPict ) ; + m_hPict = NULL ; + } + } + break ; + case kMacBitmapTypeGrafWorld : + { + if ( m_hBitmap ) + { + wxMacDestroyGWorld( m_hBitmap ) ; + m_hBitmap = NULL ; + } + } + break ; + default : + // unkown type ? + break ; + } ; + + if (m_bitmapMask) + { + delete m_bitmapMask; m_bitmapMask = NULL; + } } wxList wxBitmap::sm_handlers; @@ -71,8 +169,57 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits M_BITMAPDATA->m_height = the_height ; M_BITMAPDATA->m_depth = no_bits ; M_BITMAPDATA->m_numColors = 0; - - /* TODO: create the bitmap from data */ + if ( no_bits == 1 ) + { + M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; + M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( the_width , the_height , no_bits ) ; + M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ; + + CGrafPtr origPort ; + GDHandle origDevice ; + + GetGWorld( &origPort , &origDevice ) ; + SetGWorld( M_BITMAPDATA->m_hBitmap , NULL ) ; + + // bits is a word aligned array + + unsigned char* linestart = (unsigned char*) bits ; + int linesize = ( the_width / 16 ) * 2 ; + if ( the_width % 16 ) + { + linesize += 2 ; + } ; + + RGBColor colors[2] = { + { 0xFFFF , 0xFFFF , 0xFFFF } , + { 0, 0 , 0 } + } ; + + for( int y = 0 ; y < the_height ; ++y , linestart += linesize ) + { + for( int x = 0 ; x < the_width ; ++x ) + { + int index = x / 8 ; + int bit = x % 8 ; + int mask = 1 << bit ; + if ( linestart[index] & mask ) + { + SetCPixel( x , y , &colors[1] ) ; + } + else + { + SetCPixel( x , y , &colors[0] ) ; + } + } + + } + + SetGWorld( origPort , origDevice ) ; + } + else + { + //multicolor BITMAPs not yet implemented + } if ( wxTheBitmapList ) wxTheBitmapList->AddBitmap(this); @@ -102,13 +249,10 @@ wxBitmap::wxBitmap(const wxString& filename, long type) wxTheBitmapList->AddBitmap(this); } -/* TODO: maybe allow creation from XPM -// Create from data wxBitmap::wxBitmap(const char **data) { (void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); } -*/ bool wxBitmap::Create(int w, int h, int d) { @@ -120,11 +264,19 @@ bool wxBitmap::Create(int w, int h, int d) M_BITMAPDATA->m_height = h; M_BITMAPDATA->m_depth = d; - /* TODO: create new bitmap */ - + M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; + M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( w , h , d ) ; + M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ; return M_BITMAPDATA->m_ok; } +void wxBitmap::SetHBITMAP(WXHBITMAP bmp) +{ + M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; + M_BITMAPDATA->m_hBitmap = bmp ; + M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ; +} + bool wxBitmap::LoadFile(const wxString& filename, long type) { UnRef(); @@ -386,6 +538,52 @@ bool wxBitmapHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, * Standard handlers */ +class WXDLLEXPORT wxPICTResourceHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxPICTResourceHandler) +public: + inline wxPICTResourceHandler() + { + m_name = "Macintosh Pict resource"; + m_extension = ""; + m_type = wxBITMAP_TYPE_PICT_RESOURCE; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); +}; +IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler) + +bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ + Str255 theName ; + + strcpy( (char*) theName , name ) ; + c2pstr( (char*) theName ) ; + + PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ; + if ( thePict ) + { + PictInfo theInfo ; + + GetPictInfo( thePict , &theInfo , 0 , 0 , systemMethod , 0 ) ; + DetachResource( (Handle) thePict ) ; + M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypePict ; + M_BITMAPHANDLERDATA->m_hPict = thePict ; + M_BITMAPHANDLERDATA->m_width = theInfo.sourceRect.right - theInfo.sourceRect.left ; + M_BITMAPHANDLERDATA->m_height = theInfo.sourceRect.bottom - theInfo.sourceRect.top ; + + M_BITMAPHANDLERDATA->m_depth = theInfo.depth ; + M_BITMAPHANDLERDATA->m_ok = true ; + M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ; +// M_BITMAPHANDLERDATA->m_bitmapPalette; +// M_BITMAPHANDLERDATA->m_quality; + return TRUE ; + } + return FALSE ; +} + /* TODO: bitmap handlers, a bit like this: class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler { @@ -404,6 +602,251 @@ public: IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler) */ +class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxXPMFileHandler) +public: + inline wxXPMFileHandler(void) + { + m_name = "XPM bitmap file"; + m_extension = "xpm"; + m_type = wxBITMAP_TYPE_XPM; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth = -1, int desiredHeight = -1); + virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); +}; +IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler) + +bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ +#if USE_XPM_IN_MSW + XImage *ximage; + XpmAttributes xpmAttr; + HDC dc; + + M_BITMAPHANDLERDATA->m_ok = FALSE; + dc = CreateCompatibleDC(NULL); + if (dc) + { + xpmAttr.valuemask = XpmReturnPixels; + int errorStatus = XpmReadFileToImage(&dc, WXSTRINGCAST name, &ximage, (XImage **) NULL, &xpmAttr); + DeleteDC(dc); + if (errorStatus == XpmSuccess) + { + M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap; + + BITMAP bm; + GetObject((HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap, sizeof(bm), (LPSTR) & bm); + + M_BITMAPHANDLERDATA->m_width = (bm.bmWidth); + M_BITMAPHANDLERDATA->m_height = (bm.bmHeight); + M_BITMAPHANDLERDATA->m_depth = (bm.bmPlanes * bm.bmBitsPixel); + M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; + XpmFreeAttributes(&xpmAttr); + XImageFree(ximage); + + M_BITMAPHANDLERDATA->m_ok = TRUE; + return TRUE; + } + else + { + M_BITMAPHANDLERDATA->m_ok = FALSE; + return FALSE; + } + } +#endif + + return FALSE; +} + +bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) +{ +#if USE_XPM_IN_MSW + HDC dc = NULL; + + Visual *visual = NULL; + XImage ximage; + + dc = CreateCompatibleDC(NULL); + if (dc) + { + if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap)) + { /* for following SetPixel */ + /* fill the XImage struct 'by hand' */ + ximage.width = M_BITMAPHANDLERDATA->m_width; + ximage.height = M_BITMAPHANDLERDATA->m_height; + ximage.depth = M_BITMAPHANDLERDATA->m_depth; + ximage.bitmap = (void *)M_BITMAPHANDLERDATA->m_hBitmap; + int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name, + &ximage, (XImage *) NULL, (XpmAttributes *) NULL); + + if (dc) + DeleteDC(dc); + + if (errorStatus == XpmSuccess) + return TRUE; /* no error */ + else + return FALSE; + } else return FALSE; + } else return FALSE; +#else + return FALSE; +#endif +} + + +class WXDLLEXPORT wxXPMDataHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxXPMDataHandler) +public: + inline wxXPMDataHandler(void) + { + m_name = "XPM bitmap data"; + m_extension = "xpm"; + m_type = wxBITMAP_TYPE_XPM_DATA; + }; + + virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); +}; +IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler) + +bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth) +{ + XImage * ximage; + int ErrorStatus; + XpmAttributes xpmAttr; + + xpmAttr.valuemask = XpmReturnInfos; // get infos back + ErrorStatus = XpmCreateImageFromData( GetMainDevice() , (char **)data, + &ximage, (XImage **) NULL, &xpmAttr); + + if (ErrorStatus == XpmSuccess) + { + M_BITMAPHANDLERDATA->m_ok = FALSE; + M_BITMAPHANDLERDATA->m_numColors = 0; + M_BITMAPHANDLERDATA->m_hBitmap = ximage->gworldptr ; + + M_BITMAPHANDLERDATA->m_width = ximage->width; + M_BITMAPHANDLERDATA->m_height = ximage->height; + M_BITMAPHANDLERDATA->m_depth = ximage->depth; + M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels; + XpmFreeAttributes(&xpmAttr); + M_BITMAPHANDLERDATA->m_ok = TRUE; + ximage->gworldptr = NULL ; + XImageFree(ximage); // releases the malloc, but does not detroy + // the bitmap + M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeGrafWorld ; + + return TRUE; + } + else + { + M_BITMAPHANDLERDATA->m_ok = FALSE; + return FALSE; + } + return FALSE; +} + +class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler) +public: + inline wxBMPResourceHandler() + { + m_name = "Windows bitmap resource"; + m_extension = ""; + m_type = wxBITMAP_TYPE_BMP_RESOURCE; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); +}; + +IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler) + +bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ + // TODO: load colourmap. +/* + M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ::LoadBitmap(wxGetInstance(), name); + if (M_BITMAPHANDLERDATA->m_hBitmap) + { + M_BITMAPHANDLERDATA->m_ok = TRUE; + BITMAP bm; + GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(BITMAP), (LPSTR) &bm); + M_BITMAPHANDLERDATA->m_width = bm.bmWidth; + M_BITMAPHANDLERDATA->m_height = bm.bmHeight; + M_BITMAPHANDLERDATA->m_depth = bm.bmBitsPixel; + return TRUE; + } +*/ + // it's probably not found + wxLogError("Can't load bitmap '%s' from resources! Check .rc file.", name.c_str()); + + return FALSE; +} + +class WXDLLEXPORT wxBMPFileHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxBMPFileHandler) +public: + inline wxBMPFileHandler(void) + { + m_name = "Windows bitmap file"; + m_extension = "bmp"; + m_type = wxBITMAP_TYPE_BMP; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); + virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); +}; + +IMPLEMENT_DYNAMIC_CLASS(wxBMPFileHandler, wxBitmapHandler) + +bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ +#if USE_IMAGE_LOADING_IN_MSW + wxPalette *palette = NULL; + bool success = FALSE; +/* + if (type & wxBITMAP_DISCARD_COLOURMAP) + success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap); + else +*/ + success = (wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0); + if (!success && palette) + { + delete palette; + palette = NULL; + } + if (palette) + M_BITMAPHANDLERDATA->m_bitmapPalette = *palette; + return success; +#else + return FALSE; +#endif +} + +bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *pal) +{ +#if USE_IMAGE_LOADING_IN_MSW + wxPalette *actualPalette = (wxPalette *)pal; + if (!actualPalette && (!M_BITMAPHANDLERDATA->m_bitmapPalette.IsNull())) + actualPalette = & (M_BITMAPHANDLERDATA->m_bitmapPalette); + return (wxSaveBitmap(WXSTRINGCAST name, bitmap, actualPalette) != 0); +#else + return FALSE; +#endif +} + + + void wxBitmap::CleanUpHandlers() { wxNode *node = sm_handlers.First(); @@ -419,12 +862,10 @@ void wxBitmap::CleanUpHandlers() void wxBitmap::InitStandardHandlers() { -/* TODO: initialize all standard bitmap or derive class handlers here. - AddHandler(new wxBMPResourceHandler); - AddHandler(new wxBMPFileHandler); - AddHandler(new wxXPMFileHandler); - AddHandler(new wxXPMDataHandler); - AddHandler(new wxICOResourceHandler); - AddHandler(new wxICOFileHandler); -*/ + AddHandler( new wxPICTResourceHandler ) ; + AddHandler( new wxICONResourceHandler ) ; + AddHandler(new wxXPMFileHandler); + AddHandler(new wxXPMDataHandler); + AddHandler(new wxBMPResourceHandler); + AddHandler(new wxBMPFileHandler); } diff --git a/src/mac/carbon/brush.cpp b/src/mac/carbon/brush.cpp index 4f28e92f53..cb9d76d1ab 100644 --- a/src/mac/carbon/brush.cpp +++ b/src/mac/carbon/brush.cpp @@ -24,7 +24,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) wxBrushRefData::wxBrushRefData() { m_style = wxSOLID; -// TODO: null data } wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) @@ -32,14 +31,10 @@ wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) m_style = data.m_style; m_stipple = data.m_stipple; m_colour = data.m_colour; -/* TODO: null data - m_hBrush = 0; -*/ } wxBrushRefData::~wxBrushRefData() { -// TODO: delete data } // Brushes @@ -134,7 +129,6 @@ void wxBrush::SetStipple(const wxBitmap& Stipple) bool wxBrush::RealizeResource() { -// TODO: create the brush - return FALSE; + return TRUE; } diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index befd0d7156..cb44786443 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -19,57 +19,53 @@ IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl) #endif +#include // Button + bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - m_windowStyle = style; - - parent->AddChild((wxButton *)this); - - if (id == -1) - m_windowId = NewControlId(); - else - m_windowId = id; - - // TODO: create button - - return FALSE; -} - -void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + Rect bounds ; + Str255 title ; + m_macHorizontalBorder = 2 ; // additional pixels around the real control + m_macVerticalBorder = 2 ; + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlPushButtonProc , (long) this ) ; + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + MacPostControlCreate() ; + + return TRUE; } void wxButton::SetDefault() { - wxWindow *parent = (wxWindow *)GetParent(); - if (parent) - parent->SetDefaultItem(this); - - // TODO: make button the default -} - -wxString wxButton::GetLabel() const -{ - // TODO - return wxString(""); + wxWindow *parent = (wxWindow *)GetParent(); + if (parent) + parent->SetDefaultItem(this); + + if ( m_macControl ) + { + UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ; + } } -void wxButton::SetLabel(const wxString& label) +void wxButton::Command (wxCommandEvent & event) { - // TODO + ProcessCommand (event); } -void wxButton::Command (wxCommandEvent & event) +void wxButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) { - ProcessCommand (event); + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId ); + event.SetEventObject(this); + ProcessCommand(event); } diff --git a/src/mac/carbon/checkbox.cpp b/src/mac/carbon/checkbox.cpp index dd2e2abe7a..ca99c4b778 100644 --- a/src/mac/carbon/checkbox.cpp +++ b/src/mac/carbon/checkbox.cpp @@ -20,6 +20,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox) #endif +#include + // Single check box item bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, @@ -27,41 +29,27 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = NewControlId(); - else - m_windowId = id; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - // TODO: create checkbox + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlCheckBoxProc , (long) this ) ; + + MacPostControlCreate() ; - return FALSE; -} - -void wxCheckBox::SetLabel(const wxString& label) -{ - // TODO -} - -void wxCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + return TRUE; } void wxCheckBox::SetValue(bool val) { - // TODO + ::SetControlValue( m_macControl , val ) ; } bool wxCheckBox::GetValue() const { - // TODO - return FALSE; + return ::GetControlValue( m_macControl ) ; } void wxCheckBox::Command (wxCommandEvent & event) @@ -70,6 +58,11 @@ void wxCheckBox::Command (wxCommandEvent & event) ProcessCommand (event); } +void wxCheckBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + SetValue( !GetValue() ) ; +} + // Bitmap checkbox bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label, const wxPoint& pos, @@ -100,7 +93,7 @@ void wxBitmapCheckBox::SetLabel(const wxBitmap *bitmap) void wxBitmapCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; } void wxBitmapCheckBox::SetValue(bool val) diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index a584d5303f..da3c4efc92 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -15,6 +15,7 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/choice.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) @@ -23,71 +24,103 @@ IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) 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) { - SetName(name); - SetValidator(validator); m_noStrings = n; - m_windowStyle = style; - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - // TODO: create choice control - return FALSE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0, + kControlPopupButtonProc , (long) this ) ; + + m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; + SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; + for ( int i = 0 ; i < n ; i++ ) + { + appendmenu( m_macPopUpMenuHandle , choices[i] ) ; + } + SetControlMinimum( m_macControl , 0 ) ; + SetControlMaximum( m_macControl , m_noStrings) ; + SetControlValue( m_macControl , 1 ) ; + + MacPostControlCreate() ; + + return TRUE; } void wxChoice::Append(const wxString& item) { - // TODO + appendmenu( m_macPopUpMenuHandle , item ) ; m_noStrings ++; + SetControlMaximum( m_macControl , m_noStrings) ; } void wxChoice::Delete(int n) { - // TODO + wxASSERT( n < m_noStrings ) ; + ::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ; m_noStrings --; + SetControlMaximum( m_macControl , m_noStrings) ; } void wxChoice::Clear() { - // TODO + for ( int i = 0 ; i < m_noStrings ; i++ ) + { + ::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ; + } m_noStrings = 0; + SetControlMaximum( m_macControl , m_noStrings) ; } int wxChoice::GetSelection() const { - // TODO - return 0; + return GetControlValue( m_macControl ) -1 ; } +void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); + event.SetInt(GetSelection()); + event.SetEventObject(this); + event.SetString(copystring(GetStringSelection())); + ProcessCommand(event); + delete[] event.GetString(); +} + + void wxChoice::SetSelection(int n) { - // TODO + SetControlValue( m_macControl , n + 1 ) ; } int wxChoice::FindString(const wxString& s) const { - // TODO - return 0; + for( int i = 0 ; i < m_noStrings ; i++ ) + { + if ( GetString( i ) == s ) + return i ; + } + return -1; } wxString wxChoice::GetString(int n) const { - // TODO - return wxString(""); + Str255 text ; + ::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ; + p2cstr( text ) ; + return wxString( text ); } void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x,y,width,height,sizeFlags ) ; } wxString wxChoice::GetStringSelection () const diff --git a/src/mac/carbon/clipbrd.cpp b/src/mac/carbon/clipbrd.cpp index 3fe9ebfb72..28a4b9ef3f 100644 --- a/src/mac/carbon/clipbrd.cpp +++ b/src/mac/carbon/clipbrd.cpp @@ -30,19 +30,17 @@ IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject) bool wxOpenClipboard() { - // TODO - return FALSE; + return TRUE; } bool wxCloseClipboard() { - // TODO return FALSE; } bool wxEmptyClipboard() { - // TODO + ZeroScrap() ; return FALSE; } @@ -169,7 +167,7 @@ wxClipboardClient *wxClipboard::GetClipboardClient() } void wxClipboard::SetClipboardString(char *str, long time) -{ +{/* bool got_selection; if (clipOwner) { @@ -195,6 +193,7 @@ void wxClipboard::SetClipboardString(char *str, long time) delete[] cbString; cbString = NULL; } + */ } char *wxClipboard::GetClipboardString(long time) diff --git a/src/mac/carbon/colordlg.cpp b/src/mac/carbon/colordlg.cpp index 2275a9a39d..c6037a9f96 100644 --- a/src/mac/carbon/colordlg.cpp +++ b/src/mac/carbon/colordlg.cpp @@ -14,7 +14,7 @@ #pragma implementation "colordlg.h" #endif -#include "wx/stubs/colordlg.h" +#include "wx/mac/colordlg.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) @@ -45,8 +45,20 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) int wxColourDialog::ShowModal() { - /* TODO: implement dialog - */ + Point where ; + RGBColor currentColor = m_colourData.dataColour.GetPixel() , newColor ; + + where.h = where.v = -1; + + if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor )) + { + m_colourData.dataColour.Set( 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 8d0827ef1d..cc549b5f11 100644 --- a/src/mac/carbon/colour.cpp +++ b/src/mac/carbon/colour.cpp @@ -22,13 +22,20 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) // Colour +static void wxComposeRGBColor( RGBColor * col , int red, int blue, int green ) ; +static void wxComposeRGBColor( RGBColor * col , int red, int blue, int 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; -/* TODO - m_pixel = 0; -*/ + 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) @@ -37,9 +44,8 @@ wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) m_green = g; m_blue = b; m_isInit = TRUE; -/* TODO - m_pixel = PALETTERGB (m_red, m_green, m_blue); -*/ + + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::wxColour (const wxColour& col) @@ -48,9 +54,18 @@ wxColour::wxColour (const wxColour& col) m_green = col.m_green; m_blue = col.m_blue; m_isInit = col.m_isInit; -/* TODO + m_pixel = col.m_pixel; -*/ +} + +wxColour::wxColour (const wxColour* col) +{ + m_red = col->m_red; + m_green = col->m_green; + m_blue = col->m_blue; + m_isInit = col->m_isInit; + + m_pixel = col->m_pixel; } wxColour& wxColour::operator =(const wxColour& col) @@ -59,9 +74,9 @@ wxColour& wxColour::operator =(const wxColour& col) m_green = col.m_green; m_blue = col.m_blue; m_isInit = col.m_isInit; -/* TODO + m_pixel = col.m_pixel; -*/ + return *this; } @@ -82,9 +97,8 @@ void wxColour::InitFromName(const wxString& col) m_blue = 0; m_isInit = FALSE; } -/* TODO - m_pixel = PALETTERGB (m_red, m_green, m_blue); -*/ + + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::~wxColour () @@ -97,7 +111,6 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) m_green = g; m_blue = b; m_isInit = TRUE; -/* TODO - m_pixel = PALETTERGB (m_red, m_green, m_blue); -*/ + + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 0be841bad4..905f3180aa 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -14,11 +14,15 @@ #endif #include "wx/combobox.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl) #endif +// right now we don't support editable comboboxes + + bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, @@ -28,32 +32,39 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); m_noStrings = n; - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - // TODO: create combobox control - return TRUE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0, + kControlPopupButtonProc , (long) this ) ; + + m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; + SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; + for ( int i = 0 ; i < n ; i++ ) + { + appendmenu( m_macPopUpMenuHandle , choices[i] ) ; + } + SetControlMinimum( m_macControl , 0 ) ; + SetControlMaximum( m_macControl , m_noStrings) ; + SetControlValue( m_macControl , 1 ) ; + + MacPostControlCreate() ; + + return TRUE; } wxString wxComboBox::GetValue() const { - // TODO - return wxString(""); + return GetStringSelection() ; } void wxComboBox::SetValue(const wxString& value) { - // TODO + SetStringSelection( value ) ; } // Clipboard operations @@ -116,50 +127,85 @@ void wxComboBox::SetSelection(long from, long to) void wxComboBox::Append(const wxString& item) { - // TODO + appendmenu( m_macPopUpMenuHandle , item ) ; + m_noStrings ++; + SetControlMaximum( m_macControl , m_noStrings) ; } void wxComboBox::Delete(int n) { - // TODO + wxASSERT( n < m_noStrings ) ; + ::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ; + m_noStrings --; + SetControlMaximum( m_macControl , m_noStrings) ; } void wxComboBox::Clear() { - // TODO + for ( int i = 0 ; i < m_noStrings ; i++ ) + { + ::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ; + } + m_noStrings = 0; + SetControlMaximum( m_macControl , m_noStrings) ; } int wxComboBox::GetSelection() const { - // TODO - return -1; + return GetControlValue( m_macControl ) -1 ; } void wxComboBox::SetSelection(int n) { - // TODO + SetControlValue( m_macControl , n + 1 ) ; } int wxComboBox::FindString(const wxString& s) const { - // TODO + for( int i = 0 ; i < m_noStrings ; i++ ) + { + if ( GetString( i ) == s ) + return i ; + } return -1; } wxString wxComboBox::GetString(int n) const { - // TODO - return wxString(""); + Str255 text ; + ::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ; + p2cstr( text ) ; + return wxString( text ); } wxString wxComboBox::GetStringSelection() const { - // TODO - return wxString(""); + int sel = GetSelection (); + if (sel > -1) + return wxString(this->GetString (sel)); + else + return wxString(""); } bool wxComboBox::SetStringSelection(const wxString& sel) { - // TODO - return FALSE; + int s = FindString (sel); + if (s > -1) + { + SetSelection (s); + return TRUE; + } + else + return FALSE; +} + +void wxComboBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId ); + event.SetInt(GetSelection()); + event.SetEventObject(this); + event.SetString(copystring(GetStringSelection())); + ProcessCommand(event); + delete[] event.GetString(); } + diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index b141a80ff1..d570e2c5a1 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -14,20 +14,51 @@ #endif #include "wx/control.h" +#include "wx/notebook.h" +#include "wx/tabctrl.h" +#include "wx/spinbutt.h" #if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) BEGIN_EVENT_TABLE(wxControl, wxWindow) + EVT_MOUSE_EVENTS( wxControl::OnMouseEvent ) + EVT_CHAR( wxControl::OnKeyDown ) + EVT_PAINT( wxControl::OnPaint ) END_EVENT_TABLE() #endif +#include + // Item members + +ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ; + +pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) +{ + if ( partCode != 0) + { + wxControl* wx = (wxControl*) GetControlReference( control ) ; + if ( wx ) + { + wx->MacHandleControlClick( control , partCode ) ; + } + } +} + wxControl::wxControl() { + m_macControl = NULL ; + m_macHorizontalBorder = 0 ; // additional pixels around the real control + m_macVerticalBorder = 0 ; m_backgroundColour = *wxWHITE; m_foregroundColour = *wxBLACK; m_callback = 0; + + if ( wxMacLiveScrollbarActionUPP == NULL ) + { + wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ; + } } wxControl::~wxControl() @@ -40,17 +71,31 @@ wxControl::~wxControl() if (parent->GetDefaultItem() == (wxButton*) this) parent->SetDefaultItem(NULL); } + if ( m_macControl ) + { + UMADisposeControl( m_macControl ) ; + m_macControl = NULL ; + } } void wxControl::SetLabel(const wxString& label) { - // TODO + m_label = label ; + + if ( m_macControl ) + { + Str255 maclabel ; + + strcpy( (char*) maclabel , label ) ; + c2pstr( (char*) maclabel ) ; + + ::SetControlTitle( m_macControl , maclabel ) ; + } } wxString wxControl::GetLabel() const { - // TODO - return wxString(""); + return m_label ; } void wxControl::ProcessCommand (wxCommandEvent & event) @@ -93,3 +138,566 @@ void wxControl::Centre (int direction) SetSize (new_x, new_y, width, height); } +void wxControl::SetClientSize (int width, int height) +{ + SetSize (-1, -1, width, height); +} + +// ------------------------ +wxList *wxWinMacControlList = NULL; +wxControl *wxFindControlFromMacControl(ControlHandle inControl ) +{ + wxNode *node = wxWinMacControlList->Find((long)inControl); + if (!node) + return NULL; + return (wxControl *)node->Data(); +} + +void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control) +{ + // adding NULL WindowRef is (first) surely a result of an error and + // (secondly) breaks menu command processing + wxCHECK_RET( inControl != (ControlHandle) NULL, "attempt to add a NULL WindowRef to window list" ); + + if ( !wxWinMacControlList->Find((long)inControl) ) + wxWinMacControlList->Append((long)inControl, control); +} + +void wxRemoveMacControlAssociation(wxControl *control) +{ + wxWinMacControlList->DeleteObject(control); +} + +void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label , + const wxPoint& pos, + const wxSize& size, long style, + const wxValidator& validator, + const wxString& name , Rect *outBounds , StringPtr maclabel ) +{ + m_label = label ; + SetName(name); + if ( &validator ) + SetValidator(validator); + + m_windowStyle = style; + parent->AddChild((wxButton *)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 ; + + + Point localOrigin ; + Rect clipRect ; + + parent->MacClientToRootWindow( &x , &y ) ; + outBounds->top = y + m_macVerticalBorder ; + outBounds->left = x + m_macHorizontalBorder ; + outBounds->bottom = outBounds->top + m_height - 2 * m_macVerticalBorder; + outBounds->right = outBounds->left + m_width - 2 * m_macHorizontalBorder ; + + strcpy( (char*) maclabel , label ) ; + if( wxApp::s_macDefaultEncodingIsPC ) + { + wxMacConvertFromPCForControls( (char*) maclabel ) ; + } + + c2pstr( (char*) maclabel ) ; +} + +void wxControl::MacPostControlCreate() +{ + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) + { + // no font + } + else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) + { + ControlFontStyleRec controlstyle ; + controlstyle.flags = kControlUseFontMask ; + controlstyle.font = kControlFontSmallBoldSystemFont ; + + ::UMASetControlFontStyle( m_macControl , &controlstyle ) ; + } + else + { + ControlFontStyleRec controlstyle ; + controlstyle.flags = kControlUseFontMask ; + controlstyle.font = kControlFontSmallSystemFont ; + + ::UMASetControlFontStyle( m_macControl , &controlstyle ) ; + } + ControlHandle container = GetParent()->MacGetContainerForEmbedding() ; + wxASSERT_MSG( container != NULL , "No valid mac container control" ) ; + ::UMAEmbedControl( m_macControl , container ) ; + MacAdjustControlRect() ; + wxAssociateControlWithMacControl( m_macControl , this ) ; +} + +void wxControl::MacAdjustControlRect() +{ + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + if ( m_width == -1 || m_height == -1 ) + { + Rect bestsize = { 0 , 0 , 0 , 0 } ; + short baselineoffset ; + + UMAGetBestControlRect( m_macControl , &bestsize , &baselineoffset ) ; + + if ( EmptyRect( &bestsize ) ) + { + baselineoffset = 0; + bestsize.left = bestsize.top = 0 ; + bestsize.right = 16 ; + bestsize.bottom = 16 ; + if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) + { + bestsize.bottom = 16 ; + } + else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) + { + bestsize.bottom = 24 ; + } + } + + if ( m_width == -1 ) + { + if ( IsKindOf( CLASSINFO( wxButton ) ) ) + { + m_width = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder; + } + else if ( IsKindOf( CLASSINFO( wxStaticText ) ) ) + { + m_width = m_label.Length() * 8 ; + } + else + m_width = bestsize.right - bestsize.left + 2 * m_macHorizontalBorder; + } + if ( m_height == -1 ) + { + m_height = bestsize.bottom - bestsize.top ; + if ( m_height < 10 ) + m_height = 13 ; + + m_height += 2 * m_macVerticalBorder; + } + + wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ; + if ( helper.Ok() ) + { + UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; + } + } +} +ControlHandle wxControl::MacGetContainerForEmbedding() +{ + if ( m_macControl ) + return m_macControl ; + + return wxWindow::MacGetContainerForEmbedding() ; +} + +void wxControl::MacSuperChangedPosition() +{ + if ( m_macControl ) + { + int former_mac_x = (**m_macControl).contrlRect.left ; + int former_mac_y = (**m_macControl).contrlRect.top ; + int mac_x = m_x ; + int mac_y = m_y ; + GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ; + + WindowRef rootwindow = GetMacRootWindow() ; + wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ; + UMASetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ; + wxMacDrawingHelper focus( wxrootwindow ) ; + + if ( mac_x != former_mac_x || mac_y != former_mac_y ) + { + { + Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; + InvalRect( &inval ) ; + } + UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; + { + Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; + InvalRect( &inval ) ; + } + } + if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) ) + { + } + else + { + UMASetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ; + } + } + + wxWindow::MacSuperChangedPosition() ; +} + +void wxControl::MacSuperEnabled( bool enabled ) +{ + if ( m_macControl ) + { + if ( UMAHasAppearance() ) + { + if ( !enabled ) + { + ::DeactivateControl( m_macControl ) ; + } + else + { + if ( m_macEnabled ) + ::ActivateControl( m_macControl ) ; + } + } + else + { + if ( !enabled ) + { + ::HiliteControl( m_macControl , 255 ) ; + } + else + { + if ( m_macEnabled ) + ::HiliteControl( m_macControl , 0 ) ; + } + } + } + wxWindow::MacSuperEnabled( enabled ) ; +} + +void wxControl::MacSuperShown( bool show ) +{ + if ( m_macControl ) + { + if ( !show ) + { + ::UMAHideControl( m_macControl ) ; + } + else + { + if ( m_macShown ) + ::UMAShowControl( m_macControl ) ; + } + } + + wxWindow::MacSuperShown( show ) ; +} + +void wxControl::DoSetSize(int x, int y, + int width, int height, + int sizeFlags ) +{ + if ( m_macControl == NULL ) + { + wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ; + return ; + } + + WindowRef rootwindow = GetMacRootWindow() ; + wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ; + UMASetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ; + + int former_x = m_x ; + int former_y = m_y ; + int former_w = m_width ; + int former_h = m_height ; + + int former_mac_x = (**m_macControl).contrlRect.left ; + int former_mac_y = (**m_macControl).contrlRect.top ; + + int currentX, currentY; + GetPosition(¤tX, ¤tY); + int currentW,currentH; + GetSize(¤tW, ¤tH); + + int actualWidth = width; + int actualHeight = height; + int actualX = x; + int actualY = y; + if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + actualX = currentX; + if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + actualY = currentY; + if (width == -1) + actualWidth = currentW ; + if (height == -1) + actualHeight = currentH ; + + if ( actualX == currentX && actualY == currentY && actualWidth == currentW && actualHeight == currentH) + return ; + + AdjustForParentClientOrigin(actualX, actualY, sizeFlags); + wxMacDrawingHelper focus( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ; + + int mac_x = actualX ; + int mac_y = actualY ; + GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ; + + if ( mac_x != former_mac_x || mac_y != former_mac_y ) + { + { + Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; + InvalRect( &inval ) ; + } + UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; + { + Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; + InvalRect( &inval ) ; + } + } + + if ( actualX != former_x || actualY != former_y ) + { + m_x = actualX ; + m_y = actualY ; + + MacRepositionScrollBars() ; + // To consider -> should the parameters be the effective or the virtual coordinates (AdjustForParent..) + wxMoveEvent event(wxPoint(m_x, m_y), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + if ( actualWidth != former_w || actualHeight != former_h ) + { + { + Rect inval = { mac_y , mac_x , mac_y + former_h , mac_x + former_w } ; + InvalRect( &inval ) ; + } + m_width = actualWidth ; + m_height = actualHeight ; + + UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; + { + Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; + InvalRect( &inval ) ; + } + + MacRepositionScrollBars() ; + wxSizeEvent event(wxSize(m_width, m_height), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) ) + { + } + else + { + UMASetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ; + } +} + +void wxControl::DoSetClientSize(int width, int height) +{ + DoSetSize( -1 , -1 , width , height ) ; +} + +bool wxControl::Show(bool show) +{ + if ( m_macControl == NULL ) + return wxWindow::Show( show ) ; + + if ( m_macShown == show ) + return TRUE ; + + if ( show ) + ::UMAShowControl( m_macControl ) ; + else + ::UMAHideControl( m_macControl ) ; + + return wxWindow::Show( show ) ; +} + +void wxControl::Enable(bool enable) +{ + if ( m_macControl == NULL ) + return wxWindow::Enable( enable ) ; + + if ( m_macEnabled == enable ) + return ; + + if ( UMAHasAppearance() ) + { + if ( enable ) + ::ActivateControl( m_macControl ) ; + else + ::DeactivateControl( m_macControl ) ; + } + else + { + if ( enable ) + ::HiliteControl( m_macControl , 0 ) ; + else + ::HiliteControl( m_macControl , 255 ) ; + } + + return wxWindow::Enable( enable ) ; +} + +void wxControl::Refresh(bool eraseBack, const wxRect *rect) +{ + if ( m_macControl ) + { + wxWindow::Refresh( eraseBack , rect ) ; + } + else + { + wxWindow::Refresh( eraseBack , rect ) ; + } +} + +void wxControl::OnPaint(wxPaintEvent& event) +{ + if ( m_macControl ) + { + WindowRef window = GetMacRootWindow() ; + if ( window ) + { + wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( win ) + { + wxMacDrawingHelper help( win ) ; + SetOrigin( 0 , 0 ) ; + + bool hasTabBehind = false ; + wxWindow* parent = GetParent() ; + while ( parent ) + { + if( parent->m_macWindowData ) + { + UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ; + break ; + } + + if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) + { + if ( ((wxControl*)parent)->m_macControl ) + SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ; + break ; + } + + parent = parent->GetParent() ; + } + + UMADrawControl( m_macControl ) ; + UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ; + } + } + } + else + { + wxWindow::OnPaint( event ) ; + } +} + +void wxControl::OnKeyDown( wxKeyEvent &event ) +{ + if ( m_macControl == NULL ) + return ; + + EventRecord *ev = wxTheApp->MacGetCurrentEvent() ; + short keycode ; + short keychar ; + keychar = short(ev->message & charCodeMask); + keycode = short(ev->message & keyCodeMask) >> 8 ; + + UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ; +} + +void wxControl::OnMouseEvent( wxMouseEvent &event ) +{ + if ( m_macControl == NULL ) + { + event.Skip() ; + return ; + } + + if (event.GetEventType() == wxEVT_LEFT_DOWN ) + { + + int x = event.m_x ; + int y = event.m_y ; + + MacClientToRootWindow( &x , &y ) ; + + ControlHandle control ; + Point localwhere ; + GrafPtr port ; + SInt16 controlpart ; + WindowRef window = GetMacRootWindow() ; + + 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 ; + + controlpart = FindControl( localwhere , window , &control ) ; + { + if ( AcceptsFocus() && FindFocus() != this ) + { + SetFocus() ; + } + if ( control && UMAIsControlActive( control ) ) + { + { + if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() ) + controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ; + else + controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; + wxTheApp->s_lastMouseDown = 0 ; + if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) ) + && (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice + { + MacHandleControlClick( control , controlpart ) ; + } + } + } + } + } +} + +bool wxControl::MacCanFocus() const +{ + { if ( m_macControl == NULL ) + return true ; + else + return false ; + } +} + +void wxControl::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; +} + diff --git a/src/mac/carbon/corersrc.r b/src/mac/carbon/corersrc.r index a37b064b21..528e794811 100644 --- a/src/mac/carbon/corersrc.r +++ b/src/mac/carbon/corersrc.r @@ -1,8 +1,50 @@ #include -resource 'ALRT' (128, purgeable) { +#if UNIVERSAL_INTERFACES_VERSION > 0x320 + #include +#endif + +#define kMacOKAlertResourceID 128 +#define kMacYesNoAlertResourceID 129 +#define kMacYesNoCancelAlertResourceID 130 +#define kMacNoYesAlertResourceID 131 +#define kMacNoYesCancelAlertResourceID 132 + +resource 'ALRT' (kMacOKAlertResourceID, purgeable) { + {70, 50, 198, 470}, + kMacOKAlertResourceID, + { /* array: 4 elements */ + /* [1] */ + OK, visible, sound1, + /* [2] */ + OK, visible, sound1, + /* [3] */ + OK, visible, sound1, + /* [4] */ + OK, visible, sound1 + }, + noAutoCenter +}; + +resource 'ALRT' (kMacYesNoAlertResourceID, purgeable) { + {70, 50, 198, 470}, + kMacYesNoAlertResourceID, + { /* array: 4 elements */ + /* [1] */ + OK, visible, sound1, + /* [2] */ + OK, visible, sound1, + /* [3] */ + OK, visible, sound1, + /* [4] */ + OK, visible, sound1 + }, + noAutoCenter +}; + +resource 'ALRT' (kMacYesNoAlertResourceID + 10, purgeable) { {70, 50, 198, 470}, - 128, + kMacYesNoAlertResourceID + 10, { /* array: 4 elements */ /* [1] */ OK, visible, sound1, @@ -16,9 +58,9 @@ resource 'ALRT' (128, purgeable) { noAutoCenter }; -resource 'ALRT' (129, purgeable) { +resource 'ALRT' (kMacYesNoAlertResourceID + 20, purgeable) { {70, 50, 198, 470}, - 129, + kMacYesNoAlertResourceID + 20, { /* array: 4 elements */ /* [1] */ OK, visible, sound1, @@ -32,7 +74,7 @@ resource 'ALRT' (129, purgeable) { noAutoCenter }; -resource 'ALRT' (130, purgeable) { +resource 'ALRT' (kMacYesNoCancelAlertResourceID, purgeable) { {70, 50, 198, 470}, 130, { /* array: 4 elements */ @@ -48,7 +90,7 @@ resource 'ALRT' (130, purgeable) { noAutoCenter }; -resource 'ALRT' (131, purgeable) { +resource 'ALRT' (kMacNoYesAlertResourceID, purgeable) { {70, 50, 198, 470}, 131, { /* array: 4 elements */ @@ -64,7 +106,7 @@ resource 'ALRT' (131, purgeable) { noAutoCenter }; -resource 'ALRT' (132, purgeable) { +resource 'ALRT' (kMacNoYesCancelAlertResourceID, purgeable) { {70, 50, 198, 470}, 132, { /* array: 4 elements */ @@ -80,7 +122,7 @@ resource 'ALRT' (132, purgeable) { noAutoCenter }; -resource 'DITL' (128, purgeable) { +resource 'DITL' (kMacOKAlertResourceID, purgeable) { { /* array DITLarray: 3 elements */ /* [1] */ {100, 340, 120, 408}, @@ -103,13 +145,71 @@ resource 'DITL' (128, purgeable) { } }; -resource 'DITL' (129, purgeable) { +resource 'DITL' (kMacYesNoAlertResourceID, purgeable) { { /* array DITLarray: 4 elements */ /* [1] */ {100, 340, 120, 408}, Button { enabled, - "Yes" + "Ja" + }, + /* [2] */ + {100, 260, 120, 324}, + Button { + enabled, + "Nein" + }, + /* [3] */ + {38, 64, 88, 408}, + StaticText { + disabled, + "^1" + }, + /* [4] */ + {10, 64, 30, 412}, + StaticText { + disabled, + "^0" + } + } +}; + +resource 'DITL' (kMacYesNoAlertResourceID + 10, purgeable) { + { /* array DITLarray: 4 elements */ + /* [1] */ + {100, 340, 120, 408}, + Button { + enabled, + "Oui" + }, + /* [2] */ + {100, 260, 120, 324}, + Button { + enabled, + "Non" + }, + /* [3] */ + {38, 64, 88, 408}, + StaticText { + disabled, + "^1" + }, + /* [4] */ + {10, 64, 30, 412}, + StaticText { + disabled, + "^0" + } + } +}; + +resource 'DITL' (kMacYesNoAlertResourceID + 20, purgeable) { + { /* array DITLarray: 4 elements */ + /* [1] */ + {100, 340, 120, 408}, + Button { + enabled, + "Si" }, /* [2] */ {100, 260, 120, 324}, @@ -132,7 +232,7 @@ resource 'DITL' (129, purgeable) { } }; -resource 'DITL' (130, purgeable) { +resource 'DITL' (kMacYesNoCancelAlertResourceID, purgeable) { { /* array DITLarray: 5 elements */ /* [1] */ {100, 340, 120, 408}, @@ -167,7 +267,7 @@ resource 'DITL' (130, purgeable) { } }; -resource 'DITL' (131, purgeable) { +resource 'DITL' (kMacNoYesAlertResourceID, purgeable) { { /* array DITLarray: 4 elements */ /* [1] */ {100, 340, 120, 408}, @@ -196,7 +296,7 @@ resource 'DITL' (131, purgeable) { } }; -resource 'DITL' (132, purgeable) { +resource 'DITL' (kMacNoYesCancelAlertResourceID, purgeable) { { /* array DITLarray: 5 elements */ /* [1] */ {100, 340, 120, 408}, @@ -278,54 +378,17 @@ data 'DLGX' (132) { $"0000 0006 0000 0000 0000 0000 0000" /* .............. */ }; -data 'ics#' (200, "¥ New File") { - $"0000 3FE0 2C70 3458 2C78 3408 2C08 3408" /* ..?à,p4X,x4.,.4. */ - $"2C08 3408 2C08 3408 2C0E 340F 3FFE 0000" /* ,.4.,.4.,.4.?þ.. */ - $"0000 3FE0 3FF0 3FF8 3FF8 3FF8 3FF8 3FF8" /* ..?à?ð?ø?ø?ø?ø?ø */ - $"3FF8 3FF8 3FF8 3FF8 3FFE 3FFF 3FFE 0000" /* ?ø?ø?ø?ø?þ?ÿ?þ.. */ -}; - -data 'ics4' (200, "¥ New File") { - $"0000 0000 0000 0000 00FF FFFF FFF0 0000" /* .........ÿÿÿÿð.. */ - $"00F1 FFED EFFF 0000 00FF 1FDE DFCF F000" /* .ñÿíïÿ...ÿ.ÞßÏð. */ - $"00F1 FFED EFFF F000 00FF 1FDE DEEE F000" /* .ñÿíïÿð..ÿ.ÞÞîð. */ - $"00F1 FFED EDED F000 00FF 1FDE DEDE F000" /* .ñÿíííð..ÿ.ÞÞÞð. */ - $"00F1 FFED EDED F000 00FF 1FDE DEDE F000" /* .ñÿíííð..ÿ.ÞÞÞð. */ - $"00F1 FFED EDED F000 00FF 1FDE DEDE F000" /* .ñÿíííð..ÿ.ÞÞÞð. */ - $"00F1 FFED EDED FEE0 00FF 1FDE DEDE FEEE" /* .ñÿíííþà.ÿ.ÞÞÞþî */ - $"00FF FFFF FFFF FEE0 0000 0000 0000 0000" /* .ÿÿÿÿÿþà........ */ -}; - -data 'ics8' (200, "¥ New File") { - $"0000 0000 0000 0000 0000 0000 0000 0000" /* ................ */ - $"0000 FFFF FFFF FFFF FFFF FF00 0000 0000" /* ..ÿÿÿÿÿÿÿÿÿ..... */ - $"0000 FF05 FFFF FB7F FBFF FFFF 0000 0000" /* ..ÿ.ÿÿû.ûÿÿÿ.... */ - $"0000 FFFF 0BFF 7FFB 7FFF F6FF FF00 0000" /* ..ÿÿ.ÿ.û.ÿöÿÿ... */ - $"0000 FF05 FFFF FB7F FBFF FFFF FF00 0000" /* ..ÿ.ÿÿû.ûÿÿÿÿ... */ - $"0000 FFFF 0BFF 7FFB 7FFB FBFB FF00 0000" /* ..ÿÿ.ÿ.û.ûûûÿ... */ - $"0000 FF05 FFFF FB7F FB7F FB7F FF00 0000" /* ..ÿ.ÿÿû.û.û.ÿ... */ - $"0000 FFFF 0BFF 7FFB 7FFB 7FFB FF00 0000" /* ..ÿÿ.ÿ.û.û.ûÿ... */ - $"0000 FF05 FFFF FB7F FB7F FB7F FF00 0000" /* ..ÿ.ÿÿû.û.û.ÿ... */ - $"0000 FFFF 0BFF 7FFB 7FFB 7FFB FF00 0000" /* ..ÿÿ.ÿ.û.û.ûÿ... */ - $"0000 FF05 FFFF FB7F FB7F FB7F FF00 0000" /* ..ÿ.ÿÿû.û.û.ÿ... */ - $"0000 FFFF 0BFF 7FFB 7FFB 7FFB FF00 0000" /* ..ÿÿ.ÿ.û.û.ûÿ... */ - $"0000 FF05 FFFF FB7F FB7F FB7F FFFC FC00" /* ..ÿ.ÿÿû.û.û.ÿüü. */ - $"0000 FFFF 0BFF 7FFB 7FFB 7FFB FFFC FCFC" /* ..ÿÿ.ÿ.û.û.ûÿüüü */ - $"0000 FFFF FFFF FFFF FFFF FFFF FFFC FC00" /* ..ÿÿÿÿÿÿÿÿÿÿÿüü. */ - $"0000 0000 0000 0000 0000 0000 0000 0000" /* ................ */ -}; - resource 'ldes' ( 128 ) { versionZero { 0 , - 1 , + 0 , 0 , 0 , hasVertScroll , noHorizScroll , - 0 , + 128 , noGrowSpace , } } ; @@ -536,3 +599,4 @@ resource 'STR#' (251) { } }; +// end of get file \ No newline at end of file diff --git a/src/mac/carbon/cursor.cpp b/src/mac/carbon/cursor.cpp index 4333364c93..bcbe30008b 100644 --- a/src/mac/carbon/cursor.cpp +++ b/src/mac/carbon/cursor.cpp @@ -20,18 +20,24 @@ IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) #endif +const short kwxCursorHandId = 9 ; +const short kwxCursorSizeWEId = 10 ; +const short kwxCursorSizeNSId = 11 ; +Cursor* MacArrowCursorPtr = &qd.arrow ; +CursHandle MacArrowCursor = &MacArrowCursorPtr ; +CursHandle gMacCurrentCursor = NULL ; + wxCursorRefData::wxCursorRefData() { - m_width = 32; m_height = 32; - -/* TODO - m_hCursor = 0 ; -*/ + m_width = 32; + m_height = 32; + m_hCursor = NULL ; } wxCursorRefData::~wxCursorRefData() { - // TODO: destroy cursor + if ( m_hCursor && ( m_hCursor != MacArrowCursor ) ) + ::DisposeHandle( (Handle) m_hCursor ) ; } // Cursors @@ -56,122 +62,133 @@ wxCursor::wxCursor(int cursor_type) { m_refData = new wxCursorRefData; -/* TODO switch (cursor_type) { case wxCURSOR_WAIT: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT); + M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); break; case wxCURSOR_IBEAM: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM); + M_CURSORDATA->m_hCursor = ::GetCursor(iBeamCursor); break; case wxCURSOR_CROSS: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS); + M_CURSORDATA->m_hCursor = ::GetCursor(crossCursor); break; case wxCURSOR_SIZENWSE: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENWSE); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZENESW: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENESW); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZEWE: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZEWE); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZENS: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENS); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNSId); break; case wxCURSOR_CHAR: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_HAND: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_HAND"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_BULLSEYE: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BULLSEYE"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_PENCIL: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PENCIL"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_MAGNIFIER: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_MAGNIFIER"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_NO_ENTRY: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_NO_ENTRY"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_LEFT_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_RIGHT_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_MIDDLE_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_SIZING: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_SIZING"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_WATCH: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_WATCH"); + M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); break; } case wxCURSOR_SPRAYCAN: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_ROLLER"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_PAINT_BRUSH: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PBRUSH"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_POINT_LEFT: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PLEFT"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_POINT_RIGHT: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PRIGHT"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_QUESTION_ARROW: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_QARROW"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_BLANK: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } default: case wxCURSOR_ARROW: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; - } -*/ + } +} +void wxCursor::MacInstall() const +{ + if ( m_refData && M_CURSORDATA->m_hCursor ) + { + ::SetCursor( *M_CURSORDATA->m_hCursor ) ; + gMacCurrentCursor = M_CURSORDATA->m_hCursor ; + } + else + { + ::SetCursor( *MacArrowCursor ) ; + gMacCurrentCursor = NULL ; + } } wxCursor::~wxCursor() @@ -181,7 +198,7 @@ wxCursor::~wxCursor() // Global cursor setting void wxSetCursor(const wxCursor& cursor) { - // TODO (optional on platforms with no global cursor) + cursor.MacInstall() ; } diff --git a/src/mac/carbon/data.cpp b/src/mac/carbon/data.cpp index 138289a5bf..297686b9d1 100644 --- a/src/mac/carbon/data.cpp +++ b/src/mac/carbon/data.cpp @@ -25,7 +25,7 @@ char *wxBuffer = NULL; // Windows List -wxList wxTopLevelWindows; +wxWindowList wxTopLevelWindows; // List of windows pending deletion wxList wxPendingDelete; diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 2c1c613595..e021274157 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -30,6 +30,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) #define mm2pt 2.83464566929 #define pt2mm 0.352777777778 +long wxDC::m_macCurrentPortId = 1 ; + //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- @@ -83,14 +85,136 @@ wxDC::wxDC(void) m_backgroundBrush = *wxWHITE_BRUSH; // m_palette = wxAPP_COLOURMAP; + m_macPort = NULL ; + m_ok = FALSE ; + + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + + m_macPortId = 0 ; + m_macLocalOrigin.h = m_macLocalOrigin.v = 0 ; + m_macClipRect.left = -32000 ; + m_macClipRect.top = -32000 ; + m_macClipRect.right = 32000 ; + m_macClipRect.bottom = 32000 ; + ::GetPort( &m_macOrigPort ) ; }; wxDC::~wxDC(void) { + if ( m_macPort ) + { + ::SetOrigin( 0 , 0 ) ; + ::ClipRect( &m_macPort->portRect ) ; + ::PenNormal() ; + ::SetPort( m_macOrigPort ) ; + } + ++m_macCurrentPortId ; }; -void wxDC::DrawIcon( const wxIcon &WXUNUSED(icon), long WXUNUSED(x), long WXUNUSED(y), bool WXUNUSED(useMask) ) +void wxDC::MacSetupPort() const +{ + m_macPortId = ++m_macCurrentPortId ; + ::SetPort(m_macPort); + ::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v); + ::ClipRect(&m_macClipRect); + + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; +} + +void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + long xx1 = XLOG2DEV(x); + long yy1 = YLOG2DEV(y); + + { + wxBitmapRefData * bmap = (wxBitmapRefData*) ( bmp.GetRefData()) ; + + if ( bmap ) + { + if ( bmap->m_bitmapType == kMacBitmapTypePict ) + { + Rect bitmaprect = { 0 , 0 , bmap->m_height , bmap->m_width } ; + ::OffsetRect( &bitmaprect , xx1 , yy1 ) ; + ::DrawPicture( bmap->m_hPict , &bitmaprect ) ; + } + else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) + { + if ( bmap->m_hBitmap ) + { + GWorldPtr bmapworld = bmap->m_hBitmap ; + PixMapHandle bmappixels ; + RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; + RGBColor black = { 0,0,0} ; + RGBForeColor( &black ) ; + RGBBackColor( &white ) ; + // RGBForeColor( &m_textForegroundColour.GetPixel() ) ; + // RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; + + bmappixels = GetGWorldPixMap( bmapworld ) ; + if ( LockPixels(bmappixels) ) + { + Rect source , dest ; + source.top = 0 ; + source.left = 0 ; + source.right = bmap->m_width ; + source.bottom = bmap->m_height ; + dest.top = YLOG2DEV(y) ; + dest.left = XLOG2DEV(x) ; + dest.bottom = YLOG2DEV(y + bmap->m_height ) ; + dest.right = XLOG2DEV(x + bmap->m_width ) ; + // ::ClipRect(&m_macClipRect); + CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits , + &source, &dest, srcCopy, NULL ) ; + /* + if ( m_clipping ) + { + long x1 = XLOG2DEV(m_clipX1); + long y1 = YLOG2DEV(m_clipY1); + long x2 = XLOG2DEV(m_clipX2); + long y2 = YLOG2DEV(m_clipY2); + + Rect clip = { y1 , x1 , y2 , x2 } ; + ::ClipRect(&clip); + } + */ + UnlockPixels( bmappixels ) ; + } + m_macPenInstalled = false ; + m_macBrushInstalled = false ; + m_macFontInstalled = false ; + } + } + } + } +} + +void wxDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask ) { + if (!Ok()) + return; + MacVerifySetup() ; + + long xx1 = XLOG2DEV(x); + long yy1 = YLOG2DEV(y); + + { + wxIconRefData * iconref = (wxIconRefData*) ( icon.GetRefData()) ; + + if ( iconref && iconref->m_ok && iconref->m_hIcon ) + { + Rect bitmaprect = { 0 , 0 , iconref->m_height , iconref->m_width } ; + OffsetRect( &bitmaprect , xx1 , yy1 ) ; + PlotCIconHandle( &bitmaprect , atNone , ttNone , iconref->m_hIcon ) ; + } + } }; void wxDC::DrawPoint( wxPoint& point ) @@ -155,16 +279,41 @@ void wxDC::DrawSpline( int n, wxPoint points[] ) void wxDC::SetClippingRegion( long x, long y, long width, long height ) { - m_clipping = TRUE; - m_clipX1 = x; - m_clipY1 = y; - m_clipX2 = x + width; - m_clipY2 = y + height; + MacVerifySetup() ; + if( m_clipping ) + { + m_clipX1 = wxMax( m_clipX1 , x ) ; + m_clipY1 = wxMax( m_clipY1 ,y ); + m_clipX2 = wxMin( m_clipX2, (x + width)); + m_clipY2 = wxMin( m_clipY2,(y + height)); + + } + else + { + m_clipping = TRUE; + m_clipX1 = x; + m_clipY1 = y; + m_clipX2 = x + width; + m_clipY2 = y + height; + } + + long x1 = XLOG2DEV(m_clipX1); + long y1 = YLOG2DEV(m_clipY1); + long x2 = XLOG2DEV(m_clipX2); + long y2 = XLOG2DEV(m_clipY2); + + Rect clip = { y1 , x1 , y2 , x2 } ; + + ::ClipRect( &clip ) ; + }; void wxDC::DestroyClippingRegion(void) { + MacVerifySetup() ; m_clipping = FALSE; +// Rect clip = { -32000 , -32000 , 32000 , 32000 } ; + ::ClipRect(&m_macClipRect); }; void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const @@ -199,12 +348,14 @@ void wxDC::SetTextForeground( const wxColour &col ) { if (!Ok()) return; m_textForegroundColour = col; + m_macFontInstalled = false ; }; void wxDC::SetTextBackground( const wxColour &col ) { if (!Ok()) return; m_textBackgroundColour = col; + m_macFontInstalled = false ; }; void wxDC::SetMapMode( int mode ) @@ -383,3 +534,1044 @@ void wxDC::ComputeScaleAndOrigin(void) } }; +void wxDC::SetPalette( const wxPalette& palette ) +{ +} + +void wxDC::SetBackgroundMode( int mode ) +{ + m_backgroundMode = mode ; +} + +void wxDC::SetFont( const wxFont &font ) +{ + if (!Ok()) + return; + + MacVerifySetup() ; + + m_font = font; + m_macFontInstalled = false ; +} + +void wxDC::SetPen( const wxPen &pen ) +{ + if (!Ok() ) + return; + + MacVerifySetup() ; + + if ( m_pen == pen ) + return ; + + m_pen = pen; +/* + if (!m_pen.Ok()) + return; +*/ + m_macPenInstalled = false ; +} + +void wxDC::SetBrush( const wxBrush &brush ) +{ + if (!Ok() ) + return; + MacVerifySetup() ; + + if (m_brush == brush) + return; + + m_brush = brush; + m_macBrushInstalled = false ; +} + +void wxDC::SetBackground( const wxBrush &brush ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + 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 ; +} + +void wxDC::FloodFill( long x1, long y1, const wxColour& col, int style ) +{ +} + +bool wxDC::GetPixel( long x1, long y1, wxColour *col ) const +{ + return true ; +} + +void wxDC::DrawLine( long x1, long y1, long x2, long y2 ) +{ + if (!Ok()) + return; + + MacVerifySetup() ; + + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + int offset = (m_pen.GetWidth() - 1) / 2 ; + long xx1 = XLOG2DEV(x1); + long yy1 = YLOG2DEV(y1); + long xx2 = XLOG2DEV(x2); + long yy2 = YLOG2DEV(y2); + + ::MoveTo(xx1 - offset ,yy1 - offset); + ::LineTo(xx2 - offset , yy2 - offset ); + }; +} + +void wxDC::CrossHair( long x, long y ) +{ +} + +void wxDC::DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) +{ +} + +void wxDC::DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) +{ +} + +void wxDC::DrawPoint( long x, long y ) +{ + if (!Ok()) + return; + + MacVerifySetup() ; + + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + long xx1 = XLOG2DEV(x); + long yy1 = YLOG2DEV(y); + + ::MoveTo(xx1,yy1); + ::LineTo(xx1+1, yy1+1); + }; +} + +void wxDC::DrawLines( int n, wxPoint points[], long xoffset , long yoffset ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if (m_pen.GetStyle() == wxTRANSPARENT) + return; + + MacInstallPen() ; + + int offset = (m_pen.GetWidth() - 1 ) / 2 ; + long x1, x2 , y1 , y2 ; + x1 = XLOG2DEV(points[0].x + xoffset); + y1 = YLOG2DEV(points[0].y + yoffset); + ::MoveTo(x1 - offset ,y1 - offset ); + + for (int i = 0; i < n-1; i++) + { + long x2 = XLOG2DEV(points[i+1].x + xoffset); + long y2 = YLOG2DEV(points[i+1].y + yoffset); + ::LineTo(x2 - offset , y2 - offset ); + } +} + +void wxDC::DrawPolygon( int n, wxPoint points[], long xoffset , long yoffset , + int fillStyle ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + PolyHandle polygon = OpenPoly() ; + long x1, x2 , y1 , y2 ; + x1 = XLOG2DEV(points[0].x + xoffset); + y1 = YLOG2DEV(points[0].y + yoffset); + ::MoveTo(x1,y1); + + for (int i = 0; i < n-1; i++) + { + long x2 = XLOG2DEV(points[i+1].x + xoffset); + long y2 = YLOG2DEV(points[i+1].y + yoffset); + ::LineTo(x2, y2); + } + + ClosePoly() ; + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::PaintPoly( polygon ) ; + }; + + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FramePoly( polygon ) ; + }; + KillPoly( polygon ) ; +} + +void wxDC::DrawRectangle( long x, long y, long width, long height ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + long xx = XLOG2DEV(x); + long yy = YLOG2DEV(y); + long ww = m_signX * XLOG2DEVREL(width); + long 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::DrawRoundedRectangle( long x, long y, long width, long height, double radius ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if (radius < 0.0) + radius = - radius * ((width < height) ? width : height); + + long xx = XLOG2DEV(x); + long yy = YLOG2DEV(y); + long ww = m_signX * XLOG2DEVREL(width); + long 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 , radius * 2 , radius * 2 ) ; + }; + + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FrameRoundRect( &rect , radius * 2 , radius * 2 ) ; + }; +} + +void wxDC::DrawEllipse( long x, long y, long width, long height ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + long xx = XLOG2DEV(x); + long yy = YLOG2DEV(y); + long ww = m_signX * XLOG2DEVREL(width); + long 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 ) ; + }; +} + +// ----------------------------------- spline code ---------------------------------------- + +static void wx_quadratic_spline(double a1, double b1, double a2, double b2, + double a3, double b3, double a4, double b4); +static void wx_clear_stack(void); +static int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3, + double *y3, double *x4, double *y4); +static void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, + double x4, double y4); +static bool wx_spline_add_point(double x, double y); +static void wx_spline_draw_point_array(wxDC *dc); + +static wxList wx_spline_point_list; + +#define half(z1, z2) ((z1+z2)/2.0) +#define THRESHOLD 5 + +/* iterative version */ + +static void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4, + double b4) +{ + register double xmid, ymid; + double x1, y1, x2, y2, x3, y3, x4, y4; + + wx_clear_stack(); + wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4); + + while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) { + xmid = (double)half(x2, x3); + ymid = (double)half(y2, y3); + if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD && + fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) { + wx_spline_add_point( x1, y1 ); + wx_spline_add_point( xmid, ymid ); + } else { + wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3), + (double)half(x3, x4), (double)half(y3, y4), x4, y4); + wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2), + (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid); + } + } +} + +/* utilities used by spline drawing routines */ + +typedef struct wx_spline_stack_struct { + double x1, y1, x2, y2, x3, y3, x4, y4; +} Stack; + +#define SPLINE_STACK_DEPTH 20 +static Stack wx_spline_stack[SPLINE_STACK_DEPTH]; +static Stack *wx_stack_top; +static int wx_stack_count; + +static void wx_clear_stack(void) +{ + wx_stack_top = wx_spline_stack; + wx_stack_count = 0; +} + +static void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) +{ + wx_stack_top->x1 = x1; + wx_stack_top->y1 = y1; + wx_stack_top->x2 = x2; + wx_stack_top->y2 = y2; + wx_stack_top->x3 = x3; + wx_stack_top->y3 = y3; + wx_stack_top->x4 = x4; + wx_stack_top->y4 = y4; + wx_stack_top++; + wx_stack_count++; +} + +static int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, + double *x3, double *y3, double *x4, double *y4) +{ + if (wx_stack_count == 0) + return (0); + wx_stack_top--; + wx_stack_count--; + *x1 = wx_stack_top->x1; + *y1 = wx_stack_top->y1; + *x2 = wx_stack_top->x2; + *y2 = wx_stack_top->y2; + *x3 = wx_stack_top->x3; + *y3 = wx_stack_top->y3; + *x4 = wx_stack_top->x4; + *y4 = wx_stack_top->y4; + return (1); +} + +static bool wx_spline_add_point(double x, double y) +{ + wxPoint *point = new wxPoint ; + point->x = (int) x; + point->y = (int) y; + wx_spline_point_list.Append((wxObject*)point); + return TRUE; +} + +static void wx_spline_draw_point_array(wxDC *dc) +{ + dc->DrawLines(&wx_spline_point_list, 0, 0 ); + wxNode *node = wx_spline_point_list.First(); + while (node) + { + wxPoint *point = (wxPoint *)node->Data(); + delete point; + delete node; + node = wx_spline_point_list.First(); + } +} + +void wxDC::DrawSpline( wxList *points ) +{ + wxPoint *p; + double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; + double x1, y1, x2, y2; + + wxNode *node = points->First(); + p = (wxPoint *)node->Data(); + + x1 = p->x; + y1 = p->y; + + node = node->Next(); + p = (wxPoint *)node->Data(); + + x2 = p->x; + y2 = p->y; + cx1 = (double)((x1 + x2) / 2); + cy1 = (double)((y1 + y2) / 2); + cx2 = (double)((cx1 + x2) / 2); + cy2 = (double)((cy1 + y2) / 2); + + wx_spline_add_point(x1, y1); + + while ((node = node->Next()) != NULL) + { + p = (wxPoint *)node->Data(); + x1 = x2; + y1 = y2; + x2 = p->x; + y2 = p->y; + cx4 = (double)(x1 + x2) / 2; + cy4 = (double)(y1 + y2) / 2; + cx3 = (double)(x1 + cx4) / 2; + cy3 = (double)(y1 + cy4) / 2; + + wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4); + + cx1 = cx4; + cy1 = cy4; + cx2 = (double)(cx1 + x2) / 2; + cy2 = (double)(cy1 + y2) / 2; + } + + wx_spline_add_point( cx1, cy1 ); + wx_spline_add_point( x2, y2 ); + + wx_spline_draw_point_array( this ); +} + + + +bool wxDC::CanDrawBitmap(void) const +{ + return true ; +} + + +bool wxDC::Blit( long xdest, long ydest, long width, long height, + wxDC *source, long xsrc, long ysrc, int logical_func , bool useMask ) +{ + if (!Ok()) return FALSE; + MacVerifySetup() ; + + CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; + PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; + RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; + RGBColor black = { 0,0,0} ; +// RGBForeColor( &black ) ; +// RGBBackColor( &white ) ; + RGBForeColor( &m_textForegroundColour.GetPixel() ) ; + RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; + + if ( LockPixels(bmappixels) ) + { + Rect srcrect , dstrect ; + srcrect.top = source->YLOG2DEV(ysrc) ; + srcrect.left = source->XLOG2DEV(xsrc) ; + srcrect.right = source->XLOG2DEV(xsrc + width ) ; + srcrect.bottom = source->YLOG2DEV(ysrc + height) ; + dstrect.top = YLOG2DEV(ydest) ; + dstrect.left = XLOG2DEV(xdest) ; + dstrect.bottom = YLOG2DEV(ydest + height ) ; + dstrect.right = XLOG2DEV(xdest + width ) ; +// ::ClipRect(&m_macClipRect); + CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits , + &srcrect, &dstrect, srcCopy, NULL ) ; +/* + if ( m_clipping ) + { + long x1 = XLOG2DEV(m_clipX1); + long y1 = YLOG2DEV(m_clipY1); + long x2 = XLOG2DEV(m_clipX2); + long y2 = YLOG2DEV(m_clipY2); + + Rect clip = { y1 , x1 , y2 , x2 } ; + ::ClipRect(&clip); + } +*/ + UnlockPixels( bmappixels ) ; + } + + m_macPenInstalled = false ; + m_macBrushInstalled = false ; + m_macFontInstalled = false ; + + return TRUE; +} + +void wxDC::DrawText( const wxString &string, long x, long y, bool use16) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + long xx = XLOG2DEV(x); + long yy = YLOG2DEV(y); + +// if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallFont() ; + /* + Rect clip = { -32000 , -32000 , 32000 , 32000 } ; + + ::ClipRect( &clip ) ; + */ + + FontInfo fi ; + ::GetFontInfo( &fi ) ; + + 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( string ) ; + text = macText ; + length = macText.Length() ; + } + else + { + text = string ; + length = string.Length() ; + } + + int laststop = 0 ; + int i = 0 ; + int line = 0 ; + + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { + ::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 ) ; + ::TextMode( srcOr ) ; + } +} + +bool wxDC::CanGetTextExtent(void) const +{ + if ( !Ok() ) + return false ; + + return true ; +} + +void wxDC::GetTextExtent( const wxString &string, long *width, long *height, + long *descent, long *externalLeading , + wxFont *theFont , bool use16 ) const +{ + if (!Ok()) + return; + + MacVerifySetup() ; + + wxFont formerFont = m_font ; + + if ( theFont ) + { + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + + if ( font ) + { + long yy1 = YLOG2DEV(0); + long yy2 = YLOG2DEV(font->m_macFontSize); + + ::TextFont( font->m_macFontNum ) ; + ::TextSize( abs( yy2-yy1) ) ; + ::TextFace( font->m_macFontStyle ) ; + } + } + else + { + MacInstallFont() ; + } + + FontInfo fi ; + ::GetFontInfo( &fi ) ; + + *height = fi.descent + fi.ascent ; + *descent = fi.descent ; + *externalLeading = 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 ; + *width = 0 ; + + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { + *height += fi.descent + fi.ascent + fi.leading; + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( curwidth > *width ) + *width = curwidth ; + laststop = i+1 ; + } + i++ ; + } + + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( curwidth > *width ) + *width = curwidth ; + + if ( theFont ) + { + m_macFontInstalled = false ; + } +} + +long wxDC::GetCharWidth(void) +{ + if (!Ok()) + return 1; + + MacVerifySetup() ; + + MacInstallFont() ; + + FontInfo fi ; + ::GetFontInfo( &fi ) ; + + return (fi.descent + fi.ascent) / 2 ; +} + +long wxDC::GetCharHeight(void) +{ + if (!Ok()) + return 1; + + MacVerifySetup() ; + + MacInstallFont() ; + + FontInfo fi ; + ::GetFontInfo( &fi ) ; + + return fi.descent + fi.ascent ; +} + +void wxDC::Clear(void) +{ + if (!Ok()) + return; + MacVerifySetup() ; + Rect rect = { -32767 , -32767 , 32767 , 32767 } ; + + if (m_backgroundBrush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::EraseRect( &rect ) ; + }; +} + +void wxDC::MacInstallFont() const +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if ( m_macFontInstalled ) + return ; + + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( m_scaleY * font->m_macFontSize ) ; + ::TextFace( font->m_macFontStyle ) ; + + m_macFontInstalled = true ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + + ::RGBForeColor(&m_textForegroundColour.GetPixel() ); + ::RGBBackColor(&m_textBackgroundColour.GetPixel() ); + } + else + { + short fontnum ; + + GetFNum( "\pGeneva" , &fontnum ) ; + ::TextFont( fontnum ) ; + ::TextSize( m_scaleY * 10 ) ; + ::TextFace( 0 ) ; + + // todo reset after spacing changes - or store the current spacing somewhere + + m_macFontInstalled = true ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + ::RGBForeColor( &(m_textForegroundColour.GetPixel()) ); + ::RGBBackColor(&m_textBackgroundColour.GetPixel() ); + } + + + short mode = patCopy ; + + // todo : + + switch( m_logicalFunction ) + { + case wxCOPY: // src + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + ::PenPat(&qd.black); + 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 ) ; +} + +static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern) +{ + int thePatListID = sysPatListID; + int theIndex; + switch(hatchStyle) + { + case wxBDIAGONAL_HATCH: + theIndex = 34; // WCH: this is not good + break; + case wxFDIAGONAL_HATCH: + theIndex = 26; + break; + case wxCROSS_HATCH: + theIndex = 5; + break; + case wxHORIZONTAL_HATCH: + theIndex = 25; + break; + case wxVERTICAL_HATCH: + theIndex = 6; + break; + case wxCROSSDIAG_HATCH: + theIndex = 4; // WCH: this is not good + break; + default: + theIndex = 1; // solid pattern + break; + } + GetIndPattern( pattern, thePatListID, theIndex); +} + +void wxDC::MacInstallPen() const +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if ( m_macPenInstalled ) + return ; + + ::RGBForeColor(&m_pen.GetColour().GetPixel() ); + ::RGBBackColor(&m_backgroundBrush.GetColour().GetPixel() ); + + ::PenNormal() ; + int penWidth = m_pen.GetWidth(); + ::PenSize(penWidth, penWidth); + + int penStyle = m_pen.GetStyle(); + + if (penStyle == wxSOLID) + ::PenPat(&qd.black); + else if (IS_HATCH(penStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(penStyle, &pat); + ::PenPat(&pat); + } + else + { + ::PenPat(&qd.black); + } + + short mode = patCopy ; + + // todo : + + switch( m_logicalFunction ) + { + case wxCOPY: // src + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + ::PenPat(&qd.black); + 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::MacInstallBrush() const +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if ( m_macBrushInstalled ) + return ; + + // foreground + + ::RGBForeColor(&m_brush.GetColour().GetPixel() ); + ::RGBBackColor(&m_backgroundBrush.GetColour().GetPixel() ); + + int brushStyle = m_brush.GetStyle(); + if (brushStyle == wxSOLID) + ::PenPat(&qd.black); + else if (IS_HATCH(brushStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(brushStyle, &pat); + ::PenPat(&pat); + } + else + { + ::PenPat(&qd.black); + } + + + // background + + brushStyle = m_backgroundBrush.GetStyle(); + if (brushStyle == wxSOLID) + ::BackPat(&qd.white); + else if (IS_HATCH(brushStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(brushStyle, &pat); + ::BackPat(&pat); + } + else + { + ::BackPat(&qd.white); + } + + short mode = patCopy ; + + // todo : + + switch( m_logicalFunction ) + { + case wxCOPY: // src + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + ::PenPat(&qd.black); + 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 ; +} + + diff --git a/src/mac/carbon/dcclient.cpp b/src/mac/carbon/dcclient.cpp index 925d9609ee..08aeff0504 100644 --- a/src/mac/carbon/dcclient.cpp +++ b/src/mac/carbon/dcclient.cpp @@ -38,598 +38,78 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) * wxWindowDC */ +#include + wxWindowDC::wxWindowDC(void) { -}; +} -wxWindowDC::wxWindowDC( wxWindow *window ) -{ -}; +wxWindowDC::wxWindowDC(wxWindow *the_canvas) +{ + WindowRef windowref ; + wxWindow* rootwindow ; + + // this time it is really the full window + + the_canvas->MacGetPortParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); + m_macPort = UMAGetWindowPort( windowref ) ; + MacSetupPort() ; + m_ok = TRUE ; +} wxWindowDC::~wxWindowDC(void) { -}; - -void wxWindowDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1), - const wxColour& WXUNUSED(col), int WXUNUSED(style) ) -{ -}; - -bool wxWindowDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const -{ - return FALSE; -}; - -void wxWindowDC::DrawLine( long x1, long y1, long x2, long y2 ) -{ - if (!Ok()) return; - -}; - -void wxWindowDC::CrossHair( long x, long y ) -{ - if (!Ok()) return; - -}; - -void wxWindowDC::DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) -{ - if (!Ok()) return; - - long xx1 = XLOG2DEV(x1); - long yy1 = YLOG2DEV(y1); - long xx2 = XLOG2DEV(x2); - long yy2 = YLOG2DEV(y2); - long xxc = XLOG2DEV((long)xc); - long yyc = YLOG2DEV((long)yc); - double dx = xx1 - xxc; - double dy = yy1 - yyc; - double radius = sqrt(dx*dx+dy*dy); - long r = (long)radius; - double radius1, radius2; - - if (xx1 == xx2 && yy1 == yy2) - { - radius1 = 0.0; - radius2 = 360.0; - } - else - if (radius == 0.0) - { - radius1 = radius2 = 0.0; - } - else - { - radius1 = (xx1 - xxc == 0) ? - (yy1 - yyc < 0) ? 90.0 : -90.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; - }; - long alpha1 = long(radius1 * 64.0); - long alpha2 = long((radius2 - radius1) * 64.0); - while (alpha2 <= 0) alpha2 += 360*64; - while (alpha1 > 360*64) alpha1 -= 360*64; - - if (m_brush.GetStyle() != wxTRANSPARENT) {}; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; - -}; - -void wxWindowDC::DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) -{ - if (!Ok()) return; - - long xx = XLOG2DEV(x); - long yy = YLOG2DEV(y); - long ww = m_signX * XLOG2DEVREL(width); - long hh = m_signY * YLOG2DEVREL(height); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - long start = long(sa * 64.0); - long end = long(ea * 64.0); - if (m_brush.GetStyle() != wxTRANSPARENT) {}; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; -}; - -void wxWindowDC::DrawPoint( long x, long y ) -{ - if (!Ok()) return; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; -}; - -void wxWindowDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset ) -{ - if (!Ok()) return; - - if (m_pen.GetStyle() == wxTRANSPARENT) return; - - for (int i = 0; i < n-1; i++) - { - long x1 = XLOG2DEV(points[i].x + xoffset); - long x2 = XLOG2DEV(points[i+1].x + xoffset); - long y1 = YLOG2DEV(points[i].y + yoffset); // oh, what a waste - long y2 = YLOG2DEV(points[i+1].y + yoffset); - }; -}; - -void wxWindowDC::DrawLines( wxList *points, long xoffset, long yoffset ) -{ - if (!Ok()) return; - - if (m_pen.GetStyle() == wxTRANSPARENT) return; - - wxNode *node = points->First(); - while (node->Next()) - { - wxPoint *point = (wxPoint*)node->Data(); - wxPoint *npoint = (wxPoint*)node->Next()->Data(); - long x1 = XLOG2DEV(point->x + xoffset); - long x2 = XLOG2DEV(npoint->x + xoffset); - long y1 = YLOG2DEV(point->y + yoffset); // and again... - long y2 = YLOG2DEV(npoint->y + yoffset); - node = node->Next(); - }; -}; - -void wxWindowDC::DrawPolygon( int WXUNUSED(n), wxPoint WXUNUSED(points)[], - long WXUNUSED(xoffset), long WXUNUSED(yoffset), int WXUNUSED(fillStyle) ) -{ - if (!Ok()) return; -}; - -void wxWindowDC::DrawPolygon( wxList *WXUNUSED(lines), long WXUNUSED(xoffset), - long WXUNUSED(yoffset), int WXUNUSED(fillStyle) ) -{ - if (!Ok()) return; -}; - -void wxWindowDC::DrawRectangle( long x, long y, long width, long height ) -{ - if (!Ok()) return; - - long xx = XLOG2DEV(x); - long yy = YLOG2DEV(y); - long ww = m_signX * XLOG2DEVREL(width); - long 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; } - - if (m_brush.GetStyle() != wxTRANSPARENT) {}; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; -}; - -void wxWindowDC::DrawRoundedRectangle( long x, long y, long width, long height, double radius ) -{ - if (!Ok()) return; - - if (radius < 0.0) radius = - radius * ((width < height) ? width : height); - - long xx = XLOG2DEV(x); - long yy = YLOG2DEV(y); - long ww = m_signX * XLOG2DEVREL(width); - long hh = m_signY * YLOG2DEVREL(height); - long rr = XLOG2DEVREL((long)radius); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - // CMB: if radius is zero use DrawRectangle() instead to avoid - // X drawing errors with small radii - if (rr == 0) - { - DrawRectangle( x, y, width, height ); - return; - } - - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) return; - - // CMB: adjust size if outline is drawn otherwise the result is - // 1 pixel too wide and high - if (m_pen.GetStyle() != wxTRANSPARENT) - { - ww--; - hh--; - } - - // CMB: ensure dd is not larger than rectangle otherwise we - // get an hour glass shape - long dd = 2 * rr; - if (dd > ww) dd = ww; - if (dd > hh) dd = hh; - rr = dd / 2; - - if (m_brush.GetStyle() != wxTRANSPARENT) - { - }; - - if (m_pen.GetStyle() != wxTRANSPARENT) - { - }; -}; - -void wxWindowDC::DrawEllipse( long x, long y, long width, long height ) -{ - if (!Ok()) return; - - long xx = XLOG2DEV(x); - long yy = YLOG2DEV(y); - long ww = m_signX * XLOG2DEVREL(width); - long hh = m_signY * YLOG2DEVREL(height); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - if (m_brush.GetStyle() != wxTRANSPARENT) {}; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; -}; - -bool wxWindowDC::CanDrawBitmap(void) const -{ - return TRUE; -}; - -void wxWindowDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask ) -{ - if (!Ok()) return; - - if (!icon.Ok()) return; - - int xx = XLOG2DEV(x); - int yy = YLOG2DEV(y); - -}; - -bool wxWindowDC::Blit( long xdest, long ydest, long width, long height, - wxDC *source, long xsrc, long ysrc, int WXUNUSED(logical_func), bool WXUNUSED(useMask) ) -{ - if (!Ok()) return FALSE; - - // CMB 20/5/98: add blitting of bitmaps - if (source->IsKindOf(CLASSINFO(wxMemoryDC))) - { - wxMemoryDC* srcDC = (wxMemoryDC*)source; - /* - GdkBitmap* bmap = srcDC->m_selected.GetBitmap(); - if (bmap) - { - gdk_draw_bitmap ( - m_window, - m_textGC, - bmap, - source->DeviceToLogicalX(xsrc), source->DeviceToLogicalY(ysrc), - XLOG2DEV(xdest), YLOG2DEV(ydest), - source->DeviceToLogicalXRel(width), source->DeviceToLogicalYRel(height) - ); - return TRUE; - } - */ - } - - return TRUE; -}; - -void wxWindowDC::DrawText( const wxString &text, long x, long y, bool -WXUNUSED(use16) ) -{ - if (!Ok()) return; - -}; - - - -bool wxWindowDC::CanGetTextExtent(void) const -{ - return TRUE; -}; - -void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *height, - long *WXUNUSED(descent), long *WXUNUSED(externalLeading), - wxFont *WXUNUSED(theFont), bool WXUNUSED(use16) ) -{ - if (!Ok()) return; - -}; - -long wxWindowDC::GetCharWidth(void) -{ - if (!Ok()) return 0; - return 0; -}; - -long wxWindowDC::GetCharHeight(void) -{ - if (!Ok()) return 0; - return 0; -}; - -void wxWindowDC::Clear(void) -{ - if (!Ok()) return; - -}; - -void wxWindowDC::SetFont( const wxFont &font ) -{ - if (!Ok()) return; - - m_font = font; -}; - -void wxWindowDC::SetPen( const wxPen &pen ) -{ - if (!Ok()) return; - - if (m_pen == pen) return; - - m_pen = pen; - - if (!m_pen.Ok()) return; -}; - -void wxWindowDC::SetBrush( const wxBrush &brush ) -{ - if (!Ok()) return; - - if (m_brush == brush) return; - - m_brush = brush; - - if (!m_brush.Ok()) return; - -}; - -void wxWindowDC::SetBackground( const wxBrush &brush ) -{ - if (!Ok()) return; - - if (m_backgroundBrush == brush) return; - - m_backgroundBrush = brush; - - if (!m_backgroundBrush.Ok()) return; - -}; - -void wxWindowDC::SetLogicalFunction( int function ) -{ - if (m_logicalFunction == function) return; -}; - -void wxWindowDC::SetTextForeground( const wxColour &col ) -{ - if (!Ok()) return; - - if (m_textForegroundColour == col) return; - - m_textForegroundColour = col; - if (!m_textForegroundColour.Ok()) return; -}; - -void wxWindowDC::SetTextBackground( const wxColour &col ) -{ - if (!Ok()) return; - - if (m_textBackgroundColour == col) return; - - m_textBackgroundColour = col; - if (!m_textBackgroundColour.Ok()) return; -}; - -void wxWindowDC::SetBackgroundMode( int mode ) -{ - m_backgroundMode = mode; - - if (m_brush.GetStyle() != wxSOLID && m_brush.GetStyle() != wxTRANSPARENT) - { - } -}; - -void wxWindowDC::SetPalette( const wxPalette& WXUNUSED(palette) ) -{ -}; - -void wxWindowDC::SetClippingRegion( long x, long y, long width, long height ) -{ - wxDC::SetClippingRegion( x, y, width, height ); +} - // TODO - -}; +/* + * wxClientDC + */ -void wxWindowDC::SetClippingRegion( const wxRegion& region ) +wxClientDC::wxClientDC(void) { - wxRect box = region.GetBox(); - - wxDC::SetClippingRegion( box.x, box.y, box.width, box.height ); - - // TODO } -void wxWindowDC::DestroyClippingRegion(void) +wxClientDC::wxClientDC(wxWindow *window) { - wxDC::DestroyClippingRegion(); - -}; - -// ----------------------------------- spline code ---------------------------------------- - -void wx_quadratic_spline(double a1, double b1, double a2, double b2, - double a3, double b3, double a4, double b4); -void wx_clear_stack(void); -int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3, - double *y3, double *x4, double *y4); -void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, - double x4, double y4); -static bool wx_spline_add_point(double x, double y); -static void wx_spline_draw_point_array(wxDC *dc); + WindowRef windowref ; + wxWindow* rootwindow ; + + window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); + m_macPort = UMAGetWindowPort( windowref ) ; + MacSetupPort() ; + m_ok = TRUE ; + SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID)); -wxList wx_spline_point_list; - -#define half(z1, z2) ((z1+z2)/2.0) -#define THRESHOLD 5 - -/* iterative version */ - -void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4, - double b4) -{ - register double xmid, ymid; - double x1, y1, x2, y2, x3, y3, x4, y4; - - wx_clear_stack(); - wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4); - - while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) { - xmid = (double)half(x2, x3); - ymid = (double)half(y2, y3); - if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD && - fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) { - wx_spline_add_point( x1, y1 ); - wx_spline_add_point( xmid, ymid ); - } else { - wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3), - (double)half(x3, x4), (double)half(y3, y4), x4, y4); - wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2), - (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid); - } - } } -/* utilities used by spline drawing routines */ - -typedef struct wx_spline_stack_struct { - double x1, y1, x2, y2, x3, y3, x4, y4; -} Stack; - -#define SPLINE_STACK_DEPTH 20 -static Stack wx_spline_stack[SPLINE_STACK_DEPTH]; -static Stack *wx_stack_top; -static int wx_stack_count; - -void wx_clear_stack(void) +wxClientDC::~wxClientDC(void) { - wx_stack_top = wx_spline_stack; - wx_stack_count = 0; } -void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) -{ - wx_stack_top->x1 = x1; - wx_stack_top->y1 = y1; - wx_stack_top->x2 = x2; - wx_stack_top->y2 = y2; - wx_stack_top->x3 = x3; - wx_stack_top->y3 = y3; - wx_stack_top->x4 = x4; - wx_stack_top->y4 = y4; - wx_stack_top++; - wx_stack_count++; -} +/* + * wxPaintDC + */ -int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, - double *x3, double *y3, double *x4, double *y4) +wxPaintDC::wxPaintDC(void) { - if (wx_stack_count == 0) - return (0); - wx_stack_top--; - wx_stack_count--; - *x1 = wx_stack_top->x1; - *y1 = wx_stack_top->y1; - *x2 = wx_stack_top->x2; - *y2 = wx_stack_top->y2; - *x3 = wx_stack_top->x3; - *y3 = wx_stack_top->y3; - *x4 = wx_stack_top->x4; - *y4 = wx_stack_top->y4; - return (1); } -static bool wx_spline_add_point(double x, double y) +wxPaintDC::wxPaintDC(wxWindow *window) { - wxPoint *point = new wxPoint ; - point->x = (int) x; - point->y = (int) y; - wx_spline_point_list.Append((wxObject*)point); - return TRUE; -} + WindowRef windowref ; + wxWindow* rootwindow ; + + window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); -static void wx_spline_draw_point_array(wxDC *dc) -{ - dc->DrawLines(&wx_spline_point_list, 0, 0 ); - wxNode *node = wx_spline_point_list.First(); - while (node) - { - wxPoint *point = (wxPoint *)node->Data(); - delete point; - delete node; - node = wx_spline_point_list.First(); - } + m_macPort = UMAGetWindowPort( windowref ) ; + MacSetupPort() ; + m_ok = TRUE ; + long x , y ,w , h ; + window->GetUpdateRegion().GetBox( x , y , w , h ) ; + SetClippingRegion( x , y , w , h ) ; + SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID)); } -void wxWindowDC::DrawSpline( wxList *points ) +wxPaintDC::~wxPaintDC() { - wxPoint *p; - double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; - double x1, y1, x2, y2; - - wxNode *node = points->First(); - p = (wxPoint *)node->Data(); - - x1 = p->x; - y1 = p->y; - - node = node->Next(); - p = (wxPoint *)node->Data(); - - x2 = p->x; - y2 = p->y; - cx1 = (double)((x1 + x2) / 2); - cy1 = (double)((y1 + y2) / 2); - cx2 = (double)((cx1 + x2) / 2); - cy2 = (double)((cy1 + y2) / 2); - - wx_spline_add_point(x1, y1); - - while ((node = node->Next()) != NULL) - { - p = (wxPoint *)node->Data(); - x1 = x2; - y1 = y2; - x2 = p->x; - y2 = p->y; - cx4 = (double)(x1 + x2) / 2; - cy4 = (double)(y1 + y2) / 2; - cx3 = (double)(x1 + cx4) / 2; - cy3 = (double)(y1 + cy4) / 2; - - wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4); - - cx1 = cx4; - cy1 = cy4; - cx2 = (double)(cx1 + x2) / 2; - cy2 = (double)(cy1 + y2) / 2; - } - - wx_spline_add_point( cx1, cy1 ); - wx_spline_add_point( x2, y2 ); - - wx_spline_draw_point_array( this ); -}; +} diff --git a/src/mac/carbon/dcmemory.cpp b/src/mac/carbon/dcmemory.cpp index 7cbd330821..28a652368a 100644 --- a/src/mac/carbon/dcmemory.cpp +++ b/src/mac/carbon/dcmemory.cpp @@ -40,6 +40,18 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) m_selected = bitmap; if (m_selected.Ok()) { + wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ; + if ( bmap->m_hBitmap ) + { + m_macPort = (GrafPtr) bmap->m_hBitmap ; + MacSetupPort() ; + m_ok = TRUE ; + // SetBackground(wxBrush(*wxWHITE, wxSOLID)); + } + else + { + m_ok = FALSE; + } } else { diff --git a/src/mac/carbon/dcscreen.cpp b/src/mac/carbon/dcscreen.cpp index e03bbac0c8..1ea12f3d29 100644 --- a/src/mac/carbon/dcscreen.cpp +++ b/src/mac/carbon/dcscreen.cpp @@ -22,7 +22,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) // Create a DC representing the whole screen wxScreenDC::wxScreenDC() { - // TODO + m_macPort = LMGetWMgrPort() ; + MacSetupPort() ; + m_ok = TRUE ; } wxScreenDC::~wxScreenDC() diff --git a/src/mac/carbon/dialog.cpp b/src/mac/carbon/dialog.cpp index bf3cae5e35..7e82133eb2 100644 --- a/src/mac/carbon/dialog.cpp +++ b/src/mac/carbon/dialog.cpp @@ -19,6 +19,8 @@ #include "wx/app.h" #include "wx/settings.h" +#include + // Lists to keep track of windows, so we can disable/enable them // for modal dialogs wxList wxModalDialogs; @@ -29,6 +31,7 @@ extern wxList wxPendingDelete; IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxPanel) + EVT_SIZE(wxDialog::OnSize) EVT_BUTTON(wxID_OK, wxDialog::OnOK) EVT_BUTTON(wxID_APPLY, wxDialog::OnApply) EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel) @@ -66,9 +69,47 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, else m_windowId = id; - // TODO: create dialog + 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; + if (m_width == -1) + m_width = 20; + 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); + m_macWindowData = new MacWindowData() ; + + WindowClass wclass = kMovableModalWindowClass ; + WindowAttributes attr = kWindowNoAttributes ; + + if ( ( m_windowStyle & wxMINIMIZE_BOX ) || ( m_windowStyle & wxMAXIMIZE_BOX ) ) + { + attr |= kWindowFullZoomAttribute ; + attr |= kWindowResizableAttribute ; + } - return FALSE; + UMACreateNewWindow( wclass , attr , &theBoundsRect , &m_macWindowData->m_macWindow ) ; + wxAssociateWinWithMacWindow( m_macWindowData->m_macWindow , this ) ; + wxString label ; + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( title ) ; + else + label = title ; + UMASetWTitleC( m_macWindowData->m_macWindow , label ) ; + m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; + UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ; + m_macWindowData->m_macFocus = NULL ; + m_macShown = false ; + return TRUE; } void wxDialog::SetModal(bool flag) @@ -86,7 +127,6 @@ void wxDialog::SetModal(bool flag) wxDialog::~wxDialog() { - // TODO wxTopLevelWindows.DeleteObject(this); if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL ) @@ -99,7 +139,7 @@ wxDialog::~wxDialog() if (wxTheApp->GetExitOnFrameDelete()) { - // TODO: exit + wxTheApp->ExitMainLoop() ; } } } @@ -132,67 +172,65 @@ bool wxDialog::IsIconized() const return FALSE; } -void wxDialog::SetClientSize(int width, int height) -{ - // TODO -} - -void wxDialog::GetPosition(int *x, int *y) const -{ - // TODO -} +extern bool s_macIsInModalLoop ; bool wxDialog::Show(bool show) { - // TODO - return FALSE; -} + if ( m_macShown == show ) + return TRUE ; -void wxDialog::SetTitle(const wxString& title) -{ - // TODO -} + m_macShown = show ; -wxString wxDialog::GetTitle() const -{ - // TODO - return wxString(""); -} + bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ; -void wxDialog::Centre(int direction) -{ - int x_offset,y_offset ; - int display_width, display_height; - int width, height, x, y; - wxWindow *parent = GetParent(); - if ((direction & wxCENTER_FRAME) && parent) - { - parent->GetPosition(&x_offset,&y_offset) ; - parent->GetSize(&display_width,&display_height) ; - } - else - { - wxDisplaySize(&display_width, &display_height); - x_offset = 0 ; - y_offset = 0 ; - } + if ( modal ) + { + s_macIsInModalLoop = true ; + if (show) + { + // if we don't do it, some window might be deleted while we have pointers + // to them in our disabledWindows list and the program will crash when it + // will try to reenable them after the modal dialog end + wxTheApp->DeletePendingObjects(); - GetSize(&width, &height); - GetPosition(&x, &y); + UMAShowWindow( m_macWindowData->m_macWindow ) ; + UMASelectWindow( m_macWindowData->m_macWindow ) ; - if (direction & wxHORIZONTAL) - x = (int)((display_width - width)/2); - if (direction & wxVERTICAL) - y = (int)((display_height - height)/2); + if (!wxModalDialogs.Member(this)) + wxModalDialogs.Append(this); - SetSize(x+x_offset, y+y_offset, width, height); + while (wxModalDialogs.Member(this) ) + { + wxTheApp->MacDoOneEvent() ; + } + } + else + { + wxModalDialogs.DeleteObject(this); + UMAHideWindow( m_macWindowData->m_macWindow ) ; + } + s_macIsInModalLoop = false ; + } + else // !modal + { + if (show) + { + UMAShowWindow( m_macWindowData->m_macWindow ) ; + UMASelectWindow( m_macWindowData->m_macWindow ) ; + } + else + { + UMAHideWindow( m_macWindowData->m_macWindow ) ; + } + } + return TRUE ; } + // Replacement for Show(TRUE) for modal dialogs - returns return code int wxDialog::ShowModal() { - m_windowStyle |= wxDIALOG_MODAL; - // TODO: modal showing + m_windowStyle |= wxDIALOG_MODAL; Show(TRUE); return GetReturnCode(); } @@ -275,6 +313,16 @@ bool wxDialog::Destroy() return TRUE; } +void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event)) +{ + // if we're using constraints - do use them + #if wxUSE_CONSTRAINTS + if ( GetAutoLayout() ) { + Layout(); + } + #endif +} + void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); @@ -283,4 +331,128 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) void wxDialog::Fit() { + wxWindow::Fit(); } + +wxSizer *wxDialog::CreateTextSizer( const wxString &message ) +{ + wxBoxSizer *box = new wxBoxSizer( wxVERTICAL ); + + // get line height for empty lines + int y = 0; + wxFont new_font( GetFont() ); + if (!new_font.Ok()) new_font = *wxSWISS_FONT; + GetTextExtent( "H", (int*)NULL, &y, (int*)NULL, (int*)NULL, &new_font ); + + wxString line; + for (size_t pos = 0; pos < message.Len(); pos++) + { + if (message[pos] == _T('\n')) + { + if (!line.IsEmpty()) + { + wxStaticText *s1 = new wxStaticText( this, -1, line ); + box->Add( s1 ); + line = _T(""); + } + else + { + box->Add( 5, y ); + } + } + else + { + line += message[pos]; + } + } + + // remaining text behind last '\n' + if (!line.IsEmpty()) + { + wxStaticText *s2 = new wxStaticText( this, -1, line ); + box->Add( s2 ); + } + + return box; +} + +wxSizer *wxDialog::CreateButtonSizer( long flags ) +{ + wxBoxSizer *box = new wxBoxSizer( wxHORIZONTAL ); + +#if defined(__WXMSW__) || defined(__WXMAC__) + int margin = 6; +#else + int margin = 10; +#endif + + wxButton *ok = (wxButton *) NULL; + wxButton *cancel = (wxButton *) NULL; + wxButton *yes = (wxButton *) NULL; + wxButton *no = (wxButton *) NULL; + + // always show an OK button, unless only YES_NO is given + if ((flags & wxYES_NO) == 0) flags = flags | wxOK; + + if (flags & wxYES_NO) + { + yes = new wxButton( this, wxID_YES, _("Yes") ); + box->Add( yes, 0, wxLEFT|wxRIGHT, margin ); + no = new wxButton( this, wxID_NO, _("No") ); + box->Add( no, 0, wxLEFT|wxRIGHT, margin ); + } else + if (flags & wxYES) + { + yes = new wxButton( this, wxID_YES, _("Yes") ); + box->Add( yes, 0, wxLEFT|wxRIGHT, margin ); + } else + if (flags & wxNO) + { + no = new wxButton( this, wxID_NO, _("No") ); + box->Add( no, 0, wxLEFT|wxRIGHT, margin ); + } + + if (flags & wxOK) + { + ok = new wxButton( this, wxID_OK, _("OK") ); + box->Add( ok, 0, wxLEFT|wxRIGHT, margin ); + } + + if (flags & wxFORWARD) + box->Add( new wxButton( this, wxID_FORWARD, _("Forward") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxBACKWARD) + box->Add( new wxButton( this, wxID_BACKWARD, _("Backward") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxSETUP) + box->Add( new wxButton( this, wxID_SETUP, _("Setup") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxMORE) + box->Add( new wxButton( this, wxID_MORE, _("More...") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxHELP) + box->Add( new wxButton( this, wxID_HELP, _("Help") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxCANCEL) + { + cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); + box->Add( cancel, 0, wxLEFT|wxRIGHT, margin ); + } + + if ((flags & wxNO_DEFAULT) == 0) + { + if (ok) + { + ok->SetDefault(); + ok->SetFocus(); + } + else if (yes) + { + yes->SetDefault(); + yes->SetFocus(); + } + } + + return box; +} + diff --git a/src/mac/carbon/dirdlg.cpp b/src/mac/carbon/dirdlg.cpp index 095621b978..edfc211caa 100644 --- a/src/mac/carbon/dirdlg.cpp +++ b/src/mac/carbon/dirdlg.cpp @@ -24,6 +24,407 @@ IMPLEMENT_CLASS(wxDirDialog, wxDialog) #endif +enum { + kSelectItem = 10, // select button item number + kSFGetFolderDlgID = 250, // dialog resource number + kStrListID = 250, // our strings + kSelectStrNum = 1, // word 'Select: ' for button + kDesktopStrNum = 2, // word 'Desktop' for button + kSelectNoQuoteStrNum = 3, // word 'Select: ' for button + + kUseQuotes = true, // parameter for SetButtonName + kDontUseQuotes = false +}; + +// the data we need to pass to our standard file hook routine +// includes a pointer to the dialog, a pointer to the standard +// file reply record (so we can inspect the current selection) +// and a copy of the "previous" file spec of the reply record +// so we can see if the selection has changed + +struct UserDataRec { + StandardFileReply *sfrPtr; + FSSpec oldSelectionFSSpec; + DialogPtr theDlgPtr; +}; +typedef struct UserDataRec + UserDataRec, *UserDataRecPtr; + +static void GetLabelString(StringPtr theStr, short stringNum) +{ + GetIndString(theStr, kStrListID, stringNum); +} + +static void CopyPStr(StringPtr src, StringPtr dest) +{ + BlockMoveData(src, dest, 1 + src[0]); +} + +static char GetSelectKey(void) +{ + // this is the key used to trigger the select button + + // NOT INTERNATIONAL SAVVY; should at least grab it from resources + + return 's'; +} + + +// SetButtonName sets the name of the Select button in the dialog +// +// To do this, we need to call the Script Manager to truncate the +// label in the middle to fit the button and to merge the button +// name with the word Select (possibly followed by quotes). Using +// the Script Manager avoids all sorts of problems internationally. +// +// buttonName is the name to appear following the word Select +// quoteFlag should be true if the name is to appear in quotes + +static void SetButtonName(DialogPtr theDlgPtr, short buttonID, StringPtr buttonName, + Boolean quoteFlag) +{ + short buttonType; + Handle buttonHandle; + Rect buttonRect; + short textWidth; + Handle labelHandle; + Handle nameHandle; + Str15 keyStr; + Str255 labelStr; + OSErr err; + + nameHandle = nil; + labelHandle = nil; + + // get the details of the button from the dialog + + GetDialogItem(theDlgPtr, buttonID, &buttonType, &buttonHandle, &buttonRect); + + // get the string for the select button label, "Select ^0" or "Select Ò^0Ó" + + GetLabelString(labelStr, (quoteFlag == kUseQuotes) ? kSelectStrNum : kSelectNoQuoteStrNum); + + // make string handles containing the select button label and the + // file name to be stuffed into the button + + err = PtrToHand(&labelStr[1], &labelHandle, labelStr[0]); + if (err != noErr) goto Bail; + + // cut out the middle of the file name to fit the button + // + // we'll temporarily use labelStr here to hold the modified button name + // since we don't own the buttonName string storage space + + textWidth = (buttonRect.right - buttonRect.left) - StringWidth(labelStr); + + CopyPStr(buttonName, labelStr); + (void) TruncString(textWidth, labelStr, smTruncMiddle); + + err = PtrToHand(&labelStr[1], &nameHandle, labelStr[0]); + if (err != noErr) goto Bail; + + // replace the ^0 in the Select string with the file name + + CopyPStr("\p^0", keyStr); + + (void) ReplaceText(labelHandle, nameHandle, keyStr); + + labelStr[0] = (unsigned char) GetHandleSize(labelHandle); + BlockMoveData(*labelHandle, &labelStr[1], labelStr[0]); + + // now set the control title, and re-validate the area + // above the control to avoid a needless redraw + + SetControlTitle((ControlHandle) buttonHandle, labelStr); + + ValidRect(&buttonRect); + +Bail: + if (nameHandle) DisposeHandle(nameHandle); + if (labelHandle) DisposeHandle(labelHandle); + +} + +// FlashButton briefly highlights the dialog button +// as feedback for key equivalents + +static void FlashButton(DialogPtr theDlgPtr, short buttonID) +{ + short buttonType; + Handle buttonHandle; + Rect buttonRect; + unsigned long finalTicks; + + GetDialogItem(theDlgPtr, buttonID, &buttonType, &buttonHandle, &buttonRect); + HiliteControl((ControlHandle) buttonHandle, kControlButtonPart); + Delay(10, &finalTicks); + HiliteControl((ControlHandle) buttonHandle, 0); +} + +static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2) +{ + return (spec1->vRefNum == spec2->vRefNum + && spec1->parID == spec2->parID + && EqualString(spec1->name, spec2->name, false, false)); +} +// MyModalDialogFilter maps a key to the Select button, and handles +// flashing of the button when the key is hit + +static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec, + short *item, Ptr dataPtr) +{ +#pragma unused (dataPtr) + + // make certain the proper dialog is showing, 'cause standard file + // can nest dialogs but calls the same filter for each + + if (((WindowPeek) theDlgPtr)->refCon == sfMainDialogRefCon) + { + // check if the select button was hit + + if ((eventRec->what == keyDown) + && (eventRec->modifiers & cmdKey) + && ((eventRec->message & charCodeMask) == GetSelectKey())) + { + *item = kSelectItem; + FlashButton(theDlgPtr, kSelectItem); + return true; + } + } + + return false; +} + + +// MyDlgHook is a hook routine that maps the select button to Open +// and sets the Select button name + +static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, Ptr dataPtr) +{ + UserDataRecPtr theUserDataRecPtr; + long desktopDirID; + short desktopVRefNum; + FSSpec tempSpec; + Str63 desktopName; + OSErr err; + + // be sure Std File is really showing us the intended dialog, + // not a nested modal dialog + + if (((WindowPeek) theDlgPtr)->refCon != sfMainDialogRefCon) + { + return item; + } + + theUserDataRecPtr = (UserDataRecPtr) dataPtr; + + // map the Select button to Open + + if (item == kSelectItem) + { + item = sfItemOpenButton; + } + + // find the desktop folder + + err = FindFolder(theUserDataRecPtr->sfrPtr->sfFile.vRefNum, + kDesktopFolderType, kDontCreateFolder, + &desktopVRefNum, &desktopDirID); + + if (err != noErr) + { + // for errors, get value that won't match any real vRefNum/dirID + desktopVRefNum = 0; + desktopDirID = 0; + } + + // change the Select button label if the selection has changed or + // if this is the first call to the hook + + if (item == sfHookFirstCall + || item == sfHookChangeSelection + || item == sfHookRebuildList + || ! SameFSSpec(&theUserDataRecPtr->sfrPtr->sfFile, + &theUserDataRecPtr->oldSelectionFSSpec)) + { + // be sure there is a file name selected + + if (theUserDataRecPtr->sfrPtr->sfFile.name[0] != '\0') + { + SetButtonName(theDlgPtr, kSelectItem, + theUserDataRecPtr->sfrPtr->sfFile.name, + kUseQuotes); // true -> use quotes + } + else + { + // is the desktop selected? + + if (theUserDataRecPtr->sfrPtr->sfFile.vRefNum == desktopVRefNum + && theUserDataRecPtr->sfrPtr->sfFile.parID == desktopDirID) + { + // set button to "Select Desktop" + + GetLabelString(desktopName, kDesktopStrNum); + SetButtonName(theDlgPtr, kSelectItem, + desktopName, kDontUseQuotes); // false -> no quotes + } + else + { + // get parent directory's name for the Select button + // + // passing an empty name string to FSMakeFSSpec gets the + // name of the folder specified by the parID parameter + + (void) FSMakeFSSpec(theUserDataRecPtr->sfrPtr->sfFile.vRefNum, + theUserDataRecPtr->sfrPtr->sfFile.parID, "\p", + &tempSpec); + SetButtonName(theDlgPtr, kSelectItem, + tempSpec.name, kUseQuotes); // true -> use quotes + } + } + } + + // save the current selection as the old selection for comparison next time + // + // it's not valid on the first call, though, or if we don't have a + // name available from standard file + + if (item != sfHookFirstCall || theUserDataRecPtr->sfrPtr->sfFile.name[0] != '\0') + { + theUserDataRecPtr->oldSelectionFSSpec = theUserDataRecPtr->sfrPtr->sfFile; + } + else + { + // on first call, empty string won't set the button correctly, + // so invalidate oldSelection + + theUserDataRecPtr->oldSelectionFSSpec.vRefNum = 999; + theUserDataRecPtr->oldSelectionFSSpec.parID = 0; + } + + return item; +} + +void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileFilterYDUPP fileFilter, StandardFileReply *theSFR) +{ + Point thePt; + SFTypeList mySFTypeList; + UserDataRec myData; + FSSpec tempSpec; + Boolean folderFlag; + Boolean wasAliasedFlag; + DlgHookYDUPP dlgHookUPP; + ModalFilterYDUPP myModalFilterUPP; + OSErr err; + + + // presumably we're running System 7 or later so CustomGetFile is + // available + + // set initial contents of Select button to a space + + CopyPStr("\p ", theSFR->sfFile.name); + + // point the user data parameter at the reply record so we can get to it later + + myData.sfrPtr = theSFR; + + // display the dialog + + dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook); + myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter); + + thePt.h = thePt.v = -1; // center dialog + + ParamText( message , NULL , NULL , NULL ) ; + + CustomGetFile( fileFilter, + -1, // show all types + mySFTypeList, + theSFR, + kSFGetFolderDlgID, + thePt, // top left point + dlgHookUPP, + myModalFilterUPP, + nil, // activate list + nil, // activate proc + &myData); + + DisposeRoutineDescriptor(dlgHookUPP); + DisposeRoutineDescriptor(myModalFilterUPP); + + // if cancel wasn't pressed and no fatal error occurred... + + if (theSFR->sfGood) + { + // if no name is in the reply record file spec, + // use the file spec of the parent folder + + if (theSFR->sfFile.name[0] == '\0') + { + err = FSMakeFSSpec(theSFR->sfFile.vRefNum, theSFR->sfFile.parID, + "\p", &tempSpec); + if (err == noErr) + { + theSFR->sfFile = tempSpec; + } + else + { + // no name to return, forget it + + theSFR->sfGood = false; + } + } + + // if there is now a name in the file spec, check if it's + // for a folder or a volume + + if (theSFR->sfFile.name[0] != '\0') + { + // the parID of the root of a disk is always fsRtParID == 1 + + if (theSFR->sfFile.parID == fsRtParID) + { + theSFR->sfIsVolume = true; + theSFR->sfIsFolder = false; // it would be reasonable for this to be true, too + } + + // we have a valid FSSpec, now let's make sure it's not for an alias file + + err = ResolveAliasFile(&theSFR->sfFile, true, &folderFlag, &wasAliasedFlag); + if (err != noErr) + { + theSFR->sfGood = false; + } + + // did the alias resolve to a folder? + + if (folderFlag && ! theSFR->sfIsVolume) + { + theSFR->sfIsFolder = true; + } + } + } +} + +static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr) +{ +#pragma unused (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 + + return !(visibleFlag && folderFlag); +} + wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message, const wxString& defaultPath, long style, const wxPoint& pos) @@ -36,7 +437,35 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message, int wxDirDialog::ShowModal() { - // TODO + { + Str255 prompt ; + Str255 path ; + + strcpy((char *)prompt, m_message) ; + c2pstr((char *)prompt ) ; + + strcpy((char *)path, m_path ) ; + c2pstr((char *)path ) ; + + FileFilterYDUPP invisiblesExcludedCustomFilterUPP; + StandardFileReply reply ; + invisiblesExcludedCustomFilterUPP = + NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter); + + StandardGetFolder( prompt , path , invisiblesExcludedCustomFilterUPP, &reply); + + DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP); + if ( reply.sfGood == false ) + { + m_path = "" ; + return wxID_CANCEL ; + } + else + { + m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ; + return wxID_OK ; + } + } return wxID_CANCEL; } diff --git a/src/mac/carbon/filedlg.cpp b/src/mac/carbon/filedlg.cpp index b6f5b1912d..66de687b80 100644 --- a/src/mac/carbon/filedlg.cpp +++ b/src/mac/carbon/filedlg.cpp @@ -23,7 +23,352 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog) #endif -WXDLLEXPORT wxString wxFileSelector(const char *title, +// begin wxmac + +#include "morefile.h" +#include "moreextr.h" +#include "fullpath.h" +#include "fspcompa.h" +#include "PLStringFuncs.h" + +char * gfilters[] = +{ + "*.TXT" , + + NULL +} ; + +OSType gfiltersmac[] = +{ + 'TEXT' , + + '****' +} ; + +static void wxMacSetupStandardFile(short newVRefNum, long newDirID) +{ + enum + { SFSaveDisk = 0x214, CurDirStore = 0x398 }; + *(short *) SFSaveDisk = -1 * newVRefNum; + *(long *) CurDirStore = newDirID; +} + +static void wxMacSetupStandardFileFromPath( const char* s ) +{ + Str255 volume ; + Str255 path ; + short vRefNum ; + long dirRef ; + short i,j ; + Boolean isDirectory ; + + for (i=0 ; (s[i]!=0) && (s[i]!=':') ;i++) + { + volume[i]=s[i] ; + } + volume[i]=':' ; + volume[i+1]=0 ; + + // then copy the rest of the filename + + for (j=0;(s[i]!=0);i++,j++) + { + path[j]=s[i] ; + } + path[j]=0 ; + + c2pstr((Ptr) volume) ; + c2pstr((Ptr) path) ; + + SetVol(volume, 0) ; + GetVol( NULL, &vRefNum ) ; + + GetDirectoryID( vRefNum , fsRtDirID , path , &dirRef , &isDirectory ) ; + wxMacSetupStandardFile(vRefNum, dirRef) ; +} + +enum { + kSelectItem = 10, // select button item number + kSFGetFileDlgID = 251, // dialog resource number + kStrListID = 251, // our strings + kSelectStrNum = 1, // word 'Select: ' for button + kDesktopStrNum = 2, // word 'Desktop' for button + kSelectNoQuoteStrNum = 3, // word 'Select: ' for button + + kUseQuotes = true, // parameter for SetButtonName + kDontUseQuotes = false +}; + +// the data we need to pass to our standard file hook routine +// includes a pointer to the dialog, a pointer to the standard +// file reply record (so we can inspect the current selection) +// and a copy of the "previous" file spec of the reply record +// so we can see if the selection has changed + +const int kwxMacFileTypes = 10 ; + +struct OpenUserDataRec { + StandardFileReply *sfrPtr; + FSSpec oldSelectionFSSpec; + char filter[kwxMacFileTypes][10] ; + OSType filtermactypes[kwxMacFileTypes] ; + int numfilters ; + DialogPtr theDlgPtr; +}; +typedef struct OpenUserDataRec + OpenUserDataRec, *OpenUserDataRecPtr; + +static void GetLabelString(StringPtr theStr, short stringNum) +{ + GetIndString(theStr, kStrListID, stringNum); +} + +static void CopyPStr(StringPtr src, StringPtr dest) +{ + BlockMoveData(src, dest, 1 + src[0]); +} + +static char GetSelectKey(void) +{ + // this is the key used to trigger the select button + + // NOT INTERNATIONAL SAVVY; should at least grab it from resources + + return 's'; +} + +// FlashButton briefly highlights the dialog button +// as feedback for key equivalents + +static void FlashButton(DialogPtr theDlgPtr, short buttonID) +{ + short buttonType; + Handle buttonHandle; + Rect buttonRect; + unsigned long finalTicks; + + GetDialogItem(theDlgPtr, buttonID, &buttonType, &buttonHandle, &buttonRect); + HiliteControl((ControlHandle) buttonHandle, kControlButtonPart); + Delay(10, &finalTicks); + HiliteControl((ControlHandle) buttonHandle, 0); +} + +static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2) +{ + return (spec1->vRefNum == spec2->vRefNum + && spec1->parID == spec2->parID + && EqualString(spec1->name, spec2->name, false, false)); +} +// MyModalDialogFilter maps a key to the Select button, and handles +// flashing of the button when the key is hit + +static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec, + short *item, Ptr dataPtr) +{ +#pragma unused (dataPtr) + + // make certain the proper dialog is showing, 'cause standard file + // can nest dialogs but calls the same filter for each + + if (((WindowPeek) theDlgPtr)->refCon == sfMainDialogRefCon) + { + // check if the select button was hit + /* + if ((eventRec->what == keyDown) + && (eventRec->modifiers & cmdKey) + && ((eventRec->message & charCodeMask) == GetSelectKey())) + { + *item = kSelectItem; + FlashButton(theDlgPtr, kSelectItem); + return true; + } + */ + } + + return false; +} + +void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const char *filter , FileFilterYDUPP fileFilter, StandardFileReply *theSFR) +{ + Point thePt; + OpenUserDataRec myData; + FSSpec tempSpec; + Boolean folderFlag; + Boolean wasAliasedFlag; + DlgHookYDUPP dlgHookUPP; + ModalFilterYDUPP myModalFilterUPP; + OSErr err; + SFTypeList types ; + + + // presumably we're running System 7 or later so CustomGetFile is + // available + + // set initial contents of Select button to a space + + CopyPStr("\p ", theSFR->sfFile.name); + + // point the user data parameter at the reply record so we can get to it later + + myData.sfrPtr = theSFR; + if ( filter && filter[0] ) + { + myData.numfilters = 1 ; + for ( int i = 0 ; i < myData.numfilters ; i++ ) + { + int j ; + + strcpy( myData.filter[i] , filter ) ; + for( j = 0 ; myData.filter[i][j] ; j++ ) + { + myData.filter[i][j] = toupper( myData.filter[i][j] ) ; + } + for ( j = 0 ; gfilters[j] ; j++ ) + { + if ( strcmp( myData.filter[i] , gfilters[j] ) == 0 ) + { + myData.filtermactypes[i] = gfiltersmac[j] ; + break ; + } + } + if( gfilters[j] == NULL ) + { + myData.filtermactypes[i] = '****' ; + } + } + } + else + { + myData.numfilters = 0 ; + } + // display the dialog + + dlgHookUPP = NULL ; +// dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook); + myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter); + + thePt.h = thePt.v = -1; // center dialog + + ParamText( message , NULL , NULL , NULL ) ; + + CustomGetFile( fileFilter, + -1, // show all types + NULL, + theSFR, + kSFGetFileDlgID, + thePt, // top left point + dlgHookUPP, + myModalFilterUPP, + nil, // activate list + nil, // activate proc + &myData); + + DisposeRoutineDescriptor(dlgHookUPP); + DisposeRoutineDescriptor(myModalFilterUPP); + + // if cancel wasn't pressed and no fatal error occurred... + + if (theSFR->sfGood) + { + // if no name is in the reply record file spec, + // use the file spec of the parent folder + + if (theSFR->sfFile.name[0] == '\0') + { + err = FSMakeFSSpec(theSFR->sfFile.vRefNum, theSFR->sfFile.parID, + "\p", &tempSpec); + if (err == noErr) + { + theSFR->sfFile = tempSpec; + } + else + { + // no name to return, forget it + + theSFR->sfGood = false; + } + } + + // if there is now a name in the file spec, check if it's + // for a folder or a volume + + if (theSFR->sfFile.name[0] != '\0') + { + // the parID of the root of a disk is always fsRtParID == 1 + + if (theSFR->sfFile.parID == fsRtParID) + { + theSFR->sfIsVolume = true; + theSFR->sfIsFolder = false; // it would be reasonable for this to be true, too + } + + // we have a valid FSSpec, now let's make sure it's not for an alias file + + err = ResolveAliasFile(&theSFR->sfFile, true, &folderFlag, &wasAliasedFlag); + if (err != noErr) + { + theSFR->sfGood = false; + } + + // did the alias resolve to a folder? + + if (folderFlag && ! theSFR->sfIsVolume) + { + theSFR->sfIsFolder = true; + } + } + } +} + +static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr) +{ + Str255 filename ; + 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 ) + { + if ( data->numfilters > 0 ) + { + PLstrcpy( filename ,myCInfoPBPtr->hFileInfo.ioNamePtr ) ; + if ( filename[0] >= 4 ) + { + for( int j = 1 ; j <= filename[0] ; j++ ) + { + filename[j] = toupper( filename[j] ) ; + } + for ( int i = 0 ; i < data->numfilters ; ++i ) + { + if ( myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType == data->filtermactypes[i] ) + return false ; + + if ( strncmp( (char*) filename + 1 + filename[0] - 4 , + & data->filter[i][ strlen(data->filter[i]) - 4 ] , 4 ) == 0 ) + return false ; + } + } + return true ; + } + } + + return false ; +} + +// end wxmac + +wxString wxFileSelector(const char *title, const char *defaultDir, const char *defaultFileName, const char *defaultExtension, const char *filter, int flags, wxWindow *parent, int x, int y) @@ -100,7 +445,61 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, int wxFileDialog::ShowModal() { - // TODO + if ( m_dialogStyle & wxSAVE ) + { + StandardFileReply reply ; + Str255 prompt ; + Str255 filename ; + + strcpy((char *)prompt, m_message) ; + c2pstr((char *)prompt ) ; + + strcpy((char *)filename, m_fileName) ; + c2pstr((char *)filename ) ; + + StandardPutFile( prompt , filename , &reply ) ; + if ( reply.sfGood == false ) + { + m_path = "" ; + return wxID_CANCEL ; + } + else + { + m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ; + return wxID_OK ; + } + } + else + { + OSType types = '????' ; + Str255 prompt ; + Str255 path ; + + strcpy((char *)prompt, m_message) ; + c2pstr((char *)prompt ) ; + + strcpy((char *)path, m_path ) ; + c2pstr((char *)path ) ; + + FileFilterYDUPP crossPlatformFileFilterUPP; + StandardFileReply reply ; + crossPlatformFileFilterUPP = + NewFileFilterYDProc(CrossPlatformFileFilter); + + ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply); + + DisposeRoutineDescriptor(crossPlatformFileFilterUPP); + if ( reply.sfGood == false ) + { + m_path = "" ; + return wxID_CANCEL ; + } + else + { + m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ; + return wxID_OK ; + } + } return wxID_CANCEL; } diff --git a/src/mac/carbon/font.cpp b/src/mac/carbon/font.cpp index 493a6a25ba..2409e1a38b 100644 --- a/src/mac/carbon/font.cpp +++ b/src/mac/carbon/font.cpp @@ -31,9 +31,10 @@ wxFontRefData::wxFontRefData() m_weight = 0; m_underlined = 0; m_faceName = ""; -/* TODO - m_hFont = 0; -*/ + + m_macFontSize = m_pointSize ; + m_macFontNum = systemFont ; + m_macFontStyle = normal ; } wxFontRefData::wxFontRefData(const wxFontRefData& data) @@ -45,9 +46,10 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data) m_weight = data.m_weight; m_underlined = data.m_underlined; m_faceName = data.m_faceName; -/* TODO - m_hFont = 0; -*/ + + m_macFontSize = m_pointSize ; + m_macFontNum = systemFont ; + m_macFontStyle = normal ; } wxFontRefData::~wxFontRefData() @@ -55,6 +57,56 @@ wxFontRefData::~wxFontRefData() // TODO: delete font data } +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( "\pHelvetica" , &m_macFontNum) ; + break ; + case wxMODERN : + ::GetFNum( "\pMonaco" , &m_macFontNum) ; + break ; + } + } + else + { + if ( m_faceName == "systemfont" ) + m_macFontNum = ::GetSysFont() ; + else if ( m_faceName == "applicationfont" ) + m_macFontNum = ::GetAppFont() ; + else + { + strcpy(wxBuffer, m_faceName); + C2PStr(wxBuffer); + ::GetFNum( (unsigned char*) wxBuffer, &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 ; +} + wxFont::wxFont() { if ( wxTheFontList ) @@ -94,8 +146,8 @@ wxFont::~wxFont() bool wxFont::RealizeResource() { - // TODO: create the font (if there is a native font object) - return FALSE; + M_FONTDATA->MacFindFont() ; + return TRUE; } void wxFont::Unshare() diff --git a/src/mac/carbon/fontdlg.cpp b/src/mac/carbon/fontdlg.cpp index 60e8e9b987..d775c24c16 100644 --- a/src/mac/carbon/fontdlg.cpp +++ b/src/mac/carbon/fontdlg.cpp @@ -14,7 +14,7 @@ #pragma implementation "fontdlg.h" #endif -#include "wx/stubs/fontdlg.h" +#include "wx/mac/fontdlg.h" #include "wx/cmndata.h" #if !USE_SHARED_LIBRARY diff --git a/src/mac/carbon/frame.cpp b/src/mac/carbon/frame.cpp index 55f1e3b72c..5a95ac9097 100644 --- a/src/mac/carbon/frame.cpp +++ b/src/mac/carbon/frame.cpp @@ -23,6 +23,8 @@ #include "wx/settings.h" #include "wx/app.h" +#include + extern wxList wxModelessWindows; extern wxList wxPendingDelete; @@ -47,7 +49,11 @@ bool wxFrame::m_useNativeStatusBar = FALSE; wxFrame::wxFrame() { +#if wxUSE_TOOLBAR m_frameToolBar = NULL ; +#endif + m_macShown = false ; + // in order to be able to give size events on show m_frameMenuBar = NULL; m_frameStatusBar = NULL; @@ -69,7 +75,10 @@ bool wxFrame::Create(wxWindow *parent, SetName(name); m_windowStyle = style; m_frameMenuBar = NULL; + +#if wxUSE_TOOLBAR m_frameToolBar = NULL ; +#endif m_frameStatusBar = NULL; SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); @@ -83,9 +92,63 @@ bool wxFrame::Create(wxWindow *parent, wxModelessWindows.Append(this); - // TODO: create frame. - - return 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; + if (m_width == -1) + m_width = 20; + m_height = size.y; + if (m_height == -1) + m_height = 20; + + m_macWindowData = new MacWindowData() ; + + ::SetRect(&theBoundsRect, m_x, m_y, m_x + m_width, m_y + m_height); + + WindowClass wclass = kDocumentWindowClass ; + WindowAttributes attr = kWindowNoAttributes ; + + if ( ( m_windowStyle & wxMINIMIZE_BOX ) || ( m_windowStyle & wxMAXIMIZE_BOX ) ) + { + attr |= kWindowFullZoomAttribute ; + attr |= kWindowResizableAttribute ; + } + if ( m_windowStyle & wxSTAY_ON_TOP ) + { + wclass = kFloatingWindowClass ; + +// if ( m_windowStyle & wxCAPTION ) +// attr |= kHasPaletteTitlebarMask ; + } + else + { + } + if ( m_windowStyle & wxSYSTEM_MENU ) + { + attr |= kWindowCloseBoxAttribute ; + } + UMACreateNewWindow( wclass , attr , &theBoundsRect , &m_macWindowData->m_macWindow ) ; + wxAssociateWinWithMacWindow( m_macWindowData->m_macWindow , this ) ; + wxString label ; + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( title ) ; + else + label = title ; + UMASetWTitleC( m_macWindowData->m_macWindow , label ) ; + UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ; + m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; + m_macWindowData->m_macFocus = NULL ; + m_macShown = false ; + return TRUE; } wxFrame::~wxFrame() @@ -105,46 +168,13 @@ wxFrame::~wxFrame() if (wxTheApp->GetExitOnFrameDelete()) { - // TODO signal to the app that we're going to close + wxTheApp->ExitMainLoop() ; } } wxModelessWindows.DeleteObject(this); } -// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. -void wxFrame::GetClientSize(int *x, int *y) const -{ - // TODO -} - -// Set the client size (i.e. leave the calculation of borders etc. -// to wxWindows) -void wxFrame::SetClientSize(int width, int height) -{ - // TODO -} - -void wxFrame::GetSize(int *width, int *height) const -{ - // TODO -} - -void wxFrame::GetPosition(int *x, int *y) const -{ - // TODO -} - -void wxFrame::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO -} - -bool wxFrame::Show(bool show) -{ - // TODO - return FALSE; -} void wxFrame::Iconize(bool iconize) { @@ -170,17 +200,6 @@ bool wxFrame::IsMaximized(void) const return FALSE; } -void wxFrame::SetTitle(const wxString& title) -{ - // TODO -} - -wxString wxFrame::GetTitle() const -{ - // TODO - return wxString(""); -} - void wxFrame::SetIcon(const wxIcon& icon) { m_icon = icon; @@ -192,10 +211,12 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, { wxStatusBar *statusBar = NULL; - statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), + statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 17), style, name); // Set the height according to the font and the border size + // we shouldn't do this on the mac, because we have to fit the grow box + /* wxClientDC dc(statusBar); dc.SetFont(statusBar->GetFont()); @@ -206,6 +227,8 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, statusBar->SetSize(-1, -1, 100, height); + */ + statusBar->SetFieldsCount(number); return statusBar; } @@ -245,6 +268,8 @@ void wxFrame::SetStatusWidths(int n, const int widths_field[]) void wxFrame::PositionStatusBar() { + if (m_frameStatusBar ) + { int w, h; GetClientSize(&w, &h); int sw, sh; @@ -253,6 +278,7 @@ void wxFrame::PositionStatusBar() // 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); + } } void wxFrame::SetMenuBar(wxMenuBar *menuBar) @@ -264,8 +290,8 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) } m_frameMenuBar = menuBar; - - // TODO + // TODO : we move this into the app code + m_frameMenuBar->MacInstallMenuBar() ; } void wxFrame::Fit() @@ -333,8 +359,12 @@ void wxFrame::OnSize(wxSizeEvent& event) wxWindow *win = (wxWindow *)node->Data(); if ( !win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)) && - (win != GetStatusBar()) && - (win != GetToolBar()) ) + (win != GetStatusBar()) +#if wxUSE_TOOLBAR + && + (win != GetToolBar()) +#endif + ) { if ( child ) return; // it's our second subwindow - nothing to do @@ -410,21 +440,6 @@ wxMenuBar *wxFrame::GetMenuBar() const return m_frameMenuBar; } -void wxFrame::Centre(int direction) -{ - int display_width, display_height, width, height, x, y; - wxDisplaySize(&display_width, &display_height); - - GetSize(&width, &height); - GetPosition(&x, &y); - - if (direction & wxHORIZONTAL) - x = (int)((display_width - width)/2); - if (direction & wxVERTICAL) - y = (int)((display_height - height)/2); - - SetSize(x, y, width, height); -} // Call this to simulate a menu command void wxFrame::Command(int id) @@ -434,7 +449,7 @@ void wxFrame::Command(int id) void wxFrame::ProcessCommand(int id) { - wxCommandEvent commandEvent(wxEVENT_TYPE_MENU_COMMAND, id); + wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); commandEvent.SetInt( id ); commandEvent.SetEventObject( this ); @@ -450,18 +465,14 @@ void wxFrame::ProcessCommand(int id) } */ - // Process events starting with the window with the focus, if any. - wxWindow* focusWin = wxFindFocusDescendant(this); - - wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler(); - - evtHandler->ProcessEvent(commandEvent); + GetEventHandler()->ProcessEvent(commandEvent); } // Checks if there is a toolbar, and returns the first free client position wxPoint wxFrame::GetClientAreaOrigin() const { wxPoint pt(0, 0); +#if wxUSE_TOOLBAR if (GetToolBar()) { int w, h; @@ -476,33 +487,46 @@ wxPoint wxFrame::GetClientAreaOrigin() const pt.y += h; } } +#endif return pt; } -void wxFrame::ScreenToClient(int *x, int *y) const +void wxFrame::GetClientSize(int *x, int *y) const { - wxWindow::ScreenToClient(x, y); - - // We may be faking the client origin. - // So a window that's really at (0, 30) may appear - // (to wxWin apps) to be at (0, 0). - wxPoint pt(GetClientAreaOrigin()); - *x -= pt.x; - *y -= pt.y; + wxWindow::GetClientSize( x , y ) ; + + if ( GetStatusBar() ) + { + int statusX, statusY; + GetStatusBar()->GetClientSize(&statusX, &statusY); + *y -= statusY; + } + + wxPoint pt(GetClientAreaOrigin()); + *y -= pt.y; + *x -= pt.x; } -void wxFrame::ClientToScreen(int *x, int *y) const +void wxFrame::DoSetClientSize(int clientwidth, int clientheight) { - // We may be faking the client origin. - // So a window that's really at (0, 30) may appear - // (to wxWin apps) to be at (0, 0). - wxPoint pt1(GetClientAreaOrigin()); - *x += pt1.x; - *y += pt1.y; - - wxWindow::ClientToScreen(x, y); + 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 ) ; } + +#if wxUSE_TOOLBAR wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { wxCHECK_MSG( m_frameToolBar == NULL, FALSE, @@ -534,7 +558,10 @@ void wxFrame::PositionToolBar() // the toolbar/status bar were added. // So DEFINITELY replace the line below with something appropriate. - GetClientSize(& cw, &ch); + // GetClientSize(& cw, &ch); + + cw = m_width ; + ch = m_height ; if ( GetStatusBar() ) { @@ -562,4 +589,4 @@ void wxFrame::PositionToolBar() } } } - +#endif diff --git a/src/mac/carbon/gauge.cpp b/src/mac/carbon/gauge.cpp index a85fbc498f..7dc3b5e813 100644 --- a/src/mac/carbon/gauge.cpp +++ b/src/mac/carbon/gauge.cpp @@ -19,67 +19,65 @@ IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl) #endif +#include + bool wxGauge::Create(wxWindow *parent, wxWindowID id, int range, const wxPoint& pos, - const wxSize& size, + const wxSize& s, long style, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - m_rangeMax = range; - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - - // TODO - return FALSE; -} - -void wxGauge::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + wxSize size = s ; + Rect bounds ; + Str255 title ; + m_rangeMax = range ; + m_macHorizontalBorder = 2 ; // additional pixels around the real control + m_macVerticalBorder = 2 ; + + if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y) + { + size = wxSize( 200 , 16 ) ; + } + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , range, + kControlProgressBarProc , (long) this ) ; + + MacPostControlCreate() ; + + return TRUE; } void wxGauge::SetShadowWidth(int w) { - // TODO optional } void wxGauge::SetBezelFace(int w) { - // TODO optional } void wxGauge::SetRange(int r) { m_rangeMax = r; - // TODO + ::SetControlMaximum( m_macControl , m_rangeMax ) ; } void wxGauge::SetValue(int pos) { m_gaugePos = pos; - // TODO + ::SetControlValue( m_macControl , m_gaugePos ) ; } int wxGauge::GetShadowWidth() const { - // TODO optional return 0; } int wxGauge::GetBezelFace() const { - // TODO optional return 0; } diff --git a/src/mac/carbon/icon.cpp b/src/mac/carbon/icon.cpp index 6deee7dbdc..537165343e 100644 --- a/src/mac/carbon/icon.cpp +++ b/src/mac/carbon/icon.cpp @@ -26,12 +26,30 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) wxIconRefData::wxIconRefData() { - // TODO: init icon handle + m_ok = FALSE; + m_width = 0; + m_height = 0; + m_depth = 0; + m_quality = 0; + m_numColors = 0; + m_bitmapMask = NULL; + m_hBitmap = NULL ; + m_hIcon = NULL ; } wxIconRefData::~wxIconRefData() { - // TODO: destroy icon handle + if ( m_hIcon ) + { + DisposeCIcon( m_hIcon ) ; + m_hIcon = NULL ; + } + + if (m_bitmapMask) + { + delete m_bitmapMask; + m_bitmapMask = NULL; + } } wxIcon::wxIcon() @@ -68,3 +86,32 @@ bool wxIcon::LoadFile(const wxString& filename, long type, return FALSE; } +IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler) + +bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ + Str255 theName ; + short theId ; + OSType theType ; + strcpy( (char*) theName , name ) ; + c2pstr( (char*) theName ) ; + + Handle resHandle = GetNamedResource( 'cicn' , theName ) ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + + CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ; + if ( theIcon ) + { + M_ICONHANDLERDATA->m_hIcon = theIcon ; + M_ICONHANDLERDATA->m_width = 32 ; + M_ICONHANDLERDATA->m_height = 32 ; + + M_ICONHANDLERDATA->m_depth = 8 ; + M_ICONHANDLERDATA->m_ok = true ; + M_ICONHANDLERDATA->m_numColors = 256 ; + return TRUE ; + } + return FALSE ; +} \ No newline at end of file diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 1dad21e12c..e17f1b8213 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -18,10 +18,22 @@ #include "wx/dynarray.h" #include "wx/log.h" +#include "wx/utils.h" +#include "extldef.h" + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) + +BEGIN_EVENT_TABLE(wxListBox, wxControl) + EVT_SIZE( wxListBox::OnSize ) +END_EVENT_TABLE() #endif +#include + +extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ; +const short kwxMacListWithVerticalScrollbar = 128 ; + // ============================================================================ // list box control implementation // ============================================================================ @@ -41,111 +53,197 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_noItems = n; + m_noItems = 0 ; // this will be increased by our append command m_selected = 0; - SetName(name); - SetValidator(validator); - - if (parent) parent->AddChild(this); - - wxSystemSettings settings; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); - - m_windowId = ( id == -1 ) ? (int)NewControlId() : id; - - // TODO create listbox - - return FALSE; + Rect bounds ; + Str255 title ; + m_macHorizontalBorder = 5 ; // additional pixels around the real control + m_macVerticalBorder = 5 ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , kwxMacListWithVerticalScrollbar , 0 , 0, + kControlListBoxProc , (long) this ) ; + + long result ; + UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; + + NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ; + (**m_macList).selFlags = lOnlyOne ; + if ( style & wxLB_MULTIPLE ) + { + (**m_macList).selFlags += lNoExtend ; + } + else if ( style & wxLB_EXTENDED ) + { + (**m_macList).selFlags += lExtendDrag ; + } + Point pt = (**m_macList).cellSize ; + pt.v = 14 ; + LCellSize( pt , m_macList ) ; + + LAddColumn( 1 , 0 , m_macList ) ; + + MacPostControlCreate() ; + + ControlFontStyleRec controlstyle ; + controlstyle.flags = kControlUseFontMask + kControlUseSizeMask ; + //controlstyle.font = kControlFontSmallSystemFont ; + controlstyle.font = kFontIDMonaco ; + controlstyle.size = 9 ; + ::UMASetControlFontStyle( m_macControl , &controlstyle ) ; + + for ( int i = 0 ; i < n ; i++ ) + { + Append( choices[i] ) ; + } + + LSetDrawingMode( true , m_macList ) ; + + return TRUE; } wxListBox::~wxListBox() { +// DisposeExtLDEFInfo( m_macList ) ; } void wxListBox::SetFirstItem(int N) { - // TODO + MacScrollTo( N ) ; } void wxListBox::SetFirstItem(const wxString& s) { - // TODO + MacScrollTo( FindString( s ) ) ; } void wxListBox::Delete(int N) { - m_noItems --; - // TODO + m_dataArray.Remove( N ) ; + m_stringArray.Remove( N ) ; + m_noItems --; + + MacDelete( N ) ; } void wxListBox::Append(const wxString& item) { - m_noItems ++; - - // TODO + Append( item , NULL ) ; } void wxListBox::Append(const wxString& item, char *Client_data) { - m_noItems ++; - - // TODO + if( wxApp::s_macDefaultEncodingIsPC ) + { + m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ; + } + else + m_stringArray.Add( item ) ; + m_dataArray.Add( Client_data ) ; + m_noItems ++; + + MacAppend( item ) ; } void wxListBox::Set(int n, const wxString *choices, char** clientData) { - m_noItems = n; - - // TODO + Clear() ; + for( int i = 0 ; i < n ; ++i ) + { + if ( clientData ) + Append( choices[i] , clientData[0] ) ; + else + Append( choices[i] ) ; + } } -int wxListBox::FindString(const wxString& s) const +int wxListBox::FindString(const wxString& st) const { - // TODO - return -1; + wxString s ; + if( wxApp::s_macDefaultEncodingIsPC ) + { + s = wxMacMakeMacStringFromPC( st ) ; + } + else + s = st ; + + if ( s.Right(1) == "*" ) + { + wxString search = s.Left( s.Length() - 1 ) ; + int len = search.Length() ; + for ( int i = 0 ; i < m_noItems ; ++ i ) + { + if ( equalstring( m_stringArray[i].Left( len ) , search , false , false ) ) + return i ; + } + } + else + { + for ( int i = 0 ; i < m_noItems ; ++ i ) + { + if ( equalstring( m_stringArray[i] , s , false , false ) ) + return i ; + } + } + return -1; } void wxListBox::Clear() { m_noItems = 0; - // TODO + m_stringArray.Empty() ; + m_dataArray.Empty() ; + MacClear() ; } void wxListBox::SetSelection(int N, bool select) { - // TODO + wxCHECK_RET( N >= 0 && N < m_noItems, + "invalid index in wxListBox::SetSelection" ); + MacSetSelection( N , select ) ; } bool wxListBox::Selected(int N) const { - // TODO - return FALSE; + wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE, + "invalid index in wxListBox::Selected" ); + + return MacIsSelected( N ) ; } void wxListBox::Deselect(int N) { - // TODO + wxCHECK_RET( N >= 0 && N < m_noItems, + "invalid index in wxListBox::Deselect" ); + + SetSelection( N , false ) ; } char *wxListBox::GetClientData(int N) const { - // TODO - return (char *)NULL; + wxCHECK_MSG( N >= 0 && N < m_noItems, NULL, + "invalid index in wxListBox::GetClientData" ); + + return m_dataArray[N]; } void wxListBox::SetClientData(int N, char *Client_data) { - // TODO + wxCHECK_RET( N >= 0 && N < m_noItems, + "invalid index in wxListBox::SetClientData" ); + + m_dataArray[N] = Client_data ; } // Return number of selections and an array of selected integers int wxListBox::GetSelections(wxArrayInt& aSelections) const { - aSelections.Empty(); + return MacGetSelections( aSelections ) ; /* TODO - if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED)) + if ((m_windowStyle & wxLB_MULTIMacE) || (m_windowStyle & wxLB_EXTENDED)) { int no_sel = ?? for ( int n = 0; n < no_sel; n++ ) @@ -160,38 +258,41 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const return 1; } */ - return 0; } // Get single selection, for single choice list items int wxListBox::GetSelection() const { - // TODO - return -1; + return MacGetSelection() ; } // Find string for position wxString wxListBox::GetString(int N) const { - // TODO - return wxString(""); -} - -void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + if( wxApp::s_macDefaultEncodingIsPC ) + { + return wxMacMakePCStringFromMac( m_stringArray[N] ) ; + } + else + return m_stringArray[N] ; } void wxListBox::InsertItems(int nItems, const wxString items[], int pos) { - m_noItems += nItems; + 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] ) ; + } - // TODO + m_noItems += nItems; } void wxListBox::SetString(int N, const wxString& s) { - // TODO + m_stringArray[N] = s ; + MacSet( N , s ) ; } int wxListBox::Number () const @@ -204,7 +305,9 @@ wxString wxListBox::GetStringSelection () const { int sel = GetSelection (); if (sel > -1) - return this->GetString (sel); + { + return GetString (sel); + } else return wxString(""); } @@ -233,3 +336,182 @@ void wxListBox::Command (wxCommandEvent & event) ProcessCommand (event); } +// ============================================================================ +// list box control implementation +// ============================================================================ + +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()); + +} + +void wxListBox::MacDelete( int N ) +{ + ListHandle list ; + long result ; + Cell cell = { 0 , 0 } ; + UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &list , &result ) ; + LDelRow( 1 , N , list ) ; +} + +void wxListBox::MacInsert( int n , const char * text) +{ + Cell cell ; + + cell.h = 0 ; + cell.v = n ; + + LAddRow( 1 , cell.v , m_macList ) ; +} + +void wxListBox::MacAppend( const char * text) +{ + Cell cell = { 0 , 0 } ; + cell.v = (**m_macList).dataBounds.bottom ; + LAddRow( 1 , cell.v , m_macList ) ; +} + +void wxListBox::MacClear() +{ + LDelRow( (**m_macList).dataBounds.bottom , 0 , m_macList ) ; +} + +void wxListBox::MacSetSelection( int n , bool select ) +{ + Cell cell = { 0 , 0 } ; + if ( LGetSelect( TRUE , &cell , m_macList ) ) + { + LSetSelect( false , cell , m_macList ) ; + } + + cell.v = n ; + LSetSelect( select , cell , m_macList ) ; + LAutoScroll( m_macList ) ; +} + +bool wxListBox::MacIsSelected( int n ) const +{ + Cell cell = { 0 , 0 } ; + cell.v = n ; + return LGetSelect( false , &cell , m_macList ) ; +} + +void wxListBox::MacDestroy() +{ +// DisposeExtLDEFInfo( m_macList ) ; +} + +int wxListBox::MacGetSelection() const +{ + Cell cell = { 0 , 0 } ; + if ( LGetSelect( true , &cell , m_macList ) ) + return cell.v ; + else + return -1 ; +} + +int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const +{ + int no_sel = 0 ; + + aSelections.Empty(); + + Cell cell = { 0 , 0 } ; + cell.v = 0 ; + + while ( LGetSelect( true , &cell , m_macList ) ) + { + aSelections.Add( cell.v ) ; + no_sel++ ; + cell.v++ ; + } + return no_sel ; +} + +void wxListBox::MacSet( int n , const char * text ) +{ + // our implementation does not store anything in the list + // so we just have to redraw + Cell cell = { 0 , 0 } ; + cell.v = n ; + LDraw( cell , m_macList ) ; +} + +void wxListBox::MacScrollTo( int n ) +{ + // TODO implement scrolling +} + +void wxListBox::OnSize( const wxSizeEvent &event) +{ + Point pt = (**m_macList).cellSize ; + pt.h = m_width - 15 /* scrollbar */ - m_macHorizontalBorder * 2 ; + LCellSize( pt , m_macList ) ; +} + +void wxListBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + Boolean wasDoubleClick = false ; + long result ; + + UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ; + if ( !wasDoubleClick ) + { + MacDoClick() ; + } + else + { + MacDoDoubleClick() ; + } +} + +void wxListBox::MacSetRedraw( bool doDraw ) +{ + LSetDrawingMode( doDraw , m_macList ) ; + +} + +void wxListBox::MacDoClick() +{ + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); + wxArrayInt aSelections; + int count = GetSelections(aSelections); + if ( count > 0 ) + { + event.m_commandInt = aSelections[0] ; + event.m_clientData = GetClientData(event.m_commandInt); + wxString str(GetString(event.m_commandInt)); + if (str != "") + event.m_commandString = copystring((char *)(const char *)str); + } + else + { + return ; + /* + event.m_commandInt = -1 ; + event.m_commandString = copystring("") ; + */ + } + + event.SetEventObject( this ); + ProcessCommand(event); + if (event.m_commandString) + delete[] event.m_commandString ; +} + +void wxListBox::MacDoDoubleClick() +{ + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event) ; +} diff --git a/src/mac/carbon/makefile.unx b/src/mac/carbon/makefile.unx index d5d55d86d4..5bd62163fd 100644 --- a/src/mac/carbon/makefile.unx +++ b/src/mac/carbon/makefile.unx @@ -62,7 +62,6 @@ LIB_CPP_SRC=\ ../common/variant.cpp \ ../common/wxexpr.cpp \ ../common/socket.cpp \ - ../common/sckint.cpp \ ../common/sckaddr.cpp \ ../common/sckipc.cpp \ ../common/protocol.cpp \ diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index 1fc7c4a229..b22001b870 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -27,6 +27,8 @@ #include "wx/log.h" #include "wx/utils.h" +#include "wx/mac/uma.h" + // other standard headers // ---------------------- #include @@ -36,13 +38,146 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler) #endif +// the (popup) menu title has this special id +static const int idMenuTitle = -2; +static int formerHelpMenuItems = 0 ; + +const short kwxMacMenuBarResource = 1 ; +const short kwxMacAppleMenuId = 1 ; + // ============================================================================ // implementation // ============================================================================ +// +// Helper Functions to get Mac Menus the way they should be ;-) +// + +void wxMacCtoPString(const char* theCString, Str255 thePString); + +// remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut + +static void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts ) +{ + char *p = (char *) &outMacItemText[1] ; + short macModifiers = 0 ; + char macShortCut = 0 ; + + if ( useShortcuts && !wxApp::s_macSupportPCMenuShortcuts ) + useShortcuts = false ; + + // we have problems with a leading hypen - it will be taken as a separator + + while ( *inItemName == '-' ) + inItemName++ ; + + while( *inItemName ) + { + switch ( *inItemName ) + { + // special characters for macintosh menus -> use some replacement + case ';' : + *p++ = ',' ; + break ; + case '^' : + *p++ = ' ' ; + break ; + case '!' : + *p++ = ' ' ; + break ; + case '<' : + *p++ = ' ' ; + break ; + case '/' : + *p++ = '|' ; + break ; + case '(' : + *p++ = '[' ; + break ; + case ')' : + *p++ = ']' ; + break ; + // shortcuts + case '&' : + { + ++inItemName ; + if ( *inItemName ) + { + *p++ = *inItemName ; + if ( useShortcuts ) + macShortCut = *inItemName ; + } + else + --inItemName ; + } + break ; + // win-like accelerators + case '\t' : + { + ++inItemName ; + while( *inItemName ) + { + if (strncmp("Ctrl+", inItemName, 5) == 0) + { + inItemName = inItemName + 5; + macShortCut = *inItemName; + } + else if (strncmp("Alt+", inItemName, 4) == 0) + { + inItemName = inItemName + 4; + macModifiers |= kMenuOptionModifier ; + macShortCut = *inItemName ; + } + else if (strncmp("Shift+", inItemName, 6) == 0) + { + inItemName = inItemName + 6; + macModifiers |= kMenuShiftModifier ; + macShortCut = *inItemName ; + } + else if (strncmp("F", inItemName, 1) == 0) + { + inItemName += strlen( inItemName ) ; + // no function keys at the moment + // macModifiers |= kMenuShiftModifier ; + // macShortCut = *inItemName ; + } + else + { + break ; + } + } + + if ( *inItemName == 0 ) + --inItemName ; + + } + break ; + default : + *p++ = *inItemName ; + } + ++inItemName ; + } + + outMacItemText[0] = (p - (char *)outMacItemText) - 1; + if ( outMacShortcutChar ) + *outMacShortcutChar = macShortCut ; + if ( outMacModifiers ) + *outMacModifiers = macModifiers ; + if ( macShortCut ) + { + int pos = outMacItemText[0] ; + outMacItemText[++pos] = '/'; + outMacItemText[++pos] = toupper( macShortCut ); + outMacItemText[0] = pos ; + } +} + // Menus // Construct a menu with optional title (then use append) + +short wxMenu::s_macNextMenuId = 2 ; + wxMenu::wxMenu(const wxString& title, const wxFunction func) { m_title = title; @@ -50,23 +185,27 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func) m_eventHandler = this; m_noItems = 0; m_menuBar = NULL; + m_pInvokingWindow = NULL ; m_clientData = (void*) NULL; if (m_title != "") { - Append(-2, m_title) ; + Append(idMenuTitle, m_title) ; AppendSeparator() ; } Callback(func); - // TODO create menu + Str255 label; + wxMacBuildMenuString( label, NULL , NULL , title , false ); + m_macMenuId = s_macNextMenuId++; + wxCHECK_RET( s_macNextMenuId < 236 , "menu ids > 235 cannot be used for submenus on mac" ); + m_macMenuHandle = ::NewMenu(m_macMenuId, label); + m_macMenuEnabled = true ; } // The wxWindow destructor will take care of deleting the submenus. wxMenu::~wxMenu() { - // TODO destroy menu and children - wxNode *node = m_menuItems.First(); while (node) { @@ -83,28 +222,78 @@ wxMenu::~wxMenu() delete node; node = next; } + if (m_macMenuHandle) + ::DisposeMenu(m_macMenuHandle); } void wxMenu::Break() { - // TODO + // not available on the mac platform } // function appends a new item or submenu to the menu void wxMenu::Append(wxMenuItem *pItem) { - // TODO - wxCHECK_RET( pItem != NULL, "can't append NULL item to the menu" ); m_menuItems.Append(pItem); + if ( pItem->IsSeparator() ) + { + MacAppendMenu(m_macMenuHandle, "\p-"); + } + else + { + wxMenu *pSubMenu = pItem->GetSubMenu() ; + if ( pSubMenu != NULL ) + { + Str255 label; + wxCHECK_RET( pSubMenu->m_macMenuHandle != NULL , "invalid submenu added"); + pSubMenu->m_parent = this ; + wxMacBuildMenuString( label , NULL , NULL , pItem->GetName() ,false); + + // hardcoded adding of the submenu combination for mac + + int theEnd = label[0] + 1; + if (theEnd > 251) + theEnd = 251; // mac allows only 255 characters + label[theEnd++] = '/'; + label[theEnd++] = hMenuCmd; + label[theEnd++] = '!'; + label[theEnd++] = pSubMenu->m_macMenuId; + label[theEnd] = 0x00; + label[0] = theEnd; + + if (wxMenuBar::s_macInstalledMenuBar == m_menuBar) + { + ::InsertMenu( pSubMenu->m_macMenuHandle , -1 ) ; + } + + ::AppendMenu(m_macMenuHandle, label); + } + else + { + Str255 label ; + wxMacBuildMenuString( label , NULL , NULL , pItem->GetName(), pItem->GetId() == wxApp::s_macAboutMenuItemId); + if ( label[0] == 0 ) + { + // we cannot add empty menus on mac + label[0] = 1 ; + label[1] = ' ' ; + } + ::AppendMenu(m_macMenuHandle, label ); + if ( pItem->GetId() == idMenuTitle ) + { + UMADisableMenuItem( m_macMenuHandle , CountMItems( m_macMenuHandle ) ) ; + } + } + } + m_noItems++; } void wxMenu::AppendSeparator() { - // TODO Append(new wxMenuItem(this, ID_SEPARATOR)); } @@ -136,12 +325,31 @@ void wxMenu::Delete(int id) } if (!node) - return; + return; + + int index = pos + 1 ; + + if (index < 1) + return; + + wxMenu *pSubMenu = item->GetSubMenu(); + if ( pSubMenu != NULL ) + { + ::DeleteMenuItem( m_macMenuHandle , index); + pSubMenu->m_parent = NULL; + // TODO: Why isn't subMenu deleted here??? + // Will put this in for now. Assuming this is supposed + // to delete the menu, not just remove it. + item->DeleteSubMenu(); + } + else + { + ::DeleteMenuItem( m_macMenuHandle , index); + } m_menuItems.DeleteNode(node); + // TODO shouldn't we do this ? Ž_m_noItems--; delete item; - - // TODO } void wxMenu::Enable(int Id, bool Flag) @@ -178,8 +386,16 @@ bool wxMenu::Checked(int Id) const void wxMenu::SetTitle(const wxString& label) { + Str255 title ; m_title = label ; - // TODO + wxMacBuildMenuString( title, NULL , NULL , label , false ); + UMASetMenuTitle( m_macMenuHandle , title ) ; + if (wxMenuBar::s_macInstalledMenuBar == m_menuBar) // are we currently installed ? + { + ::SetMenuBar( GetMenuBar() ) ; + ::InvalMenuBar() ; + } + // TODO:for submenus -> their parent item text must be corrected } const wxString wxMenu::GetTitle() const @@ -189,25 +405,33 @@ const wxString wxMenu::GetTitle() const void wxMenu::SetLabel(int id, const wxString& label) { + Str255 maclabel ; + int index ; wxMenuItem *item = FindItemForId(id) ; if (item==NULL) return; + index = MacGetIndexFromItem( item ) ; + if (index < 1) + return; + if (item->GetSubMenu()==NULL) { - // TODO + wxMacBuildMenuString( maclabel , NULL , NULL , label , false ); + ::SetMenuItemText( m_macMenuHandle , index , maclabel ) ; } else { - // TODO + wxMacBuildMenuString( maclabel , NULL , NULL , label , false ); + ::SetMenuItemText( m_macMenuHandle , index , maclabel ) ; } item->SetName(label); } wxString wxMenu::GetLabel(int Id) const { - // TODO - return wxString("") ; + wxMenuItem *pItem = FindItemForId(Id) ; + return pItem->GetName() ; } // Finds the item id matching the given string, -1 if not found. @@ -295,21 +519,204 @@ void wxMenu::ProcessCommand(wxCommandEvent & event) { processed = GetEventHandler()->ProcessEvent(event); } -/* TODO - // Try the window the menu was popped up from (and up - // through the hierarchy) - if ( !processed && GetInvokingWindow()) - processed = GetInvokingWindow()->ProcessEvent(event); -*/ + + // Try the window the menu was popped up from (and up + // through the hierarchy) + if ( !processed && GetInvokingWindow()) + processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event); } bool wxWindow::PopupMenu(wxMenu *menu, int x, int y) { - // TODO - return FALSE; + menu->SetInvokingWindow(this); + ClientToScreen( &x , &y ) ; + + ::InsertMenu( menu->m_macMenuHandle , -1 ) ; + long menuResult = ::PopUpMenuSelect(menu->m_macMenuHandle ,y,x, 0) ; + menu->MacMenuSelect( this , TickCount() , HiWord(menuResult) , LoWord(menuResult) ) ; + ::DeleteMenu( menu->m_macMenuId ) ; + menu->SetInvokingWindow(NULL); + + return TRUE; +} + +// helper functions returning the mac menu position for a certain item, note that this is +// mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0 + +int wxMenu::MacGetIndexFromId( int id ) +{ + wxNode *node; + wxMenuItem *item; + int pos; + + for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) + { + item = (wxMenuItem *)node->Data(); + if (item->GetId() == id) + break; + } + + if (!node) + return 0; + + return pos + 1 ; +} + +int wxMenu::MacGetIndexFromItem( wxMenuItem *pItem ) +{ + wxNode *node; + int pos; + + for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) + { + if ((wxMenuItem *)node->Data() == pItem) + break; + } + + if (!node) + return 0; + + return pos + 1 ; +} + +void wxMenu::MacEnableMenu( bool bDoEnable ) +{ + m_macMenuEnabled = bDoEnable ; + if ( bDoEnable ) + UMAEnableMenuItem( m_macMenuHandle , 0 ) ; + else + UMADisableMenuItem( m_macMenuHandle , 0 ) ; + + ::DrawMenuBar() ; +} + +bool wxMenu::MacMenuSelect( wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum ) +{ + int pos; + wxNode *node; + + if ( m_macMenuId == macMenuId ) + { + node = m_menuItems.Nth(macMenuItemNum-1); + if (node) + { + wxMenuItem *pItem = (wxMenuItem*)node->Data(); + + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, pItem->GetId()); + event.m_timeStamp = when; + event.SetEventObject(handler); + event.SetInt( pItem->GetId() ); + + { + bool processed = false ; + + // Try a callback + if (m_callback) + { + (void) (*(m_callback)) (*this, event); + processed = TRUE; + } + + // Try the menu's event handler + if ( !processed && handler) + { + processed = handler->ProcessEvent(event); + } + + // Try the window the menu was popped up from (and up + // through the hierarchy) + if ( !processed && GetInvokingWindow()) + processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event); + } + return true ; + } + } + else if ( macMenuId == kHMHelpMenuID ) + { + int menuItem = formerHelpMenuItems ; + for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) + { + wxMenuItem * pItem = (wxMenuItem *) node->Data() ; + + wxMenu *pSubMenu = pItem->GetSubMenu() ; + if ( pSubMenu != NULL ) + { + } + else + { + if ( pItem->GetId() != wxApp::s_macAboutMenuItemId ) + ++menuItem ; + + if ( menuItem == macMenuItemNum ) + { + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, pItem->GetId()); + event.m_timeStamp = when; + event.SetEventObject(handler); + event.SetInt( pItem->GetId() ); + + { + bool processed = false ; + // Try a callback + if (m_callback) + { + (void) (*(m_callback)) (*this, event); + processed = TRUE; + } + + // Try the menu's event handler + if ( !processed && handler) + { + processed = handler->ProcessEvent(event); + } + + // Try the window the menu was popped up from (and up + // through the hierarchy) + if ( !processed && GetInvokingWindow()) + processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event); + } + + return true ; + } + } + } + } + + for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) + { + wxMenuItem * pItem = (wxMenuItem *) node->Data() ; + + wxMenu *pSubMenu = pItem->GetSubMenu() ; + if ( pSubMenu != NULL ) + { + if ( pSubMenu->MacMenuSelect( handler , when , macMenuId , macMenuItemNum ) ) + return true ; + } + } + + return false ; } // Menu Bar + +/* + +Mac Implementation note : + +The Mac has only one global menubar, so we attempt to install the currently +active menubar from a frame, we currently don't take into account mdi-frames +which would ask for menu-merging + +Secondly there is no mac api for changing a menubar that is not the current +menubar, so we have to wait for preparing the actual menubar until the +wxMenubar is to be used + +We can in subsequent versions use MacInstallMenuBar to provide some sort of +auto-merge for MDI in case this will be necessary + +*/ + +wxMenuBar* wxMenuBar::s_macInstalledMenuBar = NULL ; + wxMenuBar::wxMenuBar() { m_eventHandler = this; @@ -317,8 +724,6 @@ wxMenuBar::wxMenuBar() m_menus = NULL; m_titles = NULL; m_menuBarFrame = NULL; - - // TODO } wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[]) @@ -329,14 +734,18 @@ wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[]) m_titles = new wxString[n]; int i; for ( i = 0; i < n; i++ ) - m_titles[i] = titles[i]; + m_titles[i] = titles[i]; m_menuBarFrame = NULL; - - // TODO } wxMenuBar::~wxMenuBar() { + if (s_macInstalledMenuBar == this) + { + ::ClearMenuBar(); + s_macInstalledMenuBar = NULL; + } + int i; for (i = 0; i < m_menuCount; i++) { @@ -345,9 +754,95 @@ wxMenuBar::~wxMenuBar() delete[] m_menus; delete[] m_titles; - // TODO } +void wxMenuBar::MacInstallMenuBar() +{ + Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ; + wxString message ; + wxCHECK_RET( menubar != NULL, "can't read MBAR resource" ); + ::SetMenuBar( menubar ) ; + ::DisposeHandle( menubar ) ; + + MenuHandle menu = ::GetMenuHandle( kwxMacAppleMenuId ) ; + ::AppendResMenu(menu, 'DRVR'); + + for (int i = 0; i < m_menuCount; i++) + { + Str255 label; + wxNode *node; + wxMenuItem *item; + int pos ; + wxMenu* menu = m_menus[i] , *subMenu = NULL ; + + + if( m_titles[i] == "?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) + { + MenuHandle mh = NULL ; + if ( HMGetHelpMenuHandle( &mh ) != noErr ) + { + continue ; + } + if ( formerHelpMenuItems == 0 ) + { + if( mh ) + formerHelpMenuItems = CountMenuItems( mh ) ; + } + + for (pos = 0 , node = menu->m_menuItems.First(); node; node = node->Next(), pos++) + { + item = (wxMenuItem *)node->Data(); + subMenu = item->GetSubMenu() ; + if (subMenu) + { + // we don't support hierarchical menus in the help menu yet + } + else + { + Str255 label ; + wxMacBuildMenuString( label , NULL , NULL , item->GetName(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu + if ( label[0] == 0 ) + { + // we cannot add empty menus on mac + label[0] = 1 ; + label[1] = ' ' ; + } + if ( item->GetId() == wxApp::s_macAboutMenuItemId ) + { + ::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label ); + // ::EnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 ); + ::EnableItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 ); + } + else + { + if ( mh ) + ::AppendMenu(mh, label ); + } + } + } + } + else + { + wxMacBuildMenuString( label, NULL , NULL , m_titles[i] , false ); + UMASetMenuTitle( menu->m_macMenuHandle , label ) ; + for (pos = 0, node = menu->m_menuItems.First(); node; node = node->Next(), pos++) + { + item = (wxMenuItem *)node->Data(); + subMenu = item->GetSubMenu() ; + if (subMenu) + { + ::InsertMenu( subMenu->m_macMenuHandle , -1 ) ; + } + } + ::InsertMenu(m_menus[i]->m_macMenuHandle, 0); + } + } + ::DrawMenuBar() ; + + s_macInstalledMenuBar = this; +} + + // Must only be used AFTER menu has been attached to frame, // otherwise use individual menus to enable/disable items void wxMenuBar::Enable(int id, bool flag) @@ -357,12 +852,12 @@ void wxMenuBar::Enable(int id, bool flag) if (!item) return; - // TODO + item->Enable( flag ) ; } void wxMenuBar::EnableTop(int pos, bool flag) { - // TODO + m_menus[pos]->MacEnableMenu( flag ) ; } // Must only be used AFTER menu has been attached to frame, @@ -377,7 +872,7 @@ void wxMenuBar::Check(int id, bool flag) if (!item->IsCheckable()) return ; - // TODO + item->Check( flag ) ; } bool wxMenuBar::Checked(int id) const @@ -387,8 +882,10 @@ bool wxMenuBar::Checked(int id) const if (!item) return FALSE; - // TODO - return FALSE; + if (!item->IsCheckable()) + return FALSE ; + + return item->IsChecked() ; } bool wxMenuBar::Enabled(int id) const @@ -398,8 +895,23 @@ bool wxMenuBar::Enabled(int id) const if (!item) return FALSE; - // TODO - return FALSE ; + if ( !item->IsEnabled() ) + return FALSE ; + + if ( itemMenu->m_macMenuEnabled == false ) + return FALSE ; + + while( itemMenu->m_parent ) + { + itemMenu = (wxMenu*) itemMenu->m_parent ; + if ( itemMenu->IsKindOf( CLASSINFO( wxMenu ) ) ) + { + if ( itemMenu->m_macMenuEnabled == false ) + return FALSE ; + } + } + + return TRUE ; } @@ -411,7 +923,7 @@ void wxMenuBar::SetLabel(int id, const wxString& label) if (!item) return; - // TODO + itemMenu->SetLabel( id , label ) ; } wxString wxMenuBar::GetLabel(int id) const @@ -422,31 +934,51 @@ wxString wxMenuBar::GetLabel(int id) const if (!item) return wxString(""); - // TODO - return wxString("") ; + return itemMenu->GetLabel( id ) ; } void wxMenuBar::SetLabelTop(int pos, const wxString& label) { - // TODO + m_menus[pos]->SetTitle( label ) ; } wxString wxMenuBar::GetLabelTop(int pos) const { - // TODO - return wxString(""); + return m_menus[pos]->GetTitle() ; } bool wxMenuBar::OnDelete(wxMenu *a_menu, int pos) { - // TODO - return FALSE; + if (s_macInstalledMenuBar == this) + { + ::DeleteMenu( a_menu->m_macMenuId /* m_menus[pos]->m_macMenuId */ ) ; + ::InvalMenuBar() ; + return TRUE ; + } + else + { + return TRUE ; + } } bool wxMenuBar::OnAppend(wxMenu *a_menu, const char *title) { - // TODO - return FALSE; + if (!a_menu->m_macMenuHandle) + return FALSE; + + if (s_macInstalledMenuBar == this) + { + Str255 label; + wxMacBuildMenuString( label, NULL , NULL , title , false ); + UMASetMenuTitle( a_menu->m_macMenuHandle , label ) ; + ::InsertMenu( a_menu->m_macMenuHandle , 0 ) ; + ::InvalMenuBar() ; + return TRUE ; + } + else + { + return TRUE ; + } } void wxMenuBar::Append (wxMenu * menu, const wxString& title) @@ -477,7 +1009,8 @@ void wxMenuBar::Append (wxMenu * menu, const wxString& title) m_menus[m_menuCount - 1] = (wxMenu *)menu; m_titles[m_menuCount - 1] = title; - // TODO + ((wxMenu *)menu)->m_menuBar = (wxMenuBar *) this; + ((wxMenu *)menu)->SetParent(this); } void wxMenuBar::Delete(wxMenu * menu, int i) @@ -568,4 +1101,43 @@ wxString wxMenuBar::GetHelpString (int Id) const return wxString(""); } +void wxMenuBar::MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) +{ + // first scan fast for direct commands, i.e. menus which have these commands directly in their own list + + if ( macMenuId == kwxMacAppleMenuId && macMenuItemNum == 1 ) + { + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, wxApp::s_macAboutMenuItemId ); + event.m_timeStamp = when; + event.SetEventObject(handler); + event.SetInt( wxApp::s_macAboutMenuItemId ); + handler->ProcessEvent(event); + } + else + { + for (int i = 0; i < m_menuCount; i++) + { + if ( m_menus[i]->m_macMenuId == macMenuId || + ( macMenuId == kHMHelpMenuID && ( m_titles[i] == "?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) ) + ) + { + if ( m_menus[i]->MacMenuSelect( handler , when , macMenuId , macMenuItemNum ) ) + return ; + else + { + //TODO flag this as an error since it must contain the item + return ; + } + } + } + + for (int i = 0; i < m_menuCount; i++) + { + if ( m_menus[i]->MacMenuSelect( handler , when , macMenuId , macMenuItemNum ) ) + { + break ; + } + } + } +} diff --git a/src/mac/carbon/menuitem.cpp b/src/mac/carbon/menuitem.cpp index 38d31737e7..9195fdc50a 100644 --- a/src/mac/carbon/menuitem.cpp +++ b/src/mac/carbon/menuitem.cpp @@ -16,6 +16,7 @@ #include "wx/menu.h" #include "wx/menuitem.h" +#include // ============================================================================ // implementation // ============================================================================ @@ -49,6 +50,11 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id, m_pSubMenu = pSubMenu; m_idItem = id; m_bEnabled = TRUE; + + if ( m_strName == "E&xit" ||m_strName == "Exit" ) + { + m_strName = "Quit\tCtrl+Q" ; + } } wxMenuItem::~wxMenuItem() @@ -73,12 +79,35 @@ void wxMenuItem::DeleteSubMenu() void wxMenuItem::Enable(bool bDoEnable) { if ( m_bEnabled != bDoEnable ) { - if ( m_pSubMenu == NULL ) { // normal menu item - // TODO + if ( m_pSubMenu == NULL ) + { + // normal menu item + if ( m_pParentMenu->m_macMenuHandle ) + { + int index = m_pParentMenu->MacGetIndexFromItem( this ) ; + if ( index >= 1 ) + { + if ( bDoEnable ) + UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ; + else + UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ; + } + } } - else // submenu + else { - // TODO + // submenu + if ( m_pParentMenu->m_macMenuHandle ) + { + int index = m_pParentMenu->MacGetIndexFromItem( this ) ; + if ( index >= 1 ) + { + if ( bDoEnable ) + UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ; + else + UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ; + } + } } m_bEnabled = bDoEnable; @@ -89,7 +118,19 @@ void wxMenuItem::Check(bool bDoCheck) { wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); - if ( m_bChecked != bDoCheck ) { - // TODO + if ( m_bChecked != bDoCheck ) + { m_bChecked = bDoCheck; + if ( m_pParentMenu->m_macMenuHandle ) + { + int index = m_pParentMenu->MacGetIndexFromItem( this ) ; + if ( index >= 1 ) + { + if ( bDoCheck ) + ::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0x12 ) ; // checkmark + else + ::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0 ) ; // no mark + } + } } +} \ No newline at end of file diff --git a/src/mac/carbon/metafile.cpp b/src/mac/carbon/metafile.cpp index ddbfb8402f..97e31948bf 100644 --- a/src/mac/carbon/metafile.cpp +++ b/src/mac/carbon/metafile.cpp @@ -13,46 +13,118 @@ #pragma implementation "metafile.h" #endif -#include "wx/object.h" -#include "wx/string.h" -#include "wx/dc.h" -#include "wx/stubs/metafile.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/setup.h" +#endif + +#if wxUSE_METAFILE + +#ifndef WX_PRECOMP +#include "wx/utils.h" +#include "wx/app.h" +#endif + +#include "wx/metafile.h" #include "wx/clipbrd.h" +#include +#include + extern bool wxClipboardIsOpen; #if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxMetaFile, wxObject) -IMPLEMENT_ABSTRACT_CLASS(wxMetaFileDC, wxDC) +IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC) #endif +/* + * Metafiles + * Currently, the only purpose for making a metafile is to put + * it on the clipboard. + */ + +wxMetafileRefData::wxMetafileRefData(void) +{ + m_metafile = 0; +} + +wxMetafileRefData::~wxMetafileRefData(void) +{ + if (m_metafile) + { + KillPicture( m_metafile ) ; + m_metafile = 0; + } +} + wxMetaFile::wxMetaFile(const wxString& file) { - // TODO + m_refData = new wxMetafileRefData; + + + M_METAFILEDATA->m_metafile = 0; + wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; +/* + if (!file.IsNull() && (file.Cmp("") == 0)) + M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file); +*/ } wxMetaFile::~wxMetaFile() { - // TODO } bool wxMetaFile::SetClipboard(int width, int height) { + if (!m_refData) + return FALSE; +/* bool alreadyOpen=wxClipboardOpen(); if (!alreadyOpen) { wxOpenClipboard(); if (!wxEmptyClipboard()) return FALSE; } - bool success = wxSetClipboardData(wxDF_METAFILE,this, width,height); + bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height); if (!alreadyOpen) wxCloseClipboard(); return (bool) success; + */ + return TRUE ; } bool wxMetaFile::Play(wxDC *dc) { - // TODO + if (!m_refData) return FALSE; + + if (!dc->Ok() ) + return FALSE; + + dc->MacVerifySetup() ; + + { + PicHandle pict = GetHMETAFILE() ; + DrawPicture( pict , &(**pict).picFrame ) ; + } +/* + if (!m_refData) + return FALSE; + + dc->BeginDrawing(); + + if (dc->GetHDC() && M_METAFILEDATA->m_metafile) + PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile); + + dc->EndDrawing(); +*/ + return TRUE; } /* @@ -64,176 +136,55 @@ bool wxMetaFile::Play(wxDC *dc) // *DO* give origin/extent arguments to wxMakeMetaFilePlaceable. wxMetaFileDC::wxMetaFileDC(const wxString& file) { - // TODO + 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,100,100} ; + + m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; + ::GetPort( &m_macPort ) ; + m_ok = TRUE ; + + SetMapMode(wxMM_TEXT); } // New constructor that takes origin and extent. If you use this, don't // give origin/extent arguments to wxMakeMetaFilePlaceable. + wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg) { - // TODO -} + m_minX = 10000; + m_minY = 10000; + m_maxX = -10000; + m_maxY = -10000; -wxMetaFileDC::~wxMetaFileDC() -{ -} + wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; -void wxMetaFileDC::GetTextExtent(const wxString& string, float *x, float *y, - float *descent, float *externalLeading, wxFont *theFont, bool use16bit) -{ - // TODO -} + m_metaFile = new wxMetaFile("") ; + Rect r={yorg,xorg,yorg+yext,xorg+xext} ; + + m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; + ::GetPort( &m_macPort ) ; + m_ok = TRUE ; -wxMetaFile *wxMetaFileDC::Close() -{ - // TODO - return NULL; + SetMapMode(wxMM_TEXT); } -void wxMetaFileDC::SetMapMode(int mode) +wxMetaFileDC::~wxMetaFileDC() { - // TODO } -#if 0 - -#ifdef __WIN32__ -struct RECT32 -{ - short left; - short top; - short right; - short bottom; -}; - -struct mfPLACEABLEHEADER { - DWORD key; - short hmf; - RECT32 bbox; - WORD inch; - DWORD reserved; - WORD checksum; -}; -#else -struct mfPLACEABLEHEADER { - DWORD key; - HANDLE hmf; - RECT bbox; - WORD inch; - DWORD reserved; - WORD checksum; -}; -#endif - -/* - * Pass filename of existing non-placeable metafile, and bounding box. - * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. - * - */ - -bool wxMakeMetaFilePlaceable(const wxString& filename, float scale) +wxMetaFile *wxMetaFileDC::Close() { - return wxMakeMetaFilePlaceable(filename, 0, 0, 0, 0, scale, FALSE); + ClosePicture() ; + return m_metaFile; } -bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale, bool useOriginAndExtent) -{ - // I'm not sure if this is the correct way of suggesting a scale - // to the client application, but it's the only way I can find. - int unitsPerInch = (int)(576/scale); - - mfPLACEABLEHEADER header; - header.key = 0x9AC6CDD7L; - header.hmf = 0; - header.bbox.left = (int)(x1); - header.bbox.top = (int)(y1); - header.bbox.right = (int)(x2); - header.bbox.bottom = (int)(y2); - header.inch = unitsPerInch; - header.reserved = 0; - - // Calculate checksum - WORD *p; - mfPLACEABLEHEADER *pMFHead = &header; - for (p =(WORD *)pMFHead,pMFHead -> checksum = 0; - p < (WORD *)&pMFHead ->checksum; ++p) - pMFHead ->checksum ^= *p; - - FILE *fd = fopen((char *)(const char *)filename, "rb"); - if (!fd) return FALSE; - - char tempFileBuf[256]; - wxGetTempFileName("mf", tempFileBuf); - FILE *fHandle = fopen(tempFileBuf, "wb"); - if (!fHandle) - return FALSE; - fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle); - - // Calculate origin and extent - int originX = x1; - int originY = y1; - int extentX = x2 - x1; - int extentY = (y2 - y1); - - // Read metafile header and write - METAHEADER metaHeader; - fread((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fd); - - if (useOriginAndExtent) - metaHeader.mtSize += 15; - else - metaHeader.mtSize += 5; - - fwrite((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fHandle); - - // Write SetMapMode, SetWindowOrigin and SetWindowExt records - char modeBuffer[8]; - char originBuffer[10]; - char extentBuffer[10]; - METARECORD *modeRecord = (METARECORD *)&modeBuffer; - - METARECORD *originRecord = (METARECORD *)&originBuffer; - METARECORD *extentRecord = (METARECORD *)&extentBuffer; - - modeRecord->rdSize = 4; - modeRecord->rdFunction = META_SETMAPMODE; - modeRecord->rdParm[0] = wxMM_ANISOTROPIC; - - originRecord->rdSize = 5; - originRecord->rdFunction = META_SETWINDOWORG; - originRecord->rdParm[0] = originY; - originRecord->rdParm[1] = originX; - - extentRecord->rdSize = 5; - extentRecord->rdFunction = META_SETWINDOWEXT; - extentRecord->rdParm[0] = extentY; - extentRecord->rdParm[1] = extentX; - - fwrite((void *)modeBuffer, sizeof(char), 8, fHandle); - - if (useOriginAndExtent) - { - fwrite((void *)originBuffer, sizeof(char), 10, fHandle); - fwrite((void *)extentBuffer, sizeof(char), 10, fHandle); - } - - int ch = -2; - while (ch != EOF) - { - ch = getc(fd); - if (ch != EOF) - { - putc(ch, fHandle); - } - } - fclose(fHandle); - fclose(fd); - wxRemoveFile(filename); - wxCopyFile(tempFileBuf, filename); - wxRemoveFile(tempFileBuf); - return TRUE; -} #endif - diff --git a/src/mac/carbon/msgdlg.cpp b/src/mac/carbon/msgdlg.cpp index 775ac8f064..5aa8554038 100644 --- a/src/mac/carbon/msgdlg.cpp +++ b/src/mac/carbon/msgdlg.cpp @@ -14,11 +14,47 @@ #endif #include "wx/msgdlg.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_CLASS(wxMessageDialog, wxDialog) #endif +#define kMacOKAlertResourceID 128 +#define kMacYesNoAlertResourceID 129 +#define kMacYesNoCancelAlertResourceID 130 +#define kMacNoYesAlertResourceID 131 +#define kMacNoYesCancelAlertResourceID 132 + +short language = 0 ; + +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 ; +} + wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, long style, const wxPoint& pos) { @@ -30,7 +66,226 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, cons int wxMessageDialog::ShowModal() { - // TODO - return wxID_CANCEL; + int resultbutton = wxID_CANCEL ; + + short result ; + Str255 pascalTitle ; + Str255 pascalText ; + + strcpy( (char*) pascalTitle , m_caption ) ; + c2pstr( (char*) pascalTitle ) ; + strcpy( (char*) pascalText , m_message ) ; + wxMacConvertNewlines( (char*)pascalText ,(char*) pascalText) ; + c2pstr( (char*) pascalText ) ; + + if ( !UMAHasAppearance() ) + { + int resourceID ; + + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + resourceID = kMacYesNoCancelAlertResourceID; + else + resourceID = kMacYesNoAlertResourceID + language * 10 ; + } + else if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + resourceID = kMacOKAlertResourceID; // wrong + else + resourceID = kMacOKAlertResourceID; + } + else + { + return resultbutton ; + } + /* + if (hWnd) + msStyle |= MB_APPLMODAL; + else + msStyle |= MB_TASKMODAL; + */ + + ParamText( pascalTitle , pascalText , NULL , NULL ) ; + + if (m_dialogStyle & wxICON_EXCLAMATION) + result = Alert( resourceID , NULL ) ; + else if (m_dialogStyle & wxICON_HAND) + result = StopAlert( resourceID , NULL ) ; + else if (m_dialogStyle & wxICON_INFORMATION) + result = NoteAlert( resourceID , NULL ) ; + else if (m_dialogStyle & wxICON_QUESTION) + result = CautionAlert( resourceID , NULL ) ; + else + result = Alert( resourceID , NULL ) ; + + resultbutton = result ; + + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + switch( result ) + { + case 1 : + resultbutton = wxID_YES ; + break ; + case 2 : + resultbutton = wxID_NO ; + break ; + case 3 : + resultbutton = wxID_CANCEL ; + break ; + } + } + else + { + switch( result ) + { + case 1 : + resultbutton = wxID_YES ; + break ; + case 2 : + resultbutton = wxID_NO ; + break ; + case 3 : + break ; + } + } + } + } + else + { + AlertStdAlertParamRec param; + + param.movable = true; + param.filterProc = NULL ; + + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + param.defaultText = "\pYes" ; + param.cancelText = (StringPtr) kAlertDefaultCancelText; + param.otherText = "\pNo"; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = kAlertStdAlertCancelButton; + } + else + { + param.defaultText = "\pYes" ; + param.cancelText = NULL; + param.otherText = "\pNo"; + 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; + + if (m_dialogStyle & wxICON_EXCLAMATION) + StandardAlert( kAlertNoteAlert, pascalTitle, pascalText, ¶m, &result ); + else if (m_dialogStyle & wxICON_HAND) + StandardAlert( kAlertStopAlert, pascalTitle, pascalText, ¶m, &result ); + else if (m_dialogStyle & wxICON_INFORMATION) + StandardAlert( kAlertNoteAlert, pascalTitle, pascalText, ¶m, &result ); + else if (m_dialogStyle & wxICON_QUESTION) + StandardAlert( kAlertCautionAlert, pascalTitle, pascalText, ¶m, &result ); + else + StandardAlert( kAlertPlainAlert, 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/notebook.cpp b/src/mac/carbon/notebook.cpp index 312dd0f3d3..a4f93917eb 100644 --- a/src/mac/carbon/notebook.cpp +++ b/src/mac/carbon/notebook.cpp @@ -24,7 +24,7 @@ #include #include #include - +#include // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -32,6 +32,11 @@ // check that the page index is valid #define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount())) +const short kwxMacTabLeftMargin = 16 ; +const short kwxMacTabTopMargin = 30 ; +const short kwxMacTabRightMargin = 16 ; +const short kwxMacTabBottomMargin = 16 ; + // ---------------------------------------------------------------------------- // event table // ---------------------------------------------------------------------------- @@ -91,21 +96,16 @@ bool wxNotebook::Create(wxWindow *parent, long style, const wxString& name) { - // base init - SetName(name); - SetParent(parent); - - m_windowId = id == -1 ? NewControlId() : id; - - // style - m_windowStyle = style; - - if ( parent != NULL ) - parent->AddChild(this); - - // TODO - - return FALSE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlTabSmallProc , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } // dtor @@ -123,8 +123,7 @@ int wxNotebook::GetPageCount() const int wxNotebook::GetRowCount() const { - // TODO - return 0; + return 1; } int wxNotebook::SetSelection(int nPage) @@ -132,9 +131,11 @@ int wxNotebook::SetSelection(int nPage) wxASSERT( IS_VALID_PAGE(nPage) ); ChangePage(m_nSelection, nPage); - - // TODO - return 0; + SetControlValue( m_macControl , m_nSelection + 1 ) ; +// Boolean enabled = true ; + +// SetControlData( m_macControl, m_nSelection + 1, kControlTabEnabledFlagTag, sizeof( Boolean ), (Ptr)&enabled ); + return m_nSelection; } void wxNotebook::AdvanceSelection(bool bForward) @@ -246,7 +247,19 @@ bool wxNotebook::InsertPage(int nPage, wxASSERT( pPage != NULL ); wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE ); - // TODO: insert native widget page + ControlTabInfoRec tie ; + Boolean enabled = true ; + if ( nPage + 1 > GetControlMaximum( m_macControl ) ) + { + SetControlMaximum( m_macControl , nPage + 1 ) ; + } + + tie.version = 0 ; + tie.iconSuiteID = 0 ; + strcpy( (char*) tie.name , strText ) ; + c2pstr( (char*) tie.name ) ; + SetControlData( m_macControl, nPage + 1, kControlTabInfoTag , sizeof( ControlTabInfoRec) , (char*) &tie ) ; + SetControlData( m_macControl, m_nSelection + 1, kControlTabEnabledFlagTag, sizeof( Boolean ), (Ptr)&enabled ); // save the pointer to the page m_aPages.Insert(pPage, nPage); @@ -258,6 +271,9 @@ bool wxNotebook::InsertPage(int nPage, else if ( m_nSelection == -1 ) m_nSelection = 0; + // don't show pages by default (we'll need to adjust their size first) + pPage->Show( FALSE ) ; + return TRUE; } @@ -290,7 +306,9 @@ void wxNotebook::OnSize(wxSizeEvent& event) unsigned int nCount = m_aPages.Count(); for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) { wxNotebookPage *pPage = m_aPages[nPage]; - pPage->SetSize(0, 0, w, h); + pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin, w - kwxMacTabLeftMargin - kwxMacTabRightMargin, + h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); +// pPage->SetSize(0, 0, w, h); if ( pPage->GetAutoLayout() ) pPage->Layout(); } @@ -362,7 +380,16 @@ void wxNotebook::Command(wxCommandEvent& event) // hide the currently active panel and show the new one void wxNotebook::ChangePage(int nOldSel, int nSel) { - wxASSERT( nOldSel != nSel ); // impossible + // it's not an error (the message may be generated by the tab control itself) + // and it may happen - just do nothing + if ( nSel == nOldSel ) + { + wxNotebookPage *pPage = m_aPages[nSel]; + pPage->Show(FALSE); + pPage->Show(TRUE); + pPage->SetFocus(); + return; + } if ( nOldSel != -1 ) { m_aPages[nOldSel]->Show(FALSE); @@ -375,3 +402,11 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) m_nSelection = nSel; } +void wxNotebook::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControlValue(m_macControl) - 1, m_nSelection); + event.SetEventObject(this); + + ProcessEvent(event); +} + diff --git a/src/mac/carbon/palette.cpp b/src/mac/carbon/palette.cpp index f8db96f8d0..85a9fd16d8 100644 --- a/src/mac/carbon/palette.cpp +++ b/src/mac/carbon/palette.cpp @@ -26,12 +26,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) wxPaletteRefData::wxPaletteRefData() { - // TODO + m_palette = NULL ; + m_count = 0 ; } wxPaletteRefData::~wxPaletteRefData() { - // TODO + delete[] m_palette ; } wxPalette::wxPalette() @@ -53,7 +54,13 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre m_refData = new wxPaletteRefData; - // TODO + 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; } @@ -61,10 +68,26 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const { if ( !m_refData ) - return FALSE; - - // TODO - return FALSE; + 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 ; + } + } + + return bestpos; } bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const @@ -72,11 +95,15 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi if ( !m_refData ) return FALSE; - if (index < 0 || index > 255) + if (index < 0 || index >= M_PALETTEDATA->m_count) return FALSE; - // TODO - return FALSE; + const wxColour& col = &M_PALETTEDATA->m_palette[index] ; + *red = col.Red() ; + *green = col.Green() ; + *blue = col.Blue() ; + + return TRUE; } diff --git a/src/mac/carbon/print.cpp b/src/mac/carbon/print.cpp index 61fd6e7e99..1064058925 100644 --- a/src/mac/carbon/print.cpp +++ b/src/mac/carbon/print.cpp @@ -13,8 +13,8 @@ #pragma implementation "print.h" #endif -#include "wx/stubs/print.h" -#include "wx/stubs/printdlg.h" +#include "wx/mac/print.h" +#include "wx/mac/printdlg.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxPrinter, wxPrinterBase) diff --git a/src/mac/carbon/printdlg.cpp b/src/mac/carbon/printdlg.cpp index eae3b95568..18c7a8427e 100644 --- a/src/mac/carbon/printdlg.cpp +++ b/src/mac/carbon/printdlg.cpp @@ -14,11 +14,10 @@ #endif #include "wx/object.h" -#include "wx/stubs/printdlg.h" +#include "wx/mac/printdlg.h" #include "wx/dcprint.h" // Use generic page setup dialog: use your own native one if one exists. -#include "wx/generic/prntdlgg.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog) @@ -29,7 +28,6 @@ wxPrintDialog::wxPrintDialog(): wxDialog() { m_dialogParent = NULL; - m_printerDC = NULL; } wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data): @@ -41,7 +39,6 @@ wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data): bool wxPrintDialog::Create(wxWindow *p, wxPrintData* data) { m_dialogParent = p; - m_printerDC = NULL; if ( data ) m_printData = *data; @@ -51,26 +48,39 @@ bool wxPrintDialog::Create(wxWindow *p, wxPrintData* data) wxPrintDialog::~wxPrintDialog() { - if (m_printerDC) - delete m_printerDC; } int wxPrintDialog::ShowModal() { - // TODO - return wxID_CANCEL; + int result = wxID_CANCEL ; + OSErr err ; + wxString message ; + ::PrOpen() ; + err = PrError() ; + + if ( !err ) + { + m_printData.ConvertToNative() ; + if ( m_printData.macPrintInfo && ::PrJobDialog( m_printData.macPrintInfo ) ) + { + m_printData.ConvertFromNative() ; + result = wxID_OK ; + } + + } + else + { + message.Printf( "Print Error %d", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + } + ::PrClose() ; + + return result ; } wxDC *wxPrintDialog::GetPrintDC() { - if (m_printerDC) - { - wxDC* dc = m_printerDC; - m_printerDC = NULL; - return dc; - } - else - return NULL; + return new wxPrinterDC( m_printData ) ; } /* @@ -105,11 +115,29 @@ wxPageSetupDialog::~wxPageSetupDialog() int wxPageSetupDialog::ShowModal() { - // Uses generic page setup dialog - wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData); - int ret = genericPageSetupDialog->ShowModal(); - m_pageSetupData = genericPageSetupDialog->GetPageSetupData(); - genericPageSetupDialog->Close(TRUE); - return ret; + int result = wxID_CANCEL ; + OSErr err ; + wxString message ; + ::PrOpen() ; + err = PrError() ; + + if ( !err ) + { + m_pageSetupData.ConvertToNative() ; + if ( m_pageSetupData.m_macPageSetupInfo && ::PrStlDialog( m_pageSetupData.m_macPageSetupInfo ) ) + { + m_pageSetupData.ConvertFromNative() ; + result = wxID_OK ; + } + + } + else + { + message.Printf( "Print Error %d", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + } + ::PrClose() ; + + return result ; } diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index da582d0e52..3393009f47 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -108,7 +108,7 @@ wxString wxRadioBox::GetString(int n) const void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; } void wxRadioBox::GetSize(int *width, int *height) const @@ -140,12 +140,13 @@ void wxRadioBox::SetFocus() bool wxRadioBox::Show(bool show) { // TODO - return FALSE; + return wxWindow::Show( show ) ; } // Enable a specific button void wxRadioBox::Enable(int item, bool enable) { + wxControl::Enable(enable); // TODO } diff --git a/src/mac/carbon/region.cpp b/src/mac/carbon/region.cpp index c71d4c605a..c5c6332e06 100644 --- a/src/mac/carbon/region.cpp +++ b/src/mac/carbon/region.cpp @@ -28,19 +28,24 @@ class WXDLLEXPORT wxRegionRefData : public wxGDIRefData { public: wxRegionRefData() { + m_macRgn = NewRgn() ; } wxRegionRefData(const wxRegionRefData& data) { - // TODO + m_macRgn = NewRgn() ; + CopyRgn( data.m_macRgn , m_macRgn ) ; } ~wxRegionRefData() { - // TODO + DisposeRgn( m_macRgn ) ; } + RgnHandle m_macRgn ; }; +#define M_REGION (((wxRegionRefData*)m_refData)->m_macRgn) +#define OTHER_M_REGION(a) (((wxRegionRefData*)(a.m_refData))->m_macRgn) //----------------------------------------------------------------------------- // wxRegion @@ -52,25 +57,30 @@ public: wxRegion::wxRegion() { m_refData = new wxRegionRefData; - // TODO create empty region +} + +wxRegion::wxRegion(WXHRGN hRegion ) +{ + m_refData = new wxRegionRefData; + CopyRgn( hRegion , M_REGION ) ; } wxRegion::wxRegion(long x, long y, long w, long h) { m_refData = new wxRegionRefData; - // TODO create rect region + SetRectRgn( M_REGION , x , y , x+w , y+h ) ; } wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight) { m_refData = new wxRegionRefData; - // TODO create rect region + SetRectRgn( M_REGION , topLeft.x , topLeft.y , bottomRight.x , bottomRight.y ) ; } wxRegion::wxRegion(const wxRect& rect) { m_refData = new wxRegionRefData; - // TODO create rect region + SetRectRgn( M_REGION , rect.x , rect.y , rect.x+rect.width , rect.y+rect.height ) ; } /*! @@ -95,41 +105,42 @@ void wxRegion::Clear() bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) { // Don't change shared data - if (!m_refData) { + if (!m_refData) + { m_refData = new wxRegionRefData(); - } else if (m_refData->GetRefCount() > 1) { + } + else if (m_refData->GetRefCount() > 1) + { wxRegionRefData* ref = (wxRegionRefData*)m_refData; UnRef(); m_refData = new wxRegionRefData(*ref); } - // If ref count is 1, that means it's 'ours' anyway so no action. - - // TODO create rect region - - int mode = 0; // TODO platform-specific code + RgnHandle rgn = NewRgn() ; + SetRectRgn( rgn , x , y, x+width,y + height ) ; + switch (op) { case wxRGN_AND: - // TODO + SectRgn( M_REGION , rgn , M_REGION ) ; break ; case wxRGN_OR: - // TODO + UnionRgn( M_REGION , rgn , M_REGION ) ; break ; case wxRGN_XOR: - // TODO + XorRgn( M_REGION , rgn , M_REGION ) ; break ; case wxRGN_DIFF: - // TODO + DiffRgn( M_REGION , rgn , M_REGION ) ; break ; case wxRGN_COPY: default: - // TODO + CopyRgn( rgn ,M_REGION ) ; break ; } - // TODO do combine region + DisposeRgn( rgn ) ; - return FALSE; + return TRUE; } //! Union /e region with this. @@ -141,36 +152,35 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) // Don't change shared data if (!m_refData) { m_refData = new wxRegionRefData(); - } else if (m_refData->GetRefCount() > 1) { + } + else if (m_refData->GetRefCount() > 1) + { wxRegionRefData* ref = (wxRegionRefData*)m_refData; UnRef(); m_refData = new wxRegionRefData(*ref); } - int mode = 0; // TODO platform-specific code switch (op) { case wxRGN_AND: - // TODO + SectRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; break ; case wxRGN_OR: - // TODO + UnionRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; break ; case wxRGN_XOR: - // TODO + XorRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; break ; case wxRGN_DIFF: - // TODO + DiffRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; break ; case wxRGN_COPY: default: - // TODO + CopyRgn( OTHER_M_REGION(region) ,M_REGION ) ; break ; } - // TODO combine region - - return FALSE; + return TRUE; } bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) @@ -185,9 +195,16 @@ bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) // Outer bounds of region void wxRegion::GetBox(long& x, long& y, long&w, long &h) const { - if (m_refData) { - // TODO get box - } else { + if (m_refData) + { + Rect box = (**M_REGION).rgnBBox ; + x = box.left ; + y = box.top ; + w = box.right - box.left ; + h = box.bottom - box.top ; + } + else + { x = y = w = h = 0; } } @@ -202,8 +219,12 @@ wxRect wxRegion::GetBox() const // Is region empty? bool wxRegion::Empty() const { - // TODO - return FALSE; + return EmptyRgn( M_REGION ) ; +} + +const WXHRGN wxRegion::GetWXHRGN() const +{ + return M_REGION ; } //----------------------------------------------------------------------------- @@ -228,11 +249,11 @@ wxRegionContain wxRegion::Contains(const wxPoint& pt) const if (!m_refData) return wxOutRegion; - // TODO. Return wxInRegion if within region. - if (0) + Point p = { pt.y , pt.x } ; + if (PtInRgn( p , M_REGION ) ) return wxInRegion; - else - return wxOutRegion; + + return wxOutRegion; } // Does the region contain the rectangle (x, y, w, h)? @@ -241,8 +262,8 @@ wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const if (!m_refData) return wxOutRegion; - // TODO. Return wxInRegion if within region. - if (0) + Rect rect = { y , x , y + h , x + w } ; + if (RectInRgn( &rect , M_REGION ) ) return wxInRegion; else return wxOutRegion; @@ -308,8 +329,14 @@ void wxRegionIterator::Reset(const wxRegion& region) m_numRects = 0; else { - // TODO create m_rects and fill with rectangles for this region - m_numRects = 0; + // we cannot dissolve it into rects on mac + m_rects = new wxRect[1]; + Rect rect = (**OTHER_M_REGION( region )).rgnBBox ; + m_rects[0].x = rect.left; + m_rects[0].y = rect.top; + m_rects[0].width = rect.right - rect.left; + m_rects[0].height = rect.bottom - rect.top; + m_numRects = 1; } } diff --git a/src/mac/carbon/scrolbar.cpp b/src/mac/carbon/scrolbar.cpp index a92154acfb..a432b3e9b1 100644 --- a/src/mac/carbon/scrolbar.cpp +++ b/src/mac/carbon/scrolbar.cpp @@ -14,6 +14,7 @@ #endif #include "wx/scrolbar.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl) @@ -23,6 +24,8 @@ END_EVENT_TABLE() #endif +extern ControlActionUPP wxMacLiveScrollbarActionUPP ; + // Scrollbar bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, @@ -30,21 +33,24 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - if (!parent) - return FALSE; - parent->AddChild(this); - SetName(name); - SetValidator(validator); + if (!parent) + return FALSE; - m_windowStyle = style; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 100, + kControlScrollBarLiveProc , (long) this ) ; + + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + ::SetControlAction( m_macControl , wxMacLiveScrollbarActionUPP ) ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; + MacPostControlCreate() ; - // TODO create scrollbar - return TRUE; + return TRUE; } wxScrollBar::~wxScrollBar() @@ -53,13 +59,12 @@ wxScrollBar::~wxScrollBar() void wxScrollBar::SetThumbPosition(int viewStart) { - // TODO + ::SetControlValue( m_macControl , viewStart ) ; } int wxScrollBar::GetThumbPosition() const { - // TODO - return 0; + return ::GetControlValue( m_macControl ) ; } void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize, @@ -69,7 +74,19 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS m_pageSize = thumbSize; m_objectSize = range; - // TODO + int range1 = wxMax((m_objectSize - m_pageSize), 0) ; + + SetControlMaximum( m_macControl , range1 ) ; + SetControlMinimum( m_macControl , 0 ) ; + SetControlValue( m_macControl , position ) ; + + if ( UMAGetAppearanceVersion() >= 0x0110 ) + { +#if UMA_USE_8_6 + SetControlViewSize( m_macControl , m_pageSize ) ; +#endif + } + Refresh() ; } @@ -79,3 +96,62 @@ void wxScrollBar::Command(wxCommandEvent& event) ProcessCommand(event); } +void wxScrollBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + if ( m_macControl == NULL ) + return ; + + int position = GetControlValue( m_macControl) ; + int minPos = GetControlMinimum( m_macControl) ; + int maxPos = GetControlMaximum( m_macControl) ; + + wxEventType scrollEvent = wxEVT_NULL; + int nScrollInc; + + switch( controlpart ) + { + case kControlUpButtonPart : + nScrollInc = -1; + scrollEvent = wxEVT_SCROLL_LINEUP; + break ; + case kControlDownButtonPart : + nScrollInc = 1; + scrollEvent = wxEVT_SCROLL_LINEDOWN; + break ; + case kControlPageUpPart : + nScrollInc = -m_pageSize; + scrollEvent = wxEVT_SCROLL_PAGEUP; + break ; + case kControlPageDownPart : + nScrollInc = m_pageSize; + scrollEvent = wxEVT_SCROLL_PAGEDOWN; + break ; + case kControlIndicatorPart : + nScrollInc = 0 ; + scrollEvent = wxEVT_SCROLL_THUMBTRACK; + break ; + } + + int new_pos = position + nScrollInc; + + if (new_pos < 0) + new_pos = 0; + 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 ); + GetEventHandler()->ProcessEvent(event); +} + diff --git a/src/mac/carbon/settings.cpp b/src/mac/carbon/settings.cpp index 2beda5c2a6..b13b5733cc 100644 --- a/src/mac/carbon/settings.cpp +++ b/src/mac/carbon/settings.cpp @@ -17,39 +17,92 @@ wxColour wxSystemSettings::GetSystemColour(int index) { - // TODO - return wxColour(); + switch( index ) + { + case wxSYS_COLOUR_SCROLLBAR : + case wxSYS_COLOUR_BACKGROUND: + case wxSYS_COLOUR_ACTIVECAPTION: + case wxSYS_COLOUR_INACTIVECAPTION: + case wxSYS_COLOUR_MENU: + case wxSYS_COLOUR_WINDOW: + case wxSYS_COLOUR_WINDOWFRAME: + case wxSYS_COLOUR_ACTIVEBORDER: + case wxSYS_COLOUR_INACTIVEBORDER: + case wxSYS_COLOUR_BTNFACE: + return wxColor( 0xDD , 0xDD , 0xDD ) ; + break ; + + case wxSYS_COLOUR_BTNSHADOW: + return wxColor( 0x44 , 0x44 , 0x44 ) ; + break ; + + case wxSYS_COLOUR_BTNTEXT: + case wxSYS_COLOUR_MENUTEXT: + case wxSYS_COLOUR_WINDOWTEXT: + case wxSYS_COLOUR_CAPTIONTEXT: + case wxSYS_COLOUR_INFOTEXT: + case wxSYS_COLOUR_INACTIVECAPTIONTEXT: + return *wxBLACK; + break ; + case wxSYS_COLOUR_HIGHLIGHT: + { + RGBColor hilite ; + LMGetHiliteRGB(&hilite) ; + return wxColor( hilite.red >> 8 , hilite.green >> 8 , hilite.blue >> 8 ) ; + } + break ; + case wxSYS_COLOUR_BTNHIGHLIGHT: + case wxSYS_COLOUR_GRAYTEXT: + return wxColor( 0xCC , 0xCC , 0xCC ) ; + break ; + + case wxSYS_COLOUR_3DDKSHADOW: + return wxColor( 0x44 , 0x44 , 0x44 ) ; + break ; + case wxSYS_COLOUR_3DLIGHT: + return wxColor( 0xCC , 0xCC , 0xCC ) ; + break ; + case wxSYS_COLOUR_HIGHLIGHTTEXT : + { + RGBColor hilite ; + LMGetHiliteRGB(&hilite) ; + if ( ( hilite.red + hilite.green + hilite.blue ) == 0 ) + return *wxWHITE ; + else + return *wxBLACK ; + } + break ; + case wxSYS_COLOUR_INFOBK : + case wxSYS_COLOUR_APPWORKSPACE: + return *wxWHITE ; + break ; + } + return *wxWHITE; } wxFont wxSystemSettings::GetSystemFont(int index) { - // TODO switch (index) { - case wxSYS_DEVICE_DEFAULT_FONT: - { - break; - } - case wxSYS_DEFAULT_PALETTE: - { - break; - } - case wxSYS_SYSTEM_FIXED_FONT: - { - break; - } - case wxSYS_SYSTEM_FONT: - { - break; - } - default: - case wxSYS_DEFAULT_GUI_FONT: - { - break; - } + case wxSYS_ANSI_VAR_FONT : + case wxSYS_SYSTEM_FONT : + case wxSYS_DEVICE_DEFAULT_FONT : + case wxSYS_DEFAULT_GUI_FONT : + { + return *wxSMALL_FONT ; + } ; + break ; + case wxSYS_OEM_FIXED_FONT : + case wxSYS_ANSI_FIXED_FONT : + case wxSYS_SYSTEM_FIXED_FONT : + default : + { + return *wxNORMAL_FONT ; + } ; + break ; + } - - return wxFont(); + return *wxNORMAL_FONT; } // Get a system metric, e.g. scrollbar size @@ -58,11 +111,10 @@ int wxSystemSettings::GetSystemMetric(int index) switch ( index) { case wxSYS_MOUSE_BUTTONS: - // TODO - return 0; + return 2; // we emulate a two button mouse (ctrl + click = right button ) case wxSYS_BORDER_X: // TODO - return 0; + return 0; case wxSYS_BORDER_Y: // TODO return 0; @@ -91,14 +143,11 @@ int wxSystemSettings::GetSystemMetric(int index) // TODO return 0; case wxSYS_HSCROLL_ARROW_X: - // TODO - return 0; + return 16; case wxSYS_HSCROLL_ARROW_Y: - // TODO - return 0; + return 16; case wxSYS_HTHUMB_X: - // TODO - return 0; + return 16; case wxSYS_ICON_X: // TODO return 0; @@ -136,40 +185,33 @@ int wxSystemSettings::GetSystemMetric(int index) // TODO return 0; case wxSYS_HSCROLL_Y: - // TODO - return 0; + return 16; case wxSYS_VSCROLL_X: - // TODO - return 0; + return 16; case wxSYS_VSCROLL_ARROW_X: - // TODO - return 0; + return 16; case wxSYS_VSCROLL_ARROW_Y: - // TODO - return 0; + return 16; case wxSYS_VTHUMB_Y: - // TODO - return 0; + return 16; case wxSYS_CAPTION_Y: // TODO - return 0; + return 0; case wxSYS_MENU_Y: // TODO - return 0; + return 0; case wxSYS_NETWORK_PRESENT: // TODO - return 0; + return 0; case wxSYS_PENWINDOWS_PRESENT: - // TODO - return 0; + return 0; case wxSYS_SHOW_SOUNDS: // TODO return 0; case wxSYS_SWAP_BUTTONS: - // TODO - return 0; - default: - return 0; + return 0; + default: + return 0; } return 0; } diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index c9952342a9..936ccddb47 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -14,6 +14,7 @@ #endif #include "wx/slider.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl) @@ -34,6 +35,8 @@ wxSlider::wxSlider() m_tickFreq = 0; } +extern ControlActionUPP wxMacLiveScrollbarActionUPP ; + bool wxSlider::Create(wxWindow *parent, wxWindowID id, int value, int minValue, int maxValue, const wxPoint& pos, @@ -41,28 +44,92 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - - if (parent) parent->AddChild(this); + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_lineSize = 1; - m_windowStyle = style; - m_tickFreq = 0; + m_macMinimumStatic = NULL ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - m_rangeMax = maxValue; - m_rangeMin = minValue; - - m_pageSize = (int)((maxValue-minValue)/10); + m_lineSize = 1; + m_tickFreq = 0; - // TODO create slider + m_rangeMax = maxValue; + m_rangeMin = minValue; + + m_pageSize = (int)((maxValue-minValue)/10); + if ( m_width == -1 ) + { + m_width = 20 ; + if ( style & wxSL_LABELS && style & wxSL_VERTICAL ) + m_width += 24 ; + bounds.right = bounds.left + m_width ; + } + if ( m_height == -1 ) + { + m_height = 20 ; + if ( style & wxSL_LABELS && style & wxSL_HORIZONTAL ) + m_height += 24 ; + bounds.bottom = bounds.top + m_height ; + } + + if ( style & wxSL_LABELS && style & wxSL_HORIZONTAL ) + { + bounds.top += 12 ; + bounds.right -= 24 ; + } + + if ( style & wxSL_LABELS && style & wxSL_VERTICAL ) + { + bounds.left += 24 ; + bounds.top += 12 ; + } + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , value , minValue , maxValue, + kControlSliderProc + kControlSliderLiveFeedback + ( ( style & wxSL_AUTOTICKS ) ? kControlSliderHasTickMarks : 0 ) , (long) this ) ; + + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + ::SetControlAction( m_macControl , wxMacLiveScrollbarActionUPP ) ; + + MacPostControlCreate() ; + + if ( style & wxSL_LABELS ) + { + if ( style & wxSL_HORIZONTAL ) + { + wxSize size( 24 , 12 ) ; + wxPoint leftpos( 0 , 0 ) ; + wxPoint rightpos( m_width - 2 * 12 , 0 ) ; + wxPoint valuepos( m_width - 12 , 20 ) ; + wxString valuestring ; + + valuestring.Printf( "%d" , minValue ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , leftpos , size ) ; + valuestring.Printf( "%d" , maxValue ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , rightpos , size ) ; + valuestring.Printf( "%d" , value ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , valuepos , size ) ; + } + else + { + wxSize size( 24 , 12 ) ; + wxPoint toppos( 0 , 12 ) ; + wxPoint bottompos( 0 , m_height - 12 ) ; + wxPoint valuepos( 20 , 0 ) ; + wxString valuestring ; + + valuestring.Printf( "%d" , minValue ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , bottompos , size ) ; + valuestring.Printf( "%d" , maxValue ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , toppos , size ) ; + valuestring.Printf( "%d" , value ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , valuepos , size ) ; + } + } + + return TRUE; - return FALSE; } wxSlider::~wxSlider() @@ -71,28 +138,16 @@ wxSlider::~wxSlider() int wxSlider::GetValue() const { - // TODO - return 0; + return GetControlValue( m_macControl) ; } void wxSlider::SetValue(int value) { - // TODO -} - -void wxSlider::GetSize(int *width, int *height) const -{ - // TODO -} - -void wxSlider::GetPosition(int *x, int *y) const -{ - // TODO -} - -void wxSlider::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + wxString valuestring ; + valuestring.Printf( "%d" , value ) ; + if ( m_macMinimumStatic ) + m_macMinimumStatic->SetLabel( valuestring ) ; + SetControlValue( m_macControl , value ) ; } void wxSlider::SetRange(int minValue, int maxValue) @@ -182,9 +237,32 @@ void wxSlider::Command (wxCommandEvent & event) ProcessCommand (event); } -bool wxSlider::Show(bool show) +bool wxSlider::Show( bool show ) { - // TODO - return TRUE; + return wxWindow::Show( show ) ; } +void wxSlider::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + SInt16 value = ::GetControlValue( m_macControl ) ; + + SetValue( value ) ; + + wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); + event.SetPosition(GetControlValue( m_macControl) ); + event.SetEventObject( this ); + +#if WXWIN_COMPATIBILITY + + wxEventType oldEvent = event.GetEventType(); + event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED ); + if ( !GetEventHandler()->ProcessEvent(event) ) + { + event.SetEventType( oldEvent ); + if (!GetParent()->GetEventHandler()->ProcessEvent(event)) + event.Skip(); + } +#else + GetEventHandler()->ProcessEvent(event); +#endif +} diff --git a/src/mac/carbon/spinbutt.cpp b/src/mac/carbon/spinbutt.cpp index cbea725592..8f3e1533b8 100644 --- a/src/mac/carbon/spinbutt.cpp +++ b/src/mac/carbon/spinbutt.cpp @@ -14,6 +14,7 @@ #endif #include "wx/spinbutt.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl) @@ -28,19 +29,25 @@ wxSpinButton::wxSpinButton() bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - SetName(name); - - m_windowStyle = style; - - SetParent(parent); - m_min = 0; m_max = 100; - m_windowId = (id == -1) ? NewControlId() : id; + if (!parent) + return FALSE; + + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 100, + kControlLittleArrowsProc , (long) this ) ; + + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + MacPostControlCreate() ; - // TODO create spin button - return FALSE; + return TRUE; } wxSpinButton::~wxSpinButton() @@ -52,20 +59,23 @@ wxSpinButton::~wxSpinButton() int wxSpinButton::GetValue() const { - // TODO - return 0; + return m_value; } void wxSpinButton::SetValue(int val) { - // TODO + m_value = val ; + wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); + + event.SetPosition(m_value); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); } void wxSpinButton::SetRange(int minVal, int maxVal) { m_min = minVal; m_max = maxVal; - // TODO } // Spin event @@ -76,3 +86,49 @@ wxSpinEvent::wxSpinEvent(wxEventType commandType, int id): { } +void wxSpinButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + if ( m_macControl == NULL ) + return ; + + wxEventType scrollEvent = wxEVT_NULL; + int nScrollInc; + + switch( controlpart ) + { + case kControlUpButtonPart : + nScrollInc = 1; + scrollEvent = wxEVT_SCROLL_LINEUP; + break ; + case kControlDownButtonPart : + nScrollInc = -1; + scrollEvent = wxEVT_SCROLL_LINEDOWN; + break ; + } + + m_value = m_value + nScrollInc; + + if (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; + } + + wxScrollEvent event(scrollEvent, m_windowId); + + event.SetPosition(m_value); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); +} + + diff --git a/src/mac/carbon/statbmp.cpp b/src/mac/carbon/statbmp.cpp index a67c558465..721c254234 100644 --- a/src/mac/carbon/statbmp.cpp +++ b/src/mac/carbon/statbmp.cpp @@ -23,6 +23,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) * wxStaticBitmap */ +BEGIN_EVENT_TABLE(wxStaticBitmap, wxControl) + EVT_PAINT(wxStaticBitmap::OnPaint) +END_EVENT_TABLE() + bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, @@ -41,19 +45,27 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, m_windowStyle = style; - // TODO: create static bitmap control - return FALSE; + bool ret = wxControl::Create( parent, id, pos, size, style , name ); + + return ret; } void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; } void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) { m_messageBitmap = bitmap; - // TODO: redraw bitmap + Refresh() ; +} +void wxStaticBitmap::OnPaint( wxPaintEvent &event ) +{ + wxPaintDC dc(this); + PrepareDC(dc); + dc.SetPalette( *m_messageBitmap.GetPalette() ) ; + dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ; } diff --git a/src/mac/carbon/statbox.cpp b/src/mac/carbon/statbox.cpp index b239dc738c..abae14d07e 100644 --- a/src/mac/carbon/statbox.cpp +++ b/src/mac/carbon/statbox.cpp @@ -14,6 +14,7 @@ #endif #include "wx/statbox.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) @@ -35,28 +36,15 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - SetName(name); + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; - if (parent) parent->AddChild(this); + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlGroupBoxTextTitleProc , (long) this ) ; + + MacPostControlCreate() ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - m_windowStyle = style; - - // TODO: create static box - return FALSE; -} - -void wxStaticBox::SetLabel(const wxString& label) -{ - // TODO + return TRUE; } - -void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO -} - diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index 3b19c7184d..14c69f1d96 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -22,6 +22,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) #endif +#include + bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, @@ -29,32 +31,31 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - SetName(name); - if (parent) parent->AddChild(this); - - SetBackgroundColour(parent->GetBackgroundColour()) ; - SetForegroundColour(parent->GetForegroundColour()) ; - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - m_windowStyle = style; - - SetFont(parent->GetFont()); - - // TODO - return FALSE; -} - -void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + kControlStaticTextProc , (long) this ) ; + ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) title[0] , (char*) &title[1] ) ; + + MacPostControlCreate() ; + + return TRUE; } -void wxStaticText::SetLabel(const wxString& label) +void wxStaticText::SetLabel(const wxString& st , bool resize ) { - // TODO + m_label = st ; + wxString label ; + + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( st ) ; + else + label = st ; + + ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ; + Refresh() ; } diff --git a/src/mac/carbon/statusbr.cpp b/src/mac/carbon/statusbr.cpp index dff1ddec34..15ab99d5ac 100644 --- a/src/mac/carbon/statusbr.cpp +++ b/src/mac/carbon/statusbr.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#include "wx/stubs/statusbr.h" +#include "wx/mac/statusbr.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar); diff --git a/src/mac/carbon/tabctrl.cpp b/src/mac/carbon/tabctrl.cpp index b3b45a72d1..ea057aae52 100644 --- a/src/mac/carbon/tabctrl.cpp +++ b/src/mac/carbon/tabctrl.cpp @@ -15,6 +15,7 @@ #include "wx/control.h" #include "wx/tabctrl.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl) @@ -31,20 +32,18 @@ wxTabCtrl::wxTabCtrl() bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - m_imageList = NULL; - - SetName(name); - - m_windowStyle = style; + Rect bounds ; + Str255 title ; - SetParent(parent); + m_imageList = NULL; + + MacPreControlCreate( parent , id , "" , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; - m_windowId = (id < 0 ? NewControlId() : id); - - if (parent) parent->AddChild(this); - - // TODO: create tab control - return FALSE; + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlTabSmallProc , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } wxTabCtrl::~wxTabCtrl() diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index a2b5e7d38e..d553477f93 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -36,11 +36,14 @@ #endif #endif +#include "wx/mac/uma.h" + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) + EVT_CHAR(wxTextCtrl::OnChar) END_EVENT_TABLE() #endif @@ -54,67 +57,114 @@ wxTextCtrl::wxTextCtrl() } bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, - const wxString& value, + const wxString& st, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { - m_fileName = ""; - SetName(name); - SetValidator(validator); - if (parent) parent->AddChild(this); + m_macHorizontalBorder = 2 ; // additional pixels around the real control + m_macVerticalBorder = 2 ; - m_windowStyle = style; + wxSize mySize = size ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; + Rect bounds ; + Str255 title ; + + if ( mySize.y == -1 ) + { + if ( UMAHasAppearance() ) + mySize.y = 16 ; + else + mySize.y = 24 ; + } + MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; - return TRUE; + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + kControlEditTextProc , (long) this ) ; + MacPostControlCreate() ; + + wxString value ; + + if( wxApp::s_macDefaultEncodingIsPC ) + value = wxMacMakeMacStringFromPC( st ) ; + else + value = st ; + UMASetControlData( m_macControl, 0, kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + + return TRUE; } wxString wxTextCtrl::GetValue() const { - // TODO - return wxString(""); + Size actualsize; + UMAGetControlData( m_macControl, 0, kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; + wxBuffer[actualsize] = 0 ; + if( wxApp::s_macDefaultEncodingIsPC ) + return wxMacMakePCStringFromMac( wxBuffer ) ; + else + return wxString(wxBuffer); } -void wxTextCtrl::SetValue(const wxString& value) +void wxTextCtrl::SetValue(const wxString& st) { - // TODO + wxString value ; + + if( wxApp::s_macDefaultEncodingIsPC ) + value = wxMacMakeMacStringFromPC( st ) ; + else + value = st ; + UMASetControlData( m_macControl, 0, kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + Refresh() ; +// MacInvalidateControl() ; } void wxTextCtrl::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; } // Clipboard operations void wxTextCtrl::Copy() { - // TODO + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TECopy( teH ) ; } void wxTextCtrl::Cut() { - // TODO + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TECut( teH ) ; +// MacInvalidateControl() ; } void wxTextCtrl::Paste() { - // TODO + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TEPaste( teH ) ; +// MacInvalidateControl() ; } void wxTextCtrl::SetEditable(bool editable) { - // TODO + if ( editable ) + UMAActivateControl( m_macControl ) ; + else + UMADeactivateControl( m_macControl ) ; } void wxTextCtrl::SetInsertionPoint(long pos) { - // TODO + SetSelection( pos , pos ) ; } void wxTextCtrl::SetInsertionPointEnd() @@ -125,29 +175,72 @@ void wxTextCtrl::SetInsertionPointEnd() long wxTextCtrl::GetInsertionPoint() const { - // TODO - return 0; + ControlEditTextSelectionRec selection ; + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; +// UMAGetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; + return (**teH).selStart ; } long wxTextCtrl::GetLastPosition() const { - // TODO - return 0; + ControlEditTextSelectionRec selection ; + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + +// UMAGetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; + return (**teH).teLength ; } void wxTextCtrl::Replace(long from, long to, const wxString& value) { - // TODO + TEHandle teH ; + long size ; + + ControlEditTextSelectionRec selection ; + + selection.selStart = from ; + selection.selEnd = to ; + UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TESetSelect( from , to , teH ) ; + TEDelete( teH ) ; + TEInsert( value , value.Length() , teH ) ; +// MacInvalidateControl() ; } void wxTextCtrl::Remove(long from, long to) { - // TODO + TEHandle teH ; + long size ; + + ControlEditTextSelectionRec selection ; + + selection.selStart = from ; + selection.selEnd = to ; + UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TEDelete( teH ) ; +// MacInvalidateControl() ; } void wxTextCtrl::SetSelection(long from, long to) { - // TODO + ControlEditTextSelectionRec selection ; + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + + selection.selStart = from ; + selection.selEnd = to ; + + UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + TESetSelect( selection.selStart , selection.selEnd , teH ) ; } bool wxTextCtrl::LoadFile(const wxString& file) @@ -217,23 +310,44 @@ bool wxTextCtrl::SaveFile(const wxString& file) void wxTextCtrl::WriteText(const wxString& text) { - // TODO write text to control + TEHandle teH ; + long size ; + + memcpy( wxBuffer, text , text.Length() ) ; + wxBuffer[text.Length() ] = 0 ; +// wxMacConvertNewlines( wxBuffer , wxBuffer ) ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + + TEInsert( wxBuffer , strlen( wxBuffer) , teH ) ; + Refresh() ; } void wxTextCtrl::AppendText(const wxString& text) { - // TODO append text to control + SetInsertionPointEnd(); + WriteText(text); } void wxTextCtrl::Clear() { - // TODO + TEHandle teH ; + long size ; + ControlEditTextSelectionRec selection ; + + selection.selStart = 0 ; + selection.selEnd = 32767 ; + + UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TECut( teH ) ; +// MacInvalidateControl() ; } bool wxTextCtrl::IsModified() const { - // TODO - return FALSE; + return TRUE; } // Makes 'unmodified' @@ -266,14 +380,12 @@ void wxTextCtrl::ShowPosition(long pos) int wxTextCtrl::GetLineLength(long lineNo) const { - // TODO - return 0; + return GetValue().Length(); } wxString wxTextCtrl::GetLineText(long lineNo) const { - // TODO - return wxString(""); + return GetValue(); } /* @@ -295,6 +407,76 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) } } +void wxTextCtrl::OnChar(wxKeyEvent& event) +{ + bool handleIt = true ; + switch( event.KeyCode() ) + { + case WXK_RETURN: + { +/* Oh yes it will, because we also specify DLGC_WANTCHARS + wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER, + "this text ctrl should never receive return" ); +*/ + + if ( (m_windowStyle & wxTE_MULTILINE) == 0 ) + { + wxWindow* parent = GetParent() ; + while( parent ) + { + if ( parent->GetDefaultItem() ) + { + wxButton *defaultBtn = parent->GetDefaultItem() ; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, defaultBtn->GetId() ); + event.SetEventObject(defaultBtn); + defaultBtn->Command(event); + return ; + } + parent = parent->GetParent() ; + } ; + } + break; + } + case WXK_TAB: + // only produce navigation event if we don't process TAB ourself or + // if it's a Shift-Tab keypress (we assume nobody will ever need + // this key combo for himself) + // + // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is + // handled by Windows + if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) ) + { + wxNavigationKeyEvent eventNav; + eventNav.SetDirection(!event.ShiftDown()); + eventNav.SetWindowChange(FALSE); + eventNav.SetEventObject(this); + + if ( GetEventHandler()->ProcessEvent(eventNav) ) + return; + } + break; + } + if ( handleIt ) + { + EventRecord *ev = wxTheApp->MacGetCurrentEvent() ; + short keycode ; + short keychar ; + keychar = short(ev->message & charCodeMask); + keycode = short(ev->message & keyCodeMask) >> 8 ; + UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ; + if ( keychar >= 0x20 ) + { + { + wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); + wxString val(GetValue()); + if ( !val.IsNull() ) + event.m_commandString = WXSTRINGCAST val; + event.SetEventObject( this ); + ProcessCommand(event); + } + } + } +} // The streambuf code was partly taken from chapter 3 by Jerry Schwarz of // AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 3cb859e366..0620c12afb 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -14,6 +14,9 @@ #endif #include "wx/wx.h" + +#if wxUSE_TOOLBAR + #include "wx/toolbar.h" #if !USE_SHARED_LIBRARY @@ -23,6 +26,8 @@ BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase) END_EVENT_TABLE() #endif +#include + wxToolBar::wxToolBar() { m_maxWidth = -1; @@ -35,22 +40,36 @@ wxToolBar::wxToolBar() bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - m_maxWidth = -1; - m_maxHeight = -1; + m_maxWidth = -1; + m_maxHeight = -1; + + m_defaultWidth = 24; + m_defaultHeight = 22; - m_defaultWidth = 24; - m_defaultHeight = 22; - SetName(name); + int x = pos.x; + int y = pos.y; + int width = size.x; + int height = size.y; - m_windowStyle = style; + if (width <= 0) + width = 100; + if (height <= 0) + height = 30; + if (x < 0) + x = 0; + if (y < 0) + y = 0; - SetParent(parent); + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , wxPoint( x , y ) , wxSize( width , height ) ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; - if (parent) parent->AddChild(this); + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + kControlPlacardProc , (long) this ) ; + MacPostControlCreate() ; - // TODO create toolbar - - return FALSE; + return TRUE; } wxToolBar::~wxToolBar() @@ -58,19 +77,143 @@ wxToolBar::~wxToolBar() // TODO } +PicHandle MakePict(GWorldPtr wp) +{ + CGrafPtr origPort ; + GDHandle origDev ; + + PicHandle pict; // this is the Picture we give back + + RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ; + + GetGWorld( &origPort , &origDev ) ; + SetGWorld( wp , NULL ) ; + + pict = OpenPicture(&wp->portRect); // open a picture, this disables drawing + if(!pict) + return NULL; + + RGBBackColor( &gray ) ; + EraseRect(&wp->portRect) ; + CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself - + (BitMap*)*wp->portPixMap, // dst PixMap - no drawing occurs - + &wp->portRect, // srcRect - it will be recorded and compressed - + &wp->portRect, // dstRect - into the picture that is open - + srcCopy,NULL); // copyMode and no clip region + + ClosePicture(); // We are done recording the picture + SetGWorld( origPort , origDev ) ; + return pict; // return our groovy pict handle +} + +PicHandle MakePictWhite(GWorldPtr wp) +{ + CGrafPtr origPort ; + GDHandle origDev ; + + PicHandle pict; // this is the Picture we give back + + RGBColor white = { 0xFFFF ,0xFFFF , 0xFFFF } ; + + GetGWorld( &origPort , &origDev ) ; + SetGWorld( wp , NULL ) ; + + pict = OpenPicture(&wp->portRect); // open a picture, this disables drawing + if(!pict) + return NULL; + + RGBBackColor( &white ) ; + EraseRect(&wp->portRect) ; + CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself - + (BitMap*)*wp->portPixMap, // dst PixMap - no drawing occurs - + &wp->portRect, // srcRect - it will be recorded and compressed - + &wp->portRect, // dstRect - into the picture that is open - + srcCopy,NULL); // copyMode and no clip region + + ClosePicture(); // We are done recording the picture + SetGWorld( origPort , origDev ) ; + return pict; // return our groovy pict handle +} + +const short kwxMacToolBarTopMargin = 2 ; +const short kwxMacToolBarLeftMargin = 2 ; + bool wxToolBar::CreateTools() { - if (m_tools.Number() == 0) - return FALSE; + if (m_tools.Number() == 0) + return FALSE; - // TODO - return FALSE; + Rect toolbarrect = { m_y , m_x , m_y + m_height , m_x + m_width } ; + ControlFontStyleRec controlstyle ; + WindowPtr window = GetMacRootWindow() ; + controlstyle.flags = kControlUseFontMask ; + controlstyle.font = kControlFontSmallSystemFont ; + + wxNode *node = m_tools.First(); + int noButtons = 0; + int x = 0 ; + + while (node) + { + wxToolBarTool *tool = (wxToolBarTool *)node->Data(); + wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->m_bitmap1.GetRefData()) ; + + if( tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR ) + { + Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ; + toolrect.right = toolrect.left + m_defaultWidth ; + toolrect.bottom = toolrect.top + m_defaultHeight ; + + PicHandle icon = NULL ; + if ( bmap ) + { + if ( bmap->m_bitmapType == kMacBitmapTypePict ) + icon = bmap->m_hPict ; + else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) + { + icon = MakePict( bmap->m_hBitmap ) ; + } + } + + ControlHandle m_macToolHandle ; + + if ( icon ) + { + m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 , + kControlBehaviorOffsetContents + kControlContentPictHandle , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; + ControlButtonContentInfo info ; + + info.contentType = kControlContentPictHandle ; + info.u.picture = icon ; + + UMASetControlData( m_macToolHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; + } + else + { + m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 , + kControlBehaviorOffsetContents , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; + } + m_macToolHandles.Add( m_macToolHandle ) ; + UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ; + UMAEmbedControl( m_macToolHandle , m_macControl ) ; + + x += (int)m_defaultWidth; + noButtons ++; + } + else + { + m_macToolHandles.Add( NULL ) ; + x += (int)m_defaultWidth / 4; + } + node = node->Next(); + } + + return TRUE; } void wxToolBar::SetToolBitmapSize(const wxSize& size) { m_defaultWidth = size.x; m_defaultHeight = size.y; - // TODO } wxSize wxToolBar::GetMaxSize() const @@ -82,10 +225,21 @@ wxSize wxToolBar::GetMaxSize() const // The button size is bigger than the bitmap size wxSize wxToolBar::GetToolSize() const { - // TODO return wxSize(m_defaultWidth + 8, m_defaultHeight + 7); } +void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + int index = 0 ; + for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) + { + if ( m_macToolHandles[index] == (void*) control ) + { + OnLeftClick( ( (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ) ->m_index , ( (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ) ->m_toggleState ) ; + } + } +} + void wxToolBar::EnableTool(int toolIndex, bool enable) { wxNode *node = m_tools.Find((long)toolIndex); @@ -137,9 +291,11 @@ wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBit else tool->m_y = m_yMargin; - tool->SetSize(GetDefaultButtonWidth(), GetDefaultButtonHeight()); + tool->SetSize(m_defaultWidth, m_defaultHeight); m_tools.Append((long)index, tool); return tool; } +#endif // wxUSE_TOOLBAR + diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index 940bdc21bc..817138cb63 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -196,7 +196,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c } #endif // wxUSE_RESOURCES -static int wxBusyCursorCount = 0; +int wxBusyCursorCount = 0; +extern CursHandle gMacCurrentCursor ; +CursHandle gMacStoredActiveCursor = NULL ; // Set the cursor to the busy cursor for all windows void wxBeginBusyCursor(wxCursor *cursor) @@ -204,7 +206,8 @@ void wxBeginBusyCursor(wxCursor *cursor) wxBusyCursorCount ++; if (wxBusyCursorCount == 1) { - // TODO + gMacStoredActiveCursor = gMacCurrentCursor ; + ::SetCursor( *::GetCursor( watchCursor ) ) ; } else { @@ -221,7 +224,11 @@ void wxEndBusyCursor() wxBusyCursorCount --; if (wxBusyCursorCount == 0) { - // TODO + if ( gMacStoredActiveCursor ) + ::SetCursor( *gMacStoredActiveCursor ) ; + else + ::SetCursor( &qd.arrow ) ; + gMacStoredActiveCursor = NULL ; } } @@ -247,26 +254,40 @@ bool wxCheckForInterrupt(wxWindow *wnd) void wxGetMousePosition( int* x, int* y ) { - // TODO + Point pt ; + + GetMouse( &pt ) ; + LocalToGlobal( &pt ) ; + *x = pt.h ; + *y = pt.v ; }; // Return TRUE if we have a colour display bool wxColourDisplay() { - // TODO return TRUE; } // Returns depth of screen int wxDisplayDepth() { - // TODO - return 0; + // get max pixel depth + CGrafPtr port ; + GetCWMgrPort( &port ) ; + GDHandle maxDevice ; + + maxDevice = GetMaxDevice( &port->portRect ) ; + if ( maxDevice ) + return (**((**maxDevice).gdPMap)).pixelSize ; + else + return 8 ; } // Get size of display void wxDisplaySize(int *width, int *height) { - // TODO + *width = qd.screenBits.bounds.right - qd.screenBits.bounds.left ; + *height = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top ; + *height -= LMGetMBarHeight() ; } diff --git a/src/mac/carbon/wave.cpp b/src/mac/carbon/wave.cpp index c25681858c..804d07a097 100644 --- a/src/mac/carbon/wave.cpp +++ b/src/mac/carbon/wave.cpp @@ -15,7 +15,7 @@ #include "wx/object.h" #include "wx/string.h" -#include "wx/stubs/wave.h" +#include "wx/mac/wave.h" wxWave::wxWave() : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index a54fd3331d..e8015acc3b 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -17,7 +17,7 @@ #include "wx/menu.h" #include "wx/dc.h" #include "wx/dcclient.h" -#include "wx/utils.h" +#include "wx/utils.h" #include "wx/app.h" #include "wx/panel.h" #include "wx/layout.h" @@ -27,10 +27,20 @@ #include "wx/settings.h" #include "wx/msgdlg.h" #include "wx/frame.h" +#include "wx/notebook.h" +#include "wx/tabctrl.h" +// TODO remove the line below, just for lookup-up convenience CS +#include "wx/mac/window.h" #include "wx/menuitem.h" #include "wx/log.h" +#define wxWINDOW_HSCROLL 5998 +#define wxWINDOW_VSCROLL 5997 +#define MAC_SCROLLBAR_SIZE 16 + +#include + #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" #endif @@ -38,6 +48,7 @@ #include extern wxList wxPendingDelete; +wxWindow* gFocusWindow = NULL ; #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler) @@ -48,6 +59,7 @@ BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler) EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) EVT_INIT_DIALOG(wxWindow::OnInitDialog) EVT_IDLE(wxWindow::OnIdle) + EVT_PAINT(wxWindow::OnPaint) END_EVENT_TABLE() #endif @@ -56,37 +68,58 @@ END_EVENT_TABLE() // Constructor wxWindow::wxWindow() { - // Generic - m_windowId = 0; - m_windowStyle = 0; - m_windowParent = NULL; - m_windowEventHandler = this; - m_windowName = ""; - m_windowCursor = *wxSTANDARD_CURSOR; - m_children = new wxList; - m_constraints = NULL; - m_constraintsInvolvedIn = NULL; - m_windowSizer = NULL; - m_sizerParent = NULL; - m_autoLayout = FALSE; - m_windowValidator = NULL; - m_defaultItem = NULL; - m_returnCode = 0; - m_caretWidth = 0; m_caretHeight = 0; - m_caretEnabled = FALSE; - m_caretShown = FALSE; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; - // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; - m_foregroundColour = *wxBLACK; + Init() ; +} + +void wxWindow::Init() +{ + m_macWindowData = NULL ; + m_isWindow = TRUE; + m_x = 0; + m_y = 0 ; + m_width = 0 ; + m_height = 0 ; + // these are the defaults for MSW + m_macShown = true ; + m_macEnabled = true ; + // Generic + m_windowId = 0; + m_windowStyle = 0; + m_windowParent = NULL; + m_windowEventHandler = this; + m_windowName = ""; + m_windowCursor = *wxSTANDARD_CURSOR; + m_children = new wxWindowList; + m_constraints = NULL; + m_constraintsInvolvedIn = NULL; + m_windowSizer = NULL; + m_sizerParent = NULL; + m_autoLayout = FALSE; + m_windowValidator = NULL; + m_defaultItem = NULL; + m_returnCode = 0; + m_caretWidth = 0; m_caretHeight = 0; + m_caretEnabled = FALSE; + m_caretShown = FALSE; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; + // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_foregroundColour = *wxBLACK; + m_hScrollBar = NULL ; + m_vScrollBar = NULL ; + m_mouseInWindow = FALSE; #if wxUSE_DRAG_AND_DROP - m_pDropTarget = NULL; + m_pDropTarget = NULL; #endif } // Destructor wxWindow::~wxWindow() { + if ( s_lastMouseWindow == this ) + { + s_lastMouseWindow = NULL ; + } // Have to delete constraints/sizer FIRST otherwise // sizers may try to look at deleted windows as they // delete themselves. @@ -110,12 +143,24 @@ wxWindow::~wxWindow() m_sizerParent->RemoveChild((wxWindow *)this); #endif + if ( FindFocus() == this ) + { + // really a bad thing - maybe an error ? + // we cannot even send it a kill focus message at this stage + gFocusWindow = NULL ; + } + if (m_windowParent) m_windowParent->RemoveChild(this); DestroyChildren(); - // TODO: destroy the window + if ( m_macWindowData ) + { + UMADisposeWindow( m_macWindowData->m_macWindow ) ; + delete m_macWindowData ; + wxRemoveMacWindowAssociation( this ) ; + } delete m_children; m_children = NULL; @@ -143,7 +188,8 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - // Generic + m_isWindow = TRUE; + // Generic m_windowId = 0; m_windowStyle = 0; m_windowParent = NULL; @@ -182,7 +228,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, if ( id == -1 ) m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; @@ -193,31 +239,68 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, if ( id == -1 ) m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; - // TODO: create the window + m_x = (int)pos.x; + m_y = (int)pos.y; + AdjustForParentClientOrigin(m_x, m_y, wxSIZE_USE_EXISTING); + m_width = size.x; + m_height = size.y; + + MacCreateScrollBars( style ) ; return TRUE; } void wxWindow::SetFocus() { - // TODO + if ( AcceptsFocus() ) + { + if (gFocusWindow ) + { + wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ; + if ( control && control->GetMacControl() ) + { + UMASetKeyboardFocus( gFocusWindow->GetMacRootWindow() , control->GetMacControl() , kControlFocusNoPart ) ; + } + wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId); + event.SetEventObject(gFocusWindow); + gFocusWindow->GetEventHandler()->ProcessEvent(event) ; + } + gFocusWindow = this ; + { + wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ; + if ( control && control->GetMacControl() ) + { + UMASetKeyboardFocus( gFocusWindow->GetMacRootWindow() , control->GetMacControl() , kControlEditTextPart ) ; + } + + wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event) ; + } + } } void wxWindow::Enable(bool enable) { - // TODO + if ( m_macEnabled == enable ) + return ; + + m_macEnabled = enable ; + + MacSuperEnabled( enable ) ; + return; } void wxWindow::CaptureMouse() { - // TODO + wxTheApp->s_captureWindow = this ; } void wxWindow::ReleaseMouse() { - // TODO + wxTheApp->s_captureWindow = NULL ; } // Push/pop event handler (i.e. allow a chain of event handlers @@ -274,22 +357,85 @@ void wxWindow::DragAcceptFiles(bool accept) // Get total size void wxWindow::GetSize(int *x, int *y) const { - // TODO + *x = m_width ; + *y = m_height ; } void wxWindow::GetPosition(int *x, int *y) const { - // TODO + *x = m_x ; + *y = m_y ; + if (GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + *x -= pt.x; + *y -= pt.y; + } } void wxWindow::ScreenToClient(int *x, int *y) const { - // TODO + WindowRef window = GetMacRootWindow() ; + + Point localwhere ; + localwhere.h = * x ; + localwhere.v = * y ; + + GrafPtr port ; + ::GetPort( &port ) ; + ::SetPort( UMAGetWindowPort( window ) ) ; + ::GlobalToLocal( &localwhere ) ; + ::SetPort( port ) ; + + *x = localwhere.h ; + *y = localwhere.v ; + + MacRootWindowToClient( x , y ) ; } void wxWindow::ClientToScreen(int *x, int *y) const { - // TODO + WindowRef window = GetMacRootWindow() ; + + MacClientToRootWindow( x , y ) ; + + Point localwhere ; + localwhere.h = * x ; + localwhere.v = * y ; + + GrafPtr port ; + ::GetPort( &port ) ; + ::SetPort( UMAGetWindowPort( window ) ) ; + ::LocalToGlobal( &localwhere ) ; + ::SetPort( port ) ; + *x = localwhere.h ; + *y = localwhere.v ; +} + +void wxWindow::MacClientToRootWindow( int *x , int *y ) const +{ + if ( m_macWindowData ) + { + } + else + { + *x += m_x ; + *y += m_y ; + GetParent()->MacClientToRootWindow( x , y ) ; + } +} + +void wxWindow::MacRootWindowToClient( int *x , int *y ) const +{ + if ( m_macWindowData ) + { + } + else + { + *x -= m_x ; + *y -= m_y ; + GetParent()->MacRootWindowToClient( x , y ) ; + } } void wxWindow::SetCursor(const wxCursor& cursor) @@ -297,7 +443,9 @@ void wxWindow::SetCursor(const wxCursor& cursor) m_windowCursor = cursor; if (m_windowCursor.Ok()) { - // TODO + // since this only affects the window-cursor, we adopt the same + // behaviour as windows -> it will only change on mouse moved events + // otherwise the ::WxSetCursor routine will have to be used } } @@ -305,21 +453,132 @@ void wxWindow::SetCursor(const wxCursor& cursor) // Get size *available for subwindows* i.e. excluding menu bar etc. void wxWindow::GetClientSize(int *x, int *y) const { - // TODO -} + *x = m_width ; + *y = m_height ; + + if (m_vScrollBar && m_vScrollBar->IsShown() ) + (*x) -= MAC_SCROLLBAR_SIZE; + if (m_hScrollBar && m_hScrollBar->IsShown() ) + (*y) -= MAC_SCROLLBAR_SIZE; +} + +void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) +{ + int former_x = m_x ; + int former_y = m_y ; + int former_w = m_width ; + int former_h = m_height ; + + int currentX, currentY; + GetPosition(¤tX, ¤tY); + int currentW,currentH; + GetSize(¤tW, ¤tH); + + int actualWidth = width; + int actualHeight = height; + int actualX = x; + int actualY = y; + if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + actualX = currentX; + if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + actualY = currentY; + if (width == -1) + actualWidth = currentW ; + if (height == -1) + actualHeight = currentH ; + + if ( actualX == currentX && actualY == currentY && actualWidth == currentW && actualHeight == currentH) + { + MacRepositionScrollBars() ; // we might have a real position shift + return ; + } -void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO -} + AdjustForParentClientOrigin(actualX, actualY, sizeFlags); + + + bool doMove = false ; + bool doResize = false ; + + if ( actualX != former_x || actualY != former_y ) + { + doMove = true ; + } + if ( actualWidth != former_w || actualHeight != former_h ) + { + doResize = true ; + } -void wxWindow::SetClientSize(int width, int height) -{ - // TODO + if ( doMove || doResize ) + { + if ( m_macWindowData ) + { + } + else + { + // erase former position + { + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + Rect clientrect = { 0 , 0 , m_height , m_width } ; + InvalRect( &clientrect ) ; + } + } + } + m_x = actualX ; + m_y = actualY ; + m_width = actualWidth ; + m_height = actualHeight ; + if ( m_macWindowData ) + { + if ( doMove ) + ::MoveWindow(m_macWindowData->m_macWindow, m_x, m_y, false); // don't make frontmost + + if ( doResize ) + ::SizeWindow(m_macWindowData->m_macWindow, m_width, m_height, true); + + // the OS takes care of invalidating and erasing + + if ( IsKindOf( CLASSINFO( wxFrame ) ) ) + { + wxFrame* frame = (wxFrame*) this ; + frame->PositionStatusBar(); + frame->PositionToolBar(); + } + } + else + { + // erase new position + { + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + Rect clientrect = { 0 , 0 , m_height , m_width } ; + InvalRect( &clientrect ) ; + } + } + if ( doMove ) + wxWindow::MacSuperChangedPosition() ; // like this only children will be notified + } + MacRepositionScrollBars() ; + if ( doMove ) + { + wxMoveEvent event(wxPoint(m_x, m_y), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event) ; + } + if ( doResize ) + { + MacRepositionScrollBars() ; + wxSizeEvent event(wxSize(m_width, m_height), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + } } - // For implementation purposes - sometimes decorations make the client area // smaller + wxPoint wxWindow::GetClientAreaOrigin() const { return wxPoint(0, 0); @@ -329,35 +588,118 @@ wxPoint wxWindow::GetClientAreaOrigin() const // a toolbar that it manages itself). void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) { + if( !m_macWindowData ) + { if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) { wxPoint pt(GetParent()->GetClientAreaOrigin()); x += pt.x; y += pt.y; } + } +} + +void wxWindow::SetTitle(const wxString& title) +{ + wxString label ; + + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( title ) ; + else + label = title ; + + if ( m_macWindowData ) + UMASetWTitleC( m_macWindowData->m_macWindow , label ) ; +} + +wxString wxWindow::GetTitle() const +{ + if ( m_macWindowData ) + { + char title[256] ; + wxString label ; + UMAGetWTitleC( m_macWindowData->m_macWindow , title ) ; + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakePCStringFromMac( title ) ; + else + label = title ; + return label; + } + + return wxEmptyString ; +} + +void wxWindow::Centre(int direction) +{ + int x_offset,y_offset ; + int display_width, display_height; + int width, height, x, y; + wxWindow *parent = GetParent(); + if ((direction & wxCENTER_FRAME) && parent) + { + parent->GetPosition(&x_offset,&y_offset) ; + parent->GetSize(&display_width,&display_height) ; + } + else + { + wxDisplaySize(&display_width, &display_height); + x_offset = 0 ; + y_offset = LMGetMBarHeight() + LMGetMBarHeight() / 2 ; // approx. the window title height + } + + GetSize(&width, &height); + GetPosition(&x, &y); + + if (direction & wxHORIZONTAL) + x = (int)((display_width - width)/2); + if (direction & wxVERTICAL) + y = (int)((display_height - height)/2); + + SetSize(x+x_offset, y+y_offset, width, height); } + bool wxWindow::Show(bool show) { - // TODO - return FALSE; + if ( m_macShown == show ) + return TRUE ; + + m_macShown = show ; + if ( m_macWindowData ) + { + if (show) + { + UMAShowWindow( m_macWindowData->m_macWindow ) ; + UMASelectWindow( m_macWindowData->m_macWindow ) ; + // no need to generate events here, they will get them triggered by macos + wxSizeEvent event(wxSize(m_width, m_height), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + else + { + UMAHideWindow( m_macWindowData->m_macWindow ) ; + } + } + Refresh() ; + MacSuperShown( show ) ; + return TRUE; } bool wxWindow::IsShown() const { - // TODO - return FALSE; + return m_macShown; } int wxWindow::GetCharHeight() const { - // TODO - return 0; + wxClientDC dc ( (wxWindow*)this ) ; + return dc.GetCharHeight() ; } int wxWindow::GetCharWidth() const { - // TODO - return 0; + wxClientDC dc ( (wxWindow*)this ) ; + return dc.GetCharWidth() ; } void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, @@ -370,9 +712,104 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, // TODO } +void wxWindow::MacEraseBackground( Rect *rect ) +{ + WindowRef window = GetMacRootWindow() ; + if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) ) + { + UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ; + } + else if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) ) + { + // 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 + + wxWindow* parent = GetParent() ; + while( parent ) + { + if ( parent->m_backgroundColour != wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) ) + { + // if we have any other colours in the hierarchy + RGBBackColor( &parent->m_backgroundColour.GetPixel()) ; + break ; + } + if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() ) + { + // 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 ) )) + { + ApplyThemeBackground (kThemeBackgroundTabPane, rect, kThemeStateActive,8,true); + break ; + } + } + else + { + // we have arrived at a non control item + parent = NULL ; + break ; + } + parent = parent->GetParent() ; + } + if ( !parent ) + { + // if there is nothing special -> use default + UMASetThemeWindowBackground( window , kThemeBrushDialogBackgroundActive , false ) ; + } + } + else + { + RGBBackColor( &m_backgroundColour.GetPixel()) ; + } + + EraseRect( rect ) ; + + for (wxNode *node = m_children->First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); +// int width ; +// int height ; + +// child->GetClientSize( &width , &height ) ; + + Rect clientrect = { child->m_x , child->m_y , child->m_x +child->m_width , child->m_y + child->m_height } ; + SectRect( &clientrect , rect , &clientrect ) ; + + OffsetRect( &clientrect , -child->m_x , -child->m_y ) ; + if ( child->GetMacRootWindow() == window && child->IsReallyShown() ) + { + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + child->MacEraseBackground( &clientrect ) ; + } + } + } +} + void wxWindow::Refresh(bool eraseBack, const wxRect *rect) { - // TODO + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + int width , height ; + GetClientSize( &width , &height ) ; + Rect clientrect = { 0 , 0 , height , width } ; + ClipRect( &clientrect ) ; + + if ( rect ) + { + Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ; + SectRect( &clientrect , &r , &clientrect ) ; + } + InvalRect( &clientrect ) ; + /* + if ( eraseBack ) + { + MacEraseBackground( &clientrect ) ; + } + */ + } } // Responds to colour changes: passes event on to children. @@ -451,7 +888,7 @@ void wxWindow::GetCaretPos(int *x, int *y) const wxWindow *wxGetActiveWindow() { - // TODO + // actually this is a windows-only concept return NULL; } @@ -463,46 +900,31 @@ void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED m_maxSizeY = maxH; } -void wxWindow::Centre(int direction) -{ - int x, y, width, height, panel_width, panel_height, new_x, new_y; - - wxWindow *father = (wxWindow *)GetParent(); - if (!father) - return; - - father->GetClientSize(&panel_width, &panel_height); - GetSize(&width, &height); - GetPosition(&x, &y); - - new_x = -1; - new_y = -1; - - if (direction & wxHORIZONTAL) - new_x = (int)((panel_width - width)/2); - - if (direction & wxVERTICAL) - new_y = (int)((panel_height - height)/2); - - SetSize(new_x, new_y, -1, -1); - -} // Coordinates relative to the window void wxWindow::WarpPointer (int x_pos, int y_pos) { - // TODO + // We really dont move the mouse programmatically under mac } void wxWindow::OnEraseBackground(wxEraseEvent& event) { - // TODO + // TODO : probably we would adopt the EraseEvent structure Default(); } int wxWindow::GetScrollPos(int orient) const { - // TODO + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + return m_hScrollBar->GetThumbPosition() ; + } + else + { + if ( m_vScrollBar ) + return m_vScrollBar->GetThumbPosition() ; + } return 0; } @@ -510,34 +932,110 @@ int wxWindow::GetScrollPos(int orient) const // of positions that we can scroll. int wxWindow::GetScrollRange(int orient) const { - // TODO + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + return m_hScrollBar->GetRange() ; + } + else + { + if ( m_vScrollBar ) + return m_vScrollBar->GetRange() ; + } return 0; } int wxWindow::GetScrollThumb(int orient) const { - // TODO + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + return m_hScrollBar->GetThumbSize() ; + } + else + { + if ( m_vScrollBar ) + return m_vScrollBar->GetThumbSize() ; + } return 0; } void wxWindow::SetScrollPos(int orient, int pos, bool refresh) { - // TODO - return; + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + m_hScrollBar->SetThumbPosition( pos ) ; + } + else + { + if ( m_vScrollBar ) + m_vScrollBar->SetThumbPosition( pos ) ; + } } // New function that will replace some of the above. void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, int range, bool refresh) { - // TODO + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + { + 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 , refresh ) ; + } + } + } + else + { + if ( m_vScrollBar ) + { + 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 , refresh ) ; + } + } + } + MacRepositionScrollBars() ; } // Does a physical scroll void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) { - // TODO - return; + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + int width , height ; + GetClientSize( &width , &height ) ; + Rect scrollrect = { 0 , 0 , height , width } ; + + RgnHandle updateRgn = NewRgn() ; + ClipRect( &scrollrect ) ; + if ( rect ) + { + Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ; + SectRect( &scrollrect , &r , &scrollrect ) ; + } + ScrollRect( &scrollrect , dx , dy , updateRgn ) ; + InvalRgn( updateRgn ) ; + DisposeRgn( updateRgn ) ; + } } void wxWindow::SetFont(const wxFont& font) @@ -563,13 +1061,31 @@ void wxWindow::OnChar(wxKeyEvent& event) void wxWindow::OnPaint(wxPaintEvent& event) { - Default(); +/* + if ( m_macWindowData ) + { + wxMacDrawingClientHelper helper ( this ) ; + long x ,y ,w ,h ; + GetUpdateRegion().GetBox( x , y , w , h ) ; + UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ; + Rect r = { y , x, y+h , x+w } ; + EraseRect( &r ) ; + } + else + { + wxMacDrawingClientHelper helper ( this ) ; + long x ,y ,w ,h ; + GetUpdateRegion().GetBox( x , y , w , h ) ; + RGBBackColor( &m_backgroundColour.GetPixel() ) ; + Rect r = { y , x, y+h , x+w } ; + EraseRect( &r ) ; + } +*/ } bool wxWindow::IsEnabled() const { - // TODO - return FALSE; + return m_macEnabled ; } // Dialog support: override these and call @@ -636,8 +1152,16 @@ bool wxWindow::Validate() // Get the window with the focus wxWindow *wxWindow::FindFocus() { - // TODO - return NULL; + return gFocusWindow ; +} + +// ---------------------------------------------------------------------------- +// RTTI +// ---------------------------------------------------------------------------- + +bool wxWindow::IsTopLevel() const +{ + return wxDynamicCast(this, wxFrame) || wxDynamicCast(this, wxDialog); } void wxWindow::AddChild(wxWindow *child) @@ -659,7 +1183,7 @@ void wxWindow::DestroyChildren() wxWindow *child; if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) { delete child; - if ( GetChildren().Member(child) ) + if ( GetChildren().Find(child) ) delete node; } } /* while */ @@ -693,419 +1217,384 @@ void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event) m_windowParent->GetEventHandler()->OnCommand(win, event); } -void wxWindow::SetConstraints(wxLayoutConstraints *c) +// ---------------------------------------------------------------------------- +// constraints and sizers +// ---------------------------------------------------------------------------- + +#if wxUSE_CONSTRAINTS + +void wxWindow::SetConstraints( wxLayoutConstraints *constraints ) { - if (m_constraints) - { - UnsetConstraints(m_constraints); - delete m_constraints; - } - m_constraints = c; - if (m_constraints) - { - // Make sure other windows know they're part of a 'meaningful relationship' - if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this)) - m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this)) - m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this)) - m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this)) - m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this)) - m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this)) - m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this)) - m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this)) - m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - } + if ( m_constraints ) + { + UnsetConstraints(m_constraints); + delete m_constraints; + } + m_constraints = constraints; + if ( m_constraints ) + { + // Make sure other windows know they're part of a 'meaningful relationship' + if ( m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this) ) + m_constraints->left.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this) ) + m_constraints->top.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this) ) + m_constraints->right.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this) ) + m_constraints->bottom.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this) ) + m_constraints->width.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this) ) + m_constraints->height.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this) ) + m_constraints->centreX.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this) ) + m_constraints->centreY.GetOtherWindow()->AddConstraintReference(this); + } } -// This removes any dangling pointers to this window -// in other windows' constraintsInvolvedIn lists. +// This removes any dangling pointers to this window in other windows' +// constraintsInvolvedIn lists. void wxWindow::UnsetConstraints(wxLayoutConstraints *c) { - if (c) - { - if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this)) - c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this)) - c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this)) - c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this)) - c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this)) - c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this)) - c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this)) - c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this)) - c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - } + if ( c ) + { + if ( c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) + c->left.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) + c->top.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this) ) + c->right.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this) ) + c->bottom.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this) ) + c->width.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this) ) + c->height.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this) ) + c->centreX.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this) ) + c->centreY.GetOtherWindow()->RemoveConstraintReference(this); + } } -// Back-pointer to other windows we're involved with, so if we delete -// this window, we must delete any constraints we're involved with. +// Back-pointer to other windows we're involved with, so if we delete this +// window, we must delete any constraints we're involved with. void wxWindow::AddConstraintReference(wxWindow *otherWin) { - if (!m_constraintsInvolvedIn) - m_constraintsInvolvedIn = new wxList; - if (!m_constraintsInvolvedIn->Member(otherWin)) - m_constraintsInvolvedIn->Append(otherWin); + if ( !m_constraintsInvolvedIn ) + m_constraintsInvolvedIn = new wxWindowList; + if ( !m_constraintsInvolvedIn->Find(otherWin) ) + m_constraintsInvolvedIn->Append(otherWin); } // REMOVE back-pointer to other windows we're involved with. void wxWindow::RemoveConstraintReference(wxWindow *otherWin) { - if (m_constraintsInvolvedIn) - m_constraintsInvolvedIn->DeleteObject(otherWin); + if ( m_constraintsInvolvedIn ) + m_constraintsInvolvedIn->DeleteObject(otherWin); } // Reset any constraints that mention this window void wxWindow::DeleteRelatedConstraints() { - if (m_constraintsInvolvedIn) - { - wxNode *node = m_constraintsInvolvedIn->First(); - while (node) + if ( m_constraintsInvolvedIn ) { - wxWindow *win = (wxWindow *)node->Data(); - wxNode *next = node->Next(); - wxLayoutConstraints *constr = win->GetConstraints(); - - // Reset any constraints involving this window - if (constr) - { - constr->left.ResetIfWin((wxWindow *)this); - constr->top.ResetIfWin((wxWindow *)this); - constr->right.ResetIfWin((wxWindow *)this); - constr->bottom.ResetIfWin((wxWindow *)this); - constr->width.ResetIfWin((wxWindow *)this); - constr->height.ResetIfWin((wxWindow *)this); - constr->centreX.ResetIfWin((wxWindow *)this); - constr->centreY.ResetIfWin((wxWindow *)this); - } - delete node; - node = next; + wxWindowList::Node *node = m_constraintsInvolvedIn->GetFirst(); + while (node) + { + wxWindow *win = node->GetData(); + wxLayoutConstraints *constr = win->GetConstraints(); + + // Reset any constraints involving this window + if ( constr ) + { + constr->left.ResetIfWin(this); + constr->top.ResetIfWin(this); + constr->right.ResetIfWin(this); + constr->bottom.ResetIfWin(this); + constr->width.ResetIfWin(this); + constr->height.ResetIfWin(this); + constr->centreX.ResetIfWin(this); + constr->centreY.ResetIfWin(this); + } + + wxWindowList::Node *next = node->GetNext(); + delete node; + node = next; + } + + delete m_constraintsInvolvedIn; + m_constraintsInvolvedIn = (wxWindowList *) NULL; } - delete m_constraintsInvolvedIn; - m_constraintsInvolvedIn = NULL; - } } void wxWindow::SetSizer(wxSizer *sizer) { - m_windowSizer = sizer; - if (sizer) - sizer->SetSizerParent((wxWindow *)this); + if (m_windowSizer) delete m_windowSizer; + + m_windowSizer = sizer; } -/* - * New version - */ - bool wxWindow::Layout() { - if (GetConstraints()) - { int w, h; GetClientSize(&w, &h); - GetConstraints()->width.SetValue(w); - GetConstraints()->height.SetValue(h); - } - - // If top level (one sizer), evaluate the sizer's constraints. - if (GetSizer()) - { - int noChanges; - GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated - GetSizer()->LayoutPhase1(&noChanges); - GetSizer()->LayoutPhase2(&noChanges); - GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes - return TRUE; - } - else - { - // Otherwise, evaluate child constraints + + // If there is a sizer, use it instead of the constraints + if ( GetSizer() ) + { + GetSizer()->SetDimension( 0, 0, w, h ); + return TRUE; + } + + if ( GetConstraints() ) + { + GetConstraints()->width.SetValue(w); + GetConstraints()->height.SetValue(h); + } + + // Evaluate child constraints ResetConstraints(); // Mark all constraints as unevaluated DoPhase(1); // Just one phase need if no sizers involved DoPhase(2); SetConstraintSizes(); // Recursively set the real window sizes - } - return TRUE; + + return TRUE; } -// Do a phase of evaluating constraints: -// the default behaviour. wxSizers may do a similar -// thing, but also impose their own 'constraints' -// and order the evaluation differently. +// Do a phase of evaluating constraints: the default behaviour. wxSizers may +// do a similar thing, but also impose their own 'constraints' and order the +// evaluation differently. bool wxWindow::LayoutPhase1(int *noChanges) { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - return constr->SatisfyConstraints((wxWindow *)this, noChanges); - } - else - return TRUE; + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + return constr->SatisfyConstraints(this, noChanges); + } + else + return TRUE; } bool wxWindow::LayoutPhase2(int *noChanges) { - *noChanges = 0; - - // Layout children - DoPhase(1); - DoPhase(2); - return TRUE; + *noChanges = 0; + + // Layout children + DoPhase(1); + DoPhase(2); + return TRUE; } // Do a phase of evaluating child constraints bool wxWindow::DoPhase(int phase) { - int noIterations = 0; - int maxIterations = 500; - int noChanges = 1; - int noFailures = 0; - wxList succeeded; - while ((noChanges > 0) && (noIterations < maxIterations)) - { - noChanges = 0; - noFailures = 0; - wxNode *node = GetChildren().First(); - while (node) + int noIterations = 0; + int maxIterations = 500; + int noChanges = 1; + int noFailures = 0; + wxWindowList succeeded; + while ((noChanges > 0) && (noIterations < maxIterations)) { - wxWindow *child = (wxWindow *)node->Data(); - if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog))) - { - wxLayoutConstraints *constr = child->GetConstraints(); - if (constr) + noChanges = 0; + noFailures = 0; + wxWindowList::Node *node = GetChildren().GetFirst(); + while (node) { - if (succeeded.Member(child)) - { - } - else - { - int tempNoChanges = 0; - bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; - noChanges += tempNoChanges; - if (success) + wxWindow *child = node->GetData(); + if ( !child->IsTopLevel() ) { - succeeded.Append(child); + wxLayoutConstraints *constr = child->GetConstraints(); + if ( constr ) + { + if ( !succeeded.Find(child) ) + { + int tempNoChanges = 0; + bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; + noChanges += tempNoChanges; + if ( success ) + { + succeeded.Append(child); + } + } + } } - } + node = node->GetNext(); } - } - node = node->Next(); + + noIterations++; } - noIterations ++; - } - return TRUE; + + return TRUE; } void wxWindow::ResetConstraints() { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - constr->left.SetDone(FALSE); - constr->top.SetDone(FALSE); - constr->right.SetDone(FALSE); - constr->bottom.SetDone(FALSE); - constr->width.SetDone(FALSE); - constr->height.SetDone(FALSE); - constr->centreX.SetDone(FALSE); - constr->centreY.SetDone(FALSE); - } - wxNode *node = GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) - win->ResetConstraints(); - node = node->Next(); - } + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + constr->left.SetDone(FALSE); + constr->top.SetDone(FALSE); + constr->right.SetDone(FALSE); + constr->bottom.SetDone(FALSE); + constr->width.SetDone(FALSE); + constr->height.SetDone(FALSE); + constr->centreX.SetDone(FALSE); + constr->centreY.SetDone(FALSE); + } + wxWindowList::Node *node = GetChildren().GetFirst(); + while (node) + { + wxWindow *win = node->GetData(); + if ( !win->IsTopLevel() ) + win->ResetConstraints(); + node = node->GetNext(); + } } -// Need to distinguish between setting the 'fake' size for -// windows and sizers, and setting the real values. +// Need to distinguish between setting the 'fake' size for windows and sizers, +// and setting the real values. void wxWindow::SetConstraintSizes(bool recurse) { - wxLayoutConstraints *constr = GetConstraints(); - if (constr && constr->left.GetDone() && constr->right.GetDone() && - constr->width.GetDone() && constr->height.GetDone()) - { - int x = constr->left.GetValue(); - int y = constr->top.GetValue(); - int w = constr->width.GetValue(); - int h = constr->height.GetValue(); - - // If we don't want to resize this window, just move it... - if ((constr->width.GetRelationship() != wxAsIs) || - (constr->height.GetRelationship() != wxAsIs)) + wxLayoutConstraints *constr = GetConstraints(); + if ( constr && constr->left.GetDone() && constr->right.GetDone( ) && + constr->width.GetDone() && constr->height.GetDone()) { - // Calls Layout() recursively. AAAGH. How can we stop that. - // Simply take Layout() out of non-top level OnSizes. - SizerSetSize(x, y, w, h); + int x = constr->left.GetValue(); + int y = constr->top.GetValue(); + int w = constr->width.GetValue(); + int h = constr->height.GetValue(); + + if ( (constr->width.GetRelationship() != wxAsIs ) || + (constr->height.GetRelationship() != wxAsIs) ) + { + SetSize(x, y, w, h); + } + else + { + // If we don't want to resize this window, just move it... + Move(x, y); + } } - else + else if ( constr ) { - SizerMove(x, y); + char *windowClass = GetClassInfo()->GetClassName(); + + wxString winName; + if ( GetName() == _T("") ) + winName = _T("unnamed"); + else + winName = GetName(); + wxLogDebug( _T("Constraint(s) not satisfied for window of type %s, name %s:\n"), + (const char *)windowClass, + (const char *)winName); + if ( !constr->left.GetDone()) wxLogDebug( _T(" unsatisfied 'left' constraint.\n") ); + if ( !constr->right.GetDone()) wxLogDebug( _T(" unsatisfied 'right' constraint.\n") ); + if ( !constr->width.GetDone()) wxLogDebug( _T(" unsatisfied 'width' constraint.\n") ); + if ( !constr->height.GetDone()) wxLogDebug( _T(" unsatisfied 'height' constraint.\n") ); + wxLogDebug( _T("Please check constraints: try adding AsIs() constraints.\n") ); } - } - else if (constr) - { - char *windowClass = this->GetClassInfo()->GetClassName(); - wxString winName; - if (GetName() == "") - winName = "unnamed"; - else - winName = GetName(); - wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName); - if (!constr->left.GetDone()) - wxDebugMsg(" unsatisfied 'left' constraint.\n"); - if (!constr->right.GetDone()) - wxDebugMsg(" unsatisfied 'right' constraint.\n"); - if (!constr->width.GetDone()) - wxDebugMsg(" unsatisfied 'width' constraint.\n"); - if (!constr->height.GetDone()) - wxDebugMsg(" unsatisfied 'height' constraint.\n"); - wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n"); - } - - if (recurse) - { - wxNode *node = GetChildren().First(); - while (node) + if ( recurse ) { - wxWindow *win = (wxWindow *)node->Data(); - if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) - win->SetConstraintSizes(); - node = node->Next(); + wxWindowList::Node *node = GetChildren().GetFirst(); + while (node) + { + wxWindow *win = node->GetData(); + if ( !win->IsTopLevel() ) + win->SetConstraintSizes(); + node = node->GetNext(); + } } - } -} - -// This assumes that all sizers are 'on' the same -// window, i.e. the parent of this window. -void wxWindow::TransformSizerToActual(int *x, int *y) const -{ - if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) || - m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) ) - return; - - int xp, yp; - m_sizerParent->GetPosition(&xp, &yp); - m_sizerParent->TransformSizerToActual(&xp, &yp); - *x += xp; - *y += yp; -} - -void wxWindow::SizerSetSize(int x, int y, int w, int h) -{ - int xx = x; - int yy = y; - TransformSizerToActual(&xx, &yy); - SetSize(xx, yy, w, h); -} - -void wxWindow::SizerMove(int x, int y) -{ - int xx = x; - int yy = y; - TransformSizerToActual(&xx, &yy); - Move(xx, yy); } // Only set the size/position of the constraint (if any) void wxWindow::SetSizeConstraint(int x, int y, int w, int h) { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - if (x != -1) - { - constr->left.SetValue(x); - constr->left.SetDone(TRUE); - } - if (y != -1) + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) { - constr->top.SetValue(y); - constr->top.SetDone(TRUE); - } - if (w != -1) - { - constr->width.SetValue(w); - constr->width.SetDone(TRUE); - } - if (h != -1) - { - constr->height.SetValue(h); - constr->height.SetDone(TRUE); + if ( x != -1 ) + { + constr->left.SetValue(x); + constr->left.SetDone(TRUE); + } + if ( y != -1 ) + { + constr->top.SetValue(y); + constr->top.SetDone(TRUE); + } + if ( w != -1 ) + { + constr->width.SetValue(w); + constr->width.SetDone(TRUE); + } + if ( h != -1 ) + { + constr->height.SetValue(h); + constr->height.SetDone(TRUE); + } } - } } void wxWindow::MoveConstraint(int x, int y) { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - if (x != -1) - { - constr->left.SetValue(x); - constr->left.SetDone(TRUE); - } - if (y != -1) + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) { - constr->top.SetValue(y); - constr->top.SetDone(TRUE); + if ( x != -1 ) + { + constr->left.SetValue(x); + constr->left.SetDone(TRUE); + } + if ( y != -1 ) + { + constr->top.SetValue(y); + constr->top.SetDone(TRUE); + } } - } } void wxWindow::GetSizeConstraint(int *w, int *h) const { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *w = constr->width.GetValue(); - *h = constr->height.GetValue(); - } - else - GetSize(w, h); + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + *w = constr->width.GetValue(); + *h = constr->height.GetValue(); + } + else + GetSize(w, h); } void wxWindow::GetClientSizeConstraint(int *w, int *h) const { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *w = constr->width.GetValue(); - *h = constr->height.GetValue(); - } - else - GetClientSize(w, h); + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + *w = constr->width.GetValue(); + *h = constr->height.GetValue(); + } + else + GetClientSize(w, h); } void wxWindow::GetPositionConstraint(int *x, int *y) const { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *x = constr->left.GetValue(); - *y = constr->top.GetValue(); - } - else - GetPosition(x, y); + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + *x = constr->left.GetValue(); + *y = constr->top.GetValue(); + } + else + GetPosition(x, y); } +#endif // wxUSE_CONSTRAINTS + bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); @@ -1141,10 +1630,23 @@ void wxWindow::OnDefaultAction(wxControl *initiatingItem) void wxWindow::Clear() { - wxClientDC dc(this); + if ( m_macWindowData ) + { + wxMacDrawingClientHelper helper ( this ) ; + int w ,h ; + wxPoint origin = GetClientAreaOrigin() ; + GetClientSize( &w , &h ) ; + UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ; + Rect r = { origin.y , origin.x, origin.y+h , origin.x+w } ; + EraseRect( &r ) ; + } + else + { + wxClientDC dc(this); wxBrush brush(GetBackgroundColour(), wxSOLID); dc.SetBackground(brush); dc.Clear(); + } } // Fits the panel around the items @@ -1221,20 +1723,18 @@ wxWindow *wxWindow::FindWindow(const wxString& name) void wxWindow::OnIdle(wxIdleEvent& event) { -/* TODO: you may need to do something like this - * if your GUI doesn't generate enter/leave events - - // Check if we need to send a LEAVE event - if (m_mouseInWindow) - { - POINT pt; - ::GetCursorPos(&pt); - if (::WindowFromPoint(pt) != (HWND) GetHWND()) - { - // Generate a LEAVE event - m_mouseInWindow = FALSE; - MSWOnMouseLeave(pt.x, pt.y, 0); - } +/* + // Check if we need to send a LEAVE event + if (m_mouseInWindow) + { + POINT pt; + ::GetCursorPos(&pt); + if (::WindowFromPoint(pt) != (HWND) GetHWND()) + { + // Generate a LEAVE event + m_mouseInWindow = FALSE; + MSWOnMouseLeave(pt.x, pt.y, 0); + } } */ @@ -1257,7 +1757,7 @@ void wxWindow::Lower() bool wxWindow::AcceptsFocus() const { - return IsShown() && IsEnabled(); + return IsShown() && IsEnabled() && MacCanFocus() ; } // Update region access @@ -1292,4 +1792,818 @@ int wxWindow::NewControlId() return s_controlId; } +void wxWindow::DoSetClientSize(int width, int height) +{ + if ( width != -1 || height != -1 ) + { + + if ( width != -1 && m_vScrollBar ) + width += MAC_SCROLLBAR_SIZE ; + if ( height != -1 && m_vScrollBar ) + height += MAC_SCROLLBAR_SIZE ; + + DoSetSize( -1 , -1 , width , height ) ; + } +} + +// ------------------------ +wxList *wxWinMacWindowList = NULL; +wxWindow *wxFindWinFromMacWindow(WindowRef inWindowRef) +{ + wxNode *node = wxWinMacWindowList->Find((long)inWindowRef); + if (!node) + return NULL; + return (wxWindow *)node->Data(); +} + +void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxWindow *win) +{ + // adding NULL WindowRef is (first) surely a result of an error and + // (secondly) breaks menu command processing + wxCHECK_RET( inWindowRef != (WindowRef) NULL, "attempt to add a NULL WindowRef to window list" ); + + if ( !wxWinMacWindowList->Find((long)inWindowRef) ) + wxWinMacWindowList->Append((long)inWindowRef, win); +} + +void wxRemoveMacWindowAssociation(wxWindow *win) +{ + wxWinMacWindowList->DeleteObject(win); +} + +wxWindow* wxWindow::s_lastMouseWindow = NULL ; + +bool wxWindow::MacGetWindowFromPointSub( const wxPoint &point , wxWindow** outWin ) +{ + 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 = GetMacRootWindow() ; + + wxPoint newPoint( point ) ; + + newPoint.x -= m_x; + newPoint.y -= m_y; + + if ( m_children ) + { + for (wxNode *node = m_children->First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); + if ( child->GetMacRootWindow() == window ) + { + if (child->MacGetWindowFromPointSub(newPoint , outWin )) + return TRUE; + } + } + } + + *outWin = this ; + return TRUE; +} + +bool wxWindow::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindow** outWin ) +{ + WindowRef window ; + Point pt = { screenpoint.y , screenpoint.x } ; + if ( ::FindWindow( pt , &window ) == 3 ) + { + wxPoint point( screenpoint ) ; + wxWindow* win = wxFindWinFromMacWindow( window ) ; + win->ScreenToClient( point ) ; + return win->MacGetWindowFromPointSub( point , outWin ) ; + } + return FALSE ; +} + +extern int wxBusyCursorCount ; + +bool wxWindow::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 ) ) ) + return FALSE ; + + WindowRef window = GetMacRootWindow() ; + + event.m_x -= m_x; + event.m_y -= m_y; + + int x = event.m_x ; + int y = event.m_y ; + + if ( m_children ) + { + for (wxNode *node = m_children->First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); + if ( child->GetMacRootWindow() == window && child->IsReallyShown() && child->IsReallyEnabled() ) + { + if (child->MacDispatchMouseEvent(event)) + return TRUE; + } + } + } + + event.m_x = x ; + event.m_y = y ; + + if ( wxBusyCursorCount == 0 ) + { + m_windowCursor.MacInstall() ; + } + GetEventHandler()->ProcessEvent( event ) ; + return TRUE; +} + +void wxWindow::MacFireMouseEvent( EventRecord *ev ) +{ + wxMouseEvent event(wxEVT_LEFT_DOWN); + bool isDown = !(ev->modifiers & btnState) ; // 1 is for up + bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse + + event.m_leftDown = isDown && !controlDown; + event.m_middleDown = FALSE; + event.m_rightDown = isDown && controlDown; + + if ( ev->what == mouseDown ) + { + if ( controlDown ) + event.SetEventType(wxEVT_RIGHT_DOWN ) ; + else + event.SetEventType(wxEVT_LEFT_DOWN ) ; + } + else if ( ev->what == mouseUp ) + { + if ( controlDown ) + event.SetEventType(wxEVT_RIGHT_UP ) ; + else + event.SetEventType(wxEVT_LEFT_UP ) ; + } + else + { + event.SetEventType(wxEVT_MOTION ) ; + } + + event.m_shiftDown = ev->modifiers & shiftKey; + event.m_controlDown = ev->modifiers & controlKey; + event.m_altDown = ev->modifiers & optionKey; + event.m_metaDown = ev->modifiers & cmdKey; + + Point localwhere = ev->where ; + + GrafPtr port ; + ::GetPort( &port ) ; + ::SetPort( UMAGetWindowPort( m_macWindowData->m_macWindow ) ) ; + ::GlobalToLocal( &localwhere ) ; + ::SetPort( port ) ; + + event.m_x = localwhere.h; + event.m_y = localwhere.v; + event.m_x += m_x; + event.m_y += m_y; + +/* + wxPoint origin = GetClientAreaOrigin() ; + + event.m_x += origin.x ; + event.m_y += origin.y ; +*/ + + event.m_timeStamp = ev->when; + event.SetEventObject(this); + if ( wxTheApp->s_captureWindow ) + { + int x = event.m_x ; + int y = event.m_y ; + wxTheApp->s_captureWindow->ScreenToClient( &x , &y ) ; + event.m_x = x ; + event.m_y = y ; + wxTheApp->s_captureWindow->GetEventHandler()->ProcessEvent( event ) ; + if ( ev->what == mouseUp ) + { + wxTheApp->s_captureWindow = NULL ; + if ( wxBusyCursorCount == 0 ) + { + m_windowCursor.MacInstall() ; + } + } + } + else + { + MacDispatchMouseEvent( event ) ; + } +} + +void wxWindow::MacMouseDown( EventRecord *ev , short part) +{ + MacFireMouseEvent( ev ) ; +} + +void wxWindow::MacMouseUp( EventRecord *ev , short part) +{ + WindowPtr frontWindow ; + switch (part) + { + case inContent: + { + MacFireMouseEvent( ev ) ; + } + break ; + } +} + +void wxWindow::MacMouseMoved( EventRecord *ev , short part) +{ + WindowPtr frontWindow ; + switch (part) + { + case inContent: + { + MacFireMouseEvent( ev ) ; + } + break ; + } +} +void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating ) +{ + wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating); + event.m_timeStamp = ev->when ; + event.SetEventObject(this); + + GetEventHandler()->ProcessEvent(event); + + UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ; +} + +void wxWindow::MacRedraw( RgnHandle updatergn , long time) +{ + // updatergn is always already clipped to our boundaries + WindowRef window = GetMacRootWindow() ; + wxWindow* win = wxFindWinFromMacWindow( window ) ; + { + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + WindowRef window = GetMacRootWindow() ; + if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) ) + { + UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ; + } + else if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) ) + { + // 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 + + + wxWindow* parent = GetParent() ; + while( parent ) + { + if ( parent->GetMacRootWindow() != window ) + { + // we are in a different window on the mac system + parent = NULL ; + break ; + } + + if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() ) + { + if ( parent->m_backgroundColour != wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) ) + { + // if we have any other colours in the hierarchy + RGBBackColor( &parent->m_backgroundColour.GetPixel()) ; + 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 ) )) + { + ApplyThemeBackground (kThemeBackgroundTabPane, &(**updatergn).rgnBBox , kThemeStateActive,8,true); + break ; + } + } + else + { + parent = NULL ; + break ; + } + parent = parent->GetParent() ; + } + if ( !parent ) + { + // if there is nothing special -> use default + UMASetThemeWindowBackground( window , kThemeBrushDialogBackgroundActive , false ) ; + } + } + else + { + RGBBackColor( &m_backgroundColour.GetPixel()) ; + } + SetClip( updatergn ) ; + EraseRgn( updatergn ) ; + } + } + + + m_updateRegion = updatergn ; + wxPaintEvent event; + event.m_timeStamp = time ; + event.SetEventObject(this); + + GetEventHandler()->ProcessEvent(event); + + RgnHandle childupdate = NewRgn() ; + + for (wxNode *node = m_children->First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); + int width ; + int height ; + + child->GetClientSize( &width , &height ) ; + + SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x +width , child->m_y + height ) ; + SectRgn( childupdate , m_updateRegion.GetWXHRGN() , childupdate ) ; + OffsetRgn( childupdate , -child->m_x , -child->m_y ) ; + if ( child->GetMacRootWindow() == window && child->IsReallyShown() ) + { + // because dialogs may also be children + child->MacRedraw( childupdate , time ) ; + } + } + DisposeRgn( childupdate ) ; + // eventually a draw grow box here +} + +void wxWindow::MacUpdateImmediately() +{ + WindowRef window = GetMacRootWindow() ; + if ( window ) + { + wxWindow* win = wxFindWinFromMacWindow( window ) ; + BeginUpdate( window ) ; + if ( win ) + { + #if ! TARGET_CARBON + if ( !EmptyRgn( window->visRgn ) ) + #endif + { + win->MacRedraw( window->visRgn , wxTheApp->sm_lastMessageTime ) ; +/* + { + wxMacDrawingHelper help( win ) ; + SetOrigin( 0 , 0 ) ; + UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ; + UMAUpdateControls( window , window->visRgn ) ; + UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ; + } +*/ + } + } + EndUpdate( window ) ; + } +} + +void wxWindow::MacUpdate( EventRecord *ev ) +{ + WindowRef window = (WindowRef) ev->message ; + wxWindow * win = wxFindWinFromMacWindow( window ) ; + + BeginUpdate( window ) ; + if ( win ) + { + // if windowshade gives incompatibility , take the follwing out + #if ! TARGET_CARBON + if ( !EmptyRgn( window->visRgn ) ) + #endif + { + MacRedraw( window->visRgn , ev->when ) ; + /* + { + wxMacDrawingHelper help( this ) ; + SetOrigin( 0 , 0 ) ; + UMASetThemeWindowBackground( m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ; + UMAUpdateControls( window , window->visRgn ) ; + UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ; + } + */ + } + } + EndUpdate( window ) ; +} + +WindowRef wxWindow::GetMacRootWindow() const +{ + WindowRef window = NULL ; + wxWindow *iter = (wxWindow*)this ; + + while( iter ) + { + if ( iter->m_macWindowData ) + return iter->m_macWindowData->m_macWindow ; + + iter = iter->GetParent() ; + } + wxASSERT_MSG( 1 , "No valid mac root window" ) ; + return NULL ; +} + +void wxWindow::MacCreateScrollBars( long style ) +{ + wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ; + bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ; + int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ; + + if ( style & wxVSCROLL ) + { + m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, wxPoint(m_width-MAC_SCROLLBAR_SIZE, 0), + wxSize(MAC_SCROLLBAR_SIZE, m_height - adjust), wxVERTICAL); + } + if ( style & wxHSCROLL ) + { + m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, wxPoint(0 , m_height-MAC_SCROLLBAR_SIZE ), + wxSize( m_width - adjust, MAC_SCROLLBAR_SIZE), wxHORIZONTAL); + } + // because the create does not take into account the client area origin + MacRepositionScrollBars() ; // we might have a real position shift +} + +void wxWindow::MacRepositionScrollBars() +{ + bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ; + int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1 : 0 ; + + if ( m_vScrollBar ) + { + m_vScrollBar->SetSize( m_width-MAC_SCROLLBAR_SIZE, 0, MAC_SCROLLBAR_SIZE, m_height - adjust , wxSIZE_USE_EXISTING); + } + if ( m_hScrollBar ) + { + m_hScrollBar->SetSize( 0 , m_height-MAC_SCROLLBAR_SIZE ,m_width - adjust, MAC_SCROLLBAR_SIZE, wxSIZE_USE_EXISTING); + } +} + +void wxWindow::MacKeyDown( EventRecord *ev ) +{ +} + + + + +ControlHandle wxWindow::MacGetContainerForEmbedding() +{ + if ( m_macWindowData ) + return m_macWindowData->m_macRootControl ; + else + return GetParent()->MacGetContainerForEmbedding() ; +} + +void wxWindow::MacSuperChangedPosition() +{ + // only window-absolute structures have to be moved i.e. controls + + wxNode *node = GetChildren().First(); + while ( node ) + { + wxWindow *child = (wxWindow *)node->Data(); + child->MacSuperChangedPosition() ; + node = node->Next(); + } +} + +bool wxWindow::IsReallyShown() const +{ + if ( m_macWindowData ) + return m_macShown ; + else + return m_macShown && GetParent()->IsReallyShown() ; +} + +bool wxWindow::IsReallyEnabled() const +{ + if ( m_macWindowData ) + return m_macEnabled ; + else + return m_macEnabled && GetParent()->IsReallyEnabled() ; +} + +void wxWindow::MacSuperEnabled( bool enabled ) +{ + wxNode *node = GetChildren().First(); + while ( node ) + { + wxWindow *child = (wxWindow *)node->Data(); + if ( child->m_macEnabled ) + child->MacSuperEnabled( enabled ) ; + node = node->Next(); + } +} +void wxWindow::MacSuperShown( bool show ) +{ + wxNode *node = GetChildren().First(); + while ( node ) + { + wxWindow *child = (wxWindow *)node->Data(); + if ( child->m_macShown ) + child->MacSuperShown( show ) ; + node = node->Next(); + } +} + +bool wxWindow::MacSetupFocusPort( ) +{ + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + GrafPtr port ; + + MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ; + return MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; +} + +bool wxWindow::MacSetupFocusClientPort( ) +{ + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + GrafPtr port ; + + MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ; + return MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; +} + +bool wxWindow::MacSetupDrawingPort( ) +{ + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + GrafPtr port ; + + MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ; + return MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ; +} + +bool wxWindow::MacSetupDrawingClientPort( ) +{ + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + GrafPtr port ; + + MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ; + return MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ; +} + + +bool wxWindow::MacSetPortFocusParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* win ) +{ + if ( window == NULL ) + return false ; + + GrafPtr currPort; + GrafPtr port ; + + ::GetPort(&currPort); + port = UMAGetWindowPort( window) ; + if (currPort != port ) + ::SetPort(port); + + ::SetOrigin(-localOrigin.h, -localOrigin.v); + return true; +} + +bool wxWindow::MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* win ) +{ + if ( window == NULL ) + return false ; + + GrafPtr currPort; + GrafPtr port ; + ::GetPort(&currPort); + port = UMAGetWindowPort( window) ; + if (currPort != port ) + ::SetPort(port); + + ::SetOrigin(-localOrigin.h, -localOrigin.v); + ::ClipRect(&clipRect); + + ::PenNormal() ; + ::RGBBackColor(& win->GetBackgroundColour().GetPixel() ) ; + ::RGBForeColor(& win->GetForegroundColour().GetPixel() ) ; + ::BackPat( &qd.white ) ; + ::UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ; + return true; +} + +void wxWindow::MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) +{ + if ( m_macWindowData ) + { + localOrigin->h = 0; + localOrigin->v = 0; + clipRect->left = 0; + clipRect->top = 0; + clipRect->right = m_width; + clipRect->bottom = m_height; + *window = m_macWindowData->m_macWindow ; + *rootwin = this ; + } + else + { + wxASSERT( GetParent() != NULL ) ; + GetParent()->MacGetPortParams( localOrigin , clipRect , window, rootwin) ; + localOrigin->h += m_x; + localOrigin->v += m_y; + OffsetRect(clipRect, -m_x, -m_y); + + Rect myClip; + myClip.left = 0; + myClip.top = 0; + myClip.right = m_width; + myClip.bottom = m_height; + SectRect(clipRect, &myClip, clipRect); + } +} + +void wxWindow::MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin ) +{ + int width , height ; + GetClientSize( &width , &height ) ; + + if ( m_macWindowData ) + { + localOrigin->h = 0; + localOrigin->v = 0; + clipRect->left = 0; + clipRect->top = 0; + clipRect->right = m_width ;//width; + clipRect->bottom = m_height ;// height; + *window = m_macWindowData->m_macWindow ; + *rootwin = this ; + } + else + { + wxASSERT( GetParent() != NULL ) ; + + GetParent()->MacGetPortClientParams( localOrigin , clipRect , window, rootwin) ; + + localOrigin->h += m_x; + localOrigin->v += m_y; + OffsetRect(clipRect, -m_x, -m_y); + + Rect myClip; + myClip.left = 0; + myClip.top = 0; + myClip.right = width; + myClip.bottom = height; + SectRect(clipRect, &myClip, clipRect); + } +} + +wxMacFocusHelper::wxMacFocusHelper( wxWindow * theWindow ) +{ + m_ok = false ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + m_currentPort = NULL ; + GetPort( &m_formerPort ) ; + if ( theWindow ) + { + + theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ; + m_currentPort = UMAGetWindowPort( window ) ; + theWindow->MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; + m_ok = true ; + } +} + +wxMacFocusHelper::~wxMacFocusHelper() +{ + if ( m_ok ) + { + SetOrigin( 0 , 0 ) ; + } + if ( m_formerPort != m_currentPort ) + SetPort( m_formerPort ) ; +} + +wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow ) +{ + m_ok = false ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + m_currentPort = NULL ; + + GetPort( &m_formerPort ) ; + if ( theWindow ) + { + theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ; + m_currentPort = UMAGetWindowPort( window ) ; + if ( m_formerPort != m_currentPort ) + SetPort( m_currentPort ) ; + GetPenState( &m_savedPenState ) ; + theWindow->MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ; + m_ok = true ; + } +} + +wxMacDrawingHelper::~wxMacDrawingHelper() +{ + if ( m_ok ) + { + SetPenState( &m_savedPenState ) ; + SetOrigin( 0 , 0 ) ; + ClipRect( &m_currentPort->portRect ) ; + } + + if ( m_formerPort != m_currentPort ) + SetPort( m_formerPort ) ; +} + +wxMacFocusClientHelper::wxMacFocusClientHelper( wxWindow * theWindow ) +{ + m_ok = false ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + m_currentPort = NULL ; + + GetPort( &m_formerPort ) ; + + if ( theWindow ) + { + theWindow->MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ; + m_currentPort = UMAGetWindowPort( window ) ; + theWindow->MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; + m_ok = true ; + } +} + +wxMacFocusClientHelper::~wxMacFocusClientHelper() +{ + if ( m_ok ) + { + SetOrigin( 0 , 0 ) ; + } + if ( m_formerPort != m_currentPort ) + SetPort( m_formerPort ) ; +} + +wxMacDrawingClientHelper::wxMacDrawingClientHelper( wxWindow * theWindow ) +{ + m_ok = false ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + m_currentPort = NULL ; + + GetPort( &m_formerPort ) ; + + if ( theWindow ) + { + theWindow->MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ; + m_currentPort = UMAGetWindowPort( window ) ; + if ( m_formerPort != m_currentPort ) + SetPort( m_currentPort ) ; + GetPenState( &m_savedPenState ) ; + theWindow->MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ; + m_ok = true ; + } +} + +wxMacDrawingClientHelper::~wxMacDrawingClientHelper() +{ + if ( m_ok ) + { + SetPenState( &m_savedPenState ) ; + SetOrigin( 0 , 0 ) ; + ClipRect( &m_currentPort->portRect ) ; + } + + if ( m_formerPort != m_currentPort ) + SetPort( m_formerPort ) ; +} + +// ---------------------------------------------------------------------------- +// list classes implementation +// ---------------------------------------------------------------------------- + +void wxWindowListNode::DeleteData() +{ + delete (wxWindow *)GetData(); +} diff --git a/src/mac/checkbox.cpp b/src/mac/checkbox.cpp index dd2e2abe7a..ca99c4b778 100644 --- a/src/mac/checkbox.cpp +++ b/src/mac/checkbox.cpp @@ -20,6 +20,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox) #endif +#include + // Single check box item bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, @@ -27,41 +29,27 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = NewControlId(); - else - m_windowId = id; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; - // TODO: create checkbox + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlCheckBoxProc , (long) this ) ; + + MacPostControlCreate() ; - return FALSE; -} - -void wxCheckBox::SetLabel(const wxString& label) -{ - // TODO -} - -void wxCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + return TRUE; } void wxCheckBox::SetValue(bool val) { - // TODO + ::SetControlValue( m_macControl , val ) ; } bool wxCheckBox::GetValue() const { - // TODO - return FALSE; + return ::GetControlValue( m_macControl ) ; } void wxCheckBox::Command (wxCommandEvent & event) @@ -70,6 +58,11 @@ void wxCheckBox::Command (wxCommandEvent & event) ProcessCommand (event); } +void wxCheckBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + SetValue( !GetValue() ) ; +} + // Bitmap checkbox bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label, const wxPoint& pos, @@ -100,7 +93,7 @@ void wxBitmapCheckBox::SetLabel(const wxBitmap *bitmap) void wxBitmapCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; } void wxBitmapCheckBox::SetValue(bool val) diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index a584d5303f..da3c4efc92 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -15,6 +15,7 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/choice.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) @@ -23,71 +24,103 @@ IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) 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) { - SetName(name); - SetValidator(validator); m_noStrings = n; - m_windowStyle = style; - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - // TODO: create choice control - return FALSE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0, + kControlPopupButtonProc , (long) this ) ; + + m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; + SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; + for ( int i = 0 ; i < n ; i++ ) + { + appendmenu( m_macPopUpMenuHandle , choices[i] ) ; + } + SetControlMinimum( m_macControl , 0 ) ; + SetControlMaximum( m_macControl , m_noStrings) ; + SetControlValue( m_macControl , 1 ) ; + + MacPostControlCreate() ; + + return TRUE; } void wxChoice::Append(const wxString& item) { - // TODO + appendmenu( m_macPopUpMenuHandle , item ) ; m_noStrings ++; + SetControlMaximum( m_macControl , m_noStrings) ; } void wxChoice::Delete(int n) { - // TODO + wxASSERT( n < m_noStrings ) ; + ::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ; m_noStrings --; + SetControlMaximum( m_macControl , m_noStrings) ; } void wxChoice::Clear() { - // TODO + for ( int i = 0 ; i < m_noStrings ; i++ ) + { + ::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ; + } m_noStrings = 0; + SetControlMaximum( m_macControl , m_noStrings) ; } int wxChoice::GetSelection() const { - // TODO - return 0; + return GetControlValue( m_macControl ) -1 ; } +void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); + event.SetInt(GetSelection()); + event.SetEventObject(this); + event.SetString(copystring(GetStringSelection())); + ProcessCommand(event); + delete[] event.GetString(); +} + + void wxChoice::SetSelection(int n) { - // TODO + SetControlValue( m_macControl , n + 1 ) ; } int wxChoice::FindString(const wxString& s) const { - // TODO - return 0; + for( int i = 0 ; i < m_noStrings ; i++ ) + { + if ( GetString( i ) == s ) + return i ; + } + return -1; } wxString wxChoice::GetString(int n) const { - // TODO - return wxString(""); + Str255 text ; + ::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ; + p2cstr( text ) ; + return wxString( text ); } void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x,y,width,height,sizeFlags ) ; } wxString wxChoice::GetStringSelection () const diff --git a/src/mac/clipbrd.cpp b/src/mac/clipbrd.cpp index 3fe9ebfb72..28a4b9ef3f 100644 --- a/src/mac/clipbrd.cpp +++ b/src/mac/clipbrd.cpp @@ -30,19 +30,17 @@ IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject) bool wxOpenClipboard() { - // TODO - return FALSE; + return TRUE; } bool wxCloseClipboard() { - // TODO return FALSE; } bool wxEmptyClipboard() { - // TODO + ZeroScrap() ; return FALSE; } @@ -169,7 +167,7 @@ wxClipboardClient *wxClipboard::GetClipboardClient() } void wxClipboard::SetClipboardString(char *str, long time) -{ +{/* bool got_selection; if (clipOwner) { @@ -195,6 +193,7 @@ void wxClipboard::SetClipboardString(char *str, long time) delete[] cbString; cbString = NULL; } + */ } char *wxClipboard::GetClipboardString(long time) diff --git a/src/mac/colordlg.cpp b/src/mac/colordlg.cpp index 2275a9a39d..c6037a9f96 100644 --- a/src/mac/colordlg.cpp +++ b/src/mac/colordlg.cpp @@ -14,7 +14,7 @@ #pragma implementation "colordlg.h" #endif -#include "wx/stubs/colordlg.h" +#include "wx/mac/colordlg.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog) @@ -45,8 +45,20 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data) int wxColourDialog::ShowModal() { - /* TODO: implement dialog - */ + Point where ; + RGBColor currentColor = m_colourData.dataColour.GetPixel() , newColor ; + + where.h = where.v = -1; + + if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor )) + { + m_colourData.dataColour.Set( newColor ) ; + return wxID_OK; + } + else + { + return wxID_CANCEL; + } return wxID_CANCEL; } diff --git a/src/mac/colour.cpp b/src/mac/colour.cpp index 8d0827ef1d..cc549b5f11 100644 --- a/src/mac/colour.cpp +++ b/src/mac/colour.cpp @@ -22,13 +22,20 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) // Colour +static void wxComposeRGBColor( RGBColor * col , int red, int blue, int green ) ; +static void wxComposeRGBColor( RGBColor * col , int red, int blue, int 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; -/* TODO - m_pixel = 0; -*/ + 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) @@ -37,9 +44,8 @@ wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) m_green = g; m_blue = b; m_isInit = TRUE; -/* TODO - m_pixel = PALETTERGB (m_red, m_green, m_blue); -*/ + + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::wxColour (const wxColour& col) @@ -48,9 +54,18 @@ wxColour::wxColour (const wxColour& col) m_green = col.m_green; m_blue = col.m_blue; m_isInit = col.m_isInit; -/* TODO + m_pixel = col.m_pixel; -*/ +} + +wxColour::wxColour (const wxColour* col) +{ + m_red = col->m_red; + m_green = col->m_green; + m_blue = col->m_blue; + m_isInit = col->m_isInit; + + m_pixel = col->m_pixel; } wxColour& wxColour::operator =(const wxColour& col) @@ -59,9 +74,9 @@ wxColour& wxColour::operator =(const wxColour& col) m_green = col.m_green; m_blue = col.m_blue; m_isInit = col.m_isInit; -/* TODO + m_pixel = col.m_pixel; -*/ + return *this; } @@ -82,9 +97,8 @@ void wxColour::InitFromName(const wxString& col) m_blue = 0; m_isInit = FALSE; } -/* TODO - m_pixel = PALETTERGB (m_red, m_green, m_blue); -*/ + + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } wxColour::~wxColour () @@ -97,7 +111,6 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) m_green = g; m_blue = b; m_isInit = TRUE; -/* TODO - m_pixel = PALETTERGB (m_red, m_green, m_blue); -*/ + + wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; } diff --git a/src/mac/combobox.cpp b/src/mac/combobox.cpp index 0be841bad4..905f3180aa 100644 --- a/src/mac/combobox.cpp +++ b/src/mac/combobox.cpp @@ -14,11 +14,15 @@ #endif #include "wx/combobox.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl) #endif +// right now we don't support editable comboboxes + + bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, @@ -28,32 +32,39 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); m_noStrings = n; - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - // TODO: create combobox control - return TRUE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0, + kControlPopupButtonProc , (long) this ) ; + + m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; + SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; + for ( int i = 0 ; i < n ; i++ ) + { + appendmenu( m_macPopUpMenuHandle , choices[i] ) ; + } + SetControlMinimum( m_macControl , 0 ) ; + SetControlMaximum( m_macControl , m_noStrings) ; + SetControlValue( m_macControl , 1 ) ; + + MacPostControlCreate() ; + + return TRUE; } wxString wxComboBox::GetValue() const { - // TODO - return wxString(""); + return GetStringSelection() ; } void wxComboBox::SetValue(const wxString& value) { - // TODO + SetStringSelection( value ) ; } // Clipboard operations @@ -116,50 +127,85 @@ void wxComboBox::SetSelection(long from, long to) void wxComboBox::Append(const wxString& item) { - // TODO + appendmenu( m_macPopUpMenuHandle , item ) ; + m_noStrings ++; + SetControlMaximum( m_macControl , m_noStrings) ; } void wxComboBox::Delete(int n) { - // TODO + wxASSERT( n < m_noStrings ) ; + ::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ; + m_noStrings --; + SetControlMaximum( m_macControl , m_noStrings) ; } void wxComboBox::Clear() { - // TODO + for ( int i = 0 ; i < m_noStrings ; i++ ) + { + ::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ; + } + m_noStrings = 0; + SetControlMaximum( m_macControl , m_noStrings) ; } int wxComboBox::GetSelection() const { - // TODO - return -1; + return GetControlValue( m_macControl ) -1 ; } void wxComboBox::SetSelection(int n) { - // TODO + SetControlValue( m_macControl , n + 1 ) ; } int wxComboBox::FindString(const wxString& s) const { - // TODO + for( int i = 0 ; i < m_noStrings ; i++ ) + { + if ( GetString( i ) == s ) + return i ; + } return -1; } wxString wxComboBox::GetString(int n) const { - // TODO - return wxString(""); + Str255 text ; + ::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ; + p2cstr( text ) ; + return wxString( text ); } wxString wxComboBox::GetStringSelection() const { - // TODO - return wxString(""); + int sel = GetSelection (); + if (sel > -1) + return wxString(this->GetString (sel)); + else + return wxString(""); } bool wxComboBox::SetStringSelection(const wxString& sel) { - // TODO - return FALSE; + int s = FindString (sel); + if (s > -1) + { + SetSelection (s); + return TRUE; + } + else + return FALSE; +} + +void wxComboBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId ); + event.SetInt(GetSelection()); + event.SetEventObject(this); + event.SetString(copystring(GetStringSelection())); + ProcessCommand(event); + delete[] event.GetString(); } + diff --git a/src/mac/control.cpp b/src/mac/control.cpp index b141a80ff1..d570e2c5a1 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -14,20 +14,51 @@ #endif #include "wx/control.h" +#include "wx/notebook.h" +#include "wx/tabctrl.h" +#include "wx/spinbutt.h" #if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) BEGIN_EVENT_TABLE(wxControl, wxWindow) + EVT_MOUSE_EVENTS( wxControl::OnMouseEvent ) + EVT_CHAR( wxControl::OnKeyDown ) + EVT_PAINT( wxControl::OnPaint ) END_EVENT_TABLE() #endif +#include + // Item members + +ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ; + +pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) +{ + if ( partCode != 0) + { + wxControl* wx = (wxControl*) GetControlReference( control ) ; + if ( wx ) + { + wx->MacHandleControlClick( control , partCode ) ; + } + } +} + wxControl::wxControl() { + m_macControl = NULL ; + m_macHorizontalBorder = 0 ; // additional pixels around the real control + m_macVerticalBorder = 0 ; m_backgroundColour = *wxWHITE; m_foregroundColour = *wxBLACK; m_callback = 0; + + if ( wxMacLiveScrollbarActionUPP == NULL ) + { + wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ; + } } wxControl::~wxControl() @@ -40,17 +71,31 @@ wxControl::~wxControl() if (parent->GetDefaultItem() == (wxButton*) this) parent->SetDefaultItem(NULL); } + if ( m_macControl ) + { + UMADisposeControl( m_macControl ) ; + m_macControl = NULL ; + } } void wxControl::SetLabel(const wxString& label) { - // TODO + m_label = label ; + + if ( m_macControl ) + { + Str255 maclabel ; + + strcpy( (char*) maclabel , label ) ; + c2pstr( (char*) maclabel ) ; + + ::SetControlTitle( m_macControl , maclabel ) ; + } } wxString wxControl::GetLabel() const { - // TODO - return wxString(""); + return m_label ; } void wxControl::ProcessCommand (wxCommandEvent & event) @@ -93,3 +138,566 @@ void wxControl::Centre (int direction) SetSize (new_x, new_y, width, height); } +void wxControl::SetClientSize (int width, int height) +{ + SetSize (-1, -1, width, height); +} + +// ------------------------ +wxList *wxWinMacControlList = NULL; +wxControl *wxFindControlFromMacControl(ControlHandle inControl ) +{ + wxNode *node = wxWinMacControlList->Find((long)inControl); + if (!node) + return NULL; + return (wxControl *)node->Data(); +} + +void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control) +{ + // adding NULL WindowRef is (first) surely a result of an error and + // (secondly) breaks menu command processing + wxCHECK_RET( inControl != (ControlHandle) NULL, "attempt to add a NULL WindowRef to window list" ); + + if ( !wxWinMacControlList->Find((long)inControl) ) + wxWinMacControlList->Append((long)inControl, control); +} + +void wxRemoveMacControlAssociation(wxControl *control) +{ + wxWinMacControlList->DeleteObject(control); +} + +void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label , + const wxPoint& pos, + const wxSize& size, long style, + const wxValidator& validator, + const wxString& name , Rect *outBounds , StringPtr maclabel ) +{ + m_label = label ; + SetName(name); + if ( &validator ) + SetValidator(validator); + + m_windowStyle = style; + parent->AddChild((wxButton *)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 ; + + + Point localOrigin ; + Rect clipRect ; + + parent->MacClientToRootWindow( &x , &y ) ; + outBounds->top = y + m_macVerticalBorder ; + outBounds->left = x + m_macHorizontalBorder ; + outBounds->bottom = outBounds->top + m_height - 2 * m_macVerticalBorder; + outBounds->right = outBounds->left + m_width - 2 * m_macHorizontalBorder ; + + strcpy( (char*) maclabel , label ) ; + if( wxApp::s_macDefaultEncodingIsPC ) + { + wxMacConvertFromPCForControls( (char*) maclabel ) ; + } + + c2pstr( (char*) maclabel ) ; +} + +void wxControl::MacPostControlCreate() +{ + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) + { + // no font + } + else if ( IsKindOf( CLASSINFO( wxStaticBox ) ) ) + { + ControlFontStyleRec controlstyle ; + controlstyle.flags = kControlUseFontMask ; + controlstyle.font = kControlFontSmallBoldSystemFont ; + + ::UMASetControlFontStyle( m_macControl , &controlstyle ) ; + } + else + { + ControlFontStyleRec controlstyle ; + controlstyle.flags = kControlUseFontMask ; + controlstyle.font = kControlFontSmallSystemFont ; + + ::UMASetControlFontStyle( m_macControl , &controlstyle ) ; + } + ControlHandle container = GetParent()->MacGetContainerForEmbedding() ; + wxASSERT_MSG( container != NULL , "No valid mac container control" ) ; + ::UMAEmbedControl( m_macControl , container ) ; + MacAdjustControlRect() ; + wxAssociateControlWithMacControl( m_macControl , this ) ; +} + +void wxControl::MacAdjustControlRect() +{ + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + if ( m_width == -1 || m_height == -1 ) + { + Rect bestsize = { 0 , 0 , 0 , 0 } ; + short baselineoffset ; + + UMAGetBestControlRect( m_macControl , &bestsize , &baselineoffset ) ; + + if ( EmptyRect( &bestsize ) ) + { + baselineoffset = 0; + bestsize.left = bestsize.top = 0 ; + bestsize.right = 16 ; + bestsize.bottom = 16 ; + if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) + { + bestsize.bottom = 16 ; + } + else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) + { + bestsize.bottom = 24 ; + } + } + + if ( m_width == -1 ) + { + if ( IsKindOf( CLASSINFO( wxButton ) ) ) + { + m_width = m_label.Length() * 8 + 12 + 2 * m_macHorizontalBorder; + } + else if ( IsKindOf( CLASSINFO( wxStaticText ) ) ) + { + m_width = m_label.Length() * 8 ; + } + else + m_width = bestsize.right - bestsize.left + 2 * m_macHorizontalBorder; + } + if ( m_height == -1 ) + { + m_height = bestsize.bottom - bestsize.top ; + if ( m_height < 10 ) + m_height = 13 ; + + m_height += 2 * m_macVerticalBorder; + } + + wxMacDrawingHelper helper ( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ; + if ( helper.Ok() ) + { + UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; + } + } +} +ControlHandle wxControl::MacGetContainerForEmbedding() +{ + if ( m_macControl ) + return m_macControl ; + + return wxWindow::MacGetContainerForEmbedding() ; +} + +void wxControl::MacSuperChangedPosition() +{ + if ( m_macControl ) + { + int former_mac_x = (**m_macControl).contrlRect.left ; + int former_mac_y = (**m_macControl).contrlRect.top ; + int mac_x = m_x ; + int mac_y = m_y ; + GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ; + + WindowRef rootwindow = GetMacRootWindow() ; + wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ; + UMASetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ; + wxMacDrawingHelper focus( wxrootwindow ) ; + + if ( mac_x != former_mac_x || mac_y != former_mac_y ) + { + { + Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; + InvalRect( &inval ) ; + } + UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; + { + Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; + InvalRect( &inval ) ; + } + } + if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) ) + { + } + else + { + UMASetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ; + } + } + + wxWindow::MacSuperChangedPosition() ; +} + +void wxControl::MacSuperEnabled( bool enabled ) +{ + if ( m_macControl ) + { + if ( UMAHasAppearance() ) + { + if ( !enabled ) + { + ::DeactivateControl( m_macControl ) ; + } + else + { + if ( m_macEnabled ) + ::ActivateControl( m_macControl ) ; + } + } + else + { + if ( !enabled ) + { + ::HiliteControl( m_macControl , 255 ) ; + } + else + { + if ( m_macEnabled ) + ::HiliteControl( m_macControl , 0 ) ; + } + } + } + wxWindow::MacSuperEnabled( enabled ) ; +} + +void wxControl::MacSuperShown( bool show ) +{ + if ( m_macControl ) + { + if ( !show ) + { + ::UMAHideControl( m_macControl ) ; + } + else + { + if ( m_macShown ) + ::UMAShowControl( m_macControl ) ; + } + } + + wxWindow::MacSuperShown( show ) ; +} + +void wxControl::DoSetSize(int x, int y, + int width, int height, + int sizeFlags ) +{ + if ( m_macControl == NULL ) + { + wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ; + return ; + } + + WindowRef rootwindow = GetMacRootWindow() ; + wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ; + UMASetThemeWindowBackground( rootwindow , kThemeBrushDialogBackgroundActive , false ) ; + + int former_x = m_x ; + int former_y = m_y ; + int former_w = m_width ; + int former_h = m_height ; + + int former_mac_x = (**m_macControl).contrlRect.left ; + int former_mac_y = (**m_macControl).contrlRect.top ; + + int currentX, currentY; + GetPosition(¤tX, ¤tY); + int currentW,currentH; + GetSize(¤tW, ¤tH); + + int actualWidth = width; + int actualHeight = height; + int actualX = x; + int actualY = y; + if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + actualX = currentX; + if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + actualY = currentY; + if (width == -1) + actualWidth = currentW ; + if (height == -1) + actualHeight = currentH ; + + if ( actualX == currentX && actualY == currentY && actualWidth == currentW && actualHeight == currentH) + return ; + + AdjustForParentClientOrigin(actualX, actualY, sizeFlags); + wxMacDrawingHelper focus( wxFindWinFromMacWindow( GetMacRootWindow() ) ) ; + + int mac_x = actualX ; + int mac_y = actualY ; + GetParent()->MacClientToRootWindow( & mac_x , & mac_y ) ; + + if ( mac_x != former_mac_x || mac_y != former_mac_y ) + { + { + Rect inval = { former_mac_y , former_mac_x , former_mac_y + m_height , former_mac_x + m_width } ; + InvalRect( &inval ) ; + } + UMAMoveControl( m_macControl , mac_x + m_macHorizontalBorder , mac_y + m_macVerticalBorder ) ; + { + Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; + InvalRect( &inval ) ; + } + } + + if ( actualX != former_x || actualY != former_y ) + { + m_x = actualX ; + m_y = actualY ; + + MacRepositionScrollBars() ; + // To consider -> should the parameters be the effective or the virtual coordinates (AdjustForParent..) + wxMoveEvent event(wxPoint(m_x, m_y), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + if ( actualWidth != former_w || actualHeight != former_h ) + { + { + Rect inval = { mac_y , mac_x , mac_y + former_h , mac_x + former_w } ; + InvalRect( &inval ) ; + } + m_width = actualWidth ; + m_height = actualHeight ; + + UMASizeControl( m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; + { + Rect inval = { mac_y , mac_x , mac_y + m_height , mac_x + m_width } ; + InvalRect( &inval ) ; + } + + MacRepositionScrollBars() ; + wxSizeEvent event(wxSize(m_width, m_height), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + if ( wxrootwindow->IsKindOf( CLASSINFO( wxDialog ) ) ) + { + } + else + { + UMASetThemeWindowBackground( rootwindow , kThemeBrushDocumentWindowBackground , false ) ; + } +} + +void wxControl::DoSetClientSize(int width, int height) +{ + DoSetSize( -1 , -1 , width , height ) ; +} + +bool wxControl::Show(bool show) +{ + if ( m_macControl == NULL ) + return wxWindow::Show( show ) ; + + if ( m_macShown == show ) + return TRUE ; + + if ( show ) + ::UMAShowControl( m_macControl ) ; + else + ::UMAHideControl( m_macControl ) ; + + return wxWindow::Show( show ) ; +} + +void wxControl::Enable(bool enable) +{ + if ( m_macControl == NULL ) + return wxWindow::Enable( enable ) ; + + if ( m_macEnabled == enable ) + return ; + + if ( UMAHasAppearance() ) + { + if ( enable ) + ::ActivateControl( m_macControl ) ; + else + ::DeactivateControl( m_macControl ) ; + } + else + { + if ( enable ) + ::HiliteControl( m_macControl , 0 ) ; + else + ::HiliteControl( m_macControl , 255 ) ; + } + + return wxWindow::Enable( enable ) ; +} + +void wxControl::Refresh(bool eraseBack, const wxRect *rect) +{ + if ( m_macControl ) + { + wxWindow::Refresh( eraseBack , rect ) ; + } + else + { + wxWindow::Refresh( eraseBack , rect ) ; + } +} + +void wxControl::OnPaint(wxPaintEvent& event) +{ + if ( m_macControl ) + { + WindowRef window = GetMacRootWindow() ; + if ( window ) + { + wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( win ) + { + wxMacDrawingHelper help( win ) ; + SetOrigin( 0 , 0 ) ; + + bool hasTabBehind = false ; + wxWindow* parent = GetParent() ; + while ( parent ) + { + if( parent->m_macWindowData ) + { + UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ; + break ; + } + + if( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) )) + { + if ( ((wxControl*)parent)->m_macControl ) + SetUpControlBackground( ((wxControl*)parent)->m_macControl , -1 , true ) ; + break ; + } + + parent = parent->GetParent() ; + } + + UMADrawControl( m_macControl ) ; + UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ; + } + } + } + else + { + wxWindow::OnPaint( event ) ; + } +} + +void wxControl::OnKeyDown( wxKeyEvent &event ) +{ + if ( m_macControl == NULL ) + return ; + + EventRecord *ev = wxTheApp->MacGetCurrentEvent() ; + short keycode ; + short keychar ; + keychar = short(ev->message & charCodeMask); + keycode = short(ev->message & keyCodeMask) >> 8 ; + + UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ; +} + +void wxControl::OnMouseEvent( wxMouseEvent &event ) +{ + if ( m_macControl == NULL ) + { + event.Skip() ; + return ; + } + + if (event.GetEventType() == wxEVT_LEFT_DOWN ) + { + + int x = event.m_x ; + int y = event.m_y ; + + MacClientToRootWindow( &x , &y ) ; + + ControlHandle control ; + Point localwhere ; + GrafPtr port ; + SInt16 controlpart ; + WindowRef window = GetMacRootWindow() ; + + 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 ; + + controlpart = FindControl( localwhere , window , &control ) ; + { + if ( AcceptsFocus() && FindFocus() != this ) + { + SetFocus() ; + } + if ( control && UMAIsControlActive( control ) ) + { + { + if ( controlpart == kControlIndicatorPart && !UMAHasAppearance() ) + controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) NULL ) ; + else + controlpart = UMAHandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; + wxTheApp->s_lastMouseDown = 0 ; + if ( controlpart && ! ( ( UMAHasAppearance() || (controlpart != kControlIndicatorPart) ) + && (IsKindOf( CLASSINFO( wxScrollBar ) ) ) ) ) // otherwise we will get the event twice + { + MacHandleControlClick( control , controlpart ) ; + } + } + } + } + } +} + +bool wxControl::MacCanFocus() const +{ + { if ( m_macControl == NULL ) + return true ; + else + return false ; + } +} + +void wxControl::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; +} + diff --git a/src/mac/corersrc.r b/src/mac/corersrc.r index a37b064b21..528e794811 100644 --- a/src/mac/corersrc.r +++ b/src/mac/corersrc.r @@ -1,8 +1,50 @@ #include -resource 'ALRT' (128, purgeable) { +#if UNIVERSAL_INTERFACES_VERSION > 0x320 + #include +#endif + +#define kMacOKAlertResourceID 128 +#define kMacYesNoAlertResourceID 129 +#define kMacYesNoCancelAlertResourceID 130 +#define kMacNoYesAlertResourceID 131 +#define kMacNoYesCancelAlertResourceID 132 + +resource 'ALRT' (kMacOKAlertResourceID, purgeable) { + {70, 50, 198, 470}, + kMacOKAlertResourceID, + { /* array: 4 elements */ + /* [1] */ + OK, visible, sound1, + /* [2] */ + OK, visible, sound1, + /* [3] */ + OK, visible, sound1, + /* [4] */ + OK, visible, sound1 + }, + noAutoCenter +}; + +resource 'ALRT' (kMacYesNoAlertResourceID, purgeable) { + {70, 50, 198, 470}, + kMacYesNoAlertResourceID, + { /* array: 4 elements */ + /* [1] */ + OK, visible, sound1, + /* [2] */ + OK, visible, sound1, + /* [3] */ + OK, visible, sound1, + /* [4] */ + OK, visible, sound1 + }, + noAutoCenter +}; + +resource 'ALRT' (kMacYesNoAlertResourceID + 10, purgeable) { {70, 50, 198, 470}, - 128, + kMacYesNoAlertResourceID + 10, { /* array: 4 elements */ /* [1] */ OK, visible, sound1, @@ -16,9 +58,9 @@ resource 'ALRT' (128, purgeable) { noAutoCenter }; -resource 'ALRT' (129, purgeable) { +resource 'ALRT' (kMacYesNoAlertResourceID + 20, purgeable) { {70, 50, 198, 470}, - 129, + kMacYesNoAlertResourceID + 20, { /* array: 4 elements */ /* [1] */ OK, visible, sound1, @@ -32,7 +74,7 @@ resource 'ALRT' (129, purgeable) { noAutoCenter }; -resource 'ALRT' (130, purgeable) { +resource 'ALRT' (kMacYesNoCancelAlertResourceID, purgeable) { {70, 50, 198, 470}, 130, { /* array: 4 elements */ @@ -48,7 +90,7 @@ resource 'ALRT' (130, purgeable) { noAutoCenter }; -resource 'ALRT' (131, purgeable) { +resource 'ALRT' (kMacNoYesAlertResourceID, purgeable) { {70, 50, 198, 470}, 131, { /* array: 4 elements */ @@ -64,7 +106,7 @@ resource 'ALRT' (131, purgeable) { noAutoCenter }; -resource 'ALRT' (132, purgeable) { +resource 'ALRT' (kMacNoYesCancelAlertResourceID, purgeable) { {70, 50, 198, 470}, 132, { /* array: 4 elements */ @@ -80,7 +122,7 @@ resource 'ALRT' (132, purgeable) { noAutoCenter }; -resource 'DITL' (128, purgeable) { +resource 'DITL' (kMacOKAlertResourceID, purgeable) { { /* array DITLarray: 3 elements */ /* [1] */ {100, 340, 120, 408}, @@ -103,13 +145,71 @@ resource 'DITL' (128, purgeable) { } }; -resource 'DITL' (129, purgeable) { +resource 'DITL' (kMacYesNoAlertResourceID, purgeable) { { /* array DITLarray: 4 elements */ /* [1] */ {100, 340, 120, 408}, Button { enabled, - "Yes" + "Ja" + }, + /* [2] */ + {100, 260, 120, 324}, + Button { + enabled, + "Nein" + }, + /* [3] */ + {38, 64, 88, 408}, + StaticText { + disabled, + "^1" + }, + /* [4] */ + {10, 64, 30, 412}, + StaticText { + disabled, + "^0" + } + } +}; + +resource 'DITL' (kMacYesNoAlertResourceID + 10, purgeable) { + { /* array DITLarray: 4 elements */ + /* [1] */ + {100, 340, 120, 408}, + Button { + enabled, + "Oui" + }, + /* [2] */ + {100, 260, 120, 324}, + Button { + enabled, + "Non" + }, + /* [3] */ + {38, 64, 88, 408}, + StaticText { + disabled, + "^1" + }, + /* [4] */ + {10, 64, 30, 412}, + StaticText { + disabled, + "^0" + } + } +}; + +resource 'DITL' (kMacYesNoAlertResourceID + 20, purgeable) { + { /* array DITLarray: 4 elements */ + /* [1] */ + {100, 340, 120, 408}, + Button { + enabled, + "Si" }, /* [2] */ {100, 260, 120, 324}, @@ -132,7 +232,7 @@ resource 'DITL' (129, purgeable) { } }; -resource 'DITL' (130, purgeable) { +resource 'DITL' (kMacYesNoCancelAlertResourceID, purgeable) { { /* array DITLarray: 5 elements */ /* [1] */ {100, 340, 120, 408}, @@ -167,7 +267,7 @@ resource 'DITL' (130, purgeable) { } }; -resource 'DITL' (131, purgeable) { +resource 'DITL' (kMacNoYesAlertResourceID, purgeable) { { /* array DITLarray: 4 elements */ /* [1] */ {100, 340, 120, 408}, @@ -196,7 +296,7 @@ resource 'DITL' (131, purgeable) { } }; -resource 'DITL' (132, purgeable) { +resource 'DITL' (kMacNoYesCancelAlertResourceID, purgeable) { { /* array DITLarray: 5 elements */ /* [1] */ {100, 340, 120, 408}, @@ -278,54 +378,17 @@ data 'DLGX' (132) { $"0000 0006 0000 0000 0000 0000 0000" /* .............. */ }; -data 'ics#' (200, "¥ New File") { - $"0000 3FE0 2C70 3458 2C78 3408 2C08 3408" /* ..?à,p4X,x4.,.4. */ - $"2C08 3408 2C08 3408 2C0E 340F 3FFE 0000" /* ,.4.,.4.,.4.?þ.. */ - $"0000 3FE0 3FF0 3FF8 3FF8 3FF8 3FF8 3FF8" /* ..?à?ð?ø?ø?ø?ø?ø */ - $"3FF8 3FF8 3FF8 3FF8 3FFE 3FFF 3FFE 0000" /* ?ø?ø?ø?ø?þ?ÿ?þ.. */ -}; - -data 'ics4' (200, "¥ New File") { - $"0000 0000 0000 0000 00FF FFFF FFF0 0000" /* .........ÿÿÿÿð.. */ - $"00F1 FFED EFFF 0000 00FF 1FDE DFCF F000" /* .ñÿíïÿ...ÿ.ÞßÏð. */ - $"00F1 FFED EFFF F000 00FF 1FDE DEEE F000" /* .ñÿíïÿð..ÿ.ÞÞîð. */ - $"00F1 FFED EDED F000 00FF 1FDE DEDE F000" /* .ñÿíííð..ÿ.ÞÞÞð. */ - $"00F1 FFED EDED F000 00FF 1FDE DEDE F000" /* .ñÿíííð..ÿ.ÞÞÞð. */ - $"00F1 FFED EDED F000 00FF 1FDE DEDE F000" /* .ñÿíííð..ÿ.ÞÞÞð. */ - $"00F1 FFED EDED FEE0 00FF 1FDE DEDE FEEE" /* .ñÿíííþà.ÿ.ÞÞÞþî */ - $"00FF FFFF FFFF FEE0 0000 0000 0000 0000" /* .ÿÿÿÿÿþà........ */ -}; - -data 'ics8' (200, "¥ New File") { - $"0000 0000 0000 0000 0000 0000 0000 0000" /* ................ */ - $"0000 FFFF FFFF FFFF FFFF FF00 0000 0000" /* ..ÿÿÿÿÿÿÿÿÿ..... */ - $"0000 FF05 FFFF FB7F FBFF FFFF 0000 0000" /* ..ÿ.ÿÿû.ûÿÿÿ.... */ - $"0000 FFFF 0BFF 7FFB 7FFF F6FF FF00 0000" /* ..ÿÿ.ÿ.û.ÿöÿÿ... */ - $"0000 FF05 FFFF FB7F FBFF FFFF FF00 0000" /* ..ÿ.ÿÿû.ûÿÿÿÿ... */ - $"0000 FFFF 0BFF 7FFB 7FFB FBFB FF00 0000" /* ..ÿÿ.ÿ.û.ûûûÿ... */ - $"0000 FF05 FFFF FB7F FB7F FB7F FF00 0000" /* ..ÿ.ÿÿû.û.û.ÿ... */ - $"0000 FFFF 0BFF 7FFB 7FFB 7FFB FF00 0000" /* ..ÿÿ.ÿ.û.û.ûÿ... */ - $"0000 FF05 FFFF FB7F FB7F FB7F FF00 0000" /* ..ÿ.ÿÿû.û.û.ÿ... */ - $"0000 FFFF 0BFF 7FFB 7FFB 7FFB FF00 0000" /* ..ÿÿ.ÿ.û.û.ûÿ... */ - $"0000 FF05 FFFF FB7F FB7F FB7F FF00 0000" /* ..ÿ.ÿÿû.û.û.ÿ... */ - $"0000 FFFF 0BFF 7FFB 7FFB 7FFB FF00 0000" /* ..ÿÿ.ÿ.û.û.ûÿ... */ - $"0000 FF05 FFFF FB7F FB7F FB7F FFFC FC00" /* ..ÿ.ÿÿû.û.û.ÿüü. */ - $"0000 FFFF 0BFF 7FFB 7FFB 7FFB FFFC FCFC" /* ..ÿÿ.ÿ.û.û.ûÿüüü */ - $"0000 FFFF FFFF FFFF FFFF FFFF FFFC FC00" /* ..ÿÿÿÿÿÿÿÿÿÿÿüü. */ - $"0000 0000 0000 0000 0000 0000 0000 0000" /* ................ */ -}; - resource 'ldes' ( 128 ) { versionZero { 0 , - 1 , + 0 , 0 , 0 , hasVertScroll , noHorizScroll , - 0 , + 128 , noGrowSpace , } } ; @@ -536,3 +599,4 @@ resource 'STR#' (251) { } }; +// end of get file \ No newline at end of file diff --git a/src/mac/cursor.cpp b/src/mac/cursor.cpp index 4333364c93..bcbe30008b 100644 --- a/src/mac/cursor.cpp +++ b/src/mac/cursor.cpp @@ -20,18 +20,24 @@ IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) #endif +const short kwxCursorHandId = 9 ; +const short kwxCursorSizeWEId = 10 ; +const short kwxCursorSizeNSId = 11 ; +Cursor* MacArrowCursorPtr = &qd.arrow ; +CursHandle MacArrowCursor = &MacArrowCursorPtr ; +CursHandle gMacCurrentCursor = NULL ; + wxCursorRefData::wxCursorRefData() { - m_width = 32; m_height = 32; - -/* TODO - m_hCursor = 0 ; -*/ + m_width = 32; + m_height = 32; + m_hCursor = NULL ; } wxCursorRefData::~wxCursorRefData() { - // TODO: destroy cursor + if ( m_hCursor && ( m_hCursor != MacArrowCursor ) ) + ::DisposeHandle( (Handle) m_hCursor ) ; } // Cursors @@ -56,122 +62,133 @@ wxCursor::wxCursor(int cursor_type) { m_refData = new wxCursorRefData; -/* TODO switch (cursor_type) { case wxCURSOR_WAIT: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT); + M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); break; case wxCURSOR_IBEAM: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM); + M_CURSORDATA->m_hCursor = ::GetCursor(iBeamCursor); break; case wxCURSOR_CROSS: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS); + M_CURSORDATA->m_hCursor = ::GetCursor(crossCursor); break; case wxCURSOR_SIZENWSE: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENWSE); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZENESW: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENESW); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZEWE: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZEWE); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeWEId); break; case wxCURSOR_SIZENS: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENS); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNSId); break; case wxCURSOR_CHAR: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_HAND: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_HAND"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_BULLSEYE: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BULLSEYE"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_PENCIL: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PENCIL"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_MAGNIFIER: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_MAGNIFIER"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_NO_ENTRY: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_NO_ENTRY"); + M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorHandId); break; } case wxCURSOR_LEFT_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_RIGHT_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_MIDDLE_BUTTON: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_SIZING: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_SIZING"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_WATCH: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_WATCH"); + M_CURSORDATA->m_hCursor = ::GetCursor(watchCursor); break; } case wxCURSOR_SPRAYCAN: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_ROLLER"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_PAINT_BRUSH: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PBRUSH"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_POINT_LEFT: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PLEFT"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_POINT_RIGHT: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PRIGHT"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_QUESTION_ARROW: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_QARROW"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } case wxCURSOR_BLANK: { - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK"); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; } default: case wxCURSOR_ARROW: - M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + M_CURSORDATA->m_hCursor = MacArrowCursor; break; - } -*/ + } +} +void wxCursor::MacInstall() const +{ + if ( m_refData && M_CURSORDATA->m_hCursor ) + { + ::SetCursor( *M_CURSORDATA->m_hCursor ) ; + gMacCurrentCursor = M_CURSORDATA->m_hCursor ; + } + else + { + ::SetCursor( *MacArrowCursor ) ; + gMacCurrentCursor = NULL ; + } } wxCursor::~wxCursor() @@ -181,7 +198,7 @@ wxCursor::~wxCursor() // Global cursor setting void wxSetCursor(const wxCursor& cursor) { - // TODO (optional on platforms with no global cursor) + cursor.MacInstall() ; } diff --git a/src/mac/data.cpp b/src/mac/data.cpp index 138289a5bf..297686b9d1 100644 --- a/src/mac/data.cpp +++ b/src/mac/data.cpp @@ -25,7 +25,7 @@ char *wxBuffer = NULL; // Windows List -wxList wxTopLevelWindows; +wxWindowList wxTopLevelWindows; // List of windows pending deletion wxList wxPendingDelete; diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index 2c1c613595..e021274157 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -30,6 +30,8 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) #define mm2pt 2.83464566929 #define pt2mm 0.352777777778 +long wxDC::m_macCurrentPortId = 1 ; + //----------------------------------------------------------------------------- // wxDC //----------------------------------------------------------------------------- @@ -83,14 +85,136 @@ wxDC::wxDC(void) m_backgroundBrush = *wxWHITE_BRUSH; // m_palette = wxAPP_COLOURMAP; + m_macPort = NULL ; + m_ok = FALSE ; + + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + + m_macPortId = 0 ; + m_macLocalOrigin.h = m_macLocalOrigin.v = 0 ; + m_macClipRect.left = -32000 ; + m_macClipRect.top = -32000 ; + m_macClipRect.right = 32000 ; + m_macClipRect.bottom = 32000 ; + ::GetPort( &m_macOrigPort ) ; }; wxDC::~wxDC(void) { + if ( m_macPort ) + { + ::SetOrigin( 0 , 0 ) ; + ::ClipRect( &m_macPort->portRect ) ; + ::PenNormal() ; + ::SetPort( m_macOrigPort ) ; + } + ++m_macCurrentPortId ; }; -void wxDC::DrawIcon( const wxIcon &WXUNUSED(icon), long WXUNUSED(x), long WXUNUSED(y), bool WXUNUSED(useMask) ) +void wxDC::MacSetupPort() const +{ + m_macPortId = ++m_macCurrentPortId ; + ::SetPort(m_macPort); + ::SetOrigin(-m_macLocalOrigin.h, -m_macLocalOrigin.v); + ::ClipRect(&m_macClipRect); + + m_macFontInstalled = false ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; +} + +void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + long xx1 = XLOG2DEV(x); + long yy1 = YLOG2DEV(y); + + { + wxBitmapRefData * bmap = (wxBitmapRefData*) ( bmp.GetRefData()) ; + + if ( bmap ) + { + if ( bmap->m_bitmapType == kMacBitmapTypePict ) + { + Rect bitmaprect = { 0 , 0 , bmap->m_height , bmap->m_width } ; + ::OffsetRect( &bitmaprect , xx1 , yy1 ) ; + ::DrawPicture( bmap->m_hPict , &bitmaprect ) ; + } + else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) + { + if ( bmap->m_hBitmap ) + { + GWorldPtr bmapworld = bmap->m_hBitmap ; + PixMapHandle bmappixels ; + RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; + RGBColor black = { 0,0,0} ; + RGBForeColor( &black ) ; + RGBBackColor( &white ) ; + // RGBForeColor( &m_textForegroundColour.GetPixel() ) ; + // RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; + + bmappixels = GetGWorldPixMap( bmapworld ) ; + if ( LockPixels(bmappixels) ) + { + Rect source , dest ; + source.top = 0 ; + source.left = 0 ; + source.right = bmap->m_width ; + source.bottom = bmap->m_height ; + dest.top = YLOG2DEV(y) ; + dest.left = XLOG2DEV(x) ; + dest.bottom = YLOG2DEV(y + bmap->m_height ) ; + dest.right = XLOG2DEV(x + bmap->m_width ) ; + // ::ClipRect(&m_macClipRect); + CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits , + &source, &dest, srcCopy, NULL ) ; + /* + if ( m_clipping ) + { + long x1 = XLOG2DEV(m_clipX1); + long y1 = YLOG2DEV(m_clipY1); + long x2 = XLOG2DEV(m_clipX2); + long y2 = YLOG2DEV(m_clipY2); + + Rect clip = { y1 , x1 , y2 , x2 } ; + ::ClipRect(&clip); + } + */ + UnlockPixels( bmappixels ) ; + } + m_macPenInstalled = false ; + m_macBrushInstalled = false ; + m_macFontInstalled = false ; + } + } + } + } +} + +void wxDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask ) { + if (!Ok()) + return; + MacVerifySetup() ; + + long xx1 = XLOG2DEV(x); + long yy1 = YLOG2DEV(y); + + { + wxIconRefData * iconref = (wxIconRefData*) ( icon.GetRefData()) ; + + if ( iconref && iconref->m_ok && iconref->m_hIcon ) + { + Rect bitmaprect = { 0 , 0 , iconref->m_height , iconref->m_width } ; + OffsetRect( &bitmaprect , xx1 , yy1 ) ; + PlotCIconHandle( &bitmaprect , atNone , ttNone , iconref->m_hIcon ) ; + } + } }; void wxDC::DrawPoint( wxPoint& point ) @@ -155,16 +279,41 @@ void wxDC::DrawSpline( int n, wxPoint points[] ) void wxDC::SetClippingRegion( long x, long y, long width, long height ) { - m_clipping = TRUE; - m_clipX1 = x; - m_clipY1 = y; - m_clipX2 = x + width; - m_clipY2 = y + height; + MacVerifySetup() ; + if( m_clipping ) + { + m_clipX1 = wxMax( m_clipX1 , x ) ; + m_clipY1 = wxMax( m_clipY1 ,y ); + m_clipX2 = wxMin( m_clipX2, (x + width)); + m_clipY2 = wxMin( m_clipY2,(y + height)); + + } + else + { + m_clipping = TRUE; + m_clipX1 = x; + m_clipY1 = y; + m_clipX2 = x + width; + m_clipY2 = y + height; + } + + long x1 = XLOG2DEV(m_clipX1); + long y1 = YLOG2DEV(m_clipY1); + long x2 = XLOG2DEV(m_clipX2); + long y2 = XLOG2DEV(m_clipY2); + + Rect clip = { y1 , x1 , y2 , x2 } ; + + ::ClipRect( &clip ) ; + }; void wxDC::DestroyClippingRegion(void) { + MacVerifySetup() ; m_clipping = FALSE; +// Rect clip = { -32000 , -32000 , 32000 , 32000 } ; + ::ClipRect(&m_macClipRect); }; void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const @@ -199,12 +348,14 @@ void wxDC::SetTextForeground( const wxColour &col ) { if (!Ok()) return; m_textForegroundColour = col; + m_macFontInstalled = false ; }; void wxDC::SetTextBackground( const wxColour &col ) { if (!Ok()) return; m_textBackgroundColour = col; + m_macFontInstalled = false ; }; void wxDC::SetMapMode( int mode ) @@ -383,3 +534,1044 @@ void wxDC::ComputeScaleAndOrigin(void) } }; +void wxDC::SetPalette( const wxPalette& palette ) +{ +} + +void wxDC::SetBackgroundMode( int mode ) +{ + m_backgroundMode = mode ; +} + +void wxDC::SetFont( const wxFont &font ) +{ + if (!Ok()) + return; + + MacVerifySetup() ; + + m_font = font; + m_macFontInstalled = false ; +} + +void wxDC::SetPen( const wxPen &pen ) +{ + if (!Ok() ) + return; + + MacVerifySetup() ; + + if ( m_pen == pen ) + return ; + + m_pen = pen; +/* + if (!m_pen.Ok()) + return; +*/ + m_macPenInstalled = false ; +} + +void wxDC::SetBrush( const wxBrush &brush ) +{ + if (!Ok() ) + return; + MacVerifySetup() ; + + if (m_brush == brush) + return; + + m_brush = brush; + m_macBrushInstalled = false ; +} + +void wxDC::SetBackground( const wxBrush &brush ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + 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 ; +} + +void wxDC::FloodFill( long x1, long y1, const wxColour& col, int style ) +{ +} + +bool wxDC::GetPixel( long x1, long y1, wxColour *col ) const +{ + return true ; +} + +void wxDC::DrawLine( long x1, long y1, long x2, long y2 ) +{ + if (!Ok()) + return; + + MacVerifySetup() ; + + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + int offset = (m_pen.GetWidth() - 1) / 2 ; + long xx1 = XLOG2DEV(x1); + long yy1 = YLOG2DEV(y1); + long xx2 = XLOG2DEV(x2); + long yy2 = YLOG2DEV(y2); + + ::MoveTo(xx1 - offset ,yy1 - offset); + ::LineTo(xx2 - offset , yy2 - offset ); + }; +} + +void wxDC::CrossHair( long x, long y ) +{ +} + +void wxDC::DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) +{ +} + +void wxDC::DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) +{ +} + +void wxDC::DrawPoint( long x, long y ) +{ + if (!Ok()) + return; + + MacVerifySetup() ; + + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + long xx1 = XLOG2DEV(x); + long yy1 = YLOG2DEV(y); + + ::MoveTo(xx1,yy1); + ::LineTo(xx1+1, yy1+1); + }; +} + +void wxDC::DrawLines( int n, wxPoint points[], long xoffset , long yoffset ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if (m_pen.GetStyle() == wxTRANSPARENT) + return; + + MacInstallPen() ; + + int offset = (m_pen.GetWidth() - 1 ) / 2 ; + long x1, x2 , y1 , y2 ; + x1 = XLOG2DEV(points[0].x + xoffset); + y1 = YLOG2DEV(points[0].y + yoffset); + ::MoveTo(x1 - offset ,y1 - offset ); + + for (int i = 0; i < n-1; i++) + { + long x2 = XLOG2DEV(points[i+1].x + xoffset); + long y2 = YLOG2DEV(points[i+1].y + yoffset); + ::LineTo(x2 - offset , y2 - offset ); + } +} + +void wxDC::DrawPolygon( int n, wxPoint points[], long xoffset , long yoffset , + int fillStyle ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + PolyHandle polygon = OpenPoly() ; + long x1, x2 , y1 , y2 ; + x1 = XLOG2DEV(points[0].x + xoffset); + y1 = YLOG2DEV(points[0].y + yoffset); + ::MoveTo(x1,y1); + + for (int i = 0; i < n-1; i++) + { + long x2 = XLOG2DEV(points[i+1].x + xoffset); + long y2 = YLOG2DEV(points[i+1].y + yoffset); + ::LineTo(x2, y2); + } + + ClosePoly() ; + if (m_brush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::PaintPoly( polygon ) ; + }; + + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FramePoly( polygon ) ; + }; + KillPoly( polygon ) ; +} + +void wxDC::DrawRectangle( long x, long y, long width, long height ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + long xx = XLOG2DEV(x); + long yy = YLOG2DEV(y); + long ww = m_signX * XLOG2DEVREL(width); + long 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::DrawRoundedRectangle( long x, long y, long width, long height, double radius ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if (radius < 0.0) + radius = - radius * ((width < height) ? width : height); + + long xx = XLOG2DEV(x); + long yy = YLOG2DEV(y); + long ww = m_signX * XLOG2DEVREL(width); + long 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 , radius * 2 , radius * 2 ) ; + }; + + if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallPen() ; + ::FrameRoundRect( &rect , radius * 2 , radius * 2 ) ; + }; +} + +void wxDC::DrawEllipse( long x, long y, long width, long height ) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + long xx = XLOG2DEV(x); + long yy = YLOG2DEV(y); + long ww = m_signX * XLOG2DEVREL(width); + long 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 ) ; + }; +} + +// ----------------------------------- spline code ---------------------------------------- + +static void wx_quadratic_spline(double a1, double b1, double a2, double b2, + double a3, double b3, double a4, double b4); +static void wx_clear_stack(void); +static int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3, + double *y3, double *x4, double *y4); +static void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, + double x4, double y4); +static bool wx_spline_add_point(double x, double y); +static void wx_spline_draw_point_array(wxDC *dc); + +static wxList wx_spline_point_list; + +#define half(z1, z2) ((z1+z2)/2.0) +#define THRESHOLD 5 + +/* iterative version */ + +static void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4, + double b4) +{ + register double xmid, ymid; + double x1, y1, x2, y2, x3, y3, x4, y4; + + wx_clear_stack(); + wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4); + + while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) { + xmid = (double)half(x2, x3); + ymid = (double)half(y2, y3); + if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD && + fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) { + wx_spline_add_point( x1, y1 ); + wx_spline_add_point( xmid, ymid ); + } else { + wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3), + (double)half(x3, x4), (double)half(y3, y4), x4, y4); + wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2), + (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid); + } + } +} + +/* utilities used by spline drawing routines */ + +typedef struct wx_spline_stack_struct { + double x1, y1, x2, y2, x3, y3, x4, y4; +} Stack; + +#define SPLINE_STACK_DEPTH 20 +static Stack wx_spline_stack[SPLINE_STACK_DEPTH]; +static Stack *wx_stack_top; +static int wx_stack_count; + +static void wx_clear_stack(void) +{ + wx_stack_top = wx_spline_stack; + wx_stack_count = 0; +} + +static void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) +{ + wx_stack_top->x1 = x1; + wx_stack_top->y1 = y1; + wx_stack_top->x2 = x2; + wx_stack_top->y2 = y2; + wx_stack_top->x3 = x3; + wx_stack_top->y3 = y3; + wx_stack_top->x4 = x4; + wx_stack_top->y4 = y4; + wx_stack_top++; + wx_stack_count++; +} + +static int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, + double *x3, double *y3, double *x4, double *y4) +{ + if (wx_stack_count == 0) + return (0); + wx_stack_top--; + wx_stack_count--; + *x1 = wx_stack_top->x1; + *y1 = wx_stack_top->y1; + *x2 = wx_stack_top->x2; + *y2 = wx_stack_top->y2; + *x3 = wx_stack_top->x3; + *y3 = wx_stack_top->y3; + *x4 = wx_stack_top->x4; + *y4 = wx_stack_top->y4; + return (1); +} + +static bool wx_spline_add_point(double x, double y) +{ + wxPoint *point = new wxPoint ; + point->x = (int) x; + point->y = (int) y; + wx_spline_point_list.Append((wxObject*)point); + return TRUE; +} + +static void wx_spline_draw_point_array(wxDC *dc) +{ + dc->DrawLines(&wx_spline_point_list, 0, 0 ); + wxNode *node = wx_spline_point_list.First(); + while (node) + { + wxPoint *point = (wxPoint *)node->Data(); + delete point; + delete node; + node = wx_spline_point_list.First(); + } +} + +void wxDC::DrawSpline( wxList *points ) +{ + wxPoint *p; + double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; + double x1, y1, x2, y2; + + wxNode *node = points->First(); + p = (wxPoint *)node->Data(); + + x1 = p->x; + y1 = p->y; + + node = node->Next(); + p = (wxPoint *)node->Data(); + + x2 = p->x; + y2 = p->y; + cx1 = (double)((x1 + x2) / 2); + cy1 = (double)((y1 + y2) / 2); + cx2 = (double)((cx1 + x2) / 2); + cy2 = (double)((cy1 + y2) / 2); + + wx_spline_add_point(x1, y1); + + while ((node = node->Next()) != NULL) + { + p = (wxPoint *)node->Data(); + x1 = x2; + y1 = y2; + x2 = p->x; + y2 = p->y; + cx4 = (double)(x1 + x2) / 2; + cy4 = (double)(y1 + y2) / 2; + cx3 = (double)(x1 + cx4) / 2; + cy3 = (double)(y1 + cy4) / 2; + + wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4); + + cx1 = cx4; + cy1 = cy4; + cx2 = (double)(cx1 + x2) / 2; + cy2 = (double)(cy1 + y2) / 2; + } + + wx_spline_add_point( cx1, cy1 ); + wx_spline_add_point( x2, y2 ); + + wx_spline_draw_point_array( this ); +} + + + +bool wxDC::CanDrawBitmap(void) const +{ + return true ; +} + + +bool wxDC::Blit( long xdest, long ydest, long width, long height, + wxDC *source, long xsrc, long ysrc, int logical_func , bool useMask ) +{ + if (!Ok()) return FALSE; + MacVerifySetup() ; + + CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ; + PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; + RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; + RGBColor black = { 0,0,0} ; +// RGBForeColor( &black ) ; +// RGBBackColor( &white ) ; + RGBForeColor( &m_textForegroundColour.GetPixel() ) ; + RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; + + if ( LockPixels(bmappixels) ) + { + Rect srcrect , dstrect ; + srcrect.top = source->YLOG2DEV(ysrc) ; + srcrect.left = source->XLOG2DEV(xsrc) ; + srcrect.right = source->XLOG2DEV(xsrc + width ) ; + srcrect.bottom = source->YLOG2DEV(ysrc + height) ; + dstrect.top = YLOG2DEV(ydest) ; + dstrect.left = XLOG2DEV(xdest) ; + dstrect.bottom = YLOG2DEV(ydest + height ) ; + dstrect.right = XLOG2DEV(xdest + width ) ; +// ::ClipRect(&m_macClipRect); + CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits , + &srcrect, &dstrect, srcCopy, NULL ) ; +/* + if ( m_clipping ) + { + long x1 = XLOG2DEV(m_clipX1); + long y1 = YLOG2DEV(m_clipY1); + long x2 = XLOG2DEV(m_clipX2); + long y2 = YLOG2DEV(m_clipY2); + + Rect clip = { y1 , x1 , y2 , x2 } ; + ::ClipRect(&clip); + } +*/ + UnlockPixels( bmappixels ) ; + } + + m_macPenInstalled = false ; + m_macBrushInstalled = false ; + m_macFontInstalled = false ; + + return TRUE; +} + +void wxDC::DrawText( const wxString &string, long x, long y, bool use16) +{ + if (!Ok()) + return; + MacVerifySetup() ; + + long xx = XLOG2DEV(x); + long yy = YLOG2DEV(y); + +// if (m_pen.GetStyle() != wxTRANSPARENT) + { + MacInstallFont() ; + /* + Rect clip = { -32000 , -32000 , 32000 , 32000 } ; + + ::ClipRect( &clip ) ; + */ + + FontInfo fi ; + ::GetFontInfo( &fi ) ; + + 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( string ) ; + text = macText ; + length = macText.Length() ; + } + else + { + text = string ; + length = string.Length() ; + } + + int laststop = 0 ; + int i = 0 ; + int line = 0 ; + + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { + ::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 ) ; + ::TextMode( srcOr ) ; + } +} + +bool wxDC::CanGetTextExtent(void) const +{ + if ( !Ok() ) + return false ; + + return true ; +} + +void wxDC::GetTextExtent( const wxString &string, long *width, long *height, + long *descent, long *externalLeading , + wxFont *theFont , bool use16 ) const +{ + if (!Ok()) + return; + + MacVerifySetup() ; + + wxFont formerFont = m_font ; + + if ( theFont ) + { + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + + if ( font ) + { + long yy1 = YLOG2DEV(0); + long yy2 = YLOG2DEV(font->m_macFontSize); + + ::TextFont( font->m_macFontNum ) ; + ::TextSize( abs( yy2-yy1) ) ; + ::TextFace( font->m_macFontStyle ) ; + } + } + else + { + MacInstallFont() ; + } + + FontInfo fi ; + ::GetFontInfo( &fi ) ; + + *height = fi.descent + fi.ascent ; + *descent = fi.descent ; + *externalLeading = 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 ; + *width = 0 ; + + while( i < length ) + { + if( text[i] == 13 || text[i] == 10) + { + *height += fi.descent + fi.ascent + fi.leading; + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( curwidth > *width ) + *width = curwidth ; + laststop = i+1 ; + } + i++ ; + } + + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + if ( curwidth > *width ) + *width = curwidth ; + + if ( theFont ) + { + m_macFontInstalled = false ; + } +} + +long wxDC::GetCharWidth(void) +{ + if (!Ok()) + return 1; + + MacVerifySetup() ; + + MacInstallFont() ; + + FontInfo fi ; + ::GetFontInfo( &fi ) ; + + return (fi.descent + fi.ascent) / 2 ; +} + +long wxDC::GetCharHeight(void) +{ + if (!Ok()) + return 1; + + MacVerifySetup() ; + + MacInstallFont() ; + + FontInfo fi ; + ::GetFontInfo( &fi ) ; + + return fi.descent + fi.ascent ; +} + +void wxDC::Clear(void) +{ + if (!Ok()) + return; + MacVerifySetup() ; + Rect rect = { -32767 , -32767 , 32767 , 32767 } ; + + if (m_backgroundBrush.GetStyle() != wxTRANSPARENT) + { + MacInstallBrush() ; + ::EraseRect( &rect ) ; + }; +} + +void wxDC::MacInstallFont() const +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if ( m_macFontInstalled ) + return ; + + wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; + + if ( font ) + { + ::TextFont( font->m_macFontNum ) ; + ::TextSize( m_scaleY * font->m_macFontSize ) ; + ::TextFace( font->m_macFontStyle ) ; + + m_macFontInstalled = true ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + + ::RGBForeColor(&m_textForegroundColour.GetPixel() ); + ::RGBBackColor(&m_textBackgroundColour.GetPixel() ); + } + else + { + short fontnum ; + + GetFNum( "\pGeneva" , &fontnum ) ; + ::TextFont( fontnum ) ; + ::TextSize( m_scaleY * 10 ) ; + ::TextFace( 0 ) ; + + // todo reset after spacing changes - or store the current spacing somewhere + + m_macFontInstalled = true ; + m_macBrushInstalled = false ; + m_macPenInstalled = false ; + ::RGBForeColor( &(m_textForegroundColour.GetPixel()) ); + ::RGBBackColor(&m_textBackgroundColour.GetPixel() ); + } + + + short mode = patCopy ; + + // todo : + + switch( m_logicalFunction ) + { + case wxCOPY: // src + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + ::PenPat(&qd.black); + 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 ) ; +} + +static void wxMacGetHatchPattern(int hatchStyle, Pattern *pattern) +{ + int thePatListID = sysPatListID; + int theIndex; + switch(hatchStyle) + { + case wxBDIAGONAL_HATCH: + theIndex = 34; // WCH: this is not good + break; + case wxFDIAGONAL_HATCH: + theIndex = 26; + break; + case wxCROSS_HATCH: + theIndex = 5; + break; + case wxHORIZONTAL_HATCH: + theIndex = 25; + break; + case wxVERTICAL_HATCH: + theIndex = 6; + break; + case wxCROSSDIAG_HATCH: + theIndex = 4; // WCH: this is not good + break; + default: + theIndex = 1; // solid pattern + break; + } + GetIndPattern( pattern, thePatListID, theIndex); +} + +void wxDC::MacInstallPen() const +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if ( m_macPenInstalled ) + return ; + + ::RGBForeColor(&m_pen.GetColour().GetPixel() ); + ::RGBBackColor(&m_backgroundBrush.GetColour().GetPixel() ); + + ::PenNormal() ; + int penWidth = m_pen.GetWidth(); + ::PenSize(penWidth, penWidth); + + int penStyle = m_pen.GetStyle(); + + if (penStyle == wxSOLID) + ::PenPat(&qd.black); + else if (IS_HATCH(penStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(penStyle, &pat); + ::PenPat(&pat); + } + else + { + ::PenPat(&qd.black); + } + + short mode = patCopy ; + + // todo : + + switch( m_logicalFunction ) + { + case wxCOPY: // src + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + ::PenPat(&qd.black); + 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::MacInstallBrush() const +{ + if (!Ok()) + return; + MacVerifySetup() ; + + if ( m_macBrushInstalled ) + return ; + + // foreground + + ::RGBForeColor(&m_brush.GetColour().GetPixel() ); + ::RGBBackColor(&m_backgroundBrush.GetColour().GetPixel() ); + + int brushStyle = m_brush.GetStyle(); + if (brushStyle == wxSOLID) + ::PenPat(&qd.black); + else if (IS_HATCH(brushStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(brushStyle, &pat); + ::PenPat(&pat); + } + else + { + ::PenPat(&qd.black); + } + + + // background + + brushStyle = m_backgroundBrush.GetStyle(); + if (brushStyle == wxSOLID) + ::BackPat(&qd.white); + else if (IS_HATCH(brushStyle)) + { + Pattern pat ; + wxMacGetHatchPattern(brushStyle, &pat); + ::BackPat(&pat); + } + else + { + ::BackPat(&qd.white); + } + + short mode = patCopy ; + + // todo : + + switch( m_logicalFunction ) + { + case wxCOPY: // src + mode = patCopy ; + break ; + case wxINVERT: // NOT dst + ::PenPat(&qd.black); + 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 ; +} + + diff --git a/src/mac/dcclient.cpp b/src/mac/dcclient.cpp index 925d9609ee..08aeff0504 100644 --- a/src/mac/dcclient.cpp +++ b/src/mac/dcclient.cpp @@ -38,598 +38,78 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) * wxWindowDC */ +#include + wxWindowDC::wxWindowDC(void) { -}; +} -wxWindowDC::wxWindowDC( wxWindow *window ) -{ -}; +wxWindowDC::wxWindowDC(wxWindow *the_canvas) +{ + WindowRef windowref ; + wxWindow* rootwindow ; + + // this time it is really the full window + + the_canvas->MacGetPortParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); + m_macPort = UMAGetWindowPort( windowref ) ; + MacSetupPort() ; + m_ok = TRUE ; +} wxWindowDC::~wxWindowDC(void) { -}; - -void wxWindowDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1), - const wxColour& WXUNUSED(col), int WXUNUSED(style) ) -{ -}; - -bool wxWindowDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const -{ - return FALSE; -}; - -void wxWindowDC::DrawLine( long x1, long y1, long x2, long y2 ) -{ - if (!Ok()) return; - -}; - -void wxWindowDC::CrossHair( long x, long y ) -{ - if (!Ok()) return; - -}; - -void wxWindowDC::DrawArc( long x1, long y1, long x2, long y2, long xc, long yc ) -{ - if (!Ok()) return; - - long xx1 = XLOG2DEV(x1); - long yy1 = YLOG2DEV(y1); - long xx2 = XLOG2DEV(x2); - long yy2 = YLOG2DEV(y2); - long xxc = XLOG2DEV((long)xc); - long yyc = YLOG2DEV((long)yc); - double dx = xx1 - xxc; - double dy = yy1 - yyc; - double radius = sqrt(dx*dx+dy*dy); - long r = (long)radius; - double radius1, radius2; - - if (xx1 == xx2 && yy1 == yy2) - { - radius1 = 0.0; - radius2 = 360.0; - } - else - if (radius == 0.0) - { - radius1 = radius2 = 0.0; - } - else - { - radius1 = (xx1 - xxc == 0) ? - (yy1 - yyc < 0) ? 90.0 : -90.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; - }; - long alpha1 = long(radius1 * 64.0); - long alpha2 = long((radius2 - radius1) * 64.0); - while (alpha2 <= 0) alpha2 += 360*64; - while (alpha1 > 360*64) alpha1 -= 360*64; - - if (m_brush.GetStyle() != wxTRANSPARENT) {}; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; - -}; - -void wxWindowDC::DrawEllipticArc( long x, long y, long width, long height, double sa, double ea ) -{ - if (!Ok()) return; - - long xx = XLOG2DEV(x); - long yy = YLOG2DEV(y); - long ww = m_signX * XLOG2DEVREL(width); - long hh = m_signY * YLOG2DEVREL(height); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - long start = long(sa * 64.0); - long end = long(ea * 64.0); - if (m_brush.GetStyle() != wxTRANSPARENT) {}; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; -}; - -void wxWindowDC::DrawPoint( long x, long y ) -{ - if (!Ok()) return; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; -}; - -void wxWindowDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset ) -{ - if (!Ok()) return; - - if (m_pen.GetStyle() == wxTRANSPARENT) return; - - for (int i = 0; i < n-1; i++) - { - long x1 = XLOG2DEV(points[i].x + xoffset); - long x2 = XLOG2DEV(points[i+1].x + xoffset); - long y1 = YLOG2DEV(points[i].y + yoffset); // oh, what a waste - long y2 = YLOG2DEV(points[i+1].y + yoffset); - }; -}; - -void wxWindowDC::DrawLines( wxList *points, long xoffset, long yoffset ) -{ - if (!Ok()) return; - - if (m_pen.GetStyle() == wxTRANSPARENT) return; - - wxNode *node = points->First(); - while (node->Next()) - { - wxPoint *point = (wxPoint*)node->Data(); - wxPoint *npoint = (wxPoint*)node->Next()->Data(); - long x1 = XLOG2DEV(point->x + xoffset); - long x2 = XLOG2DEV(npoint->x + xoffset); - long y1 = YLOG2DEV(point->y + yoffset); // and again... - long y2 = YLOG2DEV(npoint->y + yoffset); - node = node->Next(); - }; -}; - -void wxWindowDC::DrawPolygon( int WXUNUSED(n), wxPoint WXUNUSED(points)[], - long WXUNUSED(xoffset), long WXUNUSED(yoffset), int WXUNUSED(fillStyle) ) -{ - if (!Ok()) return; -}; - -void wxWindowDC::DrawPolygon( wxList *WXUNUSED(lines), long WXUNUSED(xoffset), - long WXUNUSED(yoffset), int WXUNUSED(fillStyle) ) -{ - if (!Ok()) return; -}; - -void wxWindowDC::DrawRectangle( long x, long y, long width, long height ) -{ - if (!Ok()) return; - - long xx = XLOG2DEV(x); - long yy = YLOG2DEV(y); - long ww = m_signX * XLOG2DEVREL(width); - long 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; } - - if (m_brush.GetStyle() != wxTRANSPARENT) {}; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; -}; - -void wxWindowDC::DrawRoundedRectangle( long x, long y, long width, long height, double radius ) -{ - if (!Ok()) return; - - if (radius < 0.0) radius = - radius * ((width < height) ? width : height); - - long xx = XLOG2DEV(x); - long yy = YLOG2DEV(y); - long ww = m_signX * XLOG2DEVREL(width); - long hh = m_signY * YLOG2DEVREL(height); - long rr = XLOG2DEVREL((long)radius); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - // CMB: if radius is zero use DrawRectangle() instead to avoid - // X drawing errors with small radii - if (rr == 0) - { - DrawRectangle( x, y, width, height ); - return; - } - - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) return; - - // CMB: adjust size if outline is drawn otherwise the result is - // 1 pixel too wide and high - if (m_pen.GetStyle() != wxTRANSPARENT) - { - ww--; - hh--; - } - - // CMB: ensure dd is not larger than rectangle otherwise we - // get an hour glass shape - long dd = 2 * rr; - if (dd > ww) dd = ww; - if (dd > hh) dd = hh; - rr = dd / 2; - - if (m_brush.GetStyle() != wxTRANSPARENT) - { - }; - - if (m_pen.GetStyle() != wxTRANSPARENT) - { - }; -}; - -void wxWindowDC::DrawEllipse( long x, long y, long width, long height ) -{ - if (!Ok()) return; - - long xx = XLOG2DEV(x); - long yy = YLOG2DEV(y); - long ww = m_signX * XLOG2DEVREL(width); - long hh = m_signY * YLOG2DEVREL(height); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - if (m_brush.GetStyle() != wxTRANSPARENT) {}; - - if (m_pen.GetStyle() != wxTRANSPARENT) {}; -}; - -bool wxWindowDC::CanDrawBitmap(void) const -{ - return TRUE; -}; - -void wxWindowDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask ) -{ - if (!Ok()) return; - - if (!icon.Ok()) return; - - int xx = XLOG2DEV(x); - int yy = YLOG2DEV(y); - -}; - -bool wxWindowDC::Blit( long xdest, long ydest, long width, long height, - wxDC *source, long xsrc, long ysrc, int WXUNUSED(logical_func), bool WXUNUSED(useMask) ) -{ - if (!Ok()) return FALSE; - - // CMB 20/5/98: add blitting of bitmaps - if (source->IsKindOf(CLASSINFO(wxMemoryDC))) - { - wxMemoryDC* srcDC = (wxMemoryDC*)source; - /* - GdkBitmap* bmap = srcDC->m_selected.GetBitmap(); - if (bmap) - { - gdk_draw_bitmap ( - m_window, - m_textGC, - bmap, - source->DeviceToLogicalX(xsrc), source->DeviceToLogicalY(ysrc), - XLOG2DEV(xdest), YLOG2DEV(ydest), - source->DeviceToLogicalXRel(width), source->DeviceToLogicalYRel(height) - ); - return TRUE; - } - */ - } - - return TRUE; -}; - -void wxWindowDC::DrawText( const wxString &text, long x, long y, bool -WXUNUSED(use16) ) -{ - if (!Ok()) return; - -}; - - - -bool wxWindowDC::CanGetTextExtent(void) const -{ - return TRUE; -}; - -void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *height, - long *WXUNUSED(descent), long *WXUNUSED(externalLeading), - wxFont *WXUNUSED(theFont), bool WXUNUSED(use16) ) -{ - if (!Ok()) return; - -}; - -long wxWindowDC::GetCharWidth(void) -{ - if (!Ok()) return 0; - return 0; -}; - -long wxWindowDC::GetCharHeight(void) -{ - if (!Ok()) return 0; - return 0; -}; - -void wxWindowDC::Clear(void) -{ - if (!Ok()) return; - -}; - -void wxWindowDC::SetFont( const wxFont &font ) -{ - if (!Ok()) return; - - m_font = font; -}; - -void wxWindowDC::SetPen( const wxPen &pen ) -{ - if (!Ok()) return; - - if (m_pen == pen) return; - - m_pen = pen; - - if (!m_pen.Ok()) return; -}; - -void wxWindowDC::SetBrush( const wxBrush &brush ) -{ - if (!Ok()) return; - - if (m_brush == brush) return; - - m_brush = brush; - - if (!m_brush.Ok()) return; - -}; - -void wxWindowDC::SetBackground( const wxBrush &brush ) -{ - if (!Ok()) return; - - if (m_backgroundBrush == brush) return; - - m_backgroundBrush = brush; - - if (!m_backgroundBrush.Ok()) return; - -}; - -void wxWindowDC::SetLogicalFunction( int function ) -{ - if (m_logicalFunction == function) return; -}; - -void wxWindowDC::SetTextForeground( const wxColour &col ) -{ - if (!Ok()) return; - - if (m_textForegroundColour == col) return; - - m_textForegroundColour = col; - if (!m_textForegroundColour.Ok()) return; -}; - -void wxWindowDC::SetTextBackground( const wxColour &col ) -{ - if (!Ok()) return; - - if (m_textBackgroundColour == col) return; - - m_textBackgroundColour = col; - if (!m_textBackgroundColour.Ok()) return; -}; - -void wxWindowDC::SetBackgroundMode( int mode ) -{ - m_backgroundMode = mode; - - if (m_brush.GetStyle() != wxSOLID && m_brush.GetStyle() != wxTRANSPARENT) - { - } -}; - -void wxWindowDC::SetPalette( const wxPalette& WXUNUSED(palette) ) -{ -}; - -void wxWindowDC::SetClippingRegion( long x, long y, long width, long height ) -{ - wxDC::SetClippingRegion( x, y, width, height ); +} - // TODO - -}; +/* + * wxClientDC + */ -void wxWindowDC::SetClippingRegion( const wxRegion& region ) +wxClientDC::wxClientDC(void) { - wxRect box = region.GetBox(); - - wxDC::SetClippingRegion( box.x, box.y, box.width, box.height ); - - // TODO } -void wxWindowDC::DestroyClippingRegion(void) +wxClientDC::wxClientDC(wxWindow *window) { - wxDC::DestroyClippingRegion(); - -}; - -// ----------------------------------- spline code ---------------------------------------- - -void wx_quadratic_spline(double a1, double b1, double a2, double b2, - double a3, double b3, double a4, double b4); -void wx_clear_stack(void); -int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3, - double *y3, double *x4, double *y4); -void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, - double x4, double y4); -static bool wx_spline_add_point(double x, double y); -static void wx_spline_draw_point_array(wxDC *dc); + WindowRef windowref ; + wxWindow* rootwindow ; + + window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); + m_macPort = UMAGetWindowPort( windowref ) ; + MacSetupPort() ; + m_ok = TRUE ; + SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID)); -wxList wx_spline_point_list; - -#define half(z1, z2) ((z1+z2)/2.0) -#define THRESHOLD 5 - -/* iterative version */ - -void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4, - double b4) -{ - register double xmid, ymid; - double x1, y1, x2, y2, x3, y3, x4, y4; - - wx_clear_stack(); - wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4); - - while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) { - xmid = (double)half(x2, x3); - ymid = (double)half(y2, y3); - if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD && - fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) { - wx_spline_add_point( x1, y1 ); - wx_spline_add_point( xmid, ymid ); - } else { - wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3), - (double)half(x3, x4), (double)half(y3, y4), x4, y4); - wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2), - (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid); - } - } } -/* utilities used by spline drawing routines */ - -typedef struct wx_spline_stack_struct { - double x1, y1, x2, y2, x3, y3, x4, y4; -} Stack; - -#define SPLINE_STACK_DEPTH 20 -static Stack wx_spline_stack[SPLINE_STACK_DEPTH]; -static Stack *wx_stack_top; -static int wx_stack_count; - -void wx_clear_stack(void) +wxClientDC::~wxClientDC(void) { - wx_stack_top = wx_spline_stack; - wx_stack_count = 0; } -void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) -{ - wx_stack_top->x1 = x1; - wx_stack_top->y1 = y1; - wx_stack_top->x2 = x2; - wx_stack_top->y2 = y2; - wx_stack_top->x3 = x3; - wx_stack_top->y3 = y3; - wx_stack_top->x4 = x4; - wx_stack_top->y4 = y4; - wx_stack_top++; - wx_stack_count++; -} +/* + * wxPaintDC + */ -int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, - double *x3, double *y3, double *x4, double *y4) +wxPaintDC::wxPaintDC(void) { - if (wx_stack_count == 0) - return (0); - wx_stack_top--; - wx_stack_count--; - *x1 = wx_stack_top->x1; - *y1 = wx_stack_top->y1; - *x2 = wx_stack_top->x2; - *y2 = wx_stack_top->y2; - *x3 = wx_stack_top->x3; - *y3 = wx_stack_top->y3; - *x4 = wx_stack_top->x4; - *y4 = wx_stack_top->y4; - return (1); } -static bool wx_spline_add_point(double x, double y) +wxPaintDC::wxPaintDC(wxWindow *window) { - wxPoint *point = new wxPoint ; - point->x = (int) x; - point->y = (int) y; - wx_spline_point_list.Append((wxObject*)point); - return TRUE; -} + WindowRef windowref ; + wxWindow* rootwindow ; + + window->MacGetPortClientParams(&m_macLocalOrigin, &m_macClipRect , &windowref , &rootwindow ); -static void wx_spline_draw_point_array(wxDC *dc) -{ - dc->DrawLines(&wx_spline_point_list, 0, 0 ); - wxNode *node = wx_spline_point_list.First(); - while (node) - { - wxPoint *point = (wxPoint *)node->Data(); - delete point; - delete node; - node = wx_spline_point_list.First(); - } + m_macPort = UMAGetWindowPort( windowref ) ; + MacSetupPort() ; + m_ok = TRUE ; + long x , y ,w , h ; + window->GetUpdateRegion().GetBox( x , y , w , h ) ; + SetClippingRegion( x , y , w , h ) ; + SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID)); } -void wxWindowDC::DrawSpline( wxList *points ) +wxPaintDC::~wxPaintDC() { - wxPoint *p; - double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; - double x1, y1, x2, y2; - - wxNode *node = points->First(); - p = (wxPoint *)node->Data(); - - x1 = p->x; - y1 = p->y; - - node = node->Next(); - p = (wxPoint *)node->Data(); - - x2 = p->x; - y2 = p->y; - cx1 = (double)((x1 + x2) / 2); - cy1 = (double)((y1 + y2) / 2); - cx2 = (double)((cx1 + x2) / 2); - cy2 = (double)((cy1 + y2) / 2); - - wx_spline_add_point(x1, y1); - - while ((node = node->Next()) != NULL) - { - p = (wxPoint *)node->Data(); - x1 = x2; - y1 = y2; - x2 = p->x; - y2 = p->y; - cx4 = (double)(x1 + x2) / 2; - cy4 = (double)(y1 + y2) / 2; - cx3 = (double)(x1 + cx4) / 2; - cy3 = (double)(y1 + cy4) / 2; - - wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4); - - cx1 = cx4; - cy1 = cy4; - cx2 = (double)(cx1 + x2) / 2; - cy2 = (double)(cy1 + y2) / 2; - } - - wx_spline_add_point( cx1, cy1 ); - wx_spline_add_point( x2, y2 ); - - wx_spline_draw_point_array( this ); -}; +} diff --git a/src/mac/dcmemory.cpp b/src/mac/dcmemory.cpp index 7cbd330821..28a652368a 100644 --- a/src/mac/dcmemory.cpp +++ b/src/mac/dcmemory.cpp @@ -40,6 +40,18 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) m_selected = bitmap; if (m_selected.Ok()) { + wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ; + if ( bmap->m_hBitmap ) + { + m_macPort = (GrafPtr) bmap->m_hBitmap ; + MacSetupPort() ; + m_ok = TRUE ; + // SetBackground(wxBrush(*wxWHITE, wxSOLID)); + } + else + { + m_ok = FALSE; + } } else { diff --git a/src/mac/dcscreen.cpp b/src/mac/dcscreen.cpp index e03bbac0c8..1ea12f3d29 100644 --- a/src/mac/dcscreen.cpp +++ b/src/mac/dcscreen.cpp @@ -22,7 +22,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) // Create a DC representing the whole screen wxScreenDC::wxScreenDC() { - // TODO + m_macPort = LMGetWMgrPort() ; + MacSetupPort() ; + m_ok = TRUE ; } wxScreenDC::~wxScreenDC() diff --git a/src/mac/dialog.cpp b/src/mac/dialog.cpp index bf3cae5e35..7e82133eb2 100644 --- a/src/mac/dialog.cpp +++ b/src/mac/dialog.cpp @@ -19,6 +19,8 @@ #include "wx/app.h" #include "wx/settings.h" +#include + // Lists to keep track of windows, so we can disable/enable them // for modal dialogs wxList wxModalDialogs; @@ -29,6 +31,7 @@ extern wxList wxPendingDelete; IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxPanel) + EVT_SIZE(wxDialog::OnSize) EVT_BUTTON(wxID_OK, wxDialog::OnOK) EVT_BUTTON(wxID_APPLY, wxDialog::OnApply) EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel) @@ -66,9 +69,47 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, else m_windowId = id; - // TODO: create dialog + 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; + if (m_width == -1) + m_width = 20; + 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); + m_macWindowData = new MacWindowData() ; + + WindowClass wclass = kMovableModalWindowClass ; + WindowAttributes attr = kWindowNoAttributes ; + + if ( ( m_windowStyle & wxMINIMIZE_BOX ) || ( m_windowStyle & wxMAXIMIZE_BOX ) ) + { + attr |= kWindowFullZoomAttribute ; + attr |= kWindowResizableAttribute ; + } - return FALSE; + UMACreateNewWindow( wclass , attr , &theBoundsRect , &m_macWindowData->m_macWindow ) ; + wxAssociateWinWithMacWindow( m_macWindowData->m_macWindow , this ) ; + wxString label ; + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( title ) ; + else + label = title ; + UMASetWTitleC( m_macWindowData->m_macWindow , label ) ; + m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ; + UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ; + m_macWindowData->m_macFocus = NULL ; + m_macShown = false ; + return TRUE; } void wxDialog::SetModal(bool flag) @@ -86,7 +127,6 @@ void wxDialog::SetModal(bool flag) wxDialog::~wxDialog() { - // TODO wxTopLevelWindows.DeleteObject(this); if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL ) @@ -99,7 +139,7 @@ wxDialog::~wxDialog() if (wxTheApp->GetExitOnFrameDelete()) { - // TODO: exit + wxTheApp->ExitMainLoop() ; } } } @@ -132,67 +172,65 @@ bool wxDialog::IsIconized() const return FALSE; } -void wxDialog::SetClientSize(int width, int height) -{ - // TODO -} - -void wxDialog::GetPosition(int *x, int *y) const -{ - // TODO -} +extern bool s_macIsInModalLoop ; bool wxDialog::Show(bool show) { - // TODO - return FALSE; -} + if ( m_macShown == show ) + return TRUE ; -void wxDialog::SetTitle(const wxString& title) -{ - // TODO -} + m_macShown = show ; -wxString wxDialog::GetTitle() const -{ - // TODO - return wxString(""); -} + bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ; -void wxDialog::Centre(int direction) -{ - int x_offset,y_offset ; - int display_width, display_height; - int width, height, x, y; - wxWindow *parent = GetParent(); - if ((direction & wxCENTER_FRAME) && parent) - { - parent->GetPosition(&x_offset,&y_offset) ; - parent->GetSize(&display_width,&display_height) ; - } - else - { - wxDisplaySize(&display_width, &display_height); - x_offset = 0 ; - y_offset = 0 ; - } + if ( modal ) + { + s_macIsInModalLoop = true ; + if (show) + { + // if we don't do it, some window might be deleted while we have pointers + // to them in our disabledWindows list and the program will crash when it + // will try to reenable them after the modal dialog end + wxTheApp->DeletePendingObjects(); - GetSize(&width, &height); - GetPosition(&x, &y); + UMAShowWindow( m_macWindowData->m_macWindow ) ; + UMASelectWindow( m_macWindowData->m_macWindow ) ; - if (direction & wxHORIZONTAL) - x = (int)((display_width - width)/2); - if (direction & wxVERTICAL) - y = (int)((display_height - height)/2); + if (!wxModalDialogs.Member(this)) + wxModalDialogs.Append(this); - SetSize(x+x_offset, y+y_offset, width, height); + while (wxModalDialogs.Member(this) ) + { + wxTheApp->MacDoOneEvent() ; + } + } + else + { + wxModalDialogs.DeleteObject(this); + UMAHideWindow( m_macWindowData->m_macWindow ) ; + } + s_macIsInModalLoop = false ; + } + else // !modal + { + if (show) + { + UMAShowWindow( m_macWindowData->m_macWindow ) ; + UMASelectWindow( m_macWindowData->m_macWindow ) ; + } + else + { + UMAHideWindow( m_macWindowData->m_macWindow ) ; + } + } + return TRUE ; } + // Replacement for Show(TRUE) for modal dialogs - returns return code int wxDialog::ShowModal() { - m_windowStyle |= wxDIALOG_MODAL; - // TODO: modal showing + m_windowStyle |= wxDIALOG_MODAL; Show(TRUE); return GetReturnCode(); } @@ -275,6 +313,16 @@ bool wxDialog::Destroy() return TRUE; } +void wxDialog::OnSize(wxSizeEvent& WXUNUSED(event)) +{ + // if we're using constraints - do use them + #if wxUSE_CONSTRAINTS + if ( GetAutoLayout() ) { + Layout(); + } + #endif +} + void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); @@ -283,4 +331,128 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) void wxDialog::Fit() { + wxWindow::Fit(); } + +wxSizer *wxDialog::CreateTextSizer( const wxString &message ) +{ + wxBoxSizer *box = new wxBoxSizer( wxVERTICAL ); + + // get line height for empty lines + int y = 0; + wxFont new_font( GetFont() ); + if (!new_font.Ok()) new_font = *wxSWISS_FONT; + GetTextExtent( "H", (int*)NULL, &y, (int*)NULL, (int*)NULL, &new_font ); + + wxString line; + for (size_t pos = 0; pos < message.Len(); pos++) + { + if (message[pos] == _T('\n')) + { + if (!line.IsEmpty()) + { + wxStaticText *s1 = new wxStaticText( this, -1, line ); + box->Add( s1 ); + line = _T(""); + } + else + { + box->Add( 5, y ); + } + } + else + { + line += message[pos]; + } + } + + // remaining text behind last '\n' + if (!line.IsEmpty()) + { + wxStaticText *s2 = new wxStaticText( this, -1, line ); + box->Add( s2 ); + } + + return box; +} + +wxSizer *wxDialog::CreateButtonSizer( long flags ) +{ + wxBoxSizer *box = new wxBoxSizer( wxHORIZONTAL ); + +#if defined(__WXMSW__) || defined(__WXMAC__) + int margin = 6; +#else + int margin = 10; +#endif + + wxButton *ok = (wxButton *) NULL; + wxButton *cancel = (wxButton *) NULL; + wxButton *yes = (wxButton *) NULL; + wxButton *no = (wxButton *) NULL; + + // always show an OK button, unless only YES_NO is given + if ((flags & wxYES_NO) == 0) flags = flags | wxOK; + + if (flags & wxYES_NO) + { + yes = new wxButton( this, wxID_YES, _("Yes") ); + box->Add( yes, 0, wxLEFT|wxRIGHT, margin ); + no = new wxButton( this, wxID_NO, _("No") ); + box->Add( no, 0, wxLEFT|wxRIGHT, margin ); + } else + if (flags & wxYES) + { + yes = new wxButton( this, wxID_YES, _("Yes") ); + box->Add( yes, 0, wxLEFT|wxRIGHT, margin ); + } else + if (flags & wxNO) + { + no = new wxButton( this, wxID_NO, _("No") ); + box->Add( no, 0, wxLEFT|wxRIGHT, margin ); + } + + if (flags & wxOK) + { + ok = new wxButton( this, wxID_OK, _("OK") ); + box->Add( ok, 0, wxLEFT|wxRIGHT, margin ); + } + + if (flags & wxFORWARD) + box->Add( new wxButton( this, wxID_FORWARD, _("Forward") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxBACKWARD) + box->Add( new wxButton( this, wxID_BACKWARD, _("Backward") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxSETUP) + box->Add( new wxButton( this, wxID_SETUP, _("Setup") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxMORE) + box->Add( new wxButton( this, wxID_MORE, _("More...") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxHELP) + box->Add( new wxButton( this, wxID_HELP, _("Help") ), 0, wxLEFT|wxRIGHT, margin ); + + if (flags & wxCANCEL) + { + cancel = new wxButton( this, wxID_CANCEL, _("Cancel") ); + box->Add( cancel, 0, wxLEFT|wxRIGHT, margin ); + } + + if ((flags & wxNO_DEFAULT) == 0) + { + if (ok) + { + ok->SetDefault(); + ok->SetFocus(); + } + else if (yes) + { + yes->SetDefault(); + yes->SetFocus(); + } + } + + return box; +} + diff --git a/src/mac/dirdlg.cpp b/src/mac/dirdlg.cpp index 095621b978..edfc211caa 100644 --- a/src/mac/dirdlg.cpp +++ b/src/mac/dirdlg.cpp @@ -24,6 +24,407 @@ IMPLEMENT_CLASS(wxDirDialog, wxDialog) #endif +enum { + kSelectItem = 10, // select button item number + kSFGetFolderDlgID = 250, // dialog resource number + kStrListID = 250, // our strings + kSelectStrNum = 1, // word 'Select: ' for button + kDesktopStrNum = 2, // word 'Desktop' for button + kSelectNoQuoteStrNum = 3, // word 'Select: ' for button + + kUseQuotes = true, // parameter for SetButtonName + kDontUseQuotes = false +}; + +// the data we need to pass to our standard file hook routine +// includes a pointer to the dialog, a pointer to the standard +// file reply record (so we can inspect the current selection) +// and a copy of the "previous" file spec of the reply record +// so we can see if the selection has changed + +struct UserDataRec { + StandardFileReply *sfrPtr; + FSSpec oldSelectionFSSpec; + DialogPtr theDlgPtr; +}; +typedef struct UserDataRec + UserDataRec, *UserDataRecPtr; + +static void GetLabelString(StringPtr theStr, short stringNum) +{ + GetIndString(theStr, kStrListID, stringNum); +} + +static void CopyPStr(StringPtr src, StringPtr dest) +{ + BlockMoveData(src, dest, 1 + src[0]); +} + +static char GetSelectKey(void) +{ + // this is the key used to trigger the select button + + // NOT INTERNATIONAL SAVVY; should at least grab it from resources + + return 's'; +} + + +// SetButtonName sets the name of the Select button in the dialog +// +// To do this, we need to call the Script Manager to truncate the +// label in the middle to fit the button and to merge the button +// name with the word Select (possibly followed by quotes). Using +// the Script Manager avoids all sorts of problems internationally. +// +// buttonName is the name to appear following the word Select +// quoteFlag should be true if the name is to appear in quotes + +static void SetButtonName(DialogPtr theDlgPtr, short buttonID, StringPtr buttonName, + Boolean quoteFlag) +{ + short buttonType; + Handle buttonHandle; + Rect buttonRect; + short textWidth; + Handle labelHandle; + Handle nameHandle; + Str15 keyStr; + Str255 labelStr; + OSErr err; + + nameHandle = nil; + labelHandle = nil; + + // get the details of the button from the dialog + + GetDialogItem(theDlgPtr, buttonID, &buttonType, &buttonHandle, &buttonRect); + + // get the string for the select button label, "Select ^0" or "Select Ò^0Ó" + + GetLabelString(labelStr, (quoteFlag == kUseQuotes) ? kSelectStrNum : kSelectNoQuoteStrNum); + + // make string handles containing the select button label and the + // file name to be stuffed into the button + + err = PtrToHand(&labelStr[1], &labelHandle, labelStr[0]); + if (err != noErr) goto Bail; + + // cut out the middle of the file name to fit the button + // + // we'll temporarily use labelStr here to hold the modified button name + // since we don't own the buttonName string storage space + + textWidth = (buttonRect.right - buttonRect.left) - StringWidth(labelStr); + + CopyPStr(buttonName, labelStr); + (void) TruncString(textWidth, labelStr, smTruncMiddle); + + err = PtrToHand(&labelStr[1], &nameHandle, labelStr[0]); + if (err != noErr) goto Bail; + + // replace the ^0 in the Select string with the file name + + CopyPStr("\p^0", keyStr); + + (void) ReplaceText(labelHandle, nameHandle, keyStr); + + labelStr[0] = (unsigned char) GetHandleSize(labelHandle); + BlockMoveData(*labelHandle, &labelStr[1], labelStr[0]); + + // now set the control title, and re-validate the area + // above the control to avoid a needless redraw + + SetControlTitle((ControlHandle) buttonHandle, labelStr); + + ValidRect(&buttonRect); + +Bail: + if (nameHandle) DisposeHandle(nameHandle); + if (labelHandle) DisposeHandle(labelHandle); + +} + +// FlashButton briefly highlights the dialog button +// as feedback for key equivalents + +static void FlashButton(DialogPtr theDlgPtr, short buttonID) +{ + short buttonType; + Handle buttonHandle; + Rect buttonRect; + unsigned long finalTicks; + + GetDialogItem(theDlgPtr, buttonID, &buttonType, &buttonHandle, &buttonRect); + HiliteControl((ControlHandle) buttonHandle, kControlButtonPart); + Delay(10, &finalTicks); + HiliteControl((ControlHandle) buttonHandle, 0); +} + +static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2) +{ + return (spec1->vRefNum == spec2->vRefNum + && spec1->parID == spec2->parID + && EqualString(spec1->name, spec2->name, false, false)); +} +// MyModalDialogFilter maps a key to the Select button, and handles +// flashing of the button when the key is hit + +static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec, + short *item, Ptr dataPtr) +{ +#pragma unused (dataPtr) + + // make certain the proper dialog is showing, 'cause standard file + // can nest dialogs but calls the same filter for each + + if (((WindowPeek) theDlgPtr)->refCon == sfMainDialogRefCon) + { + // check if the select button was hit + + if ((eventRec->what == keyDown) + && (eventRec->modifiers & cmdKey) + && ((eventRec->message & charCodeMask) == GetSelectKey())) + { + *item = kSelectItem; + FlashButton(theDlgPtr, kSelectItem); + return true; + } + } + + return false; +} + + +// MyDlgHook is a hook routine that maps the select button to Open +// and sets the Select button name + +static pascal short SFGetFolderDialogHook(short item, DialogPtr theDlgPtr, Ptr dataPtr) +{ + UserDataRecPtr theUserDataRecPtr; + long desktopDirID; + short desktopVRefNum; + FSSpec tempSpec; + Str63 desktopName; + OSErr err; + + // be sure Std File is really showing us the intended dialog, + // not a nested modal dialog + + if (((WindowPeek) theDlgPtr)->refCon != sfMainDialogRefCon) + { + return item; + } + + theUserDataRecPtr = (UserDataRecPtr) dataPtr; + + // map the Select button to Open + + if (item == kSelectItem) + { + item = sfItemOpenButton; + } + + // find the desktop folder + + err = FindFolder(theUserDataRecPtr->sfrPtr->sfFile.vRefNum, + kDesktopFolderType, kDontCreateFolder, + &desktopVRefNum, &desktopDirID); + + if (err != noErr) + { + // for errors, get value that won't match any real vRefNum/dirID + desktopVRefNum = 0; + desktopDirID = 0; + } + + // change the Select button label if the selection has changed or + // if this is the first call to the hook + + if (item == sfHookFirstCall + || item == sfHookChangeSelection + || item == sfHookRebuildList + || ! SameFSSpec(&theUserDataRecPtr->sfrPtr->sfFile, + &theUserDataRecPtr->oldSelectionFSSpec)) + { + // be sure there is a file name selected + + if (theUserDataRecPtr->sfrPtr->sfFile.name[0] != '\0') + { + SetButtonName(theDlgPtr, kSelectItem, + theUserDataRecPtr->sfrPtr->sfFile.name, + kUseQuotes); // true -> use quotes + } + else + { + // is the desktop selected? + + if (theUserDataRecPtr->sfrPtr->sfFile.vRefNum == desktopVRefNum + && theUserDataRecPtr->sfrPtr->sfFile.parID == desktopDirID) + { + // set button to "Select Desktop" + + GetLabelString(desktopName, kDesktopStrNum); + SetButtonName(theDlgPtr, kSelectItem, + desktopName, kDontUseQuotes); // false -> no quotes + } + else + { + // get parent directory's name for the Select button + // + // passing an empty name string to FSMakeFSSpec gets the + // name of the folder specified by the parID parameter + + (void) FSMakeFSSpec(theUserDataRecPtr->sfrPtr->sfFile.vRefNum, + theUserDataRecPtr->sfrPtr->sfFile.parID, "\p", + &tempSpec); + SetButtonName(theDlgPtr, kSelectItem, + tempSpec.name, kUseQuotes); // true -> use quotes + } + } + } + + // save the current selection as the old selection for comparison next time + // + // it's not valid on the first call, though, or if we don't have a + // name available from standard file + + if (item != sfHookFirstCall || theUserDataRecPtr->sfrPtr->sfFile.name[0] != '\0') + { + theUserDataRecPtr->oldSelectionFSSpec = theUserDataRecPtr->sfrPtr->sfFile; + } + else + { + // on first call, empty string won't set the button correctly, + // so invalidate oldSelection + + theUserDataRecPtr->oldSelectionFSSpec.vRefNum = 999; + theUserDataRecPtr->oldSelectionFSSpec.parID = 0; + } + + return item; +} + +void StandardGetFolder( ConstStr255Param message , ConstStr255Param path , FileFilterYDUPP fileFilter, StandardFileReply *theSFR) +{ + Point thePt; + SFTypeList mySFTypeList; + UserDataRec myData; + FSSpec tempSpec; + Boolean folderFlag; + Boolean wasAliasedFlag; + DlgHookYDUPP dlgHookUPP; + ModalFilterYDUPP myModalFilterUPP; + OSErr err; + + + // presumably we're running System 7 or later so CustomGetFile is + // available + + // set initial contents of Select button to a space + + CopyPStr("\p ", theSFR->sfFile.name); + + // point the user data parameter at the reply record so we can get to it later + + myData.sfrPtr = theSFR; + + // display the dialog + + dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook); + myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter); + + thePt.h = thePt.v = -1; // center dialog + + ParamText( message , NULL , NULL , NULL ) ; + + CustomGetFile( fileFilter, + -1, // show all types + mySFTypeList, + theSFR, + kSFGetFolderDlgID, + thePt, // top left point + dlgHookUPP, + myModalFilterUPP, + nil, // activate list + nil, // activate proc + &myData); + + DisposeRoutineDescriptor(dlgHookUPP); + DisposeRoutineDescriptor(myModalFilterUPP); + + // if cancel wasn't pressed and no fatal error occurred... + + if (theSFR->sfGood) + { + // if no name is in the reply record file spec, + // use the file spec of the parent folder + + if (theSFR->sfFile.name[0] == '\0') + { + err = FSMakeFSSpec(theSFR->sfFile.vRefNum, theSFR->sfFile.parID, + "\p", &tempSpec); + if (err == noErr) + { + theSFR->sfFile = tempSpec; + } + else + { + // no name to return, forget it + + theSFR->sfGood = false; + } + } + + // if there is now a name in the file spec, check if it's + // for a folder or a volume + + if (theSFR->sfFile.name[0] != '\0') + { + // the parID of the root of a disk is always fsRtParID == 1 + + if (theSFR->sfFile.parID == fsRtParID) + { + theSFR->sfIsVolume = true; + theSFR->sfIsFolder = false; // it would be reasonable for this to be true, too + } + + // we have a valid FSSpec, now let's make sure it's not for an alias file + + err = ResolveAliasFile(&theSFR->sfFile, true, &folderFlag, &wasAliasedFlag); + if (err != noErr) + { + theSFR->sfGood = false; + } + + // did the alias resolve to a folder? + + if (folderFlag && ! theSFR->sfIsVolume) + { + theSFR->sfIsFolder = true; + } + } + } +} + +static pascal Boolean OnlyVisibleFoldersCustomFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr) +{ +#pragma unused (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 + + return !(visibleFlag && folderFlag); +} + wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message, const wxString& defaultPath, long style, const wxPoint& pos) @@ -36,7 +437,35 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message, int wxDirDialog::ShowModal() { - // TODO + { + Str255 prompt ; + Str255 path ; + + strcpy((char *)prompt, m_message) ; + c2pstr((char *)prompt ) ; + + strcpy((char *)path, m_path ) ; + c2pstr((char *)path ) ; + + FileFilterYDUPP invisiblesExcludedCustomFilterUPP; + StandardFileReply reply ; + invisiblesExcludedCustomFilterUPP = + NewFileFilterYDProc(OnlyVisibleFoldersCustomFileFilter); + + StandardGetFolder( prompt , path , invisiblesExcludedCustomFilterUPP, &reply); + + DisposeRoutineDescriptor(invisiblesExcludedCustomFilterUPP); + if ( reply.sfGood == false ) + { + m_path = "" ; + return wxID_CANCEL ; + } + else + { + m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ; + return wxID_OK ; + } + } return wxID_CANCEL; } diff --git a/src/mac/filedlg.cpp b/src/mac/filedlg.cpp index b6f5b1912d..66de687b80 100644 --- a/src/mac/filedlg.cpp +++ b/src/mac/filedlg.cpp @@ -23,7 +23,352 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog) #endif -WXDLLEXPORT wxString wxFileSelector(const char *title, +// begin wxmac + +#include "morefile.h" +#include "moreextr.h" +#include "fullpath.h" +#include "fspcompa.h" +#include "PLStringFuncs.h" + +char * gfilters[] = +{ + "*.TXT" , + + NULL +} ; + +OSType gfiltersmac[] = +{ + 'TEXT' , + + '****' +} ; + +static void wxMacSetupStandardFile(short newVRefNum, long newDirID) +{ + enum + { SFSaveDisk = 0x214, CurDirStore = 0x398 }; + *(short *) SFSaveDisk = -1 * newVRefNum; + *(long *) CurDirStore = newDirID; +} + +static void wxMacSetupStandardFileFromPath( const char* s ) +{ + Str255 volume ; + Str255 path ; + short vRefNum ; + long dirRef ; + short i,j ; + Boolean isDirectory ; + + for (i=0 ; (s[i]!=0) && (s[i]!=':') ;i++) + { + volume[i]=s[i] ; + } + volume[i]=':' ; + volume[i+1]=0 ; + + // then copy the rest of the filename + + for (j=0;(s[i]!=0);i++,j++) + { + path[j]=s[i] ; + } + path[j]=0 ; + + c2pstr((Ptr) volume) ; + c2pstr((Ptr) path) ; + + SetVol(volume, 0) ; + GetVol( NULL, &vRefNum ) ; + + GetDirectoryID( vRefNum , fsRtDirID , path , &dirRef , &isDirectory ) ; + wxMacSetupStandardFile(vRefNum, dirRef) ; +} + +enum { + kSelectItem = 10, // select button item number + kSFGetFileDlgID = 251, // dialog resource number + kStrListID = 251, // our strings + kSelectStrNum = 1, // word 'Select: ' for button + kDesktopStrNum = 2, // word 'Desktop' for button + kSelectNoQuoteStrNum = 3, // word 'Select: ' for button + + kUseQuotes = true, // parameter for SetButtonName + kDontUseQuotes = false +}; + +// the data we need to pass to our standard file hook routine +// includes a pointer to the dialog, a pointer to the standard +// file reply record (so we can inspect the current selection) +// and a copy of the "previous" file spec of the reply record +// so we can see if the selection has changed + +const int kwxMacFileTypes = 10 ; + +struct OpenUserDataRec { + StandardFileReply *sfrPtr; + FSSpec oldSelectionFSSpec; + char filter[kwxMacFileTypes][10] ; + OSType filtermactypes[kwxMacFileTypes] ; + int numfilters ; + DialogPtr theDlgPtr; +}; +typedef struct OpenUserDataRec + OpenUserDataRec, *OpenUserDataRecPtr; + +static void GetLabelString(StringPtr theStr, short stringNum) +{ + GetIndString(theStr, kStrListID, stringNum); +} + +static void CopyPStr(StringPtr src, StringPtr dest) +{ + BlockMoveData(src, dest, 1 + src[0]); +} + +static char GetSelectKey(void) +{ + // this is the key used to trigger the select button + + // NOT INTERNATIONAL SAVVY; should at least grab it from resources + + return 's'; +} + +// FlashButton briefly highlights the dialog button +// as feedback for key equivalents + +static void FlashButton(DialogPtr theDlgPtr, short buttonID) +{ + short buttonType; + Handle buttonHandle; + Rect buttonRect; + unsigned long finalTicks; + + GetDialogItem(theDlgPtr, buttonID, &buttonType, &buttonHandle, &buttonRect); + HiliteControl((ControlHandle) buttonHandle, kControlButtonPart); + Delay(10, &finalTicks); + HiliteControl((ControlHandle) buttonHandle, 0); +} + +static Boolean SameFSSpec(FSSpecPtr spec1, FSSpecPtr spec2) +{ + return (spec1->vRefNum == spec2->vRefNum + && spec1->parID == spec2->parID + && EqualString(spec1->name, spec2->name, false, false)); +} +// MyModalDialogFilter maps a key to the Select button, and handles +// flashing of the button when the key is hit + +static pascal Boolean SFGetFolderModalDialogFilter(DialogPtr theDlgPtr, EventRecord *eventRec, + short *item, Ptr dataPtr) +{ +#pragma unused (dataPtr) + + // make certain the proper dialog is showing, 'cause standard file + // can nest dialogs but calls the same filter for each + + if (((WindowPeek) theDlgPtr)->refCon == sfMainDialogRefCon) + { + // check if the select button was hit + /* + if ((eventRec->what == keyDown) + && (eventRec->modifiers & cmdKey) + && ((eventRec->message & charCodeMask) == GetSelectKey())) + { + *item = kSelectItem; + FlashButton(theDlgPtr, kSelectItem); + return true; + } + */ + } + + return false; +} + +void ExtendedOpenFile( ConstStr255Param message , ConstStr255Param path , const char *filter , FileFilterYDUPP fileFilter, StandardFileReply *theSFR) +{ + Point thePt; + OpenUserDataRec myData; + FSSpec tempSpec; + Boolean folderFlag; + Boolean wasAliasedFlag; + DlgHookYDUPP dlgHookUPP; + ModalFilterYDUPP myModalFilterUPP; + OSErr err; + SFTypeList types ; + + + // presumably we're running System 7 or later so CustomGetFile is + // available + + // set initial contents of Select button to a space + + CopyPStr("\p ", theSFR->sfFile.name); + + // point the user data parameter at the reply record so we can get to it later + + myData.sfrPtr = theSFR; + if ( filter && filter[0] ) + { + myData.numfilters = 1 ; + for ( int i = 0 ; i < myData.numfilters ; i++ ) + { + int j ; + + strcpy( myData.filter[i] , filter ) ; + for( j = 0 ; myData.filter[i][j] ; j++ ) + { + myData.filter[i][j] = toupper( myData.filter[i][j] ) ; + } + for ( j = 0 ; gfilters[j] ; j++ ) + { + if ( strcmp( myData.filter[i] , gfilters[j] ) == 0 ) + { + myData.filtermactypes[i] = gfiltersmac[j] ; + break ; + } + } + if( gfilters[j] == NULL ) + { + myData.filtermactypes[i] = '****' ; + } + } + } + else + { + myData.numfilters = 0 ; + } + // display the dialog + + dlgHookUPP = NULL ; +// dlgHookUPP = NewDlgHookYDProc(SFGetFolderDialogHook); + myModalFilterUPP = NewModalFilterYDProc(SFGetFolderModalDialogFilter); + + thePt.h = thePt.v = -1; // center dialog + + ParamText( message , NULL , NULL , NULL ) ; + + CustomGetFile( fileFilter, + -1, // show all types + NULL, + theSFR, + kSFGetFileDlgID, + thePt, // top left point + dlgHookUPP, + myModalFilterUPP, + nil, // activate list + nil, // activate proc + &myData); + + DisposeRoutineDescriptor(dlgHookUPP); + DisposeRoutineDescriptor(myModalFilterUPP); + + // if cancel wasn't pressed and no fatal error occurred... + + if (theSFR->sfGood) + { + // if no name is in the reply record file spec, + // use the file spec of the parent folder + + if (theSFR->sfFile.name[0] == '\0') + { + err = FSMakeFSSpec(theSFR->sfFile.vRefNum, theSFR->sfFile.parID, + "\p", &tempSpec); + if (err == noErr) + { + theSFR->sfFile = tempSpec; + } + else + { + // no name to return, forget it + + theSFR->sfGood = false; + } + } + + // if there is now a name in the file spec, check if it's + // for a folder or a volume + + if (theSFR->sfFile.name[0] != '\0') + { + // the parID of the root of a disk is always fsRtParID == 1 + + if (theSFR->sfFile.parID == fsRtParID) + { + theSFR->sfIsVolume = true; + theSFR->sfIsFolder = false; // it would be reasonable for this to be true, too + } + + // we have a valid FSSpec, now let's make sure it's not for an alias file + + err = ResolveAliasFile(&theSFR->sfFile, true, &folderFlag, &wasAliasedFlag); + if (err != noErr) + { + theSFR->sfGood = false; + } + + // did the alias resolve to a folder? + + if (folderFlag && ! theSFR->sfIsVolume) + { + theSFR->sfIsFolder = true; + } + } + } +} + +static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, Ptr dataPtr) +{ + Str255 filename ; + 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 ) + { + if ( data->numfilters > 0 ) + { + PLstrcpy( filename ,myCInfoPBPtr->hFileInfo.ioNamePtr ) ; + if ( filename[0] >= 4 ) + { + for( int j = 1 ; j <= filename[0] ; j++ ) + { + filename[j] = toupper( filename[j] ) ; + } + for ( int i = 0 ; i < data->numfilters ; ++i ) + { + if ( myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType == data->filtermactypes[i] ) + return false ; + + if ( strncmp( (char*) filename + 1 + filename[0] - 4 , + & data->filter[i][ strlen(data->filter[i]) - 4 ] , 4 ) == 0 ) + return false ; + } + } + return true ; + } + } + + return false ; +} + +// end wxmac + +wxString wxFileSelector(const char *title, const char *defaultDir, const char *defaultFileName, const char *defaultExtension, const char *filter, int flags, wxWindow *parent, int x, int y) @@ -100,7 +445,61 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, int wxFileDialog::ShowModal() { - // TODO + if ( m_dialogStyle & wxSAVE ) + { + StandardFileReply reply ; + Str255 prompt ; + Str255 filename ; + + strcpy((char *)prompt, m_message) ; + c2pstr((char *)prompt ) ; + + strcpy((char *)filename, m_fileName) ; + c2pstr((char *)filename ) ; + + StandardPutFile( prompt , filename , &reply ) ; + if ( reply.sfGood == false ) + { + m_path = "" ; + return wxID_CANCEL ; + } + else + { + m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ; + return wxID_OK ; + } + } + else + { + OSType types = '????' ; + Str255 prompt ; + Str255 path ; + + strcpy((char *)prompt, m_message) ; + c2pstr((char *)prompt ) ; + + strcpy((char *)path, m_path ) ; + c2pstr((char *)path ) ; + + FileFilterYDUPP crossPlatformFileFilterUPP; + StandardFileReply reply ; + crossPlatformFileFilterUPP = + NewFileFilterYDProc(CrossPlatformFileFilter); + + ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply); + + DisposeRoutineDescriptor(crossPlatformFileFilterUPP); + if ( reply.sfGood == false ) + { + m_path = "" ; + return wxID_CANCEL ; + } + else + { + m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ; + return wxID_OK ; + } + } return wxID_CANCEL; } diff --git a/src/mac/font.cpp b/src/mac/font.cpp index 493a6a25ba..2409e1a38b 100644 --- a/src/mac/font.cpp +++ b/src/mac/font.cpp @@ -31,9 +31,10 @@ wxFontRefData::wxFontRefData() m_weight = 0; m_underlined = 0; m_faceName = ""; -/* TODO - m_hFont = 0; -*/ + + m_macFontSize = m_pointSize ; + m_macFontNum = systemFont ; + m_macFontStyle = normal ; } wxFontRefData::wxFontRefData(const wxFontRefData& data) @@ -45,9 +46,10 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data) m_weight = data.m_weight; m_underlined = data.m_underlined; m_faceName = data.m_faceName; -/* TODO - m_hFont = 0; -*/ + + m_macFontSize = m_pointSize ; + m_macFontNum = systemFont ; + m_macFontStyle = normal ; } wxFontRefData::~wxFontRefData() @@ -55,6 +57,56 @@ wxFontRefData::~wxFontRefData() // TODO: delete font data } +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( "\pHelvetica" , &m_macFontNum) ; + break ; + case wxMODERN : + ::GetFNum( "\pMonaco" , &m_macFontNum) ; + break ; + } + } + else + { + if ( m_faceName == "systemfont" ) + m_macFontNum = ::GetSysFont() ; + else if ( m_faceName == "applicationfont" ) + m_macFontNum = ::GetAppFont() ; + else + { + strcpy(wxBuffer, m_faceName); + C2PStr(wxBuffer); + ::GetFNum( (unsigned char*) wxBuffer, &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 ; +} + wxFont::wxFont() { if ( wxTheFontList ) @@ -94,8 +146,8 @@ wxFont::~wxFont() bool wxFont::RealizeResource() { - // TODO: create the font (if there is a native font object) - return FALSE; + M_FONTDATA->MacFindFont() ; + return TRUE; } void wxFont::Unshare() diff --git a/src/mac/fontdlg.cpp b/src/mac/fontdlg.cpp index 60e8e9b987..d775c24c16 100644 --- a/src/mac/fontdlg.cpp +++ b/src/mac/fontdlg.cpp @@ -14,7 +14,7 @@ #pragma implementation "fontdlg.h" #endif -#include "wx/stubs/fontdlg.h" +#include "wx/mac/fontdlg.h" #include "wx/cmndata.h" #if !USE_SHARED_LIBRARY diff --git a/src/mac/frame.cpp b/src/mac/frame.cpp index 55f1e3b72c..5a95ac9097 100644 --- a/src/mac/frame.cpp +++ b/src/mac/frame.cpp @@ -23,6 +23,8 @@ #include "wx/settings.h" #include "wx/app.h" +#include + extern wxList wxModelessWindows; extern wxList wxPendingDelete; @@ -47,7 +49,11 @@ bool wxFrame::m_useNativeStatusBar = FALSE; wxFrame::wxFrame() { +#if wxUSE_TOOLBAR m_frameToolBar = NULL ; +#endif + m_macShown = false ; + // in order to be able to give size events on show m_frameMenuBar = NULL; m_frameStatusBar = NULL; @@ -69,7 +75,10 @@ bool wxFrame::Create(wxWindow *parent, SetName(name); m_windowStyle = style; m_frameMenuBar = NULL; + +#if wxUSE_TOOLBAR m_frameToolBar = NULL ; +#endif m_frameStatusBar = NULL; SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); @@ -83,9 +92,63 @@ bool wxFrame::Create(wxWindow *parent, wxModelessWindows.Append(this); - // TODO: create frame. - - return 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; + if (m_width == -1) + m_width = 20; + m_height = size.y; + if (m_height == -1) + m_height = 20; + + m_macWindowData = new MacWindowData() ; + + ::SetRect(&theBoundsRect, m_x, m_y, m_x + m_width, m_y + m_height); + + WindowClass wclass = kDocumentWindowClass ; + WindowAttributes attr = kWindowNoAttributes ; + + if ( ( m_windowStyle & wxMINIMIZE_BOX ) || ( m_windowStyle & wxMAXIMIZE_BOX ) ) + { + attr |= kWindowFullZoomAttribute ; + attr |= kWindowResizableAttribute ; + } + if ( m_windowStyle & wxSTAY_ON_TOP ) + { + wclass = kFloatingWindowClass ; + +// if ( m_windowStyle & wxCAPTION ) +// attr |= kHasPaletteTitlebarMask ; + } + else + { + } + if ( m_windowStyle & wxSYSTEM_MENU ) + { + attr |= kWindowCloseBoxAttribute ; + } + UMACreateNewWindow( wclass , attr , &theBoundsRect , &m_macWindowData->m_macWindow ) ; + wxAssociateWinWithMacWindow( m_macWindowData->m_macWindow , this ) ; + wxString label ; + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( title ) ; + else + label = title ; + UMASetWTitleC( m_macWindowData->m_macWindow , label ) ; + UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ; + m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; + m_macWindowData->m_macFocus = NULL ; + m_macShown = false ; + return TRUE; } wxFrame::~wxFrame() @@ -105,46 +168,13 @@ wxFrame::~wxFrame() if (wxTheApp->GetExitOnFrameDelete()) { - // TODO signal to the app that we're going to close + wxTheApp->ExitMainLoop() ; } } wxModelessWindows.DeleteObject(this); } -// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. -void wxFrame::GetClientSize(int *x, int *y) const -{ - // TODO -} - -// Set the client size (i.e. leave the calculation of borders etc. -// to wxWindows) -void wxFrame::SetClientSize(int width, int height) -{ - // TODO -} - -void wxFrame::GetSize(int *width, int *height) const -{ - // TODO -} - -void wxFrame::GetPosition(int *x, int *y) const -{ - // TODO -} - -void wxFrame::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO -} - -bool wxFrame::Show(bool show) -{ - // TODO - return FALSE; -} void wxFrame::Iconize(bool iconize) { @@ -170,17 +200,6 @@ bool wxFrame::IsMaximized(void) const return FALSE; } -void wxFrame::SetTitle(const wxString& title) -{ - // TODO -} - -wxString wxFrame::GetTitle() const -{ - // TODO - return wxString(""); -} - void wxFrame::SetIcon(const wxIcon& icon) { m_icon = icon; @@ -192,10 +211,12 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, { wxStatusBar *statusBar = NULL; - statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), + statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 17), style, name); // Set the height according to the font and the border size + // we shouldn't do this on the mac, because we have to fit the grow box + /* wxClientDC dc(statusBar); dc.SetFont(statusBar->GetFont()); @@ -206,6 +227,8 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, statusBar->SetSize(-1, -1, 100, height); + */ + statusBar->SetFieldsCount(number); return statusBar; } @@ -245,6 +268,8 @@ void wxFrame::SetStatusWidths(int n, const int widths_field[]) void wxFrame::PositionStatusBar() { + if (m_frameStatusBar ) + { int w, h; GetClientSize(&w, &h); int sw, sh; @@ -253,6 +278,7 @@ void wxFrame::PositionStatusBar() // 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); + } } void wxFrame::SetMenuBar(wxMenuBar *menuBar) @@ -264,8 +290,8 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) } m_frameMenuBar = menuBar; - - // TODO + // TODO : we move this into the app code + m_frameMenuBar->MacInstallMenuBar() ; } void wxFrame::Fit() @@ -333,8 +359,12 @@ void wxFrame::OnSize(wxSizeEvent& event) wxWindow *win = (wxWindow *)node->Data(); if ( !win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)) && - (win != GetStatusBar()) && - (win != GetToolBar()) ) + (win != GetStatusBar()) +#if wxUSE_TOOLBAR + && + (win != GetToolBar()) +#endif + ) { if ( child ) return; // it's our second subwindow - nothing to do @@ -410,21 +440,6 @@ wxMenuBar *wxFrame::GetMenuBar() const return m_frameMenuBar; } -void wxFrame::Centre(int direction) -{ - int display_width, display_height, width, height, x, y; - wxDisplaySize(&display_width, &display_height); - - GetSize(&width, &height); - GetPosition(&x, &y); - - if (direction & wxHORIZONTAL) - x = (int)((display_width - width)/2); - if (direction & wxVERTICAL) - y = (int)((display_height - height)/2); - - SetSize(x, y, width, height); -} // Call this to simulate a menu command void wxFrame::Command(int id) @@ -434,7 +449,7 @@ void wxFrame::Command(int id) void wxFrame::ProcessCommand(int id) { - wxCommandEvent commandEvent(wxEVENT_TYPE_MENU_COMMAND, id); + wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); commandEvent.SetInt( id ); commandEvent.SetEventObject( this ); @@ -450,18 +465,14 @@ void wxFrame::ProcessCommand(int id) } */ - // Process events starting with the window with the focus, if any. - wxWindow* focusWin = wxFindFocusDescendant(this); - - wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler(); - - evtHandler->ProcessEvent(commandEvent); + GetEventHandler()->ProcessEvent(commandEvent); } // Checks if there is a toolbar, and returns the first free client position wxPoint wxFrame::GetClientAreaOrigin() const { wxPoint pt(0, 0); +#if wxUSE_TOOLBAR if (GetToolBar()) { int w, h; @@ -476,33 +487,46 @@ wxPoint wxFrame::GetClientAreaOrigin() const pt.y += h; } } +#endif return pt; } -void wxFrame::ScreenToClient(int *x, int *y) const +void wxFrame::GetClientSize(int *x, int *y) const { - wxWindow::ScreenToClient(x, y); - - // We may be faking the client origin. - // So a window that's really at (0, 30) may appear - // (to wxWin apps) to be at (0, 0). - wxPoint pt(GetClientAreaOrigin()); - *x -= pt.x; - *y -= pt.y; + wxWindow::GetClientSize( x , y ) ; + + if ( GetStatusBar() ) + { + int statusX, statusY; + GetStatusBar()->GetClientSize(&statusX, &statusY); + *y -= statusY; + } + + wxPoint pt(GetClientAreaOrigin()); + *y -= pt.y; + *x -= pt.x; } -void wxFrame::ClientToScreen(int *x, int *y) const +void wxFrame::DoSetClientSize(int clientwidth, int clientheight) { - // We may be faking the client origin. - // So a window that's really at (0, 30) may appear - // (to wxWin apps) to be at (0, 0). - wxPoint pt1(GetClientAreaOrigin()); - *x += pt1.x; - *y += pt1.y; - - wxWindow::ClientToScreen(x, y); + 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 ) ; } + +#if wxUSE_TOOLBAR wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { wxCHECK_MSG( m_frameToolBar == NULL, FALSE, @@ -534,7 +558,10 @@ void wxFrame::PositionToolBar() // the toolbar/status bar were added. // So DEFINITELY replace the line below with something appropriate. - GetClientSize(& cw, &ch); + // GetClientSize(& cw, &ch); + + cw = m_width ; + ch = m_height ; if ( GetStatusBar() ) { @@ -562,4 +589,4 @@ void wxFrame::PositionToolBar() } } } - +#endif diff --git a/src/mac/gauge.cpp b/src/mac/gauge.cpp index a85fbc498f..7dc3b5e813 100644 --- a/src/mac/gauge.cpp +++ b/src/mac/gauge.cpp @@ -19,67 +19,65 @@ IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl) #endif +#include + bool wxGauge::Create(wxWindow *parent, wxWindowID id, int range, const wxPoint& pos, - const wxSize& size, + const wxSize& s, long style, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - m_rangeMax = range; - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - - // TODO - return FALSE; -} - -void wxGauge::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + wxSize size = s ; + Rect bounds ; + Str255 title ; + m_rangeMax = range ; + m_macHorizontalBorder = 2 ; // additional pixels around the real control + m_macVerticalBorder = 2 ; + + if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y) + { + size = wxSize( 200 , 16 ) ; + } + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , range, + kControlProgressBarProc , (long) this ) ; + + MacPostControlCreate() ; + + return TRUE; } void wxGauge::SetShadowWidth(int w) { - // TODO optional } void wxGauge::SetBezelFace(int w) { - // TODO optional } void wxGauge::SetRange(int r) { m_rangeMax = r; - // TODO + ::SetControlMaximum( m_macControl , m_rangeMax ) ; } void wxGauge::SetValue(int pos) { m_gaugePos = pos; - // TODO + ::SetControlValue( m_macControl , m_gaugePos ) ; } int wxGauge::GetShadowWidth() const { - // TODO optional return 0; } int wxGauge::GetBezelFace() const { - // TODO optional return 0; } diff --git a/src/mac/icon.cpp b/src/mac/icon.cpp index 6deee7dbdc..537165343e 100644 --- a/src/mac/icon.cpp +++ b/src/mac/icon.cpp @@ -26,12 +26,30 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) wxIconRefData::wxIconRefData() { - // TODO: init icon handle + m_ok = FALSE; + m_width = 0; + m_height = 0; + m_depth = 0; + m_quality = 0; + m_numColors = 0; + m_bitmapMask = NULL; + m_hBitmap = NULL ; + m_hIcon = NULL ; } wxIconRefData::~wxIconRefData() { - // TODO: destroy icon handle + if ( m_hIcon ) + { + DisposeCIcon( m_hIcon ) ; + m_hIcon = NULL ; + } + + if (m_bitmapMask) + { + delete m_bitmapMask; + m_bitmapMask = NULL; + } } wxIcon::wxIcon() @@ -68,3 +86,32 @@ bool wxIcon::LoadFile(const wxString& filename, long type, return FALSE; } +IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler) + +bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ + Str255 theName ; + short theId ; + OSType theType ; + strcpy( (char*) theName , name ) ; + c2pstr( (char*) theName ) ; + + Handle resHandle = GetNamedResource( 'cicn' , theName ) ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + + CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ; + if ( theIcon ) + { + M_ICONHANDLERDATA->m_hIcon = theIcon ; + M_ICONHANDLERDATA->m_width = 32 ; + M_ICONHANDLERDATA->m_height = 32 ; + + M_ICONHANDLERDATA->m_depth = 8 ; + M_ICONHANDLERDATA->m_ok = true ; + M_ICONHANDLERDATA->m_numColors = 256 ; + return TRUE ; + } + return FALSE ; +} \ No newline at end of file diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 1dad21e12c..e17f1b8213 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -18,10 +18,22 @@ #include "wx/dynarray.h" #include "wx/log.h" +#include "wx/utils.h" +#include "extldef.h" + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) + +BEGIN_EVENT_TABLE(wxListBox, wxControl) + EVT_SIZE( wxListBox::OnSize ) +END_EVENT_TABLE() #endif +#include + +extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ; +const short kwxMacListWithVerticalScrollbar = 128 ; + // ============================================================================ // list box control implementation // ============================================================================ @@ -41,111 +53,197 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_noItems = n; + m_noItems = 0 ; // this will be increased by our append command m_selected = 0; - SetName(name); - SetValidator(validator); - - if (parent) parent->AddChild(this); - - wxSystemSettings settings; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW)); - - m_windowId = ( id == -1 ) ? (int)NewControlId() : id; - - // TODO create listbox - - return FALSE; + Rect bounds ; + Str255 title ; + m_macHorizontalBorder = 5 ; // additional pixels around the real control + m_macVerticalBorder = 5 ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , kwxMacListWithVerticalScrollbar , 0 , 0, + kControlListBoxProc , (long) this ) ; + + long result ; + UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; + + NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ; + (**m_macList).selFlags = lOnlyOne ; + if ( style & wxLB_MULTIPLE ) + { + (**m_macList).selFlags += lNoExtend ; + } + else if ( style & wxLB_EXTENDED ) + { + (**m_macList).selFlags += lExtendDrag ; + } + Point pt = (**m_macList).cellSize ; + pt.v = 14 ; + LCellSize( pt , m_macList ) ; + + LAddColumn( 1 , 0 , m_macList ) ; + + MacPostControlCreate() ; + + ControlFontStyleRec controlstyle ; + controlstyle.flags = kControlUseFontMask + kControlUseSizeMask ; + //controlstyle.font = kControlFontSmallSystemFont ; + controlstyle.font = kFontIDMonaco ; + controlstyle.size = 9 ; + ::UMASetControlFontStyle( m_macControl , &controlstyle ) ; + + for ( int i = 0 ; i < n ; i++ ) + { + Append( choices[i] ) ; + } + + LSetDrawingMode( true , m_macList ) ; + + return TRUE; } wxListBox::~wxListBox() { +// DisposeExtLDEFInfo( m_macList ) ; } void wxListBox::SetFirstItem(int N) { - // TODO + MacScrollTo( N ) ; } void wxListBox::SetFirstItem(const wxString& s) { - // TODO + MacScrollTo( FindString( s ) ) ; } void wxListBox::Delete(int N) { - m_noItems --; - // TODO + m_dataArray.Remove( N ) ; + m_stringArray.Remove( N ) ; + m_noItems --; + + MacDelete( N ) ; } void wxListBox::Append(const wxString& item) { - m_noItems ++; - - // TODO + Append( item , NULL ) ; } void wxListBox::Append(const wxString& item, char *Client_data) { - m_noItems ++; - - // TODO + if( wxApp::s_macDefaultEncodingIsPC ) + { + m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ; + } + else + m_stringArray.Add( item ) ; + m_dataArray.Add( Client_data ) ; + m_noItems ++; + + MacAppend( item ) ; } void wxListBox::Set(int n, const wxString *choices, char** clientData) { - m_noItems = n; - - // TODO + Clear() ; + for( int i = 0 ; i < n ; ++i ) + { + if ( clientData ) + Append( choices[i] , clientData[0] ) ; + else + Append( choices[i] ) ; + } } -int wxListBox::FindString(const wxString& s) const +int wxListBox::FindString(const wxString& st) const { - // TODO - return -1; + wxString s ; + if( wxApp::s_macDefaultEncodingIsPC ) + { + s = wxMacMakeMacStringFromPC( st ) ; + } + else + s = st ; + + if ( s.Right(1) == "*" ) + { + wxString search = s.Left( s.Length() - 1 ) ; + int len = search.Length() ; + for ( int i = 0 ; i < m_noItems ; ++ i ) + { + if ( equalstring( m_stringArray[i].Left( len ) , search , false , false ) ) + return i ; + } + } + else + { + for ( int i = 0 ; i < m_noItems ; ++ i ) + { + if ( equalstring( m_stringArray[i] , s , false , false ) ) + return i ; + } + } + return -1; } void wxListBox::Clear() { m_noItems = 0; - // TODO + m_stringArray.Empty() ; + m_dataArray.Empty() ; + MacClear() ; } void wxListBox::SetSelection(int N, bool select) { - // TODO + wxCHECK_RET( N >= 0 && N < m_noItems, + "invalid index in wxListBox::SetSelection" ); + MacSetSelection( N , select ) ; } bool wxListBox::Selected(int N) const { - // TODO - return FALSE; + wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE, + "invalid index in wxListBox::Selected" ); + + return MacIsSelected( N ) ; } void wxListBox::Deselect(int N) { - // TODO + wxCHECK_RET( N >= 0 && N < m_noItems, + "invalid index in wxListBox::Deselect" ); + + SetSelection( N , false ) ; } char *wxListBox::GetClientData(int N) const { - // TODO - return (char *)NULL; + wxCHECK_MSG( N >= 0 && N < m_noItems, NULL, + "invalid index in wxListBox::GetClientData" ); + + return m_dataArray[N]; } void wxListBox::SetClientData(int N, char *Client_data) { - // TODO + wxCHECK_RET( N >= 0 && N < m_noItems, + "invalid index in wxListBox::SetClientData" ); + + m_dataArray[N] = Client_data ; } // Return number of selections and an array of selected integers int wxListBox::GetSelections(wxArrayInt& aSelections) const { - aSelections.Empty(); + return MacGetSelections( aSelections ) ; /* TODO - if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED)) + if ((m_windowStyle & wxLB_MULTIMacE) || (m_windowStyle & wxLB_EXTENDED)) { int no_sel = ?? for ( int n = 0; n < no_sel; n++ ) @@ -160,38 +258,41 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const return 1; } */ - return 0; } // Get single selection, for single choice list items int wxListBox::GetSelection() const { - // TODO - return -1; + return MacGetSelection() ; } // Find string for position wxString wxListBox::GetString(int N) const { - // TODO - return wxString(""); -} - -void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + if( wxApp::s_macDefaultEncodingIsPC ) + { + return wxMacMakePCStringFromMac( m_stringArray[N] ) ; + } + else + return m_stringArray[N] ; } void wxListBox::InsertItems(int nItems, const wxString items[], int pos) { - m_noItems += nItems; + 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] ) ; + } - // TODO + m_noItems += nItems; } void wxListBox::SetString(int N, const wxString& s) { - // TODO + m_stringArray[N] = s ; + MacSet( N , s ) ; } int wxListBox::Number () const @@ -204,7 +305,9 @@ wxString wxListBox::GetStringSelection () const { int sel = GetSelection (); if (sel > -1) - return this->GetString (sel); + { + return GetString (sel); + } else return wxString(""); } @@ -233,3 +336,182 @@ void wxListBox::Command (wxCommandEvent & event) ProcessCommand (event); } +// ============================================================================ +// list box control implementation +// ============================================================================ + +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()); + +} + +void wxListBox::MacDelete( int N ) +{ + ListHandle list ; + long result ; + Cell cell = { 0 , 0 } ; + UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &list , &result ) ; + LDelRow( 1 , N , list ) ; +} + +void wxListBox::MacInsert( int n , const char * text) +{ + Cell cell ; + + cell.h = 0 ; + cell.v = n ; + + LAddRow( 1 , cell.v , m_macList ) ; +} + +void wxListBox::MacAppend( const char * text) +{ + Cell cell = { 0 , 0 } ; + cell.v = (**m_macList).dataBounds.bottom ; + LAddRow( 1 , cell.v , m_macList ) ; +} + +void wxListBox::MacClear() +{ + LDelRow( (**m_macList).dataBounds.bottom , 0 , m_macList ) ; +} + +void wxListBox::MacSetSelection( int n , bool select ) +{ + Cell cell = { 0 , 0 } ; + if ( LGetSelect( TRUE , &cell , m_macList ) ) + { + LSetSelect( false , cell , m_macList ) ; + } + + cell.v = n ; + LSetSelect( select , cell , m_macList ) ; + LAutoScroll( m_macList ) ; +} + +bool wxListBox::MacIsSelected( int n ) const +{ + Cell cell = { 0 , 0 } ; + cell.v = n ; + return LGetSelect( false , &cell , m_macList ) ; +} + +void wxListBox::MacDestroy() +{ +// DisposeExtLDEFInfo( m_macList ) ; +} + +int wxListBox::MacGetSelection() const +{ + Cell cell = { 0 , 0 } ; + if ( LGetSelect( true , &cell , m_macList ) ) + return cell.v ; + else + return -1 ; +} + +int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const +{ + int no_sel = 0 ; + + aSelections.Empty(); + + Cell cell = { 0 , 0 } ; + cell.v = 0 ; + + while ( LGetSelect( true , &cell , m_macList ) ) + { + aSelections.Add( cell.v ) ; + no_sel++ ; + cell.v++ ; + } + return no_sel ; +} + +void wxListBox::MacSet( int n , const char * text ) +{ + // our implementation does not store anything in the list + // so we just have to redraw + Cell cell = { 0 , 0 } ; + cell.v = n ; + LDraw( cell , m_macList ) ; +} + +void wxListBox::MacScrollTo( int n ) +{ + // TODO implement scrolling +} + +void wxListBox::OnSize( const wxSizeEvent &event) +{ + Point pt = (**m_macList).cellSize ; + pt.h = m_width - 15 /* scrollbar */ - m_macHorizontalBorder * 2 ; + LCellSize( pt , m_macList ) ; +} + +void wxListBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + Boolean wasDoubleClick = false ; + long result ; + + UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ; + if ( !wasDoubleClick ) + { + MacDoClick() ; + } + else + { + MacDoDoubleClick() ; + } +} + +void wxListBox::MacSetRedraw( bool doDraw ) +{ + LSetDrawingMode( doDraw , m_macList ) ; + +} + +void wxListBox::MacDoClick() +{ + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); + wxArrayInt aSelections; + int count = GetSelections(aSelections); + if ( count > 0 ) + { + event.m_commandInt = aSelections[0] ; + event.m_clientData = GetClientData(event.m_commandInt); + wxString str(GetString(event.m_commandInt)); + if (str != "") + event.m_commandString = copystring((char *)(const char *)str); + } + else + { + return ; + /* + event.m_commandInt = -1 ; + event.m_commandString = copystring("") ; + */ + } + + event.SetEventObject( this ); + ProcessCommand(event); + if (event.m_commandString) + delete[] event.m_commandString ; +} + +void wxListBox::MacDoDoubleClick() +{ + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event) ; +} diff --git a/src/mac/makefile.unx b/src/mac/makefile.unx index d5d55d86d4..5bd62163fd 100644 --- a/src/mac/makefile.unx +++ b/src/mac/makefile.unx @@ -62,7 +62,6 @@ LIB_CPP_SRC=\ ../common/variant.cpp \ ../common/wxexpr.cpp \ ../common/socket.cpp \ - ../common/sckint.cpp \ ../common/sckaddr.cpp \ ../common/sckipc.cpp \ ../common/protocol.cpp \ diff --git a/src/mac/menu.cpp b/src/mac/menu.cpp index 1fc7c4a229..b22001b870 100644 --- a/src/mac/menu.cpp +++ b/src/mac/menu.cpp @@ -27,6 +27,8 @@ #include "wx/log.h" #include "wx/utils.h" +#include "wx/mac/uma.h" + // other standard headers // ---------------------- #include @@ -36,13 +38,146 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler) #endif +// the (popup) menu title has this special id +static const int idMenuTitle = -2; +static int formerHelpMenuItems = 0 ; + +const short kwxMacMenuBarResource = 1 ; +const short kwxMacAppleMenuId = 1 ; + // ============================================================================ // implementation // ============================================================================ +// +// Helper Functions to get Mac Menus the way they should be ;-) +// + +void wxMacCtoPString(const char* theCString, Str255 thePString); + +// remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut + +static void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts ) +{ + char *p = (char *) &outMacItemText[1] ; + short macModifiers = 0 ; + char macShortCut = 0 ; + + if ( useShortcuts && !wxApp::s_macSupportPCMenuShortcuts ) + useShortcuts = false ; + + // we have problems with a leading hypen - it will be taken as a separator + + while ( *inItemName == '-' ) + inItemName++ ; + + while( *inItemName ) + { + switch ( *inItemName ) + { + // special characters for macintosh menus -> use some replacement + case ';' : + *p++ = ',' ; + break ; + case '^' : + *p++ = ' ' ; + break ; + case '!' : + *p++ = ' ' ; + break ; + case '<' : + *p++ = ' ' ; + break ; + case '/' : + *p++ = '|' ; + break ; + case '(' : + *p++ = '[' ; + break ; + case ')' : + *p++ = ']' ; + break ; + // shortcuts + case '&' : + { + ++inItemName ; + if ( *inItemName ) + { + *p++ = *inItemName ; + if ( useShortcuts ) + macShortCut = *inItemName ; + } + else + --inItemName ; + } + break ; + // win-like accelerators + case '\t' : + { + ++inItemName ; + while( *inItemName ) + { + if (strncmp("Ctrl+", inItemName, 5) == 0) + { + inItemName = inItemName + 5; + macShortCut = *inItemName; + } + else if (strncmp("Alt+", inItemName, 4) == 0) + { + inItemName = inItemName + 4; + macModifiers |= kMenuOptionModifier ; + macShortCut = *inItemName ; + } + else if (strncmp("Shift+", inItemName, 6) == 0) + { + inItemName = inItemName + 6; + macModifiers |= kMenuShiftModifier ; + macShortCut = *inItemName ; + } + else if (strncmp("F", inItemName, 1) == 0) + { + inItemName += strlen( inItemName ) ; + // no function keys at the moment + // macModifiers |= kMenuShiftModifier ; + // macShortCut = *inItemName ; + } + else + { + break ; + } + } + + if ( *inItemName == 0 ) + --inItemName ; + + } + break ; + default : + *p++ = *inItemName ; + } + ++inItemName ; + } + + outMacItemText[0] = (p - (char *)outMacItemText) - 1; + if ( outMacShortcutChar ) + *outMacShortcutChar = macShortCut ; + if ( outMacModifiers ) + *outMacModifiers = macModifiers ; + if ( macShortCut ) + { + int pos = outMacItemText[0] ; + outMacItemText[++pos] = '/'; + outMacItemText[++pos] = toupper( macShortCut ); + outMacItemText[0] = pos ; + } +} + // Menus // Construct a menu with optional title (then use append) + +short wxMenu::s_macNextMenuId = 2 ; + wxMenu::wxMenu(const wxString& title, const wxFunction func) { m_title = title; @@ -50,23 +185,27 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func) m_eventHandler = this; m_noItems = 0; m_menuBar = NULL; + m_pInvokingWindow = NULL ; m_clientData = (void*) NULL; if (m_title != "") { - Append(-2, m_title) ; + Append(idMenuTitle, m_title) ; AppendSeparator() ; } Callback(func); - // TODO create menu + Str255 label; + wxMacBuildMenuString( label, NULL , NULL , title , false ); + m_macMenuId = s_macNextMenuId++; + wxCHECK_RET( s_macNextMenuId < 236 , "menu ids > 235 cannot be used for submenus on mac" ); + m_macMenuHandle = ::NewMenu(m_macMenuId, label); + m_macMenuEnabled = true ; } // The wxWindow destructor will take care of deleting the submenus. wxMenu::~wxMenu() { - // TODO destroy menu and children - wxNode *node = m_menuItems.First(); while (node) { @@ -83,28 +222,78 @@ wxMenu::~wxMenu() delete node; node = next; } + if (m_macMenuHandle) + ::DisposeMenu(m_macMenuHandle); } void wxMenu::Break() { - // TODO + // not available on the mac platform } // function appends a new item or submenu to the menu void wxMenu::Append(wxMenuItem *pItem) { - // TODO - wxCHECK_RET( pItem != NULL, "can't append NULL item to the menu" ); m_menuItems.Append(pItem); + if ( pItem->IsSeparator() ) + { + MacAppendMenu(m_macMenuHandle, "\p-"); + } + else + { + wxMenu *pSubMenu = pItem->GetSubMenu() ; + if ( pSubMenu != NULL ) + { + Str255 label; + wxCHECK_RET( pSubMenu->m_macMenuHandle != NULL , "invalid submenu added"); + pSubMenu->m_parent = this ; + wxMacBuildMenuString( label , NULL , NULL , pItem->GetName() ,false); + + // hardcoded adding of the submenu combination for mac + + int theEnd = label[0] + 1; + if (theEnd > 251) + theEnd = 251; // mac allows only 255 characters + label[theEnd++] = '/'; + label[theEnd++] = hMenuCmd; + label[theEnd++] = '!'; + label[theEnd++] = pSubMenu->m_macMenuId; + label[theEnd] = 0x00; + label[0] = theEnd; + + if (wxMenuBar::s_macInstalledMenuBar == m_menuBar) + { + ::InsertMenu( pSubMenu->m_macMenuHandle , -1 ) ; + } + + ::AppendMenu(m_macMenuHandle, label); + } + else + { + Str255 label ; + wxMacBuildMenuString( label , NULL , NULL , pItem->GetName(), pItem->GetId() == wxApp::s_macAboutMenuItemId); + if ( label[0] == 0 ) + { + // we cannot add empty menus on mac + label[0] = 1 ; + label[1] = ' ' ; + } + ::AppendMenu(m_macMenuHandle, label ); + if ( pItem->GetId() == idMenuTitle ) + { + UMADisableMenuItem( m_macMenuHandle , CountMItems( m_macMenuHandle ) ) ; + } + } + } + m_noItems++; } void wxMenu::AppendSeparator() { - // TODO Append(new wxMenuItem(this, ID_SEPARATOR)); } @@ -136,12 +325,31 @@ void wxMenu::Delete(int id) } if (!node) - return; + return; + + int index = pos + 1 ; + + if (index < 1) + return; + + wxMenu *pSubMenu = item->GetSubMenu(); + if ( pSubMenu != NULL ) + { + ::DeleteMenuItem( m_macMenuHandle , index); + pSubMenu->m_parent = NULL; + // TODO: Why isn't subMenu deleted here??? + // Will put this in for now. Assuming this is supposed + // to delete the menu, not just remove it. + item->DeleteSubMenu(); + } + else + { + ::DeleteMenuItem( m_macMenuHandle , index); + } m_menuItems.DeleteNode(node); + // TODO shouldn't we do this ? Ž_m_noItems--; delete item; - - // TODO } void wxMenu::Enable(int Id, bool Flag) @@ -178,8 +386,16 @@ bool wxMenu::Checked(int Id) const void wxMenu::SetTitle(const wxString& label) { + Str255 title ; m_title = label ; - // TODO + wxMacBuildMenuString( title, NULL , NULL , label , false ); + UMASetMenuTitle( m_macMenuHandle , title ) ; + if (wxMenuBar::s_macInstalledMenuBar == m_menuBar) // are we currently installed ? + { + ::SetMenuBar( GetMenuBar() ) ; + ::InvalMenuBar() ; + } + // TODO:for submenus -> their parent item text must be corrected } const wxString wxMenu::GetTitle() const @@ -189,25 +405,33 @@ const wxString wxMenu::GetTitle() const void wxMenu::SetLabel(int id, const wxString& label) { + Str255 maclabel ; + int index ; wxMenuItem *item = FindItemForId(id) ; if (item==NULL) return; + index = MacGetIndexFromItem( item ) ; + if (index < 1) + return; + if (item->GetSubMenu()==NULL) { - // TODO + wxMacBuildMenuString( maclabel , NULL , NULL , label , false ); + ::SetMenuItemText( m_macMenuHandle , index , maclabel ) ; } else { - // TODO + wxMacBuildMenuString( maclabel , NULL , NULL , label , false ); + ::SetMenuItemText( m_macMenuHandle , index , maclabel ) ; } item->SetName(label); } wxString wxMenu::GetLabel(int Id) const { - // TODO - return wxString("") ; + wxMenuItem *pItem = FindItemForId(Id) ; + return pItem->GetName() ; } // Finds the item id matching the given string, -1 if not found. @@ -295,21 +519,204 @@ void wxMenu::ProcessCommand(wxCommandEvent & event) { processed = GetEventHandler()->ProcessEvent(event); } -/* TODO - // Try the window the menu was popped up from (and up - // through the hierarchy) - if ( !processed && GetInvokingWindow()) - processed = GetInvokingWindow()->ProcessEvent(event); -*/ + + // Try the window the menu was popped up from (and up + // through the hierarchy) + if ( !processed && GetInvokingWindow()) + processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event); } bool wxWindow::PopupMenu(wxMenu *menu, int x, int y) { - // TODO - return FALSE; + menu->SetInvokingWindow(this); + ClientToScreen( &x , &y ) ; + + ::InsertMenu( menu->m_macMenuHandle , -1 ) ; + long menuResult = ::PopUpMenuSelect(menu->m_macMenuHandle ,y,x, 0) ; + menu->MacMenuSelect( this , TickCount() , HiWord(menuResult) , LoWord(menuResult) ) ; + ::DeleteMenu( menu->m_macMenuId ) ; + menu->SetInvokingWindow(NULL); + + return TRUE; +} + +// helper functions returning the mac menu position for a certain item, note that this is +// mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0 + +int wxMenu::MacGetIndexFromId( int id ) +{ + wxNode *node; + wxMenuItem *item; + int pos; + + for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) + { + item = (wxMenuItem *)node->Data(); + if (item->GetId() == id) + break; + } + + if (!node) + return 0; + + return pos + 1 ; +} + +int wxMenu::MacGetIndexFromItem( wxMenuItem *pItem ) +{ + wxNode *node; + int pos; + + for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) + { + if ((wxMenuItem *)node->Data() == pItem) + break; + } + + if (!node) + return 0; + + return pos + 1 ; +} + +void wxMenu::MacEnableMenu( bool bDoEnable ) +{ + m_macMenuEnabled = bDoEnable ; + if ( bDoEnable ) + UMAEnableMenuItem( m_macMenuHandle , 0 ) ; + else + UMADisableMenuItem( m_macMenuHandle , 0 ) ; + + ::DrawMenuBar() ; +} + +bool wxMenu::MacMenuSelect( wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum ) +{ + int pos; + wxNode *node; + + if ( m_macMenuId == macMenuId ) + { + node = m_menuItems.Nth(macMenuItemNum-1); + if (node) + { + wxMenuItem *pItem = (wxMenuItem*)node->Data(); + + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, pItem->GetId()); + event.m_timeStamp = when; + event.SetEventObject(handler); + event.SetInt( pItem->GetId() ); + + { + bool processed = false ; + + // Try a callback + if (m_callback) + { + (void) (*(m_callback)) (*this, event); + processed = TRUE; + } + + // Try the menu's event handler + if ( !processed && handler) + { + processed = handler->ProcessEvent(event); + } + + // Try the window the menu was popped up from (and up + // through the hierarchy) + if ( !processed && GetInvokingWindow()) + processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event); + } + return true ; + } + } + else if ( macMenuId == kHMHelpMenuID ) + { + int menuItem = formerHelpMenuItems ; + for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) + { + wxMenuItem * pItem = (wxMenuItem *) node->Data() ; + + wxMenu *pSubMenu = pItem->GetSubMenu() ; + if ( pSubMenu != NULL ) + { + } + else + { + if ( pItem->GetId() != wxApp::s_macAboutMenuItemId ) + ++menuItem ; + + if ( menuItem == macMenuItemNum ) + { + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, pItem->GetId()); + event.m_timeStamp = when; + event.SetEventObject(handler); + event.SetInt( pItem->GetId() ); + + { + bool processed = false ; + // Try a callback + if (m_callback) + { + (void) (*(m_callback)) (*this, event); + processed = TRUE; + } + + // Try the menu's event handler + if ( !processed && handler) + { + processed = handler->ProcessEvent(event); + } + + // Try the window the menu was popped up from (and up + // through the hierarchy) + if ( !processed && GetInvokingWindow()) + processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event); + } + + return true ; + } + } + } + } + + for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++) + { + wxMenuItem * pItem = (wxMenuItem *) node->Data() ; + + wxMenu *pSubMenu = pItem->GetSubMenu() ; + if ( pSubMenu != NULL ) + { + if ( pSubMenu->MacMenuSelect( handler , when , macMenuId , macMenuItemNum ) ) + return true ; + } + } + + return false ; } // Menu Bar + +/* + +Mac Implementation note : + +The Mac has only one global menubar, so we attempt to install the currently +active menubar from a frame, we currently don't take into account mdi-frames +which would ask for menu-merging + +Secondly there is no mac api for changing a menubar that is not the current +menubar, so we have to wait for preparing the actual menubar until the +wxMenubar is to be used + +We can in subsequent versions use MacInstallMenuBar to provide some sort of +auto-merge for MDI in case this will be necessary + +*/ + +wxMenuBar* wxMenuBar::s_macInstalledMenuBar = NULL ; + wxMenuBar::wxMenuBar() { m_eventHandler = this; @@ -317,8 +724,6 @@ wxMenuBar::wxMenuBar() m_menus = NULL; m_titles = NULL; m_menuBarFrame = NULL; - - // TODO } wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[]) @@ -329,14 +734,18 @@ wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[]) m_titles = new wxString[n]; int i; for ( i = 0; i < n; i++ ) - m_titles[i] = titles[i]; + m_titles[i] = titles[i]; m_menuBarFrame = NULL; - - // TODO } wxMenuBar::~wxMenuBar() { + if (s_macInstalledMenuBar == this) + { + ::ClearMenuBar(); + s_macInstalledMenuBar = NULL; + } + int i; for (i = 0; i < m_menuCount; i++) { @@ -345,9 +754,95 @@ wxMenuBar::~wxMenuBar() delete[] m_menus; delete[] m_titles; - // TODO } +void wxMenuBar::MacInstallMenuBar() +{ + Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ; + wxString message ; + wxCHECK_RET( menubar != NULL, "can't read MBAR resource" ); + ::SetMenuBar( menubar ) ; + ::DisposeHandle( menubar ) ; + + MenuHandle menu = ::GetMenuHandle( kwxMacAppleMenuId ) ; + ::AppendResMenu(menu, 'DRVR'); + + for (int i = 0; i < m_menuCount; i++) + { + Str255 label; + wxNode *node; + wxMenuItem *item; + int pos ; + wxMenu* menu = m_menus[i] , *subMenu = NULL ; + + + if( m_titles[i] == "?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) + { + MenuHandle mh = NULL ; + if ( HMGetHelpMenuHandle( &mh ) != noErr ) + { + continue ; + } + if ( formerHelpMenuItems == 0 ) + { + if( mh ) + formerHelpMenuItems = CountMenuItems( mh ) ; + } + + for (pos = 0 , node = menu->m_menuItems.First(); node; node = node->Next(), pos++) + { + item = (wxMenuItem *)node->Data(); + subMenu = item->GetSubMenu() ; + if (subMenu) + { + // we don't support hierarchical menus in the help menu yet + } + else + { + Str255 label ; + wxMacBuildMenuString( label , NULL , NULL , item->GetName(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu + if ( label[0] == 0 ) + { + // we cannot add empty menus on mac + label[0] = 1 ; + label[1] = ' ' ; + } + if ( item->GetId() == wxApp::s_macAboutMenuItemId ) + { + ::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label ); + // ::EnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 ); + ::EnableItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 ); + } + else + { + if ( mh ) + ::AppendMenu(mh, label ); + } + } + } + } + else + { + wxMacBuildMenuString( label, NULL , NULL , m_titles[i] , false ); + UMASetMenuTitle( menu->m_macMenuHandle , label ) ; + for (pos = 0, node = menu->m_menuItems.First(); node; node = node->Next(), pos++) + { + item = (wxMenuItem *)node->Data(); + subMenu = item->GetSubMenu() ; + if (subMenu) + { + ::InsertMenu( subMenu->m_macMenuHandle , -1 ) ; + } + } + ::InsertMenu(m_menus[i]->m_macMenuHandle, 0); + } + } + ::DrawMenuBar() ; + + s_macInstalledMenuBar = this; +} + + // Must only be used AFTER menu has been attached to frame, // otherwise use individual menus to enable/disable items void wxMenuBar::Enable(int id, bool flag) @@ -357,12 +852,12 @@ void wxMenuBar::Enable(int id, bool flag) if (!item) return; - // TODO + item->Enable( flag ) ; } void wxMenuBar::EnableTop(int pos, bool flag) { - // TODO + m_menus[pos]->MacEnableMenu( flag ) ; } // Must only be used AFTER menu has been attached to frame, @@ -377,7 +872,7 @@ void wxMenuBar::Check(int id, bool flag) if (!item->IsCheckable()) return ; - // TODO + item->Check( flag ) ; } bool wxMenuBar::Checked(int id) const @@ -387,8 +882,10 @@ bool wxMenuBar::Checked(int id) const if (!item) return FALSE; - // TODO - return FALSE; + if (!item->IsCheckable()) + return FALSE ; + + return item->IsChecked() ; } bool wxMenuBar::Enabled(int id) const @@ -398,8 +895,23 @@ bool wxMenuBar::Enabled(int id) const if (!item) return FALSE; - // TODO - return FALSE ; + if ( !item->IsEnabled() ) + return FALSE ; + + if ( itemMenu->m_macMenuEnabled == false ) + return FALSE ; + + while( itemMenu->m_parent ) + { + itemMenu = (wxMenu*) itemMenu->m_parent ; + if ( itemMenu->IsKindOf( CLASSINFO( wxMenu ) ) ) + { + if ( itemMenu->m_macMenuEnabled == false ) + return FALSE ; + } + } + + return TRUE ; } @@ -411,7 +923,7 @@ void wxMenuBar::SetLabel(int id, const wxString& label) if (!item) return; - // TODO + itemMenu->SetLabel( id , label ) ; } wxString wxMenuBar::GetLabel(int id) const @@ -422,31 +934,51 @@ wxString wxMenuBar::GetLabel(int id) const if (!item) return wxString(""); - // TODO - return wxString("") ; + return itemMenu->GetLabel( id ) ; } void wxMenuBar::SetLabelTop(int pos, const wxString& label) { - // TODO + m_menus[pos]->SetTitle( label ) ; } wxString wxMenuBar::GetLabelTop(int pos) const { - // TODO - return wxString(""); + return m_menus[pos]->GetTitle() ; } bool wxMenuBar::OnDelete(wxMenu *a_menu, int pos) { - // TODO - return FALSE; + if (s_macInstalledMenuBar == this) + { + ::DeleteMenu( a_menu->m_macMenuId /* m_menus[pos]->m_macMenuId */ ) ; + ::InvalMenuBar() ; + return TRUE ; + } + else + { + return TRUE ; + } } bool wxMenuBar::OnAppend(wxMenu *a_menu, const char *title) { - // TODO - return FALSE; + if (!a_menu->m_macMenuHandle) + return FALSE; + + if (s_macInstalledMenuBar == this) + { + Str255 label; + wxMacBuildMenuString( label, NULL , NULL , title , false ); + UMASetMenuTitle( a_menu->m_macMenuHandle , label ) ; + ::InsertMenu( a_menu->m_macMenuHandle , 0 ) ; + ::InvalMenuBar() ; + return TRUE ; + } + else + { + return TRUE ; + } } void wxMenuBar::Append (wxMenu * menu, const wxString& title) @@ -477,7 +1009,8 @@ void wxMenuBar::Append (wxMenu * menu, const wxString& title) m_menus[m_menuCount - 1] = (wxMenu *)menu; m_titles[m_menuCount - 1] = title; - // TODO + ((wxMenu *)menu)->m_menuBar = (wxMenuBar *) this; + ((wxMenu *)menu)->SetParent(this); } void wxMenuBar::Delete(wxMenu * menu, int i) @@ -568,4 +1101,43 @@ wxString wxMenuBar::GetHelpString (int Id) const return wxString(""); } +void wxMenuBar::MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) +{ + // first scan fast for direct commands, i.e. menus which have these commands directly in their own list + + if ( macMenuId == kwxMacAppleMenuId && macMenuItemNum == 1 ) + { + wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, wxApp::s_macAboutMenuItemId ); + event.m_timeStamp = when; + event.SetEventObject(handler); + event.SetInt( wxApp::s_macAboutMenuItemId ); + handler->ProcessEvent(event); + } + else + { + for (int i = 0; i < m_menuCount; i++) + { + if ( m_menus[i]->m_macMenuId == macMenuId || + ( macMenuId == kHMHelpMenuID && ( m_titles[i] == "?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) ) + ) + { + if ( m_menus[i]->MacMenuSelect( handler , when , macMenuId , macMenuItemNum ) ) + return ; + else + { + //TODO flag this as an error since it must contain the item + return ; + } + } + } + + for (int i = 0; i < m_menuCount; i++) + { + if ( m_menus[i]->MacMenuSelect( handler , when , macMenuId , macMenuItemNum ) ) + { + break ; + } + } + } +} diff --git a/src/mac/menuitem.cpp b/src/mac/menuitem.cpp index 38d31737e7..9195fdc50a 100644 --- a/src/mac/menuitem.cpp +++ b/src/mac/menuitem.cpp @@ -16,6 +16,7 @@ #include "wx/menu.h" #include "wx/menuitem.h" +#include // ============================================================================ // implementation // ============================================================================ @@ -49,6 +50,11 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id, m_pSubMenu = pSubMenu; m_idItem = id; m_bEnabled = TRUE; + + if ( m_strName == "E&xit" ||m_strName == "Exit" ) + { + m_strName = "Quit\tCtrl+Q" ; + } } wxMenuItem::~wxMenuItem() @@ -73,12 +79,35 @@ void wxMenuItem::DeleteSubMenu() void wxMenuItem::Enable(bool bDoEnable) { if ( m_bEnabled != bDoEnable ) { - if ( m_pSubMenu == NULL ) { // normal menu item - // TODO + if ( m_pSubMenu == NULL ) + { + // normal menu item + if ( m_pParentMenu->m_macMenuHandle ) + { + int index = m_pParentMenu->MacGetIndexFromItem( this ) ; + if ( index >= 1 ) + { + if ( bDoEnable ) + UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ; + else + UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ; + } + } } - else // submenu + else { - // TODO + // submenu + if ( m_pParentMenu->m_macMenuHandle ) + { + int index = m_pParentMenu->MacGetIndexFromItem( this ) ; + if ( index >= 1 ) + { + if ( bDoEnable ) + UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ; + else + UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ; + } + } } m_bEnabled = bDoEnable; @@ -89,7 +118,19 @@ void wxMenuItem::Check(bool bDoCheck) { wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); - if ( m_bChecked != bDoCheck ) { - // TODO + if ( m_bChecked != bDoCheck ) + { m_bChecked = bDoCheck; + if ( m_pParentMenu->m_macMenuHandle ) + { + int index = m_pParentMenu->MacGetIndexFromItem( this ) ; + if ( index >= 1 ) + { + if ( bDoCheck ) + ::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0x12 ) ; // checkmark + else + ::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0 ) ; // no mark + } + } } +} \ No newline at end of file diff --git a/src/mac/metafile.cpp b/src/mac/metafile.cpp index ddbfb8402f..97e31948bf 100644 --- a/src/mac/metafile.cpp +++ b/src/mac/metafile.cpp @@ -13,46 +13,118 @@ #pragma implementation "metafile.h" #endif -#include "wx/object.h" -#include "wx/string.h" -#include "wx/dc.h" -#include "wx/stubs/metafile.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include "wx/setup.h" +#endif + +#if wxUSE_METAFILE + +#ifndef WX_PRECOMP +#include "wx/utils.h" +#include "wx/app.h" +#endif + +#include "wx/metafile.h" #include "wx/clipbrd.h" +#include +#include + extern bool wxClipboardIsOpen; #if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxMetaFile, wxObject) -IMPLEMENT_ABSTRACT_CLASS(wxMetaFileDC, wxDC) +IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC) #endif +/* + * Metafiles + * Currently, the only purpose for making a metafile is to put + * it on the clipboard. + */ + +wxMetafileRefData::wxMetafileRefData(void) +{ + m_metafile = 0; +} + +wxMetafileRefData::~wxMetafileRefData(void) +{ + if (m_metafile) + { + KillPicture( m_metafile ) ; + m_metafile = 0; + } +} + wxMetaFile::wxMetaFile(const wxString& file) { - // TODO + m_refData = new wxMetafileRefData; + + + M_METAFILEDATA->m_metafile = 0; + wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; +/* + if (!file.IsNull() && (file.Cmp("") == 0)) + M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file); +*/ } wxMetaFile::~wxMetaFile() { - // TODO } bool wxMetaFile::SetClipboard(int width, int height) { + if (!m_refData) + return FALSE; +/* bool alreadyOpen=wxClipboardOpen(); if (!alreadyOpen) { wxOpenClipboard(); if (!wxEmptyClipboard()) return FALSE; } - bool success = wxSetClipboardData(wxDF_METAFILE,this, width,height); + bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height); if (!alreadyOpen) wxCloseClipboard(); return (bool) success; + */ + return TRUE ; } bool wxMetaFile::Play(wxDC *dc) { - // TODO + if (!m_refData) return FALSE; + + if (!dc->Ok() ) + return FALSE; + + dc->MacVerifySetup() ; + + { + PicHandle pict = GetHMETAFILE() ; + DrawPicture( pict , &(**pict).picFrame ) ; + } +/* + if (!m_refData) + return FALSE; + + dc->BeginDrawing(); + + if (dc->GetHDC() && M_METAFILEDATA->m_metafile) + PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile); + + dc->EndDrawing(); +*/ + return TRUE; } /* @@ -64,176 +136,55 @@ bool wxMetaFile::Play(wxDC *dc) // *DO* give origin/extent arguments to wxMakeMetaFilePlaceable. wxMetaFileDC::wxMetaFileDC(const wxString& file) { - // TODO + 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,100,100} ; + + m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; + ::GetPort( &m_macPort ) ; + m_ok = TRUE ; + + SetMapMode(wxMM_TEXT); } // New constructor that takes origin and extent. If you use this, don't // give origin/extent arguments to wxMakeMetaFilePlaceable. + wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg) { - // TODO -} + m_minX = 10000; + m_minY = 10000; + m_maxX = -10000; + m_maxY = -10000; -wxMetaFileDC::~wxMetaFileDC() -{ -} + wxASSERT_MSG( file.IsEmpty() , "no file based metafile support yet") ; -void wxMetaFileDC::GetTextExtent(const wxString& string, float *x, float *y, - float *descent, float *externalLeading, wxFont *theFont, bool use16bit) -{ - // TODO -} + m_metaFile = new wxMetaFile("") ; + Rect r={yorg,xorg,yorg+yext,xorg+xext} ; + + m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ; + ::GetPort( &m_macPort ) ; + m_ok = TRUE ; -wxMetaFile *wxMetaFileDC::Close() -{ - // TODO - return NULL; + SetMapMode(wxMM_TEXT); } -void wxMetaFileDC::SetMapMode(int mode) +wxMetaFileDC::~wxMetaFileDC() { - // TODO } -#if 0 - -#ifdef __WIN32__ -struct RECT32 -{ - short left; - short top; - short right; - short bottom; -}; - -struct mfPLACEABLEHEADER { - DWORD key; - short hmf; - RECT32 bbox; - WORD inch; - DWORD reserved; - WORD checksum; -}; -#else -struct mfPLACEABLEHEADER { - DWORD key; - HANDLE hmf; - RECT bbox; - WORD inch; - DWORD reserved; - WORD checksum; -}; -#endif - -/* - * Pass filename of existing non-placeable metafile, and bounding box. - * Adds a placeable metafile header, sets the mapping mode to anisotropic, - * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode. - * - */ - -bool wxMakeMetaFilePlaceable(const wxString& filename, float scale) +wxMetaFile *wxMetaFileDC::Close() { - return wxMakeMetaFilePlaceable(filename, 0, 0, 0, 0, scale, FALSE); + ClosePicture() ; + return m_metaFile; } -bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale, bool useOriginAndExtent) -{ - // I'm not sure if this is the correct way of suggesting a scale - // to the client application, but it's the only way I can find. - int unitsPerInch = (int)(576/scale); - - mfPLACEABLEHEADER header; - header.key = 0x9AC6CDD7L; - header.hmf = 0; - header.bbox.left = (int)(x1); - header.bbox.top = (int)(y1); - header.bbox.right = (int)(x2); - header.bbox.bottom = (int)(y2); - header.inch = unitsPerInch; - header.reserved = 0; - - // Calculate checksum - WORD *p; - mfPLACEABLEHEADER *pMFHead = &header; - for (p =(WORD *)pMFHead,pMFHead -> checksum = 0; - p < (WORD *)&pMFHead ->checksum; ++p) - pMFHead ->checksum ^= *p; - - FILE *fd = fopen((char *)(const char *)filename, "rb"); - if (!fd) return FALSE; - - char tempFileBuf[256]; - wxGetTempFileName("mf", tempFileBuf); - FILE *fHandle = fopen(tempFileBuf, "wb"); - if (!fHandle) - return FALSE; - fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle); - - // Calculate origin and extent - int originX = x1; - int originY = y1; - int extentX = x2 - x1; - int extentY = (y2 - y1); - - // Read metafile header and write - METAHEADER metaHeader; - fread((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fd); - - if (useOriginAndExtent) - metaHeader.mtSize += 15; - else - metaHeader.mtSize += 5; - - fwrite((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fHandle); - - // Write SetMapMode, SetWindowOrigin and SetWindowExt records - char modeBuffer[8]; - char originBuffer[10]; - char extentBuffer[10]; - METARECORD *modeRecord = (METARECORD *)&modeBuffer; - - METARECORD *originRecord = (METARECORD *)&originBuffer; - METARECORD *extentRecord = (METARECORD *)&extentBuffer; - - modeRecord->rdSize = 4; - modeRecord->rdFunction = META_SETMAPMODE; - modeRecord->rdParm[0] = wxMM_ANISOTROPIC; - - originRecord->rdSize = 5; - originRecord->rdFunction = META_SETWINDOWORG; - originRecord->rdParm[0] = originY; - originRecord->rdParm[1] = originX; - - extentRecord->rdSize = 5; - extentRecord->rdFunction = META_SETWINDOWEXT; - extentRecord->rdParm[0] = extentY; - extentRecord->rdParm[1] = extentX; - - fwrite((void *)modeBuffer, sizeof(char), 8, fHandle); - - if (useOriginAndExtent) - { - fwrite((void *)originBuffer, sizeof(char), 10, fHandle); - fwrite((void *)extentBuffer, sizeof(char), 10, fHandle); - } - - int ch = -2; - while (ch != EOF) - { - ch = getc(fd); - if (ch != EOF) - { - putc(ch, fHandle); - } - } - fclose(fHandle); - fclose(fd); - wxRemoveFile(filename); - wxCopyFile(tempFileBuf, filename); - wxRemoveFile(tempFileBuf); - return TRUE; -} #endif - diff --git a/src/mac/msgdlg.cpp b/src/mac/msgdlg.cpp index 775ac8f064..5aa8554038 100644 --- a/src/mac/msgdlg.cpp +++ b/src/mac/msgdlg.cpp @@ -14,11 +14,47 @@ #endif #include "wx/msgdlg.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_CLASS(wxMessageDialog, wxDialog) #endif +#define kMacOKAlertResourceID 128 +#define kMacYesNoAlertResourceID 129 +#define kMacYesNoCancelAlertResourceID 130 +#define kMacNoYesAlertResourceID 131 +#define kMacNoYesCancelAlertResourceID 132 + +short language = 0 ; + +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 ; +} + wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption, long style, const wxPoint& pos) { @@ -30,7 +66,226 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, cons int wxMessageDialog::ShowModal() { - // TODO - return wxID_CANCEL; + int resultbutton = wxID_CANCEL ; + + short result ; + Str255 pascalTitle ; + Str255 pascalText ; + + strcpy( (char*) pascalTitle , m_caption ) ; + c2pstr( (char*) pascalTitle ) ; + strcpy( (char*) pascalText , m_message ) ; + wxMacConvertNewlines( (char*)pascalText ,(char*) pascalText) ; + c2pstr( (char*) pascalText ) ; + + if ( !UMAHasAppearance() ) + { + int resourceID ; + + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + resourceID = kMacYesNoCancelAlertResourceID; + else + resourceID = kMacYesNoAlertResourceID + language * 10 ; + } + else if (m_dialogStyle & wxOK) + { + if (m_dialogStyle & wxCANCEL) + resourceID = kMacOKAlertResourceID; // wrong + else + resourceID = kMacOKAlertResourceID; + } + else + { + return resultbutton ; + } + /* + if (hWnd) + msStyle |= MB_APPLMODAL; + else + msStyle |= MB_TASKMODAL; + */ + + ParamText( pascalTitle , pascalText , NULL , NULL ) ; + + if (m_dialogStyle & wxICON_EXCLAMATION) + result = Alert( resourceID , NULL ) ; + else if (m_dialogStyle & wxICON_HAND) + result = StopAlert( resourceID , NULL ) ; + else if (m_dialogStyle & wxICON_INFORMATION) + result = NoteAlert( resourceID , NULL ) ; + else if (m_dialogStyle & wxICON_QUESTION) + result = CautionAlert( resourceID , NULL ) ; + else + result = Alert( resourceID , NULL ) ; + + resultbutton = result ; + + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + switch( result ) + { + case 1 : + resultbutton = wxID_YES ; + break ; + case 2 : + resultbutton = wxID_NO ; + break ; + case 3 : + resultbutton = wxID_CANCEL ; + break ; + } + } + else + { + switch( result ) + { + case 1 : + resultbutton = wxID_YES ; + break ; + case 2 : + resultbutton = wxID_NO ; + break ; + case 3 : + break ; + } + } + } + } + else + { + AlertStdAlertParamRec param; + + param.movable = true; + param.filterProc = NULL ; + + if (m_dialogStyle & wxYES_NO) + { + if (m_dialogStyle & wxCANCEL) + { + param.defaultText = "\pYes" ; + param.cancelText = (StringPtr) kAlertDefaultCancelText; + param.otherText = "\pNo"; + param.helpButton = false ; + param.defaultButton = kAlertStdAlertOKButton; + param.cancelButton = kAlertStdAlertCancelButton; + } + else + { + param.defaultText = "\pYes" ; + param.cancelText = NULL; + param.otherText = "\pNo"; + 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; + + if (m_dialogStyle & wxICON_EXCLAMATION) + StandardAlert( kAlertNoteAlert, pascalTitle, pascalText, ¶m, &result ); + else if (m_dialogStyle & wxICON_HAND) + StandardAlert( kAlertStopAlert, pascalTitle, pascalText, ¶m, &result ); + else if (m_dialogStyle & wxICON_INFORMATION) + StandardAlert( kAlertNoteAlert, pascalTitle, pascalText, ¶m, &result ); + else if (m_dialogStyle & wxICON_QUESTION) + StandardAlert( kAlertCautionAlert, pascalTitle, pascalText, ¶m, &result ); + else + StandardAlert( kAlertPlainAlert, 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/notebook.cpp b/src/mac/notebook.cpp index 312dd0f3d3..a4f93917eb 100644 --- a/src/mac/notebook.cpp +++ b/src/mac/notebook.cpp @@ -24,7 +24,7 @@ #include #include #include - +#include // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -32,6 +32,11 @@ // check that the page index is valid #define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount())) +const short kwxMacTabLeftMargin = 16 ; +const short kwxMacTabTopMargin = 30 ; +const short kwxMacTabRightMargin = 16 ; +const short kwxMacTabBottomMargin = 16 ; + // ---------------------------------------------------------------------------- // event table // ---------------------------------------------------------------------------- @@ -91,21 +96,16 @@ bool wxNotebook::Create(wxWindow *parent, long style, const wxString& name) { - // base init - SetName(name); - SetParent(parent); - - m_windowId = id == -1 ? NewControlId() : id; - - // style - m_windowStyle = style; - - if ( parent != NULL ) - parent->AddChild(this); - - // TODO - - return FALSE; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlTabSmallProc , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } // dtor @@ -123,8 +123,7 @@ int wxNotebook::GetPageCount() const int wxNotebook::GetRowCount() const { - // TODO - return 0; + return 1; } int wxNotebook::SetSelection(int nPage) @@ -132,9 +131,11 @@ int wxNotebook::SetSelection(int nPage) wxASSERT( IS_VALID_PAGE(nPage) ); ChangePage(m_nSelection, nPage); - - // TODO - return 0; + SetControlValue( m_macControl , m_nSelection + 1 ) ; +// Boolean enabled = true ; + +// SetControlData( m_macControl, m_nSelection + 1, kControlTabEnabledFlagTag, sizeof( Boolean ), (Ptr)&enabled ); + return m_nSelection; } void wxNotebook::AdvanceSelection(bool bForward) @@ -246,7 +247,19 @@ bool wxNotebook::InsertPage(int nPage, wxASSERT( pPage != NULL ); wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE ); - // TODO: insert native widget page + ControlTabInfoRec tie ; + Boolean enabled = true ; + if ( nPage + 1 > GetControlMaximum( m_macControl ) ) + { + SetControlMaximum( m_macControl , nPage + 1 ) ; + } + + tie.version = 0 ; + tie.iconSuiteID = 0 ; + strcpy( (char*) tie.name , strText ) ; + c2pstr( (char*) tie.name ) ; + SetControlData( m_macControl, nPage + 1, kControlTabInfoTag , sizeof( ControlTabInfoRec) , (char*) &tie ) ; + SetControlData( m_macControl, m_nSelection + 1, kControlTabEnabledFlagTag, sizeof( Boolean ), (Ptr)&enabled ); // save the pointer to the page m_aPages.Insert(pPage, nPage); @@ -258,6 +271,9 @@ bool wxNotebook::InsertPage(int nPage, else if ( m_nSelection == -1 ) m_nSelection = 0; + // don't show pages by default (we'll need to adjust their size first) + pPage->Show( FALSE ) ; + return TRUE; } @@ -290,7 +306,9 @@ void wxNotebook::OnSize(wxSizeEvent& event) unsigned int nCount = m_aPages.Count(); for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) { wxNotebookPage *pPage = m_aPages[nPage]; - pPage->SetSize(0, 0, w, h); + pPage->SetSize(kwxMacTabLeftMargin, kwxMacTabTopMargin, w - kwxMacTabLeftMargin - kwxMacTabRightMargin, + h - kwxMacTabTopMargin - kwxMacTabBottomMargin ); +// pPage->SetSize(0, 0, w, h); if ( pPage->GetAutoLayout() ) pPage->Layout(); } @@ -362,7 +380,16 @@ void wxNotebook::Command(wxCommandEvent& event) // hide the currently active panel and show the new one void wxNotebook::ChangePage(int nOldSel, int nSel) { - wxASSERT( nOldSel != nSel ); // impossible + // it's not an error (the message may be generated by the tab control itself) + // and it may happen - just do nothing + if ( nSel == nOldSel ) + { + wxNotebookPage *pPage = m_aPages[nSel]; + pPage->Show(FALSE); + pPage->Show(TRUE); + pPage->SetFocus(); + return; + } if ( nOldSel != -1 ) { m_aPages[nOldSel]->Show(FALSE); @@ -375,3 +402,11 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) m_nSelection = nSel; } +void wxNotebook::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControlValue(m_macControl) - 1, m_nSelection); + event.SetEventObject(this); + + ProcessEvent(event); +} + diff --git a/src/mac/palette.cpp b/src/mac/palette.cpp index f8db96f8d0..85a9fd16d8 100644 --- a/src/mac/palette.cpp +++ b/src/mac/palette.cpp @@ -26,12 +26,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject) wxPaletteRefData::wxPaletteRefData() { - // TODO + m_palette = NULL ; + m_count = 0 ; } wxPaletteRefData::~wxPaletteRefData() { - // TODO + delete[] m_palette ; } wxPalette::wxPalette() @@ -53,7 +54,13 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre m_refData = new wxPaletteRefData; - // TODO + 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; } @@ -61,10 +68,26 @@ bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *gre int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const { if ( !m_refData ) - return FALSE; - - // TODO - return FALSE; + 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 ; + } + } + + return bestpos; } bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const @@ -72,11 +95,15 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi if ( !m_refData ) return FALSE; - if (index < 0 || index > 255) + if (index < 0 || index >= M_PALETTEDATA->m_count) return FALSE; - // TODO - return FALSE; + const wxColour& col = &M_PALETTEDATA->m_palette[index] ; + *red = col.Red() ; + *green = col.Green() ; + *blue = col.Blue() ; + + return TRUE; } diff --git a/src/mac/print.cpp b/src/mac/print.cpp index 61fd6e7e99..1064058925 100644 --- a/src/mac/print.cpp +++ b/src/mac/print.cpp @@ -13,8 +13,8 @@ #pragma implementation "print.h" #endif -#include "wx/stubs/print.h" -#include "wx/stubs/printdlg.h" +#include "wx/mac/print.h" +#include "wx/mac/printdlg.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxPrinter, wxPrinterBase) diff --git a/src/mac/printdlg.cpp b/src/mac/printdlg.cpp index eae3b95568..18c7a8427e 100644 --- a/src/mac/printdlg.cpp +++ b/src/mac/printdlg.cpp @@ -14,11 +14,10 @@ #endif #include "wx/object.h" -#include "wx/stubs/printdlg.h" +#include "wx/mac/printdlg.h" #include "wx/dcprint.h" // Use generic page setup dialog: use your own native one if one exists. -#include "wx/generic/prntdlgg.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog) @@ -29,7 +28,6 @@ wxPrintDialog::wxPrintDialog(): wxDialog() { m_dialogParent = NULL; - m_printerDC = NULL; } wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data): @@ -41,7 +39,6 @@ wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data): bool wxPrintDialog::Create(wxWindow *p, wxPrintData* data) { m_dialogParent = p; - m_printerDC = NULL; if ( data ) m_printData = *data; @@ -51,26 +48,39 @@ bool wxPrintDialog::Create(wxWindow *p, wxPrintData* data) wxPrintDialog::~wxPrintDialog() { - if (m_printerDC) - delete m_printerDC; } int wxPrintDialog::ShowModal() { - // TODO - return wxID_CANCEL; + int result = wxID_CANCEL ; + OSErr err ; + wxString message ; + ::PrOpen() ; + err = PrError() ; + + if ( !err ) + { + m_printData.ConvertToNative() ; + if ( m_printData.macPrintInfo && ::PrJobDialog( m_printData.macPrintInfo ) ) + { + m_printData.ConvertFromNative() ; + result = wxID_OK ; + } + + } + else + { + message.Printf( "Print Error %d", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + } + ::PrClose() ; + + return result ; } wxDC *wxPrintDialog::GetPrintDC() { - if (m_printerDC) - { - wxDC* dc = m_printerDC; - m_printerDC = NULL; - return dc; - } - else - return NULL; + return new wxPrinterDC( m_printData ) ; } /* @@ -105,11 +115,29 @@ wxPageSetupDialog::~wxPageSetupDialog() int wxPageSetupDialog::ShowModal() { - // Uses generic page setup dialog - wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData); - int ret = genericPageSetupDialog->ShowModal(); - m_pageSetupData = genericPageSetupDialog->GetPageSetupData(); - genericPageSetupDialog->Close(TRUE); - return ret; + int result = wxID_CANCEL ; + OSErr err ; + wxString message ; + ::PrOpen() ; + err = PrError() ; + + if ( !err ) + { + m_pageSetupData.ConvertToNative() ; + if ( m_pageSetupData.m_macPageSetupInfo && ::PrStlDialog( m_pageSetupData.m_macPageSetupInfo ) ) + { + m_pageSetupData.ConvertFromNative() ; + result = wxID_OK ; + } + + } + else + { + message.Printf( "Print Error %d", err ) ; + wxMessageDialog dialog( NULL , message , "", wxICON_HAND | wxOK) ; + } + ::PrClose() ; + + return result ; } diff --git a/src/mac/radiobox.cpp b/src/mac/radiobox.cpp index da582d0e52..3393009f47 100644 --- a/src/mac/radiobox.cpp +++ b/src/mac/radiobox.cpp @@ -108,7 +108,7 @@ wxString wxRadioBox::GetString(int n) const void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; } void wxRadioBox::GetSize(int *width, int *height) const @@ -140,12 +140,13 @@ void wxRadioBox::SetFocus() bool wxRadioBox::Show(bool show) { // TODO - return FALSE; + return wxWindow::Show( show ) ; } // Enable a specific button void wxRadioBox::Enable(int item, bool enable) { + wxControl::Enable(enable); // TODO } diff --git a/src/mac/region.cpp b/src/mac/region.cpp index c71d4c605a..c5c6332e06 100644 --- a/src/mac/region.cpp +++ b/src/mac/region.cpp @@ -28,19 +28,24 @@ class WXDLLEXPORT wxRegionRefData : public wxGDIRefData { public: wxRegionRefData() { + m_macRgn = NewRgn() ; } wxRegionRefData(const wxRegionRefData& data) { - // TODO + m_macRgn = NewRgn() ; + CopyRgn( data.m_macRgn , m_macRgn ) ; } ~wxRegionRefData() { - // TODO + DisposeRgn( m_macRgn ) ; } + RgnHandle m_macRgn ; }; +#define M_REGION (((wxRegionRefData*)m_refData)->m_macRgn) +#define OTHER_M_REGION(a) (((wxRegionRefData*)(a.m_refData))->m_macRgn) //----------------------------------------------------------------------------- // wxRegion @@ -52,25 +57,30 @@ public: wxRegion::wxRegion() { m_refData = new wxRegionRefData; - // TODO create empty region +} + +wxRegion::wxRegion(WXHRGN hRegion ) +{ + m_refData = new wxRegionRefData; + CopyRgn( hRegion , M_REGION ) ; } wxRegion::wxRegion(long x, long y, long w, long h) { m_refData = new wxRegionRefData; - // TODO create rect region + SetRectRgn( M_REGION , x , y , x+w , y+h ) ; } wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight) { m_refData = new wxRegionRefData; - // TODO create rect region + SetRectRgn( M_REGION , topLeft.x , topLeft.y , bottomRight.x , bottomRight.y ) ; } wxRegion::wxRegion(const wxRect& rect) { m_refData = new wxRegionRefData; - // TODO create rect region + SetRectRgn( M_REGION , rect.x , rect.y , rect.x+rect.width , rect.y+rect.height ) ; } /*! @@ -95,41 +105,42 @@ void wxRegion::Clear() bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) { // Don't change shared data - if (!m_refData) { + if (!m_refData) + { m_refData = new wxRegionRefData(); - } else if (m_refData->GetRefCount() > 1) { + } + else if (m_refData->GetRefCount() > 1) + { wxRegionRefData* ref = (wxRegionRefData*)m_refData; UnRef(); m_refData = new wxRegionRefData(*ref); } - // If ref count is 1, that means it's 'ours' anyway so no action. - - // TODO create rect region - - int mode = 0; // TODO platform-specific code + RgnHandle rgn = NewRgn() ; + SetRectRgn( rgn , x , y, x+width,y + height ) ; + switch (op) { case wxRGN_AND: - // TODO + SectRgn( M_REGION , rgn , M_REGION ) ; break ; case wxRGN_OR: - // TODO + UnionRgn( M_REGION , rgn , M_REGION ) ; break ; case wxRGN_XOR: - // TODO + XorRgn( M_REGION , rgn , M_REGION ) ; break ; case wxRGN_DIFF: - // TODO + DiffRgn( M_REGION , rgn , M_REGION ) ; break ; case wxRGN_COPY: default: - // TODO + CopyRgn( rgn ,M_REGION ) ; break ; } - // TODO do combine region + DisposeRgn( rgn ) ; - return FALSE; + return TRUE; } //! Union /e region with this. @@ -141,36 +152,35 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) // Don't change shared data if (!m_refData) { m_refData = new wxRegionRefData(); - } else if (m_refData->GetRefCount() > 1) { + } + else if (m_refData->GetRefCount() > 1) + { wxRegionRefData* ref = (wxRegionRefData*)m_refData; UnRef(); m_refData = new wxRegionRefData(*ref); } - int mode = 0; // TODO platform-specific code switch (op) { case wxRGN_AND: - // TODO + SectRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; break ; case wxRGN_OR: - // TODO + UnionRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; break ; case wxRGN_XOR: - // TODO + XorRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; break ; case wxRGN_DIFF: - // TODO + DiffRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; break ; case wxRGN_COPY: default: - // TODO + CopyRgn( OTHER_M_REGION(region) ,M_REGION ) ; break ; } - // TODO combine region - - return FALSE; + return TRUE; } bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) @@ -185,9 +195,16 @@ bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) // Outer bounds of region void wxRegion::GetBox(long& x, long& y, long&w, long &h) const { - if (m_refData) { - // TODO get box - } else { + if (m_refData) + { + Rect box = (**M_REGION).rgnBBox ; + x = box.left ; + y = box.top ; + w = box.right - box.left ; + h = box.bottom - box.top ; + } + else + { x = y = w = h = 0; } } @@ -202,8 +219,12 @@ wxRect wxRegion::GetBox() const // Is region empty? bool wxRegion::Empty() const { - // TODO - return FALSE; + return EmptyRgn( M_REGION ) ; +} + +const WXHRGN wxRegion::GetWXHRGN() const +{ + return M_REGION ; } //----------------------------------------------------------------------------- @@ -228,11 +249,11 @@ wxRegionContain wxRegion::Contains(const wxPoint& pt) const if (!m_refData) return wxOutRegion; - // TODO. Return wxInRegion if within region. - if (0) + Point p = { pt.y , pt.x } ; + if (PtInRgn( p , M_REGION ) ) return wxInRegion; - else - return wxOutRegion; + + return wxOutRegion; } // Does the region contain the rectangle (x, y, w, h)? @@ -241,8 +262,8 @@ wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const if (!m_refData) return wxOutRegion; - // TODO. Return wxInRegion if within region. - if (0) + Rect rect = { y , x , y + h , x + w } ; + if (RectInRgn( &rect , M_REGION ) ) return wxInRegion; else return wxOutRegion; @@ -308,8 +329,14 @@ void wxRegionIterator::Reset(const wxRegion& region) m_numRects = 0; else { - // TODO create m_rects and fill with rectangles for this region - m_numRects = 0; + // we cannot dissolve it into rects on mac + m_rects = new wxRect[1]; + Rect rect = (**OTHER_M_REGION( region )).rgnBBox ; + m_rects[0].x = rect.left; + m_rects[0].y = rect.top; + m_rects[0].width = rect.right - rect.left; + m_rects[0].height = rect.bottom - rect.top; + m_numRects = 1; } } diff --git a/src/mac/scrolbar.cpp b/src/mac/scrolbar.cpp index a92154acfb..a432b3e9b1 100644 --- a/src/mac/scrolbar.cpp +++ b/src/mac/scrolbar.cpp @@ -14,6 +14,7 @@ #endif #include "wx/scrolbar.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl) @@ -23,6 +24,8 @@ END_EVENT_TABLE() #endif +extern ControlActionUPP wxMacLiveScrollbarActionUPP ; + // Scrollbar bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, @@ -30,21 +33,24 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - if (!parent) - return FALSE; - parent->AddChild(this); - SetName(name); - SetValidator(validator); + if (!parent) + return FALSE; - m_windowStyle = style; + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 100, + kControlScrollBarLiveProc , (long) this ) ; + + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + ::SetControlAction( m_macControl , wxMacLiveScrollbarActionUPP ) ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; + MacPostControlCreate() ; - // TODO create scrollbar - return TRUE; + return TRUE; } wxScrollBar::~wxScrollBar() @@ -53,13 +59,12 @@ wxScrollBar::~wxScrollBar() void wxScrollBar::SetThumbPosition(int viewStart) { - // TODO + ::SetControlValue( m_macControl , viewStart ) ; } int wxScrollBar::GetThumbPosition() const { - // TODO - return 0; + return ::GetControlValue( m_macControl ) ; } void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize, @@ -69,7 +74,19 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS m_pageSize = thumbSize; m_objectSize = range; - // TODO + int range1 = wxMax((m_objectSize - m_pageSize), 0) ; + + SetControlMaximum( m_macControl , range1 ) ; + SetControlMinimum( m_macControl , 0 ) ; + SetControlValue( m_macControl , position ) ; + + if ( UMAGetAppearanceVersion() >= 0x0110 ) + { +#if UMA_USE_8_6 + SetControlViewSize( m_macControl , m_pageSize ) ; +#endif + } + Refresh() ; } @@ -79,3 +96,62 @@ void wxScrollBar::Command(wxCommandEvent& event) ProcessCommand(event); } +void wxScrollBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + if ( m_macControl == NULL ) + return ; + + int position = GetControlValue( m_macControl) ; + int minPos = GetControlMinimum( m_macControl) ; + int maxPos = GetControlMaximum( m_macControl) ; + + wxEventType scrollEvent = wxEVT_NULL; + int nScrollInc; + + switch( controlpart ) + { + case kControlUpButtonPart : + nScrollInc = -1; + scrollEvent = wxEVT_SCROLL_LINEUP; + break ; + case kControlDownButtonPart : + nScrollInc = 1; + scrollEvent = wxEVT_SCROLL_LINEDOWN; + break ; + case kControlPageUpPart : + nScrollInc = -m_pageSize; + scrollEvent = wxEVT_SCROLL_PAGEUP; + break ; + case kControlPageDownPart : + nScrollInc = m_pageSize; + scrollEvent = wxEVT_SCROLL_PAGEDOWN; + break ; + case kControlIndicatorPart : + nScrollInc = 0 ; + scrollEvent = wxEVT_SCROLL_THUMBTRACK; + break ; + } + + int new_pos = position + nScrollInc; + + if (new_pos < 0) + new_pos = 0; + 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 ); + GetEventHandler()->ProcessEvent(event); +} + diff --git a/src/mac/settings.cpp b/src/mac/settings.cpp index 2beda5c2a6..b13b5733cc 100644 --- a/src/mac/settings.cpp +++ b/src/mac/settings.cpp @@ -17,39 +17,92 @@ wxColour wxSystemSettings::GetSystemColour(int index) { - // TODO - return wxColour(); + switch( index ) + { + case wxSYS_COLOUR_SCROLLBAR : + case wxSYS_COLOUR_BACKGROUND: + case wxSYS_COLOUR_ACTIVECAPTION: + case wxSYS_COLOUR_INACTIVECAPTION: + case wxSYS_COLOUR_MENU: + case wxSYS_COLOUR_WINDOW: + case wxSYS_COLOUR_WINDOWFRAME: + case wxSYS_COLOUR_ACTIVEBORDER: + case wxSYS_COLOUR_INACTIVEBORDER: + case wxSYS_COLOUR_BTNFACE: + return wxColor( 0xDD , 0xDD , 0xDD ) ; + break ; + + case wxSYS_COLOUR_BTNSHADOW: + return wxColor( 0x44 , 0x44 , 0x44 ) ; + break ; + + case wxSYS_COLOUR_BTNTEXT: + case wxSYS_COLOUR_MENUTEXT: + case wxSYS_COLOUR_WINDOWTEXT: + case wxSYS_COLOUR_CAPTIONTEXT: + case wxSYS_COLOUR_INFOTEXT: + case wxSYS_COLOUR_INACTIVECAPTIONTEXT: + return *wxBLACK; + break ; + case wxSYS_COLOUR_HIGHLIGHT: + { + RGBColor hilite ; + LMGetHiliteRGB(&hilite) ; + return wxColor( hilite.red >> 8 , hilite.green >> 8 , hilite.blue >> 8 ) ; + } + break ; + case wxSYS_COLOUR_BTNHIGHLIGHT: + case wxSYS_COLOUR_GRAYTEXT: + return wxColor( 0xCC , 0xCC , 0xCC ) ; + break ; + + case wxSYS_COLOUR_3DDKSHADOW: + return wxColor( 0x44 , 0x44 , 0x44 ) ; + break ; + case wxSYS_COLOUR_3DLIGHT: + return wxColor( 0xCC , 0xCC , 0xCC ) ; + break ; + case wxSYS_COLOUR_HIGHLIGHTTEXT : + { + RGBColor hilite ; + LMGetHiliteRGB(&hilite) ; + if ( ( hilite.red + hilite.green + hilite.blue ) == 0 ) + return *wxWHITE ; + else + return *wxBLACK ; + } + break ; + case wxSYS_COLOUR_INFOBK : + case wxSYS_COLOUR_APPWORKSPACE: + return *wxWHITE ; + break ; + } + return *wxWHITE; } wxFont wxSystemSettings::GetSystemFont(int index) { - // TODO switch (index) { - case wxSYS_DEVICE_DEFAULT_FONT: - { - break; - } - case wxSYS_DEFAULT_PALETTE: - { - break; - } - case wxSYS_SYSTEM_FIXED_FONT: - { - break; - } - case wxSYS_SYSTEM_FONT: - { - break; - } - default: - case wxSYS_DEFAULT_GUI_FONT: - { - break; - } + case wxSYS_ANSI_VAR_FONT : + case wxSYS_SYSTEM_FONT : + case wxSYS_DEVICE_DEFAULT_FONT : + case wxSYS_DEFAULT_GUI_FONT : + { + return *wxSMALL_FONT ; + } ; + break ; + case wxSYS_OEM_FIXED_FONT : + case wxSYS_ANSI_FIXED_FONT : + case wxSYS_SYSTEM_FIXED_FONT : + default : + { + return *wxNORMAL_FONT ; + } ; + break ; + } - - return wxFont(); + return *wxNORMAL_FONT; } // Get a system metric, e.g. scrollbar size @@ -58,11 +111,10 @@ int wxSystemSettings::GetSystemMetric(int index) switch ( index) { case wxSYS_MOUSE_BUTTONS: - // TODO - return 0; + return 2; // we emulate a two button mouse (ctrl + click = right button ) case wxSYS_BORDER_X: // TODO - return 0; + return 0; case wxSYS_BORDER_Y: // TODO return 0; @@ -91,14 +143,11 @@ int wxSystemSettings::GetSystemMetric(int index) // TODO return 0; case wxSYS_HSCROLL_ARROW_X: - // TODO - return 0; + return 16; case wxSYS_HSCROLL_ARROW_Y: - // TODO - return 0; + return 16; case wxSYS_HTHUMB_X: - // TODO - return 0; + return 16; case wxSYS_ICON_X: // TODO return 0; @@ -136,40 +185,33 @@ int wxSystemSettings::GetSystemMetric(int index) // TODO return 0; case wxSYS_HSCROLL_Y: - // TODO - return 0; + return 16; case wxSYS_VSCROLL_X: - // TODO - return 0; + return 16; case wxSYS_VSCROLL_ARROW_X: - // TODO - return 0; + return 16; case wxSYS_VSCROLL_ARROW_Y: - // TODO - return 0; + return 16; case wxSYS_VTHUMB_Y: - // TODO - return 0; + return 16; case wxSYS_CAPTION_Y: // TODO - return 0; + return 0; case wxSYS_MENU_Y: // TODO - return 0; + return 0; case wxSYS_NETWORK_PRESENT: // TODO - return 0; + return 0; case wxSYS_PENWINDOWS_PRESENT: - // TODO - return 0; + return 0; case wxSYS_SHOW_SOUNDS: // TODO return 0; case wxSYS_SWAP_BUTTONS: - // TODO - return 0; - default: - return 0; + return 0; + default: + return 0; } return 0; } diff --git a/src/mac/slider.cpp b/src/mac/slider.cpp index c9952342a9..936ccddb47 100644 --- a/src/mac/slider.cpp +++ b/src/mac/slider.cpp @@ -14,6 +14,7 @@ #endif #include "wx/slider.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl) @@ -34,6 +35,8 @@ wxSlider::wxSlider() m_tickFreq = 0; } +extern ControlActionUPP wxMacLiveScrollbarActionUPP ; + bool wxSlider::Create(wxWindow *parent, wxWindowID id, int value, int minValue, int maxValue, const wxPoint& pos, @@ -41,28 +44,92 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - - if (parent) parent->AddChild(this); + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - m_lineSize = 1; - m_windowStyle = style; - m_tickFreq = 0; + m_macMinimumStatic = NULL ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - m_rangeMax = maxValue; - m_rangeMin = minValue; - - m_pageSize = (int)((maxValue-minValue)/10); + m_lineSize = 1; + m_tickFreq = 0; - // TODO create slider + m_rangeMax = maxValue; + m_rangeMin = minValue; + + m_pageSize = (int)((maxValue-minValue)/10); + if ( m_width == -1 ) + { + m_width = 20 ; + if ( style & wxSL_LABELS && style & wxSL_VERTICAL ) + m_width += 24 ; + bounds.right = bounds.left + m_width ; + } + if ( m_height == -1 ) + { + m_height = 20 ; + if ( style & wxSL_LABELS && style & wxSL_HORIZONTAL ) + m_height += 24 ; + bounds.bottom = bounds.top + m_height ; + } + + if ( style & wxSL_LABELS && style & wxSL_HORIZONTAL ) + { + bounds.top += 12 ; + bounds.right -= 24 ; + } + + if ( style & wxSL_LABELS && style & wxSL_VERTICAL ) + { + bounds.left += 24 ; + bounds.top += 12 ; + } + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , value , minValue , maxValue, + kControlSliderProc + kControlSliderLiveFeedback + ( ( style & wxSL_AUTOTICKS ) ? kControlSliderHasTickMarks : 0 ) , (long) this ) ; + + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + ::SetControlAction( m_macControl , wxMacLiveScrollbarActionUPP ) ; + + MacPostControlCreate() ; + + if ( style & wxSL_LABELS ) + { + if ( style & wxSL_HORIZONTAL ) + { + wxSize size( 24 , 12 ) ; + wxPoint leftpos( 0 , 0 ) ; + wxPoint rightpos( m_width - 2 * 12 , 0 ) ; + wxPoint valuepos( m_width - 12 , 20 ) ; + wxString valuestring ; + + valuestring.Printf( "%d" , minValue ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , leftpos , size ) ; + valuestring.Printf( "%d" , maxValue ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , rightpos , size ) ; + valuestring.Printf( "%d" , value ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , valuepos , size ) ; + } + else + { + wxSize size( 24 , 12 ) ; + wxPoint toppos( 0 , 12 ) ; + wxPoint bottompos( 0 , m_height - 12 ) ; + wxPoint valuepos( 20 , 0 ) ; + wxString valuestring ; + + valuestring.Printf( "%d" , minValue ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , bottompos , size ) ; + valuestring.Printf( "%d" , maxValue ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , toppos , size ) ; + valuestring.Printf( "%d" , value ) ; + m_macMinimumStatic = new wxStaticText( this , -1 , valuestring , valuepos , size ) ; + } + } + + return TRUE; - return FALSE; } wxSlider::~wxSlider() @@ -71,28 +138,16 @@ wxSlider::~wxSlider() int wxSlider::GetValue() const { - // TODO - return 0; + return GetControlValue( m_macControl) ; } void wxSlider::SetValue(int value) { - // TODO -} - -void wxSlider::GetSize(int *width, int *height) const -{ - // TODO -} - -void wxSlider::GetPosition(int *x, int *y) const -{ - // TODO -} - -void wxSlider::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + wxString valuestring ; + valuestring.Printf( "%d" , value ) ; + if ( m_macMinimumStatic ) + m_macMinimumStatic->SetLabel( valuestring ) ; + SetControlValue( m_macControl , value ) ; } void wxSlider::SetRange(int minValue, int maxValue) @@ -182,9 +237,32 @@ void wxSlider::Command (wxCommandEvent & event) ProcessCommand (event); } -bool wxSlider::Show(bool show) +bool wxSlider::Show( bool show ) { - // TODO - return TRUE; + return wxWindow::Show( show ) ; } +void wxSlider::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + SInt16 value = ::GetControlValue( m_macControl ) ; + + SetValue( value ) ; + + wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); + event.SetPosition(GetControlValue( m_macControl) ); + event.SetEventObject( this ); + +#if WXWIN_COMPATIBILITY + + wxEventType oldEvent = event.GetEventType(); + event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED ); + if ( !GetEventHandler()->ProcessEvent(event) ) + { + event.SetEventType( oldEvent ); + if (!GetParent()->GetEventHandler()->ProcessEvent(event)) + event.Skip(); + } +#else + GetEventHandler()->ProcessEvent(event); +#endif +} diff --git a/src/mac/spinbutt.cpp b/src/mac/spinbutt.cpp index cbea725592..8f3e1533b8 100644 --- a/src/mac/spinbutt.cpp +++ b/src/mac/spinbutt.cpp @@ -14,6 +14,7 @@ #endif #include "wx/spinbutt.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl) @@ -28,19 +29,25 @@ wxSpinButton::wxSpinButton() bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - SetName(name); - - m_windowStyle = style; - - SetParent(parent); - m_min = 0; m_max = 100; - m_windowId = (id == -1) ? NewControlId() : id; + if (!parent) + return FALSE; + + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 100, + kControlLittleArrowsProc , (long) this ) ; + + wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ; + + MacPostControlCreate() ; - // TODO create spin button - return FALSE; + return TRUE; } wxSpinButton::~wxSpinButton() @@ -52,20 +59,23 @@ wxSpinButton::~wxSpinButton() int wxSpinButton::GetValue() const { - // TODO - return 0; + return m_value; } void wxSpinButton::SetValue(int val) { - // TODO + m_value = val ; + wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); + + event.SetPosition(m_value); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); } void wxSpinButton::SetRange(int minVal, int maxVal) { m_min = minVal; m_max = maxVal; - // TODO } // Spin event @@ -76,3 +86,49 @@ wxSpinEvent::wxSpinEvent(wxEventType commandType, int id): { } +void wxSpinButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + if ( m_macControl == NULL ) + return ; + + wxEventType scrollEvent = wxEVT_NULL; + int nScrollInc; + + switch( controlpart ) + { + case kControlUpButtonPart : + nScrollInc = 1; + scrollEvent = wxEVT_SCROLL_LINEUP; + break ; + case kControlDownButtonPart : + nScrollInc = -1; + scrollEvent = wxEVT_SCROLL_LINEDOWN; + break ; + } + + m_value = m_value + nScrollInc; + + if (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; + } + + wxScrollEvent event(scrollEvent, m_windowId); + + event.SetPosition(m_value); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); +} + + diff --git a/src/mac/statbmp.cpp b/src/mac/statbmp.cpp index a67c558465..721c254234 100644 --- a/src/mac/statbmp.cpp +++ b/src/mac/statbmp.cpp @@ -23,6 +23,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl) * wxStaticBitmap */ +BEGIN_EVENT_TABLE(wxStaticBitmap, wxControl) + EVT_PAINT(wxStaticBitmap::OnPaint) +END_EVENT_TABLE() + bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, @@ -41,19 +45,27 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id, m_windowStyle = style; - // TODO: create static bitmap control - return FALSE; + bool ret = wxControl::Create( parent, id, pos, size, style , name ); + + return ret; } void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; } void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) { m_messageBitmap = bitmap; - // TODO: redraw bitmap + Refresh() ; +} +void wxStaticBitmap::OnPaint( wxPaintEvent &event ) +{ + wxPaintDC dc(this); + PrepareDC(dc); + dc.SetPalette( *m_messageBitmap.GetPalette() ) ; + dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ; } diff --git a/src/mac/statbox.cpp b/src/mac/statbox.cpp index b239dc738c..abae14d07e 100644 --- a/src/mac/statbox.cpp +++ b/src/mac/statbox.cpp @@ -14,6 +14,7 @@ #endif #include "wx/statbox.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) @@ -35,28 +36,15 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - SetName(name); + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; - if (parent) parent->AddChild(this); + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlGroupBoxTextTitleProc , (long) this ) ; + + MacPostControlCreate() ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - m_windowStyle = style; - - // TODO: create static box - return FALSE; -} - -void wxStaticBox::SetLabel(const wxString& label) -{ - // TODO + return TRUE; } - -void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO -} - diff --git a/src/mac/stattext.cpp b/src/mac/stattext.cpp index 3b19c7184d..14c69f1d96 100644 --- a/src/mac/stattext.cpp +++ b/src/mac/stattext.cpp @@ -22,6 +22,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) #endif +#include + bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, @@ -29,32 +31,31 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - SetName(name); - if (parent) parent->AddChild(this); - - SetBackgroundColour(parent->GetBackgroundColour()) ; - SetForegroundColour(parent->GetForegroundColour()) ; - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; - - m_windowStyle = style; - - SetFont(parent->GetFont()); - - // TODO - return FALSE; -} - -void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + kControlStaticTextProc , (long) this ) ; + ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) title[0] , (char*) &title[1] ) ; + + MacPostControlCreate() ; + + return TRUE; } -void wxStaticText::SetLabel(const wxString& label) +void wxStaticText::SetLabel(const wxString& st , bool resize ) { - // TODO + m_label = st ; + wxString label ; + + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( st ) ; + else + label = st ; + + ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ; + Refresh() ; } diff --git a/src/mac/statusbr.cpp b/src/mac/statusbr.cpp index dff1ddec34..15ab99d5ac 100644 --- a/src/mac/statusbr.cpp +++ b/src/mac/statusbr.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#include "wx/stubs/statusbr.h" +#include "wx/mac/statusbr.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar); diff --git a/src/mac/tabctrl.cpp b/src/mac/tabctrl.cpp index b3b45a72d1..ea057aae52 100644 --- a/src/mac/tabctrl.cpp +++ b/src/mac/tabctrl.cpp @@ -15,6 +15,7 @@ #include "wx/control.h" #include "wx/tabctrl.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl) @@ -31,20 +32,18 @@ wxTabCtrl::wxTabCtrl() bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - m_imageList = NULL; - - SetName(name); - - m_windowStyle = style; + Rect bounds ; + Str255 title ; - SetParent(parent); + m_imageList = NULL; + + MacPreControlCreate( parent , id , "" , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; - m_windowId = (id < 0 ? NewControlId() : id); - - if (parent) parent->AddChild(this); - - // TODO: create tab control - return FALSE; + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + kControlTabSmallProc , (long) this ) ; + + MacPostControlCreate() ; + return TRUE ; } wxTabCtrl::~wxTabCtrl() diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index a2b5e7d38e..d553477f93 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -36,11 +36,14 @@ #endif #endif +#include "wx/mac/uma.h" + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) + EVT_CHAR(wxTextCtrl::OnChar) END_EVENT_TABLE() #endif @@ -54,67 +57,114 @@ wxTextCtrl::wxTextCtrl() } bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, - const wxString& value, + const wxString& st, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { - m_fileName = ""; - SetName(name); - SetValidator(validator); - if (parent) parent->AddChild(this); + m_macHorizontalBorder = 2 ; // additional pixels around the real control + m_macVerticalBorder = 2 ; - m_windowStyle = style; + wxSize mySize = size ; - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; + Rect bounds ; + Str255 title ; + + if ( mySize.y == -1 ) + { + if ( UMAHasAppearance() ) + mySize.y = 16 ; + else + mySize.y = 24 ; + } + MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; - return TRUE; + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + kControlEditTextProc , (long) this ) ; + MacPostControlCreate() ; + + wxString value ; + + if( wxApp::s_macDefaultEncodingIsPC ) + value = wxMacMakeMacStringFromPC( st ) ; + else + value = st ; + UMASetControlData( m_macControl, 0, kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + + return TRUE; } wxString wxTextCtrl::GetValue() const { - // TODO - return wxString(""); + Size actualsize; + UMAGetControlData( m_macControl, 0, kControlEditTextTextTag , 32767 , wxBuffer , &actualsize) ; + wxBuffer[actualsize] = 0 ; + if( wxApp::s_macDefaultEncodingIsPC ) + return wxMacMakePCStringFromMac( wxBuffer ) ; + else + return wxString(wxBuffer); } -void wxTextCtrl::SetValue(const wxString& value) +void wxTextCtrl::SetValue(const wxString& st) { - // TODO + wxString value ; + + if( wxApp::s_macDefaultEncodingIsPC ) + value = wxMacMakeMacStringFromPC( st ) ; + else + value = st ; + UMASetControlData( m_macControl, 0, kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; + Refresh() ; +// MacInvalidateControl() ; } void wxTextCtrl::SetSize(int x, int y, int width, int height, int sizeFlags) { - // TODO + wxControl::SetSize( x , y , width , height , sizeFlags ) ; } // Clipboard operations void wxTextCtrl::Copy() { - // TODO + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TECopy( teH ) ; } void wxTextCtrl::Cut() { - // TODO + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TECut( teH ) ; +// MacInvalidateControl() ; } void wxTextCtrl::Paste() { - // TODO + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TEPaste( teH ) ; +// MacInvalidateControl() ; } void wxTextCtrl::SetEditable(bool editable) { - // TODO + if ( editable ) + UMAActivateControl( m_macControl ) ; + else + UMADeactivateControl( m_macControl ) ; } void wxTextCtrl::SetInsertionPoint(long pos) { - // TODO + SetSelection( pos , pos ) ; } void wxTextCtrl::SetInsertionPointEnd() @@ -125,29 +175,72 @@ void wxTextCtrl::SetInsertionPointEnd() long wxTextCtrl::GetInsertionPoint() const { - // TODO - return 0; + ControlEditTextSelectionRec selection ; + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; +// UMAGetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; + return (**teH).selStart ; } long wxTextCtrl::GetLastPosition() const { - // TODO - return 0; + ControlEditTextSelectionRec selection ; + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + +// UMAGetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection , &size ) ; + return (**teH).teLength ; } void wxTextCtrl::Replace(long from, long to, const wxString& value) { - // TODO + TEHandle teH ; + long size ; + + ControlEditTextSelectionRec selection ; + + selection.selStart = from ; + selection.selEnd = to ; + UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TESetSelect( from , to , teH ) ; + TEDelete( teH ) ; + TEInsert( value , value.Length() , teH ) ; +// MacInvalidateControl() ; } void wxTextCtrl::Remove(long from, long to) { - // TODO + TEHandle teH ; + long size ; + + ControlEditTextSelectionRec selection ; + + selection.selStart = from ; + selection.selEnd = to ; + UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TEDelete( teH ) ; +// MacInvalidateControl() ; } void wxTextCtrl::SetSelection(long from, long to) { - // TODO + ControlEditTextSelectionRec selection ; + TEHandle teH ; + long size ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + + selection.selStart = from ; + selection.selEnd = to ; + + UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + TESetSelect( selection.selStart , selection.selEnd , teH ) ; } bool wxTextCtrl::LoadFile(const wxString& file) @@ -217,23 +310,44 @@ bool wxTextCtrl::SaveFile(const wxString& file) void wxTextCtrl::WriteText(const wxString& text) { - // TODO write text to control + TEHandle teH ; + long size ; + + memcpy( wxBuffer, text , text.Length() ) ; + wxBuffer[text.Length() ] = 0 ; +// wxMacConvertNewlines( wxBuffer , wxBuffer ) ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + + TEInsert( wxBuffer , strlen( wxBuffer) , teH ) ; + Refresh() ; } void wxTextCtrl::AppendText(const wxString& text) { - // TODO append text to control + SetInsertionPointEnd(); + WriteText(text); } void wxTextCtrl::Clear() { - // TODO + TEHandle teH ; + long size ; + ControlEditTextSelectionRec selection ; + + selection.selStart = 0 ; + selection.selEnd = 32767 ; + + UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; + + UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; + TECut( teH ) ; +// MacInvalidateControl() ; } bool wxTextCtrl::IsModified() const { - // TODO - return FALSE; + return TRUE; } // Makes 'unmodified' @@ -266,14 +380,12 @@ void wxTextCtrl::ShowPosition(long pos) int wxTextCtrl::GetLineLength(long lineNo) const { - // TODO - return 0; + return GetValue().Length(); } wxString wxTextCtrl::GetLineText(long lineNo) const { - // TODO - return wxString(""); + return GetValue(); } /* @@ -295,6 +407,76 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) } } +void wxTextCtrl::OnChar(wxKeyEvent& event) +{ + bool handleIt = true ; + switch( event.KeyCode() ) + { + case WXK_RETURN: + { +/* Oh yes it will, because we also specify DLGC_WANTCHARS + wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER, + "this text ctrl should never receive return" ); +*/ + + if ( (m_windowStyle & wxTE_MULTILINE) == 0 ) + { + wxWindow* parent = GetParent() ; + while( parent ) + { + if ( parent->GetDefaultItem() ) + { + wxButton *defaultBtn = parent->GetDefaultItem() ; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, defaultBtn->GetId() ); + event.SetEventObject(defaultBtn); + defaultBtn->Command(event); + return ; + } + parent = parent->GetParent() ; + } ; + } + break; + } + case WXK_TAB: + // only produce navigation event if we don't process TAB ourself or + // if it's a Shift-Tab keypress (we assume nobody will ever need + // this key combo for himself) + // + // NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is + // handled by Windows + if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) ) + { + wxNavigationKeyEvent eventNav; + eventNav.SetDirection(!event.ShiftDown()); + eventNav.SetWindowChange(FALSE); + eventNav.SetEventObject(this); + + if ( GetEventHandler()->ProcessEvent(eventNav) ) + return; + } + break; + } + if ( handleIt ) + { + EventRecord *ev = wxTheApp->MacGetCurrentEvent() ; + short keycode ; + short keychar ; + keychar = short(ev->message & charCodeMask); + keycode = short(ev->message & keyCodeMask) >> 8 ; + UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ; + if ( keychar >= 0x20 ) + { + { + wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId); + wxString val(GetValue()); + if ( !val.IsNull() ) + event.m_commandString = WXSTRINGCAST val; + event.SetEventObject( this ); + ProcessCommand(event); + } + } + } +} // The streambuf code was partly taken from chapter 3 by Jerry Schwarz of // AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 3cb859e366..0620c12afb 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -14,6 +14,9 @@ #endif #include "wx/wx.h" + +#if wxUSE_TOOLBAR + #include "wx/toolbar.h" #if !USE_SHARED_LIBRARY @@ -23,6 +26,8 @@ BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase) END_EVENT_TABLE() #endif +#include + wxToolBar::wxToolBar() { m_maxWidth = -1; @@ -35,22 +40,36 @@ wxToolBar::wxToolBar() bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { - m_maxWidth = -1; - m_maxHeight = -1; + m_maxWidth = -1; + m_maxHeight = -1; + + m_defaultWidth = 24; + m_defaultHeight = 22; - m_defaultWidth = 24; - m_defaultHeight = 22; - SetName(name); + int x = pos.x; + int y = pos.y; + int width = size.x; + int height = size.y; - m_windowStyle = style; + if (width <= 0) + width = 100; + if (height <= 0) + height = 30; + if (x < 0) + x = 0; + if (y < 0) + y = 0; - SetParent(parent); + Rect bounds ; + Str255 title ; + + MacPreControlCreate( parent , id , "" , wxPoint( x , y ) , wxSize( width , height ) ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; - if (parent) parent->AddChild(this); + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , "\p" , true , 0 , 0 , 1, + kControlPlacardProc , (long) this ) ; + MacPostControlCreate() ; - // TODO create toolbar - - return FALSE; + return TRUE; } wxToolBar::~wxToolBar() @@ -58,19 +77,143 @@ wxToolBar::~wxToolBar() // TODO } +PicHandle MakePict(GWorldPtr wp) +{ + CGrafPtr origPort ; + GDHandle origDev ; + + PicHandle pict; // this is the Picture we give back + + RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ; + + GetGWorld( &origPort , &origDev ) ; + SetGWorld( wp , NULL ) ; + + pict = OpenPicture(&wp->portRect); // open a picture, this disables drawing + if(!pict) + return NULL; + + RGBBackColor( &gray ) ; + EraseRect(&wp->portRect) ; + CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself - + (BitMap*)*wp->portPixMap, // dst PixMap - no drawing occurs - + &wp->portRect, // srcRect - it will be recorded and compressed - + &wp->portRect, // dstRect - into the picture that is open - + srcCopy,NULL); // copyMode and no clip region + + ClosePicture(); // We are done recording the picture + SetGWorld( origPort , origDev ) ; + return pict; // return our groovy pict handle +} + +PicHandle MakePictWhite(GWorldPtr wp) +{ + CGrafPtr origPort ; + GDHandle origDev ; + + PicHandle pict; // this is the Picture we give back + + RGBColor white = { 0xFFFF ,0xFFFF , 0xFFFF } ; + + GetGWorld( &origPort , &origDev ) ; + SetGWorld( wp , NULL ) ; + + pict = OpenPicture(&wp->portRect); // open a picture, this disables drawing + if(!pict) + return NULL; + + RGBBackColor( &white ) ; + EraseRect(&wp->portRect) ; + CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself - + (BitMap*)*wp->portPixMap, // dst PixMap - no drawing occurs - + &wp->portRect, // srcRect - it will be recorded and compressed - + &wp->portRect, // dstRect - into the picture that is open - + srcCopy,NULL); // copyMode and no clip region + + ClosePicture(); // We are done recording the picture + SetGWorld( origPort , origDev ) ; + return pict; // return our groovy pict handle +} + +const short kwxMacToolBarTopMargin = 2 ; +const short kwxMacToolBarLeftMargin = 2 ; + bool wxToolBar::CreateTools() { - if (m_tools.Number() == 0) - return FALSE; + if (m_tools.Number() == 0) + return FALSE; - // TODO - return FALSE; + Rect toolbarrect = { m_y , m_x , m_y + m_height , m_x + m_width } ; + ControlFontStyleRec controlstyle ; + WindowPtr window = GetMacRootWindow() ; + controlstyle.flags = kControlUseFontMask ; + controlstyle.font = kControlFontSmallSystemFont ; + + wxNode *node = m_tools.First(); + int noButtons = 0; + int x = 0 ; + + while (node) + { + wxToolBarTool *tool = (wxToolBarTool *)node->Data(); + wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->m_bitmap1.GetRefData()) ; + + if( tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR ) + { + Rect toolrect = { toolbarrect.top + kwxMacToolBarTopMargin , toolbarrect.left + x + kwxMacToolBarLeftMargin , 0 , 0 } ; + toolrect.right = toolrect.left + m_defaultWidth ; + toolrect.bottom = toolrect.top + m_defaultHeight ; + + PicHandle icon = NULL ; + if ( bmap ) + { + if ( bmap->m_bitmapType == kMacBitmapTypePict ) + icon = bmap->m_hPict ; + else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld ) + { + icon = MakePict( bmap->m_hBitmap ) ; + } + } + + ControlHandle m_macToolHandle ; + + if ( icon ) + { + m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 , + kControlBehaviorOffsetContents + kControlContentPictHandle , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; + ControlButtonContentInfo info ; + + info.contentType = kControlContentPictHandle ; + info.u.picture = icon ; + + UMASetControlData( m_macToolHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ; + } + else + { + m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 , + kControlBehaviorOffsetContents , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ; + } + m_macToolHandles.Add( m_macToolHandle ) ; + UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ; + UMAEmbedControl( m_macToolHandle , m_macControl ) ; + + x += (int)m_defaultWidth; + noButtons ++; + } + else + { + m_macToolHandles.Add( NULL ) ; + x += (int)m_defaultWidth / 4; + } + node = node->Next(); + } + + return TRUE; } void wxToolBar::SetToolBitmapSize(const wxSize& size) { m_defaultWidth = size.x; m_defaultHeight = size.y; - // TODO } wxSize wxToolBar::GetMaxSize() const @@ -82,10 +225,21 @@ wxSize wxToolBar::GetMaxSize() const // The button size is bigger than the bitmap size wxSize wxToolBar::GetToolSize() const { - // TODO return wxSize(m_defaultWidth + 8, m_defaultHeight + 7); } +void wxToolBar::MacHandleControlClick( ControlHandle control , SInt16 controlpart ) +{ + int index = 0 ; + for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) + { + if ( m_macToolHandles[index] == (void*) control ) + { + OnLeftClick( ( (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ) ->m_index , ( (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ) ->m_toggleState ) ; + } + } +} + void wxToolBar::EnableTool(int toolIndex, bool enable) { wxNode *node = m_tools.Find((long)toolIndex); @@ -137,9 +291,11 @@ wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBit else tool->m_y = m_yMargin; - tool->SetSize(GetDefaultButtonWidth(), GetDefaultButtonHeight()); + tool->SetSize(m_defaultWidth, m_defaultHeight); m_tools.Append((long)index, tool); return tool; } +#endif // wxUSE_TOOLBAR + diff --git a/src/mac/utils.cpp b/src/mac/utils.cpp index 940bdc21bc..817138cb63 100644 --- a/src/mac/utils.cpp +++ b/src/mac/utils.cpp @@ -196,7 +196,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, int *value, c } #endif // wxUSE_RESOURCES -static int wxBusyCursorCount = 0; +int wxBusyCursorCount = 0; +extern CursHandle gMacCurrentCursor ; +CursHandle gMacStoredActiveCursor = NULL ; // Set the cursor to the busy cursor for all windows void wxBeginBusyCursor(wxCursor *cursor) @@ -204,7 +206,8 @@ void wxBeginBusyCursor(wxCursor *cursor) wxBusyCursorCount ++; if (wxBusyCursorCount == 1) { - // TODO + gMacStoredActiveCursor = gMacCurrentCursor ; + ::SetCursor( *::GetCursor( watchCursor ) ) ; } else { @@ -221,7 +224,11 @@ void wxEndBusyCursor() wxBusyCursorCount --; if (wxBusyCursorCount == 0) { - // TODO + if ( gMacStoredActiveCursor ) + ::SetCursor( *gMacStoredActiveCursor ) ; + else + ::SetCursor( &qd.arrow ) ; + gMacStoredActiveCursor = NULL ; } } @@ -247,26 +254,40 @@ bool wxCheckForInterrupt(wxWindow *wnd) void wxGetMousePosition( int* x, int* y ) { - // TODO + Point pt ; + + GetMouse( &pt ) ; + LocalToGlobal( &pt ) ; + *x = pt.h ; + *y = pt.v ; }; // Return TRUE if we have a colour display bool wxColourDisplay() { - // TODO return TRUE; } // Returns depth of screen int wxDisplayDepth() { - // TODO - return 0; + // get max pixel depth + CGrafPtr port ; + GetCWMgrPort( &port ) ; + GDHandle maxDevice ; + + maxDevice = GetMaxDevice( &port->portRect ) ; + if ( maxDevice ) + return (**((**maxDevice).gdPMap)).pixelSize ; + else + return 8 ; } // Get size of display void wxDisplaySize(int *width, int *height) { - // TODO + *width = qd.screenBits.bounds.right - qd.screenBits.bounds.left ; + *height = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top ; + *height -= LMGetMBarHeight() ; } diff --git a/src/mac/wave.cpp b/src/mac/wave.cpp index c25681858c..804d07a097 100644 --- a/src/mac/wave.cpp +++ b/src/mac/wave.cpp @@ -15,7 +15,7 @@ #include "wx/object.h" #include "wx/string.h" -#include "wx/stubs/wave.h" +#include "wx/mac/wave.h" wxWave::wxWave() : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) diff --git a/src/mac/window.cpp b/src/mac/window.cpp index a54fd3331d..e8015acc3b 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -17,7 +17,7 @@ #include "wx/menu.h" #include "wx/dc.h" #include "wx/dcclient.h" -#include "wx/utils.h" +#include "wx/utils.h" #include "wx/app.h" #include "wx/panel.h" #include "wx/layout.h" @@ -27,10 +27,20 @@ #include "wx/settings.h" #include "wx/msgdlg.h" #include "wx/frame.h" +#include "wx/notebook.h" +#include "wx/tabctrl.h" +// TODO remove the line below, just for lookup-up convenience CS +#include "wx/mac/window.h" #include "wx/menuitem.h" #include "wx/log.h" +#define wxWINDOW_HSCROLL 5998 +#define wxWINDOW_VSCROLL 5997 +#define MAC_SCROLLBAR_SIZE 16 + +#include + #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" #endif @@ -38,6 +48,7 @@ #include extern wxList wxPendingDelete; +wxWindow* gFocusWindow = NULL ; #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler) @@ -48,6 +59,7 @@ BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler) EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) EVT_INIT_DIALOG(wxWindow::OnInitDialog) EVT_IDLE(wxWindow::OnIdle) + EVT_PAINT(wxWindow::OnPaint) END_EVENT_TABLE() #endif @@ -56,37 +68,58 @@ END_EVENT_TABLE() // Constructor wxWindow::wxWindow() { - // Generic - m_windowId = 0; - m_windowStyle = 0; - m_windowParent = NULL; - m_windowEventHandler = this; - m_windowName = ""; - m_windowCursor = *wxSTANDARD_CURSOR; - m_children = new wxList; - m_constraints = NULL; - m_constraintsInvolvedIn = NULL; - m_windowSizer = NULL; - m_sizerParent = NULL; - m_autoLayout = FALSE; - m_windowValidator = NULL; - m_defaultItem = NULL; - m_returnCode = 0; - m_caretWidth = 0; m_caretHeight = 0; - m_caretEnabled = FALSE; - m_caretShown = FALSE; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; - // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; - m_foregroundColour = *wxBLACK; + Init() ; +} + +void wxWindow::Init() +{ + m_macWindowData = NULL ; + m_isWindow = TRUE; + m_x = 0; + m_y = 0 ; + m_width = 0 ; + m_height = 0 ; + // these are the defaults for MSW + m_macShown = true ; + m_macEnabled = true ; + // Generic + m_windowId = 0; + m_windowStyle = 0; + m_windowParent = NULL; + m_windowEventHandler = this; + m_windowName = ""; + m_windowCursor = *wxSTANDARD_CURSOR; + m_children = new wxWindowList; + m_constraints = NULL; + m_constraintsInvolvedIn = NULL; + m_windowSizer = NULL; + m_sizerParent = NULL; + m_autoLayout = FALSE; + m_windowValidator = NULL; + m_defaultItem = NULL; + m_returnCode = 0; + m_caretWidth = 0; m_caretHeight = 0; + m_caretEnabled = FALSE; + m_caretShown = FALSE; + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; + // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; + m_foregroundColour = *wxBLACK; + m_hScrollBar = NULL ; + m_vScrollBar = NULL ; + m_mouseInWindow = FALSE; #if wxUSE_DRAG_AND_DROP - m_pDropTarget = NULL; + m_pDropTarget = NULL; #endif } // Destructor wxWindow::~wxWindow() { + if ( s_lastMouseWindow == this ) + { + s_lastMouseWindow = NULL ; + } // Have to delete constraints/sizer FIRST otherwise // sizers may try to look at deleted windows as they // delete themselves. @@ -110,12 +143,24 @@ wxWindow::~wxWindow() m_sizerParent->RemoveChild((wxWindow *)this); #endif + if ( FindFocus() == this ) + { + // really a bad thing - maybe an error ? + // we cannot even send it a kill focus message at this stage + gFocusWindow = NULL ; + } + if (m_windowParent) m_windowParent->RemoveChild(this); DestroyChildren(); - // TODO: destroy the window + if ( m_macWindowData ) + { + UMADisposeWindow( m_macWindowData->m_macWindow ) ; + delete m_macWindowData ; + wxRemoveMacWindowAssociation( this ) ; + } delete m_children; m_children = NULL; @@ -143,7 +188,8 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { - // Generic + m_isWindow = TRUE; + // Generic m_windowId = 0; m_windowStyle = 0; m_windowParent = NULL; @@ -182,7 +228,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, if ( id == -1 ) m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ; m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ; @@ -193,31 +239,68 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, if ( id == -1 ) m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; - // TODO: create the window + m_x = (int)pos.x; + m_y = (int)pos.y; + AdjustForParentClientOrigin(m_x, m_y, wxSIZE_USE_EXISTING); + m_width = size.x; + m_height = size.y; + + MacCreateScrollBars( style ) ; return TRUE; } void wxWindow::SetFocus() { - // TODO + if ( AcceptsFocus() ) + { + if (gFocusWindow ) + { + wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ; + if ( control && control->GetMacControl() ) + { + UMASetKeyboardFocus( gFocusWindow->GetMacRootWindow() , control->GetMacControl() , kControlFocusNoPart ) ; + } + wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId); + event.SetEventObject(gFocusWindow); + gFocusWindow->GetEventHandler()->ProcessEvent(event) ; + } + gFocusWindow = this ; + { + wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ; + if ( control && control->GetMacControl() ) + { + UMASetKeyboardFocus( gFocusWindow->GetMacRootWindow() , control->GetMacControl() , kControlEditTextPart ) ; + } + + wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event) ; + } + } } void wxWindow::Enable(bool enable) { - // TODO + if ( m_macEnabled == enable ) + return ; + + m_macEnabled = enable ; + + MacSuperEnabled( enable ) ; + return; } void wxWindow::CaptureMouse() { - // TODO + wxTheApp->s_captureWindow = this ; } void wxWindow::ReleaseMouse() { - // TODO + wxTheApp->s_captureWindow = NULL ; } // Push/pop event handler (i.e. allow a chain of event handlers @@ -274,22 +357,85 @@ void wxWindow::DragAcceptFiles(bool accept) // Get total size void wxWindow::GetSize(int *x, int *y) const { - // TODO + *x = m_width ; + *y = m_height ; } void wxWindow::GetPosition(int *x, int *y) const { - // TODO + *x = m_x ; + *y = m_y ; + if (GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + *x -= pt.x; + *y -= pt.y; + } } void wxWindow::ScreenToClient(int *x, int *y) const { - // TODO + WindowRef window = GetMacRootWindow() ; + + Point localwhere ; + localwhere.h = * x ; + localwhere.v = * y ; + + GrafPtr port ; + ::GetPort( &port ) ; + ::SetPort( UMAGetWindowPort( window ) ) ; + ::GlobalToLocal( &localwhere ) ; + ::SetPort( port ) ; + + *x = localwhere.h ; + *y = localwhere.v ; + + MacRootWindowToClient( x , y ) ; } void wxWindow::ClientToScreen(int *x, int *y) const { - // TODO + WindowRef window = GetMacRootWindow() ; + + MacClientToRootWindow( x , y ) ; + + Point localwhere ; + localwhere.h = * x ; + localwhere.v = * y ; + + GrafPtr port ; + ::GetPort( &port ) ; + ::SetPort( UMAGetWindowPort( window ) ) ; + ::LocalToGlobal( &localwhere ) ; + ::SetPort( port ) ; + *x = localwhere.h ; + *y = localwhere.v ; +} + +void wxWindow::MacClientToRootWindow( int *x , int *y ) const +{ + if ( m_macWindowData ) + { + } + else + { + *x += m_x ; + *y += m_y ; + GetParent()->MacClientToRootWindow( x , y ) ; + } +} + +void wxWindow::MacRootWindowToClient( int *x , int *y ) const +{ + if ( m_macWindowData ) + { + } + else + { + *x -= m_x ; + *y -= m_y ; + GetParent()->MacRootWindowToClient( x , y ) ; + } } void wxWindow::SetCursor(const wxCursor& cursor) @@ -297,7 +443,9 @@ void wxWindow::SetCursor(const wxCursor& cursor) m_windowCursor = cursor; if (m_windowCursor.Ok()) { - // TODO + // since this only affects the window-cursor, we adopt the same + // behaviour as windows -> it will only change on mouse moved events + // otherwise the ::WxSetCursor routine will have to be used } } @@ -305,21 +453,132 @@ void wxWindow::SetCursor(const wxCursor& cursor) // Get size *available for subwindows* i.e. excluding menu bar etc. void wxWindow::GetClientSize(int *x, int *y) const { - // TODO -} + *x = m_width ; + *y = m_height ; + + if (m_vScrollBar && m_vScrollBar->IsShown() ) + (*x) -= MAC_SCROLLBAR_SIZE; + if (m_hScrollBar && m_hScrollBar->IsShown() ) + (*y) -= MAC_SCROLLBAR_SIZE; +} + +void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) +{ + int former_x = m_x ; + int former_y = m_y ; + int former_w = m_width ; + int former_h = m_height ; + + int currentX, currentY; + GetPosition(¤tX, ¤tY); + int currentW,currentH; + GetSize(¤tW, ¤tH); + + int actualWidth = width; + int actualHeight = height; + int actualX = x; + int actualY = y; + if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + actualX = currentX; + if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + actualY = currentY; + if (width == -1) + actualWidth = currentW ; + if (height == -1) + actualHeight = currentH ; + + if ( actualX == currentX && actualY == currentY && actualWidth == currentW && actualHeight == currentH) + { + MacRepositionScrollBars() ; // we might have a real position shift + return ; + } -void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags) -{ - // TODO -} + AdjustForParentClientOrigin(actualX, actualY, sizeFlags); + + + bool doMove = false ; + bool doResize = false ; + + if ( actualX != former_x || actualY != former_y ) + { + doMove = true ; + } + if ( actualWidth != former_w || actualHeight != former_h ) + { + doResize = true ; + } -void wxWindow::SetClientSize(int width, int height) -{ - // TODO + if ( doMove || doResize ) + { + if ( m_macWindowData ) + { + } + else + { + // erase former position + { + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + Rect clientrect = { 0 , 0 , m_height , m_width } ; + InvalRect( &clientrect ) ; + } + } + } + m_x = actualX ; + m_y = actualY ; + m_width = actualWidth ; + m_height = actualHeight ; + if ( m_macWindowData ) + { + if ( doMove ) + ::MoveWindow(m_macWindowData->m_macWindow, m_x, m_y, false); // don't make frontmost + + if ( doResize ) + ::SizeWindow(m_macWindowData->m_macWindow, m_width, m_height, true); + + // the OS takes care of invalidating and erasing + + if ( IsKindOf( CLASSINFO( wxFrame ) ) ) + { + wxFrame* frame = (wxFrame*) this ; + frame->PositionStatusBar(); + frame->PositionToolBar(); + } + } + else + { + // erase new position + { + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + Rect clientrect = { 0 , 0 , m_height , m_width } ; + InvalRect( &clientrect ) ; + } + } + if ( doMove ) + wxWindow::MacSuperChangedPosition() ; // like this only children will be notified + } + MacRepositionScrollBars() ; + if ( doMove ) + { + wxMoveEvent event(wxPoint(m_x, m_y), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event) ; + } + if ( doResize ) + { + MacRepositionScrollBars() ; + wxSizeEvent event(wxSize(m_width, m_height), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + } } - // For implementation purposes - sometimes decorations make the client area // smaller + wxPoint wxWindow::GetClientAreaOrigin() const { return wxPoint(0, 0); @@ -329,35 +588,118 @@ wxPoint wxWindow::GetClientAreaOrigin() const // a toolbar that it manages itself). void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) { + if( !m_macWindowData ) + { if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) { wxPoint pt(GetParent()->GetClientAreaOrigin()); x += pt.x; y += pt.y; } + } +} + +void wxWindow::SetTitle(const wxString& title) +{ + wxString label ; + + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakeMacStringFromPC( title ) ; + else + label = title ; + + if ( m_macWindowData ) + UMASetWTitleC( m_macWindowData->m_macWindow , label ) ; +} + +wxString wxWindow::GetTitle() const +{ + if ( m_macWindowData ) + { + char title[256] ; + wxString label ; + UMAGetWTitleC( m_macWindowData->m_macWindow , title ) ; + if( wxApp::s_macDefaultEncodingIsPC ) + label = wxMacMakePCStringFromMac( title ) ; + else + label = title ; + return label; + } + + return wxEmptyString ; +} + +void wxWindow::Centre(int direction) +{ + int x_offset,y_offset ; + int display_width, display_height; + int width, height, x, y; + wxWindow *parent = GetParent(); + if ((direction & wxCENTER_FRAME) && parent) + { + parent->GetPosition(&x_offset,&y_offset) ; + parent->GetSize(&display_width,&display_height) ; + } + else + { + wxDisplaySize(&display_width, &display_height); + x_offset = 0 ; + y_offset = LMGetMBarHeight() + LMGetMBarHeight() / 2 ; // approx. the window title height + } + + GetSize(&width, &height); + GetPosition(&x, &y); + + if (direction & wxHORIZONTAL) + x = (int)((display_width - width)/2); + if (direction & wxVERTICAL) + y = (int)((display_height - height)/2); + + SetSize(x+x_offset, y+y_offset, width, height); } + bool wxWindow::Show(bool show) { - // TODO - return FALSE; + if ( m_macShown == show ) + return TRUE ; + + m_macShown = show ; + if ( m_macWindowData ) + { + if (show) + { + UMAShowWindow( m_macWindowData->m_macWindow ) ; + UMASelectWindow( m_macWindowData->m_macWindow ) ; + // no need to generate events here, they will get them triggered by macos + wxSizeEvent event(wxSize(m_width, m_height), m_windowId); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } + else + { + UMAHideWindow( m_macWindowData->m_macWindow ) ; + } + } + Refresh() ; + MacSuperShown( show ) ; + return TRUE; } bool wxWindow::IsShown() const { - // TODO - return FALSE; + return m_macShown; } int wxWindow::GetCharHeight() const { - // TODO - return 0; + wxClientDC dc ( (wxWindow*)this ) ; + return dc.GetCharHeight() ; } int wxWindow::GetCharWidth() const { - // TODO - return 0; + wxClientDC dc ( (wxWindow*)this ) ; + return dc.GetCharWidth() ; } void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, @@ -370,9 +712,104 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, // TODO } +void wxWindow::MacEraseBackground( Rect *rect ) +{ + WindowRef window = GetMacRootWindow() ; + if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) ) + { + UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ; + } + else if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) ) + { + // 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 + + wxWindow* parent = GetParent() ; + while( parent ) + { + if ( parent->m_backgroundColour != wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) ) + { + // if we have any other colours in the hierarchy + RGBBackColor( &parent->m_backgroundColour.GetPixel()) ; + break ; + } + if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() ) + { + // 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 ) )) + { + ApplyThemeBackground (kThemeBackgroundTabPane, rect, kThemeStateActive,8,true); + break ; + } + } + else + { + // we have arrived at a non control item + parent = NULL ; + break ; + } + parent = parent->GetParent() ; + } + if ( !parent ) + { + // if there is nothing special -> use default + UMASetThemeWindowBackground( window , kThemeBrushDialogBackgroundActive , false ) ; + } + } + else + { + RGBBackColor( &m_backgroundColour.GetPixel()) ; + } + + EraseRect( rect ) ; + + for (wxNode *node = m_children->First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); +// int width ; +// int height ; + +// child->GetClientSize( &width , &height ) ; + + Rect clientrect = { child->m_x , child->m_y , child->m_x +child->m_width , child->m_y + child->m_height } ; + SectRect( &clientrect , rect , &clientrect ) ; + + OffsetRect( &clientrect , -child->m_x , -child->m_y ) ; + if ( child->GetMacRootWindow() == window && child->IsReallyShown() ) + { + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + child->MacEraseBackground( &clientrect ) ; + } + } + } +} + void wxWindow::Refresh(bool eraseBack, const wxRect *rect) { - // TODO + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + int width , height ; + GetClientSize( &width , &height ) ; + Rect clientrect = { 0 , 0 , height , width } ; + ClipRect( &clientrect ) ; + + if ( rect ) + { + Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ; + SectRect( &clientrect , &r , &clientrect ) ; + } + InvalRect( &clientrect ) ; + /* + if ( eraseBack ) + { + MacEraseBackground( &clientrect ) ; + } + */ + } } // Responds to colour changes: passes event on to children. @@ -451,7 +888,7 @@ void wxWindow::GetCaretPos(int *x, int *y) const wxWindow *wxGetActiveWindow() { - // TODO + // actually this is a windows-only concept return NULL; } @@ -463,46 +900,31 @@ void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED m_maxSizeY = maxH; } -void wxWindow::Centre(int direction) -{ - int x, y, width, height, panel_width, panel_height, new_x, new_y; - - wxWindow *father = (wxWindow *)GetParent(); - if (!father) - return; - - father->GetClientSize(&panel_width, &panel_height); - GetSize(&width, &height); - GetPosition(&x, &y); - - new_x = -1; - new_y = -1; - - if (direction & wxHORIZONTAL) - new_x = (int)((panel_width - width)/2); - - if (direction & wxVERTICAL) - new_y = (int)((panel_height - height)/2); - - SetSize(new_x, new_y, -1, -1); - -} // Coordinates relative to the window void wxWindow::WarpPointer (int x_pos, int y_pos) { - // TODO + // We really dont move the mouse programmatically under mac } void wxWindow::OnEraseBackground(wxEraseEvent& event) { - // TODO + // TODO : probably we would adopt the EraseEvent structure Default(); } int wxWindow::GetScrollPos(int orient) const { - // TODO + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + return m_hScrollBar->GetThumbPosition() ; + } + else + { + if ( m_vScrollBar ) + return m_vScrollBar->GetThumbPosition() ; + } return 0; } @@ -510,34 +932,110 @@ int wxWindow::GetScrollPos(int orient) const // of positions that we can scroll. int wxWindow::GetScrollRange(int orient) const { - // TODO + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + return m_hScrollBar->GetRange() ; + } + else + { + if ( m_vScrollBar ) + return m_vScrollBar->GetRange() ; + } return 0; } int wxWindow::GetScrollThumb(int orient) const { - // TODO + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + return m_hScrollBar->GetThumbSize() ; + } + else + { + if ( m_vScrollBar ) + return m_vScrollBar->GetThumbSize() ; + } return 0; } void wxWindow::SetScrollPos(int orient, int pos, bool refresh) { - // TODO - return; + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + m_hScrollBar->SetThumbPosition( pos ) ; + } + else + { + if ( m_vScrollBar ) + m_vScrollBar->SetThumbPosition( pos ) ; + } } // New function that will replace some of the above. void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, int range, bool refresh) { - // TODO + if ( orient == wxHORIZONTAL ) + { + if ( m_hScrollBar ) + { + 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 , refresh ) ; + } + } + } + else + { + if ( m_vScrollBar ) + { + 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 , refresh ) ; + } + } + } + MacRepositionScrollBars() ; } // Does a physical scroll void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) { - // TODO - return; + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + int width , height ; + GetClientSize( &width , &height ) ; + Rect scrollrect = { 0 , 0 , height , width } ; + + RgnHandle updateRgn = NewRgn() ; + ClipRect( &scrollrect ) ; + if ( rect ) + { + Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ; + SectRect( &scrollrect , &r , &scrollrect ) ; + } + ScrollRect( &scrollrect , dx , dy , updateRgn ) ; + InvalRgn( updateRgn ) ; + DisposeRgn( updateRgn ) ; + } } void wxWindow::SetFont(const wxFont& font) @@ -563,13 +1061,31 @@ void wxWindow::OnChar(wxKeyEvent& event) void wxWindow::OnPaint(wxPaintEvent& event) { - Default(); +/* + if ( m_macWindowData ) + { + wxMacDrawingClientHelper helper ( this ) ; + long x ,y ,w ,h ; + GetUpdateRegion().GetBox( x , y , w , h ) ; + UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ; + Rect r = { y , x, y+h , x+w } ; + EraseRect( &r ) ; + } + else + { + wxMacDrawingClientHelper helper ( this ) ; + long x ,y ,w ,h ; + GetUpdateRegion().GetBox( x , y , w , h ) ; + RGBBackColor( &m_backgroundColour.GetPixel() ) ; + Rect r = { y , x, y+h , x+w } ; + EraseRect( &r ) ; + } +*/ } bool wxWindow::IsEnabled() const { - // TODO - return FALSE; + return m_macEnabled ; } // Dialog support: override these and call @@ -636,8 +1152,16 @@ bool wxWindow::Validate() // Get the window with the focus wxWindow *wxWindow::FindFocus() { - // TODO - return NULL; + return gFocusWindow ; +} + +// ---------------------------------------------------------------------------- +// RTTI +// ---------------------------------------------------------------------------- + +bool wxWindow::IsTopLevel() const +{ + return wxDynamicCast(this, wxFrame) || wxDynamicCast(this, wxDialog); } void wxWindow::AddChild(wxWindow *child) @@ -659,7 +1183,7 @@ void wxWindow::DestroyChildren() wxWindow *child; if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) { delete child; - if ( GetChildren().Member(child) ) + if ( GetChildren().Find(child) ) delete node; } } /* while */ @@ -693,419 +1217,384 @@ void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event) m_windowParent->GetEventHandler()->OnCommand(win, event); } -void wxWindow::SetConstraints(wxLayoutConstraints *c) +// ---------------------------------------------------------------------------- +// constraints and sizers +// ---------------------------------------------------------------------------- + +#if wxUSE_CONSTRAINTS + +void wxWindow::SetConstraints( wxLayoutConstraints *constraints ) { - if (m_constraints) - { - UnsetConstraints(m_constraints); - delete m_constraints; - } - m_constraints = c; - if (m_constraints) - { - // Make sure other windows know they're part of a 'meaningful relationship' - if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this)) - m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this)) - m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this)) - m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this)) - m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this)) - m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this)) - m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this)) - m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this)) - m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this); - } + if ( m_constraints ) + { + UnsetConstraints(m_constraints); + delete m_constraints; + } + m_constraints = constraints; + if ( m_constraints ) + { + // Make sure other windows know they're part of a 'meaningful relationship' + if ( m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this) ) + m_constraints->left.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this) ) + m_constraints->top.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this) ) + m_constraints->right.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this) ) + m_constraints->bottom.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this) ) + m_constraints->width.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this) ) + m_constraints->height.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this) ) + m_constraints->centreX.GetOtherWindow()->AddConstraintReference(this); + if ( m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this) ) + m_constraints->centreY.GetOtherWindow()->AddConstraintReference(this); + } } -// This removes any dangling pointers to this window -// in other windows' constraintsInvolvedIn lists. +// This removes any dangling pointers to this window in other windows' +// constraintsInvolvedIn lists. void wxWindow::UnsetConstraints(wxLayoutConstraints *c) { - if (c) - { - if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this)) - c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this)) - c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this)) - c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this)) - c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this)) - c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this)) - c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this)) - c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this)) - c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); - } + if ( c ) + { + if ( c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) + c->left.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this) ) + c->top.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this) ) + c->right.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this) ) + c->bottom.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this) ) + c->width.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this) ) + c->height.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this) ) + c->centreX.GetOtherWindow()->RemoveConstraintReference(this); + if ( c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this) ) + c->centreY.GetOtherWindow()->RemoveConstraintReference(this); + } } -// Back-pointer to other windows we're involved with, so if we delete -// this window, we must delete any constraints we're involved with. +// Back-pointer to other windows we're involved with, so if we delete this +// window, we must delete any constraints we're involved with. void wxWindow::AddConstraintReference(wxWindow *otherWin) { - if (!m_constraintsInvolvedIn) - m_constraintsInvolvedIn = new wxList; - if (!m_constraintsInvolvedIn->Member(otherWin)) - m_constraintsInvolvedIn->Append(otherWin); + if ( !m_constraintsInvolvedIn ) + m_constraintsInvolvedIn = new wxWindowList; + if ( !m_constraintsInvolvedIn->Find(otherWin) ) + m_constraintsInvolvedIn->Append(otherWin); } // REMOVE back-pointer to other windows we're involved with. void wxWindow::RemoveConstraintReference(wxWindow *otherWin) { - if (m_constraintsInvolvedIn) - m_constraintsInvolvedIn->DeleteObject(otherWin); + if ( m_constraintsInvolvedIn ) + m_constraintsInvolvedIn->DeleteObject(otherWin); } // Reset any constraints that mention this window void wxWindow::DeleteRelatedConstraints() { - if (m_constraintsInvolvedIn) - { - wxNode *node = m_constraintsInvolvedIn->First(); - while (node) + if ( m_constraintsInvolvedIn ) { - wxWindow *win = (wxWindow *)node->Data(); - wxNode *next = node->Next(); - wxLayoutConstraints *constr = win->GetConstraints(); - - // Reset any constraints involving this window - if (constr) - { - constr->left.ResetIfWin((wxWindow *)this); - constr->top.ResetIfWin((wxWindow *)this); - constr->right.ResetIfWin((wxWindow *)this); - constr->bottom.ResetIfWin((wxWindow *)this); - constr->width.ResetIfWin((wxWindow *)this); - constr->height.ResetIfWin((wxWindow *)this); - constr->centreX.ResetIfWin((wxWindow *)this); - constr->centreY.ResetIfWin((wxWindow *)this); - } - delete node; - node = next; + wxWindowList::Node *node = m_constraintsInvolvedIn->GetFirst(); + while (node) + { + wxWindow *win = node->GetData(); + wxLayoutConstraints *constr = win->GetConstraints(); + + // Reset any constraints involving this window + if ( constr ) + { + constr->left.ResetIfWin(this); + constr->top.ResetIfWin(this); + constr->right.ResetIfWin(this); + constr->bottom.ResetIfWin(this); + constr->width.ResetIfWin(this); + constr->height.ResetIfWin(this); + constr->centreX.ResetIfWin(this); + constr->centreY.ResetIfWin(this); + } + + wxWindowList::Node *next = node->GetNext(); + delete node; + node = next; + } + + delete m_constraintsInvolvedIn; + m_constraintsInvolvedIn = (wxWindowList *) NULL; } - delete m_constraintsInvolvedIn; - m_constraintsInvolvedIn = NULL; - } } void wxWindow::SetSizer(wxSizer *sizer) { - m_windowSizer = sizer; - if (sizer) - sizer->SetSizerParent((wxWindow *)this); + if (m_windowSizer) delete m_windowSizer; + + m_windowSizer = sizer; } -/* - * New version - */ - bool wxWindow::Layout() { - if (GetConstraints()) - { int w, h; GetClientSize(&w, &h); - GetConstraints()->width.SetValue(w); - GetConstraints()->height.SetValue(h); - } - - // If top level (one sizer), evaluate the sizer's constraints. - if (GetSizer()) - { - int noChanges; - GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated - GetSizer()->LayoutPhase1(&noChanges); - GetSizer()->LayoutPhase2(&noChanges); - GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes - return TRUE; - } - else - { - // Otherwise, evaluate child constraints + + // If there is a sizer, use it instead of the constraints + if ( GetSizer() ) + { + GetSizer()->SetDimension( 0, 0, w, h ); + return TRUE; + } + + if ( GetConstraints() ) + { + GetConstraints()->width.SetValue(w); + GetConstraints()->height.SetValue(h); + } + + // Evaluate child constraints ResetConstraints(); // Mark all constraints as unevaluated DoPhase(1); // Just one phase need if no sizers involved DoPhase(2); SetConstraintSizes(); // Recursively set the real window sizes - } - return TRUE; + + return TRUE; } -// Do a phase of evaluating constraints: -// the default behaviour. wxSizers may do a similar -// thing, but also impose their own 'constraints' -// and order the evaluation differently. +// Do a phase of evaluating constraints: the default behaviour. wxSizers may +// do a similar thing, but also impose their own 'constraints' and order the +// evaluation differently. bool wxWindow::LayoutPhase1(int *noChanges) { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - return constr->SatisfyConstraints((wxWindow *)this, noChanges); - } - else - return TRUE; + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + return constr->SatisfyConstraints(this, noChanges); + } + else + return TRUE; } bool wxWindow::LayoutPhase2(int *noChanges) { - *noChanges = 0; - - // Layout children - DoPhase(1); - DoPhase(2); - return TRUE; + *noChanges = 0; + + // Layout children + DoPhase(1); + DoPhase(2); + return TRUE; } // Do a phase of evaluating child constraints bool wxWindow::DoPhase(int phase) { - int noIterations = 0; - int maxIterations = 500; - int noChanges = 1; - int noFailures = 0; - wxList succeeded; - while ((noChanges > 0) && (noIterations < maxIterations)) - { - noChanges = 0; - noFailures = 0; - wxNode *node = GetChildren().First(); - while (node) + int noIterations = 0; + int maxIterations = 500; + int noChanges = 1; + int noFailures = 0; + wxWindowList succeeded; + while ((noChanges > 0) && (noIterations < maxIterations)) { - wxWindow *child = (wxWindow *)node->Data(); - if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog))) - { - wxLayoutConstraints *constr = child->GetConstraints(); - if (constr) + noChanges = 0; + noFailures = 0; + wxWindowList::Node *node = GetChildren().GetFirst(); + while (node) { - if (succeeded.Member(child)) - { - } - else - { - int tempNoChanges = 0; - bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; - noChanges += tempNoChanges; - if (success) + wxWindow *child = node->GetData(); + if ( !child->IsTopLevel() ) { - succeeded.Append(child); + wxLayoutConstraints *constr = child->GetConstraints(); + if ( constr ) + { + if ( !succeeded.Find(child) ) + { + int tempNoChanges = 0; + bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; + noChanges += tempNoChanges; + if ( success ) + { + succeeded.Append(child); + } + } + } } - } + node = node->GetNext(); } - } - node = node->Next(); + + noIterations++; } - noIterations ++; - } - return TRUE; + + return TRUE; } void wxWindow::ResetConstraints() { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - constr->left.SetDone(FALSE); - constr->top.SetDone(FALSE); - constr->right.SetDone(FALSE); - constr->bottom.SetDone(FALSE); - constr->width.SetDone(FALSE); - constr->height.SetDone(FALSE); - constr->centreX.SetDone(FALSE); - constr->centreY.SetDone(FALSE); - } - wxNode *node = GetChildren().First(); - while (node) - { - wxWindow *win = (wxWindow *)node->Data(); - if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) - win->ResetConstraints(); - node = node->Next(); - } + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + constr->left.SetDone(FALSE); + constr->top.SetDone(FALSE); + constr->right.SetDone(FALSE); + constr->bottom.SetDone(FALSE); + constr->width.SetDone(FALSE); + constr->height.SetDone(FALSE); + constr->centreX.SetDone(FALSE); + constr->centreY.SetDone(FALSE); + } + wxWindowList::Node *node = GetChildren().GetFirst(); + while (node) + { + wxWindow *win = node->GetData(); + if ( !win->IsTopLevel() ) + win->ResetConstraints(); + node = node->GetNext(); + } } -// Need to distinguish between setting the 'fake' size for -// windows and sizers, and setting the real values. +// Need to distinguish between setting the 'fake' size for windows and sizers, +// and setting the real values. void wxWindow::SetConstraintSizes(bool recurse) { - wxLayoutConstraints *constr = GetConstraints(); - if (constr && constr->left.GetDone() && constr->right.GetDone() && - constr->width.GetDone() && constr->height.GetDone()) - { - int x = constr->left.GetValue(); - int y = constr->top.GetValue(); - int w = constr->width.GetValue(); - int h = constr->height.GetValue(); - - // If we don't want to resize this window, just move it... - if ((constr->width.GetRelationship() != wxAsIs) || - (constr->height.GetRelationship() != wxAsIs)) + wxLayoutConstraints *constr = GetConstraints(); + if ( constr && constr->left.GetDone() && constr->right.GetDone( ) && + constr->width.GetDone() && constr->height.GetDone()) { - // Calls Layout() recursively. AAAGH. How can we stop that. - // Simply take Layout() out of non-top level OnSizes. - SizerSetSize(x, y, w, h); + int x = constr->left.GetValue(); + int y = constr->top.GetValue(); + int w = constr->width.GetValue(); + int h = constr->height.GetValue(); + + if ( (constr->width.GetRelationship() != wxAsIs ) || + (constr->height.GetRelationship() != wxAsIs) ) + { + SetSize(x, y, w, h); + } + else + { + // If we don't want to resize this window, just move it... + Move(x, y); + } } - else + else if ( constr ) { - SizerMove(x, y); + char *windowClass = GetClassInfo()->GetClassName(); + + wxString winName; + if ( GetName() == _T("") ) + winName = _T("unnamed"); + else + winName = GetName(); + wxLogDebug( _T("Constraint(s) not satisfied for window of type %s, name %s:\n"), + (const char *)windowClass, + (const char *)winName); + if ( !constr->left.GetDone()) wxLogDebug( _T(" unsatisfied 'left' constraint.\n") ); + if ( !constr->right.GetDone()) wxLogDebug( _T(" unsatisfied 'right' constraint.\n") ); + if ( !constr->width.GetDone()) wxLogDebug( _T(" unsatisfied 'width' constraint.\n") ); + if ( !constr->height.GetDone()) wxLogDebug( _T(" unsatisfied 'height' constraint.\n") ); + wxLogDebug( _T("Please check constraints: try adding AsIs() constraints.\n") ); } - } - else if (constr) - { - char *windowClass = this->GetClassInfo()->GetClassName(); - wxString winName; - if (GetName() == "") - winName = "unnamed"; - else - winName = GetName(); - wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName); - if (!constr->left.GetDone()) - wxDebugMsg(" unsatisfied 'left' constraint.\n"); - if (!constr->right.GetDone()) - wxDebugMsg(" unsatisfied 'right' constraint.\n"); - if (!constr->width.GetDone()) - wxDebugMsg(" unsatisfied 'width' constraint.\n"); - if (!constr->height.GetDone()) - wxDebugMsg(" unsatisfied 'height' constraint.\n"); - wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n"); - } - - if (recurse) - { - wxNode *node = GetChildren().First(); - while (node) + if ( recurse ) { - wxWindow *win = (wxWindow *)node->Data(); - if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) - win->SetConstraintSizes(); - node = node->Next(); + wxWindowList::Node *node = GetChildren().GetFirst(); + while (node) + { + wxWindow *win = node->GetData(); + if ( !win->IsTopLevel() ) + win->SetConstraintSizes(); + node = node->GetNext(); + } } - } -} - -// This assumes that all sizers are 'on' the same -// window, i.e. the parent of this window. -void wxWindow::TransformSizerToActual(int *x, int *y) const -{ - if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) || - m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) ) - return; - - int xp, yp; - m_sizerParent->GetPosition(&xp, &yp); - m_sizerParent->TransformSizerToActual(&xp, &yp); - *x += xp; - *y += yp; -} - -void wxWindow::SizerSetSize(int x, int y, int w, int h) -{ - int xx = x; - int yy = y; - TransformSizerToActual(&xx, &yy); - SetSize(xx, yy, w, h); -} - -void wxWindow::SizerMove(int x, int y) -{ - int xx = x; - int yy = y; - TransformSizerToActual(&xx, &yy); - Move(xx, yy); } // Only set the size/position of the constraint (if any) void wxWindow::SetSizeConstraint(int x, int y, int w, int h) { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - if (x != -1) - { - constr->left.SetValue(x); - constr->left.SetDone(TRUE); - } - if (y != -1) + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) { - constr->top.SetValue(y); - constr->top.SetDone(TRUE); - } - if (w != -1) - { - constr->width.SetValue(w); - constr->width.SetDone(TRUE); - } - if (h != -1) - { - constr->height.SetValue(h); - constr->height.SetDone(TRUE); + if ( x != -1 ) + { + constr->left.SetValue(x); + constr->left.SetDone(TRUE); + } + if ( y != -1 ) + { + constr->top.SetValue(y); + constr->top.SetDone(TRUE); + } + if ( w != -1 ) + { + constr->width.SetValue(w); + constr->width.SetDone(TRUE); + } + if ( h != -1 ) + { + constr->height.SetValue(h); + constr->height.SetDone(TRUE); + } } - } } void wxWindow::MoveConstraint(int x, int y) { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - if (x != -1) - { - constr->left.SetValue(x); - constr->left.SetDone(TRUE); - } - if (y != -1) + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) { - constr->top.SetValue(y); - constr->top.SetDone(TRUE); + if ( x != -1 ) + { + constr->left.SetValue(x); + constr->left.SetDone(TRUE); + } + if ( y != -1 ) + { + constr->top.SetValue(y); + constr->top.SetDone(TRUE); + } } - } } void wxWindow::GetSizeConstraint(int *w, int *h) const { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *w = constr->width.GetValue(); - *h = constr->height.GetValue(); - } - else - GetSize(w, h); + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + *w = constr->width.GetValue(); + *h = constr->height.GetValue(); + } + else + GetSize(w, h); } void wxWindow::GetClientSizeConstraint(int *w, int *h) const { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *w = constr->width.GetValue(); - *h = constr->height.GetValue(); - } - else - GetClientSize(w, h); + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + *w = constr->width.GetValue(); + *h = constr->height.GetValue(); + } + else + GetClientSize(w, h); } void wxWindow::GetPositionConstraint(int *x, int *y) const { - wxLayoutConstraints *constr = GetConstraints(); - if (constr) - { - *x = constr->left.GetValue(); - *y = constr->top.GetValue(); - } - else - GetPosition(x, y); + wxLayoutConstraints *constr = GetConstraints(); + if ( constr ) + { + *x = constr->left.GetValue(); + *y = constr->top.GetValue(); + } + else + GetPosition(x, y); } +#endif // wxUSE_CONSTRAINTS + bool wxWindow::Close(bool force) { wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); @@ -1141,10 +1630,23 @@ void wxWindow::OnDefaultAction(wxControl *initiatingItem) void wxWindow::Clear() { - wxClientDC dc(this); + if ( m_macWindowData ) + { + wxMacDrawingClientHelper helper ( this ) ; + int w ,h ; + wxPoint origin = GetClientAreaOrigin() ; + GetClientSize( &w , &h ) ; + UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ; + Rect r = { origin.y , origin.x, origin.y+h , origin.x+w } ; + EraseRect( &r ) ; + } + else + { + wxClientDC dc(this); wxBrush brush(GetBackgroundColour(), wxSOLID); dc.SetBackground(brush); dc.Clear(); + } } // Fits the panel around the items @@ -1221,20 +1723,18 @@ wxWindow *wxWindow::FindWindow(const wxString& name) void wxWindow::OnIdle(wxIdleEvent& event) { -/* TODO: you may need to do something like this - * if your GUI doesn't generate enter/leave events - - // Check if we need to send a LEAVE event - if (m_mouseInWindow) - { - POINT pt; - ::GetCursorPos(&pt); - if (::WindowFromPoint(pt) != (HWND) GetHWND()) - { - // Generate a LEAVE event - m_mouseInWindow = FALSE; - MSWOnMouseLeave(pt.x, pt.y, 0); - } +/* + // Check if we need to send a LEAVE event + if (m_mouseInWindow) + { + POINT pt; + ::GetCursorPos(&pt); + if (::WindowFromPoint(pt) != (HWND) GetHWND()) + { + // Generate a LEAVE event + m_mouseInWindow = FALSE; + MSWOnMouseLeave(pt.x, pt.y, 0); + } } */ @@ -1257,7 +1757,7 @@ void wxWindow::Lower() bool wxWindow::AcceptsFocus() const { - return IsShown() && IsEnabled(); + return IsShown() && IsEnabled() && MacCanFocus() ; } // Update region access @@ -1292,4 +1792,818 @@ int wxWindow::NewControlId() return s_controlId; } +void wxWindow::DoSetClientSize(int width, int height) +{ + if ( width != -1 || height != -1 ) + { + + if ( width != -1 && m_vScrollBar ) + width += MAC_SCROLLBAR_SIZE ; + if ( height != -1 && m_vScrollBar ) + height += MAC_SCROLLBAR_SIZE ; + + DoSetSize( -1 , -1 , width , height ) ; + } +} + +// ------------------------ +wxList *wxWinMacWindowList = NULL; +wxWindow *wxFindWinFromMacWindow(WindowRef inWindowRef) +{ + wxNode *node = wxWinMacWindowList->Find((long)inWindowRef); + if (!node) + return NULL; + return (wxWindow *)node->Data(); +} + +void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxWindow *win) +{ + // adding NULL WindowRef is (first) surely a result of an error and + // (secondly) breaks menu command processing + wxCHECK_RET( inWindowRef != (WindowRef) NULL, "attempt to add a NULL WindowRef to window list" ); + + if ( !wxWinMacWindowList->Find((long)inWindowRef) ) + wxWinMacWindowList->Append((long)inWindowRef, win); +} + +void wxRemoveMacWindowAssociation(wxWindow *win) +{ + wxWinMacWindowList->DeleteObject(win); +} + +wxWindow* wxWindow::s_lastMouseWindow = NULL ; + +bool wxWindow::MacGetWindowFromPointSub( const wxPoint &point , wxWindow** outWin ) +{ + 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 = GetMacRootWindow() ; + + wxPoint newPoint( point ) ; + + newPoint.x -= m_x; + newPoint.y -= m_y; + + if ( m_children ) + { + for (wxNode *node = m_children->First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); + if ( child->GetMacRootWindow() == window ) + { + if (child->MacGetWindowFromPointSub(newPoint , outWin )) + return TRUE; + } + } + } + + *outWin = this ; + return TRUE; +} + +bool wxWindow::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindow** outWin ) +{ + WindowRef window ; + Point pt = { screenpoint.y , screenpoint.x } ; + if ( ::FindWindow( pt , &window ) == 3 ) + { + wxPoint point( screenpoint ) ; + wxWindow* win = wxFindWinFromMacWindow( window ) ; + win->ScreenToClient( point ) ; + return win->MacGetWindowFromPointSub( point , outWin ) ; + } + return FALSE ; +} + +extern int wxBusyCursorCount ; + +bool wxWindow::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 ) ) ) + return FALSE ; + + WindowRef window = GetMacRootWindow() ; + + event.m_x -= m_x; + event.m_y -= m_y; + + int x = event.m_x ; + int y = event.m_y ; + + if ( m_children ) + { + for (wxNode *node = m_children->First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); + if ( child->GetMacRootWindow() == window && child->IsReallyShown() && child->IsReallyEnabled() ) + { + if (child->MacDispatchMouseEvent(event)) + return TRUE; + } + } + } + + event.m_x = x ; + event.m_y = y ; + + if ( wxBusyCursorCount == 0 ) + { + m_windowCursor.MacInstall() ; + } + GetEventHandler()->ProcessEvent( event ) ; + return TRUE; +} + +void wxWindow::MacFireMouseEvent( EventRecord *ev ) +{ + wxMouseEvent event(wxEVT_LEFT_DOWN); + bool isDown = !(ev->modifiers & btnState) ; // 1 is for up + bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse + + event.m_leftDown = isDown && !controlDown; + event.m_middleDown = FALSE; + event.m_rightDown = isDown && controlDown; + + if ( ev->what == mouseDown ) + { + if ( controlDown ) + event.SetEventType(wxEVT_RIGHT_DOWN ) ; + else + event.SetEventType(wxEVT_LEFT_DOWN ) ; + } + else if ( ev->what == mouseUp ) + { + if ( controlDown ) + event.SetEventType(wxEVT_RIGHT_UP ) ; + else + event.SetEventType(wxEVT_LEFT_UP ) ; + } + else + { + event.SetEventType(wxEVT_MOTION ) ; + } + + event.m_shiftDown = ev->modifiers & shiftKey; + event.m_controlDown = ev->modifiers & controlKey; + event.m_altDown = ev->modifiers & optionKey; + event.m_metaDown = ev->modifiers & cmdKey; + + Point localwhere = ev->where ; + + GrafPtr port ; + ::GetPort( &port ) ; + ::SetPort( UMAGetWindowPort( m_macWindowData->m_macWindow ) ) ; + ::GlobalToLocal( &localwhere ) ; + ::SetPort( port ) ; + + event.m_x = localwhere.h; + event.m_y = localwhere.v; + event.m_x += m_x; + event.m_y += m_y; + +/* + wxPoint origin = GetClientAreaOrigin() ; + + event.m_x += origin.x ; + event.m_y += origin.y ; +*/ + + event.m_timeStamp = ev->when; + event.SetEventObject(this); + if ( wxTheApp->s_captureWindow ) + { + int x = event.m_x ; + int y = event.m_y ; + wxTheApp->s_captureWindow->ScreenToClient( &x , &y ) ; + event.m_x = x ; + event.m_y = y ; + wxTheApp->s_captureWindow->GetEventHandler()->ProcessEvent( event ) ; + if ( ev->what == mouseUp ) + { + wxTheApp->s_captureWindow = NULL ; + if ( wxBusyCursorCount == 0 ) + { + m_windowCursor.MacInstall() ; + } + } + } + else + { + MacDispatchMouseEvent( event ) ; + } +} + +void wxWindow::MacMouseDown( EventRecord *ev , short part) +{ + MacFireMouseEvent( ev ) ; +} + +void wxWindow::MacMouseUp( EventRecord *ev , short part) +{ + WindowPtr frontWindow ; + switch (part) + { + case inContent: + { + MacFireMouseEvent( ev ) ; + } + break ; + } +} + +void wxWindow::MacMouseMoved( EventRecord *ev , short part) +{ + WindowPtr frontWindow ; + switch (part) + { + case inContent: + { + MacFireMouseEvent( ev ) ; + } + break ; + } +} +void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating ) +{ + wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating); + event.m_timeStamp = ev->when ; + event.SetEventObject(this); + + GetEventHandler()->ProcessEvent(event); + + UMAHighlightAndActivateWindow( m_macWindowData->m_macWindow , inIsActivating ) ; +} + +void wxWindow::MacRedraw( RgnHandle updatergn , long time) +{ + // updatergn is always already clipped to our boundaries + WindowRef window = GetMacRootWindow() ; + wxWindow* win = wxFindWinFromMacWindow( window ) ; + { + wxMacDrawingClientHelper focus( this ) ; + if ( focus.Ok() ) + { + WindowRef window = GetMacRootWindow() ; + if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) ) + { + UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ; + } + else if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) ) + { + // 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 + + + wxWindow* parent = GetParent() ; + while( parent ) + { + if ( parent->GetMacRootWindow() != window ) + { + // we are in a different window on the mac system + parent = NULL ; + break ; + } + + if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() ) + { + if ( parent->m_backgroundColour != wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) ) + { + // if we have any other colours in the hierarchy + RGBBackColor( &parent->m_backgroundColour.GetPixel()) ; + 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 ) )) + { + ApplyThemeBackground (kThemeBackgroundTabPane, &(**updatergn).rgnBBox , kThemeStateActive,8,true); + break ; + } + } + else + { + parent = NULL ; + break ; + } + parent = parent->GetParent() ; + } + if ( !parent ) + { + // if there is nothing special -> use default + UMASetThemeWindowBackground( window , kThemeBrushDialogBackgroundActive , false ) ; + } + } + else + { + RGBBackColor( &m_backgroundColour.GetPixel()) ; + } + SetClip( updatergn ) ; + EraseRgn( updatergn ) ; + } + } + + + m_updateRegion = updatergn ; + wxPaintEvent event; + event.m_timeStamp = time ; + event.SetEventObject(this); + + GetEventHandler()->ProcessEvent(event); + + RgnHandle childupdate = NewRgn() ; + + for (wxNode *node = m_children->First(); node; node = node->Next()) + { + wxWindow *child = (wxWindow*)node->Data(); + int width ; + int height ; + + child->GetClientSize( &width , &height ) ; + + SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x +width , child->m_y + height ) ; + SectRgn( childupdate , m_updateRegion.GetWXHRGN() , childupdate ) ; + OffsetRgn( childupdate , -child->m_x , -child->m_y ) ; + if ( child->GetMacRootWindow() == window && child->IsReallyShown() ) + { + // because dialogs may also be children + child->MacRedraw( childupdate , time ) ; + } + } + DisposeRgn( childupdate ) ; + // eventually a draw grow box here +} + +void wxWindow::MacUpdateImmediately() +{ + WindowRef window = GetMacRootWindow() ; + if ( window ) + { + wxWindow* win = wxFindWinFromMacWindow( window ) ; + BeginUpdate( window ) ; + if ( win ) + { + #if ! TARGET_CARBON + if ( !EmptyRgn( window->visRgn ) ) + #endif + { + win->MacRedraw( window->visRgn , wxTheApp->sm_lastMessageTime ) ; +/* + { + wxMacDrawingHelper help( win ) ; + SetOrigin( 0 , 0 ) ; + UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ; + UMAUpdateControls( window , window->visRgn ) ; + UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ; + } +*/ + } + } + EndUpdate( window ) ; + } +} + +void wxWindow::MacUpdate( EventRecord *ev ) +{ + WindowRef window = (WindowRef) ev->message ; + wxWindow * win = wxFindWinFromMacWindow( window ) ; + + BeginUpdate( window ) ; + if ( win ) + { + // if windowshade gives incompatibility , take the follwing out + #if ! TARGET_CARBON + if ( !EmptyRgn( window->visRgn ) ) + #endif + { + MacRedraw( window->visRgn , ev->when ) ; + /* + { + wxMacDrawingHelper help( this ) ; + SetOrigin( 0 , 0 ) ; + UMASetThemeWindowBackground( m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ; + UMAUpdateControls( window , window->visRgn ) ; + UMASetThemeWindowBackground( m_macWindowData->m_macWindow , m_macWindowData->m_macWindowBackgroundTheme , false ) ; + } + */ + } + } + EndUpdate( window ) ; +} + +WindowRef wxWindow::GetMacRootWindow() const +{ + WindowRef window = NULL ; + wxWindow *iter = (wxWindow*)this ; + + while( iter ) + { + if ( iter->m_macWindowData ) + return iter->m_macWindowData->m_macWindow ; + + iter = iter->GetParent() ; + } + wxASSERT_MSG( 1 , "No valid mac root window" ) ; + return NULL ; +} + +void wxWindow::MacCreateScrollBars( long style ) +{ + wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , "attempt to create window twice" ) ; + bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ; + int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ; + + if ( style & wxVSCROLL ) + { + m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, wxPoint(m_width-MAC_SCROLLBAR_SIZE, 0), + wxSize(MAC_SCROLLBAR_SIZE, m_height - adjust), wxVERTICAL); + } + if ( style & wxHSCROLL ) + { + m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, wxPoint(0 , m_height-MAC_SCROLLBAR_SIZE ), + wxSize( m_width - adjust, MAC_SCROLLBAR_SIZE), wxHORIZONTAL); + } + // because the create does not take into account the client area origin + MacRepositionScrollBars() ; // we might have a real position shift +} + +void wxWindow::MacRepositionScrollBars() +{ + bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ; + int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1 : 0 ; + + if ( m_vScrollBar ) + { + m_vScrollBar->SetSize( m_width-MAC_SCROLLBAR_SIZE, 0, MAC_SCROLLBAR_SIZE, m_height - adjust , wxSIZE_USE_EXISTING); + } + if ( m_hScrollBar ) + { + m_hScrollBar->SetSize( 0 , m_height-MAC_SCROLLBAR_SIZE ,m_width - adjust, MAC_SCROLLBAR_SIZE, wxSIZE_USE_EXISTING); + } +} + +void wxWindow::MacKeyDown( EventRecord *ev ) +{ +} + + + + +ControlHandle wxWindow::MacGetContainerForEmbedding() +{ + if ( m_macWindowData ) + return m_macWindowData->m_macRootControl ; + else + return GetParent()->MacGetContainerForEmbedding() ; +} + +void wxWindow::MacSuperChangedPosition() +{ + // only window-absolute structures have to be moved i.e. controls + + wxNode *node = GetChildren().First(); + while ( node ) + { + wxWindow *child = (wxWindow *)node->Data(); + child->MacSuperChangedPosition() ; + node = node->Next(); + } +} + +bool wxWindow::IsReallyShown() const +{ + if ( m_macWindowData ) + return m_macShown ; + else + return m_macShown && GetParent()->IsReallyShown() ; +} + +bool wxWindow::IsReallyEnabled() const +{ + if ( m_macWindowData ) + return m_macEnabled ; + else + return m_macEnabled && GetParent()->IsReallyEnabled() ; +} + +void wxWindow::MacSuperEnabled( bool enabled ) +{ + wxNode *node = GetChildren().First(); + while ( node ) + { + wxWindow *child = (wxWindow *)node->Data(); + if ( child->m_macEnabled ) + child->MacSuperEnabled( enabled ) ; + node = node->Next(); + } +} +void wxWindow::MacSuperShown( bool show ) +{ + wxNode *node = GetChildren().First(); + while ( node ) + { + wxWindow *child = (wxWindow *)node->Data(); + if ( child->m_macShown ) + child->MacSuperShown( show ) ; + node = node->Next(); + } +} + +bool wxWindow::MacSetupFocusPort( ) +{ + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + GrafPtr port ; + + MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ; + return MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; +} + +bool wxWindow::MacSetupFocusClientPort( ) +{ + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + GrafPtr port ; + + MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ; + return MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; +} + +bool wxWindow::MacSetupDrawingPort( ) +{ + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + GrafPtr port ; + + MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ; + return MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ; +} + +bool wxWindow::MacSetupDrawingClientPort( ) +{ + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + GrafPtr port ; + + MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ; + return MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ; +} + + +bool wxWindow::MacSetPortFocusParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* win ) +{ + if ( window == NULL ) + return false ; + + GrafPtr currPort; + GrafPtr port ; + + ::GetPort(&currPort); + port = UMAGetWindowPort( window) ; + if (currPort != port ) + ::SetPort(port); + + ::SetOrigin(-localOrigin.h, -localOrigin.v); + return true; +} + +bool wxWindow::MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* win ) +{ + if ( window == NULL ) + return false ; + + GrafPtr currPort; + GrafPtr port ; + ::GetPort(&currPort); + port = UMAGetWindowPort( window) ; + if (currPort != port ) + ::SetPort(port); + + ::SetOrigin(-localOrigin.h, -localOrigin.v); + ::ClipRect(&clipRect); + + ::PenNormal() ; + ::RGBBackColor(& win->GetBackgroundColour().GetPixel() ) ; + ::RGBForeColor(& win->GetForegroundColour().GetPixel() ) ; + ::BackPat( &qd.white ) ; + ::UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ; + return true; +} + +void wxWindow::MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) +{ + if ( m_macWindowData ) + { + localOrigin->h = 0; + localOrigin->v = 0; + clipRect->left = 0; + clipRect->top = 0; + clipRect->right = m_width; + clipRect->bottom = m_height; + *window = m_macWindowData->m_macWindow ; + *rootwin = this ; + } + else + { + wxASSERT( GetParent() != NULL ) ; + GetParent()->MacGetPortParams( localOrigin , clipRect , window, rootwin) ; + localOrigin->h += m_x; + localOrigin->v += m_y; + OffsetRect(clipRect, -m_x, -m_y); + + Rect myClip; + myClip.left = 0; + myClip.top = 0; + myClip.right = m_width; + myClip.bottom = m_height; + SectRect(clipRect, &myClip, clipRect); + } +} + +void wxWindow::MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin ) +{ + int width , height ; + GetClientSize( &width , &height ) ; + + if ( m_macWindowData ) + { + localOrigin->h = 0; + localOrigin->v = 0; + clipRect->left = 0; + clipRect->top = 0; + clipRect->right = m_width ;//width; + clipRect->bottom = m_height ;// height; + *window = m_macWindowData->m_macWindow ; + *rootwin = this ; + } + else + { + wxASSERT( GetParent() != NULL ) ; + + GetParent()->MacGetPortClientParams( localOrigin , clipRect , window, rootwin) ; + + localOrigin->h += m_x; + localOrigin->v += m_y; + OffsetRect(clipRect, -m_x, -m_y); + + Rect myClip; + myClip.left = 0; + myClip.top = 0; + myClip.right = width; + myClip.bottom = height; + SectRect(clipRect, &myClip, clipRect); + } +} + +wxMacFocusHelper::wxMacFocusHelper( wxWindow * theWindow ) +{ + m_ok = false ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + m_currentPort = NULL ; + GetPort( &m_formerPort ) ; + if ( theWindow ) + { + + theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ; + m_currentPort = UMAGetWindowPort( window ) ; + theWindow->MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; + m_ok = true ; + } +} + +wxMacFocusHelper::~wxMacFocusHelper() +{ + if ( m_ok ) + { + SetOrigin( 0 , 0 ) ; + } + if ( m_formerPort != m_currentPort ) + SetPort( m_formerPort ) ; +} + +wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow ) +{ + m_ok = false ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + m_currentPort = NULL ; + + GetPort( &m_formerPort ) ; + if ( theWindow ) + { + theWindow->MacGetPortParams( &localOrigin , &clipRect , &window , &rootwin) ; + m_currentPort = UMAGetWindowPort( window ) ; + if ( m_formerPort != m_currentPort ) + SetPort( m_currentPort ) ; + GetPenState( &m_savedPenState ) ; + theWindow->MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ; + m_ok = true ; + } +} + +wxMacDrawingHelper::~wxMacDrawingHelper() +{ + if ( m_ok ) + { + SetPenState( &m_savedPenState ) ; + SetOrigin( 0 , 0 ) ; + ClipRect( &m_currentPort->portRect ) ; + } + + if ( m_formerPort != m_currentPort ) + SetPort( m_formerPort ) ; +} + +wxMacFocusClientHelper::wxMacFocusClientHelper( wxWindow * theWindow ) +{ + m_ok = false ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + m_currentPort = NULL ; + + GetPort( &m_formerPort ) ; + + if ( theWindow ) + { + theWindow->MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ; + m_currentPort = UMAGetWindowPort( window ) ; + theWindow->MacSetPortFocusParams( localOrigin, clipRect, window , rootwin ) ; + m_ok = true ; + } +} + +wxMacFocusClientHelper::~wxMacFocusClientHelper() +{ + if ( m_ok ) + { + SetOrigin( 0 , 0 ) ; + } + if ( m_formerPort != m_currentPort ) + SetPort( m_formerPort ) ; +} + +wxMacDrawingClientHelper::wxMacDrawingClientHelper( wxWindow * theWindow ) +{ + m_ok = false ; + Point localOrigin ; + Rect clipRect ; + WindowRef window ; + wxWindow *rootwin ; + m_currentPort = NULL ; + + GetPort( &m_formerPort ) ; + + if ( theWindow ) + { + theWindow->MacGetPortClientParams( &localOrigin , &clipRect , &window , &rootwin) ; + m_currentPort = UMAGetWindowPort( window ) ; + if ( m_formerPort != m_currentPort ) + SetPort( m_currentPort ) ; + GetPenState( &m_savedPenState ) ; + theWindow->MacSetPortDrawingParams( localOrigin, clipRect, window , rootwin ) ; + m_ok = true ; + } +} + +wxMacDrawingClientHelper::~wxMacDrawingClientHelper() +{ + if ( m_ok ) + { + SetPenState( &m_savedPenState ) ; + SetOrigin( 0 , 0 ) ; + ClipRect( &m_currentPort->portRect ) ; + } + + if ( m_formerPort != m_currentPort ) + SetPort( m_formerPort ) ; +} + +// ---------------------------------------------------------------------------- +// list classes implementation +// ---------------------------------------------------------------------------- + +void wxWindowListNode::DeleteData() +{ + delete (wxWindow *)GetData(); +} diff --git a/src/msw/iniconf.cpp b/src/msw/iniconf.cpp index f3d0a6727b..e65785791d 100644 --- a/src/msw/iniconf.cpp +++ b/src/msw/iniconf.cpp @@ -344,16 +344,22 @@ bool wxIniConfig::Read(const wxString& szKey, long *pl) const // is it really nMagic? lVal = GetPrivateProfileInt(m_strGroup, strKey, nMagic2, m_strLocalFilename); - if ( lVal == nMagic2 ) { + if ( lVal != nMagic2 ) { // the nMagic it returned was indeed read from the file *pl = lVal; return TRUE; } + // CS : I have no idea why they should look up in win.ini + // and if at all they have to do the same procedure using the two magic numbers + // otherwise it always returns true, even if the key was not there at all +#if 0 // no, it was just returning the default value, so now look in win.ini - *pl = GetProfileInt(GetVendorName(), GetKeyName(szKey), *pl); + *pl = GetProfileInt(GetVendorName(), GetKeyName(szKey), *pl); return TRUE; +#endif + return FALSE ; } bool wxIniConfig::Write(const wxString& szKey, const wxString& szValue) diff --git a/user/wxTest/horse.png b/user/wxTest/horse.png index 326b7c786787f25de36e3ac26f20ae09817e1437..f1ad7558e4917c38d1dafc49f7bccac10219adee 100644 GIT binary patch literal 5 McmeAS@N?$^00ndbc>n+a literal 68850 zcmXtf2Qb_J|9>bIsUun=HA;M})E=!}q(-G^rL|I9ZDNa6Ge*s}X6;e5W{c38RYXyH z#0s@b?7jW-z5o5*x!n8Sxx6oz_q|@v=VLwJKG)R*v4H>p07&bJ8j^he{l7Pm5&)pk zSE4m1U);2Ms;LHO{@=?1KK7aX39Z``V^8w={~y^_{E`3wH$Y2G^`-BWc7t&hZ?_+x zecATb{I@RRc3-okP!jIL!tjSDIKj7$dKJc>LRT!=(vR={aZR5qP;Ko8P_o^IBL4Gw z%9M7$+9<{NF;hdYH$P{UDh=cLiel;Cm1;vyVtd}m6HfK+=p05;uff>PblGJz1zDI%RZM_ zTr)kS8}Oi!-RD)bXHXM{qdtJwU_wk@WB`QwE|U9b`f`cY-0kD$43|Xydph&W^#c17 z|7I^_>Dw5q5*Eei8!kox?@*LrYiIe!sn@Z*Q$J*ooMEoG?^lFIl8ESe$~(wh&3qlmT9@0*yTFgr1h$~tgJEj@}i`Y{WgBWZKr?k z`roqSSlqC#05R7j_~E}!nfg1hpPiE{##4=oxf}5pr87%2l*x@Poe<^V<2O$813_o| z)jc;avqxm?uo6dSIMm#HwVL4%`@LsjUk~?c2Dlyt8tt3VK5FhAP5Fn@sQAQcZT)4- zI{?`0EJElMvR=*$eqJ-V+x+I2+_jkUm6+BCalAO5UZr>0L-OMjSWz-Kbj_=wW@P&q z`PhPk`mWHg-`}2pb-WvqU09`jIr&W4+N6Kg^B3gtl&UW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)75ktg%Qrb411tnAd;`6{NC)G-}m^ z0#bTysLT<#vMJ4pQiqqUQnyaxQU+|*sYA$OGAr)SyiI0@y!!`s?mr5ZcHZ5~mqY{r F06UqyWJ>@5 diff --git a/utils/dialoged/docs/dialog.gif b/utils/dialoged/docs/dialog.gif index ae430e334576ccc77c788a042dccda4ff62bae84..656e658287839b27a9fb3bc90cc3b2f589503bc3 100644 GIT binary patch delta 6 NcmaFKIEit>BmfD10-yi@ delta 94 zcmV-k0HObq0qFsdl2;o2j>4NU(lth>w_P?iOMzRLQxw^Y&ztsgekXuZ7)}>oafK|5 zM*xgaiFZzr5|ogRYlVo0gkOSoWptyOpiGLUDyXR_ah0#IuoJPgw2z~>84&;gJJ@0= A{Qv*} diff --git a/utils/dialoged/docs/forward.gif b/utils/dialoged/docs/forward.gif index 9c81e8c92fed7fe851ce02e7854dc26a58eae9b2..9c8421838a9822c3bcc3d5b9a40732a72647b558 100644 GIT binary patch delta 5 McmZ3&m^&dC00t2P5C8xG delta 61 zcmV-D0K)%mqydm^HyX5<&4|xlpYoDsn}K3#l-r!ce^~9fOp>GGBv?XN2y%$1p}06> Tz!51qNm*$bV410zSpWb#w2&Mp diff --git a/utils/dialoged/docs/gauge.gif b/utils/dialoged/docs/gauge.gif index af79fe1aef58a40ea131f9d7c82201cf74ba1d0d..237d885fbef1495844c149c4216437fb0a8a0670 100644 GIT binary patch delta 6 Ncmcb@xPWoO0ssj{0;d1~ delta 59 zcmV-B0L1^G0n`DIpfnn8&$H(EU43Bd-*snuaDP8#LU93uQ8p8RFpy7lk&r+vmzbHF RnG>6ypE4qiqZttZ06Q&{7~uc_ diff --git a/utils/dialoged/docs/tofront.gif b/utils/dialoged/docs/tofront.gif index ff09220da3e1912f64891777c0cef2e7c16e8bfa..6b9ca4f6409818cbae26ff21267c4ca2b3af30cc 100644 GIT binary patch delta 5 McmeBV%$|@900n{p@c;k- delta 36 scmd1qWSo#KCl$1n*Q-+W+r0R*rOLidyTjOLij<}(D4WdeWMHrc0QmO|t^fc4 diff --git a/utils/dialoged/docs/up.gif b/utils/dialoged/docs/up.gif index 316d0d2a14b571bea2eb874efd04bfe509f53b34..f9e7031e64cf9bd17eac8190eefce2526d90a052 100644 GIT binary patch literal 6 NcmZ?wbh9u|1ONrB0jB@} literal 137 zcmV;40CxXJNk%v~VHyA!0Pz3-zrVld=jU&4Z(9HWEC2ui02%-o0007FjE||ytzv+j zv|1owxcuhWh0?c)Avq0}dTQw^q7qBdoDA6WKJ*l>%gtCeAWZlgxpoy|ZDMRPr_m>p rx}08pS4?)u<%PW