From 0a67a93b17c37c018f60e662645ee2a44ba4e58e Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 8 May 2001 07:29:46 +0000 Subject: [PATCH] mac fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10045 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/mac/install.txt | 8 + include/wx/mac/dc.h | 190 ----------------------- include/wx/mac/dcmemory.h | 2 +- include/wx/mac/glcanvas.h | 121 +++++++++++++++ include/wx/mac/mdi.h | 14 +- include/wx/mac/notebook.h | 2 +- include/wx/mac/radiobut.h | 11 +- include/wx/mac/setup.h | 2 + include/wx/mac/window.h | 4 +- src/mac/app.cpp | 54 ++++++- src/mac/button.cpp | 12 +- src/mac/carbon/app.cpp | 54 ++++++- src/mac/carbon/button.cpp | 12 +- src/mac/carbon/combobox.cpp | 3 +- src/mac/carbon/control.cpp | 2 + src/mac/carbon/dc.cpp | 23 --- src/mac/carbon/dcclient.cpp | 1 + src/mac/carbon/dcmemory.cpp | 10 +- src/mac/carbon/frame.cpp | 17 +-- src/mac/carbon/glcanvas.cpp | 290 ++++++++++++++++++++++++++++++++++++ src/mac/carbon/macnotfy.cpp | 1 - src/mac/carbon/mdi.cpp | 140 ++++++++++++----- src/mac/carbon/radiobox.cpp | 7 +- src/mac/carbon/radiobut.cpp | 74 +++------ src/mac/carbon/slider.cpp | 19 +-- src/mac/carbon/statbmp.cpp | 2 +- src/mac/carbon/textctrl.cpp | 4 +- src/mac/carbon/toolbar.cpp | 2 +- src/mac/carbon/utils.cpp | 90 ++++++++--- src/mac/carbon/window.cpp | 41 ++--- src/mac/combobox.cpp | 3 +- src/mac/control.cpp | 2 + src/mac/dc.cpp | 23 --- src/mac/dcclient.cpp | 1 + src/mac/dcmemory.cpp | 10 +- src/mac/frame.cpp | 17 +-- src/mac/glcanvas.cpp | 290 ++++++++++++++++++++++++++++++++++++ src/mac/macnotfy.cpp | 1 - src/mac/mdi.cpp | 140 ++++++++++++----- src/mac/radiobox.cpp | 7 +- src/mac/radiobut.cpp | 74 +++------ src/mac/slider.cpp | 19 +-- src/mac/statbmp.cpp | 2 +- src/mac/textctrl.cpp | 4 +- src/mac/toolbar.cpp | 2 +- src/mac/utils.cpp | 90 ++++++++--- src/mac/window.cpp | 41 ++--- 47 files changed, 1328 insertions(+), 610 deletions(-) create mode 100644 include/wx/mac/glcanvas.h create mode 100644 src/mac/carbon/glcanvas.cpp create mode 100644 src/mac/glcanvas.cpp diff --git a/docs/mac/install.txt b/docs/mac/install.txt index 2f188666e3..63e88368e9 100644 --- a/docs/mac/install.txt +++ b/docs/mac/install.txt @@ -31,6 +31,14 @@ CodeWarrior Pro 5:Pre-Release:Carbon & MacOSX Development:Carbonized MSL and CodeWarrior Pro 5:Pre-Release:Carbon & MacOSX Development:Carbonized Runtimes (consult the file CodeWarrior Pro 5:Pre-Release:Carbon & MacOSX Development:Carbon & MacOSX README) +OpenGL +------ + +in order to build opengl support you must install the opengl libraries and headers from +http://developer.apple.com/opengl/index.html + +if you don't want OpenGL support, set the wxUSE_OPENGL in mac/setup.h to 0 + Project Files ------------- diff --git a/include/wx/mac/dc.h b/include/wx/mac/dc.h index 19b29a926d..e59e0164b9 100644 --- a/include/wx/mac/dc.h +++ b/include/wx/mac/dc.h @@ -103,196 +103,6 @@ class WXDLLEXPORT wxDC: public wxDCBase virtual void SetTextForeground(const wxColour& colour) ; virtual void SetTextBackground(const wxColour& colour) ; -// -// - -/* - void BeginDrawing(void) {}; - void EndDrawing(void) {}; - - virtual bool Ok(void) const { return m_ok; }; - - 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 ; - 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 ); - 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 ); - 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 ); - 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 ); - 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 ); - virtual void DrawPoint( wxPoint& point ); - - 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 ); - inline void DrawRectangle(const wxPoint& pt, const wxSize& sz) - { - DrawRectangle(pt.x, pt.y, sz.x, sz.y); - } - inline void DrawRectangle(const wxRect& rect) - { - DrawRectangle(rect.x, rect.y, rect.width, rect.height); - } - 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); - } - inline void DrawRoundedRectangle(const wxRect& rect, double radius = 20.0) - { - DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, radius); - } - - 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); - } - inline void DrawEllipse(const wxRect& rect) - { - DrawEllipse(rect.x, rect.y, rect.width, rect.height); - } - - virtual void DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 ); - virtual void DrawSpline( wxList *points ); - virtual void DrawSpline( int n, wxPoint points[] ); - - 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) - { - DrawIcon(icon, pt.x, pt.y); - } - - 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 ); - 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 ); - inline void DrawText(const wxString& text, const wxPoint& pt, bool use16bit = FALSE) - { - DrawText(text, pt.x, pt.y, use16bit); - } - - virtual bool CanGetTextExtent(void) const ; - virtual void GetTextExtent( const wxString &string, int *width, int *height, - int *descent = NULL, int *externalLeading = NULL, - wxFont *theFont = NULL, bool use16 = FALSE ) const ; - virtual wxCoord GetCharWidth(void) const; - virtual wxCoord GetCharHeight(void) const; - - virtual void Clear(void); - - virtual void SetFont( const wxFont &font ); - virtual wxFont& GetFont(void) const { return (wxFont&) m_font; }; - - virtual void SetPen( const wxPen &pen ); - virtual wxPen& GetPen(void) const { return (wxPen&) m_pen; }; - - virtual void SetBrush( const wxBrush &brush ); - virtual wxBrush& GetBrush(void) const { return (wxBrush&) m_brush; }; - - virtual void SetBackground( const wxBrush &brush ); - virtual wxBrush& GetBackground(void) const { return (wxBrush&) m_backgroundBrush; }; - - virtual void SetLogicalFunction( int function ); - virtual int GetLogicalFunction(void) const { return m_logicalFunction; }; - - virtual void SetTextForeground( const wxColour &col ); - virtual void SetTextBackground( const wxColour &col ); - virtual wxColour& GetTextBackground(void) const { return (wxColour&)m_textBackgroundColour; }; - virtual wxColour& GetTextForeground(void) const { return (wxColour&)m_textForegroundColour; }; - - virtual void SetBackgroundMode( int mode ); - virtual int GetBackgroundMode(void) const { return m_backgroundMode; }; - - virtual void SetPalette( const wxPalette& palette ); - void SetColourMap( const wxPalette& palette ) { SetPalette(palette); }; - - // the first two must be overridden and called - virtual void SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); - virtual void SetClippingRegion( const wxRect& rect ); - virtual void DestroyClippingRegion(void); - virtual void GetClippingBox( wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height ) const; - virtual void GetClippingBox( long *x, long *y, long *width, long *height ) const; - virtual void GetClippingBox(wxRect& rect) const; - - virtual inline long MinX(void) const { return m_minX; } - virtual inline long MaxX(void) const { return m_maxX; } - virtual inline long MinY(void) const { return m_minY; } - virtual inline long MaxY(void) const { return m_maxY; } - - virtual void GetSize( int* width, int* height ) const; - inline wxSize GetSize(void) const { int w, h; GetSize(&w, &h); return wxSize(w, h); } - virtual void GetSizeMM( long* width, long* height ) const; - - - virtual int GetMapMode(void) const { return m_mappingMode; }; - - virtual void GetUserScale( double *x, double *y ); - virtual void GetLogicalScale( double *x, double *y ); - - virtual void GetLogicalOrigin( long *x, long *y ); - virtual void GetDeviceOrigin( long *x, long *y ); - virtual void SetInternalDeviceOrigin( long x, long y ); - virtual void GetInternalDeviceOrigin( long *x, long *y ); - - virtual void SetOptimization( bool WXUNUSED(optimize) ) {}; - virtual bool GetOptimization(void) { return m_optimize; }; - - virtual long DeviceToLogicalX(long x) const; - virtual long DeviceToLogicalY(long y) const; - virtual long DeviceToLogicalXRel(long x) const; - virtual long DeviceToLogicalYRel(long y) const; - virtual long LogicalToDeviceX(long x) const; - virtual long LogicalToDeviceY(long y) const; - virtual long LogicalToDeviceXRel(long x) const; - virtual long LogicalToDeviceYRel(long y) const; - - void CalcBoundingBox( long x, long y ); -*/ - void ComputeScaleAndOrigin(void); public: diff --git a/include/wx/mac/dcmemory.h b/include/wx/mac/dcmemory.h index 642ae88afd..ab38f69f9c 100644 --- a/include/wx/mac/dcmemory.h +++ b/include/wx/mac/dcmemory.h @@ -27,7 +27,7 @@ class WXDLLEXPORT wxMemoryDC: public wxPaintDC wxMemoryDC( wxDC *dc ); // Create compatible DC ~wxMemoryDC(void); virtual void SelectObject( const wxBitmap& bitmap ); - void GetSize( int *width, int *height ) const; + virtual void DoGetSize( int *width, int *height ) const; wxBitmap GetSelectedObject() { return m_selected ; } private: wxBitmap m_selected; diff --git a/include/wx/mac/glcanvas.h b/include/wx/mac/glcanvas.h new file mode 100644 index 0000000000..73e067d301 --- /dev/null +++ b/include/wx/mac/glcanvas.h @@ -0,0 +1,121 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: glcanvas.h +// Purpose: wxGLCanvas, for using OpenGL with wxWindows under Macintosh +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma interface "glcanvas.h" +#endif + +#ifndef _WX_GLCANVAS_H_ +#define _WX_GLCANVAS_H_ + +#include "wx/setup.h" + +#if wxUSE_GLCANVAS + +#include "wx/palette.h" +#include "wx/scrolwin.h" + +#include +#include + +//--------------------------------------------------------------------------- +// Constants for attriblist +//--------------------------------------------------------------------------- + +enum +{ + WX_GL_RGBA=1, /* use true color palette */ + WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */ + WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */ + WX_GL_DOUBLEBUFFER, /* use doublebuffer */ + WX_GL_STEREO, /* use stereoscopic display */ + WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */ + WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ + WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ + WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */ + WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */ + WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ + WX_GL_STENCIL_SIZE, /* bits for stencil buffer */ + WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */ + WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */ + WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */ + WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */ +}; + +class WXDLLEXPORT wxGLCanvas; /* forward reference */ + +class WXDLLEXPORT wxGLContext: public wxObject +{ +public: + wxGLContext(AGLPixelFormat fmt, wxGLCanvas *win, + const wxPalette& WXUNUSED(palette), + const wxGLContext *other /* for sharing display lists */ + ); + ~wxGLContext(); + + void SetCurrent(); + void Update(); // must be called after window drag/grows/zoom or clut change + void SetColour(const char *colour); + void SwapBuffers(); + + + inline wxWindow* GetWindow() const { return m_window; } + inline AGLDrawable GetDrawable() const { return m_drawable; } + +public: + AGLContext m_glContext; + AGLDrawable m_drawable; + wxWindow* m_window; +}; + +class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow +{ + DECLARE_CLASS(wxGLCanvas) + public: + wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette); + wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, + wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas", + int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); + + wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, + const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette ); + + ~wxGLCanvas(); + + bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette); + + void SetCurrent(); + void SetColour(const char *colour); + void SwapBuffers(); + void UpdateContext(); + void SetViewport(); + + // Unlike some other platforms, this must get called if you override it. + // It sets the viewport correctly and update the context. + // You shouldn't call glViewport yourself either (use SetViewport if you must reset it.) + void OnSize(wxSizeEvent& event); + + inline wxGLContext* GetContext() const { return m_glContext; } + +protected: + wxGLContext* m_glContext; + +DECLARE_EVENT_TABLE() +}; + +#endif // wxUSE_GLCANVAS +#endif // _WX_GLCANVAS_H_ diff --git a/include/wx/mac/mdi.h b/include/wx/mac/mdi.h index 93038739f8..ec727aa331 100644 --- a/include/wx/mac/mdi.h +++ b/include/wx/mac/mdi.h @@ -87,7 +87,14 @@ protected: // TODO maybe have this member wxMDIClientWindow *m_clientWindow; + wxMDIChildFrame * m_currentChild; + wxMenu* m_windowMenu; + // TRUE if MDI Frame is intercepting commands, not child + bool m_parentFrameActive; + +private: + friend class WXDLLEXPORT wxMDIChildFrame; DECLARE_EVENT_TABLE() }; @@ -105,6 +112,7 @@ public: long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr) { + Init() ; Create(parent, id, title, pos, size, style, name); } @@ -120,14 +128,16 @@ public: // Set menu bar void SetMenuBar(wxMenuBar *menu_bar); - void SetClientSize(int width, int height); - void GetPosition(int *x, int *y) const ; // MDI operations virtual void Maximize(); virtual void Maximize( bool ){ Maximize() ; } // this one is inherited from wxFrame virtual void Restore(); virtual void Activate(); +protected: + + // common part of all ctors + void Init(); }; /* The client window is a child of the parent MDI frame, and itself diff --git a/include/wx/mac/notebook.h b/include/wx/mac/notebook.h index aa51b7e781..e70d4d15c5 100644 --- a/include/wx/mac/notebook.h +++ b/include/wx/mac/notebook.h @@ -32,7 +32,7 @@ class WXDLLEXPORT wxWindow; // array of notebook pages typedef wxWindow wxNotebookPage; // so far, any window can be a page -WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages); +WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayPages) ; // ---------------------------------------------------------------------------- // wxNotebook diff --git a/include/wx/mac/radiobut.h b/include/wx/mac/radiobut.h index 6a2c5b1c6a..3e2a1e07a2 100644 --- a/include/wx/mac/radiobut.h +++ b/include/wx/mac/radiobut.h @@ -22,6 +22,8 @@ WXDLLEXPORT_DATA(extern const char*) wxRadioButtonNameStr; class WXDLLEXPORT wxRadioButton: public wxControl { + DECLARE_DYNAMIC_CLASS(wxRadioButton) + protected: public: inline wxRadioButton() {} inline wxRadioButton(wxWindow *parent, wxWindowID id, @@ -51,14 +53,9 @@ public: wxRadioButton *AddInCycle(wxRadioButton *cycle); inline wxRadioButton *NextInCycle() {return m_cycle;} - void OnIdle( wxIdleEvent &event ); - -protected: + protected: + wxRadioButton *m_cycle; - -private: - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxRadioButton) }; // Not implemented diff --git a/include/wx/mac/setup.h b/include/wx/mac/setup.h index 6984ad1257..5c2022a8b3 100644 --- a/include/wx/mac/setup.h +++ b/include/wx/mac/setup.h @@ -267,6 +267,8 @@ #define wxUSE_ZIPSTREAM 1 // 0 // input stream for reading from zip archives +// OpenGL canvas +#define wxUSE_GLCANVAS 1 /* * Finer detail * diff --git a/include/wx/mac/window.h b/include/wx/mac/window.h index bd6c9cec42..e8efb280d1 100644 --- a/include/wx/mac/window.h +++ b/include/wx/mac/window.h @@ -270,14 +270,16 @@ public : virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ; virtual void MacDoGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ; MacWindowData* MacGetWindowData() { return m_macWindowData ; } + static WindowRef MacGetWindowInUpdate() { return s_macWindowInUpdate ; } bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; } static wxWindow* s_lastMouseWindow ; private: virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindow** outWin ) ; protected: - MacWindowData* m_macWindowData ; + static WindowRef s_macWindowInUpdate ; RgnHandle m_macUpdateRgn ; + bool m_macEraseOnRedraw ; int m_x ; int m_y ; diff --git a/src/mac/app.cpp b/src/mac/app.cpp index b30fd5576d..314d307ec8 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -350,6 +350,7 @@ bool wxApp::Initialize() // Mac-specific UMAInitToolbox( 4 ) ; + SetEventMask( everyEvent ) ; UMAShowWatchCursor() ; #ifdef __UNIX__ @@ -458,6 +459,17 @@ bool wxApp::Initialize() wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase->Initialize(); +#if wxUSE_LOG + // flush the logged messages if any and install a 'safer' log target: the + // default one (wxLogGui) can't be used after the resources are freed just + // below and the user suppliedo ne might be even more unsafe (using any + // wxWindows GUI function is unsafe starting from now) + wxLog::DontCreateOnDemand(); + + // this will flush the old messages if any + delete wxLog::SetActiveTarget(new wxLogStderr); +#endif // wxUSE_LOG + wxInitializeStockLists(); wxInitializeStockObjects(); @@ -953,7 +965,7 @@ void wxApp::MacDoOneEvent() { EventRecord event ; - long sleepTime = ::GetCaretTime(); + long sleepTime = 1 ; // GetCaretTime() / 4 ; if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn)) { @@ -973,6 +985,7 @@ void wxApp::MacDoOneEvent() // repeaters + DeletePendingObjects() ; wxMacProcessNotifierAndPendingEvents() ; } @@ -1050,6 +1063,8 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) short windowPart = ::FindWindow(ev->where, &window); wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( wxPendingDelete.Member(win) ) + return ; BitMap screenBits; GetQDGlobalsScreenBits( &screenBits ); @@ -1166,7 +1181,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) SetOrigin( 0 , 0 ) ; SetPort( port ) ; } - if ( window != frontWindow ) + if ( window != frontWindow && wxTheApp->s_captureWindow == NULL ) { if ( s_macIsInModalLoop ) { @@ -1423,7 +1438,37 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) void wxApp::MacHandleKeyUpEvent( EventRecord *ev ) { - // nothing to do + wxToolTip::RemoveToolTips() ; + + UInt32 menuresult = UMAMenuEvent(ev) ; + if ( HiWord( menuresult ) ) + { + } + else + { + short keycode ; + short keychar ; + keychar = short(ev->message & charCodeMask); + keycode = short(ev->message & keyCodeMask) >> 8 ; + + wxWindow* focus = wxWindow::FindFocus() ; + if ( focus ) + { + long keyval = wxMacTranslateKey(keychar, keycode) ; + + wxKeyEvent event(wxEVT_KEY_UP); + 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 = keyval; + event.m_x = ev->where.h; + event.m_y = ev->where.v; + event.m_timeStamp = ev->when; + event.SetEventObject(focus); + bool handled = focus->GetEventHandler()->ProcessEvent( event ) ; + } + } } void wxApp::MacHandleActivateEvent( EventRecord *ev ) @@ -1451,7 +1496,8 @@ void wxApp::MacHandleUpdateEvent( EventRecord *ev ) wxWindow * win = wxFindWinFromMacWindow( window ) ; if ( win ) { - win->MacUpdate( ev ) ; + if ( !wxPendingDelete.Member(win) ) + win->MacUpdate( ev ) ; } else { diff --git a/src/mac/button.cpp b/src/mac/button.cpp index 72e1af8e5d..c67c470acf 100644 --- a/src/mac/button.cpp +++ b/src/mac/button.cpp @@ -85,18 +85,20 @@ void wxButton::SetDefault() wxSize wxButton::DoGetBestSize() const { + wxSize sz = GetDefaultSize() ; + int wBtn = m_label.Length() * 8 + 12 ; int hBtn = 20 ; - if ( wBtn < 80 ) - wBtn = 80 ; - - return wxSize(wBtn, hBtn); + if (wBtn > sz.x) sz.x = wBtn; + if (hBtn > sz.y) sz.y = hBtn; + + return sz ; } wxSize wxButton::GetDefaultSize() { - int wBtn = 80 /* + 2 * m_macHorizontalBorder */ ; + int wBtn = 70 /* + 2 * m_macHorizontalBorder */ ; int hBtn = 20 /* + 2 * m_macVerticalBorder */ ; return wxSize(wBtn, hBtn); diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index b30fd5576d..314d307ec8 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -350,6 +350,7 @@ bool wxApp::Initialize() // Mac-specific UMAInitToolbox( 4 ) ; + SetEventMask( everyEvent ) ; UMAShowWatchCursor() ; #ifdef __UNIX__ @@ -458,6 +459,17 @@ bool wxApp::Initialize() wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase->Initialize(); +#if wxUSE_LOG + // flush the logged messages if any and install a 'safer' log target: the + // default one (wxLogGui) can't be used after the resources are freed just + // below and the user suppliedo ne might be even more unsafe (using any + // wxWindows GUI function is unsafe starting from now) + wxLog::DontCreateOnDemand(); + + // this will flush the old messages if any + delete wxLog::SetActiveTarget(new wxLogStderr); +#endif // wxUSE_LOG + wxInitializeStockLists(); wxInitializeStockObjects(); @@ -953,7 +965,7 @@ void wxApp::MacDoOneEvent() { EventRecord event ; - long sleepTime = ::GetCaretTime(); + long sleepTime = 1 ; // GetCaretTime() / 4 ; if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn)) { @@ -973,6 +985,7 @@ void wxApp::MacDoOneEvent() // repeaters + DeletePendingObjects() ; wxMacProcessNotifierAndPendingEvents() ; } @@ -1050,6 +1063,8 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) short windowPart = ::FindWindow(ev->where, &window); wxWindow* win = wxFindWinFromMacWindow( window ) ; + if ( wxPendingDelete.Member(win) ) + return ; BitMap screenBits; GetQDGlobalsScreenBits( &screenBits ); @@ -1166,7 +1181,7 @@ void wxApp::MacHandleMouseDownEvent( EventRecord *ev ) SetOrigin( 0 , 0 ) ; SetPort( port ) ; } - if ( window != frontWindow ) + if ( window != frontWindow && wxTheApp->s_captureWindow == NULL ) { if ( s_macIsInModalLoop ) { @@ -1423,7 +1438,37 @@ void wxApp::MacHandleKeyDownEvent( EventRecord *ev ) void wxApp::MacHandleKeyUpEvent( EventRecord *ev ) { - // nothing to do + wxToolTip::RemoveToolTips() ; + + UInt32 menuresult = UMAMenuEvent(ev) ; + if ( HiWord( menuresult ) ) + { + } + else + { + short keycode ; + short keychar ; + keychar = short(ev->message & charCodeMask); + keycode = short(ev->message & keyCodeMask) >> 8 ; + + wxWindow* focus = wxWindow::FindFocus() ; + if ( focus ) + { + long keyval = wxMacTranslateKey(keychar, keycode) ; + + wxKeyEvent event(wxEVT_KEY_UP); + 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 = keyval; + event.m_x = ev->where.h; + event.m_y = ev->where.v; + event.m_timeStamp = ev->when; + event.SetEventObject(focus); + bool handled = focus->GetEventHandler()->ProcessEvent( event ) ; + } + } } void wxApp::MacHandleActivateEvent( EventRecord *ev ) @@ -1451,7 +1496,8 @@ void wxApp::MacHandleUpdateEvent( EventRecord *ev ) wxWindow * win = wxFindWinFromMacWindow( window ) ; if ( win ) { - win->MacUpdate( ev ) ; + if ( !wxPendingDelete.Member(win) ) + win->MacUpdate( ev ) ; } else { diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index 72e1af8e5d..c67c470acf 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -85,18 +85,20 @@ void wxButton::SetDefault() wxSize wxButton::DoGetBestSize() const { + wxSize sz = GetDefaultSize() ; + int wBtn = m_label.Length() * 8 + 12 ; int hBtn = 20 ; - if ( wBtn < 80 ) - wBtn = 80 ; - - return wxSize(wBtn, hBtn); + if (wBtn > sz.x) sz.x = wBtn; + if (hBtn > sz.y) sz.y = hBtn; + + return sz ; } wxSize wxButton::GetDefaultSize() { - int wBtn = 80 /* + 2 * m_macHorizontalBorder */ ; + int wBtn = 70 /* + 2 * m_macHorizontalBorder */ ; int hBtn = 20 /* + 2 * m_macVerticalBorder */ ; return wxSize(wBtn, hBtn); diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index a2841c7996..d765346c5c 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -215,8 +215,7 @@ void wxComboBox::MacHandleControlClick( ControlHandle control , SInt16 controlpa wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId ); event.SetInt(GetSelection()); event.SetEventObject(this); - event.SetString(copystring(GetStringSelection())); + event.SetString(GetStringSelection()); ProcessCommand(event); - delete[] event.GetString(); } diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index 63610676a0..eb83a83ee0 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -303,6 +303,8 @@ void wxControl::MacAdjustControlRect() if ( IsKindOf( CLASSINFO( wxButton ) ) ) { m_width = m_label.Length() * 8 + 12 ; + if ( m_width < 70 ) + m_width = 70 ; } else if ( IsKindOf( CLASSINFO( wxStaticText ) ) ) { diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index b1e9a3b4c4..119818f6c6 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -45,18 +45,11 @@ long wxDC::m_macCurrentPortId = 1 ; wxDC::wxDC() { m_ok = FALSE; -// m_optimize = FALSE; -// m_autoSetting = FALSE; m_colour = TRUE; - m_clipping = FALSE; m_mm_to_pix_x = mm2pt; m_mm_to_pix_y = mm2pt; - m_logicalOriginX = 0; - m_logicalOriginY = 0; - m_deviceOriginX = 0; - m_deviceOriginY = 0; m_internalDeviceOriginX = 0; m_internalDeviceOriginY = 0; m_externalDeviceOriginX = 0; @@ -69,28 +62,12 @@ wxDC::wxDC() m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; m_needComputeScaleY = FALSE; - m_signX = 1; // default x-axis left to right - m_signY = 1; // default y-axis top down - m_maxX = m_maxY = -100000; m_minY = m_minY = 100000; - m_logicalFunction = wxCOPY; -// m_textAlignment = wxALIGN_TOP_LEFT; - m_backgroundMode = wxTRANSPARENT; - - m_textForegroundColour = *wxBLACK; - m_textBackgroundColour = *wxWHITE; - m_pen = *wxBLACK_PEN; - m_font = *wxNORMAL_FONT; - m_brush = *wxTRANSPARENT_BRUSH; - m_backgroundBrush = *wxWHITE_BRUSH; - -// m_palette = wxAPP_COLOURMAP; m_macPort = NULL ; m_macMask = NULL ; m_ok = FALSE ; diff --git a/src/mac/carbon/dcclient.cpp b/src/mac/carbon/dcclient.cpp index 92cb39201b..ef0d666568 100644 --- a/src/mac/carbon/dcclient.cpp +++ b/src/mac/carbon/dcclient.cpp @@ -61,6 +61,7 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas) MacSetupPort() ; m_ok = TRUE ; + SetBackground(wxBrush(the_canvas->GetBackgroundColour(), wxSOLID)); } wxWindowDC::~wxWindowDC() diff --git a/src/mac/carbon/dcmemory.cpp b/src/mac/carbon/dcmemory.cpp index a56c7b5c49..fba8a5891e 100644 --- a/src/mac/carbon/dcmemory.cpp +++ b/src/mac/carbon/dcmemory.cpp @@ -23,11 +23,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) wxMemoryDC::wxMemoryDC(void) { + m_ok = TRUE; + SetBackground(*wxWHITE_BRUSH); + SetBrush(*wxWHITE_BRUSH); + SetPen(*wxBLACK_PEN); m_ok = FALSE; }; wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) { + m_ok = TRUE; + SetBackground(*wxWHITE_BRUSH); + SetBrush(*wxWHITE_BRUSH); + SetPen(*wxBLACK_PEN); m_ok = FALSE; }; @@ -75,7 +83,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) }; }; -void wxMemoryDC::GetSize( int *width, int *height ) const +void wxMemoryDC::DoGetSize( int *width, int *height ) const { if (m_selected.Ok()) { diff --git a/src/mac/carbon/frame.cpp b/src/mac/carbon/frame.cpp index aded221ea5..bbbef8f74b 100644 --- a/src/mac/carbon/frame.cpp +++ b/src/mac/carbon/frame.cpp @@ -54,6 +54,14 @@ bool wxFrame::m_useNativeStatusBar = FALSE; void wxFrame::Init() { + m_frameMenuBar = NULL; + +#if wxUSE_TOOLBAR + m_frameToolBar = NULL ; +#endif + m_frameStatusBar = NULL; + m_winLastFocused = NULL ; + m_iconized = FALSE; #if wxUSE_TOOLTIPS @@ -94,14 +102,6 @@ bool wxFrame::Create(wxWindow *parent, long style, const wxString& name) { - m_frameMenuBar = NULL; - -#if wxUSE_TOOLBAR - m_frameToolBar = NULL ; -#endif - m_frameStatusBar = NULL; - m_winLastFocused = NULL ; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); if ( id > -1 ) @@ -229,7 +229,6 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) return; } - m_frameMenuBar = NULL; m_frameMenuBar = menuBar; // m_frameMenuBar->MacInstallMenuBar() ; m_frameMenuBar->Attach(this); diff --git a/src/mac/carbon/glcanvas.cpp b/src/mac/carbon/glcanvas.cpp new file mode 100644 index 0000000000..b3832d29fa --- /dev/null +++ b/src/mac/carbon/glcanvas.cpp @@ -0,0 +1,290 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: glcanvas.cpp +// Purpose: wxGLCanvas, for using OpenGL with wxWindows under Macintosh +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "glcanvas.h" +#endif + +#include "wx/wxprec.h" + +#if defined(__BORLANDC__) +#pragma hdrstop +#endif + +#include "wx/setup.h" + +#if wxUSE_GLCANVAS + +#ifndef WX_PRECOMP +#include "wx/frame.h" +#endif + +#include "wx/settings.h" +#include "wx/log.h" + +#include "wx/glcanvas.h" +#include "wx/mac/uma.h" + +#include + +/* + * GLContext implementation + */ + +wxGLContext::wxGLContext( + AGLPixelFormat fmt, wxGLCanvas *win, + const wxPalette& palette, + const wxGLContext *other /* for sharing display lists */ +) +{ + m_window = win; + + m_drawable = (AGLDrawable) UMAGetWindowPort(win->GetMacRootWindow()); + + m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL); + wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") ); + + GLboolean b; + b = aglSetDrawable(m_glContext, m_drawable); + wxCHECK_RET( b, wxT("Couldn't bind OpenGl context") ); + aglEnable(m_glContext , AGL_BUFFER_RECT ) ; + b = aglSetCurrentContext(m_glContext); + wxCHECK_RET( b, wxT("Couldn't activate OpenGl context") ); +} + +wxGLContext::~wxGLContext() +{ + if (m_glContext) + { + aglSetCurrentContext(NULL); + aglDestroyContext(m_glContext); + } +} + +void wxGLContext::SwapBuffers() +{ + if (m_glContext) + { + aglSwapBuffers(m_glContext); + } +} + +void wxGLContext::SetCurrent() +{ + if (m_glContext) + { + aglSetCurrentContext(m_glContext); + } +} + +void wxGLContext::Update() +{ + if (m_glContext) + { + aglUpdateContext(m_glContext); + } +} + +void wxGLContext::SetColour(const char *colour) +{ + float r = 0.0; + float g = 0.0; + float b = 0.0; + wxColour *col = wxTheColourDatabase->FindColour(colour); + if (col) + { + r = (float)(col->Red()/256.0); + g = (float)(col->Green()/256.0); + b = (float)(col->Blue()/256.0); + glColor3f( r, g, b); + } +} + + +/* + * wxGLCanvas implementation + */ + +IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow) + +BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow) + EVT_SIZE(wxGLCanvas::OnSize) +END_EVENT_TABLE() + +wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette) +{ + Create(parent, NULL, id, pos, size, style, name, attribList, palette); +} + +wxGLCanvas::wxGLCanvas( wxWindow *parent, + const wxGLContext *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette ) +{ + Create(parent, shared, id, pos, size, style, name, attribList, palette); +} + +wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette ) +{ + Create(parent, shared ? shared->GetContext() : NULL, id, pos, size, style, name, attribList, palette); +} + +wxGLCanvas::~wxGLCanvas() +{ + if (m_glContext) + delete m_glContext; +} + +bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette) +{ + m_macEraseOnRedraw = false ; + GLint data[512]; + GLint defs[] = { AGL_RGBA, + AGL_DOUBLEBUFFER, + AGL_MINIMUM_POLICY, + AGL_DEPTH_SIZE, 1, // use largest available depth buffer + AGL_RED_SIZE, 1, + AGL_GREEN_SIZE, 1, + AGL_BLUE_SIZE, 1, + AGL_ALPHA_SIZE, 0, + AGL_NONE }; + GLint *attribs; + if (!attribList) + { + attribs = defs; + } + else + { + int data[512], arg=0, p=0; + + data[p++] = AGL_MINIMUM_POLICY; // make _SIZE tags behave more like GLX + while( (attribList[arg]!=0) && (p<512) ) + { + switch( attribList[arg++] ) + { + case WX_GL_RGBA: data[p++] = AGL_RGBA; break; + case WX_GL_BUFFER_SIZE: + data[p++]=AGL_BUFFER_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_LEVEL: + data[p++]=AGL_LEVEL; data[p++]=attribList[arg++]; break; + case WX_GL_DOUBLEBUFFER: data[p++] = AGL_DOUBLEBUFFER; break; + case WX_GL_STEREO: data[p++] = AGL_STEREO; break; + case WX_GL_AUX_BUFFERS: + data[p++]=AGL_AUX_BUFFERS; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_RED: + data[p++]=AGL_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_GREEN: + data[p++]=AGL_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_BLUE: + data[p++]=AGL_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ALPHA: + data[p++]=AGL_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_DEPTH_SIZE: + data[p++]=AGL_DEPTH_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_STENCIL_SIZE: + data[p++]=AGL_STENCIL_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_RED: + data[p++]=AGL_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_GREEN: + data[p++]=AGL_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_BLUE: + data[p++]=AGL_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_ALPHA: + data[p++]=AGL_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + default: + break; + } + } + data[p] = 0; + + attribs = defs; + } + wxScrolledWindow::Create( parent, id, pos, size, style, name ); + + AGLPixelFormat fmt = aglChoosePixelFormat(NULL, 0, attribs); + wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); + + m_glContext = new wxGLContext(fmt, this, palette, shared); + + aglDestroyPixelFormat(fmt); + + return true; +} + +void wxGLCanvas::SwapBuffers() +{ + if (m_glContext) + m_glContext->SwapBuffers(); +} + +void wxGLCanvas::UpdateContext() +{ + if (m_glContext) + m_glContext->Update(); +} + +void wxGLCanvas::SetViewport() +{ + // viewport is initially set to entire port + // adjust glViewport to just this window + int x = 0 ; + int y = 0 ; + + MacClientToRootWindow( &x , &y ) ; + int width, height; + GetClientSize(& width, & height); + Rect bounds ; + GetWindowPortBounds( GetMacRootWindow() , &bounds ) ; + GLint parms[4] ; + parms[0] = x ; + parms[1] = bounds.bottom - bounds.top - ( y + height ) ; + parms[2] = width ; + parms[3] = height ; + + aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; +} + +void wxGLCanvas::OnSize(wxSizeEvent& event) +{ + if (m_glContext) + { + UpdateContext(); + m_glContext->SetCurrent(); + + SetViewport(); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 ); + glMatrixMode(GL_MODELVIEW); + } +} + +void wxGLCanvas::SetCurrent() +{ + if (m_glContext) + { + m_glContext->SetCurrent(); + } +} + +void wxGLCanvas::SetColour(const char *colour) +{ + if (m_glContext) + m_glContext->SetColour(colour); +} + +#endif // wxUSE_GLCANVAS diff --git a/src/mac/carbon/macnotfy.cpp b/src/mac/carbon/macnotfy.cpp index db406cdc63..a47fce31e5 100644 --- a/src/mac/carbon/macnotfy.cpp +++ b/src/mac/carbon/macnotfy.cpp @@ -59,7 +59,6 @@ void wxMacCreateNotifierTable() void wxMacDestroyNotifierTable() { - wxASSERT( gMacNotificationEvents.top == gMacNotificationEvents.bottom ) ; } wxMacNotifierTableRef wxMacGetNotifierTable() diff --git a/src/mac/carbon/mdi.cpp b/src/mac/carbon/mdi.cpp index 887f726504..79197cdecd 100644 --- a/src/mac/carbon/mdi.cpp +++ b/src/mac/carbon/mdi.cpp @@ -36,10 +36,28 @@ END_EVENT_TABLE() #endif +static const int IDM_WINDOWTILE = 4001; +static const int IDM_WINDOWTILEHOR = 4001; +static const int IDM_WINDOWCASCADE = 4002; +static const int IDM_WINDOWICONS = 4003; +static const int IDM_WINDOWNEXT = 4004; +static const int IDM_WINDOWTILEVERT = 4005; + +// This range gives a maximum of 500 MDI children. Should be enough :-) +static const int wxFIRST_MDI_CHILD = 4100; +static const int wxLAST_MDI_CHILD = 4600; + +// Status border dimensions +static const int wxTHICK_LINE_BORDER = 3; + // Parent frame wxMDIParentFrame::wxMDIParentFrame() { + m_clientWindow = NULL; + m_currentChild = NULL; + m_windowMenu = (wxMenu*) NULL; + m_parentFrameActive = TRUE; } bool wxMDIParentFrame::Create(wxWindow *parent, @@ -50,30 +68,58 @@ bool wxMDIParentFrame::Create(wxWindow *parent, long style, const wxString& name) { - if (!parent) - wxTopLevelWindows.Append(this); - - SetName(name); - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id > -1 ) - m_windowId = id; - else - m_windowId = (int)NewControlId(); - - // this window does not exist really - - wxModelessWindows.Append(this); + m_clientWindow = NULL; + m_currentChild = NULL; + + // this style can be used to prevent a window from having the standard MDI + // "Window" menu + if ( style & wxFRAME_NO_WINDOW_MENU ) + { + m_windowMenu = (wxMenu *)NULL; + style -= wxFRAME_NO_WINDOW_MENU ; + } + else // normal case: we have the window menu, so construct it + { + m_windowMenu = new wxMenu; + + m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade")); + m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally")); + m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically")); + m_windowMenu->AppendSeparator(); + m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons")); + m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next")); + } + + wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ; + m_parentFrameActive = TRUE; + + OnCreateClient(); return TRUE; } wxMDIParentFrame::~wxMDIParentFrame() { + DestroyChildren(); + // already delete by DestroyChildren() + m_frameToolBar = NULL; + m_frameStatusBar = NULL; + m_clientWindow = NULL ; + + if (m_windowMenu) + { + delete m_windowMenu; + m_windowMenu = (wxMenu*) NULL; + } + + if ( m_clientWindow ) + { + delete m_clientWindow; + m_clientWindow = NULL ; + } } + // Get size *available for subwindows* i.e. excluding menu bar. void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const { @@ -102,21 +148,34 @@ void wxMDIParentFrame::OnSize(wxSizeEvent& event) void wxMDIParentFrame::OnActivate(wxActivateEvent& event) { - // Do nothing + if ( m_currentChild && event.GetActive() ) + { + wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); + event.SetEventObject( m_currentChild ); + m_currentChild->GetEventHandler()->ProcessEvent(event) ; + } + else if ( event.GetActive() ) + { + if ( m_frameMenuBar != NULL ) + { + m_frameMenuBar->MacInstallMenuBar() ; + } + + } } // Returns the active MDI child window wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { - // TODO - return NULL; + return m_currentChild ; } // Create the client window class (don't Create the window, // just return a new class) wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() { - return new wxMDIClientWindow ; + m_clientWindow = new wxMDIClientWindow( this ); + return m_clientWindow; } // Responds to colour changes, and passes event on to children. @@ -157,6 +216,10 @@ void wxMDIParentFrame::ActivatePrevious() // Child frame wxMDIChildFrame::wxMDIChildFrame() +{ + Init() ; +} +void wxMDIChildFrame::Init() { } @@ -187,18 +250,10 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, wxMDIChildFrame::~wxMDIChildFrame() { -} - -// Set the client size (i.e. leave the calculation of borders etc. -// to wxWindows) -void wxMDIChildFrame::SetClientSize(int width, int height) -{ - // TODO -} - -void wxMDIChildFrame::GetPosition(int *x, int *y) const -{ - // TODO + DestroyChildren(); + // already delete by DestroyChildren() + m_frameToolBar = NULL; + m_frameStatusBar = NULL; } void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) @@ -209,20 +264,21 @@ void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) // MDI operations void wxMDIChildFrame::Maximize() { - // TODO + wxFrame::Maximize() ; } void wxMDIChildFrame::Restore() { - // TODO + wxFrame::Restore() ; } void wxMDIChildFrame::Activate() { - // TODO } -// Client window +//----------------------------------------------------------------------------- +// wxMDIClientWindow +//----------------------------------------------------------------------------- wxMDIClientWindow::wxMDIClientWindow() { @@ -230,14 +286,22 @@ wxMDIClientWindow::wxMDIClientWindow() wxMDIClientWindow::~wxMDIClientWindow() { + DestroyChildren(); } bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) { - // TODO create client window + + m_windowId = (int)NewControlId(); + + if ( parent ) + { + parent->AddChild(this); + } m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); - return FALSE; + wxModelessWindows.Append(this); + return TRUE; } // Explicitly call default scroll behaviour diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index 877ba66899..3f3279dd04 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -105,8 +105,11 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, for (i = 0; i < n; i++) { - wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(),choices[i],wxPoint(5,20*i+10)); - m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); + wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(),choices[i],wxPoint(5,20*i+10), + wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ; + if ( i == 0 ) + m_radioButtonCycle = radBtn ; +// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } SetSelection(0); diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index 1f5bb9c67a..aff004469b 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -18,10 +18,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) -BEGIN_EVENT_TABLE(wxRadioButton, wxControl) - EVT_IDLE( wxRadioButton::OnIdle ) -END_EVENT_TABLE() - #include bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, @@ -34,8 +30,6 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - m_cycle=NULL; - MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, @@ -43,53 +37,28 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, MacPostControlCreate() ; - return TRUE; -} - -void wxRadioButton::OnIdle( wxIdleEvent &event ) -{ - if (!m_cycle && HasFlag(wxRB_GROUP)) + if (HasFlag(wxRB_GROUP)) + { + AddInCycle( NULL ) ; + } + else + { + /* search backward for last group start */ + wxRadioButton *chief = (wxRadioButton*) NULL; + wxWindowList::Node *node = parent->GetChildren().GetLast(); + while (node) { - // we are a stand-alone radiobutton and have - // the group flag indicating we have to collect - // the other radiobuttons belonging to this one - - bool reached_this = FALSE; - wxRadioButton *m_radioButtonCycle = NULL; - m_radioButtonCycle = AddInCycle( m_radioButtonCycle ); - - wxWindow *parent = GetParent(); - wxNode *node = parent->GetChildren().First(); - while (node) - { - wxWindow *child = (wxWindow*) node->Data(); - - node = node->Next(); - - // start searching behind current radiobutton - if (!reached_this) - { - reached_this = (this == child); - continue; - } - - if (child->IsKindOf( CLASSINFO ( wxRadioButton ) )) - { - wxRadioButton *rb = (wxRadioButton*) child; - - // already reached next group - if (rb->HasFlag(wxRB_GROUP)) break; - - // part of a radiobox - if (rb->NextInCycle()) break; - - m_radioButtonCycle = rb->AddInCycle( m_radioButtonCycle ); - } - } - + wxWindow *child = node->GetData(); + if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) ) + { + chief = (wxRadioButton*) child; + if (child->HasFlag(wxRB_GROUP)) break; + } + node = node->GetPrevious(); } - - event.Skip( TRUE ); + AddInCycle( chief ) ; + } + return TRUE; } void wxRadioButton::SetValue(bool val) @@ -140,7 +109,8 @@ wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle) } else { current=cycle; - while ((next=current->m_cycle)!=cycle) current=current->m_cycle; + while ((next=current->m_cycle)!=cycle) + current=current->m_cycle; m_cycle=cycle; current->m_cycle=this; return(cycle); diff --git a/src/mac/carbon/slider.cpp b/src/mac/carbon/slider.cpp index 05b29b696a..ffb6631aca 100644 --- a/src/mac/carbon/slider.cpp +++ b/src/mac/carbon/slider.cpp @@ -312,20 +312,13 @@ void wxSlider::MacHandleControlClick( ControlHandle control , SInt16 controlpart SetValue( value ) ; wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); - event.SetPosition(GetControlValue( m_macControl) ); + event.SetPosition(value); event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); -#if WXWIN_COMPATIBILITY + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); + cevent.SetInt( value ); + cevent.SetEventObject( this ); - 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 + GetEventHandler()->ProcessEvent( cevent ); } diff --git a/src/mac/carbon/statbmp.cpp b/src/mac/carbon/statbmp.cpp index 47aa296e1c..f85c66b456 100644 --- a/src/mac/carbon/statbmp.cpp +++ b/src/mac/carbon/statbmp.cpp @@ -71,7 +71,7 @@ void wxStaticBitmap::OnPaint( wxPaintEvent &event ) wxPaintDC dc(this); PrepareDC(dc); dc.SetPalette( *m_messageBitmap.GetPalette() ) ; - dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ; + dc.DrawBitmap( m_messageBitmap , 0 , 0 , TRUE ) ; } wxSize wxStaticBitmap::DoGetBestSize() const diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 0a51bb757e..0806570a55 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -396,7 +396,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) TESetSelect( from , to , teH ) ; TEDelete( teH ) ; TEInsert( value , value.Length() , teH ) ; -// MacInvalidateControl() ; + Refresh() ; } void wxTextCtrl::Remove(long from, long to) @@ -411,7 +411,7 @@ void wxTextCtrl::Remove(long from, long to) UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TEDelete( teH ) ; -// MacInvalidateControl() ; + Refresh() ; } void wxTextCtrl::SetSelection(long from, long to) diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 738c7fcd91..4dad035bad 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -150,7 +150,7 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons m_x = x ; m_y = y ; } - + return true ; } wxToolBar::~wxToolBar() diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index 029f1fa968..28c069a63a 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -39,15 +39,35 @@ bool wxGetFullHostName(wxChar *buf, int maxSize) // Get hostname only (without domain name) bool wxGetHostName(char *buf, int maxSize) { - // TODO - return FALSE; + // Gets Chooser name of user by examining a System resource. + + const short kComputerNameID = -16413; + + short oldResFile = CurResFile() ; + UseResFile(0); + StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); + UseResFile(oldResFile); + + if (chooserName && *chooserName) + { + int length = (*chooserName)[0] ; + if ( length + 1 > maxSize ) + { + length = maxSize - 1 ; + } + strncpy( buf , (char*) &(*chooserName)[1] , length ) ; + buf[length] = 0 ; + } + else + buf[0] = 0 ; + + return TRUE; } // Get user ID e.g. jacs bool wxGetUserId(char *buf, int maxSize) { - // TODO - return FALSE; + return wxGetUserName( buf , maxSize ) ; } const wxChar* wxGetHomeDir(wxString *pstr) @@ -56,13 +76,32 @@ const wxChar* wxGetHomeDir(wxString *pstr) return pstr->c_str() ; } - - // Get user name e.g. AUTHOR bool wxGetUserName(char *buf, int maxSize) { - // TODO - return FALSE; + // Gets Chooser name of user by examining a System resource. + + const short kChooserNameID = -16096; + + short oldResFile = CurResFile() ; + UseResFile(0); + StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); + UseResFile(oldResFile); + + if (chooserName && *chooserName) + { + int length = (*chooserName)[0] ; + if ( length + 1 > maxSize ) + { + length = maxSize - 1 ; + } + strncpy( buf , (char*) &(*chooserName)[1] , length ) ; + buf[length] = 0 ; + } + else + buf[0] = 0 ; + + return TRUE; } int wxKill(long pid, int sig) @@ -83,13 +122,21 @@ bool wxShell(const wxString& command) // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) long wxGetFreeMemory() { - // TODO - return 0; + return FreeMem() ; +} + +void wxUsleep(unsigned long milliseconds) +{ + clock_t start = clock() ; + do + { + YieldToAnyThread() ; + } while( clock() - start < milliseconds / CLOCKS_PER_SEC ) ; } void wxSleep(int nSecs) { - // TODO + wxUsleep(1000*nSecs); } // Consume all events until no more left @@ -108,8 +155,9 @@ void wxDebugMsg(const char *fmt ...) va_start(ap, fmt); - // wvsprintf(buffer,fmt,ap) ; - // TODO: output buffer + vsprintf(buffer,fmt,ap) ; + strcat(buffer,";g") ; + debugstr(buffer) ; va_end(ap); } @@ -117,27 +165,33 @@ void wxDebugMsg(const char *fmt ...) // Non-fatal error: pop up message box and (possibly) continue void wxError(const wxString& msg, const wxString& title) { - // TODO + wxSprintf(wxBuffer, wxT("%s\nContinue?"), WXSTRINGCAST msg); + if (wxMessageBox(wxBuffer, title, wxYES_NO) == wxID_NO ) wxExit(); } // Fatal error: pop up message box and abort void wxFatalError(const wxString& msg, const wxString& title) { - // TODO + wxSprintf(wxBuffer, wxT("%s: %s"), WXSTRINGCAST title, WXSTRINGCAST msg); + wxMessageBox(wxBuffer); + wxExit(); } #endif // !__UNIX__ // Emit a beeeeeep void wxBell() { - // TODO + SysBeep(30); } int wxGetOsVersion(int *majorVsn, int *minorVsn) { - // TODO - return 0; + long theSystem ; + Gestalt(gestaltSystemVersion, &theSystem) ; + *minorVsn = (theSystem & 0xFF ) ; + *majorVsn = (theSystem >> 8 ) ; // are there x-platform conventions ? + return wxMACINTOSH; } // Reading and writing resources (eg WIN.INI, .Xdefaults) diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 382b71024f..148538256d 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -113,6 +113,8 @@ void wxWindow::Init() // generic InitBase(); + m_macEraseOnRedraw = true ; + // MSW specific m_doubleClickAllowed = 0; m_winCaptured = FALSE; @@ -130,6 +132,7 @@ void wxWindow::Init() m_isShown = TRUE; m_macWindowData = NULL ; + m_macEraseOnRedraw = true ; m_x = 0; m_y = 0 ; @@ -811,6 +814,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, void wxWindow::MacEraseBackground( Rect *rect ) { +/* WindowRef window = GetMacRootWindow() ; if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) ) { @@ -878,6 +882,7 @@ void wxWindow::MacEraseBackground( Rect *rect ) } } } +*/ } void wxWindow::Refresh(bool eraseBack, const wxRect *rect) @@ -1827,8 +1832,10 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time) if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() ) eraseBackground = true ; SetClip( updatergn ) ; - if ( eraseBackground ) + if ( eraseBackground && m_macEraseOnRedraw ) { + // todo : find a clever algorithm, which only will do this + // if really necessary EraseRgn( updatergn ) ; } } @@ -2310,37 +2317,7 @@ long wxWindow::MacRemoveBordersFromStyle( long style ) { return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ; } -/* -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 ) - { - SetPort( m_currentPort ) ; - SetOrigin( 0 , 0 ) ; - } - if ( m_formerPort != m_currentPort ) - SetPort( m_formerPort ) ; -} -*/ + wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow ) { diff --git a/src/mac/combobox.cpp b/src/mac/combobox.cpp index a2841c7996..d765346c5c 100644 --- a/src/mac/combobox.cpp +++ b/src/mac/combobox.cpp @@ -215,8 +215,7 @@ void wxComboBox::MacHandleControlClick( ControlHandle control , SInt16 controlpa wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId ); event.SetInt(GetSelection()); event.SetEventObject(this); - event.SetString(copystring(GetStringSelection())); + event.SetString(GetStringSelection()); ProcessCommand(event); - delete[] event.GetString(); } diff --git a/src/mac/control.cpp b/src/mac/control.cpp index 63610676a0..eb83a83ee0 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -303,6 +303,8 @@ void wxControl::MacAdjustControlRect() if ( IsKindOf( CLASSINFO( wxButton ) ) ) { m_width = m_label.Length() * 8 + 12 ; + if ( m_width < 70 ) + m_width = 70 ; } else if ( IsKindOf( CLASSINFO( wxStaticText ) ) ) { diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index b1e9a3b4c4..119818f6c6 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -45,18 +45,11 @@ long wxDC::m_macCurrentPortId = 1 ; wxDC::wxDC() { m_ok = FALSE; -// m_optimize = FALSE; -// m_autoSetting = FALSE; m_colour = TRUE; - m_clipping = FALSE; m_mm_to_pix_x = mm2pt; m_mm_to_pix_y = mm2pt; - m_logicalOriginX = 0; - m_logicalOriginY = 0; - m_deviceOriginX = 0; - m_deviceOriginY = 0; m_internalDeviceOriginX = 0; m_internalDeviceOriginY = 0; m_externalDeviceOriginX = 0; @@ -69,28 +62,12 @@ wxDC::wxDC() m_scaleX = 1.0; m_scaleY = 1.0; - m_mappingMode = wxMM_TEXT; m_needComputeScaleX = FALSE; m_needComputeScaleY = FALSE; - m_signX = 1; // default x-axis left to right - m_signY = 1; // default y-axis top down - m_maxX = m_maxY = -100000; m_minY = m_minY = 100000; - m_logicalFunction = wxCOPY; -// m_textAlignment = wxALIGN_TOP_LEFT; - m_backgroundMode = wxTRANSPARENT; - - m_textForegroundColour = *wxBLACK; - m_textBackgroundColour = *wxWHITE; - m_pen = *wxBLACK_PEN; - m_font = *wxNORMAL_FONT; - m_brush = *wxTRANSPARENT_BRUSH; - m_backgroundBrush = *wxWHITE_BRUSH; - -// m_palette = wxAPP_COLOURMAP; m_macPort = NULL ; m_macMask = NULL ; m_ok = FALSE ; diff --git a/src/mac/dcclient.cpp b/src/mac/dcclient.cpp index 92cb39201b..ef0d666568 100644 --- a/src/mac/dcclient.cpp +++ b/src/mac/dcclient.cpp @@ -61,6 +61,7 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas) MacSetupPort() ; m_ok = TRUE ; + SetBackground(wxBrush(the_canvas->GetBackgroundColour(), wxSOLID)); } wxWindowDC::~wxWindowDC() diff --git a/src/mac/dcmemory.cpp b/src/mac/dcmemory.cpp index a56c7b5c49..fba8a5891e 100644 --- a/src/mac/dcmemory.cpp +++ b/src/mac/dcmemory.cpp @@ -23,11 +23,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC) wxMemoryDC::wxMemoryDC(void) { + m_ok = TRUE; + SetBackground(*wxWHITE_BRUSH); + SetBrush(*wxWHITE_BRUSH); + SetPen(*wxBLACK_PEN); m_ok = FALSE; }; wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) { + m_ok = TRUE; + SetBackground(*wxWHITE_BRUSH); + SetBrush(*wxWHITE_BRUSH); + SetPen(*wxBLACK_PEN); m_ok = FALSE; }; @@ -75,7 +83,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) }; }; -void wxMemoryDC::GetSize( int *width, int *height ) const +void wxMemoryDC::DoGetSize( int *width, int *height ) const { if (m_selected.Ok()) { diff --git a/src/mac/frame.cpp b/src/mac/frame.cpp index aded221ea5..bbbef8f74b 100644 --- a/src/mac/frame.cpp +++ b/src/mac/frame.cpp @@ -54,6 +54,14 @@ bool wxFrame::m_useNativeStatusBar = FALSE; void wxFrame::Init() { + m_frameMenuBar = NULL; + +#if wxUSE_TOOLBAR + m_frameToolBar = NULL ; +#endif + m_frameStatusBar = NULL; + m_winLastFocused = NULL ; + m_iconized = FALSE; #if wxUSE_TOOLTIPS @@ -94,14 +102,6 @@ bool wxFrame::Create(wxWindow *parent, long style, const wxString& name) { - m_frameMenuBar = NULL; - -#if wxUSE_TOOLBAR - m_frameToolBar = NULL ; -#endif - m_frameStatusBar = NULL; - m_winLastFocused = NULL ; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); if ( id > -1 ) @@ -229,7 +229,6 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) return; } - m_frameMenuBar = NULL; m_frameMenuBar = menuBar; // m_frameMenuBar->MacInstallMenuBar() ; m_frameMenuBar->Attach(this); diff --git a/src/mac/glcanvas.cpp b/src/mac/glcanvas.cpp new file mode 100644 index 0000000000..b3832d29fa --- /dev/null +++ b/src/mac/glcanvas.cpp @@ -0,0 +1,290 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: glcanvas.cpp +// Purpose: wxGLCanvas, for using OpenGL with wxWindows under Macintosh +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "glcanvas.h" +#endif + +#include "wx/wxprec.h" + +#if defined(__BORLANDC__) +#pragma hdrstop +#endif + +#include "wx/setup.h" + +#if wxUSE_GLCANVAS + +#ifndef WX_PRECOMP +#include "wx/frame.h" +#endif + +#include "wx/settings.h" +#include "wx/log.h" + +#include "wx/glcanvas.h" +#include "wx/mac/uma.h" + +#include + +/* + * GLContext implementation + */ + +wxGLContext::wxGLContext( + AGLPixelFormat fmt, wxGLCanvas *win, + const wxPalette& palette, + const wxGLContext *other /* for sharing display lists */ +) +{ + m_window = win; + + m_drawable = (AGLDrawable) UMAGetWindowPort(win->GetMacRootWindow()); + + m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL); + wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") ); + + GLboolean b; + b = aglSetDrawable(m_glContext, m_drawable); + wxCHECK_RET( b, wxT("Couldn't bind OpenGl context") ); + aglEnable(m_glContext , AGL_BUFFER_RECT ) ; + b = aglSetCurrentContext(m_glContext); + wxCHECK_RET( b, wxT("Couldn't activate OpenGl context") ); +} + +wxGLContext::~wxGLContext() +{ + if (m_glContext) + { + aglSetCurrentContext(NULL); + aglDestroyContext(m_glContext); + } +} + +void wxGLContext::SwapBuffers() +{ + if (m_glContext) + { + aglSwapBuffers(m_glContext); + } +} + +void wxGLContext::SetCurrent() +{ + if (m_glContext) + { + aglSetCurrentContext(m_glContext); + } +} + +void wxGLContext::Update() +{ + if (m_glContext) + { + aglUpdateContext(m_glContext); + } +} + +void wxGLContext::SetColour(const char *colour) +{ + float r = 0.0; + float g = 0.0; + float b = 0.0; + wxColour *col = wxTheColourDatabase->FindColour(colour); + if (col) + { + r = (float)(col->Red()/256.0); + g = (float)(col->Green()/256.0); + b = (float)(col->Blue()/256.0); + glColor3f( r, g, b); + } +} + + +/* + * wxGLCanvas implementation + */ + +IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow) + +BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow) + EVT_SIZE(wxGLCanvas::OnSize) +END_EVENT_TABLE() + +wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette) +{ + Create(parent, NULL, id, pos, size, style, name, attribList, palette); +} + +wxGLCanvas::wxGLCanvas( wxWindow *parent, + const wxGLContext *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette ) +{ + Create(parent, shared, id, pos, size, style, name, attribList, palette); +} + +wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette ) +{ + Create(parent, shared ? shared->GetContext() : NULL, id, pos, size, style, name, attribList, palette); +} + +wxGLCanvas::~wxGLCanvas() +{ + if (m_glContext) + delete m_glContext; +} + +bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, + const wxPoint& pos, const wxSize& size, long style, const wxString& name, + int *attribList, const wxPalette& palette) +{ + m_macEraseOnRedraw = false ; + GLint data[512]; + GLint defs[] = { AGL_RGBA, + AGL_DOUBLEBUFFER, + AGL_MINIMUM_POLICY, + AGL_DEPTH_SIZE, 1, // use largest available depth buffer + AGL_RED_SIZE, 1, + AGL_GREEN_SIZE, 1, + AGL_BLUE_SIZE, 1, + AGL_ALPHA_SIZE, 0, + AGL_NONE }; + GLint *attribs; + if (!attribList) + { + attribs = defs; + } + else + { + int data[512], arg=0, p=0; + + data[p++] = AGL_MINIMUM_POLICY; // make _SIZE tags behave more like GLX + while( (attribList[arg]!=0) && (p<512) ) + { + switch( attribList[arg++] ) + { + case WX_GL_RGBA: data[p++] = AGL_RGBA; break; + case WX_GL_BUFFER_SIZE: + data[p++]=AGL_BUFFER_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_LEVEL: + data[p++]=AGL_LEVEL; data[p++]=attribList[arg++]; break; + case WX_GL_DOUBLEBUFFER: data[p++] = AGL_DOUBLEBUFFER; break; + case WX_GL_STEREO: data[p++] = AGL_STEREO; break; + case WX_GL_AUX_BUFFERS: + data[p++]=AGL_AUX_BUFFERS; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_RED: + data[p++]=AGL_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_GREEN: + data[p++]=AGL_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_BLUE: + data[p++]=AGL_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ALPHA: + data[p++]=AGL_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_DEPTH_SIZE: + data[p++]=AGL_DEPTH_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_STENCIL_SIZE: + data[p++]=AGL_STENCIL_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_RED: + data[p++]=AGL_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_GREEN: + data[p++]=AGL_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_BLUE: + data[p++]=AGL_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break; + case WX_GL_MIN_ACCUM_ALPHA: + data[p++]=AGL_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break; + default: + break; + } + } + data[p] = 0; + + attribs = defs; + } + wxScrolledWindow::Create( parent, id, pos, size, style, name ); + + AGLPixelFormat fmt = aglChoosePixelFormat(NULL, 0, attribs); + wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") ); + + m_glContext = new wxGLContext(fmt, this, palette, shared); + + aglDestroyPixelFormat(fmt); + + return true; +} + +void wxGLCanvas::SwapBuffers() +{ + if (m_glContext) + m_glContext->SwapBuffers(); +} + +void wxGLCanvas::UpdateContext() +{ + if (m_glContext) + m_glContext->Update(); +} + +void wxGLCanvas::SetViewport() +{ + // viewport is initially set to entire port + // adjust glViewport to just this window + int x = 0 ; + int y = 0 ; + + MacClientToRootWindow( &x , &y ) ; + int width, height; + GetClientSize(& width, & height); + Rect bounds ; + GetWindowPortBounds( GetMacRootWindow() , &bounds ) ; + GLint parms[4] ; + parms[0] = x ; + parms[1] = bounds.bottom - bounds.top - ( y + height ) ; + parms[2] = width ; + parms[3] = height ; + + aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ; +} + +void wxGLCanvas::OnSize(wxSizeEvent& event) +{ + if (m_glContext) + { + UpdateContext(); + m_glContext->SetCurrent(); + + SetViewport(); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 ); + glMatrixMode(GL_MODELVIEW); + } +} + +void wxGLCanvas::SetCurrent() +{ + if (m_glContext) + { + m_glContext->SetCurrent(); + } +} + +void wxGLCanvas::SetColour(const char *colour) +{ + if (m_glContext) + m_glContext->SetColour(colour); +} + +#endif // wxUSE_GLCANVAS diff --git a/src/mac/macnotfy.cpp b/src/mac/macnotfy.cpp index db406cdc63..a47fce31e5 100644 --- a/src/mac/macnotfy.cpp +++ b/src/mac/macnotfy.cpp @@ -59,7 +59,6 @@ void wxMacCreateNotifierTable() void wxMacDestroyNotifierTable() { - wxASSERT( gMacNotificationEvents.top == gMacNotificationEvents.bottom ) ; } wxMacNotifierTableRef wxMacGetNotifierTable() diff --git a/src/mac/mdi.cpp b/src/mac/mdi.cpp index 887f726504..79197cdecd 100644 --- a/src/mac/mdi.cpp +++ b/src/mac/mdi.cpp @@ -36,10 +36,28 @@ END_EVENT_TABLE() #endif +static const int IDM_WINDOWTILE = 4001; +static const int IDM_WINDOWTILEHOR = 4001; +static const int IDM_WINDOWCASCADE = 4002; +static const int IDM_WINDOWICONS = 4003; +static const int IDM_WINDOWNEXT = 4004; +static const int IDM_WINDOWTILEVERT = 4005; + +// This range gives a maximum of 500 MDI children. Should be enough :-) +static const int wxFIRST_MDI_CHILD = 4100; +static const int wxLAST_MDI_CHILD = 4600; + +// Status border dimensions +static const int wxTHICK_LINE_BORDER = 3; + // Parent frame wxMDIParentFrame::wxMDIParentFrame() { + m_clientWindow = NULL; + m_currentChild = NULL; + m_windowMenu = (wxMenu*) NULL; + m_parentFrameActive = TRUE; } bool wxMDIParentFrame::Create(wxWindow *parent, @@ -50,30 +68,58 @@ bool wxMDIParentFrame::Create(wxWindow *parent, long style, const wxString& name) { - if (!parent) - wxTopLevelWindows.Append(this); - - SetName(name); - m_windowStyle = style; - - if (parent) parent->AddChild(this); - - if ( id > -1 ) - m_windowId = id; - else - m_windowId = (int)NewControlId(); - - // this window does not exist really - - wxModelessWindows.Append(this); + m_clientWindow = NULL; + m_currentChild = NULL; + + // this style can be used to prevent a window from having the standard MDI + // "Window" menu + if ( style & wxFRAME_NO_WINDOW_MENU ) + { + m_windowMenu = (wxMenu *)NULL; + style -= wxFRAME_NO_WINDOW_MENU ; + } + else // normal case: we have the window menu, so construct it + { + m_windowMenu = new wxMenu; + + m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade")); + m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally")); + m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically")); + m_windowMenu->AppendSeparator(); + m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons")); + m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next")); + } + + wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ; + m_parentFrameActive = TRUE; + + OnCreateClient(); return TRUE; } wxMDIParentFrame::~wxMDIParentFrame() { + DestroyChildren(); + // already delete by DestroyChildren() + m_frameToolBar = NULL; + m_frameStatusBar = NULL; + m_clientWindow = NULL ; + + if (m_windowMenu) + { + delete m_windowMenu; + m_windowMenu = (wxMenu*) NULL; + } + + if ( m_clientWindow ) + { + delete m_clientWindow; + m_clientWindow = NULL ; + } } + // Get size *available for subwindows* i.e. excluding menu bar. void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const { @@ -102,21 +148,34 @@ void wxMDIParentFrame::OnSize(wxSizeEvent& event) void wxMDIParentFrame::OnActivate(wxActivateEvent& event) { - // Do nothing + if ( m_currentChild && event.GetActive() ) + { + wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); + event.SetEventObject( m_currentChild ); + m_currentChild->GetEventHandler()->ProcessEvent(event) ; + } + else if ( event.GetActive() ) + { + if ( m_frameMenuBar != NULL ) + { + m_frameMenuBar->MacInstallMenuBar() ; + } + + } } // Returns the active MDI child window wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { - // TODO - return NULL; + return m_currentChild ; } // Create the client window class (don't Create the window, // just return a new class) wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() { - return new wxMDIClientWindow ; + m_clientWindow = new wxMDIClientWindow( this ); + return m_clientWindow; } // Responds to colour changes, and passes event on to children. @@ -157,6 +216,10 @@ void wxMDIParentFrame::ActivatePrevious() // Child frame wxMDIChildFrame::wxMDIChildFrame() +{ + Init() ; +} +void wxMDIChildFrame::Init() { } @@ -187,18 +250,10 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, wxMDIChildFrame::~wxMDIChildFrame() { -} - -// Set the client size (i.e. leave the calculation of borders etc. -// to wxWindows) -void wxMDIChildFrame::SetClientSize(int width, int height) -{ - // TODO -} - -void wxMDIChildFrame::GetPosition(int *x, int *y) const -{ - // TODO + DestroyChildren(); + // already delete by DestroyChildren() + m_frameToolBar = NULL; + m_frameStatusBar = NULL; } void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) @@ -209,20 +264,21 @@ void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) // MDI operations void wxMDIChildFrame::Maximize() { - // TODO + wxFrame::Maximize() ; } void wxMDIChildFrame::Restore() { - // TODO + wxFrame::Restore() ; } void wxMDIChildFrame::Activate() { - // TODO } -// Client window +//----------------------------------------------------------------------------- +// wxMDIClientWindow +//----------------------------------------------------------------------------- wxMDIClientWindow::wxMDIClientWindow() { @@ -230,14 +286,22 @@ wxMDIClientWindow::wxMDIClientWindow() wxMDIClientWindow::~wxMDIClientWindow() { + DestroyChildren(); } bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) { - // TODO create client window + + m_windowId = (int)NewControlId(); + + if ( parent ) + { + parent->AddChild(this); + } m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); - return FALSE; + wxModelessWindows.Append(this); + return TRUE; } // Explicitly call default scroll behaviour diff --git a/src/mac/radiobox.cpp b/src/mac/radiobox.cpp index 877ba66899..3f3279dd04 100644 --- a/src/mac/radiobox.cpp +++ b/src/mac/radiobox.cpp @@ -105,8 +105,11 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, for (i = 0; i < n; i++) { - wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(),choices[i],wxPoint(5,20*i+10)); - m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); + wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(),choices[i],wxPoint(5,20*i+10), + wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ; + if ( i == 0 ) + m_radioButtonCycle = radBtn ; +// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } SetSelection(0); diff --git a/src/mac/radiobut.cpp b/src/mac/radiobut.cpp index 1f5bb9c67a..aff004469b 100644 --- a/src/mac/radiobut.cpp +++ b/src/mac/radiobut.cpp @@ -18,10 +18,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) -BEGIN_EVENT_TABLE(wxRadioButton, wxControl) - EVT_IDLE( wxRadioButton::OnIdle ) -END_EVENT_TABLE() - #include bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, @@ -34,8 +30,6 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, Rect bounds ; Str255 title ; - m_cycle=NULL; - MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, @@ -43,53 +37,28 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, MacPostControlCreate() ; - return TRUE; -} - -void wxRadioButton::OnIdle( wxIdleEvent &event ) -{ - if (!m_cycle && HasFlag(wxRB_GROUP)) + if (HasFlag(wxRB_GROUP)) + { + AddInCycle( NULL ) ; + } + else + { + /* search backward for last group start */ + wxRadioButton *chief = (wxRadioButton*) NULL; + wxWindowList::Node *node = parent->GetChildren().GetLast(); + while (node) { - // we are a stand-alone radiobutton and have - // the group flag indicating we have to collect - // the other radiobuttons belonging to this one - - bool reached_this = FALSE; - wxRadioButton *m_radioButtonCycle = NULL; - m_radioButtonCycle = AddInCycle( m_radioButtonCycle ); - - wxWindow *parent = GetParent(); - wxNode *node = parent->GetChildren().First(); - while (node) - { - wxWindow *child = (wxWindow*) node->Data(); - - node = node->Next(); - - // start searching behind current radiobutton - if (!reached_this) - { - reached_this = (this == child); - continue; - } - - if (child->IsKindOf( CLASSINFO ( wxRadioButton ) )) - { - wxRadioButton *rb = (wxRadioButton*) child; - - // already reached next group - if (rb->HasFlag(wxRB_GROUP)) break; - - // part of a radiobox - if (rb->NextInCycle()) break; - - m_radioButtonCycle = rb->AddInCycle( m_radioButtonCycle ); - } - } - + wxWindow *child = node->GetData(); + if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) ) + { + chief = (wxRadioButton*) child; + if (child->HasFlag(wxRB_GROUP)) break; + } + node = node->GetPrevious(); } - - event.Skip( TRUE ); + AddInCycle( chief ) ; + } + return TRUE; } void wxRadioButton::SetValue(bool val) @@ -140,7 +109,8 @@ wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle) } else { current=cycle; - while ((next=current->m_cycle)!=cycle) current=current->m_cycle; + while ((next=current->m_cycle)!=cycle) + current=current->m_cycle; m_cycle=cycle; current->m_cycle=this; return(cycle); diff --git a/src/mac/slider.cpp b/src/mac/slider.cpp index 05b29b696a..ffb6631aca 100644 --- a/src/mac/slider.cpp +++ b/src/mac/slider.cpp @@ -312,20 +312,13 @@ void wxSlider::MacHandleControlClick( ControlHandle control , SInt16 controlpart SetValue( value ) ; wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); - event.SetPosition(GetControlValue( m_macControl) ); + event.SetPosition(value); event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); -#if WXWIN_COMPATIBILITY + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId ); + cevent.SetInt( value ); + cevent.SetEventObject( this ); - 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 + GetEventHandler()->ProcessEvent( cevent ); } diff --git a/src/mac/statbmp.cpp b/src/mac/statbmp.cpp index 47aa296e1c..f85c66b456 100644 --- a/src/mac/statbmp.cpp +++ b/src/mac/statbmp.cpp @@ -71,7 +71,7 @@ void wxStaticBitmap::OnPaint( wxPaintEvent &event ) wxPaintDC dc(this); PrepareDC(dc); dc.SetPalette( *m_messageBitmap.GetPalette() ) ; - dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ; + dc.DrawBitmap( m_messageBitmap , 0 , 0 , TRUE ) ; } wxSize wxStaticBitmap::DoGetBestSize() const diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index 0a51bb757e..0806570a55 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -396,7 +396,7 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value) TESetSelect( from , to , teH ) ; TEDelete( teH ) ; TEInsert( value , value.Length() , teH ) ; -// MacInvalidateControl() ; + Refresh() ; } void wxTextCtrl::Remove(long from, long to) @@ -411,7 +411,7 @@ void wxTextCtrl::Remove(long from, long to) UMASetControlData( m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; UMAGetControlData( m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; TEDelete( teH ) ; -// MacInvalidateControl() ; + Refresh() ; } void wxTextCtrl::SetSelection(long from, long to) diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 738c7fcd91..4dad035bad 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -150,7 +150,7 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons m_x = x ; m_y = y ; } - + return true ; } wxToolBar::~wxToolBar() diff --git a/src/mac/utils.cpp b/src/mac/utils.cpp index 029f1fa968..28c069a63a 100644 --- a/src/mac/utils.cpp +++ b/src/mac/utils.cpp @@ -39,15 +39,35 @@ bool wxGetFullHostName(wxChar *buf, int maxSize) // Get hostname only (without domain name) bool wxGetHostName(char *buf, int maxSize) { - // TODO - return FALSE; + // Gets Chooser name of user by examining a System resource. + + const short kComputerNameID = -16413; + + short oldResFile = CurResFile() ; + UseResFile(0); + StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); + UseResFile(oldResFile); + + if (chooserName && *chooserName) + { + int length = (*chooserName)[0] ; + if ( length + 1 > maxSize ) + { + length = maxSize - 1 ; + } + strncpy( buf , (char*) &(*chooserName)[1] , length ) ; + buf[length] = 0 ; + } + else + buf[0] = 0 ; + + return TRUE; } // Get user ID e.g. jacs bool wxGetUserId(char *buf, int maxSize) { - // TODO - return FALSE; + return wxGetUserName( buf , maxSize ) ; } const wxChar* wxGetHomeDir(wxString *pstr) @@ -56,13 +76,32 @@ const wxChar* wxGetHomeDir(wxString *pstr) return pstr->c_str() ; } - - // Get user name e.g. AUTHOR bool wxGetUserName(char *buf, int maxSize) { - // TODO - return FALSE; + // Gets Chooser name of user by examining a System resource. + + const short kChooserNameID = -16096; + + short oldResFile = CurResFile() ; + UseResFile(0); + StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); + UseResFile(oldResFile); + + if (chooserName && *chooserName) + { + int length = (*chooserName)[0] ; + if ( length + 1 > maxSize ) + { + length = maxSize - 1 ; + } + strncpy( buf , (char*) &(*chooserName)[1] , length ) ; + buf[length] = 0 ; + } + else + buf[0] = 0 ; + + return TRUE; } int wxKill(long pid, int sig) @@ -83,13 +122,21 @@ bool wxShell(const wxString& command) // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) long wxGetFreeMemory() { - // TODO - return 0; + return FreeMem() ; +} + +void wxUsleep(unsigned long milliseconds) +{ + clock_t start = clock() ; + do + { + YieldToAnyThread() ; + } while( clock() - start < milliseconds / CLOCKS_PER_SEC ) ; } void wxSleep(int nSecs) { - // TODO + wxUsleep(1000*nSecs); } // Consume all events until no more left @@ -108,8 +155,9 @@ void wxDebugMsg(const char *fmt ...) va_start(ap, fmt); - // wvsprintf(buffer,fmt,ap) ; - // TODO: output buffer + vsprintf(buffer,fmt,ap) ; + strcat(buffer,";g") ; + debugstr(buffer) ; va_end(ap); } @@ -117,27 +165,33 @@ void wxDebugMsg(const char *fmt ...) // Non-fatal error: pop up message box and (possibly) continue void wxError(const wxString& msg, const wxString& title) { - // TODO + wxSprintf(wxBuffer, wxT("%s\nContinue?"), WXSTRINGCAST msg); + if (wxMessageBox(wxBuffer, title, wxYES_NO) == wxID_NO ) wxExit(); } // Fatal error: pop up message box and abort void wxFatalError(const wxString& msg, const wxString& title) { - // TODO + wxSprintf(wxBuffer, wxT("%s: %s"), WXSTRINGCAST title, WXSTRINGCAST msg); + wxMessageBox(wxBuffer); + wxExit(); } #endif // !__UNIX__ // Emit a beeeeeep void wxBell() { - // TODO + SysBeep(30); } int wxGetOsVersion(int *majorVsn, int *minorVsn) { - // TODO - return 0; + long theSystem ; + Gestalt(gestaltSystemVersion, &theSystem) ; + *minorVsn = (theSystem & 0xFF ) ; + *majorVsn = (theSystem >> 8 ) ; // are there x-platform conventions ? + return wxMACINTOSH; } // Reading and writing resources (eg WIN.INI, .Xdefaults) diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 382b71024f..148538256d 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -113,6 +113,8 @@ void wxWindow::Init() // generic InitBase(); + m_macEraseOnRedraw = true ; + // MSW specific m_doubleClickAllowed = 0; m_winCaptured = FALSE; @@ -130,6 +132,7 @@ void wxWindow::Init() m_isShown = TRUE; m_macWindowData = NULL ; + m_macEraseOnRedraw = true ; m_x = 0; m_y = 0 ; @@ -811,6 +814,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, void wxWindow::MacEraseBackground( Rect *rect ) { +/* WindowRef window = GetMacRootWindow() ; if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) ) { @@ -878,6 +882,7 @@ void wxWindow::MacEraseBackground( Rect *rect ) } } } +*/ } void wxWindow::Refresh(bool eraseBack, const wxRect *rect) @@ -1827,8 +1832,10 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time) if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() ) eraseBackground = true ; SetClip( updatergn ) ; - if ( eraseBackground ) + if ( eraseBackground && m_macEraseOnRedraw ) { + // todo : find a clever algorithm, which only will do this + // if really necessary EraseRgn( updatergn ) ; } } @@ -2310,37 +2317,7 @@ long wxWindow::MacRemoveBordersFromStyle( long style ) { return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ; } -/* -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 ) - { - SetPort( m_currentPort ) ; - SetOrigin( 0 , 0 ) ; - } - if ( m_formerPort != m_currentPort ) - SetPort( m_formerPort ) ; -} -*/ + wxMacDrawingHelper::wxMacDrawingHelper( wxWindow * theWindow ) { -- 2.45.2