mac fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10045 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ) ) )
|
||||
{
|
||||
|
||||
@@ -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 ;
|
||||
|
||||
@@ -61,6 +61,7 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas)
|
||||
|
||||
MacSetupPort() ;
|
||||
m_ok = TRUE ;
|
||||
SetBackground(wxBrush(the_canvas->GetBackgroundColour(), wxSOLID));
|
||||
}
|
||||
|
||||
wxWindowDC::~wxWindowDC()
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
290
src/mac/carbon/glcanvas.cpp
Normal file
290
src/mac/carbon/glcanvas.cpp
Normal file
@@ -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 <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
|
||||
@@ -59,7 +59,6 @@ void wxMacCreateNotifierTable()
|
||||
|
||||
void wxMacDestroyNotifierTable()
|
||||
{
|
||||
wxASSERT( gMacNotificationEvents.top == gMacNotificationEvents.bottom ) ;
|
||||
}
|
||||
|
||||
wxMacNotifierTableRef wxMacGetNotifierTable()
|
||||
|
||||
@@ -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);
|
||||
m_clientWindow = NULL;
|
||||
m_currentChild = NULL;
|
||||
|
||||
SetName(name);
|
||||
m_windowStyle = style;
|
||||
// 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;
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
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"));
|
||||
}
|
||||
|
||||
if ( id > -1 )
|
||||
m_windowId = id;
|
||||
else
|
||||
m_windowId = (int)NewControlId();
|
||||
|
||||
// this window does not exist really
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
|
||||
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,
|
||||
@@ -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);
|
||||
|
||||
@@ -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 );
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
|
||||
wxEventType oldEvent = event.GetEventType();
|
||||
event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED );
|
||||
if ( !GetEventHandler()->ProcessEvent(event) )
|
||||
{
|
||||
event.SetEventType( oldEvent );
|
||||
if (!GetParent()->GetEventHandler()->ProcessEvent(event))
|
||||
event.Skip();
|
||||
}
|
||||
#else
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
#endif
|
||||
|
||||
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId );
|
||||
cevent.SetInt( value );
|
||||
cevent.SetEventObject( this );
|
||||
|
||||
GetEventHandler()->ProcessEvent( cevent );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ) ) )
|
||||
{
|
||||
|
||||
@@ -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 ;
|
||||
|
||||
@@ -61,6 +61,7 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas)
|
||||
|
||||
MacSetupPort() ;
|
||||
m_ok = TRUE ;
|
||||
SetBackground(wxBrush(the_canvas->GetBackgroundColour(), wxSOLID));
|
||||
}
|
||||
|
||||
wxWindowDC::~wxWindowDC()
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
290
src/mac/glcanvas.cpp
Normal file
290
src/mac/glcanvas.cpp
Normal file
@@ -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 <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
|
||||
@@ -59,7 +59,6 @@ void wxMacCreateNotifierTable()
|
||||
|
||||
void wxMacDestroyNotifierTable()
|
||||
{
|
||||
wxASSERT( gMacNotificationEvents.top == gMacNotificationEvents.bottom ) ;
|
||||
}
|
||||
|
||||
wxMacNotifierTableRef wxMacGetNotifierTable()
|
||||
|
||||
134
src/mac/mdi.cpp
134
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);
|
||||
m_clientWindow = NULL;
|
||||
m_currentChild = NULL;
|
||||
|
||||
SetName(name);
|
||||
m_windowStyle = style;
|
||||
// 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;
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
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"));
|
||||
}
|
||||
|
||||
if ( id > -1 )
|
||||
m_windowId = id;
|
||||
else
|
||||
m_windowId = (int)NewControlId();
|
||||
|
||||
// this window does not exist really
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
|
||||
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,
|
||||
@@ -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);
|
||||
|
||||
@@ -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 );
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
|
||||
wxEventType oldEvent = event.GetEventType();
|
||||
event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED );
|
||||
if ( !GetEventHandler()->ProcessEvent(event) )
|
||||
{
|
||||
event.SetEventType( oldEvent );
|
||||
if (!GetParent()->GetEventHandler()->ProcessEvent(event))
|
||||
event.Skip();
|
||||
}
|
||||
#else
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
#endif
|
||||
|
||||
wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId );
|
||||
cevent.SetInt( value );
|
||||
cevent.SetEventObject( this );
|
||||
|
||||
GetEventHandler()->ProcessEvent( cevent );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user