]> git.saurik.com Git - wxWidgets.git/commitdiff
CW5.2 Pro Adaptions, wxMac starting to move in
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 5 Nov 1999 09:16:09 +0000 (09:16 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 5 Nov 1999 09:16:09 +0000 (09:16 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4366 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

176 files changed:
docs/latex/wx/splitter.gif
include/wx/defs.h
include/wx/gdicmn.h
include/wx/mac/app.h
include/wx/mac/bitmap.h
include/wx/mac/bmpbuttn.h
include/wx/mac/button.h
include/wx/mac/checkbox.h
include/wx/mac/choice.h
include/wx/mac/clipbrd.h
include/wx/mac/colour.h
include/wx/mac/combobox.h
include/wx/mac/control.h
include/wx/mac/cursor.h
include/wx/mac/dc.h
include/wx/mac/dcclient.h
include/wx/mac/dcmemory.h
include/wx/mac/dcprint.h
include/wx/mac/dialog.h
include/wx/mac/dnd.h
include/wx/mac/font.h
include/wx/mac/frame.h
include/wx/mac/gauge.h
include/wx/mac/icon.h
include/wx/mac/listbox.h
include/wx/mac/macsock.h
include/wx/mac/mdi.h
include/wx/mac/menu.h
include/wx/mac/menuitem.h
include/wx/mac/metafile.h
include/wx/mac/notebook.h
include/wx/mac/palette.h
include/wx/mac/radiobox.h
include/wx/mac/region.h
include/wx/mac/scrolbar.h
include/wx/mac/setup.h
include/wx/mac/slider.h
include/wx/mac/spinbutt.h
include/wx/mac/statbmp.h
include/wx/mac/statbox.h
include/wx/mac/stattext.h
include/wx/mac/statusbr.h
include/wx/mac/textctrl.h
include/wx/mac/timer.h
include/wx/mac/toolbar.h
include/wx/mac/window.h
include/wx/msw/gsockmsw.h
include/wx/wx_cw.h
include/wx/wx_cw_cm.h
include/wx/wx_cw_d.h
include/wx_cw.pch
include/wx_cw.pch++
include/wx_cw_d.pch
include/wx_cw_d.pch++
samples/help/doc/ClassGraph.class
samples/help/doc/ClassGraphPanel.class
samples/help/doc/ClassLayout.class
samples/help/doc/NavigatorButton.class
src/common/db.cpp
src/common/dbtable.cpp
src/common/socket.cpp
src/jpeg/jconfig.h
src/mac/app.cpp
src/mac/apprsrc.r
src/mac/bitmap.cpp
src/mac/brush.cpp
src/mac/button.cpp
src/mac/carbon/app.cpp
src/mac/carbon/apprsrc.r
src/mac/carbon/bitmap.cpp
src/mac/carbon/brush.cpp
src/mac/carbon/button.cpp
src/mac/carbon/checkbox.cpp
src/mac/carbon/choice.cpp
src/mac/carbon/clipbrd.cpp
src/mac/carbon/colordlg.cpp
src/mac/carbon/colour.cpp
src/mac/carbon/combobox.cpp
src/mac/carbon/control.cpp
src/mac/carbon/corersrc.r
src/mac/carbon/cursor.cpp
src/mac/carbon/data.cpp
src/mac/carbon/dc.cpp
src/mac/carbon/dcclient.cpp
src/mac/carbon/dcmemory.cpp
src/mac/carbon/dcscreen.cpp
src/mac/carbon/dialog.cpp
src/mac/carbon/dirdlg.cpp
src/mac/carbon/filedlg.cpp
src/mac/carbon/font.cpp
src/mac/carbon/fontdlg.cpp
src/mac/carbon/frame.cpp
src/mac/carbon/gauge.cpp
src/mac/carbon/icon.cpp
src/mac/carbon/listbox.cpp
src/mac/carbon/makefile.unx
src/mac/carbon/menu.cpp
src/mac/carbon/menuitem.cpp
src/mac/carbon/metafile.cpp
src/mac/carbon/msgdlg.cpp
src/mac/carbon/notebook.cpp
src/mac/carbon/palette.cpp
src/mac/carbon/print.cpp
src/mac/carbon/printdlg.cpp
src/mac/carbon/radiobox.cpp
src/mac/carbon/region.cpp
src/mac/carbon/scrolbar.cpp
src/mac/carbon/settings.cpp
src/mac/carbon/slider.cpp
src/mac/carbon/spinbutt.cpp
src/mac/carbon/statbmp.cpp
src/mac/carbon/statbox.cpp
src/mac/carbon/stattext.cpp
src/mac/carbon/statusbr.cpp
src/mac/carbon/tabctrl.cpp
src/mac/carbon/textctrl.cpp
src/mac/carbon/toolbar.cpp
src/mac/carbon/utils.cpp
src/mac/carbon/wave.cpp
src/mac/carbon/window.cpp
src/mac/checkbox.cpp
src/mac/choice.cpp
src/mac/clipbrd.cpp
src/mac/colordlg.cpp
src/mac/colour.cpp
src/mac/combobox.cpp
src/mac/control.cpp
src/mac/corersrc.r
src/mac/cursor.cpp
src/mac/data.cpp
src/mac/dc.cpp
src/mac/dcclient.cpp
src/mac/dcmemory.cpp
src/mac/dcscreen.cpp
src/mac/dialog.cpp
src/mac/dirdlg.cpp
src/mac/filedlg.cpp
src/mac/font.cpp
src/mac/fontdlg.cpp
src/mac/frame.cpp
src/mac/gauge.cpp
src/mac/icon.cpp
src/mac/listbox.cpp
src/mac/makefile.unx
src/mac/menu.cpp
src/mac/menuitem.cpp
src/mac/metafile.cpp
src/mac/msgdlg.cpp
src/mac/notebook.cpp
src/mac/palette.cpp
src/mac/print.cpp
src/mac/printdlg.cpp
src/mac/radiobox.cpp
src/mac/region.cpp
src/mac/scrolbar.cpp
src/mac/settings.cpp
src/mac/slider.cpp
src/mac/spinbutt.cpp
src/mac/statbmp.cpp
src/mac/statbox.cpp
src/mac/stattext.cpp
src/mac/statusbr.cpp
src/mac/tabctrl.cpp
src/mac/textctrl.cpp
src/mac/toolbar.cpp
src/mac/utils.cpp
src/mac/wave.cpp
src/mac/window.cpp
src/msw/iniconf.cpp
user/wxTest/horse.png
utils/dialoged/docs/books.gif
utils/dialoged/docs/dialog.gif
utils/dialoged/docs/forward.gif
utils/dialoged/docs/gauge.gif
utils/dialoged/docs/tofront.gif
utils/dialoged/docs/up.gif

index 04bfd9fe488d5519e7089a788316be1c84cba60f..53bd095bd0917bb6f1606e9f18363cc91b8d24f5 100644 (file)
Binary files a/docs/latex/wx/splitter.gif and b/docs/latex/wx/splitter.gif differ
index 422f97d30ad6d75d80b236a8b84af2ed94ad0d1b..1cf504cb50d0b45fb734be86441b36b94db57054 100644 (file)
@@ -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;
index c1439e021620debecea63a6562a6f1e65e761016..0fcea7fdcc5ffb7ac5cab56ea4c235cb51491344 100644 (file)
@@ -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
 };
 
index 7cab45cffaf21682e922de8bc82ae77dbbcfa63e..4d50c75d0612664aa5945445b8fc3408c8bef15c 100644 (file)
@@ -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_
 
index 1d2f5417e504c6b8279007c583323deefe1fd556..92eda5882ded333bc64f2815f3722f0bc7019365 100644 (file)
@@ -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_
index defe39e438b272cef097aab9fe4a58271f6ad3d5..8c0ec5efae0ecf979efe1cc7400e9ffea7264171 100644 (file)
@@ -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; }
index 68b67d8c96ff370f261b924f60bbf9041712a222..3f4d6884529b0a20b1636aedab1b8c8a7186ecf0 100644 (file)
@@ -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);
 };
 
index 8bf41d99582c0e1d7827cddee1e5f54964050c10..94a2fdceebf6b4245ac90c67acf2fa4a07cf565e 100644 (file)
@@ -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_
index 7f360ed5cc379c5396b16c32362ebff0aa16dc98..46829449411f1bf37443842d38a02dfdb0666976 100644 (file)
@@ -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
index 697dc9d9396cdf42f030823e258ab626b42dca2c..4d3658ed3c2b6ef8c88f6c9f87e106ed2c0171b1 100644 (file)
 
 #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
index 16ffdac9aad515ddaba442f7dc90fb337c7dba9b..407c0140cafb13f004b0c11c7dd8c9ee607dedff 100644 (file)
@@ -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)
index 07054af74e7bbd327c86a1bb7e00823299003930..6fda37448e5c5a472171bc40a4d3e907f5b714b9 100644 (file)
@@ -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
index c75756a72a8a1016db8278654a291232f390f445..7d8f6d185d3598347c3f0320e8a5e45c6431c730 100644 (file)
 #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_
index bc6397069fc9d4d0ee10bba44479520ccec6f9c4..250005009140ec4773cdf5c4c71e71f18e9edc57 100644 (file)
@@ -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);
index ce3e9998d1d98aafbd63526c3501b9b95228ef6a..a685c9a5766d333f5f4195aa76ec3991811a4957 100644 (file)
@@ -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
index 29e4e6f7a06c5b50c1b6ae3dd31415874eef2dbc..c2a118c6a1a2aff11b20c7fcdbb5529a1a60f742 100644 (file)
 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
index c6c57376420c83bf866bdbd71898ab7f362a0421..642ae88afd1942acdb6fbf8880eec871bebe7649 100644 (file)
@@ -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;
 };
 
index 2ea66d15bf9af88206f360d8311719bc9b3cef4b..07f876fc85d8321c05aec4bc7a45c55b79499d92 100644 (file)
@@ -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
index d68cc7c9a0f0612e7138e02c0a8f4d08c1e52c9a..0b595e9c9defe3b54e4b58672375a0b6aba43e88 100644 (file)
@@ -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()
 };
 
index 5a7a65335f43519c006de7e4ad8e71f568232b15..e3a149ed857396232c71235ed7e69eee5eecd3cc 100644 (file)
@@ -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: 
   
index aff8fb3a759d10f1dd05ddfa6266e8218e71c690..f7596f241b292a355094e08d4f1d23fa8e3a79dd 100644 (file)
 /////////////////////////////////////////////////////////////////////////////
 // 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
index 64ec0d6cd19dc4e6ee01918b2c0433ccd350197e..ae5e085877ab879194629b07b61d97c52c261ca1 100644 (file)
 #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()
 };
index ce19d9ef1fb20d29e9fca2bd29477fc5985d642a..b88f5187a7d15c78b4dd16c4ae31015fa838dfbb 100644 (file)
@@ -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:
index df475672ba243c5a826fb59cf52864485ffeb66e..fed25013ff1083f85f5e39092a4082ac405a8333 100644 (file)
@@ -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_
index d95db4379b0a72abd9bacc25851f2b4d7d1657f3..0ab770ac57165df0865e548b05a0e5cf600716a9 100644 (file)
@@ -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
index 5703eb5f004d44f305a19b4772824c4cee70d00e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
-/*********************************************************************
-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 <errno.h>
-#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 <sys/types.h>
-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 <sys/cdefs.h>
-
-#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 <compat.h>
-//#include <sys/ioctl.h>
-#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 <sys/fcntl.h>
-//#include <sys/stat.h>
-//#include <dirent.h>
-//#include <Types.h>
-//#include <Events.h>
-//#include <Files.h>
-//#include <AppleTalk.h>
-//#include <CTBUtilities.h>
-//#include <Packages.h>
-//#include <PPCToolBox.h>
-//#include <StandardFile.h>
-//#include <stdio.h>
-//#include <sys/time.h>
-
-
-/*
- * 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 <sys/socket.h>
-
-/*
- * 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 <string.h>
-//#include <netinet/in.h>
-//#include <netdb.h>
-//#include <sys/un.h>
-//#include <unistd.h>
-//#include <machine/endian.h>
-//
-
-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 ;
-       } ;
-
index 6f9fc294e2abc327cd4b3eef69d407d54e92509b..fc3cf946034e707beace39fe5a71887b8ec1db3e 100644 (file)
@@ -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();
 };
index fa3936557c40c6be7ff93edbe361af94f7482de5..3c5634d20254238639fa04e661b553f81eeb34e5 100644 (file)
@@ -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_
index 9c912967f1208e186ae59dc5dc58249fcb789b1d..97359a102ae962f99b7cac869c07a427bd4d53b1 100644 (file)
 #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
index e4be296d929fe941e6063147387f4ee1870d4300..c65ec890715f4ad97373a267b194cdc8c597e71e 100644 (file)
 #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_
index 83f8c1ce4e1d7ff81c7cf285c1f2cd4bbb2e7292..0e43da55d8ad4cc7c5a07c2d21b728274e844c12 100644 (file)
@@ -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();
 
index 3482b339341aa25b7df0f354f1ed9f7b0f998b68..c359654e79449215fdb55c4cee7f7096dae10ea5 100644 (file)
@@ -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)
index cb7c5ba405b0d9c353e39f5b08f51d58bbff5917..8a4529edca4f1708aa657b5cc5c6cdd96e4e3cf7 100644 (file)
@@ -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
index 04d143c2e92ac6a747d91e0638fa598dcc2fba5b..bbe826196dd735bf3be4a03cb58364f6427a2133 100644 (file)
@@ -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;
index 3ec992e78ed1dd99aa3d6f16c8b1c7a6253890be..10e80637dbff11d2ae4332310bef2eda8c36ad42 100644 (file)
@@ -55,6 +55,7 @@ public:
     bool refresh = TRUE);
 
   void Command(wxCommandEvent& event);
+               virtual void                                            MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
 
 protected:
     int m_pageSize;
index 77f7dfa27b8bf4284621172dfc22f0919252329f..2498112208ca023be06182f41867ff44d84d7575 100644 (file)
  * 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
 // 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
                                   // but you can't mix them. Set to 1 for <iostream.h>,
                                   // 0 for <iostream>
 
+#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)
                                // 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_
index 239e914e5cedb657ef56e3cfd4dbc19d035d2046..e71b62fdb1854388776337295a12a764928d5d0e 100644 (file)
@@ -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;
index afdb978c3fc972cee771671b55d341b77a3a54a7..caa1b77db23a58b8fe0d403f0c40019163af2c9c 100644 (file)
@@ -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
index f371fddd2d00d35b417d065d1f039e02720ada39..f2162aeb10e6448d69cbca51858abff84c33f8af 100644 (file)
@@ -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
index 1aa4a6f88a5e0268b9134639f15c83899c7a57a3..a70d8e11c6c577a5f71b21166064779aca7be390 100644 (file)
@@ -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()
 };
index aa8eaf229eb9731065a8474cffd145c543ad046e..1117b6fc9aef7db2d0129785ea5fc6c3fd9a2eb4 100644 (file)
@@ -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)) {};
index 28567b19e1fed20b9e3dff8488b1df863378c4fc..a83d84ae336faf889064facb9aaf4948745908fc 100644 (file)
@@ -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
index 675e21bb3fcabe3f523f9cbfe46cfdd5580b0de2..da11bfad29451f6255cfd566b5461fbd4e7aa98c 100644 (file)
@@ -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
index e668d30bec94ea771125a332d26255bd304db86c..0f656dae8ff5965008b0fcdb309431901c09abc5 100644 (file)
@@ -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_
index e42c5827ef73f332b0d59ee68f8bf1f0a3fee289..6fe126b788ba707766c3d95e3f28248c6ef16400 100644 (file)
 #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_
index 0d37a8b0711a8ce7d965db4e1d18302e65f362ce..7c4bb6b097d1d29adba9f50d5a1f021f372e14eb 100644 (file)
 #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_
index e745060b5817c42bbce2746a8d27ccb3400df8ef..6c3befccb5064917f053cb7fe46f2ea324b0251f 100644 (file)
 
 #include <winsock.h>
 
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /* Definition of GSocket */
+typedef
 struct _GSocket
 {
   SOCKET m_fd;
index c8bf670a268f6dce83a53fe426ab6f5b68a0d21d..5480949118df0d0b9aa4bcd0500d31bacc0131d5 100644 (file)
 #ifndef _WX_CW__
 #define _WX_CW__
 
+#if __option(profile)
+#ifdef __cplusplus
+       #if __POWERPC__
+               #include <wx_PPC++_prof.mch>
+       #elif __INTEL__
+               #include <wx_x86++_prof.mch>
+       #elif __CFM68K__
+               #include <wx_cfm++_prof.mch>
+       #else
+               #include <wx_68k++_prof.mch>
+       #endif
+#else
+       #if __POWERPC__
+               #include <wx_PPC_prof.mch>
+       #elif __INTEL__
+               #include <wx_x86_prof.mch>
+       #elif __CFM68K__
+               #include <wx_cfm_prof.mch>
+       #else
+               #include <wx_68k_prof.mch>
+       #endif
+#endif
+#else
 #ifdef __cplusplus
        #if __POWERPC__
                #include <wx_PPC++.mch>
@@ -33,6 +56,6 @@
                #include <wx_68k.mch>
        #endif
 #endif
-
+#endif
 #endif
     // _WX_CW__
index dd2c3fa06c5fcc4b8f98af0af2e26e6ac1a8a373..2fe7cf96783d286a3296d5964489bacff194b0f0 100644 (file)
@@ -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 <MacHeadersPPCX++>
+                       #else
+                                       #include <MacHeadersPPCX>
+                       #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__
 #ifdef __WXMSW__
     #include <ansi_prefix.win32.h>
     #include <ansi_parms.h>
+    #ifdef __MWERKS__
     #if defined( __MSL__ ) && __MSL__ >= 0x5012
                        #define fileno  _fileno
                        #define fdopen  _fdopen
                        #define tell    _tell
     #endif
+    #endif
 #elif defined( __WXMAC__)
     #include <ansi_prefix.mac.h>
 #endif
 
 #define USE_DEFINE
+
 // in order to avoid problems further down in wxWindows
 
 #ifdef __cplusplus
+
 extern "C" 
 {
 #endif
index f56d8cdc0ab5ab2c4352260a552fdad03b68071b..75a2a5ed2e8bc9ce0b2449c45e965e88165c8368 100644 (file)
@@ -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 <wx_PPC++_d.mch>
@@ -33,6 +36,7 @@
                #include <wx_68k_d.mch>
        #endif
 #endif
+#endif
 
 #endif
     // _WX_CW__
index c5efcf3859554275079502904a6292530ccdc930..8a5a49d142321674d07d897398b9365b5bb80e94 100644 (file)
@@ -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"
index 8ff1e4604ba5acb3d041e018221a4805592751f5..a9f69244735bcc7d88022a08a94f91e0304665b0 100644 (file)
@@ -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
index 12b3530b86df26151d19e5de46810c3d700099f3..a38cd139e540a9f1f0f0362a0569b8598b4915c5 100644 (file)
@@ -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"
        
 #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 <windows.h>
+    #include "wx/msw/winundef.h"
+#endif
index 4659812a8b0d2b33f872e5886449db1130d5e7b8..cb5643a468b785601ad15fd9f96c8ae8e8b4c411 100644 (file)
@@ -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
index 3c6afea84468c9da332caf0b750afca416c20ed1..2ebf9199b816fbf93a6807749bd2fe37c3213ed8 100644 (file)
Binary files a/samples/help/doc/ClassGraph.class and b/samples/help/doc/ClassGraph.class differ
index 4e3b5162cb2ae3b64c20d7b16d5e2918121d36df..4c0f4f9e1bf864921b12b0634f8785045566ec6c 100644 (file)
Binary files a/samples/help/doc/ClassGraphPanel.class and b/samples/help/doc/ClassGraphPanel.class differ
index 40eb67e0e98927ee4f295707fa8d0b1dc7888374..46457cfdd1ddf861a6bd933502949490199e45cc 100644 (file)
Binary files a/samples/help/doc/ClassLayout.class and b/samples/help/doc/ClassLayout.class differ
index 9f447021d04f4e91483db54bf2d21718de3f4f43..0c1e6cdd422f0027197d61492e4357a51a6e200b 100644 (file)
Binary files a/samples/help/doc/NavigatorButton.class and b/samples/help/doc/NavigatorButton.class differ
index 073e09d2523ef49cb822f9e88fa7d1a125cee1e4..91f822b73663b11b1e95f8c8b5b66f09816dd794 100644 (file)
@@ -96,6 +96,10 @@ DbList WXDLLEXPORT *PtrBegDbList = 0;
        extern wxList TablesInUse;
 #endif
 
+#ifdef __MWERKS__
+#define stricmp _stricmp
+#define strnicmp _strnicmp
+#endif
 // SQL Log defaults to be used by GetDbConnection
 enum sqlLog SQLLOGstate                                = sqlLogOFF;
 
index 1bec4d64fb7083239e4a650ebadd876cff2ae674..1ee5fb07eda4dfed86ba1a7123b5368d8fa1b74f 100644 (file)
        #include "wx/dbtable.h"
 #endif
 
+#ifdef __MWERKS__
+#define stricmp _stricmp
+#define strnicmp _strnicmp
+#endif
+
 #ifdef __UNIX__
 // The HPUX preprocessor lines below were commented out on 8/20/97
 // because macros.h currently redefines DEBUG and is unneeded.
index cb112f0642a954a7cfe16c06b579140416581dfc..0f7a63316572f5aa12582fd38cc4dd34d8598285 100644 (file)
@@ -45,7 +45,7 @@
 #include "wx/socket.h"
 
 
-#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMOTIF__)
+#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMOTIF__) || defined(__WXMAC__)
     #define PROCESS_EVENTS() wxYield()
 #elif defined(__WXGTK__)
     #include <gtk/gtk.h>
index 83d28b7bdb14365ca13bc5cac9261c294b96b4ff..7367459c4c7aac71537804879e2fe71ffdfa3107 100644 (file)
 /* 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
index 3061f99aeaeda5ecf31808a1ab6300fc92e43359..fd5a0009b06d358b9b217c14d4c27f45ac84da6f 100644 (file)
 
 // mac
 
+#if __option(profile)
+       #include <profiler.h>
+#endif 
+
 #include "apprsrc.h"
 
+#include <wx/mac/uma.h>
+
 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 ) , &currentMouseWindow ) ; 
+                               
+                               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
index 408a135a9f25428b367df9afe2cf6e8a00ae8393..343157d8d1e636dde6fd82e288274e2df7e06464 100644 (file)
@@ -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
index 1e6255f55162f1ea94dba34153f66508a6906847..3a66121d493152449872e4bf661e882abaad6552 100644 (file)
 #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 <PictUtils.h>
+
+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);
 }
index 4f28e92f53475598e8fb475fd7b1a0d387d7e90d..cb9d76d1ab28ca05b8bc687c4d0080cabc5feb5c 100644 (file)
@@ -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;
 }
 
index befd0d71564ad3486bddfb4281f03acd6fd16e9d..cb447864436f46509010b71e92df25801593cfa2 100644 (file)
 IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
 #endif
 
+#include <wx/mac/uma.h>
 // 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);
 }
 
index 3061f99aeaeda5ecf31808a1ab6300fc92e43359..fd5a0009b06d358b9b217c14d4c27f45ac84da6f 100644 (file)
 
 // mac
 
+#if __option(profile)
+       #include <profiler.h>
+#endif 
+
 #include "apprsrc.h"
 
+#include <wx/mac/uma.h>
+
 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 ) , &currentMouseWindow ) ; 
+                               
+                               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
index 408a135a9f25428b367df9afe2cf6e8a00ae8393..343157d8d1e636dde6fd82e288274e2df7e06464 100644 (file)
@@ -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
index 1e6255f55162f1ea94dba34153f66508a6906847..3a66121d493152449872e4bf661e882abaad6552 100644 (file)
 #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 <PictUtils.h>
+
+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);
 }
index 4f28e92f53475598e8fb475fd7b1a0d387d7e90d..cb9d76d1ab28ca05b8bc687c4d0080cabc5feb5c 100644 (file)
@@ -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;
 }
 
index befd0d71564ad3486bddfb4281f03acd6fd16e9d..cb447864436f46509010b71e92df25801593cfa2 100644 (file)
 IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
 #endif
 
+#include <wx/mac/uma.h>
 // 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);
 }
 
index dd2e2abe7ab8f644876b4e370b3ce0e77961ef75..ca99c4b778bbfe036bad4482e3ca4f1a4ade410d 100644 (file)
@@ -20,6 +20,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
 #endif
 
+#include <wx/mac/uma.h>
+
 // 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)
index a584d5303fb41c40ef4ba78fe4aa66f5e8b13818..da3c4efc925bdd5db6eb8cbf9149c30a8e5e7130 100644 (file)
@@ -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
index 3fe9ebfb72bd1051ee93be1ef95df8aac44dea26..28a4b9ef3f793e2311c40ba9c4433c6c8ddfbf47 100644 (file)
@@ -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)
index 2275a9a39d679502d0a4c20e4d09c29009dc9445..c6037a9f964eb9959db27a0dc3f02957e76028e4 100644 (file)
@@ -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.", &currentColor, &newColor ))
+       {
+               m_colourData.dataColour.Set( newColor ) ;
+       return wxID_OK;
+       }
+       else
+       {
+       return wxID_CANCEL;
+       }
 
     return wxID_CANCEL;
 }
index 8d0827ef1d7f1536832bf8c34eb3feb2e154cecb..cc549b5f1144e11e602a5fad4b94f8132ab95a14 100644 (file)
@@ -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 ) ;
 }
index 0be841bad4dabe1a3db99195f50a26b7b2419441..905f3180aa4bc0af8bed2c60774a2725ee19d3e3 100644 (file)
 #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();
 }
+
index b141a80ff1c9bc933cc4af9101ff80adb24cb527..d570e2c5a1ee02a7a0129150830ca9e1cffc83d0 100644 (file)
 #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 <wx/mac/uma.h>
+
 // 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(&currentX, &currentY);
+  int currentW,currentH;
+  GetSize(&currentW, &currentH);
+
+  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" ) ;
+}
+
index a37b064b216e710ece00f717c5ea90bf1d3c4506..528e79481115b5ef3117c596dee59a98b81d4ff8 100644 (file)
@@ -1,8 +1,50 @@
 #include <Types.r>
 
-resource 'ALRT' (128, purgeable) {
+#if UNIVERSAL_INTERFACES_VERSION > 0x320
+       #include <ControlDefinitions.r>
+#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
index 4333364c931cc08c781cc38f2998b2fc29bc69c8..bcbe30008b84c592cd30444e29edbee1092d5c05 100644 (file)
 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() ;
 }
 
 
index 138289a5bf4f5ca7ab402b0cd4761f81d876da7c..297686b9d1989b0dfe53c3564ed2e448de3ecc65 100644 (file)
@@ -25,7 +25,7 @@
 char *wxBuffer = NULL;
 
 // Windows List
-wxList wxTopLevelWindows;
+wxWindowList wxTopLevelWindows;
 
 // List of windows pending deletion
 wxList wxPendingDelete;
index 2c1c613595e27d5a9f17345e534f8dda57a4e3f3..e021274157dd889050aae4946cd8a80b0fd1a2a3 100644 (file)
@@ -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 ;
+}
+
+
index 925d9609ee1771b240d3b41f8196b63cdcf3dfc1..08aeff0504b08756924ad120d8b3b94c8ace8340 100644 (file)
@@ -38,598 +38,78 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
  * wxWindowDC
  */
 
+#include <wx/mac/uma.h>
+
 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 );
-};
+}
index 7cbd330821f76b4c97a124689b631d859e829e03..28a652368a97e41c1058b70f1469f67367563a3d 100644 (file)
@@ -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
   {
index e03bbac0c80d8fbfbb86a792919de9e65948729c..1ea12f3d29c45024a2ef8e5d73f94163ebfbf70c 100644 (file)
@@ -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()
index bf3cae5e352be74e0494d910408c79df3bdbac97..7e82133eb223c23f0b4cbe683d074314e1020453 100644 (file)
@@ -19,6 +19,8 @@
 #include "wx/app.h"
 #include "wx/settings.h"
 
+#include <wx/mac/uma.h>
+
 // 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;
+}
+
index 095621b978ebe12a862622298ae8d5f1f48db38d..edfc211caa05465c25cd36acde69e55c778c1d88 100644 (file)
 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;
 }
 
index b6f5b1912dfc28663d161dfb4d5d88c2a79c5fe1..66de687b80b6f5ebeffc3376fec4455d6d4aa5b5 100644 (file)
 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;
 }
 
index 493a6a25baf3dbd7c84cbf073f857397f7e6b494..2409e1a38b170a92c1b809aaeb10d25bd079cd4d 100644 (file)
@@ -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()
index 60e8e9b987958d84ca818de0d767cad90438f9c3..d775c24c169eeefdea89bd141b3df424f2226783 100644 (file)
@@ -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
index 55f1e3b72c132d90555fbc6622ae329c906f76f5..5a95ac9097692e320a1deb4e203e48418191feea 100644 (file)
@@ -23,6 +23,8 @@
 #include "wx/settings.h"
 #include "wx/app.h"
 
+#include <wx/mac/uma.h>
+
 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( &currentclientwidth , &currentclientheight ) ;
+       GetSize( &currentwidth , &currentheight ) ;
+       
+       // 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
index a85fbc498ffacbc22cc601acc40b6835be0ffb0a..7dc3b5e8133e9435f0faec3340983159249815ed 100644 (file)
 IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
 #endif
 
+#include <wx/mac/uma.h>
+
 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;
 }
 
index 6deee7dbdc2d7baea731c76061cf01cda56e13ed..537165343e72e87a96ec2bf6ac7b8bbd81daf955 100644 (file)
@@ -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
index 1dad21e12c4167ff042aa439ebb08261f70c4caf..e17f1b8213b7c9e92488ff23dad784160ff0aa4f 100644 (file)
 #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 <wx/mac/uma.h>
+
+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) ; 
+}
index d5d55d86d46f87da87d5bbce2ece6bd74227f477..5bd62163fd42e2e75a43ca2133cdadc664da28d1 100644 (file)
@@ -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 \
index 1fc7c4a22941326f98c5bf900b6c9a354c2200d9..b22001b870b32f575de8fcda9122758d5177a9f4 100644 (file)
@@ -27,6 +27,8 @@
 #include "wx/log.h"
 #include "wx/utils.h"
 
+#include "wx/mac/uma.h"
+
 // other standard headers
 // ----------------------
 #include <string.h>
@@ -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 ? \8e_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 ;
+               }
+               }
+       }
+}
 
index 38d31737e7704c9429e23872d12ee6a04634eaa6..9195fdc50a13b75b6b525c61d132c60f56754069 100644 (file)
@@ -16,6 +16,7 @@
 #include "wx/menu.h"
 #include "wx/menuitem.h"
 
+#include <wx/mac/uma.h>
 // ============================================================================
 // 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
index ddbfb8402ffb5140bb2ffe808dda731aef14ba47..97e31948bf9db3a05d19b4190b481f2cec35de83 100644 (file)
 #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 <stdio.h>
+#include <string.h>
+
 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
-
index 775ac8f06415ee18d97780f8b10682c349a62bb6..5aa8554038e4959c5e492e2f80a5c1c413f5f1ec 100644 (file)
 #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, &param, &result );
+         else if (m_dialogStyle & wxICON_HAND)
+                               StandardAlert( kAlertStopAlert, pascalTitle, pascalText, &param, &result );
+         else if (m_dialogStyle & wxICON_INFORMATION)
+                       StandardAlert( kAlertNoteAlert, pascalTitle, pascalText, &param, &result );
+         else if (m_dialogStyle & wxICON_QUESTION)
+                               StandardAlert( kAlertCautionAlert, pascalTitle, pascalText, &param, &result );
+               else
+                               StandardAlert( kAlertPlainAlert, pascalTitle, pascalText, &param, &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 ;
 }
 
index 312dd0f3d3ae8a62ddf0ac466bb04cd20a4c5aa9..a4f93917eb93c6a26ecb3eae157a7d41bcbc9093 100644 (file)
@@ -24,7 +24,7 @@
 #include  <wx/log.h>
 #include  <wx/imaglist.h>
 #include  <wx/notebook.h>
-
+#include <wx/mac/uma.h>
 // ----------------------------------------------------------------------------
 // macros
 // ----------------------------------------------------------------------------
 // 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);
+}
+
index f8db96f8d0894b7970275f7565fed661a7516cea..85a9fd16d8346f140ac9127f71b2217f94747e27 100644 (file)
@@ -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;
 }
 
 
index 61fd6e7e993835abbbd6d9bd7d9c27a7c9ca03c5..1064058925d102b910c961361acefaac3377a549 100644 (file)
@@ -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)
index eae3b95568777cc53ac4ed40f4e0f8b6a778cd09..18c7a8427e244c53973cb4c1a70e6d3882ec41ba 100644 (file)
 #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 ;
 }
 
index da582d0e52ef7fcb9755e3b355a3df8dda5785be..3393009f47ea2200ae0cca2a62018f192a4e182a 100644 (file)
@@ -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
 }
 
index c71d4c605a45a15004c399c66b2a1577e4c6e716..c5c6332e06fbd1c45a0f00372d4a252a2f3aadce 100644 (file)
@@ -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;
     }
 }
 
index a92154acfb116da48cde9e08a556a83c2ecff8ee..a432b3e9b122d7542304fc72e50333712a16c4c8 100644 (file)
@@ -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);
+}
+
index 2beda5c2a6896dee8513827fa63bc8eabb8af5e7..b13b5733ccc9f314816194d8f03ae89ffdd01628 100644 (file)
 
 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;
 }
index c9952342a968bc6f464811f2f05a047ee51d4028..936ccddb477dfede68c3a6e1bb809583925c08cf 100644 (file)
@@ -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
+}
index cbea725592c8f95dac6f02e666f996866107b16e..8f3e1533b86bad4403aad5c260b58ccd170d233c 100644 (file)
@@ -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);
+}
+
+
index a67c55846579664d9442eb2c4d7d1d76207e5d56..721c2542348307ccd730a6533923bba23238b590 100644 (file)
@@ -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 ) ;
 }
 
index b239dc738c830175d1f18afc795245ca00b4ecee..abae14d07e2a1a03c8cb029640840d84b34e82d5 100644 (file)
@@ -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
-}
-
index 3b19c7184dbe9748fbb2adba56d8cd2f840134dc..14c69f1d96917abe4c96e9b5b1f9bd4b33084570 100644 (file)
@@ -22,6 +22,8 @@
 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
 #endif
 
+#include <wx/mac/uma.h>
+
 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() ;
 }
 
index dff1ddec349d403d75c6596fff23fa53337937d7..15ab99d5ac82c6c4991eb95c3b783ed9d21ba1a0 100644 (file)
@@ -17,7 +17,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
-#include "wx/stubs/statusbr.h"
+#include "wx/mac/statusbr.h"
 
 #if     !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar);
index b3b45a72d12a038b60322fd7c374ac7ca3108551..ea057aae520a2607ca18ac0ac57a9d7b6415f995 100644 (file)
@@ -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()
index a2b5e7d38effbe43e23612fb33c0be7463d4917e..d553477f93b6aa315fda8a05f98fa0d075a306d2 100644 (file)
 #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
 
index 3cb859e3663f8890c53ac03a83946a4211578515..0620c12afb0d45331c97c321f45f5e1c8a327c1b 100644 (file)
@@ -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 <wx/mac/uma.h>
+
 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
+
index 940bdc21bc70afca29338f5312137ea167ba7d5a..817138cb63f2d440462b7e347bb721103d613970 100644 (file)
@@ -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() ;
 }
 
index c25681858c1ff36786d670c8a5d2366a617c25a2..804d07a0972b33184ee30d10ed87836353652e32 100644 (file)
@@ -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)
index a54fd3331d66f33a34bf6fa0579c9e64a314eaae..e8015acc3be10154222c399832802e0b086aec3a 100644 (file)
@@ -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"
 #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 <wx/mac/uma.h>
+
 #if  wxUSE_DRAG_AND_DROP
 #include "wx/dnd.h"
 #endif
@@ -38,6 +48,7 @@
 #include <string.h>
 
 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(&currentX, &currentY);
+  int currentW,currentH;
+  GetSize(&currentW, &currentH);
+
+  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();
+}
 
index dd2e2abe7ab8f644876b4e370b3ce0e77961ef75..ca99c4b778bbfe036bad4482e3ca4f1a4ade410d 100644 (file)
@@ -20,6 +20,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
 #endif
 
+#include <wx/mac/uma.h>
+
 // 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)
index a584d5303fb41c40ef4ba78fe4aa66f5e8b13818..da3c4efc925bdd5db6eb8cbf9149c30a8e5e7130 100644 (file)
@@ -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
index 3fe9ebfb72bd1051ee93be1ef95df8aac44dea26..28a4b9ef3f793e2311c40ba9c4433c6c8ddfbf47 100644 (file)
@@ -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)
index 2275a9a39d679502d0a4c20e4d09c29009dc9445..c6037a9f964eb9959db27a0dc3f02957e76028e4 100644 (file)
@@ -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.", &currentColor, &newColor ))
+       {
+               m_colourData.dataColour.Set( newColor ) ;
+       return wxID_OK;
+       }
+       else
+       {
+       return wxID_CANCEL;
+       }
 
     return wxID_CANCEL;
 }
index 8d0827ef1d7f1536832bf8c34eb3feb2e154cecb..cc549b5f1144e11e602a5fad4b94f8132ab95a14 100644 (file)
@@ -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 ) ;
 }
index 0be841bad4dabe1a3db99195f50a26b7b2419441..905f3180aa4bc0af8bed2c60774a2725ee19d3e3 100644 (file)
 #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();
 }
+
index b141a80ff1c9bc933cc4af9101ff80adb24cb527..d570e2c5a1ee02a7a0129150830ca9e1cffc83d0 100644 (file)
 #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 <wx/mac/uma.h>
+
 // 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(&currentX, &currentY);
+  int currentW,currentH;
+  GetSize(&currentW, &currentH);
+
+  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" ) ;
+}
+
index a37b064b216e710ece00f717c5ea90bf1d3c4506..528e79481115b5ef3117c596dee59a98b81d4ff8 100644 (file)
@@ -1,8 +1,50 @@
 #include <Types.r>
 
-resource 'ALRT' (128, purgeable) {
+#if UNIVERSAL_INTERFACES_VERSION > 0x320
+       #include <ControlDefinitions.r>
+#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
index 4333364c931cc08c781cc38f2998b2fc29bc69c8..bcbe30008b84c592cd30444e29edbee1092d5c05 100644 (file)
 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() ;
 }
 
 
index 138289a5bf4f5ca7ab402b0cd4761f81d876da7c..297686b9d1989b0dfe53c3564ed2e448de3ecc65 100644 (file)
@@ -25,7 +25,7 @@
 char *wxBuffer = NULL;
 
 // Windows List
-wxList wxTopLevelWindows;
+wxWindowList wxTopLevelWindows;
 
 // List of windows pending deletion
 wxList wxPendingDelete;
index 2c1c613595e27d5a9f17345e534f8dda57a4e3f3..e021274157dd889050aae4946cd8a80b0fd1a2a3 100644 (file)
@@ -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 ;
+}
+
+
index 925d9609ee1771b240d3b41f8196b63cdcf3dfc1..08aeff0504b08756924ad120d8b3b94c8ace8340 100644 (file)
@@ -38,598 +38,78 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
  * wxWindowDC
  */
 
+#include <wx/mac/uma.h>
+
 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 );
-};
+}
index 7cbd330821f76b4c97a124689b631d859e829e03..28a652368a97e41c1058b70f1469f67367563a3d 100644 (file)
@@ -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
   {
index e03bbac0c80d8fbfbb86a792919de9e65948729c..1ea12f3d29c45024a2ef8e5d73f94163ebfbf70c 100644 (file)
@@ -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()
index bf3cae5e352be74e0494d910408c79df3bdbac97..7e82133eb223c23f0b4cbe683d074314e1020453 100644 (file)
@@ -19,6 +19,8 @@
 #include "wx/app.h"
 #include "wx/settings.h"
 
+#include <wx/mac/uma.h>
+
 // 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;
+}
+
index 095621b978ebe12a862622298ae8d5f1f48db38d..edfc211caa05465c25cd36acde69e55c778c1d88 100644 (file)
 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;
 }
 
index b6f5b1912dfc28663d161dfb4d5d88c2a79c5fe1..66de687b80b6f5ebeffc3376fec4455d6d4aa5b5 100644 (file)
 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;
 }
 
index 493a6a25baf3dbd7c84cbf073f857397f7e6b494..2409e1a38b170a92c1b809aaeb10d25bd079cd4d 100644 (file)
@@ -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()
index 60e8e9b987958d84ca818de0d767cad90438f9c3..d775c24c169eeefdea89bd141b3df424f2226783 100644 (file)
@@ -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
index 55f1e3b72c132d90555fbc6622ae329c906f76f5..5a95ac9097692e320a1deb4e203e48418191feea 100644 (file)
@@ -23,6 +23,8 @@
 #include "wx/settings.h"
 #include "wx/app.h"
 
+#include <wx/mac/uma.h>
+
 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( &currentclientwidth , &currentclientheight ) ;
+       GetSize( &currentwidth , &currentheight ) ;
+       
+       // 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
index a85fbc498ffacbc22cc601acc40b6835be0ffb0a..7dc3b5e8133e9435f0faec3340983159249815ed 100644 (file)
 IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
 #endif
 
+#include <wx/mac/uma.h>
+
 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;
 }
 
index 6deee7dbdc2d7baea731c76061cf01cda56e13ed..537165343e72e87a96ec2bf6ac7b8bbd81daf955 100644 (file)
@@ -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
index 1dad21e12c4167ff042aa439ebb08261f70c4caf..e17f1b8213b7c9e92488ff23dad784160ff0aa4f 100644 (file)
 #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 <wx/mac/uma.h>
+
+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) ; 
+}
index d5d55d86d46f87da87d5bbce2ece6bd74227f477..5bd62163fd42e2e75a43ca2133cdadc664da28d1 100644 (file)
@@ -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 \
index 1fc7c4a22941326f98c5bf900b6c9a354c2200d9..b22001b870b32f575de8fcda9122758d5177a9f4 100644 (file)
@@ -27,6 +27,8 @@
 #include "wx/log.h"
 #include "wx/utils.h"
 
+#include "wx/mac/uma.h"
+
 // other standard headers
 // ----------------------
 #include <string.h>
@@ -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 ? \8e_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 ;
+               }
+               }
+       }
+}
 
index 38d31737e7704c9429e23872d12ee6a04634eaa6..9195fdc50a13b75b6b525c61d132c60f56754069 100644 (file)
@@ -16,6 +16,7 @@
 #include "wx/menu.h"
 #include "wx/menuitem.h"
 
+#include <wx/mac/uma.h>
 // ============================================================================
 // 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
index ddbfb8402ffb5140bb2ffe808dda731aef14ba47..97e31948bf9db3a05d19b4190b481f2cec35de83 100644 (file)
 #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 <stdio.h>
+#include <string.h>
+
 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
-
index 775ac8f06415ee18d97780f8b10682c349a62bb6..5aa8554038e4959c5e492e2f80a5c1c413f5f1ec 100644 (file)
 #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, &param, &result );
+         else if (m_dialogStyle & wxICON_HAND)
+                               StandardAlert( kAlertStopAlert, pascalTitle, pascalText, &param, &result );
+         else if (m_dialogStyle & wxICON_INFORMATION)
+                       StandardAlert( kAlertNoteAlert, pascalTitle, pascalText, &param, &result );
+         else if (m_dialogStyle & wxICON_QUESTION)
+                               StandardAlert( kAlertCautionAlert, pascalTitle, pascalText, &param, &result );
+               else
+                               StandardAlert( kAlertPlainAlert, pascalTitle, pascalText, &param, &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 ;
 }
 
index 312dd0f3d3ae8a62ddf0ac466bb04cd20a4c5aa9..a4f93917eb93c6a26ecb3eae157a7d41bcbc9093 100644 (file)
@@ -24,7 +24,7 @@
 #include  <wx/log.h>
 #include  <wx/imaglist.h>
 #include  <wx/notebook.h>
-
+#include <wx/mac/uma.h>
 // ----------------------------------------------------------------------------
 // macros
 // ----------------------------------------------------------------------------
 // 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);
+}
+
index f8db96f8d0894b7970275f7565fed661a7516cea..85a9fd16d8346f140ac9127f71b2217f94747e27 100644 (file)
@@ -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;
 }
 
 
index 61fd6e7e993835abbbd6d9bd7d9c27a7c9ca03c5..1064058925d102b910c961361acefaac3377a549 100644 (file)
@@ -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)
index eae3b95568777cc53ac4ed40f4e0f8b6a778cd09..18c7a8427e244c53973cb4c1a70e6d3882ec41ba 100644 (file)
 #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 ;
 }
 
index da582d0e52ef7fcb9755e3b355a3df8dda5785be..3393009f47ea2200ae0cca2a62018f192a4e182a 100644 (file)
@@ -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
 }
 
index c71d4c605a45a15004c399c66b2a1577e4c6e716..c5c6332e06fbd1c45a0f00372d4a252a2f3aadce 100644 (file)
@@ -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;
     }
 }
 
index a92154acfb116da48cde9e08a556a83c2ecff8ee..a432b3e9b122d7542304fc72e50333712a16c4c8 100644 (file)
@@ -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);
+}
+
index 2beda5c2a6896dee8513827fa63bc8eabb8af5e7..b13b5733ccc9f314816194d8f03ae89ffdd01628 100644 (file)
 
 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;
 }
index c9952342a968bc6f464811f2f05a047ee51d4028..936ccddb477dfede68c3a6e1bb809583925c08cf 100644 (file)
@@ -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
+}
index cbea725592c8f95dac6f02e666f996866107b16e..8f3e1533b86bad4403aad5c260b58ccd170d233c 100644 (file)
@@ -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);
+}
+
+
index a67c55846579664d9442eb2c4d7d1d76207e5d56..721c2542348307ccd730a6533923bba23238b590 100644 (file)
@@ -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 ) ;
 }
 
index b239dc738c830175d1f18afc795245ca00b4ecee..abae14d07e2a1a03c8cb029640840d84b34e82d5 100644 (file)
@@ -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
-}
-
index 3b19c7184dbe9748fbb2adba56d8cd2f840134dc..14c69f1d96917abe4c96e9b5b1f9bd4b33084570 100644 (file)
@@ -22,6 +22,8 @@
 IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
 #endif
 
+#include <wx/mac/uma.h>
+
 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() ;
 }
 
index dff1ddec349d403d75c6596fff23fa53337937d7..15ab99d5ac82c6c4991eb95c3b783ed9d21ba1a0 100644 (file)
@@ -17,7 +17,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
-#include "wx/stubs/statusbr.h"
+#include "wx/mac/statusbr.h"
 
 #if     !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar);
index b3b45a72d12a038b60322fd7c374ac7ca3108551..ea057aae520a2607ca18ac0ac57a9d7b6415f995 100644 (file)
@@ -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()
index a2b5e7d38effbe43e23612fb33c0be7463d4917e..d553477f93b6aa315fda8a05f98fa0d075a306d2 100644 (file)
 #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
 
index 3cb859e3663f8890c53ac03a83946a4211578515..0620c12afb0d45331c97c321f45f5e1c8a327c1b 100644 (file)
@@ -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 <wx/mac/uma.h>
+
 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
+
index 940bdc21bc70afca29338f5312137ea167ba7d5a..817138cb63f2d440462b7e347bb721103d613970 100644 (file)
@@ -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() ;
 }
 
index c25681858c1ff36786d670c8a5d2366a617c25a2..804d07a0972b33184ee30d10ed87836353652e32 100644 (file)
@@ -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)
index a54fd3331d66f33a34bf6fa0579c9e64a314eaae..e8015acc3be10154222c399832802e0b086aec3a 100644 (file)
@@ -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"
 #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 <wx/mac/uma.h>
+
 #if  wxUSE_DRAG_AND_DROP
 #include "wx/dnd.h"
 #endif
@@ -38,6 +48,7 @@
 #include <string.h>
 
 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(&currentX, &currentY);
+  int currentW,currentH;
+  GetSize(&currentW, &currentH);
+
+  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();
+}
 
index f3d0a6727bdde376d28e5107415288a76190c825..e65785791dd66aefec0ebe347dcb8061677746d3 100644 (file)
@@ -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)
index 326b7c786787f25de36e3ac26f20ae09817e1437..f1ad7558e4917c38d1dafc49f7bccac10219adee 100644 (file)
Binary files a/user/wxTest/horse.png and b/user/wxTest/horse.png differ
index a9a1e46844cb79b3a787ae9bb3e6e2d508bf03df..83f0742f96d4621cd489b4183742ddbdb2bed2c0 100644 (file)
Binary files a/utils/dialoged/docs/books.gif and b/utils/dialoged/docs/books.gif differ
index ae430e334576ccc77c788a042dccda4ff62bae84..656e658287839b27a9fb3bc90cc3b2f589503bc3 100644 (file)
Binary files a/utils/dialoged/docs/dialog.gif and b/utils/dialoged/docs/dialog.gif differ
index 9c81e8c92fed7fe851ce02e7854dc26a58eae9b2..9c8421838a9822c3bcc3d5b9a40732a72647b558 100644 (file)
Binary files a/utils/dialoged/docs/forward.gif and b/utils/dialoged/docs/forward.gif differ
index af79fe1aef58a40ea131f9d7c82201cf74ba1d0d..237d885fbef1495844c149c4216437fb0a8a0670 100644 (file)
Binary files a/utils/dialoged/docs/gauge.gif and b/utils/dialoged/docs/gauge.gif differ
index ff09220da3e1912f64891777c0cef2e7c16e8bfa..6b9ca4f6409818cbae26ff21267c4ca2b3af30cc 100644 (file)
Binary files a/utils/dialoged/docs/tofront.gif and b/utils/dialoged/docs/tofront.gif differ
index 316d0d2a14b571bea2eb874efd04bfe509f53b34..f9e7031e64cf9bd17eac8190eefce2526d90a052 100644 (file)
Binary files a/utils/dialoged/docs/up.gif and b/utils/dialoged/docs/up.gif differ