wx/wxprec.h already includes wx/defs.h (with other minor cleaning).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38790 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2006-04-18 09:05:00 +00:00
parent ce3e37f1ec
commit 18f3decb46
28 changed files with 710 additions and 638 deletions

View File

@@ -19,7 +19,6 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/apptrait.h" #include "wx/apptrait.h"
#include "wx/defs.h"
#include "wx/object.h" #include "wx/object.h"
#include "wx/string.h" #include "wx/string.h"
#include "wx/timer.h" #include "wx/timer.h"
@@ -2301,4 +2300,3 @@ IMPLEMENT_DYNAMIC_CLASS(wxSocketModule, wxModule)
#endif #endif
// wxUSE_SOCKETS // wxUSE_SOCKETS

View File

@@ -1,21 +1,20 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: generic/imaglist.cpp // Name: src/mac/carbon/imaglist.cpp
// Purpose: // Purpose:
// Author: Robert Roebling // Author: Robert Roebling
// Id: $id$ // RCS_ID: $Id$
// Copyright: (c) 1998 Robert Roebling // Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h" #include "wx/wxprec.h"
#if wxUSE_IMAGLIST
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
#include "wx/defs.h" #if wxUSE_IMAGLIST
#include "wx/imaglist.h" #include "wx/imaglist.h"
#include "wx/icon.h" #include "wx/icon.h"
#include "wx/image.h" #include "wx/image.h"
@@ -262,4 +261,3 @@ bool wxImageList::Draw(
} }
#endif // wxUSE_IMAGLIST #endif // wxUSE_IMAGLIST

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: app.cpp // Name: src/mac/classic/app.cpp
// Purpose: wxApp // Purpose: wxApp
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
@@ -9,7 +9,11 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/window.h" #include "wx/window.h"
#include "wx/frame.h" #include "wx/frame.h"
@@ -72,10 +76,10 @@ extern size_t g_numberOfThreads;
// statics for implementation // statics for implementation
static bool s_inYield = FALSE; static bool s_inYield = false;
#if TARGET_CARBON #if TARGET_CARBON
static bool s_inReceiveEvent = FALSE ; static bool s_inReceiveEvent = false ;
static EventTime sleepTime = kEventDurationNoWait ; static EventTime sleepTime = kEventDurationNoWait ;
#else #else
static long sleepTime = 0 ; static long sleepTime = 0 ;
@@ -229,7 +233,7 @@ short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU
{ {
wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId); wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId);
if (!win->ProcessEvent(exitEvent)) if (!win->ProcessEvent(exitEvent))
win->Close(TRUE ) ; win->Close(true) ;
} }
else else
{ {
@@ -273,7 +277,7 @@ void wxApp::MacPrintFile(const wxString & fileName )
if (printout) if (printout)
{ {
wxPrinter printer; wxPrinter printer;
printer.Print(view->GetFrame(), printout, TRUE); printer.Print(view->GetFrame(), printout, true);
delete printout; delete printout;
} }
} }
@@ -328,13 +332,13 @@ static pascal OSStatus
MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{ {
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar(); wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar();
if ( mbar ) if ( mbar )
{ {
wxFrame* win = mbar->GetFrame(); wxFrame* win = mbar->GetFrame();
if ( win ) if ( win )
{ {
// VZ: we could find the menu from its handle here by examining all // VZ: we could find the menu from its handle here by examining all
// the menus in the menu bar recursively but knowing that neither // the menus in the menu bar recursively but knowing that neither
// wxMSW nor wxGTK do it why bother... // wxMSW nor wxGTK do it why bother...
@@ -348,7 +352,7 @@ MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
&menuRef); &menuRef);
#endif // 0 #endif // 0
wxEventType type=0; wxEventType type=0;
MenuCommand cmd=0; MenuCommand cmd=0;
switch (GetEventKind(event)) switch (GetEventKind(event))
{ {
@@ -629,7 +633,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
UMAShowArrowCursor() ; UMAShowArrowCursor() ;
ParamText("\pFatal Error", message, (ConstStr255Param)"\p", (ConstStr255Param)"\p"); ParamText("\pFatal Error", message, (ConstStr255Param)"\p", (ConstStr255Param)"\p");
itemHit = Alert(128, nil); itemHit = Alert(128, nil);
return FALSE ; return false ;
} }
#ifndef __DARWIN__ #ifndef __DARWIN__
@@ -735,7 +739,7 @@ bool wxApp::OnInitGui()
#endif #endif
} }
return TRUE ; return true ;
} }
void wxApp::CleanUp() void wxApp::CleanUp()
@@ -1069,18 +1073,18 @@ pascal OSStatus wxMacApplicationEventHandler( EventHandlerCallRef handler , Even
wxApp::wxApp() wxApp::wxApp()
{ {
m_printMode = wxPRINT_WINDOWS; m_printMode = wxPRINT_WINDOWS;
m_auto3D = TRUE; m_auto3D = true;
m_macCurrentEvent = NULL ; m_macCurrentEvent = NULL ;
#if TARGET_CARBON #if TARGET_CARBON
m_macCurrentEventHandlerCallRef = NULL ; m_macCurrentEventHandlerCallRef = NULL ;
#endif #endif
} }
int wxApp::MainLoop() int wxApp::MainLoop()
{ {
m_keepGoing = TRUE; m_keepGoing = true;
while (m_keepGoing) while (m_keepGoing)
{ {
@@ -1092,7 +1096,7 @@ int wxApp::MainLoop()
void wxApp::ExitMainLoop() void wxApp::ExitMainLoop()
{ {
m_keepGoing = FALSE; m_keepGoing = false;
} }
// Is a message/event pending? // Is a message/event pending?
@@ -1102,7 +1106,7 @@ bool wxApp::Pending()
// without the receive event (with pull param = false ) nothing is ever reported // without the receive event (with pull param = false ) nothing is ever reported
EventRef theEvent; EventRef theEvent;
ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &theEvent); ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &theEvent);
return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ; return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ;
#else #else
EventRecord event ; EventRecord event ;
@@ -1145,7 +1149,7 @@ void wxApp::Exit()
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event)) void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{ {
if (GetTopWindow()) if (GetTopWindow())
GetTopWindow()->Close(TRUE); GetTopWindow()->Close(true);
} }
// Default behaviour: close the application with prompts. The // Default behaviour: close the application with prompts. The
@@ -1155,7 +1159,7 @@ void wxApp::OnQueryEndSession(wxCloseEvent& event)
if (GetTopWindow()) if (GetTopWindow())
{ {
if (!GetTopWindow()->Close(!event.CanVeto())) if (!GetTopWindow()->Close(!event.CanVeto()))
event.Veto(TRUE); event.Veto(true);
} }
} }
@@ -1176,10 +1180,10 @@ bool wxApp::Yield(bool onlyIfNeeded)
wxFAIL_MSG( wxT("wxYield called recursively" ) ); wxFAIL_MSG( wxT("wxYield called recursively" ) );
} }
return FALSE; return false;
} }
s_inYield = TRUE; s_inYield = true;
#if wxUSE_THREADS #if wxUSE_THREADS
YieldToAnyThread() ; YieldToAnyThread() ;
@@ -1230,9 +1234,9 @@ bool wxApp::Yield(bool onlyIfNeeded)
#endif #endif
wxMacProcessNotifierAndPendingEvents() ; wxMacProcessNotifierAndPendingEvents() ;
s_inYield = FALSE; s_inYield = false;
return TRUE; return true;
} }
// platform specifics // platform specifics
@@ -1381,7 +1385,7 @@ void wxApp::MacDoOneEvent()
/*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr ) /*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr )
{ {
// Override to process unhandled events as you please // Override to process unhandled events as you please
} }
void wxApp::MacHandleOneEvent( WXEVENTREF evr ) void wxApp::MacHandleOneEvent( WXEVENTREF evr )
@@ -1508,7 +1512,7 @@ void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr )
{ {
// we must avoid reentrancy problems when processing high level events eg printing // we must avoid reentrancy problems when processing high level events eg printing
bool former = s_inYield ; bool former = s_inYield ;
s_inYield = TRUE ; s_inYield = true ;
EventRecord* ev = (EventRecord*) evr ; EventRecord* ev = (EventRecord*) evr ;
::AEProcessAppleEvent( ev ) ; ::AEProcessAppleEvent( ev ) ;
s_inYield = former ; s_inYield = former ;
@@ -1849,7 +1853,7 @@ bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below
wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
KeyMap keymap; KeyMap keymap;
GetKeys(keymap); GetKeys(keymap);
return !!(BitTst(keymap, (sizeof(KeyMap)*8) - key)); return !!(BitTst(keymap, (sizeof(KeyMap)*8) - key));
} }
@@ -1973,7 +1977,7 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi
} }
if (!handled) if (!handled)
{ {
event.Skip( FALSE ) ; event.Skip( false ) ;
event.SetEventType( wxEVT_CHAR ) ; event.SetEventType( wxEVT_CHAR ) ;
// raw value again // raw value again
event.m_keyCode = realkeyval ; event.m_keyCode = realkeyval ;
@@ -2202,7 +2206,7 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr )
bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse
event.m_leftDown = isDown && !controlDown; event.m_leftDown = isDown && !controlDown;
event.m_middleDown = FALSE; event.m_middleDown = false;
event.m_rightDown = isDown && controlDown; event.m_rightDown = isDown && controlDown;
event.m_shiftDown = ev->modifiers & shiftKey; event.m_shiftDown = ev->modifiers & shiftKey;
event.m_controlDown = ev->modifiers & controlKey; event.m_controlDown = ev->modifiers & controlKey;
@@ -2303,7 +2307,7 @@ void wxApp::MacHandleMouseMovedEvent(wxInt32 x , wxInt32 y ,wxUint32 modifiers ,
event.m_leftDown = isDown && !controlDown; event.m_leftDown = isDown && !controlDown;
event.m_middleDown = FALSE; event.m_middleDown = false;
event.m_rightDown = isDown && controlDown; event.m_rightDown = isDown && controlDown;
event.m_shiftDown = modifiers & shiftKey; event.m_shiftDown = modifiers & shiftKey;

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: bitmap.cpp // Name: src/mac/classic/bitmap.cpp
// Purpose: wxBitmap // Purpose: wxBitmap
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
@@ -9,7 +9,11 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/bitmap.h" #include "wx/bitmap.h"
#include "wx/icon.h" #include "wx/icon.h"
@@ -353,7 +357,7 @@ wxBitmapRefData::wxBitmapRefData()
: m_width(0) : m_width(0)
, m_height(0) , m_height(0)
, m_depth(0) , m_depth(0)
, m_ok(FALSE) , m_ok(false)
, m_numColors(0) , m_numColors(0)
, m_quality(0) , m_quality(0)
{ {
@@ -508,12 +512,12 @@ wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type)
bool wxBitmap::CreateFromXpm(const char **bits) bool wxBitmap::CreateFromXpm(const char **bits)
{ {
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") ); wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") );
wxXPMDecoder decoder; wxXPMDecoder decoder;
wxImage img = decoder.ReadData(bits); wxImage img = decoder.ReadData(bits);
wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid bitmap data") ); wxCHECK_MSG( img.Ok(), false, wxT("invalid bitmap data") );
*this = wxBitmap(img); *this = wxBitmap(img);
return TRUE; return true;
} }
wxBitmap::wxBitmap(const char **bits) wxBitmap::wxBitmap(const char **bits)
@@ -710,7 +714,7 @@ bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int
if ( handler == NULL ) { if ( handler == NULL ) {
wxLogWarning(wxT("no bitmap handler for type %d defined."), type); wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
return FALSE; return false;
} }
return handler->Create(this, data, type, width, height, depth); return handler->Create(this, data, type, width, height, depth);
@@ -1162,7 +1166,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
UnlockPixels( GetGWorldPixMap( (GWorldPtr) m_maskBitmap) ); UnlockPixels( GetGWorldPixMap( (GWorldPtr) m_maskBitmap) );
UnlockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP()) ); UnlockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP()) );
return FALSE; return false;
} }
// Create a mask from a bitmap and a palette index indicating // Create a mask from a bitmap and a palette index indicating
@@ -1171,7 +1175,7 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
{ {
// TODO // TODO
wxCHECK_MSG( 0, false, wxT("wxMask::Create not yet implemented")); wxCHECK_MSG( 0, false, wxT("wxMask::Create not yet implemented"));
return FALSE; return false;
} }
// Create a mask from a bitmap and a colour indicating // Create a mask from a bitmap and a colour indicating
@@ -1226,7 +1230,7 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
UnlockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP() ) ) ; UnlockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP() ) ) ;
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
return TRUE; return true;
} }
bool wxMask::PointMasked(int x, int y) bool wxMask::PointMasked(int x, int y)
@@ -1260,18 +1264,18 @@ wxBitmapHandler::~wxBitmapHandler()
bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth) bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
{ {
return FALSE; return false;
} }
bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight) int desiredWidth, int desiredHeight)
{ {
return FALSE; return false;
} }
bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
{ {
return FALSE; return false;
} }
/* /*
@@ -1317,9 +1321,9 @@ bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo
M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ; M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ;
// M_BITMAPHANDLERDATA->m_bitmapPalette; // M_BITMAPHANDLERDATA->m_bitmapPalette;
// M_BITMAPHANDLERDATA->m_quality; // M_BITMAPHANDLERDATA->m_quality;
return TRUE ; return true ;
} }
return FALSE ; return false ;
} }
void wxBitmap::InitStandardHandlers() void wxBitmap::InitStandardHandlers()

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: button.cpp // Name: src/mac/classic/button.cpp
// Purpose: wxButton // Purpose: wxButton
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/button.h" #include "wx/button.h"
#include "wx/panel.h" #include "wx/panel.h"
@@ -32,7 +36,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& lbl,
wxString label(lbl); wxString label(lbl);
if (label.empty() && wxIsStockID(id)) if (label.empty() && wxIsStockID(id))
label = wxGetStockLabel(id); label = wxGetStockLabel(id);
if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) ) if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
return false; return false;
@@ -44,16 +48,16 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& lbl,
m_macHorizontalBorder = kMacOSXHorizontalBorder; m_macHorizontalBorder = kMacOSXHorizontalBorder;
m_macVerticalBorder = kMacOSXVerticalBorder; m_macVerticalBorder = kMacOSXVerticalBorder;
} }
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlPushButtonProc , (long) this ) ; kControlPushButtonProc , (long) this ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
return TRUE; return true;
} }
void wxButton::SetDefault() void wxButton::SetDefault()
@@ -84,18 +88,18 @@ void wxButton::SetDefault()
wxSize wxButton::DoGetBestSize() const wxSize wxButton::DoGetBestSize() const
{ {
wxSize sz = GetDefaultSize() ; wxSize sz = GetDefaultSize() ;
int wBtn = m_label.Length() * 8 + 12 + 2 * kMacOSXHorizontalBorder ; int wBtn = m_label.Length() * 8 + 12 + 2 * kMacOSXHorizontalBorder ;
if (wBtn > sz.x) sz.x = wBtn; if (wBtn > sz.x) sz.x = wBtn;
return sz ; return sz ;
} }
wxSize wxButton::GetDefaultSize() wxSize wxButton::GetDefaultSize()
{ {
int wBtn = 70 ; int wBtn = 70 ;
int hBtn = 20 ; int hBtn = 20 ;
if ( UMAHasAquaLayout() ) if ( UMAHasAquaLayout() )
@@ -119,7 +123,7 @@ void wxButton::Command (wxCommandEvent & event)
ProcessCommand (event); ProcessCommand (event);
} }
void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) ) void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) )
{ {
if ( controlpart != kControlNoPart ) if ( controlpart != kControlNoPart )
{ {
@@ -128,4 +132,3 @@ void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 contr
ProcessCommand(event); ProcessCommand(event);
} }
} }

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: checkbox.cpp // Name: src/mac/classic/checkbox.cpp
// Purpose: wxCheckBox // Purpose: wxCheckBox
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/checkbox.h" #include "wx/checkbox.h"
@@ -30,7 +34,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
SInt16 maxValue = 1 /* kControlCheckboxCheckedValue */; SInt16 maxValue = 1 /* kControlCheckboxCheckedValue */;
@@ -39,12 +43,12 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
maxValue = 2 /* kControlCheckboxMixedValue */; maxValue = 2 /* kControlCheckboxMixedValue */;
} }
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , maxValue, m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , maxValue,
kControlCheckBoxProc , (long) this ) ; kControlCheckBoxProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
return TRUE; return true;
} }
void wxCheckBox::SetValue(bool val) void wxCheckBox::SetValue(bool val)
@@ -88,7 +92,7 @@ void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
MacRedrawControl() ; MacRedrawControl() ;
} }
void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown) ) void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown) )
{ {
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId ); wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
wxCheckBoxState state = Get3StateValue(); wxCheckBoxState state = Get3StateValue();
@@ -143,7 +147,7 @@ bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id,
// TODO: Create the bitmap checkbox // TODO: Create the bitmap checkbox
return FALSE; return false;
} }
void wxBitmapCheckBox::SetLabel(const wxBitmap *bitmap) void wxBitmapCheckBox::SetLabel(const wxBitmap *bitmap)
@@ -167,7 +171,5 @@ bool wxBitmapCheckBox::GetValue() const
{ {
// TODO // TODO
wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented")); wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));
return FALSE; return false;
} }

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: control.cpp // Name: src/mac/classic/control.cpp
// Purpose: wxControl class // Purpose: wxControl class
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
@@ -9,7 +9,11 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/control.h" #include "wx/control.h"
#include "wx/panel.h" #include "wx/panel.h"
@@ -30,8 +34,8 @@
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow) IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
BEGIN_EVENT_TABLE(wxControl, wxWindow) BEGIN_EVENT_TABLE(wxControl, wxWindow)
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent ) EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
EVT_PAINT( wxControl::OnPaint ) EVT_PAINT( wxControl::OnPaint )
END_EVENT_TABLE() END_EVENT_TABLE()
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -82,7 +86,7 @@ ControlDefUPP wxMacControlActionUPP = NULL ;
pascal SInt32 wxMacControlDefinition(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param) pascal SInt32 wxMacControlDefinition(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
{ {
wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ; wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
{ {
@@ -132,7 +136,7 @@ pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessa
} }
return status ; return status ;
} }
wxControl::wxControl() wxControl::wxControl()
{ {
m_macControl = NULL ; m_macControl = NULL ;
@@ -161,7 +165,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id,
m_macControl = NULL ; m_macControl = NULL ;
m_macHorizontalBorder = 0 ; // additional pixels around the real control m_macHorizontalBorder = 0 ; // additional pixels around the real control
m_macVerticalBorder = 0 ; m_macVerticalBorder = 0 ;
bool rval = wxWindow::Create(parent, id, pos, size, style, name); bool rval = wxWindow::Create(parent, id, pos, size, style, name);
if ( parent ) if ( parent )
{ {
@@ -178,7 +182,7 @@ bool wxControl::Create(wxWindow *parent, wxWindowID id,
wxControl::~wxControl() wxControl::~wxControl()
{ {
m_isBeingDeleted = TRUE; m_isBeingDeleted = true;
wxRemoveMacControlAssociation( this ) ; wxRemoveMacControlAssociation( this ) ;
// If we delete an item, we should initialize the parent panel, // If we delete an item, we should initialize the parent panel,
// because it could now be invalid. // because it could now be invalid.
@@ -203,7 +207,7 @@ void wxControl::SetLabel(const wxString& title)
if ( m_macControl ) if ( m_macControl )
{ {
UMASetControlTitle( (ControlHandle) m_macControl , m_label , m_font.GetEncoding() ) ; UMASetControlTitle( (ControlHandle) m_macControl , m_label , m_font.GetEncoding() ) ;
} }
Refresh() ; Refresh() ;
} }
@@ -212,7 +216,7 @@ wxSize wxControl::DoGetBestSize() const
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlHandle) m_macControl == NULL )
return wxWindow::DoGetBestSize() ; return wxWindow::DoGetBestSize() ;
Rect bestsize = { 0 , 0 , 0 , 0 } ; Rect bestsize = { 0 , 0 , 0 , 0 } ;
short baselineoffset ; short baselineoffset ;
int bestWidth, bestHeight ; int bestWidth, bestHeight ;
@@ -230,12 +234,12 @@ wxSize wxControl::DoGetBestSize() const
} }
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
{ {
bestsize.bottom = 24 ; bestsize.bottom = 24 ;
} }
} }
bestWidth = bestsize.right - bestsize.left ; bestWidth = bestsize.right - bestsize.left ;
bestWidth += 2 * m_macHorizontalBorder ; bestWidth += 2 * m_macHorizontalBorder ;
bestHeight = bestsize.bottom - bestsize.top ; bestHeight = bestsize.bottom - bestsize.top ;
@@ -244,7 +248,7 @@ wxSize wxControl::DoGetBestSize() const
bestHeight += 2 * m_macVerticalBorder; bestHeight += 2 * m_macVerticalBorder;
return wxSize(bestWidth, bestHeight); return wxSize(bestWidth, bestHeight);
} }
@@ -282,11 +286,11 @@ void wxRemoveMacControlAssociation(wxControl *control)
wxWinMacControlList->DeleteObject(control); wxWinMacControlList->DeleteObject(control);
} }
void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label , void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel ) const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
{ {
m_label = label ; m_label = label ;
@@ -295,7 +299,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l
m_height = size.y ; m_height = size.y ;
m_x = pos.x ; m_x = pos.x ;
m_y = pos.y ; m_y = pos.y ;
((Rect*)outBounds)->top = -10; ((Rect*)outBounds)->top = -10;
((Rect*)outBounds)->left = -10; ((Rect*)outBounds)->left = -10;
((Rect*)outBounds)->bottom = 0; ((Rect*)outBounds)->bottom = 0;
@@ -308,7 +312,7 @@ void wxControl::MacPostControlCreate()
{ {
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
DoSetWindowVariant( m_windowVariant ) ; DoSetWindowVariant( m_windowVariant ) ;
/* /*
if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
{ {
// no font // no font
@@ -318,19 +322,19 @@ void wxControl::MacPostControlCreate()
ControlFontStyleRec controlstyle ; ControlFontStyleRec controlstyle ;
controlstyle.flags = kControlUseFontMask ; controlstyle.flags = kControlUseFontMask ;
controlstyle.font = kControlFontSmallBoldSystemFont ; controlstyle.font = kControlFontSmallBoldSystemFont ;
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ; ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
} }
else else
{ {
ControlFontStyleRec controlstyle ; ControlFontStyleRec controlstyle ;
controlstyle.flags = kControlUseFontMask ; controlstyle.flags = kControlUseFontMask ;
if (IsKindOf( CLASSINFO( wxButton ) ) ) if (IsKindOf( CLASSINFO( wxButton ) ) )
controlstyle.font = kControlFontBigSystemFont ; // eventually kControlFontBigSystemFont ; controlstyle.font = kControlFontBigSystemFont ; // eventually kControlFontBigSystemFont ;
else else
controlstyle.font = kControlFontSmallSystemFont ; controlstyle.font = kControlFontSmallSystemFont ;
::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ; ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
} }
*/ */
@@ -372,43 +376,43 @@ void wxControl::MacPostControlCreate()
#endif #endif
#endif #endif
SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ; SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
// Adjust the controls size and position // Adjust the controls size and position
wxPoint pos(m_x, m_y); wxPoint pos(m_x, m_y);
wxSize best_size( DoGetBestSize() ); wxSize best_size( DoGetBestSize() );
wxSize new_size( m_width, m_height ); wxSize new_size( m_width, m_height );
m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control
if (new_size.x == -1) { if (new_size.x == -1) {
new_size.x = best_size.x; new_size.x = best_size.x;
} }
if (new_size.y == -1) { if (new_size.y == -1) {
new_size.y = best_size.y; new_size.y = best_size.y;
} }
SetSize(pos.x, pos.y, new_size.x, new_size.y); SetSize(pos.x, pos.y, new_size.x, new_size.y);
#if wxUSE_UNICODE #if wxUSE_UNICODE
UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ; UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ;
#endif #endif
if ( m_macControlIsShown ) if ( m_macControlIsShown )
UMAShowControl( (ControlHandle) m_macControl ) ; UMAShowControl( (ControlHandle) m_macControl ) ;
SetCursor( *wxSTANDARD_CURSOR ) ; SetCursor( *wxSTANDARD_CURSOR ) ;
Refresh() ; Refresh() ;
} }
void wxControl::MacAdjustControlRect() void wxControl::MacAdjustControlRect()
{ {
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
if ( m_width == -1 || m_height == -1 ) if ( m_width == -1 || m_height == -1 )
{ {
Rect bestsize = { 0 , 0 , 0 , 0 } ; Rect bestsize = { 0 , 0 , 0 , 0 } ;
short baselineoffset ; short baselineoffset ;
::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ; ::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
if ( EmptyRect( &bestsize ) ) if ( EmptyRect( &bestsize ) )
@@ -423,7 +427,7 @@ void wxControl::MacAdjustControlRect()
} }
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) ) else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
{ {
bestsize.bottom = 24 ; bestsize.bottom = 24 ;
} }
} }
@@ -441,7 +445,7 @@ void wxControl::MacAdjustControlRect()
} }
else else
m_width = bestsize.right - bestsize.left ; m_width = bestsize.right - bestsize.left ;
m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ; m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
} }
if ( m_height == -1 ) if ( m_height == -1 )
@@ -452,11 +456,11 @@ void wxControl::MacAdjustControlRect()
m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ; m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
} }
MacUpdateDimensions() ; MacUpdateDimensions() ;
} }
} }
WXWidget wxControl::MacGetContainerForEmbedding() WXWidget wxControl::MacGetContainerForEmbedding()
{ {
if ( m_macControl ) if ( m_macControl )
return m_macControl ; return m_macControl ;
@@ -464,29 +468,29 @@ WXWidget wxControl::MacGetContainerForEmbedding()
return wxWindow::MacGetContainerForEmbedding() ; return wxWindow::MacGetContainerForEmbedding() ;
} }
void wxControl::MacUpdateDimensions() void wxControl::MacUpdateDimensions()
{ {
// actually in the current systems this should never be possible, but later reparenting // actually in the current systems this should never be possible, but later reparenting
// may become a reality // may become a reality
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlHandle) m_macControl == NULL )
return ; return ;
if ( GetParent() == NULL ) if ( GetParent() == NULL )
return ; return ;
WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
if ( rootwindow == NULL ) if ( rootwindow == NULL )
return ; return ;
Rect oldBounds ; Rect oldBounds ;
GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ; GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ; int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ; int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ; int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ; int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ; GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ; bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ; bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
@@ -504,19 +508,19 @@ void wxControl::MacUpdateDimensions()
} }
} }
void wxControl::MacSuperChangedPosition() void wxControl::MacSuperChangedPosition()
{ {
MacUpdateDimensions() ; MacUpdateDimensions() ;
wxWindow::MacSuperChangedPosition() ; wxWindow::MacSuperChangedPosition() ;
} }
void wxControl::MacSuperEnabled( bool enabled ) void wxControl::MacSuperEnabled( bool enabled )
{ {
Refresh(FALSE) ; Refresh(false) ;
wxWindow::MacSuperEnabled( enabled ) ; wxWindow::MacSuperEnabled( enabled ) ;
} }
void wxControl::MacSuperShown( bool show ) void wxControl::MacSuperShown( bool show )
{ {
if ( (ControlHandle) m_macControl ) if ( (ControlHandle) m_macControl )
{ {
@@ -537,7 +541,7 @@ void wxControl::MacSuperShown( bool show )
} }
} }
} }
wxWindow::MacSuperShown( show ) ; wxWindow::MacSuperShown( show ) ;
} }
@@ -566,11 +570,11 @@ void wxControl::DoSetSize(int x, int y,
return ; return ;
} }
bool wxControl::Show(bool show) bool wxControl::Show(bool show)
{ {
if ( !wxWindow::Show( show ) ) if ( !wxWindow::Show( show ) )
return FALSE ; return false ;
if ( (ControlHandle) m_macControl ) if ( (ControlHandle) m_macControl )
{ {
if ( !show ) if ( !show )
@@ -590,13 +594,13 @@ bool wxControl::Show(bool show)
} }
} }
} }
return TRUE ; return true ;
} }
bool wxControl::Enable(bool enable) bool wxControl::Enable(bool enable)
{ {
if ( !wxWindow::Enable(enable) ) if ( !wxWindow::Enable(enable) )
return FALSE; return false;
if ( (ControlHandle) m_macControl ) if ( (ControlHandle) m_macControl )
{ {
@@ -605,7 +609,7 @@ bool wxControl::Enable(bool enable)
else else
UMADeactivateControl( (ControlHandle) m_macControl ) ; UMADeactivateControl( (ControlHandle) m_macControl ) ;
} }
return TRUE ; return true ;
} }
void wxControl::Refresh(bool eraseBack, const wxRect *rect) void wxControl::Refresh(bool eraseBack, const wxRect *rect)
@@ -642,18 +646,18 @@ void wxControl::OnPaint(wxPaintEvent& event)
} }
void wxControl::OnEraseBackground(wxEraseEvent& event) void wxControl::OnEraseBackground(wxEraseEvent& event)
{ {
wxWindow::OnEraseBackground( event ) ; wxWindow::OnEraseBackground( event ) ;
} }
void wxControl::OnKeyDown( wxKeyEvent &event ) void wxControl::OnKeyDown( wxKeyEvent &event )
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlHandle) m_macControl == NULL )
return ; return ;
#if TARGET_CARBON #if TARGET_CARBON
char charCode ; char charCode ;
UInt32 keyCode ; UInt32 keyCode ;
UInt32 modifiers ; UInt32 modifiers ;
GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode ); GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
@@ -661,7 +665,7 @@ void wxControl::OnKeyDown( wxKeyEvent &event )
GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
::HandleControlKey( (ControlHandle) m_macControl , keyCode , charCode , modifiers ) ; ::HandleControlKey( (ControlHandle) m_macControl , keyCode , charCode , modifiers ) ;
#else #else
EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
short keycode ; short keycode ;
@@ -673,43 +677,43 @@ void wxControl::OnKeyDown( wxKeyEvent &event )
#endif #endif
} }
void wxControl::OnMouseEvent( wxMouseEvent &event ) void wxControl::OnMouseEvent( wxMouseEvent &event )
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlHandle) m_macControl == NULL )
{ {
event.Skip() ; event.Skip() ;
return ; return ;
} }
if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK ) if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
{ {
int x = event.m_x ; int x = event.m_x ;
int y = event.m_y ; int y = event.m_y ;
MacClientToRootWindow( &x , &y ) ; MacClientToRootWindow( &x , &y ) ;
ControlHandle control ; ControlHandle control ;
Point localwhere ; Point localwhere ;
SInt16 controlpart ; SInt16 controlpart ;
localwhere.h = x ; localwhere.h = x ;
localwhere.v = y ; localwhere.v = y ;
short modifiers = 0; short modifiers = 0;
if ( !event.m_leftDown && !event.m_rightDown ) if ( !event.m_leftDown && !event.m_rightDown )
modifiers |= btnState ; modifiers |= btnState ;
if ( event.m_shiftDown ) if ( event.m_shiftDown )
modifiers |= shiftKey ; modifiers |= shiftKey ;
if ( event.m_controlDown ) if ( event.m_controlDown )
modifiers |= controlKey ; modifiers |= controlKey ;
if ( event.m_altDown ) if ( event.m_altDown )
modifiers |= optionKey ; modifiers |= optionKey ;
if ( event.m_metaDown ) if ( event.m_metaDown )
modifiers |= cmdKey ; modifiers |= cmdKey ;
{ {
@@ -719,7 +723,7 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
{ {
controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
wxTheApp->s_lastMouseDown = 0 ; wxTheApp->s_lastMouseDown = 0 ;
if ( control && controlpart != kControlNoPart ) if ( control && controlpart != kControlNoPart )
{ {
MacHandleControlClick( (WXWidget) control , controlpart , false /* mouse not down anymore */ ) ; MacHandleControlClick( (WXWidget) control , controlpart , false /* mouse not down anymore */ ) ;
} }
@@ -729,19 +733,19 @@ void wxControl::OnMouseEvent( wxMouseEvent &event )
} }
else else
{ {
event.Skip() ; event.Skip() ;
} }
} }
bool wxControl::MacCanFocus() const bool wxControl::MacCanFocus() const
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlHandle) m_macControl == NULL )
return true ; return true ;
else else
return false ; return false ;
} }
void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
{ {
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
} }
@@ -752,16 +756,16 @@ void wxControl::DoSetWindowVariant( wxWindowVariant variant )
{ {
wxWindow::SetWindowVariant( variant ) ; wxWindow::SetWindowVariant( variant ) ;
return ; return ;
}
m_windowVariant = variant ;
ControlSize size ; }
ControlFontStyleRec fontStyle; m_windowVariant = variant ;
fontStyle.flags = kControlUseFontMask ;
ControlSize size ;
ControlFontStyleRec fontStyle;
fontStyle.flags = kControlUseFontMask ;
// we will get that from the settings later // we will get that from the settings later
// and make this NORMAL later, but first // and make this NORMAL later, but first
// we have a few calculations that we must fix // we have a few calculations that we must fix
if ( variant == wxWINDOW_VARIANT_NORMAL ) if ( variant == wxWINDOW_VARIANT_NORMAL )
@@ -771,38 +775,38 @@ void wxControl::DoSetWindowVariant( wxWindowVariant variant )
else else
variant = wxWINDOW_VARIANT_SMALL ; variant = wxWINDOW_VARIANT_SMALL ;
} }
switch ( variant ) switch ( variant )
{ {
case wxWINDOW_VARIANT_NORMAL : case wxWINDOW_VARIANT_NORMAL :
size = kControlSizeNormal; size = kControlSizeNormal;
fontStyle.font = kControlFontBigSystemFont; fontStyle.font = kControlFontBigSystemFont;
break ; break ;
case wxWINDOW_VARIANT_SMALL : case wxWINDOW_VARIANT_SMALL :
size = kControlSizeSmall; size = kControlSizeSmall;
fontStyle.font = kControlFontSmallSystemFont; fontStyle.font = kControlFontSmallSystemFont;
break ; break ;
case wxWINDOW_VARIANT_MINI : case wxWINDOW_VARIANT_MINI :
if (UMAGetSystemVersion() >= 0x1030 ) if (UMAGetSystemVersion() >= 0x1030 )
{ {
size = 3 ; // not always defined in the header size = 3 ; // not always defined in the header
fontStyle.font = -5 ; // not always defined in the header fontStyle.font = -5 ; // not always defined in the header
} }
else else
{ {
size = kControlSizeSmall; size = kControlSizeSmall;
fontStyle.font = kControlFontSmallSystemFont; fontStyle.font = kControlFontSmallSystemFont;
} }
break; break;
break ; break ;
case wxWINDOW_VARIANT_LARGE : case wxWINDOW_VARIANT_LARGE :
size = kControlSizeLarge; size = kControlSizeLarge;
fontStyle.font = kControlFontBigSystemFont; fontStyle.font = kControlFontBigSystemFont;
break ; break ;
default: default:
wxFAIL_MSG(_T("unexpected window variant")); wxFAIL_MSG(_T("unexpected window variant"));
break ; break ;
} }
::SetControlData( (ControlHandle) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size ); ::SetControlData( (ControlHandle) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size );
::SetControlFontStyle( (ControlHandle) m_macControl , &fontStyle ); ::SetControlFontStyle( (ControlHandle) m_macControl , &fontStyle );
} }

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: cursor.cpp // Name: src/mac/classic/cursor.cpp
// Purpose: wxCursor class // Purpose: wxCursor class
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/app.h" #include "wx/app.h"
#include "wx/cursor.h" #include "wx/cursor.h"
@@ -41,7 +45,7 @@ wxCursor gMacCurrentCursor ;
wxCursorRefData::wxCursorRefData() wxCursorRefData::wxCursorRefData()
{ {
m_width = 16; m_width = 16;
m_height = 16; m_height = 16;
m_hCursor = NULL ; m_hCursor = NULL ;
m_disposeHandle = false ; m_disposeHandle = false ;
@@ -59,7 +63,7 @@ wxCursorRefData::~wxCursorRefData()
else if ( m_disposeHandle ) else if ( m_disposeHandle )
{ {
::DisposeHandle( (Handle ) m_hCursor ) ; ::DisposeHandle( (Handle ) m_hCursor ) ;
} }
else if ( m_releaseHandle ) else if ( m_releaseHandle )
{ {
// we don't release the resource since it may already // we don't release the resource since it may already
@@ -82,24 +86,24 @@ wxCursor::wxCursor( const wxImage &image )
CreateFromImage( image ) ; CreateFromImage( image ) ;
} }
wxCursor::wxCursor(const char **bits) wxCursor::wxCursor(const char **bits)
{ {
(void) CreateFromXpm(bits); (void) CreateFromXpm(bits);
} }
wxCursor::wxCursor(char **bits) wxCursor::wxCursor(char **bits)
{ {
(void) CreateFromXpm((const char **)bits); (void) CreateFromXpm((const char **)bits);
} }
bool wxCursor::CreateFromXpm(const char **bits) bool wxCursor::CreateFromXpm(const char **bits)
{ {
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid cursor data") ); wxCHECK_MSG( bits != NULL, false, wxT("invalid cursor data") );
wxXPMDecoder decoder; wxXPMDecoder decoder;
wxImage img = decoder.ReadData(bits); wxImage img = decoder.ReadData(bits);
wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid cursor data") ); wxCHECK_MSG( img.Ok(), false, wxT("invalid cursor data") );
CreateFromImage( img ) ; CreateFromImage( img ) ;
return TRUE; return true;
} }
short GetCTabIndex( CTabHandle colors , RGBColor *col ) short GetCTabIndex( CTabHandle colors , RGBColor *col )
@@ -120,18 +124,18 @@ short GetCTabIndex( CTabHandle colors , RGBColor *col )
return retval ; return retval ;
} }
void wxCursor::CreateFromImage(const wxImage & image) void wxCursor::CreateFromImage(const wxImage & image)
{ {
m_refData = new wxCursorRefData; m_refData = new wxCursorRefData;
int w = 16; int w = 16;
int h = 16; int h = 16;
int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X); int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y); int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
int image_w = image.GetWidth(); int image_w = image.GetWidth();
int image_h = image.GetHeight(); int image_h = image.GetHeight();
wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w && wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w &&
hotSpotY >= 0 && hotSpotY < image_h, hotSpotY >= 0 && hotSpotY < image_h,
_T("invalid cursor hot spot coordinates") ); _T("invalid cursor hot spot coordinates") );
@@ -149,15 +153,15 @@ void wxCursor::CreateFromImage(const wxImage & image)
} }
else if ((w != image_w) || (h != image_h)) else if ((w != image_w) || (h != image_h))
{ {
hotSpotX = int(hotSpotX * double(w) / double(image_w)); hotSpotX = int(hotSpotX * double(w) / double(image_w));
hotSpotY = int(hotSpotY * double(h) / double(image_h)); hotSpotY = int(hotSpotY * double(h) / double(image_h));
image16 = image.Scale(w, h); image16 = image.Scale(w, h);
} }
unsigned char * rgbBits = image16.GetData(); unsigned char * rgbBits = image16.GetData();
bool bHasMask = image16.HasMask() ; bool bHasMask = image16.HasMask() ;
#if 0 #if 0
// monochrome implementation // monochrome implementation
M_CURSORDATA->m_hCursor = NewHandle( sizeof( Cursor ) ) ; M_CURSORDATA->m_hCursor = NewHandle( sizeof( Cursor ) ) ;
@@ -166,7 +170,7 @@ void wxCursor::CreateFromImage(const wxImage & image)
CursPtr cp = *(CursHandle)M_CURSORDATA->m_hCursor ; CursPtr cp = *(CursHandle)M_CURSORDATA->m_hCursor ;
memset( cp->data , 0 , sizeof( Bits16 ) ) ; memset( cp->data , 0 , sizeof( Bits16 ) ) ;
memset( cp->mask , 0 , sizeof( Bits16 ) ) ; memset( cp->mask , 0 , sizeof( Bits16 ) ) ;
unsigned char mr = image16.GetMaskRed() ; unsigned char mr = image16.GetMaskRed() ;
unsigned char mg = image16.GetMaskGreen() ; unsigned char mg = image16.GetMaskGreen() ;
unsigned char mb = image16.GetMaskBlue() ; unsigned char mb = image16.GetMaskBlue() ;
@@ -174,7 +178,7 @@ void wxCursor::CreateFromImage(const wxImage & image)
{ {
short rowbits = 0 ; short rowbits = 0 ;
short maskbits = 0 ; short maskbits = 0 ;
for ( int x = 0 ; x < w ; ++x ) for ( int x = 0 ; x < w ; ++x )
{ {
long pos = (y * w + x) * 3; long pos = (y * w + x) * 3;
@@ -221,36 +225,36 @@ void wxCursor::CreateFromImage(const wxImage & image)
} }
HLock( (Handle) ch) ; HLock( (Handle) ch) ;
(**ch).crsrType = 0x8001 ; // color cursors (**ch).crsrType = 0x8001 ; // color cursors
(**ch).crsrMap = pm ; (**ch).crsrMap = pm ;
short bytesPerRow = bytesPerPixel * extent ; short bytesPerRow = bytesPerPixel * extent ;
(**pm).baseAddr = 0; (**pm).baseAddr = 0;
(**pm).rowBytes = bytesPerRow | 0x8000; (**pm).rowBytes = bytesPerRow | 0x8000;
(**pm).bounds = bounds; (**pm).bounds = bounds;
(**pm).pmVersion = 0; (**pm).pmVersion = 0;
(**pm).packType = 0; (**pm).packType = 0;
(**pm).packSize = 0; (**pm).packSize = 0;
(**pm).hRes = 0x00480000; /* 72 DPI default res */ (**pm).hRes = 0x00480000; /* 72 DPI default res */
(**pm).vRes = 0x00480000; /* 72 DPI default res */ (**pm).vRes = 0x00480000; /* 72 DPI default res */
(**pm).pixelSize = depth; (**pm).pixelSize = depth;
(**pm).pixelType = 0; (**pm).pixelType = 0;
(**pm).cmpCount = 1; (**pm).cmpCount = 1;
(**pm).cmpSize = depth; (**pm).cmpSize = depth;
(**pm).pmTable = newColors; (**pm).pmTable = newColors;
(**ch).crsrData = NewHandleClear( extent * bytesPerRow ) ; (**ch).crsrData = NewHandleClear( extent * bytesPerRow ) ;
(**ch).crsrXData = NULL ; (**ch).crsrXData = NULL ;
(**ch).crsrXValid = 0; (**ch).crsrXValid = 0;
(**ch).crsrXHandle = NULL; (**ch).crsrXHandle = NULL;
(**ch).crsrHotSpot.h = hotSpotX ; (**ch).crsrHotSpot.h = hotSpotX ;
(**ch).crsrHotSpot.v = hotSpotY ; (**ch).crsrHotSpot.v = hotSpotY ;
(**ch).crsrXTable = NULL ; (**ch).crsrXTable = NULL ;
(**ch).crsrID = GetCTSeed() ; (**ch).crsrID = GetCTSeed() ;
memset( (**ch).crsr1Data , 0 , sizeof( Bits16 ) ) ; memset( (**ch).crsr1Data , 0 , sizeof( Bits16 ) ) ;
memset( (**ch).crsrMask , 0 , sizeof( Bits16 ) ) ; memset( (**ch).crsrMask , 0 , sizeof( Bits16 ) ) ;
unsigned char mr = image16.GetMaskRed() ; unsigned char mr = image16.GetMaskRed() ;
unsigned char mg = image16.GetMaskGreen() ; unsigned char mg = image16.GetMaskGreen() ;
unsigned char mb = image16.GetMaskBlue() ; unsigned char mb = image16.GetMaskBlue() ;
@@ -258,7 +262,7 @@ void wxCursor::CreateFromImage(const wxImage & image)
{ {
short rowbits = 0 ; short rowbits = 0 ;
short maskbits = 0 ; short maskbits = 0 ;
for ( int x = 0 ; x < w ; ++x ) for ( int x = 0 ; x < w ; ++x )
{ {
long pos = (y * w + x) * 3; long pos = (y * w + x) * 3;
@@ -267,7 +271,7 @@ void wxCursor::CreateFromImage(const wxImage & image)
unsigned char g = rgbBits[pos+1] ; unsigned char g = rgbBits[pos+1] ;
unsigned char b = rgbBits[pos+2] ; unsigned char b = rgbBits[pos+2] ;
RGBColor col = { 0xFFFF ,0xFFFF, 0xFFFF } ; RGBColor col = { 0xFFFF ,0xFFFF, 0xFFFF } ;
if ( bHasMask && r==mr && g==mg && b==mb ) if ( bHasMask && r==mr && g==mg && b==mb )
{ {
// masked area, does not appear anywhere // masked area, does not appear anywhere
@@ -279,10 +283,10 @@ void wxCursor::CreateFromImage(const wxImage & image)
rowbits |= ( 1 << (15-x) ) ; rowbits |= ( 1 << (15-x) ) ;
} }
maskbits |= ( 1 << (15-x) ) ; maskbits |= ( 1 << (15-x) ) ;
col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ; col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ;
} }
*((*(**ch).crsrData) + y * bytesPerRow + x) = *((*(**ch).crsrData) + y * bytesPerRow + x) =
GetCTabIndex( newColors , &col) ; GetCTabIndex( newColors , &col) ;
} }
(**ch).crsr1Data[y] = rowbits ; (**ch).crsr1Data[y] = rowbits ;
@@ -292,7 +296,7 @@ void wxCursor::CreateFromImage(const wxImage & image)
{ {
memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ; memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ;
} }
HUnlock((Handle) ch) ; HUnlock((Handle) ch) ;
M_CURSORDATA->m_hCursor = ch ; M_CURSORDATA->m_hCursor = ch ;
M_CURSORDATA->m_isColorCursor = true ; M_CURSORDATA->m_isColorCursor = true ;
@@ -305,8 +309,8 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE ) if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE )
{ {
Str255 theName ; Str255 theName ;
wxMacStringToPascal( cursor_file , theName ) ; wxMacStringToPascal( cursor_file , theName ) ;
wxStAppResource resload ; wxStAppResource resload ;
Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ; Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ;
if ( resHandle ) if ( resHandle )
@@ -320,7 +324,7 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
M_CURSORDATA->m_isColorCursor = true ; M_CURSORDATA->m_isColorCursor = true ;
} }
else else
{ {
Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ; Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ;
if ( resHandle ) if ( resHandle )
{ {
@@ -352,7 +356,7 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
wxCursor::wxCursor(int cursor_type) wxCursor::wxCursor(int cursor_type)
{ {
m_refData = new wxCursorRefData; m_refData = new wxCursorRefData;
switch (cursor_type) switch (cursor_type)
{ {
case wxCURSOR_COPY_ARROW: case wxCURSOR_COPY_ARROW:
@@ -485,7 +489,7 @@ wxCursor::wxCursor(int cursor_type)
M_CURSORDATA->m_releaseHandle = true ; M_CURSORDATA->m_releaseHandle = true ;
} }
void wxCursor::MacInstall() const void wxCursor::MacInstall() const
{ {
gMacCurrentCursor = *this ; gMacCurrentCursor = *this ;
if ( m_refData && M_CURSORDATA->m_themeCursor != -1 ) if ( m_refData && M_CURSORDATA->m_themeCursor != -1 )
@@ -514,5 +518,3 @@ void wxSetCursor(const wxCursor& cursor)
{ {
cursor.MacInstall() ; cursor.MacInstall() ;
} }

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: mac/dataobj.cpp // Name: src/mac/classic/dataobj.cpp
// Purpose: implementation of wxDataObject class // Purpose: implementation of wxDataObject class
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
@@ -9,6 +9,12 @@
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// ============================================================================ // ============================================================================
// declarations // declarations
// ============================================================================ // ============================================================================
@@ -17,13 +23,9 @@
// headers // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/intl.h" #include "wx/intl.h"
#endif #endif
#include "wx/defs.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/dataobj.h" #include "wx/dataobj.h"
@@ -166,9 +168,7 @@ bool wxDataObject::IsSupportedFormat(
// wxFileDataObject // wxFileDataObject
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxFileDataObject::GetDataHere( bool wxFileDataObject::GetDataHere( void* pBuf ) const
void* pBuf
) const
{ {
wxString sFilenames; wxString sFilenames;
@@ -179,7 +179,7 @@ bool wxFileDataObject::GetDataHere(
} }
memcpy(pBuf, sFilenames.mbc_str(), sFilenames.Len() + 1); memcpy(pBuf, sFilenames.mbc_str(), sFilenames.Len() + 1);
return TRUE; return true;
} }
size_t wxFileDataObject::GetDataSize() const size_t wxFileDataObject::GetDataSize() const
@@ -204,7 +204,7 @@ bool wxFileDataObject::SetData(
AddFile(wxString::FromAscii((char*)pBuf)); AddFile(wxString::FromAscii((char*)pBuf));
return TRUE; return true;
} }
void wxFileDataObject::AddFile( void wxFileDataObject::AddFile(
@@ -252,13 +252,13 @@ void wxBitmapDataObject::SetBitmap(
} }
} }
void wxBitmapDataObject::Init() void wxBitmapDataObject::Init()
{ {
m_pictHandle = NULL ; m_pictHandle = NULL ;
m_pictCreated = false ; m_pictCreated = false ;
} }
void wxBitmapDataObject::Clear() void wxBitmapDataObject::Clear()
{ {
if ( m_pictCreated && m_pictHandle ) if ( m_pictCreated && m_pictHandle )
{ {
@@ -267,17 +267,15 @@ void wxBitmapDataObject::Clear()
m_pictHandle = NULL ; m_pictHandle = NULL ;
} }
bool wxBitmapDataObject::GetDataHere( bool wxBitmapDataObject::GetDataHere( void* pBuf ) const
void* pBuf
) const
{ {
if (!m_pictHandle) if (!m_pictHandle)
{ {
wxFAIL_MSG(wxT("attempt to copy empty bitmap failed")); wxFAIL_MSG(wxT("attempt to copy empty bitmap failed"));
return FALSE; return false;
} }
memcpy(pBuf, *(Handle)m_pictHandle, GetHandleSize((Handle)m_pictHandle)); memcpy(pBuf, *(Handle)m_pictHandle, GetHandleSize((Handle)m_pictHandle));
return TRUE; return true;
} }
size_t wxBitmapDataObject::GetDataSize() const size_t wxBitmapDataObject::GetDataSize() const
@@ -296,7 +294,7 @@ bool wxBitmapDataObject::SetData(
m_pictHandle = picHandle ; m_pictHandle = picHandle ;
m_pictCreated = false ; m_pictCreated = false ;
Rect frame = (**picHandle).picFrame ; Rect frame = (**picHandle).picFrame ;
m_bitmap.SetPict( picHandle ) ; m_bitmap.SetPict( picHandle ) ;
m_bitmap.SetWidth( frame.right - frame.left ) ; m_bitmap.SetWidth( frame.right - frame.left ) ;
m_bitmap.SetHeight( frame.bottom - frame.top ) ; m_bitmap.SetHeight( frame.bottom - frame.top ) ;

View File

@@ -1,15 +1,20 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: dirdlg.cpp // Name: src/mac/classic/dirdlg.cpp
// Purpose: wxDirDialog // Purpose: wxDirDialog
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/dirdlg.h" #include "wx/dirdlg.h"
@@ -49,7 +54,7 @@ int wxDirDialog::ShowModal()
NavReplyRecord mNavReply; NavReplyRecord mNavReply;
AEDesc* mDefaultLocation = NULL ; AEDesc* mDefaultLocation = NULL ;
bool mSelectDefault = false ; bool mSelectDefault = false ;
::NavGetDefaultDialogOptions(&mNavOptions); ::NavGetDefaultDialogOptions(&mNavOptions);
mNavFilterUPP = nil; mNavFilterUPP = nil;
@@ -63,20 +68,20 @@ int wxDirDialog::ShowModal()
mNavReply.selection.dataHandle = nil; mNavReply.selection.dataHandle = nil;
mNavReply.keyScript = smSystemScript; mNavReply.keyScript = smSystemScript;
mNavReply.fileTranslation = nil; mNavReply.fileTranslation = nil;
// Set default location, the location // Set default location, the location
// that's displayed when the dialog // that's displayed when the dialog
// first appears // first appears
if ( mDefaultLocation ) { if ( mDefaultLocation ) {
if (mSelectDefault) { if (mSelectDefault) {
mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation; mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
} else { } else {
mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation; mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
} }
} }
OSErr err = ::NavChooseFolder( OSErr err = ::NavChooseFolder(
mDefaultLocation, mDefaultLocation,
&mNavReply, &mNavReply,
@@ -84,36 +89,36 @@ int wxDirDialog::ShowModal()
NULL, NULL,
mNavFilterUPP, mNavFilterUPP,
0L); // User Data 0L); // User Data
if ( (err != noErr) && (err != userCanceledErr) ) { if ( (err != noErr) && (err != userCanceledErr) ) {
m_path = wxT("") ; m_path = wxEmptyString ;
return wxID_CANCEL ; return wxID_CANCEL ;
} }
if (mNavReply.validRecord) { // User chose a folder if (mNavReply.validRecord) { // User chose a folder
FSSpec folderInfo; FSSpec folderInfo;
FSSpec outFileSpec ; FSSpec outFileSpec ;
AEDesc specDesc ; AEDesc specDesc ;
OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc); OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc);
if ( err != noErr ) { if ( err != noErr ) {
m_path = wxT("") ; m_path = wxEmptyString ;
return wxID_CANCEL ; return wxID_CANCEL ;
} }
folderInfo = **(FSSpec**) specDesc.dataHandle; folderInfo = **(FSSpec**) specDesc.dataHandle;
if (specDesc.dataHandle != nil) { if (specDesc.dataHandle != nil) {
::AEDisposeDesc(&specDesc); ::AEDisposeDesc(&specDesc);
} }
// mNavReply.GetFileSpec(folderInfo); // mNavReply.GetFileSpec(folderInfo);
// The FSSpec from NavChooseFolder is NOT the file spec // The FSSpec from NavChooseFolder is NOT the file spec
// for the folder. The parID field is actually the DirID // for the folder. The parID field is actually the DirID
// of the folder itself, not the folder's parent, and // of the folder itself, not the folder's parent, and
// the name field is empty. We must call PBGetCatInfo // the name field is empty. We must call PBGetCatInfo
// to get the parent DirID and folder name // to get the parent DirID and folder name
Str255 name; Str255 name;
CInfoPBRec thePB; // Directory Info Parameter Block CInfoPBRec thePB; // Directory Info Parameter Block
thePB.dirInfo.ioCompletion = nil; thePB.dirInfo.ioCompletion = nil;
@@ -121,20 +126,19 @@ int wxDirDialog::ShowModal()
thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID
thePB.dirInfo.ioNamePtr = name; thePB.dirInfo.ioNamePtr = name;
thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID
err = ::PBGetCatInfoSync(&thePB); err = ::PBGetCatInfoSync(&thePB);
if ( err != noErr ) { if ( err != noErr ) {
m_path = wxT("") ; m_path = wxEmptyString;
return wxID_CANCEL ; return wxID_CANCEL ;
} }
// Create cannonical FSSpec // Create cannonical FSSpec
::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID, ::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID,
name, &outFileSpec); name, &outFileSpec);
// outFolderDirID = thePB.dirInfo.ioDrDirID; // outFolderDirID = thePB.dirInfo.ioDrDirID;
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ; m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
return wxID_OK ; return wxID_OK ;
} }
return wxID_CANCEL; return wxID_CANCEL;
} }

View File

@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: dnd.cpp // Name: src/mac/classic/dnd.cpp
// Purpose: wxDropTarget, wxDropSource, wxDataObject implementation // Purpose: wxDropTarget, wxDropSource, wxDataObject implementation
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
@@ -9,7 +9,11 @@
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
@@ -26,14 +30,14 @@
void wxMacEnsureTrackingHandlersInstalled() ; void wxMacEnsureTrackingHandlersInstalled() ;
typedef struct typedef struct
{ {
wxWindow* m_currentTargetWindow ; wxWindow* m_currentTargetWindow ;
wxDropTarget* m_currentTarget ; wxDropTarget* m_currentTarget ;
wxDropSource* m_currentSource ; wxDropSource* m_currentSource ;
} MacTrackingGlobals ; } MacTrackingGlobals ;
MacTrackingGlobals gTrackingGlobals ; MacTrackingGlobals gTrackingGlobals ;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// wxDropTarget // wxDropTarget
@@ -56,7 +60,7 @@ wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x),
bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) ) bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
{ {
if (!m_dataObject) if (!m_dataObject)
return FALSE; return false;
return CurrentDragHasSupportedFormat() ; return CurrentDragHasSupportedFormat() ;
} }
@@ -73,13 +77,13 @@ wxDragResult wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
return GetData() ? def : wxDragNone; return GetData() ? def : wxDragNone;
} }
bool wxDropTarget::CurrentDragHasSupportedFormat() bool wxDropTarget::CurrentDragHasSupportedFormat()
{ {
bool supported = false ; bool supported = false ;
if ( gTrackingGlobals.m_currentSource != NULL ) if ( gTrackingGlobals.m_currentSource != NULL )
{ {
wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ;
if ( data ) if ( data )
{ {
size_t formatcount = data->GetFormatCount() ; size_t formatcount = data->GetFormatCount() ;
@@ -88,7 +92,7 @@ bool wxDropTarget::CurrentDragHasSupportedFormat()
for (size_t i = 0; !supported && i < formatcount ; i++) for (size_t i = 0; !supported && i < formatcount ; i++)
{ {
wxDataFormat format = array[i] ; wxDataFormat format = array[i] ;
if ( m_dataObject->IsSupported( format ) ) if ( m_dataObject->IsSupported( format ) )
{ {
supported = true ; supported = true ;
break ; break ;
@@ -102,7 +106,7 @@ bool wxDropTarget::CurrentDragHasSupportedFormat()
UInt16 items ; UInt16 items ;
OSErr result; OSErr result;
CountDragItems((DragReference)m_currentDrag, &items); CountDragItems((DragReference)m_currentDrag, &items);
for (UInt16 index = 1; index <= items && supported == false ; ++index) for (UInt16 index = 1; index <= items && supported == false ; ++index)
{ {
ItemReference theItem; ItemReference theItem;
FlavorType theType ; FlavorType theType ;
@@ -120,22 +124,22 @@ bool wxDropTarget::CurrentDragHasSupportedFormat()
} }
} }
} }
return supported ; return supported ;
} }
bool wxDropTarget::GetData() bool wxDropTarget::GetData()
{ {
if (!m_dataObject) if (!m_dataObject)
return FALSE; return false;
if ( !CurrentDragHasSupportedFormat() ) if ( !CurrentDragHasSupportedFormat() )
return FALSE ; return false ;
bool transferred = false ; bool transferred = false ;
if ( gTrackingGlobals.m_currentSource != NULL ) if ( gTrackingGlobals.m_currentSource != NULL )
{ {
wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ; wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ;
if ( data ) if ( data )
{ {
size_t formatcount = data->GetFormatCount() ; size_t formatcount = data->GetFormatCount() ;
@@ -144,12 +148,12 @@ bool wxDropTarget::GetData()
for (size_t i = 0; !transferred && i < formatcount ; i++) for (size_t i = 0; !transferred && i < formatcount ; i++)
{ {
wxDataFormat format = array[i] ; wxDataFormat format = array[i] ;
if ( m_dataObject->IsSupported( format ) ) if ( m_dataObject->IsSupported( format ) )
{ {
int size = data->GetDataSize( format ); int size = data->GetDataSize( format );
transferred = true ; transferred = true ;
if (size == 0) if (size == 0)
{ {
m_dataObject->SetData(format , 0 , 0 ) ; m_dataObject->SetData(format , 0 , 0 ) ;
} }
@@ -171,7 +175,7 @@ bool wxDropTarget::GetData()
OSErr result; OSErr result;
bool firstFileAdded = false ; bool firstFileAdded = false ;
CountDragItems((DragReference)m_currentDrag, &items); CountDragItems((DragReference)m_currentDrag, &items);
for (UInt16 index = 1; index <= items; ++index) for (UInt16 index = 1; index <= items; ++index)
{ {
ItemReference theItem; ItemReference theItem;
FlavorType theType ; FlavorType theType ;
@@ -186,7 +190,7 @@ bool wxDropTarget::GetData()
{ {
FlavorFlags theFlags; FlavorFlags theFlags;
result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags); result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags);
if (result == noErr) if (result == noErr)
{ {
Size dataSize ; Size dataSize ;
Ptr theData ; Ptr theData ;
@@ -198,11 +202,11 @@ bool wxDropTarget::GetData()
dataSize++ ; dataSize++ ;
} }
theData = new char[dataSize]; theData = new char[dataSize];
GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L); GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L);
if( theType == 'TEXT' ) if( theType == 'TEXT' )
{ {
theData[dataSize]=0 ; theData[dataSize]=0 ;
wxString convert( theData , wxConvLocal ) ; wxString convert( theData , wxConvLocal ) ;
m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert ); m_dataObject->SetData( format, convert.Length() * sizeof(wxChar), (const wxChar*) convert );
} }
else if ( theType == kDragFlavorTypeHFS ) else if ( theType == kDragFlavorTypeHFS )
@@ -214,7 +218,7 @@ bool wxDropTarget::GetData()
else else
{ {
((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ; ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ;
firstFileAdded = true ; firstFileAdded = true ;
} }
} }
else else
@@ -228,7 +232,7 @@ bool wxDropTarget::GetData()
} }
} }
} }
return TRUE ; return true ;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -268,13 +272,13 @@ wxDropSource::~wxDropSource()
wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)) wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
{ {
wxASSERT_MSG( m_data, wxT("Drop source: no data") ); wxASSERT_MSG( m_data, wxT("Drop source: no data") );
if (!m_data) if (!m_data)
return (wxDragResult) wxDragNone; return (wxDragResult) wxDragNone;
if (m_data->GetFormatCount() == 0) if (m_data->GetFormatCount() == 0)
return (wxDragResult) wxDragNone; return (wxDragResult) wxDragNone;
OSErr result; OSErr result;
DragReference theDrag; DragReference theDrag;
RgnHandle dragRegion; RgnHandle dragRegion;
@@ -306,9 +310,9 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
HFSFlavor theFlavor ; HFSFlavor theFlavor ;
OSErr err = noErr; OSErr err = noErr;
CInfoPBRec cat; CInfoPBRec cat;
wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ; wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ;
cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name; cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name;
cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum; cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum;
cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID; cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID;
@@ -327,20 +331,20 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator; theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator;
theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType; theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType;
} }
AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0); AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0);
} }
} }
else else
{ {
AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0);
} }
delete[] dataPtr ; delete[] dataPtr ;
} }
delete[] formats ; delete[] formats ;
dragRegion = NewRgn(); dragRegion = NewRgn();
RgnHandle tempRgn = NewRgn() ; RgnHandle tempRgn = NewRgn() ;
EventRecord* ev = NULL ; EventRecord* ev = NULL ;
#if !TARGET_CARBON // TODO #if !TARGET_CARBON // TODO
ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ; ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
@@ -351,29 +355,29 @@ wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
#endif #endif
const short dragRegionOuterBoundary = 10 ; const short dragRegionOuterBoundary = 10 ;
const short dragRegionInnerBoundary = 9 ; const short dragRegionInnerBoundary = 9 ;
SetRectRgn( dragRegion , ev->where.h - dragRegionOuterBoundary , SetRectRgn( dragRegion , ev->where.h - dragRegionOuterBoundary ,
ev->where.v - dragRegionOuterBoundary , ev->where.v - dragRegionOuterBoundary ,
ev->where.h + dragRegionOuterBoundary , ev->where.h + dragRegionOuterBoundary ,
ev->where.v + dragRegionOuterBoundary ) ; ev->where.v + dragRegionOuterBoundary ) ;
SetRectRgn( tempRgn , ev->where.h - dragRegionInnerBoundary , SetRectRgn( tempRgn , ev->where.h - dragRegionInnerBoundary ,
ev->where.v - dragRegionInnerBoundary , ev->where.v - dragRegionInnerBoundary ,
ev->where.h + dragRegionInnerBoundary , ev->where.h + dragRegionInnerBoundary ,
ev->where.v + dragRegionInnerBoundary ) ; ev->where.v + dragRegionInnerBoundary ) ;
DiffRgn( dragRegion , tempRgn , dragRegion ) ; DiffRgn( dragRegion , tempRgn , dragRegion ) ;
DisposeRgn( tempRgn ) ; DisposeRgn( tempRgn ) ;
// TODO:work with promises in order to return data only when drag // TODO:work with promises in order to return data only when drag
// was successfully completed // was successfully completed
gTrackingGlobals.m_currentSource = this ; gTrackingGlobals.m_currentSource = this ;
result = TrackDrag(theDrag, ev , dragRegion); result = TrackDrag(theDrag, ev , dragRegion);
DisposeRgn(dragRegion); DisposeRgn(dragRegion);
DisposeDrag(theDrag); DisposeDrag(theDrag);
gTrackingGlobals.m_currentSource = NULL ; gTrackingGlobals.m_currentSource = NULL ;
KeyMap keymap; KeyMap keymap;
GetKeys(keymap); GetKeys(keymap);
bool optionDown = keymap[1] & 4; bool optionDown = keymap[1] & 4;
@@ -388,11 +392,11 @@ bool wxDropSource::MacInstallDefaultCursor(wxDragResult effect)
{ {
cursor.MacInstall() ; cursor.MacInstall() ;
return TRUE; return true;
} }
else else
{ {
return FALSE; return false;
} }
} }
@@ -423,19 +427,19 @@ void wxMacEnsureTrackingHandlersInstalled()
pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow, pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow,
void *handlerRefCon, DragReference theDrag) void *handlerRefCon, DragReference theDrag)
{ {
MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon; MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon;
Point mouse, localMouse; Point mouse, localMouse;
DragAttributes attributes; DragAttributes attributes;
GetDragAttributes(theDrag, &attributes); GetDragAttributes(theDrag, &attributes);
wxTopLevelWindowMac* toplevel = wxFindWinFromMacWindow( (WXWindow) theWindow ) ; wxTopLevelWindowMac* toplevel = wxFindWinFromMacWindow( (WXWindow) theWindow ) ;
KeyMap keymap; KeyMap keymap;
GetKeys(keymap); GetKeys(keymap);
bool optionDown = keymap[1] & 4; bool optionDown = keymap[1] & 4;
wxDragResult result = optionDown ? wxDragCopy : wxDragMove; wxDragResult result = optionDown ? wxDragCopy : wxDragMove;
switch(theMessage) switch(theMessage)
{ {
case kDragTrackingEnterHandler: case kDragTrackingEnterHandler:
break; break;
@@ -454,8 +458,8 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
GlobalToLocal(&localMouse); GlobalToLocal(&localMouse);
// if (attributes & kDragHasLeftSenderWindow) // if (attributes & kDragHasLeftSenderWindow)
{ {
wxPoint point(localMouse.h , localMouse.v) ; wxPoint point(localMouse.h , localMouse.v) ;
wxWindow *win = NULL ; wxWindow *win = NULL ;
@@ -487,14 +491,14 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
trackingGlobals->m_currentTarget = win->GetDropTarget() ; trackingGlobals->m_currentTarget = win->GetDropTarget() ;
{ {
if ( trackingGlobals->m_currentTarget ) if ( trackingGlobals->m_currentTarget )
{ {
trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ; trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
result = trackingGlobals->m_currentTarget->OnEnter( result = trackingGlobals->m_currentTarget->OnEnter(
localx , localy , result ) ; localx , localy , result ) ;
} }
if ( result != wxDragNone ) if ( result != wxDragNone )
{ {
int x , y ; int x , y ;
@@ -552,12 +556,12 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
} }
} }
} }
} }
// MyTrackItemUnderMouse(localMouse, theWindow); // MyTrackItemUnderMouse(localMouse, theWindow);
break; break;
case kDragTrackingLeaveWindow: case kDragTrackingLeaveWindow:
if (trackingGlobals->m_currentTarget) if (trackingGlobals->m_currentTarget)
{ {
trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ; trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
trackingGlobals->m_currentTarget->OnLeave() ; trackingGlobals->m_currentTarget->OnLeave() ;
@@ -573,13 +577,13 @@ pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, Wind
pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow, pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow,
void *handlerRefCon, void *handlerRefCon,
DragReference theDrag) DragReference theDrag)
{ {
MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon; MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon;
if ( trackingGlobals->m_currentTarget ) if ( trackingGlobals->m_currentTarget )
{ {
Point mouse,localMouse ; Point mouse,localMouse ;
int localx,localy ; int localx,localy ;
trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ; trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
GetDragMouse(theDrag, &mouse, 0L); GetDragMouse(theDrag, &mouse, 0L);
localMouse = mouse; localMouse = mouse;

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: filedlg.cpp // Name: src/mac/classic/filedlg.cpp
// Purpose: wxFileDialog // Purpose: wxFileDialog
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
@@ -9,7 +9,12 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/app.h" #include "wx/app.h"
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/dialog.h" #include "wx/dialog.h"
@@ -183,7 +188,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
// an explanatory text, in that case the first part is name and extension at the same time // an explanatory text, in that case the first part is name and extension at the same time
wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ; wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ;
if ( current.IsEmpty() ) if ( current.empty() )
myData->extensions.Add( myData->name[filterIndex] ) ; myData->extensions.Add( myData->name[filterIndex] ) ;
else else
myData->extensions.Add( current.MakeUpper() ) ; myData->extensions.Add( current.MakeUpper() ) ;
@@ -200,21 +205,21 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
wxString extension = myData->extensions[i]; wxString extension = myData->extensions[i];
if (extension.GetChar(0) == '*') if (extension.GetChar(0) == '*')
extension = extension.Mid(1); // Remove leading * extension = extension.Mid(1); // Remove leading *
if (extension.GetChar(0) == '.') if (extension.GetChar(0) == '.')
{ {
extension = extension.Mid(1); // Remove leading . extension = extension.Mid(1); // Remove leading .
} }
if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator )) if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator ))
{ {
myData->filtermactypes.Add( (OSType)fileType ); myData->filtermactypes.Add( (OSType)fileType );
} }
else else
{ {
myData->filtermactypes.Add( '****' ) ; // We'll fail safe if it's not recognized myData->filtermactypes.Add( '****' ) ; // We'll fail safe if it's not recognized
} }
} }
} }
} }
@@ -319,16 +324,16 @@ pascal Boolean CrossPlatformFilterCallback (
CFURLRef fullURLRef; CFURLRef fullURLRef;
fullURLRef = ::CFURLCreateFromFSRef(NULL, &fsref); fullURLRef = ::CFURLCreateFromFSRef(NULL, &fsref);
#ifdef __UNIX__ #ifdef __UNIX__
CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle; CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
#else #else
CFURLPathStyle pathstyle = kCFURLHFSPathStyle; CFURLPathStyle pathstyle = kCFURLHFSPathStyle;
#endif #endif
CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle); CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
::CFRelease( fullURLRef ) ; ::CFRelease( fullURLRef ) ;
wxString file = wxMacCFStringHolder(cfString).AsString(wxFont::GetDefaultEncoding()); wxString file = wxMacCFStringHolder(cfString).AsString(wxFont::GetDefaultEncoding());
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ; display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
} }
@@ -615,7 +620,7 @@ int wxFileDialog::ShowModal()
OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc); OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
if ( err != noErr ) if ( err != noErr )
{ {
m_path = wxT("") ; m_path = wxEmptyString ;
return wxID_CANCEL ; return wxID_CANCEL ;
} }
outFileSpec = **(FSSpec**) specDesc.dataHandle; outFileSpec = **(FSSpec**) specDesc.dataHandle;
@@ -638,4 +643,3 @@ int wxFileDialog::ShowModal()
return wxID_CANCEL; return wxID_CANCEL;
#endif // TARGET_CARBON #endif // TARGET_CARBON
} }

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: font.cpp // Name: src/mac/classic/font.cpp
// Purpose: wxFont class // Purpose: wxFont class
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
@@ -9,7 +9,12 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/string.h" #include "wx/string.h"
#include "wx/font.h" #include "wx/font.h"
#include "wx/fontutil.h" #include "wx/fontutil.h"
@@ -33,7 +38,7 @@ public:
, m_family(wxDEFAULT) , m_family(wxDEFAULT)
, m_style(wxNORMAL) , m_style(wxNORMAL)
, m_weight(wxNORMAL) , m_weight(wxNORMAL)
, m_underlined(FALSE) , m_underlined(false)
, m_faceName(wxT("Geneva")) , m_faceName(wxT("Geneva"))
, m_encoding(wxFONTENCODING_DEFAULT) , m_encoding(wxFONTENCODING_DEFAULT)
, m_macFontNum(0) , m_macFontNum(0)
@@ -41,7 +46,7 @@ public:
, m_macFontStyle(0) , m_macFontStyle(0)
, m_macATSUFontID() , m_macATSUFontID()
{ {
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, false,
wxT("Geneva"), wxFONTENCODING_DEFAULT); wxT("Geneva"), wxFONTENCODING_DEFAULT);
} }
@@ -88,9 +93,9 @@ public:
} }
virtual ~wxFontRefData(); virtual ~wxFontRefData();
void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; } void SetNoAntiAliasing( bool no = true ) { m_noAA = no; }
bool GetNoAntiAliasing() const { return m_noAA; } bool GetNoAntiAliasing() const { return m_noAA; }
protected: protected:
// common part of all ctors // common part of all ctors
void Init(int size, void Init(int size,
@@ -110,8 +115,8 @@ protected:
bool m_underlined; bool m_underlined;
wxString m_faceName; wxString m_faceName;
wxFontEncoding m_encoding; wxFontEncoding m_encoding;
bool m_noAA; // No anti-aliasing bool m_noAA; // No anti-aliasing
public: public:
short m_macFontNum; short m_macFontNum;
short m_macFontSize; short m_macFontSize;
@@ -152,7 +157,7 @@ void wxFontRefData::Init(int pointSize,
m_macFontSize = 0; m_macFontSize = 0;
m_macFontStyle = 0; m_macFontStyle = 0;
m_fontId = 0; m_fontId = 0;
m_noAA = FALSE; m_noAA = false;
} }
wxFontRefData::~wxFontRefData() wxFontRefData::~wxFontRefData()
@@ -205,19 +210,19 @@ void wxFontRefData::MacFindFont()
m_macFontStyle = 0; m_macFontStyle = 0;
if (m_weight == wxBOLD) if (m_weight == wxBOLD)
m_macFontStyle |= bold; m_macFontStyle |= bold;
if (m_style == wxITALIC || m_style == wxSLANT) if (m_style == wxITALIC || m_style == wxSLANT)
m_macFontStyle |= italic; m_macFontStyle |= italic;
if (m_underlined) if (m_underlined)
m_macFontStyle |= underline; m_macFontStyle |= underline;
m_macFontSize = m_pointSize ; m_macFontSize = m_pointSize ;
//TODO:if we supply the style as an additional parameter we must make a testing //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 //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 //information, meanwhile we just take the normal font and apply the features after
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
OSStatus status = OSStatus status =
#endif // __WXDEBUG__ #endif // __WXDEBUG__
::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID); ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID);
/* /*
status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) , status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) ,
kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ; kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ;
@@ -257,7 +262,7 @@ bool wxFont::Create(int pointSize,
RealizeResource(); RealizeResource();
return TRUE; return true;
} }
wxFont::~wxFont() wxFont::~wxFont()
@@ -267,7 +272,7 @@ wxFont::~wxFont()
bool wxFont::RealizeResource() bool wxFont::RealizeResource()
{ {
M_FONTDATA->MacFindFont() ; M_FONTDATA->MacFindFont() ;
return TRUE; return true;
} }
void wxFont::SetEncoding(wxFontEncoding encoding) void wxFont::SetEncoding(wxFontEncoding encoding)
@@ -434,4 +439,3 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
return &(M_FONTDATA->m_info); return &(M_FONTDATA->m_info);
} }

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: mac/mimetype.cpp // Name: src/mac/classic/mimetype.cpp
// Purpose: classes and functions to manage MIME types // Purpose: classes and functions to manage MIME types
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
@@ -16,10 +16,6 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#ifndef WX_PRECOMP
#include "wx/defs.h"
#endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/string.h" #include "wx/string.h"
#if wxUSE_GUI #if wxUSE_GUI

View File

@@ -9,7 +9,11 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_PALETTE #if wxUSE_PALETTE

View File

@@ -1,28 +1,26 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: printwin.cpp // Name: src/mac/classic/printwin.cpp
// Purpose: wxMacPrinter framework // Purpose: wxMacPrinter framework
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 04/01/98 // Created: 04/01/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif #endif
#include "wx/defs.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/msgdlg.h" #include "wx/msgdlg.h"
#endif #endif
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -43,7 +41,7 @@ IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase)
#if TARGET_CARBON #if TARGET_CARBON
wxNativePrintData* wxNativePrintData::Create() wxNativePrintData* wxNativePrintData::Create()
{ {
return new wxMacCarbonPrintData() ; return new wxMacCarbonPrintData() ;
} }
@@ -69,7 +67,7 @@ wxMacCarbonPrintData::~wxMacCarbonPrintData()
(void)PMRelease(m_macPrintSettings); (void)PMRelease(m_macPrintSettings);
m_macPrintSettings = kPMNoPrintSettings; m_macPrintSettings = kPMNoPrintSettings;
} }
if ( m_macPrintSession != kPMNoReference ) if ( m_macPrintSession != kPMNoReference )
{ {
(void)PMRelease(m_macPrintSession); (void)PMRelease(m_macPrintSession);
@@ -77,7 +75,7 @@ wxMacCarbonPrintData::~wxMacCarbonPrintData()
} }
} }
void wxMacCarbonPrintData::ValidateOrCreate() void wxMacCarbonPrintData::ValidateOrCreate()
{ {
OSStatus err = noErr ; OSStatus err = noErr ;
if ( m_macPrintSession == kPMNoReference ) if ( m_macPrintSession == kPMNoReference )
@@ -88,7 +86,7 @@ void wxMacCarbonPrintData::ValidateOrCreate()
if ( m_macPageFormat == kPMNoPageFormat) if ( m_macPageFormat == kPMNoPageFormat)
{ {
err = PMCreatePageFormat((PMPageFormat *) &m_macPageFormat); err = PMCreatePageFormat((PMPageFormat *) &m_macPageFormat);
// Note that PMPageFormat is not session-specific, but calling // Note that PMPageFormat is not session-specific, but calling
// PMSessionDefaultPageFormat assigns values specific to the printer // PMSessionDefaultPageFormat assigns values specific to the printer
// associated with the current printing session. // associated with the current printing session.
@@ -105,12 +103,12 @@ void wxMacCarbonPrintData::ValidateOrCreate()
(PMPageFormat) m_macPageFormat, (PMPageFormat) m_macPageFormat,
kPMDontWantBoolean); kPMDontWantBoolean);
} }
// Set up a valid PrintSettings object. // Set up a valid PrintSettings object.
if ( m_macPrintSettings == kPMNoPrintSettings) if ( m_macPrintSettings == kPMNoPrintSettings)
{ {
err = PMCreatePrintSettings((PMPrintSettings *) &m_macPrintSettings); err = PMCreatePrintSettings((PMPrintSettings *) &m_macPrintSettings);
// Note that PMPrintSettings is not session-specific, but calling // Note that PMPrintSettings is not session-specific, but calling
// PMSessionDefaultPrintSettings assigns values specific to the printer // PMSessionDefaultPrintSettings assigns values specific to the printer
// associated with the current printing session. // associated with the current printing session.
@@ -149,7 +147,7 @@ void wxMacCarbonPrintData::TransferFrom( wxPrintData* data )
} }
else else
PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ; PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ;
// PMDuplexMode not yet accessible via API // PMDuplexMode not yet accessible via API
// PMQualityMode not yet accessible via API // PMQualityMode not yet accessible via API
// todo paperSize // todo paperSize
@@ -158,12 +156,12 @@ void wxMacCarbonPrintData::TransferFrom( wxPrintData* data )
void wxMacCarbonPrintData::TransferTo( wxPrintData* data ) void wxMacCarbonPrintData::TransferTo( wxPrintData* data )
{ {
OSStatus err = noErr ; OSStatus err = noErr ;
UInt32 copies ; UInt32 copies ;
err = PMGetCopies( m_macPrintSettings , &copies ) ; err = PMGetCopies( m_macPrintSettings , &copies ) ;
if ( err == noErr ) if ( err == noErr )
data->SetNoCopies( copies ) ; data->SetNoCopies( copies ) ;
PMOrientation orientation ; PMOrientation orientation ;
err = PMGetOrientation( m_macPageFormat , &orientation ) ; err = PMGetOrientation( m_macPageFormat , &orientation ) ;
if ( err == noErr ) if ( err == noErr )
@@ -184,16 +182,16 @@ void wxMacCarbonPrintData::TransferTo( wxPrintData* data )
m_printerName = name.AsString() ; m_printerName = name.AsString() ;
} }
#endif #endif
PMColorMode color ; PMColorMode color ;
err = PMGetColorMode( m_macPrintSettings, &color ) ; err = PMGetColorMode( m_macPrintSettings, &color ) ;
if ( err == noErr ) if ( err == noErr )
data->SetColour( !(color == kPMBlackAndWhite) ) ; data->SetColour( !(color == kPMBlackAndWhite) ) ;
// PMDuplexMode not yet accessible via API // PMDuplexMode not yet accessible via API
// PMQualityMode not yet accessible via API // PMQualityMode not yet accessible via API
// todo paperSize // todo paperSize
PMRect rPaper; PMRect rPaper;
err = PMGetUnadjustedPaperRect( m_macPageFormat, &rPaper); err = PMGetUnadjustedPaperRect( m_macPageFormat, &rPaper);
if ( err == noErr ) if ( err == noErr )
{ {
@@ -215,7 +213,7 @@ void wxMacCarbonPrintData::TransferFrom( wxPageSetupData *data )
void wxMacCarbonPrintData::TransferTo( wxPageSetupData* data ) void wxMacCarbonPrintData::TransferTo( wxPageSetupData* data )
{ {
PMRect rPaper; PMRect rPaper;
OSStatus err = PMGetUnadjustedPaperRect(m_macPageFormat, &rPaper); OSStatus err = PMGetUnadjustedPaperRect(m_macPageFormat, &rPaper);
if ( err == noErr ) if ( err == noErr )
{ {
@@ -224,14 +222,14 @@ void wxMacCarbonPrintData::TransferTo( wxPageSetupData* data )
if ( err == noErr ) if ( err == noErr )
{ {
data->SetMinMarginTopLeft( wxPoint ( data->SetMinMarginTopLeft( wxPoint (
(int)(((double) rPage.left - rPaper.left ) * pt2mm) , (int)(((double) rPage.left - rPaper.left ) * pt2mm) ,
(int)(((double) rPage.top - rPaper.top ) * pt2mm) ) ) ; (int)(((double) rPage.top - rPaper.top ) * pt2mm) ) ) ;
data->SetMinMarginBottomRight( wxPoint ( data->SetMinMarginBottomRight( wxPoint (
(wxCoord)(((double) rPaper.right - rPage.right ) * pt2mm), (wxCoord)(((double) rPaper.right - rPage.right ) * pt2mm),
(wxCoord)(((double) rPaper.bottom - rPage.bottom ) * pt2mm)) ) ; (wxCoord)(((double) rPaper.bottom - rPage.bottom ) * pt2mm)) ) ;
} }
} }
} }
void wxMacCarbonPrintData::TransferTo( wxPrintDialogData* data ) void wxMacCarbonPrintData::TransferTo( wxPrintDialogData* data )
@@ -266,34 +264,34 @@ void wxMacCarbonPrintData::CopyFrom( wxNativePrintData* d )
{ {
wxMacCarbonPrintData *data = (wxMacCarbonPrintData*) d ; wxMacCarbonPrintData *data = (wxMacCarbonPrintData*) d ;
if ( data->m_macPrintSession != kPMNoReference ) if ( data->m_macPrintSession != kPMNoReference )
PMRetain( data->m_macPrintSession ) ; PMRetain( data->m_macPrintSession ) ;
if ( m_macPrintSession != kPMNoReference ) if ( m_macPrintSession != kPMNoReference )
{ {
PMRelease( m_macPrintSession ) ; PMRelease( m_macPrintSession ) ;
m_macPrintSession = kPMNoReference ; m_macPrintSession = kPMNoReference ;
} }
if ( data->m_macPrintSession != kPMNoReference ) if ( data->m_macPrintSession != kPMNoReference )
m_macPrintSession = data->m_macPrintSession ; m_macPrintSession = data->m_macPrintSession ;
if ( data->m_macPrintSettings != kPMNoPrintSettings ) if ( data->m_macPrintSettings != kPMNoPrintSettings )
PMRetain( data->m_macPrintSettings ) ; PMRetain( data->m_macPrintSettings ) ;
if ( m_macPrintSettings != kPMNoPrintSettings ) if ( m_macPrintSettings != kPMNoPrintSettings )
{ {
PMRelease( m_macPrintSettings ) ; PMRelease( m_macPrintSettings ) ;
m_macPrintSettings = kPMNoPrintSettings ; m_macPrintSettings = kPMNoPrintSettings ;
} }
if ( data->m_macPrintSettings != kPMNoPrintSettings ) if ( data->m_macPrintSettings != kPMNoPrintSettings )
m_macPrintSettings = data->m_macPrintSettings ; m_macPrintSettings = data->m_macPrintSettings ;
if ( data->m_macPageFormat != kPMNoPageFormat ) if ( data->m_macPageFormat != kPMNoPageFormat )
PMRetain( data->m_macPageFormat ) ; PMRetain( data->m_macPageFormat ) ;
if ( m_macPageFormat != kPMNoPageFormat ) if ( m_macPageFormat != kPMNoPageFormat )
{ {
PMRelease( m_macPageFormat ) ; PMRelease( m_macPageFormat ) ;
m_macPageFormat = kPMNoPageFormat ; m_macPageFormat = kPMNoPageFormat ;
} }
if ( data->m_macPageFormat != kPMNoPageFormat ) if ( data->m_macPageFormat != kPMNoPageFormat )
m_macPageFormat = data->m_macPageFormat ; m_macPageFormat = data->m_macPageFormat ;
} }
int wxMacCarbonPrintData::ShowPrintDialog() int wxMacCarbonPrintData::ShowPrintDialog()
@@ -301,9 +299,9 @@ int wxMacCarbonPrintData::ShowPrintDialog()
int result = wxID_CANCEL ; int result = wxID_CANCEL ;
OSErr err = noErr ; OSErr err = noErr ;
wxString message ; wxString message ;
Boolean accepted; Boolean accepted;
{ {
// Display the Print dialog. // Display the Print dialog.
if (err == noErr) if (err == noErr)
@@ -337,7 +335,7 @@ int wxMacCarbonPrintData::ShowPageSetupDialog()
int result = wxID_CANCEL ; int result = wxID_CANCEL ;
OSErr err = noErr ; OSErr err = noErr ;
wxString message ; wxString message ;
Boolean accepted; Boolean accepted;
{ {
// Display the Page Setup dialog. // Display the Page Setup dialog.
@@ -350,8 +348,8 @@ int wxMacCarbonPrintData::ShowPageSetupDialog()
{ {
err = kPMCancel; // user clicked Cancel button err = kPMCancel; // user clicked Cancel button
} }
} }
// If the user did not cancel, flatten and save the PageFormat object // If the user did not cancel, flatten and save the PageFormat object
// with our document. // with our document.
if (err == noErr) { if (err == noErr) {
@@ -370,7 +368,7 @@ int wxMacCarbonPrintData::ShowPageSetupDialog()
#else #else
wxNativePrintData* wxNativePrintData::Create() wxNativePrintData* wxNativePrintData::Create()
{ {
return new wxMacClassicPrintData() ; return new wxMacClassicPrintData() ;
} }
@@ -387,7 +385,7 @@ wxMacClassicPrintData::~wxMacClassicPrintData()
DisposeHandle( (Handle) m_macPrintSettings ) ; DisposeHandle( (Handle) m_macPrintSettings ) ;
} }
void wxMacClassicPrintData::ValidateOrCreate() void wxMacClassicPrintData::ValidateOrCreate()
{ {
if ( m_macPrintSettings == NULL ) if ( m_macPrintSettings == NULL )
{ {
@@ -420,7 +418,7 @@ void wxMacClassicPrintData::TransferFrom( wxPrintData* data )
void wxMacClassicPrintData::TransferTo( wxPrintData* data ) void wxMacClassicPrintData::TransferTo( wxPrintData* data )
{ {
data->SetNoCopies( (**m_macPrintSettings).prJob.iCopies ); data->SetNoCopies( (**m_macPrintSettings).prJob.iCopies );
data->SetPaperSize( wxSize( data->SetPaperSize( wxSize(
((double) (**m_macPrintSettings).rPaper.right - (**m_macPrintSettings).rPaper.left ) * pt2mm , ((double) (**m_macPrintSettings).rPaper.right - (**m_macPrintSettings).rPaper.left ) * pt2mm ,
((double) (**m_macPrintSettings).rPaper.bottom - (**m_macPrintSettings).rPaper.top ) * pt2mm ) ) ; ((double) (**m_macPrintSettings).rPaper.bottom - (**m_macPrintSettings).rPaper.top ) * pt2mm ) ) ;
} }
@@ -466,7 +464,7 @@ int wxMacClassicPrintData::ShowPrintDialog()
int result = wxID_CANCEL ; int result = wxID_CANCEL ;
OSErr err = noErr ; OSErr err = noErr ;
wxString message ; wxString message ;
err = ::UMAPrOpen() ; err = ::UMAPrOpen() ;
if ( err == noErr ) if ( err == noErr )
{ {
@@ -474,12 +472,12 @@ int wxMacClassicPrintData::ShowPrintDialog()
{ {
result = wxID_OK ; result = wxID_OK ;
} }
} }
else else
{ {
message.Printf( wxT("Print Error %d"), err ) ; message.Printf( wxT("Print Error %d"), err ) ;
wxMessageDialog dialog( NULL , message , wxT(""), wxICON_HAND | wxOK) ; wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
dialog.ShowModal(); dialog.ShowModal();
} }
::UMAPrClose() ; ::UMAPrClose() ;
@@ -492,7 +490,7 @@ int wxMacClassicPrintData::ShowPageSetupDialog()
int result = wxID_CANCEL ; int result = wxID_CANCEL ;
OSErr err = noErr ; OSErr err = noErr ;
wxString message ; wxString message ;
err = ::UMAPrOpen() ; err = ::UMAPrOpen() ;
if ( err == noErr ) if ( err == noErr )
{ {
@@ -500,7 +498,7 @@ int wxMacClassicPrintData::ShowPageSetupDialog()
{ {
result = wxID_OK ; result = wxID_OK ;
} }
} }
else else
{ {
@@ -529,19 +527,19 @@ wxMacPrinter::~wxMacPrinter(void)
bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
{ {
sm_abortIt = FALSE; sm_abortIt = false;
sm_abortWindow = NULL; sm_abortWindow = NULL;
if (!printout) if (!printout)
return FALSE; return false;
printout->SetIsPreview(FALSE); printout->SetIsPreview(false);
if (m_printDialogData.GetMinPage() < 1) if (m_printDialogData.GetMinPage() < 1)
m_printDialogData.SetMinPage(1); m_printDialogData.SetMinPage(1);
if (m_printDialogData.GetMaxPage() < 1) if (m_printDialogData.GetMaxPage() < 1)
m_printDialogData.SetMaxPage(9999); m_printDialogData.SetMaxPage(9999);
// Create a suitable device context // Create a suitable device context
wxDC *dc = NULL; wxDC *dc = NULL;
if (prompt) if (prompt)
{ {
@@ -556,69 +554,69 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
{ {
dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ; dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
} }
// May have pressed cancel. // May have pressed cancel.
if (!dc || !dc->Ok()) if (!dc || !dc->Ok())
{ {
if (dc) delete dc; if (dc) delete dc;
return FALSE; return false;
} }
// on the mac we have always pixels as addressing mode with 72 dpi // on the mac we have always pixels as addressing mode with 72 dpi
printout->SetPPIScreen(72, 72); printout->SetPPIScreen(72, 72);
printout->SetPPIPrinter(72, 72); printout->SetPPIPrinter(72, 72);
// Set printout parameters // Set printout parameters
printout->SetDC(dc); printout->SetDC(dc);
int w, h; int w, h;
wxCoord ww, hh; wxCoord ww, hh;
dc->GetSize(&w, &h); dc->GetSize(&w, &h);
printout->SetPageSizePixels((int)w, (int)h); printout->SetPageSizePixels((int)w, (int)h);
dc->GetSizeMM(&ww, &hh); dc->GetSizeMM(&ww, &hh);
printout->SetPageSizeMM((int)ww, (int)hh); printout->SetPageSizeMM((int)ww, (int)hh);
// Create an abort window // Create an abort window
wxBeginBusyCursor(); wxBeginBusyCursor();
printout->OnPreparePrinting(); printout->OnPreparePrinting();
// Get some parameters from the printout, if defined // Get some parameters from the printout, if defined
int fromPage, toPage; int fromPage, toPage;
int minPage, maxPage; int minPage, maxPage;
printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
if (maxPage == 0) if (maxPage == 0)
{ {
wxEndBusyCursor(); wxEndBusyCursor();
return FALSE; return false;
} }
// Only set min and max, because from and to have been // Only set min and max, because from and to have been
// set by the user // set by the user
m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMinPage(minPage);
m_printDialogData.SetMaxPage(maxPage); m_printDialogData.SetMaxPage(maxPage);
wxWindow *win = CreateAbortWindow(parent, printout); wxWindow *win = CreateAbortWindow(parent, printout);
wxSafeYield(win,true); wxSafeYield(win,true);
if (!win) if (!win)
{ {
wxEndBusyCursor(); wxEndBusyCursor();
wxMessageBox(wxT("Sorry, could not create an abort dialog."), wxT("Print Error"), wxOK, parent); wxMessageBox(wxT("Sorry, could not create an abort dialog."), wxT("Print Error"), wxOK, parent);
delete dc; delete dc;
return FALSE; return false;
} }
sm_abortWindow = win; sm_abortWindow = win;
sm_abortWindow->Show(TRUE); sm_abortWindow->Show(true);
wxSafeYield(win,true); wxSafeYield(win,true);
printout->OnBeginPrinting(); printout->OnBeginPrinting();
bool keepGoing = TRUE; bool keepGoing = true;
int copyCount; int copyCount;
for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++) for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++)
{ {
@@ -630,14 +628,14 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
} }
if (sm_abortIt) if (sm_abortIt)
break; break;
int pn; int pn;
for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn);
pn++) pn++)
{ {
if (sm_abortIt) if (sm_abortIt)
{ {
keepGoing = FALSE; keepGoing = false;
break; break;
} }
else else
@@ -658,36 +656,36 @@ bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
} }
printout->OnEndDocument(); printout->OnEndDocument();
} }
printout->OnEndPrinting(); printout->OnEndPrinting();
if (sm_abortWindow) if (sm_abortWindow)
{ {
sm_abortWindow->Show(FALSE); sm_abortWindow->Show(false);
delete sm_abortWindow; delete sm_abortWindow;
sm_abortWindow = NULL; sm_abortWindow = NULL;
} }
wxEndBusyCursor(); wxEndBusyCursor();
delete dc; delete dc;
return TRUE; return true;
} }
wxDC* wxMacPrinter::PrintDialog(wxWindow *parent) wxDC* wxMacPrinter::PrintDialog(wxWindow *parent)
{ {
wxDC* dc = (wxDC*) NULL; wxDC* dc = (wxDC*) NULL;
wxPrintDialog dialog(parent, & m_printDialogData); wxPrintDialog dialog(parent, & m_printDialogData);
int ret = dialog.ShowModal(); int ret = dialog.ShowModal();
if (ret == wxID_OK) if (ret == wxID_OK)
{ {
dc = dialog.GetPrintDC(); dc = dialog.GetPrintDC();
m_printDialogData = dialog.GetPrintDialogData(); m_printDialogData = dialog.GetPrintDialogData();
} }
return dc; return dc;
} }
@@ -695,15 +693,15 @@ bool wxMacPrinter::Setup(wxWindow *parent)
{ {
#if 0 #if 0
wxPrintDialog dialog(parent, & m_printDialogData); wxPrintDialog dialog(parent, & m_printDialogData);
dialog.GetPrintDialogData().SetSetupDialog(TRUE); dialog.GetPrintDialogData().SetSetupDialog(true);
int ret = dialog.ShowModal(); int ret = dialog.ShowModal();
if (ret == wxID_OK) if (ret == wxID_OK)
{ {
m_printDialogData = dialog.GetPrintDialogData(); m_printDialogData = dialog.GetPrintDialogData();
} }
return (ret == wxID_OK); return (ret == wxID_OK);
#endif #endif
return wxID_CANCEL; return wxID_CANCEL;
@@ -734,7 +732,7 @@ wxMacPrintPreview::~wxMacPrintPreview(void)
bool wxMacPrintPreview::Print(bool interactive) bool wxMacPrintPreview::Print(bool interactive)
{ {
if (!m_printPrintout) if (!m_printPrintout)
return FALSE; return false;
wxMacPrinter printer(&m_printDialogData); wxMacPrinter printer(&m_printDialogData);
return printer.Print(m_previewFrame, m_printPrintout, interactive); return printer.Print(m_previewFrame, m_printPrintout, interactive);
} }
@@ -743,7 +741,7 @@ void wxMacPrintPreview::DetermineScaling(void)
{ {
int screenWidth , screenHeight ; int screenWidth , screenHeight ;
wxDisplaySize( &screenWidth , &screenHeight ) ; wxDisplaySize( &screenWidth , &screenHeight ) ;
m_previewPrintout->SetPPIScreen( 72 , 72 ) ; m_previewPrintout->SetPPIScreen( 72 , 72 ) ;
m_previewPrintout->SetPPIPrinter( 72 , 72 ) ; m_previewPrintout->SetPPIPrinter( 72 , 72 ) ;
m_previewPrintout->SetPageSizeMM( (int) (8.0 * 25.6), (int) (11.0 * 25.6) ); m_previewPrintout->SetPageSizeMM( (int) (8.0 * 25.6), (int) (11.0 * 25.6) );
@@ -751,7 +749,7 @@ void wxMacPrintPreview::DetermineScaling(void)
m_pageWidth = 8 * 72 ; m_pageWidth = 8 * 72 ;
m_pageHeight = 11 * 72 ; m_pageHeight = 11 * 72 ;
m_previewScale = 1 ; m_previewScale = 1 ;
// Get a device context for the currently selected printer // Get a device context for the currently selected printer
wxPrinterDC printerDC(m_printDialogData.GetPrintData()); wxPrinterDC printerDC(m_printDialogData.GetPrintData());
if (printerDC.Ok()) if (printerDC.Ok())
@@ -773,6 +771,6 @@ void wxMacPrintPreview::DetermineScaling(void)
// At 100%, the page should look about page-size on the screen. // At 100%, the page should look about page-size on the screen.
// m_previewScale = (float)((float)screenWidth/(float)printerWidth); // m_previewScale = (float)((float)screenWidth/(float)printerWidth);
// m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerXRes); // m_previewScale = m_previewScale * (float)((float)screenXRes/(float)printerXRes);
m_previewScale = 1 ; m_previewScale = 1 ;
} }

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: radiobut.cpp // Name: src/mac/classic/radiobut.cpp
// Purpose: wxRadioButton // Purpose: wxRadioButton
// Author: AUTHOR // Author: AUTHOR
// Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox // Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox
// Created: ??/??/98 // Created: ??/??/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) AUTHOR // Copyright: (c) AUTHOR
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/radiobut.h" #include "wx/radiobut.h"
@@ -29,38 +33,38 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlRadioButtonProc , (long) this ) ; kControlRadioButtonProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
m_cycle = this ; m_cycle = this ;
if (HasFlag(wxRB_GROUP)) if (HasFlag(wxRB_GROUP))
{
AddInCycle( NULL ) ;
}
else
{
/* search backward for last group start */
wxRadioButton *chief = (wxRadioButton*) NULL;
wxWindowList::Node *node = parent->GetChildren().GetLast();
while (node)
{ {
wxWindow *child = node->GetData(); AddInCycle( NULL ) ;
if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) )
{
chief = (wxRadioButton*) child;
if (child->HasFlag(wxRB_GROUP)) break;
}
node = node->GetPrevious();
} }
AddInCycle( chief ) ; else
} {
return TRUE; /* search backward for last group start */
wxRadioButton *chief = (wxRadioButton*) NULL;
wxWindowList::Node *node = parent->GetChildren().GetLast();
while (node)
{
wxWindow *child = node->GetData();
if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) )
{
chief = (wxRadioButton*) child;
if (child->HasFlag(wxRB_GROUP)) break;
}
node = node->GetPrevious();
}
AddInCycle( chief ) ;
}
return true;
} }
void wxRadioButton::SetValue(bool val) void wxRadioButton::SetValue(bool val)
@@ -68,9 +72,9 @@ void wxRadioButton::SetValue(bool val)
wxRadioButton *cycle; wxRadioButton *cycle;
if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val ) if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val )
return ; return ;
::SetControl32BitValue( (ControlHandle) m_macControl , val ) ; ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ;
if (val) if (val)
{ {
cycle=this->NextInCycle(); cycle=this->NextInCycle();
if (cycle!=NULL) { if (cycle!=NULL) {
@@ -94,12 +98,12 @@ void wxRadioButton::Command (wxCommandEvent & event)
ProcessCommand (event); ProcessCommand (event);
} }
void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
{ {
if ( GetValue() ) if ( GetValue() )
return ; return ;
wxRadioButton *cycle, *old = NULL ; wxRadioButton *cycle, *old = NULL ;
cycle=this->NextInCycle(); cycle=this->NextInCycle();
if (cycle!=NULL) { if (cycle!=NULL) {
while (cycle!=this) { while (cycle!=this) {
@@ -128,17 +132,17 @@ void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpar
wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle) wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
{ {
wxRadioButton *next,*current; wxRadioButton *next,*current;
if (cycle==NULL) { if (cycle==NULL) {
m_cycle=this; m_cycle=this;
return(this); return(this);
} }
else { else {
current=cycle; current=cycle;
while ((next=current->m_cycle)!=cycle) while ((next=current->m_cycle)!=cycle)
current=current->m_cycle; current=current->m_cycle;
m_cycle=cycle; m_cycle=cycle;
current->m_cycle=this; current->m_cycle=this;
return(cycle); return(cycle);
} }
} }

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: scrolbar.cpp // Name: src/mac/classic/scrolbar.cpp
// Purpose: wxScrollBar // Purpose: wxScrollBar
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/intl.h" #include "wx/intl.h"
@@ -34,7 +38,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
const wxString& name) const wxString& name)
{ {
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return FALSE; return false;
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
@@ -42,7 +46,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = (WXWidget) ::NewControl(MAC_WXHWND(parent->MacGetRootWindow()) , m_macControl = (WXWidget) ::NewControl(MAC_WXHWND(parent->MacGetRootWindow()) ,
&bounds , title , false , 0 , 0 , 100, &bounds , title , false , 0 , 0 , 100,
kControlScrollBarLiveProc , (long) this) ; kControlScrollBarLiveProc , (long) this) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
@@ -51,7 +55,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
MacPostControlCreate() ; MacPostControlCreate() ;
return TRUE; return true;
} }
wxScrollBar::~wxScrollBar() wxScrollBar::~wxScrollBar()
@@ -99,22 +103,22 @@ void wxScrollBar::Command(wxCommandEvent& event)
ProcessCommand(event); ProcessCommand(event);
} }
void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown )
{ {
if ( (ControlHandle) m_macControl == NULL ) if ( (ControlHandle) m_macControl == NULL )
return ; return ;
int position = GetControl32BitValue( (ControlHandle) m_macControl) ; int position = GetControl32BitValue( (ControlHandle) m_macControl) ;
int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ; int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ;
int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ; int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ;
wxEventType scrollEvent = wxEVT_NULL; wxEventType scrollEvent = wxEVT_NULL;
int nScrollInc = 0; int nScrollInc = 0;
// all events have already been reported during mouse down, except for THUMBRELEASE // all events have already been reported during mouse down, except for THUMBRELEASE
if ( !mouseStillDown && controlpart !=kControlIndicatorPart ) if ( !mouseStillDown && controlpart !=kControlIndicatorPart )
return ; return ;
switch( controlpart ) switch( controlpart )
{ {
case kControlUpButtonPart : case kControlUpButtonPart :
@@ -144,16 +148,16 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart
wxFAIL_MSG(wxT("illegal scrollbar selector")); wxFAIL_MSG(wxT("illegal scrollbar selector"));
break ; break ;
} }
int new_pos = position + nScrollInc; int new_pos = position + nScrollInc;
if (new_pos < minPos) if (new_pos < minPos)
new_pos = minPos; new_pos = minPos;
if (new_pos > maxPos) if (new_pos > maxPos)
new_pos = maxPos; new_pos = maxPos;
if ( nScrollInc ) if ( nScrollInc )
SetThumbPosition(new_pos); SetThumbPosition(new_pos);
wxScrollEvent event(scrollEvent, m_windowId); wxScrollEvent event(scrollEvent, m_windowId);
if ( m_windowStyle & wxHORIZONTAL ) if ( m_windowStyle & wxHORIZONTAL )
{ {
@@ -174,4 +178,3 @@ void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart
else else
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: slider.cpp // Name: src/mac/classic/slider.cpp
// Purpose: wxSlider // Purpose: wxSlider
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_SLIDER #if wxUSE_SLIDER

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: spinbutt.cpp // Name: src/mac/classic/spinbutt.cpp
// Purpose: wxSpinButton // Purpose: wxSpinButton
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_SPINBTN #if wxUSE_SPINBTN

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: spinbutt.cpp // Name: src/mac/classic/spinbutt.cpp
// Purpose: wxSpinCtrl // Purpose: wxSpinCtrl
// Author: Robert // Author: Robert
// Modified by: Mark Newsam (Based on GTK file) // Modified by: Mark Newsam (Based on GTK file)
@@ -8,14 +8,18 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_SPINCTRL
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/textctrl.h" #include "wx/textctrl.h"
#endif //WX_PRECOMP #endif //WX_PRECOMP
#if wxUSE_SPINCTRL
#include "wx/spinbutt.h" #include "wx/spinbutt.h"
#include "wx/spinctrl.h" #include "wx/spinctrl.h"
@@ -58,7 +62,7 @@ protected:
{ {
// Hand button down events to wxSpinCtrl. Doesn't work. // Hand button down events to wxSpinCtrl. Doesn't work.
if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event )) if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event ))
return TRUE; return true;
return wxTextCtrl::ProcessEvent( event ); return wxTextCtrl::ProcessEvent( event );
} }
@@ -116,7 +120,7 @@ BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
@@ -145,7 +149,7 @@ bool wxSpinCtrl::Create(wxWindow *parent,
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style, if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style,
wxDefaultValidator, name) ) wxDefaultValidator, name) )
{ {
return FALSE; return false;
} }
// the string value overrides the numeric one (for backwards compatibility // the string value overrides the numeric one (for backwards compatibility
@@ -171,7 +175,7 @@ bool wxSpinCtrl::Create(wxWindow *parent,
} }
DoSetSize(pos.x , pos.y , csize.x, csize.y); DoSetSize(pos.x , pos.y , csize.x, csize.y);
return TRUE; return true;
} }
wxSpinCtrl::~wxSpinCtrl() wxSpinCtrl::~wxSpinCtrl()
@@ -216,15 +220,15 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
bool wxSpinCtrl::Enable(bool enable) bool wxSpinCtrl::Enable(bool enable)
{ {
if ( !wxControl::Enable(enable) ) if ( !wxControl::Enable(enable) )
return FALSE; return false;
return TRUE; return true;
} }
bool wxSpinCtrl::Show(bool show) bool wxSpinCtrl::Show(bool show)
{ {
if ( !wxControl::Show(show) ) if ( !wxControl::Show(show) )
return FALSE; return false;
return TRUE; return true;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -237,18 +241,18 @@ bool wxSpinCtrl::GetTextValue(int *val) const
if ( !m_text->GetValue().ToLong(&l) ) if ( !m_text->GetValue().ToLong(&l) )
{ {
// not a number at all // not a number at all
return FALSE; return false;
} }
if ( l < GetMin() || l > GetMax() ) if ( l < GetMin() || l > GetMax() )
{ {
// out of range // out of range
return FALSE; return false;
} }
*val = l; *val = l;
return TRUE; return true;
} }
int wxSpinCtrl::GetValue() const int wxSpinCtrl::GetValue() const
@@ -321,9 +325,9 @@ void wxSpinCtrl::SetSelection(long from, long to)
// be selected // be selected
if ( (from == -1) && (to == -1) ) if ( (from == -1) && (to == -1) )
{ {
from = 0; from = 0;
} }
m_text->SetSelection(from, to); m_text->SetSelection(from, to);
} }
#endif // wxUSE_SPINCTRL #endif // wxUSE_SPINCTRL

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: statbmp.cpp // Name: src/mac/classic/statbmp.cpp
// Purpose: wxStaticBitmap // Purpose: wxStaticBitmap
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/statbmp.h" #include "wx/statbmp.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
@@ -54,7 +58,7 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name ); bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
SetBestSize( size ) ; SetBestSize( size ) ;
return ret; return ret;
} }
@@ -66,16 +70,15 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
Refresh() ; Refresh() ;
} }
void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) ) void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
{ {
wxPaintDC dc(this); wxPaintDC dc(this);
PrepareDC(dc); PrepareDC(dc);
dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ; dc.DrawBitmap( m_bitmap , 0 , 0 , true ) ;
} }
wxSize wxStaticBitmap::DoGetBestSize() const wxSize wxStaticBitmap::DoGetBestSize() const
{ {
return wxWindow::DoGetBestSize() ; return wxWindow::DoGetBestSize() ;
} }

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: statbox.cpp // Name: src/mac/classic/statbox.cpp
// Purpose: wxStaticBox // Purpose: wxStaticBox
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/statbox.h" #include "wx/statbox.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -23,7 +27,7 @@ END_EVENT_TABLE()
/* /*
* Static box * Static box
*/ */
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
@@ -37,13 +41,13 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlGroupBoxTextTitleProc , (long) this ) ; kControlGroupBoxTextTitleProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
return TRUE; return true;
} }

View File

@@ -1,15 +1,19 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: tabctrl.cpp // Name: src/mac/classic/tabctrl.cpp
// Purpose: wxTabCtrl // Purpose: wxTabCtrl
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: 1998-01-01 // Created: 1998-01-01
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_TAB_DIALOG #if wxUSE_TAB_DIALOG
@@ -36,16 +40,16 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
m_imageList = NULL; m_imageList = NULL;
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlTabSmallProc , (long) this ) ; kControlTabSmallProc , (long) this ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
return TRUE ; return true ;
} }
wxTabCtrl::~wxTabCtrl() wxTabCtrl::~wxTabCtrl()
@@ -60,14 +64,14 @@ void wxTabCtrl::Command(wxCommandEvent& event)
bool wxTabCtrl::DeleteAllItems() bool wxTabCtrl::DeleteAllItems()
{ {
// TODO // TODO
return FALSE; return false;
} }
// Delete an item // Delete an item
bool wxTabCtrl::DeleteItem(int item) bool wxTabCtrl::DeleteItem(int item)
{ {
// TODO // TODO
return FALSE; return false;
} }
// Get the selection // Get the selection
@@ -101,7 +105,7 @@ int wxTabCtrl::GetItemCount() const
bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const
{ {
// TODO // TODO
return FALSE; return false;
} }
// Get the number of rows // Get the number of rows
@@ -143,7 +147,7 @@ int wxTabCtrl::HitTest(const wxPoint& pt, long& flags)
bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data) bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data)
{ {
// TODO // TODO
return FALSE; return false;
} }
// Set the selection // Set the selection
@@ -163,21 +167,21 @@ void wxTabCtrl::SetImageList(wxImageList* imageList)
bool wxTabCtrl::SetItemText(int item, const wxString& text) bool wxTabCtrl::SetItemText(int item, const wxString& text)
{ {
// TODO // TODO
return FALSE; return false;
} }
// Set the image for an item // Set the image for an item
bool wxTabCtrl::SetItemImage(int item, int image) bool wxTabCtrl::SetItemImage(int item, int image)
{ {
// TODO // TODO
return FALSE; return false;
} }
// Set the data for an item // Set the data for an item
bool wxTabCtrl::SetItemData(int item, void* data) bool wxTabCtrl::SetItemData(int item, void* data)
{ {
// TODO // TODO
return FALSE; return false;
} }
// Set the size for a fixed-width tab control // Set the size for a fixed-width tab control

View File

@@ -9,7 +9,11 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_TEXTCTRL #if wxUSE_TEXTCTRL

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/mac/tglbtn.cpp // Name: src/mac/classic/tglbtn.cpp
// Purpose: Definition of the wxToggleButton class, which implements a // Purpose: Definition of the wxToggleButton class, which implements a
// toggle button under wxMac. // toggle button under wxMac.
// Author: Stefan Csomor // Author: Stefan Csomor
@@ -10,6 +10,12 @@
// License: Rocketeer license // License: Rocketeer license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// ============================================================================ // ============================================================================
// declatations // declatations
// ============================================================================ // ============================================================================
@@ -18,7 +24,6 @@
// headers // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "wx/defs.h"
#include "wx/tglbtn.h" #include "wx/tglbtn.h"
#if wxUSE_TOGGLEBTN #if wxUSE_TOGGLEBTN
@@ -63,25 +68,25 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
m_macHorizontalBorder = kMacOSXHorizontalBorder; m_macHorizontalBorder = kMacOSXHorizontalBorder;
m_macVerticalBorder = kMacOSXVerticalBorder; m_macVerticalBorder = kMacOSXVerticalBorder;
} }
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , kControlBehaviorToggles , 1, m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , kControlBehaviorToggles , 1,
kControlBevelButtonNormalBevelProc , (long) this ) ; kControlBevelButtonNormalBevelProc , (long) this ) ;
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
MacPostControlCreate() ; MacPostControlCreate() ;
return TRUE; return true;
} }
wxSize wxToggleButton::DoGetBestSize() const wxSize wxToggleButton::DoGetBestSize() const
{ {
int wBtn = 70 ; int wBtn = 70 ;
int hBtn = 20 ; int hBtn = 20 ;
int lBtn = m_label.Length() * 8 + 12 ; int lBtn = m_label.Length() * 8 + 12 ;
if (lBtn > wBtn) if (lBtn > wBtn)
wBtn = lBtn; wBtn = lBtn;
if ( UMAHasAquaLayout() ) if ( UMAHasAquaLayout() )
@@ -108,7 +113,7 @@ void wxToggleButton::Command(wxCommandEvent & event)
ProcessCommand(event); ProcessCommand(event);
} }
void wxToggleButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) ) void wxToggleButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) )
{ {
if ( controlpart != kControlNoPart ) if ( controlpart != kControlNoPart )
{ {
@@ -120,4 +125,3 @@ void wxToggleButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16
} }
#endif // wxUSE_TOGGLEBTN #endif // wxUSE_TOGGLEBTN

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: tooltip.cpp // Name: src/mac/classic/tooltip.cpp
// Purpose: wxToolTip implementation // Purpose: wxToolTip implementation
// Author: Robert Roebling // Author: Robert Roebling
// Id: $Id$ // Id: $Id$
@@ -7,7 +7,11 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
@@ -30,18 +34,18 @@ class wxMacToolTip
public : public :
wxMacToolTip( ) ; wxMacToolTip( ) ;
~wxMacToolTip() ; ~wxMacToolTip() ;
void Setup( WindowRef window , const wxString& text , wxPoint localPosition ) ; void Setup( WindowRef window , const wxString& text , wxPoint localPosition ) ;
long GetMark() { return m_mark ; } long GetMark() { return m_mark ; }
void Draw() ; void Draw() ;
void Clear() ; void Clear() ;
bool IsShown() { return m_shown ; } bool IsShown() { return m_shown ; }
private : private :
wxString m_label ; wxString m_label ;
wxPoint m_position ; wxPoint m_position ;
Rect m_rect ; Rect m_rect ;
WindowRef m_window ; WindowRef m_window ;
PicHandle m_backpict ; PicHandle m_backpict ;
bool m_shown ; bool m_shown ;
long m_mark ; long m_mark ;
@@ -60,7 +64,7 @@ public:
void Notify() void Notify()
{ {
if ( m_mark == m_tip->GetMark() ) if ( m_mark == m_tip->GetMark() )
m_tip->Draw() ; m_tip->Draw() ;
} }
protected: protected:
wxMacToolTip* m_tip; wxMacToolTip* m_tip;
@@ -92,14 +96,14 @@ wxToolTip::~wxToolTip()
void wxToolTip::SetTip( const wxString &tip ) void wxToolTip::SetTip( const wxString &tip )
{ {
m_text = tip; m_text = tip;
if ( m_window ) if ( m_window )
{ {
/* /*
// update it immediately // update it immediately
wxToolInfo ti(GetHwndOf(m_window)); wxToolInfo ti(GetHwndOf(m_window));
ti.lpszText = (wxChar *)m_text.c_str(); ti.lpszText = (wxChar *)m_text.c_str();
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti); (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);
*/ */
} }
@@ -149,7 +153,7 @@ void wxToolTip::RelayEvent( wxWindow *win , wxMouseEvent &event )
s_ToolTip.Clear() ; s_ToolTip.Clear() ;
s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ; s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ;
s_LastWindowEntered = win ; s_LastWindowEntered = win ;
WindowRef window = MAC_WXHWND( win->MacGetRootWindow() ) ; WindowRef window = MAC_WXHWND( win->MacGetRootWindow() ) ;
int x = event.m_x ; int x = event.m_x ;
int y = event.m_y ; int y = event.m_y ;
@@ -184,7 +188,7 @@ wxMacToolTip::wxMacToolTip()
m_timer = NULL ; m_timer = NULL ;
} }
void wxMacToolTip::Setup( WindowRef win , const wxString& text , wxPoint localPosition ) void wxMacToolTip::Setup( WindowRef win , const wxString& text , wxPoint localPosition )
{ {
m_mark++ ; m_mark++ ;
Clear() ; Clear() ;
@@ -198,13 +202,13 @@ void wxMacToolTip::Setup( WindowRef win , const wxString& text , wxPoint localP
m_timer = new wxMacToolTipTimer( this , s_ToolTipDelay ) ; m_timer = new wxMacToolTipTimer( this , s_ToolTipDelay ) ;
} }
wxMacToolTip::~wxMacToolTip() wxMacToolTip::~wxMacToolTip()
{ {
if ( m_timer ) { if ( m_timer ) {
delete m_timer ; delete m_timer ;
m_timer = NULL; m_timer = NULL;
} }
if ( m_backpict ) if ( m_backpict )
Clear() ; Clear() ;
} }
@@ -215,7 +219,7 @@ void wxMacToolTip::Draw()
{ {
if ( m_label.Length() == 0 ) if ( m_label.Length() == 0 )
return ; return ;
if ( m_window == s_ToolTipWindowRef ) if ( m_window == s_ToolTipWindowRef )
{ {
m_shown = true ; m_shown = true ;
@@ -244,7 +248,7 @@ void wxMacToolTip::Draw()
Style fontStyle ; Style fontStyle ;
GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
GetFNum( fontName, &fontId ); GetFNum( fontName, &fontId );
TextFont( fontId ) ; TextFont( fontId ) ;
TextSize( fontSize ) ; TextSize( fontSize ) ;
TextFace( fontStyle ) ; TextFace( fontStyle ) ;
@@ -252,7 +256,7 @@ void wxMacToolTip::Draw()
::GetFontInfo(&fontInfo); ::GetFontInfo(&fontInfo);
short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
short height = 0 ; short height = 0 ;
int i = 0 ; int i = 0 ;
int length = m_label.Length() ; int length = m_label.Length() ;
int width = 0 ; int width = 0 ;
@@ -267,7 +271,7 @@ void wxMacToolTip::Draw()
thiswidth = ::TextWidth( text , laststop , i - laststop ) ; thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
if ( thiswidth > width ) if ( thiswidth > width )
width = thiswidth ; width = thiswidth ;
height += lineh ; height += lineh ;
laststop = i+1 ; laststop = i+1 ;
} }
@@ -280,7 +284,7 @@ void wxMacToolTip::Draw()
width = thiswidth ; width = thiswidth ;
height += lineh ; height += lineh ;
} }
m_rect.left = m_position.x + kTipOffset; m_rect.left = m_position.x + kTipOffset;
m_rect.top = m_position.y + kTipOffset; m_rect.top = m_position.y + kTipOffset;
m_rect.right = m_rect.left + width + 2 * kTipBorder; m_rect.right = m_rect.left + width + 2 * kTipBorder;
@@ -311,41 +315,41 @@ void wxMacToolTip::Draw()
ClipRect( &m_rect ) ; ClipRect( &m_rect ) ;
BackColor( whiteColor ) ; BackColor( whiteColor ) ;
ForeColor(blackColor ) ; ForeColor(blackColor ) ;
GWorldPtr port ; GWorldPtr port ;
NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ;
CGrafPtr origPort ; CGrafPtr origPort ;
GDHandle origDevice ; GDHandle origDevice ;
GetGWorld( &origPort , &origDevice ) ; GetGWorld( &origPort , &origDevice ) ;
SetGWorld( port , NULL ) ; SetGWorld( port , NULL ) ;
m_backpict = OpenPicture(&m_rect); m_backpict = OpenPicture(&m_rect);
CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)),
GetPortBitMapForCopyBits(port), GetPortBitMapForCopyBits(port),
&m_rect, &m_rect,
&m_rect, &m_rect,
srcCopy, srcCopy,
NULL); NULL);
ClosePicture(); ClosePicture();
SetGWorld( origPort , origDevice ) ; SetGWorld( origPort , origDevice ) ;
DisposeGWorld( port ) ; DisposeGWorld( port ) ;
PenNormal() ; PenNormal() ;
RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ;
BackColor( whiteColor ) ; BackColor( whiteColor ) ;
RGBForeColor( &tooltipbackground ) ; RGBForeColor( &tooltipbackground ) ;
PaintRect( &m_rect ) ; PaintRect( &m_rect ) ;
ForeColor(blackColor ) ; ForeColor(blackColor ) ;
FrameRect( &m_rect ) ; FrameRect( &m_rect ) ;
SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ;
::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder);
i = 0 ; i = 0 ;
laststop = 0 ; laststop = 0 ;
height = 0 ; height = 0 ;
while( i < length ) while( i < length )
{ {
if( text[i] == 13 || text[i] == 10) if( text[i] == 13 || text[i] == 10)
@@ -358,12 +362,12 @@ void wxMacToolTip::Draw()
i++ ; i++ ;
} }
::DrawText( text , laststop , i - laststop ) ; ::DrawText( text , laststop , i - laststop ) ;
::TextMode( srcOr ) ; ::TextMode( srcOr ) ;
#endif #endif
} }
} }
void wxToolTip::NotifyWindowDelete( WXHWND win ) void wxToolTip::NotifyWindowDelete( WXHWND win )
{ {
if ( win == s_ToolTipWindowRef ) if ( win == s_ToolTipWindowRef )
{ {
@@ -384,7 +388,7 @@ void wxMacToolTip::Clear()
#if TARGET_CARBON #if TARGET_CARBON
HMHideTag() ; HMHideTag() ;
m_helpTextRef.Release() ; m_helpTextRef.Release() ;
#else #else
if ( m_window == s_ToolTipWindowRef && m_backpict ) if ( m_window == s_ToolTipWindowRef && m_backpict )
{ {
wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ; wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ;
@@ -401,4 +405,3 @@ void wxMacToolTip::Clear()
} }
#endif #endif

View File

@@ -9,7 +9,11 @@
// Licence: The wxWindows licence // Licence: The wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "wx/defs.h" #include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_GUI #if wxUSE_GUI