mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2025-12-18 16:50:20 +08:00
split classic and carbon
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26277 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
36
src/mac/classic/Info.plist.in
Normal file
36
src/mac/classic/Info.plist.in
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
|
||||
<plist version="0.9">
|
||||
<dict>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.wxwindows.IDENTIFIER</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>EXECUTABLE</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>wxmac.icns</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>EXECUTABLE</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>VERSION</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>VERSION</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>EXECUTABLE version VERSION, (c) 2002 wxWindows</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
<string>VERSION, (c) 2002 wxWindows</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright 2002 wxWindows</string>
|
||||
<key>LSRequiresCarbon</key>
|
||||
<true/>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
108
src/mac/classic/accel.cpp
Normal file
108
src/mac/classic/accel.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: accel.cpp
|
||||
// Purpose: wxAcceleratorTable
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "accel.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
#include "wx/accel.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAccelList: a list of wxAcceleratorEntries
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WX_DECLARE_LIST(wxAcceleratorEntry, wxAccelList);
|
||||
#include "wx/listimpl.cpp"
|
||||
WX_DEFINE_LIST(wxAccelList);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAccelRefData: the data used by wxAcceleratorTable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
|
||||
{
|
||||
friend class WXDLLEXPORT wxAcceleratorTable;
|
||||
public:
|
||||
wxAcceleratorRefData();
|
||||
~wxAcceleratorRefData();
|
||||
|
||||
wxAccelList m_accels;
|
||||
};
|
||||
|
||||
#define M_ACCELDATA ((wxAcceleratorRefData *)m_refData)
|
||||
|
||||
wxAcceleratorRefData::wxAcceleratorRefData()
|
||||
: m_accels()
|
||||
{
|
||||
}
|
||||
|
||||
wxAcceleratorRefData::~wxAcceleratorRefData()
|
||||
{
|
||||
m_accels.DeleteContents( TRUE );
|
||||
}
|
||||
|
||||
wxAcceleratorTable::wxAcceleratorTable()
|
||||
{
|
||||
m_refData = NULL;
|
||||
}
|
||||
|
||||
wxAcceleratorTable::~wxAcceleratorTable()
|
||||
{
|
||||
}
|
||||
|
||||
// Create from an array
|
||||
wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[])
|
||||
{
|
||||
m_refData = new wxAcceleratorRefData;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
int flag = entries[i].GetFlags();
|
||||
int keycode = entries[i].GetKeyCode();
|
||||
int command = entries[i].GetCommand();
|
||||
if ((keycode >= (int)'a') && (keycode <= (int)'z')) keycode = (int)toupper( (char)keycode );
|
||||
M_ACCELDATA->m_accels.Append( new wxAcceleratorEntry( flag, keycode, command ) );
|
||||
}
|
||||
}
|
||||
|
||||
bool wxAcceleratorTable::Ok() const
|
||||
{
|
||||
return (m_refData != NULL);
|
||||
}
|
||||
|
||||
int wxAcceleratorTable::GetCommand( wxKeyEvent &event )
|
||||
{
|
||||
if (!Ok()) return -1;
|
||||
|
||||
wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxAcceleratorEntry *entry = (wxAcceleratorEntry*)node->GetData();
|
||||
if ((event.m_keyCode == entry->GetKeyCode()) &&
|
||||
(((entry->GetFlags() & wxACCEL_CTRL) == 0) || event.ControlDown()) &&
|
||||
(((entry->GetFlags() & wxACCEL_SHIFT) == 0) || event.ShiftDown()) &&
|
||||
(((entry->GetFlags() & wxACCEL_ALT) == 0) || event.AltDown() || event.MetaDown()))
|
||||
{
|
||||
return entry->GetCommand();
|
||||
}
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
2
src/mac/classic/aga.cpp
Normal file
2
src/mac/classic/aga.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
// NOT NEEDED ANYMORE
|
||||
|
||||
2439
src/mac/classic/app.cpp
Normal file
2439
src/mac/classic/app.cpp
Normal file
File diff suppressed because it is too large
Load Diff
6
src/mac/classic/apprsrc.h
Normal file
6
src/mac/classic/apprsrc.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#define kMacSTRWrongMachine 1
|
||||
#define kMacSTRSmallSize 2
|
||||
#define kMacSTRNoMemory 3
|
||||
#define kMacSTROldSystem 4
|
||||
#define kMacSTRGenericAbout 5
|
||||
#define kMacSTRNoPre8Yet 6
|
||||
32
src/mac/classic/apprsrc.r
Normal file
32
src/mac/classic/apprsrc.r
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifdef __UNIX__
|
||||
# include <Carbon.r>
|
||||
#else
|
||||
# include <Types.r>
|
||||
#endif
|
||||
#include "apprsrc.h"
|
||||
|
||||
resource 'STR#' ( 128 , "Simple Alert Messages" )
|
||||
{
|
||||
{
|
||||
"This application needs at least a MacPlus" ,
|
||||
"This application needs more memory" ,
|
||||
"This application is out of memory" ,
|
||||
"This application needs at least System 8.6" ,
|
||||
"About this wxWindows Application" ,
|
||||
"This application needs Appearance extension (built in with System 8) - this restriction will be relieved in the final release"
|
||||
}
|
||||
} ;
|
||||
|
||||
resource 'MENU' (1, preload)
|
||||
{
|
||||
1, textMenuProc, 0b11111111111111111111111111111110 , enabled, apple ,
|
||||
{
|
||||
"About<EFBFBD>" , noicon, nokey,nomark,plain ,
|
||||
"-" , noicon, nokey,nomark,plain
|
||||
}
|
||||
} ;
|
||||
|
||||
resource 'MBAR' (1,preload)
|
||||
{
|
||||
{ 1 } ;
|
||||
} ;
|
||||
1436
src/mac/classic/bitmap.cpp
Normal file
1436
src/mac/classic/bitmap.cpp
Normal file
File diff suppressed because it is too large
Load Diff
113
src/mac/classic/bmpbuttn.cpp
Normal file
113
src/mac/classic/bmpbuttn.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: bmpbuttn.cpp
|
||||
// Purpose: wxBitmapButton
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "bmpbuttn.h"
|
||||
#endif
|
||||
|
||||
#include "wx/window.h"
|
||||
#include "wx/bmpbuttn.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
||||
#endif
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
// since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create
|
||||
// essentially creates an additional button
|
||||
if ( !wxControl::Create(parent, id, pos, size,
|
||||
style, validator, name) )
|
||||
return false;
|
||||
|
||||
m_bmpNormal = bitmap;
|
||||
|
||||
if (style & wxBU_AUTODRAW)
|
||||
{
|
||||
m_marginX = wxDEFAULT_BUTTON_MARGIN;
|
||||
m_marginY = wxDEFAULT_BUTTON_MARGIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_marginX = 0;
|
||||
m_marginY = 0;
|
||||
}
|
||||
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
|
||||
if ( bitmap.Ok() )
|
||||
{
|
||||
wxSize newSize = DoGetBestSize();
|
||||
if ( width == -1 )
|
||||
width = newSize.x;
|
||||
if ( height == -1 )
|
||||
height = newSize.y;
|
||||
}
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_bmpNormal = bitmap;
|
||||
wxBitmapRefData * bmap = NULL ;
|
||||
|
||||
if ( m_bmpNormal.Ok() )
|
||||
bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
|
||||
|
||||
MacPreControlCreate( parent , id , wxEmptyString , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 ,
|
||||
kControlBehaviorOffsetContents +
|
||||
( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ?
|
||||
kControlContentCIconHandle : kControlContentPictHandle ) , 0,
|
||||
(( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
|
||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
|
||||
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||
if ( info.contentType != kControlNoContent )
|
||||
{
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
}
|
||||
MacPostControlCreate() ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
m_bmpNormal = bitmap;
|
||||
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||
if ( info.contentType != kControlNoContent )
|
||||
{
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wxSize wxBitmapButton::DoGetBestSize() const
|
||||
{
|
||||
wxSize best;
|
||||
if (m_bmpNormal.Ok())
|
||||
{
|
||||
best.x = m_bmpNormal.GetWidth() + 2*m_marginX;
|
||||
best.y = m_bmpNormal.GetHeight() + 2*m_marginY;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
229
src/mac/classic/brush.cpp
Normal file
229
src/mac/classic/brush.cpp
Normal file
@@ -0,0 +1,229 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: brush.cpp
|
||||
// Purpose: wxBrush
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "brush.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/brush.h"
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
|
||||
{
|
||||
friend class WXDLLEXPORT wxBrush;
|
||||
public:
|
||||
wxBrushRefData();
|
||||
wxBrushRefData(const wxBrushRefData& data);
|
||||
~wxBrushRefData();
|
||||
|
||||
protected:
|
||||
wxMacBrushKind m_macBrushKind ;
|
||||
int m_style;
|
||||
wxBitmap m_stipple ;
|
||||
wxColour m_colour;
|
||||
|
||||
ThemeBrush m_macThemeBrush ;
|
||||
|
||||
ThemeBackgroundKind m_macThemeBackground ;
|
||||
Rect m_macThemeBackgroundExtent ;
|
||||
};
|
||||
|
||||
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
|
||||
|
||||
wxBrushRefData::wxBrushRefData()
|
||||
: m_style(wxSOLID)
|
||||
{
|
||||
m_macBrushKind = kwxMacBrushColour ;
|
||||
}
|
||||
|
||||
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
|
||||
: wxGDIRefData()
|
||||
, m_style(data.m_style)
|
||||
{
|
||||
m_stipple = data.m_stipple;
|
||||
m_colour = data.m_colour;
|
||||
m_macBrushKind = data.m_macBrushKind ;
|
||||
m_macThemeBrush = data.m_macThemeBrush ;
|
||||
m_macThemeBackground = data.m_macThemeBackground ;
|
||||
m_macThemeBackgroundExtent = data.m_macThemeBackgroundExtent ;
|
||||
}
|
||||
|
||||
wxBrushRefData::~wxBrushRefData()
|
||||
{
|
||||
}
|
||||
|
||||
// Brushes
|
||||
wxBrush::wxBrush()
|
||||
{
|
||||
}
|
||||
|
||||
wxBrush::~wxBrush()
|
||||
{
|
||||
}
|
||||
|
||||
wxBrush::wxBrush(const wxColour& col, int Style)
|
||||
{
|
||||
m_refData = new wxBrushRefData;
|
||||
|
||||
M_BRUSHDATA->m_colour = col;
|
||||
M_BRUSHDATA->m_style = Style;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
wxBrush::wxBrush(const wxBitmap& stipple)
|
||||
{
|
||||
m_refData = new wxBrushRefData;
|
||||
|
||||
M_BRUSHDATA->m_colour = *wxBLACK;
|
||||
M_BRUSHDATA->m_stipple = stipple;
|
||||
|
||||
if (M_BRUSHDATA->m_stipple.GetMask())
|
||||
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
|
||||
else
|
||||
M_BRUSHDATA->m_style = wxSTIPPLE;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
wxBrush::wxBrush(ThemeBrush macThemeBrush )
|
||||
{
|
||||
m_refData = new wxBrushRefData;
|
||||
|
||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
|
||||
M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
void wxBrush::Unshare()
|
||||
{
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
{
|
||||
m_refData = new wxBrushRefData();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
}
|
||||
|
||||
void wxBrush::SetColour(const wxColour& col)
|
||||
{
|
||||
Unshare();
|
||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
|
||||
M_BRUSHDATA->m_colour = col;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
|
||||
M_BRUSHDATA->m_colour.Set(r, g, b);
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxBrush::SetStyle(int Style)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
|
||||
M_BRUSHDATA->m_style = Style;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxBrush::SetStipple(const wxBitmap& Stipple)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
|
||||
M_BRUSHDATA->m_stipple = Stipple;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
|
||||
M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxBrush::SetMacThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
|
||||
M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
|
||||
M_BRUSHDATA->m_macThemeBackgroundExtent = *(Rect*)extent ;
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
bool wxBrush::RealizeResource()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const
|
||||
{
|
||||
if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
|
||||
{
|
||||
if ( extent )
|
||||
*(Rect*)extent = M_BRUSHDATA->m_macThemeBackgroundExtent ;
|
||||
return M_BRUSHDATA->m_macThemeBackground ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
short wxBrush::GetMacTheme() const
|
||||
{
|
||||
return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack);
|
||||
}
|
||||
|
||||
wxColour& wxBrush::GetColour() const
|
||||
{
|
||||
return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour);
|
||||
}
|
||||
|
||||
int wxBrush::GetStyle() const
|
||||
{
|
||||
return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0);
|
||||
}
|
||||
|
||||
wxBitmap *wxBrush::GetStipple() const
|
||||
{
|
||||
return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0);
|
||||
}
|
||||
|
||||
wxMacBrushKind wxBrush::MacGetBrushKind() const
|
||||
{
|
||||
return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour);
|
||||
}
|
||||
132
src/mac/classic/button.cpp
Normal file
132
src/mac/classic/button.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: button.cpp
|
||||
// Purpose: wxButton
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "button.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/button.h"
|
||||
#include "wx/panel.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||
#endif
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
// Button
|
||||
|
||||
static const int kMacOSXHorizontalBorder = 2 ;
|
||||
static const int kMacOSXVerticalBorder = 4 ;
|
||||
|
||||
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
|
||||
return false;
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
|
||||
if ( UMAHasAquaLayout() )
|
||||
{
|
||||
m_macHorizontalBorder = kMacOSXHorizontalBorder;
|
||||
m_macVerticalBorder = kMacOSXVerticalBorder;
|
||||
}
|
||||
|
||||
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
|
||||
kControlPushButtonProc , (long) this ) ;
|
||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
|
||||
|
||||
MacPostControlCreate() ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxButton::SetDefault()
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
wxButton *btnOldDefault = NULL;
|
||||
if ( parent )
|
||||
{
|
||||
btnOldDefault = wxDynamicCast(parent->GetDefaultItem(),
|
||||
wxButton);
|
||||
parent->SetDefaultItem(this);
|
||||
}
|
||||
|
||||
Boolean inData;
|
||||
if ( btnOldDefault && btnOldDefault->m_macControl )
|
||||
{
|
||||
inData = 0;
|
||||
::SetControlData( (ControlHandle) btnOldDefault->m_macControl , kControlButtonPart ,
|
||||
kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ;
|
||||
}
|
||||
if ( (ControlHandle) m_macControl )
|
||||
{
|
||||
inData = 1;
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart ,
|
||||
kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ;
|
||||
}
|
||||
}
|
||||
|
||||
wxSize wxButton::DoGetBestSize() const
|
||||
{
|
||||
wxSize sz = GetDefaultSize() ;
|
||||
|
||||
int wBtn = m_label.Length() * 8 + 12 + 2 * kMacOSXHorizontalBorder ;
|
||||
|
||||
if (wBtn > sz.x) sz.x = wBtn;
|
||||
|
||||
return sz ;
|
||||
}
|
||||
|
||||
wxSize wxButton::GetDefaultSize()
|
||||
{
|
||||
int wBtn = 70 ;
|
||||
int hBtn = 20 ;
|
||||
|
||||
if ( UMAHasAquaLayout() )
|
||||
{
|
||||
wBtn += 2 * kMacOSXHorizontalBorder ;
|
||||
hBtn += 2 * kMacOSXVerticalBorder ;
|
||||
}
|
||||
|
||||
return wxSize(wBtn, hBtn);
|
||||
}
|
||||
|
||||
void wxButton::Command (wxCommandEvent & event)
|
||||
{
|
||||
if ( (ControlHandle) m_macControl )
|
||||
{
|
||||
HiliteControl( (ControlHandle) m_macControl , kControlButtonPart ) ;
|
||||
unsigned long finalTicks ;
|
||||
Delay( 8 , &finalTicks ) ;
|
||||
HiliteControl( (ControlHandle) m_macControl , 0 ) ;
|
||||
}
|
||||
ProcessCommand (event);
|
||||
}
|
||||
|
||||
void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) )
|
||||
{
|
||||
if ( controlpart != kControlNoPart )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId );
|
||||
event.SetEventObject(this);
|
||||
ProcessCommand(event);
|
||||
}
|
||||
}
|
||||
|
||||
7
src/mac/classic/carbrsrc.r
Normal file
7
src/mac/classic/carbrsrc.r
Normal file
@@ -0,0 +1,7 @@
|
||||
// carbon for 9
|
||||
data 'carb' (0) {
|
||||
$"0000" /* .. */
|
||||
};
|
||||
|
||||
// the plist resource should only be included in the application
|
||||
// since it contains the bundle information and should not be duplicated
|
||||
179
src/mac/classic/checkbox.cpp
Normal file
179
src/mac/classic/checkbox.cpp
Normal file
@@ -0,0 +1,179 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: checkbox.cpp
|
||||
// Purpose: wxCheckBox
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "checkbox.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/checkbox.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
|
||||
#endif
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
// Single check box item
|
||||
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) )
|
||||
return false;
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
|
||||
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
SInt16 maxValue = 1 /* kControlCheckboxCheckedValue */;
|
||||
if (style & wxCHK_3STATE)
|
||||
{
|
||||
maxValue = 2 /* kControlCheckboxMixedValue */;
|
||||
}
|
||||
|
||||
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , maxValue,
|
||||
kControlCheckBoxProc , (long) this ) ;
|
||||
|
||||
MacPostControlCreate() ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxCheckBox::SetValue(bool val)
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
Set3StateValue(wxCHK_CHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
Set3StateValue(wxCHK_UNCHECKED);
|
||||
}
|
||||
}
|
||||
|
||||
bool wxCheckBox::GetValue() const
|
||||
{
|
||||
return (DoGet3StateValue() != 0);
|
||||
}
|
||||
|
||||
void wxCheckBox::Command (wxCommandEvent & event)
|
||||
{
|
||||
int state = event.GetInt();
|
||||
|
||||
wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED)
|
||||
|| (state == wxCHK_UNDETERMINED),
|
||||
wxT("event.GetInt() returned an invalid checkbox state") );
|
||||
|
||||
Set3StateValue((wxCheckBoxState) state);
|
||||
|
||||
ProcessCommand(event);
|
||||
}
|
||||
|
||||
wxCheckBoxState wxCheckBox::DoGet3StateValue() const
|
||||
{
|
||||
return (wxCheckBoxState) ::GetControl32BitValue( (ControlHandle) m_macControl );
|
||||
}
|
||||
|
||||
void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
|
||||
{
|
||||
::SetControl32BitValue( (ControlHandle) m_macControl , (int) val) ;
|
||||
MacRedrawControl() ;
|
||||
}
|
||||
|
||||
void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown) )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
|
||||
wxCheckBoxState state = Get3StateValue();
|
||||
|
||||
if (state == wxCHK_UNCHECKED)
|
||||
{
|
||||
state = wxCHK_CHECKED;
|
||||
}
|
||||
else if (state == wxCHK_CHECKED)
|
||||
{
|
||||
// If the style flag to allow the user setting the undetermined state
|
||||
// is set, then set the state to undetermined. Otherwise set state to
|
||||
// unchecked.
|
||||
if ( Is3rdStateAllowedForUser() )
|
||||
{
|
||||
state = wxCHK_UNDETERMINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = wxCHK_UNCHECKED;
|
||||
}
|
||||
}
|
||||
else if (state == wxCHK_UNDETERMINED)
|
||||
{
|
||||
state = wxCHK_UNCHECKED;
|
||||
}
|
||||
Set3StateValue(state);
|
||||
|
||||
event.SetInt(state);
|
||||
event.SetEventObject(this);
|
||||
ProcessCommand(event);
|
||||
}
|
||||
|
||||
// Bitmap checkbox
|
||||
bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxBitmap *label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
m_windowStyle = style;
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
// TODO: Create the bitmap checkbox
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxBitmapCheckBox::SetLabel(const wxBitmap *bitmap)
|
||||
{
|
||||
// TODO
|
||||
wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
|
||||
}
|
||||
|
||||
void wxBitmapCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
wxControl::SetSize( x , y , width , height , sizeFlags ) ;
|
||||
}
|
||||
|
||||
void wxBitmapCheckBox::SetValue(bool val)
|
||||
{
|
||||
// TODO
|
||||
wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
|
||||
}
|
||||
|
||||
bool wxBitmapCheckBox::GetValue() const
|
||||
{
|
||||
// TODO
|
||||
wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
453
src/mac/classic/checklst.cpp
Normal file
453
src/mac/classic/checklst.cpp
Normal file
@@ -0,0 +1,453 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: checklst.cpp
|
||||
// Purpose: implementation of wxCheckListBox class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// headers & declarations
|
||||
// ============================================================================
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "checklst.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_CHECKLISTBOX
|
||||
|
||||
#include "wx/checklst.h"
|
||||
#include "wx/arrstr.h"
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
#include <Appearance.h>
|
||||
|
||||
// ============================================================================
|
||||
// implementation of wxCheckListBox
|
||||
// ============================================================================
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
|
||||
|
||||
const short kwxMacListWithVerticalScrollbar = 128 ;
|
||||
const short kwxMacListItemHeight = 14 ;
|
||||
const short kwxMacListCheckboxWidth = 14 ;
|
||||
|
||||
#if PRAGMA_STRUCT_ALIGN
|
||||
#pragma options align=mac68k
|
||||
#elif PRAGMA_STRUCT_PACKPUSH
|
||||
#pragma pack(push, 2)
|
||||
#elif PRAGMA_STRUCT_PACK
|
||||
#pragma pack(2)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
unsigned short instruction;
|
||||
void (*function)();
|
||||
} ldefRec, *ldefPtr, **ldefHandle;
|
||||
|
||||
#if PRAGMA_STRUCT_ALIGN
|
||||
#pragma options align=reset
|
||||
#elif PRAGMA_STRUCT_PACKPUSH
|
||||
#pragma pack(pop)
|
||||
#elif PRAGMA_STRUCT_PACK
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, Rect *drawRect,
|
||||
Cell cell, short dataOffset, short dataLength,
|
||||
ListHandle listHandle ) ;
|
||||
}
|
||||
|
||||
static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, Rect *drawRect,
|
||||
Cell cell, short dataOffset, short dataLength,
|
||||
ListHandle listHandle )
|
||||
{
|
||||
wxCheckListBox* list;
|
||||
list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
|
||||
if ( list == NULL )
|
||||
return ;
|
||||
|
||||
GrafPtr savePort;
|
||||
GrafPtr grafPtr;
|
||||
RgnHandle savedClipRegion;
|
||||
SInt32 savedPenMode;
|
||||
GetPort(&savePort);
|
||||
SetPort((**listHandle).port);
|
||||
grafPtr = (**listHandle).port ;
|
||||
// typecast our refCon
|
||||
|
||||
// Calculate the cell rect.
|
||||
|
||||
switch( message ) {
|
||||
case lInitMsg:
|
||||
break;
|
||||
|
||||
case lCloseMsg:
|
||||
break;
|
||||
|
||||
case lDrawMsg:
|
||||
{
|
||||
const wxString text = list->m_stringArray[cell.v] ;
|
||||
int checked = list->m_checks[cell.v] ;
|
||||
|
||||
// Save the current clip region, and set the clip region to the area we are about
|
||||
// to draw.
|
||||
|
||||
savedClipRegion = NewRgn();
|
||||
GetClip( savedClipRegion );
|
||||
|
||||
ClipRect( drawRect );
|
||||
EraseRect( drawRect );
|
||||
|
||||
const wxFont& font = list->GetFont();
|
||||
if ( font.Ok() )
|
||||
{
|
||||
::TextFont( font.GetMacFontNum() ) ;
|
||||
::TextSize( font.GetMacFontSize()) ;
|
||||
::TextFace( font.GetMacFontStyle() ) ;
|
||||
}
|
||||
|
||||
ThemeButtonDrawInfo info ;
|
||||
info.state = kThemeStateActive ;
|
||||
info.value = checked ? kThemeButtonOn : kThemeButtonOff ;
|
||||
info.adornment = kThemeAdornmentNone ;
|
||||
Rect checkRect = *drawRect ;
|
||||
|
||||
|
||||
checkRect.left +=0 ;
|
||||
checkRect.top +=0 ;
|
||||
checkRect.right = checkRect.left + list->m_checkBoxWidth ;
|
||||
checkRect.bottom = checkRect.top + list->m_checkBoxHeight ;
|
||||
DrawThemeButton(&checkRect,kThemeCheckBox,
|
||||
&info,NULL,NULL, NULL,0);
|
||||
|
||||
MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset );
|
||||
|
||||
DrawText(text, 0 , text.Length());
|
||||
// If the cell is hilited, do the hilite now. Paint the cell contents with the
|
||||
// appropriate QuickDraw transform mode.
|
||||
|
||||
if( isSelected ) {
|
||||
savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
|
||||
SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode );
|
||||
PaintRect( drawRect );
|
||||
SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode );
|
||||
}
|
||||
|
||||
// Restore the saved clip region.
|
||||
|
||||
SetClip( savedClipRegion );
|
||||
DisposeRgn( savedClipRegion );
|
||||
}
|
||||
break;
|
||||
case lHiliteMsg:
|
||||
|
||||
// Hilite or unhilite the cell. Paint the cell contents with the
|
||||
// appropriate QuickDraw transform mode.
|
||||
|
||||
GetPort( &grafPtr );
|
||||
savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
|
||||
SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode );
|
||||
PaintRect( drawRect );
|
||||
SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode );
|
||||
break;
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
SetPort(savePort);
|
||||
}
|
||||
|
||||
extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
|
||||
|
||||
static ListDefUPP macCheckListDefUPP = NULL ;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxCheckListBox::Init()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxCheckListBox::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
const wxArrayString& choices,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString &name)
|
||||
{
|
||||
wxCArrayString chs(choices);
|
||||
|
||||
return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
|
||||
style, validator, name);
|
||||
}
|
||||
|
||||
bool wxCheckListBox::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
int n,
|
||||
const wxString choices[],
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString &name)
|
||||
{
|
||||
if ( !wxCheckListBoxBase::Create(parent, id, pos, size,
|
||||
n, choices, style, validator, name) )
|
||||
return false;
|
||||
|
||||
m_noItems = 0 ; // this will be increased by our append command
|
||||
m_selected = 0;
|
||||
|
||||
m_checkBoxWidth = 12;
|
||||
m_checkBoxHeight= 10;
|
||||
|
||||
long h = m_checkBoxHeight ;
|
||||
#if TARGET_CARBON
|
||||
GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth);
|
||||
GetThemeMetric(kThemeMetricCheckBoxHeight,&h);
|
||||
#endif
|
||||
|
||||
const wxFont& font = GetFont();
|
||||
|
||||
FontInfo finfo;
|
||||
FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo);
|
||||
|
||||
m_TextBaseLineOffset= finfo.leading+finfo.ascent;
|
||||
m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent;
|
||||
|
||||
if (m_checkBoxHeight<h)
|
||||
{
|
||||
m_TextBaseLineOffset+= (h-m_checkBoxHeight)/2;
|
||||
m_checkBoxHeight= h;
|
||||
}
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
|
||||
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
ListDefSpec listDef;
|
||||
listDef.defType = kListDefUserProcType;
|
||||
if ( macCheckListDefUPP == NULL )
|
||||
{
|
||||
macCheckListDefUPP = NewListDefUPP( wxMacCheckListDefinition );
|
||||
}
|
||||
listDef.u.userProc = macCheckListDefUPP ;
|
||||
|
||||
#if TARGET_CARBON
|
||||
Size asize;
|
||||
|
||||
|
||||
CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true,
|
||||
m_checkBoxHeight+2, 14, false, &listDef, (ControlRef *)&m_macControl );
|
||||
|
||||
GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag,
|
||||
sizeof(ListHandle), (Ptr) &m_macList, &asize);
|
||||
|
||||
SetControlReference( (ControlHandle) m_macControl, (long) this);
|
||||
SetControlVisibility( (ControlHandle) m_macControl, false, false);
|
||||
|
||||
#else
|
||||
|
||||
long result ;
|
||||
|
||||
wxStAppResource resload ;
|
||||
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false ,
|
||||
kwxMacListWithVerticalScrollbar , 0 , 0,
|
||||
kControlListBoxProc , (long) this ) ;
|
||||
::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
|
||||
sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
|
||||
|
||||
HLock( (Handle) m_macList ) ;
|
||||
ldefHandle ldef ;
|
||||
ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ;
|
||||
if ( (**(ListHandle)m_macList).listDefProc != NULL )
|
||||
{
|
||||
(**ldef).instruction = 0x4EF9; /* JMP instruction */
|
||||
(**ldef).function = (void(*)()) listDef.u.userProc;
|
||||
(**(ListHandle)m_macList).listDefProc = (Handle) ldef ;
|
||||
}
|
||||
|
||||
Point pt = (**(ListHandle)m_macList).cellSize ;
|
||||
pt.v = 14 ;
|
||||
LCellSize( pt , (ListHandle)m_macList ) ;
|
||||
LAddColumn( 1 , 0 , (ListHandle)m_macList ) ;
|
||||
#endif
|
||||
OptionBits options = 0;
|
||||
if ( style & wxLB_MULTIPLE )
|
||||
{
|
||||
options += lNoExtend ;
|
||||
}
|
||||
else if ( style & wxLB_EXTENDED )
|
||||
{
|
||||
options += lExtendDrag ;
|
||||
}
|
||||
else
|
||||
{
|
||||
options = (OptionBits) lOnlyOne ;
|
||||
}
|
||||
SetListSelectionFlags((ListHandle)m_macList, options);
|
||||
|
||||
MacPostControlCreate() ;
|
||||
|
||||
for ( int i = 0 ; i < n ; i++ )
|
||||
{
|
||||
Append( choices[i] ) ;
|
||||
}
|
||||
|
||||
LSetDrawingMode( true , (ListHandle) m_macList ) ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxCheckListBox functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxCheckListBox::IsChecked(size_t item) const
|
||||
{
|
||||
wxCHECK_MSG( item < m_checks.GetCount(), FALSE,
|
||||
_T("invalid index in wxCheckListBox::IsChecked") );
|
||||
|
||||
return m_checks[item] != 0;
|
||||
}
|
||||
|
||||
void wxCheckListBox::Check(size_t item, bool check)
|
||||
{
|
||||
wxCHECK_RET( item < m_checks.GetCount(),
|
||||
_T("invalid index in wxCheckListBox::Check") );
|
||||
|
||||
// intermediate var is needed to avoid compiler warning with VC++
|
||||
bool isChecked = m_checks[item] != 0;
|
||||
if ( check != isChecked )
|
||||
{
|
||||
m_checks[item] = check;
|
||||
|
||||
MacRedrawControl() ;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// methods forwarded to wxListBox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxCheckListBox::Delete(int n)
|
||||
{
|
||||
wxCHECK_RET( n < GetCount(), _T("invalid index in wxListBox::Delete") );
|
||||
|
||||
wxListBox::Delete(n);
|
||||
|
||||
m_checks.RemoveAt(n);
|
||||
}
|
||||
|
||||
int wxCheckListBox::DoAppend(const wxString& item)
|
||||
{
|
||||
LSetDrawingMode( false , (ListHandle) m_macList ) ;
|
||||
int pos = wxListBox::DoAppend(item);
|
||||
|
||||
// the item is initially unchecked
|
||||
m_checks.Insert(FALSE, pos);
|
||||
LSetDrawingMode( true , (ListHandle) m_macList ) ;
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void wxCheckListBox::DoInsertItems(const wxArrayString& items, int pos)
|
||||
{
|
||||
wxListBox::DoInsertItems(items, pos);
|
||||
|
||||
size_t count = items.GetCount();
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
m_checks.Insert(FALSE, pos + n);
|
||||
}
|
||||
}
|
||||
|
||||
void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData)
|
||||
{
|
||||
// call it first as it does DoClear()
|
||||
wxListBox::DoSetItems(items, clientData);
|
||||
|
||||
size_t count = items.GetCount();
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
m_checks.Add(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void wxCheckListBox::DoClear()
|
||||
{
|
||||
m_checks.Empty();
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
|
||||
EVT_CHAR(wxCheckListBox::OnChar)
|
||||
EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// this will only work as soon as
|
||||
|
||||
void wxCheckListBox::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
if ( event.GetKeyCode() == WXK_SPACE )
|
||||
{
|
||||
int index = GetSelection() ;
|
||||
if ( index >= 0 )
|
||||
{
|
||||
Check(index, !IsChecked(index) ) ;
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId());
|
||||
event.SetInt(index);
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
}
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
|
||||
{
|
||||
// clicking on the item selects it, clicking on the checkmark toggles
|
||||
if ( event.GetX() <= 20 /*check width*/ ) {
|
||||
int lineheight ;
|
||||
int topcell ;
|
||||
#if TARGET_CARBON
|
||||
Point pt ;
|
||||
GetListCellSize( (ListHandle)m_macList , &pt ) ;
|
||||
lineheight = pt.v ;
|
||||
ListBounds visible ;
|
||||
GetListVisibleCells( (ListHandle)m_macList , &visible ) ;
|
||||
topcell = visible.top ;
|
||||
#else
|
||||
lineheight = (**(ListHandle)m_macList).cellSize.v ;
|
||||
topcell = (**(ListHandle)m_macList).visible.top ;
|
||||
#endif
|
||||
size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ;
|
||||
|
||||
if ( nItem < (size_t)m_noItems )
|
||||
{
|
||||
Check(nItem, !IsChecked(nItem) ) ;
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId());
|
||||
event.SetInt(nItem);
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
//else: it's not an error, just click outside of client zone
|
||||
}
|
||||
else {
|
||||
// implement default behaviour: clicking on the item selects it
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_CHECKLISTBOX
|
||||
300
src/mac/classic/choice.cpp
Normal file
300
src/mac/classic/choice.cpp
Normal file
@@ -0,0 +1,300 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: choice.cpp
|
||||
// Purpose: wxChoice
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "choice.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/choice.h"
|
||||
#include "wx/menu.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
|
||||
#endif
|
||||
|
||||
extern MenuHandle NewUniqueMenu() ;
|
||||
|
||||
wxChoice::~wxChoice()
|
||||
{
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
size_t i, max = GetCount();
|
||||
|
||||
for ( i = 0; i < max; ++i )
|
||||
delete GetClientObject(i);
|
||||
}
|
||||
|
||||
// DeleteMenu( m_macPopUpMenuId ) ;
|
||||
// DisposeMenu( m_macPopUpMenuHandle ) ;
|
||||
}
|
||||
|
||||
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
const wxArrayString& choices,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
wxCArrayString chs(choices);
|
||||
|
||||
return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
|
||||
style, validator, name);
|
||||
}
|
||||
|
||||
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
int n, const wxString choices[],
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) )
|
||||
return false;
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
|
||||
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
|
||||
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 ,
|
||||
kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
|
||||
|
||||
m_macPopUpMenuHandle = NewUniqueMenu() ;
|
||||
SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
|
||||
SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ;
|
||||
SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ;
|
||||
if ( n > 0 )
|
||||
SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ;
|
||||
MacPostControlCreate() ;
|
||||
// TODO wxCB_SORT
|
||||
for ( int i = 0; i < n; i++ )
|
||||
{
|
||||
Append(choices[i]);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// adding/deleting items to/from the list
|
||||
// ----------------------------------------------------------------------------
|
||||
int wxChoice::DoAppend(const wxString& item)
|
||||
{
|
||||
UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item, m_font.GetEncoding() );
|
||||
m_strings.Add( item ) ;
|
||||
m_datas.Add( NULL ) ;
|
||||
int index = m_strings.GetCount() - 1 ;
|
||||
DoSetItemClientData( index , NULL ) ;
|
||||
SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ;
|
||||
return index ;
|
||||
}
|
||||
|
||||
int wxChoice::DoInsert(const wxString& item, int pos)
|
||||
{
|
||||
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
|
||||
wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
|
||||
|
||||
if (pos == GetCount())
|
||||
return DoAppend(item);
|
||||
|
||||
UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item, m_font.GetEncoding() );
|
||||
m_strings.Insert( item, pos ) ;
|
||||
m_datas.Insert( NULL, pos ) ;
|
||||
DoSetItemClientData( pos , NULL ) ;
|
||||
SetControl32BitMaximum( (ControlHandle) m_macControl , pos) ;
|
||||
return pos ;
|
||||
}
|
||||
|
||||
void wxChoice::Delete(int n)
|
||||
{
|
||||
wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
delete GetClientObject(n);
|
||||
}
|
||||
::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ;
|
||||
m_strings.RemoveAt( n ) ;
|
||||
m_datas.RemoveAt( n ) ;
|
||||
SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ;
|
||||
}
|
||||
|
||||
void wxChoice::Clear()
|
||||
{
|
||||
FreeData();
|
||||
for ( int i = 0 ; i < GetCount() ; i++ )
|
||||
{
|
||||
::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , 1 ) ;
|
||||
}
|
||||
m_strings.Empty() ;
|
||||
m_datas.Empty() ;
|
||||
SetControl32BitMaximum( (ControlHandle) m_macControl , 0 ) ;
|
||||
}
|
||||
|
||||
void wxChoice::FreeData()
|
||||
{
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
size_t count = GetCount();
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
delete GetClientObject(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// selection
|
||||
// ----------------------------------------------------------------------------
|
||||
int wxChoice::GetSelection() const
|
||||
{
|
||||
return GetControl32BitValue( (ControlHandle) m_macControl ) -1 ;
|
||||
}
|
||||
|
||||
void wxChoice::SetSelection(int n)
|
||||
{
|
||||
SetControl32BitValue( (ControlHandle) m_macControl , n + 1 ) ;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string list functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxChoice::GetCount() const
|
||||
{
|
||||
return m_strings.GetCount() ;
|
||||
}
|
||||
|
||||
int wxChoice::FindString(const wxString& s) const
|
||||
{
|
||||
for( int i = 0 ; i < GetCount() ; i++ )
|
||||
{
|
||||
if ( GetString( i ).IsSameAs(s, FALSE) )
|
||||
return i ;
|
||||
}
|
||||
return wxNOT_FOUND ;
|
||||
}
|
||||
|
||||
void wxChoice::SetString(int n, const wxString& s)
|
||||
{
|
||||
wxFAIL_MSG(wxT("wxChoice::SetString() not yet implemented"));
|
||||
#if 0 // should do this, but no Insert() so far
|
||||
Delete(n);
|
||||
Insert(n + 1, s);
|
||||
#endif
|
||||
}
|
||||
|
||||
wxString wxChoice::GetString(int n) const
|
||||
{
|
||||
wxCHECK_MSG( n >= 0 && (size_t)n < m_strings.GetCount(), _T(""),
|
||||
_T("wxChoice::GetString(): invalid index") );
|
||||
|
||||
return m_strings[n] ;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// client data
|
||||
// ----------------------------------------------------------------------------
|
||||
void wxChoice::DoSetItemClientData( int n, void* clientData )
|
||||
{
|
||||
wxCHECK_RET( n >= 0 && (size_t)n < m_datas.GetCount(),
|
||||
wxT("invalid index in wxChoice::SetClientData") );
|
||||
|
||||
m_datas[n] = (char*) clientData ;
|
||||
}
|
||||
|
||||
void *wxChoice::DoGetItemClientData(int n) const
|
||||
{
|
||||
wxCHECK_MSG( n >= 0 && (size_t)n < m_datas.GetCount(), NULL,
|
||||
wxT("invalid index in wxChoice::GetClientData") );
|
||||
return (void *)m_datas[n];
|
||||
}
|
||||
|
||||
void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData )
|
||||
{
|
||||
DoSetItemClientData(n, clientData);
|
||||
}
|
||||
|
||||
wxClientData* wxChoice::DoGetItemClientObject( int n ) const
|
||||
{
|
||||
return (wxClientData *)DoGetItemClientData(n);
|
||||
}
|
||||
|
||||
void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
||||
int n = GetSelection();
|
||||
// actually n should be made sure by the os to be a valid selection, but ...
|
||||
if ( n > -1 )
|
||||
{
|
||||
event.SetInt( n );
|
||||
event.SetString(GetStringSelection());
|
||||
event.SetEventObject(this);
|
||||
if ( HasClientObjectData() )
|
||||
event.SetClientObject( GetClientObject(n) );
|
||||
else if ( HasClientUntypedData() )
|
||||
event.SetClientData( GetClientData(n) );
|
||||
ProcessCommand(event);
|
||||
}
|
||||
}
|
||||
|
||||
wxSize wxChoice::DoGetBestSize() const
|
||||
{
|
||||
int lbWidth = GetCount() > 0 ? 20 : 100; // some defaults
|
||||
int lbHeight = 20;
|
||||
int wLine;
|
||||
#if TARGET_CARBON
|
||||
long metric ;
|
||||
GetThemeMetric(kThemeMetricPopupButtonHeight , &metric );
|
||||
lbHeight = metric ;
|
||||
#endif
|
||||
{
|
||||
wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;
|
||||
if ( m_font.Ok() )
|
||||
{
|
||||
::TextFont( m_font.GetMacFontNum() ) ;
|
||||
::TextSize( m_font.GetMacFontSize() ) ;
|
||||
::TextFace( m_font.GetMacFontStyle() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
::TextFont( kFontIDMonaco ) ;
|
||||
::TextSize( 9 );
|
||||
::TextFace( 0 ) ;
|
||||
}
|
||||
// Find the widest line
|
||||
for(int i = 0; i < GetCount(); i++) {
|
||||
wxString str(GetString(i));
|
||||
#if wxUSE_UNICODE
|
||||
Point bounds={0,0} ;
|
||||
SInt16 baseline ;
|
||||
::GetThemeTextDimensions( wxMacCFStringHolder( str , m_font.GetEncoding() ) ,
|
||||
kThemeCurrentPortFont,
|
||||
kThemeStateActive,
|
||||
false,
|
||||
&bounds,
|
||||
&baseline );
|
||||
wLine = bounds.h ;
|
||||
#else
|
||||
wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
|
||||
#endif
|
||||
lbWidth = wxMax(lbWidth, wLine);
|
||||
}
|
||||
// Add room for the popup arrow
|
||||
lbWidth += 2 * lbHeight ;
|
||||
// And just a bit more
|
||||
int cx = ::TextWidth( "X" , 0 , 1 ) ;
|
||||
lbWidth += cx ;
|
||||
|
||||
}
|
||||
return wxSize(lbWidth, lbHeight);
|
||||
}
|
||||
406
src/mac/classic/clipbrd.cpp
Normal file
406
src/mac/classic/clipbrd.cpp
Normal file
@@ -0,0 +1,406 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: clipbrd.cpp
|
||||
// Purpose: Clipboard functionality
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "clipbrd.h"
|
||||
#endif
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/metafile.h"
|
||||
#include "wx/clipbrd.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#ifndef __DARWIN__
|
||||
#include <Scrap.h>
|
||||
#endif
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#define wxUSE_DATAOBJ 1
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// the trace mask we use with wxLogTrace() - call
|
||||
// wxLog::AddTraceMask(TRACE_CLIPBOARD) to enable the trace messages from here
|
||||
// (there will be a *lot* of them!)
|
||||
static const wxChar *TRACE_CLIPBOARD = _T("clipboard");
|
||||
|
||||
void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
OSErr err = noErr ;
|
||||
#else
|
||||
OSStatus err = noErr ;
|
||||
#endif
|
||||
void * data = NULL ;
|
||||
Size byteCount;
|
||||
|
||||
switch (dataFormat.GetType())
|
||||
{
|
||||
case wxDF_OEMTEXT:
|
||||
dataFormat = wxDF_TEXT;
|
||||
// fall through
|
||||
|
||||
case wxDF_TEXT:
|
||||
break;
|
||||
case wxDF_UNICODETEXT:
|
||||
break;
|
||||
case wxDF_BITMAP :
|
||||
case wxDF_METAFILE :
|
||||
break ;
|
||||
default:
|
||||
{
|
||||
wxLogError(_("Unsupported clipboard format."));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_CARBON
|
||||
ScrapRef scrapRef;
|
||||
|
||||
err = GetCurrentScrap( &scrapRef );
|
||||
if ( err != noTypeErr && err != memFullErr )
|
||||
{
|
||||
ScrapFlavorFlags flavorFlags;
|
||||
|
||||
if (( err = GetScrapFlavorFlags( scrapRef, dataFormat.GetFormatId(), &flavorFlags )) == noErr)
|
||||
{
|
||||
if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr)
|
||||
{
|
||||
Size allocSize = byteCount ;
|
||||
if ( dataFormat.GetType() == wxDF_TEXT )
|
||||
allocSize += 1 ;
|
||||
else if ( dataFormat.GetType() == wxDF_UNICODETEXT )
|
||||
allocSize += 2 ;
|
||||
|
||||
data = new char[ allocSize ] ;
|
||||
|
||||
if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr )
|
||||
{
|
||||
*len = allocSize ;
|
||||
if ( dataFormat.GetType() == wxDF_TEXT )
|
||||
((char*)data)[byteCount] = 0 ;
|
||||
if ( dataFormat.GetType() == wxDF_UNICODETEXT )
|
||||
((wxChar*)data)[byteCount/2] = 0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete[] ((char *)data) ;
|
||||
data = NULL ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
long offset ;
|
||||
Handle datahandle = NewHandle(0) ;
|
||||
HLock( datahandle ) ;
|
||||
GetScrap( datahandle , dataFormat.GetFormatId() , &offset ) ;
|
||||
HUnlock( datahandle ) ;
|
||||
if ( GetHandleSize( datahandle ) > 0 )
|
||||
{
|
||||
byteCount = GetHandleSize( datahandle ) ;
|
||||
Size allocSize = byteCount ;
|
||||
if ( dataFormat.GetType() == wxDF_TEXT )
|
||||
allocSize += 1 ;
|
||||
else if ( dataFormat.GetType() == wxDF_UNICODETEXT )
|
||||
allocSize += 2 ;
|
||||
|
||||
data = new char[ allocSize ] ;
|
||||
|
||||
memcpy( (char*) data , (char*) *datahandle , byteCount ) ;
|
||||
if ( dataFormat.GetType() == wxDF_TEXT )
|
||||
((char*)data)[byteCount] = 0 ;
|
||||
if ( dataFormat.GetType() == wxDF_UNICODETEXT )
|
||||
((wxChar*)data)[byteCount/2] = 0 ;
|
||||
*len = byteCount ;
|
||||
}
|
||||
DisposeHandle( datahandle ) ;
|
||||
#endif
|
||||
if ( err )
|
||||
{
|
||||
wxLogSysError(_("Failed to get clipboard data."));
|
||||
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
if ( dataFormat.GetType() == wxDF_TEXT )
|
||||
{
|
||||
wxMacConvertNewlines10To13( (char*) data ) ;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Generalized clipboard implementation by Matthew Flatt
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
||||
|
||||
wxClipboard::wxClipboard()
|
||||
{
|
||||
m_open = false ;
|
||||
m_data = NULL ;
|
||||
}
|
||||
|
||||
wxClipboard::~wxClipboard()
|
||||
{
|
||||
if (m_data)
|
||||
{
|
||||
delete m_data;
|
||||
m_data = (wxDataObject*) NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void wxClipboard::Clear()
|
||||
{
|
||||
if (m_data)
|
||||
{
|
||||
delete m_data;
|
||||
m_data = (wxDataObject*) NULL;
|
||||
}
|
||||
#if TARGET_CARBON
|
||||
OSStatus err ;
|
||||
err = ClearCurrentScrap( );
|
||||
#else
|
||||
OSErr err ;
|
||||
err = ZeroScrap( );
|
||||
#endif
|
||||
if ( err )
|
||||
{
|
||||
wxLogSysError(_("Failed to empty the clipboard."));
|
||||
}
|
||||
}
|
||||
|
||||
bool wxClipboard::Flush()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxClipboard::Open()
|
||||
{
|
||||
wxCHECK_MSG( !m_open, FALSE, wxT("clipboard already open") );
|
||||
m_open = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool wxClipboard::IsOpened() const
|
||||
{
|
||||
return m_open;
|
||||
}
|
||||
|
||||
bool wxClipboard::SetData( wxDataObject *data )
|
||||
{
|
||||
wxCHECK_MSG( m_open, FALSE, wxT("clipboard not open") );
|
||||
|
||||
wxCHECK_MSG( data, FALSE, wxT("data is invalid") );
|
||||
|
||||
Clear();
|
||||
// as we can only store one wxDataObject, this is the same in this
|
||||
// implementation
|
||||
return AddData( data );
|
||||
}
|
||||
|
||||
bool wxClipboard::AddData( wxDataObject *data )
|
||||
{
|
||||
wxCHECK_MSG( m_open, FALSE, wxT("clipboard not open") );
|
||||
|
||||
wxCHECK_MSG( data, FALSE, wxT("data is invalid") );
|
||||
|
||||
/* we can only store one wxDataObject */
|
||||
Clear();
|
||||
|
||||
m_data = data;
|
||||
|
||||
/* get formats from wxDataObjects */
|
||||
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
|
||||
m_data->GetAllFormats( array );
|
||||
|
||||
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
||||
{
|
||||
wxLogTrace( TRACE_CLIPBOARD,
|
||||
wxT("wxClipboard now supports atom %s"),
|
||||
array[i].GetId().c_str() );
|
||||
|
||||
#if !TARGET_CARBON
|
||||
OSErr err = noErr ;
|
||||
#else
|
||||
OSStatus err = noErr ;
|
||||
#endif
|
||||
size_t sz = data->GetDataSize( array[i] ) ;
|
||||
void* buf = malloc( sz + 1 ) ;
|
||||
if ( buf )
|
||||
{
|
||||
data->GetDataHere( array[i] , buf ) ;
|
||||
OSType mactype = 0 ;
|
||||
switch ( array[i].GetType() )
|
||||
{
|
||||
case wxDF_TEXT:
|
||||
case wxDF_OEMTEXT:
|
||||
mactype = kScrapFlavorTypeText ;
|
||||
break ;
|
||||
#if wxUSE_UNICODE
|
||||
case wxDF_UNICODETEXT :
|
||||
mactype = kScrapFlavorTypeUnicode ;
|
||||
break ;
|
||||
#endif
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
case wxDF_METAFILE:
|
||||
mactype = kScrapFlavorTypePicture ;
|
||||
break ;
|
||||
#endif
|
||||
case wxDF_BITMAP:
|
||||
case wxDF_DIB:
|
||||
mactype = kScrapFlavorTypePicture ;
|
||||
break ;
|
||||
default:
|
||||
break ;
|
||||
}
|
||||
UMAPutScrap( sz , mactype , buf ) ;
|
||||
free( buf ) ;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] array;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void wxClipboard::Close()
|
||||
{
|
||||
wxCHECK_RET( m_open, wxT("clipboard not open") );
|
||||
|
||||
m_open = false ;
|
||||
|
||||
// Get rid of cached object. If this is not done copying from another application will
|
||||
// only work once
|
||||
if (m_data)
|
||||
{
|
||||
delete m_data;
|
||||
m_data = (wxDataObject*) NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool wxClipboard::IsSupported( const wxDataFormat &dataFormat )
|
||||
{
|
||||
if ( m_data )
|
||||
{
|
||||
return m_data->IsSupported( dataFormat ) ;
|
||||
}
|
||||
#if TARGET_CARBON
|
||||
OSStatus err = noErr;
|
||||
ScrapRef scrapRef;
|
||||
|
||||
err = GetCurrentScrap( &scrapRef );
|
||||
if ( err != noTypeErr && err != memFullErr )
|
||||
{
|
||||
ScrapFlavorFlags flavorFlags;
|
||||
Size byteCount;
|
||||
|
||||
if (( err = GetScrapFlavorFlags( scrapRef, dataFormat.GetFormatId(), &flavorFlags )) == noErr)
|
||||
{
|
||||
if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr)
|
||||
{
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
#else
|
||||
long offset ;
|
||||
Handle datahandle = NewHandle(0) ;
|
||||
HLock( datahandle ) ;
|
||||
GetScrap( datahandle , dataFormat.GetFormatId() , &offset ) ;
|
||||
HUnlock( datahandle ) ;
|
||||
bool hasData = GetHandleSize( datahandle ) > 0 ;
|
||||
DisposeHandle( datahandle ) ;
|
||||
return hasData ;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxClipboard::GetData( wxDataObject& data )
|
||||
{
|
||||
wxCHECK_MSG( m_open, FALSE, wxT("clipboard not open") );
|
||||
|
||||
size_t formatcount = data.GetFormatCount() + 1 ;
|
||||
wxDataFormat *array = new wxDataFormat[ formatcount ];
|
||||
array[0] = data.GetPreferredFormat();
|
||||
data.GetAllFormats( &array[1] );
|
||||
|
||||
bool transferred = false ;
|
||||
|
||||
if ( m_data )
|
||||
{
|
||||
for (size_t i = 0; !transferred && i < formatcount ; i++)
|
||||
{
|
||||
wxDataFormat format = array[i] ;
|
||||
if ( m_data->IsSupported( format ) )
|
||||
{
|
||||
int size = m_data->GetDataSize( format );
|
||||
transferred = true ;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
data.SetData(format , 0 , 0 ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *d = new char[size];
|
||||
m_data->GetDataHere( format , (void*) d );
|
||||
data.SetData( format , size , d ) ;
|
||||
delete[] d ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* get formats from wxDataObjects */
|
||||
if ( !transferred )
|
||||
{
|
||||
for (size_t i = 0; !transferred && i < formatcount ; i++)
|
||||
{
|
||||
wxDataFormat format = array[i] ;
|
||||
|
||||
switch ( format.GetType() )
|
||||
{
|
||||
case wxDF_TEXT :
|
||||
case wxDF_OEMTEXT :
|
||||
case wxDF_BITMAP :
|
||||
case wxDF_METAFILE :
|
||||
{
|
||||
long len ;
|
||||
char* s = (char*)wxGetClipboardData(format, &len );
|
||||
if ( s )
|
||||
{
|
||||
data.SetData( format , len , s ) ;
|
||||
delete [] s;
|
||||
|
||||
transferred = true ;
|
||||
}
|
||||
}
|
||||
break ;
|
||||
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete[] array ;
|
||||
return transferred ;
|
||||
}
|
||||
70
src/mac/classic/colordlg.cpp
Normal file
70
src/mac/classic/colordlg.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: colordlg.cpp
|
||||
// Purpose: wxColourDialog class. NOTE: you can use the generic class
|
||||
// if you wish, instead of implementing this.
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "colordlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/mac/colordlg.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
#ifndef __DARWIN__
|
||||
#include <ColorPicker.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxColourDialog
|
||||
*/
|
||||
|
||||
wxColourDialog::wxColourDialog()
|
||||
{
|
||||
m_dialogParent = NULL;
|
||||
}
|
||||
|
||||
wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
|
||||
{
|
||||
Create(parent, data);
|
||||
}
|
||||
|
||||
bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
|
||||
{
|
||||
m_dialogParent = parent;
|
||||
|
||||
if (data)
|
||||
m_colourData = *data;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int wxColourDialog::ShowModal()
|
||||
{
|
||||
Point where ;
|
||||
RGBColor currentColor = *((RGBColor*)m_colourData.m_dataColour.GetPixel()) , newColor ;
|
||||
|
||||
where.h = where.v = -1;
|
||||
|
||||
if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor ))
|
||||
{
|
||||
m_colourData.m_dataColour.Set( (WXCOLORREF*) &newColor ) ;
|
||||
return wxID_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxID_CANCEL;
|
||||
}
|
||||
|
||||
return wxID_CANCEL;
|
||||
}
|
||||
|
||||
116
src/mac/classic/colour.cpp
Normal file
116
src/mac/classic/colour.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: colour.cpp
|
||||
// Purpose: wxColour class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "colour.h"
|
||||
#endif
|
||||
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/colour.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
|
||||
#endif
|
||||
|
||||
// Colour
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
|
||||
static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
|
||||
{
|
||||
RGBColor* col = (RGBColor*) color ;
|
||||
col->red = (red << 8) + red;
|
||||
col->blue = (blue << 8) + blue;
|
||||
col->green = (green << 8) + green;
|
||||
}
|
||||
|
||||
void wxColour::Init()
|
||||
{
|
||||
m_isInit = false;
|
||||
m_red =
|
||||
m_blue =
|
||||
m_green = 0;
|
||||
|
||||
wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
|
||||
}
|
||||
|
||||
wxColour::wxColour (const wxColour& col)
|
||||
: wxObject()
|
||||
{
|
||||
m_red = col.m_red;
|
||||
m_green = col.m_green;
|
||||
m_blue = col.m_blue;
|
||||
m_isInit = col.m_isInit;
|
||||
|
||||
memcpy( &m_pixel , &col.m_pixel , 6 ) ;
|
||||
}
|
||||
|
||||
wxColour::wxColour (const wxColour* col)
|
||||
{
|
||||
m_red = col->m_red;
|
||||
m_green = col->m_green;
|
||||
m_blue = col->m_blue;
|
||||
m_isInit = col->m_isInit;
|
||||
|
||||
memcpy( &m_pixel , &col->m_pixel , 6 ) ;
|
||||
}
|
||||
|
||||
wxColour& wxColour::operator =(const wxColour& col)
|
||||
{
|
||||
m_red = col.m_red;
|
||||
m_green = col.m_green;
|
||||
m_blue = col.m_blue;
|
||||
m_isInit = col.m_isInit;
|
||||
|
||||
memcpy( &m_pixel , &col.m_pixel , 6 ) ;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void wxColour::InitFromName(const wxString& name)
|
||||
{
|
||||
if ( wxTheColourDatabase )
|
||||
{
|
||||
wxColour col = wxTheColourDatabase->Find(name);
|
||||
if ( col.Ok() )
|
||||
{
|
||||
*this = col;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// leave invalid
|
||||
Init();
|
||||
}
|
||||
|
||||
wxColour::~wxColour ()
|
||||
{
|
||||
}
|
||||
|
||||
void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
m_red = r;
|
||||
m_green = g;
|
||||
m_blue = b;
|
||||
m_isInit = true;
|
||||
|
||||
wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
|
||||
}
|
||||
|
||||
void wxColour::Set( const WXCOLORREF* color )
|
||||
{
|
||||
RGBColor* col = (RGBColor*) color ;
|
||||
memcpy( &m_pixel , color , 6 ) ;
|
||||
m_red = col->red>>8 ;
|
||||
m_blue = col->blue>>8 ;
|
||||
m_green = col->green>>8 ;
|
||||
}
|
||||
540
src/mac/classic/combobox.cpp
Normal file
540
src/mac/classic/combobox.cpp
Normal file
File diff suppressed because it is too large
Load Diff
814
src/mac/classic/control.cpp
Normal file
814
src/mac/classic/control.cpp
Normal file
File diff suppressed because it is too large
Load Diff
159
src/mac/classic/corersrc.r
Normal file
159
src/mac/classic/corersrc.r
Normal file
@@ -0,0 +1,159 @@
|
||||
#ifdef __UNIX__
|
||||
#include <Carbon.r>
|
||||
#else
|
||||
#include <Types.r>
|
||||
#if UNIVERSAL_INTERFACES_VERSION > 0x320
|
||||
#include <ControlDefinitions.r>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
resource 'ldes' ( 128 )
|
||||
{
|
||||
versionZero
|
||||
{
|
||||
0 ,
|
||||
0 ,
|
||||
0 ,
|
||||
0 ,
|
||||
hasVertScroll ,
|
||||
noHorizScroll ,
|
||||
0 ,
|
||||
noGrowSpace ,
|
||||
}
|
||||
} ;
|
||||
|
||||
resource 'ldes' ( 129 )
|
||||
{
|
||||
versionZero
|
||||
{
|
||||
0 ,
|
||||
0 ,
|
||||
0 ,
|
||||
0 ,
|
||||
hasVertScroll ,
|
||||
hasHorizScroll ,
|
||||
0 ,
|
||||
noGrowSpace ,
|
||||
}
|
||||
} ;
|
||||
|
||||
data 'CURS' (10) {
|
||||
$"0000 03E0 0630 0808 1004 31C6 2362 2222"
|
||||
$"2362 31C6 1004 0808 0630 03E0 0000 0000"
|
||||
$"0000 03E0 07F0 0FF8 1FFC 3FFE 3FFE 3FFE"
|
||||
$"3FFE 3FFE 1FFC 0FF8 07F0 03E0 0000 0000"
|
||||
$"0007 0008"
|
||||
};
|
||||
|
||||
data 'CURS' (11) {
|
||||
$"0000 0000 0000 0000 0000 0000 0000 0000"
|
||||
$"0000 0000 0000 0000 0000 0000 0000 0000"
|
||||
$"0000 0000 0000 0000 0000 0000 0000 0000"
|
||||
$"0000 0000 0000 0000 0000 0000 0000 0000"
|
||||
$"0000 0000"
|
||||
};
|
||||
|
||||
data 'CURS' (12) {
|
||||
$"00F0 0088 0108 0190 0270 0220 0440 0440"
|
||||
$"0880 0880 1100 1E00 1C00 1800 1000 0000"
|
||||
$"00F0 00F8 01F8 01F0 03F0 03E0 07C0 07C0"
|
||||
$"0F80 0F80 1F00 1E00 1C00 1800 1000 0000"
|
||||
$"000E 0003"
|
||||
};
|
||||
|
||||
data 'CURS' (13) {
|
||||
$"0000 1E00 2100 4080 4080 4080 4080 2180"
|
||||
$"1FC0 00E0 0070 0038 001C 000E 0006 0000"
|
||||
$"3F00 7F80 FFC0 FFC0 FFC0 FFC0 FFC0 7FC0"
|
||||
$"3FE0 1FF0 00F8 007C 003E 001F 000F 0007"
|
||||
$"0004 0004"
|
||||
};
|
||||
|
||||
data 'CURS' (14) {
|
||||
$"0000 07E0 1FF0 3838 3C0C 6E0E 6706 6386"
|
||||
$"61C6 60E6 7076 303C 1C1C 0FF8 07E0 0000"
|
||||
$"0540 0FF0 3FF8 3C3C 7E0E FF0F 6F86 E7C7"
|
||||
$"63E6 E1F7 70FE 707E 3C3C 1FFC 0FF0 0540"
|
||||
$"0007 0007"
|
||||
};
|
||||
|
||||
data 'CURS' (15) {
|
||||
$"0000 0380 0380 0380 0380 0380 0380 0FE0"
|
||||
$"1FF0 1FF0 0000 1FF0 1FF0 1550 1550 1550"
|
||||
$"07C0 07C0 07C0 07C0 07C0 07C0 0FE0 1FF0"
|
||||
$"3FF8 3FF8 3FF8 3FF8 3FF8 3FF8 3FF8 3FF8"
|
||||
$"000B 0007"
|
||||
};
|
||||
|
||||
data 'CURS' (16) {
|
||||
$"00C0 0140 0640 08C0 3180 47FE 8001 8001"
|
||||
$"81FE 8040 01C0 0040 03C0 C080 3F80 0000"
|
||||
$"00C0 01C0 07C0 0FC0 3F80 7FFE FFFF FFFF"
|
||||
$"FFFE FFC0 FFC0 FFC0 FFC0 FF80 3F80 0000"
|
||||
$"0006 000F"
|
||||
};
|
||||
|
||||
data 'CURS' (17) {
|
||||
$"0100 0280 0260 0310 018C 7FE3 8000 8000"
|
||||
$"7F80 0200 0380 0200 03C0 0107 01F8 0000"
|
||||
$"0100 0380 03E0 03F0 01FC 7FFF FFFF FFFF"
|
||||
$"FFFF 03FF 03FF 03FF 03FF 01FF 01F8 0000"
|
||||
$"0006 0000"
|
||||
};
|
||||
|
||||
data 'CURS' (18) {
|
||||
$"0000 4078 60FC 71CE 7986 7C06 7E0E 7F1C"
|
||||
$"7FB8 7C30 6C30 4600 0630 0330 0300 0000"
|
||||
$"C078 E0FC F1FE FBFF FFCF FF8F FF1F FFBE"
|
||||
$"FFFC FE78 FF78 EFF8 CFF8 87F8 07F8 0300"
|
||||
$"0001 0001"
|
||||
};
|
||||
|
||||
data 'CURS' (19) {
|
||||
$"0000 0002 0006 000E 001E 003E 007E 00FE"
|
||||
$"01FE 003E 0036 0062 0060 00C0 00C0 0000"
|
||||
$"0003 0007 000F 001F 003F 007F 00FF 01FF"
|
||||
$"03FF 07FF 007F 00F7 00F3 01E1 01E0 01C0"
|
||||
$"0001 000E"
|
||||
};
|
||||
|
||||
data 'CURS' (20) {
|
||||
$"0000 0080 01C0 03E0 0080 0080 0080 1FFC"
|
||||
$"1FFC 0080 0080 0080 03E0 01C0 0080 0000"
|
||||
$"0080 01C0 03E0 07F0 0FF8 01C0 3FFE 3FFE"
|
||||
$"3FFE 3FFE 01C0 0FF8 07F0 03E0 01C0 0080"
|
||||
$"0007 0008"
|
||||
};
|
||||
|
||||
data 'CURS' (21) {
|
||||
$"0000 0080 01C0 03E0 0080 0888 188C 3FFE"
|
||||
$"188C 0888 0080 03E0 01C0 0080 0000 0000"
|
||||
$"0080 01C0 03E0 07F0 0BE8 1DDC 3FFE 7FFF"
|
||||
$"3FFE 1DDC 0BE8 07F0 03E0 01C0 0080 0000"
|
||||
$"0007 0008"
|
||||
};
|
||||
|
||||
data 'CURS' (22) {
|
||||
$"0000 001E 000E 060E 0712 03A0 01C0 00E0"
|
||||
$"0170 1238 1C18 1C00 1E00 0000 0000 0000"
|
||||
$"007F 003F 0E1F 0F0F 0F97 07E3 03E1 21F0"
|
||||
$"31F8 3A7C 3C3C 3E1C 3F00 3F80 0000 0000"
|
||||
$"0006 0009"
|
||||
};
|
||||
|
||||
data 'CURS' (23) {
|
||||
$"0000 7800 7000 7060 48E0 05C0 0380 0700"
|
||||
$"0E80 1C48 1838 0038 0078 0000 0000 0000"
|
||||
$"FE00 FC00 F870 F0F0 E9F0 C7E0 87C0 0F84"
|
||||
$"1F8C 3E5C 3C3C 387C 00FC 01FC 0000 0000"
|
||||
$"0006 0006"
|
||||
};
|
||||
|
||||
data 'CURS' (24) {
|
||||
$"0006 000E 001C 0018 0020 0040 00F8 0004"
|
||||
$"1FF4 200C 2AA8 1FF0 1F80 3800 6000 8000"
|
||||
$"000F 001F 003E 007C 0070 00E0 01FC 3FF6"
|
||||
$"7FF6 7FFE 7FFC 7FF8 3FF0 7FC0 F800 E000"
|
||||
$"000A 0006"
|
||||
};
|
||||
|
||||
505
src/mac/classic/cursor.cpp
Normal file
505
src/mac/classic/cursor.cpp
Normal file
File diff suppressed because it is too large
Load Diff
25
src/mac/classic/data.cpp
Normal file
25
src/mac/classic/data.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mac/data.cpp
|
||||
// Purpose: Various global Mac-specific data
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/event.h"
|
||||
|
||||
#if wxUSE_SHARED_LIBRARY
|
||||
///// Event tables (also must be in one, statically-linked file for shared libraries)
|
||||
|
||||
// This is the base, wxEvtHandler 'bootstrap' code which is expanded manually here
|
||||
const wxEventTable *wxEvtHandler::GetEventTable() const { return &wxEvtHandler::sm_eventTable; }
|
||||
|
||||
const wxEventTable wxEvtHandler::sm_eventTable =
|
||||
{ NULL, &wxEvtHandler::sm_eventTableEntries[0] };
|
||||
|
||||
const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = { { 0, 0, 0, NULL } };
|
||||
#endif
|
||||
|
||||
308
src/mac/classic/dataobj.cpp
Normal file
308
src/mac/classic/dataobj.cpp
Normal file
@@ -0,0 +1,308 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mac/dataobj.cpp
|
||||
// Purpose: implementation of wxDataObject class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 10/21/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1999 Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dataobj.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/intl.h"
|
||||
#endif
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/log.h"
|
||||
#include "wx/dataobj.h"
|
||||
#include "wx/mstream.h"
|
||||
#include "wx/image.h"
|
||||
#include "wx/mac/private.h"
|
||||
#include <Scrap.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDataFormat
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxDataFormat::wxDataFormat()
|
||||
{
|
||||
m_type = wxDF_INVALID;
|
||||
m_format = 0;
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( wxDataFormatId vType )
|
||||
{
|
||||
SetType(vType);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( const wxChar* zId)
|
||||
{
|
||||
SetId(zId);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( const wxString& rId)
|
||||
{
|
||||
SetId(rId);
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( NativeFormat vFormat)
|
||||
{
|
||||
SetId(vFormat);
|
||||
}
|
||||
|
||||
void wxDataFormat::SetType( wxDataFormatId Type )
|
||||
{
|
||||
m_type = Type;
|
||||
|
||||
if (m_type == wxDF_TEXT )
|
||||
m_format = kScrapFlavorTypeText;
|
||||
else if (m_type == wxDF_UNICODETEXT )
|
||||
m_format = kScrapFlavorTypeUnicode ;
|
||||
else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE )
|
||||
m_format = kScrapFlavorTypePicture;
|
||||
else if (m_type == wxDF_FILENAME)
|
||||
m_format = kDragFlavorTypeHFS ;
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( wxT("invalid dataformat") );
|
||||
|
||||
// this is '????' but it can't be used in the code because ??' is
|
||||
// parsed as a trigraph!
|
||||
m_format = 0x3f3f3f3f;
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxDataFormat::GetId() const
|
||||
{
|
||||
// note that m_format is not a pointer to string, it *is* itself a 4
|
||||
// character string
|
||||
char text[5] ;
|
||||
strncpy( text , (char*) &m_format , 4 ) ;
|
||||
text[4] = 0 ;
|
||||
|
||||
return wxString::FromAscii( text ) ;
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId( NativeFormat format )
|
||||
{
|
||||
m_format = format;
|
||||
|
||||
if (m_format == kScrapFlavorTypeText)
|
||||
m_type = wxDF_TEXT;
|
||||
else if (m_format == kScrapFlavorTypeUnicode )
|
||||
m_type = wxDF_UNICODETEXT;
|
||||
else if (m_format == kScrapFlavorTypePicture)
|
||||
m_type = wxDF_BITMAP;
|
||||
else if (m_format == kDragFlavorTypeHFS )
|
||||
m_type = wxDF_FILENAME;
|
||||
else
|
||||
m_type = wxDF_PRIVATE;
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId( const wxChar* zId )
|
||||
{
|
||||
m_type = wxDF_PRIVATE;
|
||||
m_format = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// wxDataObject
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
wxDataObject::wxDataObject()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxDataObject::IsSupportedFormat(
|
||||
const wxDataFormat& rFormat
|
||||
, Direction vDir
|
||||
) const
|
||||
{
|
||||
size_t nFormatCount = GetFormatCount(vDir);
|
||||
|
||||
if (nFormatCount == 1)
|
||||
{
|
||||
return rFormat == GetPreferredFormat();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxDataFormat* pFormats = new wxDataFormat[nFormatCount];
|
||||
GetAllFormats( pFormats
|
||||
,vDir
|
||||
);
|
||||
|
||||
size_t n;
|
||||
|
||||
for (n = 0; n < nFormatCount; n++)
|
||||
{
|
||||
if (pFormats[n] == rFormat)
|
||||
break;
|
||||
}
|
||||
|
||||
delete [] pFormats;
|
||||
|
||||
// found?
|
||||
return n < nFormatCount;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFileDataObject
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxFileDataObject::GetDataHere(
|
||||
void* pBuf
|
||||
) const
|
||||
{
|
||||
wxString sFilenames;
|
||||
|
||||
for (size_t i = 0; i < m_filenames.GetCount(); i++)
|
||||
{
|
||||
sFilenames += m_filenames[i];
|
||||
sFilenames += (wxChar)0;
|
||||
}
|
||||
|
||||
memcpy(pBuf, sFilenames.mbc_str(), sFilenames.Len() + 1);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
size_t wxFileDataObject::GetDataSize() const
|
||||
{
|
||||
size_t nRes = 0;
|
||||
|
||||
for (size_t i = 0; i < m_filenames.GetCount(); i++)
|
||||
{
|
||||
nRes += m_filenames[i].Len();
|
||||
nRes += 1;
|
||||
}
|
||||
|
||||
return nRes + 1;
|
||||
}
|
||||
|
||||
bool wxFileDataObject::SetData(
|
||||
size_t WXUNUSED(nSize)
|
||||
, const void* pBuf
|
||||
)
|
||||
{
|
||||
m_filenames.Empty();
|
||||
|
||||
AddFile(wxString::FromAscii((char*)pBuf));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxFileDataObject::AddFile(
|
||||
const wxString& rFilename
|
||||
)
|
||||
{
|
||||
m_filenames.Add(rFilename);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmapDataObject
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxBitmapDataObject::wxBitmapDataObject()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
wxBitmapDataObject::wxBitmapDataObject(
|
||||
const wxBitmap& rBitmap
|
||||
)
|
||||
: wxBitmapDataObjectBase(rBitmap)
|
||||
{
|
||||
Init();
|
||||
if ( m_bitmap.Ok() )
|
||||
{
|
||||
m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
|
||||
}
|
||||
}
|
||||
|
||||
wxBitmapDataObject::~wxBitmapDataObject()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void wxBitmapDataObject::SetBitmap(
|
||||
const wxBitmap& rBitmap
|
||||
)
|
||||
{
|
||||
Clear();
|
||||
wxBitmapDataObjectBase::SetBitmap(rBitmap);
|
||||
if ( m_bitmap.Ok() )
|
||||
{
|
||||
m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxBitmapDataObject::Init()
|
||||
{
|
||||
m_pictHandle = NULL ;
|
||||
m_pictCreated = false ;
|
||||
}
|
||||
|
||||
void wxBitmapDataObject::Clear()
|
||||
{
|
||||
if ( m_pictCreated && m_pictHandle )
|
||||
{
|
||||
KillPicture( (PicHandle) m_pictHandle ) ;
|
||||
}
|
||||
m_pictHandle = NULL ;
|
||||
}
|
||||
|
||||
bool wxBitmapDataObject::GetDataHere(
|
||||
void* pBuf
|
||||
) const
|
||||
{
|
||||
if (!m_pictHandle)
|
||||
{
|
||||
wxFAIL_MSG(wxT("attempt to copy empty bitmap failed"));
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(pBuf, *(Handle)m_pictHandle, GetHandleSize((Handle)m_pictHandle));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
size_t wxBitmapDataObject::GetDataSize() const
|
||||
{
|
||||
return GetHandleSize((Handle)m_pictHandle) ;
|
||||
}
|
||||
|
||||
bool wxBitmapDataObject::SetData(
|
||||
size_t nSize
|
||||
, const void* pBuf
|
||||
)
|
||||
{
|
||||
Clear();
|
||||
PicHandle picHandle = (PicHandle) NewHandle( nSize ) ;
|
||||
memcpy( *picHandle , pBuf , nSize ) ;
|
||||
m_pictHandle = picHandle ;
|
||||
m_pictCreated = false ;
|
||||
Rect frame = (**picHandle).picFrame ;
|
||||
|
||||
m_bitmap.SetPict( picHandle ) ;
|
||||
m_bitmap.SetWidth( frame.right - frame.left ) ;
|
||||
m_bitmap.SetHeight( frame.bottom - frame.top ) ;
|
||||
return m_bitmap.Ok();
|
||||
}
|
||||
2297
src/mac/classic/dc.cpp
Normal file
2297
src/mac/classic/dc.cpp
Normal file
File diff suppressed because it is too large
Load Diff
175
src/mac/classic/dcclient.cpp
Normal file
175
src/mac/classic/dcclient.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dcclient.cpp
|
||||
// Purpose: wxClientDC class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dcclient.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/region.h"
|
||||
#include "wx/window.h"
|
||||
#include "wx/toplevel.h"
|
||||
#include <math.h>
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constants
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define RAD2DEG 57.2957795131
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxPaintDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxWindowDC
|
||||
*/
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
wxWindowDC::wxWindowDC()
|
||||
{
|
||||
m_window = NULL ;
|
||||
}
|
||||
|
||||
wxWindowDC::wxWindowDC(wxWindow *window)
|
||||
{
|
||||
m_window = window ;
|
||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
|
||||
int x , y ;
|
||||
x = y = 0 ;
|
||||
window->MacWindowToRootWindow( &x , &y ) ;
|
||||
m_macLocalOrigin.x = x ;
|
||||
m_macLocalOrigin.y = y ;
|
||||
CopyRgn( (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
m_ok = TRUE ;
|
||||
SetBackground(window->MacGetBackgroundBrush());
|
||||
}
|
||||
|
||||
wxWindowDC::~wxWindowDC()
|
||||
{
|
||||
}
|
||||
|
||||
void wxWindowDC::DoGetSize( int* width, int* height ) const
|
||||
{
|
||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||
|
||||
m_window->GetSize(width, height);
|
||||
}
|
||||
|
||||
/*
|
||||
* wxClientDC
|
||||
*/
|
||||
|
||||
wxClientDC::wxClientDC()
|
||||
{
|
||||
m_window = NULL ;
|
||||
}
|
||||
|
||||
wxClientDC::wxClientDC(wxWindow *window)
|
||||
{
|
||||
m_window = window ;
|
||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||
if (!rootwindow)
|
||||
return;
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||
wxSize size = window->GetClientSize() ;
|
||||
int x , y ;
|
||||
x = origin.x ;
|
||||
y = origin.y ;
|
||||
window->MacWindowToRootWindow( &x , &y ) ;
|
||||
m_macLocalOrigin.x = x ;
|
||||
m_macLocalOrigin.y = y ;
|
||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
|
||||
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
|
||||
m_ok = TRUE ;
|
||||
SetBackground(window->MacGetBackgroundBrush());
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
|
||||
wxClientDC::~wxClientDC()
|
||||
{
|
||||
}
|
||||
|
||||
void wxClientDC::DoGetSize(int *width, int *height) const
|
||||
{
|
||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||
|
||||
m_window->GetClientSize( width, height );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* wxPaintDC
|
||||
*/
|
||||
|
||||
wxPaintDC::wxPaintDC()
|
||||
{
|
||||
m_window = NULL ;
|
||||
}
|
||||
|
||||
wxPaintDC::wxPaintDC(wxWindow *window)
|
||||
{
|
||||
m_window = window ;
|
||||
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
|
||||
WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
|
||||
wxPoint origin = window->GetClientAreaOrigin() ;
|
||||
wxSize size = window->GetClientSize() ;
|
||||
int x , y ;
|
||||
x = origin.x ;
|
||||
y = origin.y ;
|
||||
window->MacWindowToRootWindow( &x , &y ) ;
|
||||
m_macLocalOrigin.x = x ;
|
||||
m_macLocalOrigin.y = y ;
|
||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
|
||||
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
|
||||
SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_macPort = UMAGetWindowPort( windowref ) ;
|
||||
|
||||
m_ok = TRUE ;
|
||||
SetBackground(window->MacGetBackgroundBrush());
|
||||
SetFont( window->GetFont() ) ;
|
||||
}
|
||||
|
||||
wxPaintDC::~wxPaintDC()
|
||||
{
|
||||
}
|
||||
|
||||
void wxPaintDC::DoGetSize(int *width, int *height) const
|
||||
{
|
||||
wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
|
||||
|
||||
m_window->GetClientSize( width, height );
|
||||
}
|
||||
|
||||
|
||||
100
src/mac/classic/dcmemory.cpp
Normal file
100
src/mac/classic/dcmemory.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dcmemory.cpp
|
||||
// Purpose: wxMemoryDC class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dcmemory.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxMemoryDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
|
||||
|
||||
wxMemoryDC::wxMemoryDC(void)
|
||||
: m_selected()
|
||||
{
|
||||
m_ok = TRUE;
|
||||
SetBackground(*wxWHITE_BRUSH);
|
||||
SetBrush(*wxWHITE_BRUSH);
|
||||
SetPen(*wxBLACK_PEN);
|
||||
m_ok = FALSE;
|
||||
};
|
||||
|
||||
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||
: m_selected()
|
||||
{
|
||||
m_ok = TRUE;
|
||||
SetBackground(*wxWHITE_BRUSH);
|
||||
SetBrush(*wxWHITE_BRUSH);
|
||||
SetPen(*wxBLACK_PEN);
|
||||
m_ok = FALSE;
|
||||
};
|
||||
|
||||
wxMemoryDC::~wxMemoryDC()
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||
}
|
||||
};
|
||||
|
||||
void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
|
||||
}
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
if ( m_selected.GetHBITMAP() )
|
||||
{
|
||||
m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
||||
wxMask * mask = bitmap.GetMask() ;
|
||||
if ( mask )
|
||||
{
|
||||
m_macMask = mask->GetMaskBitmap() ;
|
||||
}
|
||||
SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
|
||||
m_ok = TRUE ;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ok = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ok = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void wxMemoryDC::DoGetSize( int *width, int *height ) const
|
||||
{
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
if (width) (*width) = m_selected.GetWidth();
|
||||
if (height) (*height) = m_selected.GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width) (*width) = 0;
|
||||
if (height) (*height) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
416
src/mac/classic/dcprint.cpp
Normal file
416
src/mac/classic/dcprint.cpp
Normal file
@@ -0,0 +1,416 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dcprint.cpp
|
||||
// Purpose: wxPrinterDC class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dcprint.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif
|
||||
|
||||
#include "wx/dcprint.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include <math.h>
|
||||
#include "wx/mac/uma.h"
|
||||
#include "wx/mac/private/print.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxPrinterDC, wxDC)
|
||||
#endif
|
||||
|
||||
class wxNativePrinterDC
|
||||
{
|
||||
public :
|
||||
wxNativePrinterDC() {}
|
||||
virtual ~wxNativePrinterDC() {}
|
||||
virtual bool StartDoc( wxPrinterDC* dc , const wxString& message ) = 0;
|
||||
virtual void EndDoc( wxPrinterDC* dc ) = 0;
|
||||
virtual void StartPage( wxPrinterDC* dc ) = 0;
|
||||
virtual void EndPage( wxPrinterDC* dc ) = 0;
|
||||
virtual wxCoord GetMaxX() const = 0 ;
|
||||
virtual wxCoord GetMaxY() const = 0 ;
|
||||
// returns 0 in case of no Error, otherwise platform specific error codes
|
||||
virtual wxUint32 GetStatus() const = 0 ;
|
||||
bool Ok() { return GetStatus() == 0 ; }
|
||||
|
||||
static wxNativePrinterDC* Create(wxPrintData* data) ;
|
||||
} ;
|
||||
|
||||
#if TARGET_CARBON
|
||||
|
||||
class wxMacCarbonPrinterDC : public wxNativePrinterDC
|
||||
{
|
||||
public :
|
||||
wxMacCarbonPrinterDC( wxPrintData* data ) ;
|
||||
~wxMacCarbonPrinterDC() ;
|
||||
virtual bool StartDoc( wxPrinterDC* dc , const wxString& message ) ;
|
||||
virtual void EndDoc( wxPrinterDC* dc ) ;
|
||||
virtual void StartPage( wxPrinterDC* dc ) ;
|
||||
virtual void EndPage( wxPrinterDC* dc ) ;
|
||||
virtual wxCoord GetMaxX() const { return m_maxX ; }
|
||||
virtual wxCoord GetMaxY() const { return m_maxY ; }
|
||||
virtual wxUint32 GetStatus() const { return m_err ; }
|
||||
private :
|
||||
GrafPtr m_macPrintFormerPort ;
|
||||
wxCoord m_maxX ;
|
||||
wxCoord m_maxY ;
|
||||
OSStatus m_err ;
|
||||
} ;
|
||||
|
||||
wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
|
||||
{
|
||||
::GetPort( & m_macPrintFormerPort ) ;
|
||||
|
||||
m_err = noErr ;
|
||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) data->m_nativePrintData ;
|
||||
|
||||
PMRect rPage;
|
||||
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
|
||||
if ( m_err != noErr )
|
||||
return;
|
||||
|
||||
m_maxX = wxCoord(rPage.right - rPage.left) ;
|
||||
m_maxY = wxCoord(rPage.bottom - rPage.top);
|
||||
}
|
||||
|
||||
wxMacCarbonPrinterDC::~wxMacCarbonPrinterDC()
|
||||
{
|
||||
// nothing to release from print data, as wxPrinterDC has all data in its wxPrintData member
|
||||
::SetPort( m_macPrintFormerPort ) ;
|
||||
}
|
||||
|
||||
wxNativePrinterDC* wxNativePrinterDC::Create(wxPrintData* data)
|
||||
{
|
||||
return new wxMacCarbonPrinterDC(data) ;
|
||||
}
|
||||
|
||||
bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED(message) )
|
||||
{
|
||||
if ( m_err )
|
||||
return false ;
|
||||
|
||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
|
||||
|
||||
m_err = PMSessionBeginDocument(native->m_macPrintSession,
|
||||
native->m_macPrintSettings,
|
||||
native->m_macPageFormat);
|
||||
if ( m_err != noErr )
|
||||
return false;
|
||||
|
||||
PMRect rPage;
|
||||
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
|
||||
if ( m_err != noErr )
|
||||
return false;
|
||||
|
||||
m_maxX = (wxCoord)(rPage.right - rPage.left);
|
||||
m_maxY = (wxCoord)(rPage.bottom - rPage.top);
|
||||
return true ;
|
||||
}
|
||||
|
||||
void wxMacCarbonPrinterDC::EndDoc( wxPrinterDC* dc )
|
||||
{
|
||||
if ( m_err )
|
||||
return ;
|
||||
|
||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
|
||||
|
||||
m_err = PMSessionEndDocument(native->m_macPrintSession);
|
||||
}
|
||||
|
||||
void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
|
||||
{
|
||||
if ( m_err )
|
||||
return ;
|
||||
|
||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
|
||||
|
||||
m_err = PMSessionBeginPage(native->m_macPrintSession,
|
||||
native->m_macPageFormat,
|
||||
nil);
|
||||
|
||||
if ( m_err == noErr )
|
||||
{
|
||||
m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
|
||||
nil,
|
||||
(void**) &dc->m_macPort );
|
||||
}
|
||||
|
||||
if ( m_err != noErr )
|
||||
{
|
||||
PMSessionEndPage(native->m_macPrintSession);
|
||||
PMSessionEndDocument(native->m_macPrintSession);
|
||||
}
|
||||
else
|
||||
{
|
||||
PMRect rPage;
|
||||
|
||||
m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
|
||||
if ( !m_err )
|
||||
{
|
||||
dc->m_macLocalOrigin.x = (int) rPage.left;
|
||||
dc->m_macLocalOrigin.y = (int) rPage.top;
|
||||
}
|
||||
// since this is a non-critical error, we set the flag back
|
||||
m_err = noErr ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
|
||||
{
|
||||
if ( m_err )
|
||||
return ;
|
||||
|
||||
wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
|
||||
|
||||
m_err = PMSessionEndPage(native->m_macPrintSession);
|
||||
if ( m_err != noErr )
|
||||
{
|
||||
PMSessionEndDocument(native->m_macPrintSession);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
class wxMacClassicPrinterDC : public wxNativePrinterDC
|
||||
{
|
||||
public :
|
||||
wxMacClassicPrinterDC( wxPrintData* data ) ;
|
||||
~wxMacClassicPrinterDC() ;
|
||||
virtual bool StartDoc( wxPrinterDC* dc , const wxString& message ) ;
|
||||
virtual void EndDoc( wxPrinterDC* dc ) ;
|
||||
virtual void StartPage( wxPrinterDC* dc ) ;
|
||||
virtual void EndPage( wxPrinterDC* dc ) ;
|
||||
virtual wxCoord GetMaxX() const { return m_maxX ; }
|
||||
virtual wxCoord GetMaxY() const { return m_maxY ; }
|
||||
virtual wxUint32 GetStatus() const { return m_err ; }
|
||||
private :
|
||||
GrafPtr m_macPrintFormerPort ;
|
||||
TPPrPort m_macPrintingPort ;
|
||||
OSErr m_err ;
|
||||
long m_maxX ;
|
||||
long m_maxY ;
|
||||
} ;
|
||||
|
||||
wxNativePrinterDC* wxNativePrinterDC::Create(wxPrintData* data)
|
||||
{
|
||||
return new wxMacClassicPrinterDC(data) ;
|
||||
}
|
||||
|
||||
wxMacClassicPrinterDC::wxMacClassicPrinterDC(wxPrintData* data)
|
||||
{
|
||||
::GetPort( &m_macPrintFormerPort ) ;
|
||||
m_err = noErr ;
|
||||
::UMAPrOpen() ;
|
||||
m_err = PrError() ;
|
||||
if ( m_err != noErr )
|
||||
return;
|
||||
|
||||
wxMacClassicPrintData *native = (wxMacClassicPrintData*) data->m_nativePrintData ;
|
||||
|
||||
if ( ::PrValidate( native->m_macPrintSettings ) )
|
||||
{
|
||||
// the driver has changed in the mean time, should we pop up a page setup dialog ?
|
||||
if ( !::PrStlDialog( native->m_macPrintSettings ) )
|
||||
{
|
||||
m_err = -1 ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_err = PrError() ;
|
||||
|
||||
if ( m_err == noErr )
|
||||
{
|
||||
m_maxX = (**native->m_macPrintSettings).prInfo.rPage.right - (**native->m_macPrintSettings).prInfo.rPage.left ;
|
||||
m_maxY = (**native->m_macPrintSettings).prInfo.rPage.bottom - (**native->m_macPrintSettings).prInfo.rPage.top ;
|
||||
}
|
||||
}
|
||||
|
||||
wxMacClassicPrinterDC::~wxMacClassicPrinterDC()
|
||||
{
|
||||
::UMAPrClose() ;
|
||||
::SetPort( LMGetWMgrPort() ) ;
|
||||
}
|
||||
|
||||
bool wxMacClassicPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED(message) )
|
||||
{
|
||||
if ( m_err )
|
||||
return false ;
|
||||
|
||||
wxMacClassicPrintData *native = (wxMacClassicPrintData*) dc->GetPrintData().m_nativePrintData ;
|
||||
m_macPrintingPort = ::PrOpenDoc( native->m_macPrintSettings , NULL , NULL ) ;
|
||||
m_err = PrError() ;
|
||||
if ( m_err )
|
||||
return false ;
|
||||
|
||||
// sets current port
|
||||
dc->m_macPort = (GrafPtr ) m_macPrintingPort ;
|
||||
m_maxX = (**native->m_macPrintSettings).prInfo.rPage.right - (**native->m_macPrintSettings).prInfo.rPage.left ;
|
||||
m_maxY = (**native->m_macPrintSettings).prInfo.rPage.bottom - (**native->m_macPrintSettings).prInfo.rPage.top ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void wxMacClassicPrinterDC::EndDoc( wxPrinterDC* dc )
|
||||
{
|
||||
if ( m_err )
|
||||
return ;
|
||||
|
||||
PrCloseDoc( m_macPrintingPort ) ;
|
||||
m_err = PrError() ;
|
||||
}
|
||||
|
||||
void wxMacClassicPrinterDC::StartPage( wxPrinterDC* dc )
|
||||
{
|
||||
if ( m_err )
|
||||
return ;
|
||||
|
||||
wxMacClassicPrintData *native = (wxMacClassicPrintData*) dc->GetPrintData().m_nativePrintData ;
|
||||
|
||||
PrOpenPage( m_macPrintingPort , NULL ) ;
|
||||
dc->m_macLocalOrigin.x = (**native->m_macPrintSettings).rPaper.left ;
|
||||
dc->m_macLocalOrigin.y = (**native->m_macPrintSettings).rPaper.top ;
|
||||
// m_macPrintingPort is now the current port
|
||||
Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
|
||||
::ClipRect( &clip ) ;
|
||||
m_err = PrError() ;
|
||||
if ( m_err != noErr )
|
||||
::PrCloseDoc( m_macPrintingPort ) ;
|
||||
}
|
||||
|
||||
void wxMacClassicPrinterDC::EndPage( wxPrinterDC* dc )
|
||||
{
|
||||
if ( m_err )
|
||||
return ;
|
||||
|
||||
PrClosePage( m_macPrintingPort ) ;
|
||||
m_err = PrError() ;
|
||||
if ( m_err != noErr )
|
||||
::PrCloseDoc( m_macPrintingPort ) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
|
||||
{
|
||||
m_ok = FALSE ;
|
||||
m_printData = printdata ;
|
||||
m_printData.ConvertToNative() ;
|
||||
m_nativePrinterDC = wxNativePrinterDC::Create( &m_printData ) ;
|
||||
if ( m_nativePrinterDC )
|
||||
{
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
|
||||
if ( !m_ok )
|
||||
{
|
||||
wxString message ;
|
||||
message.Printf( wxT("Print Error %u"), m_nativePrinterDC->GetStatus() ) ;
|
||||
wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
|
||||
dialog.ShowModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxPrinterDC::~wxPrinterDC(void)
|
||||
{
|
||||
delete m_nativePrinterDC ;
|
||||
}
|
||||
|
||||
bool wxPrinterDC::StartDoc( const wxString& message )
|
||||
{
|
||||
wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;
|
||||
|
||||
if ( !m_ok )
|
||||
return false ;
|
||||
|
||||
if ( m_nativePrinterDC->StartDoc(this, message ) )
|
||||
{
|
||||
// in case we have to do additional things when successful
|
||||
}
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
if ( !m_ok )
|
||||
{
|
||||
wxString message ;
|
||||
message.Printf( wxT("Print Error %u"), m_nativePrinterDC->GetStatus() ) ;
|
||||
wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
|
||||
dialog.ShowModal();
|
||||
}
|
||||
|
||||
return m_ok ;
|
||||
}
|
||||
|
||||
void wxPrinterDC::EndDoc(void)
|
||||
{
|
||||
if ( !m_ok )
|
||||
return ;
|
||||
|
||||
m_nativePrinterDC->EndDoc( this ) ;
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
|
||||
if ( !m_ok )
|
||||
{
|
||||
wxString message ;
|
||||
message.Printf( wxT("Print Error %u"), m_nativePrinterDC->GetStatus() ) ;
|
||||
wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
|
||||
dialog.ShowModal();
|
||||
}
|
||||
}
|
||||
|
||||
void wxPrinterDC::StartPage(void)
|
||||
{
|
||||
if ( !m_ok )
|
||||
return ;
|
||||
|
||||
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_macFontInstalled = false ;
|
||||
m_macBrushInstalled = false ;
|
||||
m_macPenInstalled = false ;
|
||||
|
||||
m_nativePrinterDC->StartPage(this) ;
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
|
||||
}
|
||||
|
||||
void wxPrinterDC::EndPage(void)
|
||||
{
|
||||
if ( !m_ok )
|
||||
return ;
|
||||
|
||||
m_nativePrinterDC->EndPage(this) ;
|
||||
m_ok = m_nativePrinterDC->Ok() ;
|
||||
}
|
||||
|
||||
void wxPrinterDC::DoGetSize(int *width, int *height) const
|
||||
{
|
||||
wxCHECK_RET( m_ok , _T("GetSize() doesn't work without a valid wxPrinterDC") );
|
||||
|
||||
if ( width )
|
||||
* width = m_nativePrinterDC->GetMaxX() ;
|
||||
if ( height )
|
||||
* height = m_nativePrinterDC->GetMaxY() ;
|
||||
}
|
||||
|
||||
|
||||
63
src/mac/classic/dcscreen.cpp
Normal file
63
src/mac/classic/dcscreen.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dcscreen.cpp
|
||||
// Purpose: wxScreenDC class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dcscreen.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dcscreen.h"
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
|
||||
#endif
|
||||
|
||||
// Create a DC representing the whole screen
|
||||
wxScreenDC::wxScreenDC()
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
m_macPort = GetQDGlobalsThePort() ;
|
||||
GrafPtr port ;
|
||||
GetPort( &port ) ;
|
||||
SetPort( (GrafPtr) m_macPort ) ;
|
||||
Point pt = { 0,0 } ;
|
||||
LocalToGlobal( &pt ) ;
|
||||
SetPort( port ) ;
|
||||
m_macLocalOrigin.x = -pt.h ;
|
||||
m_macLocalOrigin.y = -pt.v ;
|
||||
#else
|
||||
m_macPort = LMGetWMgrPort() ;
|
||||
m_macLocalOrigin.x = 0 ;
|
||||
m_macLocalOrigin.y = 0 ;
|
||||
#endif
|
||||
m_ok = TRUE ;
|
||||
BitMap screenBits;
|
||||
GetQDGlobalsScreenBits( &screenBits );
|
||||
m_minX = screenBits.bounds.left ;
|
||||
#if TARGET_CARBON
|
||||
SInt16 height ;
|
||||
GetThemeMenuBarHeight( &height ) ;
|
||||
m_minY = screenBits.bounds.top + height ;
|
||||
#else
|
||||
m_minY = screenBits.bounds.top + LMGetMBarHeight() ;
|
||||
#endif
|
||||
m_maxX = screenBits.bounds.right ;
|
||||
m_maxY = screenBits.bounds.bottom ;
|
||||
MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
|
||||
OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
|
||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||
}
|
||||
|
||||
wxScreenDC::~wxScreenDC()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
268
src/mac/classic/dialog.cpp
Normal file
268
src/mac/classic/dialog.cpp
Normal file
@@ -0,0 +1,268 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialog.cpp
|
||||
// Purpose: wxDialog class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dialog.h"
|
||||
#endif
|
||||
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/settings.h"
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
// Lists to keep track of windows, so we can disable/enable them
|
||||
// for modal dialogs
|
||||
wxList wxModalDialogs;
|
||||
//wxList wxModelessWindows; // Frames and modeless dialogs
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
|
||||
EVT_CHAR_HOOK(wxDialog::OnCharHook)
|
||||
|
||||
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
|
||||
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif
|
||||
|
||||
wxDialog::wxDialog()
|
||||
{
|
||||
m_isShown = FALSE;
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
}
|
||||
|
||||
bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
|
||||
|
||||
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
|
||||
return FALSE;
|
||||
|
||||
MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) & ~(wxYES|wxOK|wxNO|wxCANCEL) , name ) ;
|
||||
|
||||
m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
|
||||
SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::SetModal(bool flag)
|
||||
{
|
||||
if ( flag )
|
||||
{
|
||||
m_windowStyle |= wxDIALOG_MODAL;
|
||||
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
#if TARGET_CARBON
|
||||
SetWindowModality( (WindowRef) MacGetWindowRef() , kWindowModalityAppModal , NULL ) ;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
m_windowStyle &= ~wxDIALOG_MODAL;
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
}
|
||||
}
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
Show(FALSE);
|
||||
}
|
||||
|
||||
// By default, pressing escape cancels the dialog , on mac command-stop does the same thing
|
||||
void wxDialog::OnCharHook(wxKeyEvent& event)
|
||||
{
|
||||
if (( event.m_keyCode == WXK_ESCAPE ||
|
||||
( event.m_keyCode == '.' && event.MetaDown() ) )
|
||||
&& FindWindow(wxID_CANCEL) )
|
||||
{
|
||||
// Behaviour changed in 2.0: we'll send a Cancel message
|
||||
// to the dialog instead of Close.
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
|
||||
return;
|
||||
}
|
||||
// We didn't process this event.
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
bool wxDialog::IsModal() const
|
||||
{
|
||||
return (GetWindowStyleFlag() & wxDIALOG_MODAL) != 0;
|
||||
}
|
||||
|
||||
|
||||
bool wxDialog::IsModalShowing() const
|
||||
{
|
||||
return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
|
||||
}
|
||||
|
||||
bool wxDialog::Show(bool show)
|
||||
{
|
||||
if ( !wxDialogBase::Show(show) )
|
||||
{
|
||||
// nothing to do
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( show )
|
||||
{
|
||||
// usually will result in TransferDataToWindow() being called
|
||||
InitDialog();
|
||||
}
|
||||
|
||||
if ( IsModal() )
|
||||
{
|
||||
if ( show )
|
||||
{
|
||||
DoShowModal();
|
||||
}
|
||||
else // end of modal dialog
|
||||
{
|
||||
// this will cause IsModalShowing() return FALSE and our local
|
||||
// message loop will terminate
|
||||
wxModalDialogs.DeleteObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if !TARGET_CARBON
|
||||
extern bool s_macIsInModalLoop ;
|
||||
#endif
|
||||
|
||||
void wxDialog::DoShowModal()
|
||||
{
|
||||
wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
|
||||
|
||||
wxModalDialogs.Append(this);
|
||||
|
||||
#if TARGET_CARBON
|
||||
BeginAppModalStateForWindow( (WindowRef) MacGetWindowRef()) ;
|
||||
#else
|
||||
// TODO : test whether parent gets disabled
|
||||
bool formerModal = s_macIsInModalLoop ;
|
||||
s_macIsInModalLoop = true ;
|
||||
#endif
|
||||
while ( IsModalShowing() )
|
||||
{
|
||||
wxTheApp->MacDoOneEvent() ;
|
||||
// calls process idle itself
|
||||
}
|
||||
|
||||
#if TARGET_CARBON
|
||||
EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ;
|
||||
#else
|
||||
// TODO probably reenable the parent window if any
|
||||
s_macIsInModalLoop = formerModal ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Replacement for Show(TRUE) for modal dialogs - returns return code
|
||||
int wxDialog::ShowModal()
|
||||
{
|
||||
if ( !IsModal() )
|
||||
{
|
||||
SetModal(TRUE);
|
||||
}
|
||||
|
||||
Show(TRUE);
|
||||
return GetReturnCode();
|
||||
}
|
||||
|
||||
// NB: this function (surprizingly) may be called for both modal and modeless
|
||||
// dialogs and should work for both of them
|
||||
void wxDialog::EndModal(int retCode)
|
||||
{
|
||||
SetReturnCode(retCode);
|
||||
Show(FALSE);
|
||||
}
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
// We'll send a Cancel message by default,
|
||||
// which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close().
|
||||
// We wouldn't want to destroy the dialog by default, since the dialog may have been
|
||||
// created on the stack.
|
||||
// However, this does mean that calling dialog->Close() won't delete the dialog
|
||||
// unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
|
||||
// sure to destroy the dialog.
|
||||
// The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
|
||||
|
||||
static wxList closing;
|
||||
|
||||
if ( closing.Member(this) )
|
||||
return;
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
|
||||
|
||||
closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
146
src/mac/classic/dirdlg.cpp
Normal file
146
src/mac/classic/dirdlg.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dirdlg.cpp
|
||||
// Purpose: wxDirDialog
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dirdlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/dirdlg.h"
|
||||
|
||||
#include "wx/cmndata.h"
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
#ifdef __DARWIN__
|
||||
#include <Carbon/Carbon.h>
|
||||
#else
|
||||
#include <Navigation.h>
|
||||
#endif
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_CLASS(wxDirDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
wxDirDialog::wxDirDialog(wxWindow *parent,
|
||||
const wxString& message,
|
||||
const wxString& defaultPath,
|
||||
long style,
|
||||
const wxPoint& WXUNUSED(pos),
|
||||
const wxSize& WXUNUSED(size),
|
||||
const wxString& WXUNUSED(name))
|
||||
{
|
||||
wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
|
||||
m_message = message;
|
||||
m_dialogStyle = style;
|
||||
m_parent = parent;
|
||||
m_path = defaultPath;
|
||||
}
|
||||
|
||||
int wxDirDialog::ShowModal()
|
||||
{
|
||||
NavDialogOptions mNavOptions;
|
||||
NavObjectFilterUPP mNavFilterUPP = NULL;
|
||||
NavPreviewUPP mNavPreviewUPP = NULL ;
|
||||
NavReplyRecord mNavReply;
|
||||
AEDesc* mDefaultLocation = NULL ;
|
||||
bool mSelectDefault = false ;
|
||||
|
||||
::NavGetDefaultDialogOptions(&mNavOptions);
|
||||
|
||||
mNavFilterUPP = nil;
|
||||
mNavPreviewUPP = nil;
|
||||
mSelectDefault = false;
|
||||
mNavReply.validRecord = false;
|
||||
mNavReply.replacing = false;
|
||||
mNavReply.isStationery = false;
|
||||
mNavReply.translationNeeded = false;
|
||||
mNavReply.selection.descriptorType = typeNull;
|
||||
mNavReply.selection.dataHandle = nil;
|
||||
mNavReply.keyScript = smSystemScript;
|
||||
mNavReply.fileTranslation = nil;
|
||||
|
||||
// Set default location, the location
|
||||
// that's displayed when the dialog
|
||||
// first appears
|
||||
|
||||
if ( mDefaultLocation ) {
|
||||
|
||||
if (mSelectDefault) {
|
||||
mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
|
||||
} else {
|
||||
mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
|
||||
}
|
||||
}
|
||||
|
||||
OSErr err = ::NavChooseFolder(
|
||||
mDefaultLocation,
|
||||
&mNavReply,
|
||||
&mNavOptions,
|
||||
NULL,
|
||||
mNavFilterUPP,
|
||||
0L); // User Data
|
||||
|
||||
if ( (err != noErr) && (err != userCanceledErr) ) {
|
||||
m_path = wxT("") ;
|
||||
return wxID_CANCEL ;
|
||||
}
|
||||
|
||||
if (mNavReply.validRecord) { // User chose a folder
|
||||
|
||||
FSSpec folderInfo;
|
||||
FSSpec outFileSpec ;
|
||||
AEDesc specDesc ;
|
||||
|
||||
OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc);
|
||||
if ( err != noErr ) {
|
||||
m_path = wxT("") ;
|
||||
return wxID_CANCEL ;
|
||||
}
|
||||
folderInfo = **(FSSpec**) specDesc.dataHandle;
|
||||
if (specDesc.dataHandle != nil) {
|
||||
::AEDisposeDesc(&specDesc);
|
||||
}
|
||||
|
||||
// mNavReply.GetFileSpec(folderInfo);
|
||||
|
||||
// The FSSpec from NavChooseFolder is NOT the file spec
|
||||
// for the folder. The parID field is actually the DirID
|
||||
// of the folder itself, not the folder's parent, and
|
||||
// the name field is empty. We must call PBGetCatInfo
|
||||
// to get the parent DirID and folder name
|
||||
|
||||
Str255 name;
|
||||
CInfoPBRec thePB; // Directory Info Parameter Block
|
||||
thePB.dirInfo.ioCompletion = nil;
|
||||
thePB.dirInfo.ioVRefNum = folderInfo.vRefNum; // Volume is right
|
||||
thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID
|
||||
thePB.dirInfo.ioNamePtr = name;
|
||||
thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID
|
||||
|
||||
err = ::PBGetCatInfoSync(&thePB);
|
||||
if ( err != noErr ) {
|
||||
m_path = wxT("") ;
|
||||
return wxID_CANCEL ;
|
||||
}
|
||||
// Create cannonical FSSpec
|
||||
::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID,
|
||||
name, &outFileSpec);
|
||||
|
||||
// outFolderDirID = thePB.dirInfo.ioDrDirID;
|
||||
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
|
||||
return wxID_OK ;
|
||||
}
|
||||
return wxID_CANCEL;
|
||||
}
|
||||
|
||||
322
src/mac/classic/dirmac.cpp
Normal file
322
src/mac/classic/dirmac.cpp
Normal file
@@ -0,0 +1,322 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: msw/dir.cpp
|
||||
// Purpose: wxDir implementation for Mac
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 08.12.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1999 Stefan Csomor <csomor@advanced.ch>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dir.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#endif // PCH
|
||||
|
||||
#include "wx/dir.h"
|
||||
#include "wx/filefn.h" // for wxPathExists()
|
||||
|
||||
#ifndef __DARWIN__
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
#ifdef __DARWIN__
|
||||
# include "MoreFilesX.h"
|
||||
#else
|
||||
# include "MoreFiles.h"
|
||||
# include "MoreFilesExtras.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260 // from VC++ headers
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define M_DIR ((wxDirData *)m_data)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// this class stores everything we need to enumerate the files
|
||||
class wxDirData
|
||||
{
|
||||
public:
|
||||
wxDirData(const wxString& dirname);
|
||||
~wxDirData();
|
||||
|
||||
void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
|
||||
void SetFlags(int flags) { m_flags = flags; }
|
||||
|
||||
bool Read(wxString *filename); // reads the next
|
||||
void Rewind() ;
|
||||
|
||||
const wxString& GetName() const { return m_dirname; }
|
||||
bool Ok() const { return m_ok; }
|
||||
|
||||
private:
|
||||
CInfoPBRec m_CPB ;
|
||||
wxInt16 m_index ;
|
||||
long m_dirId ;
|
||||
Str255 m_name ;
|
||||
Boolean m_isDir ;
|
||||
|
||||
wxString m_dirname;
|
||||
wxString m_filespec;
|
||||
|
||||
int m_flags;
|
||||
bool m_ok;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDirData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxDirData::wxDirData(const wxString& dirname)
|
||||
: m_dirname(dirname)
|
||||
{
|
||||
m_ok = false;
|
||||
|
||||
OSErr err;
|
||||
|
||||
// throw away the trailing slashes
|
||||
size_t n = m_dirname.length();
|
||||
wxCHECK_RET( n, _T("empty dir name in wxDir") );
|
||||
|
||||
while ( n > 0 && wxIsPathSeparator(m_dirname[--n]) )
|
||||
;
|
||||
|
||||
m_dirname.Truncate(n + 1);
|
||||
|
||||
#ifdef __DARWIN__
|
||||
FSRef theRef;
|
||||
|
||||
// get the FSRef associated with the POSIX path
|
||||
err = FSPathMakeRef((const UInt8 *) m_dirname.c_str(), &theRef, NULL);
|
||||
FSGetVRefNum(&theRef, &(m_CPB.hFileInfo.ioVRefNum));
|
||||
|
||||
err = FSGetNodeID( &theRef , &m_dirId , &m_isDir ) ;
|
||||
#else
|
||||
FSSpec fsspec ;
|
||||
|
||||
wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
|
||||
m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
|
||||
|
||||
err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
|
||||
#endif
|
||||
//wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ;
|
||||
if ( (err == noErr) || (err == nsvErr))
|
||||
m_ok = true;
|
||||
else
|
||||
wxLogError(wxString(wxT("Error accessing directory ")) + m_dirname);
|
||||
|
||||
m_CPB.hFileInfo.ioNamePtr = m_name ;
|
||||
m_index = 0 ;
|
||||
}
|
||||
|
||||
wxDirData::~wxDirData()
|
||||
{
|
||||
}
|
||||
|
||||
void wxDirData::Rewind()
|
||||
{
|
||||
m_index = 0 ;
|
||||
}
|
||||
|
||||
bool wxDirData::Read(wxString *filename)
|
||||
{
|
||||
if ( !m_isDir )
|
||||
return FALSE ;
|
||||
|
||||
wxString result;
|
||||
|
||||
short err = noErr ;
|
||||
|
||||
while ( err == noErr )
|
||||
{
|
||||
m_index++ ;
|
||||
m_CPB.dirInfo.ioFDirIndex = m_index;
|
||||
m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
|
||||
err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
|
||||
if ( err != noErr )
|
||||
break ;
|
||||
|
||||
// its hidden but we don't want it
|
||||
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) )
|
||||
continue ;
|
||||
#ifdef __DARWIN__
|
||||
// under X, names that start with '.' are hidden
|
||||
if ( ( m_name[1] == '.' ) && !(m_flags & wxDIR_HIDDEN) )
|
||||
continue;
|
||||
#endif
|
||||
#if TARGET_CARBON
|
||||
// under X thats the way the mounting points look like
|
||||
if ( ( m_CPB.dirInfo.ioDrDirID == 0 ) && ( m_flags & wxDIR_DIRS) )
|
||||
break ;
|
||||
#endif
|
||||
// we have a directory
|
||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) )
|
||||
break ;
|
||||
|
||||
// its a file but we don't want it
|
||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) )
|
||||
continue ;
|
||||
|
||||
wxString file = wxMacMakeStringFromPascal( m_name ) ;
|
||||
if ( m_filespec.IsEmpty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") )
|
||||
{
|
||||
}
|
||||
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) == wxT("*") )
|
||||
{
|
||||
if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == wxT("*") )
|
||||
{
|
||||
if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
}
|
||||
else if ( file.Upper() != m_filespec.Upper() )
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
|
||||
break ;
|
||||
}
|
||||
if ( err != noErr )
|
||||
{
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
*filename = wxMacMakeStringFromPascal( m_name ) ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDir helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
bool wxDir::Exists(const wxString& dir)
|
||||
{
|
||||
return wxPathExists(dir);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDir construction/destruction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxDir::wxDir(const wxString& dirname)
|
||||
{
|
||||
m_data = NULL;
|
||||
|
||||
(void)Open(dirname);
|
||||
}
|
||||
|
||||
bool wxDir::Open(const wxString& dirname)
|
||||
{
|
||||
delete M_DIR;
|
||||
m_data = new wxDirData(dirname);
|
||||
if (m_data->Ok())
|
||||
return TRUE;
|
||||
else
|
||||
{
|
||||
delete m_data;
|
||||
m_data = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxDir::IsOpened() const
|
||||
{
|
||||
return m_data != NULL;
|
||||
}
|
||||
|
||||
wxString wxDir::GetName() const
|
||||
{
|
||||
wxString name;
|
||||
if ( m_data )
|
||||
{
|
||||
name = M_DIR->GetName();
|
||||
if ( !name.empty() && (name.Last() == _T('/')) )
|
||||
{
|
||||
// chop off the last (back)slash
|
||||
name.Truncate(name.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
wxDir::~wxDir()
|
||||
{
|
||||
if (M_DIR != NULL) {
|
||||
delete M_DIR;
|
||||
m_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDir enumerating
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxDir::GetFirst(wxString *filename,
|
||||
const wxString& filespec,
|
||||
int flags) const
|
||||
{
|
||||
wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
|
||||
|
||||
M_DIR->Rewind();
|
||||
|
||||
M_DIR->SetFileSpec(filespec);
|
||||
M_DIR->SetFlags(flags);
|
||||
|
||||
return GetNext(filename);
|
||||
}
|
||||
|
||||
bool wxDir::GetNext(wxString *filename) const
|
||||
{
|
||||
wxCHECK_MSG( IsOpened(), FALSE, _T("must wxDir::Open() first") );
|
||||
|
||||
wxCHECK_MSG( filename, FALSE, _T("bad pointer in wxDir::GetNext()") );
|
||||
|
||||
return M_DIR->Read(filename);
|
||||
}
|
||||
446
src/mac/classic/display.cpp
Normal file
446
src/mac/classic/display.cpp
Normal file
@@ -0,0 +1,446 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: display.cpp
|
||||
// Purpose: Mac implementation of wxDisplay class
|
||||
// Author: Brian Victor
|
||||
// Modified by: Royce Mitchell III & Ryan Norton
|
||||
// Created: 06/21/02
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "display.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_DISPLAY
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dynarray.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#endif
|
||||
|
||||
#ifdef __DARWIN__
|
||||
#include <Carbon/Carbon.h>
|
||||
#else
|
||||
#include <Gestalt.h>
|
||||
#include <Displays.h>
|
||||
#include <Quickdraw.h>
|
||||
#include <Video.h> //for VDSwitchInfoRec
|
||||
#include <FixMath.h>
|
||||
#endif
|
||||
|
||||
#include "wx/display.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/string.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxDisplayMacPriv
|
||||
{
|
||||
public:
|
||||
GDHandle m_hndl;
|
||||
};
|
||||
|
||||
size_t wxDisplayBase::GetCount()
|
||||
{
|
||||
GDHandle hndl;
|
||||
size_t num = 0;
|
||||
hndl = DMGetFirstScreenDevice(true);
|
||||
while(hndl)
|
||||
{
|
||||
num++;
|
||||
hndl = DMGetNextScreenDevice(hndl, true);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
int wxDisplayBase::GetFromPoint(const wxPoint &p)
|
||||
{
|
||||
GDHandle hndl;
|
||||
size_t num = 0;
|
||||
hndl = DMGetFirstScreenDevice(true);
|
||||
while(hndl)
|
||||
{
|
||||
Rect screenrect = (*hndl)->gdRect;
|
||||
if (p.x >= screenrect.left &&
|
||||
p.x <= screenrect.right &&
|
||||
p.y >= screenrect.top &&
|
||||
p.y <= screenrect.bottom)
|
||||
{
|
||||
return num;
|
||||
}
|
||||
num++;
|
||||
hndl = DMGetNextScreenDevice(hndl, true);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ),
|
||||
m_priv ( new wxDisplayMacPriv() )
|
||||
{
|
||||
GDHandle hndl;
|
||||
hndl = DMGetFirstScreenDevice(true);
|
||||
m_priv->m_hndl = NULL;
|
||||
while(hndl)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
m_priv->m_hndl = hndl;
|
||||
}
|
||||
index--;
|
||||
hndl = DMGetNextScreenDevice(hndl, true);
|
||||
}
|
||||
}
|
||||
|
||||
wxRect wxDisplay::GetGeometry() const
|
||||
{
|
||||
if (!(m_priv)) return wxRect(0, 0, 0, 0);
|
||||
if (!(m_priv->m_hndl)) return wxRect(0, 0, 0, 0);
|
||||
Rect screenrect = (*(m_priv->m_hndl))->gdRect;
|
||||
return wxRect( screenrect.left, screenrect.top,
|
||||
screenrect.right - screenrect.left, screenrect.bottom - screenrect.top);
|
||||
}
|
||||
|
||||
int wxDisplay::GetDepth() const
|
||||
{
|
||||
if (!(m_priv)) return 0;
|
||||
if (!(m_priv->m_hndl)) return 0;
|
||||
|
||||
// This cryptic looking code is based on Apple's sample code:
|
||||
// http://developer.apple.com/samplecode/Sample_Code/Graphics_2D/GDevVideo/Gen.cp.htm
|
||||
|
||||
//RN - according to the docs
|
||||
//gdPMap is a bitmap-type representation of the GDevice, and all
|
||||
//0x0000FFFF does is get the lower 16 bits of pixelSize. However,
|
||||
//since pixelSize is only 16 bits (a short)...
|
||||
return ((*(*(m_priv->m_hndl))->gdPMap)->pixelSize) & 0x0000FFFF;
|
||||
}
|
||||
|
||||
wxString wxDisplay::GetName() const
|
||||
{
|
||||
// Macs don't name their displays...
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
struct DMModeIteratorRec
|
||||
{
|
||||
wxArrayVideoModes* pModes;
|
||||
const wxVideoMode* pMatchMode;
|
||||
};
|
||||
|
||||
pascal void DMModeListIteratorProc ( void* pData,
|
||||
DMListIndexType nIndex,
|
||||
DMDisplayModeListEntryPtr pInfo)
|
||||
{
|
||||
DMModeIteratorRec* pInfoData = (DMModeIteratorRec*) pData;
|
||||
|
||||
//Note that in testing the refresh rate is always 0 on my ibook - RN
|
||||
int refresh = (int) Fix2Long(pInfo->displayModeResolutionInfo->csRefreshRate);
|
||||
|
||||
for(unsigned long i = 0; i < pInfo->displayModeDepthBlockInfo->depthBlockCount; ++i)
|
||||
{
|
||||
#define pDBI pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthVPBlock
|
||||
|
||||
if (wxVideoMode((int) pInfo->displayModeResolutionInfo->csHorizontalPixels,
|
||||
(int) pInfo->displayModeResolutionInfo->csVerticalLines,
|
||||
(int) pDBI->vpPixelSize,
|
||||
refresh).Matches(*pInfoData->pMatchMode) )
|
||||
{
|
||||
pInfoData->pModes->Add(wxVideoMode((int) pInfo->displayModeResolutionInfo->csHorizontalPixels,
|
||||
(int) pInfo->displayModeResolutionInfo->csVerticalLines,
|
||||
(int) pDBI->vpPixelSize,
|
||||
refresh));
|
||||
}
|
||||
#undef pDBI
|
||||
}
|
||||
}
|
||||
|
||||
struct DMModeInfoRec
|
||||
{
|
||||
const wxVideoMode* pMode;
|
||||
VDSwitchInfoRec sMode;
|
||||
bool bMatched;
|
||||
};
|
||||
|
||||
pascal void DMModeInfoProc ( void* pData,
|
||||
DMListIndexType nIndex,
|
||||
DMDisplayModeListEntryPtr pInfo)
|
||||
{
|
||||
DMModeInfoRec* pInfoData = (DMModeInfoRec*) pData;
|
||||
Fixed refresh = Long2Fix(pInfoData->pMode->refresh);
|
||||
|
||||
for(unsigned long i = 0; i < pInfo->displayModeDepthBlockInfo->depthBlockCount; ++i)
|
||||
{
|
||||
#define pDBI pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthVPBlock
|
||||
if (pInfoData->pMode->w == (int&) pInfo->displayModeResolutionInfo->csHorizontalPixels &&
|
||||
pInfoData->pMode->h == (int&) pInfo->displayModeResolutionInfo->csVerticalLines &&
|
||||
pInfoData->pMode->bpp == (int) pDBI->vpPixelSize &&
|
||||
refresh == pInfo->displayModeResolutionInfo->csRefreshRate)
|
||||
{
|
||||
memcpy(&pInfoData->sMode, pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthSwitchInfo,
|
||||
sizeof(VDSwitchInfoRec));
|
||||
pInfoData->sMode.csMode = pDBI->vpPixelSize;
|
||||
pInfoData->bMatched = true;
|
||||
break;
|
||||
}
|
||||
#undef pDBI
|
||||
}
|
||||
}
|
||||
|
||||
struct DMModeTransRec
|
||||
{
|
||||
wxVideoMode Mode;
|
||||
const VDSwitchInfoRec* psMode;
|
||||
bool bMatched;
|
||||
};
|
||||
|
||||
pascal void DMModeTransProc ( void* pData,
|
||||
DMListIndexType nIndex,
|
||||
DMDisplayModeListEntryPtr pInfo)
|
||||
{
|
||||
DMModeTransRec* pInfoData = (DMModeTransRec*) pData;
|
||||
|
||||
for(unsigned long i = 0; i < pInfo->displayModeDepthBlockInfo->depthBlockCount; ++i)
|
||||
{
|
||||
#define pDBI pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthVPBlock
|
||||
if (pInfoData->psMode->csData == pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthSwitchInfo->csData)
|
||||
{
|
||||
pInfoData->Mode = wxVideoMode((int) pInfo->displayModeResolutionInfo->csHorizontalPixels,
|
||||
(int) pInfo->displayModeResolutionInfo->csVerticalLines,
|
||||
(int) pDBI->vpPixelSize,
|
||||
(int) Fix2Long(pInfo->displayModeResolutionInfo->csRefreshRate) );
|
||||
pInfoData->bMatched = true;
|
||||
break;
|
||||
}
|
||||
#undef pDBI
|
||||
}
|
||||
}
|
||||
|
||||
wxArrayVideoModes
|
||||
wxDisplay::GetModes(const wxVideoMode& mode) const
|
||||
{
|
||||
|
||||
wxArrayVideoModes Modes;
|
||||
|
||||
unsigned long dwDMVer;
|
||||
Gestalt(gestaltDisplayMgrVers, (long*) &dwDMVer);
|
||||
|
||||
//Check DM version (for backward compatibility only - 7.5.3+ use 2.0)
|
||||
if (dwDMVer >= 0x020000) //version 2?
|
||||
{
|
||||
|
||||
DMListIndexType nNumModes;
|
||||
DMListType pModes;
|
||||
DMDisplayModeListIteratorUPP uppMLI;
|
||||
DisplayIDType nDisplayID;
|
||||
|
||||
wxASSERT(DMGetDisplayIDByGDevice(m_priv->m_hndl, &nDisplayID, false) == noErr);
|
||||
//Create a new list...
|
||||
wxASSERT_MSG(DMNewDisplayModeList(nDisplayID, NULL, NULL, &nNumModes, &pModes) == noErr, wxT("Could not create a new display mode list") );
|
||||
|
||||
uppMLI = NewDMDisplayModeListIteratorUPP(DMModeListIteratorProc);
|
||||
wxASSERT(uppMLI);
|
||||
|
||||
DMModeIteratorRec sModeInfo;
|
||||
sModeInfo.pModes = &Modes;
|
||||
sModeInfo.pMatchMode = &mode;
|
||||
for (DMListIndexType i = 0; i < nNumModes; ++i)
|
||||
{
|
||||
wxASSERT(DMGetIndexedDisplayModeFromList(pModes, i, NULL,
|
||||
uppMLI, &sModeInfo) == noErr);
|
||||
}
|
||||
DisposeDMDisplayModeListIteratorUPP(uppMLI);
|
||||
wxASSERT(DMDisposeList(pModes) == noErr);
|
||||
}
|
||||
else //DM 1.0, 1.2, 1.x
|
||||
{
|
||||
wxLogSysError(wxString::Format(wxT("Display Manager Version %u Not Supported! Present? %s"),
|
||||
(unsigned int) dwDMVer / 0x10000,
|
||||
(dwDMVer & (1 << gestaltDisplayMgrPresent) ? wxT("Yes") : wxT("No")) )
|
||||
);
|
||||
}
|
||||
|
||||
return Modes;
|
||||
}
|
||||
|
||||
wxVideoMode wxDisplay::GetCurrentMode() const
|
||||
{
|
||||
unsigned long dwDMVer;
|
||||
wxVideoMode RetMode;
|
||||
|
||||
Gestalt(gestaltDisplayMgrVers, (long*) &dwDMVer);
|
||||
//Check DM version (for backward compatibility only - 7.5.3+ use 2.0)
|
||||
if (dwDMVer >= 0x020000) //version 2?
|
||||
{
|
||||
VDSwitchInfoRec sMode; //Note - csMode member also contains the bit depth
|
||||
if (DMGetDisplayMode(m_priv->m_hndl, &sMode) == noErr)
|
||||
{
|
||||
DMListIndexType nNumModes;
|
||||
DMListType pModes;
|
||||
DMDisplayModeListIteratorUPP uppMLI;
|
||||
DisplayIDType nDisplayID;
|
||||
|
||||
wxASSERT(DMGetDisplayIDByGDevice(m_priv->m_hndl, &nDisplayID, false) == noErr);
|
||||
//Create a new list...
|
||||
wxASSERT_MSG(DMNewDisplayModeList(nDisplayID, NULL, NULL, &nNumModes, &pModes) == noErr,
|
||||
wxT("Could not create a new display mode list") );
|
||||
|
||||
uppMLI = NewDMDisplayModeListIteratorUPP(DMModeTransProc);
|
||||
wxASSERT(uppMLI);
|
||||
|
||||
DMModeTransRec sModeInfo;
|
||||
sModeInfo.bMatched = false;
|
||||
sModeInfo.psMode = &sMode;
|
||||
for (DMListIndexType i = 0; i < nNumModes; ++i)
|
||||
{
|
||||
wxASSERT(DMGetIndexedDisplayModeFromList(pModes, i, NULL,
|
||||
uppMLI, &sModeInfo) == noErr);
|
||||
|
||||
if ( sModeInfo.bMatched == true )
|
||||
{
|
||||
RetMode = sModeInfo.Mode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DisposeDMDisplayModeListIteratorUPP(uppMLI);
|
||||
wxASSERT(DMDisposeList(pModes) == noErr);
|
||||
}
|
||||
else //Can't get current mode?
|
||||
{
|
||||
wxLogSysError(wxString::Format(wxT("Couldn't obtain current display mode!!!\ndwDMVer:%u"),
|
||||
(unsigned int) dwDMVer));
|
||||
}
|
||||
}
|
||||
else //DM ver 1
|
||||
{
|
||||
wxLogSysError(wxString::Format(wxT("Display Manager Version %u Not Supported! Present? %s"),
|
||||
(unsigned int) dwDMVer / 0x10000,
|
||||
(dwDMVer & (1 << gestaltDisplayMgrPresent) ? wxT("Yes") : wxT("No")) )
|
||||
);
|
||||
}
|
||||
|
||||
return RetMode;
|
||||
}
|
||||
|
||||
bool wxDisplay::ChangeMode(const wxVideoMode& mode)
|
||||
{
|
||||
unsigned long dwDMVer;
|
||||
Gestalt(gestaltDisplayMgrVers, (long*)&dwDMVer);
|
||||
if (GetCount() == 1 || dwDMVer >= 0x020000)
|
||||
{
|
||||
if (mode == wxDefaultVideoMode)
|
||||
{
|
||||
//#ifndef __DARWIN__
|
||||
// Handle hDisplayState;
|
||||
// if (DMBeginConfigureDisplays(&hDisplayState) != noErr)
|
||||
// {
|
||||
// wxLogSysError(wxT("Could not lock display for display mode changing!"));
|
||||
// return false;
|
||||
// }
|
||||
// wxASSERT( DMUseScreenPrefs(true, hDisplayState) == noErr);
|
||||
// DMEndConfigureDisplays(hDisplayState);
|
||||
// return true;
|
||||
//#else
|
||||
//hmmmmm....
|
||||
return true;
|
||||
//#endif
|
||||
}
|
||||
|
||||
//0 & NULL for params 2 & 3 of DMSetVideoMode signal it to use defaults (current mode)
|
||||
//DM 2.0+ doesn't use params 2 & 3 of DMSetDisplayMode
|
||||
//so we have to use this icky structure
|
||||
VDSwitchInfoRec sMode;
|
||||
memset(&sMode, 0, sizeof(VDSwitchInfoRec) );
|
||||
|
||||
DMListIndexType nNumModes;
|
||||
DMListType pModes;
|
||||
DMDisplayModeListIteratorUPP uppMLI;
|
||||
DisplayIDType nDisplayID;
|
||||
|
||||
wxASSERT(DMGetDisplayIDByGDevice(m_priv->m_hndl, &nDisplayID, false) == noErr);
|
||||
//Create a new list...
|
||||
wxASSERT_MSG(DMNewDisplayModeList(nDisplayID, NULL, NULL, &nNumModes, &pModes) == noErr,
|
||||
wxT("Could not create a new display mode list") );
|
||||
|
||||
uppMLI = NewDMDisplayModeListIteratorUPP(DMModeInfoProc);
|
||||
wxASSERT(uppMLI);
|
||||
|
||||
DMModeInfoRec sModeInfo;
|
||||
sModeInfo.bMatched = false;
|
||||
sModeInfo.pMode = &mode;
|
||||
unsigned int i;
|
||||
for(i = 0; i < nNumModes; ++i)
|
||||
{
|
||||
wxASSERT(DMGetIndexedDisplayModeFromList(pModes, i, NULL,
|
||||
uppMLI, &sModeInfo) == noErr);
|
||||
if (sModeInfo.bMatched == true)
|
||||
{
|
||||
sMode = sModeInfo.sMode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == nNumModes)
|
||||
return false;
|
||||
|
||||
DisposeDMDisplayModeListIteratorUPP(uppMLI);
|
||||
wxASSERT(DMDisposeList(pModes) == noErr);
|
||||
|
||||
// For the really paranoid -
|
||||
// unsigned long flags;
|
||||
// Boolean bok;
|
||||
// wxASSERT(noErr == DMCheckDisplayMode(m_priv->m_hndl, sMode.csData,
|
||||
// sMode.csMode, &flags, NULL, &bok));
|
||||
// wxASSERT(bok);
|
||||
|
||||
Handle hDisplayState;
|
||||
if (DMBeginConfigureDisplays(&hDisplayState) != noErr)
|
||||
{
|
||||
wxLogSysError(wxT("Could not lock display for display mode changing!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned long dwBPP = (unsigned long) mode.bpp;
|
||||
if (DMSetDisplayMode(m_priv->m_hndl, sMode.csData,
|
||||
(unsigned long*) &(dwBPP), NULL
|
||||
//(unsigned long) &sMode
|
||||
, hDisplayState
|
||||
) != noErr)
|
||||
{
|
||||
DMEndConfigureDisplays(hDisplayState);
|
||||
wxMessageBox(wxString::Format(wxT("Could not set the display mode")));
|
||||
return false;
|
||||
}
|
||||
DMEndConfigureDisplays(hDisplayState);
|
||||
}
|
||||
else //DM 1.0, 1.2, 1.x
|
||||
{
|
||||
wxLogSysError(wxString::Format(wxT("Monitor gravitation not supported yet. dwDMVer:%u"),
|
||||
(unsigned int) dwDMVer));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxDisplay::~wxDisplay()
|
||||
{
|
||||
if ( m_priv )
|
||||
{
|
||||
delete m_priv;
|
||||
m_priv = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_DISPLAY
|
||||
607
src/mac/classic/dnd.cpp
Normal file
607
src/mac/classic/dnd.cpp
Normal file
File diff suppressed because it is too large
Load Diff
647
src/mac/classic/filedlg.cpp
Normal file
647
src/mac/classic/filedlg.cpp
Normal file
File diff suppressed because it is too large
Load Diff
446
src/mac/classic/font.cpp
Normal file
446
src/mac/classic/font.cpp
Normal file
@@ -0,0 +1,446 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: font.cpp
|
||||
// Purpose: wxFont class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "font.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/font.h"
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/utils.h"
|
||||
|
||||
#include "wx/fontutil.h"
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
#include <ATSUnicode.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
||||
{
|
||||
friend class WXDLLEXPORT wxFont;
|
||||
public:
|
||||
wxFontRefData()
|
||||
: m_fontId(0)
|
||||
, m_pointSize(10)
|
||||
, m_family(wxDEFAULT)
|
||||
, m_style(wxNORMAL)
|
||||
, m_weight(wxNORMAL)
|
||||
, m_underlined(FALSE)
|
||||
, m_faceName(wxT("Geneva"))
|
||||
, m_encoding(wxFONTENCODING_DEFAULT)
|
||||
, m_macFontNum(0)
|
||||
, m_macFontSize(0)
|
||||
, m_macFontStyle(0)
|
||||
, m_macATSUFontID()
|
||||
{
|
||||
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
|
||||
wxT("Geneva"), wxFONTENCODING_DEFAULT);
|
||||
}
|
||||
|
||||
wxFontRefData(const wxFontRefData& data)
|
||||
: wxGDIRefData()
|
||||
, m_fontId(data.m_fontId)
|
||||
, m_pointSize(data.m_pointSize)
|
||||
, m_family(data.m_family)
|
||||
, m_style(data.m_style)
|
||||
, m_weight(data.m_weight)
|
||||
, m_underlined(data.m_underlined)
|
||||
, m_faceName(data.m_faceName)
|
||||
, m_encoding(data.m_encoding)
|
||||
, m_macFontNum(data.m_macFontNum)
|
||||
, m_macFontSize(data.m_macFontSize)
|
||||
, m_macFontStyle(data.m_macFontStyle)
|
||||
, m_macATSUFontID(data.m_macATSUFontID)
|
||||
{
|
||||
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
||||
data.m_underlined, data.m_faceName, data.m_encoding);
|
||||
}
|
||||
|
||||
wxFontRefData(int size,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
: m_fontId(0)
|
||||
, m_pointSize(size)
|
||||
, m_family(family)
|
||||
, m_style(style)
|
||||
, m_weight(weight)
|
||||
, m_underlined(underlined)
|
||||
, m_faceName(faceName)
|
||||
, m_encoding(encoding)
|
||||
, m_macFontNum(0)
|
||||
, m_macFontSize(0)
|
||||
, m_macFontStyle(0)
|
||||
, m_macATSUFontID(0)
|
||||
{
|
||||
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||
}
|
||||
|
||||
virtual ~wxFontRefData();
|
||||
void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
|
||||
bool GetNoAntiAliasing() { return m_noAA; }
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init(int size,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding);
|
||||
|
||||
// font characterstics
|
||||
int m_fontId;
|
||||
int m_pointSize;
|
||||
int m_family;
|
||||
int m_style;
|
||||
int m_weight;
|
||||
bool m_underlined;
|
||||
wxString m_faceName;
|
||||
wxFontEncoding m_encoding;
|
||||
bool m_noAA; // No anti-aliasing
|
||||
|
||||
public:
|
||||
short m_macFontNum;
|
||||
short m_macFontSize;
|
||||
unsigned char m_macFontStyle;
|
||||
wxUint32 m_macATSUFontID;
|
||||
|
||||
wxNativeFontInfo m_info;
|
||||
|
||||
public:
|
||||
void MacFindFont() ;
|
||||
};
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontRefData::Init(int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
m_style = style;
|
||||
m_pointSize = pointSize;
|
||||
m_family = family;
|
||||
m_style = style;
|
||||
m_weight = weight;
|
||||
m_underlined = underlined;
|
||||
m_faceName = faceName;
|
||||
m_encoding = encoding;
|
||||
|
||||
m_macFontNum = 0 ;
|
||||
m_macFontSize = 0;
|
||||
m_macFontStyle = 0;
|
||||
m_fontId = 0;
|
||||
m_noAA = FALSE;
|
||||
}
|
||||
|
||||
wxFontRefData::~wxFontRefData()
|
||||
{
|
||||
}
|
||||
|
||||
void wxFontRefData::MacFindFont()
|
||||
{
|
||||
if( m_faceName.Length() == 0 )
|
||||
{
|
||||
switch( m_family )
|
||||
{
|
||||
case wxDEFAULT :
|
||||
m_macFontNum = ::GetAppFont() ;
|
||||
break ;
|
||||
case wxDECORATIVE :
|
||||
::GetFNum( "\pTimes" , &m_macFontNum) ;
|
||||
break ;
|
||||
case wxROMAN :
|
||||
::GetFNum( "\pTimes" , &m_macFontNum) ;
|
||||
break ;
|
||||
case wxSCRIPT :
|
||||
::GetFNum( "\pTimes" , &m_macFontNum) ;
|
||||
break ;
|
||||
case wxSWISS :
|
||||
::GetFNum( "\pGeneva" , &m_macFontNum) ;
|
||||
break ;
|
||||
case wxMODERN :
|
||||
::GetFNum( "\pMonaco" , &m_macFontNum) ;
|
||||
break ;
|
||||
}
|
||||
Str255 name ;
|
||||
GetFontName( m_macFontNum , name ) ;
|
||||
m_faceName = wxMacMakeStringFromPascal( name ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_faceName == wxT("systemfont") )
|
||||
m_macFontNum = ::GetSysFont() ;
|
||||
else if ( m_faceName == wxT("applicationfont") )
|
||||
m_macFontNum = ::GetAppFont() ;
|
||||
else
|
||||
{
|
||||
Str255 fontname ;
|
||||
wxMacStringToPascal( m_faceName , fontname ) ;
|
||||
::GetFNum( fontname, &m_macFontNum);
|
||||
}
|
||||
}
|
||||
|
||||
m_macFontStyle = 0;
|
||||
if (m_weight == wxBOLD)
|
||||
m_macFontStyle |= bold;
|
||||
if (m_style == wxITALIC || m_style == wxSLANT)
|
||||
m_macFontStyle |= italic;
|
||||
if (m_underlined)
|
||||
m_macFontStyle |= underline;
|
||||
m_macFontSize = m_pointSize ;
|
||||
|
||||
//TODO:if we supply the style as an additional parameter we must make a testing
|
||||
//sequence in order to degrade gracefully while trying to maintain most of the style
|
||||
//information, meanwhile we just take the normal font and apply the features after
|
||||
#ifdef __WXDEBUG__
|
||||
OSStatus status =
|
||||
#endif // __WXDEBUG__
|
||||
::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID);
|
||||
/*
|
||||
status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) ,
|
||||
kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ;
|
||||
*/
|
||||
wxASSERT_MSG( status == noErr , wxT("couldn't retrieve font identifier") ) ;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFont
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::Init()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxFont::Create(const wxNativeFontInfo& info)
|
||||
{
|
||||
return Create(info.pointSize, info.family, info.style, info.weight,
|
||||
info.underlined, info.faceName, info.encoding);
|
||||
}
|
||||
|
||||
wxFont::wxFont(const wxString& fontdesc)
|
||||
{
|
||||
wxNativeFontInfo info;
|
||||
if ( info.FromString(fontdesc) )
|
||||
(void)Create(info);
|
||||
}
|
||||
|
||||
bool wxFont::Create(int pointSize,
|
||||
int family,
|
||||
int style,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
UnRef();
|
||||
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||
underlined, faceName, encoding);
|
||||
|
||||
RealizeResource();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxFont::~wxFont()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxFont::RealizeResource()
|
||||
{
|
||||
M_FONTDATA->MacFindFont() ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxFont::SetEncoding(wxFontEncoding encoding)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->m_encoding = encoding;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::Unshare()
|
||||
{
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
{
|
||||
m_refData = new wxFontRefData();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
}
|
||||
|
||||
void wxFont::SetPointSize(int pointSize)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->m_pointSize = pointSize;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetFamily(int family)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->m_family = family;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetStyle(int style)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->m_style = style;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(int weight)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->m_weight = weight;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetFaceName(const wxString& faceName)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->m_faceName = faceName;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetUnderlined(bool underlined)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->m_underlined = underlined;
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetNoAntiAliasing( bool no )
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->SetNoAntiAliasing( no );
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// TODO: insert checks everywhere for M_FONTDATA == NULL!
|
||||
|
||||
int wxFont::GetPointSize() const
|
||||
{
|
||||
return M_FONTDATA->m_pointSize;
|
||||
}
|
||||
|
||||
int wxFont::GetFamily() const
|
||||
{
|
||||
return M_FONTDATA->m_family;
|
||||
}
|
||||
|
||||
int wxFont::GetStyle() const
|
||||
{
|
||||
return M_FONTDATA->m_style;
|
||||
}
|
||||
|
||||
int wxFont::GetWeight() const
|
||||
{
|
||||
return M_FONTDATA->m_weight;
|
||||
}
|
||||
|
||||
bool wxFont::GetUnderlined() const
|
||||
{
|
||||
return M_FONTDATA->m_underlined;
|
||||
}
|
||||
|
||||
wxString wxFont::GetFaceName() const
|
||||
{
|
||||
wxString str;
|
||||
if ( M_FONTDATA )
|
||||
str = M_FONTDATA->m_faceName ;
|
||||
return str;
|
||||
}
|
||||
|
||||
wxFontEncoding wxFont::GetEncoding() const
|
||||
{
|
||||
return M_FONTDATA->m_encoding;
|
||||
}
|
||||
|
||||
bool wxFont::GetNoAntiAliasing()
|
||||
{
|
||||
return M_FONTDATA->m_noAA;
|
||||
}
|
||||
|
||||
short wxFont::GetMacFontNum() const
|
||||
{
|
||||
return M_FONTDATA->m_macFontNum;
|
||||
}
|
||||
|
||||
short wxFont::GetMacFontSize() const
|
||||
{
|
||||
return M_FONTDATA->m_macFontSize;
|
||||
}
|
||||
|
||||
wxByte wxFont::GetMacFontStyle() const
|
||||
{
|
||||
return M_FONTDATA->m_macFontStyle;
|
||||
}
|
||||
|
||||
wxUint32 wxFont::GetMacATSUFontID() const
|
||||
{
|
||||
return M_FONTDATA->m_macATSUFontID;
|
||||
}
|
||||
|
||||
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||
{
|
||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
|
||||
|
||||
M_FONTDATA->m_info.InitFromFont(*this);
|
||||
|
||||
return &(M_FONTDATA->m_info);
|
||||
}
|
||||
|
||||
54
src/mac/classic/fontdlg.cpp
Normal file
54
src/mac/classic/fontdlg.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: fontdlg.cpp
|
||||
// Purpose: wxFontDialog class. NOTE: you can use the generic class
|
||||
// if you wish, instead of implementing this.
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "fontdlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/mac/fontdlg.h"
|
||||
#include "wx/cmndata.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* wxFontDialog
|
||||
*/
|
||||
|
||||
wxFontDialog::wxFontDialog()
|
||||
{
|
||||
m_dialogParent = NULL;
|
||||
}
|
||||
|
||||
wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& data)
|
||||
{
|
||||
Create(parent, data);
|
||||
}
|
||||
|
||||
bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data)
|
||||
{
|
||||
m_dialogParent = parent;
|
||||
|
||||
m_fontData = data;
|
||||
|
||||
// TODO: you may need to do dialog creation here, unless it's
|
||||
// done in ShowModal.
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int wxFontDialog::ShowModal()
|
||||
{
|
||||
// TODO: show (maybe create) the dialog
|
||||
return wxID_CANCEL;
|
||||
}
|
||||
|
||||
173
src/mac/classic/fontenum.cpp
Normal file
173
src/mac/classic/fontenum.cpp
Normal file
@@ -0,0 +1,173 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mac/fontenum.cpp
|
||||
// Purpose: wxFontEnumerator class for MacOS
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "fontenum.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/font.h"
|
||||
#endif
|
||||
|
||||
#include "wx/fontenum.h"
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/fontmap.h"
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/encinfo.h"
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxFontEnumeratorHelper
|
||||
{
|
||||
public:
|
||||
wxFontEnumeratorHelper(wxFontEnumerator *fontEnum);
|
||||
|
||||
// control what exactly are we enumerating
|
||||
bool SetEncoding(wxFontEncoding encoding);
|
||||
void SetFixedOnly(bool fixedOnly)
|
||||
{ m_fixedOnly = fixedOnly; }
|
||||
|
||||
// call to start enumeration
|
||||
void DoEnumerate();
|
||||
|
||||
private:
|
||||
// the object we forward calls to OnFont() to
|
||||
wxFontEnumerator *m_fontEnum;
|
||||
|
||||
// if != -1, enum only fonts which have this encoding
|
||||
int m_charset;
|
||||
|
||||
// if not empty, enum only the fonts with this facename
|
||||
wxString m_facename;
|
||||
|
||||
// if TRUE, enum only fixed fonts
|
||||
bool m_fixedOnly;
|
||||
};
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontEnumeratorHelper
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator *fontEnum)
|
||||
{
|
||||
m_fontEnum = fontEnum;
|
||||
m_charset = -1;
|
||||
m_fixedOnly = FALSE;
|
||||
}
|
||||
|
||||
bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding)
|
||||
{
|
||||
wxNativeEncodingInfo info;
|
||||
if ( !wxGetNativeFontEncoding(encoding, &info) )
|
||||
{
|
||||
if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
|
||||
{
|
||||
// no such encodings at all
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
m_charset = info.charset;
|
||||
m_facename = info.facename;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxFontEnumeratorHelper::DoEnumerate()
|
||||
{
|
||||
MenuHandle menu ;
|
||||
Str255 p_name ;
|
||||
|
||||
short lines ;
|
||||
|
||||
menu = NewMenu( 32000 , "\pFont" ) ;
|
||||
AppendResMenu( menu , 'FONT' ) ;
|
||||
lines = CountMenuItems( menu ) ;
|
||||
|
||||
for ( int i = 1 ; i < lines+1 ; i ++ )
|
||||
{
|
||||
GetMenuItemText( menu , i , p_name ) ;
|
||||
wxString c_name = wxMacMakeStringFromPascal(p_name) ;
|
||||
|
||||
/*
|
||||
|
||||
if ( m_fixedOnly )
|
||||
{
|
||||
// check that it's a fixed pitch font (there is *no* error here, the
|
||||
// flag name is misleading!)
|
||||
if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
|
||||
{
|
||||
// not a fixed pitch font
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_charset != -1 )
|
||||
{
|
||||
// check that we have the right encoding
|
||||
if ( lf->lfCharSet != m_charset )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
m_fontEnum->OnFacename( c_name ) ;
|
||||
}
|
||||
DisposeMenu( menu ) ;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontEnumerator
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
|
||||
bool fixedWidthOnly)
|
||||
{
|
||||
wxFontEnumeratorHelper fe(this);
|
||||
if ( fe.SetEncoding(encoding) )
|
||||
{
|
||||
fe.SetFixedOnly(fixedWidthOnly);
|
||||
|
||||
fe.DoEnumerate();
|
||||
}
|
||||
// else: no such fonts, unknown encoding
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
|
||||
{
|
||||
wxFAIL_MSG(wxT("wxFontEnumerator::EnumerateEncodings() not yet implemented"));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
117
src/mac/classic/fontutil.cpp
Normal file
117
src/mac/classic/fontutil.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: msw/fontutil.cpp
|
||||
// Purpose: font-related helper functions for wxMSW
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 05.11.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "fontutil.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/string.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/intl.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/fontmap.h"
|
||||
#include "wx/encinfo.h"
|
||||
|
||||
#include "wx/tokenzr.h"
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxNativeEncodingInfo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// convert to/from the string representation: format is
|
||||
// facename[;charset]
|
||||
|
||||
bool wxNativeEncodingInfo::FromString(const wxString& s)
|
||||
{
|
||||
wxStringTokenizer tokenizer(s, _T(";"));
|
||||
|
||||
facename = tokenizer.GetNextToken();
|
||||
if ( !facename )
|
||||
return FALSE;
|
||||
|
||||
wxString tmp = tokenizer.GetNextToken();
|
||||
if ( !tmp )
|
||||
{
|
||||
// default charset (don't use DEFAULT_CHARSET though because of subtle
|
||||
// Windows 9x/NT differences in handling it)
|
||||
charset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
|
||||
{
|
||||
// should be a number!
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxString wxNativeEncodingInfo::ToString() const
|
||||
{
|
||||
wxString s(facename);
|
||||
if ( charset != 0 )
|
||||
{
|
||||
s << _T(';') << charset;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helper functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxGetNativeFontEncoding(wxFontEncoding encoding,
|
||||
wxNativeEncodingInfo *info)
|
||||
{
|
||||
wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
|
||||
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
encoding = wxFont::GetDefaultEncoding();
|
||||
}
|
||||
|
||||
info->encoding = encoding ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
|
||||
{
|
||||
// basically we should be able to support every encoding via the OS
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
338
src/mac/classic/frame.cpp
Normal file
338
src/mac/classic/frame.cpp
Normal file
@@ -0,0 +1,338 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: frame.cpp
|
||||
// Purpose: wxFrame
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "frame.h"
|
||||
#endif
|
||||
|
||||
#include "wx/frame.h"
|
||||
#include "wx/statusbr.h"
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/menuitem.h"
|
||||
#include "wx/menu.h"
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/app.h"
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
extern wxWindowList wxModelessWindows;
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
|
||||
EVT_ACTIVATE(wxFrame::OnActivate)
|
||||
// EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
|
||||
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
|
||||
// EVT_IDLE(wxFrame::OnIdle)
|
||||
// EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
|
||||
#endif
|
||||
|
||||
#define WX_MAC_STATUSBAR_HEIGHT 15
|
||||
// ----------------------------------------------------------------------------
|
||||
// creation/destruction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
m_hwndToolTip = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxPoint wxFrame::GetClientAreaOrigin() const
|
||||
{
|
||||
// on mac we are at position -1,-1 with the control
|
||||
wxPoint pt(0, 0);
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
if ( GetToolBar() )
|
||||
{
|
||||
int w, h;
|
||||
GetToolBar()->GetSize(& w, & h);
|
||||
|
||||
if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
|
||||
{
|
||||
pt.x += w - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.y += h - 1 ;
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
bool wxFrame::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
|
||||
|
||||
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
|
||||
return FALSE;
|
||||
|
||||
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
|
||||
|
||||
m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
|
||||
SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
m_isBeingDeleted = TRUE;
|
||||
DeleteAllBars();
|
||||
}
|
||||
|
||||
|
||||
bool wxFrame::Enable(bool enable)
|
||||
{
|
||||
if ( !wxWindow::Enable(enable) )
|
||||
return FALSE;
|
||||
|
||||
if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() )
|
||||
{
|
||||
int iMaxMenu = m_frameMenuBar->GetMenuCount();
|
||||
for ( int i = 0 ; i < iMaxMenu ; ++ i )
|
||||
{
|
||||
m_frameMenuBar->EnableTop( i , enable ) ;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
|
||||
const wxString& name)
|
||||
{
|
||||
wxStatusBar *statusBar = NULL;
|
||||
|
||||
statusBar = new wxStatusBar(this, id,
|
||||
style, name);
|
||||
statusBar->SetSize( 100 , 15 ) ;
|
||||
statusBar->SetFieldsCount(number);
|
||||
return statusBar;
|
||||
}
|
||||
|
||||
void wxFrame::PositionStatusBar()
|
||||
{
|
||||
if (m_frameStatusBar )
|
||||
{
|
||||
int w, h;
|
||||
GetClientSize(&w, &h);
|
||||
int sw, sh;
|
||||
m_frameStatusBar->GetSize(&sw, &sh);
|
||||
|
||||
// Since we wish the status bar to be directly under the client area,
|
||||
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
|
||||
m_frameStatusBar->SetSize(0, h, w, sh);
|
||||
}
|
||||
}
|
||||
|
||||
// Responds to colour changes, and passes event on to children.
|
||||
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
|
||||
Refresh();
|
||||
|
||||
if ( m_frameStatusBar )
|
||||
{
|
||||
wxSysColourChangedEvent event2;
|
||||
event2.SetEventObject( m_frameStatusBar );
|
||||
m_frameStatusBar->ProcessEvent(event2);
|
||||
}
|
||||
|
||||
// Propagate the event to the non-top-level children
|
||||
wxWindow::OnSysColourChanged(event);
|
||||
}
|
||||
|
||||
|
||||
// Default activation behaviour - set the focus for the first child
|
||||
// subwindow found.
|
||||
void wxFrame::OnActivate(wxActivateEvent& event)
|
||||
{
|
||||
if ( !event.GetActive() )
|
||||
{
|
||||
// remember the last focused child if it is our child
|
||||
m_winLastFocused = FindFocus();
|
||||
|
||||
// so we NULL it out if it's a child from some other frame
|
||||
wxWindow *win = m_winLastFocused;
|
||||
while ( win )
|
||||
{
|
||||
if ( win->IsTopLevel() )
|
||||
{
|
||||
if ( win != this )
|
||||
{
|
||||
m_winLastFocused = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
win = win->GetParent();
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
else
|
||||
{
|
||||
// restore focus to the child which was last focused
|
||||
wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
|
||||
: NULL;
|
||||
if ( !parent )
|
||||
{
|
||||
parent = this;
|
||||
}
|
||||
|
||||
wxSetFocusToChild(parent, &m_winLastFocused);
|
||||
|
||||
if ( m_frameMenuBar != NULL )
|
||||
{
|
||||
m_frameMenuBar->MacInstallMenuBar() ;
|
||||
}
|
||||
else if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame)))
|
||||
{
|
||||
// Trying toplevel frame menbar
|
||||
if( ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar() )
|
||||
((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar()->MacInstallMenuBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxFrame::DetachMenuBar()
|
||||
{
|
||||
if ( m_frameMenuBar )
|
||||
{
|
||||
m_frameMenuBar->UnsetInvokingWindow();
|
||||
}
|
||||
|
||||
wxFrameBase::DetachMenuBar();
|
||||
}
|
||||
|
||||
void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
|
||||
{
|
||||
wxFrameBase::AttachMenuBar(menuBar);
|
||||
|
||||
if (m_frameMenuBar)
|
||||
{
|
||||
m_frameMenuBar->SetInvokingWindow( this );
|
||||
}
|
||||
}
|
||||
|
||||
void wxFrame::DoGetClientSize(int *x, int *y) const
|
||||
{
|
||||
wxWindow::DoGetClientSize( x , y ) ;
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
if ( GetStatusBar() && y )
|
||||
{
|
||||
int statusX, statusY;
|
||||
GetStatusBar()->GetClientSize(&statusX, &statusY);
|
||||
*y -= statusY;
|
||||
}
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
wxPoint pt(GetClientAreaOrigin());
|
||||
if ( y )
|
||||
*y -= pt.y;
|
||||
if ( x )
|
||||
*x -= pt.x;
|
||||
}
|
||||
|
||||
void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
|
||||
{
|
||||
int currentclientwidth , currentclientheight ;
|
||||
int currentwidth , currentheight ;
|
||||
|
||||
GetClientSize( ¤tclientwidth , ¤tclientheight ) ;
|
||||
GetSize( ¤twidth , ¤theight ) ;
|
||||
|
||||
// find the current client size
|
||||
|
||||
// Find the difference between the entire window (title bar and all)
|
||||
// and the client area; add this to the new client size to move the
|
||||
// window
|
||||
|
||||
DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth ,
|
||||
currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ;
|
||||
}
|
||||
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
|
||||
{
|
||||
if ( wxFrameBase::CreateToolBar(style, id, name) )
|
||||
{
|
||||
PositionToolBar();
|
||||
}
|
||||
|
||||
return m_frameToolBar;
|
||||
}
|
||||
|
||||
void wxFrame::PositionToolBar()
|
||||
{
|
||||
int cw, ch;
|
||||
|
||||
cw = m_width ;
|
||||
ch = m_height ;
|
||||
|
||||
if ( GetStatusBar() )
|
||||
{
|
||||
int statusX, statusY;
|
||||
GetStatusBar()->GetClientSize(&statusX, &statusY);
|
||||
ch -= statusY;
|
||||
}
|
||||
|
||||
if (GetToolBar())
|
||||
{
|
||||
int tw, th;
|
||||
GetToolBar()->GetSize(& tw, & th);
|
||||
|
||||
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
|
||||
{
|
||||
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
|
||||
// means, pretend we don't have toolbar/status bar, so we
|
||||
// have the original client size.
|
||||
GetToolBar()->SetSize(-1, -1, tw, ch + 2 , wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the 'real' position
|
||||
GetToolBar()->SetSize(-1, -1, cw + 2, th, wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
95
src/mac/classic/gauge.cpp
Normal file
95
src/mac/classic/gauge.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: gauge.cpp
|
||||
// Purpose: wxGauge class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "gauge.h"
|
||||
#endif
|
||||
|
||||
#include "wx/gauge.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
|
||||
#endif
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
bool wxGauge::Create(wxWindow *parent, wxWindowID id,
|
||||
int range,
|
||||
const wxPoint& pos,
|
||||
const wxSize& s,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !wxGaugeBase::Create(parent, id, range, pos, s, style, validator, name) )
|
||||
return false;
|
||||
|
||||
wxSize size = s ;
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_rangeMax = range ;
|
||||
m_gaugePos = 0 ;
|
||||
|
||||
if ( size.x == wxDefaultSize.x && size.y == wxDefaultSize.y)
|
||||
{
|
||||
size = wxSize( 200 , 16 ) ;
|
||||
}
|
||||
|
||||
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ;
|
||||
|
||||
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range,
|
||||
kControlProgressBarProc , (long) this ) ;
|
||||
|
||||
MacPostControlCreate() ;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxGauge::SetShadowWidth(int w)
|
||||
{
|
||||
}
|
||||
|
||||
void wxGauge::SetBezelFace(int w)
|
||||
{
|
||||
}
|
||||
|
||||
void wxGauge::SetRange(int r)
|
||||
{
|
||||
m_rangeMax = r;
|
||||
::SetControl32BitMaximum( (ControlHandle) m_macControl , m_rangeMax ) ;
|
||||
}
|
||||
|
||||
void wxGauge::SetValue(int pos)
|
||||
{
|
||||
m_gaugePos = pos;
|
||||
::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ;
|
||||
}
|
||||
|
||||
int wxGauge::GetShadowWidth() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxGauge::GetBezelFace() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxGauge::GetRange() const
|
||||
{
|
||||
return m_rangeMax;
|
||||
}
|
||||
|
||||
int wxGauge::GetValue() const
|
||||
{
|
||||
return m_gaugePos;
|
||||
}
|
||||
|
||||
22
src/mac/classic/gdiobj.cpp
Normal file
22
src/mac/classic/gdiobj.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: gdiobj.cpp
|
||||
// Purpose: wxGDIObject class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "gdiobj.h"
|
||||
#endif
|
||||
|
||||
#include "wx/gdiobj.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
|
||||
#endif
|
||||
|
||||
// TODO: Nothing to do, unless you want to.
|
||||
385
src/mac/classic/glcanvas.cpp
Normal file
385
src/mac/classic/glcanvas.cpp
Normal file
@@ -0,0 +1,385 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: glcanvas.cpp
|
||||
// Purpose: wxGLCanvas, for using OpenGL with wxWindows under Macintosh
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// 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"
|
||||
|
||||
// DLL options compatibility check:
|
||||
#include "wx/build.h"
|
||||
WX_CHECK_BUILD_OPTIONS("wxGL")
|
||||
|
||||
/*
|
||||
* 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(MAC_WXHWND(win->MacGetRootWindow()));
|
||||
|
||||
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 wxChar *colour)
|
||||
{
|
||||
wxColour col = wxTheColourDatabase->Find(colour);
|
||||
if (col.Ok())
|
||||
{
|
||||
float r = (float)(col.Red()/256.0);
|
||||
float g = (float)(col.Green()/256.0);
|
||||
float b = (float)(col.Blue()/256.0);
|
||||
glColor3f( r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* wxGLCanvas implementation
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow)
|
||||
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 != NULL) {
|
||||
delete m_glContext;
|
||||
m_glContext = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static AGLPixelFormat ChoosePixelFormat(const int *attribList)
|
||||
{
|
||||
GLint data[512];
|
||||
GLint defaultAttribs[] = { 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 = defaultAttribs;
|
||||
}
|
||||
else
|
||||
{
|
||||
int 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 = data;
|
||||
}
|
||||
|
||||
return aglChoosePixelFormat(NULL, 0, attribs);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
wxWindow::Create( parent, id, pos, size, style, name );
|
||||
|
||||
AGLPixelFormat fmt = ChoosePixelFormat(attribList);
|
||||
wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") );
|
||||
|
||||
m_glContext = new wxGLContext(fmt, this, palette, shared);
|
||||
m_macCanvasIsShown = true ;
|
||||
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 ;
|
||||
|
||||
wxWindow* iter = this ;
|
||||
while( iter->GetParent() )
|
||||
{
|
||||
iter = iter->GetParent() ;
|
||||
}
|
||||
|
||||
if ( iter && iter->IsTopLevel() )
|
||||
{
|
||||
MacClientToRootWindow( &x , &y ) ;
|
||||
int width, height;
|
||||
GetClientSize(& width, & height);
|
||||
Rect bounds ;
|
||||
GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ;
|
||||
GLint parms[4] ;
|
||||
parms[0] = x ;
|
||||
parms[1] = bounds.bottom - bounds.top - ( y + height ) ;
|
||||
parms[2] = width ;
|
||||
parms[3] = height ;
|
||||
|
||||
if ( !m_macCanvasIsShown )
|
||||
parms[0] += 20000 ;
|
||||
aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLCanvas::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
MacUpdateView() ;
|
||||
}
|
||||
|
||||
void wxGLCanvas::MacUpdateView()
|
||||
{
|
||||
if (m_glContext)
|
||||
{
|
||||
UpdateContext();
|
||||
m_glContext->SetCurrent();
|
||||
SetViewport();
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLCanvas::MacSuperChangedPosition()
|
||||
{
|
||||
MacUpdateView() ;
|
||||
wxWindow::MacSuperChangedPosition() ;
|
||||
}
|
||||
|
||||
void wxGLCanvas::MacTopLevelWindowChangedPosition()
|
||||
{
|
||||
MacUpdateView() ;
|
||||
wxWindow::MacTopLevelWindowChangedPosition() ;
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetCurrent()
|
||||
{
|
||||
if (m_glContext)
|
||||
{
|
||||
m_glContext->SetCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
void wxGLCanvas::SetColour(const wxChar *colour)
|
||||
{
|
||||
if (m_glContext)
|
||||
m_glContext->SetColour(colour);
|
||||
}
|
||||
|
||||
bool wxGLCanvas::Show(bool show)
|
||||
{
|
||||
if ( !wxWindow::Show( show ) )
|
||||
return FALSE ;
|
||||
|
||||
if ( !show )
|
||||
{
|
||||
if ( m_macCanvasIsShown )
|
||||
{
|
||||
m_macCanvasIsShown = false ;
|
||||
SetViewport() ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( MacIsReallyShown() && !m_macCanvasIsShown )
|
||||
{
|
||||
m_macCanvasIsShown = true ;
|
||||
SetViewport() ;
|
||||
}
|
||||
}
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
void wxGLCanvas::MacSuperShown( bool show )
|
||||
{
|
||||
if ( !show )
|
||||
{
|
||||
if ( m_macCanvasIsShown )
|
||||
{
|
||||
m_macCanvasIsShown = false ;
|
||||
SetViewport() ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( MacIsReallyShown() && !m_macCanvasIsShown )
|
||||
{
|
||||
m_macCanvasIsShown = true ;
|
||||
SetViewport() ;
|
||||
}
|
||||
}
|
||||
|
||||
wxWindow::MacSuperShown( show ) ;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxGLApp
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxGLApp, wxApp)
|
||||
|
||||
bool wxGLApp::InitGLVisual(int *attribList)
|
||||
{
|
||||
AGLPixelFormat fmt = ChoosePixelFormat(attribList);
|
||||
if (fmt != NULL) {
|
||||
aglDestroyPixelFormat(fmt);
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
wxGLApp::~wxGLApp(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif // wxUSE_GLCANVAS
|
||||
1653
src/mac/classic/gsocket.c
Normal file
1653
src/mac/classic/gsocket.c
Normal file
File diff suppressed because it is too large
Load Diff
181
src/mac/classic/gsockosx.c
Normal file
181
src/mac/classic/gsockosx.c
Normal file
@@ -0,0 +1,181 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Project: GSocket (Generic Socket) for WX
|
||||
* Name: gsockosx.c
|
||||
* Purpose: GSocket: Mac OS X mach-o part
|
||||
* CVSID: $Id$
|
||||
* Mac code by Brian Victor, February 2002. Email comments to bhv1@psu.edu
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#if wxUSE_SOCKETS
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "wx/gsocket.h"
|
||||
#include "wx/unix/gsockunx.h"
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#define ALL_CALLBACK_TYPES (kCFSocketReadCallBack | kCFSocketWriteCallBack | kCFSocketConnectCallBack)
|
||||
|
||||
struct MacGSocketData
|
||||
{
|
||||
CFSocketRef socket;
|
||||
CFRunLoopSourceRef source;
|
||||
};
|
||||
|
||||
void Mac_Socket_Callback(CFSocketRef s, CFSocketCallBackType callbackType,
|
||||
CFDataRef address, const void* data, void* info)
|
||||
{
|
||||
GSocket* socket = (GSocket*)info;
|
||||
struct MacGSocketData* macdata;
|
||||
macdata = (struct MacGSocketData*)socket->m_gui_dependent;
|
||||
if (!macdata) return;
|
||||
switch (callbackType)
|
||||
{
|
||||
case kCFSocketConnectCallBack:
|
||||
assert(!socket->m_server);
|
||||
socket->m_functions->Detected_Write(socket);
|
||||
break;
|
||||
case kCFSocketReadCallBack:
|
||||
socket->m_functions->Detected_Read(socket);
|
||||
break;
|
||||
case kCFSocketWriteCallBack:
|
||||
socket->m_functions->Detected_Write(socket);
|
||||
break;
|
||||
default:
|
||||
break; /* We shouldn't get here. */
|
||||
}
|
||||
}
|
||||
|
||||
struct MacGSocketData* _GSocket_Get_Mac_Socket(GSocket *socket)
|
||||
{
|
||||
/* If socket is already created, returns a pointer to the data */
|
||||
/* Otherwise, creates socket and returns the pointer */
|
||||
CFSocketContext cont;
|
||||
struct MacGSocketData* data = (struct MacGSocketData*)socket->m_gui_dependent;
|
||||
|
||||
if (data && data->source) return data;
|
||||
|
||||
/* CFSocket has not been created, create it: */
|
||||
if (socket->m_fd < 0 || !data) return NULL;
|
||||
cont.version = 0; cont.retain = NULL;
|
||||
cont.release = NULL; cont.copyDescription = NULL;
|
||||
cont.info = socket;
|
||||
|
||||
CFSocketRef cf = CFSocketCreateWithNative(NULL, socket->m_fd,
|
||||
ALL_CALLBACK_TYPES, Mac_Socket_Callback, &cont);
|
||||
CFRunLoopSourceRef source = CFSocketCreateRunLoopSource(NULL, cf, 0);
|
||||
assert(source);
|
||||
socket->m_gui_dependent = (char*)data;
|
||||
|
||||
/* Keep the source and the socket around. */
|
||||
data->source = source;
|
||||
data->socket = cf;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
int _GSocket_GUI_Init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void _GSocket_GUI_Cleanup(void)
|
||||
{
|
||||
}
|
||||
|
||||
int _GSocket_GUI_Init_Socket(GSocket *socket)
|
||||
{
|
||||
struct MacGSocketData *data = malloc(sizeof(struct MacGSocketData));
|
||||
if (data)
|
||||
{
|
||||
socket->m_gui_dependent = (char*)data;
|
||||
data->socket = NULL;
|
||||
data->source = NULL;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _GSocket_GUI_Destroy_Socket(GSocket *socket)
|
||||
{
|
||||
struct MacGSocketData *data = (struct MacGSocketData*)(socket->m_gui_dependent);
|
||||
if (data)
|
||||
{
|
||||
CFRelease(data->socket);
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
||||
void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event)
|
||||
{
|
||||
int c;
|
||||
struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
|
||||
if (!data) return;
|
||||
switch (event)
|
||||
{
|
||||
case GSOCK_CONNECTION:
|
||||
if(socket->m_server)
|
||||
c = kCFSocketReadCallBack;
|
||||
else
|
||||
c = kCFSocketConnectCallBack;
|
||||
break;
|
||||
case GSOCK_LOST:
|
||||
case GSOCK_INPUT:
|
||||
c = kCFSocketReadCallBack;
|
||||
break;
|
||||
case GSOCK_OUTPUT:
|
||||
c = kCFSocketWriteCallBack;
|
||||
break;
|
||||
default:
|
||||
c = 0;
|
||||
}
|
||||
CFSocketEnableCallBacks(data->socket, c);
|
||||
}
|
||||
|
||||
void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event)
|
||||
{
|
||||
int c;
|
||||
struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
|
||||
if (!data) return;
|
||||
switch (event)
|
||||
{
|
||||
case GSOCK_CONNECTION:
|
||||
if(socket->m_server)
|
||||
c = kCFSocketReadCallBack;
|
||||
else
|
||||
c = kCFSocketConnectCallBack;
|
||||
break;
|
||||
case GSOCK_LOST:
|
||||
case GSOCK_INPUT:
|
||||
c = kCFSocketReadCallBack;
|
||||
break;
|
||||
case GSOCK_OUTPUT:
|
||||
c = kCFSocketWriteCallBack;
|
||||
break;
|
||||
default:
|
||||
c = 0;
|
||||
}
|
||||
CFSocketDisableCallBacks(data->socket, c);
|
||||
}
|
||||
|
||||
void _GSocket_Enable_Events(GSocket *socket)
|
||||
{
|
||||
struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
|
||||
if (!data) return;
|
||||
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), data->source, kCFRunLoopDefaultMode);
|
||||
}
|
||||
|
||||
void _GSocket_Disable_Events(GSocket *socket)
|
||||
{
|
||||
struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
|
||||
if (!data) return;
|
||||
|
||||
/* CFSocketInvalidate does CFRunLoopRemoveSource anyway */
|
||||
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), data->source, kCFRunLoopCommonModes);
|
||||
CFSocketInvalidate(data->socket);
|
||||
}
|
||||
|
||||
#endif // wxUSE_SOCKETS
|
||||
181
src/mac/classic/gsockosx.cpp
Normal file
181
src/mac/classic/gsockosx.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
/* -------------------------------------------------------------------------
|
||||
* Project: GSocket (Generic Socket) for WX
|
||||
* Name: gsockosx.c
|
||||
* Purpose: GSocket: Mac OS X mach-o part
|
||||
* CVSID: $Id$
|
||||
* Mac code by Brian Victor, February 2002. Email comments to bhv1@psu.edu
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#if wxUSE_SOCKETS
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "wx/gsocket.h"
|
||||
#include "wx/unix/gsockunx.h"
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#define ALL_CALLBACK_TYPES (kCFSocketReadCallBack | kCFSocketWriteCallBack | kCFSocketConnectCallBack)
|
||||
|
||||
struct MacGSocketData
|
||||
{
|
||||
CFSocketRef socket;
|
||||
CFRunLoopSourceRef source;
|
||||
};
|
||||
|
||||
void Mac_Socket_Callback(CFSocketRef s, CFSocketCallBackType callbackType,
|
||||
CFDataRef address, const void* data, void* info)
|
||||
{
|
||||
GSocket* socket = (GSocket*)info;
|
||||
struct MacGSocketData* macdata;
|
||||
macdata = (struct MacGSocketData*)socket->m_gui_dependent;
|
||||
if (!macdata) return;
|
||||
switch (callbackType)
|
||||
{
|
||||
case kCFSocketConnectCallBack:
|
||||
assert(!socket->m_server);
|
||||
socket->m_functions->Detected_Write(socket);
|
||||
break;
|
||||
case kCFSocketReadCallBack:
|
||||
socket->m_functions->Detected_Read(socket);
|
||||
break;
|
||||
case kCFSocketWriteCallBack:
|
||||
socket->m_functions->Detected_Write(socket);
|
||||
break;
|
||||
default:
|
||||
break; /* We shouldn't get here. */
|
||||
}
|
||||
}
|
||||
|
||||
struct MacGSocketData* _GSocket_Get_Mac_Socket(GSocket *socket)
|
||||
{
|
||||
/* If socket is already created, returns a pointer to the data */
|
||||
/* Otherwise, creates socket and returns the pointer */
|
||||
CFSocketContext cont;
|
||||
struct MacGSocketData* data = (struct MacGSocketData*)socket->m_gui_dependent;
|
||||
|
||||
if (data && data->source) return data;
|
||||
|
||||
/* CFSocket has not been created, create it: */
|
||||
if (socket->m_fd < 0 || !data) return NULL;
|
||||
cont.version = 0; cont.retain = NULL;
|
||||
cont.release = NULL; cont.copyDescription = NULL;
|
||||
cont.info = socket;
|
||||
|
||||
CFSocketRef cf = CFSocketCreateWithNative(NULL, socket->m_fd,
|
||||
ALL_CALLBACK_TYPES, Mac_Socket_Callback, &cont);
|
||||
CFRunLoopSourceRef source = CFSocketCreateRunLoopSource(NULL, cf, 0);
|
||||
assert(source);
|
||||
socket->m_gui_dependent = (char*)data;
|
||||
|
||||
/* Keep the source and the socket around. */
|
||||
data->source = source;
|
||||
data->socket = cf;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
int _GSocket_GUI_Init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void _GSocket_GUI_Cleanup(void)
|
||||
{
|
||||
}
|
||||
|
||||
int _GSocket_GUI_Init_Socket(GSocket *socket)
|
||||
{
|
||||
struct MacGSocketData *data = malloc(sizeof(struct MacGSocketData));
|
||||
if (data)
|
||||
{
|
||||
socket->m_gui_dependent = (char*)data;
|
||||
data->socket = NULL;
|
||||
data->source = NULL;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _GSocket_GUI_Destroy_Socket(GSocket *socket)
|
||||
{
|
||||
struct MacGSocketData *data = (struct MacGSocketData*)(socket->m_gui_dependent);
|
||||
if (data)
|
||||
{
|
||||
CFRelease(data->socket);
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
||||
void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event)
|
||||
{
|
||||
int c;
|
||||
struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
|
||||
if (!data) return;
|
||||
switch (event)
|
||||
{
|
||||
case GSOCK_CONNECTION:
|
||||
if(socket->m_server)
|
||||
c = kCFSocketReadCallBack;
|
||||
else
|
||||
c = kCFSocketConnectCallBack;
|
||||
break;
|
||||
case GSOCK_LOST:
|
||||
case GSOCK_INPUT:
|
||||
c = kCFSocketReadCallBack;
|
||||
break;
|
||||
case GSOCK_OUTPUT:
|
||||
c = kCFSocketWriteCallBack;
|
||||
break;
|
||||
default:
|
||||
c = 0;
|
||||
}
|
||||
CFSocketEnableCallBacks(data->socket, c);
|
||||
}
|
||||
|
||||
void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event)
|
||||
{
|
||||
int c;
|
||||
struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
|
||||
if (!data) return;
|
||||
switch (event)
|
||||
{
|
||||
case GSOCK_CONNECTION:
|
||||
if(socket->m_server)
|
||||
c = kCFSocketReadCallBack;
|
||||
else
|
||||
c = kCFSocketConnectCallBack;
|
||||
break;
|
||||
case GSOCK_LOST:
|
||||
case GSOCK_INPUT:
|
||||
c = kCFSocketReadCallBack;
|
||||
break;
|
||||
case GSOCK_OUTPUT:
|
||||
c = kCFSocketWriteCallBack;
|
||||
break;
|
||||
default:
|
||||
c = 0;
|
||||
}
|
||||
CFSocketDisableCallBacks(data->socket, c);
|
||||
}
|
||||
|
||||
void _GSocket_Enable_Events(GSocket *socket)
|
||||
{
|
||||
struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
|
||||
if (!data) return;
|
||||
|
||||
CFRunLoopAddSource(CFRunLoopGetCurrent(), data->source, kCFRunLoopDefaultMode);
|
||||
}
|
||||
|
||||
void _GSocket_Disable_Events(GSocket *socket)
|
||||
{
|
||||
struct MacGSocketData* data = _GSocket_Get_Mac_Socket(socket);
|
||||
if (!data) return;
|
||||
|
||||
/* CFSocketInvalidate does CFRunLoopRemoveSource anyway */
|
||||
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), data->source, kCFRunLoopCommonModes);
|
||||
CFSocketInvalidate(data->socket);
|
||||
}
|
||||
|
||||
#endif // wxUSE_SOCKETS
|
||||
84
src/mac/classic/helpxxxx.cpp
Normal file
84
src/mac/classic/helpxxxx.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: helpxxxx.cpp
|
||||
// Purpose: Help system: native implementation
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "helpxxxx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/stubs/helpxxxx.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxXXXXHelpController, wxHelpControllerBase)
|
||||
#endif
|
||||
|
||||
wxXXXXHelpController::wxXXXXHelpController()
|
||||
{
|
||||
m_helpFile = "";
|
||||
}
|
||||
|
||||
wxXXXXHelpController::~wxXXXXHelpController()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxXXXXHelpController::Initialize(const wxString& filename)
|
||||
{
|
||||
m_helpFile = filename;
|
||||
// TODO any other inits
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxXXXXHelpController::LoadFile(const wxString& file)
|
||||
{
|
||||
m_helpFile = file;
|
||||
// TODO
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxXXXXHelpController::DisplayContents()
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxXXXXHelpController::DisplaySection(int section)
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxXXXXHelpController::DisplayBlock(long block)
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxXXXXHelpController::KeywordSearch(const wxString& k,
|
||||
wxHelpSearchMode WXUNUSED(mode))
|
||||
{
|
||||
if (m_helpFile == "") return FALSE;
|
||||
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Can't close the help window explicitly in WinHelp
|
||||
bool wxXXXXHelpController::Quit()
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxXXXXHelpController::OnQuit()
|
||||
{
|
||||
}
|
||||
|
||||
417
src/mac/classic/hid.cpp
Normal file
417
src/mac/classic/hid.cpp
Normal file
@@ -0,0 +1,417 @@
|
||||
#include "hid.h"
|
||||
|
||||
#define wxFORCECHECK_MSG(arg, msg) \
|
||||
{\
|
||||
if (arg) \
|
||||
{\
|
||||
wxLogSysError(wxString::Format(wxT("Message:%s\nHID: %s failed!"), wxT(msg), wxT(#arg)));\
|
||||
return false;\
|
||||
}\
|
||||
}
|
||||
#define wxIOCHECK(arg, msg) wxFORCECHECK_MSG(arg != kIOReturnSuccess, msg)
|
||||
#define wxKERNCHECK(arg, msg) wxFORCECHECK_MSG(arg != KERN_SUCCESS, msg)
|
||||
#define wxSCHECK(arg, msg) wxFORCECHECK_MSG(arg != S_OK, msg)
|
||||
|
||||
void CFShowTypeIDDescription(CFTypeRef pData)
|
||||
{
|
||||
if(!pData)
|
||||
{
|
||||
wxMessageBox("AHHH!");
|
||||
return;
|
||||
}
|
||||
|
||||
wxMessageBox(
|
||||
CFStringGetCStringPtr(
|
||||
CFCopyTypeIDDescription(CFGetTypeID(pData)),CFStringGetSystemEncoding()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
|
||||
bool wxHIDDevice::Create (const int& nClass, const int& nType)
|
||||
{
|
||||
//Create the mach port
|
||||
wxIOCHECK(IOMasterPort(bootstrap_port, &m_pPort), "Could not create mach port");
|
||||
|
||||
//Dictionary that will hold first
|
||||
//the matching dictionary for determining which kind of devices we want,
|
||||
//then later some registry properties from an iterator (see below)
|
||||
CFMutableDictionaryRef pDictionary;
|
||||
|
||||
//Create a dictionary
|
||||
//The call to IOServiceMatching filters down the
|
||||
//the services we want to hid services (and also eats the
|
||||
//dictionary up for us (consumes one reference))
|
||||
wxASSERT((pDictionary = IOServiceMatching(kIOHIDDeviceKey)) != NULL );
|
||||
|
||||
//Here we'll filter down the services to what we want
|
||||
if (nType != -1)
|
||||
{
|
||||
CFNumberRef pType = CFNumberCreate(kCFAllocatorDefault,
|
||||
kCFNumberIntType, &nType);
|
||||
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsageKey), pType);
|
||||
CFRelease(pType);
|
||||
}
|
||||
if (nClass != -1)
|
||||
{
|
||||
CFNumberRef pClass = CFNumberCreate(kCFAllocatorDefault,
|
||||
kCFNumberIntType, &nClass);
|
||||
CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsagePageKey), pClass);
|
||||
CFRelease(pClass);
|
||||
}
|
||||
|
||||
//Now get the maching services
|
||||
io_iterator_t pIterator;
|
||||
wxIOCHECK(IOServiceGetMatchingServices(m_pPort, pDictionary, &pIterator), "No Matching HID Services");
|
||||
wxASSERT(pIterator != NULL);
|
||||
|
||||
//Now we iterate through them
|
||||
io_object_t pObject;
|
||||
while ( (pObject = IOIteratorNext(pIterator)) != NULL)
|
||||
{
|
||||
wxASSERT(IORegistryEntryCreateCFProperties(pObject, &pDictionary,
|
||||
kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS);
|
||||
|
||||
//Just for sanity :)
|
||||
wxASSERT(CFGetTypeID(CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey))) == CFStringGetTypeID());
|
||||
|
||||
//Get [product] name
|
||||
m_szName = CFStringGetCStringPtr (
|
||||
(CFStringRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey)),
|
||||
CFStringGetSystemEncoding()
|
||||
);
|
||||
|
||||
//
|
||||
//Now the hard part - in order to scan things we need "cookies" -
|
||||
//
|
||||
wxCFArray CookieArray = CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDElementKey));
|
||||
BuildCookies(CookieArray);
|
||||
if (m_ppQueue != NULL)
|
||||
wxASSERT((*m_ppQueue)->start(m_ppQueue) == S_OK);
|
||||
|
||||
//Create the interface (good grief - long function names!)
|
||||
SInt32 nScore;
|
||||
IOCFPlugInInterface** ppPlugin;
|
||||
wxIOCHECK(IOCreatePlugInInterfaceForService(pObject, kIOHIDDeviceUserClientTypeID,
|
||||
kIOCFPlugInInterfaceID, &ppPlugin, &nScore), "");
|
||||
|
||||
//Now, the final thing we can check before we fall back to asserts
|
||||
//(because the dtor only checks if the device is ok, so if anything
|
||||
//fails from now on the dtor will delete the device anyway, so we can't break from this).
|
||||
|
||||
//Get the HID interface from the plugin to the mach port
|
||||
wxSCHECK((*ppPlugin)->QueryInterface(ppPlugin,
|
||||
CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void**) &m_ppDevice), "");
|
||||
|
||||
//release the plugin
|
||||
(*ppPlugin)->Release(ppPlugin);
|
||||
|
||||
//open the HID interface...
|
||||
wxASSERT((*m_ppDevice)->open(m_ppDevice, 0) == S_OK);
|
||||
|
||||
//cleanup
|
||||
CFRelease(pDictionary);
|
||||
IOObjectRelease(pObject);
|
||||
break;
|
||||
}
|
||||
//iterator cleanup
|
||||
IOObjectRelease(pIterator);
|
||||
|
||||
return true;
|
||||
}//end Create()
|
||||
|
||||
void wxHIDDevice::AddCookie(CFTypeRef Data, const int& i)
|
||||
{
|
||||
CFNumberGetValue(
|
||||
(CFNumberRef) CFDictionaryGetValue ( (CFDictionaryRef) Data
|
||||
, CFSTR(kIOHIDElementCookieKey)
|
||||
),
|
||||
kCFNumberIntType,
|
||||
&m_pCookies[i]
|
||||
);
|
||||
}
|
||||
|
||||
void wxHIDDevice::AddCookieInQueue(CFTypeRef Data, const int& i)
|
||||
{
|
||||
AddCookie(Data, i);
|
||||
wxASSERT((*m_ppQueue)->addElement(m_ppQueue, m_pCookies[i], 0) == S_OK);//3rd Param flags (none yet)
|
||||
}
|
||||
|
||||
void wxHIDDevice::InitCookies(const size_t& dwSize, bool bQueue)
|
||||
{
|
||||
m_pCookies = new IOHIDElementCookie[dwSize];
|
||||
if (bQueue)
|
||||
{
|
||||
wxASSERT( m_ppQueue != NULL);
|
||||
wxASSERT( (m_ppQueue = (*m_ppDevice)->allocQueue(m_ppDevice)) != NULL);
|
||||
wxASSERT( (*m_ppQueue)->create(m_ppQueue, 0, 512) == S_OK); //Param 2, flags, none yet
|
||||
}
|
||||
}
|
||||
|
||||
bool wxHIDDevice::IsActive(const int& nIndex)
|
||||
{
|
||||
wxASSERT(m_pCookies[nIndex] != NULL);
|
||||
IOHIDEventStruct Event;
|
||||
(*m_ppDevice)->getElementValue(m_ppDevice, m_pCookies[nIndex], &Event);
|
||||
return !!Event.value;
|
||||
}
|
||||
|
||||
|
||||
wxHIDDevice::~wxHIDDevice()
|
||||
{
|
||||
if (m_ppDevice != NULL)
|
||||
{
|
||||
(*m_ppDevice)->close(m_ppDevice);
|
||||
(*m_ppDevice)->Release(m_ppDevice);
|
||||
mach_port_deallocate(mach_task_self(), m_pPort);
|
||||
}
|
||||
|
||||
if (m_pCookies != NULL)
|
||||
{
|
||||
delete [] m_pCookies;
|
||||
if (m_ppQueue != NULL)
|
||||
{
|
||||
(*m_ppQueue)->stop(m_ppQueue);
|
||||
(*m_ppQueue)->dispose(m_ppQueue);
|
||||
(*m_ppQueue)->Release(m_ppQueue);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
enum
|
||||
{
|
||||
kHIDUsage_KeyboardHyphen = 0x2D,
|
||||
kHIDUsage_KeyboardEqualSign = 0x2E,
|
||||
kHIDUsage_KeyboardOpenBracket = 0x2F,
|
||||
kHIDUsage_KeyboardCloseBracket = 0x30,
|
||||
kHIDUsage_KeyboardBackslash = 0x31, //* \ or | *
|
||||
kHIDUsage_KeyboardNonUSPound = 0x32, /* Non-US # or _ *
|
||||
kHIDUsage_KeyboardSemicolon = 0x33, /* ; or : *
|
||||
kHIDUsage_KeyboardQuote = 0x34, /* ' or " *
|
||||
kHIDUsage_KeyboardGraveAccentAndTilde = 0x35, /* Grave Accent and Tilde *
|
||||
kHIDUsage_KeyboardComma = 0x36, /* , or < *
|
||||
kHIDUsage_KeyboardPeriod = 0x37, /* . or > *
|
||||
kHIDUsage_KeyboardSlash = 0x38, /* / or ? *
|
||||
kHIDUsage_KeyboardCapsLock = 0x39, /* Caps Lock *
|
||||
|
||||
kHIDUsage_KeyboardPrintScreen = 0x46, /* Print Screen *
|
||||
kHIDUsage_KeyboardScrollLock = 0x47, /* Scroll Lock *
|
||||
kHIDUsage_KeyboardPause = 0x48, /* Pause *
|
||||
kHIDUsage_KeyboardInsert = 0x49, /* Insert *
|
||||
kHIDUsage_KeyboardHome = 0x4A, /* Home *
|
||||
kHIDUsage_KeyboardDeleteForward = 0x4C, /* Delete Forward *
|
||||
|
||||
kHIDUsage_KeyboardUpArrow
|
||||
kHIDUsage_KeypadNumLock
|
||||
kHIDUsage_KeypadSlash
|
||||
kHIDUsage_KeypadAsterisk
|
||||
kHIDUsage_KeypadHyphen
|
||||
kHIDUsage_KeypadPlus
|
||||
kHIDUsage_KeypadEnter
|
||||
kHIDUsage_KeypadPeriod
|
||||
kHIDUsage_KeyboardNonUSBackslash
|
||||
kHIDUsage_KeyboardApplication
|
||||
kHIDUsage_KeyboardPower
|
||||
kHIDUsage_KeypadEqualSign
|
||||
};
|
||||
/*
|
||||
enum wxKeyCode
|
||||
{
|
||||
|
||||
WXK_START = 300,
|
||||
WXK_LBUTTON,
|
||||
WXK_RBUTTON,
|
||||
WXK_CANCEL,
|
||||
WXK_MBUTTON,
|
||||
WXK_CLEAR,
|
||||
WXK_SHIFT,
|
||||
WXK_ALT,
|
||||
WXK_CONTROL,
|
||||
WXK_MENU,
|
||||
WXK_PAUSE,
|
||||
WXK_PRIOR, * Page up *
|
||||
WXK_NEXT, * Page down *
|
||||
WXK_END,
|
||||
WXK_HOME,
|
||||
WXK_LEFT,
|
||||
WXK_UP,
|
||||
WXK_RIGHT,
|
||||
WXK_DOWN,
|
||||
WXK_SELECT,
|
||||
WXK_PRINT,
|
||||
WXK_EXECUTE,
|
||||
WXK_SNAPSHOT,
|
||||
WXK_INSERT,
|
||||
WXK_HELP,
|
||||
WXK_MULTIPLY,
|
||||
WXK_ADD,
|
||||
WXK_SEPARATOR,
|
||||
WXK_SUBTRACT,
|
||||
WXK_DECIMAL,
|
||||
WXK_DIVIDE,
|
||||
WXK_PAGEUP,
|
||||
WXK_PAGEDOWN,
|
||||
|
||||
WXK_NUMPAD_SPACE,
|
||||
WXK_NUMPAD_TAB,
|
||||
WXK_NUMPAD_ENTER,
|
||||
WXK_NUMPAD_HOME,
|
||||
WXK_NUMPAD_LEFT,
|
||||
WXK_NUMPAD_UP,
|
||||
WXK_NUMPAD_RIGHT,
|
||||
WXK_NUMPAD_DOWN,
|
||||
WXK_NUMPAD_PRIOR,
|
||||
WXK_NUMPAD_PAGEUP,
|
||||
WXK_NUMPAD_NEXT,
|
||||
WXK_NUMPAD_PAGEDOWN,
|
||||
WXK_NUMPAD_END,
|
||||
WXK_NUMPAD_BEGIN,
|
||||
WXK_NUMPAD_INSERT,
|
||||
WXK_NUMPAD_DELETE,
|
||||
WXK_NUMPAD_EQUAL,
|
||||
WXK_NUMPAD_MULTIPLY,
|
||||
WXK_NUMPAD_ADD,
|
||||
WXK_NUMPAD_SEPARATOR,
|
||||
WXK_NUMPAD_SUBTRACT,
|
||||
WXK_NUMPAD_DECIMAL,
|
||||
WXK_NUMPAD_DIVIDE,
|
||||
|
||||
WXK_WINDOWS_LEFT,
|
||||
WXK_WINDOWS_RIGHT,
|
||||
WXK_WINDOWS_MENU ,
|
||||
WXK_COMMAND
|
||||
};
|
||||
|
||||
*/
|
||||
enum
|
||||
{
|
||||
WXK_RSHIFT = 400,
|
||||
WXK_RALT,
|
||||
WXK_RCONTROL,
|
||||
WXK_RMENU
|
||||
|
||||
};
|
||||
|
||||
bool wxHIDKeyboard::Create()
|
||||
{
|
||||
return wxHIDDevice::Create(kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard);
|
||||
}
|
||||
|
||||
void wxHIDKeyboard::BuildCookies(wxCFArray& Array)
|
||||
{
|
||||
Array = CFDictionaryGetValue((CFDictionaryRef)Array[0], CFSTR(kIOHIDElementKey));
|
||||
InitCookies(500);
|
||||
int i,
|
||||
nUsage;
|
||||
for (i = 0; i < Array.Count(); ++i)
|
||||
{
|
||||
CFNumberGetValue(
|
||||
(CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) Array[i], CFSTR(kIOHIDElementUsageKey)),
|
||||
kCFNumberLongType, &nUsage);
|
||||
|
||||
if (nUsage >= kHIDUsage_KeyboardA && nUsage <= kHIDUsage_KeyboardZ)
|
||||
AddCookie(Array[i], 'A' + (nUsage - kHIDUsage_KeyboardA) );
|
||||
else if (nUsage >= kHIDUsage_Keyboard1 && nUsage <= kHIDUsage_Keyboard9)
|
||||
AddCookie(Array[i], '1' + (nUsage - kHIDUsage_Keyboard1) );
|
||||
else if (nUsage >= kHIDUsage_KeyboardF1 && nUsage <= kHIDUsage_KeyboardF12)
|
||||
AddCookie(Array[i], WXK_F1 + (nUsage - kHIDUsage_KeyboardF1) );
|
||||
else if (nUsage >= kHIDUsage_KeyboardF13 && nUsage <= kHIDUsage_KeyboardF24)
|
||||
AddCookie(Array[i], WXK_F13 + (nUsage - kHIDUsage_KeyboardF13) );
|
||||
else if (nUsage >= kHIDUsage_Keypad1 && nUsage <= kHIDUsage_Keypad9)
|
||||
AddCookie(Array[i], WXK_NUMPAD1 + (nUsage - kHIDUsage_Keypad1) );
|
||||
else switch (nUsage)
|
||||
{
|
||||
//0's (wx & ascii go 0-9, but HID goes 1-0)
|
||||
case kHIDUsage_Keyboard0:
|
||||
AddCookie(Array[i],'0');
|
||||
break;
|
||||
case kHIDUsage_Keypad0:
|
||||
AddCookie(Array[i],WXK_NUMPAD0);
|
||||
break;
|
||||
|
||||
//Basic
|
||||
case kHIDUsage_KeyboardReturnOrEnter:
|
||||
AddCookie(Array[i], WXK_RETURN);
|
||||
break;
|
||||
case kHIDUsage_KeyboardEscape:
|
||||
AddCookie(Array[i], WXK_ESCAPE);
|
||||
break;
|
||||
case kHIDUsage_KeyboardDeleteOrBackspace:
|
||||
AddCookie(Array[i], WXK_BACK);
|
||||
break;
|
||||
case kHIDUsage_KeyboardTab:
|
||||
AddCookie(Array[i], WXK_TAB);
|
||||
break;
|
||||
case kHIDUsage_KeyboardSpacebar:
|
||||
AddCookie(Array[i], WXK_SPACE);
|
||||
break;
|
||||
case kHIDUsage_KeyboardPageUp:
|
||||
AddCookie(Array[i], WXK_PRIOR);
|
||||
break;
|
||||
case kHIDUsage_KeyboardEnd:
|
||||
AddCookie(Array[i], WXK_END);
|
||||
break;
|
||||
case kHIDUsage_KeyboardPageDown:
|
||||
AddCookie(Array[i], WXK_NEXT);
|
||||
break;
|
||||
case kHIDUsage_KeyboardRightArrow:
|
||||
AddCookie(Array[i], WXK_RIGHT);
|
||||
break;
|
||||
case kHIDUsage_KeyboardLeftArrow:
|
||||
AddCookie(Array[i], WXK_LEFT);
|
||||
break;
|
||||
case kHIDUsage_KeyboardDownArrow:
|
||||
AddCookie(Array[i], WXK_DOWN);
|
||||
break;
|
||||
case kHIDUsage_KeyboardUpArrow:
|
||||
AddCookie(Array[i], WXK_UP);
|
||||
break;
|
||||
|
||||
//LEDS
|
||||
case kHIDUsage_KeyboardCapsLock:
|
||||
AddCookie(Array[i],WXK_CAPITAL);
|
||||
break;
|
||||
case kHIDUsage_KeypadNumLock:
|
||||
AddCookie(Array[i],WXK_NUMLOCK);
|
||||
break;
|
||||
case kHIDUsage_KeyboardScrollLock:
|
||||
AddCookie(Array[i],WXK_SCROLL);
|
||||
break;
|
||||
|
||||
//Menu keys, Shift, other specials
|
||||
case kHIDUsage_KeyboardLeftControl:
|
||||
AddCookie(Array[i],WXK_CONTROL);
|
||||
break;
|
||||
case kHIDUsage_KeyboardLeftShift:
|
||||
AddCookie(Array[i],WXK_SHIFT);
|
||||
break;
|
||||
case kHIDUsage_KeyboardLeftAlt:
|
||||
AddCookie(Array[i],WXK_ALT);
|
||||
break;
|
||||
case kHIDUsage_KeyboardLeftGUI:
|
||||
AddCookie(Array[i],WXK_MENU);
|
||||
break;
|
||||
case kHIDUsage_KeyboardRightControl:
|
||||
AddCookie(Array[i],WXK_RCONTROL);
|
||||
break;
|
||||
case kHIDUsage_KeyboardRightShift:
|
||||
AddCookie(Array[i],WXK_RSHIFT);
|
||||
break;
|
||||
case kHIDUsage_KeyboardRightAlt:
|
||||
AddCookie(Array[i],WXK_RALT);
|
||||
break;
|
||||
case kHIDUsage_KeyboardRightGUI:
|
||||
AddCookie(Array[i],WXK_RMENU);
|
||||
break;
|
||||
|
||||
//Default
|
||||
default:
|
||||
//not in wx keycodes - do nothing....
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//end buildcookies
|
||||
132
src/mac/classic/icon.cpp
Normal file
132
src/mac/classic/icon.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: icon.cpp
|
||||
// Purpose: wxIcon class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "icon.h"
|
||||
#endif
|
||||
|
||||
#include "wx/icon.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
||||
#endif
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
|
||||
/*
|
||||
* Icons
|
||||
*/
|
||||
|
||||
wxIcon::wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const char bits[], int width, int height) :
|
||||
wxBitmap(bits, width, height)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( const char **bits ) :
|
||||
wxBitmap(bits)
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( char **bits ) :
|
||||
wxBitmap(bits)
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const wxString& icon_file, int flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
LoadFile(icon_file, (wxBitmapType) flags, desiredWidth, desiredHeight);
|
||||
}
|
||||
|
||||
wxIcon::~wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxBitmapRefData;
|
||||
|
||||
wxBitmapHandler *handler = FindHandler((wxBitmapType)type);
|
||||
|
||||
if ( handler )
|
||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
|
||||
{
|
||||
wxIcon *icon = (wxIcon*)(&bmp);
|
||||
*this = *icon;
|
||||
}
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
||||
|
||||
bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
short theId = -1 ;
|
||||
if ( name == wxT("wxICON_INFORMATION") )
|
||||
{
|
||||
theId = kNoteIcon ;
|
||||
}
|
||||
else if ( name == wxT("wxICON_QUESTION") )
|
||||
{
|
||||
theId = kCautionIcon ;
|
||||
}
|
||||
else if ( name == wxT("wxICON_WARNING") )
|
||||
{
|
||||
theId = kCautionIcon ;
|
||||
}
|
||||
else if ( name == wxT("wxICON_ERROR") )
|
||||
{
|
||||
theId = kStopIcon ;
|
||||
}
|
||||
else
|
||||
{
|
||||
Str255 theName ;
|
||||
OSType theType ;
|
||||
wxMacStringToPascal( name , theName ) ;
|
||||
|
||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||
if ( resHandle != 0L )
|
||||
{
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
}
|
||||
}
|
||||
if ( theId != -1 )
|
||||
{
|
||||
CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
|
||||
if ( theIcon )
|
||||
{
|
||||
M_BITMAPHANDLERDATA->m_hIcon = theIcon ;
|
||||
M_BITMAPHANDLERDATA->m_width = 32 ;
|
||||
M_BITMAPHANDLERDATA->m_height = 32 ;
|
||||
|
||||
M_BITMAPHANDLERDATA->m_depth = 8 ;
|
||||
M_BITMAPHANDLERDATA->m_ok = true ;
|
||||
M_BITMAPHANDLERDATA->m_numColors = 256 ;
|
||||
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
return FALSE ;
|
||||
}
|
||||
286
src/mac/classic/joystick.cpp
Normal file
286
src/mac/classic/joystick.cpp
Normal file
@@ -0,0 +1,286 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: joystick.cpp
|
||||
// Purpose: wxJoystick class
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "joystick.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#include "wx/joystick.h"
|
||||
|
||||
#if wxUSE_JOYSTICK
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxJoystick, wxObject)
|
||||
|
||||
// Attributes
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxPoint wxJoystick::GetPosition() const
|
||||
{
|
||||
// TODO
|
||||
return wxPoint(0, 0);
|
||||
}
|
||||
|
||||
int wxJoystick::GetZPosition() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetButtonState() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetPOVPosition() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetPOVCTSPosition() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetRudderPosition() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetUPosition() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetVPosition() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetMovementThreshold() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wxJoystick::SetMovementThreshold(int threshold)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Capabilities
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool wxJoystick::IsOk() const
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int wxJoystick::GetNumberJoysticks() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetManufacturerId() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetProductId() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxString wxJoystick::GetProductName() const
|
||||
{
|
||||
// TODO
|
||||
return wxString(wxT(""));
|
||||
}
|
||||
|
||||
int wxJoystick::GetXMin() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetYMin() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetZMin() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetXMax() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetYMax() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetZMax() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetNumberButtons() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetNumberAxes() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetMaxButtons() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetMaxAxes() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetPollingMin() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetPollingMax() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetRudderMin() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetRudderMax() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetUMin() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetUMax() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetVMin() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxJoystick::GetVMax() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool wxJoystick::HasRudder() const
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxJoystick::HasZ() const
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxJoystick::HasU() const
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxJoystick::HasV() const
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxJoystick::HasPOV() const
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxJoystick::HasPOV4Dir() const
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxJoystick::HasPOVCTS() const
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Operations
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool wxJoystick::SetCapture(wxWindow* win, int pollingFreq)
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxJoystick::ReleaseCapture()
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
// wxUSE_JOYSTICK
|
||||
|
||||
1023
src/mac/classic/listbox.cpp
Normal file
1023
src/mac/classic/listbox.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user