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
-------------
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:
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;
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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 <gl.h>
+#include <agl.h>
+
+//---------------------------------------------------------------------------
+// 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_
// 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()
};
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr)
{
+ Init() ;
Create(parent, id, title, pos, size, style, name);
}
// 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
// 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
class WXDLLEXPORT wxRadioButton: public wxControl
{
+ DECLARE_DYNAMIC_CLASS(wxRadioButton)
+ protected:
public:
inline wxRadioButton() {}
inline wxRadioButton(wxWindow *parent, wxWindowID id,
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
#define wxUSE_ZIPSTREAM 1 // 0
// input stream for reading from zip archives
+// OpenGL canvas
+#define wxUSE_GLCANVAS 1
/*
* Finer detail
*
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 ;
// Mac-specific
UMAInitToolbox( 4 ) ;
+ SetEventMask( everyEvent ) ;
UMAShowWatchCursor() ;
#ifdef __UNIX__
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();
{
EventRecord event ;
- long sleepTime = ::GetCaretTime();
+ long sleepTime = 1 ; // GetCaretTime() / 4 ;
if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn))
{
// repeaters
+ DeletePendingObjects() ;
wxMacProcessNotifierAndPendingEvents() ;
}
short windowPart = ::FindWindow(ev->where, &window);
wxWindow* win = wxFindWinFromMacWindow( window ) ;
+ if ( wxPendingDelete.Member(win) )
+ return ;
BitMap screenBits;
GetQDGlobalsScreenBits( &screenBits );
SetOrigin( 0 , 0 ) ;
SetPort( port ) ;
}
- if ( window != frontWindow )
+ if ( window != frontWindow && wxTheApp->s_captureWindow == NULL )
{
if ( s_macIsInModalLoop )
{
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 )
wxWindow * win = wxFindWinFromMacWindow( window ) ;
if ( win )
{
- win->MacUpdate( ev ) ;
+ if ( !wxPendingDelete.Member(win) )
+ win->MacUpdate( ev ) ;
}
else
{
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);
// Mac-specific
UMAInitToolbox( 4 ) ;
+ SetEventMask( everyEvent ) ;
UMAShowWatchCursor() ;
#ifdef __UNIX__
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();
{
EventRecord event ;
- long sleepTime = ::GetCaretTime();
+ long sleepTime = 1 ; // GetCaretTime() / 4 ;
if (WaitNextEvent(everyEvent, &event,sleepTime, s_macCursorRgn))
{
// repeaters
+ DeletePendingObjects() ;
wxMacProcessNotifierAndPendingEvents() ;
}
short windowPart = ::FindWindow(ev->where, &window);
wxWindow* win = wxFindWinFromMacWindow( window ) ;
+ if ( wxPendingDelete.Member(win) )
+ return ;
BitMap screenBits;
GetQDGlobalsScreenBits( &screenBits );
SetOrigin( 0 , 0 ) ;
SetPort( port ) ;
}
- if ( window != frontWindow )
+ if ( window != frontWindow && wxTheApp->s_captureWindow == NULL )
{
if ( s_macIsInModalLoop )
{
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 )
wxWindow * win = wxFindWinFromMacWindow( window ) ;
if ( win )
{
- win->MacUpdate( ev ) ;
+ if ( !wxPendingDelete.Member(win) )
+ win->MacUpdate( ev ) ;
}
else
{
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);
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();
}
if ( IsKindOf( CLASSINFO( wxButton ) ) )
{
m_width = m_label.Length() * 8 + 12 ;
+ if ( m_width < 70 )
+ m_width = 70 ;
}
else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
{
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;
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 ;
MacSetupPort() ;
m_ok = TRUE ;
+ SetBackground(wxBrush(the_canvas->GetBackgroundColour(), wxSOLID));
}
wxWindowDC::~wxWindowDC()
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;
};
};
};
-void wxMemoryDC::GetSize( int *width, int *height ) const
+void wxMemoryDC::DoGetSize( int *width, int *height ) const
{
if (m_selected.Ok())
{
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
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 )
return;
}
- m_frameMenuBar = NULL;
m_frameMenuBar = menuBar;
// m_frameMenuBar->MacInstallMenuBar() ;
m_frameMenuBar->Attach(this);
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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 <agl.h>
+
+/*
+ * 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
void wxMacDestroyNotifierTable()
{
- wxASSERT( gMacNotificationEvents.top == gMacNotificationEvents.bottom ) ;
}
wxMacNotifierTableRef wxMacGetNotifierTable()
#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,
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
{
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.
// Child frame
wxMDIChildFrame::wxMDIChildFrame()
+{
+ Init() ;
+}
+void wxMDIChildFrame::Init()
{
}
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)
// MDI operations
void wxMDIChildFrame::Maximize()
{
- // TODO
+ wxFrame::Maximize() ;
}
void wxMDIChildFrame::Restore()
{
- // TODO
+ wxFrame::Restore() ;
}
void wxMDIChildFrame::Activate()
{
- // TODO
}
-// Client window
+//-----------------------------------------------------------------------------
+// wxMDIClientWindow
+//-----------------------------------------------------------------------------
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
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);
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
-BEGIN_EVENT_TABLE(wxRadioButton, wxControl)
- EVT_IDLE( wxRadioButton::OnIdle )
-END_EVENT_TABLE()
-
#include <wx/mac/uma.h>
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,
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)
}
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);
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 );
}
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
TESetSelect( from , to , teH ) ;
TEDelete( teH ) ;
TEInsert( value , value.Length() , teH ) ;
-// MacInvalidateControl() ;
+ Refresh() ;
}
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)
m_x = x ;
m_y = y ;
}
-
+ return true ;
}
wxToolBar::~wxToolBar()
// 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)
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)
// 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
va_start(ap, fmt);
- // wvsprintf(buffer,fmt,ap) ;
- // TODO: output buffer
+ vsprintf(buffer,fmt,ap) ;
+ strcat(buffer,";g") ;
+ debugstr(buffer) ;
va_end(ap);
}
// 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)
// generic
InitBase();
+ m_macEraseOnRedraw = true ;
+
// MSW specific
m_doubleClickAllowed = 0;
m_winCaptured = FALSE;
m_isShown = TRUE;
m_macWindowData = NULL ;
+ m_macEraseOnRedraw = true ;
m_x = 0;
m_y = 0 ;
void wxWindow::MacEraseBackground( Rect *rect )
{
+/*
WindowRef window = GetMacRootWindow() ;
if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
{
}
}
}
+*/
}
void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
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 ) ;
}
}
{
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 )
{
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();
}
if ( IsKindOf( CLASSINFO( wxButton ) ) )
{
m_width = m_label.Length() * 8 + 12 ;
+ if ( m_width < 70 )
+ m_width = 70 ;
}
else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
{
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;
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 ;
MacSetupPort() ;
m_ok = TRUE ;
+ SetBackground(wxBrush(the_canvas->GetBackgroundColour(), wxSOLID));
}
wxWindowDC::~wxWindowDC()
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;
};
};
};
-void wxMemoryDC::GetSize( int *width, int *height ) const
+void wxMemoryDC::DoGetSize( int *width, int *height ) const
{
if (m_selected.Ok())
{
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
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 )
return;
}
- m_frameMenuBar = NULL;
m_frameMenuBar = menuBar;
// m_frameMenuBar->MacInstallMenuBar() ;
m_frameMenuBar->Attach(this);
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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 <agl.h>
+
+/*
+ * 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
void wxMacDestroyNotifierTable()
{
- wxASSERT( gMacNotificationEvents.top == gMacNotificationEvents.bottom ) ;
}
wxMacNotifierTableRef wxMacGetNotifierTable()
#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,
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
{
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.
// Child frame
wxMDIChildFrame::wxMDIChildFrame()
+{
+ Init() ;
+}
+void wxMDIChildFrame::Init()
{
}
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)
// MDI operations
void wxMDIChildFrame::Maximize()
{
- // TODO
+ wxFrame::Maximize() ;
}
void wxMDIChildFrame::Restore()
{
- // TODO
+ wxFrame::Restore() ;
}
void wxMDIChildFrame::Activate()
{
- // TODO
}
-// Client window
+//-----------------------------------------------------------------------------
+// wxMDIClientWindow
+//-----------------------------------------------------------------------------
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
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);
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
-BEGIN_EVENT_TABLE(wxRadioButton, wxControl)
- EVT_IDLE( wxRadioButton::OnIdle )
-END_EVENT_TABLE()
-
#include <wx/mac/uma.h>
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,
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)
}
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);
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 );
}
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
TESetSelect( from , to , teH ) ;
TEDelete( teH ) ;
TEInsert( value , value.Length() , teH ) ;
-// MacInvalidateControl() ;
+ Refresh() ;
}
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)
m_x = x ;
m_y = y ;
}
-
+ return true ;
}
wxToolBar::~wxToolBar()
// 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)
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)
// 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
va_start(ap, fmt);
- // wvsprintf(buffer,fmt,ap) ;
- // TODO: output buffer
+ vsprintf(buffer,fmt,ap) ;
+ strcat(buffer,";g") ;
+ debugstr(buffer) ;
va_end(ap);
}
// 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)
// generic
InitBase();
+ m_macEraseOnRedraw = true ;
+
// MSW specific
m_doubleClickAllowed = 0;
m_winCaptured = FALSE;
m_isShown = TRUE;
m_macWindowData = NULL ;
+ m_macEraseOnRedraw = true ;
m_x = 0;
m_y = 0 ;
void wxWindow::MacEraseBackground( Rect *rect )
{
+/*
WindowRef window = GetMacRootWindow() ;
if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
{
}
}
}
+*/
}
void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
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 ) ;
}
}
{
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 )
{