+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: accel.h
-// Purpose: wxAcceleratorTable class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_ACCEL_H_
-#define _WX_ACCEL_H_
-
-#include "wx/string.h"
-#include "wx/event.h"
-
-class WXDLLEXPORT wxAcceleratorTable: public wxObject
-{
-DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
-public:
- wxAcceleratorTable();
- wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]); // Load from array
-
- virtual ~wxAcceleratorTable();
-
- bool operator == (const wxAcceleratorTable& accel) const
- { return m_refData == accel.m_refData; }
- bool operator != (const wxAcceleratorTable& accel) const
- { return m_refData != accel.m_refData; }
-
- bool Ok() const { return IsOk(); }
- bool IsOk() const;
-
- int GetCommand( wxKeyEvent &event );
-};
-
-// WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
-
-#endif
- // _WX_ACCEL_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: aga.h
-// Purpose: Gray Controls implementation
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-
-// NOT NEEDED ANYMORE
\ No newline at end of file
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: app.h
-// Purpose: wxApp class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_APP_H_
-#define _WX_APP_H_
-
-#include "wx/defs.h"
-#include "wx/object.h"
-#include "wx/gdicmn.h"
-#include "wx/event.h"
-
-class WXDLLEXPORT wxFrame;
-class WXDLLEXPORT wxWindowMac;
-class WXDLLEXPORT wxApp ;
-class WXDLLEXPORT wxKeyEvent;
-class WXDLLEXPORT wxLog;
-
-#define wxPRINT_WINDOWS 1
-#define wxPRINT_POSTSCRIPT 2
-
-WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
-
-// Force an exit from main loop
-void WXDLLEXPORT wxExit();
-
-// Yield to other apps/messages
-bool WXDLLEXPORT wxYield();
-
-// Represents the application. Derive OnInit and declare
-// a new App object to start application
-class WXDLLEXPORT wxApp: public wxAppBase
-{
- DECLARE_DYNAMIC_CLASS(wxApp)
-
- wxApp();
- virtual ~wxApp() {}
-
- virtual int MainLoop();
- virtual void ExitMainLoop();
- virtual bool Pending() ;
- virtual bool Dispatch() ;
-
- virtual void Exit();
-
- virtual bool Yield(bool onlyIfNeeded = FALSE);
- virtual void WakeUpIdle();
-
- virtual void SetPrintMode(int mode) { m_printMode = mode; }
- virtual int GetPrintMode() const { return m_printMode; }
-
-#if wxUSE_GUI
- // setting up all MacOS Specific Event-Handlers etc
- virtual bool OnInitGui();
-#endif // wxUSE_GUI
- // implementation only
- void OnIdle(wxIdleEvent& event);
- void OnEndSession(wxCloseEvent& event);
- void OnQueryEndSession(wxCloseEvent& event);
-
- // Windows only, but for compatibility...
- inline void SetAuto3D(bool flag) { m_auto3D = flag; }
- inline bool GetAuto3D() const { return m_auto3D; }
-
-protected:
- bool m_showOnInit;
- int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
- bool m_auto3D ; // Always use 3D controls, except
- // where overriden
-public:
-
- static bool sm_isEmbedded;
- // Implementation
- virtual bool Initialize(int& argc, wxChar **argv);
- virtual void CleanUp();
-
- bool IsExiting() { return !m_keepGoing ; }
-#if TARGET_CARBON
- // the installed application event handler
- WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
- WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
- void MacSetCurrentEvent( WXEVENTREF event , WXEVENTHANDLERCALLREF handler )
- { m_macCurrentEvent = event ; m_macCurrentEventHandlerCallRef = handler ; }
-#endif
-
-public:
- static long sm_lastMessageTime;
- static wxWindow* s_captureWindow ;
- static int s_lastMouseDown ; // 0 = none , 1 = left , 2 = right
- static WXHRGN s_macCursorRgn ;
- static long s_lastModifiers ;
-
- int m_nCmdShow;
-
-private:
- bool m_keepGoing ;
-
- // mac specifics
-#if TARGET_CARBON
- WXEVENTHANDLERREF m_macEventHandler ;
- WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
-#endif
- WXEVENTREF m_macCurrentEvent ;
-
-public:
- static bool s_macSupportPCMenuShortcuts ;
- static long s_macAboutMenuItemId ;
- static long s_macPreferencesMenuItemId ;
- static long s_macExitMenuItemId ;
- static wxString s_macHelpMenuTitleName ;
-
- static bool s_macHasAppearance ;
- static long s_macAppearanceVersion ;
- static bool s_macHasNavigation ;
- static bool s_macNavigationVersion ;
- static bool s_macHasWindowManager ;
- static long s_macWindowManagerVersion ;
- static bool s_macHasMenuManager ;
- static long s_macMenuManagerVersion ;
- static bool s_macHasDialogManager ;
- static long s_macDialogManagerVersion ;
-
- WXHRGN m_macCursorRgn ;
- WXHRGN m_macSleepRgn ;
- WXHRGN m_macHelpRgn ;
-
- virtual void MacSuspend( bool convertClipboard ) ;
- virtual void MacResume( bool convertClipboard ) ;
- virtual void MacConvertPrivateToPublicScrap() ;
- virtual void MacConvertPublicToPrivateScrap() ;
-
- void MacDoOneEvent() ;
- WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
- void MacHandleOneEvent( WXEVENTREF ev ) ;
-
- // For embedded use. By default does nothing.
- virtual void MacHandleUnhandledEvent( WXEVENTREF ev );
-
-#if !TARGET_CARBON
- virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
- virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;
- virtual void MacHandleOSEvent( WXEVENTREF ev ) ;
- virtual void MacHandleDiskEvent( WXEVENTREF ev ) ;
- virtual void MacHandleActivateEvent( WXEVENTREF ev ) ;
- virtual void MacHandleUpdateEvent( WXEVENTREF ev ) ;
- virtual void MacHandleMouseDownEvent( WXEVENTREF ev ) ;
-
- void MacHandleModifierEvents( WXEVENTREF ev ) ;
-
- virtual void MacHandleKeyDownEvent( WXEVENTREF ev ) ;
- virtual void MacHandleKeyUpEvent( WXEVENTREF ev ) ;
- virtual void MacHandleHighLevelEvent( WXEVENTREF ev ) ;
-
-#else
- virtual void MacHandleMouseMovedEvent( wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp ) ;
-#endif
-
- void MacHandleMenuCommand( wxUint32 command ) ;
- bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
- bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , short wherex , short wherey ) ;
-
- virtual short MacHandleAEODoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
- virtual short MacHandleAEPDoc(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
- virtual short MacHandleAEOApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
- virtual short MacHandleAEQuit(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
- virtual short MacHandleAERApp(const WXAPPLEEVENTREF event , WXAPPLEEVENTREF reply) ;
-
- // in response of an open-document apple event
- virtual void MacOpenFile(const wxString &fileName) ;
- // in response of a print-document apple event
- virtual void MacPrintFile(const wxString &fileName) ;
- // in response of a open-application apple event
- virtual void MacNewFile() ;
- // in response of a reopen-application apple event
- virtual void MacReopenApp() ;
-
- DECLARE_EVENT_TABLE()
-};
-
-class WXDLLEXPORT wxStAppResource
-{
-public:
- wxStAppResource() ;
- ~wxStAppResource() ;
-
- // opaque pointer for CFragInitBlock
- static void OpenSharedLibraryResource(const void *) ;
- static void CloseSharedLibraryResource() ;
-
-private:
- short m_currentRefNum ;
-} ;
-
-#endif
- // _WX_APP_H_
-
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/apptbase.h
-// Purpose: declaration of wxAppTraits for Mac systems
-// Author: Vadim Zeitlin
-// Modified by: Stefan Csomor
-// Created: 23.06.2003
-// RCS-ID: $Id$
-// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MAC_APPTBASE_H_
-#define _WX_MAC_APPTBASE_H_
-
-// ----------------------------------------------------------------------------
-// wxAppTraits: the Mac version adds extra hooks needed by Mac code
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxAppTraits : public wxAppTraitsBase
-{
-public:
- // wxExecute() support methods
- // ---------------------------
-
- // TODO
-
- // wxThread helpers
- // ----------------
-
-
- // TODO
-
- // other miscellaneous helpers
- // ---------------------------
-
-};
-
-#endif // _WX_MAC_APPTBASE_H_
-
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/apptrait.h
-// Purpose: standard implementations of wxAppTraits for MacOS
-// Author: Vadim Zeitlin
-// Modified by: Stefan Csomor
-// Created: 23.06.2003
-// RCS-ID: $Id$
-// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MAC_APPTRAIT_H_
-#define _WX_MAC_APPTRAIT_H_
-
-// ----------------------------------------------------------------------------
-// wxGUI/ConsoleAppTraits: must derive from wxAppTraits, not wxAppTraitsBase
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxConsoleAppTraits : public wxConsoleAppTraitsBase
-{
-public:
- // other miscellaneous helpers
- // ---------------------------
-
- virtual wxToolkitInfo& GetToolkitInfo();
-};
-
-#if wxUSE_GUI
-
-class WXDLLEXPORT wxGUIAppTraits : public wxGUIAppTraitsBase
-{
-public:
- // other miscellaneous helpers
- // ---------------------------
-
- virtual wxToolkitInfo& GetToolkitInfo();
-};
-
-#endif // wxUSE_GUI
-
-#endif // _WX_MAC_APPTRAIT_H_
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: bitmap.h
-// Purpose: wxBitmap class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_BITMAP_H_
-#define _WX_BITMAP_H_
-
-#include "wx/palette.h"
-
-// Bitmap
-class WXDLLEXPORT wxBitmap;
-class WXDLLEXPORT wxBitmapHandler;
-class WXDLLEXPORT wxControl;
-class WXDLLEXPORT wxCursor;
-class WXDLLEXPORT wxDC;
-class WXDLLEXPORT wxIcon;
-class WXDLLEXPORT wxImage;
-class WXDLLEXPORT wxPixelDataBase;
-
-// A mask is a bitmap used for drawing bitmaps
-// it can be a monochrome bitmap or a multi-bit bitmap which transfers to alpha channels
-// transparently.
-class WXDLLEXPORT wxMask: public wxObject
-{
- DECLARE_DYNAMIC_CLASS(wxMask)
- DECLARE_NO_COPY_CLASS(wxMask)
-
-public:
- wxMask();
-
- // Construct a mask from a bitmap and a colour indicating
- // the transparent area
- wxMask(const wxBitmap& bitmap, const wxColour& colour);
-
- // Construct a mask from a bitmap and a palette index indicating
- // the transparent area
- wxMask(const wxBitmap& bitmap, int paletteIndex);
-
- // Construct a mask from a mono bitmap (copies the bitmap).
- wxMask(const wxBitmap& bitmap);
-
- virtual ~wxMask();
-
- bool Create(const wxBitmap& bitmap, const wxColour& colour);
- bool Create(const wxBitmap& bitmap, int paletteIndex);
- bool Create(const wxBitmap& bitmap);
-
- // Implementation
- bool PointMasked(int x, int y);
- inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; }
- inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; }
- int GetDepth() const { return m_depth ; }
- void SetDepth( int depth ) { m_depth = depth ; }
-protected:
- WXHBITMAP m_maskBitmap;
- int m_depth ;
-};
-
-enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict , kMacBitmapTypeIcon } ;
-
-class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
-{
- DECLARE_NO_COPY_CLASS(wxBitmapRefData)
-
- friend class WXDLLEXPORT wxBitmap;
- friend class WXDLLEXPORT wxIcon;
- friend class WXDLLEXPORT wxCursor;
-public:
- wxBitmapRefData();
- virtual ~wxBitmapRefData();
-
-public:
- int m_width;
- int m_height;
- int m_depth;
- bool m_ok;
- int m_numColors;
-#if wxUSE_PALETTE
- wxPalette m_bitmapPalette;
-#endif // wxUSE_PALETTE
- int m_quality;
-
- int m_bitmapType ;
- WXHMETAFILE m_hPict ;
- WXHBITMAP m_hBitmap;
- WXHICON m_hIcon ;
- wxMask * m_bitmapMask; // Optional mask
- bool m_hasAlpha;
-};
-
-#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
-
-class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase
-{
- DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
-public:
- wxBitmapHandler() : m_name(), m_extension(), m_type(0) { }
- virtual ~wxBitmapHandler();
-
- virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
- virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight);
- virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
-
- void SetName(const wxString& name) { m_name = name; }
- void SetExtension(const wxString& ext) { m_extension = ext; }
- void SetType(long type) { m_type = type; }
- wxString GetName() const { return m_name; }
- wxString GetExtension() const { return m_extension; }
- long GetType() const { return m_type; }
-
-protected:
- wxString m_name;
- wxString m_extension;
- long m_type;
-};
-
-#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
-
-class WXDLLEXPORT wxBitmap: public wxBitmapBase
-{
- DECLARE_DYNAMIC_CLASS(wxBitmap)
-
- friend class WXDLLEXPORT wxBitmapHandler;
-
-public:
- wxBitmap(); // Platform-specific
-
- // Initialize with raw data.
- wxBitmap(const char bits[], int width, int height, int depth = 1);
-
- // Initialize with XPM data
- bool CreateFromXpm(const char **bits);
- wxBitmap(const char **bits);
- wxBitmap(char **bits);
-
- // Load a file or resource
- wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_PICT_RESOURCE);
-
- // Constructor for generalised creation from data
- wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1);
-
- // If depth is omitted, will create a bitmap compatible with the display
- wxBitmap(int width, int height, int depth = -1);
-
- // Convert from wxImage:
- wxBitmap(const wxImage& image, int depth = -1);
-
- virtual ~wxBitmap();
-
- wxImage ConvertToImage() const;
-
- // get the given part of bitmap
- wxBitmap GetSubBitmap( const wxRect& rect ) const;
-
- virtual bool Create(int width, int height, int depth = -1);
- virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1);
- virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE);
- virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
-
- // copies the contents and mask of the given (colour) icon to the bitmap
- virtual bool CopyFromIcon(const wxIcon& icon);
-
- bool Ok() const { return IsOk(); }
- bool IsOk() const;
- int GetWidth() const;
- int GetHeight() const;
- int GetDepth() const;
- int GetQuality() const;
- void SetWidth(int w);
- void SetHeight(int h);
- void SetDepth(int d);
- void SetQuality(int q);
- void SetOk(bool isOk);
-
-#if wxUSE_PALETTE
- wxPalette* GetPalette() const;
- void SetPalette(const wxPalette& palette);
-#endif // wxUSE_PALETTE
-
- wxMask *GetMask() const;
- void SetMask(wxMask *mask) ;
-
- int GetBitmapType() const;
-
- static void InitStandardHandlers();
-
- // raw bitmap access support functions, for internal use only
- void *GetRawData(wxPixelDataBase& data, int bpp);
- void UngetRawData(wxPixelDataBase& data);
-
- void UseAlpha();
-
-public:
- WXHBITMAP GetHBITMAP() const;
- inline WXHICON GetHICON() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hIcon : 0); }
- WXHMETAFILE GetPict(bool *created = NULL ) const;
-
- void SetHBITMAP(WXHBITMAP bmp);
- void SetHICON(WXHICON ico);
- void SetPict( WXHMETAFILE pict ) ;
-
- bool FreeResource(bool force = FALSE);
-};
-#endif
- // _WX_BITMAP_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: bmpbuttn.h
-// Purpose: wxBitmapButton class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_BMPBUTTN_H_
-#define _WX_BMPBUTTN_H_
-
-#include "wx/button.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxButtonNameStr[];
-
-#define wxDEFAULT_BUTTON_MARGIN 4
-
-class WXDLLEXPORT wxBitmapButton: public wxBitmapButtonBase
-{
- DECLARE_DYNAMIC_CLASS(wxBitmapButton)
-
-public:
- wxBitmapButton()
- {
- SetMargins(wxDEFAULT_BUTTON_MARGIN, wxDEFAULT_BUTTON_MARGIN);
- }
-
- wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxButtonNameStr)
- {
- Create(parent, id, bitmap, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxButtonNameStr);
-
- virtual void SetBitmapLabel(const wxBitmap& bitmap);
-
-/*
- // TODO: Implementation
- virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
- virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel );
- virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel );
- virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg );
-*/
-
-protected:
- virtual wxSize DoGetBestSize() const;
-};
-
-#endif
- // _WX_BMPBUTTN_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/brush.h
-// Purpose: wxBrush class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_BRUSH_H_
-#define _WX_BRUSH_H_
-
-#include "wx/gdicmn.h"
-#include "wx/gdiobj.h"
-#include "wx/bitmap.h"
-
-class WXDLLEXPORT wxBrush;
-
-typedef enum
-{
- kwxMacBrushColour ,
- kwxMacBrushTheme ,
- kwxMacBrushThemeBackground
-} wxMacBrushKind ;
-
-// Brush
-class WXDLLEXPORT wxBrush: public wxBrushBase
-{
- DECLARE_DYNAMIC_CLASS(wxBrush)
-
-public:
- wxBrush();
- wxBrush(short macThemeBrush ) ;
- wxBrush(const wxColour& col, int style = wxSOLID);
- wxBrush(const wxBitmap& stipple);
- virtual ~wxBrush();
-
- virtual void SetColour(const wxColour& col) ;
- virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
- virtual void SetStyle(int style) ;
- virtual void SetStipple(const wxBitmap& stipple) ;
- virtual void SetMacTheme(short macThemeBrush) ;
- virtual void SetMacThemeBackground(unsigned long macThemeBackground , WXRECTPTR extent) ;
-
- bool operator == (const wxBrush& brush) const
- { return m_refData == brush.m_refData; }
- bool operator != (const wxBrush& brush) const
- { return m_refData != brush.m_refData; }
-
- wxMacBrushKind MacGetBrushKind() const ;
-
- unsigned long GetMacThemeBackground(WXRECTPTR extent) const ;
- short GetMacTheme() const ;
- wxColour& GetColour() const ;
- virtual int GetStyle() const ;
- wxBitmap *GetStipple() const ;
-
- virtual bool Ok() const { return IsOk(); }
- virtual bool IsOk() const { return (m_refData != NULL) ; }
-
-// Implementation
-
- // Useful helper: create the brush resource
- bool RealizeResource();
-
- // When setting properties, we must make sure we're not changing
- // another object
- void Unshare();
-};
-
-#endif
- // _WX_BRUSH_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: button.h
-// Purpose: wxButton class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_BUTTON_H_
-#define _WX_BUTTON_H_
-
-#include "wx/control.h"
-#include "wx/gdicmn.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxButtonNameStr[];
-
-// Pushbutton
-class WXDLLEXPORT wxButton: public wxButtonBase
-{
- DECLARE_DYNAMIC_CLASS(wxButton)
- public:
- inline wxButton() {}
- inline wxButton(wxWindow *parent, wxWindowID id,
- const wxString& label = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxButtonNameStr)
- {
- Create(parent, id, label, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxString& label = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxButtonNameStr);
-
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
- static wxSize GetDefaultSize();
-
- virtual void SetDefault();
- virtual void Command(wxCommandEvent& event);
-protected:
- virtual wxSize DoGetBestSize() const ;
-};
-
-#endif
- // _WX_BUTTON_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: checkbox.h
-// Purpose: wxCheckBox class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_CHECKBOX_H_
-#define _WX_CHECKBOX_H_
-
-// Checkbox item (single checkbox)
-class WXDLLEXPORT wxCheckBox : public wxCheckBoxBase
-{
-public:
- wxCheckBox() { }
- wxCheckBox(wxWindow *parent, wxWindowID id, const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxCheckBoxNameStr)
- {
- Create(parent, id, label, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id, const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxCheckBoxNameStr);
- virtual void SetValue(bool);
- virtual bool GetValue() const;
-
- void DoSet3StateValue(wxCheckBoxState val);
- virtual wxCheckBoxState DoGet3StateValue() const;
-
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown );
- virtual void Command(wxCommandEvent& event);
-
- DECLARE_DYNAMIC_CLASS(wxCheckBox)
-};
-
-class WXDLLEXPORT wxBitmap;
-class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
-{
-public:
- int checkWidth;
- int checkHeight;
-
- wxBitmapCheckBox()
- : checkWidth(-1), checkHeight(-1)
- { }
-
- wxBitmapCheckBox(wxWindow *parent, wxWindowID id, const wxBitmap *label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxCheckBoxNameStr)
- {
- Create(parent, id, label, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id, const wxBitmap *bitmap,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxCheckBoxNameStr);
- virtual void SetValue(bool);
- virtual bool GetValue() const;
- virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
- virtual void SetLabel(const wxBitmap *bitmap);
- virtual void SetLabel( const wxString & WXUNUSED(name) ) {}
-
- DECLARE_DYNAMIC_CLASS(wxBitmapCheckBox)
-};
-#endif
- // _WX_CHECKBOX_H_
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/checklst.h
-// Purpose: wxCheckListBox class - a listbox with checkable items
-// Note: this is an optional class.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_CHECKLST_H_
-#define _WX_CHECKLST_H_
-
-class WXDLLEXPORT wxCheckListBox : public wxCheckListBoxBase
-{
- DECLARE_DYNAMIC_CLASS(wxCheckListBox)
-public:
- // ctors
- wxCheckListBox() { Init(); }
- wxCheckListBox(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- int nStrings = 0,
- const wxString *choices = NULL,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListBoxNameStr)
- {
- Init();
-
- Create(parent, id, pos, size, nStrings, choices, style, validator, name);
- }
- wxCheckListBox(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListBoxNameStr)
- {
- Init();
-
- Create(parent, id, pos, size, choices, style, validator, name);
- }
-
- bool Create(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- int nStrings = 0,
- const wxString *choices = NULL,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListBoxNameStr);
- bool Create(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListBoxNameStr);
-
- // items may be checked
- bool IsChecked(unsigned int uiIndex) const;
- void Check(unsigned int uiIndex, bool bCheck = true);
- void OnChar(wxKeyEvent& event) ;
- void OnLeftClick(wxMouseEvent& event) ;
-
- // metrics
- wxInt32 m_checkBoxWidth;
- wxInt32 m_checkBoxHeight;
- wxInt32 m_TextBaseLineOffset;
-
- // the array containing the checked status of the items
- wxArrayInt m_checks;
-
- // override all methods which add/delete items to update m_checks array as
- // well
- virtual void Delete(unsigned int n);
-protected:
- virtual int DoAppend(const wxString& item);
- virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
- virtual void DoSetItems(const wxArrayString& items, void **clientData);
- virtual void DoClear();
- // common part of all ctors
- void Init();
-private:
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_CHECKLST_H_
+++ /dev/null
-/*
- * Name: wx/mac/chkconf.h
- * Purpose: Compiler-specific configuration checking
- * Author: Julian Smart
- * Modified by:
- * Created: 01/02/97
- * RCS-ID: $Id$
- * Copyright: (c) Julian Smart
- * Licence: wxWindows licence
- */
-
-#ifndef _WX_MAC_CHKCONF_H_
-#define _WX_MAC_CHKCONF_H_
-
-/*
- * disable the settings which don't work for some compilers
- */
-
-/*
- * wxUSE_DEBUG_NEW_ALWAYS doesn't work with CodeWarrior
- */
-
-#if defined(__MWERKS__)
- #undef wxUSE_DEBUG_NEW_ALWAYS
- #define wxUSE_DEBUG_NEW_ALWAYS 0
-#endif
-
-#endif
- /* _WX_MAC_CHKCONF_H_ */
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/choice.h
-// Purpose: wxChoice class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_CHOICE_H_
-#define _WX_CHOICE_H_
-
-#include "wx/control.h"
-
-#include "wx/dynarray.h"
-#include "wx/arrstr.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxChoiceNameStr[];
-
-WX_DEFINE_ARRAY( char * , wxChoiceDataArray ) ;
-
-// Choice item
-class WXDLLEXPORT wxChoice: public wxChoiceBase
-{
- DECLARE_DYNAMIC_CLASS(wxChoice)
-
-public:
- wxChoice()
- : m_strings(), m_datas(), m_macPopUpMenuHandle(NULL)
- {}
-
- virtual ~wxChoice() ;
-
- wxChoice(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- int n = 0, const wxString choices[] = NULL,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxChoiceNameStr)
- {
- Create(parent, id, pos, size, n, choices, style, validator, name);
- }
- wxChoice(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxChoiceNameStr)
- {
- Create(parent, id, pos, size, choices, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- int n = 0, const wxString choices[] = NULL,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxChoiceNameStr);
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxChoiceNameStr);
-
- // implement base class pure virtuals
- virtual int DoAppend(const wxString& item);
- virtual int DoInsert(const wxString& item, unsigned int pos);
- virtual void Delete(unsigned int n);
- virtual void Clear();
-
- virtual unsigned int GetCount() const ;
- virtual int GetSelection() const ;
- virtual void SetSelection(int n);
-
- virtual wxString GetString(unsigned int n) const ;
- virtual void SetString(unsigned int pos, const wxString& s);
- void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
-
-protected:
- virtual wxSize DoGetBestSize() const ;
-
-public: // for wxComboBox only
- virtual void DoSetItemClientData(unsigned int n, void* clientData );
- virtual void* DoGetItemClientData(unsigned int n) const;
- virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
- virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
-
-protected:
- // free all memory we have (used by Clear() and dtor)
- // prevent collision with some BSD definitions of macro Free()
- void FreeData();
-
- wxArrayString m_strings;
- wxChoiceDataArray m_datas ;
- WXHMENU m_macPopUpMenuHandle ;
-};
-
-#endif
- // _WX_CHOICE_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: clipbrd.h
-// Purpose: Clipboard functionality.
-// Note: this functionality is under review, and
-// is derived from wxWidgets 1.xx code. Please contact
-// the wxWidgets developers for further information.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_CLIPBRD_H_
-#define _WX_CLIPBRD_H_
-
-#if wxUSE_CLIPBOARD
-
-#include "wx/list.h"
-#include "wx/module.h"
-#include "wx/dataobj.h" // for wxDataFormat
-
-//-----------------------------------------------------------------------------
-// wxClipboard
-//-----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxDataObject;
-class WXDLLEXPORT wxClipboard : public wxClipboardBase
-{
- DECLARE_DYNAMIC_CLASS(wxClipboard)
-
-public:
- wxClipboard();
- virtual ~wxClipboard();
-
- // open the clipboard before SetData() and GetData()
- virtual bool Open();
-
- // close the clipboard after SetData() and GetData()
- virtual void Close();
-
- // query whether the clipboard is opened
- virtual bool IsOpened() const;
-
- // set the clipboard data. all other formats will be deleted.
- virtual bool SetData( wxDataObject *data );
-
- // add to the clipboard data.
- virtual bool AddData( wxDataObject *data );
-
- // ask if data in correct format is available
- virtual bool IsSupported( const wxDataFormat& format );
-
- // fill data with data on the clipboard (if available)
- virtual bool GetData( wxDataObject& data );
-
- // clears wxTheClipboard and the system's clipboard if possible
- virtual void Clear();
-
- // flushes the clipboard: this means that the data which is currently on
- // clipboard will stay available even after the application exits (possibly
- // eating memory), otherwise the clipboard will be emptied on exit
- virtual bool Flush();
-
- // X11 has two clipboards which get selected by this call. Empty on MSW.
- void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
-
-private:
- wxDataObject *m_data;
- bool m_open;
-};
-
-#endif // wxUSE_CLIPBOARD
-
-#endif
- // _WX_CLIPBRD_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/colordlg.h
-// Purpose: wxColourDialog class. Use generic version if no
-// platform-specific implementation.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_COLORDLG_H_
-#define _WX_COLORDLG_H_
-
-#include "wx/defs.h"
-#include "wx/dialog.h"
-#include "wx/cmndata.h"
-
-/*
- * Platform-specific colour dialog implementation
- */
-
-class WXDLLEXPORT wxColourDialog: public wxDialog
-{
-DECLARE_DYNAMIC_CLASS(wxColourDialog)
-public:
- wxColourDialog();
- wxColourDialog(wxWindow *parent, wxColourData *data = NULL);
-
- bool Create(wxWindow *parent, wxColourData *data = NULL);
-
- int ShowModal();
- wxColourData& GetColourData() { return m_colourData; }
-
-protected:
- wxColourData m_colourData;
- wxWindow* m_dialogParent;
-};
-
-#endif
- // _WX_COLORDLG_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/colour.h
-// Purpose: wxColour class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_COLOUR_H_
-#define _WX_COLOUR_H_
-
-#include "wx/object.h"
-#include "wx/string.h"
-
-// Colour
-class WXDLLEXPORT wxColour: public wxColourBase
-{
-public:
- // constructors
- // ------------
-
- // default
- wxColour() { Init(); }
- DEFINE_STD_WXCOLOUR_CONSTRUCTORS
-
- // copy ctors and assignment operators
- wxColour( const wxColour& col );
- wxColour( const wxColour* col );
- wxColour& operator = ( const wxColour& col );
-
- // dtor
- virtual ~wxColour();
-
- // accessors
- bool Ok() const { return IsOk(); }
- bool IsOk() const {return m_isInit; }
-
- unsigned char Red() const { return m_red; }
- unsigned char Green() const { return m_green; }
- unsigned char Blue() const { return m_blue; }
-
- // comparison
- bool operator == (const wxColour& colour) const
- {
- return (m_isInit == colour.m_isInit
- && m_red == colour.m_red
- && m_green == colour.m_green
- && m_blue == colour.m_blue);
- }
- bool operator != (const wxColour& colour) const { return !(*this == colour); }
-
- const WXCOLORREF& GetPixel() const { return m_pixel; };
-
-protected:
-
- // Helper function
- void Init();
-
- void InitWith( unsigned char red, unsigned char green, unsigned char blue );
-
-private:
- bool m_isInit;
- unsigned char m_red;
- unsigned char m_blue;
- unsigned char m_green;
-
-public:
- WXCOLORREF m_pixel ;
- void Set( const WXCOLORREF* color ) ;
-
-private:
- DECLARE_DYNAMIC_CLASS(wxColour)
-};
-
-#endif
- // _WX_COLOUR_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/combobox.h
-// Purpose: wxComboBox class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_COMBOBOX_H_
-#define _WX_COMBOBOX_H_
-
-#include "wx/choice.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxComboBoxNameStr[];
-
-// Combobox item
-class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase
-{
- DECLARE_DYNAMIC_CLASS(wxComboBox)
-
- public:
- inline wxComboBox() {}
- virtual ~wxComboBox();
- // override the base class virtuals involved in geometry calculations
- virtual wxSize DoGetBestSize() const;
- virtual void DoMoveWindow(int x, int y, int width, int height);
-
- // forward these functions to all subcontrols
- virtual bool Enable(bool enable = true);
- virtual bool Show(bool show = true);
- virtual void SetFocus();
-
- // callback functions
- virtual void DelegateTextChanged( const wxString& value );
- virtual void DelegateChoice( const wxString& value );
-
- inline wxComboBox(wxWindow *parent, wxWindowID id,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- int n = 0, const wxString choices[] = NULL,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxComboBoxNameStr)
- {
- Create(parent, id, value, pos, size, n, choices, style, validator, name);
- }
- inline wxComboBox(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxComboBoxNameStr)
- {
- Create(parent, id, value, pos, size, choices, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- int n = 0, const wxString choices[] = NULL,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxComboBoxNameStr);
- bool Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxComboBoxNameStr);
-
- // List functions
- virtual void Delete(unsigned int n);
- virtual void Clear();
-
- virtual int GetSelection() const ;
- virtual void SetSelection(int n);
- virtual int FindString(const wxString& s, bool bCase = false) const;
- virtual wxString GetString(unsigned int n) const ;
- virtual wxString GetStringSelection() const ;
- virtual void SetString(unsigned int n, const wxString& s);
-
- // Text field functions
- virtual wxString GetValue() const ;
- virtual void SetValue(const wxString& value);
-
- // Clipboard operations
- virtual void Copy();
- virtual void Cut();
- virtual void Paste();
- virtual void SetInsertionPoint(long pos);
- virtual void SetInsertionPointEnd();
- virtual long GetInsertionPoint() const ;
- virtual wxTextPos GetLastPosition() const ;
- virtual void Replace(long from, long to, const wxString& value);
- virtual void Remove(long from, long to);
- virtual void SetSelection(long from, long to);
- virtual void SetEditable(bool editable);
- virtual unsigned int GetCount() const { return m_choice->GetCount() ; }
-
- virtual bool IsEditable() const ;
-
- virtual void Undo() ;
- virtual void Redo() ;
- virtual void SelectAll() ;
-
- virtual bool CanCopy() const ;
- virtual bool CanCut() const ;
- virtual bool CanPaste() const ;
- virtual bool CanUndo() const ;
- virtual bool CanRedo() const ;
-
- void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
-
- wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
-
-protected:
- virtual int DoAppend(const wxString& item) ;
- virtual int DoInsert(const wxString& item, unsigned int pos) ;
-
- virtual void DoSetItemClientData(unsigned int n, void* clientData);
- virtual void* DoGetItemClientData(unsigned int n) const ;
- virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
- virtual wxClientData* DoGetItemClientObject(unsigned int n) const ;
-
- void FreeData();
-
- // the subcontrols
- wxTextCtrl* m_text;
- wxChoice* m_choice;
-};
-
-#endif
- // _WX_COMBOBOX_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: control.h
-// Purpose: wxControl class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_CONTROL_H_
-#define _WX_CONTROL_H_
-
-WXDLLEXPORT_DATA(extern const wxChar) wxControlNameStr[];
-
-// General item class
-class WXDLLEXPORT wxControl : public wxControlBase
-{
- DECLARE_ABSTRACT_CLASS(wxControl)
-
-public:
- wxControl();
- wxControl(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxControlNameStr)
- {
- Create(parent, id, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxControlNameStr);
- virtual ~wxControl();
-
- // Simulates an event
- virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
-
- // implementation from now on
- // --------------------------
-
- // Calls the callback and appropriate event handlers
- bool ProcessCommand(wxCommandEvent& event);
- virtual void SetLabel(const wxString& title) ;
-
- wxList& GetSubcontrols() { return m_subControls; }
-
- void OnEraseBackground(wxEraseEvent& event);
-
- virtual bool Enable(bool enable = TRUE) ;
- virtual bool Show(bool show = TRUE) ;
- virtual void DoSetWindowVariant( wxWindowVariant variant ) ;
-
- virtual void MacRedrawControl () ;
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
- virtual void MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name ,
- WXRECTPTR outBounds ,
- unsigned char* maclabel ) ;
- virtual void MacPostControlCreate() ;
- virtual void MacAdjustControlRect() ;
- virtual WXWidget MacGetContainerForEmbedding() ;
- virtual void MacSuperChangedPosition() ;
- virtual void MacSuperEnabled( bool enabled ) ;
- virtual void MacSuperShown( bool show ) ;
- virtual bool MacCanFocus() const ;
- virtual void MacUpdateDimensions() ;
- void* MacGetControlAction() { return m_macControlAction ; }
-
- virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags = wxSIZE_AUTO ) ;
- void OnKeyDown( wxKeyEvent &event ) ;
- void OnMouseEvent( wxMouseEvent &event ) ;
- void OnPaint(wxPaintEvent& event) ;
- virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL) ;
- WXWidget GetMacControl() { return m_macControl ;}
-
-protected:
- // For controls like radiobuttons which are really composite
- WXWidget m_macControl ;
- void* m_macControlAction ;
- bool m_macControlIsShown ;
- wxList m_subControls;
- int m_macHorizontalBorder ;
- int m_macVerticalBorder ;
-
- virtual wxSize DoGetBestSize() const;
-
-private:
- DECLARE_EVENT_TABLE()
-};
-
-
-wxControl *wxFindControlFromMacControl(WXWidget inControl ) ;
-void wxAssociateControlWithMacControl(WXWidget inControl, wxControl *control) ;
-void wxRemoveMacControlAssociation(wxControl *control) ;
-
-#endif
- // _WX_CONTROL_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/cursor.h
-// Purpose: wxCursor class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_CURSOR_H_
-#define _WX_CURSOR_H_
-
-#include "wx/bitmap.h"
-
-class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
-{
- DECLARE_NO_COPY_CLASS(wxCursorRefData)
-
- friend class WXDLLEXPORT wxBitmap;
- friend class WXDLLEXPORT wxCursor;
-public:
- wxCursorRefData();
- virtual ~wxCursorRefData();
-
-protected:
- WXHCURSOR m_hCursor;
- bool m_disposeHandle;
- bool m_releaseHandle;
- bool m_isColorCursor ;
- long m_themeCursor ;
-};
-
-#define M_CURSORDATA ((wxCursorRefData *)m_refData)
-#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
-
-// Cursor
-class WXDLLEXPORT wxCursor: public wxBitmap
-{
- DECLARE_DYNAMIC_CLASS(wxCursor)
-
-public:
- wxCursor();
-
- wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1,
- const char maskBits[] = NULL);
-
- wxCursor(const wxImage & image) ;
- wxCursor(const char **bits) ;
- wxCursor(char **bits) ;
- wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_MACCURSOR_RESOURCE,
- int hotSpotX = 0, int hotSpotY = 0);
-
- wxCursor(int cursor_type);
- virtual ~wxCursor();
-
- bool CreateFromXpm(const char **bits) ;
- virtual bool Ok() const { return IsOk(); }
- virtual bool IsOk() const { return (m_refData != NULL && ( M_CURSORDATA->m_hCursor != NULL || M_CURSORDATA->m_themeCursor != -1 ) ) ; }
-
- inline bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
- inline bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
-
- void MacInstall() const ;
-
- void SetHCURSOR(WXHCURSOR cursor);
- inline WXHCURSOR GetHCURSOR() const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
-private :
- void CreateFromImage(const wxImage & image) ;
-};
-
-extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor);
-
-#endif
- // _WX_CURSOR_H_
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: mac/dataform.h
-// Purpose: declaration of the wxDataFormat class
-// Author: Stefan Csomor (lifted from dnd.h)
-// Modified by:
-// Created: 10/21/99
-// RCS-ID: $Id$
-// Copyright: (c) 1999 Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MAC_DATAFORM_H
-#define _WX_MAC_DATAFORM_H
-
-class WXDLLEXPORT wxDataFormat
-{
-public:
- typedef unsigned long NativeFormat;
-
- wxDataFormat();
- wxDataFormat(wxDataFormatId vType);
- wxDataFormat(const wxString& rId);
- wxDataFormat(const wxChar* pId);
- wxDataFormat(NativeFormat vFormat);
-
- wxDataFormat& operator=(NativeFormat vFormat)
- { SetId(vFormat); return *this; }
-
- // comparison (must have both versions)
- bool operator==(NativeFormat format) const
- { return m_format == (NativeFormat)format; }
- bool operator!=(NativeFormat format) const
- { return m_format != (NativeFormat)format; }
- bool operator==(wxDataFormatId format) const
- { return m_type == (wxDataFormatId)format; }
- bool operator!=(wxDataFormatId format) const
- { return m_type != (wxDataFormatId)format; }
-
- // explicit and implicit conversions to NativeFormat which is one of
- // standard data types (implicit conversion is useful for preserving the
- // compatibility with old code)
- NativeFormat GetFormatId() const { return m_format; }
- operator NativeFormat() const { return m_format; }
-
- void SetId(NativeFormat format);
-
- // string ids are used for custom types - this SetId() must be used for
- // application-specific formats
- wxString GetId() const;
- void SetId(const wxChar* pId);
-
- // implementation
- wxDataFormatId GetType() const { return m_type; }
- void SetType( wxDataFormatId type );
-
-private:
- wxDataFormatId m_type;
- NativeFormat m_format;
-};
-
-#endif // _WX_MAC_DATAFORM_H
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: mac/dataobj.h
-// Purpose: declaration of the wxDataObject
-// Author: Stefan Csomor (adapted from Robert Roebling's gtk port)
-// Modified by:
-// Created: 10/21/99
-// RCS-ID: $Id$
-// Copyright: (c) 1998, 1999 Vadim Zeitlin, Robert Roebling
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MAC_DATAOBJ_H_
-#define _WX_MAC_DATAOBJ_H_
-
-// ----------------------------------------------------------------------------
-// wxDataObject is the same as wxDataObjectBase under wxGTK
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxDataObject : public wxDataObjectBase
-{
-public:
- wxDataObject();
-#ifdef __DARWIN__
- virtual ~wxDataObject() { }
-#endif
-
- virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
-};
-
-#endif // _WX_MAC_DATAOBJ_H_
-
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: os2/dataobj2.h
-// Purpose: declaration of standard wxDataObjectSimple-derived classes
-// Author: David Webster (adapted from Robert Roebling's gtk port
-// Modified by:
-// Created: 10/21/99
-// RCS-ID: $Id$
-// Copyright: (c) 1998, 1999 Vadim Zeitlin, Robert Roebling
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_GTK_DATAOBJ2_H_
-#define _WX_GTK_DATAOBJ2_H_
-
-// ----------------------------------------------------------------------------
-// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxBitmapDataObject : public wxBitmapDataObjectBase
-{
-public:
- // ctors
- wxBitmapDataObject();
- wxBitmapDataObject(const wxBitmap& bitmap);
-
- // destr
- virtual ~wxBitmapDataObject();
-
- // override base class virtual to update PNG data too
- virtual void SetBitmap(const wxBitmap& bitmap);
-
- // implement base class pure virtuals
- // ----------------------------------
-
- virtual size_t GetDataSize() const ;
- virtual bool GetDataHere(void *buf) const ;
- virtual bool SetData(size_t len, const void *buf);
-
-protected :
- void Init() ;
- void Clear() ;
-
- void* m_pictHandle ;
- bool m_pictCreated ;
-private:
- // Virtual function hiding supression
- size_t GetDataSize(const wxDataFormat& rFormat) const
- { return(wxDataObjectSimple::GetDataSize(rFormat)); }
- bool GetDataHere(const wxDataFormat& rFormat, void* pBuf) const
- { return(wxDataObjectSimple::GetDataHere(rFormat, pBuf)); }
- bool SetData(const wxDataFormat& rFormat, size_t nLen, const void* pBuf)
- { return(wxDataObjectSimple::SetData(rFormat, nLen, pBuf)); }
-};
-
-// ----------------------------------------------------------------------------
-// wxFileDataObject is a specialization of wxDataObject for file names
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxFileDataObject : public wxFileDataObjectBase
-{
-public:
- // implement base class pure virtuals
- // ----------------------------------
-
- void AddFile( const wxString &filename );
-
- virtual size_t GetDataSize() const;
- virtual bool GetDataHere(void *buf) const;
- virtual bool SetData(size_t len, const void *buf);
-
-private:
- // Virtual function hiding supression
- size_t GetDataSize(const wxDataFormat& rFormat) const
- { return(wxDataObjectSimple::GetDataSize(rFormat)); }
- bool GetDataHere(const wxDataFormat& rFormat, void* pBuf) const
- { return(wxDataObjectSimple::GetDataHere(rFormat, pBuf)); }
- bool SetData(const wxDataFormat& rFormat, size_t nLen, const void* pBuf)
- { return(wxDataObjectSimple::SetData(rFormat, nLen, pBuf)); }
-};
-
-#endif // _WX_GTK_DATAOBJ2_H_
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: dc.h
-// Purpose: wxDC class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_DC_H_
-#define _WX_DC_H_
-
-#include "wx/pen.h"
-#include "wx/brush.h"
-#include "wx/icon.h"
-#include "wx/font.h"
-#include "wx/gdicmn.h"
-
-//-----------------------------------------------------------------------------
-// constants
-//-----------------------------------------------------------------------------
-
-#ifndef MM_TEXT
-#define MM_TEXT 0
-#define MM_ISOTROPIC 1
-#define MM_ANISOTROPIC 2
-#define MM_LOMETRIC 3
-#define MM_HIMETRIC 4
-#define MM_TWIPS 5
-#define MM_POINTS 6
-#define MM_METRIC 7
-#endif
-
-//-----------------------------------------------------------------------------
-// global variables
-//-----------------------------------------------------------------------------
-
-class wxMacPortStateHelper ;
-//-----------------------------------------------------------------------------
-// wxDC
-//-----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxDC: public wxDCBase
-{
- DECLARE_DYNAMIC_CLASS(wxDC)
- DECLARE_NO_COPY_CLASS(wxDC)
-
- public:
-
- wxDC();
- virtual ~wxDC();
-
-
- // implement base class pure virtuals
- // ----------------------------------
-
- virtual void Clear();
-
- virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
- virtual void EndDoc(void) {};
-
- virtual void StartPage(void) {};
- virtual void EndPage(void) {};
-
- virtual void SetFont(const wxFont& font);
- virtual void SetPen(const wxPen& pen);
- virtual void SetBrush(const wxBrush& brush);
- virtual void SetBackground(const wxBrush& brush);
- virtual void SetBackgroundMode(int mode);
- virtual void SetPalette(const wxPalette& palette);
-
- virtual void DestroyClippingRegion();
-
- virtual wxCoord GetCharHeight() const;
- virtual wxCoord GetCharWidth() const;
- virtual void DoGetTextExtent(const wxString& string,
- wxCoord *x, wxCoord *y,
- wxCoord *descent = NULL,
- wxCoord *externalLeading = NULL,
- wxFont *theFont = NULL) const;
- virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
-
- virtual bool CanDrawBitmap() const;
- virtual bool CanGetTextExtent() const;
- virtual int GetDepth() const;
- virtual wxSize GetPPI() const;
-
- virtual void SetMapMode(int mode);
- virtual void SetUserScale(double x, double y);
-
- virtual void SetLogicalScale(double x, double y);
- virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
- virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
- virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
- virtual void SetLogicalFunction(int function);
-
- virtual void SetTextForeground(const wxColour& colour) ;
- virtual void SetTextBackground(const wxColour& colour) ;
-
- virtual void ComputeScaleAndOrigin();
-
- public:
-
- wxCoord XDEV2LOG(wxCoord x) const
- {
- return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX;
- }
- wxCoord XDEV2LOGREL(wxCoord x) const
- {
- return wxRound((double)(x) / m_scaleX);
- }
- wxCoord YDEV2LOG(wxCoord y) const
- {
- return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY;
- }
- wxCoord YDEV2LOGREL(wxCoord y) const
- {
- return wxRound((double)(y) / m_scaleY);
- }
- wxCoord XLOG2DEV(wxCoord x) const
- {
- return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX;
- }
- wxCoord XLOG2DEVREL(wxCoord x) const
- {
- return wxRound((double)(x) * m_scaleX);
- }
- wxCoord YLOG2DEV(wxCoord y) const
- {
- return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY;
- }
- wxCoord YLOG2DEVREL(wxCoord y) const
- {
- return wxRound((double)(y) * m_scaleY);
- }
-
- wxCoord XLOG2DEVMAC(wxCoord x) const
- {
- return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX + m_macLocalOrigin.x;
- }
-
- wxCoord YLOG2DEVMAC(wxCoord y) const
- {
- return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY + m_macLocalOrigin.y;
- }
-
- WXHRGN MacGetCurrentClipRgn() { return m_macCurrentClipRgn ; }
- static void MacSetupBackgroundForCurrentPort(const wxBrush& background ) ;
-//
-
-protected:
- virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
- int style = wxFLOOD_SURFACE);
-
- virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
-
- virtual void DoDrawPoint(wxCoord x, wxCoord y);
- virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
-
- virtual void DoDrawArc(wxCoord x1, wxCoord y1,
- wxCoord x2, wxCoord y2,
- wxCoord xc, wxCoord yc);
-
- virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
- double sa, double ea);
-
- virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
- virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
- wxCoord width, wxCoord height,
- double radius);
- virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
-
- virtual void DoCrossHair(wxCoord x, wxCoord y);
-
- virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
- virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
- bool useMask = false);
-
- virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
- virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
- double angle);
-
- virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
- wxDC *source, wxCoord xsrc, wxCoord ysrc,
- int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
-
- // this is gnarly - we can't even call this function DoSetClippingRegion()
- // because of virtual function hiding
- virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
- virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
- wxCoord width, wxCoord height);
-
- virtual void DoGetSizeMM(int* width, int* height) const;
-
- virtual void DoDrawLines(int n, wxPoint points[],
- wxCoord xoffset, wxCoord yoffset);
- virtual void DoDrawPolygon(int n, wxPoint points[],
- wxCoord xoffset, wxCoord yoffset,
- int fillStyle = wxODDEVEN_RULE);
-
- protected:
- //begin wxmac
- // Variables used for scaling
- double m_mm_to_pix_x,m_mm_to_pix_y;
- // not yet used
- bool m_needComputeScaleX,m_needComputeScaleY;
- // If un-scrolled is non-zero or d.o. changes with scrolling.
- // Set using SetInternalDeviceOrigin().
- long m_internalDeviceOriginX,m_internalDeviceOriginY;
- // To be set by external classes such as wxScrolledWindow
- // using SetDeviceOrigin()
- long m_externalDeviceOriginX,m_externalDeviceOriginY;
-
- // Begin implementation for Mac
- public:
-
- WXHDC m_macPort ;
- WXHBITMAP m_macMask ;
-
- // in order to preserve the const inheritance of the virtual functions, we have to
- // use mutable variables starting from CWPro 5
-
- void MacInstallFont() const ;
- void MacInstallPen() const ;
- void MacInstallBrush() const ;
-
- mutable bool m_macFontInstalled ;
- mutable bool m_macPenInstalled ;
- mutable bool m_macBrushInstalled ;
-
- WXHRGN m_macBoundaryClipRgn ;
- WXHRGN m_macCurrentClipRgn ;
- wxPoint m_macLocalOrigin ;
- void MacSetupPort( wxMacPortStateHelper* ph ) const ;
- void MacCleanupPort( wxMacPortStateHelper* ph ) const ;
- mutable void* m_macATSUIStyle ;
- mutable wxMacPortStateHelper* m_macCurrentPortStateHelper ;
- mutable bool m_macFormerAliasState ;
- mutable short m_macFormerAliasSize ;
- mutable bool m_macAliasWasEnabled ;
- mutable void* m_macForegroundPixMap ;
- mutable void* m_macBackgroundPixMap ;
-};
-
-#endif
- // _WX_DC_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: dcclient.h
-// Purpose: wxClientDC, wxPaintDC and wxWindowDC classes
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_DCCLIENT_H_
-#define _WX_DCCLIENT_H_
-
-#include "wx/dc.h"
-
-//-----------------------------------------------------------------------------
-// classes
-//-----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxPaintDC;
-class WXDLLEXPORT wxWindow;
-
-class WXDLLEXPORT wxWindowDC: public wxDC
-{
- DECLARE_DYNAMIC_CLASS(wxWindowDC)
-
- public:
- wxWindowDC(void);
-
- // Create a DC corresponding to a canvas
- wxWindowDC(wxWindow *win);
-
- virtual ~wxWindowDC(void);
- virtual void DoGetSize( int *width, int *height ) const;
- protected :
- wxWindow *m_window;
-};
-
-
-class WXDLLEXPORT wxClientDC: public wxWindowDC
-{
- DECLARE_DYNAMIC_CLASS(wxClientDC)
-
- public:
- wxClientDC(void);
-
- // Create a DC corresponding to a canvas
- wxClientDC(wxWindow *win);
-
- virtual ~wxClientDC(void);
- virtual void DoGetSize( int *width, int *height ) const;
-};
-
-class WXDLLEXPORT wxPaintDC: public wxWindowDC
-{
- DECLARE_DYNAMIC_CLASS(wxPaintDC)
-
- public:
- wxPaintDC(void);
-
- // Create a DC corresponding to a canvas
- wxPaintDC(wxWindow *win);
-
- virtual ~wxPaintDC(void);
- virtual void DoGetSize( int *width, int *height ) const;
-};
-
-#endif
- // _WX_DCCLIENT_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: dcmemory.h
-// Purpose: wxMemoryDC class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_DCMEMORY_H_
-#define _WX_DCMEMORY_H_
-
-#include "wx/dcclient.h"
-
-class WXDLLEXPORT wxMemoryDC: public wxPaintDC
-{
- DECLARE_DYNAMIC_CLASS(wxMemoryDC)
-
- public:
- wxMemoryDC( const wxBitmap& bitmap = wxNullBitmap );
- wxMemoryDC( wxDC *dc ); // Create compatible DC
- virtual ~wxMemoryDC(void);
- virtual void SelectObject( const wxBitmap& bitmap );
- virtual void DoGetSize( int *width, int *height ) const;
- wxBitmap GetSelectedObject() { return m_selected ; }
- private:
- wxBitmap m_selected;
-};
-
-#endif
- // _WX_DCMEMORY_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/dcprint.h
-// Purpose: wxPrinterDC class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_DCPRINT_H_
-#define _WX_DCPRINT_H_
-
-#include "wx/dc.h"
-#include "wx/cmndata.h"
-
-class wxNativePrinterDC ;
-
-class WXDLLEXPORT wxPrinterDC: public wxDC
-{
- public:
- DECLARE_CLASS(wxPrinterDC)
-
-#if wxUSE_PRINTING_ARCHITECTURE
- // Create a printer DC
- wxPrinterDC(const wxPrintData& printdata );
- virtual ~wxPrinterDC();
-
- virtual bool StartDoc( const wxString& WXUNUSED(message) ) ;
- virtual void EndDoc(void) ;
- virtual void StartPage(void) ;
- virtual void EndPage(void) ;
-
- wxRect GetPaperRect();
-
- wxPrintData& GetPrintData() { return m_printData; }
- virtual void DoGetSize( int *width, int *height ) const;
-
- protected:
- wxPrintData m_printData ;
- wxNativePrinterDC* m_nativePrinterDC ;
-#endif // wxUSE_PRINTING_ARCHITECTURE
-};
-
-#endif
- // _WX_DCPRINT_H_
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: dcscreen.h
-// Purpose: wxScreenDC class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_DCSCREEN_H_
-#define _WX_DCSCREEN_H_
-
-#include "wx/dcclient.h"
-
-class WXDLLEXPORT wxScreenDC: public wxWindowDC
-{
- DECLARE_DYNAMIC_CLASS(wxScreenDC)
-
- public:
- // Create a DC representing the whole screen
- wxScreenDC();
- virtual ~wxScreenDC();
-
- // Compatibility with X's requirements for
- // drawing on top of all windows
- static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return TRUE; }
- static bool StartDrawingOnTop(wxRect* WXUNUSED(rect) = NULL) { return TRUE; }
- static bool EndDrawingOnTop() { return TRUE; }
-};
-
-#endif
- // _WX_DCSCREEN_H_
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: dialog.h
-// Purpose: wxDialog class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_DIALOG_H_
-#define _WX_DIALOG_H_
-
-#include "wx/panel.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxDialogNameStr[];
-
-class WXDLLEXPORT wxMacToolTip;
-
-// Dialog boxes
-class WXDLLEXPORT wxDialog : public wxDialogBase
-{
- DECLARE_DYNAMIC_CLASS(wxDialog)
-
-public:
- wxDialog() { Init(); }
-
- // Constructor with a modal flag, but no window id - the old convention
- wxDialog(wxWindow *parent,
- const wxString& title, bool modal,
- int x = -1, int y= -1, int width = 500, int height = 500,
- long style = wxDEFAULT_DIALOG_STYLE,
- const wxString& name = wxDialogNameStr)
- {
- Init();
- m_isModalStyle = modal;
- Create(parent, -1, title, wxPoint(x, y), wxSize(width, height),
- style, name);
- }
-
- // Constructor with no modal flag - the new convention.
- wxDialog(wxWindow *parent, wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_DIALOG_STYLE,
- const wxString& name = wxDialogNameStr)
- {
- Init();
- Create(parent, id, title, pos, size, style, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_DIALOG_STYLE,
- const wxString& name = wxDialogNameStr);
-
- virtual ~wxDialog();
-
-// virtual bool Destroy();
- virtual bool Show(bool show = true);
-
- void SetModal(bool flag);
- virtual bool IsModal() const;
-
- // For now, same as Show(TRUE) but returns return code
- virtual int ShowModal();
-
- // may be called to terminate the dialog with the given return code
- virtual void EndModal(int retCode);
-
- // returns TRUE if we're in a modal loop
- bool IsModalShowing() const;
-
- // implementation
- // --------------
-
- // event handlers
- void OnCharHook(wxKeyEvent& event);
- void OnCloseWindow(wxCloseEvent& event);
-
- // Standard buttons
- void OnOK(wxCommandEvent& event);
- void OnApply(wxCommandEvent& event);
- void OnCancel(wxCommandEvent& event);
-
- // Responds to colour changes
- void OnSysColourChanged(wxSysColourChangedEvent& event);
-
- // show modal dialog and enter modal loop
- void DoShowModal();
-
-private:
- void Init();
- bool m_isModalStyle;
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_DIALOG_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: dirdlg.h
-// Purpose: wxDirDialog class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_DIRDLG_H_
-#define _WX_DIRDLG_H_
-
-class WXDLLEXPORT wxDirDialog : public wxDirDialogBase
-{
-public:
- wxDirDialog(wxWindow *parent,
- const wxString& message = wxDirSelectorPromptStr,
- const wxString& defaultPath = _T(""),
- long style = wxDD_DEFAULT_STYLE,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- const wxString& name = wxDirDialogNameStr);
-
- virtual int ShowModal();
-
-protected:
- wxWindow * m_parent;
-
- DECLARE_DYNAMIC_CLASS(wxDirDialog)
-};
-
-#endif
- // _WX_DIRDLG_H_
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/dnd.h
-// Purpose: Declaration of the wxDropTarget, wxDropSource class etc.
-// Author: Stefan Csomor
-// RCS-ID: $Id$
-// Copyright: (c) 1998 Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_DND_H_
-#define _WX_DND_H_
-
-#if wxUSE_DRAG_AND_DROP
-
-#include "wx/defs.h"
-#include "wx/object.h"
-#include "wx/string.h"
-#include "wx/string.h"
-#include "wx/dataobj.h"
-#include "wx/cursor.h"
-
-//-------------------------------------------------------------------------
-// classes
-//-------------------------------------------------------------------------
-
-class WXDLLEXPORT wxWindow;
-
-class WXDLLEXPORT wxDropTarget;
-class WXDLLEXPORT wxTextDropTarget;
-class WXDLLEXPORT wxFileDropTarget;
-
-class WXDLLEXPORT wxDropSource;
-
-// ----------------------------------------------------------------------------
-// macros
-// ----------------------------------------------------------------------------
-
-// this macro may be used instead for wxDropSource ctor arguments: it will use
-// the icon 'name' from an XPM file under GTK, but will expand to something
-// else under MSW. If you don't use it, you will have to use #ifdef in the
-// application code.
-#define wxDROP_ICON(X) wxCursor( (const char**) X##_xpm )
-
-//-------------------------------------------------------------------------
-// wxDropTarget
-//-------------------------------------------------------------------------
-
-class WXDLLEXPORT wxDropTarget: public wxDropTargetBase
-{
- public:
-
- wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL );
-
- virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
- virtual bool OnDrop(wxCoord x, wxCoord y);
- virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
- virtual bool GetData();
-
- bool CurrentDragHasSupportedFormat() ;
- void SetCurrentDrag( void* drag ) { m_currentDrag = drag ; }
- void* GetCurrentDrag() { return m_currentDrag ; }
- protected :
- void* m_currentDrag ;
-};
-
-//-------------------------------------------------------------------------
-// wxDropSource
-//-------------------------------------------------------------------------
-
-class WXDLLEXPORT wxDropSource: public wxDropSourceBase
-{
-public:
- // ctors: if you use default ctor you must call SetData() later!
- //
- // NB: the "wxWindow *win" parameter is unused and is here only for wxGTK
- // compatibility, as well as both icon parameters
- wxDropSource( wxWindow *win = (wxWindow *)NULL,
- const wxCursor &cursorCopy = wxNullCursor,
- const wxCursor &cursorMove = wxNullCursor,
- const wxCursor &cursorStop = wxNullCursor);
-
- /* constructor for setting one data object */
- wxDropSource( wxDataObject& data,
- wxWindow *win,
- const wxCursor &cursorCopy = wxNullCursor,
- const wxCursor &cursorMove = wxNullCursor,
- const wxCursor &cursorStop = wxNullCursor);
-
- virtual ~wxDropSource();
-
- // do it (call this in response to a mouse button press, for example)
- // params: if bAllowMove is false, data can be only copied
- virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
-
- wxWindow* GetWindow() { return m_window ; }
- void SetCurrentDrag( void* drag ) { m_currentDrag = drag ; }
- void* GetCurrentDrag() { return m_currentDrag ; }
- bool MacInstallDefaultCursor(wxDragResult effect) ;
-protected :
-
- wxWindow *m_window;
- void* m_currentDrag ;
-};
-
-#endif // wxUSE_DRAG_AND_DROP
-
-#endif
- //_WX_DND_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: filedlg.h
-// Purpose: wxFileDialog class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_FILEDLG_H_
-#define _WX_FILEDLG_H_
-
-//-------------------------------------------------------------------------
-// wxFileDialog
-//-------------------------------------------------------------------------
-
-class WXDLLEXPORT wxFileDialog: public wxFileDialogBase
-{
-DECLARE_DYNAMIC_CLASS(wxFileDialog)
-protected:
- wxArrayString m_fileNames;
- wxArrayString m_paths;
-
-public:
- wxFileDialog(wxWindow *parent,
- const wxString& message = wxFileSelectorPromptStr,
- const wxString& defaultDir = wxEmptyString,
- const wxString& defaultFile = wxEmptyString,
- const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
- long style = 0,
- const wxPoint& pos = wxDefaultPosition);
-
- virtual void GetPaths(wxArrayString& paths) const { paths = m_paths; }
- virtual void GetFilenames(wxArrayString& files) const { files = m_fileNames ; }
-
- virtual int ShowModal();
-
- // not supported for file dialog, RR
- virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
- int WXUNUSED(width), int WXUNUSED(height),
- int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
-};
-
-#endif // _WX_FILEDLG_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: font.h
-// Purpose: wxFont class
-// Author: Julian Smart
-// Modified by:
-// Created: 01/02/97
-// RCS-ID: $Id$
-// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_FONT_H_
-#define _WX_FONT_H_
-
-// ----------------------------------------------------------------------------
-// wxFont
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxFont : public wxFontBase
-{
-public:
- // ctors and such
- wxFont() { }
-
- wxFont(int size,
- int family,
- int style,
- int weight,
- bool underlined = FALSE,
- const wxString& face = wxEmptyString,
- wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
- {
- (void)Create(size, family, style, weight, underlined, face, encoding);
- }
-
- wxFont(const wxNativeFontInfo& info)
- {
- (void)Create(info);
- }
-
- wxFont(const wxString& fontDesc);
-
- bool Create(int size,
- int family,
- int style,
- int weight,
- bool underlined = FALSE,
- const wxString& face = wxEmptyString,
- wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
-
- bool Create(const wxNativeFontInfo& info);
-
- virtual ~wxFont();
-
- // implement base class pure virtuals
- virtual int GetPointSize() const;
- virtual int GetFamily() const;
- virtual int GetStyle() const;
- virtual int GetWeight() const;
- virtual bool GetUnderlined() const;
- virtual wxString GetFaceName() const;
- virtual wxFontEncoding GetEncoding() const;
- virtual const wxNativeFontInfo *GetNativeFontInfo() const;
-
- virtual void SetPointSize(int pointSize);
- virtual void SetFamily(int family);
- virtual void SetStyle(int style);
- virtual void SetWeight(int weight);
- virtual bool SetFaceName(const wxString& faceName);
- virtual void SetUnderlined(bool underlined);
- virtual void SetEncoding(wxFontEncoding encoding);
-
- // implementation only from now on
- // -------------------------------
-
- virtual bool RealizeResource();
-
- // Unofficial API, don't use
- virtual void SetNoAntiAliasing( bool noAA = TRUE ) ;
- virtual bool GetNoAntiAliasing() const ;
-
- // Mac-specific, risks to change, don't use in portable code
- short GetMacFontNum() const;
- short GetMacFontSize() const;
- wxByte GetMacFontStyle() const;
- wxUint32 GetMacATSUFontID() const;
-
-protected:
- void Unshare();
-
-private:
- DECLARE_DYNAMIC_CLASS(wxFont)
-};
-
-#endif
- // _WX_FONT_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: fontdlg.h
-// Purpose: wxFontDialog class. Use generic version if no
-// platform-specific implementation.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_FONTDLG_H_
-#define _WX_FONTDLG_H_
-
-#include "wx/dialog.h"
-#include "wx/cmndata.h"
-
-/*
- * Font dialog
- */
-
-class WXDLLEXPORT wxFontDialog: public wxDialog
-{
-DECLARE_DYNAMIC_CLASS(wxFontDialog)
-public:
- wxFontDialog();
- wxFontDialog(wxWindow *parent, const wxFontData& data);
-
- bool Create(wxWindow *parent, const wxFontData& data);
-
- int ShowModal();
- wxFontData& GetFontData() { return m_fontData; }
-
-protected:
- wxWindow* m_dialogParent;
- wxFontData m_fontData;
-};
-
-#endif
- // _WX_FONTDLG_H_
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: frame.h
-// Purpose: wxFrame class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_FRAME_H_
-#define _WX_FRAME_H_
-
-#include "wx/window.h"
-#include "wx/toolbar.h"
-#include "wx/accel.h"
-#include "wx/icon.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxFrameNameStr[];
-WXDLLEXPORT_DATA(extern const wxChar) wxToolBarNameStr[];
-
-class WXDLLEXPORT wxMenuBar;
-class WXDLLEXPORT wxStatusBar;
-class WXDLLEXPORT wxMacToolTip ;
-
-class WXDLLEXPORT wxFrame: public wxFrameBase
-{
-public:
- // construction
- wxFrame() { Init(); }
- wxFrame(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = wxFrameNameStr)
- {
- Init();
-
- Create(parent, id, title, pos, size, style, name);
- }
-
- bool Create(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = wxFrameNameStr);
-
- virtual ~wxFrame();
-
- // implementation only from now on
- // -------------------------------
-
- // override some more virtuals
- virtual bool Enable(bool enable = TRUE) ;
-
- // get the origin of the client area (which may be different from (0, 0)
- // if the frame has a toolbar) in client coordinates
- virtual wxPoint GetClientAreaOrigin() const;
-
- // event handlers
- void OnActivate(wxActivateEvent& event);
- void OnSysColourChanged(wxSysColourChangedEvent& event);
-
- // Toolbar
-#if wxUSE_TOOLBAR
- virtual wxToolBar* CreateToolBar(long style = -1,
- wxWindowID id = -1,
- const wxString& name = wxToolBarNameStr);
-
- virtual void PositionToolBar();
-#endif // wxUSE_TOOLBAR
-
- // Status bar
-#if wxUSE_STATUSBAR
- virtual wxStatusBar* OnCreateStatusBar(int number = 1,
- long style = wxST_SIZEGRIP,
- wxWindowID id = 0,
- const wxString& name = wxStatusLineNameStr);
-
- virtual void PositionStatusBar();
-#endif // wxUSE_STATUSBAR
-
- // tooltip management
-#if wxUSE_TOOLTIPS
- wxMacToolTip* GetToolTipCtrl() const { return m_hwndToolTip; }
- void SetToolTipCtrl(wxMacToolTip *tt) { m_hwndToolTip = tt; }
- wxMacToolTip* m_hwndToolTip ;
-#endif // tooltips
-
- // called by wxWindow whenever it gets focus
- void SetLastFocus(wxWindow *win) { m_winLastFocused = win; }
- wxWindow *GetLastFocus() const { return m_winLastFocused; }
-
-protected:
- // common part of all ctors
- void Init();
-
- // override base class virtuals
- virtual void DoGetClientSize(int *width, int *height) const;
- virtual void DoSetClientSize(int width, int height);
-
- virtual void DetachMenuBar();
- virtual void AttachMenuBar(wxMenuBar *menubar);
-
-protected:
- // the last focused child: we restore focus to it on activation
- wxWindow *m_winLastFocused;
-
-private:
- DECLARE_EVENT_TABLE()
- DECLARE_DYNAMIC_CLASS(wxFrame)
-};
-
-#endif
- // _WX_FRAME_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: gauge.h
-// Purpose: wxGauge class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_GAUGE_H_
-#define _WX_GAUGE_H_
-
-#include "wx/control.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxGaugeNameStr[];
-
-// Group box
-class WXDLLEXPORT wxGauge: public wxGaugeBase
-{
- DECLARE_DYNAMIC_CLASS(wxGauge)
- public:
- inline wxGauge() { m_rangeMax = 0; m_gaugePos = 0; }
-
- inline wxGauge(wxWindow *parent, wxWindowID id,
- int range,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxGA_HORIZONTAL,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxGaugeNameStr)
- {
- Create(parent, id, range, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- int range,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxGA_HORIZONTAL,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxGaugeNameStr);
-
- void SetShadowWidth(int w);
- void SetBezelFace(int w);
- void SetRange(int r);
- void SetValue(int pos);
-
- int GetShadowWidth() const ;
- int GetBezelFace() const ;
- int GetRange() const ;
- int GetValue() const ;
-
- void Pulse();
-
- virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ;
-
- protected:
- int m_rangeMax;
- int m_gaugePos;
-};
-
-#endif
- // _WX_GAUGE_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/glcanvas.h
-// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_GLCANVAS_H_
-#define _WX_GLCANVAS_H_
-
-#include "wx/defs.h"
-
-#if wxUSE_GLCANVAS
-
-#include "wx/palette.h"
-#include "wx/scrolwin.h"
-#include "wx/app.h"
-
-#ifdef __DARWIN__
-# include <OpenGL/gl.h>
-# include <AGL/agl.h>
-#else
-# include <gl.h>
-# include <agl.h>
-#endif
-
-class WXDLLEXPORT wxGLCanvas; /* forward reference */
-
-class WXDLLEXPORT wxGLContext: public wxObject
-{
-public:
- wxGLContext(AGLPixelFormat fmt, wxGLCanvas *win,
- const wxPalette& WXUNUSED(palette),
- const wxGLContext *other /* for sharing display lists */
- );
- virtual ~wxGLContext();
-
- void SetCurrent();
- void Update(); // must be called after window drag/grows/zoom or clut change
- void SetColour(const wxChar *colour);
- void SwapBuffers();
-
-
- inline wxWindow* GetWindow() const { return m_window; }
- inline AGLDrawable GetDrawable() const { return m_drawable; }
-
-public:
- AGLContext m_glContext;
- AGLDrawable m_drawable;
- wxWindow* m_window;
-};
-
-class WXDLLEXPORT wxGLCanvas: public wxWindow
-{
- DECLARE_CLASS(wxGLCanvas)
- public:
- wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxString& name = wxT("GLCanvas") , int *attribList = 0, const wxPalette& palette = wxNullPalette);
- wxGLCanvas( wxWindow *parent, const wxGLContext *shared,
- wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas"),
- int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette );
-
- wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id = wxID_ANY,
- const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
- const wxString& name = wxT("GLCanvas"), int *attribList = 0, const wxPalette& palette = wxNullPalette );
-
- virtual ~wxGLCanvas();
-
- bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id,
- const wxPoint& pos, const wxSize& size, long style, const wxString& name,
- int *attribList, const wxPalette& palette);
-
- void SetCurrent();
- void SetColour(const wxChar *colour);
- void SwapBuffers();
- void UpdateContext();
- void SetViewport();
- virtual bool Show(bool show = true) ;
-
- // Unlike some other platforms, this must get called if you override it.
- // It sets the viewport correctly and update the context.
- // You shouldn't call glViewport yourself either (use SetViewport if you must reset it.)
- void OnSize(wxSizeEvent& event);
-
- virtual void MacSuperChangedPosition() ;
- virtual void MacTopLevelWindowChangedPosition() ;
- virtual void MacSuperShown( bool show ) ;
-
- void MacUpdateView() ;
-
- inline wxGLContext* GetContext() const { return m_glContext; }
-
-protected:
- wxGLContext* m_glContext;
- bool m_macCanvasIsShown ;
-DECLARE_EVENT_TABLE()
-};
-
-#endif // wxUSE_GLCANVAS
-#endif // _WX_GLCANVAS_H_
+++ /dev/null
-/* -------------------------------------------------------------------------
- * Project: GSocket (Generic Socket) for WX
- * Name: gsockunx.h
- * Copyright: (c) Guilhem Lavaux
- * Licence: wxWindows Licence
- * Purpose: GSocket Macintosh header
- * CVSID: $Id$
- * -------------------------------------------------------------------------
- */
-
-#ifndef __GSOCK_UNX_H
-#define __GSOCK_UNX_H
-
-#ifndef __GSOCKET_STANDALONE__
-#include "wx/setup.h"
-#endif
-
-#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
-
-#ifndef __GSOCKET_STANDALONE__
-#include "wx/gsocket.h"
-#else
-#include "gsocket.h"
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-typedef GSocket* GSocketPtr ;
-
-/* Definition of GSocket */
-struct _GSocket
-{
- wxMacNotifierTableRef m_mac_events ;
- EndpointRef m_endpoint;
- GAddress *m_local;
- GAddress *m_peer;
- GSocketError m_error;
-
- int m_non_blocking;
- int m_server;
- int m_stream;
- int m_oriented;
- unsigned long m_timeout;
-
- /* Callbacks */
- GSocketEventFlags m_detected;
- GSocketCallback m_cbacks[GSOCK_MAX_EVENT];
- char *m_data[GSOCK_MAX_EVENT];
- int m_takesEvents ;
-};
-
-/* Definition of GAddress */
-
-struct _GAddress
-{
- UInt32 m_host ;
- UInt16 m_port ;
- GAddressType m_family;
- GSocketError m_error;
-};
-
-/* Input / Output */
-
-GSocketError _GSocket_Input_Timeout(GSocket *socket);
-GSocketError _GSocket_Output_Timeout(GSocket *socket);
-int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size);
-int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size);
-int _GSocket_Send_Stream(GSocket *socket, const char *buffer, int size);
-int _GSocket_Send_Dgram(GSocket *socket, const char *buffer, int size);
-
-/* Callbacks */
-
-void _GSocket_Enable_Events(GSocket *socket);
-void _GSocket_Disable_Events(GSocket *socket);
-void _GSocket_Internal_Proc(unsigned long e , void* data ) ;
-
-/* GAddress */
-
-GSocketError _GAddress_translate_from(GAddress *address,
- InetAddress *addr );
-GSocketError _GAddress_translate_to(GAddress *address,
- InetAddress *addr);
-
-GSocketError _GAddress_Init_INET(GAddress *address);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
-
-#endif /* __GSOCK_UNX_H */
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: helpxxxx.h
-// Purpose: Help system: native implementation for your system. Replace
-// XXXX with suitable name.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_HELPXXXX_H_
-#define _WX_HELPXXXX_H_
-
-#include "wx/wx.h"
-
-#include "wx/helpbase.h"
-
-class WXDLLEXPORT wxXXXXHelpController: public wxHelpControllerBase
-{
- DECLARE_CLASS(wxXXXXHelpController)
-
- public:
- wxXXXXHelpController();
- virtual ~wxXXXXHelpController();
-
- // Must call this to set the filename and server name
- virtual bool Initialize(const wxString& file);
-
- // If file is "", reloads file given in Initialize
- virtual bool LoadFile(const wxString& file = "");
- virtual bool DisplayContents();
- virtual bool DisplaySection(int sectionNo);
- virtual bool DisplayBlock(long blockNo);
- virtual bool KeywordSearch(const wxString& k,
- wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
-
- virtual bool Quit();
- virtual void OnQuit();
-
- inline wxString GetHelpFile() const { return m_helpFile; }
-
-protected:
- wxString m_helpFile;
-};
-
-#endif
- // _WX_HELPXXXX_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: icon.h
-// Purpose: wxIcon class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_ICON_H_
-#define _WX_ICON_H_
-
-#include "wx/bitmap.h"
-
-// Icon
-class WXDLLEXPORT wxIcon: public wxBitmap
-{
-public:
- wxIcon();
-
- wxIcon(const char **data);
- wxIcon(char **data);
- wxIcon(const char bits[], int width , int height );
- wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
- int desiredWidth = -1, int desiredHeight = -1);
- wxIcon(const wxIconLocation& loc)
- {
- LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
- }
- virtual ~wxIcon();
-
- bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
- int desiredWidth /* = -1 */ , int desiredHeight = -1);
- bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE )
- { return LoadFile( name , flags , -1 , -1 ) ; }
-
- bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
- bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
-
- // create from bitmap (which should have a mask unless it's monochrome):
- // there shouldn't be any implicit bitmap -> icon conversion (i.e. no
- // ctors, assignment operators...), but it's ok to have such function
- void CopyFromBitmap(const wxBitmap& bmp);
-
- DECLARE_DYNAMIC_CLASS(wxIcon)
-};
-
-/*
-class WXDLLEXPORT wxICONFileHandler: public wxBitmapHandler
-{
- DECLARE_DYNAMIC_CLASS(wxICONFileHandler)
-public:
- inline wxICONFileHandler()
- {
- m_name = "ICO icon file";
- m_extension = "ico";
- m_type = wxBITMAP_TYPE_ICO;
- };
-
- virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth = -1, int desiredHeight = -1);
-};
-*/
-
-class WXDLLEXPORT wxICONResourceHandler: public wxBitmapHandler
-{
- DECLARE_DYNAMIC_CLASS(wxICONResourceHandler)
-public:
- inline wxICONResourceHandler()
- {
- m_name = wxT("ICON resource");
- m_extension = wxEmptyString;
- m_type = wxBITMAP_TYPE_ICON_RESOURCE;
- };
-
- virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth = -1, int desiredHeight = -1);
-
-};
-
-#endif
- // _WX_ICON_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: imaglist.h
-// Purpose: wxImageList class. Note: if your GUI doesn't have
-// an image list equivalent, you can use the generic class
-// in src/generic.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_IMAGLIST_H_
-#define _WX_IMAGLIST_H_
-
-#include "wx/bitmap.h"
-
-/*
- * wxImageList is used for wxListCtrl, wxTreeCtrl. These controls refer to
- * images for their items by an index into an image list.
- * A wxImageList is capable of creating images with optional masks from
- * a variety of sources - a single bitmap plus a colour to indicate the mask,
- * two bitmaps, or an icon.
- *
- */
-
-// Flags for Draw
-#define wxIMAGELIST_DRAW_NORMAL 0x0001
-#define wxIMAGELIST_DRAW_TRANSPARENT 0x0002
-#define wxIMAGELIST_DRAW_SELECTED 0x0004
-#define wxIMAGELIST_DRAW_FOCUSED 0x0008
-
-// Flag values for Set/GetImageList
-enum {
- wxIMAGE_LIST_NORMAL, // Normal icons
- wxIMAGE_LIST_SMALL, // Small icons
- wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation)
-};
-
-// Eventually we'll make this a reference-counted wxGDIObject. For
-// now, the app must take care of ownership issues. That is, the
-// image lists must be explicitly deleted after the control(s) that uses them
-// is (are) deleted, or when the app exits.
-class WXDLLEXPORT wxImageList: public wxObject
-{
- DECLARE_DYNAMIC_CLASS(wxImageList)
- public:
- /*
- * Public interface
- */
-
- wxImageList();
-
- // Creates an image list.
- // Specify the width and height of the images in the list,
- // whether there are masks associated with them (e.g. if creating images
- // from icons), and the initial size of the list.
- inline wxImageList(int width, int height, bool mask = TRUE, int initialCount = 1)
- {
- Create(width, height, mask, initialCount);
- }
- virtual ~wxImageList();
-
-
- // Attributes
- ////////////////////////////////////////////////////////////////////////////
-
- // Returns the number of images in the image list.
- int GetImageCount() const;
-
- bool GetSize(int index, int&width, int &height) const;
-
- // Operations
- ////////////////////////////////////////////////////////////////////////////
-
- // Creates an image list
- // width, height specify the size of the images in the list (all the same).
- // mask specifies whether the images have masks or not.
- // initialNumber is the initial number of images to reserve.
- bool Create(int width, int height, bool mask = TRUE, int initialNumber = 1);
-
- // Adds a bitmap, and optionally a mask bitmap.
- // Note that wxImageList creates *new* bitmaps, so you may delete
- // 'bitmap' and 'mask' after calling Add.
- int Add(const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
-
- // Adds a bitmap, using the specified colour to create the mask bitmap
- // Note that wxImageList creates *new* bitmaps, so you may delete
- // 'bitmap' after calling Add.
- int Add(const wxBitmap& bitmap, const wxColour& maskColour);
-
- // Adds a bitmap and mask from an icon.
- int Add(const wxIcon& icon);
-
- // Replaces a bitmap, optionally passing a mask bitmap.
- // Note that wxImageList creates new bitmaps, so you may delete
- // 'bitmap' and 'mask' after calling Replace.
- bool Replace(int index, const wxBitmap& bitmap, const wxBitmap& mask = wxNullBitmap);
-
-/* Not supported by Win95
- // Replacing a bitmap, using the specified colour to create the mask bitmap
- // Note that wxImageList creates new bitmaps, so you may delete
- // 'bitmap'.
- bool Replace(int index, const wxBitmap& bitmap, const wxColour& maskColour);
-*/
-
- // Replaces a bitmap and mask from an icon.
- // You can delete 'icon' after calling Replace.
- bool Replace(int index, const wxIcon& icon);
-
- // Removes the image at the given index.
- bool Remove(int index);
-
- // Remove all images
- bool RemoveAll();
-
- // Draws the given image on a dc at the specified position.
- // If 'solidBackground' is TRUE, Draw sets the image list background
- // colour to the background colour of the wxDC, to speed up
- // drawing by eliminating masked drawing where possible.
- bool Draw(int index, wxDC& dc, int x, int y,
- int flags = wxIMAGELIST_DRAW_NORMAL, bool solidBackground = FALSE);
-
-/* TODO (optional?)
- wxIcon *MakeIcon(int index);
-*/
-
-/* TODO
- // Implementation
- ////////////////////////////////////////////////////////////////////////////
-
- // Returns the native image list handle
- inline WXHIMAGELIST GetHIMAGELIST() const { return m_hImageList; }
-
-protected:
- WXHIMAGELIST m_hImageList;
-*/
-
-};
-
-#endif
- // _WX_IMAGLIST_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: joystick.h
-// Purpose: wxJoystick class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_JOYSTICK_H_
-#define _WX_JOYSTICK_H_
-
-#include "wx/event.h"
-
-class WXDLLEXPORT wxJoystick: public wxObject
-{
- DECLARE_DYNAMIC_CLASS(wxJoystick)
- public:
- /*
- * Public interface
- */
-
- wxJoystick(int joystick = wxJOYSTICK1) { m_joystick = joystick; };
-
- // Attributes
- ////////////////////////////////////////////////////////////////////////////
-
- wxPoint GetPosition() const;
- int GetZPosition() const;
- int GetButtonState() const;
- int GetPOVPosition() const;
- int GetPOVCTSPosition() const;
- int GetRudderPosition() const;
- int GetUPosition() const;
- int GetVPosition() const;
- int GetMovementThreshold() const;
- void SetMovementThreshold(int threshold) ;
-
- // Capabilities
- ////////////////////////////////////////////////////////////////////////////
-
- bool IsOk() const; // Checks that the joystick is functioning
- static int GetNumberJoysticks() ;
- int GetManufacturerId() const ;
- int GetProductId() const ;
- wxString GetProductName() const ;
- int GetXMin() const;
- int GetYMin() const;
- int GetZMin() const;
- int GetXMax() const;
- int GetYMax() const;
- int GetZMax() const;
- int GetNumberButtons() const;
- int GetNumberAxes() const;
- int GetMaxButtons() const;
- int GetMaxAxes() const;
- int GetPollingMin() const;
- int GetPollingMax() const;
- int GetRudderMin() const;
- int GetRudderMax() const;
- int GetUMin() const;
- int GetUMax() const;
- int GetVMin() const;
- int GetVMax() const;
-
- bool HasRudder() const;
- bool HasZ() const;
- bool HasU() const;
- bool HasV() const;
- bool HasPOV() const;
- bool HasPOV4Dir() const;
- bool HasPOVCTS() const;
-
- // Operations
- ////////////////////////////////////////////////////////////////////////////
-
- // pollingFreq = 0 means that movement events are sent when above the threshold.
- // If pollingFreq > 0, events are received every this many milliseconds.
- bool SetCapture(wxWindow* win, int pollingFreq = 0);
- bool ReleaseCapture();
-
-protected:
- int m_joystick;
-};
-
-#endif
- // _WX_JOYSTICK_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/listbox.h
-// Purpose: wxListBox class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef _WX_LISTBOX_H_
-#define _WX_LISTBOX_H_
-
-// ----------------------------------------------------------------------------
-// simple types
-// ----------------------------------------------------------------------------
-#include "wx/dynarray.h"
-#include "wx/arrstr.h"
-
-#if wxUSE_OWNER_DRAWN
- class WXDLLEXPORT wxOwnerDrawn;
-
- // define the array of list box items
- #include "wx/dynarray.h"
-
- WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
-#endif // wxUSE_OWNER_DRAWN
-
-// forward decl for GetSelections()
-class wxArrayInt;
-
-// List box item
-
-WX_DEFINE_ARRAY( char * , wxListDataArray ) ;
-
-// ----------------------------------------------------------------------------
-// List box control
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxListBox : public wxListBoxBase
-{
-public:
- // ctors and such
- wxListBox();
- wxListBox(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- int n = 0, const wxString choices[] = NULL,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListBoxNameStr)
- {
- Create(parent, id, pos, size, n, choices, style, validator, name);
- }
- wxListBox(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListBoxNameStr)
- {
- Create(parent, id, pos, size, choices, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- int n = 0, const wxString choices[] = NULL,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListBoxNameStr);
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListBoxNameStr);
-
- virtual ~wxListBox();
- virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
-
- // implement base class pure virtuals
- virtual void Clear();
- virtual void Delete(unsigned int n);
-
- virtual unsigned int GetCount() const;
- virtual wxString GetString(unsigned int n) const;
- virtual void SetString(unsigned int n, const wxString& s);
- virtual int FindString(const wxString& s, bool bCase = false) const;
-
- virtual bool IsSelected(int n) const;
- virtual void DoSetSelection(int n, bool select);
- virtual int GetSelection() const;
- virtual int GetSelections(wxArrayInt& aSelections) const;
-
- virtual int DoAppend(const wxString& item);
- virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
- virtual void DoSetItems(const wxArrayString& items, void **clientData);
-
- virtual void DoSetFirstItem(int n);
-
- virtual void DoSetItemClientData(unsigned int n, void* clientData);
- virtual void* DoGetItemClientData(unsigned int n) const;
- virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
- virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
- virtual void DoSetSize(int x, int y,int width, int height,int sizeFlags = wxSIZE_AUTO ) ;
-
- // wxCheckListBox support
-#if wxUSE_OWNER_DRAWN
- // plug-in for derived classes
- virtual wxOwnerDrawn *CreateItem(size_t n);
-
- // allows to get the item and use SetXXX functions to set it's appearance
- wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
-
- // get the index of the given item
- int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
-#endif // wxUSE_OWNER_DRAWN
-
- // Windows callbacks
-
- virtual void SetupColours();
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
- virtual bool MacCanFocus() const { return true ; }
- void OnChar(wxKeyEvent& event);
-
- void* m_macList ;
- wxArrayString m_stringArray ;
- wxListDataArray m_dataArray ;
- wxArrayInt m_selectionPreImage ;
- void MacSetRedraw( bool doDraw ) ;
-protected:
- void MacDestroy() ;
- void MacDelete( int n ) ;
- void MacInsert( int n , const wxString& item) ;
- void MacAppend( const wxString& item) ;
- void MacSet( int n , const wxString& item ) ;
- void MacClear() ;
- void MacSetSelection( int n , bool select ) ;
- int MacGetSelection() const ;
- int MacGetSelections(wxArrayInt& aSelections) const ;
- bool MacIsSelected( int n ) const ;
- void MacScrollTo( int n ) ;
- void OnSize( wxSizeEvent &size ) ;
- void MacDoClick() ;
- void MacDoDoubleClick() ;
-
- // do we have multiple selections?
- bool HasMultipleSelection() const;
-
- // free memory (common part of Clear() and dtor)
- // prevent collision with some BSD definitions of macro Free()
- void FreeData();
-
- unsigned int m_noItems;
- int m_selected;
- wxString m_typeIn ;
- long m_lastTypeIn ;
-
- virtual wxSize DoGetBestSize() const;
-
-#if wxUSE_OWNER_DRAWN
- // control items
- wxListBoxItemsArray m_aItems;
-#endif
-
-private:
- DECLARE_DYNAMIC_CLASS(wxListBox)
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_LISTBOX_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: listctrl.h
-// Purpose: wxListCtrl class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_LISTCTRL_H_
-#define _WX_LISTCTRL_H_
-
-#include "wx/control.h"
-#include "wx/event.h"
-#include "wx/imaglist.h"
-
-/*
- The wxListCtrl can show lists of items in four different modes:
- wxLC_LIST: multicolumn list view, with optional small icons (icons could be
- optional for some platforms). Columns are computed automatically,
- i.e. you don't set columns as in wxLC_REPORT. In other words,
- the list wraps, unlike a wxListBox.
- wxLC_REPORT: single or multicolumn report view (with optional header)
- wxLC_ICON: large icon view, with optional labels
- wxLC_SMALL_ICON: small icon view, with optional labels
-
- You can change the style dynamically, either with SetSingleStyle or
- SetWindowStyleFlag.
-
- Further window styles:
-
- wxLC_ALIGN_TOP icons align to the top (default)
- wxLC_ALIGN_LEFT icons align to the left
- wxLC_AUTOARRANGE icons arrange themselves
- wxLC_USER_TEXT the app provides label text on demand, except for column headers
- wxLC_EDIT_LABELS labels are editable: app will be notified.
- wxLC_NO_HEADER no header in report mode
- wxLC_NO_SORT_HEADER can't click on header
- wxLC_SINGLE_SEL single selection
- wxLC_SORT_ASCENDING sort ascending (must still supply a comparison callback in SortItems)
- wxLC_SORT_DESCENDING sort descending (ditto)
-
- Items are referred to by their index (position in the list starting from zero).
-
- Label text is supplied via insertion/setting functions and is stored by the
- control, unless the wxLC_USER_TEXT style has been specified, in which case
- the app will be notified when text is required (see sample).
-
- Images are dealt with by (optionally) associating 3 image lists with the control.
- Zero-based indexes into these image lists indicate which image is to be used for
- which item. Each image in an image list can contain a mask, and can be made out
- of either a bitmap, two bitmaps or an icon. See ImagList.h for more details.
-
- Notifications are passed via the wxWidgets 2.0 event system.
-
- See the sample wxListCtrl app for API usage.
-
- */
-
-// Mask flags to tell app/GUI what fields of wxListItem are valid
-#define wxLIST_MASK_STATE 0x0001
-#define wxLIST_MASK_TEXT 0x0002
-#define wxLIST_MASK_IMAGE 0x0004
-#define wxLIST_MASK_DATA 0x0008
-#define wxLIST_SET_ITEM 0x0010
-#define wxLIST_MASK_WIDTH 0x0020
-#define wxLIST_MASK_FORMAT 0x0040
-
-// State flags for indicating the state of an item
-#define wxLIST_STATE_DONTCARE 0x0000
-#define wxLIST_STATE_DROPHILITED 0x0001
-#define wxLIST_STATE_FOCUSED 0x0002
-#define wxLIST_STATE_SELECTED 0x0004
-#define wxLIST_STATE_CUT 0x0008
-
-// Hit test flags, used in HitTest
-#define wxLIST_HITTEST_ABOVE 0x0001 // Above the client area.
-#define wxLIST_HITTEST_BELOW 0x0002 // Below the client area.
-#define wxLIST_HITTEST_NOWHERE 0x0004 // In the client area but below the last item.
-#define wxLIST_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item.
-#define wxLIST_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item.
-#define wxLIST_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item.
-#define wxLIST_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state.
-#define wxLIST_HITTEST_TOLEFT 0x0400 // To the left of the client area.
-#define wxLIST_HITTEST_TORIGHT 0x0800 // To the right of the client area.
-
-#define wxLIST_HITTEST_ONITEM (wxLIST_HITTEST_ONITEMICON | wxLIST_HITTEST_ONITEMLABEL wxLIST_HITTEST_ONITEMSTATEICON)
-
-// Flags for GetNextItem
-enum {
- wxLIST_NEXT_ABOVE, // Searches for an item above the specified item
- wxLIST_NEXT_ALL, // Searches for subsequent item by index
- wxLIST_NEXT_BELOW, // Searches for an item below the specified item
- wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item
- wxLIST_NEXT_RIGHT, // Searches for an item to the right of the specified item
-};
-
-// Alignment flags for Arrange
-enum {
- wxLIST_ALIGN_DEFAULT,
- wxLIST_ALIGN_LEFT,
- wxLIST_ALIGN_TOP,
- wxLIST_ALIGN_SNAP_TO_GRID
-};
-
-// Column format
-enum {
- wxLIST_FORMAT_LEFT,
- wxLIST_FORMAT_RIGHT,
- wxLIST_FORMAT_CENTRE,
- wxLIST_FORMAT_CENTER = wxLIST_FORMAT_CENTRE
-};
-
-// Autosize values for SetColumnWidth
-enum {
- wxLIST_AUTOSIZE = -1,
- wxLIST_AUTOSIZE_USEHEADER = -2
-};
-
-// Flag values for GetItemRect
-enum {
- wxLIST_RECT_BOUNDS,
- wxLIST_RECT_ICON,
- wxLIST_RECT_LABEL
-};
-
-// Flag values for FindItem
-enum {
- wxLIST_FIND_UP,
- wxLIST_FIND_DOWN,
- wxLIST_FIND_LEFT,
- wxLIST_FIND_RIGHT
-};
-
-// wxListItem: data representing an item, or report field.
-// It also doubles up to represent entire column information
-// when inserting or setting a column.
-class WXDLLEXPORT wxListItem: public wxObject
-{
- DECLARE_DYNAMIC_CLASS(wxListItem)
-public:
- long m_mask; // Indicates what fields are valid
- long m_itemId; // The zero-based item position
- int m_col; // Zero-based column, if in report mode
- long m_state; // The state of the item
- long m_stateMask; // Which flags of m_state are valid (uses same flags)
- wxString m_text; // The label/header text
- int m_image; // The zero-based index into an image list
- long m_data; // App-defined data
-
- // For columns only
- int m_format; // left, right, centre
- int m_width; // width of column
-
- wxListItem();
-};
-
-// type of compare function for wxListCtrl sort operation
-typedef int (*wxListCtrlCompare)(long item1, long item2, long sortData);
-
-class WXDLLEXPORT wxListCtrl: public wxControl
-{
- DECLARE_DYNAMIC_CLASS(wxListCtrl)
- public:
- /*
- * Public interface
- */
-
- wxListCtrl();
-
- inline wxListCtrl(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxListCtrlNameStr)
- {
- Create(parent, id, pos, size, style, validator, name);
- }
- virtual ~wxListCtrl();
-
- bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListCtrlNameStr);
-
-
- // Attributes
- ////////////////////////////////////////////////////////////////////////////
-
- // Gets information about this column
- bool GetColumn(int col, wxListItem& item) const;
-
- // Sets information about this column
- bool SetColumn(int col, wxListItem& item) ;
-
- // Gets the column width
- int GetColumnWidth(int col) const;
-
- // Sets the column width
- bool SetColumnWidth(int col, int width) ;
-
- // Gets the number of items that can fit vertically in the
- // visible area of the list control (list or report view)
- // or the total number of items in the list control (icon
- // or small icon view)
- int GetCountPerPage() const;
-
- // Gets the edit control for editing labels.
- wxTextCtrl* GetEditControl() const;
-
- // Gets information about the item
- bool GetItem(wxListItem& info) const ;
-
- // Sets information about the item
- bool SetItem(wxListItem& info) ;
-
- // Sets a string field at a particular column
- long SetItem(long index, int col, const wxString& label, int imageId = -1);
-
- // Gets the item state
- int GetItemState(long item, long stateMask) const ;
-
- // Sets the item state
- bool SetItemState(long item, long state, long stateMask) ;
-
- // Sets the item image
- bool SetItemImage(long item, int image, int selImage) ;
- bool SetItemColumnImage(long item, long column, int image);
-
- // Gets the item text
- wxString GetItemText(long item) const ;
-
- // Sets the item text
- void SetItemText(long item, const wxString& str) ;
-
- // Gets the item data
- long GetItemData(long item) const ;
-
- // Sets the item data
- bool SetItemData(long item, long data) ;
-
- // Gets the item rectangle
- bool GetItemRect(long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS) const ;
-
- // Gets the item position
- bool GetItemPosition(long item, wxPoint& pos) const ;
-
- // Sets the item position
- bool SetItemPosition(long item, const wxPoint& pos) ;
-
- // Gets the number of items in the list control
- int GetItemCount() const;
-
- // Gets the number of columns in the list control
- int GetColumnCount() const;
-
- // Retrieves the spacing between icons in pixels.
- // If isSmall is true, gets the spacing for the small icon
- // view, otherwise the large icon view.
- int GetItemSpacing(bool isSmall) const;
-
- // Gets the number of selected items in the list control
- int GetSelectedItemCount() const;
-
- // Gets the text colour of the listview
- wxColour GetTextColour() const;
-
- // Sets the text colour of the listview
- void SetTextColour(const wxColour& col);
-
- // Gets the index of the topmost visible item when in
- // list or report view
- long GetTopItem() const ;
-
- // Add or remove a single window style
- void SetSingleStyle(long style, bool add = true) ;
-
- // Set the whole window style
- void SetWindowStyleFlag(long style) ;
-
- // Searches for an item, starting from 'item'.
- // item can be -1 to find the first item that matches the
- // specified flags.
- // Returns the item or -1 if unsuccessful.
- long GetNextItem(long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE) const ;
-
- // Implementation: converts wxWidgets style to MSW style.
- // Can be a single style flag or a bit list.
- // oldStyle is 'normalised' so that it doesn't contain
- // conflicting styles.
- long ConvertToMSWStyle(long& oldStyle, long style) const;
-
- // Gets one of the three image lists
- wxImageList *GetImageList(int which) const ;
-
- // Sets the image list
- // N.B. There's a quirk in the Win95 list view implementation.
- // If in wxLC_LIST mode, it'll *still* display images by the labels if
- // there's a small-icon image list set for the control - even though you
- // haven't specified wxLIST_MASK_IMAGE when inserting.
- // So you have to set a NULL small-icon image list to be sure that
- // the wxLC_LIST mode works without icons. Of course, you may want icons...
- void SetImageList(wxImageList *imageList, int which) ;
-
- // Operations
- ////////////////////////////////////////////////////////////////////////////
-
- // Arranges the items
- bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
-
- // Deletes an item
- bool DeleteItem(long item);
-
- // Deletes all items
- bool DeleteAllItems() ;
-
- // Deletes a column
- bool DeleteColumn(int col);
-
- // Deletes all columns
- bool DeleteAllColumns();
-
- // Clears items, and columns if there are any.
- void ClearAll();
-
- // Edit the label
- wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl));
-
- // End label editing, optionally cancelling the edit
- bool EndEditLabel(bool cancel);
-
- // Ensures this item is visible
- bool EnsureVisible(long item) ;
-
- // Find an item whose label matches this string, starting from the item after 'start'
- // or the beginning if 'start' is -1.
- long FindItem(long start, const wxString& str, bool partial = false);
-
- // Find an item whose data matches this data, starting from the item after 'start'
- // or the beginning if 'start' is -1.
- long FindItem(long start, long data);
-
- // Find an item nearest this position in the specified direction, starting from
- // the item after 'start' or the beginning if 'start' is -1.
- long FindItem(long start, const wxPoint& pt, int direction);
-
- // Determines which item (if any) is at the specified point,
- // giving details in 'flags' (see wxLIST_HITTEST_... flags above)
- long HitTest(const wxPoint& point, int& flags);
-
- // Inserts an item, returning the index of the new item if successful,
- // -1 otherwise.
- // TOD: Should also have some further convenience functions
- // which don't require setting a wxListItem object
- long InsertItem(wxListItem& info);
-
- // Insert a string item
- long InsertItem(long index, const wxString& label);
-
- // Insert an image item
- long InsertItem(long index, int imageIndex);
-
- // Insert an image/string item
- long InsertItem(long index, const wxString& label, int imageIndex);
-
- // For list view mode (only), inserts a column.
- long InsertColumn(long col, wxListItem& info);
-
- long InsertColumn(long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT,
- int width = -1);
-
- // Scrolls the list control. If in icon, small icon or report view mode,
- // x specifies the number of pixels to scroll. If in list view mode, x
- // specifies the number of columns to scroll.
- // If in icon, small icon or list view mode, y specifies the number of pixels
- // to scroll. If in report view mode, y specifies the number of lines to scroll.
- bool ScrollList(int dx, int dy);
-
- // Sort items.
-
- // fn is a function which takes 3 long arguments: item1, item2, data.
- // item1 is the long data associated with a first item (NOT the index).
- // item2 is the long data associated with a second item (NOT the index).
- // data is the same value as passed to SortItems.
- // The return value is a negative number if the first item should precede the second
- // item, a positive number of the second item should precede the first,
- // or zero if the two items are equivalent.
-
- // data is arbitrary data to be passed to the sort function.
- bool SortItems(wxListCtrlCompare fn, long data);
-
-/* Why should we need this function? Leave for now.
- * We might need it because item data may have changed,
- * but the display needs refreshing (in string callback mode)
- // Updates an item. If the list control has the wxLI_AUTO_ARRANGE style,
- // the items will be rearranged.
- bool Update(long item);
-*/
-
- void Command(wxCommandEvent& event) { ProcessCommand(event); };
-
-protected:
- wxTextCtrl* m_textCtrl; // The control used for editing a label
- wxImageList * m_imageListNormal; // The image list for normal icons
- wxImageList * m_imageListSmall; // The image list for small icons
- wxImageList * m_imageListState; // The image list state icons (not implemented yet)
-
- long m_baseStyle; // Basic Windows style flags, for recreation purposes
- wxStringList m_stringPool; // Pool of 3 strings to satisfy Windows callback
- // requirements
- int m_colCount; // Windows doesn't have GetColumnCount so must
- // keep track of inserted/deleted columns
-
-};
-
-class WXDLLEXPORT wxListEvent: public wxCommandEvent
-{
- DECLARE_DYNAMIC_CLASS(wxListEvent)
-
- public:
- wxListEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
-
- int m_code;
- long m_itemIndex;
- long m_oldItemIndex;
- int m_col;
- bool m_cancelled;
- wxPoint m_pointDrag;
-
- wxListItem m_item;
-};
-
-typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
-
-#define EVT_LIST_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_LIST_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_LIST_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_DELETE_ITEM(id, fn) { wxEVT_COMMAND_LIST_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_DELETE_ALL_ITEMS(id, fn) { wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_GET_INFO(id, fn) { wxEVT_COMMAND_LIST_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_SET_INFO(id, fn) { wxEVT_COMMAND_LIST_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_ITEM_SELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_ITEM_DESELECTED(id, fn) { wxEVT_COMMAND_LIST_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
-
-#endif
- // _WX_LISTCTRL_H_
+++ /dev/null
-/* -------------------------------------------------------------------------
- * Project: Mac Notifier Support
- * Name: macnotfy.h
- * Author: Stefan CSomor
- * Purpose: Mac Notifier include file
- * CVSID: $Id$
- * -------------------------------------------------------------------------
- */
-
-#ifndef MAC_NOTIFYERS
-#define MAC_NOTIFYERS
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-typedef void (*wxMacNotificationProcPtr)(unsigned long event , void* data ) ;
-
-typedef void *wxMacNotifierTableRef ;
-void wxMacCreateNotifierTable() ;
-void wxMacDestroyNotifierTable() ;
-wxMacNotifierTableRef wxMacGetNotifierTable() ;
-void wxMacAddEvent( wxMacNotifierTableRef table , wxMacNotificationProcPtr handler , unsigned long event , void* data , short wakeUp ) ;
-void wxMacWakeUp() ;
-void wxMacProcessNotifierEvents() ;
-void wxMacProcessNotifierAndPendingEvents() ;
-void wxMacRemoveAllNotifiersForData( wxMacNotifierTableRef table , void* data ) ;
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* MAC_NOTIFYERS */
\ No newline at end of file
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: mdi.h
-// Purpose: MDI (Multiple Document Interface) classes.
-// This doesn't have to be implemented just like Windows,
-// it could be a tabbed design as in wxGTK.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MDI_H_
-#define _WX_MDI_H_
-
-#include "wx/frame.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxFrameNameStr[];
-WXDLLEXPORT_DATA(extern const wxChar) wxStatusLineNameStr[];
-
-class WXDLLEXPORT wxMDIClientWindow;
-class WXDLLEXPORT wxMDIChildFrame;
-
-class WXDLLEXPORT wxMDIParentFrame: public wxFrame
-{
- DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
-
-public:
-
- wxMDIParentFrame();
- inline wxMDIParentFrame(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window
- const wxString& name = wxFrameNameStr)
- {
- Create(parent, id, title, pos, size, style, name);
- }
-
- virtual ~wxMDIParentFrame();
-
- bool Create(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
- const wxString& name = wxFrameNameStr);
-
- // Mac OS activate event
- virtual void MacActivate(long timestamp, bool activating);
-
- // wxWidgets activate event
- void OnActivate(wxActivateEvent& event);
- void OnSysColourChanged(wxSysColourChangedEvent& event);
-
- void SetMenuBar(wxMenuBar *menu_bar);
-
- // Get the active MDI child window (Windows only)
- wxMDIChildFrame *GetActiveChild() const ;
-
- // Get the client window
- inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; };
-
- // Create the client window class (don't Create the window,
- // just return a new class)
- virtual wxMDIClientWindow *OnCreateClient() ;
-
- // MDI operations
- virtual void Cascade();
- virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL);
- virtual void ArrangeIcons();
- virtual void ActivateNext();
- virtual void ActivatePrevious();
-
-protected:
-
- // TODO maybe have this member
- wxMDIClientWindow *m_clientWindow;
- wxMDIChildFrame * m_currentChild;
- wxMenu* m_windowMenu;
-
- // TRUE if MDI Frame is intercepting commands, not child
- bool m_parentFrameActive;
-
-private:
- friend class WXDLLEXPORT wxMDIChildFrame;
-DECLARE_EVENT_TABLE()
-};
-
-class WXDLLEXPORT wxMDIChildFrame: public wxFrame
-{
-DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
-public:
-
- wxMDIChildFrame();
- inline wxMDIChildFrame(wxMDIParentFrame *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = wxFrameNameStr)
- {
- Init() ;
- Create(parent, id, title, pos, size, style, name);
- }
-
- virtual ~wxMDIChildFrame();
-
- bool Create(wxMDIParentFrame *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = wxFrameNameStr);
-
- // Mac OS activate event
- virtual void MacActivate(long timestamp, bool activating);
-
- // Set menu bar
- void SetMenuBar(wxMenuBar *menu_bar);
-
- // MDI operations
- virtual void Maximize();
- virtual void Maximize( bool ){ Maximize() ; } // this one is inherited from wxFrame
- virtual void Restore();
- virtual void Activate();
-protected:
-
- // common part of all ctors
- void Init();
-};
-
-/* The client window is a child of the parent MDI frame, and itself
- * contains the child MDI frames.
- * However, you create the MDI children as children of the MDI parent:
- * only in the implementation does the client window become the parent
- * of the children. Phew! So the children are sort of 'adopted'...
- */
-
-class WXDLLEXPORT wxMDIClientWindow: public wxWindow
-{
- DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
- public:
-
- wxMDIClientWindow() ;
- inline wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
- {
- CreateClient(parent, style);
- }
-
- virtual ~wxMDIClientWindow();
-
- // Note: this is virtual, to allow overridden behaviour.
- virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL);
-
- // Gets the size available for subwindows after menu size, toolbar size
- // and status bar size have been subtracted. If you want to manage your own
- // toolbar(s), don't call SetToolBar.
- void DoGetClientSize(int *width, int *height) const;
-
- // Explicitly call default scroll behaviour
- void OnScroll(wxScrollEvent& event);
-
-protected:
-
-DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_MDI_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: menu.h
-// Purpose: wxMenu, wxMenuBar classes
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MENU_H_
-#define _WX_MENU_H_
-
-class WXDLLEXPORT wxFrame;
-
-#include "wx/arrstr.h"
-
-// ----------------------------------------------------------------------------
-// Menu
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxMenu : public wxMenuBase
-{
-public:
- // ctors & dtor
- wxMenu(const wxString& title, long style = 0)
- : wxMenuBase(title, style) { Init(); }
-
- wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
-
- virtual ~wxMenu();
-
- // implement base class virtuals
- virtual wxMenuItem* DoAppend(wxMenuItem *item);
- virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
- virtual wxMenuItem* DoRemove(wxMenuItem *item);
- virtual void Attach(wxMenuBarBase *menubar) ;
-
- virtual void Break();
-
- virtual void SetTitle(const wxString& title);
-
- // MSW-specific
- bool ProcessCommand(wxCommandEvent& event);
-
- // implementation only from now on
- // -------------------------------
-
- int MacGetIndexFromId( int id ) ;
- int MacGetIndexFromItem( wxMenuItem *pItem ) ;
- void MacEnableMenu( bool bDoEnable ) ;
- // MacOS needs to know about submenus somewhere within this menu
- // before it can be displayed , also hide special menu items like preferences
- // that are handled by the OS
- void MacBeforeDisplay( bool isSubMenu ) ;
- // undo all changes from the MacBeforeDisplay call
- void MacAfterDisplay( bool isSubMenu ) ;
-
- // semi-private accessors
- // get the window which contains this menu
- wxWindow *GetWindow() const;
- // get the menu handle
- WXHMENU GetHMenu() const { return m_hMenu; }
-
- short MacGetMenuId() { return m_macMenuId ; }
-
-private:
- // common part of all ctors
- void Init();
-
- // common part of Append/Insert (behaves as Append is pos == (size_t)-1)
- bool DoInsertOrAppend(wxMenuItem *item, size_t pos = (size_t)-1);
-
- // terminate the current radio group, if any
- void EndRadioGroup();
-
- // if TRUE, insert a breal before appending the next item
- bool m_doBreak;
-
- // the position of the first item in the current radio group or -1
- int m_startRadioGroup;
-
- // the menu handle of this menu
- WXHMENU m_hMenu;
-
- short m_macMenuId;
-
- static short s_macNextMenuId ;
-
- DECLARE_DYNAMIC_CLASS(wxMenu)
-};
-
-// ----------------------------------------------------------------------------
-// Menu Bar (a la Windows)
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
-{
-public:
- // ctors & dtor
- // default constructor
- wxMenuBar();
- // unused under MSW
- wxMenuBar(long style);
- // menubar takes ownership of the menus arrays but copies the titles
- wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
- virtual ~wxMenuBar();
-
- // menubar construction
- virtual bool Append( wxMenu *menu, const wxString &title );
- virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
- virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
- virtual wxMenu *Remove(size_t pos);
-
- virtual int FindMenuItem(const wxString& menuString,
- const wxString& itemString) const;
- virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
-
- virtual void EnableTop( size_t pos, bool flag );
- virtual void SetLabelTop( size_t pos, const wxString& label );
- virtual wxString GetLabelTop( size_t pos ) const;
-
- // implementation from now on
- WXHMENU Create();
- int FindMenu(const wxString& title);
- void Detach();
-
- // returns TRUE if we're attached to a frame
- bool IsAttached() const { return m_menuBarFrame != NULL; }
- // get the frame we live in
- wxFrame *GetFrame() const { return m_menuBarFrame; }
- // attach to a frame
- void Attach(wxFrame *frame);
-
- // clear the invoking window for all menus and submenus
- void UnsetInvokingWindow() ;
-
- // set the invoking window for all menus and submenus
- void SetInvokingWindow( wxFrame* frame ) ;
-
- // if the menubar is modified, the display is not updated automatically,
- // call this function to update it (m_menuBarFrame should be !NULL)
- void Refresh(bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL);
-
- void MacInstallMenuBar() ;
- static wxMenuBar* MacGetInstalledMenuBar() { return s_macInstalledMenuBar ; }
- static void MacSetCommonMenuBar(wxMenuBar* menubar) { s_macCommonMenuBar=menubar; }
- static wxMenuBar* MacGetCommonMenuBar() { return s_macCommonMenuBar; }
-
-protected:
- // common part of all ctors
- void Init();
- wxWindow *m_invokingWindow;
-
- wxArrayString m_titles;
-
-private:
- static wxMenuBar* s_macInstalledMenuBar ;
- static wxMenuBar* s_macCommonMenuBar ;
-
- DECLARE_DYNAMIC_CLASS(wxMenuBar)
-};
-
-#endif // _WX_MENU_H_
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/menuitem.h
-// Purpose: wxMenuItem class
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 11.11.97
-// RCS-ID: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _MENUITEM_H
-#define _MENUITEM_H
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#include "wx/defs.h"
-
-// ----------------------------------------------------------------------------
-// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
-// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxMenuItem: public wxMenuItemBase
-{
-public:
- // ctor & dtor
- wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL,
- int id = wxID_SEPARATOR,
- const wxString& name = wxEmptyString,
- const wxString& help = wxEmptyString,
- wxItemKind kind = wxITEM_NORMAL,
- wxMenu *subMenu = (wxMenu *)NULL);
- virtual ~wxMenuItem();
-
- // override base class virtuals
- virtual void SetText(const wxString& strName);
-
- virtual void Enable(bool bDoEnable = true);
- virtual void Check(bool bDoCheck = true);
-
- virtual void SetBitmap(const wxBitmap& bitmap) ;
- virtual const wxBitmap& GetBitmap() const { return m_bitmap; }
-
- // update the os specific representation
- void UpdateItemBitmap() ;
- void UpdateItemText() ;
- void UpdateItemStatus() ;
-
- // mark item as belonging to the given radio group
- void SetAsRadioGroupStart();
- void SetRadioGroupStart(int start);
- void SetRadioGroupEnd(int end);
-
-private:
- void UncheckRadio() ;
-
- // the positions of the first and last items of the radio group this item
- // belongs to or -1: start is the radio group start and is valid for all
- // but first radio group items (m_isRadioGroupStart == FALSE), end is valid
- // only for the first one
- union
- {
- int start;
- int end;
- } m_radioGroup;
-
- // does this item start a radio group?
- bool m_isRadioGroupStart;
-
- wxBitmap m_bitmap; // Bitmap for menuitem, if any
- void* m_menu ; // the appropriate menu , may also be a system menu
-
- DECLARE_DYNAMIC_CLASS(wxMenuItem)
-};
-
-#endif //_MENUITEM_H
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: metafile.h
-// Purpose: wxMetaFile, wxMetaFileDC classes.
-// This probably should be restricted to Windows platforms,
-// but if there is an equivalent on your platform, great.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef _WX_METAFIILE_H_
-#define _WX_METAFIILE_H_
-
-#if wxUSE_METAFILE
-#include "wx/dc.h"
-#include "wx/gdiobj.h"
-
-#if wxUSE_DATAOBJ
-#include "wx/dataobj.h"
-#endif
-
-/*
- * Metafile and metafile device context classes
- *
- */
-
-#define wxMetaFile wxMetafile
-#define wxMetaFileDC wxMetafileDC
-
-class WXDLLEXPORT wxMetafile;
-
-class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
-{
- friend class WXDLLEXPORT wxMetafile;
-public:
- wxMetafileRefData(void);
- virtual ~wxMetafileRefData(void);
-
-public:
- WXHMETAFILE m_metafile;
-};
-
-#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
-
-class WXDLLEXPORT wxMetafile: public wxGDIObject
-{
- DECLARE_DYNAMIC_CLASS(wxMetafile)
-public:
- wxMetafile(const wxString& file = wxEmptyString);
- virtual ~wxMetafile(void);
-
- // After this is called, the metafile cannot be used for anything
- // since it is now owned by the clipboard.
- virtual bool SetClipboard(int width = 0, int height = 0);
-
- virtual bool Play(wxDC *dc);
- inline bool Ok() const { return IsOk(); }
- inline bool IsOk(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
-
- wxSize GetSize() const;
- int GetWidth() const { return GetSize().x; }
- int GetHeight() const { return GetSize().y; }
-
- // Implementation
- inline WXHMETAFILE GetHMETAFILE() const { return M_METAFILEDATA->m_metafile; }
- void SetHMETAFILE(WXHMETAFILE mf) ;
-
- // Operators
- inline bool operator == (const wxMetafile& metafile) const { return m_refData == metafile.m_refData; }
- inline bool operator != (const wxMetafile& metafile) const { return m_refData != metafile.m_refData; }
-
-protected:
-};
-
-class WXDLLEXPORT wxMetafileDC: public wxDC
-{
- DECLARE_DYNAMIC_CLASS(wxMetafileDC)
-
- public:
- // the ctor parameters specify the filename (empty for memory metafiles),
- // the metafile picture size and the optional description/comment
- wxMetafileDC(const wxString& filename = wxEmptyString,
- int width = 0, int height = 0,
- const wxString& description = wxEmptyString);
-
- virtual ~wxMetafileDC(void);
-
- // Should be called at end of drawing
- virtual wxMetafile *Close(void);
- virtual void DoGetSize(int *width, int *height) const ;
-
- // Implementation
- inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
- inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
-
-protected:
- wxMetafile* m_metaFile;
-};
-
-/*
- * Pass filename of existing non-placeable metafile, and bounding box.
- * Adds a placeable metafile header, sets the mapping mode to anisotropic,
- * and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
- *
- */
-
-// No origin or extent
-#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
-bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
-
-// Optional origin and extent
-bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
-
-// ----------------------------------------------------------------------------
-// wxMetafileDataObject is a specialization of wxDataObject for metafile data
-// ----------------------------------------------------------------------------
-
-#if wxUSE_DATAOBJ
-class WXDLLEXPORT wxMetafileDataObject : public wxDataObjectSimple
-{
-public:
- // ctors
- wxMetafileDataObject()
- : wxDataObjectSimple(wxDF_METAFILE) { };
- wxMetafileDataObject(const wxMetafile& metafile)
- : wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
-
- // virtual functions which you may override if you want to provide data on
- // demand only - otherwise, the trivial default versions will be used
- virtual void SetMetafile(const wxMetafile& metafile)
- { m_metafile = metafile; }
- virtual wxMetafile GetMetafile() const
- { return m_metafile; }
-
- // implement base class pure virtuals
- virtual size_t GetDataSize() const;
- virtual bool GetDataHere(void *buf) const;
- virtual bool SetData(size_t len, const void *buf);
-
- virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const
- { return GetDataSize(); }
- virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
- void *buf) const
- { return GetDataHere(buf); }
- virtual bool SetData(const wxDataFormat& WXUNUSED(format),
- size_t len, const void *buf)
- { return SetData(len, buf); }
-protected:
- wxMetafile m_metafile;
-};
-#endif
-
-#endif // wxUSE_METAFILE
-
-
-#endif
- // _WX_METAFIILE_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/mimetype.h
-// Purpose: classes and functions to manage MIME types
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 23.09.98
-// RCS-ID: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows licence (part of wxExtra library)
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _MIMETYPE_IMPL_H
-#define _MIMETYPE_IMPL_H
-
-#include "wx/defs.h"
-#include "wx/mimetype.h"
-
-
-class wxMimeTypesManagerImpl
-{
-public :
- wxMimeTypesManagerImpl() { }
-#ifdef __DARWIN__
- ~wxMimeTypesManagerImpl() { }
-#endif
-
- // load all data into memory - done when it is needed for the first time
- void Initialize(int mailcapStyles = wxMAILCAP_STANDARD,
- const wxString& extraDir = wxEmptyString);
-
- // and delete the data here
- void ClearData();
-
- // implement containing class functions
- wxFileType *GetFileTypeFromExtension(const wxString& ext);
- wxFileType *GetOrAllocateFileTypeFromExtension(const wxString& ext) ;
- wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
-
- size_t EnumAllFileTypes(wxArrayString& mimetypes);
-
- // this are NOPs under MacOS
- bool ReadMailcap(const wxString& WXUNUSED(filename), bool WXUNUSED(fallback) = TRUE) { return TRUE; }
- bool ReadMimeTypes(const wxString& WXUNUSED(filename)) { return TRUE; }
-
- void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
-
- // create a new filetype association
- wxFileType *Associate(const wxFileTypeInfo& ftInfo);
- // remove association
- bool Unassociate(wxFileType *ft);
-
- // create a new filetype with the given name and extension
- wxFileType *CreateFileType(const wxString& filetype, const wxString& ext);
-
-private:
- wxArrayFileTypeInfo m_fallbacks;
-};
-
-class wxFileTypeImpl
-{
-public:
- // initialization functions
- // this is used to construct a list of mimetypes which match;
- // if built with GetFileTypeFromMimetype index 0 has the exact match and
- // index 1 the type / * match
- // if built with GetFileTypeFromExtension, index 0 has the mimetype for
- // the first extension found, index 1 for the second and so on
-
- void Init(wxMimeTypesManagerImpl *manager, size_t index)
- { m_manager = manager; m_index.Add(index); }
-
- // initialize us with our file type name
- void SetFileType(const wxString& strFileType)
- { m_strFileType = strFileType; }
- void SetExt(const wxString& ext)
- { m_ext = ext; }
-
- // implement accessor functions
- bool GetExtensions(wxArrayString& extensions);
- bool GetMimeType(wxString *mimeType) const;
- bool GetMimeTypes(wxArrayString& mimeTypes) const;
- bool GetIcon(wxIconLocation *iconLoc) const;
- bool GetDescription(wxString *desc) const;
- bool GetOpenCommand(wxString *openCmd,
- const wxFileType::MessageParameters&) const
- { return GetCommand(openCmd, "open"); }
- bool GetPrintCommand(wxString *printCmd,
- const wxFileType::MessageParameters&) const
- { return GetCommand(printCmd, "print"); }
-
- size_t GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
- const wxFileType::MessageParameters& params) const;
-
- // remove the record for this file type
- // probably a mistake to come here, use wxMimeTypesManager.Unassociate (ft) instead
- bool Unassociate(wxFileType *ft)
- {
- return m_manager->Unassociate(ft);
- }
-
- // set an arbitrary command, ask confirmation if it already exists and
- // overwriteprompt is TRUE
- bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
- bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
-
- private:
- // helper function
- bool GetCommand(wxString *command, const char *verb) const;
-
- wxMimeTypesManagerImpl *m_manager;
- wxArrayInt m_index; // in the wxMimeTypesManagerImpl arrays
- wxString m_strFileType, m_ext;
-};
-
-#endif
- //_MIMETYPE_H
-
-/* vi: set cin tw=80 ts=4 sw=4: */
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: minifram.h
-// Purpose: wxMiniFrame class. A small frame for e.g. floating toolbars.
-// If there is no equivalent on your platform, just make it a
-// normal frame.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MINIFRAM_H_
-#define _WX_MINIFRAM_H_
-
-#include "wx/frame.h"
-
-class WXDLLEXPORT wxMiniFrame: public wxFrame {
-
- DECLARE_DYNAMIC_CLASS(wxMiniFrame)
-
-public:
- inline wxMiniFrame() {}
- inline wxMiniFrame(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE|wxTINY_CAPTION_HORIZ,
- const wxString& name = wxFrameNameStr)
- {
- // Use wxFrame constructor in absence of more specific code.
- Create(parent, id, title, pos, size, style | wxFRAME_TOOL_WINDOW | wxFRAME_FLOAT_ON_PARENT , name);
- }
-
- virtual ~wxMiniFrame() {}
-protected:
-};
-
-#endif
- // _WX_MINIFRAM_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/msgdlg.h
-// Purpose: wxMessageDialog class. Use generic version if no
-// platform-specific implementation.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MSGBOXDLG_H_
-#define _WX_MSGBOXDLG_H_
-
-#include "wx/defs.h"
-#include "wx/dialog.h"
-
-/*
- * Message box dialog
- */
-
-WXDLLEXPORT_DATA(extern const wxChar) wxMessageBoxCaptionStr[];
-
-class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
-{
- DECLARE_DYNAMIC_CLASS(wxMessageDialog)
-
-protected:
- wxString m_caption;
- wxString m_message;
- wxWindow * m_parent;
-public:
- wxMessageDialog(wxWindow *parent,
- const wxString& message,
- const wxString& caption = wxMessageBoxCaptionStr,
- long style = wxOK|wxCENTRE,
- const wxPoint& pos = wxDefaultPosition);
-
- int ShowModal();
-
- // not supported for message dialog, RR
- virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
- int WXUNUSED(width), int WXUNUSED(height),
- int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {}
-
-};
-
-#endif
- // _WX_MSGBOXDLG_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: notebook.h
-// Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
-// Author: Stefan Csomor
-// Modified by:
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_NOTEBOOK_H_
-#define _WX_NOTEBOOK_H_
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-#include "wx/event.h"
-
-// ----------------------------------------------------------------------------
-// types
-// ----------------------------------------------------------------------------
-
-// fwd declarations
-class WXDLLEXPORT wxImageList;
-class WXDLLEXPORT wxWindow;
-
-// ----------------------------------------------------------------------------
-// wxNotebook
-// ----------------------------------------------------------------------------
-
-class wxNotebook : public wxNotebookBase
-{
-public:
- // ctors
- // -----
- // default for dynamic class
- wxNotebook();
- // the same arguments as for wxControl (@@@ any special styles?)
- wxNotebook(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxNotebookNameStr);
- // Create() function
- bool Create(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxNotebookNameStr);
- // dtor
- virtual ~wxNotebook();
-
- // accessors
- // ---------
- // set the currently selected page, return the index of the previously
- // selected one (or -1 on error)
- // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
- int SetSelection(size_t nPage);
- // get the currently selected page
- int GetSelection() const { return m_nSelection; }
-
- // set/get the title of a page
- bool SetPageText(size_t nPage, const wxString& strText);
- wxString GetPageText(size_t nPage) const;
-
- // sets/returns item's image index in the current image list
- int GetPageImage(size_t nPage) const;
- bool SetPageImage(size_t nPage, int nImage);
-
- // control the appearance of the notebook pages
- // set the size (the same for all pages)
- virtual void SetPageSize(const wxSize& size);
- // set the padding between tabs (in pixels)
- virtual void SetPadding(const wxSize& padding);
- // sets the size of the tabs (assumes all tabs are the same size)
- virtual void SetTabSize(const wxSize& sz);
-
- // calculate size for wxNotebookSizer
- wxSize CalcSizeFromPage(const wxSize& sizePage) const;
- wxRect GetPageRect() const ;
-
- // operations
- // ----------
- // remove all pages
- bool DeleteAllPages();
- // the same as AddPage(), but adds it at the specified position
- bool InsertPage(size_t nPage,
- wxNotebookPage *pPage,
- const wxString& strText,
- bool bSelect = false,
- int imageId = -1);
-
- // callbacks
- // ---------
- void OnSize(wxSizeEvent& event);
- void OnSelChange(wxNotebookEvent& event);
- void OnSetFocus(wxFocusEvent& event);
- void OnNavigationKey(wxNavigationKeyEvent& event);
- void OnMouse(wxMouseEvent &event);
-
- // implementation
- // --------------
-
-#if wxUSE_CONSTRAINTS
- virtual void SetConstraintSizes(bool recurse = true);
- virtual bool DoPhase(int nPhase);
-
-#endif
-
- // base class virtuals
- // -------------------
- virtual void Command(wxCommandEvent& event);
-protected:
- virtual wxSize DoGetBestSize() const ;
- virtual wxNotebookPage *DoRemovePage(size_t page) ;
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
- // common part of all ctors
- void Init();
-
- // helper functions
- void ChangePage(int nOldSel, int nSel); // change pages
- void MacSetupTabs();
-
- // the icon indices
- wxArrayInt m_images;
-
- int m_nSelection; // the current selection (-1 if none)
-
- DECLARE_DYNAMIC_CLASS(wxNotebook)
- DECLARE_EVENT_TABLE()
-};
-
-
-#endif // _WX_NOTEBOOK_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/palette.h
-// Purpose: wxPalette class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_PALETTE_H_
-#define _WX_PALETTE_H_
-
-#include "wx/colour.h"
-#include "wx/gdiobj.h"
-
-class WXDLLEXPORT wxPalette;
-
-class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
-{
- DECLARE_NO_COPY_CLASS(wxPaletteRefData)
-
- friend class WXDLLEXPORT wxPalette;
-public:
- wxPaletteRefData();
- virtual ~wxPaletteRefData();
-protected:
- wxColour* m_palette;
- wxInt32 m_count ;
-};
-
-#define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
-
-class WXDLLEXPORT wxPalette: public wxPaletteBase
-{
- DECLARE_DYNAMIC_CLASS(wxPalette)
-
-public:
- wxPalette();
-
- wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
- virtual ~wxPalette();
- bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
- int GetPixel(unsigned char red, unsigned char green, unsigned char blue) const;
- bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
-
- virtual bool Ok() const { return IsOk(); }
- virtual bool IsOk() const { return (m_refData != NULL) ; }
-
- inline bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
- inline bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
-
-/* TODO: implementation
- inline WXHPALETTE GetHPALETTE() const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); }
- void SetHPALETTE(WXHPALETTE pal);
-*/
-};
-
-#endif
- // _WX_PALETTE_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/pen.h
-// Purpose: wxPen class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_PEN_H_
-#define _WX_PEN_H_
-
-#include "wx/gdiobj.h"
-#include "wx/colour.h"
-#include "wx/bitmap.h"
-
-class WXDLLEXPORT wxPen;
-
-class WXDLLEXPORT wxPenRefData: public wxGDIRefData
-{
- friend class WXDLLEXPORT wxPen;
-public:
- wxPenRefData();
- wxPenRefData(const wxPenRefData& data);
- virtual ~wxPenRefData();
-
- wxPenRefData& operator=(const wxPenRefData& data);
-
-protected:
- int m_width;
- int m_style;
- int m_join ;
- int m_cap ;
- wxBitmap m_stipple ;
- int m_nbDash ;
- wxDash * m_dash ;
- wxColour m_colour;
-/* TODO: implementation
- WXHPEN m_hPen;
-*/
-};
-
-#define M_PENDATA ((wxPenRefData *)m_refData)
-
-// Pen
-class WXDLLEXPORT wxPen: public wxGDIObject
-{
- DECLARE_DYNAMIC_CLASS(wxPen)
-public:
- wxPen();
- wxPen(const wxColour& col, int width = 1, int style = wxSOLID);
- wxPen(const wxBitmap& stipple, int width);
- virtual ~wxPen();
-
- inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; }
- inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; }
-
- virtual bool Ok() const { return IsOk(); }
- virtual bool IsOk() const { return (m_refData != NULL) ; }
-
- // Override in order to recreate the pen
- void SetColour(const wxColour& col) ;
- void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
-
- void SetWidth(int width) ;
- void SetStyle(int style) ;
- void SetStipple(const wxBitmap& stipple) ;
- void SetDashes(int nb_dashes, const wxDash *dash) ;
- void SetJoin(int join) ;
- void SetCap(int cap) ;
-
- inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
- inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
- inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
- inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
- inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
- inline int GetDashes(wxDash **ptr) const {
- *ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
- }
-
- inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
-
-// Implementation
-
- // Useful helper: create the brush resource
- bool RealizeResource();
-
- // When setting properties, we must make sure we're not changing
- // another object
- void Unshare();
-};
-
-#endif
- // _WX_PEN_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: pnghand.h
-// Purpose: PNG bitmap handler
-// Author: Julian Smart
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_PNGHAND_H_
-#define _WX_PNGHAND_H_
-
-class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler
-{
- DECLARE_DYNAMIC_CLASS(wxPNGFileHandler)
-public:
- inline wxPNGFileHandler(void)
- {
- m_name = wxT("PNG bitmap file");
- m_extension = wxT("bmp");
- m_type = wxBITMAP_TYPE_PNG;
- };
-
- virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight);
- virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
-};
-
-#endif
- // _WX_PNGHAND_H_
-
+++ /dev/null
-/*
- * File: pngread.h
- * Purpose: PNG file reader
- * Author: Alejandro Aguilar Sierra/Julian Smart
- * Created: 1995
- * Copyright: (c) 1995, Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
- *
- *
- */
-
-#ifndef _WX_PNGREAD__
-#define _WX_PNGREAD__
-
-#ifndef byte
-typedef unsigned char byte;
-#endif
-
-#define WXIMA_COLORS DIB_PAL_COLORS
-
-typedef byte * ImagePointerType;
-
-typedef struct
-{
- byte red;
- byte green;
- byte blue;
-} rgb_color_struct;
-
-
-#define COLORTYPE_PALETTE 1
-#define COLORTYPE_COLOR 2
-#define COLORTYPE_ALPHA 4
-
-class wxPNGReader
-{
-protected:
- int filetype;
- char filename[255];
- ImagePointerType RawImage; // Image data
-
- int Width, Height; // Dimensions
- int Depth; // (bits x pixel)
- int ColorType; // Bit 1 = Palette used
- // Bit 2 = Color used
- // Bit 3 = Alpha used
-
- long EfeWidth; // Efective Width
-
- void *lpbi;
- int bgindex;
- wxPalette* m_palette;
- bool imageOK;
-friend class wxPNGReaderIter;
-public:
- wxPNGReader(void);
- wxPNGReader (char* ImageFileName); // Read an image file
- virtual ~wxPNGReader ();
-
- void Create(int width, int height, int deep, int colortype=-1);
-
- bool ReadFile( char* ImageFileName=0 );
- bool SaveFile( char* ImageFileName=0 );
- bool SaveXPM(char *filename, char *name = 0);
- int GetWidth( void ) const { return Width; };
- int GetHeight( void ) const { return Height; };
- int GetDepth( void ) const { return Depth; };
- int GetColorType( void ) const { return ColorType; };
-
- int GetIndex(int x, int y);
- bool GetRGB(int x, int y, byte* r, byte* g, byte* b);
-
- bool SetIndex(int x, int y, int index);
- bool SetRGB(int x, int y, byte r, byte g, byte b);
-
- // ColorMap settings
- bool SetPalette(wxPalette* colourmap);
- bool SetPalette(int n, rgb_color_struct *rgb_struct);
- bool SetPalette(int n, byte *r, byte *g=0, byte *b=0);
- wxPalette* GetPalette() const { return m_palette; }
-
- void NullData();
- inline int GetBGIndex(void) { return bgindex; }
-
- inline bool Inside(int x, int y)
- { return (0<=y && y<Height && 0<=x && x<Width); }
-
- virtual wxBitmap *GetBitmap(void);
- virtual bool InstantiateBitmap(wxBitmap *bitmap);
- wxMask *CreateMask(void);
-
- inline bool Ok() const { return IsOk(); }
- inline bool IsOk(void) { return imageOK; }
-};
-
-class wxPNGReaderIter
-{
-protected:
- int Itx, Ity; // Counters
- int Stepx, Stepy;
- ImagePointerType IterImage; // Image pointer
- wxPNGReader *ima;
-public:
-// Constructors
- wxPNGReaderIter ( void );
- wxPNGReaderIter ( wxPNGReader *imax );
- operator wxPNGReader* ();
-
-// Iterators
- bool ItOK ();
- void reset ();
- void upset ();
- void SetRow(byte *buf, int n);
- void GetRow(byte *buf, int n);
- byte GetByte( ) { return IterImage[Itx]; }
- void SetByte(byte b) { IterImage[Itx] = b; }
- ImagePointerType GetRow(void);
- bool NextRow();
- bool PrevRow();
- bool NextByte();
- bool PrevByte();
-
- void SetSteps(int x, int y=0) { Stepx = x; Stepy = y; }
- void GetSteps(int *x, int *y) { *x = Stepx; *y = Stepy; }
- bool NextStep();
- bool PrevStep();
-
-////////////////////////// AD - for interlace ///////////////////////////////
- void SetY(int y);
-/////////////////////////////////////////////////////////////////////////////
-};
-
-
-inline
-wxPNGReaderIter::wxPNGReaderIter(void)
-{
- ima = 0;
- IterImage = 0;
- Itx = Ity = 0;
- Stepx = Stepy = 0;
-}
-
-inline
-wxPNGReaderIter::wxPNGReaderIter(wxPNGReader *imax): ima(imax)
-{
- if (ima)
- IterImage = ima->RawImage;
- Itx = Ity = 0;
- Stepx = Stepy = 0;
-}
-
-inline
-wxPNGReaderIter::operator wxPNGReader* ()
-{
- return ima;
-}
-
-inline
-bool wxPNGReaderIter::ItOK ()
-{
- if (ima)
- return ima->Inside(Itx, Ity);
- else
- return FALSE;
-}
-
-
-inline void wxPNGReaderIter::reset()
-{
- IterImage = ima->RawImage;
- Itx = Ity = 0;
-}
-
-inline void wxPNGReaderIter::upset()
-{
- Itx = 0;
- Ity = ima->Height-1;
- IterImage = ima->RawImage + ima->EfeWidth*(ima->Height-1);
-}
-
-inline bool wxPNGReaderIter::NextRow()
-{
- if (++Ity >= ima->Height) return 0;
- IterImage += ima->EfeWidth;
- return 1;
-}
-
-inline bool wxPNGReaderIter::PrevRow()
-{
- if (--Ity < 0) return 0;
- IterImage -= ima->EfeWidth;
- return 1;
-}
-
-////////////////////////// AD - for interlace ///////////////////////////////
-inline void wxPNGReaderIter::SetY(int y)
-{
- if ((y < 0) || (y > ima->Height)) return;
- Ity = y;
- IterImage = ima->RawImage + ima->EfeWidth*y;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-
-inline void wxPNGReaderIter::SetRow(byte *buf, int n)
-{
-// Here should be bcopy or memcpy
- //_fmemcpy(IterImage, (void far *)buf, n);
- if (n<0)
- n = ima->GetWidth();
-
- for (int i=0; i<n; i++) IterImage[i] = buf[i];
-}
-
-inline void wxPNGReaderIter::GetRow(byte *buf, int n)
-{
- for (int i=0; i<n; i++) buf[i] = IterImage[i];
-}
-
-inline ImagePointerType wxPNGReaderIter::GetRow()
-{
- return IterImage;
-}
-
-inline bool wxPNGReaderIter::NextByte()
-{
- if (++Itx < ima->EfeWidth)
- return 1;
- else
- if (++Ity < ima->Height)
- {
- IterImage += ima->EfeWidth;
- Itx = 0;
- return 1;
- } else
- return 0;
-}
-
-inline bool wxPNGReaderIter::PrevByte()
-{
- if (--Itx >= 0)
- return 1;
- else
- if (--Ity >= 0)
- {
- IterImage -= ima->EfeWidth;
- Itx = 0;
- return 1;
- } else
- return 0;
-}
-
-inline bool wxPNGReaderIter::NextStep()
-{
- Itx += Stepx;
- if (Itx < ima->EfeWidth)
- return 1;
- else {
- Ity += Stepy;
- if (Ity < ima->Height)
- {
- IterImage += ima->EfeWidth;
- Itx = 0;
- return 1;
- } else
- return 0;
- }
-}
-
-inline bool wxPNGReaderIter::PrevStep()
-{
- Itx -= Stepx;
- if (Itx >= 0)
- return 1;
- else {
- Ity -= Stepy;
- if (Ity >= 0 && Ity < ima->Height)
- {
- IterImage -= ima->EfeWidth;
- Itx = 0;
- return 1;
- } else
- return 0;
- }
-}
-
-#endif
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: printdlg.h
-// Purpose: wxPrintDialog, wxPageSetupDialog classes.
-// Use generic, PostScript version if no
-// platform-specific implementation.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_PRINTDLG_H_
-#define _WX_PRINTDLG_H_
-
-#include "wx/dialog.h"
-#include "wx/cmndata.h"
-
-/*
- * wxPrinterDialog
- * The common dialog for printing.
- */
-
-class WXDLLEXPORT wxDC;
-class WXDLLEXPORT wxPrintDialog: public wxDialog
-{
- DECLARE_DYNAMIC_CLASS(wxPrintDialog)
-
- public:
- wxPrintDialog();
- wxPrintDialog(wxWindow *parent, wxPrintDialogData* data = NULL);
- wxPrintDialog(wxWindow *parent, wxPrintData* data );
- virtual ~wxPrintDialog();
-
- bool Create(wxWindow *parent, wxPrintDialogData* data = NULL);
- virtual int ShowModal();
-
- wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; }
- wxPrintData& GetPrintData() { return m_printDialogData.GetPrintData(); }
- virtual wxDC *GetPrintDC();
-
- private:
- wxPrintDialogData m_printDialogData;
- wxDC* m_printerDC;
- bool m_destroyDC;
- wxWindow* m_dialogParent;
-};
-
-class WXDLLEXPORT wxPageSetupDialog: public wxDialog
-{
- DECLARE_DYNAMIC_CLASS(wxPageSetupDialog)
-
- public:
- wxPageSetupDialog();
- wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL);
- virtual ~wxPageSetupDialog();
-
- bool Create(wxWindow *parent, wxPageSetupData *data = NULL);
- virtual int ShowModal();
-
- virtual wxPageSetupData& GetPageSetupDialogData() { return m_pageSetupData; }
- private:
- wxPageSetupData m_pageSetupData;
- wxWindow* m_dialogParent;
-};
-
-
-/*
-* wxMacPageMarginsDialog
-* A Mac dialog for setting the page margins separately from page setup since
-* (native) wxMacPageSetupDialog doesn't let you set margins.
-*/
-
-class WXDLLEXPORT wxMacPageMarginsDialog : public wxDialog
-{
-public:
- wxMacPageMarginsDialog(wxFrame* parent, wxPageSetupData* data);
- bool TransferToWindow();
- bool TransferDataFromWindow();
- virtual wxPageSetupData& GetPageSetupDialogData() { return *m_pageSetupDialogData; }
-
-private:
- wxPageSetupData* m_pageSetupDialogData;
-
- wxPoint m_MinMarginTopLeft;
- wxPoint m_MinMarginBottomRight;
- wxTextCtrl *m_LeftMargin;
- wxTextCtrl *m_TopMargin;
- wxTextCtrl *m_RightMargin;
- wxTextCtrl *m_BottomMargin;
-
- void GetMinMargins();
- bool CheckValue(wxTextCtrl* textCtrl, int *value, int minValue, const wxString& name);
-
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacPageMarginsDialog)
-};
-
-
-#endif // _WX_PRINTDLG_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: printwin.h
-// Purpose: wxWindowsPrinter, wxWindowsPrintPreview classes
-// Author: Julian Smart
-// Modified by:
-// Created: 01/02/97
-// RCS-ID: $Id$
-// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_PRINTWIN_H_
-#define _WX_PRINTWIN_H_
-
-#include "wx/prntbase.h"
-
-/*
- * Represents the printer: manages printing a wxPrintout object
- */
-
-class WXDLLEXPORT wxMacPrinter: public wxPrinterBase
-{
- DECLARE_DYNAMIC_CLASS(wxMacPrinter)
-
- public:
- wxMacPrinter(wxPrintDialogData *data = NULL);
- virtual ~wxMacPrinter();
-
- virtual bool Print(wxWindow *parent,
- wxPrintout *printout,
- bool prompt = TRUE);
- virtual wxDC* PrintDialog(wxWindow *parent);
- virtual bool Setup(wxWindow *parent);
-
-};
-
-/*
- * wxPrintPreview
- * Programmer creates an object of this class to preview a wxPrintout.
- */
-
-class WXDLLEXPORT wxMacPrintPreview: public wxPrintPreviewBase
-{
- DECLARE_CLASS(wxMacPrintPreview)
-
- public:
- wxMacPrintPreview(wxPrintout *printout,
- wxPrintout *printoutForPrinting = NULL,
- wxPrintDialogData *data = NULL);
- wxMacPrintPreview(wxPrintout *printout,
- wxPrintout *printoutForPrinting,
- wxPrintData *data);
- virtual ~wxMacPrintPreview();
-
- virtual bool Print(bool interactive);
- virtual void DetermineScaling();
-};
-
-#endif
- // _WX_PRINTWIN_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/private.h
-// Purpose: Private declarations: as this header is only included by
-// wxWidgets itself, it may contain identifiers which don't start
-// with "wx".
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_PRIVATE_H_
-#define _WX_PRIVATE_H_
-
-#include "wx/defs.h"
-#include "wx/app.h"
-
-#ifdef __DARWIN__
-# include <Carbon/Carbon.h>
-#else
-# include <Quickdraw.h>
-# include <Appearance.h>
-# include <Folders.h>
-# include <Controls.h>
-# include <ControlDefinitions.h>
-# include <LowMem.h>
-# include <Gestalt.h>
-#endif
-
-#if UNIVERSAL_INTERFACES_VERSION < 0x0340
- #error "please update to Apple's lastest universal headers from http://developer.apple.com/sdk/"
-#endif
-
-#if wxUSE_GUI
-
-#include "wx/window.h"
-
-class wxMacPortStateHelper
-{
- DECLARE_NO_COPY_CLASS(wxMacPortStateHelper)
-
-public:
- wxMacPortStateHelper( GrafPtr newport) ;
- wxMacPortStateHelper() ;
- ~wxMacPortStateHelper() ;
-
- void Setup( GrafPtr newport ) ;
- void Clear() ;
- bool IsCleared() { return m_clip == NULL ; }
- GrafPtr GetCurrentPort() { return m_currentPort ; }
-
-private:
- GrafPtr m_currentPort ;
- GrafPtr m_oldPort ;
- RgnHandle m_clip ;
- ThemeDrawingState m_drawingState ;
- short m_textFont ;
- short m_textSize ;
- short m_textStyle ;
- short m_textMode ;
-} ;
-
-class WXDLLEXPORT wxMacPortSetter
-{
- DECLARE_NO_COPY_CLASS(wxMacPortSetter)
-
-public:
- wxMacPortSetter( const wxDC* dc ) ;
- ~wxMacPortSetter() ;
-private:
- wxMacPortStateHelper m_ph ;
- const wxDC* m_dc ;
-} ;
-
-class WXDLLEXPORT wxMacWindowClipper
-{
- DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
-
-public:
- wxMacWindowClipper( const wxWindow* win ) ;
- ~wxMacWindowClipper() ;
-private:
- RgnHandle m_formerClip ;
- RgnHandle m_newClip ;
-} ;
-
-class wxMacDrawingHelper
-{
- DECLARE_NO_COPY_CLASS(wxMacDrawingHelper)
-
-public:
- wxMacDrawingHelper( wxWindowMac * theWindow , bool clientArea = false ) ;
- ~wxMacDrawingHelper() ;
- bool Ok() const { return IsOk(); }
- bool IsOk() { return m_ok ; }
- void LocalToWindow( Rect *rect) { OffsetRect( rect , m_origin.h , m_origin.v ) ; }
- void LocalToWindow( Point *pt ) { AddPt( m_origin , pt ) ; }
- void LocalToWindow( RgnHandle rgn ) { OffsetRgn( rgn , m_origin.h , m_origin.v ) ; }
- const Point& GetOrigin() { return m_origin ; }
-private:
- Point m_origin ;
- GrafPtr m_formerPort ;
- GrafPtr m_currentPort ;
- PenState m_savedPenState ;
- bool m_ok ;
-} ;
-
-// app.h
-bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
-
-#endif // wxUSE_GUI
-
-// filefn.h
-WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
-WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
-WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ;
-# ifndef __DARWIN__
-// Mac file names are POSIX (Unix style) under Darwin, so these are not needed
-WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
-WXDLLEXPORT void wxUnixFilename2FSSpec( const wxChar *path , FSSpec *spec ) ;
-WXDLLEXPORT wxString wxMac2UnixFilename( const wxChar *s) ;
-WXDLLEXPORT wxString wxUnix2MacFilename( const wxChar *s);
-# endif
-
-// utils.h
-WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum,
- OSType folderType,
- Boolean createFolder);
-WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
- OSType folderType,
- Boolean createFolder);
-
-#if wxUSE_GUI
-
-GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
-void wxMacDestroyGWorld( GWorldPtr gw ) ;
-PicHandle wxMacCreatePict( GWorldPtr gw , GWorldPtr mask = NULL ) ;
-CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize ) ;
-void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
-CTabHandle wxMacCreateColorTable( int numColors ) ;
-void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType = 0 ) ;
-
-#define MAC_WXCOLORREF(a) (*((RGBColor*)&(a)))
-#define MAC_WXHBITMAP(a) (GWorldPtr(a))
-#define MAC_WXHMETAFILE(a) (PicHandle(a))
-#define MAC_WXHICON(a) (CIconHandle(a))
-#define MAC_WXHCURSOR(a) (CursHandle(a))
-#define MAC_WXHRGN(a) (RgnHandle(a))
-#define MAC_WXHWND(a) (WindowPtr(a))
-#define MAC_WXRECPTR(a) ((Rect*)a)
-#define MAC_WXPOINTPTR(a) ((Point*)a)
-#define MAC_WXHMENU(a) ((MenuHandle)a)
-
-#endif // wxUSE_GUI
-
-//---------------------------------------------------------------------------
-// wxMac string conversions
-//---------------------------------------------------------------------------
-
-void wxMacSetupConverters() ;
-void wxMacCleanupConverters() ;
-
-void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
-wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
-
-void wxMacConvertNewlines13To10( char * data ) ;
-void wxMacConvertNewlines10To13( char * data ) ;
-void wxMacConvertNewlines13To10( wxString *data ) ;
-void wxMacConvertNewlines10To13( wxString *data ) ;
-
-#if wxUSE_UNICODE
-void wxMacConvertNewlines13To10( wxChar * data ) ;
-void wxMacConvertNewlines10To13( wxChar * data ) ;
-#endif
-
-#if TARGET_CARBON
-
-class wxMacCFStringHolder
-{
-public:
- wxMacCFStringHolder()
- {
- m_cfs = NULL ;
- m_release = false ;
- }
-
- wxMacCFStringHolder(const wxString &str , wxFontEncoding encoding )
- {
- m_cfs = NULL ;
- m_release = false ;
- Assign( str , encoding ) ;
- }
-
- wxMacCFStringHolder(CFStringRef ref , bool release = true )
- {
- m_cfs = ref ;
- m_release = release ;
- }
-
- ~wxMacCFStringHolder()
- {
- Release() ;
- }
-
- CFStringRef Detach()
- {
- CFStringRef retval = m_cfs ;
- m_release = false ;
- m_cfs = NULL ;
- return retval ;
- }
-
- void Release()
- {
- if ( m_release && m_cfs)
- CFRelease( m_cfs ) ;
- m_cfs = NULL ;
- }
-
- void Assign( const wxString &str , wxFontEncoding encoding ) ;
-
- operator CFStringRef () { return m_cfs; }
- wxString AsString( wxFontEncoding encoding = wxFONTENCODING_DEFAULT ) ;
-
-private:
-
- CFStringRef m_cfs;
- bool m_release ;
-} ;
-
-#endif
-
-
-
-wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
-wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
-
-
-#endif
- // _WX_PRIVATE_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/private/print.h
-// Purpose: private implementation for printing on MacOS
-// Author: Stefan Csomor
-// Modified by:
-// Created: 03/02/99
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MAC_PRIVATE_PRINT_H_
-#define _WX_MAC_PRIVATE_PRINT_H_
-
-#include "wx/cmndata.h"
-#include "wx/mac/private.h"
-
-#if TARGET_CARBON && !defined(__DARWIN__)
-# include <PMApplication.h>
-#endif
-
-#ifndef __DARWIN__
-# include "Printing.h"
-#endif
-
-#if TARGET_CARBON
-#if !PM_USE_SESSION_APIS
-#error "only Carbon Printing Session API is supported"
-#endif
-#endif
-
-class wxNativePrintData
-{
-public :
- wxNativePrintData() {}
- virtual ~wxNativePrintData() {}
-
- virtual void TransferFrom( wxPrintData * ) = 0 ;
- virtual void TransferTo( wxPrintData * ) = 0 ;
-
- virtual void TransferFrom( wxPageSetupDialogData * ) = 0 ;
- virtual void TransferTo( wxPageSetupDialogData * ) = 0 ;
-
- virtual void TransferFrom( wxPrintDialogData * ) = 0 ;
- virtual void TransferTo( wxPrintDialogData * ) = 0 ;
-
- virtual void CopyFrom( wxNativePrintData * ) = 0;
-
- virtual int ShowPrintDialog() = 0 ;
- virtual int ShowPageSetupDialog() = 0 ;
-
- static wxNativePrintData* Create() ;
-} ;
-
-#if TARGET_CARBON
-
-class wxMacCarbonPrintData : public wxNativePrintData
-{
-public :
- wxMacCarbonPrintData() ;
- ~wxMacCarbonPrintData() ;
-
- virtual void TransferFrom( wxPrintData * ) ;
- virtual void TransferTo( wxPrintData * ) ;
-
- virtual void TransferFrom( wxPageSetupDialogData * ) ;
- virtual void TransferTo( wxPageSetupDialogData * ) ;
-
- virtual void TransferFrom( wxPrintDialogData * ) ;
- virtual void TransferTo( wxPrintDialogData * ) ;
-
- virtual void CopyFrom( wxNativePrintData * ) ;
- virtual int ShowPrintDialog() ;
- virtual int ShowPageSetupDialog() ;
-private :
- virtual void ValidateOrCreate() ;
-public :
- PMPrintSession m_macPrintSession ;
- PMPageFormat m_macPageFormat ;
- PMPrintSettings m_macPrintSettings ;
-} ;
-
-#else
-
-class wxMacClassicPrintData : public wxNativePrintData
-{
-public :
- wxMacClassicPrintData() ;
- ~wxMacClassicPrintData() ;
- virtual void TransferFrom( wxPrintData * ) ;
- virtual void TransferTo( wxPrintData * ) ;
- virtual void TransferFrom( wxPageSetupDialogData * ) ;
- virtual void TransferTo( wxPageSetupDialogData * ) ;
- virtual void TransferFrom( wxPrintDialogData * ) ;
- virtual void TransferTo( wxPrintDialogData * ) ;
- virtual void CopyFrom( wxNativePrintData * ) ;
- virtual int ShowPrintDialog() ;
- virtual int ShowPageSetupDialog() ;
-private :
- virtual void ValidateOrCreate() ;
-public :
- THPrint m_macPrintSettings ;
-} ;
-
-#endif
-
-#endif
- // _WX_MAC_PRIVATE_PRINT_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/radiobox.h
-// Purpose: wxRadioBox class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_RADIOBOX_H_
-#define _WX_RADIOBOX_H_
-
-// List box item
-class WXDLLEXPORT wxBitmap ;
-
-class WXDLLEXPORT wxRadioButton ;
-
-class WXDLLEXPORT wxRadioBox: public wxControl, public wxRadioBoxBase
-{
- DECLARE_DYNAMIC_CLASS(wxRadioBox)
-public:
-// Constructors & destructor
- wxRadioBox();
- inline wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title,
- const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- int n = 0, const wxString choices[] = NULL,
- int majorDim = 0, long style = wxRA_HORIZONTAL,
- const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr)
- {
- Create(parent, id, title, pos, size, n, choices, majorDim, style, val, name);
- }
- inline wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title,
- const wxPoint& pos, const wxSize& size,
- const wxArrayString& choices,
- int majorDim = 0, long style = wxRA_HORIZONTAL,
- const wxValidator& val = wxDefaultValidator,
- const wxString& name = wxRadioBoxNameStr)
- {
- Create(parent, id, title, pos, size, choices,
- majorDim, style, val, name);
- }
- virtual ~wxRadioBox();
- bool Create(wxWindow *parent, wxWindowID id, const wxString& title,
- const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- int n = 0, const wxString choices[] = NULL,
- int majorDim = 0, long style = wxRA_HORIZONTAL,
- const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr);
- bool Create(wxWindow *parent, wxWindowID id, const wxString& title,
- const wxPoint& pos, const wxSize& size,
- const wxArrayString& choices,
- int majorDim = 0, long style = wxRA_HORIZONTAL,
- const wxValidator& val = wxDefaultValidator,
- const wxString& name = wxRadioBoxNameStr);
-
- // Enabling
- virtual bool Enable(bool enable = true);
- virtual bool Enable(unsigned int item, bool enable = true);
- virtual bool IsItemEnabled(unsigned int WXUNUSED(n)) const
- {
- /* TODO */
- return true;
- }
-
- // Showing
- virtual bool Show(bool show = true);
- virtual bool Show(unsigned int item, bool show = true);
- virtual bool IsItemShown(unsigned int WXUNUSED(n)) const
- {
- /* TODO */
- return true;
- }
-
-// Specific functions (in wxWidgets2 reference)
- virtual void SetSelection(int item);
- virtual int GetSelection() const;
-
- virtual unsigned int GetCount() const { return m_noItems; }
-
- virtual wxString GetString(unsigned int item) const;
- virtual void SetString(unsigned int item, const wxString& label);
-
-
- virtual wxString GetLabel() const;
- virtual void SetLabel(const wxString& label) ;
-
-// Other external functions
- void Command(wxCommandEvent& event);
- void SetFocus();
-
-// Other variable access functions
- inline int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; }
- inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
-
- void OnRadioButton( wxCommandEvent& event ) ;
-
-protected:
- wxRadioButton *m_radioButtonCycle;
-
- unsigned int m_noItems;
- int m_noRowsOrCols;
-
-// Internal functions
- virtual wxSize DoGetBestSize() const ;
- virtual void DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags = wxSIZE_AUTO);
-
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_RADIOBOX_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: radiobut.h
-// Purpose: wxRadioButton class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 01/02/97
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_RADIOBUT_H_
-#define _WX_RADIOBUT_H_
-
-class WXDLLEXPORT wxRadioButton: public wxControl
-{
- DECLARE_DYNAMIC_CLASS(wxRadioButton)
- protected:
-public:
- inline wxRadioButton() {}
- inline wxRadioButton(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxRadioButtonNameStr)
- {
- Create(parent, id, label, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxRadioButtonNameStr);
-
- virtual void SetValue(bool val);
- virtual bool GetValue() const ;
-
- // implementation
-
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown );
- void Command(wxCommandEvent& event);
- wxRadioButton *AddInCycle(wxRadioButton *cycle);
- inline wxRadioButton *NextInCycle() {return m_cycle;}
-
- protected:
-
- wxRadioButton *m_cycle;
-};
-
-// Not implemented
-#if 0
-class WXDLLEXPORT wxBitmap ;
-
-WXDLLEXPORT_DATA(extern const wxChar) wxBitmapRadioButtonNameStr[];
-
-class WXDLLEXPORT wxBitmapRadioButton: public wxRadioButton
-{
- DECLARE_DYNAMIC_CLASS(wxBitmapRadioButton)
- protected:
- wxBitmap *theButtonBitmap;
- public:
- inline wxBitmapRadioButton() { theButtonBitmap = NULL; }
- inline wxBitmapRadioButton(wxWindow *parent, wxWindowID id,
- const wxBitmap *label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxBitmapRadioButtonNameStr)
- {
- Create(parent, id, label, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxBitmap *label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxBitmapRadioButtonNameStr);
-
- virtual void SetLabel(const wxBitmap *label);
- virtual void SetValue(bool val) ;
- virtual bool GetValue() const ;
-};
-#endif
-
-#endif
- // _WX_RADIOBUT_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: region.h
-// Purpose: wxRegion class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_REGION_H_
-#define _WX_REGION_H_
-
-#include "wx/list.h"
-#include "wx/gdiobj.h"
-#include "wx/gdicmn.h"
-
-class WXDLLEXPORT wxRect;
-class WXDLLEXPORT wxPoint;
-
-// So far, for internal use only
-enum wxRegionOp {
-wxRGN_AND, // Creates the intersection of the two combined regions.
-wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
-wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
-wxRGN_OR, // Creates the union of two combined regions.
-wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
-};
-
-class WXDLLEXPORT wxRegion : public wxGDIObject {
-DECLARE_DYNAMIC_CLASS(wxRegion);
- friend class WXDLLEXPORT wxRegionIterator;
-public:
- wxRegion(long x, long y, long w, long h);
- wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
- wxRegion(const wxRect& rect);
- wxRegion( WXHRGN hRegion );
- wxRegion();
- wxRegion( const wxBitmap& bmp)
- {
- Union(bmp);
- }
- wxRegion( const wxBitmap& bmp,
- const wxColour& transColour, int tolerance = 0)
- {
- Union(bmp, transColour, tolerance);
- }
-
- virtual ~wxRegion();
-
- //# Modify region
- // Clear current region
- void Clear();
-
- // Union rectangle or region with this.
- bool Union(long x, long y, long width, long height)
- { return Combine(x, y, width, height, wxRGN_OR); }
- bool Union(const wxRect& rect)
- { return Combine(rect, wxRGN_OR); }
- bool Union(const wxRegion& region)
- { return Combine(region, wxRGN_OR); }
-
- // Intersect rectangle or region with this.
- bool Intersect(long x, long y, long width, long height)
- { return Combine(x, y, width, height, wxRGN_AND); }
- bool Intersect(const wxRect& rect)
- { return Combine(rect, wxRGN_AND); }
- bool Intersect(const wxRegion& region)
- { return Combine(region, wxRGN_AND); }
-
- // Subtract rectangle or region from this:
- // Combines the parts of 'this' that are not part of the second region.
- bool Subtract(long x, long y, long width, long height)
- { return Combine(x, y, width, height, wxRGN_DIFF); }
- bool Subtract(const wxRect& rect)
- { return Combine(rect, wxRGN_DIFF); }
- bool Subtract(const wxRegion& region)
- { return Combine(region, wxRGN_DIFF); }
-
- // XOR: the union of two combined regions except for any overlapping areas.
- bool Xor(long x, long y, long width, long height)
- { return Combine(x, y, width, height, wxRGN_XOR); }
- bool Xor(const wxRect& rect)
- { return Combine(rect, wxRGN_XOR); }
- bool Xor(const wxRegion& region)
- { return Combine(region, wxRGN_XOR); }
-
- //# Information on region
- // Outer bounds of region
- void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
- wxRect GetBox() const ;
-
- // Is region empty?
- bool Empty() const;
- inline bool IsEmpty() const { return Empty(); }
-
- //# Tests
- // Does the region contain the point (x,y)?
- wxRegionContain Contains(long x, long y) const;
- // Does the region contain the point pt?
- wxRegionContain Contains(const wxPoint& pt) const;
- // Does the region contain the rectangle (x, y, w, h)?
- wxRegionContain Contains(long x, long y, long w, long h) const;
- // Does the region contain the rectangle rect?
- wxRegionContain Contains(const wxRect& rect) const;
-
- // Convert the region to a B&W bitmap with the white pixels being inside
- // the region.
- wxBitmap ConvertToBitmap() const;
-
- // Use the non-transparent pixels of a wxBitmap for the region to combine
- // with this region. First version takes transparency from bitmap's mask,
- // second lets the user specify the colour to be treated as transparent
- // along with an optional tolerance value.
- // NOTE: implemented in common/rgncmn.cpp
- bool Union(const wxBitmap& bmp);
- bool Union(const wxBitmap& bmp,
- const wxColour& transColour, int tolerance = 0);
-
- // Internal
- bool Combine(long x, long y, long width, long height, wxRegionOp op);
- bool Combine(const wxRegion& region, wxRegionOp op);
- bool Combine(const wxRect& rect, wxRegionOp op);
- const WXHRGN GetWXHRGN() const ;
-};
-
-class WXDLLEXPORT wxRegionIterator : public wxObject
-{
- DECLARE_DYNAMIC_CLASS(wxRegionIterator)
-
-public:
- wxRegionIterator();
- wxRegionIterator(const wxRegion& region);
- wxRegionIterator(const wxRegionIterator& iterator);
- virtual ~wxRegionIterator();
-
- wxRegionIterator& operator=(const wxRegionIterator& iterator);
-
- void Reset() { m_current = 0; }
- void Reset(const wxRegion& region);
-
- operator bool () const { return m_current < m_numRects; }
- bool HaveRects() const { return m_current < m_numRects; }
-
- wxRegionIterator& operator++();
- wxRegionIterator operator++(int);
-
- long GetX() const;
- long GetY() const;
- long GetW() const;
- long GetWidth() const { return GetW(); }
- long GetH() const;
- long GetHeight() const { return GetH(); }
- wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
-private:
- void SetRects(long numRects, wxRect *rects);
-
- long m_current;
- long m_numRects;
- wxRegion m_region;
- wxRect* m_rects;
-};
-
-#endif
- // _WX_REGION_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: scrollbar.h
-// Purpose: wxScrollBar class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_SCROLBAR_H_
-#define _WX_SCROLBAR_H_
-
-#include "wx/control.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxScrollBarNameStr[];
-
-// Scrollbar item
-class WXDLLEXPORT wxScrollBar: public wxControl
-{
- DECLARE_DYNAMIC_CLASS(wxScrollBar)
-
-public:
- inline wxScrollBar() { m_pageSize = 0; m_viewSize = 0; m_objectSize = 0; }
- virtual ~wxScrollBar();
-
- inline wxScrollBar(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSB_HORIZONTAL,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxScrollBarNameStr)
- {
- Create(parent, id, pos, size, style, validator, name);
- }
- bool Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSB_HORIZONTAL,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxScrollBarNameStr);
-
- int GetThumbPosition() const ;
- inline int GetThumbSize() const { return m_viewSize; }
- inline int GetPageSize() const { return m_pageSize; }
- inline int GetRange() const { return m_objectSize; }
-
- bool IsVertical() const { return (m_windowStyle & wxVERTICAL) != 0; }
-
- virtual void SetThumbPosition(int viewStart);
- virtual void SetScrollbar(int position, int thumbSize, int range, int pageSize,
- bool refresh = TRUE);
-
- void Command(wxCommandEvent& event);
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
-
-protected:
- int m_pageSize;
- int m_viewSize;
- int m_objectSize;
-
-DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_SCROLBAR_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: slider.h
-// Purpose: wxSlider class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_SLIDER_H_
-#define _WX_SLIDER_H_
-
-#include "wx/control.h"
-#include "wx/slider.h"
-#include "wx/stattext.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxSliderNameStr[];
-
-// Slider
-class WXDLLEXPORT wxSlider: public wxControl
-{
- DECLARE_DYNAMIC_CLASS(wxSlider)
-
-public:
- wxSlider();
-
- inline wxSlider(wxWindow *parent, wxWindowID id,
- int value, int minValue, int maxValue,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSL_HORIZONTAL,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxSliderNameStr)
- {
- Create(parent, id, value, minValue, maxValue, pos, size, style, validator, name);
- }
-
- virtual ~wxSlider();
-
- bool Create(wxWindow *parent, wxWindowID id,
- int value, int minValue, int maxValue,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSL_HORIZONTAL,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxSliderNameStr);
-
- virtual int GetValue() const ;
- virtual void SetValue(int);
-
- void SetRange(int minValue, int maxValue);
-
- inline int GetMin() const { return m_rangeMin; }
- inline int GetMax() const { return m_rangeMax; }
-
- void SetMin(int minValue) { SetRange(minValue, m_rangeMax); }
- void SetMax(int maxValue) { SetRange(m_rangeMin, maxValue); }
-
- // For trackbars only
- void SetTickFreq(int n, int pos);
- inline int GetTickFreq() const { return m_tickFreq; }
- void SetPageSize(int pageSize);
- int GetPageSize() const ;
- void ClearSel() ;
- void ClearTicks() ;
- void SetLineSize(int lineSize);
- int GetLineSize() const ;
- int GetSelEnd() const ;
- int GetSelStart() const ;
- void SetSelection(int minPos, int maxPos);
- void SetThumbLength(int len) ;
- int GetThumbLength() const ;
- void SetTick(int tickPos) ;
-
-
- // set min/max size of the slider
- virtual void DoSetSizeHints( int minW, int minH,
- int maxW = -1, int maxH = -1,
- int incW = -1, int incH = -1 );
-
- protected:
- virtual wxSize DoGetBestSize() const;
- virtual void DoSetSize(int x, int y, int w, int h, int sizeFlags);
- virtual void DoMoveWindow(int x, int y, int w, int h);
-
- void Command(wxCommandEvent& event);
- void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
- virtual void MacUpdateDimensions() ;
-
- wxStaticText* m_macMinimumStatic ;
- wxStaticText* m_macMaximumStatic ;
- wxStaticText* m_macValueStatic ;
-
- int m_rangeMin;
- int m_rangeMax;
- int m_pageSize;
- int m_lineSize;
- int m_tickFreq;
-private :
-DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_SLIDER_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: sound.h
-// Purpose: wxSound class (loads and plays short Windows .wav files).
-// Optional on non-Windows platforms.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_SOUND_H_
-#define _WX_SOUND_H_
-
-#if wxUSE_SOUND
-
-#include "wx/object.h"
-
-class WXDLLEXPORT wxSound : public wxSoundBase
-{
-public:
- wxSound();
- wxSound(const wxString& fileName, bool isResource = FALSE);
- wxSound(int size, const wxByte* data);
- virtual ~wxSound();
-
-public:
- bool Create(const wxString& fileName, bool isResource = FALSE);
- bool IsOk() const { return !m_sndname.IsEmpty(); }
-
-protected:
- // prevent collision with some BSD definitions of macro Free()
- bool FreeData();
-
- bool DoPlay(unsigned flags) const;
-
-private:
- void* m_sndChan;
-
- wxString m_sndname;
- void* m_hSnd;
- int m_waveLength;
- bool m_isResource;
-};
-
-#endif
-#endif
- // _WX_SOUND_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: spinbutt.h
-// Purpose: wxSpinButton class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_SPINBUTT_H_
-#define _WX_SPINBUTT_H_
-
-#include "wx/control.h"
-#include "wx/event.h"
-
-/*
- The wxSpinButton is like a small scrollbar than is often placed next
- to a text control.
-
- wxSP_HORIZONTAL: horizontal spin button
- wxSP_VERTICAL: vertical spin button (the default)
- wxSP_ARROW_KEYS: arrow keys increment/decrement value
- wxSP_WRAP: value wraps at either end
- */
-
-class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase
-{
-public:
- // construction
- wxSpinButton();
-
- wxSpinButton(wxWindow *parent,
- wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
- const wxString& name = wxT("wxSpinButton"))
- {
- Create(parent, id, pos, size, style, name);
- }
-
- virtual ~wxSpinButton();
-
- bool Create(wxWindow *parent,
- wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
- const wxString& name = wxT("wxSpinButton"));
-
-
- // accessors
- virtual int GetMin() const;
- virtual int GetMax() const;
- virtual int GetValue() const;
- virtual void SetValue(int val);
- virtual void SetRange(int minVal, int maxVal);
-
- // implementation
-
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
-
-protected:
- void MacHandleValueChanged( int inc ) ;
- virtual wxSize DoGetBestSize() const;
- int m_value ;
-
-private:
- DECLARE_DYNAMIC_CLASS(wxSpinButton)
-};
-
-#endif
- // _WX_SPINBUTT_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/generic/spinctlg.h
-// Purpose: generic wxSpinCtrl class
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 28.10.99
-// RCS-ID: $Id$
-// Copyright: (c) Vadim Zeitlin
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MAC_SPINCTRL_H_
-#define _WX_MAC_SPINCTRL_H_
-
-// ----------------------------------------------------------------------------
-// wxSpinCtrl is a combination of wxSpinButton and wxTextCtrl, so if
-// wxSpinButton is available, this is what we do - but if it isn't, we still
-// define wxSpinCtrl class which then has the same appearance as wxTextCtrl but
-// the different interface. This allows to write programs using wxSpinCtrl
-// without tons of #ifdefs.
-// ----------------------------------------------------------------------------
-
-#if wxUSE_SPINBTN
-
-class WXDLLEXPORT wxSpinButton;
-class WXDLLEXPORT wxTextCtrl;
-
-// ----------------------------------------------------------------------------
-// wxSpinCtrl is a combination of wxTextCtrl and wxSpinButton
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxSpinCtrl : public wxControl
-{
-public:
- wxSpinCtrl() { Init(); }
-
- wxSpinCtrl(wxWindow *parent,
- wxWindowID id = -1,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
- int min = 0, int max = 100, int initial = 0,
- const wxString& name = _T("wxSpinCtrl"))
- {
- Init();
- Create(parent, id, value, pos, size, style, min, max, initial, name);
- }
-
- bool Create(wxWindow *parent,
- wxWindowID id = -1,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
- int min = 0, int max = 100, int initial = 0,
- const wxString& name = _T("wxSpinCtrl"));
-
- // wxTextCtrl-like method
- void SetSelection(long from, long to);
-
- virtual ~wxSpinCtrl();
-
- // operations
- void SetValue(int val);
- void SetValue(const wxString& text);
- void SetRange(int min, int max);
-
- // accessors
- int GetValue() const;
- int GetMin() const;
- int GetMax() const;
-
- // implementation from now on
-
- // forward these functions to all subcontrols
- virtual bool Enable(bool enable = TRUE);
- virtual bool Show(bool show = TRUE);
-
- // get the subcontrols
- wxTextCtrl *GetText() const { return m_text; }
- wxSpinButton *GetSpinButton() const { return m_btn; }
-
- // set the value of the text (only)
- void SetTextValue(int val);
-
- // put the numeric value of the string in the text ctrl into val and return
- // TRUE or return FALSE if the text ctrl doesn't contain a number or if the
- // number is out of range
- bool GetTextValue(int *val) const;
-
-protected:
- // override the base class virtuals involved into geometry calculations
- virtual wxSize DoGetBestSize() const;
- virtual void DoMoveWindow(int x, int y, int width, int height);
-
- // common part of all ctors
- void Init();
-
-private:
- // the subcontrols
- wxTextCtrl *m_text;
- wxSpinButton *m_btn;
-
-private:
- DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
-};
-
-#else // !wxUSE_SPINBTN
-
-// ----------------------------------------------------------------------------
-// wxSpinCtrl is just a text control
-// ----------------------------------------------------------------------------
-
-#include "wx/textctrl.h"
-
-class WXDLLEXPORT wxSpinCtrl : public wxTextCtrl
-{
-public:
- wxSpinCtrl() { Init(); }
-
- wxSpinCtrl(wxWindow *parent,
- wxWindowID id = -1,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
- int min = 0, int max = 100, int initial = 0,
- const wxString& name = _T("wxSpinCtrl"))
- {
- Create(parent, id, value, pos, size, style, min, max, initial, name);
- }
-
- bool Create(wxWindow *parent,
- wxWindowID id = -1,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
- int min = 0, int max = 100, int initial = 0,
- const wxString& name = _T("wxSpinCtrl"))
- {
- SetRange(min, max);
-
- bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style,
- wxDefaultValidator, name);
- SetValue(initial);
-
- return ok;
- }
-
- // accessors
- int GetValue(int WXUNUSED(dummy) = 1) const
- {
- int n;
- if ( (wxSscanf(wxTextCtrl::GetValue(), wxT("%d"), &n) != 1) )
- n = INT_MIN;
-
- return n;
- }
-
- int GetMin() const { return m_min; }
- int GetMax() const { return m_max; }
-
- // operations
- void SetValue(const wxString& value) { wxTextCtrl::SetValue(value); }
- void SetValue(int val) { wxString s; s << val; wxTextCtrl::SetValue(s); }
- void SetRange(int min, int max) { m_min = min; m_max = max; }
-
-protected:
- // initialize m_min/max with the default values
- void Init() { SetRange(0, 100); }
-
- int m_min;
- int m_max;
-
-private:
- DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
-};
-
-#endif // wxUSE_SPINBTN/!wxUSE_SPINBTN
-
-#endif // _WX_MAC_SPINCTRL_H_
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: statbmp.h
-// Purpose: wxStaticBitmap class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_STATBMP_H_
-#define _WX_STATBMP_H_
-
-#include "wx/icon.h"
-
-class WXDLLEXPORT wxStaticBitmap: public wxStaticBitmapBase
-{
- DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
- public:
- inline wxStaticBitmap() { }
-
- inline wxStaticBitmap(wxWindow *parent, wxWindowID id,
- const wxBitmap& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxStaticBitmapNameStr)
- {
- Create(parent, id, label, pos, size, style, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxBitmap& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxStaticBitmapNameStr);
-
- virtual void SetBitmap(const wxBitmap& bitmap);
-
- virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
- virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
- void OnPaint( wxPaintEvent &event ) ;
-
- wxBitmap GetBitmap() const { return m_bitmap; }
- wxIcon GetIcon() const
- {
- // icons and bitmaps are really the same thing in wxMac
- return (const wxIcon &)m_bitmap;
- }
- void SetIcon(const wxIcon& icon) { SetBitmap( (const wxBitmap &)icon ) ; }
-
- // overriden base class virtuals
- virtual bool AcceptsFocus() const { return FALSE; }
- virtual wxSize DoGetBestSize() const ;
-
- protected:
- wxBitmap m_bitmap;
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_STATBMP_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: statbox.h
-// Purpose: wxStaticBox class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_STATBOX_H_
-#define _WX_STATBOX_H_
-
-#include "wx/control.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxStaticBoxNameStr[];
-
-// Group box
-class WXDLLEXPORT wxStaticBox: public wxControl
-{
- DECLARE_DYNAMIC_CLASS(wxStaticBox)
-
- public:
- inline wxStaticBox() {}
- inline wxStaticBox(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxStaticBoxNameStr)
- {
- Create(parent, id, label, pos, size, style, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxStaticBoxNameStr);
-
- virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
- virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
-
-
-protected:
-
-DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_STATBOX_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: mac/statline.h
-// Purpose: a generic wxStaticLine class used for mac before adaptation
-// Author: Vadim Zeitlin
-// Created: 28.06.99
-// Version: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_GENERIC_STATLINE_H_
-#define _WX_GENERIC_STATLINE_H_
-
-class wxStaticBox;
-
-// ----------------------------------------------------------------------------
-// wxStaticLine
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxStaticLine : public wxStaticLineBase
-{
-public:
- // constructors and pseudo-constructors
- wxStaticLine() : m_statbox(NULL) { }
-
- wxStaticLine( wxWindow *parent,
- wxWindowID id = wxID_ANY,
- const wxPoint &pos = wxDefaultPosition,
- const wxSize &size = wxDefaultSize,
- long style = wxLI_HORIZONTAL,
- const wxString &name = wxStaticLineNameStr )
- : m_statbox(NULL)
- {
- Create(parent, id, pos, size, style, name);
- }
-
- bool Create( wxWindow *parent,
- wxWindowID id = wxID_ANY,
- const wxPoint &pos = wxDefaultPosition,
- const wxSize &size = wxDefaultSize,
- long style = wxLI_HORIZONTAL,
- const wxString &name = wxStaticLineNameStr );
-
- // it's necessary to override this wxWindow function because we
- // will want to return the main widget for m_statbox
- //
- WXWidget GetMainWidget() const;
-
-protected:
- // we implement the static line using a static box
- wxStaticBox *m_statbox;
-
- DECLARE_DYNAMIC_CLASS(wxStaticLine)
-};
-
-#endif // _WX_GENERIC_STATLINE_H_
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: stattext.h
-// Purpose: wxStaticText class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_STATTEXT_H_
-#define _WX_STATTEXT_H_
-
-class WXDLLEXPORT wxStaticText: public wxStaticTextBase
-{
- DECLARE_DYNAMIC_CLASS(wxStaticText)
- public:
- inline wxStaticText() : m_label() { }
-
- inline wxStaticText(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxStaticTextNameStr)
- {
- Create(parent, id, label, pos, size, style, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxStaticTextNameStr);
-
- // accessors
- void SetLabel( const wxString &str ) ;
- bool SetFont( const wxFont &font );
-
- // operations
- virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
- virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
- // events
- void DrawParagraph(wxDC &dc, wxString paragraph, int &y);
- void OnPaint( wxPaintEvent &event ) ;
- void OnDraw( wxDC &dc ) ;
- virtual wxSize DoGetBestSize() const ;
- virtual bool AcceptsFocus() const { return FALSE; }
- private :
- wxString m_label ;
-
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_STATTEXT_H_
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: statusbr.h
-// Purpose: native implementation of wxStatusBar. Optional; can use generic
-// version instead.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_STATBAR_H_
-#define _WX_STATBAR_H_
-
-class WXDLLEXPORT wxStatusBarMac : public wxStatusBarGeneric
-{
- DECLARE_DYNAMIC_CLASS(wxStatusBarMac);
-
- wxStatusBarMac();
- wxStatusBarMac(wxWindow *parent, wxWindowID id,
- long style = 0,
- const wxString& name = wxPanelNameStr)
- {
- Create(parent, id, style, name);
- }
-
- virtual ~wxStatusBarMac();
-
- bool Create(wxWindow *parent, wxWindowID id,
- long style ,
- const wxString& name = wxPanelNameStr) ;
-
- virtual void DrawFieldText(wxDC& dc, int i);
- virtual void DrawField(wxDC& dc, int i);
- virtual void SetStatusText(const wxString& text, int number = 0) ;
- ////////////////////////////////////////////////////////////////////////
- // Implementation
-
- virtual void MacSuperEnabled( bool enable ) ;
-
- void OnPaint(wxPaintEvent& event);
-protected:
-
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_STATBAR_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: tabctrl.h
-// Purpose: wxTabCtrl class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_TABCTRL_H_
-#define _WX_TABCTRL_H_
-
-class wxImageList;
-
-/*
- * Flags returned by HitTest
- */
-
-#define wxTAB_HITTEST_NOWHERE 1
-#define wxTAB_HITTEST_ONICON 2
-#define wxTAB_HITTEST_ONLABEL 4
-#define wxTAB_HITTEST_ONITEM 6
-
-class WXDLLEXPORT wxTabCtrl: public wxControl
-{
- DECLARE_DYNAMIC_CLASS(wxTabCtrl)
- public:
- /*
- * Public interface
- */
-
- wxTabCtrl();
-
- inline wxTabCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long style = 0, const wxString& name = wxT("tabCtrl"))
- {
- Create(parent, id, pos, size, style, name);
- }
- virtual ~wxTabCtrl();
-
-// Accessors
-
- // Get the selection
- int GetSelection() const;
-
- // Get the tab with the current keyboard focus
- int GetCurFocus() const;
-
- // Get the associated image list
- wxImageList* GetImageList() const;
-
- // Get the number of items
- int GetItemCount() const;
-
- // Get the rect corresponding to the tab
- bool GetItemRect(int item, wxRect& rect) const;
-
- // Get the number of rows
- int GetRowCount() const;
-
- // Get the item text
- wxString GetItemText(int item) const ;
-
- // Get the item image
- int GetItemImage(int item) const;
-
- // Get the item data
- void* GetItemData(int item) const;
-
- // Set the selection
- int SetSelection(int item);
-
- // Set the image list
- void SetImageList(wxImageList* imageList);
-
- // Set the text for an item
- bool SetItemText(int item, const wxString& text);
-
- // Set the image for an item
- bool SetItemImage(int item, int image);
-
- // Set the data for an item
- bool SetItemData(int item, void* data);
-
- // Set the size for a fixed-width tab control
- void SetItemSize(const wxSize& size);
-
- // Set the padding between tabs
- void SetPadding(const wxSize& padding);
-
-// Operations
-
- bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long style = 0, const wxString& name = wxT("tabCtrl"));
-
- // Delete all items
- bool DeleteAllItems();
-
- // Delete an item
- bool DeleteItem(int item);
-
- // Hit test
- int HitTest(const wxPoint& pt, long& flags);
-
- // Insert an item
- bool InsertItem(int item, const wxString& text, int imageId = -1, void* data = NULL);
-
- void Command(wxCommandEvent& event);
-
-protected:
- wxImageList* m_imageList;
-
-DECLARE_EVENT_TABLE()
-};
-
-class WXDLLEXPORT wxTabEvent: public wxCommandEvent
-{
- DECLARE_DYNAMIC_CLASS(wxTabEvent)
-
- public:
- wxTabEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
-};
-
-typedef void (wxEvtHandler::*wxTabEventFunction)(wxTabEvent&);
-
-#define EVT_TAB_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TAB_SEL_CHANGED, \
- id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn, NULL },
-#define EVT_TAB_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TAB_SEL_CHANGING, \
- id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn, NULL },
-
-#endif
- // _WX_TABCTRL_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////
-// File: wx/mac/classic/taskbarosx.h
-// Purpose: Defines wxTaskBarIcon class for OSX
-// Author: Ryan Norton
-// Modified by:
-// Created: 04/04/2003
-// RCS-ID: $Id$
-// Copyright: (c) Ryan Norton, 2003
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////
-
-#ifndef _TASKBAR_H_
-#define _TASKBAR_H_
-
-class WXDLLEXPORT wxIcon;
-class WXDLLEXPORT wxMenu;
-
-class WXDLLEXPORT wxTaskBarIcon : public wxTaskBarIconBase
-{
-public:
- //type of taskbar item to create (currently only DOCK is implemented)
- enum wxTaskBarIconType
- {
- DOCK,
- STATUSITEM,
- MENUEXTRA
- };
-
- wxTaskBarIcon(const wxTaskBarIconType& nType = DOCK);
- virtual ~wxTaskBarIcon();
-
- // Operations:
- bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxEmptyString);
- bool RemoveIcon();
- bool PopupMenu(wxMenu *menu);
-
-protected:
- wxTaskBarIconType m_nType;
-
- DECLARE_DYNAMIC_CLASS(wxTaskBarIcon)
-};
-
-#endif
- // _TASKBAR_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: textctrl.h
-// Purpose: wxTextCtrl class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_TEXTCTRL_H_
-#define _WX_TEXTCTRL_H_
-
-#include "wx/control.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxTextCtrlNameStr[];
-
-// Single-line text item
-class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
-{
- DECLARE_DYNAMIC_CLASS(wxTextCtrl)
-
-public:
- // creation
- // --------
- wxTextCtrl() { Init(); }
- virtual ~wxTextCtrl();
- wxTextCtrl(wxWindow *parent, wxWindowID id,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxTextCtrlNameStr)
- {
- Init();
-
- Create(parent, id, value, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent, wxWindowID id,
- const wxString& value = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize, long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxTextCtrlNameStr);
-
- // accessors
- // ---------
- virtual wxString GetValue() const ;
- virtual void SetValue(const wxString& value);
-
- virtual int GetLineLength(long lineNo) const;
- virtual wxString GetLineText(long lineNo) const;
- virtual int GetNumberOfLines() const;
-
- virtual bool IsModified() const;
- virtual bool IsEditable() const;
-
- // If the return values from and to are the same, there is no selection.
- virtual void GetSelection(long* from, long* to) const;
-
- // operations
- // ----------
-
- // editing
-
- virtual void Clear();
- virtual void Replace(long from, long to, const wxString& value);
- virtual void Remove(long from, long to);
-
- // sets/clears the dirty flag
- virtual void MarkDirty();
- virtual void DiscardEdits();
-
- // set the max number of characters which may be entered in a single line
- // text control
- virtual void SetMaxLength(unsigned long len) ;
-
- // text control under some platforms supports the text styles: these
- // methods allow to apply the given text style to the given selection or to
- // set/get the style which will be used for all appended text
- virtual bool SetStyle(long start, long end, const wxTextAttr& style);
- virtual bool SetDefaultStyle(const wxTextAttr& style);
-
- // writing text inserts it at the current position, appending always
- // inserts it at the end
- virtual void WriteText(const wxString& text);
- virtual void AppendText(const wxString& text);
-
- // translate between the position (which is just an index in the text ctrl
- // considering all its contents as a single strings) and (x, y) coordinates
- // which represent column and line.
- virtual long XYToPosition(long x, long y) const;
- virtual bool PositionToXY(long pos, long *x, long *y) const;
-
- virtual void ShowPosition(long pos);
-
- // Clipboard operations
- virtual void Copy();
- virtual void Cut();
- virtual void Paste();
-
- virtual bool CanCopy() const;
- virtual bool CanCut() const;
- virtual bool CanPaste() const;
-
- // Undo/redo
- virtual void Undo();
- virtual void Redo();
-
- virtual bool CanUndo() const;
- virtual bool CanRedo() const;
-
- // Insertion point
- virtual void SetInsertionPoint(long pos);
- virtual void SetInsertionPointEnd();
- virtual long GetInsertionPoint() const;
- virtual wxTextPos GetLastPosition() const;
-
- virtual void SetSelection(long from, long to);
- virtual void SetEditable(bool editable);
-
- // Implementation from now on
- // --------------------------
-
- // Implementation
- // --------------
- virtual void Command(wxCommandEvent& event);
-
- virtual bool AcceptsFocus() const;
-
- // callbacks
- void OnDropFiles(wxDropFilesEvent& event);
- void OnChar(wxKeyEvent& event); // Process 'enter' if required
-
- void OnCut(wxCommandEvent& event);
- void OnCopy(wxCommandEvent& event);
- void OnPaste(wxCommandEvent& event);
- void OnUndo(wxCommandEvent& event);
- void OnRedo(wxCommandEvent& event);
-
- void OnUpdateCut(wxUpdateUIEvent& event);
- void OnUpdateCopy(wxUpdateUIEvent& event);
- void OnUpdatePaste(wxUpdateUIEvent& event);
- void OnUpdateUndo(wxUpdateUIEvent& event);
- void OnUpdateRedo(wxUpdateUIEvent& event);
-
- virtual bool MacCanFocus() const { return true ; }
- virtual bool MacSetupCursor( const wxPoint& pt ) ;
-
- virtual void MacSuperShown( bool show ) ;
- virtual bool Show(bool show = true) ;
-
-protected:
- // common part of all ctors
- void Init();
-
- virtual wxSize DoGetBestSize() const;
-
- bool m_editable ;
-
- // flag is set to true when the user edits the controls contents
- bool m_dirty;
-
- // one of the following objects is used for representation, the other one is NULL
- void* m_macTE ;
- void* m_macTXN ;
- void* m_macTXNvars ;
- bool m_macUsesTXN ;
- unsigned long m_maxLength ;
-
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_TEXTCTRL_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/tglbtn.h
-// Purpose: Declaration of the wxToggleButton class, which implements a
-// toggle button under wxMac.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 08.02.01
-// RCS-ID: $Id$
-// Copyright: (c) 2004 Stefan Csomor
-// License: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_TOGGLEBUTTON_H_
-#define _WX_TOGGLEBUTTON_H_
-
-WXDLLEXPORT_DATA(extern const wxChar) wxCheckBoxNameStr[];
-
-// Checkbox item (single checkbox)
-class WXDLLEXPORT wxToggleButton : public wxControl
-{
-public:
- wxToggleButton() {}
- wxToggleButton(wxWindow *parent,
- wxWindowID id,
- const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxCheckBoxNameStr)
- {
- Create(parent, id, label, pos, size, style, validator, name);
- }
-
- bool Create(wxWindow *parent,
- wxWindowID id,
- const wxString& label,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = wxCheckBoxNameStr);
-
- virtual void SetValue(bool value);
- virtual bool GetValue() const ;
-
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
-
- virtual void Command(wxCommandEvent& event);
-
-protected:
- virtual wxSize DoGetBestSize() const;
-
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton)
-};
-
-#endif // _WX_TOGGLEBUTTON_H_
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: timer.h
-// Purpose: wxTimer class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_TIMER_H_
-#define _WX_TIMER_H_
-
-#include "wx/object.h"
-#include "wx/mac/macnotfy.h"
-
-class wxTimer ;
-
-struct MacTimerInfo ;
-
-class WXDLLEXPORT wxTimer: public wxTimerBase
-{
-public:
- wxTimer() { Init(); }
- wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id) { Init(); }
- virtual ~wxTimer();
-
- virtual bool Start(int milliseconds = -1,
- bool one_shot = FALSE); // Start timer
- virtual void Stop(); // Stop timer
-
- virtual bool IsRunning() const ;
-
- MacTimerInfo* m_info;
-protected :
- void Init();
-private:
-
- DECLARE_ABSTRACT_CLASS(wxTimer)
-};
-
-#endif
- // _WX_TIMER_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: toolbar.h
-// Purpose: wxToolBar class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_TOOLBAR_H_
-#define _WX_TOOLBAR_H_
-
-#if wxUSE_TOOLBAR
-
-#include "wx/tbarbase.h"
-#include "wx/dynarray.h"
-
-WXDLLEXPORT_DATA(extern const wxChar) wxToolBarNameStr[];
-
-class WXDLLEXPORT wxToolBar: public wxToolBarBase
-{
- DECLARE_DYNAMIC_CLASS(wxToolBar)
- public:
- /*
- * Public interface
- */
-
- wxToolBar() { Init(); }
-
-
- inline wxToolBar(wxWindow *parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long style = wxNO_BORDER|wxTB_HORIZONTAL,
- const wxString& name = wxToolBarNameStr)
- {
- Init();
- Create(parent, id, pos, size, style, name);
- }
- virtual ~wxToolBar();
-
- bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long style = wxNO_BORDER|wxTB_HORIZONTAL,
- const wxString& name = wxToolBarNameStr);
-
- // override/implement base class virtuals
- virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
-
- virtual bool Realize();
-
- virtual void SetToolBitmapSize(const wxSize& size);
- virtual wxSize GetToolSize() const;
-
- virtual void SetRows(int nRows);
-
- // Add all the buttons
-
- virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
- virtual wxString MacGetToolTipString( wxPoint &where ) ;
- void OnPaint(wxPaintEvent& event) ;
- void OnMouse(wxMouseEvent& event) ;
- virtual void MacSuperChangedPosition() ;
-protected:
- // common part of all ctors
- void Init();
-
- // implement base class pure virtuals
- virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
- virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
-
- virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
- virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
- virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
-
- virtual wxToolBarToolBase *CreateTool(int id,
- const wxString& label,
- const wxBitmap& bmpNormal,
- const wxBitmap& bmpDisabled,
- wxItemKind kind,
- wxObject *clientData,
- const wxString& shortHelp,
- const wxString& longHelp);
- virtual wxToolBarToolBase *CreateTool(wxControl *control);
-
- DECLARE_EVENT_TABLE()
-};
-
-#endif // wxUSE_TOOLBAR
-
-#endif
- // _WX_TOOLBAR_H_
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: mac/tooltip.h
-// Purpose: wxToolTip class - tooltip control
-// Author: Stefan Csomor
-// Modified by:
-// Created: 31.01.99
-// RCS-ID: $Id$
-// Copyright: (c) 1999 Robert Roebling, Vadim Zeitlin, Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-
-class wxToolTip : public wxObject
-{
-public:
- // ctor & dtor
- wxToolTip(const wxString &tip);
- virtual ~wxToolTip();
-
- // accessors
- // tip text
- void SetTip(const wxString& tip);
- const wxString& GetTip() const { return m_text; }
-
- // the window we're associated with
- void SetWindow(wxWindow *win);
- wxWindow *GetWindow() const { return m_window; }
-
- // controlling tooltip behaviour: globally change tooltip parameters
- // enable or disable the tooltips globally
- static void Enable(bool flag);
- // set the delay after which the tooltip appears
- static void SetDelay(long milliseconds);
- static void NotifyWindowDelete( WXHWND win ) ;
-
- // implementation only from now on
- // -------------------------------
-
- // should be called in response to mouse events
- static void RelayEvent(wxWindow *win , wxMouseEvent &event);
- static void RemoveToolTips();
-
-private:
- wxString m_text; // tooltip text
- wxWindow *m_window; // window we're associated with
- DECLARE_ABSTRACT_CLASS(wxToolTip)
-};
-
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/toplevel.h
-// Purpose: wxTopLevelWindowMac is the Mac implementation of wxTLW
-// Author: Stefan Csomor
-// Modified by:
-// Created: 20.09.01
-// RCS-ID: $Id$
-// Copyright: (c) 2001 Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_MSW_TOPLEVEL_H_
-#define _WX_MSW_TOPLEVEL_H_
-
-#if wxUSE_SYSTEM_OPTIONS
- #define wxMAC_WINDOW_PLAIN_TRANSITION _T("mac.window-plain-transition")
-#endif
-
-// ----------------------------------------------------------------------------
-// wxTopLevelWindowMac
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxTopLevelWindowMac : public wxTopLevelWindowBase
-{
-public:
- // constructors and such
- wxTopLevelWindowMac() { Init(); }
-
- wxTopLevelWindowMac(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = wxFrameNameStr)
- {
- Init();
-
- (void)Create(parent, id, title, pos, size, style, name);
- }
-
- bool Create(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE,
- const wxString& name = wxFrameNameStr);
-
- virtual ~wxTopLevelWindowMac();
-
- // implement base class pure virtuals
- virtual void Maximize(bool maximize = true);
- virtual bool IsMaximized() const;
- virtual void Iconize(bool iconize = true);
- virtual bool IsIconized() const;
- virtual void SetIcon(const wxIcon& icon);
- virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); }
- virtual void Restore();
-
- virtual bool SetShape(const wxRegion& region);
-
- virtual bool ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style) = wxFULLSCREEN_ALL)
- { return false; }
- virtual bool IsFullScreen() const { return false; }
-
- // implementation from now on
- // --------------------------
-
- static void MacDelayedDeactivation(long timestamp);
- virtual void MacCreateRealWindow( const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name ) ;
- static WXWindow MacGetWindowInUpdate() { return s_macWindowInUpdate ; }
- virtual void MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR clipRect, WXWindow *window , wxWindowMac** rootwin ) ;
- virtual void ClearBackground() ;
- virtual WXWidget MacGetContainerForEmbedding() ;
- WXWindow MacGetWindowRef() { return m_macWindow ; }
- virtual void MacActivate( long timestamp , bool inIsActivating ) ;
- virtual void MacUpdate( long timestamp ) ;
-#if !TARGET_CARBON
- virtual void MacMouseDown( WXEVENTREF ev , short windowPart ) ;
- virtual void MacMouseUp( WXEVENTREF ev , short windowPart ) ;
- virtual void MacMouseMoved( WXEVENTREF ev , short windowPart ) ;
- virtual void MacKeyDown( WXEVENTREF ev ) ;
-#endif
- virtual void MacFireMouseEvent( wxUint16 kind , wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp ) ;
-
- virtual void SetTitle( const wxString& title);
- virtual wxString GetTitle() const;
-
- virtual void Raise();
- virtual void Lower();
- virtual bool Show( bool show = true );
- virtual void DoMoveWindow(int x, int y, int width, int height);
- void MacInvalidate( const WXRECTPTR rect, bool eraseBackground ) ;
- short MacGetWindowBackgroundTheme() const { return m_macWindowBackgroundTheme ; }
- static bool MacEnableCompositing( bool useCompositing );
- bool MacUsesCompositing() { return m_macUsesCompositing; }
-
-#if TARGET_CARBON
- WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
-#endif
-protected:
- // common part of all ctors
- void Init();
-
- // is the frame currently iconized?
- bool m_iconized;
-
- // should the frame be maximized when it will be shown? set by Maximize()
- // when it is called while the frame is hidden
- bool m_maximizeOnShow;
- bool m_macUsesCompositing ;
-
- short m_macWindowBackgroundTheme ;
- WXWindow m_macWindow ;
- WXWidget m_macRootControl ;
- wxWindowMac* m_macFocus ;
- WXHRGN m_macNoEraseUpdateRgn ;
- bool m_macNeedsErasing ;
-
- static WXWindow s_macWindowInUpdate ;
- static wxTopLevelWindowMac *s_macDeactivateWindow;
- static bool s_macWindowCompositing ;
-private :
-#if TARGET_CARBON
- WXEVENTHANDLERREF m_macEventHandler ;
-#endif
-};
-
-// list of all frames and modeless dialogs
-extern WXDLLEXPORT_DATA(wxWindowList) wxModelessWindows;
-
-// associate mac windows with wx counterparts
-
-wxTopLevelWindowMac* wxFindWinFromMacWindow( WXWindow inWindow ) ;
-void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win) ;
-
-
-#endif // _WX_MSW_TOPLEVEL_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/treectrl.h
-// Purpose: wxTreeCtrl class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_TREECTRL_H_
-#define _WX_TREECTRL_H_
-
-#include "wx/control.h"
-#include "wx/event.h"
-#include "wx/imaglist.h"
-
-#define wxTREE_MASK_HANDLE 0x0001
-#define wxTREE_MASK_STATE 0x0002
-#define wxTREE_MASK_TEXT 0x0004
-#define wxTREE_MASK_IMAGE 0x0008
-#define wxTREE_MASK_SELECTED_IMAGE 0x0010
-#define wxTREE_MASK_CHILDREN 0x0020
-#define wxTREE_MASK_DATA 0x0040
-
-#define wxTREE_STATE_BOLD 0x0001
-#define wxTREE_STATE_DROPHILITED 0x0002
-#define wxTREE_STATE_EXPANDED 0x0004
-#define wxTREE_STATE_EXPANDEDONCE 0x0008
-#define wxTREE_STATE_FOCUSED 0x0010
-#define wxTREE_STATE_SELECTED 0x0020
-#define wxTREE_STATE_CUT 0x0040
-
-#define wxTREE_HITTEST_ABOVE 0x0001 // Above the client area.
-#define wxTREE_HITTEST_BELOW 0x0002 // Below the client area.
-#define wxTREE_HITTEST_NOWHERE 0x0004 // In the client area but below the last item.
-#define wxTREE_HITTEST_ONITEMBUTTON 0x0010 // On the button associated with an item.
-#define wxTREE_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item.
-#define wxTREE_HITTEST_ONITEMINDENT 0x0040 // In the indentation associated with an item.
-#define wxTREE_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item.
-#define wxTREE_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item.
-#define wxTREE_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state.
-#define wxTREE_HITTEST_TOLEFT 0x0400 // To the right of the client area.
-#define wxTREE_HITTEST_TORIGHT 0x0800 // To the left of the client area.
-
-#define wxTREE_HITTEST_ONITEM (wxTREE_HITTEST_ONITEMICON | wxTREE_HITTEST_ONITEMLABEL | wxTREE_HITTEST_ONITEMSTATEICON)
-
-// Flags for GetNextItem
-enum {
- wxTREE_NEXT_CARET, // Retrieves the currently selected item.
- wxTREE_NEXT_CHILD, // Retrieves the first child item. The hItem parameter must be NULL.
- wxTREE_NEXT_DROPHILITE, // Retrieves the item that is the target of a drag-and-drop operation.
- wxTREE_NEXT_FIRSTVISIBLE, // Retrieves the first visible item.
- wxTREE_NEXT_NEXT, // Retrieves the next sibling item.
- wxTREE_NEXT_NEXTVISIBLE, // Retrieves the next visible item that follows the specified item.
- wxTREE_NEXT_PARENT, // Retrieves the parent of the specified item.
- wxTREE_NEXT_PREVIOUS, // Retrieves the previous sibling item.
- wxTREE_NEXT_PREVIOUSVISIBLE, // Retrieves the first visible item that precedes the specified item.
- wxTREE_NEXT_ROOT // Retrieves the first child item of the root item of which the specified item is a part.
-};
-
-#if WXWIN_COMPATIBILITY_2_6
- // Flags for InsertItem
- enum {
- wxTREE_INSERT_LAST = -1,
- wxTREE_INSERT_FIRST = -2,
- wxTREE_INSERT_SORT = -3
- };
-#endif
-
-class WXDLLEXPORT wxTreeItem: public wxObject
-{
- DECLARE_DYNAMIC_CLASS(wxTreeItem)
-public:
- long m_mask;
- long m_itemId;
- long m_state;
- long m_stateMask;
- wxString m_text;
- int m_image;
- int m_selectedImage;
- int m_children;
- long m_data;
-
- wxTreeItem();
-
-// Accessors
- inline long GetMask() const { return m_mask; }
- inline long GetItemId() const { return m_itemId; }
- inline long GetState() const { return m_state; }
- inline long GetStateMask() const { return m_stateMask; }
- inline wxString GetText() const { return m_text; }
- inline int GetImage() const { return m_image; }
- inline int GetSelectedImage() const { return m_selectedImage; }
- inline int GetChildren() const { return m_children; }
- inline long GetData() const { return m_data; }
-
- inline void SetMask(long mask) { m_mask = mask; }
- inline void SetItemId(long id) { m_itemId = m_itemId = id; }
- inline void SetState(long state) { m_state = state; }
- inline void SetStateMask(long stateMask) { m_stateMask = stateMask; }
- inline void GetText(const wxString& text) { m_text = text; }
- inline void SetImage(int image) { m_image = image; }
- inline void GetSelectedImage(int selImage) { m_selectedImage = selImage; }
- inline void SetChildren(int children) { m_children = children; }
- inline void SetData(long data) { m_data = data; }
-};
-
-class WXDLLEXPORT wxTreeCtrl: public wxControl
-{
-public:
- /*
- * Public interface
- */
-
- // creation
- // --------
- wxTreeCtrl();
-
- inline wxTreeCtrl(wxWindow *parent, wxWindowID id = wxID_ANY,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = "wxTreeCtrl")
- {
- Create(parent, id, pos, size, style, validator, name);
- }
- virtual ~wxTreeCtrl();
-
- bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = "wxTreeCtrl");
-
- // accessors
- // ---------
- //
- virtual unsigned int GetCount() const;
-
- // indent
- int GetIndent() const;
- void SetIndent(int indent);
- // image list
- wxImageList *GetImageList(int which = wxIMAGE_LIST_NORMAL) const;
-
- // navigation inside the tree
- long GetNextItem(long item, int code) const;
- bool ItemHasChildren(long item) const;
- long GetChild(long item) const;
- long GetItemParent(long item) const;
- long GetFirstVisibleItem() const;
- long GetNextVisibleItem(long item) const;
- long GetSelection() const;
- long GetRootItem() const;
-
- // generic function for (g|s)etting item attributes
- bool GetItem(wxTreeItem& info) const;
- bool SetItem(wxTreeItem& info);
- // item state
- int GetItemState(long item, long stateMask) const;
- bool SetItemState(long item, long state, long stateMask);
- // item image
- bool SetItemImage(long item, int image, int selImage);
- // item text
- wxString GetItemText(long item) const;
- void SetItemText(long item, const wxString& str);
- // custom data associated with the item
- long GetItemData(long item) const;
- bool SetItemData(long item, long data);
- // convenience function
- bool IsItemExpanded(long item)
- {
- return (GetItemState(item, wxTREE_STATE_EXPANDED) &
- wxTREE_STATE_EXPANDED) != 0;
- }
-
- // bounding rect
- bool GetItemRect(long item, wxRect& rect, bool textOnly = false) const;
- //
- wxTextCtrl* GetEditControl() const;
-
- // operations
- // ----------
- // adding/deleting items
- bool DeleteItem(long item);
-
-#if WXWIN_COMPATIBILITY_2_6
- wxDEPRECATED( long InsertItem(long parent, wxTreeItem& info,
- long insertAfter = wxTREE_INSERT_LAST) );
- // If image > -1 and selImage == -1, the same image is used for
- // both selected and unselected items.
- wxDEPRECATED( long InsertItem(long parent, const wxString& label,
- int image = -1, int selImage = -1,
- long insertAfter = wxTREE_INSERT_LAST) );
- wxDEPRECATED( bool ExpandItem(long item, int action) );
- wxDEPRECATED( void SetImageList(wxImageList *imageList, int which = wxIMAGE_LIST_NORMAL) );
-#endif // WXWIN_COMPATIBILITY_2_6
-
- // changing item state
- bool ExpandItem(long item) { return ExpandItem(item, wxTREE_EXPAND_EXPAND); }
- bool CollapseItem(long item) { return ExpandItem(item, wxTREE_EXPAND_COLLAPSE); }
- bool ToggleItem(long item) { return ExpandItem(item, wxTREE_EXPAND_TOGGLE); }
- // common interface for {Expand|Collapse|Toggle}Item
-
- //
- bool SelectItem(long item);
- bool ScrollTo(long item);
- bool DeleteAllItems();
-
- // Edit the label (tree must have the focus)
- wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl));
-
- // End label editing, optionally cancelling the edit
- bool EndEditLabel(bool cancel);
-
- long HitTest(const wxPoint& point, int& flags);
- // wxImageList *CreateDragImage(long item);
- bool SortChildren(long item);
- bool EnsureVisible(long item);
-
- void Command(wxCommandEvent& event) { ProcessCommand(event); };
-
-protected:
- wxTextCtrl* m_textCtrl;
- wxImageList* m_imageListNormal;
- wxImageList* m_imageListState;
-
- DECLARE_DYNAMIC_CLASS(wxTreeCtrl)
-};
-
-/*
- wxEVT_COMMAND_TREE_BEGIN_DRAG,
- wxEVT_COMMAND_TREE_BEGIN_RDRAG,
- wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT,
- wxEVT_COMMAND_TREE_END_LABEL_EDIT,
- wxEVT_COMMAND_TREE_DELETE_ITEM,
- wxEVT_COMMAND_TREE_GET_INFO,
- wxEVT_COMMAND_TREE_SET_INFO,
- wxEVT_COMMAND_TREE_ITEM_EXPANDED,
- wxEVT_COMMAND_TREE_ITEM_EXPANDING,
- wxEVT_COMMAND_TREE_ITEM_COLLAPSED,
- wxEVT_COMMAND_TREE_ITEM_COLLAPSING,
- wxEVT_COMMAND_TREE_SEL_CHANGED,
- wxEVT_COMMAND_TREE_SEL_CHANGING,
- wxEVT_COMMAND_TREE_KEY_DOWN
-*/
-
-class WXDLLEXPORT wxTreeEvent: public wxCommandEvent
-{
- DECLARE_DYNAMIC_CLASS(wxTreeEvent)
-
-public:
-
- wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
-
- int m_code;
- wxTreeItem m_item;
- long m_oldItem;
- wxPoint m_pointDrag;
-
- inline long GetOldItem() const { return m_oldItem; }
- inline wxTreeItem& GetItem() const { return (wxTreeItem&) m_item; }
- inline wxPoint GetPoint() const { return m_pointDrag; }
- inline int GetCode() const { return m_code; }
-};
-
-typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
-
-#define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-
-#endif
- // _WX_TREECTRL_H_
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/classic/uma.h
-// Purpose: Universal MacOS API
-// Author: Stefan Csomor
-// Modified by:
-// Created: 03/02/99
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef H_UMA
-#define H_UMA
-
-#include "wx/mac/private.h"
-
-void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded) ;
-void UMACleanupToolbox() ;
-long UMAGetSystemVersion() ;
-bool UMAHasAppearance() ;
-long UMAGetAppearanceVersion() ;
-bool UMAHasWindowManager() ;
-long UMAGetWindowManagerAttr() ;
-bool UMAHasAquaLayout() ;
-
-bool UMASystemIsInitialized() ;
-void UMASetSystemIsInitialized(bool val);
-
-// process manager
-
-long UMAGetProcessMode() ;
-bool UMAGetProcessModeDoesActivateOnFGSwitch() ;
-
-#if wxUSE_GUI
-
-// menu manager
-
-MenuRef UMANewMenu( SInt16 id , const wxString& title , wxFontEncoding encoding) ;
-void UMASetMenuTitle( MenuRef menu , const wxString& title , wxFontEncoding encoding) ;
-UInt32 UMAMenuEvent( EventRecord *inEvent ) ;
-void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex item , bool enable ) ;
-
-void UMAAppendSubMenuItem( MenuRef menu , const wxString& title , wxFontEncoding encoding , SInt16 submenuid ) ;
-void UMAInsertSubMenuItem( MenuRef menu , const wxString& title , wxFontEncoding encoding , MenuItemIndex item , SInt16 submenuid ) ;
-void UMAAppendMenuItem( MenuRef menu , const wxString& title , wxFontEncoding encoding , wxAcceleratorEntry *entry = NULL ) ;
-void UMAInsertMenuItem( MenuRef menu , const wxString& title , wxFontEncoding encoding , MenuItemIndex item , wxAcceleratorEntry *entry = NULL ) ;
-void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEntry *entry ) ;
-
-void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title , wxFontEncoding encoding ) ;
-
-// quickdraw
-
-void UMAShowWatchCursor() ;
-void UMAShowArrowCursor() ;
-
-#if !TARGET_CARBON
-OSStatus UMAPrOpen() ;
-OSStatus UMAPrClose() ;
-#endif
-
-// window manager
-
-GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) ;
-void UMADisposeWindow( WindowRef inWindowRef ) ;
-void UMASetWTitle( WindowRef inWindowRef , const wxString& title , wxFontEncoding encoding) ;
-
-void UMADrawGrowIcon( WindowRef inWindowRef ) ;
-void UMAShowHide( WindowRef inWindowRef , Boolean show) ;
-
-// appearance manager
-
-void UMADrawControl( ControlHandle inControl ) ;
-
-void UMAEnableControl( ControlHandle inControl ) ;
-void UMADisableControl( ControlHandle inControl ) ;
-void UMAActivateControl( ControlHandle inControl ) ;
-void UMADeactivateControl( ControlHandle inControl ) ;
-// ControlPartCode hiliteState) ;
-void UMAShowControl (ControlHandle theControl) ;
-void UMAHideControl (ControlHandle theControl);
-void UMAActivateControl (ControlHandle inControl);
-void UMADeactivateControl (ControlHandle inControl);
-void UMASetControlTitle( ControlHandle inControl , const wxString& title , wxFontEncoding encoding) ;
-
-void UMAMoveControl( ControlHandle inControl , short x , short y ) ;
-void UMASizeControl( ControlHandle inControl , short x , short y ) ;
-// control hierarchy
-
-// keyboard focus
-OSErr UMASetKeyboardFocus (WindowPtr inWindow,
- ControlHandle inControl,
- ControlFocusPart inPart) ;
-
-// events
-
-void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn ) ;
-OSErr UMAGetRootControl( WindowPtr inWindow , ControlHandle *outControl ) ;
-
-// handling control data
-bool UMAIsWindowFloating( WindowRef inWindow ) ;
-bool UMAIsWindowModal( WindowRef inWindow ) ;
-
-void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate ) ;
-
-OSStatus UMAGetHelpMenu(
- MenuRef * outHelpMenu,
- MenuItemIndex * outFirstCustomItemIndex); /* can be NULL */
-
-// Appearance Drawing
-
-OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState ) ;
-
-// Clipboard support
-
-OSStatus UMAPutScrap( Size size , OSType type , void *data ) ;
-
-// accessor helpers
-
-#if !TARGET_CARBON
-#define ClearCurrentScrap() ZeroScrap() ;
-#define GetApplicationScript() smSystemScript
-#else
-
-// calls not in carbon
-
-#endif
-#define GetWindowUpdateRgn( inWindow , updateRgn ) GetWindowRegion( inWindow , kWindowUpdateRgn, updateRgn )
-
-#endif // wxUSE_GUI
-
-#endif
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: wx/mac/carbon/window.h
-// Purpose: wxWindowMac class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _WX_WINDOW_H_
-#define _WX_WINDOW_H_
-
-#include "wx/brush.h"
-
-// ---------------------------------------------------------------------------
-// forward declarations
-// ---------------------------------------------------------------------------
-
-class WXDLLEXPORT wxButton;
-class WXDLLEXPORT wxScrollBar;
-class WXDLLEXPORT wxTopLevelWindowMac;
-
-// ---------------------------------------------------------------------------
-// constants
-// ---------------------------------------------------------------------------
-
-class WXDLLEXPORT wxWindowMac: public wxWindowBase
-{
- DECLARE_DYNAMIC_CLASS(wxWindowMac)
-
- friend class wxDC;
- friend class wxPaintDC;
-
-public:
-
- wxWindowMac()
- : m_macBackgroundBrush()
- , m_macVisibleRegion()
- , m_x(0), m_y(0), m_width(0), m_height(0)
- , m_hScrollBar(NULL), m_vScrollBar(NULL)
- , m_label(wxEmptyString)
- { Init(); }
-
- wxWindowMac(wxWindowMac *parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr)
- {
- Init();
- Create(parent, id, pos, size, style, name);
- }
-
- virtual ~wxWindowMac();
-
- bool Create(wxWindowMac *parent,
- wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0,
- const wxString& name = wxPanelNameStr);
-
-
- // implement base class pure virtuals
- virtual void SetLabel( const wxString& title);
- virtual wxString GetLabel() const;
-
- virtual void Raise();
- virtual void Lower();
-
- virtual bool Show( bool show = true );
- virtual bool Enable( bool enable = true );
-
- virtual void SetFocus();
-
- virtual void WarpPointer(int x, int y);
-
- virtual void Refresh( bool eraseBackground = true,
- const wxRect *rect = (const wxRect *) NULL );
-
- virtual bool SetCursor( const wxCursor &cursor );
- virtual bool SetFont(const wxFont& font)
- { return wxWindowBase::SetFont(font); }
- virtual int GetCharHeight() const;
- virtual int GetCharWidth() const;
- virtual void GetTextExtent(const wxString& string,
- int *x, int *y,
- int *descent = (int *) NULL,
- int *externalLeading = (int *) NULL,
- const wxFont *theFont = (const wxFont *) NULL)
- const;
-
- virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
-
- virtual void SetScrollbar( int orient, int pos, int thumbVisible,
- int range, bool refresh = true );
- virtual void SetScrollPos( int orient, int pos, bool refresh = true );
- virtual int GetScrollPos( int orient ) const;
- virtual int GetScrollThumb( int orient ) const;
- virtual int GetScrollRange( int orient ) const;
- virtual void ScrollWindow( int dx, int dy,
- const wxRect* rect = (wxRect *) NULL );
-
-#if wxUSE_DRAG_AND_DROP
- virtual void SetDropTarget( wxDropTarget *dropTarget );
-#endif // wxUSE_DRAG_AND_DROP
-
- // Accept files for dragging
- virtual void DragAcceptFiles(bool accept);
-
- // Native resource loading (implemented in src/msw/nativdlg.cpp)
- // FIXME: should they really be all virtual?
- wxWindowMac* GetWindowChild1(wxWindowID id);
- wxWindowMac* GetWindowChild(wxWindowID id);
-
- // implementation from now on
- // --------------------------
-
- void MacClientToRootWindow( int *x , int *y ) const ;
- void MacRootWindowToClient( int *x , int *y ) const ;
- void MacWindowToRootWindow( int *x , int *y ) const ;
- void MacRootWindowToWindow( int *x , int *y ) const ;
-
- virtual wxString MacGetToolTipString( wxPoint &where ) ;
-
- // simple accessors
- // ----------------
-
-// WXHWND GetHWND() const { return m_hWnd; }
-// void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
- virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
-
- bool GetTransparentBackground() const { return m_backgroundTransparent; }
- void SetTransparent(bool t = true) { m_backgroundTransparent = t; }
-
- // event handlers
- // --------------
- void OnSetFocus(wxFocusEvent& event) ;
- void OnNcPaint(wxNcPaintEvent& event);
- void OnEraseBackground(wxEraseEvent& event);
- void OnMouseEvent( wxMouseEvent &event ) ;
-
- void MacOnScroll(wxScrollEvent&event ) ;
-
- bool AcceptsFocus() const ;
-
-public:
- void OnInternalIdle();
-
- // For implementation purposes - sometimes decorations make the client area
- // smaller
- virtual wxPoint GetClientAreaOrigin() const;
-
- wxWindowMac *FindItem(long id) const;
- wxWindowMac *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const;
-
- // Make a Windows extended style from the given wxWidgets window style
- static WXDWORD MakeExtendedStyle(long style,
- bool eliminateBorders = true);
- // Determine whether 3D effects are wanted
- WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
-
- // MSW only: true if this control is part of the main control
- virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return false; };
-
- // Setup background and foreground colours correctly
- virtual void SetupColours();
-
-public:
- static bool MacGetWindowFromPoint( const wxPoint &point , wxWindowMac** outWin ) ;
- virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin ) ;
- virtual void MacRedraw( WXHRGN updatergn , long time , bool erase) ;
- virtual bool MacCanFocus() const { return true ; }
-
- virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
- // this should not be overriden in classes above wxWindowMac because it is called from its destructor via DeleteChildren
- virtual void RemoveChild( wxWindowBase *child );
- virtual void MacPaintBorders( int left , int top ) ;
- WXWindow MacGetRootWindow() const ;
- wxTopLevelWindowMac* MacGetTopLevelWindow() const ;
-
- virtual WXWidget MacGetContainerForEmbedding() ;
-
- virtual long MacGetLeftBorderSize() const ;
- virtual long MacGetRightBorderSize() const ;
- virtual long MacGetTopBorderSize() const ;
- virtual long MacGetBottomBorderSize() const ;
-
- static long MacRemoveBordersFromStyle( long style ) ;
- virtual void MacSuperChangedPosition() ;
- // the absolute coordinates of this item within the toplevel window may have changed
- virtual void MacUpdateDimensions() {}
- // the absolute coortinates of this window's root have changed
- virtual void MacTopLevelWindowChangedPosition() ;
- virtual void MacSuperShown( bool show ) ;
- virtual void MacSuperEnabled( bool enable ) ;
- bool MacIsReallyShown() const ;
- virtual void Update() ;
- // for compatibility
- void MacUpdateImmediately() { Update() ; }
- virtual bool MacSetupCursor( const wxPoint& pt ) ;
-
-// virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindowMac* rootwin ) ;
-// virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin ) ;
-// virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindowMac** rootwin) ;
- const wxBrush& MacGetBackgroundBrush() ;
- const wxRegion& MacGetVisibleRegion( bool respectChildrenAndSiblings = true ) ;
- bool MacIsWindowScrollbar( const wxScrollBar* sb )
- { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
- static wxWindowMac* s_lastMouseWindow ;
-private:
-protected:
- wxBrush m_macBackgroundBrush ;
- wxRegion m_macVisibleRegion ;
- int m_x ;
- int m_y ;
- int m_width ;
- int m_height ;
-
- wxScrollBar* m_hScrollBar ;
- wxScrollBar* m_vScrollBar ;
- wxString m_label ;
-
- void MacCreateScrollBars( long style ) ;
- void MacRepositionScrollBars() ;
-
- bool m_backgroundTransparent ;
-
- // implement the base class pure virtuals
- virtual void DoClientToScreen( int *x, int *y ) const;
- virtual void DoScreenToClient( int *x, int *y ) const;
- virtual void DoGetPosition( int *x, int *y ) const;
- virtual void DoGetSize( int *width, int *height ) const;
- virtual void DoGetClientSize( int *width, int *height ) const;
- virtual void DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags = wxSIZE_AUTO);
- virtual void DoSetClientSize(int width, int height);
-
- virtual void DoCaptureMouse();
- virtual void DoReleaseMouse();
-
- // move the window to the specified location and resize it: this is called
- // from both DoSetSize() and DoSetClientSize() and would usually just call
- // ::MoveWindow() except for composite controls which will want to arrange
- // themselves inside the given rectangle
- virtual void DoMoveWindow(int x, int y, int width, int height);
-
-#if wxUSE_TOOLTIPS
- virtual void DoSetToolTip( wxToolTip *tip );
-#endif // wxUSE_TOOLTIPS
-
-private:
- // common part of all ctors
- void Init();
-
- DECLARE_NO_COPY_CLASS(wxWindowMac)
- DECLARE_EVENT_TABLE()
-};
-
-#endif
- // _WX_WINDOW_H_
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
-<plist version="0.9">
-<dict>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleIdentifier</key>
- <string>org.wxwindows.IDENTIFIER</string>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>EXECUTABLE</string>
- <key>CFBundleIconFile</key>
- <string>wxmac.icns</string>
- <key>CFBundleName</key>
- <string>EXECUTABLE</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>VERSION</string>
- <key>CFBundleShortVersionString</key>
- <string>VERSION</string>
- <key>CFBundleGetInfoString</key>
- <string>EXECUTABLE version VERSION, (c) 2002 wxWindows</string>
- <key>CFBundleLongVersionString</key>
- <string>VERSION, (c) 2002 wxWindows</string>
- <key>NSHumanReadableCopyright</key>
- <string>Copyright 2002 wxWindows</string>
- <key>LSRequiresCarbon</key>
- <true/>
- <key>CSResourcesFileMapped</key>
- <true/>
-</dict>
-</plist>
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/accel.cpp
-// Purpose: wxAcceleratorTable
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/accel.h"
-
-#ifndef WX_PRECOMP
- #include "wx/string.h"
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
-
-// ----------------------------------------------------------------------------
-// wxAccelList: a list of wxAcceleratorEntries
-// ----------------------------------------------------------------------------
-
-WX_DECLARE_LIST(wxAcceleratorEntry, wxAccelList);
-#include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wxAccelList)
-
-// ----------------------------------------------------------------------------
-// wxAccelRefData: the data used by wxAcceleratorTable
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
-{
- friend class WXDLLEXPORT wxAcceleratorTable;
-public:
- wxAcceleratorRefData();
- virtual ~wxAcceleratorRefData();
-
- wxAccelList m_accels;
-};
-
-#define M_ACCELDATA ((wxAcceleratorRefData *)m_refData)
-
-wxAcceleratorRefData::wxAcceleratorRefData()
- : m_accels()
-{
-}
-
-wxAcceleratorRefData::~wxAcceleratorRefData()
-{
- m_accels.DeleteContents( true );
-}
-
-wxAcceleratorTable::wxAcceleratorTable()
-{
- m_refData = NULL;
-}
-
-wxAcceleratorTable::~wxAcceleratorTable()
-{
-}
-
-// Create from an array
-wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[])
-{
- m_refData = new wxAcceleratorRefData;
-
- for (int i = 0; i < n; i++)
- {
- int flag = entries[i].GetFlags();
- int keycode = entries[i].GetKeyCode();
- int command = entries[i].GetCommand();
- if ((keycode >= (int)'a') && (keycode <= (int)'z')) keycode = (int)toupper( (char)keycode );
- M_ACCELDATA->m_accels.Append( new wxAcceleratorEntry( flag, keycode, command ) );
- }
-}
-
-bool wxAcceleratorTable::IsOk() const
-{
- return (m_refData != NULL);
-}
-
-int wxAcceleratorTable::GetCommand( wxKeyEvent &event )
-{
- if (!Ok()) return -1;
-
- wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst();
- while (node)
- {
- wxAcceleratorEntry *entry = (wxAcceleratorEntry*)node->GetData();
- if ((event.m_keyCode == entry->GetKeyCode()) &&
- (((entry->GetFlags() & wxACCEL_CTRL) == 0) || event.ControlDown()) &&
- (((entry->GetFlags() & wxACCEL_SHIFT) == 0) || event.ShiftDown()) &&
- (((entry->GetFlags() & wxACCEL_ALT) == 0) || event.AltDown() || event.MetaDown()))
- {
- return entry->GetCommand();
- }
- node = node->GetNext();
- }
-
- return -1;
-}
+++ /dev/null
-// NOT NEEDED ANYMORE
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/app.cpp
-// Purpose: wxApp
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/app.h"
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/log.h"
- #include "wx/utils.h"
- #include "wx/window.h"
- #include "wx/frame.h"
- #include "wx/dc.h"
- #include "wx/button.h"
- #include "wx/menu.h"
- #include "wx/pen.h"
- #include "wx/brush.h"
- #include "wx/palette.h"
- #include "wx/icon.h"
- #include "wx/cursor.h"
- #include "wx/dialog.h"
- #include "wx/msgdlg.h"
- #include "wx/textctrl.h"
- #include "wx/memory.h"
- #include "wx/gdicmn.h"
- #include "wx/module.h"
-#endif
-
-#include "wx/tooltip.h"
-#include "wx/docview.h"
-#include "wx/filename.h"
-
-#include <string.h>
-
-// mac
-
-#ifndef __DARWIN__
- #if __option(profile)
- #include <profiler.h>
- #endif
-#endif
-
-#include "apprsrc.h"
-
-#include "wx/mac/uma.h"
-#include "wx/mac/macnotfy.h"
-
-#ifdef __DARWIN__
-# include <CoreServices/CoreServices.h>
-# if defined(WXMAKINGDLL_CORE)
-# include <mach-o/dyld.h>
-# endif
-#else
-# include <Sound.h>
-# include <Threads.h>
-# include <ToolUtils.h>
-# include <DiskInit.h>
-# include <Devices.h>
-#endif
-
-extern wxList wxPendingDelete;
-extern wxList *wxWinMacWindowList;
-extern wxList *wxWinMacControlList;
-#if wxUSE_THREADS
-extern size_t g_numberOfThreads;
-#endif // wxUSE_THREADS
-
-// statics for implementation
-
-static bool s_inYield = false;
-
-#if TARGET_CARBON
-static bool s_inReceiveEvent = false ;
-static EventTime sleepTime = kEventDurationNoWait ;
-#else
-static long sleepTime = 0 ;
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
-BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
- EVT_IDLE(wxApp::OnIdle)
- EVT_END_SESSION(wxApp::OnEndSession)
- EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
-END_EVENT_TABLE()
-
-const short kMacMinHeap = (29 * 1024) ;
-// platform specific static variables
-
-const short kwxMacMenuBarResource = 1 ;
-const short kwxMacAppleMenuId = 1 ;
-
-WXHRGN wxApp::s_macCursorRgn = NULL;
-wxWindow* wxApp::s_captureWindow = NULL ;
-int wxApp::s_lastMouseDown = 0 ;
-long wxApp::sm_lastMessageTime = 0;
-long wxApp::s_lastModifiers = 0 ;
-
-
-bool wxApp::s_macSupportPCMenuShortcuts = true ;
-long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
-long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ;
-long wxApp::s_macExitMenuItemId = wxID_EXIT ;
-wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ;
-
-// Normally we're not a plugin
-bool wxApp::sm_isEmbedded = false;
-//----------------------------------------------------------------------
-// Core Apple Event Support
-//----------------------------------------------------------------------
-
-pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long refcon ) ;
-pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon ) ;
-pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon ) ;
-pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon ) ;
-pascal OSErr AEHandleRApp( const AppleEvent *event , AppleEvent *reply , long refcon ) ;
-
-pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) )
-{
- return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ;
-}
-
-pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) )
-{
- return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ;
-}
-
-pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) )
-{
- return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ;
-}
-
-pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) )
-{
- return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
-}
-
-pascal OSErr AEHandleRApp( const AppleEvent *event , AppleEvent *reply , long WXUNUSED(refcon) )
-{
- return wxTheApp->MacHandleAERApp( (AppleEvent*) event , reply) ;
-}
-
-// AEODoc Calls MacOpenFile on each of the files passed
-
-short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
-{
- AEDescList docList;
- AEKeyword keywd;
- DescType returnedType;
- Size actualSize;
- long itemsInList;
- FSSpec theSpec;
- OSErr err;
- short i;
- err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
- if (err != noErr)
- return err;
-
- err = AECountItems(&docList, &itemsInList);
- if (err != noErr)
- return err;
-
- ProcessSerialNumber PSN ;
- PSN.highLongOfPSN = 0 ;
- PSN.lowLongOfPSN = kCurrentProcess ;
- SetFrontProcess( &PSN ) ;
-
- for (i = 1; i <= itemsInList; i++) {
- AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
- (Ptr) & theSpec, sizeof(theSpec), &actualSize);
- wxString fName = wxMacFSSpec2MacFilename(&theSpec);
- MacOpenFile(fName);
- }
- return noErr;
-}
-
-// AEPDoc Calls MacPrintFile on each of the files passed
-
-short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply))
-{
- AEDescList docList;
- AEKeyword keywd;
- DescType returnedType;
- Size actualSize;
- long itemsInList;
- FSSpec theSpec;
- OSErr err;
- short i;
- err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
- if (err != noErr)
- return err;
-
- err = AECountItems(&docList, &itemsInList);
- if (err != noErr)
- return err;
-
- ProcessSerialNumber PSN ;
- PSN.highLongOfPSN = 0 ;
- PSN.lowLongOfPSN = kCurrentProcess ;
- SetFrontProcess( &PSN ) ;
-
- for (i = 1; i <= itemsInList; i++) {
- AEGetNthPtr(&docList, i, typeFSS, &keywd, &returnedType,
- (Ptr) & theSpec, sizeof(theSpec), &actualSize);
- wxString fName = wxMacFSSpec2MacFilename(&theSpec);
- MacPrintFile(fName);
- }
- return noErr;
-}
-
-// AEOApp calls MacNewFile
-
-short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
-{
- MacNewFile() ;
- return noErr ;
-}
-
-// AEQuit attempts to quit the application
-
-short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
-{
- wxWindow* win = GetTopWindow() ;
- if ( win )
- {
- wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId);
- if (!win->ProcessEvent(exitEvent))
- win->Close(true) ;
- }
- else
- {
- ExitMainLoop() ;
- }
- return noErr ;
-}
-
-// AEROApp calls MacReopenApp
-
-short wxApp::MacHandleAERApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
-{
- MacReopenApp() ;
- return noErr ;
-}
-
-
-//----------------------------------------------------------------------
-// Support Routines linking the Mac...File Calls to the Document Manager
-//----------------------------------------------------------------------
-
-void wxApp::MacOpenFile(const wxString & fileName )
-{
- wxDocManager* dm = wxDocManager::GetDocumentManager() ;
- if ( dm )
- dm->CreateDocument(fileName , wxDOC_SILENT ) ;
-}
-
-void wxApp::MacPrintFile(const wxString & fileName )
-{
- wxDocManager* dm = wxDocManager::GetDocumentManager() ;
- if ( dm )
- {
- wxDocument *doc = dm->CreateDocument(fileName , wxDOC_SILENT ) ;
- if ( doc )
- {
- wxView* view = doc->GetFirstView() ;
- if( view )
- {
- wxPrintout *printout = view->OnCreatePrintout();
- if (printout)
- {
- wxPrinter printer;
- printer.Print(view->GetFrame(), printout, true);
- delete printout;
- }
- }
- if (doc->Close())
- {
- doc->DeleteAllViews();
- dm->RemoveDocument(doc) ;
- }
- }
- }
-}
-
-void wxApp::MacNewFile()
-{
-}
-
-void wxApp::MacReopenApp()
-{
- // eventually check for open docs, if none, call MacNewFile
-}
-
-//----------------------------------------------------------------------
-// Carbon Event Handler
-//----------------------------------------------------------------------
-
-#if TARGET_CARBON
-
- static const EventTypeSpec eventList[] =
- {
- { kEventClassCommand, kEventProcessCommand } ,
- { kEventClassCommand, kEventCommandUpdateStatus } ,
-
- { kEventClassMenu, kEventMenuOpening },
- { kEventClassMenu, kEventMenuClosed },
- { kEventClassMenu, kEventMenuTargetItem },
-
- { kEventClassApplication , kEventAppActivated } ,
- { kEventClassApplication , kEventAppDeactivated } ,
- // handling the quit event is not recommended by apple
- // rather using the quit apple event - which we do
-
- { kEventClassAppleEvent , kEventAppleEvent } ,
-
- { kEventClassMouse , kEventMouseDown } ,
- { kEventClassMouse , kEventMouseMoved } ,
- { kEventClassMouse , kEventMouseUp } ,
- { kEventClassMouse , kEventMouseDragged } ,
- { 'WXMC' , 'WXMC' }
- } ;
-
-static pascal OSStatus
-MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar();
-
- if ( mbar )
- {
- wxFrame* win = mbar->GetFrame();
- if ( win )
- {
-
- // VZ: we could find the menu from its handle here by examining all
- // the menus in the menu bar recursively but knowing that neither
- // wxMSW nor wxGTK do it why bother...
-#if 0
- MenuRef menuRef;
-
- GetEventParameter(event,
- kEventParamDirectObject,
- typeMenuRef, NULL,
- sizeof(menuRef), NULL,
- &menuRef);
-#endif // 0
-
- wxEventType type=0;
- MenuCommand cmd=0;
- switch (GetEventKind(event))
- {
- case kEventMenuOpening:
- type = wxEVT_MENU_OPEN;
- break;
- case kEventMenuClosed:
- type = wxEVT_MENU_CLOSE;
- break;
- case kEventMenuTargetItem:
- type = wxEVT_MENU_HIGHLIGHT;
- GetEventParameter(event, kEventParamMenuCommand,
- typeMenuCommand, NULL,
- sizeof(cmd), NULL, &cmd);
- if (cmd == 0) return eventNotHandledErr;
- break;
- default:
- wxFAIL_MSG(wxT("Unexpected menu event kind"));
- break;
- }
-
- wxMenuEvent wxevent(type, cmd);
- wxevent.SetEventObject(win);
-
- (void)win->GetEventHandler()->ProcessEvent(wxevent);
- }
- }
-
- return eventNotHandledErr;
-}
-
-// due to the rather low-level event API of wxWidgets, we cannot use RunApplicationEventLoop
-// but have to use ReceiveNextEvent dealing with events manually, therefore we also have
-// to deal with clicks in the menu bar explicitly
-
-pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
-
-static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- Point point ;
- UInt32 modifiers = 0;
- EventMouseButton button = 0 ;
- UInt32 click = 0 ;
-
- GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
- sizeof( Point ), NULL, &point );
- GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL,
- sizeof( UInt32 ), NULL, &modifiers );
- GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL,
- sizeof( EventMouseButton ), NULL, &button );
- GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL,
- sizeof( UInt32 ), NULL, &click );
-
- if ( button == 0 || GetEventKind( event ) == kEventMouseUp )
- modifiers += btnState ;
-
-
- switch( GetEventKind(event) )
- {
- case kEventMouseDown :
- {
- WindowRef window ;
-
- short windowPart = ::FindWindow(point, &window);
-
- if ( windowPart == inMenuBar )
- {
- MenuSelect( point ) ;
- result = noErr ;
- }
- }
- break ;
- case kEventMouseDragged :
- case kEventMouseUp :
- {
- if ( wxTheApp->s_captureWindow )
- wxMacWindowEventHandler( handler , event , (void*) wxTheApp->s_captureWindow->MacGetTopLevelWindow() ) ;
- }
- break ;
- case kEventMouseMoved :
- {
- wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
- result = noErr ;
- break ;
- }
- break ;
- }
-
- return result ;
-}
-
-static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- HICommand command ;
-
- GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL,
- sizeof( HICommand ), NULL, &command );
-
- MenuCommand id = command.commandID ;
- if ( id == kHICommandPreferences )
- id = wxApp::s_macPreferencesMenuItemId ;
-
- wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
- wxMenu* menu = NULL ;
- wxMenuItem* item = NULL ;
-
- if ( mbar )
- {
- item = mbar->FindItem( id , &menu ) ;
- // it is not 100 % sure that an menu of id 0 is really ours, safety check
- if ( id == 0 && menu != NULL && menu->GetHMenu() != command.menu.menuRef )
- {
- item = NULL ;
- menu = NULL ;
- }
- }
-
- if ( item == NULL || menu == NULL || mbar == NULL )
- return result ;
-
- switch( GetEventKind( event ) )
- {
- case kEventProcessCommand :
- {
- if (item->IsCheckable())
- {
- item->Check( !item->IsChecked() ) ;
- }
-
- menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
- result = noErr ;
- }
- break ;
- case kEventCommandUpdateStatus:
- // eventually trigger an updateui round
- result = noErr ;
- break ;
- default :
- break ;
- }
-
- return result ;
-}
-
-static pascal OSStatus ApplicationEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
- switch ( GetEventKind( event ) )
- {
- case kEventAppActivated :
- {
- if ( wxTheApp )
- wxTheApp->MacResume( true ) ;
- result = noErr ;
- }
- break ;
- case kEventAppDeactivated :
- {
- if ( wxTheApp )
- wxTheApp->MacSuspend( true ) ;
- result = noErr ;
- }
- break ;
- default :
- break ;
- }
- return result ;
-}
-
-pascal OSStatus wxAppEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
- switch( GetEventClass( event ) )
- {
- case kEventClassCommand :
- result = CommandEventHandler( handler , event , data ) ;
- break ;
- case kEventClassApplication :
- result = ApplicationEventHandler( handler , event , data ) ;
- break ;
- case kEventClassMenu :
- result = MenuEventHandler( handler , event , data ) ;
- break ;
- case kEventClassMouse :
- result = MouseEventHandler( handler , event , data ) ;
- break ;
- case kEventClassAppleEvent :
- {
- EventRecord rec ;
- wxMacConvertEventToRecord( event , &rec ) ;
- result = AEProcessAppleEvent( &rec ) ;
- }
- break ;
- default :
- break ;
- }
-
- return result ;
-}
-
-DEFINE_ONE_SHOT_HANDLER_GETTER( wxAppEventHandler )
-
-#endif
-
-#if defined(WXMAKINGDLL_CORE) && !defined(__DARWIN__)
-// we know it's there ;-)
-WXIMPORT char std::__throws_bad_alloc ;
-#endif
-
-bool wxApp::Initialize(int& argc, wxChar **argv)
-{
- int error = 0 ;
-
- // Mac-specific
-
- UMAInitToolbox( 4, sm_isEmbedded ) ;
- SetEventMask( everyEvent ) ;
- UMAShowWatchCursor() ;
-
-#if defined(WXMAKINGDLL_CORE) && defined(__DARWIN__)
- // open shared library resources from here since we don't have
- // __wxinitialize in Mach-O shared libraries
- wxStAppResource::OpenSharedLibraryResource(NULL);
-#endif
-
-#ifndef __DARWIN__
- // test the minimal configuration necessary
-
-# if !TARGET_CARBON
- long theSystem ;
- long theMachine;
-
- if (Gestalt(gestaltMachineType, &theMachine) != noErr)
- {
- error = kMacSTRWrongMachine;
- }
- else if (theMachine < gestaltMacPlus)
- {
- error = kMacSTRWrongMachine;
- }
- else if (Gestalt(gestaltSystemVersion, &theSystem) != noErr )
- {
- error = kMacSTROldSystem ;
- }
- else if ( theSystem < 0x0860 )
- {
- error = kMacSTROldSystem ;
- }
- else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
- {
- error = kMacSTRSmallSize;
- }
-# endif
- /*
- else
- {
- if ( !UMAHasAppearance() )
- {
- error = kMacSTRNoPre8Yet ;
- }
- }
- */
-#endif
-
- // if we encountered any problems so far, give the error code and exit immediately
-
- if ( error )
- {
- wxStAppResource resload ;
- short itemHit;
- Str255 message;
-
- GetIndString(message, 128, error);
- UMAShowArrowCursor() ;
- ParamText("\pFatal Error", message, (ConstStr255Param)"\p", (ConstStr255Param)"\p");
- itemHit = Alert(128, nil);
- return false ;
- }
-
-#ifndef __DARWIN__
-# if __option(profile)
- ProfilerInit( collectDetailed, bestTimeBase , 40000 , 50 ) ;
-# endif
-#endif
-
-#ifndef __DARWIN__
- // now avoid exceptions thrown for new (bad_alloc)
- // FIXME CS for some changes outside wxMac does not compile anymore
-#if 0
- std::__throws_bad_alloc = 0 ;
-#endif
-
-#endif
-
- s_macCursorRgn = ::NewRgn() ;
-
- // Mac OS X passes a process serial number command line argument when
- // the application is launched from the Finder. This argument must be
- // removed from the command line arguments before being handled by the
- // application (otherwise applications would need to handle it)
- if ( argc > 1 )
- {
- static const wxChar *ARG_PSN = _T("-psn_");
- if ( wxStrncmp(argv[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 )
- {
- // remove this argument
- --argc;
- memmove(argv + 1, argv + 2, argc * sizeof(char *));
- }
- }
-
- if ( !wxAppBase::Initialize(argc, argv) )
- return false;
-
-#if wxUSE_INTL
- wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
-#endif
-
-
- wxWinMacWindowList = new wxList(wxKEY_INTEGER);
- wxWinMacControlList = new wxList(wxKEY_INTEGER);
-
- wxMacCreateNotifierTable() ;
-
- UMAShowArrowCursor() ;
-
- return true;
-}
-
-bool wxApp::OnInitGui()
-{
- if( !wxAppBase::OnInitGui() )
- return false ;
-
-#if TARGET_CARBON
- InstallStandardEventHandler( GetApplicationEventTarget() ) ;
-
- if (!sm_isEmbedded)
- {
- InstallApplicationEventHandler(
- GetwxAppEventHandlerUPP(),
- GetEventTypeCount(eventList), eventList, wxTheApp, (EventHandlerRef *)&(wxTheApp->m_macEventHandler));
- }
-#endif
-
- if (!sm_isEmbedded)
- {
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
- AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
- NewAEEventHandlerUPP(AEHandleODoc) ,
- 0 , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
- NewAEEventHandlerUPP(AEHandleOApp) ,
- 0 , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
- NewAEEventHandlerUPP(AEHandlePDoc) ,
- 0 , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEReopenApplication ,
- NewAEEventHandlerUPP(AEHandleRApp) ,
- 0 , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
- NewAEEventHandlerUPP(AEHandleQuit) ,
- 0 , FALSE ) ;
-#else
- AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
- NewAEEventHandlerProc(AEHandleODoc) ,
- 0 , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
- NewAEEventHandlerProc(AEHandleOApp) ,
- 0 , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
- NewAEEventHandlerProc(AEHandlePDoc) ,
- 0 , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEReopenApplication ,
- NewAEEventHandlerProc(AEHandleRApp) ,
- 0 , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
- NewAEEventHandlerProc(AEHandleQuit) ,
- 0 , FALSE ) ;
-#endif
- }
-
- return true ;
-}
-
-void wxApp::CleanUp()
-{
- wxToolTip::RemoveToolTips() ;
-
- // One last chance for pending objects to be cleaned up
- wxTheApp->DeletePendingObjects();
-
- wxMacDestroyNotifierTable() ;
-
- delete wxWinMacWindowList ;
- wxWinMacWindowList = NULL;
-
- delete wxWinMacControlList ;
- wxWinMacControlList = NULL;
-
-#ifndef __DARWIN__
-# if __option(profile)
- ProfilerDump( (StringPtr)"\papp.prof" ) ;
- ProfilerTerm() ;
-# endif
-#endif
-
-#if defined(WXMAKINGDLL_CORE) && defined(__DARWIN__)
- // close shared library resources from here since we don't have
- // __wxterminate in Mach-O shared libraries
- wxStAppResource::CloseSharedLibraryResource();
-#endif
-
- UMACleanupToolbox() ;
- if (s_macCursorRgn) {
- ::DisposeRgn((RgnHandle)s_macCursorRgn);
- }
-
- #if 0
- TerminateAE() ;
- #endif
-
- wxAppBase::CleanUp();
-}
-
-//----------------------------------------------------------------------
-// misc initialization stuff
-//----------------------------------------------------------------------
-
-// extern variable for shared library resource id
-// need to be able to find it with NSLookupAndBindSymbol
-short gSharedLibraryResource = kResFileNotOpened ;
-
-#if defined(WXMAKINGDLL_CORE) && defined(__DARWIN__)
-CFBundleRef gSharedLibraryBundle = NULL;
-#endif /* WXMAKINGDLL_CORE && __DARWIN__ */
-
-wxStAppResource::wxStAppResource()
-{
- m_currentRefNum = CurResFile() ;
- if ( gSharedLibraryResource != kResFileNotOpened )
- {
- UseResFile( gSharedLibraryResource ) ;
- }
-}
-
-wxStAppResource::~wxStAppResource()
-{
- if ( m_currentRefNum != kResFileNotOpened )
- {
- UseResFile( m_currentRefNum ) ;
- }
-}
-
-void wxStAppResource::OpenSharedLibraryResource(const void *initBlock)
-{
- gSharedLibraryResource = kResFileNotOpened;
-
-#ifdef WXMAKINGDLL_CORE
- if ( initBlock != NULL ) {
- const CFragInitBlock *theInitBlock = (const CFragInitBlock *)initBlock;
- FSSpec *fileSpec = NULL;
-
- if (theInitBlock->fragLocator.where == kDataForkCFragLocator) {
- fileSpec = theInitBlock->fragLocator.u.onDisk.fileSpec;
- }
- else if (theInitBlock->fragLocator.where == kResourceCFragLocator) {
- fileSpec = theInitBlock->fragLocator.u.inSegs.fileSpec;
- }
-
- if (fileSpec != NULL) {
- gSharedLibraryResource = FSpOpenResFile(fileSpec, fsRdPerm);
- }
- }
- else {
-#ifdef __DARWIN__
- // Open the shared library resource file if it is not yet open
- NSSymbol theSymbol;
- NSModule theModule;
- const char *theLibPath;
-
- gSharedLibraryBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.wxwindows.wxWidgets"));
- if (gSharedLibraryBundle != NULL) {
- // wxWidgets has been bundled into a framework
- // load the framework resources
-
- gSharedLibraryResource = CFBundleOpenBundleResourceMap(gSharedLibraryBundle);
- }
- else {
- // wxWidgets is a simple dynamic shared library
- // load the resources from the data fork of a separate resource file
- wxString theResPath;
- wxString theName;
- FSRef theResRef;
- OSErr theErr = noErr;
-
- // get the library path
- theSymbol = NSLookupAndBindSymbol("_gSharedLibraryResource");
- theModule = NSModuleForSymbol(theSymbol);
- theLibPath = NSLibraryNameForModule(theModule);
-
- // if we call wxLogDebug from here then, as wxTheApp hasn't been
- // created yet when we're called from wxApp::Initialize(), wxLog
- // is going to create a default stderr-based log target instead of
- // the expected normal GUI one -- don't do it, if we really want
- // to see this message just use fprintf() here
-#if 0
- wxLogDebug( wxT("wxMac library installation name is '%s'"),
- theLibPath );
-#endif
-
- // allocate copy to replace .dylib.* extension with .rsrc
- if (theLibPath != NULL) {
-#if wxUSE_UNICODE
- theResPath = wxString(theLibPath, wxConvLocal);
-#else
- theResPath = wxString(theLibPath);
-#endif
- // replace '_core' with '' in case of multi-lib build
- theResPath.Replace(wxT("_core"), wxEmptyString);
- // replace ".dylib" shared library extension with ".rsrc"
- theResPath.Replace(wxT(".dylib"), wxT(".rsrc"));
- // Find the begining of the filename
- theName = theResPath.AfterLast('/');
-
-#if 0
- wxLogDebug( wxT("wxMac resources file name is '%s'"),
- theResPath.mb_str() );
-#endif
-
- theErr = FSPathMakeRef((UInt8 *) theResPath.mb_str(), &theResRef, false);
- if (theErr != noErr) {
- // try in current directory (using name only)
- theErr = FSPathMakeRef((UInt8 *) theName.mb_str(), &theResRef, false);
- }
-
- // open the resource file
- if (theErr == noErr) {
- theErr = FSOpenResourceFile( &theResRef, 0, NULL, fsRdPerm,
- &gSharedLibraryResource);
- }
- if (theErr != noErr) {
-#ifdef __WXDEBUG__
- wxLogDebug( wxT("unable to open wxMac resource file '%s'\n"),
- theResPath.mb_str() );
-#endif // __WXDEBUG__
- }
-
- }
- }
-#endif /* __DARWIN__ */
- }
-#endif /* WXMAKINGDLL_CORE */
-}
-
-void wxStAppResource::CloseSharedLibraryResource()
-{
-#ifdef WXMAKINGDLL_CORE
- // Close the shared library resource file
- if (gSharedLibraryResource != kResFileNotOpened) {
-#ifdef __DARWIN__
- if (gSharedLibraryBundle != NULL) {
- CFBundleCloseBundleResourceMap(gSharedLibraryBundle,
- gSharedLibraryResource);
- gSharedLibraryBundle = NULL;
- }
- else
-#endif /* __DARWIN__ */
- {
- CloseResFile(gSharedLibraryResource);
- }
- gSharedLibraryResource = kResFileNotOpened;
- }
-#endif /* WXMAKINGDLL_CORE */
-}
-
-#if defined(WXMAKINGDLL_CORE) && !defined(__DARWIN__)
-
-// for shared libraries we have to manually get the correct resource
-// ref num upon initializing and releasing when terminating, therefore
-// the __wxinitialize and __wxterminate must be used
-
-extern "C" {
- void __sinit(void); /* (generated by linker) */
- pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
- pascal void __terminate(void);
-}
-
-pascal OSErr __wxinitialize(const CFragInitBlock *theInitBlock)
-{
- wxStAppResource::OpenSharedLibraryResource( theInitBlock ) ;
- return __initialize( theInitBlock ) ;
-}
-
-pascal void __wxterminate(void)
-{
- wxStAppResource::CloseSharedLibraryResource() ;
- __terminate() ;
-}
-
-#endif /* WXMAKINGDLL_CORE && !__DARWIN__ */
-
-#if TARGET_CARBON
-
-bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec)
-{
- bool converted = ConvertEventRefToEventRecord( event,rec) ;
- OSStatus err = noErr ;
- if ( !converted )
- {
- switch( GetEventClass( event ) )
- {
- case kEventClassKeyboard :
- {
- converted = true ;
- switch( GetEventKind(event) )
- {
- case kEventRawKeyDown :
- rec->what = keyDown ;
- break ;
- case kEventRawKeyRepeat :
- rec->what = autoKey ;
- break ;
- case kEventRawKeyUp :
- rec->what = keyUp ;
- break ;
- case kEventRawKeyModifiersChanged :
- rec->what = nullEvent ;
- break ;
- default :
- converted = false ;
- break ;
- }
- if ( converted )
- {
- UInt32 keyCode ;
- unsigned char charCode ;
- UInt32 modifiers ;
- GetMouse( &rec->where) ;
-
- err = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers);
- err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode);
- err = GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode);
- rec->modifiers = modifiers ;
- rec->message = (keyCode << 8 ) + charCode ;
- }
- }
- break ;
- case kEventClassTextInput :
- {
- switch( GetEventKind( event ) )
- {
- case kEventTextInputUnicodeForKeyEvent :
- {
- EventRef rawEvent ;
- err = GetEventParameter( event , kEventParamTextInputSendKeyboardEvent ,typeEventRef,NULL,sizeof(rawEvent),NULL,&rawEvent ) ;
- converted = true ;
- {
- UInt32 keyCode ;
- unsigned char charCode ;
- UInt32 modifiers ;
- GetMouse( &rec->where) ;
- rec->what = keyDown ;
- err = GetEventParameter(rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, 4, NULL, &modifiers);
- err = GetEventParameter(rawEvent, kEventParamKeyCode, typeUInt32, NULL, 4, NULL, &keyCode);
- err = GetEventParameter(rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode);
- rec->modifiers = modifiers ;
- rec->message = (keyCode << 8 ) + charCode ;
- }
- }
- break ;
- default :
- break ;
- }
- }
- break ;
- }
- }
-
- return converted ;
-}
-
-/*
-pascal OSStatus wxMacApplicationEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- EventRecord rec ;
- switch ( GetEventClass( event ) )
- {
- case kEventClassKeyboard :
- if ( wxMacConvertEventToRecord( event , &rec ) )
- {
- wxTheApp->MacHandleModifierEvents( &rec ) ;
- wxTheApp->MacHandleOneEvent( &rec ) ;
- result = noErr ;
- }
- break ;
- case kEventClassTextInput :
- if ( wxMacConvertEventToRecord( event , &rec ) )
- {
- wxTheApp->MacHandleModifierEvents( &rec ) ;
- wxTheApp->MacHandleOneEvent( &rec ) ;
- result = noErr ;
- }
- break ;
- default :
- break ;
- }
- return result ;
-}
-*/
-#endif
-
-wxApp::wxApp()
-{
- m_printMode = wxPRINT_WINDOWS;
- m_auto3D = true;
-
- m_macCurrentEvent = NULL ;
-#if TARGET_CARBON
- m_macCurrentEventHandlerCallRef = NULL ;
-#endif
-}
-
-int wxApp::MainLoop()
-{
- m_keepGoing = true;
-
- while (m_keepGoing)
- {
- MacDoOneEvent() ;
- }
-
- return 0;
-}
-
-void wxApp::ExitMainLoop()
-{
- m_keepGoing = false;
-}
-
-// Is a message/event pending?
-bool wxApp::Pending()
-{
-#if TARGET_CARBON
- // without the receive event (with pull param = false ) nothing is ever reported
- EventRef theEvent;
- ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &theEvent);
- return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ;
-#else
- EventRecord event ;
-
- return EventAvail( everyEvent , &event ) ;
-#endif
-}
-
-// Dispatch a message.
-bool wxApp::Dispatch()
-{
- MacDoOneEvent() ;
-
- return true;
-}
-
-void wxApp::OnIdle(wxIdleEvent& event)
-{
- wxAppBase::OnIdle(event);
-
- // If they are pending events, we must process them: pending events are
- // either events to the threads other than main or events posted with
- // wxPostEvent() functions
- wxMacProcessNotifierAndPendingEvents();
-
- if(!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar())
- wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
-}
-
-void wxApp::WakeUpIdle()
-{
- wxMacWakeUp() ;
-}
-
-void wxApp::Exit()
-{
- wxApp::CleanUp();
- ::ExitToShell() ;
-}
-
-void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
-{
- if (GetTopWindow())
- GetTopWindow()->Close(true);
-}
-
-// Default behaviour: close the application with prompts. The
-// user can veto the close, and therefore the end session.
-void wxApp::OnQueryEndSession(wxCloseEvent& event)
-{
- if (GetTopWindow())
- {
- if (!GetTopWindow()->Close(!event.CanVeto()))
- event.Veto(true);
- }
-}
-
-extern "C" void wxCYield() ;
-void wxCYield()
-{
- wxYield() ;
-}
-
-// Yield to other processes
-
-bool wxApp::Yield(bool onlyIfNeeded)
-{
- if (s_inYield)
- {
- if ( !onlyIfNeeded )
- {
- wxFAIL_MSG( wxT("wxYield called recursively" ) );
- }
-
- return false;
- }
-
- s_inYield = true;
-
-#if wxUSE_THREADS
- YieldToAnyThread() ;
-#endif
- // by definition yield should handle all non-processed events
-#if TARGET_CARBON
- EventRef theEvent;
-
- OSStatus status = noErr ;
- do
- {
- s_inReceiveEvent = true ;
- status = ReceiveNextEvent(0, NULL,kEventDurationNoWait,true,&theEvent) ;
- s_inReceiveEvent = false ;
-
- if ( status == eventLoopTimedOutErr )
- {
- // make sure next time the event loop will trigger idle events
- sleepTime = kEventDurationNoWait ;
- }
- else if ( status == eventLoopQuitErr )
- {
- // according to QA1061 this may also occur when a WakeUp Process
- // is executed
- }
- else
- {
- MacHandleOneEvent( theEvent ) ;
- ReleaseEvent(theEvent);
- }
- } while( status == noErr ) ;
-#else
- EventRecord event ;
-
- // having a larger value here leads to large performance slowdowns
- // so we cannot give background apps more processor time here
- // we do so however having a large sleep value in the main event loop
- sleepTime = 0 ;
-
- while ( !IsExiting() && WaitNextEvent(everyEvent, &event,sleepTime, (RgnHandle) wxApp::s_macCursorRgn))
- {
- MacHandleModifierEvents( &event ) ;
- MacHandleOneEvent( &event );
- if ( event.what != kHighLevelEvent )
- SetRectRgn( (RgnHandle) wxApp::s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ;
- }
- MacHandleModifierEvents( &event ) ;
-#endif
-
- wxMacProcessNotifierAndPendingEvents() ;
- s_inYield = false;
-
- return true;
-}
-
-// platform specifics
-
-void wxApp::MacSuspend( bool convertClipboard )
-{
-#if !TARGET_CARBON
- // we have to deactive the top level windows manually
-
- wxWindowListNode* node = wxTopLevelWindows.GetFirst();
- while (node)
- {
- wxTopLevelWindow* win = (wxTopLevelWindow*) node->Data();
-#if TARGET_CARBON
-#if 0 // having problems right now with that
- if (!win->HasFlag(wxSTAY_ON_TOP))
-#endif
-#endif
- win->MacActivate( ((EventRecord*) MacGetCurrentEvent())->when , false ) ;
-
- node = node->GetNext();
- }
-
- ::HideFloatingWindows() ;
-#endif
- s_lastMouseDown = 0 ;
-
- if( convertClipboard )
- {
- MacConvertPrivateToPublicScrap() ;
- }
-}
-
-extern wxList wxModalDialogs;
-
-void wxApp::MacResume( bool convertClipboard )
-{
- s_lastMouseDown = 0 ;
- if( convertClipboard )
- {
- MacConvertPublicToPrivateScrap() ;
- }
-
-#if !TARGET_CARBON
- ::ShowFloatingWindows() ;
- // raise modal dialogs in case a non modal window was selected to activate the app
-
- wxNode* node = wxModalDialogs.GetFirst();
- while (node)
- {
- wxDialog* dialog = (wxDialog *) node->GetData();
- dialog->Raise();
-
- node = node->GetNext();
- }
-#endif
-}
-
-void wxApp::MacConvertPrivateToPublicScrap()
-{
-}
-
-void wxApp::MacConvertPublicToPrivateScrap()
-{
-}
-
-void wxApp::MacDoOneEvent()
-{
-#if TARGET_CARBON
- EventRef theEvent;
-
- s_inReceiveEvent = true ;
- OSStatus status = ReceiveNextEvent(0, NULL,sleepTime,true,&theEvent) ;
- s_inReceiveEvent = false ;
- if ( status == eventLoopTimedOutErr )
- {
- if ( wxTheApp->ProcessIdle() )
- sleepTime = kEventDurationNoWait ;
- else
- {
-#if wxUSE_THREADS
- if (g_numberOfThreads)
- {
- sleepTime = kEventDurationNoWait;
- }
- else
-#endif // wxUSE_THREADS
- {
- sleepTime = kEventDurationSecond;
- }
- }
- }
- else if ( status == eventLoopQuitErr )
- {
- // according to QA1061 this may also occur when a WakeUp Process
- // is executed
- }
- else
- {
- MacHandleOneEvent( theEvent ) ;
- ReleaseEvent(theEvent);
- sleepTime = kEventDurationNoWait ;
- }
-#else
- EventRecord event ;
-
- EventMask eventMask = everyEvent ;
-
- if (WaitNextEvent(eventMask, &event, sleepTime, (RgnHandle) s_macCursorRgn))
- {
- MacHandleModifierEvents( &event ) ;
- MacHandleOneEvent( &event );
- }
- else
- {
- MacHandleModifierEvents( &event ) ;
- // idlers
- WindowPtr window = ::FrontWindow() ;
- if ( window )
- ::IdleControls( window ) ;
-
- if ( wxTheApp->ProcessIdle() )
- sleepTime = kEventDurationNoWait;
- else
- {
-#if wxUSE_THREADS
- if (g_numberOfThreads)
- {
- sleepTime = kEventDurationNoWait;
- }
- else
-#endif // wxUSE_THREADS
- {
- sleepTime = kEventDurationSecond;
- }
- }
- }
- if ( event.what != kHighLevelEvent )
- SetRectRgn( (RgnHandle) s_macCursorRgn , event.where.h , event.where.v , event.where.h + 1 , event.where.v + 1 ) ;
-#endif
- // repeaters
-
- DeletePendingObjects() ;
- wxMacProcessNotifierAndPendingEvents() ;
-}
-
-/*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr )
-{
- // Override to process unhandled events as you please
-}
-
-void wxApp::MacHandleOneEvent( WXEVENTREF evr )
-{
-#if TARGET_CARBON
- EventTargetRef theTarget;
- theTarget = GetEventDispatcherTarget();
- m_macCurrentEvent = evr ;
- OSStatus status = SendEventToEventTarget ((EventRef) evr , theTarget);
- if(status == eventNotHandledErr)
- {
- MacHandleUnhandledEvent(evr);
- }
-#else
- EventRecord* ev = (EventRecord*) evr ;
- m_macCurrentEvent = ev ;
-
- wxApp::sm_lastMessageTime = ev->when ;
-
- switch (ev->what)
- {
- case mouseDown:
- MacHandleMouseDownEvent( ev ) ;
- if ( ev->modifiers & controlKey )
- s_lastMouseDown = 2;
- else
- s_lastMouseDown = 1;
- break;
- case mouseUp:
- if ( s_lastMouseDown == 2 )
- {
- ev->modifiers |= controlKey ;
- }
- else
- {
- ev->modifiers &= ~controlKey ;
- }
- MacHandleMouseUpEvent( ev ) ;
- s_lastMouseDown = 0;
- break;
- case activateEvt:
- MacHandleActivateEvent( ev ) ;
- break;
- case updateEvt:
- // In embedded mode we first let the UnhandledEvent function
- // try to handle the update event. If we handle it ourselves
- // first and then pass it on, the host's windows won't update.
- MacHandleUnhandledEvent(ev);
- MacHandleUpdateEvent( ev ) ;
- break;
- case keyDown:
- case autoKey:
- MacHandleKeyDownEvent( ev ) ;
- break;
- case keyUp:
- MacHandleKeyUpEvent( ev ) ;
- break;
- case diskEvt:
- MacHandleDiskEvent( ev ) ;
- break;
- case osEvt:
- MacHandleOSEvent( ev ) ;
- break;
- case kHighLevelEvent:
- MacHandleHighLevelEvent( ev ) ;
- break;
- default:
- break;
- }
-#endif
- wxMacProcessNotifierAndPendingEvents() ;
-}
-
-#if !TARGET_CARBON
-bool s_macIsInModalLoop = false ;
-
-void wxApp::MacHandleModifierEvents( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- if ( ev->modifiers != s_lastModifiers && wxWindow::FindFocus() != NULL )
- {
- wxKeyEvent event(wxEVT_KEY_DOWN);
-
- event.m_shiftDown = ev->modifiers & shiftKey;
- event.m_controlDown = ev->modifiers & controlKey;
- event.m_altDown = ev->modifiers & optionKey;
- event.m_metaDown = ev->modifiers & cmdKey;
-
- event.m_x = ev->where.h;
- event.m_y = ev->where.v;
- event.SetTimestamp( ev->when );
- wxWindow* focus = wxWindow::FindFocus() ;
- event.SetEventObject(focus);
-
- if ( (ev->modifiers ^ s_lastModifiers ) & controlKey )
- {
- event.m_keyCode = WXK_CONTROL ;
- event.SetEventType( ( ev->modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( (ev->modifiers ^ s_lastModifiers ) & shiftKey )
- {
- event.m_keyCode = WXK_SHIFT ;
- event.SetEventType( ( ev->modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( (ev->modifiers ^ s_lastModifiers ) & optionKey )
- {
- event.m_keyCode = WXK_ALT ;
- event.SetEventType( ( ev->modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( ( ev->modifiers ^ s_lastModifiers ) & cmdKey )
- {
- event.m_keyCode = WXK_COMMAND ;
- event.SetEventType( ( ev->modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- s_lastModifiers = ev->modifiers ;
- }
-}
-
-void wxApp::MacHandleHighLevelEvent( WXEVENTREF evr )
-{
- // we must avoid reentrancy problems when processing high level events eg printing
- bool former = s_inYield ;
- s_inYield = true ;
- EventRecord* ev = (EventRecord*) evr ;
- ::AEProcessAppleEvent( ev ) ;
- s_inYield = former ;
-}
-
-void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- wxToolTip::RemoveToolTips() ;
-
- WindowRef window;
- WindowRef frontWindow = ::FrontNonFloatingWindow() ;
- WindowAttributes frontWindowAttributes = NULL ;
- if ( frontWindow )
- ::GetWindowAttributes( frontWindow , &frontWindowAttributes ) ;
-
- short windowPart = ::FindWindow(ev->where, &window);
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( (WXWindow) window ) ;
- if ( wxPendingDelete.Member(win) )
- return ;
-
- BitMap screenBits;
- GetQDGlobalsScreenBits( &screenBits );
-
- switch (windowPart)
- {
- case inMenuBar :
- if ( s_macIsInModalLoop )
- {
- SysBeep ( 30 ) ;
- }
- else
- {
- UInt32 menuresult = MenuSelect(ev->where) ;
- MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) );
- s_lastMouseDown = 0;
- }
- break ;
- case inSysWindow :
- SystemClick( ev , window ) ;
- s_lastMouseDown = 0;
- break ;
- case inDrag :
- if ( window != frontWindow && s_macIsInModalLoop && !(ev->modifiers & cmdKey ) )
- {
- SysBeep ( 30 ) ;
- }
- else
- {
- DragWindow(window, ev->where, &screenBits.bounds);
- if (win)
- {
- GrafPtr port ;
- GetPort( &port ) ;
- Point pt = { 0, 0 } ;
- SetPortWindowPort(window) ;
- LocalToGlobal( &pt ) ;
- SetPort( port ) ;
- win->SetSize( pt.h , pt.v , -1 ,
- -1 , wxSIZE_USE_EXISTING);
- }
- s_lastMouseDown = 0;
- }
- break ;
- case inGoAway:
- if (TrackGoAway(window, ev->where))
- {
- if ( win )
- win->Close() ;
- }
- s_lastMouseDown = 0;
- break;
- case inGrow:
- {
- Rect newContentRect ;
- Rect constraintRect ;
- constraintRect.top = win->GetMinHeight() ;
- if ( constraintRect.top == -1 )
- constraintRect.top = 0 ;
- constraintRect.left = win->GetMinWidth() ;
- if ( constraintRect.left == -1 )
- constraintRect.left = 0 ;
- constraintRect.right = win->GetMaxWidth() ;
- if ( constraintRect.right == -1 )
- constraintRect.right = 32000 ;
- constraintRect.bottom = win->GetMaxHeight() ;
- if ( constraintRect.bottom == -1 )
- constraintRect.bottom = 32000 ;
-
- Boolean growResult = ResizeWindow( window , ev->where ,
- &constraintRect , &newContentRect ) ;
- if ( growResult )
- {
- win->SetSize( newContentRect.left , newContentRect.top ,
- newContentRect.right - newContentRect.left ,
- newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING);
- }
- s_lastMouseDown = 0;
- }
- break;
- case inZoomIn:
- case inZoomOut:
- if (TrackBox(window, ev->where, windowPart))
- {
- // TODO setup size event
- ZoomWindow( window , windowPart , false ) ;
- if (win)
- {
- Rect tempRect ;
- GrafPtr port ;
- GetPort( &port ) ;
- Point pt = { 0, 0 } ;
- SetPortWindowPort(window) ;
- LocalToGlobal( &pt ) ;
- SetPort( port ) ;
-
- GetWindowPortBounds(window, &tempRect ) ;
- win->SetSize( pt.h , pt.v , tempRect.right-tempRect.left ,
- tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
- }
- }
- s_lastMouseDown = 0;
- break;
- case inCollapseBox :
- // TODO setup size event
- s_lastMouseDown = 0;
- break ;
-
- case inContent :
- {
- GrafPtr port ;
- GetPort( &port ) ;
- SetPortWindowPort(window) ;
- SetPort( port ) ;
- }
- if ( window != frontWindow && wxTheApp->s_captureWindow == NULL )
- {
- if ( s_macIsInModalLoop )
- {
- SysBeep ( 30 ) ;
- }
- else if ( UMAIsWindowFloating( window ) )
- {
- if ( win )
- win->MacMouseDown( ev , windowPart ) ;
- }
- else
- {
- // Activate window first
- ::SelectWindow( window ) ;
-
- // Send event later
- if ( win )
- win->MacMouseDown( ev , windowPart ) ;
- }
- }
- else
- {
- if ( win )
- win->MacMouseDown( ev , windowPart ) ;
- }
- break ;
- default:
- break;
- }
-}
-
-void wxApp::MacHandleMouseUpEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- WindowRef window;
-
- short windowPart = inNoWindow ;
- if ( wxTheApp->s_captureWindow )
- {
- window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
- windowPart = inContent ;
- }
- else
- {
- windowPart = ::FindWindow(ev->where, &window) ;
- }
-
- switch (windowPart)
- {
- case inMenuBar :
- break ;
- case inSysWindow :
- break ;
- default:
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( (WXWindow) window ) ;
- if ( win )
- win->MacMouseUp( ev , windowPart ) ;
- }
- break;
- }
-}
-
-#endif
-
-long wxMacTranslateKey(unsigned char key, unsigned char code) ;
-long wxMacTranslateKey(unsigned char key, unsigned char code)
-{
- long retval = key ;
- switch (key)
- {
- case kHomeCharCode :
- retval = WXK_HOME;
- break;
- case kEnterCharCode :
- retval = WXK_RETURN;
- break;
- case kEndCharCode :
- retval = WXK_END;
- break;
- case kHelpCharCode :
- retval = WXK_HELP;
- break;
- case kBackspaceCharCode :
- retval = WXK_BACK;
- break;
- case kTabCharCode :
- retval = WXK_TAB;
- break;
- case kPageUpCharCode :
- retval = WXK_PAGEUP;
- break;
- case kPageDownCharCode :
- retval = WXK_PAGEDOWN;
- break;
- case kReturnCharCode :
- retval = WXK_RETURN;
- break;
- case kFunctionKeyCharCode :
- {
- switch( code )
- {
- case 0x7a :
- retval = WXK_F1 ;
- break;
- case 0x78 :
- retval = WXK_F2 ;
- break;
- case 0x63 :
- retval = WXK_F3 ;
- break;
- case 0x76 :
- retval = WXK_F4 ;
- break;
- case 0x60 :
- retval = WXK_F5 ;
- break;
- case 0x61 :
- retval = WXK_F6 ;
- break;
- case 0x62:
- retval = WXK_F7 ;
- break;
- case 0x64 :
- retval = WXK_F8 ;
- break;
- case 0x65 :
- retval = WXK_F9 ;
- break;
- case 0x6D :
- retval = WXK_F10 ;
- break;
- case 0x67 :
- retval = WXK_F11 ;
- break;
- case 0x6F :
- retval = WXK_F12 ;
- break;
- case 0x69 :
- retval = WXK_F13 ;
- break;
- case 0x6B :
- retval = WXK_F14 ;
- break;
- case 0x71 :
- retval = WXK_F15 ;
- break;
- }
- }
- break ;
- case kEscapeCharCode :
- retval = WXK_ESCAPE ;
- break ;
- case kLeftArrowCharCode :
- retval = WXK_LEFT ;
- break ;
- case kRightArrowCharCode :
- retval = WXK_RIGHT ;
- break ;
- case kUpArrowCharCode :
- retval = WXK_UP ;
- break ;
- case kDownArrowCharCode :
- retval = WXK_DOWN ;
- break ;
- case kDeleteCharCode :
- retval = WXK_DELETE ;
- default:
- break ;
- } // end switch
-
- return retval;
-}
-
-int wxKeyCodeToMacModifier(wxKeyCode key)
-{
- switch (key)
- {
- case WXK_START:
- case WXK_MENU:
- return cmdKey;
-
- case WXK_SHIFT:
- return shiftKey;
-
- case WXK_CAPITAL:
- return alphaLock;
-
- case WXK_ALT:
- return optionKey;
-
- case WXK_CONTROL:
- return controlKey;
-
- default:
- return 0;
- }
-}
-
-bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below
-{
- wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
- WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
-
- KeyMap keymap;
- GetKeys(keymap);
- return !!(BitTst(keymap, (sizeof(KeyMap)*8) - key));
-}
-
-#if !TARGET_CARBON
-void wxApp::MacHandleKeyDownEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- wxToolTip::RemoveToolTips() ;
-
- UInt32 menuresult = UMAMenuEvent(ev) ;
- if ( HiWord( menuresult ) )
- {
- if ( !s_macIsInModalLoop )
- MacHandleMenuSelect( HiWord( menuresult ) , LoWord( menuresult ) ) ;
- }
- else
- {
- wxWindow* focus = wxWindow::FindFocus() ;
-
- if ( MacSendKeyDownEvent( focus , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
- {
-#if 0
- // we must handle control keys the other way round, otherwise text content is updated too late
- // has not been handled -> perform default
- wxControl* control = wxDynamicCast( focus , wxControl ) ;
- if ( control && control->GetMacControl() != NULL )
- {
- short keycode ;
- short keychar ;
- keychar = short(ev->message & charCodeMask);
- keycode = short(ev->message & keyCodeMask) >> 8 ;
- ::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
- }
-#endif
- }
- }
-}
-
-void wxApp::MacHandleKeyUpEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- wxToolTip::RemoveToolTips() ;
-
- UInt32 menuresult = UMAMenuEvent(ev) ;
- if ( HiWord( menuresult ) )
- {
- }
- else
- {
- MacSendKeyUpEvent( wxWindow::FindFocus() , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) ;
- }
-}
-
-#endif
-
-bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey )
-{
- if ( !focus )
- return false ;
-
- short keycode ;
- short keychar ;
- keychar = short(keymessage & charCodeMask);
- keycode = short(keymessage & keyCodeMask) >> 8 ;
-
- if ( modifiers & ( controlKey|shiftKey|optionKey ) )
- {
- // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier
- // and look at the character after
- UInt32 state = 0;
- UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state);
- keychar = short(keyInfo & charCodeMask);
- keycode = short(keyInfo & keyCodeMask) >> 8 ;
- }
- long keyval = wxMacTranslateKey(keychar, keycode) ;
- long realkeyval = keyval ;
- if ( keyval == keychar )
- {
- // we are not on a special character combo -> pass the real os event-value to EVT_CHAR, but not to EVT_KEY (make upper first)
- realkeyval = short(keymessage & charCodeMask) ;
- keyval = wxToupper( keyval ) ;
- }
-
- wxKeyEvent event(wxEVT_KEY_DOWN);
- bool handled = false ;
- event.m_shiftDown = modifiers & shiftKey;
- event.m_controlDown = modifiers & controlKey;
- event.m_altDown = modifiers & optionKey;
- event.m_metaDown = modifiers & cmdKey;
- event.m_keyCode = keyval ;
-
- event.m_x = wherex;
- event.m_y = wherey;
- event.SetTimestamp(when);
- event.SetEventObject(focus);
- handled = focus->GetEventHandler()->ProcessEvent( event ) ;
- if ( handled && event.GetSkipped() )
- handled = false ;
- if ( !handled )
- {
-#if wxUSE_ACCEL
- if (!handled)
- {
- wxWindow *ancestor = focus;
- while (ancestor)
- {
- int command = ancestor->GetAcceleratorTable()->GetCommand( event );
- if (command != -1)
- {
- wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
- handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
- break;
- }
- if (ancestor->IsTopLevel())
- break;
- ancestor = ancestor->GetParent();
- }
- }
-#endif // wxUSE_ACCEL
- }
- if (!handled)
- {
- event.Skip( false ) ;
- event.SetEventType( wxEVT_CHAR ) ;
- // raw value again
- event.m_keyCode = realkeyval ;
-
- handled = focus->GetEventHandler()->ProcessEvent( event ) ;
- if ( handled && event.GetSkipped() )
- handled = false ;
- }
- if ( !handled &&
- (keyval == WXK_TAB) &&
-// CS: copied the change below from wxGTK
-// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here the control may
-// have this style, yet choose not to process this particular TAB in which
-// case TAB must still work as a navigational character
-#if 0
- (!focus->HasFlag(wxTE_PROCESS_TAB)) &&
-#endif
- (focus->GetParent()) &&
- (focus->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
- {
- wxNavigationKeyEvent new_event;
- new_event.SetEventObject( focus );
- new_event.SetDirection( !event.ShiftDown() );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
- new_event.SetWindowChange( event.ControlDown() );
- new_event.SetCurrentFocus( focus );
- handled = focus->GetEventHandler()->ProcessEvent( new_event );
- if ( handled && new_event.GetSkipped() )
- handled = false ;
- }
- // backdoor handler for default return and command escape
- if ( !handled && (!focus->IsKindOf(CLASSINFO(wxControl) ) || !focus->MacCanFocus() ) )
- {
- // if window is not having a focus still testing for default enter or cancel
- // TODO add the UMA version for ActiveNonFloatingWindow
- wxWindow* focus = wxFindWinFromMacWindow( (WXWindow) FrontWindow() ) ;
- if ( focus )
- {
- if ( keyval == WXK_RETURN )
- {
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
- if ( tlw && tlw->GetDefaultItem() )
- {
- wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
- if ( def && def->IsEnabled() )
- {
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
- event.SetEventObject(def);
- def->Command(event);
- return true ;
- }
- }
- }
- /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
- else if (keyval == WXK_ESCAPE || (keyval == '.' && modifiers & cmdKey ) )
- {
- wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
- new_event.SetEventObject( focus );
- handled = focus->GetEventHandler()->ProcessEvent( new_event );
- }
- }
- }
- return handled ;
-}
-
-bool wxApp::MacSendKeyUpEvent( wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey )
-{
- if ( !focus )
- return false ;
-
- short keycode ;
- short keychar ;
- keychar = short(keymessage & charCodeMask);
- keycode = short(keymessage & keyCodeMask) >> 8 ;
- if ( modifiers & ( controlKey|shiftKey|optionKey ) )
- {
- // control interferes with some built-in keys like pgdown, return etc. therefore we remove the controlKey modifier
- // and look at the character after
- UInt32 state = 0;
- UInt32 keyInfo = KeyTranslate((Ptr)GetScriptManagerVariable(smKCHRCache), ( modifiers & (~(controlKey|shiftKey|optionKey))) | keycode, &state);
- keychar = short(keyInfo & charCodeMask);
- keycode = short(keyInfo & keyCodeMask) >> 8 ;
- }
- long keyval = wxMacTranslateKey(keychar, keycode) ;
-
- if ( keyval == keychar )
- {
- keyval = wxToupper( keyval ) ;
- }
- bool handled = false ;
-
- wxKeyEvent event(wxEVT_KEY_UP);
- event.m_shiftDown = modifiers & shiftKey;
- event.m_controlDown = modifiers & controlKey;
- event.m_altDown = modifiers & optionKey;
- event.m_metaDown = modifiers & cmdKey;
- event.m_keyCode = keyval ;
-
- event.m_x = wherex;
- event.m_y = wherey;
- event.SetTimestamp(when);
- event.SetEventObject(focus);
- handled = focus->GetEventHandler()->ProcessEvent( event ) ;
-
- return handled ;
-}
-
-#if !TARGET_CARBON
-void wxApp::MacHandleActivateEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- WindowRef window = (WindowRef) ev->message ;
- if ( window )
- {
- bool activate = (ev->modifiers & activeFlag ) ;
- WindowClass wclass ;
- ::GetWindowClass ( window , &wclass ) ;
- if ( wclass == kFloatingWindowClass )
- {
- // if it is a floater we activate/deactivate the front non-floating window instead
- window = ::FrontNonFloatingWindow() ;
- }
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( (WXWindow) window ) ;
- if ( win )
- win->MacActivate( ev->when , activate ) ;
- }
-}
-
-void wxApp::MacHandleUpdateEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- WindowRef window = (WindowRef) ev->message ;
- wxTopLevelWindowMac * win = wxFindWinFromMacWindow( (WXWindow) window ) ;
- if ( win )
- {
- if ( !wxPendingDelete.Member(win) )
- win->MacUpdate( ev->when ) ;
- }
- else
- {
- // since there is no way of telling this foreign window to update itself
- // we have to invalidate the update region otherwise we keep getting the same
- // event over and over again
- BeginUpdate( window ) ;
- EndUpdate( window ) ;
- }
-}
-
-void wxApp::MacHandleDiskEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- if ( HiWord( ev->message ) != noErr )
- {
- OSErr err ;
- Point point ;
- SetPt( &point , 100 , 100 ) ;
-
- err = DIBadMount( point , ev->message ) ;
- wxASSERT( err == noErr ) ;
- }
-}
-
-void wxApp::MacHandleOSEvent( WXEVENTREF evr )
-{
- EventRecord* ev = (EventRecord*) evr ;
- switch( ( ev->message & osEvtMessageMask ) >> 24 )
- {
- case suspendResumeMessage :
- {
- bool isResuming = ev->message & resumeFlag ;
- bool convertClipboard = ev->message & convertClipboardFlag ;
-
- bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
- if ( isResuming )
- {
- WindowRef oldFrontWindow = NULL ;
- WindowRef newFrontWindow = NULL ;
-
- // in case we don't take care of activating ourselves, we have to synchronize
- // our idea of the active window with the process manager's - which it already activated
-
- if ( !doesActivate )
- oldFrontWindow = ::FrontNonFloatingWindow() ;
-
- MacResume( convertClipboard ) ;
-
- newFrontWindow = ::FrontNonFloatingWindow() ;
-
- if ( oldFrontWindow )
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( (WXWindow) oldFrontWindow ) ;
- if ( win )
- win->MacActivate( ev->when , false ) ;
- }
- if ( newFrontWindow )
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( (WXWindow) newFrontWindow ) ;
- if ( win )
- win->MacActivate( ev->when , true ) ;
- }
- }
- else
- {
- MacSuspend( convertClipboard ) ;
- }
- }
- break ;
- case mouseMovedMessage :
- {
- WindowRef window;
-
- wxWindow* currentMouseWindow = NULL ;
-
- if (s_captureWindow )
- {
- currentMouseWindow = s_captureWindow ;
- }
- else
- {
- wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) ,
- ¤tMouseWindow ) ;
- }
-
- if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
- {
- wxMouseEvent event ;
-
- bool isDown = !(ev->modifiers & btnState) ; // 1 is for up
- bool controlDown = ev->modifiers & controlKey ; // for simulating right mouse
-
- event.m_leftDown = isDown && !controlDown;
- event.m_middleDown = false;
- event.m_rightDown = isDown && controlDown;
- event.m_shiftDown = ev->modifiers & shiftKey;
- event.m_controlDown = ev->modifiers & controlKey;
- event.m_altDown = ev->modifiers & optionKey;
- event.m_metaDown = ev->modifiers & cmdKey;
- event.m_x = ev->where.h;
- event.m_y = ev->where.v;
- event.SetTimestamp( ev->when );
- event.SetEventObject(this);
-
- if ( wxWindow::s_lastMouseWindow )
- {
- wxMouseEvent eventleave(event);
- eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
- wxWindow::s_lastMouseWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
- eventleave.SetEventObject( wxWindow::s_lastMouseWindow ) ;
-
- wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
- }
- if ( currentMouseWindow )
- {
- wxMouseEvent evententer(event);
- evententer.SetEventType( wxEVT_ENTER_WINDOW );
- currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
- evententer.SetEventObject( currentMouseWindow ) ;
- currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
- }
- wxWindow::s_lastMouseWindow = currentMouseWindow ;
- }
-
- short windowPart = inNoWindow ;
-
- if ( s_captureWindow )
- {
- window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
- windowPart = inContent ;
- }
- else
- {
- windowPart = ::FindWindow(ev->where, &window);
- }
-
- switch (windowPart)
- {
- case inContent :
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( (WXWindow) window ) ;
- if ( win )
- win->MacMouseMoved( ev , windowPart ) ;
- else
- {
- if ( wxIsBusy() )
- {
- }
- else
- UMAShowArrowCursor();
- }
- }
- break;
- default :
- {
- if ( wxIsBusy() )
- {
- }
- else
- UMAShowArrowCursor();
- }
- break ;
- }
- }
- break ;
-
- }
-}
-#else
-
-void wxApp::MacHandleMouseMovedEvent(wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp)
-{
- WindowRef window;
-
- wxWindow* currentMouseWindow = NULL ;
-
- if (s_captureWindow )
- {
- currentMouseWindow = s_captureWindow ;
- }
- else
- {
- wxWindow::MacGetWindowFromPoint( wxPoint( x, y ) , ¤tMouseWindow ) ;
- }
-
- if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
- {
- wxMouseEvent event ;
-
- bool isDown = !(modifiers & btnState) ; // 1 is for up
- bool controlDown = modifiers & controlKey ; // for simulating right mouse
-
- event.m_leftDown = isDown && !controlDown;
-
- event.m_middleDown = false;
- event.m_rightDown = isDown && controlDown;
-
- event.m_shiftDown = modifiers & shiftKey;
- event.m_controlDown = modifiers & controlKey;
- event.m_altDown = modifiers & optionKey;
- event.m_metaDown = modifiers & cmdKey;
-
- event.m_x = x;
- event.m_y = y;
- event.SetTimestamp(timestamp);
-
- if ( wxWindow::s_lastMouseWindow )
- {
- wxMouseEvent eventleave(event);
- eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
- wxWindow::s_lastMouseWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
- eventleave.SetEventObject( wxWindow::s_lastMouseWindow ) ;
-
-#if wxUSE_TOOLTIPS
- wxToolTip::RelayEvent( wxWindow::s_lastMouseWindow , eventleave);
-#endif // wxUSE_TOOLTIPS
- wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
- }
- if ( currentMouseWindow )
- {
- wxMouseEvent evententer(event);
- evententer.SetEventType( wxEVT_ENTER_WINDOW );
- currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
- evententer.SetEventObject( currentMouseWindow ) ;
-#if wxUSE_TOOLTIPS
- wxToolTip::RelayEvent( currentMouseWindow , evententer);
-#endif // wxUSE_TOOLTIPS
- currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
- }
- wxWindow::s_lastMouseWindow = currentMouseWindow ;
- }
-
- short windowPart = inNoWindow ;
-
- if ( s_captureWindow )
- {
- window = (WindowRef) s_captureWindow->MacGetRootWindow() ;
- windowPart = inContent ;
- }
- else
- {
- Point pt= { y , x } ;
- windowPart = ::FindWindow(pt , &window);
- }
-
- switch (windowPart)
- {
- case inContent :
- {
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ;
- if ( win )
- win->MacFireMouseEvent( nullEvent , x , y , modifiers , timestamp ) ;
- else
- {
- if ( wxIsBusy() )
- {
- }
- else
- UMAShowArrowCursor();
- }
- }
- break;
- default :
- {
- if ( wxIsBusy() )
- {
- }
- else
- UMAShowArrowCursor();
- }
- break ;
- }
-}
-#endif
-
-void wxApp::MacHandleMenuCommand( wxUint32 id )
-{
- wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
- wxFrame* frame = mbar->GetFrame();
- wxCHECK_RET( mbar != NULL && frame != NULL, wxT("error in menu item callback") );
- if ( frame )
- {
- frame->ProcessCommand(id);
- }
-}
-
-#if !TARGET_CARBON
-void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
-{
- if (macMenuId == 0)
- return; // no menu item selected
-
- if (macMenuId == kwxMacAppleMenuId && macMenuItemNum > 1)
- {
- #if ! TARGET_CARBON
- Str255 deskAccessoryName ;
- GrafPtr savedPort ;
-
- GetMenuItemText(GetMenuHandle(kwxMacAppleMenuId), macMenuItemNum, deskAccessoryName);
- GetPort(&savedPort);
- OpenDeskAcc(deskAccessoryName);
- SetPort(savedPort);
- #endif
- }
- else
- {
- MenuCommand id ;
- GetMenuItemCommandID( GetMenuHandle(macMenuId) , macMenuItemNum , &id ) ;
- MacHandleMenuCommand( id ) ;
- }
- HiliteMenu(0);
-}
-#endif
+++ /dev/null
-#define kMacSTRWrongMachine 1
-#define kMacSTRSmallSize 2
-#define kMacSTRNoMemory 3
-#define kMacSTROldSystem 4
-#define kMacSTRGenericAbout 5
-#define kMacSTRNoPre8Yet 6
+++ /dev/null
-#ifdef __UNIX__
-# include <Carbon.r>
-#else
-# include <Types.r>
-#endif
-#include "apprsrc.h"
-
-resource 'STR#' ( 128 , "Simple Alert Messages" )
-{
- {
- "This application needs at least a MacPlus" ,
- "This application needs more memory" ,
- "This application is out of memory" ,
- "This application needs at least System 8.6" ,
- "About this wxWindows Application" ,
- "This application needs Appearance extension (built in with System 8) - this restriction will be relieved in the final release"
- }
-} ;
-
-resource 'MENU' (1, preload)
-{
- 1, textMenuProc, 0b11111111111111111111111111111110 , enabled, apple ,
- {
- "AboutÉ" , noicon, nokey,nomark,plain ,
- "-" , noicon, nokey,nomark,plain
- }
-} ;
-
-resource 'MBAR' (1,preload)
-{
- { 1 } ;
-} ;
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/bitmap.cpp
-// Purpose: wxBitmap
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/bitmap.h"
-
-#ifndef WX_PRECOMP
- #include "wx/log.h"
- #include "wx/icon.h"
- #include "wx/image.h"
-#endif
-
-#include "wx/xpmdecod.h"
-
-#include "wx/rawbmp.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
-IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject )
-
-#ifdef __DARWIN__
- #include <ApplicationServices/ApplicationServices.h>
-#else
- #include <PictUtils.h>
-#endif
-
-#include "wx/mac/uma.h"
-
-CTabHandle wxMacCreateColorTable( int numColors )
-{
- CTabHandle newColors; /* Handle to the new color table */
-
- /* Allocate memory for the color table */
- newColors = (CTabHandle)NewHandleClear( sizeof (ColorTable) +
- sizeof (ColorSpec) * (numColors - 1) );
- if (newColors != nil)
- {
- /* Initialize the fields */
- (**newColors).ctSeed = GetCTSeed();
- (**newColors).ctFlags = 0;
- (**newColors).ctSize = numColors - 1;
- /* Initialize the table of colors */
- }
- return newColors ;
-}
-
-void wxMacDestroyColorTable( CTabHandle colors )
-{
- DisposeHandle( (Handle) colors ) ;
-}
-
-void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue )
-{
- (**newColors).ctTable[index].value = index;
- (**newColors).ctTable[index].rgb.red = red ; // someRedValue;
- (**newColors).ctTable[index].rgb.green = green ; // someGreenValue;
- (**newColors).ctTable[index].rgb.blue = blue ; // someBlueValue;
-}
-
-GWorldPtr wxMacCreateGWorld( int width , int height , int depth )
-{
- OSErr err = noErr ;
- GWorldPtr port ;
- Rect rect = { 0 , 0 , height , width } ;
-
- if ( depth < 0 )
- {
- depth = wxDisplayDepth() ;
- }
-
- err = NewGWorld( &port , depth , &rect , NULL , NULL , 0 ) ;
- if ( err == noErr )
- {
- return port ;
- }
- return NULL ;
-}
-
-void wxMacDestroyGWorld( GWorldPtr gw )
-{
- if ( gw )
- DisposeGWorld( gw ) ;
-}
-
-#define kDefaultRes 0x00480000 /* Default resolution is 72 DPI; Fixed type */
-
-OSErr SetupCIconHandlePixMap( CIconHandle icon , short depth , Rect *bounds , CTabHandle colors )
-{
- CTabHandle newColors; /* Color table used for the off-screen PixMap */
- Ptr offBaseAddr; /* Pointer to the off-screen pixel image */
- OSErr error; /* Returns error code */
- short bytesPerRow; /* Number of bytes per row in the PixMap */
-
-
- error = noErr;
- newColors = nil;
- offBaseAddr = nil;
-
- bytesPerRow = ((depth * (bounds->right - bounds->left) + 31) / 32) * 4;
-
- /* Clone the clut if indexed color; allocate a dummy clut if direct color*/
- if (depth <= 8)
- {
- newColors = colors;
- error = HandToHand((Handle *) &newColors);
- }
- else
- {
- newColors = (CTabHandle) NewHandle(sizeof(ColorTable) -
- sizeof(CSpecArray));
- error = MemError();
- }
- if (error == noErr)
- {
- /* Allocate pixel image; long integer multiplication avoids overflow */
- (**icon).iconData = NewHandle((unsigned long) bytesPerRow * (bounds->bottom -
- bounds->top));
- if ((**icon).iconData != nil)
- {
- /* Initialize fields common to indexed and direct PixMaps */
- (**icon).iconPMap.baseAddr = 0; /* Point to image */
- (**icon).iconPMap.rowBytes = bytesPerRow | /* MSB set for PixMap */
- 0x8000;
- (**icon).iconPMap.bounds = *bounds; /* Use given bounds */
- (**icon).iconPMap.pmVersion = 0; /* No special stuff */
- (**icon).iconPMap.packType = 0; /* Default PICT pack */
- (**icon).iconPMap.packSize = 0; /* Always zero in mem */
- (**icon).iconPMap.hRes = kDefaultRes; /* 72 DPI default res */
- (**icon).iconPMap.vRes = kDefaultRes; /* 72 DPI default res */
- (**icon).iconPMap.pixelSize = depth; /* Set # bits/pixel */
-
- /* Initialize fields specific to indexed and direct PixMaps */
- if (depth <= 8)
- {
- /* PixMap is indexed */
- (**icon).iconPMap.pixelType = 0; /* Indicates indexed */
- (**icon).iconPMap.cmpCount = 1; /* Have 1 component */
- (**icon).iconPMap.cmpSize = depth; /* Component size=depth */
- (**icon).iconPMap.pmTable = newColors; /* Handle to CLUT */
- }
- else
- {
- /* PixMap is direct */
- (**icon).iconPMap.pixelType = RGBDirect; /* Indicates direct */
- (**icon).iconPMap.cmpCount = 3; /* Have 3 components */
- if (depth == 16)
- (**icon).iconPMap.cmpSize = 5; /* 5 bits/component */
- else
- (**icon).iconPMap.cmpSize = 8; /* 8 bits/component */
- (**newColors).ctSeed = 3 * (**icon).iconPMap.cmpSize;
- (**newColors).ctFlags = 0;
- (**newColors).ctSize = 0;
- (**icon).iconPMap.pmTable = newColors;
- }
- }
- else
- error = MemError();
- }
- else
- newColors = nil;
-
- /* If no errors occurred, return a handle to the new off-screen PixMap */
- if (error != noErr)
- {
- if (newColors != nil)
- DisposeCTable(newColors);
- }
-
- /* Return the error code */
- return error;
-}
-
-CIconHandle wxMacCreateCIcon(GWorldPtr image , GWorldPtr mask , short dstDepth , short iconSize )
-{
- GWorldPtr saveWorld;
- GDHandle saveHandle;
-
- GetGWorld(&saveWorld,&saveHandle); // save Graphics env state
- SetGWorld(image,nil);
-
- Rect frame = { 0 , 0 , iconSize , iconSize } ;
- Rect imageBounds = frame ;
- GetPortBounds( image , &imageBounds ) ;
-
- int bwSize = iconSize / 8 * iconSize ;
- CIconHandle icon = (CIconHandle) NewHandleClear( sizeof ( CIcon ) + 2 * bwSize) ;
- HLock((Handle)icon) ;
- SetupCIconHandlePixMap( icon , dstDepth , &frame,GetCTable(dstDepth)) ;
- HLock( (**icon).iconData ) ;
- (**icon).iconPMap.baseAddr = *(**icon).iconData ;
-
- LockPixels(GetGWorldPixMap(image));
-
- CopyBits(GetPortBitMapForCopyBits(image),
- (BitMapPtr)&((**icon).iconPMap),
- &imageBounds,
- &imageBounds,
- srcCopy | ditherCopy, nil);
-
-
- UnlockPixels(GetGWorldPixMap(image));
- HUnlock( (**icon).iconData ) ;
-
- (**icon).iconMask.rowBytes = iconSize / 8 ;
- (**icon).iconMask.bounds = frame ;
-
- (**icon).iconBMap.rowBytes = iconSize / 8 ;
- (**icon).iconBMap.bounds = frame ;
- (**icon).iconMask.baseAddr = (char*) &(**icon).iconMaskData ;
- (**icon).iconBMap.baseAddr = (char*) &(**icon).iconMaskData + bwSize ;
-
- if ( mask )
- {
- Rect r ;
- GetPortBounds( image , &r ) ;
- LockPixels(GetGWorldPixMap(mask) ) ;
- CopyBits(GetPortBitMapForCopyBits(mask) ,
- &(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
- CopyBits(GetPortBitMapForCopyBits(mask) ,
- &(**icon).iconMask , &r , &r, srcCopy , nil ) ;
- UnlockPixels(GetGWorldPixMap( mask ) ) ;
- }
- else
- {
- Rect r ;
- GetPortBounds( image , &r ) ;
- LockPixels(GetGWorldPixMap(image));
- CopyBits(GetPortBitMapForCopyBits(image) ,
- &(**icon).iconBMap , &r , &r, srcCopy , nil ) ;
- CopyBits(GetPortBitMapForCopyBits(image) ,
- &(**icon).iconMask , &r , &r, srcCopy , nil ) ;
- UnlockPixels(GetGWorldPixMap(image));
- }
-
- (**icon).iconMask.baseAddr = NULL ;
- (**icon).iconBMap.baseAddr = NULL ;
- (**icon).iconPMap.baseAddr = NULL ;
- HUnlock((Handle)icon) ;
- SetGWorld(saveWorld,saveHandle);
-
- return icon;
-}
-
-PicHandle wxMacCreatePict(GWorldPtr wp, GWorldPtr mask)
-{
- CGrafPtr origPort ;
- GDHandle origDev ;
-
- PicHandle pict;
-
- RGBColor white = { 0xffff ,0xffff , 0xffff } ;
- RGBColor black = { 0x0000 ,0x0000 , 0x0000 } ;
-
- GetGWorld( &origPort , &origDev ) ;
-
- RgnHandle clipRgn = NULL ;
-
- if ( mask )
- {
- clipRgn = NewRgn() ;
- LockPixels( GetGWorldPixMap( mask ) ) ;
- BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( mask ) ) ;
- UnlockPixels( GetGWorldPixMap( mask ) ) ;
- }
-
- SetGWorld( wp , NULL ) ;
- Rect portRect ;
- if ( clipRgn )
- GetRegionBounds( clipRgn , &portRect ) ;
- else
- GetPortBounds( wp , &portRect ) ;
- pict = OpenPicture(&portRect);
- if(pict)
- {
- RGBForeColor( &black ) ;
- RGBBackColor( &white ) ;
-
- if ( clipRgn )
- SetClip( clipRgn ) ;
-
- LockPixels( GetGWorldPixMap( wp ) ) ;
- CopyBits(GetPortBitMapForCopyBits(wp),
- GetPortBitMapForCopyBits(wp),
- &portRect,
- &portRect,
- srcCopy,clipRgn);
- UnlockPixels( GetGWorldPixMap( wp ) ) ;
- ClosePicture();
- }
- SetGWorld( origPort , origDev ) ;
- if ( clipRgn )
- DisposeRgn( clipRgn ) ;
- return pict;
-}
-
-void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bitmap , int forceType )
-{
- memset( info , 0 , sizeof(ControlButtonContentInfo) ) ;
- if ( bitmap.Ok() )
- {
- wxBitmapRefData * bmap = (wxBitmapRefData*) ( bitmap.GetRefData()) ;
- if ( bmap == NULL )
- return ;
-
- if ( bmap->m_bitmapType == kMacBitmapTypePict )
- {
- info->contentType = kControlContentPictHandle ;
- info->u.picture = MAC_WXHMETAFILE(bmap->m_hPict) ;
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
- {
- if ( (forceType == kControlContentCIconHandle || ( bmap->m_width == bmap->m_height && forceType != kControlContentPictHandle ) ) && ((bmap->m_width & 0x3) == 0) )
- {
- info->contentType = kControlContentCIconHandle ;
- if ( bitmap.GetMask() )
- {
- info->u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap()) ,
- 8 , bmap->m_width ) ;
- }
- else
- {
- info->u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ,
- 8 , bmap->m_width ) ;
- }
- }
- else
- {
- info->contentType = kControlContentPictHandle ;
- if ( bitmap.GetMask() )
- {
- info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(bitmap.GetMask()->GetMaskBitmap() ) ) ;
- }
- else
- {
- info->u.picture = wxMacCreatePict( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ) ;
- }
- }
- }
- else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
- {
- info->contentType = kControlContentCIconHandle ;
- info->u.cIconHandle = MAC_WXHICON(bmap->m_hIcon) ;
- }
- }
-}
-
-wxBitmapRefData::wxBitmapRefData()
- : m_width(0)
- , m_height(0)
- , m_depth(0)
- , m_ok(false)
- , m_numColors(0)
- , m_quality(0)
-{
- m_bitmapMask = NULL;
- m_hBitmap = NULL ;
- m_hPict = NULL ;
- m_hIcon = NULL ;
- m_bitmapType = kMacBitmapTypeUnknownType ;
- m_hasAlpha = false;
-}
-
-// TODO move this to a public function of Bitmap Ref
-static void DisposeBitmapRefData(wxBitmapRefData *data)
-{
- if ( !data )
- return ;
-
- switch (data->m_bitmapType)
- {
- case kMacBitmapTypePict :
- {
- if ( data->m_hPict )
- {
- KillPicture( MAC_WXHMETAFILE( data->m_hPict ) ) ;
- data->m_hPict = NULL ;
- }
- }
- break ;
- case kMacBitmapTypeGrafWorld :
- {
- if ( data->m_hBitmap )
- {
- wxMacDestroyGWorld( MAC_WXHBITMAP(data->m_hBitmap) ) ;
- data->m_hBitmap = NULL ;
- }
- }
- break ;
- case kMacBitmapTypeIcon :
- if ( data->m_hIcon )
- {
- DisposeCIcon( MAC_WXHICON(data->m_hIcon) ) ;
- data->m_hIcon = NULL ;
- }
-
- default :
- // unkown type ?
- break ;
- }
-
- if (data->m_bitmapMask)
- {
- delete data->m_bitmapMask;
- data->m_bitmapMask = NULL;
- }
-}
-
-wxBitmapRefData::~wxBitmapRefData()
-{
- DisposeBitmapRefData( this ) ;
-}
-
-bool wxBitmap::CopyFromIcon(const wxIcon& icon)
-{
- Ref(icon) ;
- return true;
-}
-
-wxBitmap::wxBitmap()
-{
- m_refData = NULL;
-}
-
-wxBitmap::~wxBitmap()
-{
-}
-
-wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)
-{
- m_refData = new wxBitmapRefData;
-
- M_BITMAPDATA->m_width = the_width ;
- M_BITMAPDATA->m_height = the_height ;
- M_BITMAPDATA->m_depth = no_bits ;
- M_BITMAPDATA->m_numColors = 0;
- if ( no_bits == 1 )
- {
- M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
- M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( the_width , the_height , no_bits ) ;
- M_BITMAPDATA->m_ok = (MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) != NULL ) ;
-
- CGrafPtr origPort ;
- GDHandle origDevice ;
-
- GetGWorld( &origPort , &origDevice ) ;
- SetGWorld( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , NULL ) ;
- LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) ) ) ;
-
- // bits is a char array
-
- unsigned char* linestart = (unsigned char*) bits ;
- int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
- if ( the_width % (sizeof(unsigned char) * 8) ) {
- linesize += sizeof(unsigned char);
- }
-
- RGBColor colors[2] = {
- { 0xFFFF , 0xFFFF , 0xFFFF } ,
- { 0, 0 , 0 }
- } ;
-
- for ( int y = 0 ; y < the_height ; ++y , linestart += linesize )
- {
- for ( int x = 0 ; x < the_width ; ++x )
- {
- int index = x / 8 ;
- int bit = x % 8 ;
- int mask = 1 << bit ;
- if ( linestart[index] & mask )
- {
- SetCPixel( x , y , &colors[1] ) ;
- }
- else
- {
- SetCPixel( x , y , &colors[0] ) ;
- }
- }
- }
- UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) ) ) ;
-
- SetGWorld( origPort , origDevice ) ;
- }
- else
- {
- wxFAIL_MSG(wxT("multicolor BITMAPs not yet implemented"));
- }
-}
-
-wxBitmap::wxBitmap(int w, int h, int d)
-{
- (void)Create(w, h, d);
-}
-
-wxBitmap::wxBitmap(void *data, wxBitmapType type, int width, int height, int depth)
-{
- (void) Create(data, type, width, height, depth);
-}
-
-wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type)
-{
- LoadFile(filename, type);
-}
-
-bool wxBitmap::CreateFromXpm(const char **bits)
-{
- wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") );
- wxXPMDecoder decoder;
- wxImage img = decoder.ReadData(bits);
- wxCHECK_MSG( img.Ok(), false, wxT("invalid bitmap data") );
- *this = wxBitmap(img);
- return true;
-}
-
-wxBitmap::wxBitmap(const char **bits)
-{
- (void) CreateFromXpm(bits);
-}
-
-wxBitmap::wxBitmap(char **bits)
-{
- (void) CreateFromXpm((const char **)bits);
-}
-
-wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
-{
- wxCHECK_MSG( Ok() &&
- (rect.x >= 0) && (rect.y >= 0) &&
- (rect.x+rect.width <= GetWidth()) &&
- (rect.y+rect.height <= GetHeight()),
- wxNullBitmap, wxT("invalid bitmap or bitmap region") );
-
-
- wxBitmap ret( rect.width, rect.height, GetDepth() );
- wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") );
-
- GWorldPtr origPort;
- GDHandle origDevice;
-
- GetGWorld( &origPort, &origDevice );
-
- // Update the subbitmaps reference data
- wxBitmapRefData *ref = (wxBitmapRefData *)ret.GetRefData();
-
- ref->m_numColors = M_BITMAPDATA->m_numColors;
-#if wxUSE_PALETTE
- ref->m_bitmapPalette = M_BITMAPDATA->m_bitmapPalette;
-#endif // wxUSE_PALETTE
- ref->m_bitmapType = M_BITMAPDATA->m_bitmapType;
-
- // Copy sub region of this bitmap
- if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict)
- {
- printf("GetSubBitmap: Copy a region of a Pict structure - TODO\n");
- }
- else if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypeGrafWorld)
- {
- // Copy mask
- if(GetMask())
- {
- GWorldPtr submask, mask;
- RGBColor color;
-
- mask = (GWorldPtr) GetMask()->GetMaskBitmap();
- submask = wxMacCreateGWorld(rect.width, rect.height, GetMask()->GetDepth() );
- LockPixels(GetGWorldPixMap(mask));
- LockPixels(GetGWorldPixMap(submask));
-
- for(int yy = 0; yy < rect.height; yy++)
- {
- for(int xx = 0; xx < rect.width; xx++)
- {
- SetGWorld(mask, NULL);
- GetCPixel(rect.x + xx, rect.y + yy, &color);
- SetGWorld(submask, NULL);
- SetCPixel(xx,yy, &color);
- }
- }
- UnlockPixels(GetGWorldPixMap(mask));
- UnlockPixels(GetGWorldPixMap(submask));
- ref->m_bitmapMask = new wxMask;
- ref->m_bitmapMask->SetMaskBitmap(submask);
- }
-
- // Copy bitmap
- if(GetHBITMAP())
- {
- GWorldPtr subbitmap, bitmap;
- RGBColor color;
-
- bitmap = (GWorldPtr) GetHBITMAP();
- subbitmap = (GWorldPtr) ref->m_hBitmap ;
- LockPixels(GetGWorldPixMap(bitmap));
- LockPixels(GetGWorldPixMap(subbitmap));
-
- for(int yy = 0; yy < rect.height; yy++)
- {
- for(int xx = 0; xx < rect.width; xx++)
- {
- SetGWorld(bitmap, NULL);
- GetCPixel(rect.x + xx, rect.y + yy, &color);
- SetGWorld(subbitmap, NULL);
- SetCPixel(xx, yy, &color);
- }
- }
- UnlockPixels(GetGWorldPixMap(bitmap));
- UnlockPixels(GetGWorldPixMap(subbitmap));
- }
- }
- SetGWorld( origPort, origDevice );
-
- return ret;
-}
-
-bool wxBitmap::Create(int w, int h, int d)
-{
- UnRef();
-
- m_refData = new wxBitmapRefData;
-
- M_BITMAPDATA->m_width = w;
- M_BITMAPDATA->m_height = h;
- M_BITMAPDATA->m_depth = d;
-
- M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
- M_BITMAPDATA->m_hBitmap = wxMacCreateGWorld( w , h , d ) ;
- M_BITMAPDATA->m_ok = ( M_BITMAPDATA->m_hBitmap != NULL ) ;
- return M_BITMAPDATA->m_ok;
-}
-
-int wxBitmap::GetBitmapType() const
-{
- wxCHECK_MSG( Ok(), kMacBitmapTypeUnknownType, wxT("invalid bitmap") );
-
- return M_BITMAPDATA->m_bitmapType;
-}
-
-void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
-{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
- else
- DisposeBitmapRefData( M_BITMAPDATA ) ;
-
- M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
- M_BITMAPDATA->m_hBitmap = bmp ;
- M_BITMAPDATA->m_ok = ( M_BITMAPDATA->m_hBitmap != NULL ) ;
-}
-
-void wxBitmap::SetHICON(WXHICON ico)
-{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
- else
- DisposeBitmapRefData( M_BITMAPDATA ) ;
-
- M_BITMAPDATA->m_bitmapType = kMacBitmapTypeIcon ;
- M_BITMAPDATA->m_hIcon = ico ;
- M_BITMAPDATA->m_ok = ( M_BITMAPDATA->m_hIcon != NULL ) ;
-}
-
-void wxBitmap::SetPict(WXHMETAFILE pict)
-{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
- else
- DisposeBitmapRefData( M_BITMAPDATA ) ;
-
- M_BITMAPDATA->m_bitmapType = kMacBitmapTypePict ;
- M_BITMAPDATA->m_hPict = pict ;
- M_BITMAPDATA->m_ok = ( M_BITMAPDATA->m_hPict != NULL ) ;
-}
-
-bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type)
-{
- UnRef();
-
- wxBitmapHandler *handler = FindHandler(type);
-
- if ( handler )
- {
- m_refData = new wxBitmapRefData;
-
- return handler->LoadFile(this, filename, type, -1, -1);
- }
- else
- {
- wxImage loadimage(filename, type);
- if (loadimage.Ok()) {
- *this = loadimage;
- return true;
- }
- }
- wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
- return false;
-}
-
-bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int depth)
-{
- UnRef();
-
- m_refData = new wxBitmapRefData;
-
- wxBitmapHandler *handler = FindHandler(type);
-
- if ( handler == NULL ) {
- wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
-
- return false;
- }
-
- return handler->Create(this, data, type, width, height, depth);
-}
-
-wxBitmap::wxBitmap(const wxImage& image, int depth)
-{
- wxCHECK_RET( image.Ok(), wxT("invalid image") );
- wxCHECK_RET( depth == -1, wxT("invalid bitmap depth") );
-
- m_refData = new wxBitmapRefData();
-
- // width and height of the device-dependent bitmap
- int width = image.GetWidth();
- int height = image.GetHeight();
-
- // Create picture
-
- Create( width , height , 32 ) ;
-
- CGrafPtr origPort ;
- GDHandle origDevice ;
-
- PixMapHandle pixMap = GetGWorldPixMap((GWorldPtr)GetHBITMAP()) ;
- LockPixels( pixMap );
-
- GetGWorld( &origPort , &origDevice ) ;
- SetGWorld( (GWorldPtr) GetHBITMAP() , NULL ) ;
-
- // Render image
- register unsigned char* data = image.GetData();
- char* destinationBase = GetPixBaseAddr( pixMap );
- register unsigned char* destination = (unsigned char*) destinationBase ;
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- *destination++ = 0 ;
- *destination++ = *data++ ;
- *destination++ = *data++ ;
- *destination++ = *data++ ;
- }
- destinationBase += ((**pixMap).rowBytes & 0x7fff);
- destination = (unsigned char*) destinationBase ;
- }
- if ( image.HasAlpha() )
- {
- unsigned char *alpha = image.GetAlpha();
-
- wxColour maskcolor(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
- RGBColor color ;
- wxBitmap maskBitmap ;
-
- maskBitmap.Create( width, height, 24);
- LockPixels( GetGWorldPixMap( (GWorldPtr) maskBitmap.GetHBITMAP()) );
- SetGWorld( (GWorldPtr) maskBitmap.GetHBITMAP(), NULL);
-
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- memset( &color , 255 - *alpha , sizeof( color ) );
- SetCPixel(x,y, &color);
-
- alpha += 1 ;
- }
- } // for height
- SetGWorld( (GWorldPtr) GetHBITMAP(), NULL);
- SetMask(new wxMask( maskBitmap ));
- UnlockPixels( GetGWorldPixMap( (GWorldPtr) maskBitmap.GetHBITMAP()) );
- }
- else if ( image.HasMask() )
- {
- data = image.GetData();
-
- wxColour maskcolor(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue());
- RGBColor white = { 0xffff, 0xffff, 0xffff };
- RGBColor black = { 0 , 0 , 0 };
- wxBitmap maskBitmap ;
-
- maskBitmap.Create( width, height, 1);
- LockPixels( GetGWorldPixMap( (GWorldPtr) maskBitmap.GetHBITMAP()) );
- SetGWorld( (GWorldPtr) maskBitmap.GetHBITMAP(), NULL);
-
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- if ( data[0] == image.GetMaskRed() && data[1] == image.GetMaskGreen() && data[2] == image.GetMaskBlue() )
- {
- SetCPixel(x,y, &white);
- }
- else {
- SetCPixel(x,y, &black);
- }
- data += 3 ;
- }
- } // for height
- SetGWorld( (GWorldPtr) GetHBITMAP(), NULL);
- SetMask(new wxMask( maskBitmap ));
- UnlockPixels( GetGWorldPixMap( (GWorldPtr) maskBitmap.GetHBITMAP()) );
- }
-
- UnlockPixels( GetGWorldPixMap( (GWorldPtr) GetHBITMAP()) );
- SetGWorld( origPort, origDevice );
-}
-
-wxImage wxBitmap::ConvertToImage() const
-{
- wxImage image;
-
- wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
-
- // create an wxImage object
- int width = GetWidth();
- int height = GetHeight();
- image.Create( width, height );
-
- unsigned char *data = image.GetData();
-
- wxCHECK_MSG( data, wxNullImage, wxT("Could not allocate data for image") );
-
- GWorldPtr origPort;
- GDHandle origDevice;
- RgnHandle maskRgn = NULL ;
- GWorldPtr tempPort = NULL ;
- int index;
- RGBColor color;
- // background color set to RGB(16,16,16) in consistent with wxGTK
- unsigned char mask_r=16, mask_g=16, mask_b=16;
- SInt16 r,g,b;
- wxMask *mask = GetMask();
-
- GetGWorld( &origPort, &origDevice );
- if ( GetBitmapType() != kMacBitmapTypeGrafWorld )
- {
- tempPort = wxMacCreateGWorld( width , height , -1) ;
- }
- else
- {
- tempPort = (GWorldPtr) GetHBITMAP() ;
- }
- LockPixels(GetGWorldPixMap(tempPort));
- SetGWorld( tempPort, NULL);
- if ( GetBitmapType() == kMacBitmapTypePict || GetBitmapType() == kMacBitmapTypeIcon )
- {
- Rect bitmaprect = { 0 , 0 , height, width };
- if ( GetBitmapType() == kMacBitmapTypeIcon )
- {
- ::PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(GetHICON()) ) ;
- maskRgn = NewRgn() ;
- BitMapToRegion( maskRgn , &(**(MAC_WXHICON(GetHICON()))).iconMask ) ;
- }
- else
- ::DrawPicture( (PicHandle) GetPict(), &bitmaprect ) ;
- }
- // Copy data into image
- index = 0;
- for (int yy = 0; yy < height; yy++)
- {
- for (int xx = 0; xx < width; xx++)
- {
- GetCPixel(xx,yy, &color);
- r = ((color.red ) >> 8);
- g = ((color.green ) >> 8);
- b = ((color.blue ) >> 8);
- data[index ] = r;
- data[index + 1] = g;
- data[index + 2] = b;
- if ( maskRgn )
- {
- Point pt ;
- pt.h = xx ;
- pt.v = yy ;
- if ( !PtInRgn( pt , maskRgn ) )
- {
- data[index ] = mask_r;
- data[index + 1] = mask_g;
- data[index + 2] = mask_b;
- }
- }
- else
- {
- if (mask)
- {
- if (mask->PointMasked(xx,yy))
- {
- data[index ] = mask_r;
- data[index + 1] = mask_g;
- data[index + 2] = mask_b;
- }
- }
- }
- index += 3;
- }
- }
- if (mask || maskRgn )
- {
- image.SetMaskColour( mask_r, mask_g, mask_b );
- image.SetMask( true );
- }
-
- // Free resources
- UnlockPixels(GetGWorldPixMap( tempPort ));
- SetGWorld(origPort, origDevice);
- if ( GetBitmapType() != kMacBitmapTypeGrafWorld )
- {
- wxMacDestroyGWorld( tempPort ) ;
- }
- if ( maskRgn )
- {
- DisposeRgn( maskRgn ) ;
- }
-
- return image;
-}
-
-
-bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type,
- const wxPalette *palette) const
-{
- wxBitmapHandler *handler = FindHandler(type);
-
- if ( handler )
- {
- return handler->SaveFile(this, filename, type, palette);
- }
- else
- {
- wxImage image = ConvertToImage();
-
- return image.SaveFile(filename, type);
- }
-
- wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
- return false;
-}
-
-bool wxBitmap::IsOk() const
-{
- return (M_BITMAPDATA && M_BITMAPDATA->m_ok);
-}
-
-int wxBitmap::GetHeight() const
-{
- wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
-
- return M_BITMAPDATA->m_height;
-}
-
-int wxBitmap::GetWidth() const
-{
- wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
-
- return M_BITMAPDATA->m_width;
-}
-
-int wxBitmap::GetDepth() const
-{
- wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
-
- return M_BITMAPDATA->m_depth;
-}
-
-int wxBitmap::GetQuality() const
-{
- wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
-
- return M_BITMAPDATA->m_quality;
-}
-
-wxMask *wxBitmap::GetMask() const
-{
- wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") );
-
- return M_BITMAPDATA->m_bitmapMask;
-}
-
-void wxBitmap::SetWidth(int w)
-{
- AllocExclusive();
- M_BITMAPDATA->m_width = w;
-}
-
-void wxBitmap::SetHeight(int h)
-{
- AllocExclusive();
- M_BITMAPDATA->m_height = h;
-}
-
-void wxBitmap::SetDepth(int d)
-{
- AllocExclusive();
- M_BITMAPDATA->m_depth = d;
-}
-
-void wxBitmap::SetQuality(int q)
-{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
- M_BITMAPDATA->m_quality = q;
-}
-
-void wxBitmap::SetOk(bool isOk)
-{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
- M_BITMAPDATA->m_ok = isOk;
-}
-
-#if wxUSE_PALETTE
-wxPalette *wxBitmap::GetPalette() const
-{
- wxCHECK_MSG( Ok(), NULL, wxT("Invalid bitmap GetPalette()") );
-
- return &M_BITMAPDATA->m_bitmapPalette;
-}
-
-void wxBitmap::SetPalette(const wxPalette& palette)
-{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
- M_BITMAPDATA->m_bitmapPalette = palette ;
-}
-#endif // wxUSE_PALETTE
-
-void wxBitmap::SetMask(wxMask *mask)
-{
- if (!M_BITMAPDATA)
- m_refData = new wxBitmapRefData;
-
- // Remove existing mask if there is one.
- delete M_BITMAPDATA->m_bitmapMask;
-
- M_BITMAPDATA->m_bitmapMask = mask ;
-}
-
-WXHBITMAP wxBitmap::GetHBITMAP() const
-{
- wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
-
- return MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap);
-}
-
-WXHMETAFILE wxBitmap::GetPict( bool *created ) const
-{
- wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
-
- PicHandle picture = NULL ; // This is the returned picture
- if ( created )
- (*created) = false ;
- // If bitmap already in Pict format return pointer
- if(M_BITMAPDATA->m_bitmapType == kMacBitmapTypePict) {
- return M_BITMAPDATA->m_hPict;
- }
- else if(M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld) {
- // Invalid bitmap
- return NULL;
- }
- else
- {
- if ( GetMask() )
- {
- picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , MAC_WXHBITMAP(GetMask()->GetMaskBitmap() ) ) ;
- }
- else
- {
- picture = wxMacCreatePict( MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap) , NULL ) ;
- }
- if ( created && picture )
- (*created) = true ;
- }
- return picture ;
-}
-
-/*
- * wxMask
- */
-
-wxMask::wxMask()
- : m_maskBitmap(NULL)
-{
-}
-
-// Construct a mask from a bitmap and a colour indicating
-// the transparent area
-wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
- : m_maskBitmap(NULL)
-{
- Create(bitmap, colour);
-}
-
-// Construct a mask from a bitmap and a palette index indicating
-// the transparent area
-wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
- : m_maskBitmap(NULL)
-{
- Create(bitmap, paletteIndex);
-}
-
-// Construct a mask from a mono bitmap (copies the bitmap).
-wxMask::wxMask(const wxBitmap& bitmap)
- : m_maskBitmap(NULL)
-{
- Create(bitmap);
-}
-
-wxMask::~wxMask()
-{
- if ( m_maskBitmap )
- {
- wxMacDestroyGWorld( (GWorldPtr) m_maskBitmap ) ;
- m_maskBitmap = NULL ;
- }
-}
-
-// Create a mask from a mono bitmap (copies the bitmap).
-bool wxMask::Create(const wxBitmap& bitmap)
-{
- if ( m_maskBitmap )
- {
- wxMacDestroyGWorld( (GWorldPtr) m_maskBitmap ) ;
- m_maskBitmap = NULL ;
- }
- wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
- wxT("Cannot create mask from this bitmap type (TODO)"));
- // other types would require a temporary bitmap. not yet implemented
-
- wxCHECK_MSG( bitmap.Ok(), false, wxT("Invalid bitmap"));
-
- m_depth = bitmap.GetDepth() ;
- m_maskBitmap = wxMacCreateGWorld(bitmap.GetWidth(), bitmap.GetHeight(), bitmap.GetDepth() );
- Rect rect = { 0,0, bitmap.GetHeight(), bitmap.GetWidth() };
-
- LockPixels( GetGWorldPixMap( (GWorldPtr) m_maskBitmap) );
- LockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP()) );
- CopyBits(GetPortBitMapForCopyBits( (GWorldPtr) bitmap.GetHBITMAP()),
- GetPortBitMapForCopyBits( (GWorldPtr) m_maskBitmap),
- &rect, &rect, srcCopy, 0);
- UnlockPixels( GetGWorldPixMap( (GWorldPtr) m_maskBitmap) );
- UnlockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP()) );
-
- return false;
-}
-
-// Create a mask from a bitmap and a palette index indicating
-// the transparent area
-bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex)
-{
- // TODO
- wxCHECK_MSG( 0, false, wxT("wxMask::Create not yet implemented"));
- return false;
-}
-
-// Create a mask from a bitmap and a colour indicating
-// the transparent area
-bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
-{
- if ( m_maskBitmap )
- {
- wxMacDestroyGWorld( (GWorldPtr) m_maskBitmap ) ;
- m_maskBitmap = NULL ;
- }
- wxCHECK_MSG( bitmap.GetBitmapType() == kMacBitmapTypeGrafWorld, false,
- wxT("Cannot create mask from this bitmap type (TODO)"));
- // other types would require a temporary bitmap. not yet implemented
-
- wxCHECK_MSG( bitmap.Ok(), false, wxT("Illigal bitmap"));
-
- m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 );
- m_depth = 1 ;
- LockPixels( GetGWorldPixMap( (GWorldPtr) m_maskBitmap ) );
- LockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP() ) );
- RGBColor maskColor = MAC_WXCOLORREF(colour.GetPixel());
-
- // this is not very efficient, but I can't think
- // of a better way of doing it
- CGrafPtr origPort ;
- GDHandle origDevice ;
- RGBColor col;
- RGBColor colors[2] = {
- { 0xFFFF, 0xFFFF, 0xFFFF },
- { 0, 0, 0 }};
-
- GetGWorld( &origPort , &origDevice ) ;
- for (int w = 0; w < bitmap.GetWidth(); w++)
- {
- for (int h = 0; h < bitmap.GetHeight(); h++)
- {
- SetGWorld( (GWorldPtr) bitmap.GetHBITMAP(), NULL ) ;
- GetCPixel( w , h , &col ) ;
- SetGWorld( (GWorldPtr) m_maskBitmap , NULL ) ;
- if (col.red == maskColor.red && col.green == maskColor.green && col.blue == maskColor.blue)
- {
- SetCPixel( w , h , &colors[0] ) ;
- }
- else
- {
- SetCPixel( w , h , &colors[1] ) ;
- }
- }
- }
- UnlockPixels( GetGWorldPixMap( (CGrafPtr) m_maskBitmap ) ) ;
- UnlockPixels( GetGWorldPixMap( (GWorldPtr) bitmap.GetHBITMAP() ) ) ;
- SetGWorld( origPort , origDevice ) ;
-
- return true;
-}
-
-bool wxMask::PointMasked(int x, int y)
-{
- GWorldPtr origPort;
- GDHandle origDevice;
- RGBColor color;
- bool masked = true;
-
- GetGWorld( &origPort, &origDevice);
-
- //Set port to mask and see if it masked (1) or not ( 0 )
- SetGWorld( (GWorldPtr) m_maskBitmap, NULL);
- LockPixels(GetGWorldPixMap( (GWorldPtr) m_maskBitmap));
- GetCPixel(x,y, &color);
- masked = !(color.red == 0 && color.green == 0 && color.blue == 0);
- UnlockPixels(GetGWorldPixMap( (GWorldPtr) m_maskBitmap));
-
- SetGWorld( origPort, origDevice);
-
- return masked;
-}
-
-/*
- * wxBitmapHandler
- */
-
-wxBitmapHandler::~wxBitmapHandler()
-{
-}
-
-bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
-{
- return false;
-}
-
-bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight)
-{
- return false;
-}
-
-bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
-{
- return false;
-}
-
-/*
- * Standard handlers
- */
-
-class WXDLLEXPORT wxPICTResourceHandler: public wxBitmapHandler
-{
- DECLARE_DYNAMIC_CLASS(wxPICTResourceHandler)
-public:
- inline wxPICTResourceHandler()
- {
- m_name = wxT("Macintosh Pict resource");
- m_extension = wxEmptyString;
- m_type = wxBITMAP_TYPE_PICT_RESOURCE;
- };
-
- virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight);
-};
-IMPLEMENT_DYNAMIC_CLASS(wxPICTResourceHandler, wxBitmapHandler)
-
-bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight)
-{
- Str255 theName ;
- wxMacStringToPascal( name , theName ) ;
-
- PicHandle thePict = (PicHandle ) GetNamedResource( 'PICT' , theName ) ;
- if ( thePict )
- {
- PictInfo theInfo ;
-
- GetPictInfo( thePict , &theInfo , 0 , 0 , systemMethod , 0 ) ;
- DetachResource( (Handle) thePict ) ;
- M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypePict ;
- M_BITMAPHANDLERDATA->m_hPict = thePict ;
- M_BITMAPHANDLERDATA->m_width = theInfo.sourceRect.right - theInfo.sourceRect.left ;
- M_BITMAPHANDLERDATA->m_height = theInfo.sourceRect.bottom - theInfo.sourceRect.top ;
-
- M_BITMAPHANDLERDATA->m_depth = theInfo.depth ;
- M_BITMAPHANDLERDATA->m_ok = true ;
- M_BITMAPHANDLERDATA->m_numColors = theInfo.uniqueColors ;
-// M_BITMAPHANDLERDATA->m_bitmapPalette;
-// M_BITMAPHANDLERDATA->m_quality;
- return true ;
- }
- return false ;
-}
-
-void wxBitmap::InitStandardHandlers()
-{
- AddHandler(new wxPICTResourceHandler) ;
- AddHandler(new wxICONResourceHandler) ;
-}
-
-// ----------------------------------------------------------------------------
-// raw bitmap access support
-// ----------------------------------------------------------------------------
-
-void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
-{
- if ( !Ok() )
- {
- // no bitmap, no data (raw or otherwise)
- return NULL;
- }
-
- if ( M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld )
- {
- wxFAIL_MSG( _T("GetRawData() only supported for GWorlds") );
-
- return NULL;
- }
-
- GWorldPtr gworld = MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap);
- PixMapHandle hPixMap = GetGWorldPixMap(gworld);
- wxCHECK_MSG( hPixMap && *hPixMap, NULL,
- _T("GetRawData(): failed to get PixMap from GWorld?") );
-
- wxCHECK_MSG( (*hPixMap)->pixelSize == bpp, NULL,
- _T("GetRawData(): pixel format mismatch") );
-
- if ( !LockPixels(hPixMap) )
- {
- wxFAIL_MSG( _T("failed to lock PixMap in GetRawData()") );
-
- return NULL;
- }
-
- data.m_width = GetWidth();
- data.m_height = GetHeight();
- data.m_stride = (*hPixMap)->rowBytes & 0x7fff;
-
- M_BITMAPDATA->m_hasAlpha = false;
-
- return GetPixBaseAddr(hPixMap);
-}
-
-void wxBitmap::UngetRawData(wxPixelDataBase& dataBase)
-{
- if ( !Ok() )
- return;
-
- if ( M_BITMAPDATA->m_hasAlpha )
- {
- wxAlphaPixelData& data = (wxAlphaPixelData&)dataBase;
-
- int w = data.GetWidth(),
- h = data.GetHeight();
-
- wxBitmap bmpMask(GetWidth(), GetHeight(), 32);
- wxAlphaPixelData dataMask(bmpMask, data.GetOrigin(), wxSize(w, h));
- wxAlphaPixelData::Iterator pMask(dataMask),
- p(data);
- for ( int y = 0; y < h; y++ )
- {
- wxAlphaPixelData::Iterator rowStartMask = pMask,
- rowStart = p;
-
- for ( int x = 0; x < w; x++ )
- {
- const wxAlphaPixelData::Iterator::ChannelType
- alpha = p.Alpha();
-
- pMask.Red() = alpha;
- pMask.Green() = alpha;
- pMask.Blue() = alpha;
-
- ++p;
- ++pMask;
- }
-
- p = rowStart;
- p.OffsetY(data, 1);
-
- pMask = rowStartMask;
- pMask.OffsetY(dataMask, 1);
- }
-
- SetMask(new wxMask(bmpMask));
- }
-
- GWorldPtr gworld = MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap);
- PixMapHandle hPixMap = GetGWorldPixMap(gworld);
- if ( hPixMap )
- {
- UnlockPixels(hPixMap);
- }
-}
-
-void wxBitmap::UseAlpha()
-{
- // remember that we are using alpha channel, we'll need to create a proper
- // mask in UngetRawData()
- M_BITMAPDATA->m_hasAlpha = true;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/bmpbuttn.cpp
-// Purpose: wxBitmapButton
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#if wxUSE_BMPBUTTON
-
-#include "wx/bmpbuttn.h"
-
-#ifndef WX_PRECOMP
- #include "wx/window.h"
- #include "wx/bitmap.h"
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
-
-#include "wx/mac/uma.h"
-
-bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- // since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create
- // essentially creates an additional button
- if ( !wxControl::Create(parent, id, pos, size,
- style, validator, name) )
- return false;
-
- m_bmpNormal = bitmap;
-
- if (style & wxBU_AUTODRAW)
- {
- m_marginX = wxDEFAULT_BUTTON_MARGIN;
- m_marginY = wxDEFAULT_BUTTON_MARGIN;
- }
- else
- {
- m_marginX = 0;
- m_marginY = 0;
- }
-
- int width = size.x;
- int height = size.y;
-
- if ( bitmap.Ok() )
- {
- wxSize newSize = DoGetBestSize();
- if ( width == -1 )
- width = newSize.x;
- if ( height == -1 )
- height = newSize.y;
- }
-
- Rect bounds ;
- Str255 title ;
- m_bmpNormal = bitmap;
- wxBitmapRefData * bmap = NULL ;
-
- if ( m_bmpNormal.Ok() )
- bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 ,
- kControlBehaviorOffsetContents +
- ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ?
- kControlContentCIconHandle : kControlContentPictHandle ) , 0,
- (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-
- ControlButtonContentInfo info ;
- wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
- if ( info.contentType != kControlNoContent )
- {
- ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
- }
- MacPostControlCreate() ;
-
- return true;
-}
-
-void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
-{
- m_bmpNormal = bitmap;
- InvalidateBestSize();
-
- ControlButtonContentInfo info ;
- wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
- if ( info.contentType != kControlNoContent )
- {
- ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
- }
-}
-
-
-wxSize wxBitmapButton::DoGetBestSize() const
-{
- wxSize best;
- if (m_bmpNormal.Ok())
- {
- best.x = m_bmpNormal.GetWidth() + 2*m_marginX;
- best.y = m_bmpNormal.GetHeight() + 2*m_marginY;
- }
- return best;
-}
-
-#endif // wxUSE_BMPBUTTON
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/brush.cpp
-// Purpose: wxBrush
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/brush.h"
-
-#ifndef WX_PRECOMP
- #include "wx/utils.h"
-#endif
-
-#include "wx/mac/private.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
-
-class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
-{
- friend class WXDLLEXPORT wxBrush;
-public:
- wxBrushRefData();
- wxBrushRefData(const wxBrushRefData& data);
- virtual ~wxBrushRefData();
-
-protected:
- wxMacBrushKind m_macBrushKind ;
- int m_style;
- wxBitmap m_stipple ;
- wxColour m_colour;
-
- ThemeBrush m_macThemeBrush ;
-
- ThemeBackgroundKind m_macThemeBackground ;
- Rect m_macThemeBackgroundExtent ;
-};
-
-#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
-
-wxBrushRefData::wxBrushRefData()
- : m_style(wxSOLID)
-{
- m_macBrushKind = kwxMacBrushColour ;
-}
-
-wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
- : wxGDIRefData()
- , m_style(data.m_style)
-{
- m_stipple = data.m_stipple;
- m_colour = data.m_colour;
- m_macBrushKind = data.m_macBrushKind ;
- m_macThemeBrush = data.m_macThemeBrush ;
- m_macThemeBackground = data.m_macThemeBackground ;
- m_macThemeBackgroundExtent = data.m_macThemeBackgroundExtent ;
-}
-
-wxBrushRefData::~wxBrushRefData()
-{
-}
-
-// Brushes
-wxBrush::wxBrush()
-{
-}
-
-wxBrush::~wxBrush()
-{
-}
-
-wxBrush::wxBrush(const wxColour& col, int Style)
-{
- m_refData = new wxBrushRefData;
-
- M_BRUSHDATA->m_colour = col;
- M_BRUSHDATA->m_style = Style;
-
- RealizeResource();
-}
-
-wxBrush::wxBrush(const wxBitmap& stipple)
-{
- m_refData = new wxBrushRefData;
-
- M_BRUSHDATA->m_colour = *wxBLACK;
- M_BRUSHDATA->m_stipple = stipple;
-
- if (M_BRUSHDATA->m_stipple.GetMask())
- M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
- else
- M_BRUSHDATA->m_style = wxSTIPPLE;
-
- RealizeResource();
-}
-
-wxBrush::wxBrush(ThemeBrush macThemeBrush )
-{
- m_refData = new wxBrushRefData;
-
- M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
- M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
-
- RealizeResource();
-}
-void wxBrush::Unshare()
-{
- // Don't change shared data
- if (!m_refData)
- {
- m_refData = new wxBrushRefData();
- }
- else
- {
- wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
-}
-
-void wxBrush::SetColour(const wxColour& col)
-{
- Unshare();
- M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
- M_BRUSHDATA->m_colour = col;
-
- RealizeResource();
-}
-
-void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
-{
- Unshare();
-
- M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
- M_BRUSHDATA->m_colour.Set(r, g, b);
-
- RealizeResource();
-}
-
-void wxBrush::SetStyle(int Style)
-{
- Unshare();
-
- M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
- M_BRUSHDATA->m_style = Style;
-
- RealizeResource();
-}
-
-void wxBrush::SetStipple(const wxBitmap& Stipple)
-{
- Unshare();
-
- M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
- M_BRUSHDATA->m_stipple = Stipple;
-
- RealizeResource();
-}
-
-void wxBrush::SetMacTheme(ThemeBrush macThemeBrush)
-{
- Unshare();
-
- M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
- M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
-
- RealizeResource();
-}
-
-void wxBrush::SetMacThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
-{
- Unshare();
-
- M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
- M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
- M_BRUSHDATA->m_macThemeBackgroundExtent = *(Rect*)extent ;
- RealizeResource();
-}
-
-bool wxBrush::RealizeResource()
-{
- return true;
-}
-
-unsigned long wxBrush::GetMacThemeBackground( WXRECTPTR extent) const
-{
- if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
- {
- if ( extent )
- *(Rect*)extent = M_BRUSHDATA->m_macThemeBackgroundExtent ;
- return M_BRUSHDATA->m_macThemeBackground ;
- }
- else
- {
- return 0 ;
- }
-}
-
-short wxBrush::GetMacTheme() const
-{
- return (M_BRUSHDATA ? ( M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack);
-}
-
-wxColour& wxBrush::GetColour() const
-{
- return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour);
-}
-
-int wxBrush::GetStyle() const
-{
- return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0);
-}
-
-wxBitmap *wxBrush::GetStipple() const
-{
- return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0);
-}
-
-wxMacBrushKind wxBrush::MacGetBrushKind() const
-{
- return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour);
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/button.cpp
-// Purpose: wxButton
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/button.h"
-
-#ifndef WX_PRECOMP
- #include "wx/panel.h"
-#endif
-
-#include "wx/stockitem.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
-
-#include "wx/mac/uma.h"
-// Button
-
-static const int kMacOSXHorizontalBorder = 2 ;
-static const int kMacOSXVerticalBorder = 4 ;
-
-bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& lbl,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- wxString label(lbl);
- if (label.empty() && wxIsStockID(id))
- label = wxGetStockLabel(id);
-
- if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- if ( UMAHasAquaLayout() )
- {
- m_macHorizontalBorder = kMacOSXHorizontalBorder;
- m_macVerticalBorder = kMacOSXVerticalBorder;
- }
-
- MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
- kControlPushButtonProc , (long) this ) ;
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-
- MacPostControlCreate() ;
-
- return true;
-}
-
-void wxButton::SetDefault()
-{
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
- wxButton *btnOldDefault = NULL;
- if ( tlw )
- {
- btnOldDefault = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
- tlw->SetDefaultItem(this);
- }
-
- Boolean inData;
- if ( btnOldDefault && btnOldDefault->m_macControl )
- {
- inData = 0;
- ::SetControlData( (ControlHandle) btnOldDefault->m_macControl , kControlButtonPart ,
- kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ;
- }
- if ( (ControlHandle) m_macControl )
- {
- inData = 1;
- ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart ,
- kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)(&inData) ) ;
- }
-}
-
-wxSize wxButton::DoGetBestSize() const
-{
- wxSize sz = GetDefaultSize() ;
-
- int wBtn = m_label.length() * 8 + 12 + 2 * kMacOSXHorizontalBorder ;
-
- if (wBtn > sz.x) sz.x = wBtn;
-
- return sz ;
-}
-
-wxSize wxButton::GetDefaultSize()
-{
- int wBtn = 70 ;
- int hBtn = 20 ;
-
- if ( UMAHasAquaLayout() )
- {
- wBtn += 2 * kMacOSXHorizontalBorder ;
- hBtn += 2 * kMacOSXVerticalBorder ;
- }
-
- return wxSize(wBtn, hBtn);
-}
-
-void wxButton::Command (wxCommandEvent & event)
-{
- if ( (ControlHandle) m_macControl )
- {
- HiliteControl( (ControlHandle) m_macControl , kControlButtonPart ) ;
- unsigned long finalTicks ;
- Delay( 8 , &finalTicks ) ;
- HiliteControl( (ControlHandle) m_macControl , 0 ) ;
- }
- ProcessCommand (event);
-}
-
-void wxButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) )
-{
- if ( controlpart != kControlNoPart )
- {
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId );
- event.SetEventObject(this);
- ProcessCommand(event);
- }
-}
+++ /dev/null
-// carbon for 9
-data 'carb' (0) {
- $"0000" /* .. */
-};
-
-// the plist resource should only be included in the application
-// since it contains the bundle information and should not be duplicated
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/checkbox.cpp
-// Purpose: wxCheckBox
-// Author: Stefan Csomor
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/checkbox.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
-
-#include "wx/mac/uma.h"
-
-// Single check box item
-bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
-
- SInt16 maxValue = 1 /* kControlCheckboxCheckedValue */;
- if (style & wxCHK_3STATE)
- {
- maxValue = 2 /* kControlCheckboxMixedValue */;
- }
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , maxValue,
- kControlCheckBoxProc , (long) this ) ;
-
- MacPostControlCreate() ;
-
- return true;
-}
-
-void wxCheckBox::SetValue(bool val)
-{
- if (val)
- {
- Set3StateValue(wxCHK_CHECKED);
- }
- else
- {
- Set3StateValue(wxCHK_UNCHECKED);
- }
-}
-
-bool wxCheckBox::GetValue() const
-{
- return (DoGet3StateValue() != 0);
-}
-
-void wxCheckBox::Command (wxCommandEvent & event)
-{
- int state = event.GetInt();
-
- wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED)
- || (state == wxCHK_UNDETERMINED),
- wxT("event.GetInt() returned an invalid checkbox state") );
-
- Set3StateValue((wxCheckBoxState) state);
-
- ProcessCommand(event);
-}
-
-wxCheckBoxState wxCheckBox::DoGet3StateValue() const
-{
- return (wxCheckBoxState) ::GetControl32BitValue( (ControlHandle) m_macControl );
-}
-
-void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
-{
- ::SetControl32BitValue( (ControlHandle) m_macControl , (int) val) ;
- MacRedrawControl() ;
-}
-
-void wxCheckBox::MacHandleControlClick( WXWidget WXUNUSED(control), wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown) )
-{
- wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
- wxCheckBoxState state = Get3StateValue();
-
- if (state == wxCHK_UNCHECKED)
- {
- state = wxCHK_CHECKED;
- }
- else if (state == wxCHK_CHECKED)
- {
- // If the style flag to allow the user setting the undetermined state
- // is set, then set the state to undetermined. Otherwise set state to
- // unchecked.
- if ( Is3rdStateAllowedForUser() )
- {
- state = wxCHK_UNDETERMINED;
- }
- else
- {
- state = wxCHK_UNCHECKED;
- }
- }
- else if (state == wxCHK_UNDETERMINED)
- {
- state = wxCHK_UNCHECKED;
- }
- Set3StateValue(state);
-
- event.SetInt(state);
- event.SetEventObject(this);
- ProcessCommand(event);
-}
-
-// Bitmap checkbox
-bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id,
- const wxBitmap *label,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- SetName(name);
- SetValidator(validator);
- m_windowStyle = style;
-
- if (parent) parent->AddChild(this);
-
- if ( id == -1 )
- m_windowId = NewControlId();
- else
- m_windowId = id;
-
- // TODO: Create the bitmap checkbox
-
- return false;
-}
-
-void wxBitmapCheckBox::SetLabel(const wxBitmap *bitmap)
-{
- // TODO
- wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
-}
-
-void wxBitmapCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags)
-{
- wxControl::SetSize( x , y , width , height , sizeFlags ) ;
-}
-
-void wxBitmapCheckBox::SetValue(bool val)
-{
- // TODO
- wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
-}
-
-bool wxBitmapCheckBox::GetValue() const
-{
- // TODO
- wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));
- return false;
-}
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/checklst.cpp
-// Purpose: implementation of wxCheckListBox class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// headers & declarations
-// ============================================================================
-
-#include "wx/wxprec.h"
-
-#if wxUSE_CHECKLISTBOX
-
-#include "wx/checklst.h"
-
-#ifndef WX_PRECOMP
- #include "wx/arrstr.h"
-#endif
-
-#include "wx/mac/uma.h"
-#include <Appearance.h>
-
-// ============================================================================
-// implementation of wxCheckListBox
-// ============================================================================
-
-IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
-
-const short kwxMacListWithVerticalScrollbar = 128 ;
-const short kwxMacListItemHeight = 14 ;
-const short kwxMacListCheckboxWidth = 14 ;
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-typedef struct {
- unsigned short instruction;
- void (*function)();
-} ldefRec, *ldefPtr, **ldefHandle;
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-extern "C"
-{
-static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, Rect *drawRect,
- Cell cell, short dataOffset, short dataLength,
- ListHandle listHandle ) ;
-}
-
-static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, Rect *drawRect,
- Cell cell, short dataOffset, short dataLength,
- ListHandle listHandle )
-{
- wxCheckListBox* list;
- list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
- if ( list == NULL )
- return ;
-
- GrafPtr savePort;
- GrafPtr grafPtr;
- RgnHandle savedClipRegion;
- SInt32 savedPenMode;
- GetPort(&savePort);
- SetPort((**listHandle).port);
- grafPtr = (**listHandle).port ;
- // typecast our refCon
-
- // Calculate the cell rect.
-
- switch( message ) {
- case lInitMsg:
- break;
-
- case lCloseMsg:
- break;
-
- case lDrawMsg:
- {
- const wxString text = list->m_stringArray[cell.v] ;
- int checked = list->m_checks[cell.v] ;
-
- // Save the current clip region, and set the clip region to the area we are about
- // to draw.
-
- savedClipRegion = NewRgn();
- GetClip( savedClipRegion );
-
- ClipRect( drawRect );
- EraseRect( drawRect );
-
- const wxFont& font = list->GetFont();
- if ( font.Ok() )
- {
- ::TextFont( font.GetMacFontNum() ) ;
- ::TextSize( font.GetMacFontSize()) ;
- ::TextFace( font.GetMacFontStyle() ) ;
- }
-
- ThemeButtonDrawInfo info ;
- info.state = kThemeStateActive ;
- info.value = checked ? kThemeButtonOn : kThemeButtonOff ;
- info.adornment = kThemeAdornmentNone ;
- Rect checkRect = *drawRect ;
-
-
- checkRect.left +=0 ;
- checkRect.top +=0 ;
- checkRect.right = checkRect.left + list->m_checkBoxWidth ;
- checkRect.bottom = checkRect.top + list->m_checkBoxHeight ;
- DrawThemeButton(&checkRect,kThemeCheckBox,
- &info,NULL,NULL, NULL,0);
-
- MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset );
-
- DrawText(text, 0 , text.length());
- // If the cell is hilited, do the hilite now. Paint the cell contents with the
- // appropriate QuickDraw transform mode.
-
- if( isSelected ) {
- savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
- SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode );
- PaintRect( drawRect );
- SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode );
- }
-
- // Restore the saved clip region.
-
- SetClip( savedClipRegion );
- DisposeRgn( savedClipRegion );
- }
- break;
- case lHiliteMsg:
-
- // Hilite or unhilite the cell. Paint the cell contents with the
- // appropriate QuickDraw transform mode.
-
- GetPort( &grafPtr );
- savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
- SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode );
- PaintRect( drawRect );
- SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode );
- break;
- default :
- break ;
- }
- SetPort(savePort);
-}
-
-extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
-
-static ListDefUPP macCheckListDefUPP = NULL ;
-
-// ----------------------------------------------------------------------------
-// creation
-// ----------------------------------------------------------------------------
-
-void wxCheckListBox::Init()
-{
-}
-
-bool wxCheckListBox::Create(wxWindow *parent,
- wxWindowID id,
- const wxPoint &pos,
- const wxSize &size,
- const wxArrayString& choices,
- long style,
- const wxValidator& validator,
- const wxString &name)
-{
- wxCArrayString chs(choices);
-
- return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
- style, validator, name);
-}
-
-bool wxCheckListBox::Create(wxWindow *parent,
- wxWindowID id,
- const wxPoint &pos,
- const wxSize &size,
- int n,
- const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString &name)
-{
- if ( !wxCheckListBoxBase::Create(parent, id, pos, size,
- n, choices, style, validator, name) )
- return false;
-
- m_noItems = 0 ; // this will be increased by our append command
- m_selected = 0;
-
- m_checkBoxWidth = 12;
- m_checkBoxHeight= 10;
-
- long h = m_checkBoxHeight ;
-#if TARGET_CARBON
- GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth);
- GetThemeMetric(kThemeMetricCheckBoxHeight,&h);
-#endif
-
- const wxFont& font = GetFont();
-
- FontInfo finfo;
- FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo);
-
- m_TextBaseLineOffset= finfo.leading+finfo.ascent;
- m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent;
-
- if (m_checkBoxHeight<h)
- {
- m_TextBaseLineOffset+= (h-m_checkBoxHeight)/2;
- m_checkBoxHeight= h;
- }
-
- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
-
- ListDefSpec listDef;
- listDef.defType = kListDefUserProcType;
- if ( macCheckListDefUPP == NULL )
- {
- macCheckListDefUPP = NewListDefUPP( wxMacCheckListDefinition );
- }
- listDef.u.userProc = macCheckListDefUPP ;
-
-#if TARGET_CARBON
- Size asize;
-
-
- CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true,
- m_checkBoxHeight+2, 14, false, &listDef, (ControlRef *)&m_macControl );
-
- GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag,
- sizeof(ListHandle), (Ptr) &m_macList, &asize);
-
- SetControlReference( (ControlHandle) m_macControl, (long) this);
- SetControlVisibility( (ControlHandle) m_macControl, false, false);
-
-#else
-
- long result ;
-
- wxStAppResource resload ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false ,
- kwxMacListWithVerticalScrollbar , 0 , 0,
- kControlListBoxProc , (long) this ) ;
- ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
- sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
-
- HLock( (Handle) m_macList ) ;
- ldefHandle ldef ;
- ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ;
- if ( (**(ListHandle)m_macList).listDefProc != NULL )
- {
- (**ldef).instruction = 0x4EF9; /* JMP instruction */
- (**ldef).function = (void(*)()) listDef.u.userProc;
- (**(ListHandle)m_macList).listDefProc = (Handle) ldef ;
- }
-
- Point pt = (**(ListHandle)m_macList).cellSize ;
- pt.v = 14 ;
- LCellSize( pt , (ListHandle)m_macList ) ;
- LAddColumn( 1 , 0 , (ListHandle)m_macList ) ;
-#endif
- OptionBits options = 0;
- if ( style & wxLB_MULTIPLE )
- {
- options += lNoExtend ;
- }
- else if ( style & wxLB_EXTENDED )
- {
- options += lExtendDrag ;
- }
- else
- {
- options = (OptionBits) lOnlyOne ;
- }
- SetListSelectionFlags((ListHandle)m_macList, options);
-
- MacPostControlCreate() ;
-
- for ( int i = 0 ; i < n ; i++ )
- {
- Append( choices[i] ) ;
- }
-
- LSetDrawingMode( true , (ListHandle) m_macList ) ;
-
- return true;
-}
-
-// ----------------------------------------------------------------------------
-// wxCheckListBox functions
-// ----------------------------------------------------------------------------
-
-bool wxCheckListBox::IsChecked(unsigned int item) const
-{
- wxCHECK_MSG( IsValid(item), false,
- _T("invalid index in wxCheckListBox::IsChecked") );
-
- return m_checks[item] != 0;
-}
-
-void wxCheckListBox::Check(unsigned int item, bool check)
-{
- wxCHECK_RET( IsValid(item),
- _T("invalid index in wxCheckListBox::Check") );
-
- // intermediate var is needed to avoid compiler warning with VC++
- bool isChecked = m_checks[item] != 0;
- if ( check != isChecked )
- {
- m_checks[item] = check;
-
- MacRedrawControl() ;
- }
-}
-
-// ----------------------------------------------------------------------------
-// methods forwarded to wxListBox
-// ----------------------------------------------------------------------------
-
-void wxCheckListBox::Delete(unsigned int n)
-{
- wxCHECK_RET( IsValid(n), _T("invalid index in wxListBox::Delete") );
-
- wxListBox::Delete(n);
-
- m_checks.RemoveAt(n);
-}
-
-int wxCheckListBox::DoAppend(const wxString& item)
-{
- LSetDrawingMode( false , (ListHandle) m_macList ) ;
- int pos = wxListBox::DoAppend(item);
-
- // the item is initially unchecked
- m_checks.Insert(false, pos);
- LSetDrawingMode( true , (ListHandle) m_macList ) ;
-
- return pos;
-}
-
-void wxCheckListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
-{
- wxListBox::DoInsertItems(items, pos);
-
- unsigned int count = items.GetCount();
- for ( unsigned int n = 0; n < count; n++ )
- {
- m_checks.Insert(false, pos + n);
- }
-}
-
-void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData)
-{
- // call it first as it does DoClear()
- wxListBox::DoSetItems(items, clientData);
-
- unsigned int count = items.GetCount();
- for ( unsigned int n = 0; n < count; n++ )
- {
- m_checks.Add(false);
- }
-}
-
-void wxCheckListBox::DoClear()
-{
- m_checks.Empty();
-}
-
-BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
- EVT_CHAR(wxCheckListBox::OnChar)
- EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick)
-END_EVENT_TABLE()
-
-// this will only work as soon as
-
-void wxCheckListBox::OnChar(wxKeyEvent& event)
-{
- if ( event.GetKeyCode() == WXK_SPACE )
- {
- int index = GetSelection() ;
- if ( index >= 0 )
- {
- Check(index, !IsChecked(index) ) ;
- wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId());
- event.SetInt(index);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
- }
- }
- else
- event.Skip();
-}
-
-void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
-{
- // clicking on the item selects it, clicking on the checkmark toggles
- if ( event.GetX() <= 20 /*check width*/ ) {
- int lineheight ;
- int topcell ;
-#if TARGET_CARBON
- Point pt ;
- GetListCellSize( (ListHandle)m_macList , &pt ) ;
- lineheight = pt.v ;
- ListBounds visible ;
- GetListVisibleCells( (ListHandle)m_macList , &visible ) ;
- topcell = visible.top ;
-#else
- lineheight = (**(ListHandle)m_macList).cellSize.v ;
- topcell = (**(ListHandle)m_macList).visible.top ;
-#endif
- size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ;
-
- if ( nItem < m_noItems )
- {
- Check(nItem, !IsChecked(nItem) ) ;
- wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId());
- event.SetInt(nItem);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
- }
- //else: it's not an error, just click outside of client zone
- }
- else {
- // implement default behaviour: clicking on the item selects it
- event.Skip();
- }
-}
-
-#endif // wxUSE_CHECKLISTBOX
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/choice.cpp
-// Purpose: wxChoice
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#if wxUSE_CHOICE
-
-#include "wx/choice.h"
-
-#ifndef WX_PRECOMP
- #include "wx/menu.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
-
-extern MenuHandle NewUniqueMenu() ;
-
-wxChoice::~wxChoice()
-{
- if ( HasClientObjectData() )
- {
- unsigned int i, max = GetCount();
-
- for ( i = 0; i < max; ++i )
- delete GetClientObject(i);
- }
-
- // DeleteMenu( m_macPopUpMenuId ) ;
- // DisposeMenu( m_macPopUpMenuHandle ) ;
-}
-
-bool wxChoice::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- wxCArrayString chs(choices);
-
- return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
- style, validator, name);
-}
-
-bool wxChoice::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- int n, const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 ,
- kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
-
- m_macPopUpMenuHandle = NewUniqueMenu() ;
- SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
- SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ;
- SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ;
- if ( n > 0 )
- SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ;
- MacPostControlCreate() ;
- // TODO wxCB_SORT
- for ( int i = 0; i < n; i++ )
- {
- Append(choices[i]);
- }
- return true;
-}
-
-// ----------------------------------------------------------------------------
-// adding/deleting items to/from the list
-// ----------------------------------------------------------------------------
-int wxChoice::DoAppend(const wxString& item)
-{
- UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item, m_font.GetEncoding() );
- m_strings.Add( item ) ;
- m_datas.Add( NULL ) ;
- int index = m_strings.GetCount() - 1 ;
- DoSetItemClientData( index , NULL ) ;
- SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ;
- return index ;
-}
-
-int wxChoice::DoInsert(const wxString& item, unsigned int pos)
-{
- wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
- wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
-
- if (pos == GetCount())
- return DoAppend(item);
-
- UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item, m_font.GetEncoding() );
- m_strings.Insert( item, pos ) ;
- m_datas.Insert( NULL, pos ) ;
- DoSetItemClientData( pos , NULL ) ;
- SetControl32BitMaximum( (ControlHandle) m_macControl , pos) ;
- return pos ;
-}
-
-void wxChoice::Delete(unsigned int n)
-{
- wxCHECK_RET( IsValid(n), wxT("invalid item index in wxChoice::Delete") );
- if ( HasClientObjectData() )
- {
- delete GetClientObject(n);
- }
- ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ;
- m_strings.RemoveAt( n ) ;
- m_datas.RemoveAt( n ) ;
- SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ;
-}
-
-void wxChoice::Clear()
-{
- FreeData();
- for ( unsigned int i = 0 ; i < GetCount() ; i++ )
- {
- ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , 1 ) ;
- }
- m_strings.Empty() ;
- m_datas.Empty() ;
- SetControl32BitMaximum( (ControlHandle) m_macControl , 0 ) ;
-}
-
-void wxChoice::FreeData()
-{
- if ( HasClientObjectData() )
- {
- unsigned int count = GetCount();
- for ( unsigned int n = 0; n < count; n++ )
- {
- delete GetClientObject(n);
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// selection
-// ----------------------------------------------------------------------------
-int wxChoice::GetSelection() const
-{
- return GetControl32BitValue( (ControlHandle) m_macControl ) -1 ;
-}
-
-void wxChoice::SetSelection(int n)
-{
- SetControl32BitValue( (ControlHandle) m_macControl , n + 1 ) ;
-}
-
-// ----------------------------------------------------------------------------
-// string list functions
-// ----------------------------------------------------------------------------
-
-unsigned int wxChoice::GetCount() const
-{
- return m_strings.GetCount() ;
-}
-
-void wxChoice::SetString(unsigned int n, const wxString& s)
-{
- wxFAIL_MSG(wxT("wxChoice::SetString() not yet implemented"));
-#if 0 // should do this, but no Insert() so far
- Delete(n);
- Insert(n + 1, s);
-#endif
-}
-
-wxString wxChoice::GetString(unsigned int n) const
-{
- wxCHECK_MSG( IsValid(n), wxEmptyString,
- _T("wxChoice::GetString(): invalid index") );
-
- return m_strings[n] ;
-}
-
-// ----------------------------------------------------------------------------
-// client data
-// ----------------------------------------------------------------------------
-void wxChoice::DoSetItemClientData(unsigned int n, void* clientData)
-{
- wxCHECK_RET( n >= 0 && (unsigned int)n < m_datas.GetCount(),
- wxT("invalid index in wxChoice::SetClientData") );
-
- m_datas[n] = (char*) clientData ;
-}
-
-void *wxChoice::DoGetItemClientData(unsigned int n) const
-{
- wxCHECK_MSG( n >= 0 && (unsigned int)n < m_datas.GetCount(), NULL,
- wxT("invalid index in wxChoice::GetClientData") );
- return (void *)m_datas[n];
-}
-
-void wxChoice::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
-{
- DoSetItemClientData(n, clientData);
-}
-
-wxClientData* wxChoice::DoGetItemClientObject(unsigned int n) const
-{
- return (wxClientData *)DoGetItemClientData(n);
-}
-
-void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
-{
- wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
- int n = GetSelection();
- // actually n should be made sure by the os to be a valid selection, but ...
- if ( n > -1 )
- {
- event.SetInt( n );
- event.SetString(GetStringSelection());
- event.SetEventObject(this);
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject(n) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(n) );
- ProcessCommand(event);
- }
-}
-
-wxSize wxChoice::DoGetBestSize() const
-{
- int lbWidth = GetCount() > 0 ? 20 : 100; // some defaults
- int lbHeight = 20;
- int wLine;
-#if TARGET_CARBON
- long metric ;
- GetThemeMetric(kThemeMetricPopupButtonHeight , &metric );
- lbHeight = metric ;
-#endif
- {
- wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;
- if ( m_font.Ok() )
- {
- ::TextFont( m_font.GetMacFontNum() ) ;
- ::TextSize( m_font.GetMacFontSize() ) ;
- ::TextFace( m_font.GetMacFontStyle() ) ;
- }
- else
- {
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
- }
- // Find the widest line
- for(unsigned int i = 0; i < GetCount(); i++) {
- wxString str(GetString(i));
- #if wxUSE_UNICODE
- Point bounds={0,0} ;
- SInt16 baseline ;
- ::GetThemeTextDimensions( wxMacCFStringHolder( str , m_font.GetEncoding() ) ,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- wLine = bounds.h ;
- #else
- wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ;
- #endif
- lbWidth = wxMax(lbWidth, wLine);
- }
- // Add room for the popup arrow
- lbWidth += 2 * lbHeight ;
- // And just a bit more
- int cx = ::TextWidth( "X" , 0 , 1 ) ;
- lbWidth += cx ;
-
- }
- return wxSize(lbWidth, lbHeight);
-}
-
-#endif // wxUSE_CHOICE
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/clipbrd.cpp
-// Purpose: Clipboard functionality
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/clipbrd.h"
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/log.h"
- #include "wx/app.h"
- #include "wx/utils.h"
- #include "wx/frame.h"
- #include "wx/bitmap.h"
-#endif
-
-#include "wx/metafile.h"
-
-#ifndef __DARWIN__
-#include <Scrap.h>
-#endif
-#include "wx/mac/uma.h"
-
-#define wxUSE_DATAOBJ 1
-
-#include <string.h>
-
-// the trace mask we use with wxLogTrace() - call
-// wxLog::AddTraceMask(TRACE_CLIPBOARD) to enable the trace messages from here
-// (there will be a *lot* of them!)
-static const wxChar *TRACE_CLIPBOARD = _T("clipboard");
-
-void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
-{
-#if !TARGET_CARBON
- OSErr err = noErr ;
-#else
- OSStatus err = noErr ;
-#endif
- void * data = NULL ;
- Size byteCount;
-
- switch (dataFormat.GetType())
- {
- case wxDF_OEMTEXT:
- dataFormat = wxDF_TEXT;
- // fall through
-
- case wxDF_TEXT:
- break;
- case wxDF_UNICODETEXT:
- break;
- case wxDF_BITMAP :
- case wxDF_METAFILE :
- break ;
- default:
- {
- wxLogError(_("Unsupported clipboard format."));
- return NULL;
- }
- }
-
-#if TARGET_CARBON
- ScrapRef scrapRef;
-
- err = GetCurrentScrap( &scrapRef );
- if ( err != noTypeErr && err != memFullErr )
- {
- ScrapFlavorFlags flavorFlags;
-
- if (( err = GetScrapFlavorFlags( scrapRef, dataFormat.GetFormatId(), &flavorFlags )) == noErr)
- {
- if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr)
- {
- Size allocSize = byteCount ;
- if ( dataFormat.GetType() == wxDF_TEXT )
- allocSize += 1 ;
- else if ( dataFormat.GetType() == wxDF_UNICODETEXT )
- allocSize += 2 ;
-
- data = new char[ allocSize ] ;
-
- if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr )
- {
- *len = allocSize ;
- if ( dataFormat.GetType() == wxDF_TEXT )
- ((char*)data)[byteCount] = 0 ;
- if ( dataFormat.GetType() == wxDF_UNICODETEXT )
- ((wxChar*)data)[byteCount/2] = 0 ;
- }
- else
- {
- delete[] ((char *)data) ;
- data = NULL ;
- }
- }
- }
- }
-
-#else
- long offset ;
- Handle datahandle = NewHandle(0) ;
- HLock( datahandle ) ;
- GetScrap( datahandle , dataFormat.GetFormatId() , &offset ) ;
- HUnlock( datahandle ) ;
- if ( GetHandleSize( datahandle ) > 0 )
- {
- byteCount = GetHandleSize( datahandle ) ;
- Size allocSize = byteCount ;
- if ( dataFormat.GetType() == wxDF_TEXT )
- allocSize += 1 ;
- else if ( dataFormat.GetType() == wxDF_UNICODETEXT )
- allocSize += 2 ;
-
- data = new char[ allocSize ] ;
-
- memcpy( (char*) data , (char*) *datahandle , byteCount ) ;
- if ( dataFormat.GetType() == wxDF_TEXT )
- ((char*)data)[byteCount] = 0 ;
- if ( dataFormat.GetType() == wxDF_UNICODETEXT )
- ((wxChar*)data)[byteCount/2] = 0 ;
- *len = byteCount ;
- }
- DisposeHandle( datahandle ) ;
-#endif
- if ( err )
- {
- wxLogSysError(_("Failed to get clipboard data."));
-
- return NULL ;
- }
-
- if ( dataFormat.GetType() == wxDF_TEXT )
- {
- wxMacConvertNewlines10To13( (char*) data ) ;
- }
-
- return data;
-}
-
-
-/*
- * Generalized clipboard implementation by Matthew Flatt
- */
-
-IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
-
-wxClipboard::wxClipboard()
-{
- m_open = false ;
- m_data = NULL ;
-}
-
-wxClipboard::~wxClipboard()
-{
- if (m_data)
- {
- delete m_data;
- m_data = (wxDataObject*) NULL;
- }
-}
-
-void wxClipboard::Clear()
-{
- if (m_data)
- {
- delete m_data;
- m_data = (wxDataObject*) NULL;
- }
-#if TARGET_CARBON
- OSStatus err ;
- err = ClearCurrentScrap( );
-#else
- OSErr err ;
- err = ZeroScrap( );
-#endif
- if ( err )
- {
- wxLogSysError(_("Failed to empty the clipboard."));
- }
-}
-
-bool wxClipboard::Flush()
-{
- return false;
-}
-
-bool wxClipboard::Open()
-{
- wxCHECK_MSG( !m_open, false, wxT("clipboard already open") );
- m_open = true ;
- return true ;
-}
-
-bool wxClipboard::IsOpened() const
-{
- return m_open;
-}
-
-bool wxClipboard::SetData( wxDataObject *data )
-{
- wxCHECK_MSG( m_open, false, wxT("clipboard not open") );
-
- wxCHECK_MSG( data, false, wxT("data is invalid") );
-
- Clear();
- // as we can only store one wxDataObject, this is the same in this
- // implementation
- return AddData( data );
-}
-
-bool wxClipboard::AddData( wxDataObject *data )
-{
- wxCHECK_MSG( m_open, false, wxT("clipboard not open") );
-
- wxCHECK_MSG( data, false, wxT("data is invalid") );
-
- /* we can only store one wxDataObject */
- Clear();
-
- m_data = data;
-
- /* get formats from wxDataObjects */
- wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
- m_data->GetAllFormats( array );
-
- for (size_t i = 0; i < m_data->GetFormatCount(); i++)
- {
- wxLogTrace( TRACE_CLIPBOARD,
- wxT("wxClipboard now supports atom %s"),
- array[i].GetId().c_str() );
-
-#if !TARGET_CARBON
- OSErr err = noErr ;
-#else
- OSStatus err = noErr ;
-#endif
- size_t sz = data->GetDataSize( array[i] ) ;
- void* buf = malloc( sz + 1 ) ;
- if ( buf )
- {
- data->GetDataHere( array[i] , buf ) ;
- OSType mactype = 0 ;
- switch ( array[i].GetType() )
- {
- case wxDF_TEXT:
- case wxDF_OEMTEXT:
- mactype = kScrapFlavorTypeText ;
- break ;
- #if wxUSE_UNICODE
- case wxDF_UNICODETEXT :
- mactype = kScrapFlavorTypeUnicode ;
- break ;
- #endif
- #if wxUSE_DRAG_AND_DROP
- case wxDF_METAFILE:
- mactype = kScrapFlavorTypePicture ;
- break ;
- #endif
- case wxDF_BITMAP:
- case wxDF_DIB:
- mactype = kScrapFlavorTypePicture ;
- break ;
- default:
- break ;
- }
- UMAPutScrap( sz , mactype , buf ) ;
- free( buf ) ;
- }
- }
-
- delete[] array;
-
- return true ;
-}
-
-void wxClipboard::Close()
-{
- wxCHECK_RET( m_open, wxT("clipboard not open") );
-
- m_open = false ;
-
- // Get rid of cached object. If this is not done copying from another application will
- // only work once
- if (m_data)
- {
- delete m_data;
- m_data = (wxDataObject*) NULL;
- }
-
-}
-
-bool wxClipboard::IsSupported( const wxDataFormat &dataFormat )
-{
- if ( m_data )
- {
- return m_data->IsSupported( dataFormat ) ;
- }
-#if TARGET_CARBON
- OSStatus err = noErr;
- ScrapRef scrapRef;
-
- err = GetCurrentScrap( &scrapRef );
- if ( err != noTypeErr && err != memFullErr )
- {
- ScrapFlavorFlags flavorFlags;
- Size byteCount;
-
- if (( err = GetScrapFlavorFlags( scrapRef, dataFormat.GetFormatId(), &flavorFlags )) == noErr)
- {
- if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr)
- {
- return true ;
- }
- }
- }
- return false;
-
-#else
- long offset ;
- Handle datahandle = NewHandle(0) ;
- HLock( datahandle ) ;
- GetScrap( datahandle , dataFormat.GetFormatId() , &offset ) ;
- HUnlock( datahandle ) ;
- bool hasData = GetHandleSize( datahandle ) > 0 ;
- DisposeHandle( datahandle ) ;
- return hasData ;
-#endif
-}
-
-bool wxClipboard::GetData( wxDataObject& data )
-{
- wxCHECK_MSG( m_open, false, wxT("clipboard not open") );
-
- size_t formatcount = data.GetFormatCount() + 1 ;
- wxDataFormat *array = new wxDataFormat[ formatcount ];
- array[0] = data.GetPreferredFormat();
- data.GetAllFormats( &array[1] );
-
- bool transferred = false ;
-
- if ( m_data )
- {
- for (size_t i = 0; !transferred && i < formatcount ; i++)
- {
- wxDataFormat format = array[i] ;
- if ( m_data->IsSupported( format ) )
- {
- int size = m_data->GetDataSize( format );
- transferred = true ;
-
- if (size == 0)
- {
- data.SetData(format , 0 , 0 ) ;
- }
- else
- {
- char *d = new char[size];
- m_data->GetDataHere( format , (void*) d );
- data.SetData( format , size , d ) ;
- delete[] d ;
- }
- }
- }
- }
- /* get formats from wxDataObjects */
- if ( !transferred )
- {
- for (size_t i = 0; !transferred && i < formatcount ; i++)
- {
- wxDataFormat format = array[i] ;
-
- switch ( format.GetType() )
- {
- case wxDF_TEXT :
- case wxDF_OEMTEXT :
- case wxDF_BITMAP :
- case wxDF_METAFILE :
- {
- long len ;
- char* s = (char*)wxGetClipboardData(format, &len );
- if ( s )
- {
- data.SetData( format , len , s ) ;
- delete [] s;
-
- transferred = true ;
- }
- }
- break ;
-
- default :
- break ;
- }
- }
- }
-
- delete[] array ;
- return transferred ;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: colordlg.cpp
-// Purpose: wxColourDialog class. NOTE: you can use the generic class
-// if you wish, instead of implementing this.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/mac/colordlg.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
-
-#include "wx/mac/private.h"
-#ifndef __DARWIN__
-#include <ColorPicker.h>
-#endif
-
-/*
- * wxColourDialog
- */
-
-wxColourDialog::wxColourDialog()
-{
- m_dialogParent = NULL;
-}
-
-wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
-{
- Create(parent, data);
-}
-
-bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
-{
- m_dialogParent = parent;
-
- if (data)
- m_colourData = *data;
- return TRUE;
-}
-
-int wxColourDialog::ShowModal()
-{
- Point where ;
- RGBColor currentColor = *((RGBColor*)m_colourData.m_dataColour.GetPixel()) , newColor ;
-
- where.h = where.v = -1;
-
- if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor ))
- {
- m_colourData.m_dataColour.Set( (WXCOLORREF*) &newColor ) ;
- return wxID_OK;
- }
- else
- {
- return wxID_CANCEL;
- }
-
- return wxID_CANCEL;
-}
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/colour.cpp
-// Purpose: wxColour class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/colour.h"
-
-#ifndef WX_PRECOMP
- #include "wx/gdicmn.h"
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
-
-// Colour
-
-#include "wx/mac/private.h"
-
-static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
-static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
-{
- RGBColor* col = (RGBColor*) color ;
- col->red = (red << 8) + red;
- col->blue = (blue << 8) + blue;
- col->green = (green << 8) + green;
-}
-
-void wxColour::Init()
-{
- m_isInit = false;
- m_red =
- m_blue =
- m_green = 0;
-
- wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
-}
-
-wxColour::wxColour (const wxColour& col)
- : wxObject()
-{
- m_red = col.m_red;
- m_green = col.m_green;
- m_blue = col.m_blue;
- m_isInit = col.m_isInit;
-
- memcpy( &m_pixel , &col.m_pixel , 6 ) ;
-}
-
-wxColour::wxColour (const wxColour* col)
-{
- m_red = col->m_red;
- m_green = col->m_green;
- m_blue = col->m_blue;
- m_isInit = col->m_isInit;
-
- memcpy( &m_pixel , &col->m_pixel , 6 ) ;
-}
-
-wxColour& wxColour::operator =(const wxColour& col)
-{
- m_red = col.m_red;
- m_green = col.m_green;
- m_blue = col.m_blue;
- m_isInit = col.m_isInit;
-
- memcpy( &m_pixel , &col.m_pixel , 6 ) ;
-
- return *this;
-}
-
-wxColour::~wxColour ()
-{
-}
-
-void wxColour::InitWith (unsigned char r, unsigned char g, unsigned char b)
-{
- m_red = r;
- m_green = g;
- m_blue = b;
- m_isInit = true;
-
- wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
-}
-
-void wxColour::Set( const WXCOLORREF* color )
-{
- RGBColor* col = (RGBColor*) color ;
- memcpy( &m_pixel , color , 6 ) ;
- m_red = col->red>>8 ;
- m_blue = col->blue>>8 ;
- m_green = col->green>>8 ;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/combobox.cpp
-// Purpose: wxComboBox class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/combobox.h"
-
-#ifndef WX_PRECOMP
- #include "wx/button.h"
- #include "wx/menu.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
-
-// composite combobox implementation by Dan "Bud" Keith bud@otsys.com
-
-
-static int nextPopUpMenuId = 1000 ;
-MenuHandle NewUniqueMenu()
-{
- MenuHandle handle = NewMenu( nextPopUpMenuId , "\pMenu" ) ;
- nextPopUpMenuId++ ;
- return handle ;
-}
-
-
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-// the margin between the text control and the choice
-static const wxCoord MARGIN = 2;
-static const int POPUPWIDTH = 18;
-static const int POPUPHEIGHT = 23;
-
-
-// ----------------------------------------------------------------------------
-// wxComboBoxText: text control forwards events to combobox
-// ----------------------------------------------------------------------------
-
-class wxComboBoxText : public wxTextCtrl
-{
-public:
- wxComboBoxText( wxComboBox * cb )
- : wxTextCtrl( cb , 1 )
- {
- m_cb = cb;
- }
-
-protected:
- void OnChar( wxKeyEvent& event )
- {
- if ( event.GetKeyCode() == WXK_RETURN )
- {
- wxString value = GetValue();
-
- if ( m_cb->GetCount() == 0 )
- {
- // make Enter generate "selected" event if there is only one item
- // in the combobox - without it, it's impossible to select it at
- // all!
- wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, m_cb->GetId() );
- event.SetInt( 0 );
- event.SetString( value );
- event.SetEventObject( m_cb );
- m_cb->GetEventHandler()->ProcessEvent( event );
- }
- else
- {
- // add the item to the list if it's not there yet
- if ( m_cb->FindString(value) == wxNOT_FOUND )
- {
- m_cb->Append(value);
- m_cb->SetStringSelection(value);
-
- // and generate the selected event for it
- wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, m_cb->GetId() );
- event.SetInt( m_cb->GetCount() - 1 );
- event.SetString( value );
- event.SetEventObject( m_cb );
- m_cb->GetEventHandler()->ProcessEvent( event );
- }
-
- // This will invoke the dialog default action, such
- // as the clicking the default button.
-
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
- if ( tlw && tlw->GetDefaultItem() )
- {
- wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
- if ( def && def->IsEnabled() )
- {
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
- event.SetEventObject(def);
- def->Command(event);
- return ;
- }
- }
-
- return;
- }
- }
-
- event.Skip();
- }
-
-private:
- wxComboBox *m_cb;
-
- DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(wxComboBoxText, wxTextCtrl)
- EVT_CHAR( wxComboBoxText::OnChar)
-END_EVENT_TABLE()
-
-class wxComboBoxChoice : public wxChoice
-{
-public:
- wxComboBoxChoice(wxComboBox *cb, int style)
- : wxChoice( cb , 1 )
- {
- m_cb = cb;
- }
-
-protected:
- void OnChoice( wxCommandEvent& e )
- {
- wxString s = e.GetString();
-
- m_cb->DelegateChoice( s );
- wxCommandEvent event2(wxEVT_COMMAND_COMBOBOX_SELECTED, m_cb->GetId() );
- event2.SetInt(m_cb->GetSelection());
- event2.SetEventObject(m_cb);
- event2.SetString(m_cb->GetStringSelection());
- m_cb->ProcessCommand(event2);
- }
-
-private:
- wxComboBox *m_cb;
-
- DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(wxComboBoxChoice, wxChoice)
- EVT_CHOICE(-1, wxComboBoxChoice::OnChoice)
-END_EVENT_TABLE()
-
-wxComboBox::~wxComboBox()
-{
- // delete client objects
- FreeData();
-
- // delete the controls now, don't leave them alive even though they would
- // still be eventually deleted by our parent - but it will be too late, the
- // user code expects them to be gone now
- if (m_text != NULL) {
- delete m_text;
- m_text = NULL;
- }
- if (m_choice != NULL) {
- delete m_choice;
- m_choice = NULL;
- }
-}
-
-
-// ----------------------------------------------------------------------------
-// geometry
-// ----------------------------------------------------------------------------
-
-wxSize wxComboBox::DoGetBestSize() const
-{
- wxSize size = m_choice->GetBestSize();
-
- if ( m_text != NULL )
- {
- wxSize sizeText = m_text->GetBestSize();
-
- size.x = POPUPWIDTH + sizeText.x + MARGIN;
- }
-
- return size;
-}
-
-void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
- height = POPUPHEIGHT;
-
- wxControl::DoMoveWindow(x, y, width, height);
-
- if ( m_text == NULL )
- {
- m_choice->SetSize(0, 0 , width, -1);
- }
- else
- {
- wxCoord wText = width - POPUPWIDTH - MARGIN;
- m_text->SetSize(0, 0, wText, height);
- m_choice->SetSize(0 + wText + MARGIN, 0, POPUPWIDTH, -1);
- }
-}
-
-
-
-// ----------------------------------------------------------------------------
-// operations forwarded to the subcontrols
-// ----------------------------------------------------------------------------
-
-bool wxComboBox::Enable(bool enable)
-{
- if ( !wxControl::Enable(enable) )
- return false;
-
- return true;
-}
-
-bool wxComboBox::Show(bool show)
-{
- if ( !wxControl::Show(show) )
- return false;
-
- return true;
-}
-
-void wxComboBox::SetFocus()
-{
- if ( m_text != NULL) {
- m_text->SetFocus();
- }
-}
-
-
-void wxComboBox::DelegateTextChanged( const wxString& value )
-{
- SetStringSelection( value );
-}
-
-
-void wxComboBox::DelegateChoice( const wxString& value )
-{
- SetStringSelection( value );
-}
-
-
-bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- wxCArrayString chs( choices );
-
- return Create( parent, id, value, pos, size, chs.GetCount(),
- chs.GetStrings(), style, validator, name );
-}
-
-
-bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- int n, const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
- wxDefaultValidator, name) )
- {
- return false;
- }
-
- m_choice = new wxComboBoxChoice(this, style );
-
- wxSize csize = size;
- if ( style & wxCB_READONLY )
- {
- m_text = NULL;
- }
- else
- {
- m_text = new wxComboBoxText(this);
- if ( size.y == -1 ) {
- csize.y = m_text->GetSize().y ;
- }
- }
-
- DoSetSize(pos.x, pos.y, csize.x, csize.y);
-
- for ( int i = 0 ; i < n ; i++ )
- {
- m_choice->DoAppend( choices[ i ] );
- }
-
- return true;
-}
-
-wxString wxComboBox::GetValue() const
-{
- wxString result;
-
- if ( m_text == NULL )
- {
- result = m_choice->GetString( m_choice->GetSelection() );
- }
- else
- {
- result = m_text->GetValue();
- }
-
- return result;
-}
-
-void wxComboBox::SetValue(const wxString& value)
-{
- int s = FindString (value);
- if (s == wxNOT_FOUND && !HasFlag(wxCB_READONLY) )
- {
- m_choice->Append(value) ;
- }
- SetStringSelection( value ) ;
-}
-
-// Clipboard operations
-void wxComboBox::Copy()
-{
- if ( m_text != NULL )
- {
- m_text->Copy();
- }
-}
-
-void wxComboBox::Cut()
-{
- if ( m_text != NULL )
- {
- m_text->Cut();
- }
-}
-
-void wxComboBox::Paste()
-{
- if ( m_text != NULL )
- {
- m_text->Paste();
- }
-}
-
-void wxComboBox::SetEditable(bool editable)
-{
- if ( ( m_text == NULL ) && editable )
- {
- m_text = new wxComboBoxText( this );
- }
- else if ( ( m_text != NULL ) && !editable )
- {
- delete m_text;
- m_text = NULL;
- }
-
- int currentX, currentY;
- GetPosition( ¤tX, ¤tY );
-
- int currentW, currentH;
- GetSize( ¤tW, ¤tH );
-
- DoMoveWindow( currentX, currentY, currentW, currentH );
-}
-
-void wxComboBox::SetInsertionPoint(long pos)
-{
- // TODO
-}
-
-void wxComboBox::SetInsertionPointEnd()
-{
- // TODO
-}
-
-long wxComboBox::GetInsertionPoint() const
-{
- // TODO
- return 0;
-}
-
-wxTextPos wxComboBox::GetLastPosition() const
-{
- // TODO
- return 0;
-}
-
-void wxComboBox::Replace(long from, long to, const wxString& value)
-{
- // TODO
-}
-
-void wxComboBox::Remove(long from, long to)
-{
- // TODO
-}
-
-void wxComboBox::SetSelection(long from, long to)
-{
- // TODO
-}
-
-int wxComboBox::DoAppend(const wxString& item)
-{
- return m_choice->DoAppend( item ) ;
-}
-
-int wxComboBox::DoInsert(const wxString& item, unsigned int pos)
-{
- return m_choice->DoInsert( item , pos ) ;
-}
-
-void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
-{
- return m_choice->DoSetItemClientData( n , clientData ) ;
-}
-
-void* wxComboBox::DoGetItemClientData(unsigned int n) const
-{
- return m_choice->DoGetItemClientData( n ) ;
-}
-
-void wxComboBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
-{
- return m_choice->DoSetItemClientObject(n , clientData);
-}
-
-wxClientData* wxComboBox::DoGetItemClientObject(unsigned int n) const
-{
- return m_choice->DoGetItemClientObject( n ) ;
-}
-
-void wxComboBox::FreeData()
-{
- if ( HasClientObjectData() )
- {
- unsigned int count = GetCount();
- for ( unsigned int n = 0; n < count; n++ )
- {
- SetClientObject( n, NULL );
- }
- }
-}
-
-void wxComboBox::Delete(unsigned int n)
-{
- // force client object deletion
- if( HasClientObjectData() )
- SetClientObject( n, NULL );
- m_choice->Delete( n );
-}
-
-void wxComboBox::Clear()
-{
- FreeData();
- m_choice->Clear();
-}
-
-int wxComboBox::GetSelection() const
-{
- return m_choice->GetSelection();
-}
-
-void wxComboBox::SetSelection(int n)
-{
- m_choice->SetSelection( n );
-
- if ( m_text != NULL )
- {
- m_text->SetValue(GetString(n));
- }
-}
-
-int wxComboBox::FindString(const wxString& s, bool bCase ) const
-{
- return m_choice->FindString( s , bCase );
-}
-
-wxString wxComboBox::GetString(unsigned int n) const
-{
- return m_choice->GetString( n );
-}
-
-wxString wxComboBox::GetStringSelection() const
-{
- int sel = GetSelection ();
-
- if (sel != wxNOT_FOUND)
- return wxString(this->GetString((unsigned int)sel));
- else
- return wxEmptyString;
-}
-
-void wxComboBox::SetString(unsigned int n, const wxString& s)
-{
- m_choice->SetString( n , s );
-}
-
-bool wxComboBox::IsEditable() const
-{
- return m_text != NULL && !HasFlag(wxCB_READONLY);
-}
-
-void wxComboBox::Undo()
-{
- if (m_text != NULL)
- m_text->Undo();
-}
-
-void wxComboBox::Redo()
-{
- if (m_text != NULL)
- m_text->Redo();
-}
-
-void wxComboBox::SelectAll()
-{
- if (m_text != NULL)
- m_text->SelectAll();
-}
-
-bool wxComboBox::CanCopy() const
-{
- if (m_text != NULL)
- return m_text->CanCopy();
- else
- return false;
-}
-
-bool wxComboBox::CanCut() const
-{
- if (m_text != NULL)
- return m_text->CanCut();
- else
- return false;
-}
-
-bool wxComboBox::CanPaste() const
-{
- if (m_text != NULL)
- return m_text->CanPaste();
- else
- return false;
-}
-
-bool wxComboBox::CanUndo() const
-{
- if (m_text != NULL)
- return m_text->CanUndo();
- else
- return false;
-}
-
-bool wxComboBox::CanRedo() const
-{
- if (m_text != NULL)
- return m_text->CanRedo();
- else
- return false;
-}
-
-void wxComboBox::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 WXUNUSED(controlpart) , bool WXUNUSED(mouseStillDown))
-{
- wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
- event.SetInt(GetSelection());
- event.SetEventObject(this);
- event.SetString(GetStringSelection());
- ProcessCommand(event);
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/control.cpp
-// Purpose: wxControl class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/control.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/panel.h"
- #include "wx/dc.h"
- #include "wx/dcclient.h"
- #include "wx/button.h"
- #include "wx/dialog.h"
- #include "wx/scrolbar.h"
- #include "wx/stattext.h"
- #include "wx/statbox.h"
- #include "wx/radiobox.h"
- #include "wx/sizer.h"
-#endif // WX_PRECOMP
-
-#include "wx/notebook.h"
-#include "wx/tabctrl.h"
-#include "wx/spinbutt.h"
-
-IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
-
-BEGIN_EVENT_TABLE(wxControl, wxWindow)
- EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
- EVT_PAINT( wxControl::OnPaint )
-END_EVENT_TABLE()
-
-#include "wx/mac/uma.h"
-#include "wx/mac/private.h"
-
-// Item members
-
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-typedef struct {
- unsigned short instruction;
- void (*function)();
-} cdefRec, *cdefPtr, **cdefHandle;
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-ControlActionUPP wxMacLiveScrollbarActionUPP = NULL ;
-wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ;
-
-pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode ) ;
-pascal void wxMacLiveScrollbarActionProc( ControlHandle control , ControlPartCode partCode )
-{
- if ( partCode != 0)
- {
- wxControl* wx = (wxControl*) GetControlReference( control ) ;
- if ( wx )
- {
- wx->MacHandleControlClick( (WXWidget) control , partCode , true /* stillDown */ ) ;
- }
- }
-}
-
-ControlColorUPP wxMacSetupControlBackgroundUPP = NULL ;
-ControlDefUPP wxMacControlActionUPP = NULL ;
-
-pascal SInt32 wxMacControlDefinition(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param)
-{
-
- wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ;
- if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
- {
- if( message == drawCntl )
- {
- wxMacWindowClipper clip( wx ) ;
- return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ;
- }
- else
- return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ;
- }
- return NULL ;
-}
-
-pascal OSStatus wxMacSetupControlBackground( ControlRef iControl , SInt16 iMessage , SInt16 iDepth , Boolean iIsColor )
-{
- OSStatus status = noErr ;
- switch( iMessage )
- {
- case kControlMsgSetUpBackground :
- {
- wxControl* wx = (wxControl*) GetControlReference( iControl ) ;
- if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) )
- {
- wxDC::MacSetupBackgroundForCurrentPort( wx->MacGetBackgroundBrush() ) ;
-#if TARGET_CARBON
- // under classic this would lead to partial redraws
- RgnHandle clip = NewRgn() ;
- int x = 0 , y = 0;
-
- wx->MacWindowToRootWindow( &x,&y ) ;
- CopyRgn( (RgnHandle) wx->MacGetVisibleRegion(false).GetWXHRGN() , clip ) ;
- OffsetRgn( clip , x , y ) ;
- SetClip( clip ) ;
- DisposeRgn( clip ) ;
-#endif
- }
- else
- {
- status = paramErr ;
- }
- }
- break ;
- default :
- status = paramErr ;
- break ;
- }
- return status ;
-}
-
-wxControl::wxControl()
-{
- m_macControl = NULL ;
- m_macControlAction = NULL ;
- m_macHorizontalBorder = 0 ; // additional pixels around the real control
- m_macVerticalBorder = 0 ;
- m_backgroundColour = *wxWHITE;
- m_foregroundColour = *wxBLACK;
-
- if ( wxMacLiveScrollbarActionUPP == NULL )
- {
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
- wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc );
-#else
- wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ;
-#endif
- }
-}
-
-bool wxControl::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- m_macControl = NULL ;
- m_macHorizontalBorder = 0 ; // additional pixels around the real control
- m_macVerticalBorder = 0 ;
-
- bool rval = wxWindow::Create(parent, id, pos, size, style, name);
- if ( parent )
- {
- m_backgroundColour = parent->GetBackgroundColour() ;
- m_foregroundColour = parent->GetForegroundColour() ;
- }
- if (rval) {
-#if wxUSE_VALIDATORS
- SetValidator(validator);
-#endif
- }
- return rval;
-}
-
-wxControl::~wxControl()
-{
- m_isBeingDeleted = true;
- wxRemoveMacControlAssociation( this ) ;
- // If we delete an item, we should initialize the parent panel,
- // because it could now be invalid.
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
- if ( tlw )
- {
- if ( tlw->GetDefaultItem() == (wxButton*) this)
- tlw->SetDefaultItem(NULL);
- }
- if ( (ControlHandle) m_macControl )
- {
- // in case the callback might be called during destruction
- ::SetControlColorProc( (ControlHandle) m_macControl , NULL ) ;
- ::DisposeControl( (ControlHandle) m_macControl ) ;
- m_macControl = NULL ;
- }
-}
-
-void wxControl::SetLabel(const wxString& title)
-{
- m_label = GetLabelText(title) ;
-
- if ( m_macControl )
- {
- UMASetControlTitle( (ControlHandle) m_macControl , m_label , m_font.GetEncoding() ) ;
- }
- Refresh() ;
-}
-
-wxSize wxControl::DoGetBestSize() const
-{
- if ( (ControlHandle) m_macControl == NULL )
- return wxWindow::DoGetBestSize() ;
-
- Rect bestsize = { 0 , 0 , 0 , 0 } ;
- short baselineoffset ;
- int bestWidth, bestHeight ;
- ::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
-
- if ( EmptyRect( &bestsize ) )
- {
- baselineoffset = 0;
- bestsize.left = bestsize.top = 0 ;
- bestsize.right = 16 ;
- bestsize.bottom = 16 ;
- if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
- {
- bestsize.bottom = 16 ;
- }
- else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
- {
- bestsize.bottom = 24 ;
- }
- }
-
- bestWidth = bestsize.right - bestsize.left ;
-
- bestWidth += 2 * m_macHorizontalBorder ;
-
- bestHeight = bestsize.bottom - bestsize.top ;
- if ( bestHeight < 10 )
- bestHeight = 13 ;
-
- bestHeight += 2 * m_macVerticalBorder;
-
-
- return wxSize(bestWidth, bestHeight);
-}
-
-bool wxControl::ProcessCommand (wxCommandEvent & event)
-{
- // Tries:
- // 1) OnCommand, starting at this window and working up parent hierarchy
- // 2) OnCommand then calls ProcessEvent to search the event tables.
- return GetEventHandler()->ProcessEvent(event);
-}
-
-// ------------------------
-wxList *wxWinMacControlList = NULL;
-wxControl *wxFindControlFromMacControl(ControlHandle inControl )
-{
- wxNode *node = wxWinMacControlList->Find((long)inControl);
- if (!node)
- return NULL;
- return (wxControl *)node->GetData();
-}
-
-void wxAssociateControlWithMacControl(ControlHandle inControl, wxControl *control)
-{
- // adding NULL WindowRef is (first) surely a result of an error and
- // (secondly) breaks menu command processing
- wxCHECK_RET( inControl != (ControlHandle) NULL, wxT("attempt to add a NULL WindowRef to window list") );
-
- if ( !wxWinMacControlList->Find((long)inControl) )
- wxWinMacControlList->Append((long)inControl, control);
-}
-
-void wxRemoveMacControlAssociation(wxControl *control)
-{
- if ( wxWinMacControlList )
- wxWinMacControlList->DeleteObject(control);
-}
-
-void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name , WXRECTPTR outBounds , unsigned char* maclabel )
-{
- m_label = label ;
-
- // These sizes will be adjusted in MacPostControlCreate
- m_width = size.x ;
- m_height = size.y ;
- m_x = pos.x ;
- m_y = pos.y ;
-
- ((Rect*)outBounds)->top = -10;
- ((Rect*)outBounds)->left = -10;
- ((Rect*)outBounds)->bottom = 0;
- ((Rect*)outBounds)->right = 0;
-
- wxMacStringToPascal( GetLabelText(label) , maclabel ) ;
-}
-
-void wxControl::MacPostControlCreate()
-{
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
- DoSetWindowVariant( m_windowVariant ) ;
- /*
- if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
- {
- // no font
- }
- else if ( !UMAHasAquaLayout() && (IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) ) )
- {
- ControlFontStyleRec controlstyle ;
- controlstyle.flags = kControlUseFontMask ;
- controlstyle.font = kControlFontSmallBoldSystemFont ;
-
- ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
- }
- else
- {
- ControlFontStyleRec controlstyle ;
- controlstyle.flags = kControlUseFontMask ;
-
- if (IsKindOf( CLASSINFO( wxButton ) ) )
- controlstyle.font = kControlFontBigSystemFont ; // eventually kControlFontBigSystemFont ;
- else
- controlstyle.font = kControlFontSmallSystemFont ;
-
- ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
- }
- */
- ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
- wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
- ::EmbedControl( (ControlHandle) m_macControl , container ) ;
- m_macControlIsShown = MacIsReallyShown() ;
-
- wxAssociateControlWithMacControl( (ControlHandle) m_macControl , this ) ;
- if ( wxMacSetupControlBackgroundUPP == NULL )
- {
- wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ;
- }
- if ( wxMacControlActionUPP == NULL )
- {
- wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefinition ) ;
- }
- // The following block of code is responsible for crashes when switching
- // back to windows, which can be seen in the dialogs sample.
- // It is disabled until a proper solution can be found.
-#if 0
-#if TARGET_CARBON
-/*
- only working under classic carbon
- m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
- (**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ;
-*/
-#else
- m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
-
- cdefHandle cdef ;
- cdef = (cdefHandle) NewHandle( sizeof(cdefRec) ) ;
- if ( (**(ControlHandle)m_macControl).contrlDefProc != NULL )
- {
- (**cdef).instruction = 0x4EF9; /* JMP instruction */
- (**cdef).function = (void(*)()) wxMacControlActionUPP;
- (**(ControlHandle)m_macControl).contrlDefProc = (Handle) cdef ;
- }
-#endif
-#endif
- SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
-
- // Adjust the controls size and position
- wxPoint pos(m_x, m_y);
- wxSize best_size( DoGetBestSize() );
- wxSize new_size( m_width, m_height );
-
- m_x = m_y = m_width = m_height = -1; // Forces SetSize to move/size the control
-
- if (new_size.x == -1) {
- new_size.x = best_size.x;
- }
- if (new_size.y == -1) {
- new_size.y = best_size.y;
- }
-
- SetSize(pos.x, pos.y, new_size.x, new_size.y);
-
-#if wxUSE_UNICODE
- UMASetControlTitle( (ControlHandle) m_macControl , GetLabelText(m_label) , m_font.GetEncoding() ) ;
-#endif
-
- if ( m_macControlIsShown )
- UMAShowControl( (ControlHandle) m_macControl ) ;
-
- SetCursor( *wxSTANDARD_CURSOR ) ;
-
- Refresh() ;
-}
-
-void wxControl::MacAdjustControlRect()
-{
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
- if ( m_width == -1 || m_height == -1 )
- {
- Rect bestsize = { 0 , 0 , 0 , 0 } ;
- short baselineoffset ;
-
- ::GetBestControlRect( (ControlHandle) m_macControl , &bestsize , &baselineoffset ) ;
-
- if ( EmptyRect( &bestsize ) )
- {
- baselineoffset = 0;
- bestsize.left = bestsize.top = 0 ;
- bestsize.right = 16 ;
- bestsize.bottom = 16 ;
- if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
- {
- bestsize.bottom = 16 ;
- }
- else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
- {
- bestsize.bottom = 24 ;
- }
- }
-
- if ( m_width == -1 )
- {
- if ( IsKindOf( CLASSINFO( wxButton ) ) )
- {
- m_width = m_label.length() * 8 + 12 ;
- if ( m_width < 70 )
- m_width = 70 ;
- }
- else if ( IsKindOf( CLASSINFO( wxStaticText ) ) )
- {
- m_width = m_label.length() * 8 ;
- }
- else
- m_width = bestsize.right - bestsize.left ;
-
- m_width += 2 * m_macHorizontalBorder + MacGetLeftBorderSize() + MacGetRightBorderSize() ;
- }
- if ( m_height == -1 )
- {
- m_height = bestsize.bottom - bestsize.top ;
- if ( m_height < 10 )
- m_height = 13 ;
-
- m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ;
- }
- MacUpdateDimensions() ;
- }
-}
-
-WXWidget wxControl::MacGetContainerForEmbedding()
-{
- if ( m_macControl )
- return m_macControl ;
-
- return wxWindow::MacGetContainerForEmbedding() ;
-}
-
-void wxControl::MacUpdateDimensions()
-{
- // actually in the current systems this should never be possible, but later reparenting
- // may become a reality
-
- if ( (ControlHandle) m_macControl == NULL )
- return ;
-
- if ( GetParent() == NULL )
- return ;
-
- WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
- if ( rootwindow == NULL )
- return ;
-
- Rect oldBounds ;
- GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
-
- int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
- int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
- int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder ;
- int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder ;
-
- GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
- bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
- bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
- if ( doMove || doResize )
- {
- InvalWindowRect( rootwindow, &oldBounds ) ;
- if ( doMove )
- {
- UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ;
- }
- if ( doResize )
- {
- UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ;
- }
- }
-}
-
-void wxControl::MacSuperChangedPosition()
-{
- MacUpdateDimensions() ;
- wxWindow::MacSuperChangedPosition() ;
-}
-
-void wxControl::MacSuperEnabled( bool enabled )
-{
- Refresh(false) ;
- wxWindow::MacSuperEnabled( enabled ) ;
-}
-
-void wxControl::MacSuperShown( bool show )
-{
- if ( (ControlHandle) m_macControl )
- {
- if ( !show )
- {
- if ( m_macControlIsShown )
- {
- ::UMAHideControl( (ControlHandle) m_macControl ) ;
- m_macControlIsShown = false ;
- }
- }
- else
- {
- if ( MacIsReallyShown() && !m_macControlIsShown )
- {
- ::UMAShowControl( (ControlHandle) m_macControl ) ;
- m_macControlIsShown = true ;
- }
- }
- }
-
- wxWindow::MacSuperShown( show ) ;
-}
-
-void wxControl::DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags )
-{
- wxWindow::DoSetSize( x , y ,width , height ,sizeFlags ) ;
-#if 0
- {
- Rect meta , control ;
- GetControlBounds( (ControlHandle) m_macControl , &control ) ;
- RgnHandle rgn = NewRgn() ;
- GetControlRegion( (ControlHandle) m_macControl , kControlStructureMetaPart , rgn ) ;
- GetRegionBounds( rgn , &meta ) ;
- if ( !EmptyRect( &meta ) )
- {
- wxASSERT( meta.left >= control.left - m_macHorizontalBorder ) ;
- wxASSERT( meta.right <= control.right + m_macHorizontalBorder ) ;
- wxASSERT( meta.top >= control.top - m_macVerticalBorder ) ;
- wxASSERT( meta.bottom <= control.bottom + m_macVerticalBorder ) ;
- }
- DisposeRgn( rgn ) ;
- }
-#endif
- return ;
-}
-
-bool wxControl::Show(bool show)
-{
- if ( !wxWindow::Show( show ) )
- return false ;
-
- if ( (ControlHandle) m_macControl )
- {
- if ( !show )
- {
- if ( m_macControlIsShown )
- {
- ::UMAHideControl( (ControlHandle) m_macControl ) ;
- m_macControlIsShown = false ;
- }
- }
- else
- {
- if ( MacIsReallyShown() && !m_macControlIsShown )
- {
- ::UMAShowControl( (ControlHandle) m_macControl ) ;
- m_macControlIsShown = true ;
- }
- }
- }
- return true ;
-}
-
-bool wxControl::Enable(bool enable)
-{
- if ( !wxWindow::Enable(enable) )
- return false;
-
- if ( (ControlHandle) m_macControl )
- {
- if ( enable )
- UMAActivateControl( (ControlHandle) m_macControl ) ;
- else
- UMADeactivateControl( (ControlHandle) m_macControl ) ;
- }
- return true ;
-}
-
-void wxControl::Refresh(bool eraseBack, const wxRect *rect)
-{
- wxWindow::Refresh( eraseBack , rect ) ;
-}
-
-void wxControl::MacRedrawControl()
-{
- if ( (ControlHandle) m_macControl && MacGetRootWindow() && m_macControlIsShown )
- {
- wxClientDC dc(this) ;
- wxMacPortSetter helper(&dc) ;
- wxMacWindowClipper clipper(this) ;
- wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
- UMADrawControl( (ControlHandle) m_macControl ) ;
- }
-}
-
-void wxControl::OnPaint(wxPaintEvent& event)
-{
- if ( (ControlHandle) m_macControl )
- {
- wxPaintDC dc(this) ;
- wxMacPortSetter helper(&dc) ;
- wxMacWindowClipper clipper(this) ;
- wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
- UMADrawControl( (ControlHandle) m_macControl ) ;
- }
- else
- {
- event.Skip() ;
- }
-}
-void wxControl::OnEraseBackground(wxEraseEvent& event)
-{
- wxWindow::OnEraseBackground( event ) ;
-}
-
-void wxControl::OnKeyDown( wxKeyEvent &event )
-{
- if ( (ControlHandle) m_macControl == NULL )
- return ;
-
-#if TARGET_CARBON
-
- char charCode ;
- UInt32 keyCode ;
- UInt32 modifiers ;
-
- GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
- GetEventParameter( (EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
- GetEventParameter((EventRef) wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
-
- ::HandleControlKey( (ControlHandle) m_macControl , keyCode , charCode , modifiers ) ;
-
-#else
- EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
- short keycode ;
- short keychar ;
- keychar = short(ev->message & charCodeMask);
- keycode = short(ev->message & keyCodeMask) >> 8 ;
-
- ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
-#endif
-}
-
-void wxControl::OnMouseEvent( wxMouseEvent &event )
-{
- if ( (ControlHandle) m_macControl == NULL )
- {
- event.Skip() ;
- return ;
- }
-
- if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
- {
-
- int x = event.m_x ;
- int y = event.m_y ;
-
- MacClientToRootWindow( &x , &y ) ;
-
- ControlHandle control ;
- Point localwhere ;
- SInt16 controlpart ;
-
- localwhere.h = x ;
- localwhere.v = y ;
-
- short modifiers = 0;
-
- if ( !event.m_leftDown && !event.m_rightDown )
- modifiers |= btnState ;
-
- if ( event.m_shiftDown )
- modifiers |= shiftKey ;
-
- if ( event.m_controlDown )
- modifiers |= controlKey ;
-
- if ( event.m_altDown )
- modifiers |= optionKey ;
-
- if ( event.m_metaDown )
- modifiers |= cmdKey ;
- {
- control = (ControlHandle) m_macControl ;
- if ( control && ::IsControlActive( control ) )
- {
- {
- controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
- wxTheApp->s_lastMouseDown = 0 ;
- if ( control && controlpart != kControlNoPart )
- {
- MacHandleControlClick( (WXWidget) control , controlpart , false /* mouse not down anymore */ ) ;
- }
- }
- }
- }
- }
- else
- {
- event.Skip() ;
- }
-}
-
-bool wxControl::MacCanFocus() const
-{
- if ( (ControlHandle) m_macControl == NULL )
- return true ;
- else
- return false ;
-}
-
-void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
-{
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-}
-
-void wxControl::DoSetWindowVariant( wxWindowVariant variant )
-{
- if ( m_macControl == NULL )
- {
- wxWindow::SetWindowVariant( variant ) ;
- return ;
-
- }
- m_windowVariant = variant ;
-
- ControlSize size ;
- ControlFontStyleRec fontStyle;
- fontStyle.flags = kControlUseFontMask ;
-
- // we will get that from the settings later
- // and make this NORMAL later, but first
- // we have a few calculations that we must fix
-
- if ( variant == wxWINDOW_VARIANT_NORMAL )
- {
- if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
- variant = wxWINDOW_VARIANT_NORMAL ;
- else
- variant = wxWINDOW_VARIANT_SMALL ;
- }
-
- switch ( variant )
- {
- case wxWINDOW_VARIANT_NORMAL :
- size = kControlSizeNormal;
- fontStyle.font = kControlFontBigSystemFont;
- break ;
- case wxWINDOW_VARIANT_SMALL :
- size = kControlSizeSmall;
- fontStyle.font = kControlFontSmallSystemFont;
- break ;
- case wxWINDOW_VARIANT_MINI :
- if (UMAGetSystemVersion() >= 0x1030 )
- {
- size = 3 ; // not always defined in the header
- fontStyle.font = -5 ; // not always defined in the header
- }
- else
- {
- size = kControlSizeSmall;
- fontStyle.font = kControlFontSmallSystemFont;
- }
- break;
- break ;
- case wxWINDOW_VARIANT_LARGE :
- size = kControlSizeLarge;
- fontStyle.font = kControlFontBigSystemFont;
- break ;
- default:
- wxFAIL_MSG(_T("unexpected window variant"));
- break ;
- }
- ::SetControlData( (ControlHandle) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size );
- ::SetControlFontStyle( (ControlHandle) m_macControl , &fontStyle );
-}
+++ /dev/null
-#ifdef __UNIX__
- #include <Carbon.r>
-#else
- #include <Types.r>
- #if UNIVERSAL_INTERFACES_VERSION > 0x320
- #include <ControlDefinitions.r>
- #endif
-#endif
-
-resource 'ldes' ( 128 )
-{
- versionZero
- {
- 0 ,
- 0 ,
- 0 ,
- 0 ,
- hasVertScroll ,
- noHorizScroll ,
- 0 ,
- noGrowSpace ,
- }
-} ;
-
-resource 'ldes' ( 129 )
-{
- versionZero
- {
- 0 ,
- 0 ,
- 0 ,
- 0 ,
- hasVertScroll ,
- hasHorizScroll ,
- 0 ,
- noGrowSpace ,
- }
-} ;
-
-data 'CURS' (10) {
- $"0000 03E0 0630 0808 1004 31C6 2362 2222"
- $"2362 31C6 1004 0808 0630 03E0 0000 0000"
- $"0000 03E0 07F0 0FF8 1FFC 3FFE 3FFE 3FFE"
- $"3FFE 3FFE 1FFC 0FF8 07F0 03E0 0000 0000"
- $"0007 0008"
-};
-
-data 'CURS' (11) {
- $"0000 0000 0000 0000 0000 0000 0000 0000"
- $"0000 0000 0000 0000 0000 0000 0000 0000"
- $"0000 0000 0000 0000 0000 0000 0000 0000"
- $"0000 0000 0000 0000 0000 0000 0000 0000"
- $"0000 0000"
-};
-
-data 'CURS' (12) {
- $"00F0 0088 0108 0190 0270 0220 0440 0440"
- $"0880 0880 1100 1E00 1C00 1800 1000 0000"
- $"00F0 00F8 01F8 01F0 03F0 03E0 07C0 07C0"
- $"0F80 0F80 1F00 1E00 1C00 1800 1000 0000"
- $"000E 0003"
-};
-
-data 'CURS' (13) {
- $"0000 1E00 2100 4080 4080 4080 4080 2180"
- $"1FC0 00E0 0070 0038 001C 000E 0006 0000"
- $"3F00 7F80 FFC0 FFC0 FFC0 FFC0 FFC0 7FC0"
- $"3FE0 1FF0 00F8 007C 003E 001F 000F 0007"
- $"0004 0004"
-};
-
-data 'CURS' (14) {
- $"0000 07E0 1FF0 3838 3C0C 6E0E 6706 6386"
- $"61C6 60E6 7076 303C 1C1C 0FF8 07E0 0000"
- $"0540 0FF0 3FF8 3C3C 7E0E FF0F 6F86 E7C7"
- $"63E6 E1F7 70FE 707E 3C3C 1FFC 0FF0 0540"
- $"0007 0007"
-};
-
-data 'CURS' (15) {
- $"0000 0380 0380 0380 0380 0380 0380 0FE0"
- $"1FF0 1FF0 0000 1FF0 1FF0 1550 1550 1550"
- $"07C0 07C0 07C0 07C0 07C0 07C0 0FE0 1FF0"
- $"3FF8 3FF8 3FF8 3FF8 3FF8 3FF8 3FF8 3FF8"
- $"000B 0007"
-};
-
-data 'CURS' (16) {
- $"00C0 0140 0640 08C0 3180 47FE 8001 8001"
- $"81FE 8040 01C0 0040 03C0 C080 3F80 0000"
- $"00C0 01C0 07C0 0FC0 3F80 7FFE FFFF FFFF"
- $"FFFE FFC0 FFC0 FFC0 FFC0 FF80 3F80 0000"
- $"0006 000F"
-};
-
-data 'CURS' (17) {
- $"0100 0280 0260 0310 018C 7FE3 8000 8000"
- $"7F80 0200 0380 0200 03C0 0107 01F8 0000"
- $"0100 0380 03E0 03F0 01FC 7FFF FFFF FFFF"
- $"FFFF 03FF 03FF 03FF 03FF 01FF 01F8 0000"
- $"0006 0000"
-};
-
-data 'CURS' (18) {
- $"0000 4078 60FC 71CE 7986 7C06 7E0E 7F1C"
- $"7FB8 7C30 6C30 4600 0630 0330 0300 0000"
- $"C078 E0FC F1FE FBFF FFCF FF8F FF1F FFBE"
- $"FFFC FE78 FF78 EFF8 CFF8 87F8 07F8 0300"
- $"0001 0001"
-};
-
-data 'CURS' (19) {
- $"0000 0002 0006 000E 001E 003E 007E 00FE"
- $"01FE 003E 0036 0062 0060 00C0 00C0 0000"
- $"0003 0007 000F 001F 003F 007F 00FF 01FF"
- $"03FF 07FF 007F 00F7 00F3 01E1 01E0 01C0"
- $"0001 000E"
-};
-
-data 'CURS' (20) {
- $"0000 0080 01C0 03E0 0080 0080 0080 1FFC"
- $"1FFC 0080 0080 0080 03E0 01C0 0080 0000"
- $"0080 01C0 03E0 07F0 0FF8 01C0 3FFE 3FFE"
- $"3FFE 3FFE 01C0 0FF8 07F0 03E0 01C0 0080"
- $"0007 0008"
-};
-
-data 'CURS' (21) {
- $"0000 0080 01C0 03E0 0080 0888 188C 3FFE"
- $"188C 0888 0080 03E0 01C0 0080 0000 0000"
- $"0080 01C0 03E0 07F0 0BE8 1DDC 3FFE 7FFF"
- $"3FFE 1DDC 0BE8 07F0 03E0 01C0 0080 0000"
- $"0007 0008"
-};
-
-data 'CURS' (22) {
- $"0000 001E 000E 060E 0712 03A0 01C0 00E0"
- $"0170 1238 1C18 1C00 1E00 0000 0000 0000"
- $"007F 003F 0E1F 0F0F 0F97 07E3 03E1 21F0"
- $"31F8 3A7C 3C3C 3E1C 3F00 3F80 0000 0000"
- $"0006 0009"
-};
-
-data 'CURS' (23) {
- $"0000 7800 7000 7060 48E0 05C0 0380 0700"
- $"0E80 1C48 1838 0038 0078 0000 0000 0000"
- $"FE00 FC00 F870 F0F0 E9F0 C7E0 87C0 0F84"
- $"1F8C 3E5C 3C3C 387C 00FC 01FC 0000 0000"
- $"0006 0006"
-};
-
-data 'CURS' (24) {
- $"0006 000E 001C 0018 0020 0040 00F8 0004"
- $"1FF4 200C 2AA8 1FF0 1F80 3800 6000 8000"
- $"000F 001F 003E 007C 0070 00E0 01FC 3FF6"
- $"7FF6 7FFE 7FFC 7FF8 3FF0 7FC0 F800 E000"
- $"000A 0006"
-};
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/cursor.cpp
-// Purpose: wxCursor class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/cursor.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/icon.h"
- #include "wx/image.h"
-#endif // WX_PRECOMP
-
-#include "wx/xpmdecod.h"
-
-#include "wx/mac/private.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
-
-const short kwxCursorBullseye = 10 ;
-const short kwxCursorBlank = 11 ;
-const short kwxCursorPencil = 12 ;
-const short kwxCursorMagnifier = 13 ;
-const short kwxCursorNoEntry = 14 ;
-const short kwxCursorPaintBrush = 15 ;
-const short kwxCursorPointRight = 16 ;
-const short kwxCursorPointLeft = 17 ;
-const short kwxCursorQuestionArrow = 18 ;
-const short kwxCursorRightArrow = 19 ;
-const short kwxCursorSizeNS = 20 ;
-const short kwxCursorSize = 21 ;
-const short kwxCursorSizeNESW = 22 ;
-const short kwxCursorSizeNWSE = 23 ;
-const short kwxCursorRoller = 24 ;
-
-wxCursor gMacCurrentCursor ;
-
-wxCursorRefData::wxCursorRefData()
-{
- m_width = 16;
- m_height = 16;
- m_hCursor = NULL ;
- m_disposeHandle = false ;
- m_releaseHandle = false ;
- m_isColorCursor = false ;
- m_themeCursor = -1 ;
-}
-
-wxCursorRefData::~wxCursorRefData()
-{
- if ( m_isColorCursor )
- {
- ::DisposeCCursor( (CCrsrHandle) m_hCursor ) ;
- }
- else if ( m_disposeHandle )
- {
- ::DisposeHandle( (Handle ) m_hCursor ) ;
- }
- else if ( m_releaseHandle )
- {
- // we don't release the resource since it may already
- // be in use again
- }
-}
-
-// Cursors
-wxCursor::wxCursor()
-{
-}
-
-wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
- int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
-{
-}
-
-wxCursor::wxCursor( const wxImage &image )
-{
- CreateFromImage( image ) ;
-}
-
-wxCursor::wxCursor(const char **bits)
-{
- (void) CreateFromXpm(bits);
-}
-
-wxCursor::wxCursor(char **bits)
-{
- (void) CreateFromXpm((const char **)bits);
-}
-
-bool wxCursor::CreateFromXpm(const char **bits)
-{
- wxCHECK_MSG( bits != NULL, false, wxT("invalid cursor data") );
- wxXPMDecoder decoder;
- wxImage img = decoder.ReadData(bits);
- wxCHECK_MSG( img.Ok(), false, wxT("invalid cursor data") );
- CreateFromImage( img ) ;
- return true;
-}
-
-short GetCTabIndex( CTabHandle colors , RGBColor *col )
-{
- short retval = 0 ;
- unsigned long bestdiff = 0xFFFF ;
- for ( int i = 0 ; i < (**colors).ctSize ; ++i )
- {
- unsigned long diff = abs(col->red - (**colors).ctTable[i].rgb.red ) +
- abs(col->green - (**colors).ctTable[i].rgb.green ) +
- abs(col->blue - (**colors).ctTable[i].rgb.blue ) ;
- if ( diff < bestdiff )
- {
- bestdiff = diff ;
- retval = (**colors).ctTable[i].value ;
- }
- }
- return retval ;
-}
-
-void wxCursor::CreateFromImage(const wxImage & image)
-{
- m_refData = new wxCursorRefData;
-
- int w = 16;
- int h = 16;
-
- int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
- int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
- int image_w = image.GetWidth();
- int image_h = image.GetHeight();
-
- wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w &&
- hotSpotY >= 0 && hotSpotY < image_h,
- _T("invalid cursor hot spot coordinates") );
-
- wxImage image16(image); // final image of correct size
-
- // if image is too small then place it in the center, resize it if too big
- if ((w > image_w) && (h > image_h))
- {
- wxPoint offset((w - image_w)/2, (h - image_h)/2);
- hotSpotX = hotSpotX + offset.x;
- hotSpotY = hotSpotY + offset.y;
-
- image16 = image.Size(wxSize(w, h), offset);
- }
- else if ((w != image_w) || (h != image_h))
- {
- hotSpotX = int(hotSpotX * double(w) / double(image_w));
- hotSpotY = int(hotSpotY * double(h) / double(image_h));
-
- image16 = image.Scale(w, h);
- }
-
- unsigned char * rgbBits = image16.GetData();
- bool bHasMask = image16.HasMask() ;
-
-#if 0
- // monochrome implementation
- M_CURSORDATA->m_hCursor = NewHandle( sizeof( Cursor ) ) ;
- M_CURSORDATA->m_disposeHandle = true ;
- HLock( (Handle) M_CURSORDATA->m_hCursor ) ;
- CursPtr cp = *(CursHandle)M_CURSORDATA->m_hCursor ;
- memset( cp->data , 0 , sizeof( Bits16 ) ) ;
- memset( cp->mask , 0 , sizeof( Bits16 ) ) ;
-
- unsigned char mr = image16.GetMaskRed() ;
- unsigned char mg = image16.GetMaskGreen() ;
- unsigned char mb = image16.GetMaskBlue() ;
- for ( int y = 0 ; y < h ; ++y )
- {
- short rowbits = 0 ;
- short maskbits = 0 ;
-
- for ( int x = 0 ; x < w ; ++x )
- {
- long pos = (y * w + x) * 3;
-
- unsigned char r = rgbBits[pos] ;
- unsigned char g = rgbBits[pos+1] ;
- unsigned char b = rgbBits[pos+2] ;
- if ( bHasMask && r==mr && g==mg && b==mb )
- {
- // masked area, does not appear anywhere
- }
- else
- {
- if ( (int)r + (int)g + (int)b < 0x0200 )
- {
- rowbits |= ( 1 << (15-x) ) ;
- }
- maskbits |= ( 1 << (15-x) ) ;
- }
- }
- cp->data[y] = rowbits ;
- cp->mask[y] = maskbits ;
- }
- if ( !bHasMask )
- {
- memcpy( cp->mask , cp->data , sizeof( Bits16) ) ;
- }
- cp->hotSpot.h = hotSpotX ;
- cp->hotSpot.v = hotSpotY ;
- HUnlock( (Handle) M_CURSORDATA->m_hCursor ) ;
-#else
- PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof (PixMap)) ;
- short extent = 16 ;
- short bytesPerPixel = 1 ;
- short depth = 8 ;
- Rect bounds = { 0 , 0 , extent , extent } ;
- CCrsrHandle ch = (CCrsrHandle) NewHandleClear ( sizeof( CCrsr ) ) ;
- CTabHandle newColors = GetCTable( 8 ) ;
- HandToHand((Handle *) &newColors);
- // set the values to the indices
- for ( int i = 0 ; i < (**newColors).ctSize ; ++i )
- {
- (**newColors).ctTable[i].value = i ;
- }
- HLock( (Handle) ch) ;
- (**ch).crsrType = 0x8001 ; // color cursors
- (**ch).crsrMap = pm ;
- short bytesPerRow = bytesPerPixel * extent ;
-
- (**pm).baseAddr = 0;
- (**pm).rowBytes = bytesPerRow | 0x8000;
- (**pm).bounds = bounds;
- (**pm).pmVersion = 0;
- (**pm).packType = 0;
- (**pm).packSize = 0;
- (**pm).hRes = 0x00480000; /* 72 DPI default res */
- (**pm).vRes = 0x00480000; /* 72 DPI default res */
- (**pm).pixelSize = depth;
- (**pm).pixelType = 0;
- (**pm).cmpCount = 1;
- (**pm).cmpSize = depth;
- (**pm).pmTable = newColors;
-
- (**ch).crsrData = NewHandleClear( extent * bytesPerRow ) ;
- (**ch).crsrXData = NULL ;
- (**ch).crsrXValid = 0;
- (**ch).crsrXHandle = NULL;
-
- (**ch).crsrHotSpot.h = hotSpotX ;
- (**ch).crsrHotSpot.v = hotSpotY ;
- (**ch).crsrXTable = NULL ;
- (**ch).crsrID = GetCTSeed() ;
-
- memset( (**ch).crsr1Data , 0 , sizeof( Bits16 ) ) ;
- memset( (**ch).crsrMask , 0 , sizeof( Bits16 ) ) ;
-
- unsigned char mr = image16.GetMaskRed() ;
- unsigned char mg = image16.GetMaskGreen() ;
- unsigned char mb = image16.GetMaskBlue() ;
- for ( int y = 0 ; y < h ; ++y )
- {
- short rowbits = 0 ;
- short maskbits = 0 ;
-
- for ( int x = 0 ; x < w ; ++x )
- {
- long pos = (y * w + x) * 3;
-
- unsigned char r = rgbBits[pos] ;
- unsigned char g = rgbBits[pos+1] ;
- unsigned char b = rgbBits[pos+2] ;
- RGBColor col = { 0xFFFF ,0xFFFF, 0xFFFF } ;
-
- if ( bHasMask && r==mr && g==mg && b==mb )
- {
- // masked area, does not appear anywhere
- }
- else
- {
- if ( (int)r + (int)g + (int)b < 0x0200 )
- {
- rowbits |= ( 1 << (15-x) ) ;
- }
- maskbits |= ( 1 << (15-x) ) ;
-
- col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ;
- }
- *((*(**ch).crsrData) + y * bytesPerRow + x) =
- GetCTabIndex( newColors , &col) ;
- }
- (**ch).crsr1Data[y] = rowbits ;
- (**ch).crsrMask[y] = maskbits ;
- }
- if ( !bHasMask )
- {
- memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ;
- }
-
- HUnlock((Handle) ch) ;
- M_CURSORDATA->m_hCursor = ch ;
- M_CURSORDATA->m_isColorCursor = true ;
-#endif
-}
-
-wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
-{
- m_refData = new wxCursorRefData;
- if ( flags == wxBITMAP_TYPE_MACCURSOR_RESOURCE )
- {
- Str255 theName ;
- wxMacStringToPascal( cursor_file , theName ) ;
-
- wxStAppResource resload ;
- Handle resHandle = ::GetNamedResource( 'crsr' , theName ) ;
- if ( resHandle )
- {
- short theId = -1 ;
- OSType theType ;
- GetResInfo( resHandle , &theId , &theType , theName ) ;
- ReleaseResource( resHandle ) ;
- M_CURSORDATA->m_hCursor = GetCCursor( theId ) ;
- if ( M_CURSORDATA->m_hCursor )
- M_CURSORDATA->m_isColorCursor = true ;
- }
- else
- {
- Handle resHandle = ::GetNamedResource( 'CURS' , theName ) ;
- if ( resHandle )
- {
- short theId = -1 ;
- OSType theType ;
- GetResInfo( resHandle , &theId , &theType , theName ) ;
- ReleaseResource( resHandle ) ;
- M_CURSORDATA->m_hCursor = GetCursor( theId ) ;
- if ( M_CURSORDATA->m_hCursor )
- M_CURSORDATA->m_releaseHandle = true ;
- }
- }
- }
- else
- {
- wxImage image ;
- image.LoadFile( cursor_file , flags ) ;
- if( image.Ok() )
- {
- image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X,hotSpotX ) ;
- image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y,hotSpotY ) ;
- delete m_refData ;
- CreateFromImage(image) ;
- }
- }
-}
-
-// Cursors by stock number
-wxCursor::wxCursor(int cursor_type)
-{
- m_refData = new wxCursorRefData;
-
- switch (cursor_type)
- {
- case wxCURSOR_COPY_ARROW:
- M_CURSORDATA->m_themeCursor = kThemeCopyArrowCursor ;
- break;
- case wxCURSOR_WAIT:
- M_CURSORDATA->m_themeCursor = kThemeWatchCursor ;
- break;
- case wxCURSOR_IBEAM:
- M_CURSORDATA->m_themeCursor = kThemeIBeamCursor ;
- break;
- case wxCURSOR_CROSS:
- M_CURSORDATA->m_themeCursor = kThemeCrossCursor;
- break;
- case wxCURSOR_SIZENWSE:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNWSE);
- }
- break;
- case wxCURSOR_SIZENESW:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNESW);
- }
- break;
- case wxCURSOR_SIZEWE:
- {
- M_CURSORDATA->m_themeCursor = kThemeResizeLeftRightCursor;
- }
- break;
- case wxCURSOR_SIZENS:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSizeNS);
- }
- break;
- case wxCURSOR_SIZING:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorSize);
- }
- break;
- case wxCURSOR_HAND:
- {
- M_CURSORDATA->m_themeCursor = kThemePointingHandCursor;
- }
- break;
- case wxCURSOR_BULLSEYE:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBullseye);
- }
- break;
- case wxCURSOR_PENCIL:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPencil);
- }
- break;
- case wxCURSOR_MAGNIFIER:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorMagnifier);
- }
- break;
- case wxCURSOR_NO_ENTRY:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorNoEntry);
- }
- break;
- case wxCURSOR_WATCH:
- {
- M_CURSORDATA->m_themeCursor = kThemeWatchCursor;
- break;
- }
- case wxCURSOR_PAINT_BRUSH:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPaintBrush);
- break;
- }
- case wxCURSOR_POINT_LEFT:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointLeft);
- break;
- }
- case wxCURSOR_POINT_RIGHT:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorPointRight);
- break;
- }
- case wxCURSOR_QUESTION_ARROW:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorQuestionArrow);
- break;
- }
- case wxCURSOR_BLANK:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorBlank);
- break;
- }
- case wxCURSOR_RIGHT_ARROW:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRightArrow);
- break;
- }
- case wxCURSOR_SPRAYCAN:
- {
- wxStAppResource resload ;
- M_CURSORDATA->m_hCursor = ::GetCursor(kwxCursorRoller);
- break;
- }
- case wxCURSOR_CHAR:
- case wxCURSOR_ARROW:
- case wxCURSOR_LEFT_BUTTON:
- case wxCURSOR_RIGHT_BUTTON:
- case wxCURSOR_MIDDLE_BUTTON:
- default:
- M_CURSORDATA->m_themeCursor = kThemeArrowCursor ;
- break;
- }
- if ( M_CURSORDATA->m_themeCursor == -1 )
- M_CURSORDATA->m_releaseHandle = true ;
-}
-
-void wxCursor::MacInstall() const
-{
- gMacCurrentCursor = *this ;
- if ( m_refData && M_CURSORDATA->m_themeCursor != -1 )
- {
- SetThemeCursor( M_CURSORDATA->m_themeCursor ) ;
- }
- else if ( m_refData && M_CURSORDATA->m_hCursor )
- {
- if ( M_CURSORDATA->m_isColorCursor )
- ::SetCCursor( (CCrsrHandle) M_CURSORDATA->m_hCursor ) ;
- else
- ::SetCursor( * (CursHandle) M_CURSORDATA->m_hCursor ) ;
- }
- else
- {
- SetThemeCursor( kThemeArrowCursor ) ;
- }
-}
-
-wxCursor::~wxCursor()
-{
-}
-
-// Global cursor setting
-void wxSetCursor(const wxCursor& cursor)
-{
- cursor.MacInstall() ;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/data.cpp
-// Purpose: Various global Mac-specific data
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifndef WX_PRECOMP
- #include "wx/event.h"
-#endif
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dataobj.cpp
-// Purpose: implementation of wxDataObject class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 10/21/99
-// RCS-ID: $Id$
-// Copyright: (c) 1999 Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#include "wx/dataobj.h"
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/log.h"
- #include "wx/image.h"
-#endif
-
-#include "wx/mstream.h"
-#include "wx/mac/private.h"
-#include <Scrap.h>
-
-// ----------------------------------------------------------------------------
-// functions
-// ----------------------------------------------------------------------------
-
-// ----------------------------------------------------------------------------
-// wxDataFormat
-// ----------------------------------------------------------------------------
-
-wxDataFormat::wxDataFormat()
-{
- m_type = wxDF_INVALID;
- m_format = 0;
-}
-
-wxDataFormat::wxDataFormat( wxDataFormatId vType )
-{
- SetType(vType);
-}
-
-wxDataFormat::wxDataFormat( const wxChar* zId)
-{
- SetId(zId);
-}
-
-wxDataFormat::wxDataFormat( const wxString& rId)
-{
- SetId(rId);
-}
-
-wxDataFormat::wxDataFormat( NativeFormat vFormat)
-{
- SetId(vFormat);
-}
-
-void wxDataFormat::SetType( wxDataFormatId Type )
-{
- m_type = Type;
-
- if (m_type == wxDF_TEXT )
- m_format = kScrapFlavorTypeText;
- else if (m_type == wxDF_UNICODETEXT )
- m_format = kScrapFlavorTypeUnicode ;
- else if (m_type == wxDF_BITMAP || m_type == wxDF_METAFILE )
- m_format = kScrapFlavorTypePicture;
- else if (m_type == wxDF_FILENAME)
- m_format = kDragFlavorTypeHFS ;
- else
- {
- wxFAIL_MSG( wxT("invalid dataformat") );
-
- // this is '????' but it can't be used in the code because ??' is
- // parsed as a trigraph!
- m_format = 0x3f3f3f3f;
- }
-}
-
-wxString wxDataFormat::GetId() const
-{
- // note that m_format is not a pointer to string, it *is* itself a 4
- // character string
- char text[5] ;
- strncpy( text , (char*) &m_format , 4 ) ;
- text[4] = 0 ;
-
- return wxString::FromAscii( text ) ;
-}
-
-void wxDataFormat::SetId( NativeFormat format )
-{
- m_format = format;
-
- if (m_format == kScrapFlavorTypeText)
- m_type = wxDF_TEXT;
- else if (m_format == kScrapFlavorTypeUnicode )
- m_type = wxDF_UNICODETEXT;
- else if (m_format == kScrapFlavorTypePicture)
- m_type = wxDF_BITMAP;
- else if (m_format == kDragFlavorTypeHFS )
- m_type = wxDF_FILENAME;
- else
- m_type = wxDF_PRIVATE;
-}
-
-void wxDataFormat::SetId( const wxChar* zId )
-{
- m_type = wxDF_PRIVATE;
- m_format = 0;// TODO: get the format gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE );
-}
-
-//-------------------------------------------------------------------------
-// wxDataObject
-//-------------------------------------------------------------------------
-
-wxDataObject::wxDataObject()
-{
-}
-
-bool wxDataObject::IsSupportedFormat(
- const wxDataFormat& rFormat
-, Direction vDir
-) const
-{
- size_t nFormatCount = GetFormatCount(vDir);
-
- if (nFormatCount == 1)
- {
- return rFormat == GetPreferredFormat();
- }
- else
- {
- wxDataFormat* pFormats = new wxDataFormat[nFormatCount];
- GetAllFormats( pFormats
- ,vDir
- );
-
- size_t n;
-
- for (n = 0; n < nFormatCount; n++)
- {
- if (pFormats[n] == rFormat)
- break;
- }
-
- delete [] pFormats;
-
- // found?
- return n < nFormatCount;
- }
-}
-
-// ----------------------------------------------------------------------------
-// wxFileDataObject
-// ----------------------------------------------------------------------------
-
-bool wxFileDataObject::GetDataHere( void* pBuf ) const
-{
- wxString sFilenames;
-
- for (size_t i = 0; i < m_filenames.GetCount(); i++)
- {
- sFilenames += m_filenames[i];
- sFilenames += (wxChar)0;
- }
-
- memcpy(pBuf, sFilenames.mbc_str(), sFilenames.length() + 1);
- return true;
-}
-
-size_t wxFileDataObject::GetDataSize() const
-{
- size_t nRes = 0;
-
- for (size_t i = 0; i < m_filenames.GetCount(); i++)
- {
- nRes += m_filenames[i].length();
- nRes += 1;
- }
-
- return nRes + 1;
-}
-
-bool wxFileDataObject::SetData(
- size_t WXUNUSED(nSize)
-, const void* pBuf
-)
-{
- m_filenames.Empty();
-
- AddFile(wxString::FromAscii((char*)pBuf));
-
- return true;
-}
-
-void wxFileDataObject::AddFile(
- const wxString& rFilename
-)
-{
- m_filenames.Add(rFilename);
-}
-
-// ----------------------------------------------------------------------------
-// wxBitmapDataObject
-// ----------------------------------------------------------------------------
-
-wxBitmapDataObject::wxBitmapDataObject()
-{
- Init();
-}
-
-wxBitmapDataObject::wxBitmapDataObject(
- const wxBitmap& rBitmap
-)
-: wxBitmapDataObjectBase(rBitmap)
-{
- Init();
- if ( m_bitmap.Ok() )
- {
- m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
- }
-}
-
-wxBitmapDataObject::~wxBitmapDataObject()
-{
- Clear();
-}
-
-void wxBitmapDataObject::SetBitmap(
- const wxBitmap& rBitmap
-)
-{
- Clear();
- wxBitmapDataObjectBase::SetBitmap(rBitmap);
- if ( m_bitmap.Ok() )
- {
- m_pictHandle = m_bitmap.GetPict( &m_pictCreated ) ;
- }
-}
-
-void wxBitmapDataObject::Init()
-{
- m_pictHandle = NULL ;
- m_pictCreated = false ;
-}
-
-void wxBitmapDataObject::Clear()
-{
- if ( m_pictCreated && m_pictHandle )
- {
- KillPicture( (PicHandle) m_pictHandle ) ;
- }
- m_pictHandle = NULL ;
-}
-
-bool wxBitmapDataObject::GetDataHere( void* pBuf ) const
-{
- if (!m_pictHandle)
- {
- wxFAIL_MSG(wxT("attempt to copy empty bitmap failed"));
- return false;
- }
- memcpy(pBuf, *(Handle)m_pictHandle, GetHandleSize((Handle)m_pictHandle));
- return true;
-}
-
-size_t wxBitmapDataObject::GetDataSize() const
-{
- return GetHandleSize((Handle)m_pictHandle) ;
-}
-
-bool wxBitmapDataObject::SetData(
- size_t nSize
-, const void* pBuf
-)
-{
- Clear();
- PicHandle picHandle = (PicHandle) NewHandle( nSize ) ;
- memcpy( *picHandle , pBuf , nSize ) ;
- m_pictHandle = picHandle ;
- m_pictCreated = false ;
- Rect frame = (**picHandle).picFrame ;
-
- m_bitmap.SetPict( picHandle ) ;
- m_bitmap.SetWidth( frame.right - frame.left ) ;
- m_bitmap.SetHeight( frame.bottom - frame.top ) ;
- return m_bitmap.Ok();
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dc.cpp
-// Purpose: wxDC class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 01/02/97
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/dc.h"
-
-#ifndef WX_PRECOMP
- #include "wx/log.h"
- #include "wx/app.h"
- #include "wx/dcmemory.h"
- #include "wx/dcprint.h"
- #include "wx/region.h"
- #include "wx/image.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-#if __MSL__ >= 0x6000
-namespace std {}
-using namespace std ;
-#endif
-
-#include "wx/mac/private.h"
-#include <ATSUnicode.h>
-#include <TextCommon.h>
-#include <TextEncodingConverter.h>
-#include <FixMath.h>
-
-IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
-
-//-----------------------------------------------------------------------------
-// constants
-//-----------------------------------------------------------------------------
-
-const double RAD2DEG = 180.0 / M_PI;
-const short kEmulatedMode = -1 ;
-const short kUnsupportedMode = -2 ;
-
-extern TECObjectRef s_TECNativeCToUnicode ;
-
-// set to 0 if problems arise
-#define wxMAC_EXPERIMENTAL_DC 1
-
-wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) :
- m_ph( (GrafPtr) dc->m_macPort )
-{
- wxASSERT( dc->Ok() ) ;
- m_dc = dc ;
- dc->MacSetupPort(&m_ph) ;
-}
-wxMacPortSetter::~wxMacPortSetter()
-{
- m_dc->MacCleanupPort(&m_ph) ;
-}
-
-#if wxMAC_EXPERIMENTAL_DC
-class wxMacFastPortSetter
-{
-public :
- wxMacFastPortSetter( const wxDC *dc )
- {
- wxASSERT( dc->Ok() ) ;
- GetPort( &m_oldPort ) ;
- SetPort( (GrafPtr) dc->m_macPort ) ;
- m_clipRgn = NewRgn() ;
- GetClip( m_clipRgn ) ;
- m_dc = dc ;
- dc->MacSetupPort( NULL ) ;
- }
- ~wxMacFastPortSetter()
- {
- SetPort( (GrafPtr) m_dc->m_macPort ) ;
- SetClip( m_clipRgn ) ;
- SetPort( m_oldPort ) ;
- m_dc->MacCleanupPort( NULL ) ;
- DisposeRgn( m_clipRgn ) ;
- }
-private :
- RgnHandle m_clipRgn ;
- GrafPtr m_oldPort ;
- const wxDC* m_dc ;
-} ;
-
-#else
-typedef wxMacPortSetter wxMacFastPortSetter ;
-#endif
-
-#if 0
-
-// start moving to a dual implementation for QD and CGContextRef
-
-class wxMacGraphicsContext
-{
-public :
- void DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) = 0 ;
- void SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) = 0 ;
- void SetClippingRegion( const wxRegion ®ion ) = 0 ;
- void DestroyClippingRegion() = 0 ;
- void SetTextForeground( const wxColour &col ) = 0 ;
- void SetTextBackground( const wxColour &col ) = 0 ;
- void SetLogicalScale( double x , double y ) = 0 ;
- void SetUserScale( double x , double y ) = 0;
-} ;
-
-class wxMacQuickDrawContext : public wxMacGraphicsContext
-{
-public :
-} ;
-
-#endif
-
-wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
-{
- m_formerClip = NewRgn() ;
- m_newClip = NewRgn() ;
- GetClip( m_formerClip ) ;
-
- if ( win )
- {
-#if 0
- // this clipping area was set to the parent window's drawing area, lead to problems
- // with MacOSX controls drawing outside their wx' rectangle
- RgnHandle insidergn = NewRgn() ;
- int x = 0 , y = 0;
- wxWindow *parent = win->GetParent() ;
- parent->MacWindowToRootWindow( &x,&y ) ;
- wxSize size = parent->GetSize() ;
- SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() ,
- size.x - parent->MacGetRightBorderSize(),
- size.y - parent->MacGetBottomBorderSize()) ;
- CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip ) ;
- SectRgn( m_newClip , insidergn , m_newClip ) ;
- OffsetRgn( m_newClip , x , y ) ;
- SetClip( m_newClip ) ;
- DisposeRgn( insidergn ) ;
-#else
- int x = 0 , y = 0;
- win->MacWindowToRootWindow( &x,&y ) ;
- CopyRgn( (RgnHandle) ((wxWindow*)win)->MacGetVisibleRegion().GetWXHRGN() , m_newClip ) ;
- OffsetRgn( m_newClip , x , y ) ;
- SetClip( m_newClip ) ;
-#endif
- }
-}
-
-wxMacWindowClipper::~wxMacWindowClipper()
-{
- SetClip( m_formerClip ) ;
- DisposeRgn( m_newClip ) ;
- DisposeRgn( m_formerClip ) ;
-}
-
-//-----------------------------------------------------------------------------
-// Local functions
-//-----------------------------------------------------------------------------
-static inline double dmin(double a, double b) { return a < b ? a : b; }
-static inline double dmax(double a, double b) { return a > b ? a : b; }
-static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
-
-//-----------------------------------------------------------------------------
-// wxDC
-//-----------------------------------------------------------------------------
-// this function emulates all wx colour manipulations, used to verify the implementation
-// by setting the mode in the blitting functions to kEmulatedMode
-void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor ) ;
-
-void wxMacCalculateColour( int logical_func , const RGBColor &srcColor , RGBColor &dstColor )
-{
- switch ( logical_func )
- {
- case wxAND: // src AND dst
- dstColor.red = dstColor.red & srcColor.red ;
- dstColor.green = dstColor.green & srcColor.green ;
- dstColor.blue = dstColor.blue & srcColor.blue ;
- break ;
- case wxAND_INVERT: // (NOT src) AND dst
- dstColor.red = dstColor.red & ~srcColor.red ;
- dstColor.green = dstColor.green & ~srcColor.green ;
- dstColor.blue = dstColor.blue & ~srcColor.blue ;
- break ;
- case wxAND_REVERSE:// src AND (NOT dst)
- dstColor.red = ~dstColor.red & srcColor.red ;
- dstColor.green = ~dstColor.green & srcColor.green ;
- dstColor.blue = ~dstColor.blue & srcColor.blue ;
- break ;
- case wxCLEAR: // 0
- dstColor.red = 0 ;
- dstColor.green = 0 ;
- dstColor.blue = 0 ;
- break ;
- case wxCOPY: // src
- dstColor.red = srcColor.red ;
- dstColor.green = srcColor.green ;
- dstColor.blue = srcColor.blue ;
- break ;
- case wxEQUIV: // (NOT src) XOR dst
- dstColor.red = dstColor.red ^ ~srcColor.red ;
- dstColor.green = dstColor.green ^ ~srcColor.green ;
- dstColor.blue = dstColor.blue ^ ~srcColor.blue ;
- break ;
- case wxINVERT: // NOT dst
- dstColor.red = ~dstColor.red ;
- dstColor.green = ~dstColor.green ;
- dstColor.blue = ~dstColor.blue ;
- break ;
- case wxNAND: // (NOT src) OR (NOT dst)
- dstColor.red = ~dstColor.red | ~srcColor.red ;
- dstColor.green = ~dstColor.green | ~srcColor.green ;
- dstColor.blue = ~dstColor.blue | ~srcColor.blue ;
- break ;
- case wxNOR: // (NOT src) AND (NOT dst)
- dstColor.red = ~dstColor.red & ~srcColor.red ;
- dstColor.green = ~dstColor.green & ~srcColor.green ;
- dstColor.blue = ~dstColor.blue & ~srcColor.blue ;
- break ;
- case wxNO_OP: // dst
- break ;
- case wxOR: // src OR dst
- dstColor.red = dstColor.red | srcColor.red ;
- dstColor.green = dstColor.green | srcColor.green ;
- dstColor.blue = dstColor.blue | srcColor.blue ;
- break ;
- case wxOR_INVERT: // (NOT src) OR dst
- dstColor.red = dstColor.red | ~srcColor.red ;
- dstColor.green = dstColor.green | ~srcColor.green ;
- dstColor.blue = dstColor.blue | ~srcColor.blue ;
- break ;
- case wxOR_REVERSE: // src OR (NOT dst)
- dstColor.red = ~dstColor.red | srcColor.red ;
- dstColor.green = ~dstColor.green | srcColor.green ;
- dstColor.blue = ~dstColor.blue | srcColor.blue ;
- break ;
- case wxSET: // 1
- dstColor.red = 0xFFFF ;
- dstColor.green = 0xFFFF ;
- dstColor.blue = 0xFFFF ;
- break ;
- case wxSRC_INVERT: // (NOT src)
- dstColor.red = ~srcColor.red ;
- dstColor.green = ~srcColor.green ;
- dstColor.blue = ~srcColor.blue ;
- break ;
- case wxXOR: // src XOR dst
- dstColor.red = dstColor.red ^ srcColor.red ;
- dstColor.green = dstColor.green ^ srcColor.green ;
- dstColor.blue = dstColor.blue ^ srcColor.blue ;
- break ;
- }
-}
-
-wxDC::wxDC()
-{
- m_ok = false;
- m_colour = true;
- m_mm_to_pix_x = mm2pt;
- m_mm_to_pix_y = mm2pt;
- m_internalDeviceOriginX = 0;
- m_internalDeviceOriginY = 0;
- m_externalDeviceOriginX = 0;
- m_externalDeviceOriginY = 0;
- m_logicalScaleX = 1.0;
- m_logicalScaleY = 1.0;
- m_userScaleX = 1.0;
- m_userScaleY = 1.0;
- m_scaleX = 1.0;
- m_scaleY = 1.0;
- m_needComputeScaleX = false;
- m_needComputeScaleY = false;
- m_macPort = NULL ;
- m_macMask = NULL ;
- m_ok = false ;
- m_macFontInstalled = false ;
- m_macBrushInstalled = false ;
- m_macPenInstalled = false ;
- m_macLocalOrigin.x = m_macLocalOrigin.y = 0 ;
- m_macBoundaryClipRgn = NewRgn() ;
- m_macCurrentClipRgn = NewRgn() ;
- SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , -32000 , -32000 , 32000 , 32000 ) ;
- SetRectRgn( (RgnHandle) m_macCurrentClipRgn , -32000 , -32000 , 32000 , 32000 ) ;
- m_pen = *wxBLACK_PEN;
- m_font = *wxNORMAL_FONT;
- m_brush = *wxWHITE_BRUSH;
-#ifdef __WXDEBUG__
- // needed to debug possible errors with two active drawing methods at the same time on
- // the same DC
- m_macCurrentPortStateHelper = NULL ;
-#endif
- m_macATSUIStyle = NULL ;
- m_macAliasWasEnabled = false;
- m_macForegroundPixMap = NULL ;
- m_macBackgroundPixMap = NULL ;
-}
-
-wxDC::~wxDC(void)
-{
- DisposeRgn( (RgnHandle) m_macBoundaryClipRgn ) ;
- DisposeRgn( (RgnHandle) m_macCurrentClipRgn ) ;
-}
-
-void wxDC::MacSetupPort(wxMacPortStateHelper* help) const
-{
-#ifdef __WXDEBUG__
- wxASSERT( m_macCurrentPortStateHelper == NULL ) ;
- m_macCurrentPortStateHelper = help ;
-#endif
- SetClip( (RgnHandle) m_macCurrentClipRgn);
-#if ! wxMAC_EXPERIMENTAL_DC
- m_macFontInstalled = false ;
- m_macBrushInstalled = false ;
- m_macPenInstalled = false ;
-#endif
-}
-void wxDC::MacCleanupPort(wxMacPortStateHelper* help) const
-{
-#ifdef __WXDEBUG__
- wxASSERT( m_macCurrentPortStateHelper == help ) ;
- m_macCurrentPortStateHelper = NULL ;
-#endif
- if( m_macATSUIStyle )
- {
- ::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle);
- m_macATSUIStyle = NULL ;
- }
- if ( m_macAliasWasEnabled )
- {
- SetAntiAliasedTextEnabled(m_macFormerAliasState, m_macFormerAliasSize);
- m_macAliasWasEnabled = false ;
- }
- if ( m_macForegroundPixMap )
- {
- Pattern blackColor ;
- ::PenPat(GetQDGlobalsBlack(&blackColor));
- DisposePixPat( (PixPatHandle) m_macForegroundPixMap ) ;
- m_macForegroundPixMap = NULL ;
- }
- if ( m_macBackgroundPixMap )
- {
- Pattern whiteColor ;
- ::BackPat(GetQDGlobalsWhite(&whiteColor));
- DisposePixPat( (PixPatHandle) m_macBackgroundPixMap ) ;
- m_macBackgroundPixMap = NULL ;
- }
-}
-
-void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask )
-{
- wxCHECK_RET( Ok(), wxT("invalid window dc") );
- wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") );
- wxMacFastPortSetter helper(this) ;
- wxCoord xx = XLOG2DEVMAC(x);
- wxCoord yy = YLOG2DEVMAC(y);
- wxCoord w = bmp.GetWidth();
- wxCoord h = bmp.GetHeight();
- wxCoord ww = XLOG2DEVREL(w);
- wxCoord hh = YLOG2DEVREL(h);
- // Set up drawing mode
- short mode = (m_logicalFunction == wxCOPY ? srcCopy :
- //m_logicalFunction == wxCLEAR ? WHITENESS :
- //m_logicalFunction == wxSET ? BLACKNESS :
- m_logicalFunction == wxINVERT ? hilite :
- //m_logicalFunction == wxAND ? MERGECOPY :
- m_logicalFunction == wxOR ? srcOr :
- m_logicalFunction == wxSRC_INVERT ? notSrcCopy :
- m_logicalFunction == wxXOR ? srcXor :
- m_logicalFunction == wxOR_REVERSE ? notSrcOr :
- //m_logicalFunction == wxAND_REVERSE ? SRCERASE :
- //m_logicalFunction == wxSRC_OR ? srcOr :
- //m_logicalFunction == wxSRC_AND ? SRCAND :
- srcCopy );
- if ( bmp.GetBitmapType() == kMacBitmapTypePict ) {
- Rect bitmaprect = { 0 , 0 , hh, ww };
- ::OffsetRect( &bitmaprect, xx, yy ) ;
- ::DrawPicture( (PicHandle) bmp.GetPict(), &bitmaprect ) ;
- }
- else if ( bmp.GetBitmapType() == kMacBitmapTypeGrafWorld )
- {
- GWorldPtr bmapworld = MAC_WXHBITMAP( bmp.GetHBITMAP() );
- PixMapHandle bmappixels ;
- // Set foreground and background colours (for bitmaps depth = 1)
- if(bmp.GetDepth() == 1)
- {
- RGBColor fore = MAC_WXCOLORREF(m_textForegroundColour.GetPixel());
- RGBColor back = MAC_WXCOLORREF(m_textBackgroundColour.GetPixel());
- RGBForeColor(&fore);
- RGBBackColor(&back);
- }
- else
- {
- RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
- RGBColor black = { 0,0,0} ;
- RGBForeColor( &black ) ;
- RGBBackColor( &white ) ;
- }
- bmappixels = GetGWorldPixMap( bmapworld ) ;
- wxCHECK_RET(LockPixels(bmappixels),
- wxT("DoDrawBitmap: Unable to lock pixels"));
- Rect source = { 0, 0, h, w };
- Rect dest = { yy, xx, yy + hh, xx + ww };
- if ( useMask && bmp.GetMask() )
- {
- if( LockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap()))))
- {
- CopyDeepMask
- (
- GetPortBitMapForCopyBits(bmapworld),
- GetPortBitMapForCopyBits(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())),
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
- &source, &source, &dest, mode, NULL
- );
- UnlockPixels(GetGWorldPixMap(MAC_WXHBITMAP(bmp.GetMask()->GetMaskBitmap())));
- }
- }
- else {
- CopyBits( GetPortBitMapForCopyBits( bmapworld ),
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ),
- &source, &dest, mode, NULL ) ;
- }
- UnlockPixels( bmappixels ) ;
- }
- else if ( bmp.GetBitmapType() == kMacBitmapTypeIcon )
- {
- Rect bitmaprect = { 0 , 0 , bmp.GetHeight(), bmp.GetWidth() } ;
- OffsetRect( &bitmaprect, xx, yy ) ;
- PlotCIconHandle( &bitmaprect , atNone , ttNone , MAC_WXHICON(bmp.GetHICON()) ) ;
- }
- m_macPenInstalled = false ;
- m_macBrushInstalled = false ;
- m_macFontInstalled = false ;
-}
-
-void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
-{
- wxCHECK_RET(Ok(), wxT("Invalid dc wxDC::DoDrawIcon"));
- wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
- DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ;
-}
-
-void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
-{
- wxCHECK_RET(Ok(), wxT("wxDC::DoSetClippingRegion Invalid DC"));
- wxCoord xx, yy, ww, hh;
- xx = XLOG2DEVMAC(x);
- yy = YLOG2DEVMAC(y);
- ww = XLOG2DEVREL(width);
- hh = YLOG2DEVREL(height);
- SetRectRgn( (RgnHandle) m_macCurrentClipRgn , xx , yy , xx + ww , yy + hh ) ;
- SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
- if( m_clipping )
- {
- m_clipX1 = wxMax( m_clipX1 , xx );
- m_clipY1 = wxMax( m_clipY1 , yy );
- m_clipX2 = wxMin( m_clipX2, (xx + ww));
- m_clipY2 = wxMin( m_clipY2, (yy + hh));
- }
- else
- {
- m_clipping = true;
- m_clipX1 = xx;
- m_clipY1 = yy;
- m_clipX2 = xx + ww;
- m_clipY2 = yy + hh;
- }
-}
-
-void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion )
-{
- wxCHECK_RET( Ok(), wxT("invalid window dc") ) ;
- if (region.Empty())
- {
- DestroyClippingRegion();
- return;
- }
- wxMacFastPortSetter helper(this) ;
- wxCoord x, y, w, h;
- region.GetBox( x, y, w, h );
- wxCoord xx, yy, ww, hh;
- xx = XLOG2DEVMAC(x);
- yy = YLOG2DEVMAC(y);
- ww = XLOG2DEVREL(w);
- hh = YLOG2DEVREL(h);
- // if we have a scaling that we cannot map onto native regions
- // we must use the box
- if ( ww != w || hh != h )
- {
- wxDC::DoSetClippingRegion( x, y, w, h );
- }
- else
- {
- CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn ) ;
- if ( xx != x || yy != y )
- {
- OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y ) ;
- }
- SectRgn( (RgnHandle) m_macCurrentClipRgn , (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
- if( m_clipping )
- {
- m_clipX1 = wxMax( m_clipX1 , xx );
- m_clipY1 = wxMax( m_clipY1 , yy );
- m_clipX2 = wxMin( m_clipX2, (xx + ww));
- m_clipY2 = wxMin( m_clipY2, (yy + hh));
- }
- else
- {
- m_clipping = true;
- m_clipX1 = xx;
- m_clipY1 = yy;
- m_clipX2 = xx + ww;
- m_clipY2 = yy + hh;
- }
- }
-}
-
-void wxDC::DestroyClippingRegion()
-{
- wxMacFastPortSetter helper(this) ;
- CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
- ResetClipping();
-}
-
-void wxDC::DoGetSizeMM( int* width, int* height ) const
-{
- int w = 0;
- int h = 0;
- GetSize( &w, &h );
- *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
- *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
-}
-
-void wxDC::SetTextForeground( const wxColour &col )
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- m_textForegroundColour = col;
- m_macFontInstalled = false ;
-}
-
-void wxDC::SetTextBackground( const wxColour &col )
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- m_textBackgroundColour = col;
- m_macFontInstalled = false ;
-}
-
-void wxDC::SetMapMode( int mode )
-{
- switch (mode)
- {
- case wxMM_TWIPS:
- SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
- break;
- case wxMM_POINTS:
- SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
- break;
- case wxMM_METRIC:
- SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
- break;
- case wxMM_LOMETRIC:
- SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
- break;
- default:
- case wxMM_TEXT:
- SetLogicalScale( 1.0, 1.0 );
- break;
- }
- if (mode != wxMM_TEXT)
- {
- m_needComputeScaleX = true;
- m_needComputeScaleY = true;
- }
-}
-
-void wxDC::SetUserScale( double x, double y )
-{
- // allow negative ? -> no
- m_userScaleX = x;
- m_userScaleY = y;
- ComputeScaleAndOrigin();
-}
-
-void wxDC::SetLogicalScale( double x, double y )
-{
- // allow negative ?
- m_logicalScaleX = x;
- m_logicalScaleY = y;
- ComputeScaleAndOrigin();
-}
-
-void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
-{
- m_logicalOriginX = x * m_signX; // is this still correct ?
- m_logicalOriginY = y * m_signY;
- ComputeScaleAndOrigin();
-}
-
-void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
-{
- m_externalDeviceOriginX = x;
- m_externalDeviceOriginY = y;
- ComputeScaleAndOrigin();
-}
-
-#if 0
-void wxDC::SetInternalDeviceOrigin( long x, long y )
-{
- m_internalDeviceOriginX = x;
- m_internalDeviceOriginY = y;
- ComputeScaleAndOrigin();
-}
-void wxDC::GetInternalDeviceOrigin( long *x, long *y )
-{
- if (x) *x = m_internalDeviceOriginX;
- if (y) *y = m_internalDeviceOriginY;
-}
-#endif
-
-void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
-{
- m_signX = (xLeftRight ? 1 : -1);
- m_signY = (yBottomUp ? -1 : 1);
- ComputeScaleAndOrigin();
-}
-
-wxSize wxDC::GetPPI() const
-{
- return wxSize(72, 72);
-}
-
-int wxDC::GetDepth() const
-{
- if ( IsPortColor( (CGrafPtr) m_macPort ) )
- {
- return ( (**GetPortPixMap( (CGrafPtr) m_macPort)).pixelSize ) ;
- }
- return 1 ;
-}
-
-void wxDC::ComputeScaleAndOrigin()
-{
- // CMB: copy scale to see if it changes
- double origScaleX = m_scaleX;
- double origScaleY = m_scaleY;
- m_scaleX = m_logicalScaleX * m_userScaleX;
- m_scaleY = m_logicalScaleY * m_userScaleY;
- m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
- m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
- // CMB: if scale has changed call SetPen to recalulate the line width
- if (m_scaleX != origScaleX || m_scaleY != origScaleY)
- {
- // this is a bit artificial, but we need to force wxDC to think
- // the pen has changed
- wxPen* pen = & GetPen();
- wxPen tempPen;
- m_pen = tempPen;
- SetPen(* pen);
- }
-}
-
-void wxDC::SetPalette( const wxPalette& palette )
-{
-}
-
-void wxDC::SetBackgroundMode( int mode )
-{
- m_backgroundMode = mode ;
-}
-
-void wxDC::SetFont( const wxFont &font )
-{
- m_font = font;
- m_macFontInstalled = false ;
-}
-
-void wxDC::SetPen( const wxPen &pen )
-{
- if ( m_pen == pen )
- return ;
- m_pen = pen;
- m_macPenInstalled = false ;
-}
-
-void wxDC::SetBrush( const wxBrush &brush )
-{
- if (m_brush == brush)
- return;
- m_brush = brush;
- m_macBrushInstalled = false ;
-}
-
-void wxDC::SetBackground( const wxBrush &brush )
-{
- if (m_backgroundBrush == brush)
- return;
- m_backgroundBrush = brush;
- if (!m_backgroundBrush.Ok())
- return;
- m_macBrushInstalled = false ;
-}
-
-void wxDC::SetLogicalFunction( int function )
-{
- if (m_logicalFunction == function)
- return;
- m_logicalFunction = function ;
- m_macFontInstalled = false ;
- m_macBrushInstalled = false ;
- m_macPenInstalled = false ;
-}
-
-extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
- const wxColour & col, int style);
-
-bool wxDC::DoFloodFill(wxCoord x, wxCoord y,
- const wxColour& col, int style)
-{
- return wxDoFloodFill(this, x, y, col, style);
-}
-
-bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
-{
- wxCHECK_MSG( Ok(), false, wxT("wxDC::DoGetPixel Invalid DC") );
- wxMacFastPortSetter helper(this) ;
- RGBColor colour;
- GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour );
- // Convert from Mac colour to wx
- col->Set( colour.red >> 8,
- colour.green >> 8,
- colour.blue >> 8);
- return true ;
-}
-
-void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 :
- m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2;
- wxCoord xx1 = XLOG2DEVMAC(x1) - offset;
- wxCoord yy1 = YLOG2DEVMAC(y1) - offset;
- wxCoord xx2 = XLOG2DEVMAC(x2) - offset;
- wxCoord yy2 = YLOG2DEVMAC(y2) - offset;
- if ((m_pen.GetCap() == wxCAP_ROUND) &&
- (m_pen.GetWidth() <= 1))
- {
- // Implement LAST_NOT for MAC at least for
- // orthogonal lines. RR.
- if (xx1 == xx2)
- {
- if (yy1 < yy2)
- yy2--;
- if (yy1 > yy2)
- yy2++;
- }
- if (yy1 == yy2)
- {
- if (xx1 < xx2)
- xx2--;
- if (xx1 > xx2)
- xx2++;
- }
- }
- ::MoveTo(xx1, yy1);
- ::LineTo(xx2, yy2);
- }
-}
-
-void wxDC::DoCrossHair( wxCoord x, wxCoord y )
-{
- wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") );
- wxMacFastPortSetter helper(this) ;
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- int w = 0;
- int h = 0;
- GetSize( &w, &h );
- wxCoord xx = XLOG2DEVMAC(x);
- wxCoord yy = YLOG2DEVMAC(y);
- MacInstallPen();
- ::MoveTo( XLOG2DEVMAC(0), yy );
- ::LineTo( XLOG2DEVMAC(w), yy );
- ::MoveTo( xx, YLOG2DEVMAC(0) );
- ::LineTo( xx, YLOG2DEVMAC(h) );
- CalcBoundingBox(x, y);
- CalcBoundingBox(x+w, y+h);
- }
-}
-
-/*
-* To draw arcs properly the angles need to be converted from the WX style:
-* Angles start on the +ve X axis and go anti-clockwise (As you would draw on
-* a normal axis on paper).
-* TO
-* the Mac style:
-* Angles start on the +ve y axis and go clockwise.
-*/
-
-static double wxConvertWXangleToMACangle(double angle)
-{
- double newAngle = 90 - angle ;
- if ( newAngle < 0 )
- newAngle += 360 ;
- return newAngle ;
-}
-
-void wxDC::DoDrawArc( wxCoord x1, wxCoord y1,
- wxCoord x2, wxCoord y2,
- wxCoord xc, wxCoord yc )
-{
- wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- wxCoord xx1 = XLOG2DEVMAC(x1);
- wxCoord yy1 = YLOG2DEVMAC(y1);
- wxCoord xx2 = XLOG2DEVMAC(x2);
- wxCoord yy2 = YLOG2DEVMAC(y2);
- wxCoord xxc = XLOG2DEVMAC(xc);
- wxCoord yyc = YLOG2DEVMAC(yc);
- double dx = xx1 - xxc;
- double dy = yy1 - yyc;
- double radius = sqrt((double)(dx*dx+dy*dy));
- wxCoord rad = (wxCoord)radius;
- double radius1, radius2;
- if (xx1 == xx2 && yy1 == yy2)
- {
- radius1 = 0.0;
- radius2 = 360.0;
- }
- else if (radius == 0.0)
- {
- radius1 = radius2 = 0.0;
- }
- else
- {
- radius1 = (xx1 - xxc == 0) ?
- (yy1 - yyc < 0) ? 90.0 : -90.0 :
- -atan2(double(yy1-yyc), double(xx1-xxc)) * RAD2DEG;
- radius2 = (xx2 - xxc == 0) ?
- (yy2 - yyc < 0) ? 90.0 : -90.0 :
- -atan2(double(yy2-yyc), double(xx2-xxc)) * RAD2DEG;
- }
- wxCoord alpha2 = wxCoord(radius2 - radius1);
- wxCoord alpha1 = wxCoord(wxConvertWXangleToMACangle(radius1));
- if( (xx1 > xx2) || (yy1 > yy2) ) {
- alpha2 *= -1;
- }
- Rect r = { yyc - rad, xxc - rad, yyc + rad, xxc + rad };
- if(m_brush.GetStyle() != wxTRANSPARENT) {
- MacInstallBrush();
- PaintArc(&r, alpha1, alpha2);
- }
- if(m_pen.GetStyle() != wxTRANSPARENT) {
- MacInstallPen();
- FrameArc(&r, alpha1, alpha2);
- }
-}
-
-void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
- double sa, double ea )
-{
- wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- Rect r;
- double angle = sa - ea; // Order important Mac in opposite direction to wx
- // we have to make sure that the filling is always counter-clockwise
- if ( angle > 0 )
- angle -= 360 ;
- wxCoord xx = XLOG2DEVMAC(x);
- wxCoord yy = YLOG2DEVMAC(y);
- wxCoord ww = m_signX * XLOG2DEVREL(w);
- wxCoord hh = m_signY * YLOG2DEVREL(h);
- // handle -ve width and/or height
- if (ww < 0) { ww = -ww; xx = xx - ww; }
- if (hh < 0) { hh = -hh; yy = yy - hh; }
- sa = wxConvertWXangleToMACangle(sa);
- r.top = yy;
- r.left = xx;
- r.bottom = yy + hh;
- r.right = xx + ww;
- if(m_brush.GetStyle() != wxTRANSPARENT) {
- MacInstallBrush();
- PaintArc(&r, (short)sa, (short)angle);
- }
- if(m_pen.GetStyle() != wxTRANSPARENT) {
- MacInstallPen();
- FrameArc(&r, (short)sa, (short)angle);
- }
-}
-
-void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- wxCoord xx1 = XLOG2DEVMAC(x);
- wxCoord yy1 = YLOG2DEVMAC(y);
- RGBColor pencolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel());
- ::SetCPixel( xx1,yy1,&pencolor) ;
- CalcBoundingBox(x, y);
- }
-}
-
-void wxDC::DoDrawLines(int n, wxPoint points[],
- wxCoord xoffset, wxCoord yoffset)
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- if (m_pen.GetStyle() == wxTRANSPARENT)
- return;
- MacInstallPen() ;
- wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 :
- m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2 ;
- wxCoord x1, x2 , y1 , y2 ;
- x1 = XLOG2DEVMAC(points[0].x + xoffset);
- y1 = YLOG2DEVMAC(points[0].y + yoffset);
- ::MoveTo(x1 - offset, y1 - offset );
- for (int i = 0; i < n-1; i++)
- {
- x2 = XLOG2DEVMAC(points[i+1].x + xoffset);
- y2 = YLOG2DEVMAC(points[i+1].y + yoffset);
- ::LineTo( x2 - offset, y2 - offset );
- }
-}
-
-void wxDC::DoDrawPolygon(int n, wxPoint points[],
- wxCoord xoffset, wxCoord yoffset,
- int fillStyle )
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- wxCoord x1, x2 , y1 , y2 ;
- if ( m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT )
- return ;
- PolyHandle polygon = OpenPoly();
- x2 = x1 = XLOG2DEVMAC(points[0].x + xoffset);
- y2 = y1 = YLOG2DEVMAC(points[0].y + yoffset);
- ::MoveTo(x1,y1);
- for (int i = 1; i < n; i++)
- {
- x2 = XLOG2DEVMAC(points[i].x + xoffset);
- y2 = YLOG2DEVMAC(points[i].y + yoffset);
- ::LineTo(x2, y2);
- }
- // close the polyline if necessary
- if ( x1 != x2 || y1 != y2 )
- {
- ::LineTo(x1,y1 ) ;
- }
- ClosePoly();
- if (m_brush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush();
- ::PaintPoly( polygon );
- }
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- ::FramePoly( polygon ) ;
- }
- KillPoly( polygon );
-}
-
-void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- wxCoord xx = XLOG2DEVMAC(x);
- wxCoord yy = YLOG2DEVMAC(y);
- wxCoord ww = m_signX * XLOG2DEVREL(width);
- wxCoord hh = m_signY * YLOG2DEVREL(height);
- // CMB: draw nothing if transformed w or h is 0
- if (ww == 0 || hh == 0)
- return;
- // CMB: handle -ve width and/or height
- if (ww < 0)
- {
- ww = -ww;
- xx = xx - ww;
- }
- if (hh < 0)
- {
- hh = -hh;
- yy = yy - hh;
- }
- Rect rect = { yy , xx , yy + hh , xx + ww } ;
- if (m_brush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush() ;
- ::PaintRect( &rect ) ;
- }
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- ::FrameRect( &rect ) ;
- }
-}
-
-void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
- wxCoord width, wxCoord height,
- double radius)
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- if (radius < 0.0)
- radius = - radius * ((width < height) ? width : height);
- wxCoord xx = XLOG2DEVMAC(x);
- wxCoord yy = YLOG2DEVMAC(y);
- wxCoord ww = m_signX * XLOG2DEVREL(width);
- wxCoord hh = m_signY * YLOG2DEVREL(height);
- // CMB: draw nothing if transformed w or h is 0
- if (ww == 0 || hh == 0)
- return;
- // CMB: handle -ve width and/or height
- if (ww < 0)
- {
- ww = -ww;
- xx = xx - ww;
- }
- if (hh < 0)
- {
- hh = -hh;
- yy = yy - hh;
- }
- Rect rect = { yy , xx , yy + hh , xx + ww } ;
- if (m_brush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush() ;
- ::PaintRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ;
- }
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- ::FrameRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ;
- }
-}
-
-void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- wxCoord xx = XLOG2DEVMAC(x);
- wxCoord yy = YLOG2DEVMAC(y);
- wxCoord ww = m_signX * XLOG2DEVREL(width);
- wxCoord hh = m_signY * YLOG2DEVREL(height);
- // CMB: draw nothing if transformed w or h is 0
- if (ww == 0 || hh == 0)
- return;
- // CMB: handle -ve width and/or height
- if (ww < 0)
- {
- ww = -ww;
- xx = xx - ww;
- }
- if (hh < 0)
- {
- hh = -hh;
- yy = yy - hh;
- }
- Rect rect = { yy , xx , yy + hh , xx + ww } ;
- if (m_brush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush() ;
- ::PaintOval( &rect ) ;
- }
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- ::FrameOval( &rect ) ;
- }
-}
-
-bool wxDC::CanDrawBitmap(void) const
-{
- return true ;
-}
-
-bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
- wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask,
- wxCoord xsrcMask, wxCoord ysrcMask )
-{
- wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
- wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
- if ( logical_func == wxNO_OP )
- return true ;
- if (xsrcMask == -1 && ysrcMask == -1)
- {
- xsrcMask = xsrc; ysrcMask = ysrc;
- }
- // correct the parameter in case this dc does not have a mask at all
- if ( useMask && !source->m_macMask )
- useMask = false ;
- Rect srcrect , dstrect ;
- srcrect.top = source->YLOG2DEVMAC(ysrc) ;
- srcrect.left = source->XLOG2DEVMAC(xsrc) ;
- srcrect.right = source->XLOG2DEVMAC(xsrc + width ) ;
- srcrect.bottom = source->YLOG2DEVMAC(ysrc + height) ;
- dstrect.top = YLOG2DEVMAC(ydest) ;
- dstrect.left = XLOG2DEVMAC(xdest) ;
- dstrect.bottom = YLOG2DEVMAC(ydest + height ) ;
- dstrect.right = XLOG2DEVMAC(xdest + width ) ;
- short mode = kUnsupportedMode ;
- bool invertDestinationFirst = false ;
- switch ( logical_func )
- {
- case wxAND: // src AND dst
- mode = adMin ; // ok
- break ;
- case wxAND_INVERT: // (NOT src) AND dst
- mode = notSrcOr ; // ok
- break ;
- case wxAND_REVERSE:// src AND (NOT dst)
- invertDestinationFirst = true ;
- mode = srcOr ;
- break ;
- case wxCLEAR: // 0
- mode = kEmulatedMode ;
- break ;
- case wxCOPY: // src
- mode = srcCopy ; // ok
- break ;
- case wxEQUIV: // (NOT src) XOR dst
- mode = srcXor ; // ok
- break ;
- case wxINVERT: // NOT dst
- mode = kEmulatedMode ; //or hilite ;
- break ;
- case wxNAND: // (NOT src) OR (NOT dst)
- invertDestinationFirst = true ;
- mode = srcBic ;
- break ;
- case wxNOR: // (NOT src) AND (NOT dst)
- invertDestinationFirst = true ;
- mode = notSrcOr ;
- break ;
- case wxNO_OP: // dst
- mode = kEmulatedMode ; // this has already been handled upon entry
- break ;
- case wxOR: // src OR dst
- mode = notSrcBic ;
- break ;
- case wxOR_INVERT: // (NOT src) OR dst
- mode = srcBic ;
- break ;
- case wxOR_REVERSE: // src OR (NOT dst)
- invertDestinationFirst = true ;
- mode = notSrcBic ;
- break ;
- case wxSET: // 1
- mode = kEmulatedMode ;
- break ;
- case wxSRC_INVERT: // (NOT src)
- mode = notSrcCopy ; // ok
- break ;
- case wxXOR: // src XOR dst
- mode = notSrcXor ; // ok
- break ;
- default :
- break ;
- }
- if ( mode == kUnsupportedMode )
- {
- wxFAIL_MSG(wxT("unsupported blitting mode" ));
- return false ;
- }
- CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ;
- PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
- if ( LockPixels(bmappixels) )
- {
- wxMacFastPortSetter helper(this) ;
- if ( source->GetDepth() == 1 )
- {
- RGBForeColor( &MAC_WXCOLORREF(m_textForegroundColour.GetPixel()) ) ;
- RGBBackColor( &MAC_WXCOLORREF(m_textBackgroundColour.GetPixel()) ) ;
- }
- else
- {
- // the modes need this, otherwise we'll end up having really nice colors...
- RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
- RGBColor black = { 0,0,0} ;
- RGBForeColor( &black ) ;
- RGBBackColor( &white ) ;
- }
- if ( useMask && source->m_macMask )
- {
- if ( mode == srcCopy )
- {
- if ( LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) )
- {
- CopyMask( GetPortBitMapForCopyBits( sourcePort ) ,
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(source->m_macMask) ) ,
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) ,
- &srcrect, &srcrect , &dstrect ) ;
- UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ;
- }
- }
- else
- {
- RgnHandle clipRgn = NewRgn() ;
- LockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ;
- BitMapToRegion( clipRgn , (BitMap*) *GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ;
- UnlockPixels( GetGWorldPixMap( MAC_WXHBITMAP(source->m_macMask) ) ) ;
- OffsetRgn( clipRgn , -srcrect.left + dstrect.left, -srcrect.top + dstrect.top ) ;
- if ( mode == kEmulatedMode )
- {
- Pattern pat ;
- ::PenPat(GetQDGlobalsBlack(&pat));
- if ( logical_func == wxSET )
- {
- RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ;
- ::RGBForeColor( &col ) ;
- ::PaintRgn( clipRgn ) ;
- }
- else if ( logical_func == wxCLEAR )
- {
- RGBColor col= { 0x0000, 0x0000, 0x0000 } ;
- ::RGBForeColor( &col ) ;
- ::PaintRgn( clipRgn ) ;
- }
- else if ( logical_func == wxINVERT )
- {
- MacInvertRgn( clipRgn ) ;
- }
- else
- {
- for ( int y = 0 ; y < srcrect.right - srcrect.left ; ++y )
- {
- for ( int x = 0 ; x < srcrect.bottom - srcrect.top ; ++x )
- {
- Point dstPoint = { dstrect.top + y , dstrect.left + x } ;
- Point srcPoint = { srcrect.top + y , srcrect.left + x } ;
- if ( PtInRgn( dstPoint , clipRgn ) )
- {
- RGBColor srcColor ;
- RGBColor dstColor ;
- SetPort( (GrafPtr) sourcePort ) ;
- GetCPixel( srcPoint.h , srcPoint.v , &srcColor) ;
- SetPort( (GrafPtr) m_macPort ) ;
- GetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ;
- wxMacCalculateColour( logical_func , srcColor , dstColor ) ;
- SetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ;
- }
- }
- }
- }
- }
- else
- {
- if ( invertDestinationFirst )
- {
- MacInvertRgn( clipRgn ) ;
- }
- CopyBits( GetPortBitMapForCopyBits( sourcePort ) ,
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) ,
- &srcrect, &dstrect, mode, clipRgn ) ;
- }
- DisposeRgn( clipRgn ) ;
- }
- }
- else
- {
- RgnHandle clipRgn = NewRgn() ;
- SetRectRgn( clipRgn , dstrect.left , dstrect.top , dstrect.right , dstrect.bottom ) ;
- if ( mode == kEmulatedMode )
- {
- Pattern pat ;
- ::PenPat(GetQDGlobalsBlack(&pat));
- if ( logical_func == wxSET )
- {
- RGBColor col= { 0xFFFF, 0xFFFF, 0xFFFF } ;
- ::RGBForeColor( &col ) ;
- ::PaintRgn( clipRgn ) ;
- }
- else if ( logical_func == wxCLEAR )
- {
- RGBColor col= { 0x0000, 0x0000, 0x0000 } ;
- ::RGBForeColor( &col ) ;
- ::PaintRgn( clipRgn ) ;
- }
- else if ( logical_func == wxINVERT )
- {
- MacInvertRgn( clipRgn ) ;
- }
- else
- {
- for ( int y = 0 ; y < srcrect.right - srcrect.left ; ++y )
- {
- for ( int x = 0 ; x < srcrect.bottom - srcrect.top ; ++x )
- {
- Point dstPoint = { dstrect.top + y , dstrect.left + x } ;
- Point srcPoint = { srcrect.top + y , srcrect.left + x } ;
- {
- RGBColor srcColor ;
- RGBColor dstColor ;
- SetPort( (GrafPtr) sourcePort ) ;
- GetCPixel( srcPoint.h , srcPoint.v , &srcColor) ;
- SetPort( (GrafPtr) m_macPort ) ;
- GetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ;
- wxMacCalculateColour( logical_func , srcColor , dstColor ) ;
- SetCPixel( dstPoint.h , dstPoint.v , &dstColor ) ;
- }
- }
- }
- }
- }
- else
- {
- if ( invertDestinationFirst )
- {
- MacInvertRgn( clipRgn ) ;
- }
- CopyBits( GetPortBitMapForCopyBits( sourcePort ) ,
- GetPortBitMapForCopyBits( MAC_WXHBITMAP(m_macPort) ) ,
- &srcrect, &dstrect, mode, NULL ) ;
- }
- DisposeRgn( clipRgn ) ;
- }
- UnlockPixels( bmappixels ) ;
- }
- m_macPenInstalled = false ;
- m_macBrushInstalled = false ;
- m_macFontInstalled = false ;
- return true;
-}
-
-#ifndef FixedToInt
-// as macro in FixMath.h for 10.3
-inline Fixed IntToFixed( int inInt )
-{
- return (((SInt32) inInt) << 16);
-}
-
-inline int FixedToInt( Fixed inFixed )
-{
- return (((SInt32) inFixed) >> 16);
-}
-#endif
-
-void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
- double angle)
-{
- wxCHECK_RET( Ok(), wxT("wxDC::DoDrawRotatedText Invalid window dc") );
-
- if (angle == 0.0 )
- {
- DrawText(str, x, y);
- return;
- }
-
- if ( str.length() == 0 )
- return ;
-
- wxMacFastPortSetter helper(this) ;
- MacInstallFont() ;
-
- if ( 0 )
- {
- m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize);
- SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * m_font.GetMacFontSize()));
- m_macAliasWasEnabled = true ;
- }
- OSStatus status = noErr ;
- ATSUTextLayout atsuLayout ;
- UniCharCount chars = str.length() ;
-#if wxUSE_UNICODE
- status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.length() , str.length() , 1 ,
- &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
-#else
- wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
- int wlen = wxWcslen( wchar.data() ) ;
- status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) wchar.data() , 0 , wlen , wlen , 1 ,
- &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
-#endif
- wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
- int iAngle = int( angle );
- int drawX = XLOG2DEVMAC(x) ;
- int drawY = YLOG2DEVMAC(y) ;
-
- ATSUTextMeasurement textBefore ;
- ATSUTextMeasurement textAfter ;
- ATSUTextMeasurement ascent ;
- ATSUTextMeasurement descent ;
-
-
- if ( abs(iAngle) > 0 )
- {
- Fixed atsuAngle = IntToFixed( iAngle ) ;
- ATSUAttributeTag atsuTags[] =
- {
- kATSULineRotationTag ,
- } ;
- ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
- {
- sizeof( Fixed ) ,
- } ;
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
- {
- &atsuAngle ,
- } ;
- status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag),
- atsuTags, atsuSizes, atsuValues ) ;
- }
- status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
- &textBefore , &textAfter, &ascent , &descent );
-
- drawX += (int)(sin(angle/RAD2DEG) * FixedToInt(ascent));
- drawY += (int)(cos(angle/RAD2DEG) * FixedToInt(ascent));
- status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
- IntToFixed(drawX) , IntToFixed(drawY) );
- wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") );
- Rect rect ;
- status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
- IntToFixed(drawX) , IntToFixed(drawY) , &rect );
- wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
- OffsetRect( &rect , -m_macLocalOrigin.x , -m_macLocalOrigin.y ) ;
- CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) );
- CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) );
- ::ATSUDisposeTextLayout(atsuLayout);
-}
-
-void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
-{
- wxCHECK_RET(Ok(), wxT("wxDC::DoDrawText Invalid DC"));
-
- wxMacFastPortSetter helper(this) ;
- long xx = XLOG2DEVMAC(x);
- long yy = YLOG2DEVMAC(y);
-#if TARGET_CARBON
- bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ;
- if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || m_font.GetNoAntiAliasing() )
- useDrawThemeText = false ;
-#endif
- MacInstallFont() ;
- if ( 0 )
- {
- m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize);
- SetAntiAliasedTextEnabled(true, 8);
- m_macAliasWasEnabled = true ;
- }
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
-#if TARGET_CARBON
- if ( !useDrawThemeText )
-#endif
- yy += fi.ascent ;
- ::MoveTo( xx , yy );
- if ( m_backgroundMode == wxTRANSPARENT )
- {
- ::TextMode( srcOr) ;
- }
- else
- {
- ::TextMode( srcCopy ) ;
- }
- int length = strtext.length() ;
-
- int laststop = 0 ;
- int i = 0 ;
- int line = 0 ;
- {
-#if 0 // we don't have to do all that here
- while( i < length )
- {
- if( strtext[i] == 13 || strtext[i] == 10)
- {
- wxString linetext = strtext.Mid( laststop , i - laststop ) ;
-#if TARGET_CARBON
- if ( useDrawThemeText )
- {
- Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ;
- wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ;
- if ( m_backgroundMode != wxTRANSPARENT )
- {
- Point bounds={0,0} ;
- Rect background = frame ;
- SInt16 baseline ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- background.right = background.left + bounds.h ;
- background.bottom = background.top + bounds.v ;
- ::EraseRect( &background ) ;
- }
- ::DrawThemeTextBox( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &frame,
- teJustLeft,
- nil );
- line++ ;
- }
- else
-#endif
- {
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
- ::DrawText( text , 0 , strlen(text) ) ;
- if ( m_backgroundMode != wxTRANSPARENT )
- {
- Point bounds={0,0} ;
- Rect background = frame ;
- SInt16 baseline ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- background.right = background.left + bounds.h ;
- background.bottom = background.top + bounds.v ;
- ::EraseRect( &background ) ;
- }
- line++ ;
- ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
- }
- laststop = i+1 ;
- }
- i++ ;
- }
- wxString linetext = strtext.Mid( laststop , i - laststop ) ;
-#endif // 0
- wxString linetext = strtext ;
-#if TARGET_CARBON
- if ( useDrawThemeText )
- {
- Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ;
- wxMacCFStringHolder mString( linetext , m_font.GetEncoding()) ;
-
- if ( m_backgroundMode != wxTRANSPARENT )
- {
- Point bounds={0,0} ;
- Rect background = frame ;
- SInt16 baseline ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- background.right = background.left + bounds.h ;
- background.bottom = background.top + bounds.v ;
- ::EraseRect( &background ) ;
- }
- ::DrawThemeTextBox( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &frame,
- teJustLeft,
- nil );
- }
- else
-#endif
- {
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
- if ( m_backgroundMode != wxTRANSPARENT )
- {
- Rect frame = { yy - fi.ascent + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy - fi.ascent + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ;
- short width = ::TextWidth( text , 0 , strlen(text) ) ;
- frame.right = frame.left + width ;
-
- ::EraseRect( &frame ) ;
- }
- ::DrawText( text , 0 , strlen(text) ) ;
- }
- }
- ::TextMode( srcOr ) ;
-}
-
-bool wxDC::CanGetTextExtent() const
-{
- wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
- return true ;
-}
-
-void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *height,
- wxCoord *descent, wxCoord *externalLeading ,
- wxFont *theFont ) const
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- wxFont formerFont = m_font ;
- if ( theFont )
- {
- // work around the constness
- *((wxFont*)(&m_font)) = *theFont ;
- }
- MacInstallFont() ;
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
-#if TARGET_CARBON
- bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
- if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() )
- useGetThemeText = false ;
-#endif
- if ( height )
- *height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
- if ( descent )
- *descent =YDEV2LOGREL( fi.descent );
- if ( externalLeading )
- *externalLeading = YDEV2LOGREL( fi.leading ) ;
- int length = strtext.length() ;
-
- int laststop = 0 ;
- int i = 0 ;
- int curwidth = 0 ;
- if ( width )
- {
- *width = 0 ;
-#if 0 // apparently we don't have to do all that
- while( i < length )
- {
- if( strtext[i] == 13 || strtext[i] == 10)
- {
- wxString linetext = strtext.Mid( laststop , i - laststop ) ;
- if ( height )
- *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ;
-#if TARGET_CARBON
- if ( useGetThemeText )
- {
- Point bounds={0,0} ;
- SInt16 baseline ;
- wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- curwidth = bounds.h ;
- }
- else
-#endif
- {
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
- curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
- }
- if ( curwidth > *width )
- *width = XDEV2LOGREL( curwidth ) ;
- laststop = i+1 ;
- }
- i++ ;
- }
-
- wxString linetext = strtext.Mid( laststop , i - laststop ) ;
-#endif // 0
- wxString linetext = strtext ;
-#if TARGET_CARBON
- if ( useGetThemeText )
- {
- Point bounds={0,0} ;
- SInt16 baseline ;
- wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- curwidth = bounds.h ;
- }
- else
-#endif
- {
- wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
- curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
- }
- if ( curwidth > *width )
- *width = XDEV2LOGREL( curwidth ) ;
- }
- if ( theFont )
- {
- // work around the constness
- *((wxFont*)(&m_font)) = formerFont ;
- m_macFontInstalled = false ;
- }
-}
-
-
-bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
-{
- wxCHECK_MSG(Ok(), false, wxT("Invalid DC"));
-
- widths.Empty();
- widths.Add(0, text.length());
-
- if (text.length() == 0)
- return false;
-
- wxMacFastPortSetter helper(this) ;
- MacInstallFont() ;
-#if TARGET_CARBON
- bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
- if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() )
- useGetThemeText = false ;
-
- if ( useGetThemeText )
- {
- // If anybody knows how to do this more efficiently yet still handle
- // the fractional glyph widths that may be present when using AA
- // fonts, please change it. Currently it is measuring from the
- // begining of the string for each succeding substring, which is much
- // slower than this should be.
- for (size_t i=0; i<text.length(); i++)
- {
- wxString str(text.Left(i+1));
- Point bounds = {0,0};
- SInt16 baseline ;
- wxMacCFStringHolder mString(str, m_font.GetEncoding());
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- widths[i] = XDEV2LOGREL(bounds.h);
- }
- }
- else
-#endif
- {
- wxCharBuffer buff = text.mb_str(wxConvLocal);
- size_t len = strlen(buff);
- short* measurements = new short[len+1];
- MeasureText(len, buff.data(), measurements);
-
- // Copy to widths, starting at measurements[1]
- // NOTE: this doesn't take into account any multi-byte characters
- // in buff, it probabkly should...
- for (size_t i=0; i<text.length(); i++)
- widths[i] = XDEV2LOGREL(measurements[i+1]);
-
- delete [] measurements;
- }
-
- return true;
-}
-
-
-
-wxCoord wxDC::GetCharWidth(void) const
-{
- wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- MacInstallFont() ;
- int width = 0 ;
-#if TARGET_CARBON
- bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ;
- if ( UMAGetSystemVersion() < 0x1000 || ((wxFont*)&m_font)->GetNoAntiAliasing() )
- useGetThemeText = false ;
-#endif
- char text[] = "g" ;
-#if TARGET_CARBON
- if ( useGetThemeText )
- {
- Point bounds={0,0} ;
- SInt16 baseline ;
- CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text , 1 , CFStringGetSystemEncoding(), false ) ;
- ::GetThemeTextDimensions( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- CFRelease( mString ) ;
- width = bounds.h ;
- }
- else
-#endif
- {
- width = ::TextWidth( text , 0 , 1 ) ;
- }
- return YDEV2LOGREL(width) ;
-}
-
-wxCoord wxDC::GetCharHeight(void) const
-{
- wxCHECK_MSG(Ok(), 1, wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- MacInstallFont() ;
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
- return YDEV2LOGREL( fi.descent + fi.ascent );
-}
-
-void wxDC::Clear(void)
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacFastPortSetter helper(this) ;
- Rect rect = { -31000 , -31000 , 31000 , 31000 } ;
- if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
- {
- ::PenNormal() ;
- //MacInstallBrush() ;
- MacSetupBackgroundForCurrentPort( m_backgroundBrush ) ;
- ::EraseRect( &rect ) ;
- }
-}
-
-void wxDC::MacInstallFont() const
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- // if ( m_macFontInstalled )
- // return ;
- Pattern blackColor ;
- MacSetupBackgroundForCurrentPort(m_backgroundBrush) ;
- if ( m_font.Ok() )
- {
- ::TextFont( m_font.GetMacFontNum() ) ;
- ::TextSize( (short)(m_scaleY * m_font.GetMacFontSize()) ) ;
- ::TextFace( m_font.GetMacFontStyle() ) ;
- m_macFontInstalled = true ;
- m_macBrushInstalled = false ;
- m_macPenInstalled = false ;
- RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel());
- RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel());
- ::RGBForeColor( &forecolor );
- ::RGBBackColor( &backcolor );
- }
- else
- {
- FontFamilyID fontId ;
- Str255 fontName ;
- SInt16 fontSize ;
- Style fontStyle ;
- GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
- GetFNum( fontName, &fontId );
- ::TextFont( fontId ) ;
- ::TextSize( short(m_scaleY * fontSize) ) ;
- ::TextFace( fontStyle ) ;
- // todo reset after spacing changes - or store the current spacing somewhere
- m_macFontInstalled = true ;
- m_macBrushInstalled = false ;
- m_macPenInstalled = false ;
- RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel());
- RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel());
- ::RGBForeColor( &forecolor );
- ::RGBBackColor( &backcolor );
- }
- short mode = patCopy ;
- // todo :
- switch( m_logicalFunction )
- {
- case wxCOPY: // src
- mode = patCopy ;
- break ;
- case wxINVERT: // NOT dst
- ::PenPat(GetQDGlobalsBlack(&blackColor));
- mode = patXor ;
- break ;
- case wxXOR: // src XOR dst
- mode = patXor ;
- break ;
- case wxOR_REVERSE: // src OR (NOT dst)
- mode = notPatOr ;
- break ;
- case wxSRC_INVERT: // (NOT src)
- mode = notPatCopy ;
- break ;
- case wxAND: // src AND dst
- mode = adMin ;
- break ;
- // unsupported TODO
- case wxCLEAR: // 0
- case wxAND_REVERSE:// src AND (NOT dst)
- case wxAND_INVERT: // (NOT src) AND dst
- case wxNO_OP: // dst
- case wxNOR: // (NOT src) AND (NOT dst)
- case wxEQUIV: // (NOT src) XOR dst
- case wxOR_INVERT: // (NOT src) OR dst
- case wxNAND: // (NOT src) OR (NOT dst)
- case wxOR: // src OR dst
- case wxSET: // 1
- // case wxSRC_OR: // source _bitmap_ OR destination
- // case wxSRC_AND: // source _bitmap_ AND destination
- break ;
- }
- ::PenMode( mode ) ;
- OSStatus status = noErr ;
- Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.GetMacFontSize()) ) ;
- Style qdStyle = m_font.GetMacFontStyle() ;
- ATSUFontID atsuFont = m_font.GetMacATSUFontID() ;
- status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ;
- wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ;
- ATSUAttributeTag atsuTags[] =
- {
- kATSUFontTag ,
- kATSUSizeTag ,
- // kATSUColorTag ,
- // kATSUBaselineClassTag ,
- kATSUVerticalCharacterTag,
- kATSUQDBoldfaceTag ,
- kATSUQDItalicTag ,
- kATSUQDUnderlineTag ,
- kATSUQDCondensedTag ,
- kATSUQDExtendedTag ,
- } ;
- ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
- {
- sizeof( ATSUFontID ) ,
- sizeof( Fixed ) ,
- // sizeof( RGBColor ) ,
- // sizeof( BslnBaselineClass ) ,
- sizeof( ATSUVerticalCharacterType),
- sizeof( Boolean ) ,
- sizeof( Boolean ) ,
- sizeof( Boolean ) ,
- sizeof( Boolean ) ,
- sizeof( Boolean ) ,
- } ;
- Boolean kTrue = true ;
- Boolean kFalse = false ;
- //BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ;
- ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
- {
- &atsuFont ,
- &atsuSize ,
- // &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ,
- // &kBaselineDefault ,
- &kHorizontal,
- (qdStyle & bold) ? &kTrue : &kFalse ,
- (qdStyle & italic) ? &kTrue : &kFalse ,
- (qdStyle & underline) ? &kTrue : &kFalse ,
- (qdStyle & condense) ? &kTrue : &kFalse ,
- (qdStyle & extend) ? &kTrue : &kFalse ,
- } ;
- status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag) ,
- atsuTags, atsuSizes, atsuValues);
- wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ;
-}
-
-Pattern gPatterns[] =
-{ // hatch patterns
- { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
- { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
- { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
- { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
- { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
- { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
- { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
- // dash patterns
- { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
- { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
- { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
- { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
-} ;
-
-static void wxMacGetPattern(int penStyle, Pattern *pattern)
-{
- int index = 0; // solid pattern by default
- switch(penStyle)
- {
- // hatches
- case wxBDIAGONAL_HATCH: index = 1; break;
- case wxFDIAGONAL_HATCH: index = 2; break;
- case wxCROSS_HATCH: index = 3; break;
- case wxHORIZONTAL_HATCH: index = 4; break;
- case wxVERTICAL_HATCH: index = 5; break;
- case wxCROSSDIAG_HATCH: index = 6; break;
- // dashes
- case wxDOT: index = 7; break;
- case wxLONG_DASH: index = 8; break;
- case wxSHORT_DASH: index = 9; break;
- case wxDOT_DASH: index = 10; break;
- }
- *pattern = gPatterns[index];
-}
-
-void wxDC::MacInstallPen() const
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- //Pattern blackColor;
- // if ( m_macPenInstalled )
- // return ;
- RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel());
- RGBColor backcolor = MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel());
- ::RGBForeColor( &forecolor );
- ::RGBBackColor( &backcolor );
- ::PenNormal() ;
- int penWidth = (int) (m_pen.GetWidth() * m_scaleX) ; ;
- // null means only one pixel, at whatever resolution
- if ( penWidth == 0 )
- penWidth = 1 ;
- ::PenSize(penWidth, penWidth);
-
- int penStyle = m_pen.GetStyle();
- Pattern pat;
- if (penStyle == wxUSER_DASH)
- {
- // FIXME: there should be exactly 8 items in the dash
- wxDash* dash ;
- int number = m_pen.GetDashes(&dash) ;
- int index = 0;
- for ( int i = 0 ; i < 8 ; ++i )
- {
- pat.pat[i] = dash[index] ;
- if (index < number - 1)
- index++;
- }
- }
- else
- {
- wxMacGetPattern(penStyle, &pat);
- }
- ::PenPat(&pat);
-
- short mode = patCopy ;
- // todo :
- switch( m_logicalFunction )
- {
- case wxCOPY: // only foreground color, leave background (thus not patCopy)
- mode = patOr ;
- break ;
- case wxINVERT: // NOT dst
- // ::PenPat(GetQDGlobalsBlack(&blackColor));
- mode = patXor ;
- break ;
- case wxXOR: // src XOR dst
- mode = patXor ;
- break ;
- case wxOR_REVERSE: // src OR (NOT dst)
- mode = notPatOr ;
- break ;
- case wxSRC_INVERT: // (NOT src)
- mode = notPatCopy ;
- break ;
- case wxAND: // src AND dst
- mode = adMin ;
- break ;
- // unsupported TODO
- case wxCLEAR: // 0
- case wxAND_REVERSE:// src AND (NOT dst)
- case wxAND_INVERT: // (NOT src) AND dst
- case wxNO_OP: // dst
- case wxNOR: // (NOT src) AND (NOT dst)
- case wxEQUIV: // (NOT src) XOR dst
- case wxOR_INVERT: // (NOT src) OR dst
- case wxNAND: // (NOT src) OR (NOT dst)
- case wxOR: // src OR dst
- case wxSET: // 1
- // case wxSRC_OR: // source _bitmap_ OR destination
- // case wxSRC_AND: // source _bitmap_ AND destination
- break ;
- }
- ::PenMode( mode ) ;
- m_macPenInstalled = true ;
- m_macBrushInstalled = false ;
- m_macFontInstalled = false ;
-}
-
-void wxDC::MacSetupBackgroundForCurrentPort(const wxBrush& background )
-{
- Pattern whiteColor ;
- switch( background.MacGetBrushKind() )
- {
- case kwxMacBrushTheme :
- {
- ::SetThemeBackground( background.GetMacTheme() , wxDisplayDepth() , true ) ;
- break ;
- }
- case kwxMacBrushThemeBackground :
- {
- Rect extent ;
- ThemeBackgroundKind bg = background.GetMacThemeBackground( &extent ) ;
- ::ApplyThemeBackground( bg , &extent ,kThemeStateActive , wxDisplayDepth() , true ) ;
- break ;
- }
- case kwxMacBrushColour :
- {
- ::RGBBackColor( &MAC_WXCOLORREF( background.GetColour().GetPixel()) );
- int brushStyle = background.GetStyle();
- if (brushStyle == wxSOLID)
- ::BackPat(GetQDGlobalsWhite(&whiteColor));
- else if (background.IsHatch())
- {
- Pattern pat ;
- wxMacGetPattern(brushStyle, &pat);
- ::BackPat(&pat);
- }
- else
- {
- ::BackPat(GetQDGlobalsWhite(&whiteColor));
- }
- break ;
- }
- }
-}
-
-void wxDC::MacInstallBrush() const
-{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- Pattern blackColor ;
- // if ( m_macBrushInstalled )
- // return ;
- // foreground
- bool backgroundTransparent = (GetBackgroundMode() == wxTRANSPARENT) ;
- ::RGBForeColor( &MAC_WXCOLORREF( m_brush.GetColour().GetPixel()) );
- ::RGBBackColor( &MAC_WXCOLORREF( m_backgroundBrush.GetColour().GetPixel()) );
- int brushStyle = m_brush.GetStyle();
- if (brushStyle == wxSOLID)
- {
- ::PenPat(GetQDGlobalsBlack(&blackColor));
- }
- else if (m_brush.IsHatch())
- {
- Pattern pat ;
- wxMacGetPattern(brushStyle, &pat);
- ::PenPat(&pat);
- }
- else if ( m_brush.GetStyle() == wxSTIPPLE || m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
- {
- // we force this in order to be compliant with wxMSW
- backgroundTransparent = false ;
- // for these the text fore (and back for MASK_OPAQUE) colors are used
- wxBitmap* bitmap = m_brush.GetStipple() ;
- int width = bitmap->GetWidth() ;
- int height = bitmap->GetHeight() ;
- GWorldPtr gw = NULL ;
- if ( m_brush.GetStyle() == wxSTIPPLE )
- gw = MAC_WXHBITMAP(bitmap->GetHBITMAP()) ;
- else
- gw = MAC_WXHBITMAP(bitmap->GetMask()->GetMaskBitmap()) ;
- PixMapHandle gwpixmaphandle = GetGWorldPixMap( gw ) ;
- LockPixels( gwpixmaphandle ) ;
- bool isMonochrome = !IsPortColor( gw ) ;
- if ( !isMonochrome )
- {
- if ( (**gwpixmaphandle).pixelSize == 1 )
- isMonochrome = true ;
- }
- if ( isMonochrome && width == 8 && height == 8 )
- {
- ::RGBForeColor( &MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) );
- ::RGBForeColor( &MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) );
- BitMap* gwbitmap = (BitMap*) *gwpixmaphandle ; // since the color depth is 1 it is a BitMap
- UInt8 *gwbits = (UInt8*) gwbitmap->baseAddr ;
- int alignment = gwbitmap->rowBytes & 0x7FFF ;
- Pattern pat ;
- for ( int i = 0 ; i < 8 ; ++i )
- {
- pat.pat[i] = gwbits[i*alignment+0] ;
- }
- UnlockPixels( GetGWorldPixMap( gw ) ) ;
- ::PenPat( &pat ) ;
- }
- else
- {
- // this will be the code to handle power of 2 patterns, we will have to arrive at a nice
- // caching scheme before putting this into production
- Handle image;
- long imageSize;
- PixPatHandle pixpat = NewPixPat() ;
- CopyPixMap(gwpixmaphandle, (**pixpat).patMap);
- imageSize = GetPixRowBytes((**pixpat).patMap) *
- ((**(**pixpat).patMap).bounds.bottom -
- (**(**pixpat).patMap).bounds.top);
- PtrToHand( (**gwpixmaphandle).baseAddr, &image, imageSize );
- (**pixpat).patData = image;
- if ( isMonochrome )
- {
- CTabHandle ctable = ((**((**pixpat).patMap)).pmTable) ;
- ColorSpecPtr ctspec = (ColorSpecPtr) &(**ctable).ctTable ;
- if ( ctspec[0].rgb.red == 0x0000 )
- {
- ctspec[1].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ;
- ctspec[0].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ;
- }
- else
- {
- ctspec[0].rgb = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()) ;
- ctspec[1].rgb = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()) ;
- }
- ::CTabChanged( ctable ) ;
- }
- ::PenPixPat(pixpat);
- m_macForegroundPixMap = pixpat ;
- }
- UnlockPixels( gwpixmaphandle ) ;
- }
- else
- {
- ::PenPat(GetQDGlobalsBlack(&blackColor));
- }
- short mode = patCopy ;
- switch( m_logicalFunction )
- {
- case wxCOPY: // src
- if ( backgroundTransparent )
- mode = patOr ;
- else
- mode = patCopy ;
- break ;
- case wxINVERT: // NOT dst
- if ( !backgroundTransparent )
- {
- ::PenPat(GetQDGlobalsBlack(&blackColor));
- }
- mode = patXor ;
- break ;
- case wxXOR: // src XOR dst
- mode = patXor ;
- break ;
- case wxOR_REVERSE: // src OR (NOT dst)
- mode = notPatOr ;
- break ;
- case wxSRC_INVERT: // (NOT src)
- mode = notPatCopy ;
- break ;
- case wxAND: // src AND dst
- mode = adMin ;
- break ;
- // unsupported TODO
- case wxCLEAR: // 0
- case wxAND_REVERSE:// src AND (NOT dst)
- case wxAND_INVERT: // (NOT src) AND dst
- case wxNO_OP: // dst
- case wxNOR: // (NOT src) AND (NOT dst)
- case wxEQUIV: // (NOT src) XOR dst
- case wxOR_INVERT: // (NOT src) OR dst
- case wxNAND: // (NOT src) OR (NOT dst)
- case wxOR: // src OR dst
- case wxSET: // 1
- // case wxSRC_OR: // source _bitmap_ OR destination
- // case wxSRC_AND: // source _bitmap_ AND destination
- break ;
- }
- ::PenMode( mode ) ;
- m_macBrushInstalled = true ;
- m_macPenInstalled = false ;
- m_macFontInstalled = false ;
-}
-
-// ---------------------------------------------------------------------------
-// coordinates transformations
-// ---------------------------------------------------------------------------
-
-wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
-{
- return ((wxDC *)this)->XDEV2LOG(x);
-}
-
-wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
-{
- return ((wxDC *)this)->YDEV2LOG(y);
-}
-
-wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
-{
- return ((wxDC *)this)->XDEV2LOGREL(x);
-}
-
-wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
-{
- return ((wxDC *)this)->YDEV2LOGREL(y);
-}
-
-wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
-{
- return ((wxDC *)this)->XLOG2DEV(x);
-}
-
-wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
-{
- return ((wxDC *)this)->YLOG2DEV(y);
-}
-
-wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
-{
- return ((wxDC *)this)->XLOG2DEVREL(x);
-}
-
-wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
-{
- return ((wxDC *)this)->YLOG2DEVREL(y);
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dcclient.cpp
-// Purpose: wxClientDC class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 01/02/97
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/dcclient.h"
-
-#ifndef WX_PRECOMP
- #include "wx/window.h"
- #include "wx/dcmemory.h"
- #include "wx/toplevel.h"
- #include "wx/math.h"
- #include "wx/region.h"
-#endif
-
-#include "wx/mac/private.h"
-
-//-----------------------------------------------------------------------------
-// constants
-//-----------------------------------------------------------------------------
-
-#define RAD2DEG 57.2957795131
-
-//-----------------------------------------------------------------------------
-// wxPaintDC
-//-----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
-IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
-IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
-
-/*
- * wxWindowDC
- */
-
-#include "wx/mac/uma.h"
-
-wxWindowDC::wxWindowDC()
-{
- m_window = NULL ;
-}
-
-wxWindowDC::wxWindowDC(wxWindow *window)
-{
- m_window = window ;
- wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
- WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
-
- int x , y ;
- x = y = 0 ;
- window->MacWindowToRootWindow( &x , &y ) ;
- m_macLocalOrigin.x = x ;
- m_macLocalOrigin.y = y ;
- CopyRgn( (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
- OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
- CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
- m_macPort = UMAGetWindowPort( windowref ) ;
- m_ok = true ;
- SetBackground(window->MacGetBackgroundBrush());
-}
-
-wxWindowDC::~wxWindowDC()
-{
-}
-
-void wxWindowDC::DoGetSize( int* width, int* height ) const
-{
- wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
-
- m_window->GetSize(width, height);
-}
-
-/*
- * wxClientDC
- */
-
-wxClientDC::wxClientDC()
-{
- m_window = NULL ;
-}
-
-wxClientDC::wxClientDC(wxWindow *window)
-{
- m_window = window ;
- wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
- if (!rootwindow)
- return;
- WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
- wxPoint origin = window->GetClientAreaOrigin() ;
- wxSize size = window->GetClientSize() ;
- int x , y ;
- x = origin.x ;
- y = origin.y ;
- window->MacWindowToRootWindow( &x , &y ) ;
- m_macLocalOrigin.x = x ;
- m_macLocalOrigin.y = y ;
- SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
- SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
- OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
- OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
- CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
- m_macPort = UMAGetWindowPort( windowref ) ;
-
- m_ok = true ;
- SetBackground(window->MacGetBackgroundBrush());
- SetFont( window->GetFont() ) ;
-}
-
-wxClientDC::~wxClientDC()
-{
-}
-
-void wxClientDC::DoGetSize(int *width, int *height) const
-{
- wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
-
- m_window->GetClientSize( width, height );
-}
-
-
-/*
- * wxPaintDC
- */
-
-wxPaintDC::wxPaintDC()
-{
- m_window = NULL ;
-}
-
-wxPaintDC::wxPaintDC(wxWindow *window)
-{
- m_window = window ;
- wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
- WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
- wxPoint origin = window->GetClientAreaOrigin() ;
- wxSize size = window->GetClientSize() ;
- int x , y ;
- x = origin.x ;
- y = origin.y ;
- window->MacWindowToRootWindow( &x , &y ) ;
- m_macLocalOrigin.x = x ;
- m_macLocalOrigin.y = y ;
- SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , origin.x , origin.y , origin.x + size.x , origin.y + size.y ) ;
- SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->MacGetVisibleRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
- OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , -origin.x , -origin.y ) ;
- SectRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) window->GetUpdateRegion().GetWXHRGN() , (RgnHandle) m_macBoundaryClipRgn ) ;
- OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
- CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
- m_macPort = UMAGetWindowPort( windowref ) ;
-
- m_ok = true ;
- SetBackground(window->MacGetBackgroundBrush());
- SetFont( window->GetFont() ) ;
-}
-
-wxPaintDC::~wxPaintDC()
-{
-}
-
-void wxPaintDC::DoGetSize(int *width, int *height) const
-{
- wxCHECK_RET( m_window, _T("GetSize() doesn't work without window") );
-
- m_window->GetClientSize( width, height );
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dcmemory.cpp
-// Purpose: wxMemoryDC class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 01/02/97
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/dcmemory.h"
-
-#include "wx/mac/private.h"
-
-//-----------------------------------------------------------------------------
-// wxMemoryDC
-//-----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
-
-wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
- : m_selected()
-{
- m_ok = true;
- SetBackground(*wxWHITE_BRUSH);
- SetBrush(*wxWHITE_BRUSH);
- SetPen(*wxBLACK_PEN);
- m_ok = false;
-
- if ( bitmap.IsOk() )
- SelectObject(bitmap);
-};
-
-wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
- : m_selected()
-{
- m_ok = true;
- SetBackground(*wxWHITE_BRUSH);
- SetBrush(*wxWHITE_BRUSH);
- SetPen(*wxBLACK_PEN);
- m_ok = false;
-};
-
-wxMemoryDC::~wxMemoryDC()
-{
- if ( m_selected.Ok() )
- {
- UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
- }
-};
-
-void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
-{
- if ( m_selected.Ok() )
- {
- UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) );
- }
- m_selected = bitmap;
- if (m_selected.Ok())
- {
- if ( m_selected.GetHBITMAP() )
- {
- m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
- LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
- wxMask * mask = bitmap.GetMask() ;
- if ( mask )
- {
- m_macMask = mask->GetMaskBitmap() ;
- }
- SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ;
- CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ;
- m_ok = true ;
- }
- else
- {
- m_ok = false;
- }
- }
- else
- {
- m_ok = false;
- }
-}
-
-void wxMemoryDC::DoGetSize( int *width, int *height ) const
-{
- if (m_selected.Ok())
- {
- if (width) (*width) = m_selected.GetWidth();
- if (height) (*height) = m_selected.GetHeight();
- }
- else
- {
- if (width) (*width) = 0;
- if (height) (*height) = 0;
- }
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dcprint.cpp
-// Purpose: wxPrinterDC class
-// Author: Julian Smart
-// Modified by:
-// Created: 01/02/97
-// RCS-ID: $Id$
-// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/dcprint.h"
-
-#ifndef WX_PRECOMP
- #include "wx/msgdlg.h"
- #include "wx/math.h"
-#endif
-
-#include "wx/mac/uma.h"
-#include "wx/mac/private/print.h"
-
-IMPLEMENT_CLASS(wxPrinterDC, wxDC)
-
-class wxNativePrinterDC
-{
-public :
- wxNativePrinterDC() {}
- virtual ~wxNativePrinterDC() {}
- virtual bool StartDoc( wxPrinterDC* dc , const wxString& message ) = 0;
- virtual void EndDoc( wxPrinterDC* dc ) = 0;
- virtual void StartPage( wxPrinterDC* dc ) = 0;
- virtual void EndPage( wxPrinterDC* dc ) = 0;
- virtual wxCoord GetMaxX() const = 0 ;
- virtual wxCoord GetMaxY() const = 0 ;
- // returns 0 in case of no Error, otherwise platform specific error codes
- virtual wxUint32 GetStatus() const = 0 ;
- bool Ok() { return GetStatus() == 0 ; }
-
- static wxNativePrinterDC* Create(wxPrintData* data) ;
-} ;
-
-#if TARGET_CARBON
-
-class wxMacCarbonPrinterDC : public wxNativePrinterDC
-{
-public :
- wxMacCarbonPrinterDC( wxPrintData* data ) ;
- virtual ~wxMacCarbonPrinterDC() ;
- virtual bool StartDoc( wxPrinterDC* dc , const wxString& message ) ;
- virtual void EndDoc( wxPrinterDC* dc ) ;
- virtual void StartPage( wxPrinterDC* dc ) ;
- virtual void EndPage( wxPrinterDC* dc ) ;
- virtual wxCoord GetMaxX() const { return m_maxX ; }
- virtual wxCoord GetMaxY() const { return m_maxY ; }
- virtual wxUint32 GetStatus() const { return m_err ; }
-private :
- GrafPtr m_macPrintFormerPort ;
- wxCoord m_maxX ;
- wxCoord m_maxY ;
- OSStatus m_err ;
-} ;
-
-wxMacCarbonPrinterDC::wxMacCarbonPrinterDC( wxPrintData* data )
-{
- ::GetPort( & m_macPrintFormerPort ) ;
-
- m_err = noErr ;
- wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) data->m_nativePrintData ;
-
- PMRect rPage;
- m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
- if ( m_err != noErr )
- return;
-
- m_maxX = wxCoord(rPage.right - rPage.left) ;
- m_maxY = wxCoord(rPage.bottom - rPage.top);
-}
-
-wxMacCarbonPrinterDC::~wxMacCarbonPrinterDC()
-{
- // nothing to release from print data, as wxPrinterDC has all data in its wxPrintData member
- ::SetPort( m_macPrintFormerPort ) ;
-}
-
-wxNativePrinterDC* wxNativePrinterDC::Create(wxPrintData* data)
-{
- return new wxMacCarbonPrinterDC(data) ;
-}
-
-bool wxMacCarbonPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED(message) )
-{
- if ( m_err )
- return false ;
-
- wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
-
- m_err = PMSessionBeginDocument(native->m_macPrintSession,
- native->m_macPrintSettings,
- native->m_macPageFormat);
- if ( m_err != noErr )
- return false;
-
- PMRect rPage;
- m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
- if ( m_err != noErr )
- return false;
-
- m_maxX = (wxCoord)(rPage.right - rPage.left);
- m_maxY = (wxCoord)(rPage.bottom - rPage.top);
- return true ;
-}
-
-void wxMacCarbonPrinterDC::EndDoc( wxPrinterDC* dc )
-{
- if ( m_err )
- return ;
-
- wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
-
- m_err = PMSessionEndDocument(native->m_macPrintSession);
-}
-
-void wxMacCarbonPrinterDC::StartPage( wxPrinterDC* dc )
-{
- if ( m_err )
- return ;
-
- wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
-
- m_err = PMSessionBeginPage(native->m_macPrintSession,
- native->m_macPageFormat,
- nil);
-
- if ( m_err == noErr )
- {
- m_err = PMSessionGetGraphicsContext(native->m_macPrintSession,
- nil,
- (void**) &dc->m_macPort );
- }
-
- if ( m_err != noErr )
- {
- PMSessionEndPage(native->m_macPrintSession);
- PMSessionEndDocument(native->m_macPrintSession);
- }
- else
- {
- PMRect rPage;
-
- m_err = PMGetAdjustedPageRect(native->m_macPageFormat, &rPage);
- if ( !m_err )
- {
- dc->m_macLocalOrigin.x = (int) rPage.left;
- dc->m_macLocalOrigin.y = (int) rPage.top;
- }
- // since this is a non-critical error, we set the flag back
- m_err = noErr ;
- }
-}
-
-void wxMacCarbonPrinterDC::EndPage( wxPrinterDC* dc )
-{
- if ( m_err )
- return ;
-
- wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) dc->GetPrintData().m_nativePrintData ;
-
- m_err = PMSessionEndPage(native->m_macPrintSession);
- if ( m_err != noErr )
- {
- PMSessionEndDocument(native->m_macPrintSession);
- }
-}
-
-#else
-
-class wxMacClassicPrinterDC : public wxNativePrinterDC
-{
-public :
- wxMacClassicPrinterDC( wxPrintData* data ) ;
- virtual ~wxMacClassicPrinterDC() ;
- virtual bool StartDoc( wxPrinterDC* dc , const wxString& message ) ;
- virtual void EndDoc( wxPrinterDC* dc ) ;
- virtual void StartPage( wxPrinterDC* dc ) ;
- virtual void EndPage( wxPrinterDC* dc ) ;
- virtual wxCoord GetMaxX() const { return m_maxX ; }
- virtual wxCoord GetMaxY() const { return m_maxY ; }
- virtual wxUint32 GetStatus() const { return m_err ; }
-private :
- GrafPtr m_macPrintFormerPort ;
- TPPrPort m_macPrintingPort ;
- OSErr m_err ;
- long m_maxX ;
- long m_maxY ;
-} ;
-
-wxNativePrinterDC* wxNativePrinterDC::Create(wxPrintData* data)
-{
- return new wxMacClassicPrinterDC(data) ;
-}
-
-wxMacClassicPrinterDC::wxMacClassicPrinterDC(wxPrintData* data)
-{
- ::GetPort( &m_macPrintFormerPort ) ;
- m_err = noErr ;
- ::UMAPrOpen() ;
- m_err = PrError() ;
- if ( m_err != noErr )
- return;
-
- wxMacClassicPrintData *native = (wxMacClassicPrintData*) data->m_nativePrintData ;
-
- if ( ::PrValidate( native->m_macPrintSettings ) )
- {
- // the driver has changed in the mean time, should we pop up a page setup dialog ?
- if ( !::PrStlDialog( native->m_macPrintSettings ) )
- {
- m_err = -1 ;
- return;
- }
- }
- m_err = PrError() ;
-
- if ( m_err == noErr )
- {
- m_maxX = (**native->m_macPrintSettings).prInfo.rPage.right - (**native->m_macPrintSettings).prInfo.rPage.left ;
- m_maxY = (**native->m_macPrintSettings).prInfo.rPage.bottom - (**native->m_macPrintSettings).prInfo.rPage.top ;
- }
-}
-
-wxMacClassicPrinterDC::~wxMacClassicPrinterDC()
-{
- ::UMAPrClose() ;
- ::SetPort( LMGetWMgrPort() ) ;
-}
-
-bool wxMacClassicPrinterDC::StartDoc( wxPrinterDC* dc , const wxString& WXUNUSED(message) )
-{
- if ( m_err )
- return false ;
-
- wxMacClassicPrintData *native = (wxMacClassicPrintData*) dc->GetPrintData().m_nativePrintData ;
- m_macPrintingPort = ::PrOpenDoc( native->m_macPrintSettings , NULL , NULL ) ;
- m_err = PrError() ;
- if ( m_err )
- return false ;
-
- // sets current port
- dc->m_macPort = (GrafPtr ) m_macPrintingPort ;
- m_maxX = (**native->m_macPrintSettings).prInfo.rPage.right - (**native->m_macPrintSettings).prInfo.rPage.left ;
- m_maxY = (**native->m_macPrintSettings).prInfo.rPage.bottom - (**native->m_macPrintSettings).prInfo.rPage.top ;
- return true ;
-}
-
-void wxMacClassicPrinterDC::EndDoc( wxPrinterDC* dc )
-{
- if ( m_err )
- return ;
-
- PrCloseDoc( m_macPrintingPort ) ;
- m_err = PrError() ;
-}
-
-void wxMacClassicPrinterDC::StartPage( wxPrinterDC* dc )
-{
- if ( m_err )
- return ;
-
- wxMacClassicPrintData *native = (wxMacClassicPrintData*) dc->GetPrintData().m_nativePrintData ;
-
- PrOpenPage( m_macPrintingPort , NULL ) ;
- dc->m_macLocalOrigin.x = (**native->m_macPrintSettings).rPaper.left ;
- dc->m_macLocalOrigin.y = (**native->m_macPrintSettings).rPaper.top ;
- // m_macPrintingPort is now the current port
- Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
- ::ClipRect( &clip ) ;
- m_err = PrError() ;
- if ( m_err != noErr )
- ::PrCloseDoc( m_macPrintingPort ) ;
-}
-
-void wxMacClassicPrinterDC::EndPage( wxPrinterDC* dc )
-{
- if ( m_err )
- return ;
-
- PrClosePage( m_macPrintingPort ) ;
- m_err = PrError() ;
- if ( m_err != noErr )
- ::PrCloseDoc( m_macPrintingPort ) ;
-}
-
-#endif
-
-wxPrinterDC::wxPrinterDC(const wxPrintData& printdata)
-{
- m_ok = false ;
- m_printData = printdata ;
- m_printData.ConvertToNative() ;
- m_nativePrinterDC = wxNativePrinterDC::Create( &m_printData ) ;
- if ( m_nativePrinterDC )
- {
- m_ok = m_nativePrinterDC->Ok() ;
-
- if ( !m_ok )
- {
- wxString message ;
- message.Printf( wxT("Print Error %u"), m_nativePrinterDC->GetStatus() ) ;
- wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
- dialog.ShowModal();
- }
- }
-}
-
-wxPrinterDC::~wxPrinterDC(void)
-{
- delete m_nativePrinterDC ;
-}
-
-bool wxPrinterDC::StartDoc( const wxString& message )
-{
- wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;
-
- if ( !m_ok )
- return false ;
-
- if ( m_nativePrinterDC->StartDoc(this, message ) )
- {
- // in case we have to do additional things when successful
- }
- m_ok = m_nativePrinterDC->Ok() ;
- if ( !m_ok )
- {
- wxString message ;
- message.Printf( wxT("Print Error %u"), m_nativePrinterDC->GetStatus() ) ;
- wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
- dialog.ShowModal();
- }
-
- return m_ok ;
-}
-
-void wxPrinterDC::EndDoc(void)
-{
- if ( !m_ok )
- return ;
-
- m_nativePrinterDC->EndDoc( this ) ;
- m_ok = m_nativePrinterDC->Ok() ;
-
- if ( !m_ok )
- {
- wxString message ;
- message.Printf( wxT("Print Error %u"), m_nativePrinterDC->GetStatus() ) ;
- wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
- dialog.ShowModal();
- }
-}
-
-void wxPrinterDC::StartPage(void)
-{
- if ( !m_ok )
- return ;
-
- m_logicalFunction = wxCOPY;
- // m_textAlignment = wxALIGN_TOP_LEFT;
- m_backgroundMode = wxTRANSPARENT;
-
- m_textForegroundColour = *wxBLACK;
- m_textBackgroundColour = *wxWHITE;
- m_pen = *wxBLACK_PEN;
- m_font = *wxNORMAL_FONT;
- m_brush = *wxTRANSPARENT_BRUSH;
- m_backgroundBrush = *wxWHITE_BRUSH;
-
- m_macFontInstalled = false ;
- m_macBrushInstalled = false ;
- m_macPenInstalled = false ;
-
- m_nativePrinterDC->StartPage(this) ;
- m_ok = m_nativePrinterDC->Ok() ;
-
-}
-
-void wxPrinterDC::EndPage(void)
-{
- if ( !m_ok )
- return ;
-
- m_nativePrinterDC->EndPage(this) ;
- m_ok = m_nativePrinterDC->Ok() ;
-}
-
-wxRect wxPrinterDC::GetPaperRect()
-{
- wxMacCarbonPrintData *native = (wxMacCarbonPrintData*) m_printData.GetNativeData() ;
- OSStatus err = noErr ;
- PMRect rPaper;
- err = PMGetAdjustedPaperRect(native->m_macPageFormat, &rPaper);
- if ( err != noErr )
- return pageRect;
- return wxRect(wxCoord(rPaper.left), wxCoord(rPaper.top),
- wxCoord(rPaper.right - rPaper.left), wxCoord(rPaper.bottom - rPaper.top));
-}
-
-void wxPrinterDC::DoGetSize(int *width, int *height) const
-{
- wxCHECK_RET( m_ok , _T("GetSize() doesn't work without a valid wxPrinterDC") );
-
- if ( width )
- * width = m_nativePrinterDC->GetMaxX() ;
- if ( height )
- * height = m_nativePrinterDC->GetMaxY() ;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dcscreen.cpp
-// Purpose: wxScreenDC class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/dcscreen.h"
-
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
-
-// Create a DC representing the whole screen
-wxScreenDC::wxScreenDC()
-{
-#if TARGET_CARBON
- m_macPort = GetQDGlobalsThePort() ;
- GrafPtr port ;
- GetPort( &port ) ;
- SetPort( (GrafPtr) m_macPort ) ;
- Point pt = { 0,0 } ;
- LocalToGlobal( &pt ) ;
- SetPort( port ) ;
- m_macLocalOrigin.x = -pt.h ;
- m_macLocalOrigin.y = -pt.v ;
-#else
- m_macPort = LMGetWMgrPort() ;
- m_macLocalOrigin.x = 0 ;
- m_macLocalOrigin.y = 0 ;
-#endif
- m_ok = true ;
- BitMap screenBits;
- GetQDGlobalsScreenBits( &screenBits );
- m_minX = screenBits.bounds.left ;
-#if TARGET_CARBON
- SInt16 height ;
- GetThemeMenuBarHeight( &height ) ;
- m_minY = screenBits.bounds.top + height ;
-#else
- m_minY = screenBits.bounds.top + LMGetMBarHeight() ;
-#endif
- m_maxX = screenBits.bounds.right ;
- m_maxY = screenBits.bounds.bottom ;
- MacSetRectRgn( (RgnHandle) m_macBoundaryClipRgn , m_minX , m_minY , m_maxX , m_maxY ) ;
- OffsetRgn( (RgnHandle) m_macBoundaryClipRgn , m_macLocalOrigin.x , m_macLocalOrigin.y ) ;
- CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
-}
-
-wxScreenDC::~wxScreenDC()
-{
- // TODO
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dialog.cpp
-// Purpose: wxDialog class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/dialog.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/utils.h"
- #include "wx/frame.h"
- #include "wx/settings.h"
-#endif // WX_PRECOMP
-
-#include "wx/mac/uma.h"
-
-// Lists to keep track of windows, so we can disable/enable them
-// for modal dialogs
-wxList wxModalDialogs;
-
-IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
-
-BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
- EVT_BUTTON(wxID_OK, wxDialog::OnOK)
- EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
- EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
-
- EVT_CHAR_HOOK(wxDialog::OnCharHook)
-
- EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
-
- EVT_CLOSE(wxDialog::OnCloseWindow)
-END_EVENT_TABLE()
-
-void wxDialog::Init()
-{
- m_isModalStyle = false;
- SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
-}
-
-bool wxDialog::Create(wxWindow *parent, wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
-
-
- if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
- return false;
-
- MacCreateRealWindow( title , pos , size , MacRemoveBordersFromStyle(style) & ~(wxYES|wxOK|wxNO|wxCANCEL) , name ) ;
-
- m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
- SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
-
- return true;
-}
-
-void wxDialog::SetModal(bool flag)
-{
- if ( flag )
- {
- m_isModalStyle = true;
-
- wxModelessWindows.DeleteObject(this);
-#if TARGET_CARBON
- SetWindowModality( (WindowRef) MacGetWindowRef() , kWindowModalityAppModal , NULL ) ;
-#endif
- }
- else
- {
- m_isModalStyle = false;
-
- wxModelessWindows.Append(this);
- }
-}
-
-wxDialog::~wxDialog()
-{
- m_isBeingDeleted = true;
- Show(false);
-}
-
-// By default, pressing escape cancels the dialog , on mac command-stop does the same thing
-void wxDialog::OnCharHook(wxKeyEvent& event)
-{
- if (( event.m_keyCode == WXK_ESCAPE ||
- ( event.m_keyCode == '.' && event.MetaDown() ) )
- && FindWindow(wxID_CANCEL) )
- {
- // Behaviour changed in 2.0: we'll send a Cancel message
- // to the dialog instead of Close.
- wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
- cancelEvent.SetEventObject( this );
- GetEventHandler()->ProcessEvent(cancelEvent);
-
- return;
- }
- // We didn't process this event.
- event.Skip();
-}
-
-bool wxDialog::IsModal() const
-{
- return m_isModalStyle;
-}
-
-
-bool wxDialog::IsModalShowing() const
-{
- return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast
-}
-
-bool wxDialog::Show(bool show)
-{
- if ( !wxDialogBase::Show(show) )
- {
- // nothing to do
- return false;
- }
-
- if ( show )
- {
- // usually will result in TransferDataToWindow() being called
- InitDialog();
- }
-
- if ( IsModal() )
- {
- if ( show )
- {
- DoShowModal();
- }
- else // end of modal dialog
- {
- // this will cause IsModalShowing() return false and our local
- // message loop will terminate
- wxModalDialogs.DeleteObject(this);
- }
- }
-
- return true;
-}
-
-#if !TARGET_CARBON
-extern bool s_macIsInModalLoop ;
-#endif
-
-void wxDialog::DoShowModal()
-{
- wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );
-
- wxModalDialogs.Append(this);
-
-#if TARGET_CARBON
- BeginAppModalStateForWindow( (WindowRef) MacGetWindowRef()) ;
-#else
- // TODO : test whether parent gets disabled
- bool formerModal = s_macIsInModalLoop ;
- s_macIsInModalLoop = true ;
-#endif
- while ( IsModalShowing() )
- {
- wxTheApp->MacDoOneEvent() ;
- // calls process idle itself
- }
-
-#if TARGET_CARBON
- EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ;
-#else
- // TODO probably reenable the parent window if any
- s_macIsInModalLoop = formerModal ;
-#endif
-}
-
-
-// Replacement for Show(true) for modal dialogs - returns return code
-int wxDialog::ShowModal()
-{
- if ( !IsModal() )
- {
- SetModal(true);
- }
-
- Show(true);
- return GetReturnCode();
-}
-
-// NB: this function (surprizingly) may be called for both modal and modeless
-// dialogs and should work for both of them
-void wxDialog::EndModal(int retCode)
-{
- SetReturnCode(retCode);
- Show(false);
-}
-
-// Standard buttons
-void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
-{
- if ( Validate() && TransferDataFromWindow() )
- {
- EndModal(wxID_OK);
- }
-}
-
-void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
-{
- if (Validate())
- TransferDataFromWindow();
- // TODO probably need to disable the Apply button until things change again
-}
-
-void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
-{
- EndModal(wxID_CANCEL);
-}
-
-void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
-{
- // We'll send a Cancel message by default,
- // which may close the dialog.
- // Check for looping if the Cancel event handler calls Close().
-
- // Note that if a cancel button and handler aren't present in the dialog,
- // nothing will happen when you close the dialog via the window manager, or
- // via Close().
- // We wouldn't want to destroy the dialog by default, since the dialog may have been
- // created on the stack.
- // However, this does mean that calling dialog->Close() won't delete the dialog
- // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
- // sure to destroy the dialog.
- // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
-
- static wxList closing;
-
- if ( closing.Member(this) )
- return;
-
- closing.Append(this);
-
- wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
- cancelEvent.SetEventObject( this );
- GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
-
- closing.DeleteObject(this);
-}
-
-void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
-{
- SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
- Refresh();
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dirdlg.cpp
-// Purpose: wxDirDialog
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/dirdlg.h"
-
-#ifndef WX_PRECOMP
- #include "wx/utils.h"
- #include "wx/dialog.h"
- #include "wx/cmndata.h"
-#endif // WX_PRECOMP
-
-#include "wx/mac/private.h"
-
-#ifdef __DARWIN__
- #include <Carbon/Carbon.h>
-#else
- #include <Navigation.h>
-#endif
-
-IMPLEMENT_CLASS(wxDirDialog, wxDialog)
-
-wxDirDialog::wxDirDialog(wxWindow *parent,
- const wxString& message,
- const wxString& defaultPath,
- long style,
- const wxPoint& WXUNUSED(pos),
- const wxSize& WXUNUSED(size),
- const wxString& WXUNUSED(name))
-{
- wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
- m_message = message;
- m_windowStyle = style;
- m_parent = parent;
- m_path = defaultPath;
-}
-
-int wxDirDialog::ShowModal()
-{
- NavDialogOptions mNavOptions;
- NavObjectFilterUPP mNavFilterUPP = NULL;
- NavPreviewUPP mNavPreviewUPP = NULL ;
- NavReplyRecord mNavReply;
- AEDesc* mDefaultLocation = NULL ;
- bool mSelectDefault = false ;
-
- ::NavGetDefaultDialogOptions(&mNavOptions);
-
- mNavFilterUPP = nil;
- mNavPreviewUPP = nil;
- mSelectDefault = false;
- mNavReply.validRecord = false;
- mNavReply.replacing = false;
- mNavReply.isStationery = false;
- mNavReply.translationNeeded = false;
- mNavReply.selection.descriptorType = typeNull;
- mNavReply.selection.dataHandle = nil;
- mNavReply.keyScript = smSystemScript;
- mNavReply.fileTranslation = nil;
-
- // Set default location, the location
- // that's displayed when the dialog
- // first appears
-
- if ( mDefaultLocation ) {
-
- if (mSelectDefault) {
- mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
- } else {
- mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
- }
- }
-
- OSErr err = ::NavChooseFolder(
- mDefaultLocation,
- &mNavReply,
- &mNavOptions,
- NULL,
- mNavFilterUPP,
- 0L); // User Data
-
- if ( (err != noErr) && (err != userCanceledErr) ) {
- m_path = wxEmptyString ;
- return wxID_CANCEL ;
- }
-
- if (mNavReply.validRecord) { // User chose a folder
-
- FSSpec folderInfo;
- FSSpec outFileSpec ;
- AEDesc specDesc ;
-
- OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSS, &specDesc);
- if ( err != noErr ) {
- m_path = wxEmptyString ;
- return wxID_CANCEL ;
- }
- folderInfo = **(FSSpec**) specDesc.dataHandle;
- if (specDesc.dataHandle != nil) {
- ::AEDisposeDesc(&specDesc);
- }
-
-// mNavReply.GetFileSpec(folderInfo);
-
- // The FSSpec from NavChooseFolder is NOT the file spec
- // for the folder. The parID field is actually the DirID
- // of the folder itself, not the folder's parent, and
- // the name field is empty. We must call PBGetCatInfo
- // to get the parent DirID and folder name
-
- Str255 name;
- CInfoPBRec thePB; // Directory Info Parameter Block
- thePB.dirInfo.ioCompletion = nil;
- thePB.dirInfo.ioVRefNum = folderInfo.vRefNum; // Volume is right
- thePB.dirInfo.ioDrDirID = folderInfo.parID; // Folder's DirID
- thePB.dirInfo.ioNamePtr = name;
- thePB.dirInfo.ioFDirIndex = -1; // Lookup using Volume and DirID
-
- err = ::PBGetCatInfoSync(&thePB);
- if ( err != noErr ) {
- m_path = wxEmptyString;
- return wxID_CANCEL ;
- }
- // Create cannonical FSSpec
- ::FSMakeFSSpec(thePB.dirInfo.ioVRefNum, thePB.dirInfo.ioDrParID,
- name, &outFileSpec);
-
- // outFolderDirID = thePB.dirInfo.ioDrDirID;
- m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
- return wxID_OK ;
- }
- return wxID_CANCEL;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: msw/dir.cpp
-// Purpose: wxDir implementation for Mac
-// Author: Stefan Csomor
-// Modified by:
-// Created: 08.12.99
-// RCS-ID: $Id$
-// Copyright: (c) 1999 Stefan Csomor <csomor@advanced.ch>
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/log.h"
-#endif // PCH
-
-#include "wx/dir.h"
-#include "wx/filefn.h" // for wxDirExists()
-
-#ifndef __DARWIN__
- #include <windows.h>
-#endif
-
-#include "wx/mac/private.h"
-
-#ifdef __DARWIN__
-# include "MoreFilesX.h"
-#else
-# include "MoreFiles.h"
-# include "MoreFilesExtras.h"
-#endif
-
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-#ifndef MAX_PATH
- #define MAX_PATH 260 // from VC++ headers
-#endif
-
-// ----------------------------------------------------------------------------
-// macros
-// ----------------------------------------------------------------------------
-
-#define M_DIR ((wxDirData *)m_data)
-
-// ----------------------------------------------------------------------------
-// private classes
-// ----------------------------------------------------------------------------
-
-// this class stores everything we need to enumerate the files
-class wxDirData
-{
-public:
- wxDirData(const wxString& dirname);
- ~wxDirData();
-
- void SetFileSpec(const wxString& filespec) { m_filespec = filespec; }
- void SetFlags(int flags) { m_flags = flags; }
-
- bool Read(wxString *filename); // reads the next
- void Rewind() ;
-
- const wxString& GetName() const { return m_dirname; }
- bool Ok() const { return m_ok; }
-
-private:
- CInfoPBRec m_CPB ;
- wxInt16 m_index ;
- long m_dirId ;
- Str255 m_name ;
- Boolean m_isDir ;
-
- wxString m_dirname;
- wxString m_filespec;
-
- int m_flags;
- bool m_ok;
-};
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxDirData
-// ----------------------------------------------------------------------------
-
-wxDirData::wxDirData(const wxString& dirname)
- : m_dirname(dirname)
-{
- m_ok = false;
-
- OSErr err;
-
- // throw away the trailing slashes
- size_t n = m_dirname.length();
- wxCHECK_RET( n, _T("empty dir name in wxDir") );
-
- while ( n > 0 && wxIsPathSeparator(m_dirname[--n]) )
- ;
-
- m_dirname.Truncate(n + 1);
-
-#ifdef __DARWIN__
- FSRef theRef;
-
- // get the FSRef associated with the POSIX path
- err = FSPathMakeRef((const UInt8 *) m_dirname.c_str(), &theRef, NULL);
- FSGetVRefNum(&theRef, &(m_CPB.hFileInfo.ioVRefNum));
-
- err = FSGetNodeID( &theRef , &m_dirId , &m_isDir ) ;
-#else
- FSSpec fsspec ;
-
- wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
- m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
-
- err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
-#endif
- //wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ;
- if ( (err == noErr) || (err == nsvErr))
- m_ok = true;
- else
- wxLogError(wxString(wxT("Error accessing directory ")) + m_dirname);
-
- m_CPB.hFileInfo.ioNamePtr = m_name ;
- m_index = 0 ;
-}
-
-wxDirData::~wxDirData()
-{
-}
-
-void wxDirData::Rewind()
-{
- m_index = 0 ;
-}
-
-bool wxDirData::Read(wxString *filename)
-{
- if ( !m_isDir )
- return false ;
-
- wxString result;
-
- short err = noErr ;
-
- while ( err == noErr )
- {
- m_index++ ;
- m_CPB.dirInfo.ioFDirIndex = m_index;
- m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
- err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
- if ( err != noErr )
- break ;
-
- // its hidden but we don't want it
- if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) )
- continue ;
-#ifdef __DARWIN__
- // under X, names that start with '.' are hidden
- if ( ( m_name[1] == '.' ) && !(m_flags & wxDIR_HIDDEN) )
- continue;
-#endif
-#if TARGET_CARBON
- // under X thats the way the mounting points look like
- if ( ( m_CPB.dirInfo.ioDrDirID == 0 ) && ( m_flags & wxDIR_DIRS) )
- break ;
-#endif
- // we have a directory
- if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) )
- break ;
-
- // its a file but we don't want it
- if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) )
- continue ;
-
- wxString file = wxMacMakeStringFromPascal( m_name ) ;
- if ( m_filespec.empty() || m_filespec == wxT("*.*") || m_filespec == wxT("*") )
- {
- }
- else if ( m_filespec.Length() > 1 && m_filespec.Left(1) == wxT("*") )
- {
- if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
- {
- continue ;
- }
- }
- else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == wxT("*") )
- {
- if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
- {
- continue ;
- }
- }
- else if ( file.Upper() != m_filespec.Upper() )
- {
- continue ;
- }
-
- break ;
- }
- if ( err != noErr )
- {
- return false ;
- }
-
- *filename = wxMacMakeStringFromPascal( m_name ) ;
-
- return true;
-}
-
-// ----------------------------------------------------------------------------
-// wxDir helpers
-// ----------------------------------------------------------------------------
-
-/* static */
-bool wxDir::Exists(const wxString& dir)
-{
- return wxDirExists(dir);
-}
-
-// ----------------------------------------------------------------------------
-// wxDir construction/destruction
-// ----------------------------------------------------------------------------
-
-wxDir::wxDir(const wxString& dirname)
-{
- m_data = NULL;
-
- (void)Open(dirname);
-}
-
-bool wxDir::Open(const wxString& dirname)
-{
- delete M_DIR;
- m_data = new wxDirData(dirname);
- if (m_data->Ok())
- return true;
- else
- {
- delete m_data;
- m_data = NULL;
- return false;
- }
-}
-
-bool wxDir::IsOpened() const
-{
- return m_data != NULL;
-}
-
-wxString wxDir::GetName() const
-{
- wxString name;
- if ( m_data )
- {
- name = M_DIR->GetName();
- if ( !name.empty() && (name.Last() == _T('/')) )
- {
- // chop off the last (back)slash
- name.Truncate(name.length() - 1);
- }
- }
-
- return name;
-}
-
-wxDir::~wxDir()
-{
- if (M_DIR != NULL) {
- delete M_DIR;
- m_data = NULL;
- }
-}
-
-// ----------------------------------------------------------------------------
-// wxDir enumerating
-// ----------------------------------------------------------------------------
-
-bool wxDir::GetFirst(wxString *filename,
- const wxString& filespec,
- int flags) const
-{
- wxCHECK_MSG( IsOpened(), false, _T("must wxDir::Open() first") );
-
- M_DIR->Rewind();
-
- M_DIR->SetFileSpec(filespec);
- M_DIR->SetFlags(flags);
-
- return GetNext(filename);
-}
-
-bool wxDir::GetNext(wxString *filename) const
-{
- wxCHECK_MSG( IsOpened(), false, _T("must wxDir::Open() first") );
-
- wxCHECK_MSG( filename, false, _T("bad pointer in wxDir::GetNext()") );
-
- return M_DIR->Read(filename);
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/display.cpp
-// Purpose: Mac implementation of wxDisplay class
-// Author: Brian Victor
-// Modified by: Royce Mitchell III & Ryan Norton, Vadim Zeitlin
-// Created: 06/21/02
-// RCS-ID: $Id$
-// Copyright: (c) wxWidgets team
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_DISPLAY
-
-#include "wx/display.h"
-
-#ifndef WX_PRECOMP
- #include "wx/dynarray.h"
- #include "wx/log.h"
- #include "wx/string.h"
- #include "wx/gdicmn.h"
-#endif
-
-#ifdef __DARWIN__
- #include <Carbon/Carbon.h>
-#else
- #include <Gestalt.h>
- #include <Displays.h>
- #include <Quickdraw.h>
- #include <Video.h> //for VDSwitchInfoRec
- #include <FixMath.h>
-#endif
-
-#include "wx/display_impl.h"
-
-// ----------------------------------------------------------------------------
-// display implementation classes
-// ----------------------------------------------------------------------------
-
-class wxDisplayImplMac : public wxDisplayImpl
-{
-public:
- wxDisplayImplMac(size_t n, GDHandle hndl)
- : wxDisplayImpl(n),
- m_hndl(hndl)
- {
- }
-
- virtual wxRect GetGeometry() const;
- virtual wxString GetName() const { return wxString(); }
-
- virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const;
- virtual wxVideoMode GetCurrentMode() const;
- virtual bool ChangeMode(const wxVideoMode& mode);
-
-private:
- GDHandle m_hndl;
-
- DECLARE_NO_COPY_CLASS(wxDisplayImplMac)
-};
-
-class wxDisplayFactoryMac : public wxDisplayFactory
-{
-public:
- wxDisplayFactoryMac();
-
- virtual wxDisplayImpl *CreateDisplay(size_t n);
- virtual size_t GetCount();
- virtual int GetFromPoint(const wxPoint& pt);
-
-protected:
- DECLARE_NO_COPY_CLASS(wxDisplayFactoryMac)
-};
-
-// ============================================================================
-// wxDisplayFactoryMac implementation
-// ============================================================================
-
-size_t wxDisplayFactoryMac::GetCount()
-{
- size_t num = 0;
- GDHandle hndl = DMGetFirstScreenDevice(true);
- while(hndl)
- {
- num++;
- hndl = DMGetNextScreenDevice(hndl, true);
- }
- return num;
-}
-
-int wxDisplayFactoryMac::GetFromPoint(const wxPoint &p)
-{
- size_t num = 0;
- GDHandle hndl = DMGetFirstScreenDevice(true);
- while(hndl)
- {
- Rect screenrect = (*hndl)->gdRect;
- if (p.x >= screenrect.left &&
- p.x <= screenrect.right &&
- p.y >= screenrect.top &&
- p.y <= screenrect.bottom)
- {
- return num;
- }
- num++;
- hndl = DMGetNextScreenDevice(hndl, true);
- }
-
- return wxNOT_FOUND;
-}
-
-wxDisplayImpl *wxDisplayFactoryMac::CreateDisplay(size_t n)
-{
- size_t nOrig = n;
-
- GDHandle hndl = DMGetFirstScreenDevice(true);
- while(hndl)
- {
- if (n == 0)
- {
- return new wxDisplayImplMac(nOrig, hndl);
- }
- n--;
- hndl = DMGetNextScreenDevice(hndl, true);
- }
-
- return NULL;
-}
-
-// ============================================================================
-// wxDisplayImplMac implementation
-// ============================================================================
-
-wxRect wxDisplayImplMac::GetGeometry() const
-{
- Rect screenrect = (*m_hndl)->gdRect;
- return wxRect(screenrect.left, screenrect.top,
- screenrect.right - screenrect.left,
- screenrect.bottom - screenrect.top);
-}
-
-struct DMModeIteratorRec
-{
- wxArrayVideoModes* pModes;
- const wxVideoMode* pMatchMode;
-};
-
-pascal void DMModeListIteratorProc ( void* pData,
- DMListIndexType nIndex,
- DMDisplayModeListEntryPtr pInfo)
-{
- DMModeIteratorRec* pInfoData = (DMModeIteratorRec*) pData;
-
- //Note that in testing the refresh rate is always 0 on my ibook - RN
- int refresh = (int) Fix2Long(pInfo->displayModeResolutionInfo->csRefreshRate);
-
- for(unsigned long i = 0; i < pInfo->displayModeDepthBlockInfo->depthBlockCount; ++i)
- {
-#define pDBI pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthVPBlock
-
- if (wxVideoMode((int) pInfo->displayModeResolutionInfo->csHorizontalPixels,
- (int) pInfo->displayModeResolutionInfo->csVerticalLines,
- (int) pDBI->vpPixelSize,
- refresh).Matches(*pInfoData->pMatchMode) )
- {
- pInfoData->pModes->Add(wxVideoMode((int) pInfo->displayModeResolutionInfo->csHorizontalPixels,
- (int) pInfo->displayModeResolutionInfo->csVerticalLines,
- (int) pDBI->vpPixelSize,
- refresh));
- }
-#undef pDBI
- }
-}
-
-struct DMModeInfoRec
-{
- const wxVideoMode* pMode;
- VDSwitchInfoRec sMode;
- bool bMatched;
-};
-
-pascal void DMModeInfoProc ( void* pData,
- DMListIndexType nIndex,
- DMDisplayModeListEntryPtr pInfo)
-{
- DMModeInfoRec* pInfoData = (DMModeInfoRec*) pData;
- Fixed refresh = Long2Fix(pInfoData->pMode->refresh);
-
- for(unsigned long i = 0; i < pInfo->displayModeDepthBlockInfo->depthBlockCount; ++i)
- {
-#define pDBI pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthVPBlock
- if (pInfoData->pMode->w == (int&) pInfo->displayModeResolutionInfo->csHorizontalPixels &&
- pInfoData->pMode->h == (int&) pInfo->displayModeResolutionInfo->csVerticalLines &&
- pInfoData->pMode->bpp == (int) pDBI->vpPixelSize &&
- refresh == pInfo->displayModeResolutionInfo->csRefreshRate)
- {
- memcpy(&pInfoData->sMode, pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthSwitchInfo,
- sizeof(VDSwitchInfoRec));
- pInfoData->sMode.csMode = pDBI->vpPixelSize;
- pInfoData->bMatched = true;
- break;
- }
-#undef pDBI
- }
-}
-
-struct DMModeTransRec
-{
- wxVideoMode Mode;
- const VDSwitchInfoRec* psMode;
- bool bMatched;
-};
-
-pascal void DMModeTransProc ( void* pData,
- DMListIndexType nIndex,
- DMDisplayModeListEntryPtr pInfo)
-{
- DMModeTransRec* pInfoData = (DMModeTransRec*) pData;
-
- for(unsigned long i = 0; i < pInfo->displayModeDepthBlockInfo->depthBlockCount; ++i)
- {
-#define pDBI pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthVPBlock
- if (pInfoData->psMode->csData == pInfo->displayModeDepthBlockInfo->depthVPBlock[i].depthSwitchInfo->csData)
- {
- pInfoData->Mode = wxVideoMode((int) pInfo->displayModeResolutionInfo->csHorizontalPixels,
- (int) pInfo->displayModeResolutionInfo->csVerticalLines,
- (int) pDBI->vpPixelSize,
- (int) Fix2Long(pInfo->displayModeResolutionInfo->csRefreshRate) );
- pInfoData->bMatched = true;
- break;
- }
-#undef pDBI
- }
-}
-
-wxArrayVideoModes wxDisplayImplMac::GetModes(const wxVideoMode& mode) const
-{
- wxArrayVideoModes Modes;
-
- unsigned long dwDMVer;
- Gestalt(gestaltDisplayMgrVers, (long*) &dwDMVer);
-
- //Check DM version (for backward compatibility only - 7.5.3+ use 2.0)
- if (dwDMVer >= 0x020000) //version 2?
- {
-
- DMListIndexType nNumModes;
- DMListType pModes;
- DMDisplayModeListIteratorUPP uppMLI;
- DisplayIDType nDisplayID;
-
- wxASSERT(DMGetDisplayIDByGDevice(m_hndl, &nDisplayID, false) == noErr);
- //Create a new list...
- wxASSERT_MSG(DMNewDisplayModeList(nDisplayID, NULL, NULL, &nNumModes, &pModes) == noErr, wxT("Could not create a new display mode list") );
-
- uppMLI = NewDMDisplayModeListIteratorUPP(DMModeListIteratorProc);
- wxASSERT(uppMLI);
-
- DMModeIteratorRec sModeInfo;
- sModeInfo.pModes = &Modes;
- sModeInfo.pMatchMode = &mode;
- for (DMListIndexType i = 0; i < nNumModes; ++i)
- {
- wxASSERT(DMGetIndexedDisplayModeFromList(pModes, i, NULL,
- uppMLI, &sModeInfo) == noErr);
- }
- DisposeDMDisplayModeListIteratorUPP(uppMLI);
- wxASSERT(DMDisposeList(pModes) == noErr);
- }
- else //DM 1.0, 1.2, 1.x
- {
- wxLogSysError(wxString::Format(wxT("Display Manager Version %u Not Supported! Present? %s"),
- (unsigned int) dwDMVer / 0x10000,
- (dwDMVer & (1 << gestaltDisplayMgrPresent) ? wxT("Yes") : wxT("No")) )
- );
- }
-
- return Modes;
-}
-
-wxVideoMode wxDisplayImplMac::GetCurrentMode() const
-{
- unsigned long dwDMVer;
- wxVideoMode RetMode;
-
- Gestalt(gestaltDisplayMgrVers, (long*) &dwDMVer);
- //Check DM version (for backward compatibility only - 7.5.3+ use 2.0)
- if (dwDMVer >= 0x020000) //version 2?
- {
- VDSwitchInfoRec sMode; //Note - csMode member also contains the bit depth
- if (DMGetDisplayMode(m_hndl, &sMode) == noErr)
- {
- DMListIndexType nNumModes;
- DMListType pModes;
- DMDisplayModeListIteratorUPP uppMLI;
- DisplayIDType nDisplayID;
-
- wxASSERT(DMGetDisplayIDByGDevice(m_hndl, &nDisplayID, false) == noErr);
- //Create a new list...
- wxASSERT_MSG(DMNewDisplayModeList(nDisplayID, NULL, NULL, &nNumModes, &pModes) == noErr,
- wxT("Could not create a new display mode list") );
-
- uppMLI = NewDMDisplayModeListIteratorUPP(DMModeTransProc);
- wxASSERT(uppMLI);
-
- DMModeTransRec sModeInfo;
- sModeInfo.bMatched = false;
- sModeInfo.psMode = &sMode;
- for (DMListIndexType i = 0; i < nNumModes; ++i)
- {
- wxASSERT(DMGetIndexedDisplayModeFromList(pModes, i, NULL,
- uppMLI, &sModeInfo) == noErr);
-
- if ( sModeInfo.bMatched == true )
- {
- RetMode = sModeInfo.Mode;
- break;
- }
- }
-
- DisposeDMDisplayModeListIteratorUPP(uppMLI);
- wxASSERT(DMDisposeList(pModes) == noErr);
- }
- else //Can't get current mode?
- {
- wxLogSysError(wxString::Format(wxT("Couldn't obtain current display mode!!!\ndwDMVer:%u"),
- (unsigned int) dwDMVer));
- }
- }
- else //DM ver 1
- {
- wxLogSysError(wxString::Format(wxT("Display Manager Version %u Not Supported! Present? %s"),
- (unsigned int) dwDMVer / 0x10000,
- (dwDMVer & (1 << gestaltDisplayMgrPresent) ? wxT("Yes") : wxT("No")) )
- );
- }
-
- return RetMode;
-}
-
-bool wxDisplayImplMac::ChangeMode(const wxVideoMode& mode)
-{
- unsigned long dwDMVer;
- Gestalt(gestaltDisplayMgrVers, (long*)&dwDMVer);
- if (GetCount() == 1 || dwDMVer >= 0x020000)
- {
- if (mode == wxDefaultVideoMode)
- {
-//#ifndef __DARWIN__
-// Handle hDisplayState;
-// if (DMBeginConfigureDisplays(&hDisplayState) != noErr)
-// {
-// wxLogSysError(wxT("Could not lock display for display mode changing!"));
-// return false;
-// }
-// wxASSERT( DMUseScreenPrefs(true, hDisplayState) == noErr);
-// DMEndConfigureDisplays(hDisplayState);
-// return true;
-//#else
- //hmmmmm....
- return true;
-//#endif
- }
-
- //0 & NULL for params 2 & 3 of DMSetVideoMode signal it to use defaults (current mode)
- //DM 2.0+ doesn't use params 2 & 3 of DMSetDisplayMode
- //so we have to use this icky structure
- VDSwitchInfoRec sMode;
- memset(&sMode, 0, sizeof(VDSwitchInfoRec) );
-
- DMListIndexType nNumModes;
- DMListType pModes;
- DMDisplayModeListIteratorUPP uppMLI;
- DisplayIDType nDisplayID;
-
- wxASSERT(DMGetDisplayIDByGDevice(m_hndl, &nDisplayID, false) == noErr);
- //Create a new list...
- wxASSERT_MSG(DMNewDisplayModeList(nDisplayID, NULL, NULL, &nNumModes, &pModes) == noErr,
- wxT("Could not create a new display mode list") );
-
- uppMLI = NewDMDisplayModeListIteratorUPP(DMModeInfoProc);
- wxASSERT(uppMLI);
-
- DMModeInfoRec sModeInfo;
- sModeInfo.bMatched = false;
- sModeInfo.pMode = &mode;
- unsigned int i;
- for(i = 0; i < nNumModes; ++i)
- {
- wxASSERT(DMGetIndexedDisplayModeFromList(pModes, i, NULL,
- uppMLI, &sModeInfo) == noErr);
- if (sModeInfo.bMatched == true)
- {
- sMode = sModeInfo.sMode;
- break;
- }
- }
- if(i == nNumModes)
- return false;
-
- DisposeDMDisplayModeListIteratorUPP(uppMLI);
- wxASSERT(DMDisposeList(pModes) == noErr);
-
- // For the really paranoid -
- // unsigned long flags;
- // Boolean bok;
- // wxASSERT(noErr == DMCheckDisplayMode(m_hndl, sMode.csData,
- // sMode.csMode, &flags, NULL, &bok));
- // wxASSERT(bok);
-
- Handle hDisplayState;
- if (DMBeginConfigureDisplays(&hDisplayState) != noErr)
- {
- wxLogSysError(wxT("Could not lock display for display mode changing!"));
- return false;
- }
-
- unsigned long dwBPP = (unsigned long) mode.bpp;
- if (DMSetDisplayMode(m_hndl, sMode.csData,
- (unsigned long*) &(dwBPP), NULL
- //(unsigned long) &sMode
- , hDisplayState
- ) != noErr)
- {
- DMEndConfigureDisplays(hDisplayState);
- wxLogError(wxT("Could not set the display mode"));
- return false;
- }
- DMEndConfigureDisplays(hDisplayState);
- }
- else //DM 1.0, 1.2, 1.x
- {
- wxLogSysError(wxString::Format(wxT("Monitor gravitation not supported yet. dwDMVer:%u"),
- (unsigned int) dwDMVer));
- return false;
- }
-
- return true;
-}
-
-// ============================================================================
-// wxDisplay::CreateFactory()
-// ============================================================================
-
-/* static */ wxDisplayFactory *wxDisplay::CreateFactory()
-{
- return new wxDisplayFactoryMac;
-}
-
-#endif // wxUSE_DISPLAY
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/dnd.cpp
-// Purpose: wxDropTarget, wxDropSource, wxDataObject implementation
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) 1998 Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_DRAG_AND_DROP
-
-#include "wx/dnd.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/window.h"
- #include "wx/toplevel.h"
- #include "wx/gdicmn.h"
-#endif // WX_PRECOMP
-
-#include "wx/mac/private.h"
-
-// ----------------------------------------------------------------------------
-// global
-// ----------------------------------------------------------------------------
-
-void wxMacEnsureTrackingHandlersInstalled() ;
-
-typedef struct
-{
- wxWindow* m_currentTargetWindow ;
- wxDropTarget* m_currentTarget ;
- wxDropSource* m_currentSource ;
-} MacTrackingGlobals ;
-
-MacTrackingGlobals gTrackingGlobals ;
-
-//----------------------------------------------------------------------------
-// wxDropTarget
-//----------------------------------------------------------------------------
-
-wxDropTarget::wxDropTarget( wxDataObject *data )
- : wxDropTargetBase( data )
-{
- wxMacEnsureTrackingHandlersInstalled() ;
-}
-
-wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x),
- wxCoord WXUNUSED(y),
- wxDragResult def )
-{
-
- return CurrentDragHasSupportedFormat() ? def : wxDragNone;
-}
-
-bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) )
-{
- if (!m_dataObject)
- return false;
-
- return CurrentDragHasSupportedFormat() ;
-}
-
-wxDragResult wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
- wxDragResult def )
-{
- if (!m_dataObject)
- return wxDragNone;
-
- if (!CurrentDragHasSupportedFormat())
- return wxDragNone;
-
- return GetData() ? def : wxDragNone;
-}
-
-bool wxDropTarget::CurrentDragHasSupportedFormat()
-{
- bool supported = false ;
- if ( gTrackingGlobals.m_currentSource != NULL )
- {
- wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ;
-
- if ( data )
- {
- size_t formatcount = data->GetFormatCount() ;
- wxDataFormat *array = new wxDataFormat[ formatcount ];
- data->GetAllFormats( array );
- for (size_t i = 0; !supported && i < formatcount ; i++)
- {
- wxDataFormat format = array[i] ;
- if ( m_dataObject->IsSupported( format ) )
- {
- supported = true ;
- break ;
- }
- }
- delete[] array ;
- }
- }
- if ( !supported )
- {
- UInt16 items ;
- OSErr result;
- CountDragItems((DragReference)m_currentDrag, &items);
- for (UInt16 index = 1; index <= items && supported == false ; ++index)
- {
- ItemReference theItem;
- FlavorType theType ;
- UInt16 flavors = 0 ;
- GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem);
- CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ;
- for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor )
- {
- result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType);
- if ( m_dataObject->IsSupportedFormat( wxDataFormat( theType ) ) )
- {
- supported = true ;
- break ;
- }
- }
- }
- }
- return supported ;
-}
-
-bool wxDropTarget::GetData()
-{
- if (!m_dataObject)
- return false;
-
- if ( !CurrentDragHasSupportedFormat() )
- return false ;
-
- bool transferred = false ;
- if ( gTrackingGlobals.m_currentSource != NULL )
- {
- wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject() ;
-
- if ( data )
- {
- size_t formatcount = data->GetFormatCount() ;
- wxDataFormat *array = new wxDataFormat[ formatcount ];
- data->GetAllFormats( array );
- for (size_t i = 0; !transferred && i < formatcount ; i++)
- {
- wxDataFormat format = array[i] ;
- if ( m_dataObject->IsSupported( format ) )
- {
- int size = data->GetDataSize( format );
- transferred = true ;
-
- if (size == 0)
- {
- m_dataObject->SetData(format , 0 , 0 ) ;
- }
- else
- {
- char *d = new char[size];
- data->GetDataHere( format , (void*) d );
- m_dataObject->SetData( format , size , d ) ;
- delete[] d ;
- }
- }
- }
- delete[] array ;
- }
- }
- if ( !transferred )
- {
- UInt16 items ;
- OSErr result;
- bool firstFileAdded = false ;
- CountDragItems((DragReference)m_currentDrag, &items);
- for (UInt16 index = 1; index <= items; ++index)
- {
- ItemReference theItem;
- FlavorType theType ;
- UInt16 flavors = 0 ;
- GetDragItemReferenceNumber((DragReference)m_currentDrag, index, &theItem);
- CountDragItemFlavors( (DragReference)m_currentDrag, theItem , &flavors ) ;
- for ( UInt16 flavor = 1 ; flavor <= flavors ; ++flavor )
- {
- result = GetFlavorType((DragReference)m_currentDrag, theItem, flavor , &theType);
- wxDataFormat format(theType) ;
- if ( m_dataObject->IsSupportedFormat( format ) )
- {
- FlavorFlags theFlags;
- result = GetFlavorFlags((DragReference)m_currentDrag, theItem, theType, &theFlags);
- if (result == noErr)
- {
- Size dataSize ;
- Ptr theData ;
- GetFlavorDataSize((DragReference)m_currentDrag, theItem, theType, &dataSize);
- if ( theType == 'TEXT' )
- {
- // this increment is only valid for allocating, on the next GetFlavorData
- // call it is reset again to the original value
- dataSize++ ;
- }
- theData = new char[dataSize];
- GetFlavorData((DragReference)m_currentDrag, theItem, theType, (void*) theData, &dataSize, 0L);
- if( theType == 'TEXT' )
- {
- theData[dataSize]=0 ;
- wxString convert( theData , wxConvLocal ) ;
- m_dataObject->SetData( format, convert.length() * sizeof(wxChar), (const wxChar*) convert );
- }
- else if ( theType == kDragFlavorTypeHFS )
- {
- HFSFlavor* theFile = (HFSFlavor*) theData ;
- wxString name = wxMacFSSpec2MacFilename( &theFile->fileSpec ) ;
- if ( firstFileAdded )
- ((wxFileDataObject*)m_dataObject)->AddFile( name ) ;
- else
- {
- ((wxFileDataObject*)m_dataObject)->SetData( 0 , name.c_str() ) ;
- firstFileAdded = true ;
- }
- }
- else
- {
- m_dataObject->SetData( format, dataSize, theData );
- }
- delete[] theData;
- }
- break ;
- }
- }
- }
- }
- return true ;
-}
-
-//-------------------------------------------------------------------------
-// wxDropSource
-//-------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// drag request
-
-wxDropSource::wxDropSource(wxWindow *win,
- const wxCursor &cursorCopy,
- const wxCursor &cursorMove,
- const wxCursor &cursorStop)
- : wxDropSourceBase(cursorCopy, cursorMove, cursorStop)
-{
- wxMacEnsureTrackingHandlersInstalled() ;
- m_window = win;
-}
-
-wxDropSource::wxDropSource(wxDataObject& data,
- wxWindow *win,
- const wxCursor &cursorCopy,
- const wxCursor &cursorMove,
- const wxCursor &cursorStop)
- : wxDropSourceBase(cursorCopy, cursorMove, cursorStop)
-{
- wxMacEnsureTrackingHandlersInstalled() ;
- SetData( data );
- m_window = win;
-}
-
-wxDropSource::~wxDropSource()
-{
-}
-
-
-wxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags))
-{
- wxASSERT_MSG( m_data, wxT("Drop source: no data") );
-
- if (!m_data)
- return (wxDragResult) wxDragNone;
-
- if (m_data->GetFormatCount() == 0)
- return (wxDragResult) wxDragNone;
-
- OSErr result;
- DragReference theDrag;
- RgnHandle dragRegion;
- if ((result = NewDrag(&theDrag)))
- {
- return wxDragNone ;
- }
- // add data to drag
- size_t formatCount = m_data->GetFormatCount() ;
- wxDataFormat *formats = new wxDataFormat[formatCount] ;
- m_data->GetAllFormats( formats ) ;
- ItemReference theItem = 1 ;
- for ( size_t i = 0 ; i < formatCount ; ++i )
- {
- size_t dataSize = m_data->GetDataSize( formats[i] ) ;
- Ptr dataPtr = new char[dataSize] ;
- m_data->GetDataHere( formats[i] , dataPtr ) ;
- OSType type = formats[i].GetFormatId() ;
- if ( type == 'TEXT' )
- {
- dataSize-- ;
- dataPtr[ dataSize ] = 0 ;
- wxString st( (wxChar*) dataPtr ) ;
- wxCharBuffer buf = st.mb_str( wxConvLocal) ;
- AddDragItemFlavor(theDrag, theItem, type , buf.data(), strlen(buf), 0);
- }
- else if (type == kDragFlavorTypeHFS )
- {
- HFSFlavor theFlavor ;
- OSErr err = noErr;
- CInfoPBRec cat;
-
- wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ;
-
- cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name;
- cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum;
- cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID;
- cat.hFileInfo.ioFDirIndex = 0;
- err = PBGetCatInfoSync(&cat);
- if (err == noErr )
- {
- theFlavor.fdFlags = cat.hFileInfo.ioFlFndrInfo.fdFlags;
- if (theFlavor.fileSpec.parID == fsRtParID) {
- theFlavor.fileCreator = 'MACS';
- theFlavor.fileType = 'disk';
- } else if ((cat.hFileInfo.ioFlAttrib & ioDirMask) != 0) {
- theFlavor.fileCreator = 'MACS';
- theFlavor.fileType = 'fold';
- } else {
- theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator;
- theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType;
- }
- AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0);
- }
- }
- else
- {
- AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0);
- }
- delete[] dataPtr ;
- }
- delete[] formats ;
-
- dragRegion = NewRgn();
- RgnHandle tempRgn = NewRgn() ;
-
- EventRecord* ev = NULL ;
-#if !TARGET_CARBON // TODO
- ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
-#else
- EventRecord rec ;
- ev = &rec ;
- wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ;
-#endif
- const short dragRegionOuterBoundary = 10 ;
- const short dragRegionInnerBoundary = 9 ;
-
- SetRectRgn( dragRegion , ev->where.h - dragRegionOuterBoundary ,
- ev->where.v - dragRegionOuterBoundary ,
- ev->where.h + dragRegionOuterBoundary ,
- ev->where.v + dragRegionOuterBoundary ) ;
-
- SetRectRgn( tempRgn , ev->where.h - dragRegionInnerBoundary ,
- ev->where.v - dragRegionInnerBoundary ,
- ev->where.h + dragRegionInnerBoundary ,
- ev->where.v + dragRegionInnerBoundary ) ;
-
- DiffRgn( dragRegion , tempRgn , dragRegion ) ;
- DisposeRgn( tempRgn ) ;
-
- // TODO:work with promises in order to return data only when drag
- // was successfully completed
-
- gTrackingGlobals.m_currentSource = this ;
- result = TrackDrag(theDrag, ev , dragRegion);
- DisposeRgn(dragRegion);
- DisposeDrag(theDrag);
- gTrackingGlobals.m_currentSource = NULL ;
-
- KeyMap keymap;
- GetKeys(keymap);
- bool optionDown = keymap[1] & 4;
- wxDragResult dndresult = optionDown ? wxDragCopy : wxDragMove;
- return dndresult;
-}
-
-bool wxDropSource::MacInstallDefaultCursor(wxDragResult effect)
-{
- const wxCursor& cursor = GetCursor(effect);
- if ( cursor.Ok() )
- {
- cursor.MacInstall() ;
-
- return true;
- }
- else
- {
- return false;
- }
-}
-
-bool gTrackingGlobalsInstalled = false ;
-
-// passing the globals via refcon is not needed by the CFM and later architectures anymore
-// but I'll leave it in there, just in case...
-
-pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow,
- void *handlerRefCon, DragReference theDrag) ;
-pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow, void *handlerRefCon,
-DragReference theDrag) ;
-
-void wxMacEnsureTrackingHandlersInstalled()
-{
- if( !gTrackingGlobalsInstalled )
- {
- OSErr result;
-
- result = InstallTrackingHandler(NewDragTrackingHandlerUPP(wxMacWindowDragTrackingHandler), 0L,&gTrackingGlobals);
- wxASSERT( result == noErr ) ;
- result = InstallReceiveHandler(NewDragReceiveHandlerUPP(wxMacWindowDragReceiveHandler), 0L, &gTrackingGlobals);
- wxASSERT( result == noErr ) ;
-
- gTrackingGlobalsInstalled = true ;
- }
-}
-
-pascal OSErr wxMacWindowDragTrackingHandler(DragTrackingMessage theMessage, WindowPtr theWindow,
- void *handlerRefCon, DragReference theDrag)
-{
- MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon;
- Point mouse, localMouse;
- DragAttributes attributes;
- GetDragAttributes(theDrag, &attributes);
- wxTopLevelWindowMac* toplevel = wxFindWinFromMacWindow( (WXWindow) theWindow ) ;
-
- KeyMap keymap;
- GetKeys(keymap);
- bool optionDown = keymap[1] & 4;
- wxDragResult result = optionDown ? wxDragCopy : wxDragMove;
-
- switch(theMessage)
- {
- case kDragTrackingEnterHandler:
- break;
- case kDragTrackingLeaveHandler:
- break;
- case kDragTrackingEnterWindow:
- trackingGlobals->m_currentTargetWindow = NULL ;
- trackingGlobals->m_currentTarget = NULL ;
- break;
- case kDragTrackingInWindow:
- if (toplevel == NULL)
- break;
-
- GetDragMouse(theDrag, &mouse, 0L);
- localMouse = mouse;
- GlobalToLocal(&localMouse);
-
-
-
-// if (attributes & kDragHasLeftSenderWindow)
- {
- wxPoint point(localMouse.h , localMouse.v) ;
- wxWindow *win = NULL ;
- toplevel->MacGetWindowFromPointSub( point , &win ) ;
- int localx , localy ;
- localx = localMouse.h ;
- localy = localMouse.v ;
- //TODO : should we use client coordinates
- if ( win )
- win->MacRootWindowToWindow( &localx , &localy ) ;
- if ( win != trackingGlobals->m_currentTargetWindow )
- {
- if ( trackingGlobals->m_currentTargetWindow )
- {
- // this window is left
- if ( trackingGlobals->m_currentTarget )
- {
- HideDragHilite(theDrag);
- trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
- trackingGlobals->m_currentTarget->OnLeave() ;
- trackingGlobals->m_currentTarget = NULL;
- trackingGlobals->m_currentTargetWindow = NULL ;
- }
- }
- if ( win )
- {
- // this window is entered
- trackingGlobals->m_currentTargetWindow = win ;
- trackingGlobals->m_currentTarget = win->GetDropTarget() ;
- {
-
- if ( trackingGlobals->m_currentTarget )
- {
- trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
- result = trackingGlobals->m_currentTarget->OnEnter(
- localx , localy , result ) ;
- }
-
-
- if ( result != wxDragNone )
- {
- int x , y ;
- x = y = 0 ;
- win->MacWindowToRootWindow( &x , &y ) ;
- RgnHandle hiliteRgn = NewRgn() ;
- SetRectRgn( hiliteRgn , x , y , x+win->GetSize().x ,y+win->GetSize().y) ;
- ShowDragHilite(theDrag, hiliteRgn, true);
- DisposeRgn( hiliteRgn ) ;
- }
- }
- }
- }
- else
- {
- if( trackingGlobals->m_currentTarget )
- {
- trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
- trackingGlobals->m_currentTarget->OnDragOver(
- localx , localy , result ) ;
- }
- }
-
- // set cursor for OnEnter and OnDragOver
- if ( trackingGlobals->m_currentSource && trackingGlobals->m_currentSource->GiveFeedback( result ) == FALSE )
- {
- if ( trackingGlobals->m_currentSource->MacInstallDefaultCursor( result ) == FALSE )
- {
- switch( result )
- {
- case wxDragCopy :
- {
- wxCursor cursor(wxCURSOR_COPY_ARROW) ;
- cursor.MacInstall() ;
- }
- break ;
- case wxDragMove :
- {
- wxCursor cursor(wxCURSOR_ARROW) ;
- cursor.MacInstall() ;
- }
- break ;
- case wxDragNone :
- {
- wxCursor cursor(wxCURSOR_NO_ENTRY) ;
- cursor.MacInstall() ;
- }
- break ;
-
- case wxDragError:
- case wxDragLink:
- case wxDragCancel:
- // put these here to make gcc happy
- ;
- }
- }
- }
-
- }
- // MyTrackItemUnderMouse(localMouse, theWindow);
- break;
- case kDragTrackingLeaveWindow:
- if (trackingGlobals->m_currentTarget)
- {
- trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
- trackingGlobals->m_currentTarget->OnLeave() ;
- HideDragHilite(theDrag);
- trackingGlobals->m_currentTarget = NULL ;
- }
- trackingGlobals->m_currentTargetWindow = NULL ;
- break;
- }
- return(noErr);
-}
-
-pascal OSErr wxMacWindowDragReceiveHandler(WindowPtr theWindow,
- void *handlerRefCon,
- DragReference theDrag)
-{
- MacTrackingGlobals* trackingGlobals = (MacTrackingGlobals*) handlerRefCon;
- if ( trackingGlobals->m_currentTarget )
- {
- Point mouse,localMouse ;
- int localx,localy ;
-
- trackingGlobals->m_currentTarget->SetCurrentDrag( theDrag ) ;
- GetDragMouse(theDrag, &mouse, 0L);
- localMouse = mouse;
- GlobalToLocal(&localMouse);
- localx = localMouse.h ;
- localy = localMouse.v ;
- //TODO : should we use client coordinates
- if ( trackingGlobals->m_currentTargetWindow )
- trackingGlobals->m_currentTargetWindow->MacRootWindowToWindow( &localx , &localy ) ;
- if ( trackingGlobals->m_currentTarget->OnDrop( localx , localy ) )
- {
- KeyMap keymap;
- GetKeys(keymap);
- bool optionDown = keymap[1] & 4;
- wxDragResult result = optionDown ? wxDragCopy : wxDragMove;
- trackingGlobals->m_currentTarget->OnData( localx , localy , result ) ;
- }
- }
- return(noErr);
-}
-#endif
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/filedlg.cpp
-// Purpose: wxFileDialog
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/filedlg.h"
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/app.h"
- #include "wx/utils.h"
- #include "wx/dialog.h"
-#endif
-
-#include "wx/tokenzr.h"
-#include "wx/filename.h"
-
-#ifndef __DARWIN__
- #include "PLStringFuncs.h"
-#endif
-
-IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
-
-// begin wxmac
-
-#include "wx/mac/private.h"
-
-#include <Navigation.h>
-
-#ifdef __DARWIN__
-# include "MoreFilesX.h"
-#else
-# include "MoreFiles.h"
-# include "MoreFilesExtras.h"
-#endif
-
-extern bool gUseNavServices ;
-
-// the data we need to pass to our standard file hook routine
-// includes a pointer to the dialog, a pointer to the standard
-// file reply record (so we can inspect the current selection)
-// and a copy of the "previous" file spec of the reply record
-// so we can see if the selection has changed
-
-struct OpenUserDataRec {
- int currentfilter ;
- bool saveMode ;
- wxArrayString name ;
- wxArrayString extensions ;
- wxArrayLong filtermactypes ;
- wxString defaultLocation;
-#if TARGET_CARBON
- CFArrayRef menuitems ;
-#else
- NavMenuItemSpecArrayHandle menuitems ;
-#endif
-};
-
-typedef struct OpenUserDataRec
-OpenUserDataRec, *OpenUserDataRecPtr;
-
-static pascal void NavEventProc(
- NavEventCallbackMessage inSelector,
- NavCBRecPtr ioParams,
- NavCallBackUserData ioUserData);
-
-#if TARGET_CARBON
- static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
-#else
- static NavEventUPP sStandardNavEventFilter = NewNavEventProc(NavEventProc);
-#endif
-
-static pascal void
-NavEventProc(
- NavEventCallbackMessage inSelector,
- NavCBRecPtr ioParams,
- NavCallBackUserData ioUserData )
-{
- OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
- if (inSelector == kNavCBEvent) {
-#if TARGET_CARBON
-#else
- wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
-#endif
- }
- else if ( inSelector == kNavCBStart )
- {
-#if TARGET_CARBON
- if (data && !(data->defaultLocation).empty())
- {
- // Set default location for the modern Navigation APIs
- // Apple Technical Q&A 1151
- FSSpec theFSSpec;
- wxMacFilename2FSSpec(data->defaultLocation, &theFSSpec);
- AEDesc theLocation = {typeNull, NULL};
- if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation))
- ::NavCustomControl(ioParams->context, kNavCtlSetLocation, (void *) &theLocation);
- }
-#else
- if ( data->menuitems )
- NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &(*data->menuitems)[data->currentfilter]);
-#endif
- }
- else if ( inSelector == kNavCBPopupMenuSelect )
- {
- NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ;
-#if TARGET_CARBON
-#else
- if ( menu->menuCreator == 'WXNG' )
-#endif
- {
- data->currentfilter = menu->menuType ;
- if ( data->saveMode )
- {
- int i = menu->menuType ;
- wxString extension = data->extensions[i].AfterLast('.') ;
- extension.MakeLower() ;
- wxString sfilename ;
-
-#if TARGET_CARBON
- wxMacCFStringHolder cfString( NavDialogGetSaveFileName( ioParams->context ) , false );
- sfilename = cfString.AsString() ;
-#else
- Str255 filename ;
- // get the current filename
- NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename);
- sfilename = wxMacMakeStringFromPascal( filename ) ;
-#endif
-
- int pos = sfilename.Find('.', true) ;
- if ( pos != wxNOT_FOUND )
- {
- sfilename = sfilename.Left(pos+1)+extension ;
-#if TARGET_CARBON
- cfString.Assign( sfilename , wxFONTENCODING_DEFAULT ) ;
- NavDialogSetSaveFileName( ioParams->context , cfString ) ;
-#else
- wxMacStringToPascal( sfilename , filename ) ;
- NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename);
-#endif
- }
- }
- }
- }
-}
-
-
-void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
-{
- myData->menuitems = NULL ;
- myData->currentfilter = 0 ;
- myData->saveMode = false ;
-
- if ( filter && filter[0] )
- {
- wxString filter2(filter) ;
- int filterIndex = 0;
- bool isName = true ;
- wxString current ;
- for( unsigned int i = 0; i < filter2.length() ; i++ )
- {
- if( filter2.GetChar(i) == wxT('|') )
- {
- if( isName ) {
- myData->name.Add( current ) ;
- }
- else {
- myData->extensions.Add( current.MakeUpper() ) ;
- ++filterIndex ;
- }
- isName = !isName ;
- current = wxEmptyString ;
- }
- else
- {
- current += filter2.GetChar(i) ;
- }
- }
- // we allow for compatibility reason to have a single filter expression (like *.*) without
- // 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") ) ;
- if ( current.empty() )
- myData->extensions.Add( myData->name[filterIndex] ) ;
- else
- myData->extensions.Add( current.MakeUpper() ) ;
- if ( filterIndex == 0 || isName )
- myData->name.Add( current.MakeUpper() ) ;
-
- ++filterIndex ;
-
- const size_t extCount = myData->extensions.GetCount();
- for ( size_t i = 0 ; i < extCount; i++ )
- {
- wxUint32 fileType;
- wxUint32 creator;
- wxString extension = myData->extensions[i];
-
- if (extension.GetChar(0) == '*')
- extension = extension.Mid(1); // Remove leading *
-
- if (extension.GetChar(0) == '.')
- {
- extension = extension.Mid(1); // Remove leading .
- }
-
- if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator ))
- {
- myData->filtermactypes.Add( (OSType)fileType );
- }
- else
- {
- myData->filtermactypes.Add( '****' ) ; // We'll fail safe if it's not recognized
- }
- }
- }
-}
-
-static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataRecPtr data)
-{
- wxString file(filename) ;
- file.MakeUpper() ;
-
- if ( data->extensions.GetCount() > 0 )
- {
- //for ( int i = 0 ; i < data->numfilters ; ++i )
- int i = data->currentfilter ;
- if ( data->extensions[i].Right(2) == wxT(".*") )
- return true ;
-
- {
- if ( type == (OSType)data->filtermactypes[i] )
- return true ;
-
- wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ;
- while( tokenizer.HasMoreTokens() )
- {
- wxString extension = tokenizer.GetNextToken() ;
- if ( extension.GetChar(0) == '*' )
- extension = extension.Mid(1) ;
-
- if ( file.length() >= extension.length() && extension == file.Right(extension.length() ) )
- return true ;
- }
- }
- return false ;
- }
- return true ;
-}
-
-#ifndef __DARWIN__
-static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
-{
- OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ;
- // return true if this item is invisible or a file
-
- Boolean visibleFlag;
- Boolean folderFlag;
-
- visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible);
- folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10);
-
- // because the semantics of the filter proc are "true means don't show
- // it" we need to invert the result that we return
-
- if ( !visibleFlag )
- return true ;
-
- if ( !folderFlag )
- {
- wxString file = wxMacMakeStringFromPascal( myCInfoPBPtr->hFileInfo.ioNamePtr ) ;
- return !CheckFile( file , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ;
- }
-
- return false ;
-}
-#endif
-
-// end wxmac
-
-wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
- const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
- long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
- :wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)
-{
- wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
-}
-
-pascal Boolean CrossPlatformFilterCallback (
- AEDesc *theItem,
- void *info,
- void *callBackUD,
- NavFilterModes filterMode
-)
-{
- bool display = true;
- OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
-
- if (filterMode == kNavFilteringBrowserList)
- {
- NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
- if ( !theInfo->isFolder )
- {
- if (theItem->descriptorType == typeFSS )
- {
- FSSpec spec;
- memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
- wxString file = wxMacMakeStringFromPascal( spec.name ) ;
- display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
- }
-#if TARGET_CARBON
- else if ( theItem->descriptorType == typeFSRef )
- {
- FSRef fsref ;
- memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ;
-
-
-
- CFURLRef fullURLRef;
- fullURLRef = ::CFURLCreateFromFSRef(NULL, &fsref);
-#ifdef __UNIX__
- CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
-#else
- CFURLPathStyle pathstyle = kCFURLHFSPathStyle;
-#endif
- CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
- ::CFRelease( fullURLRef ) ;
- wxString file = wxMacCFStringHolder(cfString).AsString(wxFont::GetDefaultEncoding());
-
- display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
- }
-#endif
- }
- }
-
- return display;
-}
-
-int wxFileDialog::ShowModal()
-{
-#if TARGET_CARBON
- OSErr err;
- NavDialogCreationOptions dialogCreateOptions;
- // set default options
- ::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
-
- // this was always unset in the old code
- dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation;
-
- wxMacCFStringHolder message(m_message, m_font.GetEncoding());
- dialogCreateOptions.windowTitle = message;
-
- wxMacCFStringHolder defaultFileName(m_fileName, m_font.GetEncoding());
- dialogCreateOptions.saveFileName = defaultFileName;
-
-
- NavDialogRef dialog;
- NavObjectFilterUPP navFilterUPP = NULL;
- CFArrayRef cfArray = NULL; // for popupExtension
- OpenUserDataRec myData;
- myData.defaultLocation = m_dir;
-
- if (HasFlag(wxFD_SAVE))
- {
- dialogCreateOptions.optionFlags |= kNavNoTypePopup;
- dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
- dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
-
- // The extension is important
- dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
-
- err = ::NavCreatePutFileDialog(&dialogCreateOptions,
- 'TEXT',
- 'TEXT',
- sStandardNavEventFilter,
- &myData, // for defaultLocation
- &dialog);
- }
- else
- {
- MakeUserDataRec(&myData , m_wildCard);
- size_t numfilters = myData.extensions.GetCount();
- if (numfilters > 0)
- {
- CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
- numfilters , &kCFTypeArrayCallBacks ) ;
- dialogCreateOptions.popupExtension = popup ;
- myData.menuitems = dialogCreateOptions.popupExtension ;
- for ( size_t i = 0 ; i < numfilters ; ++i )
- {
- CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] , m_font.GetEncoding() ) ) ;
- }
- }
-
- navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
- err = ::NavCreateGetFileDialog(&dialogCreateOptions,
- NULL, // NavTypeListHandle
- sStandardNavEventFilter,
- NULL, // NavPreviewUPP
- navFilterUPP,
- (void *) &myData, // inClientData
- &dialog);
- }
-
- if (err == noErr)
- err = ::NavDialogRun(dialog);
-
- // clean up filter related data, etc.
- if (navFilterUPP)
- ::DisposeNavObjectFilterUPP(navFilterUPP);
- if (cfArray)
- ::CFRelease(cfArray);
-
- if (err != noErr)
- return wxID_CANCEL;
-
- NavReplyRecord navReply;
- err = ::NavDialogGetReply(dialog, &navReply);
- if (err == noErr && navReply.validRecord)
- {
- AEKeyword theKeyword;
- DescType actualType;
- Size actualSize;
- FSRef theFSRef;
- wxString thePath ;
- long count;
- ::AECountItems(&navReply.selection , &count);
- for (long i = 1; i <= count; ++i)
- {
- err = ::AEGetNthPtr(&(navReply.selection), i, typeFSRef, &theKeyword, &actualType,
- &theFSRef, sizeof(theFSRef), &actualSize);
- if (err != noErr)
- break;
-
- CFURLRef fullURLRef;
- if (HasFlag(wxFD_SAVE))
- {
- CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
-
- if (parentURLRef)
- {
- fullURLRef =
- ::CFURLCreateCopyAppendingPathComponent(NULL,
- parentURLRef,
- navReply.saveFileName,
- false);
- ::CFRelease(parentURLRef);
- }
- }
- else
- {
- fullURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
- }
-#ifdef __UNIX__
- CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
-#else
- CFURLPathStyle pathstyle = kCFURLHFSPathStyle;
-#endif
- CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
- thePath = wxMacCFStringHolder(cfString).AsString(m_font.GetEncoding());
- if (!thePath)
- {
- ::NavDisposeReply(&navReply);
- return wxID_CANCEL;
- }
- m_path = thePath;
- m_paths.Add(m_path);
- m_fileName = wxFileNameFromPath(m_path);
- m_fileNames.Add(m_fileName);
- }
- // set these to the first hit
- m_path = m_paths[0];
- m_fileName = wxFileNameFromPath(m_path);
- m_dir = wxPathOnly(m_path);
- }
- ::NavDisposeReply(&navReply);
-
- return (err == noErr) ? wxID_OK : wxID_CANCEL;
-#else // TARGET_CARBON
-
- NavDialogOptions mNavOptions;
- NavObjectFilterUPP mNavFilterUPP = NULL;
- NavPreviewUPP mNavPreviewUPP = NULL ;
- NavReplyRecord mNavReply;
- AEDesc mDefaultLocation ;
- bool mSelectDefault = false ;
- OSStatus err = noErr ;
- // setup dialog
-
- mNavFilterUPP = nil;
- mNavPreviewUPP = nil;
- mSelectDefault = false;
- mDefaultLocation.descriptorType = typeNull;
- mDefaultLocation.dataHandle = nil;
-
- NavGetDefaultDialogOptions(&mNavOptions);
- wxMacStringToPascal( m_message , (StringPtr)mNavOptions.message ) ;
- wxMacStringToPascal( m_fileName , (StringPtr)mNavOptions.savedFileName ) ;
-
- // Set default location, the location
- // that's displayed when the dialog
- // first appears
-
- FSSpec location ;
- wxMacFilename2FSSpec( m_dir , &location ) ;
-
- err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation );
-
- if ( mDefaultLocation.dataHandle )
- {
- if (mSelectDefault)
- {
- mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
- } else {
- mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
- }
- }
-
- memset( &mNavReply , 0 , sizeof( mNavReply ) ) ;
- mNavReply.validRecord = false;
- mNavReply.replacing = false;
- mNavReply.isStationery = false;
- mNavReply.translationNeeded = false;
- mNavReply.selection.descriptorType = typeNull;
- mNavReply.selection.dataHandle = nil;
- mNavReply.keyScript = smSystemScript;
- mNavReply.fileTranslation = nil;
- mNavReply.version = kNavReplyRecordVersion ;
-
- // zero all data
-
- m_path = wxEmptyString ;
- m_fileName = wxEmptyString ;
- m_paths.Empty();
- m_fileNames.Empty();
-
- OpenUserDataRec myData;
- MakeUserDataRec( &myData , m_wildCard ) ;
- myData.currentfilter = m_filterIndex ;
- if ( myData.extensions.GetCount() > 0 )
- {
- mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.extensions.GetCount() ) ;
- myData.menuitems = mNavOptions.popupExtension ;
- for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )
- {
- (*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ;
- (*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ;
- // TODO : according to the new docs -1 to 10 are reserved for the OS
- (*mNavOptions.popupExtension)[i].menuType = i ;
- wxMacStringToPascal( myData.name[i] , (StringPtr)(*mNavOptions.popupExtension)[i].menuItemName ) ;
- }
- }
- if ( HasFlag(wxFD_SAVE) )
- {
- myData.saveMode = true ;
-
- mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
- mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
-
- err = ::NavPutFile(
- &mDefaultLocation,
- &mNavReply,
- &mNavOptions,
- sStandardNavEventFilter ,
- NULL,
- kNavGenericSignature,
- &myData); // User Data
- m_filterIndex = myData.currentfilter ;
- }
- else
- {
- myData.saveMode = false ;
-
- mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
- if ( m_windowStyle & wxFD_MULTIPLE )
- mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
- else
- mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
-
- err = ::NavGetFile(
- &mDefaultLocation,
- &mNavReply,
- &mNavOptions,
- sStandardNavEventFilter ,
- mNavPreviewUPP,
- mNavFilterUPP,
- NULL ,
- &myData);
- m_filterIndex = myData.currentfilter ;
- }
-
- DisposeNavObjectFilterUPP(mNavFilterUPP);
- if ( mDefaultLocation.dataHandle != nil )
- {
- ::AEDisposeDesc(&mDefaultLocation);
- }
-
- if ( (err != noErr) && (err != userCanceledErr) ) {
- return wxID_CANCEL ;
- }
-
- if (mNavReply.validRecord)
- {
- FSSpec outFileSpec ;
- AEDesc specDesc ;
- AEKeyword keyWord ;
-
- long count ;
- ::AECountItems( &mNavReply.selection , &count ) ;
- for ( long i = 1 ; i <= count ; ++i )
- {
- OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
- if ( err != noErr )
- {
- m_path = wxEmptyString ;
- return wxID_CANCEL ;
- }
- outFileSpec = **(FSSpec**) specDesc.dataHandle;
- if (specDesc.dataHandle != nil) {
- ::AEDisposeDesc(&specDesc);
- }
- m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
-
- m_paths.Add( m_path ) ;
- m_fileName = wxFileNameFromPath(m_path);
- m_fileNames.Add(m_fileName);
- }
- // set these to the first hit
- m_path = m_paths[ 0 ] ;
- m_fileName = wxFileNameFromPath(m_path);
- m_dir = wxPathOnly(m_path);
- NavDisposeReply( &mNavReply ) ;
- return wxID_OK ;
- }
- return wxID_CANCEL;
-#endif // TARGET_CARBON
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/font.cpp
-// Purpose: wxFont class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/font.h"
-
-#ifndef WX_PRECOMP
- #include "wx/string.h"
- #include "wx/utils.h"
- #include "wx/gdicmn.h"
-#endif
-
-#include "wx/fontutil.h"
-
-#include "wx/fontutil.h"
-
-#include "wx/mac/private.h"
-#include <ATSUnicode.h>
-
-IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
-
-class WXDLLEXPORT wxFontRefData: public wxGDIRefData
-{
- friend class WXDLLEXPORT wxFont;
-public:
- wxFontRefData()
- : m_fontId(0)
- , m_pointSize(10)
- , m_family(wxDEFAULT)
- , m_style(wxNORMAL)
- , m_weight(wxNORMAL)
- , m_underlined(false)
- , m_faceName(wxT("Geneva"))
- , m_encoding(wxFONTENCODING_DEFAULT)
- , m_macFontNum(0)
- , m_macFontSize(0)
- , m_macFontStyle(0)
- , m_macATSUFontID()
- {
- Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, false,
- wxT("Geneva"), wxFONTENCODING_DEFAULT);
- }
-
- wxFontRefData(const wxFontRefData& data)
- : wxGDIRefData()
- , m_fontId(data.m_fontId)
- , m_pointSize(data.m_pointSize)
- , m_family(data.m_family)
- , m_style(data.m_style)
- , m_weight(data.m_weight)
- , m_underlined(data.m_underlined)
- , m_faceName(data.m_faceName)
- , m_encoding(data.m_encoding)
- , m_macFontNum(data.m_macFontNum)
- , m_macFontSize(data.m_macFontSize)
- , m_macFontStyle(data.m_macFontStyle)
- , m_macATSUFontID(data.m_macATSUFontID)
- {
- Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
- data.m_underlined, data.m_faceName, data.m_encoding);
- }
-
- wxFontRefData(int size,
- int family,
- int style,
- int weight,
- bool underlined,
- const wxString& faceName,
- wxFontEncoding encoding)
- : m_fontId(0)
- , m_pointSize(size)
- , m_family(family)
- , m_style(style)
- , m_weight(weight)
- , m_underlined(underlined)
- , m_faceName(faceName)
- , m_encoding(encoding)
- , m_macFontNum(0)
- , m_macFontSize(0)
- , m_macFontStyle(0)
- , m_macATSUFontID(0)
- {
- Init(size, family, style, weight, underlined, faceName, encoding);
- }
-
- virtual ~wxFontRefData();
- void SetNoAntiAliasing( bool no = true ) { m_noAA = no; }
- bool GetNoAntiAliasing() const { return m_noAA; }
-
-protected:
- // common part of all ctors
- void Init(int size,
- int family,
- int style,
- int weight,
- bool underlined,
- const wxString& faceName,
- wxFontEncoding encoding);
-
- // font characterstics
- int m_fontId;
- int m_pointSize;
- int m_family;
- int m_style;
- int m_weight;
- bool m_underlined;
- wxString m_faceName;
- wxFontEncoding m_encoding;
- bool m_noAA; // No anti-aliasing
-
-public:
- short m_macFontNum;
- short m_macFontSize;
- unsigned char m_macFontStyle;
- wxUint32 m_macATSUFontID;
-
- wxNativeFontInfo m_info;
-
-public:
- void MacFindFont() ;
-};
-
-#define M_FONTDATA ((wxFontRefData*)m_refData)
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxFontRefData
-// ----------------------------------------------------------------------------
-
-void wxFontRefData::Init(int pointSize,
- int family,
- int style,
- int weight,
- bool underlined,
- const wxString& faceName,
- wxFontEncoding encoding)
-{
- m_style = style;
- m_pointSize = pointSize;
- m_family = family;
- m_style = style;
- m_weight = weight;
- m_underlined = underlined;
- m_faceName = faceName;
- m_encoding = encoding;
-
- m_macFontNum = 0 ;
- m_macFontSize = 0;
- m_macFontStyle = 0;
- m_fontId = 0;
- m_noAA = false;
-}
-
-wxFontRefData::~wxFontRefData()
-{
-}
-
-void wxFontRefData::MacFindFont()
-{
- if( m_faceName.empty() )
- {
- switch( m_family )
- {
- case wxDEFAULT :
- m_macFontNum = ::GetAppFont() ;
- break ;
- case wxDECORATIVE :
- ::GetFNum( "\pTimes" , &m_macFontNum) ;
- break ;
- case wxROMAN :
- ::GetFNum( "\pTimes" , &m_macFontNum) ;
- break ;
- case wxSCRIPT :
- ::GetFNum( "\pTimes" , &m_macFontNum) ;
- break ;
- case wxSWISS :
- ::GetFNum( "\pGeneva" , &m_macFontNum) ;
- break ;
- case wxMODERN :
- ::GetFNum( "\pMonaco" , &m_macFontNum) ;
- break ;
- }
- Str255 name ;
- GetFontName( m_macFontNum , name ) ;
- m_faceName = wxMacMakeStringFromPascal( name ) ;
- }
- else
- {
- if ( m_faceName == wxT("systemfont") )
- m_macFontNum = ::GetSysFont() ;
- else if ( m_faceName == wxT("applicationfont") )
- m_macFontNum = ::GetAppFont() ;
- else
- {
- Str255 fontname ;
- wxMacStringToPascal( m_faceName , fontname ) ;
- ::GetFNum( fontname, &m_macFontNum);
- }
- }
-
- m_macFontStyle = 0;
- if (m_weight == wxBOLD)
- m_macFontStyle |= bold;
- if (m_style == wxITALIC || m_style == wxSLANT)
- m_macFontStyle |= italic;
- if (m_underlined)
- m_macFontStyle |= underline;
- m_macFontSize = m_pointSize ;
-
- //TODO:if we supply the style as an additional parameter we must make a testing
- //sequence in order to degrade gracefully while trying to maintain most of the style
- //information, meanwhile we just take the normal font and apply the features after
-#ifdef __WXDEBUG__
- OSStatus status =
-#endif // __WXDEBUG__
- ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID);
- /*
- status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) ,
- kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ;
- */
- wxASSERT_MSG( status == noErr , wxT("couldn't retrieve font identifier") ) ;
-}
-
-// ----------------------------------------------------------------------------
-// wxFont
-// ----------------------------------------------------------------------------
-}
-
-bool wxFont::Create(const wxNativeFontInfo& info)
-{
- return Create(info.pointSize, info.family, info.style, info.weight,
- info.underlined, info.faceName, info.encoding);
-}
-
-wxFont::wxFont(const wxString& fontdesc)
-{
- wxNativeFontInfo info;
- if ( info.FromString(fontdesc) )
- (void)Create(info);
-}
-
-bool wxFont::Create(int pointSize,
- int family,
- int style,
- int weight,
- bool underlined,
- const wxString& faceName,
- wxFontEncoding encoding)
-{
- UnRef();
- m_refData = new wxFontRefData(pointSize, family, style, weight,
- underlined, faceName, encoding);
-
- RealizeResource();
-
- return true;
-}
-
-wxFont::~wxFont()
-{
-}
-
-bool wxFont::RealizeResource()
-{
- M_FONTDATA->MacFindFont() ;
- return true;
-}
-
-void wxFont::SetEncoding(wxFontEncoding encoding)
-{
- Unshare();
-
- M_FONTDATA->m_encoding = encoding;
-
- RealizeResource();
-}
-
-void wxFont::Unshare()
-{
- // Don't change shared data
- if (!m_refData)
- {
- m_refData = new wxFontRefData();
- }
- else
- {
- wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
-}
-
-void wxFont::SetPointSize(int pointSize)
-{
- Unshare();
-
- M_FONTDATA->m_pointSize = pointSize;
-
- RealizeResource();
-}
-
-void wxFont::SetFamily(int family)
-{
- Unshare();
-
- M_FONTDATA->m_family = family;
-
- RealizeResource();
-}
-
-void wxFont::SetStyle(int style)
-{
- Unshare();
-
- M_FONTDATA->m_style = style;
-
- RealizeResource();
-}
-
-void wxFont::SetWeight(int weight)
-{
- Unshare();
-
- M_FONTDATA->m_weight = weight;
-
- RealizeResource();
-}
-
-bool wxFont::SetFaceName(const wxString& faceName)
-{
- Unshare();
-
- M_FONTDATA->m_faceName = faceName;
-
- RealizeResource();
-
- return wxFontBase::SetFaceName(faceName);
-}
-
-void wxFont::SetUnderlined(bool underlined)
-{
- Unshare();
-
- M_FONTDATA->m_underlined = underlined;
-
- RealizeResource();
-}
-
-void wxFont::SetNoAntiAliasing( bool no )
-{
- Unshare();
-
- M_FONTDATA->SetNoAntiAliasing( no );
-
- RealizeResource();
-}
-
-// ----------------------------------------------------------------------------
-// accessors
-// ----------------------------------------------------------------------------
-
-// TODO: insert checks everywhere for M_FONTDATA == NULL!
-
-int wxFont::GetPointSize() const
-{
- return M_FONTDATA->m_pointSize;
-}
-
-int wxFont::GetFamily() const
-{
- return M_FONTDATA->m_family;
-}
-
-int wxFont::GetStyle() const
-{
- return M_FONTDATA->m_style;
-}
-
-int wxFont::GetWeight() const
-{
- return M_FONTDATA->m_weight;
-}
-
-bool wxFont::GetUnderlined() const
-{
- return M_FONTDATA->m_underlined;
-}
-
-wxString wxFont::GetFaceName() const
-{
- wxString str;
- if ( M_FONTDATA )
- str = M_FONTDATA->m_faceName ;
- return str;
-}
-
-wxFontEncoding wxFont::GetEncoding() const
-{
- return M_FONTDATA->m_encoding;
-}
-
-bool wxFont::GetNoAntiAliasing() const
-{
- return M_FONTDATA->m_noAA;
-}
-
-short wxFont::GetMacFontNum() const
-{
- return M_FONTDATA->m_macFontNum;
-}
-
-short wxFont::GetMacFontSize() const
-{
- return M_FONTDATA->m_macFontSize;
-}
-
-wxByte wxFont::GetMacFontStyle() const
-{
- return M_FONTDATA->m_macFontStyle;
-}
-
-wxUint32 wxFont::GetMacATSUFontID() const
-{
- return M_FONTDATA->m_macATSUFontID;
-}
-
-const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
-{
- wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
-
- M_FONTDATA->m_info.InitFromFont(*this);
-
- return &(M_FONTDATA->m_info);
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/fontdlg.cpp
-// Purpose: wxFontDialog class. NOTE: you can use the generic class
-// if you wish, instead of implementing this.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/mac/fontdlg.h"
-
-#ifndef WX_PRECOMP
- #include "wx/cmndata.h"
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
-
-/*
- * wxFontDialog
- */
-
-wxFontDialog::wxFontDialog()
-{
- m_dialogParent = NULL;
-}
-
-wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& data)
-{
- Create(parent, data);
-}
-
-bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data)
-{
- m_dialogParent = parent;
-
- m_fontData = data;
-
- // TODO: you may need to do dialog creation here, unless it's
- // done in ShowModal.
- return true;
-}
-
-int wxFontDialog::ShowModal()
-{
- // TODO: show (maybe create) the dialog
- return wxID_CANCEL;
-}
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/fontenum.cpp
-// Purpose: wxFontEnumerator class for MacOS
-// Author: Stefan Csomor
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/font.h"
-#endif
-
-#include "wx/fontenum.h"
-#include "wx/fontutil.h"
-#include "wx/fontmap.h"
-#include "wx/fontutil.h"
-#include "wx/encinfo.h"
-
-#include "wx/mac/private.h"
-
-// ----------------------------------------------------------------------------
-// private classes
-// ----------------------------------------------------------------------------
-
-class wxFontEnumeratorHelper
-{
-public:
- wxFontEnumeratorHelper(wxFontEnumerator *fontEnum);
-
- // control what exactly are we enumerating
- bool SetEncoding(wxFontEncoding encoding);
- void SetFixedOnly(bool fixedOnly)
- { m_fixedOnly = fixedOnly; }
-
- // call to start enumeration
- void DoEnumerate();
-
-private:
- // the object we forward calls to OnFont() to
- wxFontEnumerator *m_fontEnum;
-
- // if != -1, enum only fonts which have this encoding
- int m_charset;
-
- // if not empty, enum only the fonts with this facename
- wxString m_facename;
-
- // if TRUE, enum only fixed fonts
- bool m_fixedOnly;
-};
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxFontEnumeratorHelper
-// ----------------------------------------------------------------------------
-
-wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator *fontEnum)
-{
- m_fontEnum = fontEnum;
- m_charset = -1;
- m_fixedOnly = false;
-}
-
-bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding)
-{
- wxNativeEncodingInfo info;
- if ( !wxGetNativeFontEncoding(encoding, &info) )
- {
- if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) )
- {
- // no such encodings at all
- return false;
- }
- }
- m_charset = info.charset;
- m_facename = info.facename;
-
- return true;
-}
-
-void wxFontEnumeratorHelper::DoEnumerate()
-{
- MenuHandle menu ;
- Str255 p_name ;
-
- short lines ;
-
- menu = NewMenu( 32000 , "\pFont" ) ;
- AppendResMenu( menu , 'FONT' ) ;
- lines = CountMenuItems( menu ) ;
-
- for ( int i = 1 ; i < lines+1 ; i ++ )
- {
- GetMenuItemText( menu , i , p_name ) ;
- wxString c_name = wxMacMakeStringFromPascal(p_name) ;
-
- /*
-
- if ( m_fixedOnly )
- {
- // check that it's a fixed pitch font (there is *no* error here, the
- // flag name is misleading!)
- if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
- {
- // not a fixed pitch font
- return TRUE;
- }
- }
-
- if ( m_charset != -1 )
- {
- // check that we have the right encoding
- if ( lf->lfCharSet != m_charset )
- {
- return TRUE;
- }
- }
-
- */
- m_fontEnum->OnFacename( c_name ) ;
- }
- DisposeMenu( menu ) ;
-}
-
-// ----------------------------------------------------------------------------
-// wxFontEnumerator
-// ----------------------------------------------------------------------------
-
-bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
- bool fixedWidthOnly)
-{
- wxFontEnumeratorHelper fe(this);
- if ( fe.SetEncoding(encoding) )
- {
- fe.SetFixedOnly(fixedWidthOnly);
-
- fe.DoEnumerate();
- }
- // else: no such fonts, unknown encoding
-
- return true;
-}
-
-bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
-{
- wxFAIL_MSG(wxT("wxFontEnumerator::EnumerateEncodings() not yet implemented"));
-
- return true;
-}
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: msw/fontutil.cpp
-// Purpose: font-related helper functions for wxMSW
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 05.11.99
-// RCS-ID: $Id$
-// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/string.h"
- #include "wx/log.h"
- #include "wx/intl.h"
-#endif //WX_PRECOMP
-
-#include "wx/fontutil.h"
-#include "wx/fontmap.h"
-#include "wx/encinfo.h"
-
-#include "wx/tokenzr.h"
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxNativeEncodingInfo
-// ----------------------------------------------------------------------------
-
-// convert to/from the string representation: format is
-// facename[;charset]
-
-bool wxNativeEncodingInfo::FromString(const wxString& s)
-{
- wxStringTokenizer tokenizer(s, _T(";"));
-
- facename = tokenizer.GetNextToken();
- if ( !facename )
- return FALSE;
-
- wxString tmp = tokenizer.GetNextToken();
- if ( !tmp )
- {
- // default charset (don't use DEFAULT_CHARSET though because of subtle
- // Windows 9x/NT differences in handling it)
- charset = 0;
- }
- else
- {
- if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
- {
- // should be a number!
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-wxString wxNativeEncodingInfo::ToString() const
-{
- wxString s(facename);
- if ( charset != 0 )
- {
- s << _T(';') << charset;
- }
-
- return s;
-}
-
-// ----------------------------------------------------------------------------
-// helper functions
-// ----------------------------------------------------------------------------
-
-bool wxGetNativeFontEncoding(wxFontEncoding encoding,
- wxNativeEncodingInfo *info)
-{
- wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
-
- if ( encoding == wxFONTENCODING_DEFAULT )
- {
- encoding = wxFont::GetDefaultEncoding();
- }
-
- info->encoding = encoding ;
-
- return TRUE;
-}
-
-bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
-{
- // basically we should be able to support every encoding via the OS
- return true ;
-}
-
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/frame.cpp
-// Purpose: wxFrame
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/frame.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/dcclient.h"
- #include "wx/menu.h"
- #include "wx/dialog.h"
- #include "wx/settings.h"
- #include "wx/toolbar.h"
- #include "wx/statusbr.h"
- #include "wx/menuitem.h"
-#endif // WX_PRECOMP
-
-#include "wx/mac/uma.h"
-
-extern wxWindowList wxModelessWindows;
-
-BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
- EVT_ACTIVATE(wxFrame::OnActivate)
- // EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
- EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
-// EVT_IDLE(wxFrame::OnIdle)
-// EVT_CLOSE(wxFrame::OnCloseWindow)
-END_EVENT_TABLE()
-
-IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
-
-#define WX_MAC_STATUSBAR_HEIGHT 15
-// ----------------------------------------------------------------------------
-// creation/destruction
-// ----------------------------------------------------------------------------
-
-void wxFrame::Init()
-{
- m_frameMenuBar = NULL;
-
-#if wxUSE_TOOLBAR
- m_frameToolBar = NULL ;
-#endif
- m_frameStatusBar = NULL;
- m_winLastFocused = NULL ;
-
- m_iconized = false;
-
-#if wxUSE_TOOLTIPS
- m_hwndToolTip = 0;
-#endif
-}
-
-wxPoint wxFrame::GetClientAreaOrigin() const
-{
- // on mac we are at position -1,-1 with the control
- wxPoint pt(0, 0);
-
-#if wxUSE_TOOLBAR
- if ( GetToolBar() )
- {
- int w, h;
- GetToolBar()->GetSize(& w, & h);
-
- if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
- {
- pt.x += w - 1;
- }
- else
- {
- pt.y += h - 1 ;
- }
- }
-#endif // wxUSE_TOOLBAR
-
- return pt;
-}
-
-bool wxFrame::Create(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
-
- if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
- return false;
-
- MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
-
- m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
- SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
-
- wxModelessWindows.Append(this);
-
- return true;
-}
-
-wxFrame::~wxFrame()
-{
- m_isBeingDeleted = true;
- DeleteAllBars();
-}
-
-
-bool wxFrame::Enable(bool enable)
-{
- if ( !wxWindow::Enable(enable) )
- return false;
-
- if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() )
- {
- int iMaxMenu = m_frameMenuBar->GetMenuCount();
- for ( int i = 0 ; i < iMaxMenu ; ++ i )
- {
- m_frameMenuBar->EnableTop( i , enable ) ;
- }
- }
-
- return true;
-}
-
-wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
- const wxString& name)
-{
- wxStatusBar *statusBar = NULL;
-
- statusBar = new wxStatusBar(this, id,
- style, name);
- statusBar->SetSize( 100 , 15 ) ;
- statusBar->SetFieldsCount(number);
- return statusBar;
-}
-
-void wxFrame::PositionStatusBar()
-{
- if (m_frameStatusBar )
- {
- int w, h;
- GetClientSize(&w, &h);
- int sw, sh;
- m_frameStatusBar->GetSize(&sw, &sh);
-
- // Since we wish the status bar to be directly under the client area,
- // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
- m_frameStatusBar->SetSize(0, h, w, sh);
- }
-}
-
-// Responds to colour changes, and passes event on to children.
-void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
-{
- SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
- Refresh();
-
- if ( m_frameStatusBar )
- {
- wxSysColourChangedEvent event2;
- event2.SetEventObject( m_frameStatusBar );
- m_frameStatusBar->ProcessEvent(event2);
- }
-
- // Propagate the event to the non-top-level children
- wxWindow::OnSysColourChanged(event);
-}
-
-
-// Default activation behaviour - set the focus for the first child
-// subwindow found.
-void wxFrame::OnActivate(wxActivateEvent& event)
-{
- if ( !event.GetActive() )
- {
- // remember the last focused child if it is our child
- m_winLastFocused = FindFocus();
-
- // so we NULL it out if it's a child from some other frame
- wxWindow *win = m_winLastFocused;
- while ( win )
- {
- if ( win->IsTopLevel() )
- {
- if ( win != this )
- {
- m_winLastFocused = NULL;
- }
-
- break;
- }
-
- win = win->GetParent();
- }
-
- event.Skip();
- }
- else
- {
- // restore focus to the child which was last focused
- wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
- : NULL;
- if ( !parent )
- {
- parent = this;
- }
-
- wxSetFocusToChild(parent, &m_winLastFocused);
-
- if ( m_frameMenuBar != NULL )
- {
- m_frameMenuBar->MacInstallMenuBar() ;
- }
- else if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame)))
- {
- // Trying toplevel frame menbar
- if( ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar() )
- ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar()->MacInstallMenuBar();
- }
- }
-}
-
-void wxFrame::DetachMenuBar()
-{
- if ( m_frameMenuBar )
- {
- m_frameMenuBar->UnsetInvokingWindow();
- }
-
- wxFrameBase::DetachMenuBar();
-}
-
-void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
-{
- wxFrameBase::AttachMenuBar(menuBar);
-
- if (m_frameMenuBar)
- {
- m_frameMenuBar->SetInvokingWindow( this );
- }
-}
-
-void wxFrame::DoGetClientSize(int *x, int *y) const
-{
- wxWindow::DoGetClientSize( x , y ) ;
-
-#if wxUSE_STATUSBAR
- if ( GetStatusBar() && y )
- {
- int statusX, statusY;
- GetStatusBar()->GetClientSize(&statusX, &statusY);
- *y -= statusY;
- }
-#endif // wxUSE_STATUSBAR
-
- wxPoint pt(GetClientAreaOrigin());
- if ( y )
- *y -= pt.y;
- if ( x )
- *x -= pt.x;
-}
-
-void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
-{
- int currentclientwidth , currentclientheight ;
- int currentwidth , currentheight ;
-
- GetClientSize( ¤tclientwidth , ¤tclientheight ) ;
- GetSize( ¤twidth , ¤theight ) ;
-
- // find the current client size
-
- // Find the difference between the entire window (title bar and all)
- // and the client area; add this to the new client size to move the
- // window
-
- DoSetSize( -1 , -1 , currentwidth + clientwidth - currentclientwidth ,
- currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ;
-}
-
-
-#if wxUSE_TOOLBAR
-wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
-{
- if ( wxFrameBase::CreateToolBar(style, id, name) )
- {
- PositionToolBar();
- }
-
- return m_frameToolBar;
-}
-
-void wxFrame::PositionToolBar()
-{
- int cw, ch;
-
- cw = m_width ;
- ch = m_height ;
-
- if ( GetStatusBar() )
- {
- int statusX, statusY;
- GetStatusBar()->GetClientSize(&statusX, &statusY);
- ch -= statusY;
- }
-
- if (GetToolBar())
- {
- int tw, th;
- GetToolBar()->GetSize(& tw, & th);
-
- if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
- {
- // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
- // means, pretend we don't have toolbar/status bar, so we
- // have the original client size.
- GetToolBar()->SetSize(-1, -1, tw, ch + 2 , wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE );
- }
- else
- {
- // Use the 'real' position
- GetToolBar()->SetSize(-1, -1, cw + 2, th, wxSIZE_NO_ADJUSTMENTS | wxSIZE_ALLOW_MINUS_ONE );
- }
- }
-}
-#endif
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/gauge.cpp
-// Purpose: wxGauge class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-
-#include "wx/wxprec.h"
-
-#if wxUSE_GAUGE
-
-#include "wx/gauge.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
-
-#include "wx/mac/uma.h"
-
-bool wxGauge::Create(wxWindow *parent, wxWindowID id,
- int range,
- const wxPoint& pos,
- const wxSize& s,
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxGaugeBase::Create(parent, id, range, pos, s, style, validator, name) )
- return false;
-
- wxSize size = s ;
- Rect bounds ;
- Str255 title ;
- m_rangeMax = range ;
- m_gaugePos = 0 ;
-
- if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord)
- {
- size = wxSize( 200 , 16 ) ;
- }
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style & 0xE0FFFFFF /* no borders on mac */ , validator , name , &bounds , title ) ;
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , range,
- kControlProgressBarProc , (long) this ) ;
-
- MacPostControlCreate() ;
-
- return true;
-}
-
-void wxGauge::SetShadowWidth(int w)
-{
-}
-
-void wxGauge::SetBezelFace(int w)
-{
-}
-
-void wxGauge::SetRange(int r)
-{
- m_rangeMax = r;
- ::SetControl32BitMaximum( (ControlHandle) m_macControl , m_rangeMax ) ;
-}
-
-void wxGauge::SetValue(int pos)
-{
- m_gaugePos = pos;
- ::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ;
-}
-
-void wxGauge::Pulse()
-{
- // need to use the animate() method of NSProgressIndicator Class here
-}
-
-int wxGauge::GetShadowWidth() const
-{
- return 0;
-}
-
-int wxGauge::GetBezelFace() const
-{
- return 0;
-}
-
-int wxGauge::GetRange() const
-{
- return m_rangeMax;
-}
-
-int wxGauge::GetValue() const
-{
- return m_gaugePos;
-}
-
-#endif // wxUSE_GAUGE
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/gdiobj.cpp
-// Purpose: wxGDIObject class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/gdiobj.h"
-
-#ifndef WX_PRECOMP
- #include "wx/gdicmn.h"
-#endif
-
-#include "wx/mac/private.h"
-
-class wxStockGDIMac: public wxStockGDI
-{
-public:
- wxStockGDIMac();
-
- virtual const wxFont* GetFont(Item item);
-
-private:
- typedef wxStockGDI super;
-};
-
-static wxStockGDIMac gs_wxStockGDIMac_instance;
-
-wxStockGDIMac::wxStockGDIMac()
-{
- // Override default instance
- ms_instance = this;
-}
-
-const wxFont* wxStockGDIMac::GetFont(Item item)
-{
- wxFont* font = wx_static_cast(wxFont*, ms_stockObject[item]);
- if (font == NULL)
- {
- Str255 fontName;
- SInt16 fontSize;
- Style fontStyle;
- switch (item)
- {
- case FONT_NORMAL:
- GetThemeFont(kThemeSystemFont, GetApplicationScript(), fontName, &fontSize, &fontStyle);
- font = new wxFont(fontSize, wxMODERN, wxNORMAL, wxNORMAL, false, wxMacMakeStringFromPascal(fontName));
- break;
- case FONT_SMALL:
- GetThemeFont(kThemeSmallSystemFont, GetApplicationScript(), fontName, &fontSize, &fontStyle);
- font = new wxFont(fontSize, wxSWISS, wxNORMAL, wxNORMAL, false, wxMacMakeStringFromPascal(fontName));
- break;
- default:
- font = wx_const_cast(wxFont*, super::GetFont(item));
- break;
- }
- ms_stockObject[item] = font;
- }
- return font;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/glcanvas.cpp
-// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#if defined(__BORLANDC__)
- #pragma hdrstop
-#endif
-
-#if wxUSE_GLCANVAS
-
-#include "wx/glcanvas.h"
-
-#ifndef WX_PRECOMP
- #include "wx/frame.h"
- #include "wx/log.h"
- #include "wx/settings.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-// DLL options compatibility check:
-#include "wx/build.h"
-WX_CHECK_BUILD_OPTIONS("wxGL")
-
-/*
-* GLContext implementation
-*/
-
-wxGLContext::wxGLContext(
- AGLPixelFormat fmt, wxGLCanvas *win,
- const wxPalette& palette,
- const wxGLContext *other /* for sharing display lists */
- )
-{
- m_window = win;
-
- m_drawable = (AGLDrawable) UMAGetWindowPort(MAC_WXHWND(win->MacGetRootWindow()));
-
- m_glContext = aglCreateContext(fmt, other ? other->m_glContext : NULL);
- wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGl context") );
-
- GLboolean b;
- b = aglSetDrawable(m_glContext, m_drawable);
- wxCHECK_RET( b, wxT("Couldn't bind OpenGl context") );
- aglEnable(m_glContext , AGL_BUFFER_RECT ) ;
- b = aglSetCurrentContext(m_glContext);
- wxCHECK_RET( b, wxT("Couldn't activate OpenGl context") );
-}
-
-wxGLContext::~wxGLContext()
-{
- if (m_glContext)
- {
- aglSetCurrentContext(NULL);
- aglDestroyContext(m_glContext);
- }
-}
-
-void wxGLContext::SwapBuffers()
-{
- if (m_glContext)
- {
- aglSwapBuffers(m_glContext);
- }
-}
-
-void wxGLContext::SetCurrent()
-{
- if (m_glContext)
- {
- aglSetCurrentContext(m_glContext);
- }
-}
-
-void wxGLContext::Update()
-{
- if (m_glContext)
- {
- aglUpdateContext(m_glContext);
- }
-}
-
-void wxGLContext::SetColour(const wxChar *colour)
-{
- wxColour col = wxTheColourDatabase->Find(colour);
- if (col.Ok())
- {
- float r = (float)(col.Red()/256.0);
- float g = (float)(col.Green()/256.0);
- float b = (float)(col.Blue()/256.0);
- glColor3f( r, g, b);
- }
-}
-
-
-/*
-* wxGLCanvas implementation
-*/
-
-IMPLEMENT_CLASS(wxGLCanvas, wxWindow)
-
-BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow)
- EVT_SIZE(wxGLCanvas::OnSize)
-END_EVENT_TABLE()
-
-wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id,
- const wxPoint& pos, const wxSize& size, long style, const wxString& name,
- int *attribList, const wxPalette& palette)
-{
- Create(parent, NULL, id, pos, size, style, name, attribList, palette);
-}
-
-wxGLCanvas::wxGLCanvas( wxWindow *parent,
- const wxGLContext *shared, wxWindowID id,
- const wxPoint& pos, const wxSize& size, long style, const wxString& name,
- int *attribList, const wxPalette& palette )
-{
- Create(parent, shared, id, pos, size, style, name, attribList, palette);
-}
-
-wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id,
- const wxPoint& pos, const wxSize& size, long style, const wxString& name,
- int *attribList, const wxPalette& palette )
-{
- Create(parent, shared ? shared->GetContext() : NULL, id, pos, size, style, name, attribList, palette);
-}
-
-wxGLCanvas::~wxGLCanvas()
-{
- if (m_glContext != NULL) {
- delete m_glContext;
- m_glContext = NULL;
- }
-}
-
-static AGLPixelFormat ChoosePixelFormat(const int *attribList)
-{
- GLint data[512];
- GLint defaultAttribs[] = { AGL_RGBA,
- AGL_DOUBLEBUFFER,
- AGL_MINIMUM_POLICY,
- AGL_DEPTH_SIZE, 1, // use largest available depth buffer
- AGL_RED_SIZE, 1,
- AGL_GREEN_SIZE, 1,
- AGL_BLUE_SIZE, 1,
- AGL_ALPHA_SIZE, 0,
- AGL_NONE };
- GLint *attribs;
- if (!attribList)
- {
- attribs = defaultAttribs;
- }
- else
- {
- int arg=0, p=0;
-
- data[p++] = AGL_MINIMUM_POLICY; // make _SIZE tags behave more like GLX
- while( (attribList[arg]!=0) && (p<512) )
- {
- switch( attribList[arg++] )
- {
- case WX_GL_RGBA: data[p++] = AGL_RGBA; break;
- case WX_GL_BUFFER_SIZE:
- data[p++]=AGL_BUFFER_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_LEVEL:
- data[p++]=AGL_LEVEL; data[p++]=attribList[arg++]; break;
- case WX_GL_DOUBLEBUFFER: data[p++] = AGL_DOUBLEBUFFER; break;
- case WX_GL_STEREO: data[p++] = AGL_STEREO; break;
- case WX_GL_AUX_BUFFERS:
- data[p++]=AGL_AUX_BUFFERS; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_RED:
- data[p++]=AGL_RED_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_GREEN:
- data[p++]=AGL_GREEN_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_BLUE:
- data[p++]=AGL_BLUE_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ALPHA:
- data[p++]=AGL_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_DEPTH_SIZE:
- data[p++]=AGL_DEPTH_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_STENCIL_SIZE:
- data[p++]=AGL_STENCIL_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ACCUM_RED:
- data[p++]=AGL_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ACCUM_GREEN:
- data[p++]=AGL_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ACCUM_BLUE:
- data[p++]=AGL_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ACCUM_ALPHA:
- data[p++]=AGL_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
- default:
- break;
- }
- }
- data[p] = 0;
-
- attribs = data;
- }
-
- return aglChoosePixelFormat(NULL, 0, attribs);
-}
-
-bool wxGLCanvas::Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id,
- const wxPoint& pos, const wxSize& size, long style, const wxString& name,
- int *attribList, const wxPalette& palette)
-{
- wxWindow::Create( parent, id, pos, size, style, name );
-
- AGLPixelFormat fmt = ChoosePixelFormat(attribList);
- wxCHECK_MSG( fmt, false, wxT("Couldn't create OpenGl pixel format") );
-
- m_glContext = new wxGLContext(fmt, this, palette, shared);
- m_macCanvasIsShown = true ;
- aglDestroyPixelFormat(fmt);
-
- return true;
-}
-
-void wxGLCanvas::SwapBuffers()
-{
- if (m_glContext)
- m_glContext->SwapBuffers();
-}
-
-void wxGLCanvas::UpdateContext()
-{
- if (m_glContext)
- m_glContext->Update();
-}
-
-void wxGLCanvas::SetViewport()
-{
- // viewport is initially set to entire port
- // adjust glViewport to just this window
- int x = 0 ;
- int y = 0 ;
-
- wxWindow* iter = this ;
- while( iter->GetParent() )
- {
- iter = iter->GetParent() ;
- }
-
- if ( iter && iter->IsTopLevel() )
- {
- MacClientToRootWindow( &x , &y ) ;
- int width, height;
- GetClientSize(& width, & height);
- Rect bounds ;
- GetWindowPortBounds( MAC_WXHWND(MacGetRootWindow()) , &bounds ) ;
- GLint parms[4] ;
- parms[0] = x ;
- parms[1] = bounds.bottom - bounds.top - ( y + height ) ;
- parms[2] = width ;
- parms[3] = height ;
-
- if ( !m_macCanvasIsShown )
- parms[0] += 20000 ;
- aglSetInteger( m_glContext->m_glContext , AGL_BUFFER_RECT , parms ) ;
- }
-}
-
-void wxGLCanvas::OnSize(wxSizeEvent& event)
-{
- MacUpdateView() ;
-}
-
-void wxGLCanvas::MacUpdateView()
-{
- if (m_glContext)
- {
- UpdateContext();
- m_glContext->SetCurrent();
- SetViewport();
- }
-}
-
-void wxGLCanvas::MacSuperChangedPosition()
-{
- MacUpdateView() ;
- wxWindow::MacSuperChangedPosition() ;
-}
-
-void wxGLCanvas::MacTopLevelWindowChangedPosition()
-{
- MacUpdateView() ;
- wxWindow::MacTopLevelWindowChangedPosition() ;
-}
-
-void wxGLCanvas::SetCurrent()
-{
- if (m_glContext)
- {
- m_glContext->SetCurrent();
- }
-}
-
-void wxGLCanvas::SetColour(const wxChar *colour)
-{
- if (m_glContext)
- m_glContext->SetColour(colour);
-}
-
-bool wxGLCanvas::Show(bool show)
-{
- if ( !wxWindow::Show( show ) )
- return false ;
-
- if ( !show )
- {
- if ( m_macCanvasIsShown )
- {
- m_macCanvasIsShown = false ;
- SetViewport() ;
- }
- }
- else
- {
- if ( MacIsReallyShown() && !m_macCanvasIsShown )
- {
- m_macCanvasIsShown = true ;
- SetViewport() ;
- }
- }
- return true ;
-}
-
-void wxGLCanvas::MacSuperShown( bool show )
-{
- if ( !show )
- {
- if ( m_macCanvasIsShown )
- {
- m_macCanvasIsShown = false ;
- SetViewport() ;
- }
- }
- else
- {
- if ( MacIsReallyShown() && !m_macCanvasIsShown )
- {
- m_macCanvasIsShown = true ;
- SetViewport() ;
- }
- }
-
- wxWindow::MacSuperShown( show ) ;
-}
-
-//---------------------------------------------------------------------------
-// wxGLApp
-//---------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxGLApp, wxApp)
-
-bool wxGLApp::InitGLVisual(int *attribList)
-{
- AGLPixelFormat fmt = ChoosePixelFormat(attribList);
- if (fmt != NULL) {
- aglDestroyPixelFormat(fmt);
- return true;
- } else
- return false;
-}
-
-wxGLApp::~wxGLApp(void)
-{
-}
-
-#endif // wxUSE_GLCANVAS
+++ /dev/null
-/* -------------------------------------------------------------------------
- * Project: GSocket (Generic Socket) for WX
- * Name: src/mac/classic/gsocket.c
- * Authors: Guilhem Lavaux,
- * Guillermo Rodriguez Garcia <guille@iies.es> (maintainer)
- * Stefan CSomor
- * Purpose: GSocket main mac file
- * CVSID: $Id$
- * -------------------------------------------------------------------------
- */
-
-/*
- * PLEASE don't put C++ comments here - this is a C source file.
- */
-
-#ifndef __GSOCKET_STANDALONE__
-#include "wx/platform.h"
-#endif
-
-#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
-
-#ifdef __DARWIN__
- #include <CoreServices/CoreServices.h>
-
- #ifndef FALSE
- #define FALSE 0
- #endif
- #ifndef TRUE
- #define TRUE 1
- #endif
-#else
- #include <MacHeaders.c>
- #define OTUNIXERRORS 1
- #include <OpenTransport.h>
- #include <OpenTransportProviders.h>
- #include <OpenTptInternet.h>
-#endif
-#if TARGET_CARBON && !defined(OTAssert)
- #define OTAssert( str , cond ) /* does not exists in Carbon */
-#endif
-
-#include <assert.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <ctype.h>
-#include <utime.h>
-
-/*
- * INADDR_BROADCAST is identical to INADDR_NONE which is not defined
- * on all unices. INADDR_BROADCAST should be fine to indicate an error.
- */
-#ifndef INADDR_BROADCAST
-#define INADDR_BROADCAST 0xFFFFFFFFUL
-#endif
-#ifndef INADDR_NONE
-#define INADDR_NONE INADDR_BROADCAST
-#endif
-#ifndef INADDR_ANY
-#define INADDR_ANY 0x0UL
-#endif
-#ifndef __GSOCKET_STANDALONE__
-
-#include "wx/mac/macnotfy.h"
-#include "wx/mac/gsockmac.h"
-#include "wx/gsocket.h"
-
-#else
-
-#include "gsockmac.h"
-#include "gsocket.h"
-
-#endif /* __GSOCKET_STANDALONE__ */
-
-void wxCYield() ;
-#ifdef __WXDEBUG__
-#define qDebug 1
-#define qDebug2 1
-extern pascal void OTDebugStr(const char* str);
-#endif
-#ifndef __DARWIN__
- #include <OTDebug.h>
-#endif
-InetSvcRef gInetSvcRef = 0 ;
-int gOTInited = 0 ;
-OTNotifyUPP gOTNotifierUPP = NULL ;
-
-OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode);
-
-/* Input: ep - endpointref on which to negotiate the option
- enableReuseIPMode - desired option setting - true/false
- Return: kOTNoError indicates that the option was successfully negotiated
- OSStatus is an error if < 0, otherwise, the status field is
- returned and is > 0.
-
- IMPORTANT NOTE: The endpoint is assumed to be in synchronous more, otherwise
- this code will not function as desired
-*/
-
-
-OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
-
-{
- UInt8 buf[kOTFourByteOptionSize]; // define buffer for fourByte Option size
- TOption* opt; // option ptr to make items easier to access
- TOptMgmt req;
- TOptMgmt ret;
- OSStatus err;
-
- if (!OTIsSynchronous(ep))
- {
- return (-1);
- }
- opt = (TOption*)buf; // set option ptr to buffer
- req.opt.buf = buf;
- req.opt.len = sizeof(buf);
- req.flags = T_NEGOTIATE; // negotiate for option
-
- ret.opt.buf = buf;
- ret.opt.maxlen = kOTFourByteOptionSize;
-
- opt->level = INET_IP; // dealing with an IP Level function
-#ifdef __DARWIN__
- opt->name = kIP_REUSEADDR;
-#else
- opt->name = IP_REUSEADDR;
-#endif
- opt->len = kOTFourByteOptionSize;
- opt->status = 0;
- *(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
-
- err = OTOptionManagement(ep, &req, &ret);
-
- // if no error then return the option status value
- if (err == kOTNoError)
- {
- if (opt->status != T_SUCCESS)
- err = opt->status;
- else
- err = kOTNoError;
- }
-
- return err;
-}
-
-
-pascal void OTInetEventHandler(void*s, OTEventCode event, OTResult, void *cookie) ;
-pascal void OTInetEventHandler(void*s, OTEventCode event, OTResult result, void *cookie)
-{
- int wakeUp = true ;
- GSocket* sock = (GSocket*) s ;
-
- if ( event == kOTSyncIdleEvent )
- {
- YieldToAnyThread() ;
- return ;
- }
-
- if ( s )
- {
- wxMacAddEvent( sock->m_mac_events , _GSocket_Internal_Proc , event , s , wakeUp ) ;
- }
-
- return;
-}
-
-static void SetDefaultEndpointModes(EndpointRef ep , void *data )
- // This routine sets the supplied endpoint into the default
- // mode used in this application. The specifics are:
- // blocking, synchronous, and using synch idle events with
- // the standard YieldingNotifier.
-{
- OSStatus junk = kOTNoError ;
- OTAssert ("SetDefaultEndpointModes:invalid ref", ep != kOTInvalidEndpointRef ) ;
- junk = OTSetAsynchronous(ep);
- OTAssert("SetDefaultEndpointModes: Could not set asynchronous", junk == noErr);
-/*
- junk = OTSetBlocking(ep);
- OTAssert("SetDefaultEndpointModes: Could not set blocking", junk == noErr);
- junk = OTSetSynchronous(ep);
- OTAssert("SetDefaultEndpointModes: Could not set synchronous", junk == noErr);
- junk = OTSetBlocking(ep);
- OTAssert("SetDefaultEndpointModes: Could not set blocking", junk == noErr);
-*/
- junk = OTInstallNotifier(ep, gOTNotifierUPP, data);
- OTAssert("SetDefaultEndpointModes: Could not install notifier", junk == noErr);
-/*
- junk = OTUseSyncIdleEvents(ep, true);
- OTAssert("SetDefaultEndpointModes: Could not use sync idle events", junk == noErr);
-*/
-}
-
-/* Global initialisers */
-
-void GSocket_SetGUIFunctions(struct GSocketGUIFunctionsTable *table)
-{
- // do nothing, wxMac doesn't have wxBase-GUI separation yet
-}
-
-int GSocket_Init()
-{
- return TRUE;
-}
-
-int GSocket_Verify_Inited() ;
-int GSocket_Verify_Inited()
-{
- OSStatus err ;
-#if TARGET_CARBON
- // Marc Newsam: added the clientcontext variable
- // however, documentation is unclear how this works
- OTClientContextPtr clientcontext;
-
- if ( gInetSvcRef )
- return TRUE ;
-
- InitOpenTransportInContext(kInitOTForApplicationMask, &clientcontext);
- gOTInited = 1 ;
- gInetSvcRef = OTOpenInternetServicesInContext(kDefaultInternetServicesPath,
- NULL, &err, clientcontext);
-#else
- if ( gInetSvcRef )
- return TRUE ;
-
- InitOpenTransport() ;
- gOTInited = 1 ;
- gInetSvcRef = OTOpenInternetServices(kDefaultInternetServicesPath, NULL, &err);
-#endif
- if ( gInetSvcRef == NULL || err != kOTNoError )
- {
- OTAssert("Could not open Inet Services", err == noErr);
- return FALSE ;
- }
- gOTNotifierUPP = NewOTNotifyUPP( OTInetEventHandler ) ;
- return TRUE ;
-}
-
-void GSocket_Cleanup()
-{
- if ( gOTInited != 0 )
- {
- if ( gInetSvcRef != NULL )
- OTCloseProvider( gInetSvcRef );
- #if TARGET_CARBON
- CloseOpenTransportInContext( NULL ) ;
- #else
- CloseOpenTransport() ;
- #endif
- if ( gOTNotifierUPP )
- DisposeOTNotifyUPP( gOTNotifierUPP ) ;
- }
-}
-
-/* Constructors / Destructors for GSocket */
-
-GSocket *GSocket_new()
-{
-
- int i;
- GSocket *socket;
-
- if ( GSocket_Verify_Inited() == FALSE )
- return NULL ;
-
- socket = (GSocket *)malloc(sizeof(GSocket));
-
- if (socket == NULL)
- return NULL;
-
- socket->m_endpoint = NULL ;
- for (i=0;i<GSOCK_MAX_EVENT;i++)
- {
- socket->m_cbacks[i] = NULL;
- }
- socket->m_detected = 0;
- socket->m_local = NULL;
- socket->m_peer = NULL;
- socket->m_error = GSOCK_NOERROR;
- socket->m_server = FALSE;
- socket->m_stream = TRUE;
- socket->m_non_blocking = FALSE;
- socket->m_timeout = 1*1000;
- /* 10 sec * 1000 millisec */
- socket->m_takesEvents = TRUE ;
- socket->m_mac_events = wxMacGetNotifierTable() ;
- return socket;
-}
-
-void GSocket_destroy(GSocket *socket)
-{
- assert(socket != NULL);
-
- /* Check that the socket is really shutdowned */
- if (socket->m_endpoint != kOTInvalidEndpointRef)
- GSocket_Shutdown(socket);
-
-
- /* Destroy private addresses */
- if (socket->m_local)
- GAddress_destroy(socket->m_local);
-
- if (socket->m_peer)
- GAddress_destroy(socket->m_peer);
-
- /* Destroy the socket itself */
- free(socket);
-}
-
-/* GSocket_Shutdown:
- * Disallow further read/write operations on this socket, close
- * the fd and disable all callbacks.
- */
-void GSocket_Shutdown(GSocket *socket)
-{
- OSStatus err ;
- int evt;
-
- assert(socket != NULL);
-
- /* If socket has been created, shutdown it */
- if (socket->m_endpoint != kOTInvalidEndpointRef )
- {
- err = OTSndOrderlyDisconnect( socket->m_endpoint ) ;
- if ( err != kOTNoError )
- {
-
- }
- err = OTRcvOrderlyDisconnect( socket->m_endpoint ) ;
- err = OTUnbind( socket->m_endpoint ) ;
- err = OTCloseProvider( socket->m_endpoint ) ;
- socket->m_endpoint = kOTInvalidEndpointRef ;
- }
-
- /* Disable GUI callbacks */
- for (evt = 0; evt < GSOCK_MAX_EVENT; evt++)
- socket->m_cbacks[evt] = NULL;
-
- socket->m_detected = 0;
- _GSocket_Disable_Events(socket);
- wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , socket ) ;
-}
-
-
-/* Address handling */
-
-/* GSocket_SetLocal:
- * GSocket_GetLocal:
- * GSocket_SetPeer:
- * GSocket_GetPeer:
- * Set or get the local or peer address for this socket. The 'set'
- * functions return GSOCK_NOERROR on success, an error code otherwise.
- * The 'get' functions return a pointer to a GAddress object on success,
- * or NULL otherwise, in which case they set the error code of the
- * corresponding GSocket.
- *
- * Error codes:
- * GSOCK_INVSOCK - the socket is not valid.
- * GSOCK_INVADDR - the address is not valid.
- */
-GSocketError GSocket_SetLocal(GSocket *socket, GAddress *address)
-{
- assert(socket != NULL);
-
- /* the socket must be initialized, or it must be a server */
- if ((socket->m_endpoint != kOTInvalidEndpointRef && !socket->m_server))
- {
- socket->m_error = GSOCK_INVSOCK;
- return GSOCK_INVSOCK;
- }
-
- /* check address */
- if (address == NULL || address->m_family == GSOCK_NOFAMILY)
- {
- socket->m_error = GSOCK_INVADDR;
- return GSOCK_INVADDR;
- }
-
- if (socket->m_local)
- GAddress_destroy(socket->m_local);
-
- socket->m_local = GAddress_copy(address);
-
- return GSOCK_NOERROR;
-}
-
-GSocketError GSocket_SetPeer(GSocket *socket, GAddress *address)
-{
- assert(socket != NULL);
-
- /* check address */
- if (address == NULL || address->m_family == GSOCK_NOFAMILY)
- {
- socket->m_error = GSOCK_INVADDR;
- return GSOCK_INVADDR;
- }
-
- if (socket->m_peer)
- GAddress_destroy(socket->m_peer);
-
- socket->m_peer = GAddress_copy(address);
-
- return GSOCK_NOERROR;
-}
-
-GAddress *GSocket_GetLocal(GSocket *socket)
-{
- GAddress *address = NULL ;
- GSocketError err;
- InetAddress loc ;
-
- assert(socket != NULL);
-
- /* try to get it from the m_local var first */
- if (socket->m_local)
- return GAddress_copy(socket->m_local);
-
- /* else, if the socket is initialized, try getsockname */
- if (socket->m_endpoint == kOTInvalidEndpointRef)
- {
- socket->m_error = GSOCK_INVSOCK;
- return NULL;
- }
-
-
-/* we do not support multihoming with this code at the moment
- OTGetProtAddress will have to be used then - but we don't have a handy
- method to use right now
-*/
- {
- InetInterfaceInfo info;
- OTInetGetInterfaceInfo(&info, kDefaultInetInterface);
- loc.fHost = info.fAddress ;
- loc.fPort = 0 ;
- loc.fAddressType = AF_INET ;
- }
-
- /* got a valid address from getsockname, create a GAddress object */
- address = GAddress_new();
- if (address == NULL)
- {
- socket->m_error = GSOCK_MEMERR;
- return NULL;
- }
-
- err = _GAddress_translate_from(address, &loc);
- if (err != GSOCK_NOERROR)
- {
- GAddress_destroy(address);
- socket->m_error = err;
- return NULL;
- }
-
- return address;
-}
-
-GAddress *GSocket_GetPeer(GSocket *socket)
-{
- assert(socket != NULL);
-
- /* try to get it from the m_peer var */
- if (socket->m_peer)
- return GAddress_copy(socket->m_peer);
-
- return NULL;
-}
-
-/* Server specific parts */
-
-/* GSocket_SetServer:
- * Sets up this socket as a server. The local address must have been
- * set with GSocket_SetLocal() before GSocket_SetServer() is called.
- * Returns GSOCK_NOERROR on success, one of the following otherwise:
- *
- * Error codes:
- * GSOCK_INVSOCK - the socket is in use.
- * GSOCK_INVADDR - the local address has not been set.
- * GSOCK_IOERR - low-level error.
- */
-GSocketError GSocket_SetServer(GSocket *sck)
-{
- assert(sck != NULL);
-
- /* must not be in use */
- if (sck->m_endpoint != kOTInvalidEndpointRef )
- {
- sck->m_error = GSOCK_INVSOCK;
- return GSOCK_INVSOCK;
- }
-
- /* the local addr must have been set */
- if (!sck->m_local)
- {
- sck->m_error = GSOCK_INVADDR;
- return GSOCK_INVADDR;
- }
-
- /* Initialize all fields */
- sck->m_stream = TRUE;
- sck->m_server = TRUE;
- sck->m_oriented = TRUE;
-
-// TODO
-#if 0
- /* Create the socket */
- sck->m_endpoint = socket(sck->m_local->m_realfamily, SOCK_STREAM, 0);
- socket_set_ref( sck->m_endpoint , (unsigned long) &gMacNetEvents , (unsigned long) sck ) ;
- if (sck->m_endpoint == kOTInvalidEndpointRef)
- {
- sck->m_error = GSOCK_IOERR;
- return GSOCK_IOERR;
- }
-
- ioctl(sck->m_endpoint, FIONBIO, &arg);
- _GSocket_Enable_Events(sck);
-
- /* Bind to the local address,
- * retrieve the actual address bound,
- * and listen up to 5 connections.
- */
- if ((bind(sck->m_endpoint, sck->m_local->m_addr, sck->m_local->m_len) != 0) ||
- (getsockname(sck->m_endpoint,
- sck->m_local->m_addr,
- (WX_SOCKLEN_T *) &sck->m_local->m_len) != 0) ||
- (listen(sck->m_endpoint, 5) != 0))
- {
- close(sck->m_endpoint);
- sck->m_endpoint = -1;
- sck->m_error = GSOCK_IOERR;
- return GSOCK_IOERR;
- }
-#endif
- return GSOCK_NOERROR;
-}
-
-/* GSocket_WaitConnection:
- * Waits for an incoming client connection. Returns a pointer to
- * a GSocket object, or NULL if there was an error, in which case
- * the last error field will be updated for the calling GSocket.
- *
- * Error codes (set in the calling GSocket)
- * GSOCK_INVSOCK - the socket is not valid or not a server.
- * GSOCK_TIMEDOUT - timeout, no incoming connections.
- * GSOCK_WOULDBLOCK - the call would block and the socket is nonblocking.
- * GSOCK_MEMERR - couldn't allocate memory.
- * GSOCK_IOERR - low-level error.
- */
-GSocket *GSocket_WaitConnection(GSocket *socket)
-{
- GSocket *connection = NULL ;
-
- assert(socket != NULL);
-
- /* Reenable CONNECTION events */
- socket->m_detected &= ~GSOCK_CONNECTION_FLAG;
-
- /* If the socket has already been created, we exit immediately */
- if (socket->m_endpoint == kOTInvalidEndpointRef || !socket->m_server)
- {
- socket->m_error = GSOCK_INVSOCK;
- return NULL;
- }
-
- /* Create a GSocket object for the new connection */
- connection = GSocket_new();
-
- if (!connection)
- {
- socket->m_error = GSOCK_MEMERR;
- return NULL;
- }
-
- /* Wait for a connection (with timeout) */
- if (_GSocket_Input_Timeout(socket) == GSOCK_TIMEDOUT)
- {
- GSocket_destroy(connection);
- /* socket->m_error set by _GSocket_Input_Timeout */
- return NULL;
- }
-
-// TODO
-#if 0
- connection->m_endpoint = accept(socket->m_endpoint, &from, (WX_SOCKLEN_T *) &fromlen);
-#endif
-
- if (connection->m_endpoint == kOTInvalidEndpointRef )
- {
- if (errno == EWOULDBLOCK)
- socket->m_error = GSOCK_WOULDBLOCK;
- else
- socket->m_error = GSOCK_IOERR;
-
- GSocket_destroy(connection);
- return NULL;
- }
-
- /* Initialize all fields */
- connection->m_server = FALSE;
- connection->m_stream = TRUE;
- connection->m_oriented = TRUE;
-
- /* Setup the peer address field */
- connection->m_peer = GAddress_new();
- if (!connection->m_peer)
- {
- GSocket_destroy(connection);
- socket->m_error = GSOCK_MEMERR;
- return NULL;
- }
- // TODO
- #if 0
- err = _GAddress_translate_from(connection->m_peer, &from, fromlen);
- if (err != GSOCK_NOERROR)
- {
- GAddress_destroy(connection->m_peer);
- GSocket_destroy(connection);
- socket->m_error = err;
- return NULL;
- }
-
- ioctl(connection->m_endpoint, FIONBIO, &arg);
-#endif
- _GSocket_Enable_Events(connection);
-
- return connection;
-}
-
-/* Datagram sockets */
-
-/* GSocket_SetNonOriented:
- * Sets up this socket as a non-connection oriented (datagram) socket.
- * Before using this function, the local address must have been set
- * with GSocket_SetLocal(), or the call will fail. Returns GSOCK_NOERROR
- * on success, or one of the following otherwise.
- *
- * Error codes:
- * GSOCK_INVSOCK - the socket is in use.
- * GSOCK_INVADDR - the local address has not been set.
- * GSOCK_IOERR - low-level error.
- */
-GSocketError GSocket_SetNonOriented(GSocket *sck)
-{
- assert(sck != NULL);
-
- if (sck->m_endpoint != kOTInvalidEndpointRef )
- {
- sck->m_error = GSOCK_INVSOCK;
- return GSOCK_INVSOCK;
- }
-
- if (!sck->m_local)
- {
- sck->m_error = GSOCK_INVADDR;
- return GSOCK_INVADDR;
- }
-
- /* Initialize all fields */
- sck->m_stream = FALSE;
- sck->m_server = FALSE;
- sck->m_oriented = FALSE;
-
- /* Create the socket */
-
-// TODO
-#if 0
- sck->m_endpoint = socket(sck->m_local->m_realfamily, SOCK_DGRAM, 0);
- socket_set_ref( sck->m_endpoint , (unsigned long) &gMacNetEvents , (unsigned long) sck ) ;
-#endif
- if (sck->m_endpoint == kOTInvalidEndpointRef )
- {
- sck->m_error = GSOCK_IOERR;
- return GSOCK_IOERR;
- }
-
-// TODO
-#if 0
- ioctl(sck->m_endpoint, FIONBIO, &arg);
-#endif
- _GSocket_Enable_Events(sck);
-
- /* Bind to the local address,
- * and retrieve the actual address bound.
- */
-// TODO
-#if 0
- if ((bind(sck->m_endpoint, sck->m_local->m_addr, sck->m_local->m_len) != 0) ||
- (getsockname(sck->m_endpoint,
- sck->m_local->m_addr,
- (WX_SOCKLEN_T *) &sck->m_local->m_len) != 0))
- {
- close(sck->m_endpoint);
- sck->m_endpoint = -1;
- sck->m_error = GSOCK_IOERR;
- return GSOCK_IOERR;
- }
-#endif
- return GSOCK_NOERROR;
-}
-
-/* Client specific parts */
-
-/* GSocket_Connect:
- * For stream (connection oriented) sockets, GSocket_Connect() tries
- * to establish a client connection to a server using the peer address
- * as established with GSocket_SetPeer(). Returns GSOCK_NOERROR if the
- * connection has been successfully established, or one of the error
- * codes listed below. Note that for nonblocking sockets, a return
- * value of GSOCK_WOULDBLOCK doesn't mean a failure. The connection
- * request can be completed later; you should use GSocket_Select()
- * to poll for GSOCK_CONNECTION | GSOCK_LOST, or wait for the
- * corresponding asynchronous events.
- *
- * For datagram (non connection oriented) sockets, GSocket_Connect()
- * just sets the peer address established with GSocket_SetPeer() as
- * default destination.
- *
- * Error codes:
- * GSOCK_INVSOCK - the socket is in use or not valid.
- * GSOCK_INVADDR - the peer address has not been established.
- * GSOCK_TIMEDOUT - timeout, the connection failed.
- * GSOCK_WOULDBLOCK - connection in progress (nonblocking sockets only)
- * GSOCK_MEMERR - couldn't allocate memory.
- * GSOCK_IOERR - low-level error.
- */
-GSocketError GSocket_Connect(GSocket *sck, GSocketStream stream)
-{
- InetAddress addr ;
- TEndpointInfo info;
- OSStatus err = kOTNoError;
- TCall peer ;
-
- assert(sck != NULL);
-
- /* Enable CONNECTION events (needed for nonblocking connections) */
- sck->m_detected &= ~GSOCK_CONNECTION_FLAG;
-
- if (sck->m_endpoint != kOTInvalidEndpointRef )
- {
- sck->m_error = GSOCK_INVSOCK;
- return GSOCK_INVSOCK;
- }
-
- if (!sck->m_peer)
- {
- sck->m_error = GSOCK_INVADDR;
- return GSOCK_INVADDR;
- }
-
- /* Streamed or dgram socket? */
- sck->m_stream = (stream == GSOCK_STREAMED);
- sck->m_oriented = TRUE;
- sck->m_server = FALSE;
-
- /* Create the socket */
-#if TARGET_CARBON
- sck->m_endpoint =
- OTOpenEndpointInContext( OTCreateConfiguration( kTCPName) , 0 , &info , &err , NULL ) ;
-#else
- sck->m_endpoint =
- OTOpenEndpoint( OTCreateConfiguration( kTCPName) , 0 , &info , &err ) ;
-#endif
- if ( sck->m_endpoint == kOTInvalidEndpointRef || err != kOTNoError )
- {
- sck->m_endpoint = kOTInvalidEndpointRef ;
- sck->m_error = GSOCK_IOERR;
- return GSOCK_IOERR;
- }
- err = OTBind( sck->m_endpoint , nil , nil ) ;
- if ( err != kOTNoError )
- {
- return GSOCK_IOERR;
- }
- SetDefaultEndpointModes( sck->m_endpoint , sck ) ;
-// TODO
-#if 0
- ioctl(sck->m_endpoint, FIONBIO, &arg);
-#endif
- _GSocket_Enable_Events(sck);
-
- _GAddress_translate_to( sck->m_peer , &addr ) ;
- memset( &peer , 0 , sizeof( TCall ) ) ;
- peer.addr.len = sizeof( InetAddress ) ;
- peer.addr.buf = (unsigned char*) &addr ;
- err = OTConnect( sck->m_endpoint , &peer , nil ) ;
- if ( err != noErr )
- {
- /* If connect failed with EINPROGRESS and the GSocket object
- * is in blocking mode, we select() for the specified timeout
- * checking for writability to see if the connection request
- * completes.
- */
-
- if ((err == kOTNoDataErr ) && (!sck->m_non_blocking))
- {
- if (_GSocket_Output_Timeout(sck) == GSOCK_TIMEDOUT)
- {
- OTSndOrderlyDisconnect( sck->m_endpoint ) ;
- sck->m_endpoint = kOTInvalidEndpointRef ;
- /* sck->m_error is set in _GSocket_Output_Timeout */
- return GSOCK_TIMEDOUT;
- }
- else
- {
-/*
- int error;
- WX_SOCKLEN_T len = sizeof(error);
-
- getsockopt(sck->m_endpoint, SOL_SOCKET, SO_ERROR, (void*) &error, &len);
-
- if (!error)
-*/
- return GSOCK_NOERROR;
- }
- }
-
- /* If connect failed with EINPROGRESS and the GSocket object
- * is set to nonblocking, we set m_error to GSOCK_WOULDBLOCK
- * (and return GSOCK_WOULDBLOCK) but we don't close the socket;
- * this way if the connection completes, a GSOCK_CONNECTION
- * event will be generated, if enabled.
- */
- if ((err == kOTNoDataErr) && (sck->m_non_blocking))
- {
- sck->m_error = GSOCK_WOULDBLOCK;
- return GSOCK_WOULDBLOCK;
- }
-
- /* If connect failed with an error other than EINPROGRESS,
- * then the call to GSocket_Connect has failed.
- */
- OTSndOrderlyDisconnect( sck->m_endpoint ) ;
-
- sck->m_endpoint = kOTInvalidEndpointRef ;
- sck->m_error = GSOCK_IOERR;
- return GSOCK_IOERR;
- }
-// OTInetEventHandler(sck, T_CONNECT , kOTNoError , NULL ) ;
- return GSOCK_NOERROR;
-}
-
-/* Generic IO */
-
-/* Like recv(), send(), ... */
-int GSocket_Read(GSocket *socket, char *buffer, int size)
-{
- int ret = 0 ;
-
- assert(socket != NULL);
-
- /* Reenable INPUT events */
- socket->m_detected &= ~GSOCK_INPUT_FLAG;
-
- if (socket->m_endpoint == kOTInvalidEndpointRef || socket->m_server)
- {
- socket->m_error = GSOCK_INVSOCK;
- return -1;
- }
-
- /* If the socket is blocking, wait for data (with a timeout) */
- if (_GSocket_Input_Timeout(socket) == GSOCK_TIMEDOUT)
- return -1;
-
- /* Read the data */
- if (socket->m_stream)
- ret = _GSocket_Recv_Stream(socket, buffer, size);
- else
- ret = _GSocket_Recv_Dgram(socket, buffer, size);
-
- if (ret == -1)
- {
- if (errno == EWOULDBLOCK)
- socket->m_error = GSOCK_WOULDBLOCK;
- else
- socket->m_error = GSOCK_IOERR;
- }
-
- return ret;
-}
-
-int GSocket_Write(GSocket *socket, const char *buffer, int size)
-{
- int ret;
-
- assert(socket != NULL);
-
- if (socket->m_endpoint == kOTInvalidEndpointRef || socket->m_server)
- {
- socket->m_error = GSOCK_INVSOCK;
- return -1;
- }
-
- /* If the socket is blocking, wait for writability (with a timeout) */
- if (_GSocket_Output_Timeout(socket) == GSOCK_TIMEDOUT)
- return -1;
-
- /* Write the data */
- if (socket->m_stream)
- ret = _GSocket_Send_Stream(socket, buffer, size);
- else
- ret = _GSocket_Send_Dgram(socket, buffer, size);
-
- if (ret == -1)
- {
- if (errno == EWOULDBLOCK)
- socket->m_error = GSOCK_WOULDBLOCK;
- else
- socket->m_error = GSOCK_IOERR;
-
- /* Only reenable OUTPUT events after an error (just like WSAAsyncSelect
- * in MSW). Once the first OUTPUT event is received, users can assume
- * that the socket is writable until a read operation fails. Only then
- * will further OUTPUT events be posted.
- */
- socket->m_detected &= ~GSOCK_OUTPUT_FLAG;
- return -1;
- }
-
- return ret;
-}
-
-/* GSocket_Select:
- * Polls the socket to determine its status. This function will
- * check for the events specified in the 'flags' parameter, and
- * it will return a mask indicating which operations can be
- * performed. This function won't block, regardless of the
- * mode (blocking | nonblocking) of the socket.
- */
-GSocketEventFlags GSocket_Select(GSocket *socket, GSocketEventFlags flags)
-{
- assert(socket != NULL);
- wxMacProcessNotifierEvents() ;
- /*
- state = OTGetEndpointState(socket->m_endpoint);
-
- if ( ( flags & GSOCK_INPUT_FLAG ) && ! ( socket->m_detected & GSOCK_INPUT_FLAG ) )
- {
- size_t sz = 0 ;
- OTCountDataBytes( socket->m_endpoint , &sz ) ;
- if ( state == T_INCON || sz > 0 )
- {
- socket->m_detected |= GSOCK_INPUT_FLAG ;
- (socket->m_cbacks[GSOCK_INPUT])(socket, GSOCK_INPUT, socket->m_data[GSOCK_INPUT]);
- }
- }
- if ( ( flags & GSOCK_INPUT_FLAG ) && ! ( socket->m_detected & GSOCK_OUTPUT_FLAG ) )
- {
- if ( state == T_DATAXFER || state == T_INREL )
- {
- socket->m_detected |=GSOCK_OUTPUT_FLAG ;
- (socket->m_cbacks[GSOCK_OUTPUT])(socket, GSOCK_OUTPUT, socket->m_data[GSOCK_OUTPUT]);
- }
- }
- */
- return ( flags & socket->m_detected ) ;
-}
-
-/* Flags */
-
-/* GSocket_SetNonBlocking:
- * Sets the socket to non-blocking mode. All IO calls will return
- * immediately.
- */
-void GSocket_SetNonBlocking(GSocket *socket, int non_block)
-{
- assert(socket != NULL);
-
- socket->m_non_blocking = non_block;
-}
-
-/* GSocket_SetTimeout:
- * Sets the timeout for blocking calls. Time is expressed in
- * milliseconds.
- */
-void GSocket_SetTimeout(GSocket *socket, unsigned long millisec)
-{
- assert(socket != NULL);
-
-// this is usually set too high and we have not yet been able to detect a closed
-// stream, thus we leave the 10 sec timeout
-// socket->m_timeout = millisec;
-}
-
-/* GSocket_GetError:
- * Returns the last error which occurred for this socket. Note that successful
- * operations do not clear this back to GSOCK_NOERROR, so use it only
- * after an error.
- */
-GSocketError GSocket_GetError(GSocket *socket)
-{
- assert(socket != NULL);
-
- return socket->m_error;
-}
-
-/* Callbacks */
-
-/* GSOCK_INPUT:
- * There is data to be read in the input buffer. If, after a read
- * operation, there is still data available, the callback function will
- * be called again.
- * GSOCK_OUTPUT:
- * The socket is available for writing. That is, the next write call
- * won't block. This event is generated only once, when the connection is
- * first established, and then only if a call failed with GSOCK_WOULDBLOCK,
- * when the output buffer empties again. This means that the app should
- * assume that it can write since the first OUTPUT event, and no more
- * OUTPUT events will be generated unless an error occurs.
- * GSOCK_CONNECTION:
- * Connection successfully established, for client sockets, or incoming
- * client connection, for server sockets. Wait for this event (also watch
- * out for GSOCK_LOST) after you issue a nonblocking GSocket_Connect() call.
- * GSOCK_LOST:
- * The connection is lost (or a connection request failed); this could
- * be due to a failure, or due to the peer closing it gracefully.
- */
-
-/* GSocket_SetCallback:
- * Enables the callbacks specified by 'flags'. Note that 'flags'
- * may be a combination of flags OR'ed toghether, so the same
- * callback function can be made to accept different events.
- * The callback function must have the following prototype:
- *
- * void function(GSocket *socket, GSocketEvent event, char *cdata)
- */
-void GSocket_SetCallback(GSocket *socket, GSocketEventFlags flags,
- GSocketCallback callback, char *cdata)
-{
- int count;
-
- assert(socket != NULL);
-
- for (count = 0; count < GSOCK_MAX_EVENT; count++)
- {
- if ((flags & (1 << count)) != 0)
- {
- socket->m_cbacks[count] = callback;
- socket->m_data[count] = cdata;
- }
- }
-}
-
-/* GSocket_UnsetCallback:
- * Disables all callbacks specified by 'flags', which may be a
- * combination of flags OR'ed toghether.
- */
-void GSocket_UnsetCallback(GSocket *socket, GSocketEventFlags flags)
-{
- int count;
-
- assert(socket != NULL);
-
- for (count = 0; count < GSOCK_MAX_EVENT; count++)
- {
- if ((flags & (1 << count)) != 0)
- {
- socket->m_cbacks[count] = NULL;
- socket->m_data[count] = NULL;
- }
- }
-}
-
-
-#define CALL_CALLBACK(socket, event) { \
- _GSocket_Disable(socket, event); \
- if (socket->m_cbacks[event]) \
- socket->m_cbacks[event](socket, event, socket->m_data[event]); \
-}
-
-int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size)
-{
- OTFlags flags ;
- OTResult res ;
- OTByteCount sz = 0 ;
-
- OTCountDataBytes( socket->m_endpoint , &sz ) ;
- if ( size > (int)sz )
- size = sz ;
- res = OTRcv( socket->m_endpoint , buffer , size , &flags ) ;
- if ( res < 0 )
- {
- return -1 ;
- }
-
- // we simulate another read event if there are still bytes
- if ( socket->m_takesEvents )
- {
- OTByteCount sz = 0 ;
- OTCountDataBytes( socket->m_endpoint , &sz ) ;
- if ( sz > 0 )
- {
- socket->m_detected |= GSOCK_INPUT_FLAG ;
- (socket->m_cbacks[GSOCK_INPUT])(socket, GSOCK_INPUT, socket->m_data[GSOCK_INPUT]);
- }
- }
- return res ;
-}
-
-int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size)
-{
-// TODO
- int ret = -1;
-#if 0
- struct sockaddr from;
- WX_SOCKLEN_T fromlen = sizeof(from);
- GSocketError err;
-
- fromlen = sizeof(from);
-
- ret = recvfrom(socket->m_endpoint, buffer, size, 0, &from, (WX_SOCKLEN_T *) &fromlen);
-
- if (ret == -1)
- return -1;
-
- /* Translate a system address into a GSocket address */
- if (!socket->m_peer)
- {
- socket->m_peer = GAddress_new();
- if (!socket->m_peer)
- {
- socket->m_error = GSOCK_MEMERR;
- return -1;
- }
- }
- err = _GAddress_translate_from(socket->m_peer, &from, fromlen);
- if (err != GSOCK_NOERROR)
- {
- GAddress_destroy(socket->m_peer);
- socket->m_peer = NULL;
- socket->m_error = err;
- return -1;
- }
-#endif
- return ret;
-}
-
-int _GSocket_Send_Stream(GSocket *socket, const char *buffer, int size)
-{
- OTFlags flags = 0 ;
- OTResult res ;
-
- res = OTSnd( socket->m_endpoint , (void*) buffer , size , flags ) ;
- return res ;
-}
-
-int _GSocket_Send_Dgram(GSocket *socket, const char *buffer, int size)
-{
- int ret = -1 ;
-// TODO
-#if 0
- struct sockaddr *addr;
- int len ;
- GSocketError err;
-
- if (!socket->m_peer)
- {
- socket->m_error = GSOCK_INVADDR;
- return -1;
- }
-
- err = _GAddress_translate_to(socket->m_peer, &addr, &len);
- if (err != GSOCK_NOERROR)
- {
- socket->m_error = err;
- return -1;
- }
-
- ret = sendto(socket->m_endpoint, buffer, size, 0, addr, len);
-
- /* Frees memory allocated from _GAddress_translate_to */
- free(addr);
-#endif
- return ret;
-}
-
-
-/*
- * -------------------------------------------------------------------------
- * GAddress
- * -------------------------------------------------------------------------
- */
-
-/* CHECK_ADDRESS verifies that the current family is either GSOCK_NOFAMILY
- * or GSOCK_*family*, and if it is GSOCK_NOFAMILY, it initalizes address
- * to be a GSOCK_*family*. In other cases, it returns GSOCK_INVADDR.
- */
-#define CHECK_ADDRESS(address, family, retval) \
-{ \
- if (address->m_family == GSOCK_NOFAMILY) \
- if (_GAddress_Init_##family(address) != GSOCK_NOERROR) \
- return address->m_error; \
- if (address->m_family != GSOCK_##family) \
- { \
- address->m_error = GSOCK_INVADDR; \
- return retval; \
- } \
-}
-
-GAddress *GAddress_new()
-{
- GAddress *address;
-
- if ((address = (GAddress *) malloc(sizeof(GAddress))) == NULL)
- return NULL;
-
- address->m_family = GSOCK_NOFAMILY;
- address->m_host = INADDR_NONE ;
- address->m_port = 0 ;
-
- return address;
-}
-
-GAddress *GAddress_copy(GAddress *address)
-{
- GAddress *addr2;
-
- assert(address != NULL);
-
- if ((addr2 = (GAddress *) malloc(sizeof(GAddress))) == NULL)
- return NULL;
-
- memcpy(addr2, address, sizeof(GAddress));
- return addr2;
-}
-
-void GAddress_destroy(GAddress *address)
-{
- assert(address != NULL);
-
- free(address);
-}
-
-void GAddress_SetFamily(GAddress *address, GAddressType type)
-{
- assert(address != NULL);
-
- address->m_family = type;
-}
-
-GAddressType GAddress_GetFamily(GAddress *address)
-{
- assert(address != NULL);
-
- return address->m_family;
-}
-
-GSocketError _GAddress_translate_from(GAddress *address,
- InetAddress *addr)
-{
- switch (addr->fAddressType)
- {
- case AF_INET:
- address->m_family = GSOCK_INET;
- break;
-#ifdef AF_INET6
- case AF_INET6:
- address->m_family = GSOCK_INET6;
- break;
-#endif
- default:
- {
- address->m_error = GSOCK_INVOP;
- return GSOCK_INVOP;
- }
- }
- address->m_host = addr->fHost ;
- address->m_port = addr->fPort ;
- return GSOCK_NOERROR;
-}
-
-GSocketError _GAddress_translate_to(GAddress *address,
- InetAddress *addr)
-{
- if ( GSocket_Verify_Inited() == FALSE )
- return GSOCK_IOERR ;
- memset(addr, 0 , sizeof(struct InetAddress));
- OTInitInetAddress( addr , address->m_port , address->m_host ) ;
- return GSOCK_NOERROR;
-}
-
-/*
- * -------------------------------------------------------------------------
- * Internet address family
- * -------------------------------------------------------------------------
- */
-
-GSocketError _GAddress_Init_INET(GAddress *address)
-{
- address->m_family = GSOCK_INET;
- address->m_host = kOTAnyInetAddress ;
-
- return GSOCK_NOERROR;
-}
-
-GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
-{
- InetHostInfo hinfo ;
- OSStatus ret ;
-
- if ( GSocket_Verify_Inited() == FALSE )
- return GSOCK_IOERR ;
-
- assert(address != NULL);
-
- CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
- ret = OTInetStringToAddress( gInetSvcRef , (char*) hostname , &hinfo ) ;
- if ( ret != kOTNoError )
- {
- address->m_host = INADDR_NONE ;
- address->m_error = GSOCK_NOHOST;
- return GSOCK_NOHOST;
- }
- address->m_host = hinfo.addrs[0] ;
- return GSOCK_NOERROR;
-}
-
-GSocketError GAddress_INET_SetAnyAddress(GAddress *address)
-{
- return GAddress_INET_SetHostAddress(address, INADDR_ANY);
-}
-
-GSocketError GAddress_INET_SetHostAddress(GAddress *address,
- unsigned long hostaddr)
-{
- assert(address != NULL);
-
- CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
-
- address->m_host = hostaddr ;
-
- return GSOCK_NOERROR;
-}
-
-struct service_entry
-{
- char * name ;
- unsigned short port ;
- char * protocol ;
-} ;
-typedef struct service_entry service_entry ;
-
-service_entry gServices[] =
-{
- { "http" , 80 , "tcp" }
-} ;
-
-GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
- const char *protocol)
-{
- size_t i ;
-
- assert(address != NULL);
- CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
-
- if (!port)
- {
- address->m_error = GSOCK_INVPORT;
- return GSOCK_INVPORT;
- }
- for ( i = 0 ; i < sizeof( gServices) / sizeof( service_entry ) ; ++i )
- {
- if ( strcmp( port , gServices[i].name ) == 0 )
- {
- if ( protocol == NULL || strcmp( protocol , gServices[i].protocol ) )
- {
- address->m_port = gServices[i].port ;
- return GSOCK_NOERROR;
- }
- }
- }
-
- if (isdigit(port[0]))
- {
- address->m_port = atoi(port);
- return GSOCK_NOERROR;
- }
-
- address->m_error = GSOCK_INVPORT;
- return GSOCK_INVPORT;
-}
-
-GSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port)
-{
- assert(address != NULL);
- CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
- address->m_port = port ;
-
- return GSOCK_NOERROR;
-}
-
-GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t sbuf)
-{
- InetDomainName name ;
- if ( GSocket_Verify_Inited() == FALSE )
- return GSOCK_IOERR ;
-
- assert(address != NULL);
- CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
-
- OTInetAddressToName( gInetSvcRef , address->m_host , name ) ;
- strncpy( hostname , name , sbuf ) ;
- return GSOCK_NOERROR;
-}
-
-unsigned long GAddress_INET_GetHostAddress(GAddress *address)
-{
- assert(address != NULL);
- CHECK_ADDRESS(address, INET, 0);
-
- return address->m_host;
-}
-
-unsigned short GAddress_INET_GetPort(GAddress *address)
-{
- assert(address != NULL);
- CHECK_ADDRESS(address, INET, 0);
-
- return address->m_port;
-}
-
-void _GSocket_Enable_Events(GSocket *socket)
-{
- if ( socket->m_takesEvents )
- return ;
-
- {
- OTResult state ;
- socket->m_takesEvents = TRUE ;
- state = OTGetEndpointState(socket->m_endpoint);
-
- {
- OTByteCount sz = 0 ;
- OTCountDataBytes( socket->m_endpoint , &sz ) ;
- if ( state == T_INCON || sz > 0 )
- {
- socket->m_detected |= GSOCK_INPUT_FLAG ;
- (socket->m_cbacks[GSOCK_INPUT])(socket, GSOCK_INPUT, socket->m_data[GSOCK_INPUT]);
- }
- }
- {
- if ( state == T_DATAXFER || state == T_INREL )
- {
- socket->m_detected |=GSOCK_OUTPUT_FLAG ;
- (socket->m_cbacks[GSOCK_OUTPUT])(socket, GSOCK_OUTPUT, socket->m_data[GSOCK_OUTPUT]);
- }
- }
- }
-}
-
-void _GSocket_Disable_Events(GSocket *socket)
-{
- socket->m_takesEvents = FALSE ;
-}
-
-/* _GSocket_Input_Timeout:
- * For blocking sockets, wait until data is available or
- * until timeout ellapses.
- */
-GSocketError _GSocket_Input_Timeout(GSocket *socket)
-{
- if ( !socket->m_non_blocking )
- {
- UnsignedWide now , start ;
- short formerTakesEvents = socket->m_takesEvents ;
- Microseconds(&start);
- now = start ;
- socket->m_takesEvents = FALSE ;
-
- while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
- {
- OTResult state ;
- OTByteCount sz = 0 ;
- state = OTGetEndpointState(socket->m_endpoint);
-
- OTCountDataBytes( socket->m_endpoint , &sz ) ;
- if ( state == T_INCON || sz > 0 )
- {
- socket->m_takesEvents = formerTakesEvents ;
- return GSOCK_NOERROR;
- }
- Microseconds(&now);
- }
- socket->m_takesEvents = formerTakesEvents ;
- socket->m_error = GSOCK_TIMEDOUT;
- return GSOCK_TIMEDOUT;
- }
- return GSOCK_NOERROR;
-}
-
-/* _GSocket_Output_Timeout:
- * For blocking sockets, wait until data can be sent without
- * blocking or until timeout ellapses.
- */
-GSocketError _GSocket_Output_Timeout(GSocket *socket)
-{
- if ( !socket->m_non_blocking )
- {
- UnsignedWide now , start ;
- short formerTakesEvents = socket->m_takesEvents ;
- Microseconds(&start);
- now = start ;
- socket->m_takesEvents = FALSE ;
-
- while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < socket->m_timeout * 1000.0 )
- {
- OTResult state ;
- state = OTGetEndpointState(socket->m_endpoint);
-
- if ( state == T_DATAXFER || state == T_INREL )
- {
- socket->m_takesEvents = formerTakesEvents ;
- return GSOCK_NOERROR;
- }
- Microseconds(&now);
- }
- socket->m_takesEvents = formerTakesEvents ;
- socket->m_error = GSOCK_TIMEDOUT;
- return GSOCK_TIMEDOUT;
- }
- return GSOCK_NOERROR;
-}
-
-/* GSOCK_INPUT:
- * There is data to be read in the input buffer. If, after a read
- * operation, there is still data available, the callback function will
- * be called again.
- * GSOCK_OUTPUT:
- * The socket is available for writing. That is, the next write call
- * won't block. This event is generated only once, when the connection is
- * first established, and then only if a call failed with GSOCK_WOULDBLOCK,
- * when the output buffer empties again. This means that the app should
- * assume that it can write since the first OUTPUT event, and no more
- * OUTPUT events will be generated unless an error occurs.
- * GSOCK_CONNECTION:
- * Connection successfully established, for client sockets, or incoming
- * client connection, for server sockets. Wait for this event (also watch
- * out for GSOCK_LOST) after you issue a nonblocking GSocket_Connect() call.
- * GSOCK_LOST:
- * The connection is lost (or a connection request failed); this could
- * be due to a failure, or due to the peer closing it gracefully.
- */
-
-void _GSocket_Internal_Proc(unsigned long e , void* d )
-{
-
- GSocket * socket = (GSocket*) d ;
- OTEventCode ev = (OTEventCode) e ;
- GSocketEvent event;
- GSocketEvent event2;
- GSocketCallback cback;
- char *data;
- GSocketCallback cback2;
- char *data2;
-
- if ( !socket )
- return ;
- event = GSOCK_MAX_EVENT ;
- event2 = GSOCK_MAX_EVENT ;
- cback = NULL;
- data = NULL;
- cback2 = NULL;
- data2 = NULL;
-
- /* Check that the socket still exists (it has not been
- * destroyed) and for safety, check that the m_endpoint field
- * is what we expect it to be.
- */
- if ((socket != NULL) && (socket->m_takesEvents))
- {
- switch (ev)
- {
- case T_LISTEN :
- event = GSOCK_CONNECTION ;
- break ;
- case T_CONNECT :
- event = GSOCK_CONNECTION ;
- event2 = GSOCK_OUTPUT ;
- {
- TCall retCall;
-
- retCall.addr.buf = NULL;
- retCall.addr.maxlen = 0;
- retCall.opt.buf = NULL;
- retCall.opt.maxlen = 0;
- retCall.udata.buf = NULL;
- retCall.udata.maxlen= 0;
- OTRcvConnect( socket->m_endpoint , &retCall ) ;
- }
- break ;
- case T_DISCONNECT :
- event = GSOCK_LOST ;
- break ;
- case T_GODATA :
- case T_GOEXDATA :
- event = GSOCK_OUTPUT ;
- break ;
- case T_DATA :
- event = GSOCK_INPUT ;
- break ;
- case T_EXDATA :
- event = GSOCK_INPUT ;
- break ;
- }
- if (event != GSOCK_MAX_EVENT)
- {
- cback = socket->m_cbacks[event];
- data = socket->m_data[event];
-
- if (event == GSOCK_LOST)
- socket->m_detected = GSOCK_LOST_FLAG;
- else
- socket->m_detected |= (1 << event);
- }
- if (event2 != GSOCK_MAX_EVENT)
- {
- cback2 = socket->m_cbacks[event2];
- data2 = socket->m_data[event2];
-
- if (event2 == GSOCK_LOST)
- socket->m_detected = GSOCK_LOST_FLAG;
- else
- socket->m_detected |= (1 << event2);
- }
- }
-
- /* OK, we can now leave the critical section because we have
- * already obtained the callback address (we make no further
- * accesses to socket->whatever). However, the app should
- * be prepared to handle events from a socket that has just
- * been closed!
- */
-
- if (cback != NULL)
- (cback)(socket, event, data);
- if (cback2 != NULL)
- (cback2)(socket, event2, data2);
-
-}
-
-/* Hack added for Mac OS X */
-GSocketError GAddress_UNIX_GetPath(GAddress *addr, char *path, size_t buf)
-{
- return GSOCK_INVADDR;
-}
-
-GSocketError GAddress_UNIX_SetPath(GAddress *addr, const char *path)
-{
- return GSOCK_INVADDR;
-}
-
-#endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: helpxxxx.cpp
-// Purpose: Help system: native implementation
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/stubs/helpxxxx.h"
-
-#include <string.h>
-
-IMPLEMENT_DYNAMIC_CLASS(wxXXXXHelpController, wxHelpControllerBase)
-
-wxXXXXHelpController::wxXXXXHelpController()
-{
- m_helpFile = "";
-}
-
-wxXXXXHelpController::~wxXXXXHelpController()
-{
-}
-
-bool wxXXXXHelpController::Initialize(const wxString& filename)
-{
- m_helpFile = filename;
- // TODO any other inits
- return TRUE;
-}
-
-bool wxXXXXHelpController::LoadFile(const wxString& file)
-{
- m_helpFile = file;
- // TODO
- return TRUE;
-}
-
-bool wxXXXXHelpController::DisplayContents()
-{
- // TODO
- return FALSE;
-}
-
-bool wxXXXXHelpController::DisplaySection(int section)
-{
- // TODO
- return FALSE;
-}
-
-bool wxXXXXHelpController::DisplayBlock(long block)
-{
- // TODO
- return FALSE;
-}
-
-bool wxXXXXHelpController::KeywordSearch(const wxString& k,
- wxHelpSearchMode WXUNUSED(mode))
-{
- if (m_helpFile == "") return FALSE;
-
- // TODO
- return FALSE;
-}
-
-// Can't close the help window explicitly in WinHelp
-bool wxXXXXHelpController::Quit()
-{
- // TODO
- return FALSE;
-}
-
-void wxXXXXHelpController::OnQuit()
-{
-}
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/icon.cpp
-// Purpose: wxIcon class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/icon.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
-
-#include "wx/mac/private.h"
-
-
-/*
- * Icons
- */
-
-wxIcon::wxIcon()
-{
-}
-
-wxIcon::wxIcon(const char bits[], int width, int height)
- :wxBitmap(bits, width, height)
-{
-}
-
-wxIcon::wxIcon( const char **bits ) :
- wxBitmap(bits)
-{
-}
-
-wxIcon::wxIcon( char **bits ) :
- wxBitmap(bits)
-{
-}
-
-wxIcon::wxIcon(const wxString& icon_file, int flags,
- int desiredWidth, int desiredHeight)
-{
- LoadFile(icon_file, (wxBitmapType) flags, desiredWidth, desiredHeight);
-}
-
-wxIcon::~wxIcon()
-{
-}
-
-bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
- int desiredWidth, int desiredHeight)
-{
- UnRef();
-
- m_refData = new wxBitmapRefData;
-
- wxBitmapHandler *handler = FindHandler((wxBitmapType)type);
-
- if ( handler )
- return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
- else
- return false;
-}
-
-void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
-{
- wxIcon *icon = (wxIcon*)(&bmp);
- *this = *icon;
-}
-
-IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
-
-bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight)
-{
- short theId = -1 ;
- if ( name == wxT("wxICON_INFORMATION") )
- {
- theId = kNoteIcon ;
- }
- else if ( name == wxT("wxICON_QUESTION") )
- {
- theId = kCautionIcon ;
- }
- else if ( name == wxT("wxICON_WARNING") )
- {
- theId = kCautionIcon ;
- }
- else if ( name == wxT("wxICON_ERROR") )
- {
- theId = kStopIcon ;
- }
- else
- {
- Str255 theName ;
- OSType theType ;
- wxMacStringToPascal( name , theName ) ;
-
- Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
- if ( resHandle != 0L )
- {
- GetResInfo( resHandle , &theId , &theType , theName ) ;
- ReleaseResource( resHandle ) ;
- }
- }
- if ( theId != -1 )
- {
- CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
- if ( theIcon )
- {
- M_BITMAPHANDLERDATA->m_hIcon = theIcon ;
- M_BITMAPHANDLERDATA->m_width = 32 ;
- M_BITMAPHANDLERDATA->m_height = 32 ;
-
- M_BITMAPHANDLERDATA->m_depth = 8 ;
- M_BITMAPHANDLERDATA->m_ok = true ;
- M_BITMAPHANDLERDATA->m_numColors = 256 ;
- M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ;
- return true;
- }
- }
- return false;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/joystick.cpp
-// Purpose: wxJoystick class
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#if wxUSE_JOYSTICK
-
-#include "wx/joystick.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxJoystick, wxObject)
-
-// Attributes
-////////////////////////////////////////////////////////////////////////////
-
-wxPoint wxJoystick::GetPosition() const
-{
- // TODO
- return wxPoint(0, 0);
-}
-
-int wxJoystick::GetZPosition() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetButtonState() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetPOVPosition() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetPOVCTSPosition() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetRudderPosition() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetUPosition() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetVPosition() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetMovementThreshold() const
-{
- // TODO
- return 0;
-}
-
-void wxJoystick::SetMovementThreshold(int threshold)
-{
- // TODO
-}
-
-// Capabilities
-////////////////////////////////////////////////////////////////////////////
-
-bool wxJoystick::IsOk() const
-{
- // TODO
- return false;
-}
-
-int wxJoystick::GetNumberJoysticks()
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetManufacturerId() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetProductId() const
-{
- // TODO
- return 0;
-}
-
-wxString wxJoystick::GetProductName() const
-{
- // TODO
- return wxEmptyString;
-}
-
-int wxJoystick::GetXMin() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetYMin() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetZMin() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetXMax() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetYMax() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetZMax() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetNumberButtons() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetNumberAxes() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetMaxButtons() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetMaxAxes() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetPollingMin() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetPollingMax() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetRudderMin() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetRudderMax() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetUMin() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetUMax() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetVMin() const
-{
- // TODO
- return 0;
-}
-
-int wxJoystick::GetVMax() const
-{
- // TODO
- return 0;
-}
-
-bool wxJoystick::HasRudder() const
-{
- // TODO
- return false;
-}
-
-bool wxJoystick::HasZ() const
-{
- // TODO
- return false;
-}
-
-bool wxJoystick::HasU() const
-{
- // TODO
- return false;
-}
-
-bool wxJoystick::HasV() const
-{
- // TODO
- return false;
-}
-
-bool wxJoystick::HasPOV() const
-{
- // TODO
- return false;
-}
-
-bool wxJoystick::HasPOV4Dir() const
-{
- // TODO
- return false;
-}
-
-bool wxJoystick::HasPOVCTS() const
-{
- // TODO
- return false;
-}
-
-// Operations
-////////////////////////////////////////////////////////////////////////////
-
-bool wxJoystick::SetCapture(wxWindow* win, int pollingFreq)
-{
- // TODO
- return false;
-}
-
-bool wxJoystick::ReleaseCapture()
-{
- // TODO
- return false;
-}
-
-#endif
- // wxUSE_JOYSTICK
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/listbox.cpp
-// Purpose: wxListBox
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#if wxUSE_LISTBOX
-
-#include "wx/listbox.h"
-
-#ifndef WX_PRECOMP
- #include "wx/dynarray.h"
- #include "wx/log.h"
- #include "wx/app.h"
- #include "wx/utils.h"
- #include "wx/button.h"
- #include "wx/settings.h"
- #include "wx/toplevel.h"
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
-
-BEGIN_EVENT_TABLE(wxListBox, wxControl)
- EVT_SIZE( wxListBox::OnSize )
- EVT_CHAR( wxListBox::OnChar )
-END_EVENT_TABLE()
-
-#include "wx/mac/uma.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-typedef struct {
- unsigned short instruction;
- void (*function)();
-} ldefRec, *ldefPtr, **ldefHandle;
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#if TARGET_CARBON
-const short kwxMacListItemHeight = 19 ;
-#else
-const short kwxMacListItemHeight = 14 ;
-#endif
-
-extern "C"
-{
-static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
- Cell cell, short dataOffset, short dataLength,
- ListHandle listHandle ) ;
-}
-
-static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
- Cell cell, short dataOffset, short dataLength,
- ListHandle listHandle )
-{
- wxListBox* list;
- list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
- if ( list == NULL )
- return ;
-
- GrafPtr savePort;
- GrafPtr grafPtr;
- RgnHandle savedClipRegion;
- SInt32 savedPenMode;
- GetPort(&savePort);
- SetPort((**listHandle).port);
- grafPtr = (**listHandle).port ;
- // typecast our refCon
-
- // Calculate the cell rect.
-
- switch( message ) {
- case lInitMsg:
- break;
-
- case lCloseMsg:
- break;
-
- case lDrawMsg:
- {
- const wxString linetext = list->m_stringArray[cell.v] ;
-
- // Save the current clip region, and set the clip region to the area we are about
- // to draw.
-
- savedClipRegion = NewRgn();
- GetClip( savedClipRegion );
-
- ClipRect( drawRect );
- EraseRect( drawRect );
-
- const wxFont& font = list->GetFont();
- if ( font.Ok() )
- {
- ::TextFont( font.GetMacFontNum() ) ;
- ::TextSize( font.GetMacFontSize() ) ;
- ::TextFace( font.GetMacFontStyle() ) ;
- }
- else
- {
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
- }
-
-#if TARGET_CARBON
- {
- Rect frame = { drawRect->top, drawRect->left + 4,
- drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ;
- CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , wxMacCFStringHolder(linetext , list->GetFont().GetEncoding()) ) ;
- ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ;
- ::DrawThemeTextBox( mString,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &frame,
- teJustLeft,
- nil );
- CFRelease( mString ) ;
- }
-#else
- {
- wxCharBuffer text = linetext.mb_str( wxConvLocal) ;
- MoveTo(drawRect->left + 4 , drawRect->top + 10 );
- DrawText(text, 0 , strlen(text) );
- }
-#endif
- // If the cell is hilited, do the hilite now. Paint the cell contents with the
- // appropriate QuickDraw transform mode.
-
- if( isSelected ) {
- savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
- SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode );
- PaintRect( drawRect );
- SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode );
- }
-
- // Restore the saved clip region.
-
- SetClip( savedClipRegion );
- DisposeRgn( savedClipRegion );
- }
- break;
- case lHiliteMsg:
-
- // Hilite or unhilite the cell. Paint the cell contents with the
- // appropriate QuickDraw transform mode.
-
- GetPort( &grafPtr );
- savedPenMode = GetPortPenMode( (CGrafPtr)grafPtr );
- SetPortPenMode( (CGrafPtr)grafPtr, hilitetransfermode );
- PaintRect( drawRect );
- SetPortPenMode( (CGrafPtr)grafPtr, savedPenMode );
- break;
- default :
- break ;
- }
- SetPort(savePort);
-}
-
-extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
-// resources ldef ids
-const short kwxMacListWithVerticalScrollbar = 128 ;
-const short kwxMacListWithVerticalAndHorizontalScrollbar = 129 ;
-
-// ============================================================================
-// list box control implementation
-// ============================================================================
-
-// Listbox item
-wxListBox::wxListBox()
-{
- m_noItems = 0;
- m_selected = 0;
- m_macList = NULL ;
-}
-
-static ListDefUPP macListDefUPP = NULL ;
-
-bool wxListBox::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- const wxArrayString& choices,
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- wxCArrayString chs(choices);
-
- return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
- style, validator, name);
-}
-
-bool wxListBox::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- int n, const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxListBoxBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) )
- return false;
-
- m_noItems = 0 ; // this will be increased by our append command
- m_selected = 0;
-
- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
-
- ListDefSpec listDef;
- listDef.defType = kListDefUserProcType;
- if ( macListDefUPP == NULL )
- {
- macListDefUPP = NewListDefUPP( wxMacListDefinition );
- }
- listDef.u.userProc = macListDefUPP ;
-
- Str255 fontName ;
- SInt16 fontSize ;
- Style fontStyle ;
-#if TARGET_CARBON
- GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
-#else
- GetFontName( kFontIDMonaco , fontName ) ;
- fontSize = 9 ;
- fontStyle = normal ;
-#endif
- SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) ) ) ;
-#if TARGET_CARBON
- Size asize;
-
-
- CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, (style & wxLB_HSCROLL), true,
- kwxMacListItemHeight, kwxMacListItemHeight, false, &listDef, (ControlRef *)&m_macControl );
-
- GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag,
- sizeof(ListHandle), (Ptr) &m_macList, &asize);
-
- SetControlReference( (ControlHandle) m_macControl, (long) this);
- SetControlVisibility( (ControlHandle) m_macControl, false, false);
-
-#else
-
- long result ;
- wxStAppResource resload ;
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false ,
- (style & wxLB_HSCROLL) ? kwxMacListWithVerticalAndHorizontalScrollbar : kwxMacListWithVerticalScrollbar ,
- 0 , 0, kControlListBoxProc , (long) this ) ;
- ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
- sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
-
- HLock( (Handle) m_macList ) ;
- ldefHandle ldef ;
- ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ;
- if ( (**(ListHandle)m_macList).listDefProc != NULL )
- {
- (**ldef).instruction = 0x4EF9; /* JMP instruction */
- (**ldef).function = (void(*)()) listDef.u.userProc;
- (**(ListHandle)m_macList).listDefProc = (Handle) ldef ;
- }
-
- Point pt = (**(ListHandle)m_macList).cellSize ;
- pt.v = kwxMacListItemHeight ;
- LCellSize( pt , (ListHandle)m_macList ) ;
- LAddColumn( 1 , 0 , (ListHandle)m_macList ) ;
-#endif
- OptionBits options = 0;
- if ( style & wxLB_MULTIPLE )
- {
- options += lExtendDrag + lUseSense ;
- }
- else if ( style & wxLB_EXTENDED )
- {
- // default behaviour
- }
- else
- {
- options = (OptionBits) lOnlyOne ;
- }
- SetListSelectionFlags((ListHandle)m_macList, options);
-
- for ( int i = 0 ; i < n ; i++ )
- {
- Append( choices[i] ) ;
- }
-
- MacPostControlCreate() ;
-
- LSetDrawingMode( true , (ListHandle)m_macList ) ;
-
- return true;
-}
-
-wxListBox::~wxListBox()
-{
- FreeData() ;
- // avoid access during destruction
- SetControlReference( (ControlHandle) m_macControl , NULL ) ;
- if ( m_macList )
- {
-#if !TARGET_CARBON
- DisposeHandle( (**(ListHandle)m_macList).listDefProc ) ;
- (**(ListHandle)m_macList).listDefProc = NULL ;
-#endif
- m_macList = NULL ;
- }
-}
-
-void wxListBox::FreeData()
-{
-#if wxUSE_OWNER_DRAWN
- if ( m_windowStyle & wxLB_OWNERDRAW )
- {
- size_t uiCount = m_aItems.Count();
- while ( uiCount-- != 0 ) {
- delete m_aItems[uiCount];
- m_aItems[uiCount] = NULL;
- }
-
- m_aItems.Clear();
- }
- else
-#endif // wxUSE_OWNER_DRAWN
- if ( HasClientObjectData() )
- {
- for ( unsigned int n = 0; n < m_noItems; n++ )
- {
- delete GetClientObject(n);
- }
- }
-}
-
-void wxListBox::DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags )
-{
- wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
-#if TARGET_CARBON
- Rect bounds ;
- GetControlBounds( (ControlHandle) m_macControl , &bounds ) ;
- ControlRef control = GetListVerticalScrollBar( (ListHandle)m_macList ) ;
- if ( control )
- {
- Rect scrollbounds ;
- GetControlBounds( control , &scrollbounds ) ;
- if( scrollbounds.right != bounds.right + 1 )
- {
- UMAMoveControl( control , bounds.right - (scrollbounds.right - scrollbounds.left) + 1 ,
- scrollbounds.top ) ;
- }
- }
-#endif
-}
-void wxListBox::DoSetFirstItem(int N)
-{
- MacScrollTo( N ) ;
-}
-
-void wxListBox::Delete(unsigned int n)
-{
- wxCHECK_RET( IsValid(n),
- wxT("invalid index in wxListBox::Delete") );
-
-#if wxUSE_OWNER_DRAWN
- delete m_aItems[n];
- m_aItems.RemoveAt(n);
-#else // !wxUSE_OWNER_DRAWN
- if ( HasClientObjectData() )
- {
- delete GetClientObject(n);
- }
-#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
- m_stringArray.RemoveAt(n) ;
- m_dataArray.RemoveAt(n) ;
- m_noItems--;
-
- MacDelete(n) ;
-}
-
-int wxListBox::DoAppend(const wxString& item)
-{
- InvalidateBestSize();
-
- unsigned int index = m_noItems ;
- m_stringArray.Add( item ) ;
- m_dataArray.Add( NULL );
- m_noItems ++;
- DoSetItemClientData( index , NULL ) ;
- MacAppend( item ) ;
-
- return index ;
-}
-
-void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
-{
- MacSetRedraw( false ) ;
- Clear() ;
- int n = choices.GetCount();
-
- for( int i = 0 ; i < n ; ++i )
- {
- if ( clientData )
- {
-#if wxUSE_OWNER_DRAWN
- wxASSERT_MSG(clientData[i] == NULL,
- wxT("Can't use client data with owner-drawn listboxes"));
-#else // !wxUSE_OWNER_DRAWN
- Append( choices[i] , clientData[i] ) ;
-#endif
- }
- else
- Append( choices[i] ) ;
- }
-
-#if wxUSE_OWNER_DRAWN
- if ( m_windowStyle & wxLB_OWNERDRAW ) {
- // first delete old items
- unsigned int ui = m_aItems.Count();
- while ( ui-- != 0 ) {
- delete m_aItems[ui];
- m_aItems[ui] = NULL;
- }
- m_aItems.Empty();
-
- // then create new ones
- for ( ui = 0; ui < m_noItems; ui++ ) {
- wxOwnerDrawn *pNewItem = CreateItem(ui);
- pNewItem->SetName(choices[ui]);
- m_aItems.Add(pNewItem);
- }
- }
-#endif // wxUSE_OWNER_DRAWN
- MacSetRedraw( true ) ;
-}
-
-bool wxListBox::HasMultipleSelection() const
-{
- return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED);
-}
-
-int wxListBox::FindString(const wxString& s, bool bCase) const
-{
- if ( s.Right(1) == wxT("*") )
- {
- wxString search = s.Left( s.length() - 1 ) ;
- int len = search.length() ;
- Str255 s1 , s2 ;
- wxMacStringToPascal( search , s2 ) ;
-
- for ( unsigned int i = 0 ; i < m_noItems ; ++ i )
- {
- wxMacStringToPascal( m_stringArray[i].Left( len ) , s1 ) ;
-
- if ( EqualString( s1 , s2 , bCase , false ) )
- return (int)i ;
- }
- if ( s.Left(1) == wxT("*") && s.length() > 1 )
- {
- wxString st = s ;
- st.MakeLower() ;
- for ( unsigned int i = 0 ; i < m_noItems ; ++i )
- {
- if (GetString(i).Lower().Matches(st))
- return (int)i ;
- }
- }
-
- }
- else
- {
- Str255 s1 , s2 ;
-
- wxMacStringToPascal( s , s2 ) ;
-
- for ( unsigned int i = 0 ; i < m_noItems ; ++ i )
- {
- wxMacStringToPascal( m_stringArray[i] , s1 ) ;
-
- if ( EqualString( s1 , s2 , bCase , false ) )
- return (int)i ;
- }
- }
-
- return wxNOT_FOUND;
-}
-
-void wxListBox::Clear()
-{
- FreeData();
- m_noItems = 0;
- m_stringArray.Empty() ;
- m_dataArray.Empty() ;
- MacClear() ;
-}
-
-void wxListBox::DoSetSelection(int N, bool select)
-{
- wxCHECK_RET( IsValid(N),
- wxT("invalid index in wxListBox::SetSelection") );
- MacSetSelection( N , select ) ;
- GetSelections( m_selectionPreImage ) ;
-}
-
-bool wxListBox::IsSelected(int N) const
-{
- wxCHECK_MSG( IsValid(N), false,
- wxT("invalid index in wxListBox::Selected") );
-
- return MacIsSelected( N ) ;
-}
-
-void *wxListBox::DoGetItemClientData(unsigned int n) const
-{
- wxCHECK_MSG( IsValid(n), NULL,
- wxT("invalid index in wxListBox::GetClientData"));
-
- return (void *)m_dataArray[n];
-}
-
-wxClientData *wxListBox::DoGetItemClientObject(unsigned int n) const
-{
- return (wxClientData *) DoGetItemClientData( n ) ;
-}
-
-void wxListBox::DoSetItemClientData(unsigned int n, void *Client_data)
-{
- wxCHECK_RET( IsValid(n),
- wxT("invalid index in wxListBox::SetClientData") );
-
-#if wxUSE_OWNER_DRAWN
- if ( m_windowStyle & wxLB_OWNERDRAW )
- {
- // client data must be pointer to wxOwnerDrawn, otherwise we would crash
- // in OnMeasure/OnDraw.
- wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
- }
-#endif // wxUSE_OWNER_DRAWN
- wxASSERT_MSG( m_dataArray.GetCount() >= (unsigned int) n , wxT("invalid client_data array") ) ;
-
- if ( m_dataArray.GetCount() > (size_t) n )
- {
- m_dataArray[n] = (char*) Client_data ;
- }
- else
- {
- m_dataArray.Add( (char*) Client_data ) ;
- }
-}
-
-void wxListBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
-{
- DoSetItemClientData(n, clientData);
-}
-
-// Return number of selections and an array of selected integers
-int wxListBox::GetSelections(wxArrayInt& aSelections) const
-{
- return MacGetSelections( aSelections ) ;
-}
-
-// Get single selection, for single choice list items
-int wxListBox::GetSelection() const
-{
- return MacGetSelection() ;
-}
-
-// Find string for position
-wxString wxListBox::GetString(unsigned int n) const
-{
- return m_stringArray[n] ;
-}
-
-void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
-{
- wxCHECK_RET( IsValidInsert(pos),
- wxT("invalid index in wxListBox::InsertItems") );
-
- InvalidateBestSize();
-
- unsigned int nItems = items.GetCount();
-
- for ( unsigned int i = 0 ; i < nItems ; i++ )
- {
- m_stringArray.Insert( items[i] , pos + i ) ;
- m_dataArray.Insert( NULL , pos + i ) ;
- MacInsert( pos + i , items[i] ) ;
- }
-
- m_noItems += nItems;
-}
-
-void wxListBox::SetString(unsigned int n, const wxString& s)
-{
- m_stringArray[n] = s;
- MacSet(n, s);
-}
-
-wxSize wxListBox::DoGetBestSize() const
-{
- int lbWidth = 100; // some defaults
- int lbHeight = 110;
- int wLine;
-
- {
- wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;
-
- if ( m_font.Ok() )
- {
- ::TextFont( m_font.GetMacFontNum() ) ;
- ::TextSize( m_font.GetMacFontSize() ) ;
- ::TextFace( m_font.GetMacFontStyle() ) ;
- }
- else
- {
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
- }
-
- // Find the widest line
- for(unsigned int i = 0; i < GetCount(); i++) {
- wxString str(GetString(i));
- #if wxUSE_UNICODE
- Point bounds={0,0} ;
- SInt16 baseline ;
- ::GetThemeTextDimensions( wxMacCFStringHolder( str , m_font.GetEncoding() ) ,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &bounds,
- &baseline );
- wLine = bounds.h ;
- #else
- wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ;
- #endif
- lbWidth = wxMax(lbWidth, wLine);
- }
-
- // Add room for the scrollbar
- lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
-
- // And just a bit more
- int cy = 12 ;
- int cx = ::TextWidth( "X" , 0 , 1 ) ;
- lbWidth += cx ;
-
- // don't make the listbox too tall (limit height to around 10 items) but don't
- // make it too small neither
- lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
- }
- return wxSize(lbWidth, lbHeight);
-}
-
-unsigned int wxListBox::GetCount() const
-{
- return m_noItems;
-}
-
-void wxListBox::SetupColours()
-{
- SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
- SetForegroundColour(GetParent()->GetForegroundColour());
-}
-
-void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
-{
- wxControl::Refresh( eraseBack , rect ) ;
- // MacRedrawControl() ;
-}
-
-#if wxUSE_OWNER_DRAWN
-
-class wxListBoxItem : public wxOwnerDrawn
-{
-public:
- wxListBoxItem(const wxString& str = wxEmptyString);
-};
-
-wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, false)
-{
- // no bitmaps/checkmarks
- SetMarginWidth(0);
-}
-
-wxOwnerDrawn *wxListBox::CreateItem(size_t n)
-{
- return new wxListBoxItem();
-}
-
-#endif //USE_OWNER_DRAWN
-
-// ============================================================================
-// list box control implementation
-// ============================================================================
-
-/*
-void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
-{
-wxListBox* list;
-// typecast our refCon
-list = (wxListBox*)refCon;
-
- MoveTo(cellRect->left + 4 , cellRect->top + 10 );
- const wxString text = list->m_stringArray[lCell.v] ;
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
- DrawText(text, 0 , text.length());
-
- }
-*/
-void wxListBox::MacDelete( int N )
-{
- LDelRow( 1 , N , (ListHandle)m_macList) ;
- Refresh();
-}
-
-void wxListBox::MacInsert( int n , const wxString& text)
-{
- Cell cell = { 0 , 0 } ;
- cell.v = n ;
- LAddRow( 1 , cell.v , (ListHandle)m_macList ) ;
- // LSetCell(text, strlen(text), cell, m_macList);
- Refresh();
-}
-
-void wxListBox::MacAppend( const wxString& text)
-{
- Cell cell = { 0 , 0 } ;
- cell.v = (**(ListHandle)m_macList).dataBounds.bottom ;
- LAddRow( 1 , cell.v , (ListHandle)m_macList ) ;
- // LSetCell(text, strlen(text), cell, m_macList);
- Refresh();
-}
-
-void wxListBox::MacClear()
-{
- LDelRow( (**(ListHandle)m_macList).dataBounds.bottom , 0 ,(ListHandle) m_macList ) ;
- Refresh();
-}
-
-void wxListBox::MacSetSelection( int n , bool select )
-{
- Cell cell = { 0 , 0 } ;
- if ( ! (m_windowStyle & wxLB_MULTIPLE) )
- {
- if ( LGetSelect( true , &cell , (ListHandle)m_macList ) )
- {
- LSetSelect( false , cell , (ListHandle)m_macList ) ;
- }
- }
-
- cell.v = n ;
- LSetSelect( select , cell , (ListHandle)m_macList ) ;
- LAutoScroll( (ListHandle)m_macList ) ;
- Refresh();
-}
-
-bool wxListBox::MacIsSelected( int n ) const
-{
- Cell cell = { 0 , 0 } ;
- cell.v = n ;
- return LGetSelect( false , &cell , (ListHandle)m_macList ) ;
-}
-
-void wxListBox::MacDestroy()
-{
- // DisposeExtLDEFInfo( m_macList ) ;
-}
-
-int wxListBox::MacGetSelection() const
-{
- Cell cell = { 0 , 0 } ;
- if ( LGetSelect( true , &cell , (ListHandle)m_macList ) )
- return cell.v ;
- else
- return -1 ;
-}
-
-int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
-{
- int no_sel = 0 ;
-
- aSelections.Empty();
-
- Cell cell = { 0 , 0 } ;
- cell.v = 0 ;
-
- while ( LGetSelect( true , &cell ,(ListHandle) m_macList ) )
- {
- aSelections.Add( cell.v ) ;
- no_sel++ ;
- cell.v++ ;
- }
- return no_sel ;
-}
-
-void wxListBox::MacSet( int n , const wxString& text )
-{
- // our implementation does not store anything in the list
- // so we just have to redraw
- Cell cell = { 0 , 0 } ;
- cell.v = n ;
- // LSetCell(text, strlen(text), cell, m_macList);
- Refresh();
-}
-
-void wxListBox::MacScrollTo( int n )
-{
- // TODO implement scrolling
-}
-
-void wxListBox::OnSize( wxSizeEvent &event)
-{
- Point pt;
-
-#if TARGET_CARBON
- GetListCellSize((ListHandle)m_macList, &pt);
-#else
- pt = (**(ListHandle)m_macList).cellSize ;
-#endif
- pt.h = m_width - 15 ;
- LCellSize( pt , (ListHandle)m_macList ) ;
-}
-
-void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
-{
- Boolean wasDoubleClick = false ;
- long result ;
-
- ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
- if ( !wasDoubleClick )
- {
- MacDoClick() ;
- }
- else
- {
- MacDoDoubleClick() ;
- }
-}
-
-void wxListBox::MacSetRedraw( bool doDraw )
-{
- LSetDrawingMode( doDraw , (ListHandle)m_macList ) ;
-}
-
-void wxListBox::MacDoClick()
-{
- wxArrayInt aSelections;
- int n ;
- size_t count = GetSelections(aSelections);
-
- if ( count == m_selectionPreImage.GetCount() )
- {
- bool hasChanged = false ;
- for ( size_t i = 0 ; i < count ; ++i )
- {
- if ( aSelections[i] != m_selectionPreImage[i] )
- {
- hasChanged = true ;
- break ;
- }
- }
- if ( !hasChanged )
- {
- return ;
- }
- }
-
- m_selectionPreImage = aSelections;
-
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
- event.SetEventObject( this );
-
- if ( count > 0 )
- {
- n = aSelections[0];
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject(n) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(n) );
- event.SetString(GetString(n));
- }
- else
- {
- n = -1;
- }
-
- event.SetInt(n);
-
- GetEventHandler()->ProcessEvent(event);
-}
-
-void wxListBox::MacDoDoubleClick()
-{
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event) ;
-}
-
-void wxListBox::OnChar(wxKeyEvent& event)
-{
- if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER)
- {
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
- if ( tlw && tlw->GetDefaultItem() )
- {
- wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
- if ( def && def->IsEnabled() )
- {
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
- event.SetEventObject(def);
- def->Command(event);
- return ;
- }
- }
- event.Skip() ;
- }
- /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
- else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) )
- {
- // FIXME: look in ancestors, not just parent.
- wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ;
- if (win)
- {
- wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
- new_event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( new_event );
- }
- }
- else if ( event.GetKeyCode() == WXK_TAB )
- {
- wxNavigationKeyEvent new_event;
- new_event.SetEventObject( this );
- new_event.SetDirection( !event.ShiftDown() );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
- new_event.SetWindowChange( event.ControlDown() );
- new_event.SetCurrentFocus( this );
- if ( !GetEventHandler()->ProcessEvent( new_event ) )
- event.Skip() ;
- }
- else if ( event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_UP )
- {
- // perform the default key handling first
- wxControl::OnKeyDown( event ) ;
-
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
- event.SetEventObject( this );
-
- wxArrayInt aSelections;
- int n, count = GetSelections(aSelections);
- if ( count > 0 )
- {
- n = aSelections[0];
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject(n) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(n) );
- event.SetString(GetString(n));
- }
- else
- {
- n = -1;
- }
-
- event.SetInt(n);
-
- GetEventHandler()->ProcessEvent(event);
- }
- else
- {
- if ( event.GetTimestamp() > m_lastTypeIn + 60 )
- {
- m_typeIn = wxEmptyString ;
- }
- m_lastTypeIn = event.GetTimestamp() ;
- m_typeIn += (char) event.GetKeyCode() ;
- int line = FindString(wxT("*")+m_typeIn+wxT("*")) ;
- if ( line >= 0 )
- {
- if ( GetSelection() != line )
- {
- SetSelection(line) ;
- wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
- event.SetEventObject( this );
-
- if ( HasClientObjectData() )
- event.SetClientObject( GetClientObject( line ) );
- else if ( HasClientUntypedData() )
- event.SetClientData( GetClientData(line) );
- event.SetString(GetString(line));
-
- event.SetInt(line);
-
- GetEventHandler()->ProcessEvent(event);
- }
- }
- }
-}
-
-#endif // wxUSE_LISTBOX
+++ /dev/null
-/* -------------------------------------------------------------------------
- * Project: Mac Notifier Support
- * Name: macnotfy.c
- * Author: Stefan CSomor
- * Purpose: Mac Notifier main file
- * CVSID: $Id$
- * -------------------------------------------------------------------------
- */
-
-#include "wx/wx.h"
-
-#include "wx/mac/private.h"
-
-#include "wx/mac/macnotfy.h"
-
-const short kMaxEvents = 1000 ;
-
-struct wxMacNotificationEvents
-{
- short top ;
- short bottom ;
-
- wxMacNotificationProcPtr proc[kMaxEvents] ;
- unsigned long events[kMaxEvents] ;
- void* data[kMaxEvents] ;
-} ;
-
-typedef struct wxMacNotificationEvents wxMacNotificationEvents ;
-static wxMacNotificationEvents gMacNotificationEvents ;
-
-static ProcessSerialNumber gAppProcess ;
-
-void wxMacWakeUp()
-{
- ProcessSerialNumber psn ;
- Boolean isSame ;
- psn.highLongOfPSN = 0 ;
- psn.lowLongOfPSN = kCurrentProcess ;
- SameProcess( &gAppProcess , &psn , &isSame ) ;
- if ( isSame )
- {
-#if TARGET_CARBON
- EventRef dummyEvent ;
- OSStatus err = MacCreateEvent(nil, 'WXMC', 'WXMC', GetCurrentEventTime(),
- kEventAttributeNone, &dummyEvent);
- if (err == noErr)
- {
- err = PostEventToQueue(GetMainEventQueue(), dummyEvent,
- kEventPriorityHigh);
- }
-#else
- PostEvent( nullEvent , 0 ) ;
-#endif
- }
- else
- {
- WakeUpProcess( &gAppProcess ) ;
- }
-}
-
-void wxMacCreateNotifierTable()
-{
- GetCurrentProcess(&gAppProcess);
- gMacNotificationEvents.top = 0 ;
- gMacNotificationEvents.bottom = 0 ;
- for ( int i = 0 ; i < kMaxEvents ; ++i )
- {
- gMacNotificationEvents.proc[i] = NULL ;
- gMacNotificationEvents.events[i] = NULL ;
- gMacNotificationEvents.data[i] = NULL ;
- }
-}
-
-void wxMacDestroyNotifierTable()
-{
-}
-
-wxMacNotifierTableRef wxMacGetNotifierTable()
-{
- return (wxMacNotifierTableRef) &gMacNotificationEvents ;
-}
-
-void wxMacAddEvent(
- wxMacNotifierTableRef table ,
- wxMacNotificationProcPtr handler ,
- unsigned long event ,
- void* data ,
- short wakeUp )
-{
- wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ;
- wxASSERT_MSG( handler != NULL , wxT("illegal notification proc ptr") ) ;
- /* this should be protected eventually */
- short index = e->top++ ;
-
- if ( e->top == kMaxEvents )
- e->top = 0 ;
-
- e->proc[index] = handler ;
- e->events[index] = event ;
- e->data[index] = data ;
- if ( wakeUp )
- wxMacWakeUp() ;
-}
-
-bool gInProcessing = false ;
-
-void wxMacRemoveAllNotifiersForData( wxMacNotifierTableRef table , void* data )
-{
- wxMacNotificationEvents *e = (wxMacNotificationEvents *) table ;
- /* this should be protected eventually */
- short index = e->bottom ;
-
- while ( e->top != index )
- {
- if ( e->data[index] == data )
- e->data[index] = NULL ;
- index++ ;
- if ( index == kMaxEvents )
- index = 0 ;
- }
-}
-
-void wxMacProcessNotifierEvents()
-{
- // if ( gInProcessing )
- // return ;
-
- gInProcessing = true ;
- if ( gMacNotificationEvents.top != gMacNotificationEvents.bottom )
- {
- // we only should process the notifiers that were here when we entered it
- // otherwise we might never get out...
- short count = gMacNotificationEvents.top - gMacNotificationEvents.bottom ;
- if ( count < 0 )
- count += kMaxEvents ;
-
- while ( count-- )
- {
- // consume event at bottom
- short index = gMacNotificationEvents.bottom++ ;
- if ( gMacNotificationEvents.bottom == kMaxEvents )
- gMacNotificationEvents.bottom = 0 ;
- void* data = gMacNotificationEvents.data[index] ;
- unsigned long event = gMacNotificationEvents.events[index] ;
- wxMacNotificationProcPtr handler = gMacNotificationEvents.proc[index] ;
-
- gMacNotificationEvents.data[index] = NULL ;
- gMacNotificationEvents.events[index] = NULL ;
- gMacNotificationEvents.proc[index] = NULL ;
-
- if ( handler )
- handler( event , data ) ;
- }
- }
- gInProcessing = false ;
-}
-
-void wxMacProcessNotifierAndPendingEvents()
-{
- wxMacProcessNotifierEvents() ;
- wxTheApp->ProcessPendingEvents() ;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: main.cpp
-// Purpose: Entry point
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// We don't put main() in the library any more. GD.
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/mdi.cpp
-// Purpose: MDI classes
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/mdi.h"
-
-#ifndef WX_PRECOMP
- #include "wx/log.h"
- #include "wx/menu.h"
- #include "wx/settings.h"
-#endif
-
-#include "wx/mac/private.h"
-#include "wx/mac/uma.h"
-
-extern wxWindowList wxModelessWindows;
-
-IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
-IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
-IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow)
-
-BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
- EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
- EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
-END_EVENT_TABLE()
-
-BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow)
- EVT_SCROLL(wxMDIClientWindow::OnScroll)
-END_EVENT_TABLE()
-
-static const int IDM_WINDOWTILE = 4001;
-static const int IDM_WINDOWTILEHOR = 4001;
-static const int IDM_WINDOWCASCADE = 4002;
-static const int IDM_WINDOWICONS = 4003;
-static const int IDM_WINDOWNEXT = 4004;
-static const int IDM_WINDOWTILEVERT = 4005;
-static const int IDM_WINDOWPREV = 4006;
-
-// This range gives a maximum of 500 MDI children. Should be enough :-)
-static const int wxFIRST_MDI_CHILD = 4100;
-static const int wxLAST_MDI_CHILD = 4600;
-
-// Status border dimensions
-static const int wxTHICK_LINE_BORDER = 3;
-
-// Parent frame
-
-wxMDIParentFrame::wxMDIParentFrame()
-{
- m_clientWindow = NULL;
- m_currentChild = NULL;
- m_windowMenu = (wxMenu*) NULL;
- m_parentFrameActive = true;
-}
-
-bool wxMDIParentFrame::Create(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- m_clientWindow = NULL;
- m_currentChild = NULL;
-
- // this style can be used to prevent a window from having the standard MDI
- // "Window" menu
- if ( style & wxFRAME_NO_WINDOW_MENU )
- {
- m_windowMenu = (wxMenu *)NULL;
- style -= wxFRAME_NO_WINDOW_MENU ;
- }
- else // normal case: we have the window menu, so construct it
- {
- m_windowMenu = new wxMenu;
-
- m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade"));
- m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally"));
- m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically"));
- m_windowMenu->AppendSeparator();
- m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons"));
- m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next"));
- }
-
- wxFrame::Create( parent , id , title , pos , size , style , name ) ;
- m_parentFrameActive = true;
-
- OnCreateClient();
-
- return true;
-}
-
-wxMDIParentFrame::~wxMDIParentFrame()
-{
- DestroyChildren();
- // already delete by DestroyChildren()
-#if wxUSE_TOOLBAR
- m_frameToolBar = NULL;
-#endif
-#if wxUSE_STATUSBAR
- m_frameStatusBar = NULL;
-#endif
- m_clientWindow = NULL ;
-
- if (m_windowMenu)
- {
- delete m_windowMenu;
- m_windowMenu = (wxMenu*) NULL;
- }
-
- if ( m_clientWindow )
- {
- delete m_clientWindow;
- m_clientWindow = NULL ;
- }
-}
-
-
-void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
-{
- wxFrame::SetMenuBar( menu_bar ) ;
-}
-
-void wxMDIParentFrame::MacActivate(long timestamp, bool activating)
-{
- wxLogDebug(wxT("MDI PARENT=%p MacActivate(0x%08lx,%s)"),this,timestamp,activating?wxT("ACTIV"):wxT("deact"));
- if(activating)
- {
- if(s_macDeactivateWindow && s_macDeactivateWindow->GetParent()==this)
- {
- wxLogDebug(wxT("child had been scheduled for deactivation, rehighlighting"));
- UMAHighlightAndActivateWindow((WindowRef)s_macDeactivateWindow->MacGetWindowRef(), true);
- wxLogDebug(wxT("done highliting child"));
- s_macDeactivateWindow = NULL;
- }
- else if(s_macDeactivateWindow == this)
- {
- wxLogDebug(wxT("Avoided deactivation/activation of this=%p"), this);
- s_macDeactivateWindow = NULL;
- }
- else // window to deactivate is NULL or is not us or one of our kids
- {
- // activate kid instead
- if(m_currentChild)
- m_currentChild->MacActivate(timestamp,activating);
- else
- wxFrame::MacActivate(timestamp,activating);
- }
- }
- else
- {
- // We were scheduled for deactivation, and now we do it.
- if(s_macDeactivateWindow==this)
- {
- s_macDeactivateWindow = NULL;
- if(m_currentChild)
- m_currentChild->MacActivate(timestamp,activating);
- wxFrame::MacActivate(timestamp,activating);
- }
- else // schedule ourselves for deactivation
- {
- if(s_macDeactivateWindow)
- wxLogDebug(wxT("window=%p SHOULD have been deactivated, oh well!"),s_macDeactivateWindow);
- wxLogDebug(wxT("Scheduling delayed MDI Parent deactivation"));
- s_macDeactivateWindow = this;
- }
- }
-}
-
-void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
-{
- event.Skip();
-}
-
-// Returns the active MDI child window
-wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
-{
- return m_currentChild ;
-}
-
-// Create the client window class (don't Create the window,
-// just return a new class)
-wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
-{
- m_clientWindow = new wxMDIClientWindow( this );
- return m_clientWindow;
-}
-
-// Responds to colour changes, and passes event on to children.
-void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
-{
- // TODO
-
- // Propagate the event to the non-top-level children
- wxFrame::OnSysColourChanged(event);
-}
-
-// MDI operations
-void wxMDIParentFrame::Cascade()
-{
- // TODO
-}
-
-void wxMDIParentFrame::Tile(wxOrientation WXUNUSED(orient))
-{
- // TODO
-}
-
-void wxMDIParentFrame::ArrangeIcons()
-{
- // TODO
-}
-
-void wxMDIParentFrame::ActivateNext()
-{
- // TODO
-}
-
-void wxMDIParentFrame::ActivatePrevious()
-{
- // TODO
-}
-
-// Child frame
-
-wxMDIChildFrame::wxMDIChildFrame()
-{
- Init() ;
-}
-void wxMDIChildFrame::Init()
-{
-}
-
-bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- SetName(name);
-
- if ( id != wxID_ANY )
- m_windowId = id;
- else
- m_windowId = (int)NewControlId();
-
- if (parent) parent->AddChild(this);
-
- MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
-
- m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
- SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ;
-
- wxModelessWindows.Append(this);
- return false;
-}
-
-wxMDIChildFrame::~wxMDIChildFrame()
-{
- wxMDIParentFrame *mdiparent = wxDynamicCast(m_parent, wxMDIParentFrame);
- wxASSERT(mdiparent);
- if(mdiparent->m_currentChild == this)
- mdiparent->m_currentChild = NULL;
- DestroyChildren();
- // already delete by DestroyChildren()
-#if wxUSE_TOOLBAR
- m_frameToolBar = NULL;
-#endif
-#if wxUSE_STATUSBAR
- m_frameStatusBar = NULL;
-#endif
-}
-
-void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
-{
- return wxFrame::SetMenuBar( menu_bar ) ;
-}
-
-void wxMDIChildFrame::MacActivate(long timestamp, bool activating)
-{
- wxLogDebug(wxT("MDI child=%p MacActivate(0x%08lx,%s)"),this,timestamp,activating?wxT("ACTIV"):wxT("deact"));
- wxMDIParentFrame *mdiparent = wxDynamicCast(m_parent, wxMDIParentFrame);
- wxASSERT(mdiparent);
- if(activating)
- {
- if(s_macDeactivateWindow == m_parent)
- {
- wxLogDebug(wxT("parent had been scheduled for deactivation, rehighlighting"));
- UMAHighlightAndActivateWindow((WindowRef)s_macDeactivateWindow->MacGetWindowRef(), true);
- wxLogDebug(wxT("done highliting parent"));
- s_macDeactivateWindow = NULL;
- }
- else if((mdiparent->m_currentChild==this) || !s_macDeactivateWindow)
- mdiparent->wxFrame::MacActivate(timestamp,activating);
-
- if(mdiparent->m_currentChild && mdiparent->m_currentChild!=this)
- mdiparent->m_currentChild->wxFrame::MacActivate(timestamp,false);
- mdiparent->m_currentChild = this;
-
- if(s_macDeactivateWindow==this)
- {
- wxLogDebug(wxT("Avoided deactivation/activation of this=%p"),this);
- s_macDeactivateWindow=NULL;
- }
- else
- wxFrame::MacActivate(timestamp, activating);
- }
- else
- {
- // We were scheduled for deactivation, and now we do it.
- if(s_macDeactivateWindow==this)
- {
- s_macDeactivateWindow = NULL;
- wxFrame::MacActivate(timestamp,activating);
- if(mdiparent->m_currentChild==this)
- mdiparent->wxFrame::MacActivate(timestamp,activating);
- }
- else // schedule ourselves for deactivation
- {
- if(s_macDeactivateWindow)
- wxLogDebug(wxT("window=%p SHOULD have been deactivated, oh well!"),s_macDeactivateWindow);
- wxLogDebug(wxT("Scheduling delayed deactivation"));
- s_macDeactivateWindow = this;
- }
- }
-}
-
-// MDI operations
-void wxMDIChildFrame::Maximize()
-{
- wxFrame::Maximize() ;
-}
-
-void wxMDIChildFrame::Restore()
-{
- wxFrame::Restore() ;
-}
-
-void wxMDIChildFrame::Activate()
-{
-}
-
-//-----------------------------------------------------------------------------
-// wxMDIClientWindow
-//-----------------------------------------------------------------------------
-
-wxMDIClientWindow::wxMDIClientWindow()
-{
-}
-
-wxMDIClientWindow::~wxMDIClientWindow()
-{
- DestroyChildren();
-}
-
-bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
-{
-
- m_windowId = (int)NewControlId();
-
- if ( parent )
- {
- parent->AddChild(this);
- }
- m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
-
- wxModelessWindows.Append(this);
- return true;
-}
-
-// Get size *available for subwindows* i.e. excluding menu bar.
-void wxMDIClientWindow::DoGetClientSize(int *x, int *y) const
-{
- wxDisplaySize( x , y ) ;
-}
-
-// Explicitly call default scroll behaviour
-void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
-{
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/menu.cpp
-// Purpose: wxMenu, wxMenuBar, wxMenuItem
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// headers & declarations
-// ============================================================================
-
-// wxWidgets headers
-// -----------------
-
-#include "wx/wxprec.h"
-
-#include "wx/menu.h"
-
-#ifndef WX_PRECOMP
- #include "wx/log.h"
- #include "wx/app.h"
- #include "wx/utils.h"
- #include "wx/window.h"
- #include "wx/frame.h"
- #include "wx/menuitem.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-// other standard headers
-// ----------------------
-#include <string.h>
-
-IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
-IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
-
-// the (popup) menu title has this special id
-static const int idMenuTitle = -2;
-static MenuItemIndex firstUserHelpMenuItem = 0 ;
-
-const short kwxMacMenuBarResource = 1 ;
-const short kwxMacAppleMenuId = 1 ;
-
-// ============================================================================
-// implementation
-// ============================================================================
-static void wxMenubarUnsetInvokingWindow( wxMenu *menu ) ;
-static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win );
-
-// Menus
-
-// Construct a menu with optional title (then use append)
-
-#ifdef __DARWIN__
-short wxMenu::s_macNextMenuId = 3 ;
-#else
-short wxMenu::s_macNextMenuId = 2 ;
-#endif
-
-void wxMenu::Init()
-{
- m_doBreak = false;
- m_startRadioGroup = -1;
-
- // create the menu
- m_macMenuId = s_macNextMenuId++;
- m_hMenu = UMANewMenu(m_macMenuId, m_title, wxFont::GetDefaultEncoding() );
-
- if ( !m_hMenu )
- {
- wxLogLastError(wxT("UMANewMenu failed"));
- }
-
- // if we have a title, insert it in the beginning of the menu
- if ( !m_title.empty() )
- {
- Append(idMenuTitle, m_title) ;
- AppendSeparator() ;
- }
-}
-
-wxMenu::~wxMenu()
-{
- if (MAC_WXHMENU(m_hMenu))
- ::DisposeMenu(MAC_WXHMENU(m_hMenu));
-}
-
-void wxMenu::Break()
-{
- // not available on the mac platform
-}
-
-void wxMenu::Attach(wxMenuBarBase *menubar)
-{
- wxMenuBase::Attach(menubar);
-
- EndRadioGroup();
-}
-
-// function appends a new item or submenu to the menu
-// append a new item or submenu to the menu
-bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
-{
- wxASSERT_MSG( pItem != NULL, wxT("can't append NULL item to the menu") );
-
- if ( pItem->IsSeparator() )
- {
- if ( pos == (size_t)-1 )
- MacAppendMenu(MAC_WXHMENU(m_hMenu), "\p-");
- else
- MacInsertMenuItem(MAC_WXHMENU(m_hMenu), "\p-" , pos);
- }
- else
- {
- wxMenu *pSubMenu = pItem->GetSubMenu() ;
- if ( pSubMenu != NULL )
- {
- wxASSERT_MSG( pSubMenu->m_hMenu != NULL , wxT("invalid submenu added"));
- pSubMenu->m_menuParent = this ;
-
- if (wxMenuBar::MacGetInstalledMenuBar() == GetMenuBar())
- {
- pSubMenu->MacBeforeDisplay( true ) ;
- }
-
- if ( pos == (size_t)-1 )
- UMAAppendSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), wxFont::GetDefaultEncoding() , pSubMenu->m_macMenuId);
- else
- UMAInsertSubMenuItem(MAC_WXHMENU(m_hMenu), pItem->GetText(), wxFont::GetDefaultEncoding() , pos, pSubMenu->m_macMenuId);
- pItem->UpdateItemBitmap() ;
- pItem->UpdateItemStatus() ;
- }
- else
- {
- if ( pos == (size_t)-1 )
- {
- UMAAppendMenuItem(MAC_WXHMENU(m_hMenu), wxT("a") , wxFont::GetDefaultEncoding() );
- pos = CountMenuItems(MAC_WXHMENU(m_hMenu)) ;
- }
- else
- {
- // MacOS counts menu items from 1 and inserts after, therefore having the
- // same effect as wx 0 based and inserting before, we must correct pos
- // after however for updates to be correct
- UMAInsertMenuItem(MAC_WXHMENU(m_hMenu), wxT("a"), wxFont::GetDefaultEncoding(), pos);
- pos += 1 ;
- }
-
- SetMenuItemCommandID( MAC_WXHMENU(m_hMenu) , pos , pItem->GetId() ) ;
- pItem->UpdateItemText() ;
- pItem->UpdateItemBitmap() ;
- pItem->UpdateItemStatus() ;
-
- if ( pItem->GetId() == idMenuTitle )
- {
- UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , pos , false ) ;
- }
- }
- }
- // if we're already attached to the menubar, we must update it
- if ( IsAttached() )
- {
- GetMenuBar()->Refresh();
- }
- return true ;
-}
-
-void wxMenu::EndRadioGroup()
-{
- // we're not inside a radio group any longer
- m_startRadioGroup = -1;
-}
-
-wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
-{
- wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") );
-
- bool check = false;
-
- if ( item->GetKind() == wxITEM_RADIO )
- {
- int count = GetMenuItemCount();
-
- if ( m_startRadioGroup == -1 )
- {
- // start a new radio group
- m_startRadioGroup = count;
-
- // for now it has just one element
- item->SetAsRadioGroupStart();
- item->SetRadioGroupEnd(m_startRadioGroup);
-
- // ensure that we have a checked item in the radio group
- check = true;
- }
- else // extend the current radio group
- {
- // we need to update its end item
- item->SetRadioGroupStart(m_startRadioGroup);
- wxMenuItemList::Node *node = GetMenuItems().Item(m_startRadioGroup);
-
- if ( node )
- {
- node->GetData()->SetRadioGroupEnd(count);
- }
- else
- {
- wxFAIL_MSG( _T("where is the radio group start item?") );
- }
- }
- }
- else // not a radio item
- {
- EndRadioGroup();
- }
-
- if ( !wxMenuBase::DoAppend(item) || !DoInsertOrAppend(item) )
- {
- return NULL;
- }
-
- if ( check )
- {
- // check the item initially
- item->Check(true);
- }
-
- return item;
-}
-
-wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
-{
- if (wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos))
- return item;
- else
- return NULL;
-}
-
-wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
-{
- // we need to find the items position in the child list
- size_t pos;
- wxMenuItemList::Node *node = GetMenuItems().GetFirst();
- for ( pos = 0; node; pos++ )
- {
- if ( node->GetData() == item )
- break;
-
- node = node->GetNext();
- }
-
- // DoRemove() (unlike Remove) can only be called for existing item!
- wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") );
-
- ::DeleteMenuItem(MAC_WXHMENU(m_hMenu) , pos + 1);
-
- if ( IsAttached() )
- {
- // otherwise, the change won't be visible
- GetMenuBar()->Refresh();
- }
-
- // and from internal data structures
- return wxMenuBase::DoRemove(item);
-}
-
-void wxMenu::SetTitle(const wxString& label)
-{
- m_title = label ;
- UMASetMenuTitle(MAC_WXHMENU(m_hMenu) , label , wxFont::GetDefaultEncoding() ) ;
-}
-bool wxMenu::ProcessCommand(wxCommandEvent & event)
-{
- bool processed = false;
-
- // Try the menu's event handler
- if ( !processed && GetEventHandler())
- {
- processed = GetEventHandler()->ProcessEvent(event);
- }
-
- // Try the window the menu was popped up from (and up through the
- // hierarchy)
- wxWindow *win = GetInvokingWindow();
- if ( !processed && win )
- processed = win->GetEventHandler()->ProcessEvent(event);
-
- return processed;
-}
-
-
-// ---------------------------------------------------------------------------
-// other
-// ---------------------------------------------------------------------------
-
-wxWindow *wxMenu::GetWindow() const
-{
- if ( m_invokingWindow != NULL )
- return m_invokingWindow;
- else if ( GetMenuBar() != NULL)
- return (wxWindow *) GetMenuBar()->GetFrame();
-
- return NULL;
-}
-
-// helper functions returning the mac menu position for a certain item, note that this is
-// mac-wise 1 - based, i.e. the first item has index 1 whereas on MSWin it has pos 0
-
-int wxMenu::MacGetIndexFromId( int id )
-{
- size_t pos;
- wxMenuItemList::Node *node = GetMenuItems().GetFirst();
- for ( pos = 0; node; pos++ )
- {
- if ( node->GetData()->GetId() == id )
- break;
-
- node = node->GetNext();
- }
-
- if (!node)
- return 0;
-
- return pos + 1 ;
-}
-
-int wxMenu::MacGetIndexFromItem( wxMenuItem *pItem )
-{
- size_t pos;
- wxMenuItemList::Node *node = GetMenuItems().GetFirst();
- for ( pos = 0; node; pos++ )
- {
- if ( node->GetData() == pItem )
- break;
-
- node = node->GetNext();
- }
-
- if (!node)
- return 0;
-
- return pos + 1 ;
-}
-
-void wxMenu::MacEnableMenu( bool bDoEnable )
-{
- UMAEnableMenuItem(MAC_WXHMENU(m_hMenu) , 0 , bDoEnable ) ;
-
- ::DrawMenuBar() ;
-}
-
-// MacOS needs to know about submenus somewhere within this menu
-// before it can be displayed , also hide special menu items like preferences
-// that are handled by the OS
-void wxMenu::MacBeforeDisplay( bool isSubMenu )
-{
- wxMenuItem* previousItem = NULL ;
- size_t pos ;
- wxMenuItemList::Node *node;
- wxMenuItem *item;
- for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
- {
- item = (wxMenuItem *)node->GetData();
- wxMenu* subMenu = item->GetSubMenu() ;
- if (subMenu)
- {
- subMenu->MacBeforeDisplay( true ) ;
- }
- else
- {
- #if TARGET_CARBON
- if ( UMAGetSystemVersion() >= 0x1000 )
- {
- if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId)
- {
- ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 );
- if ( GetMenuItems().GetCount() == pos + 1 &&
- previousItem != NULL &&
- previousItem->IsSeparator() )
- {
- ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos , kMenuItemAttrHidden, 0 );
- }
- }
- }
- #endif
- }
- previousItem = item ;
- }
-
- if ( isSubMenu )
- ::InsertMenu(MAC_WXHMENU( GetHMenu()), -1);
-
-}
-// undo all changes from the MacBeforeDisplay call
-void wxMenu::MacAfterDisplay( bool isSubMenu )
-{
- if ( isSubMenu )
- ::DeleteMenu(MacGetMenuId());
-
- wxMenuItem* previousItem = NULL ;
- int pos ;
- wxMenuItemList::Node *node;
- wxMenuItem *item;
- for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
- {
- item = (wxMenuItem *)node->GetData();
- wxMenu* subMenu = item->GetSubMenu() ;
- if (subMenu)
- {
- subMenu->MacAfterDisplay( true ) ;
- }
- else
- {
- // no need to undo hidings
- }
- previousItem = item ;
- }
-}
-
-// Menu Bar
-
-/*
-
-Mac Implementation note :
-
-The Mac has only one global menubar, so we attempt to install the currently
-active menubar from a frame, we currently don't take into account mdi-frames
-which would ask for menu-merging
-
-Secondly there is no mac api for changing a menubar that is not the current
-menubar, so we have to wait for preparing the actual menubar until the
-wxMenubar is to be used
-
-We can in subsequent versions use MacInstallMenuBar to provide some sort of
-auto-merge for MDI in case this will be necessary
-
-*/
-
-wxMenuBar* wxMenuBar::s_macInstalledMenuBar = NULL ;
-wxMenuBar* wxMenuBar::s_macCommonMenuBar = NULL ;
-
-void wxMenuBar::Init()
-{
- m_eventHandler = this;
- m_menuBarFrame = NULL;
- m_invokingWindow = (wxWindow*) NULL;
-}
-
-wxMenuBar::wxMenuBar()
-{
- Init();
-}
-
-wxMenuBar::wxMenuBar( long WXUNUSED(style) )
-{
- Init();
-}
-
-
-wxMenuBar::wxMenuBar(size_t count, wxMenu *menus[], const wxString titles[], long WXUNUSED(style))
-{
- Init();
-
- m_titles.Alloc(count);
-
- for ( size_t i = 0; i < count; i++ )
- {
- m_menus.Append(menus[i]);
- m_titles.Add(titles[i]);
-
- menus[i]->Attach(this);
- }
-}
-
-wxMenuBar::~wxMenuBar()
-{
- if (s_macCommonMenuBar == this)
- s_macCommonMenuBar = NULL;
- if (s_macInstalledMenuBar == this)
- {
- ::ClearMenuBar();
- s_macInstalledMenuBar = NULL;
- }
-
-}
-
-void wxMenuBar::Refresh(bool WXUNUSED(eraseBackground), const wxRect *WXUNUSED(rect))
-{
- wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") );
-
- DrawMenuBar();
-}
-
-void wxMenuBar::MacInstallMenuBar()
-{
- if ( s_macInstalledMenuBar == this )
- return ;
-
- wxStAppResource resload ;
-
- Handle menubar = ::GetNewMBar( kwxMacMenuBarResource ) ;
- wxString message ;
- wxCHECK_RET( menubar != NULL, wxT("can't read MBAR resource") );
- ::SetMenuBar( menubar ) ;
-#if TARGET_API_MAC_CARBON
- ::DisposeMenuBar( menubar ) ;
-#else
- ::DisposeHandle( menubar ) ;
-#endif
-
-#if TARGET_API_MAC_OS8
- MenuHandle menu = ::GetMenuHandle( kwxMacAppleMenuId ) ;
- if ( CountMenuItems( menu ) == 2 )
- {
- ::AppendResMenu(menu, 'DRVR');
- }
-#endif
-
- // clean-up the help menu before adding new items
- MenuHandle mh = NULL ;
- if ( UMAGetHelpMenu( &mh , &firstUserHelpMenuItem) == noErr )
- {
- for ( int i = CountMenuItems( mh ) ; i >= firstUserHelpMenuItem ; --i )
- {
- DeleteMenuItem( mh , i ) ;
- }
- }
- else
- {
- mh = NULL ;
- }
-#if TARGET_CARBON
- if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId)
- {
- wxMenuItem *item = FindItem( wxApp::s_macPreferencesMenuItemId , NULL ) ;
- if ( item == NULL || !(item->IsEnabled()) )
- DisableMenuCommand( NULL , kHICommandPreferences ) ;
- else
- EnableMenuCommand( NULL , kHICommandPreferences ) ;
- }
-#endif
- for (size_t i = 0; i < m_menus.GetCount(); i++)
- {
- wxMenuItemList::Node *node;
- wxMenuItem *item;
- int pos ;
- wxMenu* menu = m_menus[i] , *subMenu = NULL ;
-
- if( m_titles[i] == wxT("?") || m_titles[i] == wxT("&?") || m_titles[i] == wxApp::s_macHelpMenuTitleName )
- {
- if ( mh == NULL )
- {
- continue ;
- }
-
- for (pos = 0 , node = menu->GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++)
- {
- item = (wxMenuItem *)node->GetData();
- subMenu = item->GetSubMenu() ;
- if (subMenu)
- {
- // we don't support hierarchical menus in the help menu yet
- }
- else
- {
- if ( item->IsSeparator() )
- {
- if ( mh )
- MacAppendMenu(mh, "\p-" );
- }
- else
- {
- wxAcceleratorEntry* entry = wxAcceleratorEntry::Create( item->GetText() ) ;
-
- if ( item->GetId() == wxApp::s_macAboutMenuItemId )
- {
- UMASetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetText() , wxFont::GetDefaultEncoding() );
- UMAEnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 , true );
- SetMenuItemCommandID( GetMenuHandle( kwxMacAppleMenuId ) , 1 , item->GetId() ) ;
- UMASetMenuItemShortcut( GetMenuHandle( kwxMacAppleMenuId ) , 1 , entry ) ;
- }
- else
- {
- if ( mh )
- {
- UMAAppendMenuItem(mh, item->GetText() , wxFont::GetDefaultEncoding(), entry);
- SetMenuItemCommandID( mh , CountMenuItems(mh) , item->GetId() ) ;
- }
- }
-
- delete entry ;
- }
- }
- }
- }
- else
- {
- UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i], m_font.GetEncoding() ) ;
- m_menus[i]->MacBeforeDisplay(false) ;
- ::InsertMenu(MAC_WXHMENU(m_menus[i]->GetHMenu()), 0);
- }
- }
- ::DrawMenuBar() ;
- s_macInstalledMenuBar = this;
-}
-
-void wxMenuBar::EnableTop(size_t pos, bool enable)
-{
- wxCHECK_RET( IsAttached(), wxT("doesn't work with unattached menubars") );
- m_menus[pos]->MacEnableMenu( enable ) ;
- Refresh();
-}
-
-void wxMenuBar::SetLabelTop(size_t pos, const wxString& label)
-{
- wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") );
-
- m_titles[pos] = label;
-
- if ( !IsAttached() )
- {
- return;
- }
-
- m_menus[pos]->SetTitle( label ) ;
- if (wxMenuBar::s_macInstalledMenuBar == this) // are we currently installed ?
- {
- ::SetMenuBar( GetMenuBar() ) ;
- ::InvalMenuBar() ;
- }
-}
-
-wxString wxMenuBar::GetLabelTop(size_t pos) const
-{
- wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
- wxT("invalid menu index in wxMenuBar::GetLabelTop") );
-
- return m_titles[pos];
-}
-
-int wxMenuBar::FindMenu(const wxString& title)
-{
- wxString menuTitle = wxStripMenuCodes(title);
-
- size_t count = GetMenuCount();
- for ( size_t i = 0; i < count; i++ )
- {
- wxString title = wxStripMenuCodes(m_titles[i]);
- if ( menuTitle == title )
- return i;
- }
-
- return wxNOT_FOUND;
-
-}
-
-
-// ---------------------------------------------------------------------------
-// wxMenuBar construction
-// ---------------------------------------------------------------------------
-
-// ---------------------------------------------------------------------------
-// wxMenuBar construction
-// ---------------------------------------------------------------------------
-
-wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
-{
- wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title);
- if ( !menuOld )
- return NULL;
- m_titles[pos] = title;
-
- if ( IsAttached() )
- {
- if (s_macInstalledMenuBar == this)
- {
- menuOld->MacAfterDisplay( false ) ;
- ::DeleteMenu( menuOld->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
- {
- menu->MacBeforeDisplay( false ) ;
- UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title , m_font.GetEncoding() ) ;
- if ( pos == m_menus.GetCount() - 1)
- {
- ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
- }
- else
- {
- ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ;
- }
- }
- }
-
- Refresh();
- }
-
- return menuOld;
-}
-
-bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
-{
- if ( !wxMenuBarBase::Insert(pos, menu, title) )
- return false;
-
- m_titles.Insert(title, pos);
-
- UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title , m_font.GetEncoding() ) ;
-
- if ( IsAttached() && s_macInstalledMenuBar == this )
- {
- if (s_macInstalledMenuBar == this)
- {
- menu->MacBeforeDisplay( false ) ;
- if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() )
- {
- ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
- }
- else
- {
- ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , m_menus[pos+1]->MacGetMenuId() ) ;
- }
- }
- Refresh();
- }
-
- return true;
-}
-
-wxMenu *wxMenuBar::Remove(size_t pos)
-{
- wxMenu *menu = wxMenuBarBase::Remove(pos);
- if ( !menu )
- return NULL;
-
- if ( IsAttached() )
- {
- if (s_macInstalledMenuBar == this)
- {
- ::DeleteMenu( menu->MacGetMenuId() /* m_menus[pos]->MacGetMenuId() */ ) ;
- }
-
- Refresh();
- }
-
- m_titles.RemoveAt(pos);
-
- return menu;
-}
-
-bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
-{
- WXHMENU submenu = menu ? menu->GetHMenu() : 0;
- wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") );
-
- if ( !wxMenuBarBase::Append(menu, title) )
- return false;
-
- m_titles.Add(title);
-
- UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , title , m_font.GetEncoding() ) ;
-
- if ( IsAttached() )
- {
- if (s_macInstalledMenuBar == this)
- {
- ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
- }
-
- Refresh();
- }
-
- // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables
- // adding menu later on.
- if (m_invokingWindow)
- wxMenubarSetInvokingWindow( menu, m_invokingWindow );
-
- return true;
-}
-
-static void wxMenubarUnsetInvokingWindow( wxMenu *menu )
-{
- menu->SetInvokingWindow( (wxWindow*) NULL );
-
- wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
- while (node)
- {
- wxMenuItem *menuitem = node->GetData();
- if (menuitem->IsSubMenu())
- wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu() );
- node = node->GetNext();
- }
-}
-
-static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win )
-{
- menu->SetInvokingWindow( win );
-
- wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
- while (node)
- {
- wxMenuItem *menuitem = node->GetData();
- if (menuitem->IsSubMenu())
- wxMenubarSetInvokingWindow( menuitem->GetSubMenu() , win );
- node = node->GetNext();
- }
-}
-
-void wxMenuBar::UnsetInvokingWindow()
-{
- m_invokingWindow = (wxWindow*) NULL;
- wxMenuList::Node *node = m_menus.GetFirst();
- while (node)
- {
- wxMenu *menu = node->GetData();
- wxMenubarUnsetInvokingWindow( menu );
- node = node->GetNext();
- }
-}
-
-void wxMenuBar::SetInvokingWindow(wxFrame *frame)
-{
- m_invokingWindow = frame;
- wxMenuList::Node *node = m_menus.GetFirst();
- while (node)
- {
- wxMenu *menu = node->GetData();
- wxMenubarSetInvokingWindow( menu, frame );
- node = node->GetNext();
- }
-}
-
-void wxMenuBar::Detach()
-{
- wxMenuBarBase::Detach() ;
-}
-
-void wxMenuBar::Attach(wxFrame *frame)
-{
- wxMenuBarBase::Attach( frame ) ;
-}
-// ---------------------------------------------------------------------------
-// wxMenuBar searching for menu items
-// ---------------------------------------------------------------------------
-
-// Find the itemString in menuString, and return the item id or wxNOT_FOUND
-int wxMenuBar::FindMenuItem(const wxString& menuString,
- const wxString& itemString) const
-{
- wxString menuLabel = wxStripMenuCodes(menuString);
- size_t count = GetMenuCount();
- for ( size_t i = 0; i < count; i++ )
- {
- wxString title = wxStripMenuCodes(m_titles[i]);
- if ( menuString == title )
- return m_menus[i]->FindItem(itemString);
- }
-
- return wxNOT_FOUND;
-}
-
-wxMenuItem *wxMenuBar::FindItem(int id, wxMenu **itemMenu) const
-{
- if ( itemMenu )
- *itemMenu = NULL;
-
- wxMenuItem *item = NULL;
- size_t count = GetMenuCount();
- for ( size_t i = 0; !item && (i < count); i++ )
- {
- item = m_menus[i]->FindItem(id, itemMenu);
- }
-
- return item;
-}
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/menuitem.cpp
-// Purpose: wxMenuItem implementation
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// headers & declarations
-// ============================================================================
-
-#include "wx/wxprec.h"
-
-#include "wx/menuitem.h"
-#include "wx/stockitem.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/menu.h"
-#endif
-
-#include "wx/mac/uma.h"
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// dynamic classes implementation
-// ----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
-
-// ----------------------------------------------------------------------------
-// wxMenuItem
-// ----------------------------------------------------------------------------
-
-//
-// ctor & dtor
-// -----------
-
-wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
- int id,
- const wxString& text,
- const wxString& strHelp,
- wxItemKind kind,
- wxMenu *pSubMenu)
- : wxMenuItemBase(pParentMenu, id, text, strHelp, kind, pSubMenu)
-{
- // TO DISCUSS on dev : whether we can veto id 0
- // wxASSERT_MSG( id != 0 || pSubMenu != NULL , wxT("A MenuItem ID of Zero does not work under Mac") ) ;
-
- // In other languages there is no difference in naming the Exit/Quit menu item between MacOS and Windows guidelines
- // therefore these item must not be translated
- if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") )
- {
- m_text =wxT("Quit\tCtrl+Q") ;
- }
-
- m_radioGroup.start = -1;
- m_isRadioGroupStart = false;
-}
-
-wxMenuItem::~wxMenuItem()
-{
-}
-
-// change item state
-// -----------------
-
-void wxMenuItem::SetBitmap(const wxBitmap& bitmap)
-{
- m_bitmap = bitmap;
- UpdateItemBitmap() ;
-}
-
-void wxMenuItem::UpdateItemBitmap()
-{
- if ( !m_parentMenu )
- return ;
-
- MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
- MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
- if( mhandle == NULL || index == 0)
- return ;
-
- if ( m_bitmap.Ok() )
- {
- ControlButtonContentInfo info ;
- wxMacCreateBitmapButton( &info , m_bitmap , kControlContentCIconHandle ) ;
- if ( info.contentType != kControlNoContent )
- {
- if ( info.contentType == kControlContentCIconHandle )
- SetMenuItemIconHandle( mhandle , index ,
- kMenuColorIconType , (Handle) info.u.cIconHandle ) ;
- }
-
- }
-}
-
-void wxMenuItem::UpdateItemStatus()
-{
- if ( !m_parentMenu )
- return ;
-
-#if TARGET_CARBON
- if ( UMAGetSystemVersion() >= 0x1000 && GetId() == wxApp::s_macPreferencesMenuItemId)
- {
- if ( !IsEnabled() )
- DisableMenuCommand( NULL , kHICommandPreferences ) ;
- else
- EnableMenuCommand( NULL , kHICommandPreferences ) ;
- }
- if ( UMAGetSystemVersion() >= 0x1000 && GetId() == wxApp::s_macExitMenuItemId)
- {
- if ( !IsEnabled() )
- DisableMenuCommand( NULL , kHICommandQuit ) ;
- else
- EnableMenuCommand( NULL , kHICommandQuit ) ;
- }
-#endif
- {
- MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
- MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
- if( mhandle == NULL || index == 0)
- return ;
-
- UMAEnableMenuItem( mhandle , index , m_isEnabled ) ;
- if ( IsCheckable() && IsChecked() )
- ::SetItemMark( mhandle , index , 0x12 ) ; // checkmark
- else
- ::SetItemMark( mhandle , index , 0 ) ; // no mark
-
- UMASetMenuItemText( mhandle , index , m_text , wxFont::GetDefaultEncoding() ) ;
- wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ;
- UMASetMenuItemShortcut( mhandle , index , entry ) ;
- delete entry ;
- }
-}
-
-void wxMenuItem::UpdateItemText()
-{
- if ( !m_parentMenu )
- return ;
-
- MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
- MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
- if( mhandle == NULL || index == 0)
- return ;
-
- wxString text = m_text;
- if (text.IsEmpty() && !IsSeparator())
- {
- wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?"));
- text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC);
- }
-
- UMASetMenuItemText( mhandle , index , text , wxFont::GetDefaultEncoding() ) ;
- wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( text ) ;
- UMASetMenuItemShortcut( mhandle , index , entry ) ;
- delete entry ;
-}
-
-
-void wxMenuItem::Enable(bool bDoEnable)
-{
- if ( m_isEnabled != bDoEnable )
- {
- wxMenuItemBase::Enable( bDoEnable ) ;
- UpdateItemStatus() ;
- }
-}
-void wxMenuItem::UncheckRadio()
-{
- if ( m_isChecked )
- {
- wxMenuItemBase::Check( false ) ;
- UpdateItemStatus() ;
- }
-}
-
-void wxMenuItem::Check(bool bDoCheck)
-{
- wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") );
-
- if ( m_isChecked != bDoCheck )
- {
- if ( GetKind() == wxITEM_RADIO )
- {
- if ( bDoCheck )
- {
- wxMenuItemBase::Check( bDoCheck ) ;
- UpdateItemStatus() ;
-
- // get the index of this item in the menu
- const wxMenuItemList& items = m_parentMenu->GetMenuItems();
- int pos = items.IndexOf(this);
- wxCHECK_RET( pos != wxNOT_FOUND,
- _T("menuitem not found in the menu items list?") );
-
- // get the radio group range
- int start,
- end;
-
- if ( m_isRadioGroupStart )
- {
- // we already have all information we need
- start = pos;
- end = m_radioGroup.end;
- }
- else // next radio group item
- {
- // get the radio group end from the start item
- start = m_radioGroup.start;
- end = items.Item(start)->GetData()->m_radioGroup.end;
- }
-
- // also uncheck all the other items in this radio group
- wxMenuItemList::Node *node = items.Item(start);
- for ( int n = start; n <= end && node; n++ )
- {
- if ( n != pos )
- {
- ((wxMenuItem*)node->GetData())->UncheckRadio();
- }
- node = node->GetNext();
- }
- }
- }
- else
- {
- wxMenuItemBase::Check( bDoCheck ) ;
- UpdateItemStatus() ;
- }
- }
-}
-
-void wxMenuItem::SetText(const wxString& text)
-{
- // don't do anything if label didn't change
- if ( m_text == text )
- return;
-
- wxMenuItemBase::SetText(text);
-
- UpdateItemText() ;
-}
-
-// radio group stuff
-// -----------------
-
-void wxMenuItem::SetAsRadioGroupStart()
-{
- m_isRadioGroupStart = true;
-}
-
-void wxMenuItem::SetRadioGroupStart(int start)
-{
- wxASSERT_MSG( !m_isRadioGroupStart,
- _T("should only be called for the next radio items") );
-
- m_radioGroup.start = start;
-}
-
-void wxMenuItem::SetRadioGroupEnd(int end)
-{
- wxASSERT_MSG( m_isRadioGroupStart,
- _T("should only be called for the first radio item") );
-
- m_radioGroup.end = end;
-}
-
-// ----------------------------------------------------------------------------
-// wxMenuItemBase
-// ----------------------------------------------------------------------------
-
-/* static */
-wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
-{
- return wxStripMenuCodes(text);
-}
-
-wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
- int id,
- const wxString& name,
- const wxString& help,
- wxItemKind kind,
- wxMenu *subMenu)
-{
- return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/metafile.cpp
-// Purpose: wxMetaFile, wxMetaFileDC etc. These classes are optional.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_METAFILE
-
-#include "wx/metafile.h"
-
-#ifndef WX_PRECOMP
- #include "wx/utils.h"
- #include "wx/app.h"
-#endif
-
-#include "wx/clipbrd.h"
-
-#include "wx/mac/private.h"
-
-#include <stdio.h>
-#include <string.h>
-
-extern bool wxClipboardIsOpen;
-
-IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
-
-/*
- * Metafiles
- * Currently, the only purpose for making a metafile is to put
- * it on the clipboard.
- */
-
-wxMetafileRefData::wxMetafileRefData(void)
-{
- m_metafile = 0;
-}
-
-wxMetafileRefData::~wxMetafileRefData(void)
-{
- if (m_metafile)
- {
- KillPicture( (PicHandle) m_metafile ) ;
- m_metafile = 0;
- }
-}
-
-wxMetaFile::wxMetaFile(const wxString& file)
-{
- m_refData = new wxMetafileRefData;
-
-
- M_METAFILEDATA->m_metafile = 0;
- wxASSERT_MSG( file.IsEmpty() , wxT("no file based metafile support yet") ) ;
-/*
- if (!file.empty())
- M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
-*/
-}
-
-wxMetaFile::~wxMetaFile()
-{
-}
-
-bool wxMetaFile::SetClipboard(int width, int height)
-{
-#if wxUSE_DRAG_AND_DROP
- //TODO finishi this port , we need the data obj first
- if (!m_refData)
- return false;
-
- bool alreadyOpen=wxTheClipboard->IsOpened() ;
- if (!alreadyOpen)
- {
- wxTheClipboard->Open();
- wxTheClipboard->Clear();
- }
- wxDataObject *data =
- new wxMetafileDataObject( *this) ;
- bool success = wxTheClipboard->SetData(data);
- if (!alreadyOpen)
- wxTheClipboard->Close();
- return (bool) success;
-#endif
- return true ;
-}
-
-void wxMetafile::SetHMETAFILE(WXHMETAFILE mf)
-{
- if (!m_refData)
- m_refData = new wxMetafileRefData;
- if ( M_METAFILEDATA->m_metafile )
- KillPicture( (PicHandle) M_METAFILEDATA->m_metafile ) ;
-
- M_METAFILEDATA->m_metafile = mf;
-}
-
-bool wxMetaFile::Play(wxDC *dc)
-{
- if (!m_refData)
- return false;
-
- if (!dc->Ok() )
- return false;
-
- {
- wxMacPortSetter helper( dc ) ;
- PicHandle pict = (PicHandle) GetHMETAFILE() ;
- DrawPicture( pict , &(**pict).picFrame ) ;
- }
- return true;
-}
-
-wxSize wxMetaFile::GetSize() const
-{
- wxSize size = wxDefaultSize ;
- if ( Ok() )
- {
- PicHandle pict = (PicHandle) GetHMETAFILE() ;
- Rect &r = (**pict).picFrame ;
- size.x = r.right - r.left ;
- size.y = r.bottom - r.top ;
- }
-
- return size;
-}
-
-/*
- * Metafile device context
- *
- */
-
-// New constructor that takes origin and extent. If you use this, don't
-// give origin/extent arguments to wxMakeMetaFilePlaceable.
-
-wxMetaFileDC::wxMetaFileDC(const wxString& filename ,
- int width , int height ,
- const wxString& WXUNUSED(description) )
-{
- wxASSERT_MSG( width == 0 || height == 0 , _T("no arbitration of metafilesize supported") ) ;
- wxASSERT_MSG( filename.empty() , _T("no file based metafile support yet")) ;
-
- m_metaFile = new wxMetaFile(filename) ;
- Rect r={0,0,height,width} ;
-
- RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ;
- CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
-
- m_metaFile->SetHMETAFILE( OpenPicture( &r ) ) ;
- ::GetPort( (GrafPtr*) &m_macPort ) ;
- m_ok = true ;
-
- SetMapMode(wxMM_TEXT);
-}
-
-wxMetaFileDC::~wxMetaFileDC()
-{
-}
-
-void wxMetaFileDC::DoGetSize(int *width, int *height) const
-{
- wxCHECK_RET( m_metaFile , _T("GetSize() doesn't work without a metafile") );
-
- wxSize sz = m_metaFile->GetSize() ;
- if (width) (*width) = sz.x;
- if (height) (*height) = sz.y;
-}
-
-wxMetaFile *wxMetaFileDC::Close()
-{
- ClosePicture() ;
- return m_metaFile;
-}
-
-#if wxUSE_DATAOBJ
-size_t wxMetafileDataObject::GetDataSize() const
-{
- return GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ;
-}
-
-bool wxMetafileDataObject::GetDataHere(void *buf) const
-{
- memcpy( buf , (*(PicHandle)(*((wxMetafile*)&m_metafile)).GetHMETAFILE()) ,
- GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ) ;
- return true ;
-}
-
-bool wxMetafileDataObject::SetData(size_t len, const void *buf)
-{
- Handle handle = NewHandle( len ) ;
- SetHandleSize( handle , len ) ;
- memcpy( *handle , buf , len ) ;
- m_metafile.SetHMETAFILE( handle ) ;
- return true ;
-}
-#endif
-
-#endif
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/mimetype.cpp
-// Purpose: classes and functions to manage MIME types
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 23.09.98
-// RCS-ID: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows licence (part of wxExtra library)
-/////////////////////////////////////////////////////////////////////////////
-
-// for compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/mac/mimetype.h"
-
-#ifndef WX_PRECOMP
- #include "wx/dynarray.h"
- #include "wx/string.h"
- #include "wx/intl.h"
- #include "wx/log.h"
- #if wxUSE_GUI
- #include "wx/icon.h"
- #endif
-#endif //WX_PRECOMP
-
-
-#include "wx/file.h"
-#include "wx/confbase.h"
-
-// other standard headers
-#include <ctype.h>
-
-// in case we're compiling in non-GUI mode
-class WXDLLEXPORT wxIcon;
-
-bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
-{
- return false;
-}
-
-bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
-{
- return false;
-}
-
-bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
-{
- return false;
-}
-
-// @@ this function is half implemented
-bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
-{
- return false;
-}
-
-bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
-{
- if ( !m_strFileType.empty() )
- {
- *mimeType = m_strFileType ;
- return true ;
- }
- else
- return false;
-}
-
-bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
-{
- wxString s;
-
- if (GetMimeType(&s))
- {
- mimeTypes.Clear();
- mimeTypes.Add(s);
- return true;
- }
- else
- return false;
-}
-
-bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
-{
- // no such file type or no value or incorrect icon entry
- return false;
-}
-
-bool wxFileTypeImpl::GetDescription(wxString *desc) const
-{
- return false;
-}
-
-size_t
-wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
- const wxFileType::MessageParameters& params) const
-{
- wxFAIL_MSG( _T("wxFileTypeImpl::GetAllCommands() not yet implemented") );
- return 0;
-}
-
-void
-wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
-{
- wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Initialize() not yet implemented") );
-}
-
-void
-wxMimeTypesManagerImpl::ClearData()
-{
- wxFAIL_MSG( _T("wxMimeTypesManagerImpl::ClearData() not yet implemented") );
-}
-
-// extension -> file type
-wxFileType *
-wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
-{
- wxString ext = e ;
- ext = ext.Lower() ;
- if ( ext == wxT("txt") )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("text/text"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == wxT("htm") || ext == wxT("html") )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("text/html"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == wxT("gif") )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("image/gif"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == wxT("png" ))
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("image/png"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == wxT("jpg" )|| ext == wxT("jpeg") )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("image/jpeg"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == wxT("bmp") )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("image/bmp"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == wxT("tif") || ext == wxT("tiff") )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("image/tiff"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == wxT("xpm") )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("image/xpm"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
- else if ( ext == wxT("xbm") )
- {
- wxFileType *fileType = new wxFileType;
- fileType->m_impl->SetFileType(wxT("image/xbm"));
- fileType->m_impl->SetExt(ext);
- return fileType;
- }
-
- // unknown extension
- return NULL;
-}
-
-// MIME type -> extension -> file type
-wxFileType *
-wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
-{
- return NULL;
-}
-
-size_t wxMimeTypesManagerImpl::EnumAllFileTypes(wxArrayString& mimetypes)
-{
- // VZ: don't know anything about this for Mac
- wxFAIL_MSG( _T("wxMimeTypesManagerImpl::EnumAllFileTypes() not yet implemented") );
-
- return 0;
-}
-
-wxFileType *
-wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
-{
- wxFAIL_MSG( _T("wxMimeTypesManagerImpl::Associate() not yet implemented") );
-
- return NULL;
-}
-
-bool
-wxMimeTypesManagerImpl::Unassociate(wxFileType *ft)
-{
- return false;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: minifram.cpp
-// Purpose: wxMiniFrame. Optional; identical to wxFrame if not supported.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/minifram.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame)
+++ /dev/null
-/*
- File: DirectoryCopy.c
-
- Contains: A robust, general purpose directory copy routine.
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <2> 2/7/01 JL Added standard header. Updated names of includes.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-#include <MacTypes.h>
-#include <MacErrors.h>
-#include <MacMemory.h>
-#include <Files.h>
-#include <Script.h>
-#include <Math64.h>
-
-#define __COMPILINGMOREFILES
-
-#include "MoreFiles.h"
-#include "MoreFilesExtras.h"
-#include "MoreDesktopMgr.h"
-#include "FileCopy.h"
-#include "DirectoryCopy.h"
-
-/*****************************************************************************/
-
-/* local constants */
-
-enum
-{
- dirCopyBigCopyBuffSize = 0x00004000,
- dirCopyMinCopyBuffSize = 0x00000200
-};
-
-
-/*****************************************************************************/
-
-/* local data structures */
-
-/* The EnumerateGlobals structure is used to minimize the amount of
-** stack space used when recursively calling CopyLevel and to hold
-** global information that might be needed at any time. */
-
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=mac68k
-#endif
-struct EnumerateGlobals
-{
- Ptr copyBuffer; /* pointer to buffer used for file copy operations */
- long bufferSize; /* the size of the copy buffer */
- CopyErrProcPtr errorHandler; /* pointer to error handling function */
- CopyFilterProcPtr copyFilterProc; /* pointer to filter function */
- OSErr error; /* temporary holder of results - saves 2 bytes of stack each level */
- Boolean bailout; /* set to true to by error handling function if fatal error */
- short destinationVRefNum; /* the destination vRefNum */
- Str63 itemName; /* the name of the current item */
- CInfoPBRec myCPB; /* the parameter block used for PBGetCatInfo calls */
-};
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=reset
-#endif
-
-typedef struct EnumerateGlobals EnumerateGlobals;
-typedef EnumerateGlobals *EnumerateGlobalsPtr;
-
-
-/* The PreflightGlobals structure is used to minimize the amount of
-** stack space used when recursively calling GetLevelSize and to hold
-** global information that might be needed at any time. */
-
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=mac68k
-#endif
-struct PreflightGlobals
-{
- OSErr result; /* temporary holder of results - saves 2 bytes of stack each level */
- Str63 itemName; /* the name of the current item */
- CInfoPBRec myCPB; /* the parameter block used for PBGetCatInfo calls */
-
- unsigned long dstBlksPerAllocBlk; /* the number of 512 byte blocks per allocation block on destination */
-
- unsigned long allocBlksNeeded; /* the total number of allocation blocks needed */
-
- unsigned long tempBlocks; /* temporary storage for calculations (save some stack space) */
- CopyFilterProcPtr copyFilterProc; /* pointer to filter function */
-};
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=reset
-#endif
-
-typedef struct PreflightGlobals PreflightGlobals;
-typedef PreflightGlobals *PreflightGlobalsPtr;
-
-/*****************************************************************************/
-
-/* static prototypes */
-
-static void GetLevelSize(long currentDirID,
- PreflightGlobals *theGlobals);
-
-static OSErr PreflightDirectoryCopySpace(short srcVRefNum,
- long srcDirID,
- short dstVRefNum,
- CopyFilterProcPtr copyFilterProc,
- Boolean *spaceOK);
-
-static void CopyLevel(long sourceDirID,
- long dstDirID,
- EnumerateGlobals *theGlobals);
-
-/*****************************************************************************/
-
-static void GetLevelSize(long currentDirID,
- PreflightGlobals *theGlobals)
-{
- short index = 1;
-
- do
- {
- theGlobals->myCPB.dirInfo.ioFDirIndex = index;
- theGlobals->myCPB.dirInfo.ioDrDirID = currentDirID; /* we need to do this every time */
- /* through, since GetCatInfo */
- /* returns ioFlNum in this field */
- theGlobals->result = PBGetCatInfoSync(&theGlobals->myCPB);
- if ( theGlobals->result == noErr )
- {
- if ( (theGlobals->copyFilterProc == NULL) ||
- CallCopyFilterProc(theGlobals->copyFilterProc, &theGlobals->myCPB) ) /* filter if filter proc was supplied */
- {
- /* Either there's no filter proc OR the filter proc says to use this item */
- if ( (theGlobals->myCPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* we have a directory */
-
- GetLevelSize(theGlobals->myCPB.dirInfo.ioDrDirID, theGlobals); /* recurse */
- theGlobals->result = noErr; /* clear error return on way back */
- }
- else
- {
- /* We have a file - add its allocation blocks to allocBlksNeeded. */
- /* Since space on Mac OS disks is always allocated in allocation blocks, */
- /* this takes into account rounding up to the end of an allocation block. */
-
- /* get number of 512-byte blocks needed for data fork */
- if ( ((unsigned long)theGlobals->myCPB.hFileInfo.ioFlLgLen & 0x000001ff) != 0 )
- {
- theGlobals->tempBlocks = ((unsigned long)theGlobals->myCPB.hFileInfo.ioFlLgLen >> 9) + 1;
- }
- else
- {
- theGlobals->tempBlocks = (unsigned long)theGlobals->myCPB.hFileInfo.ioFlLgLen >> 9;
- }
- /* now, calculate number of new allocation blocks needed for the data fork and add it to the total */
- if ( theGlobals->tempBlocks % theGlobals->dstBlksPerAllocBlk )
- {
- theGlobals->allocBlksNeeded += (theGlobals->tempBlocks / theGlobals->dstBlksPerAllocBlk) + 1;
- }
- else
- {
- theGlobals->allocBlksNeeded += theGlobals->tempBlocks / theGlobals->dstBlksPerAllocBlk;
- }
-
- /* get number of 512-byte blocks needed for resource fork */
- if ( ((unsigned long)theGlobals->myCPB.hFileInfo.ioFlRLgLen & 0x000001ff) != 0 )
- {
- theGlobals->tempBlocks = ((unsigned long)theGlobals->myCPB.hFileInfo.ioFlRLgLen >> 9) + 1;
- }
- else
- {
- theGlobals->tempBlocks = (unsigned long)theGlobals->myCPB.hFileInfo.ioFlRLgLen >> 9;
- }
- /* now, calculate number of new allocation blocks needed for the resource fork and add it to the total */
- if ( theGlobals->tempBlocks % theGlobals->dstBlksPerAllocBlk )
- {
- theGlobals->allocBlksNeeded += (theGlobals->tempBlocks / theGlobals->dstBlksPerAllocBlk) + 1;
- }
- else
- {
- theGlobals->allocBlksNeeded += theGlobals->tempBlocks / theGlobals->dstBlksPerAllocBlk;
- }
- }
- }
- }
- ++index;
- } while ( theGlobals->result == noErr );
-}
-
-/*****************************************************************************/
-
-static OSErr PreflightDirectoryCopySpace(short srcVRefNum,
- long srcDirID,
- short dstVRefNum,
- CopyFilterProcPtr copyFilterProc,
- Boolean *spaceOK)
-{
- XVolumeParam pb;
- OSErr error;
- unsigned long dstFreeBlocks;
- PreflightGlobals theGlobals;
-
- error = XGetVolumeInfoNoName(NULL, dstVRefNum, &pb);
- if ( error == noErr )
- {
- /* Convert freeBytes to free disk blocks (512-byte blocks) */
- dstFreeBlocks = U32SetU(U64ShiftRight(pb.ioVFreeBytes, 9));
-
- /* get allocation block size (always multiple of 512) and divide by 512
- to get number of 512-byte blocks per allocation block */
- theGlobals.dstBlksPerAllocBlk = ((unsigned long)pb.ioVAlBlkSiz >> 9);
-
- theGlobals.allocBlksNeeded = 0;
-
- theGlobals.myCPB.dirInfo.ioNamePtr = theGlobals.itemName;
- theGlobals.myCPB.dirInfo.ioVRefNum = srcVRefNum;
-
- theGlobals.copyFilterProc = copyFilterProc;
-
- GetLevelSize(srcDirID, &theGlobals);
-
- /* Is there enough room on the destination volume for the source file? */
- /* Note: This will work because the largest number of disk blocks supported */
- /* on a 2TB volume is 0xffffffff and (allocBlksNeeded * dstBlksPerAllocBlk) */
- /* will always be less than 0xffffffff. */
- *spaceOK = ((theGlobals.allocBlksNeeded * theGlobals.dstBlksPerAllocBlk) <= dstFreeBlocks);
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-static void CopyLevel(long sourceDirID,
- long dstDirID,
- EnumerateGlobals *theGlobals)
-{
- long currentSrcDirID = 0 ;
- long newDirID;
- short index = 1;
-
- do
- {
- /* Get next source item at the current directory level */
-
- theGlobals->myCPB.dirInfo.ioFDirIndex = index;
- theGlobals->myCPB.dirInfo.ioDrDirID = sourceDirID;
- theGlobals->error = PBGetCatInfoSync(&theGlobals->myCPB);
-
- if ( theGlobals->error == noErr )
- {
- if ( (theGlobals->copyFilterProc == NULL) ||
- CallCopyFilterProc(theGlobals->copyFilterProc, &theGlobals->myCPB) ) /* filter if filter proc was supplied */
- {
- /* Either there's no filter proc OR the filter proc says to use this item */
-
- /* We have an item. Is it a file or directory? */
- if ( (theGlobals->myCPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* We have a directory */
-
- /* Create a new directory at the destination. No errors allowed! */
- theGlobals->error = DirCreate(theGlobals->destinationVRefNum, dstDirID, theGlobals->itemName, &newDirID);
- if ( theGlobals->error == noErr )
- {
- /* Save the current source directory ID where we can get it when we come back
- ** from recursion land. */
- currentSrcDirID = theGlobals->myCPB.dirInfo.ioDrDirID;
-
- /* Dive again (copy the directory level we just found below this one) */
- CopyLevel(theGlobals->myCPB.dirInfo.ioDrDirID, newDirID, theGlobals);
-
- if ( !theGlobals->bailout )
- {
- /* Copy comment from old to new directory. */
- /* Ignore the result because we really don't care if it worked or not. */
- (void) DTCopyComment(theGlobals->myCPB.dirInfo.ioVRefNum, currentSrcDirID, NULL, theGlobals->destinationVRefNum, newDirID, NULL);
-
- /* Copy directory attributes (dates, etc.) to newDirID. */
- /* No errors allowed */
- theGlobals->error = CopyFileMgrAttributes(theGlobals->myCPB.dirInfo.ioVRefNum, currentSrcDirID, NULL, theGlobals->destinationVRefNum, newDirID, NULL, true);
-
- /* handle any errors from CopyFileMgrAttributes */
- if ( theGlobals->error != noErr )
- {
- if ( theGlobals->errorHandler != NULL )
- {
- theGlobals->bailout = CallCopyErrProc(theGlobals->errorHandler, theGlobals->error, copyDirFMAttributesOp,
- theGlobals->myCPB.dirInfo.ioVRefNum, currentSrcDirID, NULL,
- theGlobals->destinationVRefNum, newDirID, NULL);
- }
- else
- {
- /* If you don't handle the errors with an error handler, */
- /* then the copy stops here. */
- theGlobals->bailout = true;
- }
- }
- }
- }
- else /* error handling for DirCreate */
- {
- /* note that currentSrcDirID has not been initialised when entering this execution path */
- if ( theGlobals->errorHandler != NULL )
- {
- theGlobals->bailout = CallCopyErrProc(theGlobals->errorHandler, theGlobals->error, dirCreateOp,
- theGlobals->myCPB.dirInfo.ioVRefNum, currentSrcDirID, NULL,
- theGlobals->destinationVRefNum, dstDirID, theGlobals->itemName);
- }
- else
- {
- /* If you don't handle the errors with an error handler, */
- /* then the copy stops here. */
- theGlobals->bailout = true;
- }
- }
-
- if ( !theGlobals->bailout )
- {
- /* clear error return on way back if we aren't bailing out */
- theGlobals->error = noErr;
- }
- }
- else
- {
- /* We have a file, so copy it */
-
- theGlobals->error = FileCopy(theGlobals->myCPB.hFileInfo.ioVRefNum,
- theGlobals->myCPB.hFileInfo.ioFlParID,
- theGlobals->itemName,
- theGlobals->destinationVRefNum,
- dstDirID,
- NULL,
- NULL,
- theGlobals->copyBuffer,
- theGlobals->bufferSize,
- false);
-
- /* handle any errors from FileCopy */
- if ( theGlobals->error != noErr )
- {
- if ( theGlobals->errorHandler != NULL )
- {
- theGlobals->bailout = CallCopyErrProc(theGlobals->errorHandler, theGlobals->error, fileCopyOp,
- theGlobals->myCPB.hFileInfo.ioVRefNum, theGlobals->myCPB.hFileInfo.ioFlParID, theGlobals->itemName,
- theGlobals->destinationVRefNum, dstDirID, NULL);
- if ( !theGlobals->bailout )
- {
- /* If the CopyErrProc handled the problem, clear the error here */
- theGlobals->error = noErr;
- }
- }
- else
- {
- /* If you don't handle the errors with an error handler, */
- /* then the copy stops here. */
- theGlobals->bailout = true;
- }
- }
- }
- }
- }
- else
- { /* error handling for PBGetCatInfo */
- /* it's normal to get a fnfErr when indexing; that only means you've hit the end of the directory */
- if ( theGlobals->error != fnfErr )
- {
- if ( theGlobals->errorHandler != NULL )
- {
- theGlobals->bailout = CallCopyErrProc(theGlobals->errorHandler, theGlobals->error, getNextItemOp,
- theGlobals->myCPB.dirInfo.ioVRefNum, sourceDirID, NULL, 0, 0, NULL);
- if ( !theGlobals->bailout )
- {
- /* If the CopyErrProc handled the problem, clear the error here */
- theGlobals->error = noErr;
- }
- }
- else
- {
- /* If you don't handle the errors with an error handler, */
- /* then the copy stops here. */
- theGlobals->bailout = true;
- }
- }
- }
- ++index; /* prepare to get next item */
- } while ( (theGlobals->error == noErr) && (!theGlobals->bailout) ); /* time to fall back a level? */
-}
-
-/*****************************************************************************/
-
-pascal OSErr FilteredDirectoryCopy(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName,
- ConstStr255Param copyName,
- void *copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler,
- CopyFilterProcPtr copyFilterProc)
-{
- EnumerateGlobals theGlobals;
- Boolean isDirectory;
- OSErr error;
- Boolean ourCopyBuffer = false;
- Str63 srcDirName, oldDiskName;
- Boolean spaceOK;
-
- /* Make sure a copy buffer is allocated. */
- if ( copyBufferPtr == NULL )
- {
- /* The caller didn't supply a copy buffer so grab one from the application heap.
- ** Try to get a big copy buffer, if we can't, try for a 512-byte buffer.
- ** If 512 bytes aren't available, we're in trouble. */
- copyBufferSize = dirCopyBigCopyBuffSize;
- copyBufferPtr = NewPtr(copyBufferSize);
- if ( copyBufferPtr == NULL )
- {
- copyBufferSize = dirCopyMinCopyBuffSize;
- copyBufferPtr = NewPtr(copyBufferSize);
- if ( copyBufferPtr == NULL )
- {
- return ( memFullErr );
- }
- }
- ourCopyBuffer = true;
- }
-
- /* Get the real dirID where we're copying from and make sure it is a directory. */
- error = GetDirectoryID(srcVRefNum, srcDirID, srcName, &srcDirID, &isDirectory);
- if ( error != noErr )
- {
- goto ErrorExit;
- }
- if ( !isDirectory )
- {
- error = dirNFErr;
- goto ErrorExit;
- }
-
- /* Special case destination if it is the root parent directory. */
- /* Since you can't create the root directory, this is needed if */
- /* you want to copy a directory's content to a disk's root directory. */
- if ( (dstDirID == fsRtParID) && (dstName == NULL) )
- {
- dstDirID = fsRtParID;
- isDirectory = true;
- error = noErr;
- }
- else
- {
- /* Get the real dirID where we're going to put the copy and make sure it is a directory. */
- error = GetDirectoryID(dstVRefNum, dstDirID, dstName, &dstDirID, &isDirectory);
- if ( error != noErr )
- {
- goto ErrorExit;
- }
- if ( !isDirectory )
- {
- error = dirNFErr;
- goto ErrorExit;
- }
- }
-
- /* Get the real vRefNum of both the source and destination */
- error = DetermineVRefNum(srcName, srcVRefNum, &srcVRefNum);
- if ( error != noErr )
- {
- goto ErrorExit;
- }
- error = DetermineVRefNum(dstName, dstVRefNum, &dstVRefNum);
- if ( error != noErr )
- {
- goto ErrorExit;
- }
-
- if ( preflight )
- {
- error = PreflightDirectoryCopySpace(srcVRefNum, srcDirID, dstVRefNum, copyFilterProc, &spaceOK);
- if ( error != noErr )
- {
- goto ErrorExit;
- }
- if ( !spaceOK )
- {
- error = dskFulErr; /* not enough room on destination */
- goto ErrorExit;
- }
- }
-
- /* Create the new directory in the destination directory with the */
- /* same name as the source directory. */
- error = GetDirName(srcVRefNum, srcDirID, srcDirName);
- if ( error != noErr )
- {
- goto ErrorExit;
- }
-
- /* Again, special case destination if the destination is the */
- /* root parent directory. This time, we'll rename the disk to */
- /* the source directory name. */
- if ( dstDirID == fsRtParID )
- {
- /* Get the current name of the destination disk */
- error = GetDirName(dstVRefNum, fsRtDirID, oldDiskName);
- if ( error == noErr )
- {
- /* use the copyName as srcDirName if supplied */
- if ( copyName != NULL )
- {
- /* make a copy since copyName is a const input */
- BlockMoveData(copyName, srcDirName, sizeof(Str31));
- }
- /* Shorten the name if it's too long to be the volume name */
- TruncPString(srcDirName, srcDirName, 27);
-
- /* Rename the disk */
- error = HRename(dstVRefNum, fsRtParID, oldDiskName, srcDirName);
-
- /* and copy to the root directory */
- dstDirID = fsRtDirID;
- }
- }
- else
- {
- /* use the copyName as srcDirName if supplied */
- error = DirCreate(dstVRefNum, dstDirID, ((copyName != NULL) ? copyName : srcDirName), &dstDirID);
- }
- if ( error != noErr )
- {
- /* handle any errors from DirCreate */
- if ( copyErrHandler != NULL )
- {
- if ( CallCopyErrProc(copyErrHandler, error, dirCreateOp,
- srcVRefNum, srcDirID, NULL,
- dstVRefNum, dstDirID, srcDirName) )
- {
- goto ErrorExit;
- }
- else
- {
- /* If the CopyErrProc handled the problem, clear the error here */
- /* and continue */
- error = noErr;
- }
- }
- else
- {
- /* If you don't handle the errors with an error handler, */
- /* then the copy stops here. */
- goto ErrorExit;
- }
- }
-
- /* dstDirID is now the newly created directory! */
-
- /* Set up the globals we need to access from the recursive routine. */
- theGlobals.copyBuffer = (Ptr)copyBufferPtr;
- theGlobals.bufferSize = copyBufferSize;
- theGlobals.destinationVRefNum = dstVRefNum; /* so we can get to it always */
- theGlobals.myCPB.hFileInfo.ioNamePtr = (StringPtr)&theGlobals.itemName;
- theGlobals.myCPB.hFileInfo.ioVRefNum = srcVRefNum;
- theGlobals.errorHandler = copyErrHandler;
- theGlobals.bailout = false;
- theGlobals.copyFilterProc = copyFilterProc;
-
- /* Here we go into recursion land... */
- CopyLevel(srcDirID, dstDirID, &theGlobals);
- error = theGlobals.error; /* get the result */
-
- if ( !theGlobals.bailout )
- {
- /* Copy comment from source to destination directory. */
- /* Ignore the result because we really don't care if it worked or not. */
- (void) DTCopyComment(srcVRefNum, srcDirID, NULL, dstVRefNum, dstDirID, NULL);
-
- /* Copy the File Manager attributes */
- error = CopyFileMgrAttributes(srcVRefNum, srcDirID, NULL,
- dstVRefNum, dstDirID, NULL, true);
-
- /* handle any errors from CopyFileMgrAttributes */
- if ( (error != noErr) && (copyErrHandler != NULL) )
- {
- theGlobals.bailout = CallCopyErrProc(copyErrHandler, error, copyDirFMAttributesOp,
- srcVRefNum, srcDirID, NULL,
- dstVRefNum, dstDirID, NULL);
- }
- }
-
-ErrorExit:
- /* Get rid of the copy buffer if we allocated it. */
- if ( ourCopyBuffer )
- {
- DisposePtr((Ptr)copyBufferPtr);
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DirectoryCopy(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName,
- ConstStr255Param copyName,
- void *copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler)
-{
- return ( FilteredDirectoryCopy(srcVRefNum, srcDirID, srcName,
- dstVRefNum, dstDirID, dstName,
- copyName,
- copyBufferPtr, copyBufferSize, preflight,
- copyErrHandler, NULL) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpFilteredDirectoryCopy(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- ConstStr255Param copyName,
- void *copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler,
- CopyFilterProcPtr copyFilterProc)
-{
- return ( FilteredDirectoryCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->vRefNum, dstSpec->parID, dstSpec->name,
- copyName,
- copyBufferPtr, copyBufferSize, preflight,
- copyErrHandler, copyFilterProc) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpDirectoryCopy(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- ConstStr255Param copyName,
- void *copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler)
-{
- return ( FilteredDirectoryCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->vRefNum, dstSpec->parID, dstSpec->name,
- copyName,
- copyBufferPtr, copyBufferSize, preflight,
- copyErrHandler, NULL) );
-}
-
-/*****************************************************************************/
-
+++ /dev/null
-/*
- File: DirectoryCopy.h
-
- Contains: A robust, general purpose directory copy routine.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-#ifndef __DIRECTORYCOPY__
-#define __DIRECTORYCOPY__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-enum {
- getNextItemOp = 1, /* couldn't access items in this directory - no access privileges */
- copyDirCommentOp = 2, /* couldn't copy directory's Finder comment */
- copyDirAccessPrivsOp = 3, /* couldn't copy directory's AFP access privileges */
- copyDirFMAttributesOp = 4, /* couldn't copy directory's File Manager attributes */
- dirCreateOp = 5, /* couldn't create destination directory */
- fileCopyOp = 6 /* couldn't copy file */
-};
-
-
-/*****************************************************************************/
-
-typedef CALLBACK_API( Boolean , CopyErrProcPtr )(OSErr error, short failedOperation, short srcVRefNum, long srcDirID, ConstStr255Param srcName, short dstVRefNum, long dstDirID, ConstStr255Param dstName);
-/*
- This is the prototype for the CopyErrProc function DirectoryCopy
- calls if an error condition is detected sometime during the copy. If
- CopyErrProc returns false, then DirectoryCopy attempts to continue with
- the directory copy operation. If CopyErrProc returns true, then
- DirectoryCopy stops the directory copy operation.
-
- error input: The error result code that caused CopyErrProc to
- be called.
- failedOperation input: The operation that returned an error to
- DirectoryCopy.
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source file or directory name, or nil if
- srcDirID specifies the directory.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstName input: Destination file or directory name, or nil if
- dstDirID specifies the directory.
-
- __________
-
- Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy, DirectoryCopy, FSpDirectoryCopy
-*/
-#define CallCopyErrProc(userRoutine, error, failedOperation, srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, dstName) \
- (*(userRoutine))((error), (failedOperation), (srcVRefNum), (srcDirID), (srcName), (dstVRefNum), (dstDirID), (dstName))
-
-/*****************************************************************************/
-
-typedef CALLBACK_API( Boolean , CopyFilterProcPtr )(const CInfoPBRec * cpbPtr);
-/*
- This is the prototype for the CopyFilterProc function called by
- FilteredDirectoryCopy and GetLevelSize. If true is returned,
- the file/folder is included in the copy, otherwise it is excluded.
-
- pb input: Points to the CInfoPBRec for the item under consideration.
-
- __________
-
- Also see: FilteredDirectoryCopy, FSpFilteredDirectoryCopy
-*/
-#define CallCopyFilterProc(userRoutine, cpbPtr) \
- (*(userRoutine))((cpbPtr))
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FilteredDirectoryCopy(
- short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName,
- ConstStr255Param copyName,
- void * copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler,
- CopyFilterProcPtr copyFilterProc);
-
-
-/*
- The FilteredDirectoryCopy function makes a copy of a directory
- structure in a new location. If copyBufferPtr <> NIL, it points to
- a buffer of copyBufferSize that is used to copy files data. The
- larger the supplied buffer, the faster the copy. If
- copyBufferPtr = NIL, then this routine allocates a buffer in the
- application heap. If you pass a copy buffer to this routine, make
- its size a multiple of 512 ($200) bytes for optimum performance.
-
- The optional copyFilterProc parameter lets a routine you define
- decide what files or directories are copied to the destination.
-
- FilteredDirectoryCopy normally creates a new directory *in* the
- specified destination directory and copies the source directory's
- content into the new directory. However, if root parent directory
- (fsRtParID) is passed as the dstDirID parameter and NULL is
- passed as the dstName parameter, DirectoryCopy renames the
- destination volume to the source directory's name (truncating
- if the name is longer than 27 characters) and copies the source
- directory's content into the destination volume's root directory.
- This special case is supported by FilteredDirectoryCopy, but
- not by FSpFilteredDirectoryCopy since with FSpFilteredDirectoryCopy,
- the dstName parameter can not be NULL.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source directory name, or nil if
- srcDirID specifies the directory.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstName input: Destination directory name, or nil if
- dstDirID specifies the directory.
- copyName input: Points to the new directory name if the directory
- is to be renamed or nil if the directory isn't to
- be renamed.
- copyBufferPtr input: Points to a buffer of copyBufferSize that
- is used the i/o buffer for the copy or
- nil if you want DirectoryCopy to allocate its
- own buffer in the application heap.
- copyBufferSize input: The size of the buffer pointed to
- by copyBufferPtr.
- preflight input: If true, DirectoryCopy makes sure there are
- enough allocation blocks on the destination
- volume to hold the directory's files before
- starting the copy.
- copyErrHandler input: A pointer to the routine you want called if an
- error condition is detected during the copy, or
- nil if you don't want to handle error conditions.
- If you don't handle error conditions, the first
- error will cause the copy to quit and
- DirectoryCopy will return the error.
- Error handling is recommended...
- copyFilterProc input: A pointer to the filter routine you want called
- for each item in the source directory, or NULL
- if you don't want to filter.
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Destination volume is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- tmfoErr -42 Too many files open
- fnfErr -43 Source file not found, or destination
- directory does not exist
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 The source or destination file could
- not be opened with the correct access
- modes
- dupFNErr -48 Destination file already exists
- opWrErr -49 File already open for writing
- paramErr -50 No default volume or function not
- supported by volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- memFullErr -108 Copy buffer could not be allocated
- dirNFErr -120 Directory not found or incomplete pathname
- wrgVolTypErr -123 Function not supported by volume
- afpAccessDenied -5000 User does not have the correct access
- afpDenyConflict -5006 The source or destination file could
- not be opened with the correct access
- modes
- afpObjectTypeErr -5025 Source is a directory, directory not found
- or incomplete pathname
-
- __________
-
- Also see: CopyErrProcPtr, CopyFilterProcPtr, FSpFilteredDirectoryCopy,
- DirectoryCopy, FSpDirectoryCopy, FileCopy, FSpFileCopy
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpFilteredDirectoryCopy(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec,
- ConstStr255Param copyName,
- void * copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler,
- CopyFilterProcPtr copyFilterProc);
-
-
-/*
- The FSpFilteredDirectoryCopy function makes a copy of a directory
- structure in a new location. If copyBufferPtr <> NIL, it points to
- a buffer of copyBufferSize that is used to copy files data. The
- larger the supplied buffer, the faster the copy. If
- copyBufferPtr = NIL, then this routine allocates a buffer in the
- application heap. If you pass a copy buffer to this routine, make
- its size a multiple of 512 ($200) bytes for optimum performance.
-
- The optional copyFilterProc parameter lets a routine you define
- decide what files or directories are copied to the destination.
-
- srcSpec input: An FSSpec record specifying the directory to copy.
- dstSpec input: An FSSpec record specifying destination directory
- of the copy.
- copyName input: Points to the new directory name if the directory
- is to be renamed or nil if the directory isn't to
- be renamed.
- copyBufferPtr input: Points to a buffer of copyBufferSize that
- is used the i/o buffer for the copy or
- nil if you want DirectoryCopy to allocate its
- own buffer in the application heap.
- copyBufferSize input: The size of the buffer pointed to
- by copyBufferPtr.
- preflight input: If true, FSpDirectoryCopy makes sure there are
- enough allocation blocks on the destination
- volume to hold the directory's files before
- starting the copy.
- copyErrHandler input: A pointer to the routine you want called if an
- error condition is detected during the copy, or
- nil if you don't want to handle error conditions.
- If you don't handle error conditions, the first
- error will cause the copy to quit and
- DirectoryCopy will return the error.
- Error handling is recommended...
- copyFilterProc input: A pointer to the filter routine you want called
- for each item in the source directory, or NULL
- if you don't want to filter.
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Destination volume is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- tmfoErr -42 Too many files open
- fnfErr -43 Source file not found, or destination
- directory does not exist
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 The source or destination file could
- not be opened with the correct access
- modes
- dupFNErr -48 Destination file already exists
- opWrErr -49 File already open for writing
- paramErr -50 No default volume or function not
- supported by volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- memFullErr -108 Copy buffer could not be allocated
- dirNFErr -120 Directory not found or incomplete pathname
- wrgVolTypErr -123 Function not supported by volume
- afpAccessDenied -5000 User does not have the correct access
- afpDenyConflict -5006 The source or destination file could
- not be opened with the correct access
- modes
- afpObjectTypeErr -5025 Source is a directory, directory not found
- or incomplete pathname
-
- __________
-
- Also see: CopyErrProcPtr, CopyFilterProcPtr, FilteredDirectoryCopy,
- DirectoryCopy, FSpDirectoryCopy, FileCopy, FSpFileCopy
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DirectoryCopy(
- short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName,
- ConstStr255Param copyName,
- void * copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler);
-
-
-/*
- The DirectoryCopy function makes a copy of a directory structure in a
- new location. If copyBufferPtr <> NIL, it points to a buffer of
- copyBufferSize that is used to copy files data. The larger the
- supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this
- routine allocates a buffer in the application heap. If you pass a
- copy buffer to this routine, make its size a multiple of 512
- ($200) bytes for optimum performance.
-
- DirectoryCopy normally creates a new directory *in* the specified
- destination directory and copies the source directory's content into
- the new directory. However, if root parent directory (fsRtParID)
- is passed as the dstDirID parameter and NULL is passed as the
- dstName parameter, DirectoryCopy renames the destination volume to
- the source directory's name (truncating if the name is longer than
- 27 characters) and copies the source directory's content into the
- destination volume's root directory. This special case is supported
- by DirectoryCopy, but not by FSpDirectoryCopy since with
- FSpDirectoryCopy, the dstName parameter can not be NULL.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source directory name, or nil if
- srcDirID specifies the directory.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstName input: Destination directory name, or nil if
- dstDirID specifies the directory.
- copyName input: Points to the new directory name if the directory
- is to be renamed or nil if the directory isn't to
- be renamed.
- copyBufferPtr input: Points to a buffer of copyBufferSize that
- is used the i/o buffer for the copy or
- nil if you want DirectoryCopy to allocate its
- own buffer in the application heap.
- copyBufferSize input: The size of the buffer pointed to
- by copyBufferPtr.
- preflight input: If true, DirectoryCopy makes sure there are
- enough allocation blocks on the destination
- volume to hold the directory's files before
- starting the copy.
- copyErrHandler input: A pointer to the routine you want called if an
- error condition is detected during the copy, or
- nil if you don't want to handle error conditions.
- If you don't handle error conditions, the first
- error will cause the copy to quit and
- DirectoryCopy will return the error.
- Error handling is recommended...
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Destination volume is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- tmfoErr -42 Too many files open
- fnfErr -43 Source file not found, or destination
- directory does not exist
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 The source or destination file could
- not be opened with the correct access
- modes
- dupFNErr -48 Destination file already exists
- opWrErr -49 File already open for writing
- paramErr -50 No default volume or function not
- supported by volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- memFullErr -108 Copy buffer could not be allocated
- dirNFErr -120 Directory not found or incomplete pathname
- wrgVolTypErr -123 Function not supported by volume
- afpAccessDenied -5000 User does not have the correct access
- afpDenyConflict -5006 The source or destination file could
- not be opened with the correct access
- modes
- afpObjectTypeErr -5025 Source is a directory, directory not found
- or incomplete pathname
-
- __________
-
- Also see: CopyErrProcPtr, FSpDirectoryCopy, FilteredDirectoryCopy,
- FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpDirectoryCopy(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec,
- ConstStr255Param copyName,
- void * copyBufferPtr,
- long copyBufferSize,
- Boolean preflight,
- CopyErrProcPtr copyErrHandler);
-
-
-/*
- The FSpDirectoryCopy function makes a copy of a directory structure in a
- new location. If copyBufferPtr <> NIL, it points to a buffer of
- copyBufferSize that is used to copy files data. The larger the
- supplied buffer, the faster the copy. If copyBufferPtr = NIL, then this
- routine allocates a buffer in the application heap. If you pass a
- copy buffer to this routine, make its size a multiple of 512
- ($200) bytes for optimum performance.
-
- srcSpec input: An FSSpec record specifying the directory to copy.
- dstSpec input: An FSSpec record specifying destination directory
- of the copy.
- copyName input: Points to the new directory name if the directory
- is to be renamed or nil if the directory isn't to
- be renamed.
- copyBufferPtr input: Points to a buffer of copyBufferSize that
- is used the i/o buffer for the copy or
- nil if you want DirectoryCopy to allocate its
- own buffer in the application heap.
- copyBufferSize input: The size of the buffer pointed to
- by copyBufferPtr.
- preflight input: If true, FSpDirectoryCopy makes sure there are
- enough allocation blocks on the destination
- volume to hold the directory's files before
- starting the copy.
- copyErrHandler input: A pointer to the routine you want called if an
- error condition is detected during the copy, or
- nil if you don't want to handle error conditions.
- If you don't handle error conditions, the first
- error will cause the copy to quit and
- DirectoryCopy will return the error.
- Error handling is recommended...
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Destination volume is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- tmfoErr -42 Too many files open
- fnfErr -43 Source file not found, or destination
- directory does not exist
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 The source or destination file could
- not be opened with the correct access
- modes
- dupFNErr -48 Destination file already exists
- opWrErr -49 File already open for writing
- paramErr -50 No default volume or function not
- supported by volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- memFullErr -108 Copy buffer could not be allocated
- dirNFErr -120 Directory not found or incomplete pathname
- wrgVolTypErr -123 Function not supported by volume
- afpAccessDenied -5000 User does not have the correct access
- afpDenyConflict -5006 The source or destination file could
- not be opened with the correct access
- modes
- afpObjectTypeErr -5025 Source is a directory, directory not found
- or incomplete pathname
-
- __________
-
- Also see: CopyErrProcPtr, DirectoryCopy, FilteredDirectoryCopy,
- FSpFilteredDirectoryCopy, FileCopy, FSpFileCopy
-*/
-
-/*****************************************************************************/
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __DIRECTORYCOPY__ */
-
+++ /dev/null
-/*
- File: FSpCompat.c
-
- Contains: FSSpec compatibility functions.
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <2> 2/7/01 JL Added standard header. Updated names of includes. Updated
- various routines to use new calling convention of the
- MoreFilesExtras accessor functions.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-/*
-** If building application 68K code, set GENERATENODATA to 0 for faster code.
-** If building stand-alone 68K code, set GENERATENODATA to 1 so globals
-** (static variables) are not used.
-*/
-#ifndef GENERATENODATA
-#define GENERATENODATA 0
-#endif
-
-#include <MacTypes.h>
-#include <MacErrors.h>
-#include <Files.h>
-#include <LowMem.h>
-#include <Gestalt.h>
-#include <Resources.h>
-#include <Script.h>
-
-#define __COMPILINGMOREFILES
-
-#include "MoreFilesExtras.h"
-#include "FSpCompat.h"
-
-/*****************************************************************************/
-
-/* local constants */
-
-enum {
- gestaltBugFixAttrsTwo = 'bugy',
- gestaltFSpExchangeFilesCompatibilityFix = 26,
- gestaltBugFixAttrsThree = 'bugx',
- gestaltFSpCreateScriptSupportFix = 1
-};
-
-/*****************************************************************************/
-
-/* static prototypes */
-
-
-#if !__MACOSSEVENORLATER
-static Boolean FSHasFSSpecCalls(void);
-
-static Boolean QTHasFSSpecCalls(void);
-#endif /* !__MACOSSEVENORLATER */
-
-#if !__MACOSSEVENFIVEORLATER
-static Boolean HasFSpExchangeFilesCompatibilityFix(void);
-
-static OSErr GenerateUniqueName(short volume,
- long *startSeed,
- long dir1,
- long dir2,
- StringPtr uniqueName);
-#endif /* !__MACOSSEVENFIVEORLATER */
-
-#if !__MACOSSEVENFIVEONEORLATER
-static Boolean HasFSpCreateScriptSupportFix(void);
-#endif /* !__MACOSSEVENFIVEONEORLATER */
-
-/*****************************************************************************/
-
-/* FSHasFSSpecCalls returns true if the file system provides FSSpec calls. */
-
-#if !__MACOSSEVENORLATER
-static Boolean FSHasFSSpecCalls(void)
-{
- long response;
-#if !GENERATENODATA
- static Boolean tested = false;
- static Boolean result = false;
-#else
- Boolean result = false;
-#endif
-
-#if !GENERATENODATA
- if ( !tested )
- {
- tested = true;
-#endif
- if ( Gestalt(gestaltFSAttr, &response) == noErr )
- {
- result = ((response & (1L << gestaltHasFSSpecCalls)) != 0);
- }
-#if !GENERATENODATA
- }
-#endif
- return ( result );
-}
-#endif /* !__MACOSSEVENORLATER */
-
-/*****************************************************************************/
-
-/* QTHasFSSpecCalls returns true if QuickTime provides FSSpec calls */
-/* except for FSpExchangeFiles. */
-
-#if !__MACOSSEVENORLATER
-static Boolean QTHasFSSpecCalls(void)
-{
- long response;
-#if !GENERATENODATA
- static Boolean tested = false;
- static Boolean result = false;
-#else
- Boolean result = false;
-#endif
-
-#if !GENERATENODATA
- if ( !tested )
- {
- tested = true;
-#endif
- result = (Gestalt(gestaltQuickTimeVersion, &response) == noErr);
-#if !GENERATENODATA
- }
-#endif
- return ( result );
-}
-#endif /* !__MACOSSEVENORLATER */
-
-/*****************************************************************************/
-
-/* HasFSpExchangeFilesCompatibilityFix returns true if FSpExchangeFiles */
-/* compatibility code has been fixed in system software. */
-/* This was fixed by System Update 3.0, so if SystemSevenFiveOrLater */
-/* is true, then we know the fix is in. */
-
-#if !__MACOSSEVENFIVEORLATER
-static Boolean HasFSpExchangeFilesCompatibilityFix(void)
-{
- long response;
-#if !GENERATENODATA
- static Boolean tested = false;
- static Boolean result = false;
-#else /* !GENERATENODATA */
- Boolean result = false;
-#endif /* !GENERATENODATA */
-
-#if !GENERATENODATA
- if ( !tested )
- {
- tested = true;
-#endif /* !GENERATENODATA */
- if ( Gestalt(gestaltBugFixAttrsTwo, &response) == noErr )
- {
- result = ((response & (1L << gestaltFSpExchangeFilesCompatibilityFix)) != 0);
- }
-#if !GENERATENODATA
- }
-#endif /* !GENERATENODATA */
- return ( result );
-}
-#endif /* !__MACOSSEVENFIVEORLATER */
-
-/*****************************************************************************/
-
-/* HasFSpCreateScriptSupportFix returns true if FSpCreate and */
-/* FSpCreateResFile have been fixed in system software to correctly set */
-/* the scriptCode in the volume's catalog. */
-/* This was fixed by System 7.5 Update 1.0 */
-
-#if !__MACOSSEVENFIVEONEORLATER
-static Boolean HasFSpCreateScriptSupportFix(void)
-{
- long response;
-#if !GENERATENODATA
- static Boolean tested = false;
- static Boolean result = false;
-#else
- Boolean result = false;
-#endif /* !GENERATENODATA */
-
-#if !GENERATENODATA
- if ( !tested )
- {
- tested = true;
-#endif /* !GENERATENODATA */
- if ( Gestalt(gestaltBugFixAttrsThree, &response) == noErr )
- {
- result = ((response & (1L << gestaltFSpCreateScriptSupportFix)) != 0);
- }
-#if !GENERATENODATA
- }
-#endif /* !GENERATENODATA */
- return ( result );
-}
-#endif /* !__MACOSSEVENFIVEONEORLATER */
-
-/*****************************************************************************/
-
-/*
-** File Manager FSp calls
-*/
-
-/*****************************************************************************/
-
-pascal OSErr FSMakeFSSpecCompat(short vRefNum,
- long dirID,
- ConstStr255Param fileName,
- FSSpec *spec)
-{
- OSErr result;
-
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- Boolean isDirectory;
-
- result = GetObjectLocation(vRefNum, dirID, fileName,
- &(spec->vRefNum), &(spec->parID), spec->name,
- &isDirectory);
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- /* Let the file system create the FSSpec if it can since it does the job */
- /* much more efficiently than I can. */
- result = FSMakeFSSpec(vRefNum, dirID, fileName, spec);
-
- /* Fix a bug in Macintosh PC Exchange's MakeFSSpec code where 0 is */
- /* returned in the parID field when making an FSSpec to the volume's */
- /* root directory by passing a full pathname in MakeFSSpec's */
- /* fileName parameter. Fixed in Mac OS 8.1 */
- if ( (result == noErr) && (spec->parID == 0) )
- spec->parID = fsRtParID;
- }
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpOpenDFCompat(const FSSpec *spec,
- char permission,
- short *refNum)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- OSErr result;
- HParamBlockRec pb;
-
- pb.ioParam.ioVRefNum = spec->vRefNum;
- pb.fileParam.ioDirID = spec->parID;
- pb.ioParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.ioParam.ioVersNum = 0;
- pb.ioParam.ioPermssn = permission;
- pb.ioParam.ioMisc = NULL;
- result = PBHOpenSync(&pb); /* OpenDF not supported by System 6, so use Open */
- *refNum = pb.ioParam.ioRefNum;
- return ( result );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpOpenDF(spec, permission, refNum) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpOpenRFCompat(const FSSpec *spec,
- char permission,
- short *refNum)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- OSErr result;
- HParamBlockRec pb;
-
- pb.ioParam.ioVRefNum = spec->vRefNum;
- pb.fileParam.ioDirID = spec->parID;
- pb.ioParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.ioParam.ioVersNum = 0;
- pb.ioParam.ioPermssn = permission;
- pb.ioParam.ioMisc = NULL;
- result = PBHOpenRFSync(&pb);
- *refNum = pb.ioParam.ioRefNum;
- return ( result );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpOpenRF(spec, permission, refNum) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpCreateCompat(const FSSpec *spec,
- OSType creator,
- OSType fileType,
- ScriptCode scriptTag)
-{
-#if !__MACOSSEVENFIVEONEORLATER
- OSErr result;
- UniversalFMPB pb;
-
-
- if (
-#if !__MACOSSEVENORLATER
- (!FSHasFSSpecCalls() && !QTHasFSSpecCalls()) ||
-#endif /* !__MACOSSEVENORLATER */
- !HasFSpCreateScriptSupportFix() )
- {
- /* If FSpCreate isn't called, this code will be executed */
- pb.hPB.fileParam.ioVRefNum = spec->vRefNum;
- pb.hPB.fileParam.ioDirID = spec->parID;
- pb.hPB.fileParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.hPB.fileParam.ioFVersNum = 0;
- result = PBHCreateSync(&(pb.hPB));
- if ( result == noErr )
- {
- /* get info on created item */
- pb.ciPB.hFileInfo.ioFDirIndex = 0;
- result = PBGetCatInfoSync(&(pb.ciPB));
- if ( result == noErr )
- {
- /* Set fdScript in FXInfo */
- /* The negative script constants (smSystemScript, smCurrentScript, and smAllScripts) */
- /* don't make sense on disk, so only use scriptTag if scriptTag >= smRoman */
- /* (smRoman is 0). fdScript is valid if high bit is set (see IM-6, page 9-38) */
- pb.ciPB.hFileInfo.ioFlXFndrInfo.fdScript = (scriptTag >= smRoman) ?
- ((char)scriptTag | (char)0x80) :
- (smRoman);
- /* Set creator/fileType */
- pb.ciPB.hFileInfo.ioFlFndrInfo.fdCreator = creator;
- pb.ciPB.hFileInfo.ioFlFndrInfo.fdType = fileType;
- /* Restore ioDirID field in pb which was changed by PBGetCatInfo */
- pb.ciPB.hFileInfo.ioDirID = spec->parID;
- result = PBSetCatInfoSync(&(pb.ciPB));
- }
- }
- return ( result );
- }
- else
-#endif /* !__MACOSSEVENFIVEONEORLATER */
- {
- return ( FSpCreate(spec, creator, fileType, scriptTag) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpDirCreateCompat(const FSSpec *spec,
- ScriptCode scriptTag,
- long *createdDirID)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- OSErr result;
- UniversalFMPB pb;
-
- pb.hPB.fileParam.ioVRefNum = spec->vRefNum;
- pb.hPB.fileParam.ioDirID = spec->parID;
- pb.hPB.fileParam.ioNamePtr = (StringPtr) &(spec->name);
- result = PBDirCreateSync(&(pb.hPB));
- *createdDirID = pb.hPB.fileParam.ioDirID;
- if ( result == noErr )
- {
- /* get info on created item */
- pb.ciPB.dirInfo.ioFDirIndex = 0;
- pb.ciPB.dirInfo.ioDrDirID = spec->parID;
- result = PBGetCatInfoSync(&(pb.ciPB));
- if ( result == noErr )
- {
- /* Set frScript in DXInfo */
- /* The negative script constants (smSystemScript, smCurrentScript, and smAllScripts) */
- /* don't make sense on disk, so only use scriptTag if scriptTag >= smRoman */
- /* (smRoman is 0). frScript is valid if high bit is set (see IM-6, page 9-38) */
- pb.ciPB.dirInfo.ioDrFndrInfo.frScript = (scriptTag >= smRoman) ?
- ((char)scriptTag | (char)0x80) :
- (smRoman);
- /* Restore ioDirID field in pb which was changed by PBGetCatInfo */
- pb.ciPB.dirInfo.ioDrDirID = spec->parID;
- result = PBSetCatInfoSync(&(pb.ciPB));
- }
- }
- return ( result );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpDirCreate(spec, scriptTag, createdDirID) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpDeleteCompat(const FSSpec *spec)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- HParamBlockRec pb;
-
- pb.ioParam.ioVRefNum = spec->vRefNum;
- pb.fileParam.ioDirID = spec->parID;
- pb.ioParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.ioParam.ioVersNum = 0;
- return ( PBHDeleteSync(&pb) );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpDelete(spec) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetFInfoCompat(const FSSpec *spec,
- FInfo *fndrInfo)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- OSErr result;
- HParamBlockRec pb;
-
- pb.fileParam.ioVRefNum = spec->vRefNum;
- pb.fileParam.ioDirID = spec->parID;
- pb.fileParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.fileParam.ioFVersNum = 0;
- pb.fileParam.ioFDirIndex = 0;
- result = PBHGetFInfoSync(&pb);
- *fndrInfo = pb.fileParam.ioFlFndrInfo;
- return ( result );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpGetFInfo(spec, fndrInfo) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetFInfoCompat(const FSSpec *spec,
- const FInfo *fndrInfo)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- OSErr result;
- HParamBlockRec pb;
-
- pb.fileParam.ioVRefNum = spec->vRefNum;
- pb.fileParam.ioDirID = spec->parID;
- pb.fileParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.fileParam.ioFVersNum = 0;
- pb.fileParam.ioFDirIndex = 0;
- result = PBHGetFInfoSync(&pb);
- if ( result == noErr )
- {
- pb.fileParam.ioFlFndrInfo = *fndrInfo;
- pb.fileParam.ioDirID = spec->parID;
- result = PBHSetFInfoSync(&pb);
- }
- return ( result );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpSetFInfo(spec, fndrInfo) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetFLockCompat(const FSSpec *spec)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- HParamBlockRec pb;
-
- pb.fileParam.ioVRefNum = spec->vRefNum;
- pb.fileParam.ioDirID = spec->parID;
- pb.fileParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.fileParam.ioFVersNum = 0;
- return ( PBHSetFLockSync(&pb) );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpSetFLock(spec) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpRstFLockCompat(const FSSpec *spec)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- HParamBlockRec pb;
-
- pb.fileParam.ioVRefNum = spec->vRefNum;
- pb.fileParam.ioDirID = spec->parID;
- pb.fileParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.fileParam.ioFVersNum = 0;
- return ( PBHRstFLockSync(&pb) );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpRstFLock(spec) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpRenameCompat(const FSSpec *spec,
- ConstStr255Param newName)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- HParamBlockRec pb;
-
- pb.ioParam.ioVRefNum = spec->vRefNum;
- pb.fileParam.ioDirID = spec->parID;
- pb.ioParam.ioNamePtr = (StringPtr) &(spec->name);
- pb.ioParam.ioVersNum = 0;
- pb.ioParam.ioMisc = (Ptr) newName;
- return ( PBHRenameSync(&pb) );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpRename(spec, newName) );
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpCatMoveCompat(const FSSpec *source,
- const FSSpec *dest)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- CMovePBRec pb;
-
- /* source and destination volume must be the same */
- if ( source->vRefNum != dest->vRefNum )
- return ( paramErr );
-
- pb.ioNamePtr = (StringPtr) &(source->name);
- pb.ioVRefNum = source->vRefNum;
- pb.ioDirID = source->parID;
- pb.ioNewDirID = dest->parID;
- pb.ioNewName = (StringPtr) &(dest->name);
- return ( PBCatMoveSync(&pb) );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpCatMove(source, dest) );
- }
-}
-
-/*****************************************************************************/
-
-/* GenerateUniqueName generates a name that is unique in both dir1 and dir2 */
-/* on the specified volume. Ripped off from Feldman's code. */
-
-#if !__MACOSSEVENFIVEORLATER
-static OSErr GenerateUniqueName(short volume,
- long *startSeed,
- long dir1,
- long dir2,
- StringPtr uniqueName)
-{
- OSErr error = noErr;
- long i;
- CInfoPBRec cinfo;
- unsigned char hexStr[16];
-
- for ( i = 0; i < 16; ++i )
- {
- if ( i < 10 )
- {
- hexStr[i] = 0x30 + i;
- }
- else
- {
- hexStr[i] = 0x37 + i;
- }
- }
-
- cinfo.hFileInfo.ioVRefNum = volume;
- cinfo.hFileInfo.ioFDirIndex = 0;
- cinfo.hFileInfo.ioNamePtr = uniqueName;
-
- while ( error != fnfErr )
- {
- (*startSeed)++;
- cinfo.hFileInfo.ioNamePtr[0] = 8;
- for ( i = 1; i <= 8; i++ )
- {
- cinfo.hFileInfo.ioNamePtr[i] = hexStr[((*startSeed >> ((8-i)*4)) & 0xf)];
- }
- cinfo.hFileInfo.ioDirID = dir1;
- error = fnfErr;
- for ( i = 1; i <= 2; i++ )
- {
- error = error & PBGetCatInfoSync(&cinfo);
- cinfo.hFileInfo.ioDirID = dir2;
- if ( (error != fnfErr) && (error != noErr) )
- {
- return ( error );
- }
- }
- }
- return ( noErr );
-}
-#endif /* !__MACOSSEVENFIVEORLATER */
-
-/*****************************************************************************/
-
-pascal OSErr FSpExchangeFilesCompat(const FSSpec *source,
- const FSSpec *dest)
-{
-#if !__MACOSSEVENFIVEORLATER
- if (
-#if !__MACOSSEVENORLATER
- !FSHasFSSpecCalls() ||
-#endif /* !__MACOSSEVENORLATER */
- !HasFSpExchangeFilesCompatibilityFix() )
- {
- HParamBlockRec pb;
- CInfoPBRec catInfoSource, catInfoDest;
- OSErr result, result2;
- Str31 unique1, unique2;
- StringPtr unique1Ptr, unique2Ptr, swapola;
- GetVolParmsInfoBuffer volInfo;
- long theSeed, temp;
-
- /* Make sure the source and destination are on the same volume */
- if ( source->vRefNum != dest->vRefNum )
- {
- result = diffVolErr;
- goto errorExit3;
- }
-
- /* Try PBExchangeFiles first since it preserves the file ID reference */
- pb.fidParam.ioNamePtr = (StringPtr) &(source->name);
- pb.fidParam.ioVRefNum = source->vRefNum;
- pb.fidParam.ioDestNamePtr = (StringPtr) &(dest->name);
- pb.fidParam.ioDestDirID = dest->parID;
- pb.fidParam.ioSrcDirID = source->parID;
-
- result = PBExchangeFilesSync(&pb);
-
- /* Note: The compatibility case won't work for files with *Btree control blocks. */
- /* Right now the only *Btree files are created by the system. */
- if ( result != noErr )
- {
- pb.ioParam.ioNamePtr = NULL;
- pb.ioParam.ioBuffer = (Ptr) &volInfo;
- pb.ioParam.ioReqCount = sizeof(volInfo);
- result2 = PBHGetVolParmsSync(&pb);
-
- /* continue if volume has no fileID support (or no GetVolParms support) */
- if ( (result2 == noErr) && hasFileIDs(&volInfo) )
- {
- goto errorExit3;
- }
-
- /* Get the catalog information for each file */
- /* and make sure both files are *really* files */
- catInfoSource.hFileInfo.ioVRefNum = source->vRefNum;
- catInfoSource.hFileInfo.ioFDirIndex = 0;
- catInfoSource.hFileInfo.ioNamePtr = (StringPtr) &(source->name);
- catInfoSource.hFileInfo.ioDirID = source->parID;
- catInfoSource.hFileInfo.ioACUser = 0; /* ioACUser used to be filler2 */
- result = PBGetCatInfoSync(&catInfoSource);
- if ( result != noErr )
- {
- goto errorExit3;
- }
- if ( (catInfoSource.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- result = notAFileErr;
- goto errorExit3;
- }
-
- catInfoDest.hFileInfo.ioVRefNum = dest->vRefNum;
- catInfoDest.hFileInfo.ioFDirIndex = 0;
- catInfoDest.hFileInfo.ioNamePtr = (StringPtr) &(dest->name);
- catInfoDest.hFileInfo.ioDirID = dest->parID;
- catInfoDest.hFileInfo.ioACUser = 0; /* ioACUser used to be filler2 */
- result = PBGetCatInfoSync(&catInfoDest);
- if ( result != noErr )
- {
- goto errorExit3;
- }
- if ( (catInfoDest.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- result = notAFileErr;
- goto errorExit3;
- }
-
- /* generate 2 filenames that are unique in both directories */
- theSeed = 0x64666A6C; /* a fine unlikely filename */
- unique1Ptr = (StringPtr)&unique1;
- unique2Ptr = (StringPtr)&unique2;
-
- result = GenerateUniqueName(source->vRefNum, &theSeed, source->parID, dest->parID, unique1Ptr);
- if ( result != noErr )
- {
- goto errorExit3;
- }
-
- GenerateUniqueName(source->vRefNum, &theSeed, source->parID, dest->parID, unique2Ptr);
- if ( result != noErr )
- {
- goto errorExit3;
- }
-
- /* rename source to unique1 */
- pb.fileParam.ioNamePtr = (StringPtr) &(source->name);
- pb.ioParam.ioMisc = (Ptr) unique1Ptr;
- pb.ioParam.ioVersNum = 0;
- result = PBHRenameSync(&pb);
- if ( result != noErr )
- {
- goto errorExit3;
- }
-
- /* rename dest to unique2 */
- pb.ioParam.ioMisc = (Ptr) unique2Ptr;
- pb.ioParam.ioVersNum = 0;
- pb.fileParam.ioNamePtr = (StringPtr) &(dest->name);
- pb.fileParam.ioDirID = dest->parID;
- result = PBHRenameSync(&pb);
- if ( result != noErr )
- {
- goto errorExit2; /* back out gracefully by renaming unique1 back to source */
- }
-
- /* If files are not in same directory, swap their locations */
- if ( source->parID != dest->parID )
- {
- /* move source file to dest directory */
- pb.copyParam.ioNamePtr = unique1Ptr;
- pb.copyParam.ioNewName = NULL;
- pb.copyParam.ioNewDirID = dest->parID;
- pb.copyParam.ioDirID = source->parID;
- result = PBCatMoveSync((CMovePBPtr) &pb);
- if ( result != noErr )
- {
- goto errorExit1; /* back out gracefully by renaming both files to original names */
- }
-
- /* move dest file to source directory */
- pb.copyParam.ioNamePtr = unique2Ptr;
- pb.copyParam.ioNewDirID = source->parID;
- pb.copyParam.ioDirID = dest->parID;
- result = PBCatMoveSync((CMovePBPtr) &pb);
- if ( result != noErr)
- {
- /* life is very bad. We'll at least try to move source back */
- pb.copyParam.ioNamePtr = unique1Ptr;
- pb.copyParam.ioNewName = NULL;
- pb.copyParam.ioNewDirID = source->parID;
- pb.copyParam.ioDirID = dest->parID;
- (void) PBCatMoveSync((CMovePBPtr) &pb); /* ignore errors */
- goto errorExit1; /* back out gracefully by renaming both files to original names */
- }
- }
-
- /* Make unique1Ptr point to file in source->parID */
- /* and unique2Ptr point to file in dest->parID */
- /* This lets us fall through to the rename code below */
- swapola = unique1Ptr;
- unique1Ptr = unique2Ptr;
- unique2Ptr = swapola;
-
- /* At this point, the files are in their new locations (if they were moved) */
- /* Source is named Unique1 (name pointed to by unique2Ptr) and is in dest->parID */
- /* Dest is named Unique2 (name pointed to by unique1Ptr) and is in source->parID */
- /* Need to swap attributes except mod date and swap names */
-
- /* swap the catalog info by re-aiming the CInfoPB's */
- catInfoSource.hFileInfo.ioNamePtr = unique1Ptr;
- catInfoDest.hFileInfo.ioNamePtr = unique2Ptr;
-
- catInfoSource.hFileInfo.ioDirID = source->parID;
- catInfoDest.hFileInfo.ioDirID = dest->parID;
-
- /* Swap the original mod dates with each file */
- temp = catInfoSource.hFileInfo.ioFlMdDat;
- catInfoSource.hFileInfo.ioFlMdDat = catInfoDest.hFileInfo.ioFlMdDat;
- catInfoDest.hFileInfo.ioFlMdDat = temp;
-
- /* Here's the swap (ignore errors) */
- (void) PBSetCatInfoSync(&catInfoSource);
- (void) PBSetCatInfoSync(&catInfoDest);
-
- /* rename unique2 back to dest */
-errorExit1:
- pb.ioParam.ioMisc = (Ptr) &(dest->name);
- pb.ioParam.ioVersNum = 0;
- pb.fileParam.ioNamePtr = unique2Ptr;
- pb.fileParam.ioDirID = dest->parID;
- (void) PBHRenameSync(&pb); /* ignore errors */
-
- /* rename unique1 back to source */
-errorExit2:
- pb.ioParam.ioMisc = (Ptr) &(source->name);
- pb.ioParam.ioVersNum = 0;
- pb.fileParam.ioNamePtr = unique1Ptr;
- pb.fileParam.ioDirID = source->parID;
- (void) PBHRenameSync(&pb); /* ignore errors */
- }
-errorExit3: { /* null statement */ }
- return ( result );
- }
- else
-#endif /* !__MACOSSEVENFIVEORLATER */
- {
- return ( FSpExchangeFiles(source, dest) );
- }
-}
-
-/*****************************************************************************/
-
-/*
-** Resource Manager FSp calls
-*/
-
-/*****************************************************************************/
-
-pascal short FSpOpenResFileCompat(const FSSpec *spec,
- SignedByte permission)
-{
-#if !__MACOSSEVENORLATER
- if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
- {
- return ( HOpenResFile(spec->vRefNum, spec->parID, spec->name, permission) );
- }
- else
-#endif /* !__MACOSSEVENORLATER */
- {
- return ( FSpOpenResFile(spec, permission) );
- }
-}
-
-/*****************************************************************************/
-
-pascal void FSpCreateResFileCompat(const FSSpec *spec,
- OSType creator,
- OSType fileType,
- ScriptCode scriptTag)
-{
-#if !__MACOSSEVENFIVEONEORLATER
- if (
-#if !__MACOSSEVENORLATER
- (!FSHasFSSpecCalls() && !QTHasFSSpecCalls()) ||
-#endif /* !__MACOSSEVENORLATER */
- !HasFSpCreateScriptSupportFix() )
- {
- OSErr result;
- CInfoPBRec pb;
-
- HCreateResFile(spec->vRefNum, spec->parID, spec->name);
- if ( ResError() == noErr )
- {
- /* get info on created item */
- pb.hFileInfo.ioVRefNum = spec->vRefNum;
- pb.hFileInfo.ioDirID = spec->parID;
- pb.hFileInfo.ioNamePtr = (StringPtr) &(spec->name);
- pb.hFileInfo.ioFDirIndex = 0;
- result = PBGetCatInfoSync(&pb);
- if ( result == noErr )
- {
- /* Set fdScript in FXInfo */
- /* The negative script constants (smSystemScript, smCurrentScript, and smAllScripts) */
- /* don't make sense on disk, so only use scriptTag if scriptTag >= smRoman */
- /* (smRoman is 0). fdScript is valid if high bit is set (see IM-6, page 9-38) */
- pb.hFileInfo.ioFlXFndrInfo.fdScript = (scriptTag >= smRoman) ?
- ((char)scriptTag | (char)0x80) :
- (smRoman);
- /* Set creator/fileType */
- pb.hFileInfo.ioFlFndrInfo.fdCreator = creator;
- pb.hFileInfo.ioFlFndrInfo.fdType = fileType;
-
- /* Restore ioDirID field in pb which was changed by PBGetCatInfo */
- pb.hFileInfo.ioDirID = spec->parID;
- result = PBSetCatInfoSync(&pb);
- }
- /* Set ResErr low memory global to result */
- LMSetResErr(result);
- }
- return;
- }
- else
-#endif /* !__MACOSSEVENFIVEONEORLATER */
- {
- FSpCreateResFile(spec, creator, fileType, scriptTag);
- return;
- }
-}
-
-/*****************************************************************************/
+++ /dev/null
-/*
- File: FSpCompat.h
-
- Contains: FSSpec compatibility functions.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-#ifndef __FSPCOMPAT__
-#define __FSPCOMPAT__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSMakeFSSpecCompat(
- short vRefNum,
- long dirID,
- ConstStr255Param fileName,
- FSSpec * spec);
-
-
-/*
- The FSMakeFSSpecCompat function fills in the fields of an FSSpec record.
- If the file system can't create the FSSpec, then the compatibility code
- creates a FSSpec that is exactly like an FSSpec except that spec.name
- for a file may not have the same capitalization as the file's catalog
- entry on the disk volume. That is because fileName is parsed to get the
- name instead of getting the name back from the file system. This works
- fine with System 6 where FSMakeSpec isn't available.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- fileName input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
- spec output: A file system specification to be filled in by
- FSMakeFSSpecCompat.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume doesnÕt exist
- fnfErr -43 File or directory does not exist
- (FSSpec is still valid)
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpOpenDFCompat(
- const FSSpec * spec,
- char permission,
- short * refNum);
-
-
-/*
- The FSpOpenDFCompat function opens the data fork of the file specified
- by spec.
- Differences from FSpOpenDF: If FSpOpenDF isn't available,
- FSpOpenDFCompat uses PHBOpen because System 6 doesn't support PBHOpenDF.
- This means FSpOpenDFCompat could accidentally open a driver if the
- spec->name begins with a period.
-
- spec input: An FSSpec record specifying the file whose data
- fork is to be opened.
- permission input: A constant indicating the desired file access
- permissions.
- refNum output: A reference number of an access path to the file's
- data fork.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- tmfoErr -42 Too many files open
- fnfErr -43 File not found
- opWrErr -49 File already open for writing
- permErr -54 Attempt to open locked file for writing
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access to
- the file
-
- __________
-
- See also: FSpOpenAware
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpOpenRFCompat(
- const FSSpec * spec,
- char permission,
- short * refNum);
-
-
-/*
- The FSpOpenRFCompat function opens the resource fork of the file
- specified by spec.
-
- spec input: An FSSpec record specifying the file whose resource
- fork is to be opened.
- permission input: A constant indicating the desired file access
- permissions.
- refNum output: A reference number of an access path to the file's
- resource fork.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- tmfoErr -42 Too many files open
- fnfErr -43 File not found
- opWrErr -49 File already open for writing
- permErr -54 Attempt to open locked file for writing
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access to
- the file
-
- __________
-
- See also: FSpOpenRFAware
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpCreateCompat(
- const FSSpec * spec,
- OSType creator,
- OSType fileType,
- ScriptCode scriptTag);
-
-
-/*
- The FSpCreateCompat function creates a new file with the specified
- type, creator, and script code.
- Differences from FSpCreate: FSpCreateCompat correctly sets the
- fdScript in the file's FXInfo record to scriptTag if the problem
- isn't fixed in the File Manager code.
-
- spec input: An FSSpec record specifying the file to create.
- creator input: The creator of the new file.
- fileType input The file type of the new file.
- scriptCode input: The code of the script system in which the file
- name is to be displayed.
-
- Result Codes
- noErr 0 No error
- dirFulErr -33 File directory full
- dskFulErr -34 Disk is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 Directory not found or incomplete pathname
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- dupFNErr -48 Duplicate filename and version
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 A directory exists with that name
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpDirCreateCompat(
- const FSSpec * spec,
- ScriptCode scriptTag,
- long * createdDirID);
-
-
-/*
- The FSpDirCreateCompat function creates a new directory and returns the
- directory ID of the newDirectory.
-
- spec input: An FSSpec record specifying the directory to
- create.
- scriptCode input: The code of the script system in which the
- directory name is to be displayed.
- createdDirID output: The directory ID of the directory that was
- created.
-
- Result Codes
- noErr 0 No error
- dirFulErr -33 File directory full
- dskFulErr -34 Disk is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 Directory not found or incomplete pathname
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- dupFNErr -48 Duplicate filename and version
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- wrgVolTypErr -123 Not an HFS volume
- afpAccessDenied -5000 User does not have the correct access
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpDeleteCompat(const FSSpec * spec);
-
-
-/*
- The FSpDeleteCompat function deletes a file or directory.
-
- spec input: An FSSpec record specifying the file or
- directory to delete.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Software volume lock
- fBsyErr -47 File busy, directory not empty, or
- working directory control block open
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpGetFInfoCompat(
- const FSSpec * spec,
- FInfo * fndrInfo);
-
-
-/*
- The FSpGetFInfoCompat function gets the finder information for a file.
-
- spec input: An FSSpec record specifying the file.
- fndrInfo output: If the object is a file, then its FInfo.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: FSpGetDInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetFInfoCompat(
- const FSSpec * spec,
- const FInfo * fndrInfo);
-
-
-/*
- The FSpSetFInfoCompat function sets the finder information for a file.
-
- spec input: An FSSpec record specifying the file.
- fndrInfo input: The FInfo.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Software volume lock
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Object was a directory
-
- __________
-
- Also see: FSpSetDInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetFLockCompat(const FSSpec * spec);
-
-
-/*
- The FSpSetFLockCompat function locks a file.
-
- spec input: An FSSpec record specifying the file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access to
- the file
- afpObjectTypeErr -5025 Folder locking not supported by volume
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpRstFLockCompat(const FSSpec * spec);
-
-
-/*
- The FSpRstFLockCompat function unlocks a file.
-
- spec input: An FSSpec record specifying the file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access to
- the file
- afpObjectTypeErr -5025 Folder locking not supported by volume
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpRenameCompat(
- const FSSpec * spec,
- ConstStr255Param newName);
-
-
-/*
- The FSpRenameCompat function renames a file or directory.
-
- spec input: An FSSpec record specifying the file.
- newName input: The new name of the file or directory.
-
- Result Codes
- noErr 0 No error
- dirFulErr -33 File directory full
- dskFulErr -34 Volume is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Software volume lock
- dupFNErr -48 Duplicate filename and version
- paramErr -50 No default volume
- fsRnErr -59 Problem during rename
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access to
- the file
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpCatMoveCompat(
- const FSSpec * source,
- const FSSpec * dest);
-
-
-/*
- The FSpCatMoveCompat function moves a file or directory to a different
- location on on the same volume.
-
- source input: An FSSpec record specifying the file or directory.
- dest input: An FSSpec record specifying the name and location
- of the directory into which the source file or
- directory is to be moved.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename or attempt to move into
- a file
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- fLckdErr -45 Target directory is locked
- vLckdErr -46 Software volume lock
- dupFNErr -48 Duplicate filename and version
- paramErr -50 No default volume
- badMovErr -122 Attempt to move into offspring
- wrgVolTypErr -123 Not an HFS volume
- afpAccessDenied -5000 User does not have the correct access to
- the file
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpExchangeFilesCompat(
- const FSSpec * source,
- const FSSpec * dest);
-
-
-/*
- The FSpExchangeFilesCompat function swaps the data in two files by
- changing the information in the volume's catalog and, if the files
- are open, in the file control blocks.
- Differences from FSpExchangeFiles: Correctly exchanges files on volumes
- that don't support PBExchangeFiles. FSpExchangeFiles attempts to support
- volumes that don't support PBExchangeFiles, but in System 7, 7.0.1, 7.1,
- and 7 Pro, the compatibility code just doesn't work on volumes that
- don't support PBExchangeFiles (even though you may get a noErr result).
- System Update 3.0 and System 7.5 and later have the problems in
- FSpExchangeFiles corrected.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 Function not supported by volume
- volOfflinErr -53 Volume is offline
- wrgVolTypErr -123 Not an HFS volume
- diffVolErr -1303 Files on different volumes
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Object is a directory, not a file
- afpSameObjectErr -5038 Source and destination files are the same
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( short )
-FSpOpenResFileCompat(
- const FSSpec * spec,
- SignedByte permission);
-
-
-/*
- The FSpOpenResFileCompat function opens the resource file specified
- by spec.
-
- spec input: An FSSpec record specifying the file whose
- resource file is to be opened.
- permission input: A constant indicating the desired file access
- permissions.
- function result output: A resource file reference number, or if there's
- an error -1.
-
- Result Codes
- noErr 0 No error
- nsvErr Ð35 No such volume
- ioErr Ð36 I/O error
- bdNamErr Ð37 Bad filename or volume name (perhaps zero
- length)
- eofErr Ð39 End of file
- tmfoErr Ð42 Too many files open
- fnfErr Ð43 File not found
- opWrErr Ð49 File already open with write permission
- permErr Ð54 Permissions error (on file open)
- extFSErr Ð58 Volume belongs to an external file system
- memFullErr Ð108 Not enough room in heap zone
- dirNFErr Ð120 Directory not found
- mapReadErr Ð199 Map inconsistent with operation
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( void )
-FSpCreateResFileCompat(
- const FSSpec * spec,
- OSType creator,
- OSType fileType,
- ScriptCode scriptTag);
-
-
-/*
- The FSpCreateResFileCompat function creates a new resource file with
- the specified type, creator, and script code.
- Differences from FSpCreateResFile: FSpCreateResFileCompat correctly
- sets the fdScript in the file's FXInfo record to scriptTag if the
- problem isn't fixed in the File Manager code.
-
- spec input: An FSSpec record specifying the resource file to create.
- creator input: The creator of the new file.
- fileType input The file type of the new file.
- scriptCode input: The code of the script system in which the file
- name is to be displayed.
-
- Result Codes
- noErr 0 No error
- dirFulErr Ð33 Directory full
- dskFulErr Ð34 Disk full
- nsvErr Ð35 No such volume
- ioErr Ð36 I/O error
- bdNamErr Ð37 Bad filename or volume name (perhaps zero
- length)
- tmfoErr Ð42 Too many files open
- wPrErrw Ð44 Disk is write-protected
- fLckdErr Ð45 File is locked
-*/
-
-/*****************************************************************************/
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __FSPCOMPAT__ */
-
+++ /dev/null
-/*
- File: FileCopy.c
-
- Contains: A robust, general purpose file copy routine.
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <2> 2/7/01 JL Added standard header. Updated names of includes. Updated
- various routines to use new calling convention of the
- MoreFilesExtras accessor functions.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-#include <MacTypes.h>
-#include <MacErrors.h>
-#include <MacMemory.h>
-#include <Files.h>
-#include <Math64.h>
-
-#define __COMPILINGMOREFILES
-
-#include "MoreFiles.h"
-#include "MoreFilesExtras.h"
-#include "MoreDesktopMgr.h"
-#include "FileCopy.h"
-
-/*****************************************************************************/
-
-/* local constants */
-
-/* The deny-mode privileges to use when opening the source and destination files. */
-
-enum
-{
- srcCopyMode = dmRdDenyWr,
- dstCopyMode = dmWrDenyRdWr
-};
-
-/* The largest (16K) and smallest (.5K) copy buffer to use if the caller doesn't supply
-** their own copy buffer. */
-
-enum
-{
- bigCopyBuffSize = 0x00004000,
- minCopyBuffSize = 0x00000200
-};
-
-/*****************************************************************************/
-
-/* static prototypes */
-
-static OSErr GetDestinationDirInfo(short vRefNum,
- long dirID,
- ConstStr255Param name,
- long *theDirID,
- Boolean *isDirectory,
- Boolean *isDropBox);
-/* GetDestinationDirInfo tells us if the destination is a directory, it's
- directory ID, and if it's an AppleShare drop box (write privileges only --
- no read or search privileges).
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- theDirID output: If the object is a file, then its parent directory
- ID. If the object is a directory, then its ID.
- isDirectory output: True if object is a directory; false if
- object is a file.
- isDropBox output: True if directory is an AppleShare drop box.
-*/
-
-static OSErr CheckForForks(short vRefNum,
- long dirID,
- ConstStr255Param name,
- Boolean *hasDataFork,
- Boolean *hasResourceFork);
-/* CheckForForks tells us if there is a data or resource fork to copy.
- vRefNum input: Volume specification of the file's current
- location.
- dirID input: Directory ID of the file's current location.
- name input: The name of the file.
-*/
-
-static OSErr PreflightFileCopySpace(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- ConstStr255Param dstVolName,
- short dstVRefNum,
- Boolean *spaceOK);
-/* PreflightFileCopySpace determines if there's enough space on a
- volume to copy the specified file to that volume.
- Note: The results of this routine are not perfect. For example if the
- volume's catalog or extents overflow file grows when the new file is
- created, more allocation blocks may be needed beyond those needed for
- the file's data and resource forks.
-
- srcVRefNum input: Volume specification of the file's current
- location.
- srcDirID input: Directory ID of the file's current location.
- srcName input: The name of the file.
- dstVolName input: A pointer to the name of the volume where
- the file will be copied or NULL.
- dstVRefNum input: Volume specification indicating the volume
- where the file will be copied.
- spaceOK output: true if there's enough space on the volume for
- the file's data and resource forks.
-*/
-
-/*****************************************************************************/
-
-static OSErr GetDestinationDirInfo(short vRefNum,
- long dirID,
- ConstStr255Param name,
- long *theDirID,
- Boolean *isDirectory,
- Boolean *isDropBox)
-{
- CInfoPBRec pb;
- OSErr error;
-
- pb.dirInfo.ioACUser = 0; /* ioACUser used to be filler2, clear it before calling GetCatInfo */
- error = GetCatInfoNoName(vRefNum, dirID, name, &pb);
- *theDirID = pb.dirInfo.ioDrDirID;
- *isDirectory = (pb.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0;
- /* see if access priviledges are make changes, not see folder, and not see files (drop box) */
- *isDropBox = userHasDropBoxAccess(pb.dirInfo.ioACUser);
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-static OSErr CheckForForks(short vRefNum,
- long dirID,
- ConstStr255Param name,
- Boolean *hasDataFork,
- Boolean *hasResourceFork)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.fileParam.ioNamePtr = (StringPtr)name;
- pb.fileParam.ioVRefNum = vRefNum;
- pb.fileParam.ioFVersNum = 0;
- pb.fileParam.ioDirID = dirID;
- pb.fileParam.ioFDirIndex = 0;
- error = PBHGetFInfoSync(&pb);
- *hasDataFork = (pb.fileParam.ioFlLgLen != 0);
- *hasResourceFork = (pb.fileParam.ioFlRLgLen != 0);
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-static OSErr PreflightFileCopySpace(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- ConstStr255Param dstVolName,
- short dstVRefNum,
- Boolean *spaceOK)
-{
- UniversalFMPB pb;
- OSErr error;
- unsigned long dstFreeBlocks;
- unsigned long dstBlksPerAllocBlk;
- unsigned long srcDataBlks;
- unsigned long srcResourceBlks;
-
- error = XGetVolumeInfoNoName(dstVolName, dstVRefNum, &pb.xPB);
- if ( error == noErr )
- {
- /* get allocation block size (always multiple of 512) and divide by 512
- to get number of 512-byte blocks per allocation block */
- dstBlksPerAllocBlk = ((unsigned long)pb.xPB.ioVAlBlkSiz >> 9);
-
- /* Convert freeBytes to free disk blocks (512-byte blocks) */
- dstFreeBlocks = U32SetU(U64ShiftRight(pb.xPB.ioVFreeBytes, 9));
-
- /* Now, get the size of the file's data resource forks */
- pb.hPB.fileParam.ioNamePtr = (StringPtr)srcName;
- pb.hPB.fileParam.ioVRefNum = srcVRefNum;
- pb.hPB.fileParam.ioFVersNum = 0;
- pb.hPB.fileParam.ioDirID = srcDirID;
- pb.hPB.fileParam.ioFDirIndex = 0;
- error = PBHGetFInfoSync(&pb.hPB);
- if ( error == noErr )
- {
- /* Since space on Mac OS disks is always allocated in allocation blocks, */
- /* this code takes into account rounding up to the end of an allocation block. */
-
- /* get number of 512-byte blocks needed for data fork */
- if ( ((unsigned long)pb.hPB.fileParam.ioFlLgLen & 0x000001ff) != 0 )
- {
- srcDataBlks = ((unsigned long)pb.hPB.fileParam.ioFlLgLen >> 9) + 1;
- }
- else
- {
- srcDataBlks = (unsigned long)pb.hPB.fileParam.ioFlLgLen >> 9;
- }
-
- /* now, calculate number of new allocation blocks needed */
- if ( srcDataBlks % dstBlksPerAllocBlk )
- {
- srcDataBlks = (srcDataBlks / dstBlksPerAllocBlk) + 1;
- }
- else
- {
- srcDataBlks /= dstBlksPerAllocBlk;
- }
-
- /* get number of 512-byte blocks needed for resource fork */
- if ( ((unsigned long)pb.hPB.fileParam.ioFlRLgLen & 0x000001ff) != 0 )
- {
- srcResourceBlks = ((unsigned long)pb.hPB.fileParam.ioFlRLgLen >> 9) + 1;
- }
- else
- {
- srcResourceBlks = (unsigned long)pb.hPB.fileParam.ioFlRLgLen >> 9;
- }
-
- /* now, calculate number of new allocation blocks needed */
- if ( srcResourceBlks % dstBlksPerAllocBlk )
- {
- srcResourceBlks = (srcResourceBlks / dstBlksPerAllocBlk) + 1;
- }
- else
- {
- srcResourceBlks /= dstBlksPerAllocBlk;
- }
-
- /* Is there enough room on the destination volume for the source file? */
- *spaceOK = ( ((srcDataBlks + srcResourceBlks) * dstBlksPerAllocBlk) <= dstFreeBlocks );
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FileCopy(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstPathname,
- ConstStr255Param copyName,
- void *copyBufferPtr,
- long copyBufferSize,
- Boolean preflight)
-{
- OSErr err;
-
- short srcRefNum = 0, /* 0 when source data and resource fork are closed */
- dstDataRefNum = 0, /* 0 when destination data fork is closed */
- dstRsrcRefNum = 0; /* 0 when destination resource fork is closed */
-
- Str63 dstName; /* The filename of the destination. It might be the
- ** source filename, it might be a new name... */
-
- GetVolParmsInfoBuffer infoBuffer; /* Where PBGetVolParms dumps its info */
- long srcServerAdr; /* AppleTalk server address of source (if any) */
-
- Boolean dstCreated = false, /* true when destination file has been created */
- ourCopyBuffer = false, /* true if we had to allocate the copy buffer */
- isDirectory, /* true if destination is really a directory */
- isDropBox; /* true if destination is an AppleShare drop box */
-
- long tempLong;
- short tempInt;
-
- Boolean spaceOK; /* true if there's enough room to copy the file to the destination volume */
-
- Boolean hasDataFork;
- Boolean hasResourceFork;
-
- /* Preflight for size */
- if ( preflight )
- {
- err = PreflightFileCopySpace(srcVRefNum, srcDirID, srcName,
- dstPathname, dstVRefNum, &spaceOK);
- if ( err != noErr )
- {
- return ( err );
- }
-
- if ( !spaceOK )
- {
- return ( dskFulErr );
- }
- }
-
- /* get the destination's real dirID and make sure it really is a directory */
- err = GetDestinationDirInfo(dstVRefNum, dstDirID, dstPathname,
- &dstDirID, &isDirectory, &isDropBox);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
-
- if ( !isDirectory )
- {
- return ( dirNFErr );
- }
-
- /* get the destination's real vRefNum */
- err = DetermineVRefNum(dstPathname, dstVRefNum, &dstVRefNum);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
-
- /* See if PBHCopyFile can be used. Using PBHCopyFile saves time by letting the file server
- ** copy the file if the source and destination locations are on the same file server. */
- tempLong = sizeof(infoBuffer);
- err = HGetVolParms(srcName, srcVRefNum, &infoBuffer, &tempLong);
- if ( (err != noErr) && (err != paramErr) )
- {
- return ( err );
- }
-
- if ( (err != paramErr) && hasCopyFile(&infoBuffer) )
- {
- /* The source volume supports PBHCopyFile. */
- srcServerAdr = infoBuffer.vMServerAdr;
-
- /* Now, see if the destination volume is on the same file server. */
- tempLong = sizeof(infoBuffer);
- err = HGetVolParms(NULL, dstVRefNum, &infoBuffer, &tempLong);
- if ( (err != noErr) && (err != paramErr) )
- {
- return ( err );
- }
- if ( (err != paramErr) && (srcServerAdr == infoBuffer.vMServerAdr) )
- {
- /* Source and Dest are on same server and PBHCopyFile is supported. Copy with CopyFile. */
- err = HCopyFile(srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, NULL, copyName);
- if ( err != noErr )
- {
- return ( err );
- }
-
- /* AppleShare's CopyFile clears the isAlias bit, so I still need to attempt to copy
- the File's attributes to attempt to get things right. */
- if ( copyName != NULL ) /* Did caller supply copy file name? */
- {
- /* Yes, use the caller supplied copy file name. */
- (void) CopyFileMgrAttributes(srcVRefNum, srcDirID, srcName,
- dstVRefNum, dstDirID, copyName, true);
- }
- else
- {
- /* They didn't, so get the source file name and use it. */
- if ( GetFilenameFromPathname(srcName, dstName) == noErr )
- {
- /* */
- (void) CopyFileMgrAttributes(srcVRefNum, srcDirID, srcName,
- dstVRefNum, dstDirID, dstName, true);
- }
- }
- return ( err );
- }
- }
-
- /* If we're here, then PBHCopyFile couldn't be used so we have to copy the file by hand. */
-
- /* Make sure a copy buffer is allocated. */
- if ( copyBufferPtr == NULL )
- {
- /* The caller didn't supply a copy buffer so grab one from the application heap.
- ** Try to get a big copy buffer, if we can't, try for a 512-byte buffer.
- ** If 512 bytes aren't available, we're in trouble. */
- copyBufferSize = bigCopyBuffSize;
- copyBufferPtr = NewPtr(copyBufferSize);
- if ( copyBufferPtr == NULL )
- {
- copyBufferSize = minCopyBuffSize;
- copyBufferPtr = NewPtr(copyBufferSize);
- if ( copyBufferPtr == NULL )
- {
- return ( memFullErr );
- }
- }
- ourCopyBuffer = true;
- }
-
- /* Open the source data fork. */
- err = HOpenAware(srcVRefNum, srcDirID, srcName, srcCopyMode, &srcRefNum);
- if ( err != noErr )
- return ( err );
-
- /* Once a file is opened, we have to exit via ErrorExit to make sure things are cleaned up */
-
- /* See if the copy will be renamed. */
- if ( copyName != NULL ) /* Did caller supply copy file name? */
- BlockMoveData(copyName, dstName, copyName[0] + 1); /* Yes, use the caller supplied copy file name. */
- else
- { /* They didn't, so get the source file name and use it. */
- err = GetFileLocation(srcRefNum, &tempInt, &tempLong, dstName);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
- }
-
- /* Create the destination file. */
- err = HCreateMinimum(dstVRefNum, dstDirID, dstName);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
- dstCreated = true; /* After creating the destination file, any
- ** error conditions should delete the destination file */
-
- /* An AppleShare dropbox folder is a folder for which the user has the Make Changes
- ** privilege (write access), but not See Files (read access) and See Folders (search access).
- ** Copying a file into an AppleShare dropbox presents some special problems. Here are the
- ** rules we have to follow to copy a file into a dropbox:
- ** ¥ File attributes can be changed only when both forks of a file are empty.
- ** ¥ DeskTop Manager comments can be added to a file only when both forks of a file
- ** are empty.
- ** ¥ A fork can be opened for write access only when both forks of a file are empty.
- ** So, with those rules to live with, we'll do those operations now while both forks
- ** are empty. */
-
- if ( isDropBox )
- {
- /* We only set the file attributes now if the file is being copied into a
- ** drop box. In all other cases, it is better to set the attributes last
- ** so that if FileCopy is modified to give up time to other processes
- ** periodicly, the Finder won't try to read any bundle information (because
- ** the bundle-bit will still be clear) from a partially copied file. If the
- ** copy is into a drop box, we have to set the attributes now, but since the
- ** destination forks are opened with write/deny-read/deny-write permissions,
- ** any Finder that might see the file in the drop box won't be able to open
- ** its resource fork until the resource fork is closed.
- **
- ** Note: if you do modify FileCopy to give up time to other processes, don't
- ** give up time between the time the destination file is created (above) and
- ** the time both forks are opened (below). That way, you stand the best chance
- ** of making sure the Finder doesn't read a partially copied resource fork.
- */
- /* Copy attributes but don't lock the destination. */
- err = CopyFileMgrAttributes(srcVRefNum, srcDirID, srcName,
- dstVRefNum, dstDirID, dstName, false);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
- }
-
- /* Attempt to copy the comments while both forks are empty.
- ** Ignore the result because we really don't care if it worked or not. */
- (void) DTCopyComment(srcVRefNum, srcDirID, srcName, dstVRefNum, dstDirID, dstName);
-
- /* See which forks we need to copy. By doing this, we won't create a data or resource fork
- ** for the destination unless it's really needed (some foreign file systems such as
- ** the ProDOS File System and Macintosh PC Exchange have to create additional disk
- ** structures to support resource forks). */
- err = CheckForForks(srcVRefNum, srcDirID, srcName, &hasDataFork, &hasResourceFork);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
-
- if ( hasDataFork )
- {
- /* Open the destination data fork. */
- err = HOpenAware(dstVRefNum, dstDirID, dstName, dstCopyMode, &dstDataRefNum);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
- }
-
- if ( hasResourceFork )
- {
- /* Open the destination resource fork. */
- err = HOpenRFAware(dstVRefNum, dstDirID, dstName, dstCopyMode, &dstRsrcRefNum);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
- }
-
- if ( hasDataFork )
- {
- /* Copy the data fork. */
- err = CopyFork(srcRefNum, dstDataRefNum, copyBufferPtr, copyBufferSize);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
-
- /* Close both data forks and clear reference numbers. */
- (void) FSClose(srcRefNum);
- (void) FSClose(dstDataRefNum);
- srcRefNum = dstDataRefNum = 0;
- }
- else
- {
- /* Close the source data fork since it was opened earlier */
- (void) FSClose(srcRefNum);
- srcRefNum = 0;
- }
-
- if ( hasResourceFork )
- {
- /* Open the source resource fork. */
- err = HOpenRFAware(srcVRefNum, srcDirID, srcName, srcCopyMode, &srcRefNum);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
-
- /* Copy the resource fork. */
- err = CopyFork(srcRefNum, dstRsrcRefNum, copyBufferPtr, copyBufferSize);
- if ( err != noErr )
- {
- goto ErrorExit;
- }
-
- /* Close both resource forks and clear reference numbers. */
- (void) FSClose(srcRefNum);
- (void) FSClose(dstRsrcRefNum);
- srcRefNum = dstRsrcRefNum = 0;
- }
-
- /* Get rid of the copy buffer if we allocated it. */
- if ( ourCopyBuffer )
- {
- DisposePtr((Ptr)copyBufferPtr);
- }
-
- /* Attempt to copy attributes again to set mod date. Copy lock condition this time
- ** since we're done with the copy operation. This operation will fail if we're copying
- ** into an AppleShare dropbox, so we don't check for error conditions. */
- CopyFileMgrAttributes(srcVRefNum, srcDirID, srcName,
- dstVRefNum, dstDirID, dstName, true);
-
- /* Hey, we did it! */
- return ( noErr );
-
-ErrorExit:
- if ( srcRefNum != 0 )
- {
- (void) FSClose(srcRefNum); /* Close the source file */
- }
- if ( dstDataRefNum != 0 )
- {
- (void) FSClose(dstDataRefNum); /* Close the destination file data fork */
- }
- if ( dstRsrcRefNum != 0 )
- {
- (void) FSClose(dstRsrcRefNum); /* Close the destination file resource fork */
- }
- if ( dstCreated )
- {
- (void) HDelete(dstVRefNum, dstDirID, dstName); /* Delete dest file. This may fail if the file
- is in a "drop folder" */
- }
- if ( ourCopyBuffer ) /* dispose of any memory we allocated */
- {
- DisposePtr((Ptr)copyBufferPtr);
- }
-
- return ( err );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpFileCopy(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- ConstStr255Param copyName,
- void *copyBufferPtr,
- long copyBufferSize,
- Boolean preflight)
-{
- return ( FileCopy(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->vRefNum, dstSpec->parID, dstSpec->name,
- copyName, copyBufferPtr, copyBufferSize, preflight) );
-}
-
-/*****************************************************************************/
-
+++ /dev/null
-/*
- File: FileCopy.h
-
- Contains: A robust, general purpose file copy routine.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-#ifndef __FILECOPY__
-#define __FILECOPY__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FileCopy(
- short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstPathname,
- ConstStr255Param copyName,
- void * copyBufferPtr,
- long copyBufferSize,
- Boolean preflight);
-
-
-/*
- The FileCopy function duplicates a file and optionally renames it.
- Since the PBHCopyFile routine is only available on some
- AFP server volumes under specific conditions, this routine
- either uses PBHCopyFile, or does all of the work PBHCopyFile
- does. The srcVRefNum, srcDirID and srcName are used to
- determine the location of the file to copy. The dstVRefNum
- dstDirID and dstPathname are used to determine the location of
- the destination directory. If copyName <> NIL, then it points
- to the name of the new file. If copyBufferPtr <> NIL, it
- points to a buffer of copyBufferSize that is used to copy
- the file's data. The larger the supplied buffer, the
- faster the copy. If copyBufferPtr = NIL, then this routine
- allocates a buffer in the application heap. If you pass a
- copy buffer to this routine, make its size a multiple of 512
- ($200) bytes for optimum performance.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source file name.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstPathname input: Pointer to destination directory name, or
- nil when dstDirID specifies a directory.
- copyName input: Points to the new file name if the file is
- to be renamed or nil if the file isn't to
- be renamed.
- copyBufferPtr input: Points to a buffer of copyBufferSize that
- is used the i/o buffer for the copy or
- nil if you want FileCopy to allocate its
- own buffer in the application heap.
- copyBufferSize input: The size of the buffer pointed to
- by copyBufferPtr.
- preflight input: If true, FileCopy makes sure there are enough
- allocation blocks on the destination volume to
- hold both the data and resource forks before
- starting the copy.
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Destination volume is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- tmfoErr -42 Too many files open
- fnfErr -43 Source file not found, or destination
- directory does not exist
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 The source or destination file could
- not be opened with the correct access
- modes
- dupFNErr -48 Destination file already exists
- opWrErr -49 File already open for writing
- paramErr -50 No default volume or function not
- supported by volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- memFullErr -108 Copy buffer could not be allocated
- dirNFErr -120 Directory not found or incomplete pathname
- wrgVolTypErr -123 Function not supported by volume
- afpAccessDenied -5000 User does not have the correct access
- afpDenyConflict -5006 The source or destination file could
- not be opened with the correct access
- modes
- afpObjectTypeErr -5025 Source is a directory, directory not found
- or incomplete pathname
-
- __________
-
- Also see: FSpFileCopy, DirectoryCopy, FSpDirectoryCopy
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpFileCopy(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec,
- ConstStr255Param copyName,
- void * copyBufferPtr,
- long copyBufferSize,
- Boolean preflight);
-
-
-/*
- The FSpFileCopy function duplicates a file and optionally renames it.
- Since the PBHCopyFile routine is only available on some
- AFP server volumes under specific conditions, this routine
- either uses PBHCopyFile, or does all of the work PBHCopyFile
- does. The srcSpec is used to
- determine the location of the file to copy. The dstSpec is
- used to determine the location of the
- destination directory. If copyName <> NIL, then it points
- to the name of the new file. If copyBufferPtr <> NIL, it
- points to a buffer of copyBufferSize that is used to copy
- the file's data. The larger the supplied buffer, the
- faster the copy. If copyBufferPtr = NIL, then this routine
- allocates a buffer in the application heap. If you pass a
- copy buffer to this routine, make its size a multiple of 512
- ($200) bytes for optimum performance.
-
- srcSpec input: An FSSpec record specifying the source file.
- dstSpec input: An FSSpec record specifying the destination
- directory.
- copyName input: Points to the new file name if the file is
- to be renamed or nil if the file isn't to
- be renamed.
- copyBufferPtr input: Points to a buffer of copyBufferSize that
- is used the i/o buffer for the copy or
- nil if you want FileCopy to allocate its
- own buffer in the application heap.
- copyBufferSize input: The size of the buffer pointed to
- by copyBufferPtr.
- preflight input: If true, FSpFileCopy makes sure there are
- enough allocation blocks on the destination
- volume to hold both the data and resource forks
- before starting the copy.
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Destination volume is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- tmfoErr -42 Too many files open
- fnfErr -43 Source file not found, or destination
- directory does not exist
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 The source or destination file could
- not be opened with the correct access
- modes
- dupFNErr -48 Destination file already exists
- opWrErr -49 File already open for writing
- paramErr -50 No default volume or function not
- supported by volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- memFullErr -108 Copy buffer could not be allocated
- dirNFErr -120 Directory not found or incomplete pathname
- wrgVolTypErr -123 Function not supported by volume
- afpAccessDenied -5000 User does not have the correct access
- afpDenyConflict -5006 The source or destination file could
- not be opened with the correct access
- modes
- afpObjectTypeErr -5025 Source is a directory, directory not found
- or incomplete pathname
-
- __________
-
- Also see: FileCopy, DirectoryCopy, FSpDirectoryCopy
-*/
-
-/*****************************************************************************/
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __FILECOPY__ */
-
+++ /dev/null
-/*
- File: FullPath.c
-
- Contains: Routines for dealing with full pathnames... if you really must.
-
- Version: MoreFiles
-
- Copyright: © 1995-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <2> 2/7/01 JL Added standard header. Updated names of includes.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-#include <MacTypes.h>
-#include <MacErrors.h>
-#include <MacMemory.h>
-#include <Files.h>
-#include <TextUtils.h>
-#include <Aliases.h>
-
-#define __COMPILINGMOREFILES
-
-#include "FSpCompat.h"
-#include "FullPath.h"
-
-/*
- IMPORTANT NOTE:
-
- The use of full pathnames is strongly discouraged. Full pathnames are
- particularly unreliable as a means of identifying files, directories
- or volumes within your application, for two primary reasons:
-
- ¥ The user can change the name of any element in the path at virtually
- any time.
- ¥ Volume names on the Macintosh are *not* unique. Multiple
- mounted volumes can have the same name. For this reason, the use of
- a full pathname to identify a specific volume may not produce the
- results you expect. If more than one volume has the same name and
- a full pathname is used, the File Manager currently uses the first
- mounted volume it finds with a matching name in the volume queue.
-
- In general, you should use a fileÕs name, parent directory ID, and
- volume reference number to identify a file you want to open, delete,
- or otherwise manipulate.
-
- If you need to remember the location of a particular file across
- subsequent system boots, use the Alias Manager to create an alias record
- describing the file. If the Alias Manager is not available, you can save
- the fileÕs name, its parent directory ID, and the name of the volume on
- which itÕs located. Although none of these methods is foolproof, they are
- much more reliable than using full pathnames to identify files.
-
- Nonetheless, it is sometimes useful to display a fileÕs full pathname to
- the user. For example, a backup utility might display a list of full
- pathnames of files as it copies them onto the backup medium. Or, a
- utility might want to display a dialog box showing the full pathname of
- a file when it needs the userÕs confirmation to delete the file. No
- matter how unreliable full pathnames may be from a file-specification
- viewpoint, users understand them more readily than volume reference
- numbers or directory IDs. (Hint: Use the TruncString function from
- TextUtils.h with truncMiddle as the truncWhere argument to shorten
- full pathnames to a displayable length.)
-
- The following technique for constructing the full pathname of a file is
- intended for display purposes only. Applications that depend on any
- particular structure of a full pathname are likely to fail on alternate
- foreign file systems or under future system software versions.
-*/
-
-/*****************************************************************************/
-
-pascal OSErr GetFullPath(short vRefNum,
- long dirID,
- ConstStr255Param name,
- short *fullPathLength,
- Handle *fullPath)
-{
- OSErr result;
- FSSpec spec;
-
- *fullPathLength = 0;
- *fullPath = NULL;
-
- result = FSMakeFSSpecCompat(vRefNum, dirID, name, &spec);
- if ( (result == noErr) || (result == fnfErr) )
- {
- result = FSpGetFullPath(&spec, fullPathLength, fullPath);
- }
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetFullPath(const FSSpec *spec,
- short *fullPathLength,
- Handle *fullPath)
-{
- OSErr result;
- OSErr realResult;
- FSSpec tempSpec;
- CInfoPBRec pb;
-
- *fullPathLength = 0;
- *fullPath = NULL;
-
-
- /* Default to noErr */
- realResult = result = noErr;
-
- /* work around Nav Services "bug" (it returns invalid FSSpecs with empty names) */
- if ( spec->name[0] == 0 )
- {
- result = FSMakeFSSpecCompat(spec->vRefNum, spec->parID, spec->name, &tempSpec);
- }
- else
- {
- /* Make a copy of the input FSSpec that can be modified */
- BlockMoveData(spec, &tempSpec, sizeof(FSSpec));
- }
-
- if ( result == noErr )
- {
- if ( tempSpec.parID == fsRtParID )
- {
- /* The object is a volume */
-
- /* Add a colon to make it a full pathname */
- ++tempSpec.name[0];
- tempSpec.name[tempSpec.name[0]] = ':';
-
- /* We're done */
- result = PtrToHand(&tempSpec.name[1], fullPath, tempSpec.name[0]);
- }
- else
- {
- /* The object isn't a volume */
-
- /* Is the object a file or a directory? */
- pb.dirInfo.ioNamePtr = tempSpec.name;
- pb.dirInfo.ioVRefNum = tempSpec.vRefNum;
- pb.dirInfo.ioDrDirID = tempSpec.parID;
- pb.dirInfo.ioFDirIndex = 0;
- result = PBGetCatInfoSync(&pb);
- // Allow file/directory name at end of path to not exist.
- realResult = result;
- if ( (result == noErr) || (result == fnfErr) )
- {
- /* if the object is a directory, append a colon so full pathname ends with colon */
- if ( (result == noErr) && (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- ++tempSpec.name[0];
- tempSpec.name[tempSpec.name[0]] = ':';
- }
-
- /* Put the object name in first */
- result = PtrToHand(&tempSpec.name[1], fullPath, tempSpec.name[0]);
- if ( result == noErr )
- {
- /* Get the ancestor directory names */
- pb.dirInfo.ioNamePtr = tempSpec.name;
- pb.dirInfo.ioVRefNum = tempSpec.vRefNum;
- pb.dirInfo.ioDrParID = tempSpec.parID;
- do /* loop until we have an error or find the root directory */
- {
- pb.dirInfo.ioFDirIndex = -1;
- pb.dirInfo.ioDrDirID = pb.dirInfo.ioDrParID;
- result = PBGetCatInfoSync(&pb);
- if ( result == noErr )
- {
- /* Append colon to directory name */
- ++tempSpec.name[0];
- tempSpec.name[tempSpec.name[0]] = ':';
-
- /* Add directory name to beginning of fullPath */
- (void) Munger(*fullPath, 0, NULL, 0, &tempSpec.name[1], tempSpec.name[0]);
- result = MemError();
- }
- } while ( (result == noErr) && (pb.dirInfo.ioDrDirID != fsRtDirID) );
- }
- }
- }
- }
-
- if ( result == noErr )
- {
- /* Return the length */
- *fullPathLength = GetHandleSize(*fullPath);
- result = realResult; // return realResult in case it was fnfErr
- }
- else
- {
- /* Dispose of the handle and return NULL and zero length */
- if ( *fullPath != NULL )
- {
- DisposeHandle(*fullPath);
- }
- *fullPath = NULL;
- *fullPathLength = 0;
- }
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpLocationFromFullPath(short fullPathLength,
- const void *fullPath,
- FSSpec *spec)
-{
- AliasHandle alias;
- OSErr result;
- Boolean wasChanged;
- Str32 nullString;
-
- /* Create a minimal alias from the full pathname */
- nullString[0] = 0; /* null string to indicate no zone or server name */
- result = NewAliasMinimalFromFullPath(fullPathLength, fullPath, nullString, nullString, &alias);
- if ( result == noErr )
- {
- /* Let the Alias Manager resolve the alias. */
- result = ResolveAlias(NULL, alias, spec, &wasChanged);
-
- /* work around Alias Mgr sloppy volume matching bug */
- if ( spec->vRefNum == 0 )
- {
- /* invalidate wrong FSSpec */
- spec->parID = 0;
- spec->name[0] = 0;
- result = nsvErr;
- }
- DisposeHandle((Handle)alias); /* Free up memory used */
- }
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr LocationFromFullPath(short fullPathLength,
- const void *fullPath,
- short *vRefNum,
- long *parID,
- Str31 name)
-{
- OSErr result;
- FSSpec spec;
-
- result = FSpLocationFromFullPath(fullPathLength, fullPath, &spec);
- if ( result == noErr )
- {
- *vRefNum = spec.vRefNum;
- *parID = spec.parID;
- BlockMoveData(&spec.name[0], &name[0], spec.name[0] + 1);
- }
- return ( result );
-}
-
-/*****************************************************************************/
-
+++ /dev/null
-/*
- File: FullPath.h
-
- Contains: Routines for dealing with full pathnames... if you really must.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1995-2001 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-/*
- IMPORTANT NOTE:
-
- The use of full pathnames is strongly discouraged. Full pathnames are
- particularly unreliable as a means of identifying files, directories
- or volumes within your application, for two primary reasons:
-
- ¥ The user can change the name of any element in the path at
- virtually any time.
- ¥ Volume names on the Macintosh are *not* unique. Multiple
- mounted volumes can have the same name. For this reason, the use of
- a full pathname to identify a specific volume may not produce the
- results you expect. If more than one volume has the same name and
- a full pathname is used, the File Manager currently uses the first
- mounted volume it finds with a matching name in the volume queue.
-
- In general, you should use a fileÕs name, parent directory ID, and
- volume reference number to identify a file you want to open, delete,
- or otherwise manipulate.
-
- If you need to remember the location of a particular file across
- subsequent system boots, use the Alias Manager to create an alias
- record describing the file. If the Alias Manager is not available, you
- can save the fileÕs name, its parent directory ID, and the name of the
- volume on which itÕs located. Although none of these methods is
- foolproof, they are much more reliable than using full pathnames to
- identify files.
-
- Nonetheless, it is sometimes useful to display a fileÕs full pathname
- to the user. For example, a backup utility might display a list of full
- pathnames of files as it copies them onto the backup medium. Or, a
- utility might want to display a dialog box showing the full pathname of
- a file when it needs the userÕs confirmation to delete the file. No
- matter how unreliable full pathnames may be from a file-specification
- viewpoint, users understand them more readily than volume reference
- numbers or directory IDs. (Hint: Use the TruncString function from
- TextUtils.h with truncMiddle as the truncWhere argument to shorten
- full pathnames to a displayable length.)
-
- The following technique for constructing the full pathname of a file is
- intended for display purposes only. Applications that depend on any
- particular structure of a full pathname are likely to fail on alternate
- foreign file systems or under future system software versions.
-*/
-
-#ifndef __FULLPATH__
-#define __FULLPATH__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetFullPath(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- short * fullPathLength,
- Handle * fullPath);
-
-
-/*
- The GetFullPath function builds a full pathname to the specified
- object. The full pathname is returned in the newly created handle
- fullPath and the length of the full pathname is returned in
- fullPathLength. Your program is responsible for disposing of the
- fullPath handle.
-
- Note that a full pathname can be made to a file/directory that does not
- yet exist if all directories up to that file/directory exist. In this case,
- GetFullPath will return a fnfErr.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- fullPathLength output: The number of characters in the full pathname.
- If the function fails to create a full
- pathname, it sets fullPathLength to 0.
- fullPath output: A handle to the newly created full pathname
- buffer. If the function fails to create a
- full pathname, it sets fullPath to NULL.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File or directory does not exist (fullPath
- and fullPathLength are still valid)
- paramErr -50 No default volume
- memFullErr -108 Not enough memory
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpGetFullPath
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpGetFullPath(
- const FSSpec * spec,
- short * fullPathLength,
- Handle * fullPath);
-
-
-/*
- The GetFullPath function builds a full pathname to the specified
- object. The full pathname is returned in the newly created handle
- fullPath and the length of the full pathname is returned in
- fullPathLength. Your program is responsible for disposing of the
- fullPath handle.
-
- Note that a full pathname can be made to a file/directory that does not
- yet exist if all directories up to that file/directory exist. In this case,
- FSpGetFullPath will return a fnfErr.
-
- IMPORTANT: The definition of a FSSpec is a volume reference number (not a
- drive number, working directory number, or 0), a parent directory ID (not 0),
- and the name of a file or folder (not an empty name, a full pathname, or
- a partial pathname containing one or more colon (:) characters).
- FSpGetFullPath assumes it is getting a FSSpec that matches the rules.
- If you have an FSSpec record that wasn't created by FSMakeFSSpec (or
- FSMakeFSSpecCompat from FSpCompat in MoreFiles which correctly builds
- FSSpecs), you should call GetFullPath instead of FSpGetFullPath.
-
- spec input: An FSSpec record specifying the object.
- fullPathLength output: The number of characters in the full pathname.
- If the function fails to create a full pathname,
- it sets fullPathLength to 0.
- fullPath output: A handle to the newly created full pathname
- buffer. If the function fails to create a
- full pathname, it sets fullPath to NULL.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File or directory does not exist (fullPath
- and fullPathLength are still valid)
- paramErr -50 No default volume
- memFullErr -108 Not enough memory
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: GetFullPath
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpLocationFromFullPath(
- short fullPathLength,
- const void * fullPath,
- FSSpec * spec);
-
-
-/*
- The FSpLocationFromFullPath function returns a FSSpec to the object
- specified by full pathname. This function requires the Alias Manager.
-
- fullPathLength input: The number of characters in the full pathname
- of the target.
- fullPath input: A pointer to a buffer that contains the full
- pathname of the target. The full pathname
- starts with the name of the volume, includes
- all of the directory names in the path to the
- target, and ends with the target name.
- spec output: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 The volume is not mounted
- fnfErr -43 Target not found, but volume and parent
- directory found
- paramErr -50 Parameter error
- usrCanceledErr -128 The user canceled the operation
-
- __________
-
- See also: LocationFromFullPath
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-LocationFromFullPath(
- short fullPathLength,
- const void * fullPath,
- short * vRefNum,
- long * parID,
- Str31 name);
-
-
-/*
- The LocationFromFullPath function returns the volume reference number,
- parent directory ID and name of the object specified by full pathname.
- This function requires the Alias Manager.
-
- fullPathLength input: The number of characters in the full pathname
- of the target.
- fullPath input: A pointer to a buffer that contains the full
- pathname of the target. The full pathname starts
- with the name of the volume, includes all of
- the directory names in the path to the target,
- and ends with the target name.
- vRefNum output: The volume reference number.
- parID output: The parent directory ID of the specified object.
- name output: The name of the specified object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 The volume is not mounted
- fnfErr -43 Target not found, but volume and parent
- directory found
- paramErr -50 Parameter error
- usrCanceledErr -128 The user canceled the operation
-
- __________
-
- See also: FSpLocationFromFullPath
-*/
-
-/*****************************************************************************/
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __FULLPATH__ */
-
+++ /dev/null
-/*
- File: IterateDirectory.c
-
- Contains: File Manager directory iterator routines.
-
- Version: MoreFiles
-
- Copyright: © 1995-2001 by Jim Luther and Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <2> 2/7/01 JL Added standard header. Updated names of includes.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-#include <MacTypes.h>
-#include <MacErrors.h>
-#include <Files.h>
-
-#define __COMPILINGMOREFILES
-
-#include "MoreFilesExtras.h"
-#include "IterateDirectory.h"
-
-/*
-** Type definitions
-*/
-
-/* The IterateGlobals structure is used to minimize the amount of
-** stack space used when recursively calling IterateDirectoryLevel
-** and to hold global information that might be needed at any time.
-*/
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=mac68k
-#endif
-struct IterateGlobals
-{
- IterateFilterProcPtr iterateFilter; /* pointer to IterateFilterProc */
- CInfoPBRec cPB; /* the parameter block used for PBGetCatInfo calls */
- Str63 itemName; /* the name of the current item */
- OSErr result; /* temporary holder of results - saves 2 bytes of stack each level */
- Boolean quitFlag; /* set to true if filter wants to kill interation */
- unsigned short maxLevels; /* Maximum levels to iterate through */
- unsigned short currentLevel; /* The current level IterateLevel is on */
- void *yourDataPtr; /* A pointer to caller data the filter may need to access */
-};
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=reset
-#endif
-
-typedef struct IterateGlobals IterateGlobals;
-typedef IterateGlobals *IterateGlobalsPtr;
-
-/*****************************************************************************/
-
-/* Static Prototype */
-
-static void IterateDirectoryLevel(long dirID,
- IterateGlobals *theGlobals);
-
-/*****************************************************************************/
-
-/*
-** Functions
-*/
-
-static void IterateDirectoryLevel(long dirID,
- IterateGlobals *theGlobals)
-{
- if ( (theGlobals->maxLevels == 0) || /* if maxLevels is zero, we aren't checking levels */
- (theGlobals->currentLevel < theGlobals->maxLevels) ) /* if currentLevel < maxLevels, look at this level */
- {
- short index = 1;
-
- ++theGlobals->currentLevel; /* go to next level */
-
- do
- { /* Isn't C great... What I'd give for a "WITH theGlobals DO" about now... */
-
- /* Get next source item at the current directory level */
-
- theGlobals->cPB.dirInfo.ioFDirIndex = index;
- theGlobals->cPB.dirInfo.ioDrDirID = dirID;
- theGlobals->result = PBGetCatInfoSync((CInfoPBPtr)&theGlobals->cPB);
-
- if ( theGlobals->result == noErr )
- {
- /* Call the IterateFilterProc */
- CallIterateFilterProc(theGlobals->iterateFilter, &theGlobals->cPB, &theGlobals->quitFlag, theGlobals->yourDataPtr);
-
- /* Is it a directory? */
- if ( (theGlobals->cPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* We have a directory */
- if ( !theGlobals->quitFlag )
- {
- /* Dive again if the IterateFilterProc didn't say "quit" */
- IterateDirectoryLevel(theGlobals->cPB.dirInfo.ioDrDirID, theGlobals);
- }
- }
- }
-
- ++index; /* prepare to get next item */
- } while ( (theGlobals->result == noErr) && (!theGlobals->quitFlag) ); /* time to fall back a level? */
-
- if ( (theGlobals->result == fnfErr) || /* fnfErr is OK - it only means we hit the end of this level */
- (theGlobals->result == afpAccessDenied) ) /* afpAccessDenied is OK, too - it only means we cannot see inside a directory */
- {
- theGlobals->result = noErr;
- }
-
- --theGlobals->currentLevel; /* return to previous level as we leave */
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr IterateDirectory(short vRefNum,
- long dirID,
- ConstStr255Param name,
- unsigned short maxLevels,
- IterateFilterProcPtr iterateFilter,
- void *yourDataPtr)
-{
- IterateGlobals theGlobals;
- OSErr result;
- long theDirID;
- short theVRefNum;
- Boolean isDirectory;
-
- /* Make sure there is a IterateFilter */
- if ( iterateFilter != NULL )
- {
- /* Get the real directory ID and make sure it is a directory */
- result = GetDirectoryID(vRefNum, dirID, name, &theDirID, &isDirectory);
- if ( result == noErr )
- {
- if ( isDirectory == true )
- {
- /* Get the real vRefNum */
- result = DetermineVRefNum(name, vRefNum, &theVRefNum);
- if ( result == noErr )
- {
- /* Set up the globals we need to access from the recursive routine. */
- theGlobals.iterateFilter = iterateFilter;
- theGlobals.cPB.hFileInfo.ioNamePtr = (StringPtr)&theGlobals.itemName;
- theGlobals.cPB.hFileInfo.ioVRefNum = theVRefNum;
- theGlobals.itemName[0] = 0;
- theGlobals.result = noErr;
- theGlobals.quitFlag = false;
- theGlobals.maxLevels = maxLevels;
- theGlobals.currentLevel = 0; /* start at level 0 */
- theGlobals.yourDataPtr = yourDataPtr;
-
- /* Here we go into recursion land... */
- IterateDirectoryLevel(theDirID, &theGlobals);
-
- result = theGlobals.result; /* set the result */
- }
- }
- else
- {
- result = dirNFErr; /* a file was passed instead of a directory */
- }
- }
- }
- else
- {
- result = paramErr; /* iterateFilter was NULL */
- }
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpIterateDirectory(const FSSpec *spec,
- unsigned short maxLevels,
- IterateFilterProcPtr iterateFilter,
- void *yourDataPtr)
-{
- return ( IterateDirectory(spec->vRefNum, spec->parID, spec->name,
- maxLevels, iterateFilter, yourDataPtr) );
-}
-
-/*****************************************************************************/
+++ /dev/null
-/*
- File: IterateDirectory.h
-
- Contains: File Manager directory iterator routines.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1995-2001 by Jim Luther and Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-#ifndef __ITERATEDIRECTORY__
-#define __ITERATEDIRECTORY__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-typedef CALLBACK_API( void , IterateFilterProcPtr )(const CInfoPBRec *cpbPtr, Boolean *quitFlag, void *yourDataPtr);
-/*
- This is the prototype for the IterateFilterProc function which is
- called once for each file and directory found by IterateDirectory. The
- IterateFilterProc gets a pointer to the CInfoPBRec that IterateDirectory
- used to call PBGetCatInfo. The IterateFilterProc can use the read-only
- data in the CInfoPBRec for whatever it wants.
-
- If the IterateFilterProc wants to stop IterateDirectory, it can set
- quitFlag to true (quitFlag will be passed to the IterateFilterProc
- false).
-
- The yourDataPtr parameter can point to whatever data structure you might
- want to access from within the IterateFilterProc.
-
- cpbPtr input: A pointer to the CInfoPBRec that IterateDirectory
- used to call PBGetCatInfo. The CInfoPBRec and the
- data it points to must not be changed by your
- IterateFilterProc.
- quitFlag output: Your IterateFilterProc can set quitFlag to true
- if it wants to stop IterateDirectory.
- yourDataPtr input: A pointer to whatever data structure you might
- want to access from within the IterateFilterProc.
-
- __________
-
- Also see: IterateDirectory, FSpIterateDirectory
-*/
-#define CallIterateFilterProc(userRoutine, cpbPtr, quitFlag, yourDataPtr) \
- (*(userRoutine))((cpbPtr), (quitFlag), (yourDataPtr))
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-IterateDirectory(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- unsigned short maxLevels,
- IterateFilterProcPtr iterateFilter,
- void * yourDataPtr);
-
-
-/*
- The IterateDirectory function performs a recursive iteration (scan) of
- the specified directory and calls your IterateFilterProc function once
- for each file and directory found.
-
- The maxLevels parameter lets you control how deep the recursion goes.
- If maxLevels is 1, IterateDirectory only scans the specified directory;
- if maxLevels is 2, IterateDirectory scans the specified directory and
- one subdirectory below the specified directory; etc. Set maxLevels to
- zero to scan all levels.
-
- The yourDataPtr parameter can point to whatever data structure you might
- want to access from within the IterateFilterProc.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- maxLevels input: Maximum number of directory levels to scan or
- zero to scan all directory levels.
- iterateFilter input: A pointer to the routine you want called once
- for each file and directory found by
- IterateDirectory.
- yourDataPtr input: A pointer to whatever data structure you might
- want to access from within the IterateFilterProc.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume or iterateFilter was NULL
- dirNFErr -120 Directory not found or incomplete pathname
- or a file was passed instead of a directory
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: IterateFilterProcPtr, FSpIterateDirectory
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpIterateDirectory(
- const FSSpec * spec,
- unsigned short maxLevels,
- IterateFilterProcPtr iterateFilter,
- void * yourDataPtr);
-
-
-/*
- The FSpIterateDirectory function performs a recursive iteration (scan)
- of the specified directory and calls your IterateFilterProc function once
- for each file and directory found.
-
- The maxLevels parameter lets you control how deep the recursion goes.
- If maxLevels is 1, FSpIterateDirectory only scans the specified directory;
- if maxLevels is 2, FSpIterateDirectory scans the specified directory and
- one subdirectory below the specified directory; etc. Set maxLevels to
- zero to scan all levels.
-
- The yourDataPtr parameter can point to whatever data structure you might
- want to access from within the IterateFilterProc.
-
- spec input: An FSSpec record specifying the directory to scan.
- maxLevels input: Maximum number of directory levels to scan or
- zero to scan all directory levels.
- iterateFilter input: A pointer to the routine you want called once
- for each file and directory found by
- FSpIterateDirectory.
- yourDataPtr input: A pointer to whatever data structure you might
- want to access from within the IterateFilterProc.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume or iterateFilter was NULL
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: IterateFilterProcPtr, IterateDirectory
-*/
-
-/*****************************************************************************/
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __ITERATEDIRECTORY__ */
-
+++ /dev/null
-/*
- File: MoreDesktopMgr.c
-
- Contains: A collection of useful high-level Desktop Manager routines.
- If the Desktop Manager is not available, use the Desktop file
- for 'read' operations.
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
- (NG) Nitin Ganatra
-
- Change History (most recent first):
-
- <2> 2/7/01 JL Added standard header. Updated names of includes. Updated
- various routines to use new calling convention of the
- MoreFilesExtras accessor functions.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-#include <MacTypes.h>
-#include <MacErrors.h>
-#include <MacMemory.h>
-#include <Files.h>
-#include <Resources.h>
-#include <Icons.h>
-
-#define __COMPILINGMOREFILES
-
-#include "MoreFiles.h"
-#include "MoreFilesExtras.h"
-#include "Search.h"
-#include "MoreDesktopMgr.h"
-
-/*****************************************************************************/
-
-/* Desktop file notes:
-**
-** ¥ The Desktop file is owned by the Finder and is normally open by the
-** Finder. That means that we only have read-only access to the Desktop
-** file.
-** ¥ Since the Resource Manager doesn't support shared access to resource
-** files and we're using read-only access, we don't ever leave the
-** Desktop file open. We open a path to it, get the data we want out
-** of it, and then close the open path. This is the only safe way to
-** open a resource file with read-only access since some other program
-** could have it open with write access.
-** ¥ The bundle related resources in the Desktop file are normally
-** purgable, so when we're looking through them, we don't bother to
-** release resources we're done looking at - closing the resource file
-** (which we always do) will release them.
-** ¥ Since we can't assume the Desktop file is named "Desktop"
-** (it probably is everywhere but France), we get the Desktop
-** file's name by searching the volume's root directory for a file
-** with fileType == 'FNDR' and creator == 'ERIK'. The only problem with
-** this scheme is that someone could create another file with that type
-** and creator in the root directory and we'd find the wrong file.
-** The chances of this are very slim.
-*/
-
-/*****************************************************************************/
-
-/* local defines */
-
-enum
-{
- kBNDLResType = 'BNDL',
- kFREFResType = 'FREF',
- kIconFamResType = 'ICN#',
- kFCMTResType = 'FCMT',
- kAPPLResType = 'APPL'
-};
-
-/*****************************************************************************/
-
-/* local data structures */
-
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=mac68k
-#endif
-
-struct IDRec
-{
- short localID;
- short rsrcID;
-};
-typedef struct IDRec IDRec;
-typedef IDRec *IDRecPtr;
-
-struct BundleType
-{
- OSType type; /* 'ICN#' or 'FREF' */
- short count; /* number of IDRecs - 1 */
- IDRec idArray[1];
-};
-typedef struct BundleType BundleType;
-typedef BundleType *BundleTypePtr;
-
-struct BNDLRec
-{
- OSType signature; /* creator type signature */
- short versionID; /* version - should always be 0 */
- short numTypes; /* number of elements in typeArray - 1 */
- BundleType typeArray[1];
-};
-typedef struct BNDLRec BNDLRec;
-typedef BNDLRec **BNDLRecHandle;
-
-struct FREFRec
-{
- OSType fileType; /* file type */
- short iconID; /* icon local ID */
- Str255 fileName; /* file name */
-};
-typedef struct FREFRec FREFRec;
-typedef FREFRec **FREFRecHandle;
-
-struct APPLRec
-{
- OSType creator; /* creator type signature */
- long parID; /* parent directory ID */
- Str255 applName; /* application name */
-};
-typedef struct APPLRec APPLRec;
-typedef APPLRec *APPLRecPtr;
-
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=reset
-#endif
-
-/*****************************************************************************/
-
-/* static prototypes */
-
-static OSErr GetDesktopFileName(short vRefNum,
- Str255 desktopName);
-
-static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- short *applVRefNum,
- long *applParID,
- Str255 applName);
-
-static OSErr FindBundleGivenCreator(OSType creator,
- BNDLRecHandle *returnBndl);
-
-static OSErr FindTypeInBundle(OSType typeToFind,
- BNDLRecHandle theBndl,
- BundleTypePtr *returnBundleType);
-
-static OSErr GetLocalIDFromFREF(BundleTypePtr theBundleType,
- OSType fileType,
- short *iconLocalID);
-
-static OSErr GetIconRsrcIDFromLocalID(BundleTypePtr theBundleType,
- short iconLocalID,
- short *iconRsrcID);
-
-static OSType DTIconToResIcon(short iconType);
-
-static OSErr GetIconFromDesktopFile(ConstStr255Param volName,
- short vRefNum,
- short iconType,
- OSType fileCreator,
- OSType fileType,
- Handle *iconHandle);
-
-static OSErr GetCommentID(short vRefNum,
- long dirID,
- ConstStr255Param name,
- short *commentID);
-
-static OSErr GetCommentFromDesktopFile(short vRefNum,
- long dirID,
- ConstStr255Param name,
- Str255 comment);
-
-/*****************************************************************************/
-
-/*
-** GetDesktopFileName
-**
-** Get the name of the Desktop file.
-*/
-static OSErr GetDesktopFileName(short vRefNum,
- Str255 desktopName)
-{
- OSErr error;
- HParamBlockRec pb;
- short index;
- Boolean found;
-
- pb.fileParam.ioNamePtr = desktopName;
- pb.fileParam.ioVRefNum = vRefNum;
- pb.fileParam.ioFVersNum = 0;
- index = 1;
- found = false;
- do
- {
- pb.fileParam.ioDirID = fsRtDirID;
- pb.fileParam.ioFDirIndex = index;
- error = PBHGetFInfoSync(&pb);
- if ( error == noErr )
- {
- if ( (pb.fileParam.ioFlFndrInfo.fdType == 'FNDR') &&
- (pb.fileParam.ioFlFndrInfo.fdCreator == 'ERIK') )
- {
- found = true;
- }
- }
- ++index;
- } while ( (error == noErr) && !found );
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DTOpen(ConstStr255Param volName,
- short vRefNum,
- short *dtRefNum,
- Boolean *newDTDatabase)
-{
- OSErr error;
- GetVolParmsInfoBuffer volParmsInfo;
- long infoSize;
- DTPBRec pb;
-
- /* Check for volume Desktop Manager support before calling */
- infoSize = sizeof(GetVolParmsInfoBuffer);
- error = HGetVolParms(volName, vRefNum, &volParmsInfo, &infoSize);
- if ( error == noErr )
- {
- if ( hasDesktopMgr(&volParmsInfo) )
- {
- pb.ioNamePtr = (StringPtr)volName;
- pb.ioVRefNum = vRefNum;
- error = PBDTOpenInform(&pb);
- /* PBDTOpenInform informs us if the desktop was just created */
- /* by leaving the low bit of ioTagInfo clear (0) */
- *newDTDatabase = ((pb.ioTagInfo & 1L) == 0);
- if ( error == paramErr )
- {
- error = PBDTGetPath(&pb);
- /* PBDTGetPath doesn't tell us if the database is new */
- /* so assume it is not new */
- *newDTDatabase = false;
- }
- *dtRefNum = pb.ioDTRefNum;
- }
- else
- {
- error = paramErr;
- }
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** GetAPPLFromDesktopFile
-**
-** Get a application's location from the
-** Desktop file's 'APPL' resources.
-*/
-static OSErr GetAPPLFromDesktopFile(ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- short *applVRefNum,
- long *applParID,
- Str255 applName)
-{
- OSErr error;
- short realVRefNum;
- Str255 desktopName;
- short savedResFile;
- short dfRefNum;
- Handle applResHandle;
- Boolean foundCreator;
- Ptr applPtr;
- long applSize;
-
- error = DetermineVRefNum(volName, vRefNum, &realVRefNum);
- if ( error == noErr )
- {
- error = GetDesktopFileName(realVRefNum, desktopName);
- if ( error == noErr )
- {
- savedResFile = CurResFile();
- /*
- ** Open the 'Desktop' file in the root directory. (because
- ** opening the resource file could preload unwanted resources,
- ** bracket the call with SetResLoad(s))
- */
- SetResLoad(false);
- dfRefNum = HOpenResFile(realVRefNum, fsRtDirID, desktopName, fsRdPerm);
- SetResLoad(true);
-
- if ( dfRefNum != -1)
- {
- /* Get 'APPL' resource ID 0 */
- applResHandle = Get1Resource(kAPPLResType, 0);
- if ( applResHandle != NULL )
- {
- applSize = GetHandleSize((Handle)applResHandle);
- if ( applSize != 0 ) /* make sure the APPL resource isn't empty */
- {
- foundCreator = false;
- applPtr = *applResHandle;
-
- /* APPL's don't have a count so I have to use the size as the bounds */
- while ( (foundCreator == false) &&
- (applPtr < (*applResHandle + applSize)) )
- {
- if ( ((APPLRecPtr)applPtr)->creator == creator )
- {
- foundCreator = true;
- }
- else
- {
- /* fun with pointer math... */
- applPtr += sizeof(OSType) +
- sizeof(long) +
- ((APPLRecPtr)applPtr)->applName[0] + 1;
- /* application mappings are word aligned within the resource */
- if ( ((unsigned long)applPtr % 2) != 0 )
- {
- applPtr += 1;
- }
- }
- }
- if ( foundCreator == true )
- {
- *applVRefNum = realVRefNum;
- *applParID = ((APPLRecPtr)applPtr)->parID;
- BlockMoveData(((APPLRecPtr)applPtr)->applName,
- applName,
- ((APPLRecPtr)applPtr)->applName[0] + 1);
- /* error is already noErr */
- }
- else
- {
- error = afpItemNotFound; /* didn't find a creator match */
- }
- }
- else
- {
- error = afpItemNotFound; /* no APPL mapping available */
- }
- }
- else
- {
- error = afpItemNotFound; /* no APPL mapping available */
- }
-
- /* restore the resource chain and close the Desktop file */
- UseResFile(savedResFile);
- CloseResFile(dfRefNum);
- }
- else
- {
- error = afpItemNotFound;
- }
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DTXGetAPPL(ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- Boolean searchCatalog,
- short *applVRefNum,
- long *applParID,
- Str255 applName)
-{
- OSErr error;
- UniversalFMPB pb;
- short dtRefNum;
- Boolean newDTDatabase;
- short realVRefNum;
- short index;
- Boolean applFound;
- FSSpec spec;
- long actMatchCount;
-
- /* get the real vRefNum */
- error = DetermineVRefNum(volName, vRefNum, &realVRefNum);
- if ( error == noErr )
- {
- error = DTOpen(volName, vRefNum, &dtRefNum, &newDTDatabase);
- if ( error == noErr )
- {
- if ( !newDTDatabase )
- {
- index = 0;
- applFound = false;
- do
- {
- pb.dtPB.ioNamePtr = applName;
- pb.dtPB.ioDTRefNum = dtRefNum;
- pb.dtPB.ioIndex = index;
- pb.dtPB.ioFileCreator = creator;
- error = PBDTGetAPPLSync(&pb.dtPB);
- if ( error == noErr )
- {
- /* got a match - see if it is valid */
-
- *applVRefNum = realVRefNum; /* get the vRefNum now */
- *applParID = pb.dtPB.ioAPPLParID; /* get the parent ID now */
-
- /* pb.hPB.fileParam.ioNamePtr is already set */
- pb.hPB.fileParam.ioVRefNum = realVRefNum;
- pb.hPB.fileParam.ioFVersNum = 0;
- pb.hPB.fileParam.ioDirID = *applParID;
- pb.hPB.fileParam.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- if ( PBHGetFInfoSync(&pb.hPB) == noErr )
- {
- if ( (pb.hPB.fileParam.ioFlFndrInfo.fdCreator == creator) &&
- (pb.hPB.fileParam.ioFlFndrInfo.fdType == 'APPL') )
- {
- applFound = true;
- }
- }
- }
- ++index;
- } while ( (error == noErr) && !applFound );
- if ( error != noErr )
- {
- error = afpItemNotFound;
- }
- }
- else
- {
- /* Desktop database is empty (new), set error to try CatSearch */
- error = afpItemNotFound;
- }
- }
- /* acceptable errors from Desktop Manager to continue are paramErr or afpItemNotFound */
- if ( error == paramErr )
- {
- /* if paramErr, the volume didn't support the Desktop Manager */
- /* try the Desktop file */
-
- error = GetAPPLFromDesktopFile(volName, vRefNum, creator,
- applVRefNum, applParID, applName);
- if ( error == noErr )
- {
- /* got a match - see if it is valid */
-
- pb.hPB.fileParam.ioNamePtr = applName;
- pb.hPB.fileParam.ioVRefNum = *applVRefNum;
- pb.hPB.fileParam.ioFVersNum = 0;
- pb.hPB.fileParam.ioDirID = *applParID;
- pb.hPB.fileParam.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- if ( PBHGetFInfoSync(&pb.hPB) == noErr )
- {
- if ( (pb.hPB.fileParam.ioFlFndrInfo.fdCreator != creator) ||
- (pb.hPB.fileParam.ioFlFndrInfo.fdType != 'APPL') )
- {
- error = afpItemNotFound;
- }
- }
- else if ( error == fnfErr )
- {
- error = afpItemNotFound;
- }
- }
- }
- /* acceptable error from DesktopFile code to continue is afpItemNotFound */
- if ( (error == afpItemNotFound) && searchCatalog)
- {
- /* Couldn't be found in the Desktop file either, */
- /* try searching with CatSearch if requested */
-
- error = CreatorTypeFileSearch(NULL, realVRefNum, creator, kAPPLResType, &spec, 1,
- &actMatchCount, true);
- if ( (error == noErr) || (error == eofErr) )
- {
- if ( actMatchCount > 0 )
- {
- *applVRefNum = spec.vRefNum;
- *applParID = spec.parID;
- BlockMoveData(spec.name, applName, spec.name[0] + 1);
- }
- else
- {
- error = afpItemNotFound;
- }
- }
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpDTXGetAPPL(ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- Boolean searchCatalog,
- FSSpec *spec)
-{
- return ( DTXGetAPPL(volName, vRefNum, creator, searchCatalog,
- &(spec->vRefNum), &(spec->parID), spec->name) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DTGetAPPL(ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- short *applVRefNum,
- long *applParID,
- Str255 applName)
-{
- /* Call DTXGetAPPL with the "searchCatalog" parameter true */
- return ( DTXGetAPPL(volName, vRefNum, creator, true,
- applVRefNum, applParID, applName) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpDTGetAPPL(ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- FSSpec *spec)
-{
- /* Call DTXGetAPPL with the "searchCatalog" parameter true */
- return ( DTXGetAPPL(volName, vRefNum, creator, true,
- &(spec->vRefNum), &(spec->parID), spec->name) );
-}
-
-/*****************************************************************************/
-
-/*
-** FindBundleGivenCreator
-**
-** Search the current resource file for the 'BNDL' resource with the given
-** creator and return a handle to it.
-*/
-static OSErr FindBundleGivenCreator(OSType creator,
- BNDLRecHandle *returnBndl)
-{
- OSErr error;
- short numOfBundles;
- short index;
- BNDLRecHandle theBndl;
-
- error = afpItemNotFound; /* default to not found */
-
- /* Search each BNDL resource until we find the one with a matching creator. */
-
- numOfBundles = Count1Resources(kBNDLResType);
- index = 1;
- *returnBndl = NULL;
-
- while ( (index <= numOfBundles) && (*returnBndl == NULL) )
- {
- theBndl = (BNDLRecHandle)Get1IndResource(kBNDLResType, index);
-
- if ( theBndl != NULL )
- {
- if ( (*theBndl)->signature == creator )
- {
- /* numTypes and typeArray->count will always be the actual count minus 1, */
- /* so 0 in both fields is valid. */
- if ( ((*theBndl)->numTypes >= 0) && ((*theBndl)->typeArray->count >= 0) )
- {
- /* got it */
- *returnBndl = theBndl;
- error = noErr;
- }
- }
- }
-
- index ++;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** FindTypeInBundle
-**
-** Given a Handle to a BNDL return a pointer to the desired type
-** in it. If the type is not found, or if the type's count < 0,
-** return afpItemNotFound.
-*/
-static OSErr FindTypeInBundle(OSType typeToFind,
- BNDLRecHandle theBndl,
- BundleTypePtr *returnBundleType)
-{
- OSErr error;
- short index;
- Ptr ptrIterator; /* use a Ptr so we can do ugly pointer math */
-
- error = afpItemNotFound; /* default to not found */
-
- ptrIterator = (Ptr)((*theBndl)->typeArray);
- index = 0;
- *returnBundleType = NULL;
-
- while ( (index < ((*theBndl)->numTypes + 1)) &&
- (*returnBundleType == NULL) )
- {
- if ( (((BundleTypePtr)ptrIterator)->type == typeToFind) &&
- (((BundleTypePtr)ptrIterator)->count >= 0) )
- {
- *returnBundleType = (BundleTypePtr)ptrIterator;
- error = noErr;
- }
- else
- {
- ptrIterator += ( sizeof(OSType) +
- sizeof(short) +
- ( sizeof(IDRec) * (((BundleTypePtr)ptrIterator)->count + 1) ) );
- ++index;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** GetLocalIDFromFREF
-**
-** Given a pointer to a 'FREF' BundleType record, load each 'FREF' resource
-** looking for a matching fileType. If a matching fileType is found, return
-** its icon local ID. If no match is found, return afpItemNotFound as the
-** function result.
-*/
-static OSErr GetLocalIDFromFREF(BundleTypePtr theBundleType,
- OSType fileType,
- short *iconLocalID)
-{
- OSErr error;
- short index;
- IDRecPtr idIterator;
- FREFRecHandle theFref;
-
- error = afpItemNotFound; /* default to not found */
-
- /* For each localID in this type, get the FREF resource looking for fileType */
- index = 0;
- idIterator = &theBundleType->idArray[0];
- *iconLocalID = 0;
-
- while ( (index <= theBundleType->count) && (*iconLocalID == 0) )
- {
- theFref = (FREFRecHandle)Get1Resource(kFREFResType, idIterator->rsrcID);
- if ( theFref != NULL )
- {
- if ( (*theFref)->fileType == fileType )
- {
- *iconLocalID = (*theFref)->iconID;
- error = noErr;
- }
- }
-
- ++idIterator;
- ++index;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** GetIconRsrcIDFromLocalID
-**
-** Given a pointer to a 'ICN#' BundleType record, look for the IDRec with
-** the localID that matches iconLocalID. If a matching IDRec is found,
-** return the IDRec's rsrcID field value. If no match is found, return
-** afpItemNotFound as the function result.
-*/
-static OSErr GetIconRsrcIDFromLocalID(BundleTypePtr theBundleType,
- short iconLocalID,
- short *iconRsrcID)
-{
- OSErr error;
- short index;
- IDRecPtr idIterator;
-
- error = afpItemNotFound; /* default to not found */
-
- /* Find the rsrcID of the icon family type, given the localID */
- index = 0;
- idIterator = &theBundleType->idArray[0];
- *iconRsrcID = 0;
-
- while ( (index <= theBundleType->count) && (*iconRsrcID == 0) )
- {
- if ( idIterator->localID == iconLocalID )
- {
- *iconRsrcID = idIterator->rsrcID;
- error = noErr;
- }
-
- idIterator ++;
- index ++;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** DTIconToResIcon
-**
-** Map a Desktop Manager icon type to the corresponding resource type.
-** Return (OSType)0 if there is no corresponding resource type.
-*/
-static OSType DTIconToResIcon(short iconType)
-{
- OSType resType;
-
- switch ( iconType )
- {
- case kLargeIcon:
- resType = large1BitMask;
- break;
- case kLarge4BitIcon:
- resType = large4BitData;
- break;
- case kLarge8BitIcon:
- resType = large8BitData;
- break;
- case kSmallIcon:
- resType = small1BitMask;
- break;
- case kSmall4BitIcon:
- resType = small4BitData;
- break;
- case kSmall8BitIcon:
- resType = small8BitData;
- break;
- default:
- resType = (OSType)0;
- break;
- }
-
- return ( resType );
-}
-
-/*****************************************************************************/
-
-/*
-** GetIconFromDesktopFile
-**
-** INPUT a pointer to a non-existent Handle, because we'll allocate one
-**
-** search each BNDL resource for the right fileCreator and once we get it
-** find the 'FREF' type in BNDL
-** for each localID in the type, open the FREF resource
-** if the FREF is the desired fileType
-** get its icon localID
-** get the ICN# type in BNDL
-** get the icon resource number from the icon localID
-** get the icon resource type from the desktop mgr's iconType
-** get the icon of that type and number
-*/
-static OSErr GetIconFromDesktopFile(ConstStr255Param volName,
- short vRefNum,
- short iconType,
- OSType fileCreator,
- OSType fileType,
- Handle *iconHandle)
-{
- OSErr error;
- short realVRefNum;
- Str255 desktopName;
- short savedResFile;
- short dfRefNum;
- BNDLRecHandle theBndl = NULL;
- BundleTypePtr theBundleType;
- short iconLocalID;
- short iconRsrcID;
- OSType iconRsrcType;
- Handle returnIconHandle;
- char bndlState;
-
- *iconHandle = NULL;
-
- error = DetermineVRefNum(volName, vRefNum, &realVRefNum);
- if ( error == noErr )
- {
- error = GetDesktopFileName(realVRefNum, desktopName);
- if ( error == noErr )
- {
- savedResFile = CurResFile();
-
- /*
- ** Open the 'Desktop' file in the root directory. (because
- ** opening the resource file could preload unwanted resources,
- ** bracket the call with SetResLoad(s))
- */
- SetResLoad(false);
- dfRefNum = HOpenResFile(realVRefNum, fsRtDirID, desktopName, fsRdPerm);
- SetResLoad(true);
-
- if ( dfRefNum != -1 )
- {
- /*
- ** Find the BNDL resource with the specified creator.
- */
- error = FindBundleGivenCreator(fileCreator, &theBndl);
- if ( error == noErr )
- {
- /* Lock the BNDL resource so it won't be purged when other resources are loaded */
- bndlState = HGetState((Handle)theBndl);
- HLock((Handle)theBndl);
-
- /* Find the 'FREF' BundleType record in the BNDL resource. */
- error = FindTypeInBundle(kFREFResType, theBndl, &theBundleType);
- if ( error == noErr )
- {
- /* Find the local ID in the 'FREF' resource with the specified fileType */
- error = GetLocalIDFromFREF(theBundleType, fileType, &iconLocalID);
- if ( error == noErr )
- {
- /* Find the 'ICN#' BundleType record in the BNDL resource. */
- error = FindTypeInBundle(kIconFamResType, theBndl, &theBundleType);
- if ( error == noErr )
- {
- /* Find the icon's resource ID in the 'ICN#' BundleType record */
- error = GetIconRsrcIDFromLocalID(theBundleType, iconLocalID, &iconRsrcID);
- if ( error == noErr )
- {
- /* Map Desktop Manager icon type to resource type */
- iconRsrcType = DTIconToResIcon(iconType);
-
- if ( iconRsrcType != (OSType)0 )
- {
- /* Load the icon */
- returnIconHandle = Get1Resource(iconRsrcType, iconRsrcID);
- if ( returnIconHandle != NULL )
- {
- /* Copy the resource handle, and return the copy */
- HandToHand(&returnIconHandle);
- if ( MemError() == noErr )
- {
- *iconHandle = returnIconHandle;
- }
- else
- {
- error = afpItemNotFound;
- }
- }
- else
- {
- error = afpItemNotFound;
- }
- }
- }
- }
- }
- }
- /* Restore the state of the BNDL resource */
- HSetState((Handle)theBndl, bndlState);
- }
- /* Restore the resource chain and close the Desktop file */
- UseResFile(savedResFile);
- CloseResFile(dfRefNum);
- }
- else
- {
- error = ResError(); /* could not open Desktop file */
- }
- }
- if ( (error != noErr) && (error != memFullErr) )
- {
- error = afpItemNotFound; /* force an error we should return */
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DTGetIcon(ConstStr255Param volName,
- short vRefNum,
- short iconType,
- OSType fileCreator,
- OSType fileType,
- Handle *iconHandle)
-{
- OSErr error;
- DTPBRec pb;
- short dtRefNum;
- Boolean newDTDatabase;
- Size bufferSize;
-
- *iconHandle = NULL;
- error = DTOpen(volName, vRefNum, &dtRefNum, &newDTDatabase);
- if ( error == noErr )
- {
- /* there was a desktop database and it's now open */
-
- if ( !newDTDatabase ) /* don't bother to look in a new (empty) database */
- {
- /* get the buffer size for the requested icon type */
- switch ( iconType )
- {
- case kLargeIcon:
- bufferSize = kLargeIconSize;
- break;
- case kLarge4BitIcon:
- bufferSize = kLarge4BitIconSize;
- break;
- case kLarge8BitIcon:
- bufferSize = kLarge8BitIconSize;
- break;
- case kSmallIcon:
- bufferSize = kSmallIconSize;
- break;
- case kSmall4BitIcon:
- bufferSize = kSmall4BitIconSize;
- break;
- case kSmall8BitIcon:
- bufferSize = kSmall8BitIconSize;
- break;
- default:
- iconType = 0;
- bufferSize = 0;
- break;
- }
- if ( bufferSize != 0 )
- {
- *iconHandle = NewHandle(bufferSize);
- if ( *iconHandle != NULL )
- {
- HLock(*iconHandle);
-
- pb.ioDTRefNum = dtRefNum;
- pb.ioTagInfo = 0;
- pb.ioDTBuffer = **iconHandle;
- pb.ioDTReqCount = bufferSize;
- pb.ioIconType = iconType;
- pb.ioFileCreator = fileCreator;
- pb.ioFileType = fileType;
- error = PBDTGetIconSync(&pb);
-
- HUnlock(*iconHandle);
-
- if ( error != noErr )
- {
- DisposeHandle(*iconHandle); /* dispose of the allocated memory */
- *iconHandle = NULL;
- }
- }
- else
- {
- error = memFullErr; /* handle could not be allocated */
- }
- }
- else
- {
- error = paramErr; /* unknown icon type requested */
- }
- }
- else
- {
- error = afpItemNotFound; /* the desktop database was empty - nothing to return */
- }
- }
- else
- {
- /* There is no desktop database - try the Desktop file */
-
- error = GetIconFromDesktopFile(volName, vRefNum, iconType,
- fileCreator, fileType, iconHandle);
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DTSetComment(short vRefNum,
- long dirID,
- ConstStr255Param name,
- ConstStr255Param comment)
-{
- DTPBRec pb;
- OSErr error;
- short dtRefNum;
- Boolean newDTDatabase;
-
- error = DTOpen(name, vRefNum, &dtRefNum, &newDTDatabase);
- if ( error == noErr )
- {
- pb.ioDTRefNum = dtRefNum;
- pb.ioNamePtr = (StringPtr)name;
- pb.ioDirID = dirID;
- pb.ioDTBuffer = (Ptr)&comment[1];
- /* Truncate the comment to 200 characters just in case */
- /* some file system doesn't range check */
- if ( comment[0] <= 200 )
- {
- pb.ioDTReqCount = comment[0];
- }
- else
- {
- pb.ioDTReqCount = 200;
- }
- error = PBDTSetCommentSync(&pb);
- }
- return (error);
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpDTSetComment(const FSSpec *spec,
- ConstStr255Param comment)
-{
- return (DTSetComment(spec->vRefNum, spec->parID, spec->name, comment));
-}
-
-/*****************************************************************************/
-
-/*
-** GetCommentID
-**
-** Get the comment ID number for the Desktop file's 'FCMT' resource ID from
-** the file or folders fdComment (frComment) field.
-*/
-static OSErr GetCommentID(short vRefNum,
- long dirID,
- ConstStr255Param name,
- short *commentID)
-{
- CInfoPBRec pb;
- OSErr error;
-
- error = GetCatInfoNoName(vRefNum, dirID, name, &pb);
- *commentID = pb.hFileInfo.ioFlXFndrInfo.fdComment;
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** GetCommentFromDesktopFile
-**
-** Get a file or directory's Finder comment field (if any) from the
-** Desktop file's 'FCMT' resources.
-*/
-static OSErr GetCommentFromDesktopFile(short vRefNum,
- long dirID,
- ConstStr255Param name,
- Str255 comment)
-{
- OSErr error;
- short commentID;
- short realVRefNum;
- Str255 desktopName;
- short savedResFile;
- short dfRefNum;
- StringHandle commentHandle;
-
- /* Get the comment ID number */
- error = GetCommentID(vRefNum, dirID, name, &commentID);
- if ( error == noErr )
- {
- if ( commentID != 0 ) /* commentID == 0 means there's no comment */
- {
- error = DetermineVRefNum(name, vRefNum, &realVRefNum);
- if ( error == noErr )
- {
- error = GetDesktopFileName(realVRefNum, desktopName);
- if ( error == noErr )
- {
- savedResFile = CurResFile();
- /*
- ** Open the 'Desktop' file in the root directory. (because
- ** opening the resource file could preload unwanted resources,
- ** bracket the call with SetResLoad(s))
- */
- SetResLoad(false);
- dfRefNum = HOpenResFile(realVRefNum, fsRtDirID, desktopName, fsRdPerm);
- SetResLoad(true);
-
- if ( dfRefNum != -1)
- {
- /* Get the comment resource */
- commentHandle = (StringHandle)Get1Resource(kFCMTResType,commentID);
- if ( commentHandle != NULL )
- {
- if ( GetHandleSize((Handle)commentHandle) > 0 )
- {
- BlockMoveData(*commentHandle, comment, *commentHandle[0] + 1);
- }
- else
- {
- error = afpItemNotFound; /* no comment available */
- }
- }
- else
- {
- error = afpItemNotFound; /* no comment available */
- }
-
- /* restore the resource chain and close the Desktop file */
- UseResFile(savedResFile);
- CloseResFile(dfRefNum);
- }
- else
- {
- error = afpItemNotFound;
- }
- }
- else
- {
- error = afpItemNotFound;
- }
- }
- }
- else
- {
- error = afpItemNotFound; /* no comment available */
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DTGetComment(short vRefNum,
- long dirID,
- ConstStr255Param name,
- Str255 comment)
-{
- DTPBRec pb;
- OSErr error;
- short dtRefNum;
- Boolean newDTDatabase;
-
- if (comment != NULL)
- {
- comment[0] = 0; /* return nothing by default */
-
- /* attempt to open the desktop database */
- error = DTOpen(name, vRefNum, &dtRefNum, &newDTDatabase);
- if ( error == noErr )
- {
- /* There was a desktop database and it's now open */
-
- if ( !newDTDatabase )
- {
- pb.ioDTRefNum = dtRefNum;
- pb.ioNamePtr = (StringPtr)name;
- pb.ioDirID = dirID;
- pb.ioDTBuffer = (Ptr)&comment[1];
- /*
- ** IMPORTANT NOTE #1: Inside Macintosh says that comments
- ** are up to 200 characters. While that may be correct for
- ** the HFS file system's Desktop Manager, other file
- ** systems (such as Apple Photo Access) return up to
- ** 255 characters. Make sure the comment buffer is a Str255
- ** or you'll regret it.
- **
- ** IMPORTANT NOTE #2: Although Inside Macintosh doesn't
- ** mention it, ioDTReqCount is a input field to
- ** PBDTGetCommentSync. Some file systems (like HFS) ignore
- ** ioDTReqCount and always return the full comment --
- ** others (like AppleShare) respect ioDTReqCount and only
- ** return up to ioDTReqCount characters of the comment.
- */
- pb.ioDTReqCount = sizeof(Str255) - 1;
- error = PBDTGetCommentSync(&pb);
- if (error == noErr)
- {
- comment[0] = (unsigned char)pb.ioDTActCount;
- }
- }
- }
- else
- {
- /* There is no desktop database - try the Desktop file */
- error = GetCommentFromDesktopFile(vRefNum, dirID, name, comment);
- if ( error != noErr )
- {
- error = afpItemNotFound; /* return an expected error */
- }
- }
- }
- else
- {
- error = paramErr;
- }
-
- return (error);
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpDTGetComment(const FSSpec *spec,
- Str255 comment)
-{
- return (DTGetComment(spec->vRefNum, spec->parID, spec->name, comment));
-}
-
-/*****************************************************************************/
-
-pascal OSErr DTCopyComment(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName)
-/* The destination volume must support the Desktop Manager for this to work */
-{
- OSErr error;
- Str255 comment;
-
- error = DTGetComment(srcVRefNum, srcDirID, srcName, comment);
- if ( (error == noErr) && (comment[0] > 0) )
- {
- error = DTSetComment(dstVRefNum, dstDirID, dstName, comment);
- }
- return (error);
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpDTCopyComment(const FSSpec *srcSpec,
- const FSSpec *dstSpec)
-/* The destination volume must support the Desktop Manager for this to work */
-{
- return (DTCopyComment(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->vRefNum, dstSpec->parID, dstSpec->name));
-}
-
-/*****************************************************************************/
+++ /dev/null
-/*
- File: MoreDesktopMgr.h
-
- Contains: A collection of useful high-level Desktop Manager routines. If the Desktop Manager is not available, use the Desktop file for 'read' operations.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-#ifndef __MOREDESKTOPMGR__
-#define __MOREDESKTOPMGR__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DTOpen(
- ConstStr255Param volName,
- short vRefNum,
- short * dtRefNum,
- Boolean * newDTDatabase);
-
-
-/*
- The DTOpen function opens a volume's desktop database. It returns
- the reference number of the desktop database and indicates if the
- desktop database was created as a result of this call (if it was created,
- then it is empty).
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- dtRefNum output: The reference number of Desktop Manager's
- desktop database on the specified volume.
- newDTDatabase output: true if the desktop database was created as a
- result of this call and thus empty.
- false if the desktop database was already created,
- or if it could not be determined if it was already
- created.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- paramErr -50 Volume doesn't support this function
- extFSErr -58 External file system error - no file
- system claimed this call.
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DTXGetAPPL(
- ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- Boolean searchCatalog,
- short * applVRefNum,
- long * applParID,
- Str255 applName);
-
-
-/*
- The DTXGetAPPL function finds an application (file type 'APPL') with
- the specified creator on the specified volume. It first tries to get
- the application mapping from the desktop database. If that fails,
- then it tries to find an application in the Desktop file. If that
- fails and searchCatalog is true, then it tries to find an application
- with the specified creator using the File Manager's CatSearch routine.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- creator input: The file's creator type.
- searchCatalog input: If true, search the catalog for the application
- if it isn't found in the desktop database.
- applVRefNum output: The volume reference number of the volume the
- application is on.
- applParID output: The parent directory ID of the application.
- applName output: The name of the application.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- paramErr -50 No default volume
- rfNumErr -51 Reference number invalid
- extFSErr -58 External file system error - no file
- system claimed this call
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-
- __________
-
- Also see: FSpDTGetAPPL
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpDTXGetAPPL(
- ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- Boolean searchCatalog,
- FSSpec * spec);
-
-
-/*
- The FSpDTXGetAPPL function finds an application (file type 'APPL') with
- the specified creator on the specified volume. It first tries to get
- the application mapping from the desktop database. If that fails,
- then it tries to find an application in the Desktop file. If that
- fails and searchCatalog is true, then it tries to find an application
- with the specified creator using the File Manager's CatSearch routine.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- creator input: The file's creator type.
- searchCatalog input: If true, search the catalog for the application
- if it isn't found in the desktop database.
- spec output: FSSpec record containing the application name and
- location.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- paramErr -50 No default volume
- rfNumErr -51 Reference number invalid
- extFSErr -58 External file system error - no file
- system claimed this call
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-
- __________
-
- Also see: FSpDTGetAPPL
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DTGetAPPL(
- ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- short * applVRefNum,
- long * applParID,
- Str255 applName);
-
-
-/*
- The DTGetAPPL function finds an application (file type 'APPL') with
- the specified creator on the specified volume. It first tries to get
- the application mapping from the desktop database. If that fails,
- then it tries to find an application in the Desktop file. If that
- fails, then it tries to find an application with the specified creator
- using the File Manager's CatSearch routine.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- creator input: The file's creator type.
- applVRefNum output: The volume reference number of the volume the
- application is on.
- applParID output: The parent directory ID of the application.
- applName output: The name of the application.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- paramErr -50 No default volume
- rfNumErr -51 Reference number invalid
- extFSErr -58 External file system error - no file
- system claimed this call
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-
- __________
-
- Also see: FSpDTGetAPPL
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpDTGetAPPL(
- ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- FSSpec * spec);
-
-
-/*
- The FSpDTGetAPPL function finds an application (file type 'APPL') with
- the specified creator on the specified volume. It first tries to get
- the application mapping from the desktop database. If that fails,
- then it tries to find an application in the Desktop file. If that
- fails, then it tries to find an application with the specified creator
- using the File Manager's CatSearch routine.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- creator input: The file's creator type.
- spec output: FSSpec record containing the application name and
- location.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- paramErr -50 No default volume
- rfNumErr -51 Reference number invalid
- extFSErr -58 External file system error - no file
- system claimed this call
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-
- __________
-
- Also see: DTGetAPPL
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DTGetIcon(
- ConstStr255Param volName,
- short vRefNum,
- short iconType,
- OSType fileCreator,
- OSType fileType,
- Handle * iconHandle);
-
-
-/*
- The DTGetIcon function retrieves the specified icon and returns it in
- a newly created handle. The icon is retrieves from the Desktop Manager
- or if the Desktop Manager is not available, from the Finder's Desktop
- file. Your program is responsible for disposing of the handle when it is
- done using the icon.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- iconType input: The icon type as defined in Files.h. Valid values are:
- kLargeIcon
- kLarge4BitIcon
- kLarge8BitIcon
- kSmallIcon
- kSmall4BitIcon
- kSmall8BitIcon
- fileCreator input: The icon's creator type.
- fileType input: The icon's file type.
- iconHandle output: A Handle containing the newly created icon.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- paramErr -50 Volume doesn't support this function
- rfNumErr -51 Reference number invalid
- extFSErr -58 External file system error - no file
- system claimed this call
- memFullErr -108 iconHandle could not be allocated
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DTSetComment(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- ConstStr255Param comment);
-
-
-/*
- The DTSetComment function sets a file or directory's Finder comment
- field. The volume must support the Desktop Manager because you only
- have read access to the Desktop file.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- comment input: The comment to add. Comments are limited to 200 characters;
- longer comments are truncated.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr Ð43 File or directory doesnÕt exist
- paramErr -50 Volume doesn't support this function
- wPrErr Ð44 Volume is locked through hardware
- vLckdErr Ð46 Volume is locked through software
- rfNumErr Ð51 Reference number invalid
- extFSErr -58 External file system error - no file
- system claimed this call.
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
-
- __________
-
- Also see: DTCopyComment, FSpDTCopyComment, FSpDTSetComment, DTGetComment,
- FSpDTGetComment
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpDTSetComment(
- const FSSpec * spec,
- ConstStr255Param comment);
-
-
-/*
- The FSpDTSetComment function sets a file or directory's Finder comment
- field. The volume must support the Desktop Manager because you only
- have read access to the Desktop file.
-
- spec input: An FSSpec record specifying the file or directory.
- comment input: The comment to add. Comments are limited to 200 characters;
- longer comments are truncated.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr Ð43 File or directory doesnÕt exist
- wPrErr Ð44 Volume is locked through hardware
- vLckdErr Ð46 Volume is locked through software
- rfNumErr Ð51 Reference number invalid
- paramErr -50 Volume doesn't support this function
- extFSErr -58 External file system error - no file
- system claimed this call.
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
-
- __________
-
- Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, DTGetComment,
- FSpDTGetComment
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DTGetComment(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- Str255 comment);
-
-
-/*
- The DTGetComment function gets a file or directory's Finder comment
- field (if any) from the Desktop Manager or if the Desktop Manager is
- not available, from the Finder's Desktop file.
-
- IMPORTANT NOTE: Inside Macintosh says that comments are up to
- 200 characters. While that may be correct for the HFS file system's
- Desktop Manager, other file systems (such as Apple Photo Access) return
- up to 255 characters. Make sure the comment buffer is a Str255 or you'll
- regret it.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- comment output: A Str255 where the comment is to be returned.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- paramErr -50 Volume doesn't support this function
- rfNumErr Ð51 Reference number invalid
- extFSErr -58 External file system error - no file
- system claimed this call.
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-
- __________
-
- Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment,
- FSpDTGetComment
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpDTGetComment(
- const FSSpec * spec,
- Str255 comment);
-
-
-/*
- The FSpDTGetComment function gets a file or directory's Finder comment
- field (if any) from the Desktop Manager or if the Desktop Manager is
- not available, from the Finder's Desktop file.
-
- IMPORTANT NOTE: Inside Macintosh says that comments are up to
- 200 characters. While that may be correct for the HFS file system's
- Desktop Manager, other file systems (such as Apple Photo Access) return
- up to 255 characters. Make sure the comment buffer is a Str255 or you'll
- regret it.
-
- spec input: An FSSpec record specifying the file or directory.
- comment output: A Str255 where the comment is to be returned.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- paramErr -50 Volume doesn't support this function
- rfNumErr Ð51 Reference number invalid
- extFSErr -58 External file system error - no file
- system claimed this call.
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-
- __________
-
- Also see: DTCopyComment, FSpDTCopyComment, DTSetComment, FSpDTSetComment,
- DTGetComment
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DTCopyComment(
- short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName);
-
-
-/*
- The DTCopyComment function copies the file or folder comment from the
- source to the destination object. The destination volume must support
- the Desktop Manager because you only have read access to the Desktop file.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Pointer to source object name, or nil when srcDirID
- specifies a directory that's the object.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstName input: Pointer to destination object name, or nil when
- dstDirID specifies a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr Ð43 File or directory doesnÕt exist
- wPrErr Ð44 Volume is locked through hardware
- vLckdErr Ð46 Volume is locked through software
- paramErr -50 Volume doesn't support this function
- rfNumErr Ð51 Reference number invalid
- paramErr -50 Volume doesn't support this function
- extFSErr -58 External file system error - no file
- system claimed this call.
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-
- __________
-
- Also see: FSpDTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment,
- FSpDTGetComment
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpDTCopyComment(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec);
-
-
-/*
- The FSpDTCopyComment function copies the desktop database comment from
- the source to the destination object. Both the source and the
- destination volumes must support the Desktop Manager.
-
- srcSpec input: An FSSpec record specifying the source object.
- dstSpec input: An FSSpec record specifying the destination object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr Ð43 File or directory doesnÕt exist
- wPrErr Ð44 Volume is locked through hardware
- vLckdErr Ð46 Volume is locked through software
- paramErr -50 Volume doesn't support this function
- rfNumErr Ð51 Reference number invalid
- paramErr -50 Volume doesn't support this function
- extFSErr -58 External file system error - no file
- system claimed this call.
- desktopDamagedErr -1305 The desktop database has become corrupted -
- the Finder will fix this, but if your
- application is not running with the
- Finder, use PBDTReset or PBDTDelete
- afpItemNotFound -5012 Information not found
-
- __________
-
- Also see: DTCopyComment, DTSetComment, FSpDTSetComment, DTGetComment,
- FSpDTGetComment
-*/
-
-/*****************************************************************************/
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MOREDESKTOPMGR__ */
-
+++ /dev/null
-/*
- File: MoreFiles.c
-
- Contains: The long lost high-level and FSSpec File Manager functions.
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <2> 2/7/01 JL Added standard header. Updated names of includes.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-#include <MacTypes.h>
-#include <MacErrors.h>
-#include <Files.h>
-
-#define __COMPILINGMOREFILES
-
-#include "MoreFiles.h"
-#include "MoreFilesExtras.h"
-
-/*****************************************************************************/
-
-pascal OSErr HGetVolParms(ConstStr255Param volName,
- short vRefNum,
- GetVolParmsInfoBuffer *volParmsInfo,
- long *infoSize)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.ioParam.ioNamePtr = (StringPtr)volName;
- pb.ioParam.ioVRefNum = vRefNum;
- pb.ioParam.ioBuffer = (Ptr)volParmsInfo;
- pb.ioParam.ioReqCount = *infoSize;
- error = PBHGetVolParmsSync(&pb);
- if ( error == noErr )
- {
- *infoSize = pb.ioParam.ioActCount;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HCreateMinimum(short vRefNum,
- long dirID,
- ConstStr255Param fileName)
-{
- HParamBlockRec pb;
-
- pb.fileParam.ioNamePtr = (StringPtr)fileName;
- pb.fileParam.ioVRefNum = vRefNum;
- pb.ioParam.ioVersNum = 0;
- pb.fileParam.ioDirID = dirID;
- return ( PBHCreateSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpCreateMinimum(const FSSpec *spec)
-{
- return ( HCreateMinimum(spec->vRefNum, spec->parID, spec->name) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ExchangeFiles(short vRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- long dstDirID,
- ConstStr255Param dstName)
-{
- HParamBlockRec pb;
-
- pb.fidParam.ioVRefNum = vRefNum;
- pb.fidParam.ioSrcDirID = srcDirID;
- pb.fidParam.ioNamePtr = (StringPtr)srcName;
- pb.fidParam.ioDestDirID = dstDirID;
- pb.fidParam.ioDestNamePtr = (StringPtr)dstName;
- return ( PBExchangeFilesSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ResolveFileIDRef(ConstStr255Param volName,
- short vRefNum,
- long fileID,
- long *parID,
- StringPtr fileName)
-{
- HParamBlockRec pb;
- OSErr error;
- Str255 tempStr;
-
- tempStr[0] = 0;
- if ( volName != NULL )
- {
- BlockMoveData(volName, tempStr, volName[0] + 1);
- }
- pb.fidParam.ioNamePtr = (StringPtr)tempStr;
- pb.fidParam.ioVRefNum = vRefNum;
- pb.fidParam.ioFileID = fileID;
- error = PBResolveFileIDRefSync(&pb);
- if ( error == noErr )
- {
- *parID = pb.fidParam.ioSrcDirID;
- if ( fileName != NULL )
- {
- BlockMoveData(tempStr, fileName, tempStr[0] + 1);
- }
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpResolveFileIDRef(ConstStr255Param volName,
- short vRefNum,
- long fileID,
- FSSpec *spec)
-{
- OSErr error;
-
- error = DetermineVRefNum(volName, vRefNum, &(spec->vRefNum));
- if ( error == noErr )
- {
- error = ResolveFileIDRef(volName, vRefNum, fileID, &(spec->parID), spec->name);
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr CreateFileIDRef(short vRefNum,
- long parID,
- ConstStr255Param fileName,
- long *fileID)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.fidParam.ioNamePtr = (StringPtr)fileName;
- pb.fidParam.ioVRefNum = vRefNum;
- pb.fidParam.ioSrcDirID = parID;
- error = PBCreateFileIDRefSync(&pb);
- if ( (error == noErr) || (error == fidExists) || (error == afpIDExists) )
- {
- *fileID = pb.fidParam.ioFileID;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpCreateFileIDRef(const FSSpec *spec,
- long *fileID)
-{
- return ( CreateFileIDRef(spec->vRefNum, spec->parID, spec->name, fileID) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DeleteFileIDRef(ConstStr255Param volName,
- short vRefNum,
- long fileID)
-{
- HParamBlockRec pb;
-
- pb.fidParam.ioNamePtr = (StringPtr)volName;
- pb.fidParam.ioVRefNum = vRefNum;
- pb.fidParam.ioFileID = fileID;
- return ( PBDeleteFileIDRefSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FlushFile(short refNum)
-{
- ParamBlockRec pb;
-
- pb.ioParam.ioRefNum = refNum;
- return ( PBFlushFileSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr LockRange(short refNum,
- long rangeLength,
- long rangeStart)
-{
- ParamBlockRec pb;
-
- pb.ioParam.ioRefNum = refNum;
- pb.ioParam.ioReqCount = rangeLength;
- pb.ioParam.ioPosMode = fsFromStart;
- pb.ioParam.ioPosOffset = rangeStart;
- return ( PBLockRangeSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr UnlockRange(short refNum,
- long rangeLength,
- long rangeStart)
-{
- ParamBlockRec pb;
-
- pb.ioParam.ioRefNum = refNum;
- pb.ioParam.ioReqCount = rangeLength;
- pb.ioParam.ioPosMode = fsFromStart;
- pb.ioParam.ioPosOffset = rangeStart;
- return ( PBUnlockRangeSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetForeignPrivs(short vRefNum,
- long dirID,
- ConstStr255Param name,
- void *foreignPrivBuffer,
- long *foreignPrivSize,
- long *foreignPrivInfo1,
- long *foreignPrivInfo2,
- long *foreignPrivInfo3,
- long *foreignPrivInfo4)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.foreignPrivParam.ioNamePtr = (StringPtr)name;
- pb.foreignPrivParam.ioVRefNum = vRefNum;
- pb.foreignPrivParam.ioForeignPrivDirID = dirID;
- pb.foreignPrivParam.ioForeignPrivBuffer = (Ptr)foreignPrivBuffer;
- pb.foreignPrivParam.ioForeignPrivReqCount = *foreignPrivSize;
- error = PBGetForeignPrivsSync(&pb);
- *foreignPrivSize = pb.foreignPrivParam.ioForeignPrivActCount;
- *foreignPrivInfo1 = pb.foreignPrivParam.ioForeignPrivInfo1;
- *foreignPrivInfo2 = pb.foreignPrivParam.ioForeignPrivInfo2;
- *foreignPrivInfo3 = pb.foreignPrivParam.ioForeignPrivInfo3;
- *foreignPrivInfo4 = pb.foreignPrivParam.ioForeignPrivInfo4;
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetForeignPrivs(const FSSpec *spec,
- void *foreignPrivBuffer,
- long *foreignPrivSize,
- long *foreignPrivInfo1,
- long *foreignPrivInfo2,
- long *foreignPrivInfo3,
- long *foreignPrivInfo4)
-{
- return ( GetForeignPrivs(spec->vRefNum, spec->parID, spec->name,
- foreignPrivBuffer, foreignPrivSize,
- foreignPrivInfo1, foreignPrivInfo2,
- foreignPrivInfo3, foreignPrivInfo4) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr SetForeignPrivs(short vRefNum,
- long dirID,
- ConstStr255Param name,
- const void *foreignPrivBuffer,
- long *foreignPrivSize,
- long foreignPrivInfo1,
- long foreignPrivInfo2,
- long foreignPrivInfo3,
- long foreignPrivInfo4)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.foreignPrivParam.ioNamePtr = (StringPtr)name;
- pb.foreignPrivParam.ioVRefNum = vRefNum;
- pb.foreignPrivParam.ioForeignPrivDirID = dirID;
- pb.foreignPrivParam.ioForeignPrivBuffer = (Ptr)foreignPrivBuffer;
- pb.foreignPrivParam.ioForeignPrivReqCount = *foreignPrivSize;
- pb.foreignPrivParam.ioForeignPrivInfo1 = foreignPrivInfo1;
- pb.foreignPrivParam.ioForeignPrivInfo2 = foreignPrivInfo2;
- pb.foreignPrivParam.ioForeignPrivInfo3 = foreignPrivInfo3;
- pb.foreignPrivParam.ioForeignPrivInfo4 = foreignPrivInfo4;
- error = PBSetForeignPrivsSync(&pb);
- if ( error == noErr )
- {
- *foreignPrivSize = pb.foreignPrivParam.ioForeignPrivActCount;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetForeignPrivs(const FSSpec *spec,
- const void *foreignPrivBuffer,
- long *foreignPrivSize,
- long foreignPrivInfo1,
- long foreignPrivInfo2,
- long foreignPrivInfo3,
- long foreignPrivInfo4)
-{
- return ( SetForeignPrivs(spec->vRefNum, spec->parID, spec->name,
- foreignPrivBuffer, foreignPrivSize,
- foreignPrivInfo1, foreignPrivInfo2,
- foreignPrivInfo3, foreignPrivInfo4) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HGetLogInInfo(ConstStr255Param volName,
- short vRefNum,
- short *loginMethod,
- StringPtr userName)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.objParam.ioNamePtr = (StringPtr)volName;
- pb.objParam.ioVRefNum = vRefNum;
- pb.objParam.ioObjNamePtr = userName;
- error = PBHGetLogInInfoSync(&pb);
- if ( error == noErr )
- {
- *loginMethod = pb.objParam.ioObjType;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HGetDirAccess(short vRefNum,
- long dirID,
- ConstStr255Param name,
- long *ownerID,
- long *groupID,
- long *accessRights)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.accessParam.ioNamePtr = (StringPtr)name;
- pb.accessParam.ioVRefNum = vRefNum;
- pb.fileParam.ioDirID = dirID;
- error = PBHGetDirAccessSync(&pb);
- if ( error == noErr )
- {
- *ownerID = pb.accessParam.ioACOwnerID;
- *groupID = pb.accessParam.ioACGroupID;
- *accessRights = pb.accessParam.ioACAccess;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetDirAccess(const FSSpec *spec,
- long *ownerID,
- long *groupID,
- long *accessRights)
-{
- return ( HGetDirAccess(spec->vRefNum, spec->parID, spec->name,
- ownerID, groupID, accessRights) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HSetDirAccess(short vRefNum,
- long dirID,
- ConstStr255Param name,
- long ownerID,
- long groupID,
- long accessRights)
-{
- HParamBlockRec pb;
-
- pb.accessParam.ioNamePtr = (StringPtr)name;
- pb.accessParam.ioVRefNum = vRefNum;
- pb.fileParam.ioDirID = dirID;
- pb.accessParam.ioACOwnerID = ownerID;
- pb.accessParam.ioACGroupID = groupID;
- pb.accessParam.ioACAccess = accessRights;
- return ( PBHSetDirAccessSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetDirAccess(const FSSpec *spec,
- long ownerID,
- long groupID,
- long accessRights)
-{
- return ( HSetDirAccess(spec->vRefNum, spec->parID, spec->name,
- ownerID, groupID, accessRights) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HMapID(ConstStr255Param volName,
- short vRefNum,
- long ugID,
- short objType,
- StringPtr name)
-{
- HParamBlockRec pb;
-
- pb.objParam.ioNamePtr = (StringPtr)volName;
- pb.objParam.ioVRefNum = vRefNum;
- pb.objParam.ioObjType = objType;
- pb.objParam.ioObjNamePtr = name;
- pb.objParam.ioObjID = ugID;
- return ( PBHMapIDSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HMapName(ConstStr255Param volName,
- short vRefNum,
- ConstStr255Param name,
- short objType,
- long *ugID)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.objParam.ioNamePtr = (StringPtr)volName;
- pb.objParam.ioVRefNum = vRefNum;
- pb.objParam.ioObjType = objType;
- pb.objParam.ioObjNamePtr = (StringPtr)name;
- error = PBHMapNameSync(&pb);
- if ( error == noErr )
- {
- *ugID = pb.objParam.ioObjID;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HCopyFile(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstPathname,
- ConstStr255Param copyName)
-{
- HParamBlockRec pb;
-
- pb.copyParam.ioVRefNum = srcVRefNum;
- pb.copyParam.ioDirID = srcDirID;
- pb.copyParam.ioNamePtr = (StringPtr)srcName;
- pb.copyParam.ioDstVRefNum = dstVRefNum;
- pb.copyParam.ioNewDirID = dstDirID;
- pb.copyParam.ioNewName = (StringPtr)dstPathname;
- pb.copyParam.ioCopyName = (StringPtr)copyName;
- return ( PBHCopyFileSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpCopyFile(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- ConstStr255Param copyName)
-{
- return ( HCopyFile(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->vRefNum, dstSpec->parID,
- dstSpec->name, copyName) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HMoveRename(short vRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- long dstDirID,
- ConstStr255Param dstpathName,
- ConstStr255Param copyName)
-{
- HParamBlockRec pb;
-
- pb.copyParam.ioVRefNum = vRefNum;
- pb.copyParam.ioDirID = srcDirID;
- pb.copyParam.ioNamePtr = (StringPtr)srcName;
- pb.copyParam.ioNewDirID = dstDirID;
- pb.copyParam.ioNewName = (StringPtr)dstpathName;
- pb.copyParam.ioCopyName = (StringPtr)copyName;
- return ( PBHMoveRenameSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpMoveRename(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- ConstStr255Param copyName)
-{
- OSErr error;
-
- /* make sure the FSSpecs refer to the same volume */
- if ( srcSpec->vRefNum != dstSpec->vRefNum )
- {
- error = diffVolErr;
- }
- else
- {
- error = HMoveRename(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->parID, dstSpec->name, copyName);
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetVolMountInfoSize(ConstStr255Param volName,
- short vRefNum,
- short *size)
-{
- ParamBlockRec pb;
-
- pb.ioParam.ioNamePtr = (StringPtr)volName;
- pb.ioParam.ioVRefNum = vRefNum;
- pb.ioParam.ioBuffer = (Ptr)size;
- return ( PBGetVolMountInfoSize(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetVolMountInfo(ConstStr255Param volName,
- short vRefNum,
- void *volMountInfo)
-{
- ParamBlockRec pb;
-
- pb.ioParam.ioNamePtr = (StringPtr)volName;
- pb.ioParam.ioVRefNum = vRefNum;
- pb.ioParam.ioBuffer = (Ptr)volMountInfo;
- return ( PBGetVolMountInfo(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr VolumeMount(const void *volMountInfo,
- short *vRefNum)
-{
- ParamBlockRec pb;
- OSErr error;
-
- pb.ioParam.ioBuffer = (Ptr)volMountInfo;
- error = PBVolumeMount(&pb);
- if ( error == noErr )
- {
- *vRefNum = pb.ioParam.ioVRefNum;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr Share(short vRefNum,
- long dirID,
- ConstStr255Param name)
-{
- HParamBlockRec pb;
-
- pb.fileParam.ioNamePtr = (StringPtr)name;
- pb.fileParam.ioVRefNum = vRefNum;
- pb.fileParam.ioDirID = dirID;
- return ( PBShareSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpShare(const FSSpec *spec)
-{
- return ( Share(spec->vRefNum, spec->parID, spec->name) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr Unshare(short vRefNum,
- long dirID,
- ConstStr255Param name)
-{
- HParamBlockRec pb;
-
- pb.fileParam.ioNamePtr = (StringPtr)name;
- pb.fileParam.ioVRefNum = vRefNum;
- pb.fileParam.ioDirID = dirID;
- return ( PBUnshareSync(&pb) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpUnshare(const FSSpec *spec)
-{
- return ( Unshare(spec->vRefNum, spec->parID, spec->name) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetUGEntry(short objType,
- StringPtr objName,
- long *objID)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.objParam.ioObjType = objType;
- pb.objParam.ioObjNamePtr = objName;
- pb.objParam.ioObjID = *objID;
- error = PBGetUGEntrySync(&pb);
- if ( error == noErr )
- {
- *objID = pb.objParam.ioObjID;
- }
- return ( error );
-}
-
-/*****************************************************************************/
+++ /dev/null
-/*
- File: MoreFiles.h
-
- Contains: The long lost high-level and FSSpec File Manager functions.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-#ifndef __MOREFILES__
-#define __MOREFILES__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HGetVolParms(
- ConstStr255Param volName,
- short vRefNum,
- GetVolParmsInfoBuffer * volParmsInfo,
- long * infoSize);
-
-
-/*
- The HGetVolParms function returns information about the characteristics
- of a volume. A result of paramErr usually just means the volume doesn't
- support PBHGetVolParms and the feature you were going to check
- for isn't available.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- volParmsInfo input: Pointer to GetVolParmsInfoBuffer where the
- volume attributes information is returned.
- output: Atributes information.
- infoSize input: Size of buffer pointed to by volParmsInfo.
- output: Size of data actually returned.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- paramErr -50 Volume doesn't support this function
-
- __________
-
- Also see the macros for checking attribute bits in MoreFilesExtras.h
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HCreateMinimum(
- short vRefNum,
- long dirID,
- ConstStr255Param fileName);
-
-
-/*
- The HCreateMinimum function creates a new file without attempting to set
- the creator and file type of the new file. This function is needed to
- create a file in an AppleShare "drop box" where the user can make
- changes, but cannot see folder or files.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- fileName input: The name of the new file.
-
- Result Codes
- noErr 0 No error
- dirFulErr -33 File directory full
- dskFulErr -34 Disk is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 Directory not found or incomplete pathname
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- dupFNErr -48 Duplicate filename and version
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 A directory exists with that name
-
- __________
-
- Also see: FSpCreateMinimum
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpCreateMinimum(const FSSpec * spec);
-
-
-/*
- The FSpCreateMinimum function creates a new file without attempting to set
- the the creator and file type of the new file. This function is needed to
- create a file in an AppleShare "dropbox" where the user can make
- changes, but cannot see folder or files.
-
- spec input: An FSSpec record specifying the file to create.
-
- Result Codes
- noErr 0 No error
- dirFulErr -33 File directory full
- dskFulErr -34 Disk is full
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 Directory not found or incomplete pathname
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- dupFNErr -48 Duplicate filename and version
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 A directory exists with that name
-
- __________
-
- Also see: HCreateMinimum
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ExchangeFiles(
- short vRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- long dstDirID,
- ConstStr255Param dstName);
-
-
-/*
- The ExchangeFiles function swaps the data in two files on the same
- volume by changing some of the information in the volume catalog and,
- if the files are open, in the file control blocks.
-
- vRefNum input: Volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source file name.
- dstDirID input: Destination directory ID.
- dstName input: Destination file name.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 Function not supported by volume
- volOfflinErr -53 Volume is offline
- wrgVolTypErr -123 Not an HFS volume
- diffVolErr -1303 Files on different volumes
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Object is a directory, not a file
- afpSameObjectErr -5038 Source and destination are the same
-
- __________
-
- Also see: FSpExchangeFilesCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ResolveFileIDRef(
- ConstStr255Param volName,
- short vRefNum,
- long fileID,
- long * parID,
- StringPtr fileName);
-
-
-/*
- The ResolveFileIDRef function returns the filename and parent directory ID
- of the file with the specified file ID reference.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- fileID input: The file ID reference.
- parID output: The parent directory ID of the file.
- name input: Points to a buffer (minimum Str63) where the filename
- is to be returned or must be nil.
- output: The filename.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- paramErr -50 Function not supported by volume
- volOfflinErr -53 Volume is offline
- extFSErr -58 External file system error - no file
- system claimed this call.
- wrgVolTypErr -123 Not an HFS volume
- fidNotFoundErr -1300 File ID reference not found
- notAFileErr -1302 Specified file is a directory
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Specified file is a directory
- afpIDNotFound -5034 File ID reference not found
- afpBadIDErr -5039 File ID reference not found
-
- __________
-
- Also see: FSpResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef,
- DeleteFileIDRef
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpResolveFileIDRef(
- ConstStr255Param volName,
- short vRefNum,
- long fileID,
- FSSpecPtr spec);
-
-
-/*
- The FSpResolveFileIDRef function fills in an FSSpec with the location
- of the file with the specified file ID reference.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- fileID input: The file ID reference.
- spec input: A pointer to a FSSpec record.
- output: A file system specification to be filled in by
- FSpResolveFileIDRef.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- paramErr -50 Function not supported by volume or
- no default volume
- volOfflinErr -53 Volume is offline
- extFSErr -58 External file system error - no file
- system claimed this call.
- wrgVolTypErr -123 Not an HFS volume
- fidNotFoundErr -1300 File ID reference not found
- notAFileErr -1302 Specified file is a directory
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Specified file is a directory
- afpIDNotFound -5034 File ID reference not found
- afpBadIDErr -5039 File ID reference not found
-
- __________
-
- Also see: ResolveFileIDRef, CreateFileIDRef, FSpCreateFileIDRef,
- DeleteFileIDRef
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-CreateFileIDRef(
- short vRefNum,
- long parID,
- ConstStr255Param fileName,
- long * fileID);
-
-
-/*
- The CreateFileIDRef function creates a file ID reference for the
- specified file, or if a file ID reference already exists, supplies
- the file ID reference and returns the result code fidExists or afpIDExists.
-
- vRefNum input: Volume specification.
- parID input: Directory ID.
- fileName input: The name of the file.
- fileID output: The file ID reference (if result is noErr,
- fidExists, or afpIDExists).
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- paramErr -50 Function not supported by volume
- volOfflinErr -53 Volume is offline
- extFSErr -58 External file system error - no file
- system claimed this call.
- wrgVolTypErr -123 Not an HFS volume
- fidExists -1301 File ID reference already exists
- notAFileErrn -1302 Specified file is a directory
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Specified file is a directory
- afpIDExists -5035 File ID reference already exists
-
- __________
-
- Also see: FSpResolveFileIDRef, ResolveFileIDRef, FSpCreateFileIDRef,
- DeleteFileIDRef
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpCreateFileIDRef(
- const FSSpec * spec,
- long * fileID);
-
-
-/*
- The FSpCreateFileIDRef function creates a file ID reference for the
- specified file, or if a file ID reference already exists, supplies
- the file ID reference and returns the result code fidExists or afpIDExists.
-
- spec input: An FSSpec record specifying the file.
- fileID output: The file ID reference (if result is noErr,
- fidExists, or afpIDExists).
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- paramErr -50 Function not supported by volume
- volOfflinErr -53 Volume is offline
- extFSErr -58 External file system error - no file
- system claimed this call.
- wrgVolTypErr -123 Not an HFS volume
- fidExists -1301 File ID reference already exists
- notAFileErrn -1302 Specified file is a directory
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Specified file is a directory
- afpIDExists -5035 File ID reference already exists
-
- __________
-
- Also see: FSpResolveFileIDRef, ResolveFileIDRef, CreateFileIDRef,
- DeleteFileIDRef
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DeleteFileIDRef(
- ConstStr255Param volName,
- short vRefNum,
- long fileID);
-
-
-/*
- The DeleteFileIDRef function deletes a file ID reference.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- fileID input: The file ID reference.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- vLckdErr -46 Software volume lock
- paramErr -50 Function not supported by volume
- volOfflinErr -53 Volume is offline
- extFSErr -58 External file system error - no file
- system claimed this call.
- wrgVolTypErr -123 Function is not supported by volume
- fidNotFoundErr -1300 File ID reference not found
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Specified file is a directory
- afpIDNotFound -5034 File ID reference not found
-
- __________
-
- Also see: FSpResolveFileIDRef, ResolveFileIDRef, CreateFileIDRef,
- FSpCreateFileIDRef
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FlushFile(short refNum);
-
-
-/*
- The FlushFile function writes the contents of a file's access path
- buffer (the fork data) to the volume. Note: some of the file's catalog
- information stored on the volume may not be correct until FlushVol
- is called.
-
- refNum input: The file reference number of an open file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- fnOpnErr -38 File not open
- fnfErr -43 File not found
- rfNumErr -51 Bad reference number
- extFSErr -58 External file system error - no file
- system claimed this call.
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-LockRange(
- short refNum,
- long rangeLength,
- long rangeStart);
-
-
-/*
- The LockRange function locks (denies access to) a portion of a file
- that was opened with shared read/write permission.
-
- refNum input: The file reference number of an open file.
- rangeLength input: The number of bytes in the range.
- rangeStart input: The starting byte in the range to lock.
-
- Result Codes
- noErr 0 No error
- ioErr -36 I/O error
- fnOpnErr -38 File not open
- eofErr -39 Logical end-of-file reached
- fLckdErr -45 File is locked by another user
- paramErr -50 Negative ioReqCount
- rfNumErr -51 Bad reference number
- extFSErr -58 External file system error - no file
- system claimed this call.
- volGoneErr -124 Server volume has been disconnected
- afpNoMoreLocks -5015 No more ranges can be locked
- afpRangeOverlap -5021 Part of range is already locked
-
- __________
-
- Also see: UnlockRange
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-UnlockRange(
- short refNum,
- long rangeLength,
- long rangeStart);
-
-
-/*
- The UnlockRange function unlocks (allows access to) a previously locked
- portion of a file that was opened with shared read/write permission.
-
- refNum input: The file reference number of an open file.
- rangeLength input: The number of bytes in the range.
- rangeStart input: The starting byte in the range to unlock.
-
- Result Codes
- noErr 0 No error
- ioErr -36 I/O error
- fnOpnErr -38 File not open
- eofErr -39 Logical end-of-file reached
- paramErr -50 Negative ioReqCount
- rfNumErr -51 Bad reference number
- extFSErr -58 External file system error - no file
- system claimed this call.
- volGoneErr -124 Server volume has been disconnected
- afpRangeNotLocked -5020 Specified range was not locked
-
- __________
-
- Also see: LockRange
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetForeignPrivs(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- void * foreignPrivBuffer,
- long * foreignPrivSize,
- long * foreignPrivInfo1,
- long * foreignPrivInfo2,
- long * foreignPrivInfo3,
- long * foreignPrivInfo4);
-
-
-/*
- The GetForeignPrivs function retrieves the native access-control
- information for a file or directory stored on a volume managed by
- a foreign file system.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- foreignPrivBuffer input: Pointer to buffer where the privilege
- information is returned.
- output: Privilege information.
- foreignPrivSize input: Size of buffer pointed to by
- foreignPrivBuffer.
- output: Amount of buffer actually used.
- foreignPrivInfo1 output: Information specific to privilege model.
- foreignPrivInfo2 output: Information specific to privilege model.
- foreignPrivInfo3 output: Information specific to privilege model.
- foreignPrivInfo4 output: Information specific to privilege model.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- paramErr -50 Volume is HFS or MFS (that is, it has
- no foreign privilege model), or foreign
- volume does not support these calls
-
- __________
-
- Also see: FSpGetForeignPrivs, SetForeignPrivs, FSpSetForeignPrivs
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpGetForeignPrivs(
- const FSSpec * spec,
- void * foreignPrivBuffer,
- long * foreignPrivSize,
- long * foreignPrivInfo1,
- long * foreignPrivInfo2,
- long * foreignPrivInfo3,
- long * foreignPrivInfo4);
-
-
-/*
- The FSpGetForeignPrivs function retrieves the native access-control
- information for a file or directory stored on a volume managed by
- a foreign file system.
-
- spec input: An FSSpec record specifying the object.
- foreignPrivBuffer input: Pointer to buffer where the privilege
- information is returned.
- output: Privilege information.
- foreignPrivSize input: Size of buffer pointed to by
- foreignPrivBuffer.
- output: Amount of buffer actually used.
- foreignPrivInfo1 output: Information specific to privilege model.
- foreignPrivInfo2 output: Information specific to privilege model.
- foreignPrivInfo3 output: Information specific to privilege model.
- foreignPrivInfo4 output: Information specific to privilege model.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- paramErr -50 Volume is HFS or MFS (that is, it has
- no foreign privilege model), or foreign
- volume does not support these calls
-
- __________
-
- Also see: GetForeignPrivs, SetForeignPrivs, FSpSetForeignPrivs
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-SetForeignPrivs(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- const void * foreignPrivBuffer,
- long * foreignPrivSize,
- long foreignPrivInfo1,
- long foreignPrivInfo2,
- long foreignPrivInfo3,
- long foreignPrivInfo4);
-
-
-/*
- The SetForeignPrivs function changes the native access-control
- information for a file or directory stored on a volume managed by
- a foreign file system.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- foreignPrivBuffer input: Pointer to privilege information buffer.
- foreignPrivSize input: Size of buffer pointed to by
- foreignPrivBuffer.
- output: Amount of buffer actually used.
- foreignPrivInfo1 input: Information specific to privilege model.
- foreignPrivInfo2 input: Information specific to privilege model.
- foreignPrivInfo3 input: Information specific to privilege model.
- foreignPrivInfo4 input: Information specific to privilege model.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- paramErr -50 Volume is HFS or MFS (that is, it has
- no foreign privilege model), or foreign
- volume does not support these calls
-
- __________
-
- Also see: GetForeignPrivs, FSpGetForeignPrivs, FSpSetForeignPrivs
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetForeignPrivs(
- const FSSpec * spec,
- const void * foreignPrivBuffer,
- long * foreignPrivSize,
- long foreignPrivInfo1,
- long foreignPrivInfo2,
- long foreignPrivInfo3,
- long foreignPrivInfo4);
-
-
-/*
- The FSpSetForeignPrivs function changes the native access-control
- information for a file or directory stored on a volume managed by
- a foreign file system.
-
- spec input: An FSSpec record specifying the object.
- foreignPrivBuffer input: Pointer to privilege information buffer.
- foreignPrivSize input: Size of buffer pointed to by
- foreignPrivBuffer.
- output: Amount of buffer actually used.
- foreignPrivInfo1 input: Information specific to privilege model.
- foreignPrivInfo2 input: Information specific to privilege model.
- foreignPrivInfo3 input: Information specific to privilege model.
- foreignPrivInfo4 input: Information specific to privilege model.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- paramErr -50 Volume is HFS or MFS (that is, it has
- no foreign privilege model), or foreign
- volume does not support these calls
-
- __________
-
- Also see: GetForeignPrivs, FSpGetForeignPrivs, SetForeignPrivs
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HGetLogInInfo(
- ConstStr255Param volName,
- short vRefNum,
- short * loginMethod,
- StringPtr userName);
-
-
-/*
- The HGetLogInInfo function retrieves the login method and user name
- used to log on to a particular shared volume.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: The volume reference number.
- loginMethod output: The login method used (kNoUserAuthentication,
- kPassword, kEncryptPassword, or
- kTwoWayEncryptPassword).
- userName input: Points to a buffer (minimum Str31) where the user
- name is to be returned or must be nil.
- output: The user name.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Specified volume doesnÕt exist
- paramErr -50 Function not supported by volume
-
- __________
-
- Also see: HGetDirAccess, FSpGetDirAccess, HSetDirAccess,
- FSpSetDirAccess, HMapName, HMapID
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HGetDirAccess(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- long * ownerID,
- long * groupID,
- long * accessRights);
-
-
-/*
- The HGetDirAccess function retrieves the directory access control
- information for a directory on a shared volume.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil if dirID
- specifies the directory.
- ownerID output: The directory's owner ID.
- groupID output: The directory's group ID or
- 0 if no group affiliation.
- accessRights output: The directory's access rights.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 Directory not found
- paramErr -50 Function not supported by volume
- afpAccessDenied -5000 User does not have the correct access
- to the directory
-
- __________
-
- Also see: HGetLogInInfo, FSpGetDirAccess, HSetDirAccess,
- FSpSetDirAccess, HMapName, HMapID
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpGetDirAccess(
- const FSSpec * spec,
- long * ownerID,
- long * groupID,
- long * accessRights);
-
-
-/*
- The FSpGetDirAccess function retrieves the directory access control
- information for a directory on a shared volume.
-
- spec input: An FSSpec record specifying the directory.
- ownerID output: The directory's owner ID.
- groupID output: The directory's group ID or
- 0 if no group affiliation.
- accessRights output: The directory's access rights.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 Directory not found
- paramErr -50 Function not supported by volume
- afpAccessDenied -5000 User does not have the correct access
- to the directory
-
- __________
-
- Also see: HGetLogInInfo, HGetDirAccess, HSetDirAccess,
- FSpSetDirAccess, HMapName, HMapID
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HSetDirAccess(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- long ownerID,
- long groupID,
- long accessRights);
-
-
-/*
- The HSetDirAccess function changes the directory access control
- information for a directory on a shared volume. You must own a directory
- to change its access control information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil if dirID
- specifies the directory.
- ownerID input: The directory's owner ID.
- groupID input: The directory's group ID or
- 0 if no group affiliation.
- accessRights input: The directory's access rights.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 Directory not found
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 Parameter error
- afpAccessDenied -5000 User does not have the correct access
- to the directory
- afpObjectTypeErr -5025 Object is a file, not a directory
-
- __________
-
- Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess,
- FSpSetDirAccess, HMapName, HMapID
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetDirAccess(
- const FSSpec * spec,
- long ownerID,
- long groupID,
- long accessRights);
-
-
-/*
- The FSpSetDirAccess function changes the directory access control
- information for a directory on a shared volume. You must own a directory
- to change its access control information.
-
- spec input: An FSSpec record specifying the directory.
- ownerID input: The directory's owner ID.
- groupID input: The directory's group ID or
- 0 if no group affiliation.
- accessRights input: The directory's access rights.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 Directory not found
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 Parameter error
- afpAccessDenied -5000 User does not have the correct access
- to the directory
- afpObjectTypeErr -5025 Object is a file, not a directory
-
- __________
-
- Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess,
- HMapName, HMapID
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HMapID(
- ConstStr255Param volName,
- short vRefNum,
- long ugID,
- short objType,
- StringPtr name);
-
-
-/*
- The HMapID function determines the name of a user or group if you know
- the user or group ID.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- objType input: The mapping function code: 1 if you're mapping a
- user ID to a user name or 2 if you're mapping a
- group ID to a group name.
- name input: Points to a buffer (minimum Str31) where the user
- or group name is to be returned or must be nil.
- output: The user or group name.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 Unrecognizable owner or group name
- paramErr -50 Function not supported by volume
-
- __________
-
- Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess,
- FSpSetDirAccess, HMapName
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HMapName(
- ConstStr255Param volName,
- short vRefNum,
- ConstStr255Param name,
- short objType,
- long * ugID);
-
-
-/*
- The HMapName function determines the user or group ID if you know the
- user or group name.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- name input: The user or group name.
- objType input: The mapping function code: 3 if you're mapping a
- user name to a user ID or 4 if you're mapping a
- group name to a group ID.
- ugID output: The user or group ID.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 Unrecognizable owner or group name
- paramErr -50 Function not supported by volume
-
- __________
-
- Also see: HGetLogInInfo, HGetDirAccess, FSpGetDirAccess, HSetDirAccess,
- FSpSetDirAccess, HMapID
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HCopyFile(
- short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstPathname,
- ConstStr255Param copyName);
-
-
-/*
- The HCopyFile function duplicates a file and optionally renames it.
- The source and destination volumes must be on the same file server.
- This function instructs the server to copy the file.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Source file name.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstPathname input: Pointer to destination directory name, or
- nil when dstDirID specifies a directory.
- copyName input: Points to the new file name if the file is to be
- renamed or nil if the file isn't to be renamed.
-
- Result Codes
- noErr 0 No error
- dskFulErr -34 Destination volume is full
- fnfErr -43 Source file not found, or destination
- directory does not exist
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 The source or destination file could
- not be opened with the correct access
- modes
- dupFNErr -48 Destination file already exists
- paramErr -50 Function not supported by volume
- wrgVolTypErr -123 Function not supported by volume
- afpAccessDenied -5000 The user does not have the right to
- read the source or write to the
- destination
- afpDenyConflict -5006 The source or destination file could
- not be opened with the correct access
- modes
- afpObjectTypeErr -5025 Source is a directory
-
- __________
-
- Also see: FSpCopyFile, FileCopy, FSpFileCopy
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpCopyFile(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec,
- ConstStr255Param copyName);
-
-
-/*
- The FSpCopyFile function duplicates a file and optionally renames it.
- The source and destination volumes must be on the same file server.
- This function instructs the server to copy the file.
-
- srcSpec input: An FSSpec record specifying the source file.
- dstSpec input: An FSSpec record specifying the destination
- directory.
- copyName input: Points to the new file name if the file is to be
- renamed or nil if the file isn't to be renamed.
-
- Result Codes
- noErr 0 No error
- dskFulErr -34 Destination volume is full
- fnfErr -43 Source file not found, or destination
- directory does not exist
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 The source or destination file could
- not be opened with the correct access
- modes
- dupFNErr -48 Destination file already exists
- paramErr -50 Function not supported by volume
- wrgVolTypErr -123 Function not supported by volume
- afpAccessDenied -5000 The user does not have the right to
- read the source or write to the
- destination
- afpDenyConflict -5006 The source or destination file could
- not be opened with the correct access
- modes
- afpObjectTypeErr -5025 Source is a directory
-
- __________
-
- Also see: HCopyFile, FileCopy, FSpFileCopy
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HMoveRename(
- short vRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- long dstDirID,
- ConstStr255Param dstpathName,
- ConstStr255Param copyName);
-
-
-/*
- The HMoveRename function moves a file or directory and optionally
- renames it. The source and destination locations must be on the same
- shared volume.
-
- vRefNum input: Volume specification.
- srcDirID input: Source directory ID.
- srcName input: The source object name.
- dstDirID input: Destination directory ID.
- dstName input: Pointer to destination directory name, or
- nil when dstDirID specifies a directory.
- copyName input: Points to the new name if the object is to be
- renamed or nil if the object isn't to be renamed.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 Source file or directory not found
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- dupFNErr -48 Destination already exists
- paramErr -50 Function not supported by volume
- badMovErr -122 Attempted to move directory into
- offspring
- afpAccessDenied -5000 The user does not have the right to
- move the file or directory
-
- __________
-
- Also see: FSpMoveRename, HMoveRenameCompat, FSpMoveRenameCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpMoveRename(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec,
- ConstStr255Param copyName);
-
-
-/*
- The FSpMoveRename function moves a file or directory and optionally
- renames it. The source and destination locations must be on the same
- shared volume.
-
- srcSpec input: An FSSpec record specifying the source object.
- dstSpec input: An FSSpec record specifying the destination
- directory.
- copyName input: Points to the new name if the object is to be
- renamed or nil if the object isn't to be renamed.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 Source file or directory not found
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- dupFNErr -48 Destination already exists
- paramErr -50 Function not supported by volume
- badMovErr -122 Attempted to move directory into
- offspring
- afpAccessDenied -5000 The user does not have the right to
- move the file or directory
-
- __________
-
- Also see: HMoveRename, HMoveRenameCompat, FSpMoveRenameCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetVolMountInfoSize(
- ConstStr255Param volName,
- short vRefNum,
- short * size);
-
-
-/*
- The GetVolMountInfoSize function determines the how much space the
- program needs to allocate for a volume mounting information record.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- size output: The space needed (in bytes) of the volume mounting
- information record.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- paramErr -50 Parameter error
- extFSErr -58 External file system error - no file
- system claimed this call.
-
- __________
-
- Also see: GetVolMountInfo, VolumeMount BuildAFPVolMountInfo,
- RetrieveAFPVolMountInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetVolMountInfo(
- ConstStr255Param volName,
- short vRefNum,
- void * volMountInfo);
-
-
-/*
- The GetVolMountInfo function retrieves a volume mounting information
- record containing all the information needed to mount the volume,
- except for passwords.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- volMountInfo output: Points to a volume mounting information
- record where the mounting information is to
- be returned.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- paramErr -50 Parameter error
- extFSErr -58 External file system error - no file
- system claimed this call.
-
- __________
-
- Also see: GetVolMountInfoSize, VolumeMount, BuildAFPVolMountInfo,
- RetrieveAFPVolMountInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-VolumeMount(
- const void * volMountInfo,
- short * vRefNum);
-
-
-/*
- The VolumeMount function mounts a volume using a volume mounting
- information record.
-
- volMountInfo input: Points to a volume mounting information record.
- vRefNum output: A volume reference number.
-
- Result Codes
- noErr 0 No error
- notOpenErr -28 AppleTalk is not open
- nsvErr -35 Volume not found
- paramErr -50 Parameter error; typically, zone, server,
- and volume name combination is not valid
- or not complete, or the user name is not
- recognized
- extFSErr -58 External file system error - no file
- system claimed this call.
- memFullErr -108 Not enough memory to create a new volume
- control block for mounting the volume
- afpBadUAM -5002 User authentication method is unknown
- afpBadVersNum -5003 Workstation is using an AFP version that
- the server doesnÕt recognize
- afpNoServer -5016 Server is not responding
- afpUserNotAuth -5023 User authentication failed (usually,
- password is not correct)
- afpPwdExpired -5042 Password has expired on server
- afpBadDirIDType -5060 Not a fixed directory ID volume
- afpCantMountMoreSrvrs -5061 Maximum number of volumes has been
- mounted
- afpAlreadyMounted -5062 Volume already mounted
- afpSameNodeErr -5063 Attempt to log on to a server running
- on the same machine
-
- __________
-
- Also see: GetVolMountInfoSize, GetVolMountInfo, BuildAFPVolMountInfo,
- RetrieveAFPVolMountInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-Share(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The Share function establishes a local volume or directory as a
- share point.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil if dirID
- specifies the directory.
-
- Result Codes
- noErr 0 No error
- tmfoErr -42 Too many share points
- fnfErr -43 File not found
- dupFNErr -48 Already a share point with this name
- paramErr -50 Function not supported by volume
- dirNFErrdirNFErr -120 Directory not found
- afpAccessDenied -5000 This directory cannot be shared
- afpObjectTypeErr -5025 Object was a file, not a directory
- afpContainsSharedErr -5033 The directory contains a share point
- afpInsideSharedErr -5043 The directory is inside a shared directory
-
- __________
-
- Also see: FSpShare, Unshare, FSpUnshare
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpShare(const FSSpec * spec);
-
-
-/*
- The FSpShare function establishes a local volume or directory as a
- share point.
-
- spec input: An FSSpec record specifying the share point.
-
- Result Codes
- noErr 0 No error
- tmfoErr -42 Too many share points
- fnfErr -43 File not found
- dupFNErr -48 Already a share point with this name
- paramErr -50 Function not supported by volume
- dirNFErrdirNFErr -120 Directory not found
- afpAccessDenied -5000 This directory cannot be shared
- afpObjectTypeErr -5025 Object was a file, not a directory
- afpContainsSharedErr -5033 The directory contains a share point
- afpInsideSharedErr -5043 The directory is inside a shared directory
-
- __________
-
- Also see: Share, Unshare, FSpUnshare
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-Unshare(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The Unshare function removes a share point.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil if dirID
- specifies the directory.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 File not found
- paramErr -50 Function not supported by volume
- dirNFErrdirNFErr -120 Directory not found
- afpObjectTypeErr -5025 Object was a file, not a directory; or,
- this directory is not a share point
-
- __________
-
- Also see: Share, FSpShare, FSpUnshare
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpUnshare(const FSSpec * spec);
-
-
-/*
- The FSpUnshare function removes a share point.
-
- spec input: An FSSpec record specifying the share point.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 File not found
- paramErr -50 Function not supported by volume
- dirNFErrdirNFErr -120 Directory not found
- afpObjectTypeErr -5025 Object was a file, not a directory; or,
- this directory is not a share point
-
- __________
-
- Also see: Share, FSpShare, Unshare
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetUGEntry(
- short objType,
- StringPtr objName,
- long * objID);
-
-
-/*
- The GetUGEntry function retrieves user or group entries from the
- local file server.
-
- objType input: The object type: -1 = group; 0 = user
- objName input: Points to a buffer (minimum Str31) where the user
- or group name is to be returned or must be nil.
- output: The user or group name.
- objID input: O to get the first user or group. If the entry objID
- last returned by GetUGEntry is passed, then user or
- group whose alphabetically next in the list of entries
- is returned.
- output: The user or group ID.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 No more users or groups
- paramErr -50 Function not supported; or, ioObjID is
- negative
-
- __________
-
- Also see: GetUGEntries
-*/
-
-/*****************************************************************************/
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MOREFILES__ */
-
+++ /dev/null
-/*
- File: MoreFilesExtras.c
-
- Contains: A collection of useful high-level File Manager routines
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Jim Luther
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <2> 2/7/01 JL [2500429] Changed null output parameters to real variables when
- calling GetSharedLibrary to prevent crashes with older versions
- of CFM. Added standard header. Updated names of includes. Added
- C function implementations of accessors that used to be macros
- since the generated Pascal headers no longer contain
- implementations. Updated various other routines to use new
- calling convention of the accessor functions.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-#include <MacTypes.h>
-#if !TARGET_CARBON
-#include <Traps.h>
-#include <FSM.h>
-#include <Disks.h>
-#else
-#include <HFSVolumes.h>
-#endif
-#include <OSUtils.h>
-#include <MacErrors.h>
-#include <MacMemory.h>
-#include <Files.h>
-#include <Devices.h>
-#include <Finder.h>
-#include <Folders.h>
-#include <Gestalt.h>
-#include <TextUtils.h>
-#include <Script.h>
-#include <Math64.h>
-#include <CodeFragments.h>
-#include <stddef.h>
-
-#define __COMPILINGMOREFILES
-
-#include "MoreFiles.h"
-#include "MoreDesktopMgr.h"
-#include "FSpCompat.h"
-
-#include "MoreFilesExtras.h"
-
-/*****************************************************************************/
-
-/* Functions to get information out of GetVolParmsInfoBuffer. */
-
-/* version 1 field getters */
-
-pascal short GetVolParmsInfoVersion(const GetVolParmsInfoBuffer *volParms)
-{
- return ( volParms->vMVersion );
-}
-
-pascal long GetVolParmsInfoAttrib(const GetVolParmsInfoBuffer *volParms)
-{
- return ( volParms->vMAttrib );
-}
-
-pascal Handle GetVolParmsInfoLocalHand(const GetVolParmsInfoBuffer *volParms)
-{
- return ( volParms->vMLocalHand );
-}
-
-pascal long GetVolParmsInfoServerAdr(const GetVolParmsInfoBuffer *volParms)
-{
- return ( volParms->vMServerAdr );
-}
-
-/* version 2 field getters (assume zero result if version < 2) */
-
-pascal long GetVolParmsInfoVolumeGrade(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMVersion >= 2) ? volParms->vMVolumeGrade : 0 );
-}
-
-pascal long GetVolParmsInfoForeignPrivID(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMVersion >= 2) ? volParms->vMForeignPrivID : 0 );
-}
-
-/* version 3 field getters (assume zero result if version < 3) */
-
-pascal long GetVolParmsInfoExtendedAttributes(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMVersion >= 3) ? volParms->vMExtendedAttributes : 0 );
-}
-
-/* attribute bits supported by all versions of GetVolParmsInfoBuffer */
-
-pascal Boolean isNetworkVolume(const GetVolParmsInfoBuffer *volParms)
-{
- return ( volParms->vMServerAdr != 0 );
-}
-
-pascal Boolean hasLimitFCBs(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bLimitFCBs)) != 0 );
-}
-
-pascal Boolean hasLocalWList(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bLocalWList)) != 0 );
-}
-
-pascal Boolean hasNoMiniFndr(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bNoMiniFndr)) != 0 );
-}
-
-pascal Boolean hasNoVNEdit(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bNoVNEdit)) != 0 );
-}
-
-pascal Boolean hasNoLclSync(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bNoLclSync)) != 0 );
-}
-
-pascal Boolean hasTrshOffLine(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bTrshOffLine)) != 0 );
-}
-
-pascal Boolean hasNoSwitchTo(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bNoSwitchTo)) != 0 );
-}
-
-pascal Boolean hasNoDeskItems(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bNoDeskItems)) != 0 );
-}
-
-pascal Boolean hasNoBootBlks(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bNoBootBlks)) != 0 );
-}
-
-pascal Boolean hasAccessCntl(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bAccessCntl)) != 0 );
-}
-
-pascal Boolean hasNoSysDir(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bNoSysDir)) != 0 );
-}
-
-pascal Boolean hasExtFSVol(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasExtFSVol)) != 0 );
-}
-
-pascal Boolean hasOpenDeny(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasOpenDeny)) != 0 );
-}
-
-pascal Boolean hasCopyFile(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasCopyFile)) != 0 );
-}
-
-pascal Boolean hasMoveRename(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasMoveRename)) != 0 );
-}
-
-pascal Boolean hasDesktopMgr(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasDesktopMgr)) != 0 );
-}
-
-pascal Boolean hasShortName(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasShortName)) != 0 );
-}
-
-pascal Boolean hasFolderLock(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasFolderLock)) != 0 );
-}
-
-pascal Boolean hasPersonalAccessPrivileges(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasPersonalAccessPrivileges)) != 0 );
-}
-
-pascal Boolean hasUserGroupList(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasUserGroupList)) != 0 );
-}
-
-pascal Boolean hasCatSearch(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasCatSearch)) != 0 );
-}
-
-pascal Boolean hasFileIDs(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasFileIDs)) != 0 );
-}
-
-pascal Boolean hasBTreeMgr(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasBTreeMgr)) != 0 );
-}
-
-pascal Boolean hasBlankAccessPrivileges(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bHasBlankAccessPrivileges)) != 0 );
-}
-
-pascal Boolean supportsAsyncRequests(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bSupportsAsyncRequests)) != 0 );
-}
-
-pascal Boolean supportsTrashVolumeCache(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (volParms->vMAttrib & (1L << bSupportsTrashVolumeCache)) != 0 );
-}
-
-/* attribute bits supported by version 3 and greater versions of GetVolParmsInfoBuffer */
-
-pascal Boolean volIsEjectable(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bIsEjectable)) != 0 );
-}
-
-pascal Boolean volSupportsHFSPlusAPIs(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsHFSPlusAPIs)) != 0 );
-}
-
-pascal Boolean volSupportsFSCatalogSearch(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsFSCatalogSearch)) != 0 );
-}
-
-pascal Boolean volSupportsFSExchangeObjects(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsFSExchangeObjects)) != 0 );
-}
-
-pascal Boolean volSupports2TBFiles(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupports2TBFiles)) != 0 );
-}
-
-pascal Boolean volSupportsLongNames(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsLongNames)) != 0 );
-}
-
-pascal Boolean volSupportsMultiScriptNames(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsMultiScriptNames)) != 0 );
-}
-
-pascal Boolean volSupportsNamedForks(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsNamedForks)) != 0 );
-}
-
-pascal Boolean volSupportsSubtreeIterators(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bSupportsSubtreeIterators)) != 0 );
-}
-
-pascal Boolean volL2PCanMapFileBlocks(const GetVolParmsInfoBuffer *volParms)
-{
- return ( (GetVolParmsInfoExtendedAttributes(volParms) & (1L << bL2PCanMapFileBlocks)) != 0 );
-}
-
-/*****************************************************************************/
-
-/* Functions for testing ioACUser bits. */
-
-pascal Boolean userIsOwner(SInt8 ioACUser)
-{
- return ( (ioACUser & kioACUserNotOwnerMask) == 0 );
-}
-
-pascal Boolean userHasFullAccess(SInt8 ioACUser)
-{
- return ( (ioACUser & acUserAccessMask) == acUserFull );
-}
-
-pascal Boolean userHasDropBoxAccess(SInt8 ioACUser)
-{
- return ( (ioACUser & acUserAccessMask) == acUserDropBox );
-}
-
-pascal Boolean userHasBulletinBoard(SInt8 ioACUser)
-{
- return ( (ioACUser & acUserAccessMask) == acUserBulletinBoard );
-}
-
-pascal Boolean userHasNoAccess(SInt8 ioACUser)
-{
- return ( (ioACUser & acUserAccessMask) == acUserNone );
-}
-
-/*****************************************************************************/
-
-/* local data structures */
-
-/* The DeleteEnumGlobals structure is used to minimize the amount of
-** stack space used when recursively calling DeleteLevel and to hold
-** global information that might be needed at any time. */
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#endif // PRAGMA_STRUCT_ALIGN
-struct DeleteEnumGlobals
-{
- OSErr error; /* temporary holder of results - saves 2 bytes of stack each level */
- Str63 itemName; /* the name of the current item */
- UniversalFMPB myPB; /* the parameter block used for PBGetCatInfo calls */
-};
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#endif // PRAGMA_STRUCT_ALIGN
-
-typedef struct DeleteEnumGlobals DeleteEnumGlobals;
-typedef DeleteEnumGlobals *DeleteEnumGlobalsPtr;
-
-/*****************************************************************************/
-
-/*
-** CallPBXGetVolInfoSync is the glue code needed to make PBXGetVolInfoSync
-** File Manager requests from CFM-based programs. Apple added PBXGetVolInfoSync
-** to InterfaceLib in Mac OS 8.5, so if __MACOSEIGHTFIVEORLATER is defined,
-** CallPBXGetVolInfoSync is defined back to PBXGetVolInfoSync.
-**
-** Non-CFM 68K programs don't needs this glue (and won't get it) because
-** they instead use the inline assembly glue found in the Files.h interface
-** file.
-*/
-
-#if TARGET_API_MAC_CARBON || !TARGET_RT_MAC_CFM
-
- // Carbon builds and 68K builds don't need this glue
- #define CallPBXGetVolInfoSync PBXGetVolInfoSync
-
-#else // TARGET_API_MAC_CARBON || !TARGET_RT_MAC_CFM
-
- #if __WANTPASCALELIMINATION
- #undef pascal
- #endif // __WANTPASCALELIMINATION
-
- /* This is exactly like the simple mixed mode glue in InterfaceLib in Mac OS 8.5 and 8.6 */
- static pascal OSErr PBXGetVolInfoSyncGlue(XVolumeParamPtr paramBlock)
- {
- enum
- {
- uppFSDispatchProcInfo = kRegisterBased
- | REGISTER_RESULT_LOCATION(kRegisterD0)
- | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
- | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(long))) /* selector */
- | REGISTER_ROUTINE_PARAMETER(2, kRegisterD1, SIZE_CODE(sizeof(long))) /* trap word */
- | REGISTER_ROUTINE_PARAMETER(3, kRegisterA0, SIZE_CODE(sizeof(XVolumeParamPtr)))
- };
-
- static UniversalProcPtr fsDispatchTrapAddress = NULL;
-
- /* Is this the first time we've been called? */
- if ( fsDispatchTrapAddress == NULL )
- {
- /* Yes - Get the trap address of _FSDispatch */
- fsDispatchTrapAddress = NGetTrapAddress(_FSDispatch, OSTrap);
- }
- return ( CallOSTrapUniversalProc(fsDispatchTrapAddress,
- uppFSDispatchProcInfo,
- kFSMXGetVolInfo,
- _FSDispatch,
- paramBlock) );
- }
-
- /*
- ** PBXGetVolInfoSync was added to the File Manager in System software 7.5.2.
- ** However, PBXGetVolInfoSync wasn't added to InterfaceLib until Mac OS 8.5.
- ** This wrapper calls PBXGetVolInfoSync if it is found in InterfaceLib;
- ** otherwise, it calls PBXGetVolInfoSyncGlue. This ensures that your program
- ** is calling the latest implementation of PBXGetVolInfoSync.
- */
- static pascal OSErr CallPBXGetVolInfoSync(XVolumeParamPtr paramBlock)
- {
- typedef pascal OSErr (*PBXGetVolInfoProcPtr) (XVolumeParamPtr paramBlock);
-
- OSErr result;
- CFragConnectionID connID;
- Ptr mainAddr;
- Str255 errMessage;
- static PBXGetVolInfoProcPtr PBXGetVolInfoSyncPtr = NULL;
-
- //* Is this the first time we've been called? */
- if ( PBXGetVolInfoSyncPtr == NULL )
- {
- /* Yes - Get our connection ID to InterfaceLib */
- result = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kLoadCFrag, &connID, &mainAddr, errMessage);
- if ( result == noErr )
- {
- /* See if PBXGetVolInfoSync is in InterfaceLib */
- if ( FindSymbol(connID, "\pPBXGetVolInfoSync", &(Ptr)PBXGetVolInfoSyncPtr, NULL) != noErr )
- {
- /* Use glue code if symbol isn't found */
- PBXGetVolInfoSyncPtr = PBXGetVolInfoSyncGlue;
- }
- }
- }
- /* Call PBXGetVolInfoSync if present; otherwise, call PBXGetVolInfoSyncGlue */
- return ( (*PBXGetVolInfoSyncPtr)(paramBlock) );
- }
-
- #if __WANTPASCALELIMINATION
- #define pascal
- #endif // __WANTPASCALELIMINATION
-
-#endif // TARGET_API_MAC_CARBON || !TARGET_RT_MAC_CFM
-
-/*****************************************************************************/
-
-pascal void TruncPString(StringPtr destination,
- ConstStr255Param source,
- short maxLength)
-{
- short charType;
-
- if ( source != NULL && destination != NULL ) /* don't do anything stupid */
- {
- if ( source[0] > maxLength )
- {
- /* Make sure the string isn't truncated in the middle of */
- /* a multi-byte character. */
- while (maxLength != 0)
- {
- // Note: CharacterByteType's textOffset parameter is zero-based from the textPtr parameter
- charType = CharacterByteType((Ptr)&source[1], maxLength - 1, smSystemScript);
- if ( (charType == smSingleByte) || (charType == smLastByte) )
- break; /* source[maxLength] is now a valid last character */
- --maxLength;
- }
- }
- else
- {
- maxLength = source[0];
- }
- /* Set the destination string length */
- destination[0] = maxLength;
- /* and copy maxLength characters (if needed) */
- if ( source != destination )
- {
- while ( maxLength != 0 )
- {
- destination[maxLength] = source[maxLength];
- --maxLength;
- }
- }
- }
-}
-
-/*****************************************************************************/
-
-pascal Ptr GetTempBuffer(long buffReqSize,
- long *buffActSize)
-{
- enum
- {
- kSlopMemory = 0x00008000 /* 32K - Amount of free memory to leave when allocating buffers */
- };
- Ptr tempPtr;
-
- /* Make request a multiple of 1024 bytes */
- buffReqSize = buffReqSize & 0xfffffc00;
-
- if ( buffReqSize < 0x00000400 )
- {
- /* Request was smaller than 1024 bytes - make it 1024 */
- buffReqSize = 0x00000400;
- }
-
- /* Attempt to allocate the memory */
- tempPtr = NewPtr(buffReqSize);
-
- /* If request failed, go to backup plan */
- if ( (tempPtr == NULL) && (buffReqSize > 0x00000400) )
- {
- /*
- ** Try to get largest 1024-byte block available
- ** leaving some slop for the toolbox if possible
- */
- long freeMemory = (FreeMem() - kSlopMemory) & 0xfffffc00;
-
- buffReqSize = MaxBlock() & 0xfffffc00;
-
- if ( buffReqSize > freeMemory )
- {
- buffReqSize = freeMemory;
- }
-
- if ( buffReqSize == 0 )
- {
- buffReqSize = 0x00000400;
- }
-
- tempPtr = NewPtr(buffReqSize);
- }
-
- /* Return bytes allocated */
- if ( tempPtr != NULL )
- {
- *buffActSize = buffReqSize;
- }
- else
- {
- *buffActSize = 0;
- }
-
- return ( tempPtr );
-}
-
-/*****************************************************************************/
-
-/*
-** GetVolumeInfoNoName uses pathname and vRefNum to call PBHGetVInfoSync
-** in cases where the returned volume name is not needed by the caller.
-** The pathname and vRefNum parameters are not touched, and the pb
-** parameter is initialized by PBHGetVInfoSync except that ioNamePtr in
-** the parameter block is always returned as NULL (since it might point
-** to the local tempPathname).
-**
-** I noticed using this code in several places, so here it is once.
-** This reduces the code size of MoreFiles.
-*/
-pascal OSErr GetVolumeInfoNoName(ConstStr255Param pathname,
- short vRefNum,
- HParmBlkPtr pb)
-{
- Str255 tempPathname;
- OSErr error;
-
- /* Make sure pb parameter is not NULL */
- if ( pb != NULL )
- {
- pb->volumeParam.ioVRefNum = vRefNum;
- if ( pathname == NULL )
- {
- pb->volumeParam.ioNamePtr = NULL;
- pb->volumeParam.ioVolIndex = 0; /* use ioVRefNum only */
- }
- else
- {
- BlockMoveData(pathname, tempPathname, pathname[0] + 1); /* make a copy of the string and */
- pb->volumeParam.ioNamePtr = (StringPtr)tempPathname; /* use the copy so original isn't trashed */
- pb->volumeParam.ioVolIndex = -1; /* use ioNamePtr/ioVRefNum combination */
- }
- error = PBHGetVInfoSync(pb);
- pb->volumeParam.ioNamePtr = NULL; /* ioNamePtr may point to local tempPathname, so don't return it */
- }
- else
- {
- error = paramErr;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** XGetVolumeInfoNoName uses pathname and vRefNum to call PBXGetVolInfoSync
-** in cases where the returned volume name is not needed by the caller.
-** The pathname and vRefNum parameters are not touched, and the pb
-** parameter is initialized by PBXGetVolInfoSync except that ioNamePtr in
-** the parameter block is always returned as NULL (since it might point
-** to the local tempPathname).
-*/
-pascal OSErr XGetVolumeInfoNoName(ConstStr255Param pathname,
- short vRefNum,
- XVolumeParamPtr pb)
-{
- Str255 tempPathname;
- OSErr error;
-
- /* Make sure pb parameter is not NULL */
- if ( pb != NULL )
- {
- pb->ioVRefNum = vRefNum;
- pb->ioXVersion = 0; /* this XVolumeParam version (0) */
- if ( pathname == NULL )
- {
- pb->ioNamePtr = NULL;
- pb->ioVolIndex = 0; /* use ioVRefNum only */
- }
- else
- {
- BlockMoveData(pathname, tempPathname, pathname[0] + 1); /* make a copy of the string and */
- pb->ioNamePtr = (StringPtr)tempPathname; /* use the copy so original isn't trashed */
- pb->ioVolIndex = -1; /* use ioNamePtr/ioVRefNum combination */
- }
-
- {
-#if !TARGET_API_MAC_CARBON
- long response;
-
- /* Is PBXGetVolInfo available? */
- if ( ( Gestalt(gestaltFSAttr, &response) != noErr ) || ((response & (1L << gestaltFSSupports2TBVols)) == 0) )
- {
- /* No, fall back on PBHGetVInfo */
- error = PBHGetVInfoSync((HParmBlkPtr)pb);
- if ( error == noErr )
- {
- /* calculate the ioVTotalBytes and ioVFreeBytes fields */
- pb->ioVTotalBytes = U64Multiply(U64SetU(pb->ioVNmAlBlks), U64SetU(pb->ioVAlBlkSiz));
- pb->ioVFreeBytes = U64Multiply(U64SetU(pb->ioVFrBlk), U64SetU(pb->ioVAlBlkSiz));
- }
- }
- else
-#endif
- {
- /* Yes, so use it */
- error = CallPBXGetVolInfoSync(pb);
- }
- }
- pb->ioNamePtr = NULL; /* ioNamePtr may point to local tempPathname, so don't return it */
- }
- else
- {
- error = paramErr;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetCatInfoNoName(short vRefNum,
- long dirID,
- ConstStr255Param name,
- CInfoPBPtr pb)
-{
- Str31 tempName;
- OSErr error;
-
- /* Protection against File Sharing problem */
- if ( (name == NULL) || (name[0] == 0) )
- {
- tempName[0] = 0;
- pb->dirInfo.ioNamePtr = tempName;
- pb->dirInfo.ioFDirIndex = -1; /* use ioDirID */
- }
- else
- {
- pb->dirInfo.ioNamePtr = (StringPtr)name;
- pb->dirInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- }
- pb->dirInfo.ioVRefNum = vRefNum;
- pb->dirInfo.ioDrDirID = dirID;
- error = PBGetCatInfoSync(pb);
- pb->dirInfo.ioNamePtr = NULL;
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DetermineVRefNum(ConstStr255Param pathname,
- short vRefNum,
- short *realVRefNum)
-{
- HParamBlockRec pb;
- OSErr error;
-
- error = GetVolumeInfoNoName(pathname,vRefNum, &pb);
- if ( error == noErr )
- {
- *realVRefNum = pb.volumeParam.ioVRefNum;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HGetVInfo(short volReference,
- StringPtr volName,
- short *vRefNum,
- unsigned long *freeBytes,
- unsigned long *totalBytes)
-{
- OSErr result;
- UInt64 freeBytes64;
- UInt64 totalBytes64;
-
- // get the best values possible from XGetVInfo
- result = XGetVInfo(volReference, volName, vRefNum, &freeBytes64, &totalBytes64);
- if ( result == noErr )
- {
- // and pin those values if needed
- if ( (UInt64ToUnsignedWide(freeBytes64)).hi != 0 )
- {
- // pin to maximum 512-byte block aligned value
- *freeBytes = 0xfffffe00;
- }
- else
- {
- *freeBytes = U32SetU(freeBytes64);
- }
-
- if ( (UInt64ToUnsignedWide(totalBytes64)).hi != 0 )
- {
- // pin to maximum 512-byte block aligned value
- *totalBytes = 0xfffffe00;
- }
- else
- {
- *totalBytes = U32SetU(totalBytes64);
- }
- }
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr XGetVInfo(short volReference,
- StringPtr volName,
- short *vRefNum,
- UInt64 *freeBytes,
- UInt64 *totalBytes)
-{
- OSErr result;
- XVolumeParam pb;
-
-#if !TARGET_API_MAC_CARBON
-
- long response;
-
-#endif // !TARGET_API_MAC_CARBON
-
- pb.ioVRefNum = volReference;
- pb.ioNamePtr = volName;
- pb.ioXVersion = 0; /* this XVolumeParam version (0) */
- pb.ioVolIndex = 0; /* use ioVRefNum only, return volume name */
-
-#if !TARGET_API_MAC_CARBON
-
- /* See if large volume support is available */
- if ( ( Gestalt(gestaltFSAttr, &response) == noErr ) && ((response & (1L << gestaltFSSupports2TBVols)) != 0) )
-
-#endif // !TARGET_API_MAC_CARBON
-
- {
- /* Large volume support is available */
- result = CallPBXGetVolInfoSync(&pb);
- if ( result == noErr )
- {
- /* The volume name was returned in volName (if not NULL) and */
- /* we have the volume's vRefNum and allocation block size */
- *vRefNum = pb.ioVRefNum;
-
- /* return the freeBytes and totalBytes */
- *totalBytes = pb.ioVTotalBytes;
- *freeBytes = pb.ioVFreeBytes;
- }
- }
-
-#if !TARGET_API_MAC_CARBON
-
- else
- {
- /* No large volume support */
- /* Use PBHGetVInfoSync to get the results */
- result = PBHGetVInfoSync((HParmBlkPtr)&pb);
- if ( result == noErr )
- {
- VCB *theVCB;
-
- /* The volume name was returned in volName (if not NULL) and */
- /* we have the volume's vRefNum */
- *vRefNum = pb.ioVRefNum;
-
- /* System 7.5 (and beyond) pins the number of allocation blocks and */
- /* the number of free allocation blocks returned by PBHGetVInfo to */
- /* a value so that when multiplied by the allocation block size, */
- /* the volume will look like it has $7fffffff bytes or less. This */
- /* was done so older applications that use signed math or that use */
- /* the GetVInfo function (which uses signed math) will continue to work. */
- /* However, the unpinned numbers (which we want) are always available */
- /* in the volume's VCB so we'll get those values from the VCB. */
- /* Note: Carbon doesn't support the VCB queue, so this code cannot be */
- /* used (and is conditionalized out) by Carbon applications. */
-
- /* Find the volume's VCB */
- theVCB = (VCB *)(GetVCBQHdr()->qHead);
- while ( theVCB != NULL )
- {
- if ( theVCB->vcbVRefNum == *vRefNum )
- {
- break;
- }
-
- theVCB = (VCB *)(theVCB->qLink); /* next VCB */
- }
-
- if ( theVCB != NULL )
- {
- /* Found a VCB we can use. Get the un-pinned number of allocation blocks */
- /* and the number of free blocks from the VCB. */
- *freeBytes = U64Multiply(U64SetU((unsigned short)theVCB->vcbFreeBks), U64SetU((unsigned long)pb.ioVAlBlkSiz));
- *totalBytes = U64Multiply(U64SetU((unsigned short)theVCB->vcbNmAlBlks), U64SetU((unsigned long)pb.ioVAlBlkSiz));
- }
- else
- {
- /* Didn't find a VCB we can use. Return the number of allocation blocks */
- /* and the number of free blocks returned by PBHGetVInfoSync. */
- *freeBytes = U64Multiply(U64SetU((unsigned short)pb.ioVFrBlk), U64SetU((unsigned long)pb.ioVAlBlkSiz));
- *totalBytes = U64Multiply(U64SetU((unsigned short)pb.ioVNmAlBlks), U64SetU((unsigned long)pb.ioVAlBlkSiz));
- }
-
- }
- }
-
-#endif // !TARGET_API_MAC_CARBON
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr CheckVolLock(ConstStr255Param pathname,
- short vRefNum)
-{
- HParamBlockRec pb;
- OSErr error;
-
- error = GetVolumeInfoNoName(pathname,vRefNum, &pb);
- if ( error == noErr )
- {
- if ( (pb.volumeParam.ioVAtrb & kHFSVolumeHardwareLockMask) != 0 )
- {
- error = wPrErr; /* volume locked by hardware */
- }
- else if ( (pb.volumeParam.ioVAtrb & kHFSVolumeSoftwareLockMask) != 0 )
- {
- error = vLckdErr; /* volume locked by software */
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-//
-// The following routines call Mac OS routines that are not supported by
-// Carbon:
-//
-// GetDriverName
-// FindDrive
-// GetDiskBlocks
-// GetVolState
-
-#if !TARGET_API_MAC_CARBON // {
-
- /*****************************************************************************/
-
- pascal OSErr GetDriverName(short driverRefNum,
- Str255 driverName)
- {
- OSErr result;
- DCtlHandle theDctl;
- DRVRHeaderPtr dHeaderPtr;
-
- theDctl = GetDCtlEntry(driverRefNum);
- if ( theDctl != NULL )
- {
- if ( (**theDctl).dCtlFlags & dRAMBasedMask )
- {
- /* dctlDriver is handle - dereference */
- dHeaderPtr = *((DRVRHeaderHandle)(**theDctl).dCtlDriver);
- }
- else
- {
- /* dctlDriver is pointer */
- dHeaderPtr = (DRVRHeaderPtr)(**theDctl).dCtlDriver;
- }
- BlockMoveData((*dHeaderPtr).drvrName, driverName, (*dHeaderPtr).drvrName[0] + 1);
- result = noErr;
- }
- else
- {
- driverName[0] = 0;
- result = badUnitErr; /* bad reference number */
- }
-
- return ( result );
- }
-
- /*****************************************************************************/
-
- pascal OSErr FindDrive(ConstStr255Param pathname,
- short vRefNum,
- DrvQElPtr *driveQElementPtr)
- {
- OSErr result;
- HParamBlockRec hPB;
- short driveNumber;
-
- *driveQElementPtr = NULL;
-
- /* First, use GetVolumeInfoNoName to determine the volume */
- result = GetVolumeInfoNoName(pathname, vRefNum, &hPB);
- if ( result == noErr )
- {
- /*
- ** The volume can be either online, offline, or ejected. What we find in
- ** ioVDrvInfo and ioVDRefNum will tell us which it is.
- ** See Inside Macintosh: Files page 2-80 and the Technical Note
- ** "FL 34 - VCBs and Drive Numbers : The Real Story"
- ** Where we get the drive number depends on the state of the volume.
- */
- if ( hPB.volumeParam.ioVDrvInfo != 0 )
- {
- /* The volume is online and not ejected */
- /* Get the drive number */
- driveNumber = hPB.volumeParam.ioVDrvInfo;
- }
- else
- {
- /* The volume's is either offline or ejected */
- /* in either case, the volume is NOT online */
-
- /* Is it ejected or just offline? */
- if ( hPB.volumeParam.ioVDRefNum > 0 )
- {
- /* It's ejected, the drive number is ioVDRefNum */
- driveNumber = hPB.volumeParam.ioVDRefNum;
- }
- else
- {
- /* It's offline, the drive number is the negative of ioVDRefNum */
- driveNumber = (short)-hPB.volumeParam.ioVDRefNum;
- }
- }
-
- /* Get pointer to first element in drive queue */
- *driveQElementPtr = (DrvQElPtr)(GetDrvQHdr()->qHead);
-
- /* Search for a matching drive number */
- while ( (*driveQElementPtr != NULL) && ((*driveQElementPtr)->dQDrive != driveNumber) )
- {
- *driveQElementPtr = (DrvQElPtr)(*driveQElementPtr)->qLink;
- }
-
- if ( *driveQElementPtr == NULL )
- {
- /* This should never happen since every volume must have a drive, but... */
- result = nsDrvErr;
- }
- }
-
- return ( result );
- }
-
- /*****************************************************************************/
-
- pascal OSErr GetDiskBlocks(ConstStr255Param pathname,
- short vRefNum,
- unsigned long *numBlocks)
- {
- /* Various constants for GetDiskBlocks() */
- enum
- {
- /* return format list status code */
- kFmtLstCode = 6,
-
- /* reference number of .SONY driver */
- kSonyRefNum = 0xfffb,
-
- /* values returned by DriveStatus in DrvSts.twoSideFmt */
- kSingleSided = 0,
- kDoubleSided = -1,
- kSingleSidedSize = 800, /* 400K */
- kDoubleSidedSize = 1600, /* 800K */
-
- /* values in DrvQEl.qType */
- kWordDrvSiz = 0,
- kLongDrvSiz = 1,
-
- /* more than enough formatListRecords */
- kMaxFormatListRecs = 16
- };
-
- DrvQElPtr driveQElementPtr;
- unsigned long blocks;
- ParamBlockRec pb;
- FormatListRec formatListRecords[kMaxFormatListRecs];
- DrvSts status;
- short formatListRecIndex;
- OSErr result;
-
- blocks = 0;
-
- /* Find the drive queue element for this volume */
- result = FindDrive(pathname, vRefNum, &driveQElementPtr);
-
- /*
- ** Make sure this is a real driver (dQRefNum < 0).
- ** AOCE's Mail Enclosures volume uses 0 for dQRefNum which will cause
- ** problems if you try to use it as a driver refNum.
- */
- if ( (result == noErr) && (driveQElementPtr->dQRefNum >= 0) )
- {
- result = paramErr;
- }
- else
- {
- /* Attempt to get the drive's format list. */
- /* (see the Technical Note "What Your Sony Drives For You") */
-
- pb.cntrlParam.ioVRefNum = driveQElementPtr->dQDrive;
- pb.cntrlParam.ioCRefNum = driveQElementPtr->dQRefNum;
- pb.cntrlParam.csCode = kFmtLstCode;
- pb.cntrlParam.csParam[0] = kMaxFormatListRecs;
- *(long *)&pb.cntrlParam.csParam[1] = (long)&formatListRecords[0];
-
- result = PBStatusSync(&pb);
-
- if ( result == noErr )
- {
- /* The drive supports ReturnFormatList status call. */
-
- /* Get the current disk's size. */
- for( formatListRecIndex = 0;
- formatListRecIndex < pb.cntrlParam.csParam[0];
- ++formatListRecIndex )
- {
- if ( (formatListRecords[formatListRecIndex].formatFlags &
- diCIFmtFlagsCurrentMask) != 0 )
- {
- blocks = formatListRecords[formatListRecIndex].volSize;
- }
- }
- if ( blocks == 0 )
- {
- /* This should never happen */
- result = paramErr;
- }
- }
- else if ( driveQElementPtr->dQRefNum == (short)kSonyRefNum )
- {
- /* The drive is a non-SuperDrive floppy which only supports 400K and 800K disks */
-
- result = DriveStatus(driveQElementPtr->dQDrive, &status);
- if ( result == noErr )
- {
- switch ( status.twoSideFmt )
- {
- case kSingleSided:
- blocks = kSingleSidedSize;
- break;
- case kDoubleSided:
- blocks = kDoubleSidedSize;
- break;
- default:
- /* This should never happen */
- result = paramErr;
- break;
- }
- }
- }
- else
- {
- /* The drive is not a floppy and it doesn't support ReturnFormatList */
- /* so use the dQDrvSz field(s) */
-
- result = noErr; /* reset result */
- switch ( driveQElementPtr->qType )
- {
- case kWordDrvSiz:
- blocks = driveQElementPtr->dQDrvSz;
- break;
- case kLongDrvSiz:
- blocks = ((unsigned long)driveQElementPtr->dQDrvSz2 << 16) +
- driveQElementPtr->dQDrvSz;
- break;
- default:
- /* This should never happen */
- result = paramErr;
- break;
- }
- }
- }
-
- if ( result == noErr )
- {
- *numBlocks = blocks;
- }
-
- return ( result );
- }
-
- /*****************************************************************************/
-
- pascal OSErr GetVolState(ConstStr255Param pathname,
- short vRefNum,
- Boolean *volumeOnline,
- Boolean *volumeEjected,
- Boolean *driveEjectable,
- Boolean *driverWantsEject)
- {
- HParamBlockRec pb;
- short driveNumber;
- OSErr error;
-
- error = GetVolumeInfoNoName(pathname,vRefNum, &pb);
- if ( error == noErr )
- {
- if ( pb.volumeParam.ioVDrvInfo != 0 )
- {
- /* the volume is online and not ejected */
- *volumeOnline = true;
- *volumeEjected = false;
-
- /* Get the drive number */
- driveNumber = pb.volumeParam.ioVDrvInfo;
- }
- else
- {
- /* the volume's is either offline or ejected */
- /* in either case, the volume is NOT online */
- *volumeOnline = false;
-
- /* Is it ejected? */
- *volumeEjected = pb.volumeParam.ioVDRefNum > 0;
-
- if ( *volumeEjected )
- {
- /* If ejected, the drive number is ioVDRefNum */
- driveNumber = pb.volumeParam.ioVDRefNum;
- }
- else
- {
- /* If offline, the drive number is the negative of ioVDRefNum */
- driveNumber = (short)-pb.volumeParam.ioVDRefNum;
- }
- }
-
- {
- DrvQElPtr drvQElem;
-
- /* Find the drive queue element by searching the drive queue */
- drvQElem = (DrvQElPtr)(GetDrvQHdr()->qHead);
- while ( (drvQElem != NULL) && (drvQElem->dQDrive != driveNumber) )
- {
- drvQElem = (DrvQElPtr)drvQElem->qLink;
- }
-
- if ( drvQElem != NULL )
- {
- /*
- ** Each drive queue element is preceded by 4 flag bytes.
- ** Byte 1 (the second flag byte) has bits that tell us if a
- ** drive is ejectable and if its driver wants an eject call.
- ** See Inside Macintosh: Files, page 2-85.
- */
- {
- Ptr flagBytePtr;
-
- /* point to byte 1 of the flag bytes */
- flagBytePtr = (Ptr)drvQElem;
- flagBytePtr -= 3;
-
- /*
- ** The drive is ejectable if flag byte 1 does not contain
- ** 0x08 (nonejectable) or 0x48 (nonejectable, but wants eject call).
- */
-
- *driveEjectable = (*flagBytePtr != 0x08) && (*flagBytePtr != 0x48);
-
- /*
- ** The driver wants an eject call if flag byte 1 does not contain
- ** 0x08 (nonejectable). This may seem like a minor point, but some
- ** disk drivers use the Eject request to flush their caches to disk
- ** and you wouldn't want to skip that step after unmounting a volume.
- */
-
- *driverWantsEject = (*flagBytePtr != 0x08);
- }
- }
- else
- {
- /* Didn't find the drive (this should never happen) */
- *driveEjectable = false;
- *driverWantsEject = false;
- }
- }
- }
-
- return ( error );
- }
-
- /*****************************************************************************/
-
-#endif // } !TARGET_API_MAC_CARBON
-
-/*****************************************************************************/
-
-pascal OSErr GetVolFileSystemID(ConstStr255Param pathname,
- short vRefNum,
- short *fileSystemID)
-{
- HParamBlockRec pb;
- OSErr error;
-
- error = GetVolumeInfoNoName(pathname,vRefNum, &pb);
- if ( error == noErr )
- {
- *fileSystemID = pb.volumeParam.ioVFSID;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-//
-// Note: Under Carbon there are no drive numbers, so you cannot call
-// Eject with a drive number after unmounting a volume.
-// When a Carbon application calls UnmountVol, CarbonLib will make
-// sure ejectable media is ejected (leaving ejectable media in the
-// disk drive makes no sense to Carbon applications).
-//
-pascal OSErr UnmountAndEject(ConstStr255Param pathname,
- short vRefNum)
-{
- HParamBlockRec pb;
- OSErr error;
-
- error = GetVolumeInfoNoName(pathname, vRefNum, &pb);
- if ( error == noErr )
- {
-
-#if !TARGET_API_MAC_CARBON
-
- short driveNum;
- Boolean ejected, wantsEject;
- DrvQElPtr drvQElem;
-
- if ( pb.volumeParam.ioVDrvInfo != 0 )
- {
- /* the volume is online and not ejected */
- ejected = false;
-
- /* Get the drive number */
- driveNum = pb.volumeParam.ioVDrvInfo;
- }
- else
- {
- /* the volume is ejected or offline */
-
- /* Is it ejected? */
- ejected = pb.volumeParam.ioVDRefNum > 0;
-
- if ( ejected )
- {
- /* If ejected, the drive number is ioVDRefNum */
- driveNum = pb.volumeParam.ioVDRefNum;
- }
- else
- {
- /* If offline, the drive number is the negative of ioVDRefNum */
- driveNum = (short)-pb.volumeParam.ioVDRefNum;
- }
- }
-
- /* find the drive queue element */
- drvQElem = (DrvQElPtr)(GetDrvQHdr()->qHead);
- while ( (drvQElem != NULL) && (drvQElem->dQDrive != driveNum) )
- {
- drvQElem = (DrvQElPtr)drvQElem->qLink;
- }
-
- if ( drvQElem != NULL )
- {
- /* does the drive want an eject call */
- wantsEject = (*((Ptr)((Ptr)drvQElem - 3)) != 8);
- }
- else
- {
- /* didn't find the drive!! */
- wantsEject = false;
- }
-
-#endif // !TARGET_API_MAC_CARBON
-
- /* unmount the volume */
- pb.volumeParam.ioNamePtr = NULL;
- /* ioVRefNum is already filled in from PBHGetVInfo */
- error = PBUnmountVol((ParmBlkPtr)&pb);
-
-#if !TARGET_API_MAC_CARBON
-
- if ( error == noErr )
- {
- if ( wantsEject && !ejected )
- {
- /* eject the media from the drive if needed */
- pb.volumeParam.ioVRefNum = driveNum;
- error = PBEject((ParmBlkPtr)&pb);
- }
- }
-
-#endif // !TARGET_API_MAC_CARBON
-
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr OnLine(FSSpecPtr volumes,
- short reqVolCount,
- short *actVolCount,
- short *volIndex)
-{
- HParamBlockRec pb;
- OSErr error = noErr;
- FSSpec *endVolArray;
-
- if ( *volIndex > 0 )
- {
- *actVolCount = 0;
- for ( endVolArray = volumes + reqVolCount; (volumes < endVolArray) && (error == noErr); ++volumes )
- {
- pb.volumeParam.ioNamePtr = (StringPtr) & volumes->name;
- pb.volumeParam.ioVolIndex = *volIndex;
- error = PBHGetVInfoSync(&pb);
- if ( error == noErr )
- {
- volumes->parID = fsRtParID; /* the root directory's parent is 1 */
- volumes->vRefNum = pb.volumeParam.ioVRefNum;
- ++*volIndex;
- ++*actVolCount;
- }
- }
- }
- else
- {
- error = paramErr;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr SetDefault(short newVRefNum,
- long newDirID,
- short *oldVRefNum,
- long *oldDirID)
-{
- OSErr error;
-
- /* Get the current default volume/directory. */
- error = HGetVol(NULL, oldVRefNum, oldDirID);
- if ( error == noErr )
- {
- /* Set the new default volume/directory */
- error = HSetVol(NULL, newVRefNum, newDirID);
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr RestoreDefault(short oldVRefNum,
- long oldDirID)
-{
- OSErr error;
-
-#if !TARGET_API_MAC_CARBON
-
- short defaultVRefNum;
- long defaultDirID;
- long defaultProcID;
-
- /* Determine if the default volume was a wdRefNum. */
- error = GetWDInfo(oldVRefNum, &defaultVRefNum, &defaultDirID, &defaultProcID);
- if ( error == noErr )
- {
- /* Restore the old default volume/directory, one way or the other. */
- if ( defaultDirID != fsRtDirID )
- {
- /* oldVRefNum was a wdRefNum - use SetVol */
- error = SetVol(NULL, oldVRefNum);
- }
- else
- {
-
-#endif // !TARGET_API_MAC_CARBON
-
- /* oldVRefNum was a real vRefNum - use HSetVol */
- error = HSetVol(NULL, oldVRefNum, oldDirID);
-
-#if !TARGET_API_MAC_CARBON
-
- }
- }
-#endif // !TARGET_API_MAC_CARBON
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetDInfo(short vRefNum,
- long dirID,
- ConstStr255Param name,
- DInfo *fndrInfo)
-{
- CInfoPBRec pb;
- OSErr error;
-
- error = GetCatInfoNoName(vRefNum, dirID, name, &pb);
- if ( error == noErr )
- {
- if ( (pb.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* it's a directory, return the DInfo */
- *fndrInfo = pb.dirInfo.ioDrUsrWds;
- }
- else
- {
- /* oops, a file was passed */
- error = dirNFErr;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetDInfo(const FSSpec *spec,
- DInfo *fndrInfo)
-{
- return ( GetDInfo(spec->vRefNum, spec->parID, spec->name, fndrInfo) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr SetDInfo(short vRefNum,
- long dirID,
- ConstStr255Param name,
- const DInfo *fndrInfo)
-{
- CInfoPBRec pb;
- Str31 tempName;
- OSErr error;
-
- /* Protection against File Sharing problem */
- if ( (name == NULL) || (name[0] == 0) )
- {
- tempName[0] = 0;
- pb.dirInfo.ioNamePtr = tempName;
- pb.dirInfo.ioFDirIndex = -1; /* use ioDirID */
- }
- else
- {
- pb.dirInfo.ioNamePtr = (StringPtr)name;
- pb.dirInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- }
- pb.dirInfo.ioVRefNum = vRefNum;
- pb.dirInfo.ioDrDirID = dirID;
- error = PBGetCatInfoSync(&pb);
- if ( error == noErr )
- {
- if ( (pb.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* it's a directory, set the DInfo */
- if ( pb.dirInfo.ioNamePtr == tempName )
- {
- pb.dirInfo.ioDrDirID = pb.dirInfo.ioDrParID;
- }
- else
- {
- pb.dirInfo.ioDrDirID = dirID;
- }
- pb.dirInfo.ioDrUsrWds = *fndrInfo;
- error = PBSetCatInfoSync(&pb);
- }
- else
- {
- /* oops, a file was passed */
- error = dirNFErr;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetDInfo(const FSSpec *spec,
- const DInfo *fndrInfo)
-{
- return ( SetDInfo(spec->vRefNum, spec->parID, spec->name, fndrInfo) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetDirectoryID(short vRefNum,
- long dirID,
- ConstStr255Param name,
- long *theDirID,
- Boolean *isDirectory)
-{
- CInfoPBRec pb;
- OSErr error;
-
- error = GetCatInfoNoName(vRefNum, dirID, name, &pb);
- if ( error == noErr )
- {
- *isDirectory = (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0;
- if ( *isDirectory )
- {
- *theDirID = pb.dirInfo.ioDrDirID;
- }
- else
- {
- *theDirID = pb.hFileInfo.ioFlParID;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetDirectoryID(const FSSpec *spec,
- long *theDirID,
- Boolean *isDirectory)
-{
- return ( GetDirectoryID(spec->vRefNum, spec->parID, spec->name,
- theDirID, isDirectory) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetDirName(short vRefNum,
- long dirID,
- Str31 name)
-{
- CInfoPBRec pb;
- OSErr error;
-
- if ( name != NULL )
- {
- pb.dirInfo.ioNamePtr = name;
- pb.dirInfo.ioVRefNum = vRefNum;
- pb.dirInfo.ioDrDirID = dirID;
- pb.dirInfo.ioFDirIndex = -1; /* get information about ioDirID */
- error = PBGetCatInfoSync(&pb);
- }
- else
- {
- error = paramErr;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetIOACUser(short vRefNum,
- long dirID,
- ConstStr255Param name,
- SInt8 *ioACUser)
-{
- CInfoPBRec pb;
- OSErr error;
-
- /* Clear ioACUser before calling PBGetCatInfo since some file systems
- ** don't bother to set or clear this field. If ioACUser isn't set by the
- ** file system, then you'll get the zero value back (full access) which
- ** is the access you have on volumes that don't support ioACUser.
- */
- pb.dirInfo.ioACUser = 0; /* ioACUser used to be filler2 */
- error = GetCatInfoNoName(vRefNum, dirID, name, &pb);
- if ( error == noErr )
- {
- if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) == 0 )
- {
- /* oops, a file was passed */
- error = dirNFErr;
- }
- else
- {
- *ioACUser = pb.dirInfo.ioACUser;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetIOACUser(const FSSpec *spec,
- SInt8 *ioACUser)
-{
- return ( GetIOACUser(spec->vRefNum, spec->parID, spec->name, ioACUser) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetParentID(short vRefNum,
- long dirID,
- ConstStr255Param name,
- long *parID)
-{
- CInfoPBRec pb;
- Str31 tempName;
- OSErr error;
- short realVRefNum;
-
- /* Protection against File Sharing problem */
- if ( (name == NULL) || (name[0] == 0) )
- {
- tempName[0] = 0;
- pb.hFileInfo.ioNamePtr = tempName;
- pb.hFileInfo.ioFDirIndex = -1; /* use ioDirID */
- }
- else
- {
- pb.hFileInfo.ioNamePtr = (StringPtr)name;
- pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- }
- pb.hFileInfo.ioVRefNum = vRefNum;
- pb.hFileInfo.ioDirID = dirID;
- error = PBGetCatInfoSync(&pb);
- if ( error == noErr )
- {
- /*
- ** There's a bug in HFS where the wrong parent dir ID can be
- ** returned if multiple separators are used at the end of a
- ** pathname. For example, if the pathname:
- ** 'volumeName:System Folder:Extensions::'
- ** is passed, the directory ID of the Extensions folder is
- ** returned in the ioFlParID field instead of fsRtDirID. Since
- ** multiple separators at the end of a pathname always specifies
- ** a directory, we only need to work-around cases where the
- ** object is a directory and there are multiple separators at
- ** the end of the name parameter.
- */
- if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* Its a directory */
-
- /* is there a pathname? */
- if ( pb.hFileInfo.ioNamePtr == name )
- {
- /* could it contain multiple separators? */
- if ( name[0] >= 2 )
- {
- /* does it contain multiple separators at the end? */
- if ( (name[name[0]] == ':') && (name[name[0] - 1] == ':') )
- {
- /* OK, then do the extra stuff to get the correct parID */
-
- /* Get the real vRefNum (this should not fail) */
- error = DetermineVRefNum(name, vRefNum, &realVRefNum);
- if ( error == noErr )
- {
- /* we don't need the parent's name, but add protect against File Sharing problem */
- tempName[0] = 0;
- pb.dirInfo.ioNamePtr = tempName;
- pb.dirInfo.ioVRefNum = realVRefNum;
- /* pb.dirInfo.ioDrDirID already contains the */
- /* dirID of the directory object */
- pb.dirInfo.ioFDirIndex = -1; /* get information about ioDirID */
- error = PBGetCatInfoSync(&pb);
- /* now, pb.dirInfo.ioDrParID contains the correct parID */
- }
- }
- }
- }
- }
-
- if ( error == noErr )
- {
- /* if no errors, then pb.hFileInfo.ioFlParID (pb.dirInfo.ioDrParID) */
- /* contains the parent ID */
- *parID = pb.hFileInfo.ioFlParID;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetFilenameFromPathname(ConstStr255Param pathname,
- Str255 filename)
-{
- short index;
- short nameEnd;
- OSErr error;
-
- /* default to no filename */
- filename[0] = 0;
-
- /* check for no pathname */
- if ( pathname != NULL )
- {
- /* get string length */
- index = pathname[0];
-
- /* check for empty string */
- if ( index != 0 )
- {
- /* skip over last trailing colon (if any) */
- if ( pathname[index] == ':' )
- {
- --index;
- }
-
- /* save the end of the string */
- nameEnd = index;
-
- /* if pathname ends with multiple colons, then this pathname refers */
- /* to a directory, not a file */
- if ( pathname[index] != ':' )
- {
- /* parse backwards until we find a colon or hit the beginning of the pathname */
- while ( (index != 0) && (pathname[index] != ':') )
- {
- --index;
- }
-
- /* if we parsed to the beginning of the pathname and the pathname ended */
- /* with a colon, then pathname is a full pathname to a volume, not a file */
- if ( (index != 0) || (pathname[pathname[0]] != ':') )
- {
- /* get the filename and return noErr */
- filename[0] = (char)(nameEnd - index);
- BlockMoveData(&pathname[index+1], &filename[1], nameEnd - index);
- error = noErr;
- }
- else
- {
- /* pathname to a volume, not a file */
- error = notAFileErr;
- }
- }
- else
- {
- /* directory, not a file */
- error = notAFileErr;
- }
- }
- else
- {
- /* empty string isn't a file */
- error = notAFileErr;
- }
- }
- else
- {
- /* NULL pathname isn't a file */
- error = notAFileErr;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetObjectLocation(short vRefNum,
- long dirID,
- ConstStr255Param pathname,
- short *realVRefNum,
- long *realParID,
- Str255 realName,
- Boolean *isDirectory)
-{
- OSErr error;
- CInfoPBRec pb;
- Str255 tempPathname;
-
- /* clear results */
- *realVRefNum = 0;
- *realParID = 0;
- realName[0] = 0;
-
- /*
- ** Get the real vRefNum
- */
- error = DetermineVRefNum(pathname, vRefNum, realVRefNum);
- if ( error == noErr )
- {
- /*
- ** Determine if the object already exists and if so,
- ** get the real parent directory ID if it's a file
- */
-
- /* Protection against File Sharing problem */
- if ( (pathname == NULL) || (pathname[0] == 0) )
- {
- tempPathname[0] = 0;
- pb.hFileInfo.ioNamePtr = tempPathname;
- pb.hFileInfo.ioFDirIndex = -1; /* use ioDirID */
- }
- else
- {
- pb.hFileInfo.ioNamePtr = (StringPtr)pathname;
- pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- }
- pb.hFileInfo.ioVRefNum = vRefNum;
- pb.hFileInfo.ioDirID = dirID;
- error = PBGetCatInfoSync(&pb);
- if ( error == noErr )
- {
- /*
- ** The file system object is present and we have the file's real parID
- */
-
- /* Is it a directory or a file? */
- *isDirectory = (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0;
- if ( *isDirectory )
- {
- /*
- ** It's a directory, get its name and parent dirID, and then we're done
- */
-
- pb.dirInfo.ioNamePtr = realName;
- pb.dirInfo.ioVRefNum = *realVRefNum;
- /* pb.dirInfo.ioDrDirID already contains the dirID of the directory object */
- pb.dirInfo.ioFDirIndex = -1; /* get information about ioDirID */
- error = PBGetCatInfoSync(&pb);
-
- /* get the parent ID here, because the file system can return the */
- /* wrong parent ID from the last call. */
- *realParID = pb.dirInfo.ioDrParID;
- }
- else
- {
- /*
- ** It's a file - use the parent directory ID from the last call
- ** to GetCatInfoparse, get the file name, and then we're done
- */
- *realParID = pb.hFileInfo.ioFlParID;
- error = GetFilenameFromPathname(pathname, realName);
- }
- }
- else if ( error == fnfErr )
- {
- /*
- ** The file system object is not present - see if its parent is present
- */
-
- /*
- ** Parse to get the object name from end of pathname
- */
- error = GetFilenameFromPathname(pathname, realName);
-
- /* if we can't get the object name from the end, we can't continue */
- if ( error == noErr )
- {
- /*
- ** What we want now is the pathname minus the object name
- ** for example:
- ** if pathname is 'vol:dir:file' tempPathname becomes 'vol:dir:'
- ** if pathname is 'vol:dir:file:' tempPathname becomes 'vol:dir:'
- ** if pathname is ':dir:file' tempPathname becomes ':dir:'
- ** if pathname is ':dir:file:' tempPathname becomes ':dir:'
- ** if pathname is ':file' tempPathname becomes ':'
- ** if pathname is 'file or file:' tempPathname becomes ''
- */
-
- /* get a copy of the pathname */
- BlockMoveData(pathname, tempPathname, pathname[0] + 1);
-
- /* remove the object name */
- tempPathname[0] -= realName[0];
- /* and the trailing colon (if any) */
- if ( pathname[pathname[0]] == ':' )
- {
- --tempPathname[0];
- }
-
- /* OK, now get the parent's directory ID */
-
- /* Protection against File Sharing problem */
- pb.hFileInfo.ioNamePtr = (StringPtr)tempPathname;
- if ( tempPathname[0] != 0 )
- {
- pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- }
- else
- {
- pb.hFileInfo.ioFDirIndex = -1; /* use ioDirID */
- }
- pb.hFileInfo.ioVRefNum = vRefNum;
- pb.hFileInfo.ioDirID = dirID;
- error = PBGetCatInfoSync(&pb);
- *realParID = pb.dirInfo.ioDrDirID;
-
- *isDirectory = false; /* we don't know what the object is really going to be */
- }
-
- if ( error != noErr )
- {
- error = dirNFErr; /* couldn't find parent directory */
- }
- else
- {
- error = fnfErr; /* we found the parent, but not the file */
- }
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetDirItems(short vRefNum,
- long dirID,
- ConstStr255Param name,
- Boolean getFiles,
- Boolean getDirectories,
- FSSpecPtr items,
- short reqItemCount,
- short *actItemCount,
- short *itemIndex) /* start with 1, then use what's returned */
-{
- CInfoPBRec pb;
- OSErr error;
- long theDirID;
- Boolean isDirectory;
- FSSpec *endItemsArray;
-
- if ( *itemIndex > 0 )
- {
- /* NOTE: If I could be sure that the caller passed a real vRefNum and real directory */
- /* to this routine, I could rip out calls to DetermineVRefNum and GetDirectoryID and this */
- /* routine would be much faster because of the overhead of DetermineVRefNum and */
- /* GetDirectoryID and because GetDirectoryID blows away the directory index hint the Macintosh */
- /* file system keeps for indexed calls. I can't be sure, so for maximum throughput, */
- /* pass a big array of FSSpecs so you can get the directory's contents with few calls */
- /* to this routine. */
-
- /* get the real volume reference number */
- error = DetermineVRefNum(name, vRefNum, &pb.hFileInfo.ioVRefNum);
- if ( error == noErr )
- {
- /* and the real directory ID of this directory (and make sure it IS a directory) */
- error = GetDirectoryID(vRefNum, dirID, name, &theDirID, &isDirectory);
- if ( error == noErr )
- {
- if ( isDirectory )
- {
- *actItemCount = 0;
- endItemsArray = items + reqItemCount;
- while ( (items < endItemsArray) && (error == noErr) )
- {
- pb.hFileInfo.ioNamePtr = (StringPtr) &items->name;
- pb.hFileInfo.ioDirID = theDirID;
- pb.hFileInfo.ioFDirIndex = *itemIndex;
- error = PBGetCatInfoSync(&pb);
- if ( error == noErr )
- {
- items->parID = pb.hFileInfo.ioFlParID; /* return item's parID */
- items->vRefNum = pb.hFileInfo.ioVRefNum; /* return item's vRefNum */
- ++*itemIndex; /* prepare to get next item in directory */
-
- if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- if ( getDirectories )
- {
- ++*actItemCount; /* keep this item */
- ++items; /* point to next item */
- }
- }
- else
- {
- if ( getFiles )
- {
- ++*actItemCount; /* keep this item */
- ++items; /* point to next item */
- }
- }
- }
- }
- }
- else
- {
- /* it wasn't a directory */
- error = dirNFErr;
- }
- }
- }
- }
- else
- {
- /* bad itemIndex */
- error = paramErr;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-static void DeleteLevel(long dirToDelete,
- DeleteEnumGlobalsPtr theGlobals)
-{
- long savedDir;
-
- do
- {
- /* prepare to delete directory */
- theGlobals->myPB.ciPB.dirInfo.ioNamePtr = (StringPtr)&theGlobals->itemName;
- theGlobals->myPB.ciPB.dirInfo.ioFDirIndex = 1; /* get first item */
- theGlobals->myPB.ciPB.dirInfo.ioDrDirID = dirToDelete; /* in this directory */
- theGlobals->error = PBGetCatInfoSync(&(theGlobals->myPB.ciPB));
- if ( theGlobals->error == noErr )
- {
- savedDir = dirToDelete;
- /* We have an item. Is it a file or directory? */
- if ( (theGlobals->myPB.ciPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* it's a directory */
- savedDir = theGlobals->myPB.ciPB.dirInfo.ioDrDirID; /* save dirID of directory instead */
- DeleteLevel(theGlobals->myPB.ciPB.dirInfo.ioDrDirID, theGlobals); /* Delete its contents */
- theGlobals->myPB.ciPB.dirInfo.ioNamePtr = NULL; /* prepare to delete directory */
- }
- if ( theGlobals->error == noErr )
- {
- theGlobals->myPB.ciPB.dirInfo.ioDrDirID = savedDir; /* restore dirID */
- theGlobals->myPB.hPB.fileParam.ioFVersNum = 0; /* just in case it's used on an MFS volume... */
- theGlobals->error = PBHDeleteSync(&(theGlobals->myPB.hPB)); /* delete this item */
- if ( theGlobals->error == fLckdErr )
- {
- (void) PBHRstFLockSync(&(theGlobals->myPB.hPB)); /* unlock it */
- theGlobals->error = PBHDeleteSync(&(theGlobals->myPB.hPB)); /* and try again */
- }
- }
- }
- } while ( theGlobals->error == noErr );
-
- if ( theGlobals->error == fnfErr )
- {
- theGlobals->error = noErr;
- }
-}
-
-/*****************************************************************************/
-
-pascal OSErr DeleteDirectoryContents(short vRefNum,
- long dirID,
- ConstStr255Param name)
-{
- DeleteEnumGlobals theGlobals;
- Boolean isDirectory;
- OSErr error;
-
- /* Get the real dirID and make sure it is a directory. */
- error = GetDirectoryID(vRefNum, dirID, name, &dirID, &isDirectory);
- if ( error == noErr )
- {
- if ( isDirectory )
- {
- /* Get the real vRefNum */
- error = DetermineVRefNum(name, vRefNum, &vRefNum);
- if ( error == noErr )
- {
- /* Set up the globals we need to access from the recursive routine. */
- theGlobals.myPB.ciPB.dirInfo.ioVRefNum = vRefNum;
-
- /* Here we go into recursion land... */
- DeleteLevel(dirID, &theGlobals);
- error = theGlobals.error;
- }
- }
- else
- {
- error = dirNFErr;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr DeleteDirectory(short vRefNum,
- long dirID,
- ConstStr255Param name)
-{
- OSErr error;
-
- /* Make sure a directory was specified and then delete its contents */
- error = DeleteDirectoryContents(vRefNum, dirID, name);
- if ( error == noErr )
- {
- error = HDelete(vRefNum, dirID, name);
- if ( error == fLckdErr )
- {
- (void) HRstFLock(vRefNum, dirID, name); /* unlock the directory locked by AppleShare */
- error = HDelete(vRefNum, dirID, name); /* and try again */
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr CheckObjectLock(short vRefNum,
- long dirID,
- ConstStr255Param name)
-{
- CInfoPBRec pb;
- OSErr error;
-
- error = GetCatInfoNoName(vRefNum, dirID, name, &pb);
- if ( error == noErr )
- {
- /* check locked bit */
- if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribLockedMask) != 0 )
- {
- error = fLckdErr;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpCheckObjectLock(const FSSpec *spec)
-{
- return ( CheckObjectLock(spec->vRefNum, spec->parID, spec->name) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetFileSize(short vRefNum,
- long dirID,
- ConstStr255Param fileName,
- long *dataSize,
- long *rsrcSize)
-{
- HParamBlockRec pb;
- OSErr error;
-
- pb.fileParam.ioNamePtr = (StringPtr)fileName;
- pb.fileParam.ioVRefNum = vRefNum;
- pb.fileParam.ioFVersNum = 0;
- pb.fileParam.ioDirID = dirID;
- pb.fileParam.ioFDirIndex = 0;
- error = PBHGetFInfoSync(&pb);
- if ( error == noErr )
- {
- *dataSize = pb.fileParam.ioFlLgLen;
- *rsrcSize = pb.fileParam.ioFlRLgLen;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetFileSize(const FSSpec *spec,
- long *dataSize,
- long *rsrcSize)
-{
- return ( GetFileSize(spec->vRefNum, spec->parID, spec->name, dataSize, rsrcSize) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr BumpDate(short vRefNum,
- long dirID,
- ConstStr255Param name)
-/* Given a file or directory, change its modification date to the current date/time. */
-{
- CInfoPBRec pb;
- Str31 tempName;
- OSErr error;
- unsigned long secs;
-
- /* Protection against File Sharing problem */
- if ( (name == NULL) || (name[0] == 0) )
- {
- tempName[0] = 0;
- pb.hFileInfo.ioNamePtr = tempName;
- pb.hFileInfo.ioFDirIndex = -1; /* use ioDirID */
- }
- else
- {
- pb.hFileInfo.ioNamePtr = (StringPtr)name;
- pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- }
- pb.hFileInfo.ioVRefNum = vRefNum;
- pb.hFileInfo.ioDirID = dirID;
- error = PBGetCatInfoSync(&pb);
- if ( error == noErr )
- {
- GetDateTime(&secs);
- /* set mod date to current date, or one second into the future
- if mod date = current date */
- pb.hFileInfo.ioFlMdDat = (secs == pb.hFileInfo.ioFlMdDat) ? (++secs) : (secs);
- if ( pb.dirInfo.ioNamePtr == tempName )
- {
- pb.hFileInfo.ioDirID = pb.hFileInfo.ioFlParID;
- }
- else
- {
- pb.hFileInfo.ioDirID = dirID;
- }
- error = PBSetCatInfoSync(&pb);
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpBumpDate(const FSSpec *spec)
-{
- return ( BumpDate(spec->vRefNum, spec->parID, spec->name) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ChangeCreatorType(short vRefNum,
- long dirID,
- ConstStr255Param name,
- OSType creator,
- OSType fileType)
-{
- CInfoPBRec pb;
- OSErr error;
- short realVRefNum;
- long parID;
-
- pb.hFileInfo.ioNamePtr = (StringPtr)name;
- pb.hFileInfo.ioVRefNum = vRefNum;
- pb.hFileInfo.ioDirID = dirID;
- pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- error = PBGetCatInfoSync(&pb);
- if ( error == noErr )
- {
- if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) == 0 ) /* if file */
- {
- parID = pb.hFileInfo.ioFlParID; /* save parent dirID for BumpDate call */
-
- /* If creator not 0x00000000, change creator */
- if ( creator != (OSType)0x00000000 )
- {
- pb.hFileInfo.ioFlFndrInfo.fdCreator = creator;
- }
-
- /* If fileType not 0x00000000, change fileType */
- if ( fileType != (OSType)0x00000000 )
- {
- pb.hFileInfo.ioFlFndrInfo.fdType = fileType;
- }
-
- pb.hFileInfo.ioDirID = dirID;
- error = PBSetCatInfoSync(&pb); /* now, save the new information back to disk */
-
- if ( (error == noErr) && (parID != fsRtParID) ) /* can't bump fsRtParID */
- {
- /* get the real vRefNum in case a full pathname was passed */
- error = DetermineVRefNum(name, vRefNum, &realVRefNum);
- if ( error == noErr )
- {
- error = BumpDate(realVRefNum, parID, NULL);
- /* and bump the parent directory's mod date to wake up the Finder */
- /* to the change we just made */
- }
- }
- }
- else
- {
- /* it was a directory, not a file */
- error = notAFileErr;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpChangeCreatorType(const FSSpec *spec,
- OSType creator,
- OSType fileType)
-{
- return ( ChangeCreatorType(spec->vRefNum, spec->parID, spec->name, creator, fileType) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ChangeFDFlags(short vRefNum,
- long dirID,
- ConstStr255Param name,
- Boolean setBits,
- unsigned short flagBits)
-{
- CInfoPBRec pb;
- Str31 tempName;
- OSErr error;
- short realVRefNum;
- long parID;
-
- /* Protection against File Sharing problem */
- if ( (name == NULL) || (name[0] == 0) )
- {
- tempName[0] = 0;
- pb.hFileInfo.ioNamePtr = tempName;
- pb.hFileInfo.ioFDirIndex = -1; /* use ioDirID */
- }
- else
- {
- pb.hFileInfo.ioNamePtr = (StringPtr)name;
- pb.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- }
- pb.hFileInfo.ioVRefNum = vRefNum;
- pb.hFileInfo.ioDirID = dirID;
- error = PBGetCatInfoSync(&pb);
- if ( error == noErr )
- {
- parID = pb.hFileInfo.ioFlParID; /* save parent dirID for BumpDate call */
-
- /* set or clear the appropriate bits in the Finder flags */
- if ( setBits )
- {
- /* OR in the bits */
- pb.hFileInfo.ioFlFndrInfo.fdFlags |= flagBits;
- }
- else
- {
- /* AND out the bits */
- pb.hFileInfo.ioFlFndrInfo.fdFlags &= ~flagBits;
- }
-
- if ( pb.dirInfo.ioNamePtr == tempName )
- {
- pb.hFileInfo.ioDirID = pb.hFileInfo.ioFlParID;
- }
- else
- {
- pb.hFileInfo.ioDirID = dirID;
- }
-
- error = PBSetCatInfoSync(&pb); /* now, save the new information back to disk */
-
- if ( (error == noErr) && (parID != fsRtParID) ) /* can't bump fsRtParID */
- {
- /* get the real vRefNum in case a full pathname was passed */
- error = DetermineVRefNum(name, vRefNum, &realVRefNum);
- if ( error == noErr )
- {
- error = BumpDate(realVRefNum, parID, NULL);
- /* and bump the parent directory's mod date to wake up the Finder */
- /* to the change we just made */
- }
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpChangeFDFlags(const FSSpec *spec,
- Boolean setBits,
- unsigned short flagBits)
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, setBits, flagBits) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr SetIsInvisible(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file or directory, make it invisible. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, true, kIsInvisible) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetIsInvisible(const FSSpec *spec)
- /* Given a file or directory, make it invisible. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, true, kIsInvisible) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ClearIsInvisible(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file or directory, make it visible. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, false, kIsInvisible) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpClearIsInvisible(const FSSpec *spec)
- /* Given a file or directory, make it visible. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, false, kIsInvisible) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr SetNameLocked(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file or directory, lock its name. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, true, kNameLocked) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetNameLocked(const FSSpec *spec)
- /* Given a file or directory, lock its name. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, true, kNameLocked) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ClearNameLocked(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file or directory, unlock its name. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, false, kNameLocked) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpClearNameLocked(const FSSpec *spec)
- /* Given a file or directory, unlock its name. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, false, kNameLocked) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr SetIsStationery(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file, make it a stationery pad. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, true, kIsStationery) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetIsStationery(const FSSpec *spec)
- /* Given a file, make it a stationery pad. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, true, kIsStationery) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ClearIsStationery(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file, clear the stationery bit. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, false, kIsStationery) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpClearIsStationery(const FSSpec *spec)
- /* Given a file, clear the stationery bit. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, false, kIsStationery) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr SetHasCustomIcon(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file or directory, indicate that it has a custom icon. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, true, kHasCustomIcon) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpSetHasCustomIcon(const FSSpec *spec)
- /* Given a file or directory, indicate that it has a custom icon. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, true, kHasCustomIcon) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ClearHasCustomIcon(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file or directory, indicate that it does not have a custom icon. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, false, kHasCustomIcon) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpClearHasCustomIcon(const FSSpec *spec)
- /* Given a file or directory, indicate that it does not have a custom icon. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, false, kHasCustomIcon) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr ClearHasBeenInited(short vRefNum,
- long dirID,
- ConstStr255Param name)
- /* Given a file, clear its "has been inited" bit. */
-{
- return ( ChangeFDFlags(vRefNum, dirID, name, false, kHasBeenInited) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpClearHasBeenInited(const FSSpec *spec)
- /* Given a file, clear its "has been inited" bit. */
-{
- return ( ChangeFDFlags(spec->vRefNum, spec->parID, spec->name, false, kHasBeenInited) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr CopyFileMgrAttributes(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName,
- Boolean copyLockBit)
-{
- UniversalFMPB pb;
- Str31 tempName;
- OSErr error;
- Boolean objectIsDirectory;
-
- pb.ciPB.hFileInfo.ioVRefNum = srcVRefNum;
- pb.ciPB.hFileInfo.ioDirID = srcDirID;
-
- /* Protection against File Sharing problem */
- if ( (srcName == NULL) || (srcName[0] == 0) )
- {
- tempName[0] = 0;
- pb.ciPB.hFileInfo.ioNamePtr = tempName;
- pb.ciPB.hFileInfo.ioFDirIndex = -1; /* use ioDirID */
- }
- else
- {
- pb.ciPB.hFileInfo.ioNamePtr = (StringPtr)srcName;
- pb.ciPB.hFileInfo.ioFDirIndex = 0; /* use ioNamePtr and ioDirID */
- }
- error = PBGetCatInfoSync(&pb.ciPB);
- if ( error == noErr )
- {
- objectIsDirectory = ( (pb.ciPB.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 );
- pb.ciPB.hFileInfo.ioVRefNum = dstVRefNum;
- pb.ciPB.hFileInfo.ioDirID = dstDirID;
- if ( (dstName != NULL) && (dstName[0] == 0) )
- {
- pb.ciPB.hFileInfo.ioNamePtr = NULL;
- }
- else
- {
- pb.ciPB.hFileInfo.ioNamePtr = (StringPtr)dstName;
- }
- /* don't copy the hasBeenInited bit */
- pb.ciPB.hFileInfo.ioFlFndrInfo.fdFlags = ( pb.ciPB.hFileInfo.ioFlFndrInfo.fdFlags & ~kHasBeenInited );
- error = PBSetCatInfoSync(&pb.ciPB);
- if ( (error == noErr) && (copyLockBit) && ((pb.ciPB.hFileInfo.ioFlAttrib & kioFlAttribLockedMask) != 0) )
- {
- pb.hPB.fileParam.ioFVersNum = 0;
- error = PBHSetFLockSync(&pb.hPB);
- if ( (error != noErr) && (objectIsDirectory) )
- {
- error = noErr; /* ignore lock errors if destination is directory */
- }
- }
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpCopyFileMgrAttributes(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- Boolean copyLockBit)
-{
- return ( CopyFileMgrAttributes(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->vRefNum, dstSpec->parID, dstSpec->name,
- copyLockBit) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HOpenAware(short vRefNum,
- long dirID,
- ConstStr255Param fileName,
- short denyModes,
- short *refNum)
-{
- HParamBlockRec pb;
- OSErr error;
- GetVolParmsInfoBuffer volParmsInfo;
- long infoSize = sizeof(GetVolParmsInfoBuffer);
-
- pb.ioParam.ioMisc = NULL;
- pb.fileParam.ioFVersNum = 0;
- pb.fileParam.ioNamePtr = (StringPtr)fileName;
- pb.fileParam.ioVRefNum = vRefNum;
- pb.fileParam.ioDirID = dirID;
-
- /* get volume attributes */
- /* this preflighting is needed because Foreign File Access based file systems don't */
- /* return the correct error result to the OpenDeny call */
- error = HGetVolParms(fileName, vRefNum, &volParmsInfo, &infoSize);
- if ( (error == noErr) && hasOpenDeny(&volParmsInfo) )
- {
- /* if volume supports OpenDeny, use it and return */
- pb.accessParam.ioDenyModes = denyModes;
- error = PBHOpenDenySync(&pb);
- *refNum = pb.ioParam.ioRefNum;
- }
- else if ( (error == noErr) || (error == paramErr) ) /* paramErr is OK, it just means this volume doesn't support GetVolParms */
- {
- /* OpenDeny isn't supported, so try File Manager Open functions */
-
- /* If request includes write permission, then see if the volume is */
- /* locked by hardware or software. The HFS file system doesn't check */
- /* for this when a file is opened - you only find out later when you */
- /* try to write and the write fails with a wPrErr or a vLckdErr. */
-
- if ( (denyModes & dmWr) != 0 )
- {
- error = CheckVolLock(fileName, vRefNum);
- }
- else
- {
- error = noErr;
- }
-
- if ( error == noErr )
- {
- /* Set File Manager permissions to closest thing possible */
- if ( (denyModes == dmWr) || (denyModes == dmRdWr) )
- {
- pb.ioParam.ioPermssn = fsRdWrShPerm;
- }
- else
- {
- pb.ioParam.ioPermssn = denyModes % 4;
- }
-
- error = PBHOpenDFSync(&pb); /* Try OpenDF */
- if ( error == paramErr )
- {
- error = PBHOpenSync(&pb); /* OpenDF not supported, so try Open */
- }
- *refNum = pb.ioParam.ioRefNum;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpOpenAware(const FSSpec *spec,
- short denyModes,
- short *refNum)
-{
- return ( HOpenAware(spec->vRefNum, spec->parID, spec->name, denyModes, refNum) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HOpenRFAware(short vRefNum,
- long dirID,
- ConstStr255Param fileName,
- short denyModes,
- short *refNum)
-{
- HParamBlockRec pb;
- OSErr error;
- GetVolParmsInfoBuffer volParmsInfo;
- long infoSize = sizeof(GetVolParmsInfoBuffer);
-
- pb.ioParam.ioMisc = NULL;
- pb.fileParam.ioFVersNum = 0;
- pb.fileParam.ioNamePtr = (StringPtr)fileName;
- pb.fileParam.ioVRefNum = vRefNum;
- pb.fileParam.ioDirID = dirID;
-
- /* get volume attributes */
- /* this preflighting is needed because Foreign File Access based file systems don't */
- /* return the correct error result to the OpenRFDeny call */
- error = HGetVolParms(fileName, vRefNum, &volParmsInfo, &infoSize);
- if ( (error == noErr) && hasOpenDeny(&volParmsInfo) )
- {
- /* if volume supports OpenRFDeny, use it and return */
- if ( hasOpenDeny(&volParmsInfo) )
- {
- pb.accessParam.ioDenyModes = denyModes;
- error = PBHOpenRFDenySync(&pb);
- *refNum = pb.ioParam.ioRefNum;
- }
- }
- else if ( (error == noErr) || (error == paramErr) ) /* paramErr is OK, it just means this volume doesn't support GetVolParms */
- {
- /* OpenRFDeny isn't supported, so try File Manager OpenRF function */
-
- /* If request includes write permission, then see if the volume is */
- /* locked by hardware or software. The HFS file system doesn't check */
- /* for this when a file is opened - you only find out later when you */
- /* try to write and the write fails with a wPrErr or a vLckdErr. */
-
- if ( (denyModes & dmWr) != 0 )
- {
- error = CheckVolLock(fileName, vRefNum);
- }
- else
- {
- error = noErr;
- }
-
- if ( error == noErr )
- {
- /* Set File Manager permissions to closest thing possible */
- if ( (denyModes == dmWr) || (denyModes == dmRdWr) )
- {
- pb.ioParam.ioPermssn = fsRdWrShPerm;
- }
- else
- {
- pb.ioParam.ioPermssn = denyModes % 4;
- }
-
- error = PBHOpenRFSync(&pb);
- *refNum = pb.ioParam.ioRefNum;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpOpenRFAware(const FSSpec *spec,
- short denyModes,
- short *refNum)
-{
- return ( HOpenRFAware(spec->vRefNum, spec->parID, spec->name, denyModes, refNum) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSReadNoCache(short refNum,
- long *count,
- void *buffPtr)
-{
- ParamBlockRec pb;
- OSErr error;
-
- pb.ioParam.ioRefNum = refNum;
- pb.ioParam.ioBuffer = (Ptr)buffPtr;
- pb.ioParam.ioReqCount = *count;
- pb.ioParam.ioPosMode = fsAtMark + noCacheMask; /* fsAtMark + noCacheMask */
- pb.ioParam.ioPosOffset = 0;
- error = PBReadSync(&pb);
- *count = pb.ioParam.ioActCount; /* always return count */
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSWriteNoCache(short refNum,
- long *count,
- const void *buffPtr)
-{
- ParamBlockRec pb;
- OSErr error;
-
- pb.ioParam.ioRefNum = refNum;
- pb.ioParam.ioBuffer = (Ptr)buffPtr;
- pb.ioParam.ioReqCount = *count;
- pb.ioParam.ioPosMode = fsAtMark + noCacheMask; /* fsAtMark + noCacheMask */
- pb.ioParam.ioPosOffset = 0;
- error = PBWriteSync(&pb);
- *count = pb.ioParam.ioActCount; /* always return count */
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** See if numBytes bytes of buffer1 are equal to buffer2.
-*/
-static Boolean EqualMemory(const void *buffer1, const void *buffer2, unsigned long numBytes)
-{
- register unsigned char *b1 = (unsigned char *)buffer1;
- register unsigned char *b2 = (unsigned char *)buffer2;
-
- if ( b1 != b2 ) /* if buffer pointers are same, then they are equal */
- {
- while ( numBytes > 0 )
- {
- /* compare the bytes and then increment the pointers */
- if ( (*b1++ - *b2++) != 0 )
- {
- return ( false );
- }
- --numBytes;
- }
- }
-
- return ( true );
-}
-
-/*****************************************************************************/
-
-/*
-** Read any number of bytes from an open file using read-verify mode.
-** The FSReadVerify function reads any number of bytes from an open file
-** and verifies them against the data in the buffer pointed to by buffPtr.
-**
-** Because of a bug in the HFS file system, only non-block aligned parts of
-** the read are verified against the buffer data and the rest is *copied*
-** into the buffer. Thus, you shouldn't verify against your original data;
-** instead, you should verify against a copy of the original data and then
-** compare the read-verified copy against the original data after calling
-** FSReadVerify. That's why this function isn't exported - it needs the
-** wrapper provided by FSWriteVerify.
-*/
-static OSErr FSReadVerify(short refNum,
- long *count,
- void *buffPtr)
-{
- ParamBlockRec pb;
- OSErr result;
-
- pb.ioParam.ioRefNum = refNum;
- pb.ioParam.ioBuffer = (Ptr)buffPtr;
- pb.ioParam.ioReqCount = *count;
- pb.ioParam.ioPosMode = fsAtMark + rdVerify;
- pb.ioParam.ioPosOffset = 0;
- result = PBReadSync(&pb);
- *count = pb.ioParam.ioActCount; /* always return count */
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSWriteVerify(short refNum,
- long *count,
- const void *buffPtr)
-{
- Ptr verifyBuffer;
- long position;
- long bufferSize;
- long byteCount;
- long bytesVerified;
- Ptr startVerify;
- OSErr result;
-
- /*
- ** Allocate the verify buffer
- ** Try to get get a large enough buffer to verify in one pass.
- ** If that fails, use GetTempBuffer to get a buffer.
- */
- bufferSize = *count;
- verifyBuffer = NewPtr(bufferSize);
- if ( verifyBuffer == NULL )
- {
- verifyBuffer = GetTempBuffer(bufferSize, &bufferSize);
- }
- if ( verifyBuffer != NULL )
- {
- /* Save the current position */
- result = GetFPos(refNum, &position);
- if ( result == noErr )
- {
- /* Write the data */
- result = FSWrite(refNum, count, buffPtr);
- if ( result == noErr )
- {
- /* Restore the original position */
- result = SetFPos(refNum, fsFromStart, position);
- if ( result == noErr )
- {
- /*
- ** *count = total number of bytes to verify
- ** bufferSize = the size of the verify buffer
- ** bytesVerified = number of bytes verified
- ** byteCount = number of bytes to verify this pass
- ** startVerify = position in buffPtr
- */
- bytesVerified = 0;
- startVerify = (Ptr)buffPtr;
- while ( (bytesVerified < *count) && ( result == noErr ) )
- {
- if ( (*count - bytesVerified) > bufferSize )
- {
- byteCount = bufferSize;
- }
- else
- {
- byteCount = *count - bytesVerified;
- }
- /*
- ** Copy the write buffer into the verify buffer.
- ** This step is needed because the File Manager
- ** compares the data in any non-block aligned
- ** data at the beginning and end of the read-verify
- ** request back into the file system's cache
- ** to the data in verify Buffer. However, the
- ** File Manager does not compare any full blocks
- ** and instead copies them into the verify buffer
- ** so we still have to compare the buffers again
- ** after the read-verify request completes.
- */
- BlockMoveData(startVerify, verifyBuffer, byteCount);
-
- /* Read-verify the data back into the verify buffer */
- result = FSReadVerify(refNum, &byteCount, verifyBuffer);
- if ( result == noErr )
- {
- /* See if the buffers are the same */
- if ( !EqualMemory(verifyBuffer, startVerify, byteCount) )
- {
- result = ioErr;
- }
- startVerify += byteCount;
- bytesVerified += byteCount;
- }
- }
- }
- }
- }
- DisposePtr(verifyBuffer);
- }
- else
- {
- result = memFullErr;
- }
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr CopyFork(short srcRefNum,
- short dstRefNum,
- void *copyBufferPtr,
- long copyBufferSize)
-{
- ParamBlockRec srcPB;
- ParamBlockRec dstPB;
- OSErr srcError;
- OSErr dstError;
-
- if ( (copyBufferPtr == NULL) || (copyBufferSize == 0) )
- return ( paramErr );
-
- srcPB.ioParam.ioRefNum = srcRefNum;
- dstPB.ioParam.ioRefNum = dstRefNum;
-
- /* preallocate the destination fork and */
- /* ensure the destination fork's EOF is correct after the copy */
- srcError = PBGetEOFSync(&srcPB);
- if ( srcError != noErr )
- return ( srcError );
- dstPB.ioParam.ioMisc = srcPB.ioParam.ioMisc;
- dstError = PBSetEOFSync(&dstPB);
- if ( dstError != noErr )
- return ( dstError );
-
- /* reset source fork's mark */
- srcPB.ioParam.ioPosMode = fsFromStart;
- srcPB.ioParam.ioPosOffset = 0;
- srcError = PBSetFPosSync(&srcPB);
- if ( srcError != noErr )
- return ( srcError );
-
- /* reset destination fork's mark */
- dstPB.ioParam.ioPosMode = fsFromStart;
- dstPB.ioParam.ioPosOffset = 0;
- dstError = PBSetFPosSync(&dstPB);
- if ( dstError != noErr )
- return ( dstError );
-
- /* set up fields that won't change in the loop */
- srcPB.ioParam.ioBuffer = (Ptr)copyBufferPtr;
- srcPB.ioParam.ioPosMode = fsAtMark + noCacheMask;/* fsAtMark + noCacheMask */
- /* If copyBufferSize is greater than 512 bytes, make it a multiple of 512 bytes */
- /* This will make writes on local volumes faster */
- if ( (copyBufferSize >= 512) && ((copyBufferSize & 0x1ff) != 0) )
- {
- srcPB.ioParam.ioReqCount = copyBufferSize & 0xfffffe00;
- }
- else
- {
- srcPB.ioParam.ioReqCount = copyBufferSize;
- }
- dstPB.ioParam.ioBuffer = (Ptr)copyBufferPtr;
- dstPB.ioParam.ioPosMode = fsAtMark + noCacheMask;/* fsAtMark + noCacheMask */
-
- while ( (srcError == noErr) && (dstError == noErr) )
- {
- srcError = PBReadSync(&srcPB);
- dstPB.ioParam.ioReqCount = srcPB.ioParam.ioActCount;
- dstError = PBWriteSync(&dstPB);
- }
-
- /* make sure there were no errors at the destination */
- if ( dstError != noErr )
- return ( dstError );
-
- /* make sure the only error at the source was eofErr */
- if ( srcError != eofErr )
- return ( srcError );
-
- return ( noErr );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetFileLocation(short refNum,
- short *vRefNum,
- long *dirID,
- StringPtr fileName)
-{
- FCBPBRec pb;
- OSErr error;
-
- pb.ioNamePtr = fileName;
- pb.ioVRefNum = 0;
- pb.ioRefNum = refNum;
- pb.ioFCBIndx = 0;
- error = PBGetFCBInfoSync(&pb);
- if ( error == noErr )
- {
- *vRefNum = pb.ioFCBVRefNum;
- *dirID = pb.ioFCBParID;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpGetFileLocation(short refNum,
- FSSpec *spec)
-{
- return ( GetFileLocation(refNum, &(spec->vRefNum), &(spec->parID), spec->name) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr CopyDirectoryAccess(short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName)
-{
- OSErr error;
- GetVolParmsInfoBuffer infoBuffer; /* Where PBGetVolParms dumps its info */
- long dstServerAdr; /* AppleTalk server address of destination (if any) */
- long ownerID, groupID, accessRights;
- long tempLong;
-
- /* See if destination supports directory access control */
- tempLong = sizeof(infoBuffer);
- error = HGetVolParms(dstName, dstVRefNum, &infoBuffer, &tempLong);
- if ( (error == noErr) && hasAccessCntl(&infoBuffer) )
- {
- if ( hasAccessCntl(&infoBuffer) )
- {
- dstServerAdr = infoBuffer.vMServerAdr;
-
- /* See if source supports directory access control and is on same server */
- tempLong = sizeof(infoBuffer);
- error = HGetVolParms(srcName, srcVRefNum, &infoBuffer, &tempLong);
- if ( error == noErr )
- {
- if ( hasAccessCntl(&infoBuffer) && (dstServerAdr == infoBuffer.vMServerAdr) )
- {
- /* both volumes support directory access control and they are */
- /* on same server, so copy the access information */
- error = HGetDirAccess(srcVRefNum, srcDirID, srcName, &ownerID, &groupID, &accessRights);
- if ( error == noErr )
- {
- error = HSetDirAccess(dstVRefNum, dstDirID, dstName, ownerID, groupID, accessRights);
- }
- }
- else
- {
- /* destination doesn't support directory access control or */
- /* they volumes aren't on the same server */
- error = paramErr;
- }
- }
- }
- else
- {
- /* destination doesn't support directory access control */
- error = paramErr;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpCopyDirectoryAccess(const FSSpec *srcSpec,
- const FSSpec *dstSpec)
-{
- return ( CopyDirectoryAccess(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->vRefNum, dstSpec->parID, dstSpec->name) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr HMoveRenameCompat(short vRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- long dstDirID,
- ConstStr255Param dstpathName,
- ConstStr255Param copyName)
-{
- OSErr error;
- GetVolParmsInfoBuffer volParmsInfo;
- long infoSize;
- short realVRefNum;
- long realParID;
- Str31 realName;
- Boolean isDirectory;
- long tempItemsDirID;
- long uniqueTempDirID;
- Str31 uniqueTempDirName;
- unsigned short uniqueNameoverflow;
-
- /* Get volume attributes */
- infoSize = sizeof(GetVolParmsInfoBuffer);
- error = HGetVolParms((StringPtr)srcName, vRefNum, &volParmsInfo, &infoSize);
- if ( (error == noErr) && hasMoveRename(&volParmsInfo) )
- {
- /* If volume supports move and rename, so use it and return */
- error = HMoveRename(vRefNum, srcDirID, srcName, dstDirID, dstpathName, copyName);
- }
- else if ( (error == noErr) || (error == paramErr) ) /* paramErr is OK, it just means this volume doesn't support GetVolParms */
- {
- /* MoveRename isn't supported by this volume, so do it by hand */
-
- /* If copyName isn't supplied, we can simply CatMove and return */
- if ( copyName == NULL )
- {
- error = CatMove(vRefNum, srcDirID, srcName, dstDirID, dstpathName);
- }
- else
- {
- /* Renaming is required, so we have some work to do... */
-
- /* Get the object's real name, real parent ID and real vRefNum */
- error = GetObjectLocation(vRefNum, srcDirID, (StringPtr)srcName,
- &realVRefNum, &realParID, realName, &isDirectory);
- if ( error == noErr )
- {
- /* Find the Temporary Items Folder on that volume */
- error = FindFolder(realVRefNum, kTemporaryFolderType, kCreateFolder,
- &realVRefNum, &tempItemsDirID);
- if ( error == noErr )
- {
- /* Create a new uniquely named folder in the temporary items folder. */
- /* This is done to avoid the case where 'realName' or 'copyName' already */
- /* exists in the temporary items folder. */
-
- /* Start with current tick count as uniqueTempDirName */
- NumToString(TickCount(), uniqueTempDirName);
- uniqueNameoverflow = 0;
- do
- {
- error = DirCreate(realVRefNum, tempItemsDirID, uniqueTempDirName, &uniqueTempDirID);
- if ( error == dupFNErr )
- {
- /* Duplicate name - change the first character to the next ASCII character */
- ++uniqueTempDirName[1];
- /* Make sure it isn't a colon! */
- if ( uniqueTempDirName[1] == ':' )
- {
- ++uniqueTempDirName[1];
- }
- /* Don't go too far... */
- ++uniqueNameoverflow;
- }
- } while ( (error == dupFNErr) && (uniqueNameoverflow <= 64) ); /* 64 new files per 1/60th second - not likely! */
- if ( error == noErr )
- {
- /* Move the object to the folder with uniqueTempDirID for renaming */
- error = CatMove(realVRefNum, realParID, realName, uniqueTempDirID, NULL);
- if ( error == noErr )
- {
- /* Rename the object */
- error = HRename(realVRefNum, uniqueTempDirID, realName, copyName);
- if ( error == noErr )
- {
- /* Move object to its new home */
- error = CatMove(realVRefNum, uniqueTempDirID, copyName, dstDirID, dstpathName);
- if ( error != noErr )
- {
- /* Error handling: rename object back to original name - ignore errors */
- (void) HRename(realVRefNum, uniqueTempDirID, copyName, realName);
- }
- }
- if ( error != noErr )
- {
- /* Error handling: move object back to original location - ignore errors */
- (void) CatMove(realVRefNum, uniqueTempDirID, realName, realParID, NULL);
- }
- }
- /* Done with ourTempDir, so delete it - ignore errors */
- (void) HDelete(realVRefNum, uniqueTempDirID, NULL);
- }
- }
- }
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr FSpMoveRenameCompat(const FSSpec *srcSpec,
- const FSSpec *dstSpec,
- ConstStr255Param copyName)
-{
- /* make sure the FSSpecs refer to the same volume */
- if (srcSpec->vRefNum != dstSpec->vRefNum)
- return (diffVolErr);
- return ( HMoveRenameCompat(srcSpec->vRefNum, srcSpec->parID, srcSpec->name,
- dstSpec->parID, dstSpec->name, copyName) );
-}
-
-/*****************************************************************************/
-
-pascal OSErr BuildAFPVolMountInfo(short flags,
- char nbpInterval,
- char nbpCount,
- short uamType,
- Str32 zoneName,
- Str32 serverName,
- Str27 volName,
- Str31 userName,
- Str8 userPassword,
- Str8 volPassword,
- AFPVolMountInfoPtr *afpInfoPtr)
-{
- MyAFPVolMountInfoPtr infoPtr;
- OSErr error;
-
- /* Allocate the AFPXVolMountInfo record */
- infoPtr = (MyAFPVolMountInfoPtr)NewPtrClear(sizeof(MyAFPVolMountInfo));
- if ( infoPtr != NULL )
- {
- /* Fill in an AFPVolMountInfo record that can be passed to VolumeMount */
- infoPtr->length = sizeof(MyAFPVolMountInfo);
- infoPtr->media = AppleShareMediaType;
- infoPtr->flags = flags;
- infoPtr->nbpInterval = nbpInterval;
- infoPtr->nbpCount = nbpCount;
- infoPtr->uamType = uamType;
-
- infoPtr->zoneNameOffset = offsetof(MyAFPVolMountInfo, zoneName);
- infoPtr->serverNameOffset = offsetof(MyAFPVolMountInfo, serverName);
- infoPtr->volNameOffset = offsetof(MyAFPVolMountInfo, volName);
- infoPtr->userNameOffset = offsetof(MyAFPVolMountInfo, userName);
- infoPtr->userPasswordOffset = offsetof(MyAFPVolMountInfo, userPassword);
- infoPtr->volPasswordOffset = offsetof(MyAFPVolMountInfo, volPassword);
-
- BlockMoveData(zoneName, infoPtr->zoneName, sizeof(Str32));
- BlockMoveData(serverName, infoPtr->serverName, sizeof(Str32));
- BlockMoveData(volName, infoPtr->volName, sizeof(Str27));
- BlockMoveData(userName, infoPtr->userName, sizeof(Str31));
- BlockMoveData(userPassword, infoPtr->userPassword, sizeof(Str8));
- BlockMoveData(volPassword, infoPtr->volPassword, sizeof(Str8));
-
- *afpInfoPtr = (AFPVolMountInfoPtr)infoPtr;
- error = noErr;
- }
- else
- {
- error = memFullErr;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr RetrieveAFPVolMountInfo(AFPVolMountInfoPtr afpInfoPtr,
- short *flags,
- short *uamType,
- StringPtr zoneName,
- StringPtr serverName,
- StringPtr volName,
- StringPtr userName)
-{
- StringPtr tempPtr;
- OSErr error;
-
- /* Retrieve the AFP mounting information from an AFPVolMountInfo record. */
- if ( afpInfoPtr->media == AppleShareMediaType )
- {
- *flags = afpInfoPtr->flags;
- *uamType = afpInfoPtr->uamType;
-
- if ( afpInfoPtr->zoneNameOffset != 0)
- {
- tempPtr = (StringPtr)((long)afpInfoPtr + afpInfoPtr->zoneNameOffset);
- BlockMoveData(tempPtr, zoneName, tempPtr[0] + 1);
- }
-
- if ( afpInfoPtr->serverNameOffset != 0)
- {
- tempPtr = (StringPtr)((long)afpInfoPtr + afpInfoPtr->serverNameOffset);
- BlockMoveData(tempPtr, serverName, tempPtr[0] + 1);
- }
-
- if ( afpInfoPtr->volNameOffset != 0)
- {
- tempPtr = (StringPtr)((long)afpInfoPtr + afpInfoPtr->volNameOffset);
- BlockMoveData(tempPtr, volName, tempPtr[0] + 1);
- }
-
- if ( afpInfoPtr->userNameOffset != 0)
- {
- tempPtr = (StringPtr)((long)afpInfoPtr + afpInfoPtr->userNameOffset);
- BlockMoveData(tempPtr, userName, tempPtr[0] + 1);
- }
-
- error = noErr;
- }
- else
- {
- error = paramErr;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr BuildAFPXVolMountInfo(short flags,
- char nbpInterval,
- char nbpCount,
- short uamType,
- Str32 zoneName,
- Str32 serverName,
- Str27 volName,
- Str31 userName,
- Str8 userPassword,
- Str8 volPassword,
- Str32 uamName,
- unsigned long alternateAddressLength,
- void *alternateAddress,
- AFPXVolMountInfoPtr *afpXInfoPtr)
-{
- Size infoSize;
- MyAFPXVolMountInfoPtr infoPtr;
- OSErr error;
-
- /* Calculate the size of the AFPXVolMountInfo record */
- infoSize = sizeof(MyAFPXVolMountInfo) + alternateAddressLength - 1;
-
- /* Allocate the AFPXVolMountInfo record */
- infoPtr = (MyAFPXVolMountInfoPtr)NewPtrClear(infoSize);
- if ( infoPtr != NULL )
- {
- /* Fill in an AFPXVolMountInfo record that can be passed to VolumeMount */
- infoPtr->length = infoSize;
- infoPtr->media = AppleShareMediaType;
- infoPtr->flags = flags;
- if ( alternateAddressLength != 0 )
- {
- /* make sure the volMountExtendedFlagsBit is set if there's extended address info */
- infoPtr->flags |= volMountExtendedFlagsMask;
- /* and set the only extendedFlags bit we know about */
- infoPtr->extendedFlags = kAFPExtendedFlagsAlternateAddressMask;
- }
- else
- {
- /* make sure the volMountExtendedFlagsBit is clear if there's no extended address info */
- infoPtr->flags &= ~volMountExtendedFlagsMask;
- /* and clear the extendedFlags */
- infoPtr->extendedFlags = 0;
- }
- infoPtr->nbpInterval = nbpInterval;
- infoPtr->nbpCount = nbpCount;
- infoPtr->uamType = uamType;
-
- infoPtr->zoneNameOffset = offsetof(MyAFPXVolMountInfo, zoneName);
- infoPtr->serverNameOffset = offsetof(MyAFPXVolMountInfo, serverName);
- infoPtr->volNameOffset = offsetof(MyAFPXVolMountInfo, volName);
- infoPtr->userNameOffset = offsetof(MyAFPXVolMountInfo, userName);
- infoPtr->userPasswordOffset = offsetof(MyAFPXVolMountInfo, userPassword);
- infoPtr->volPasswordOffset = offsetof(MyAFPXVolMountInfo, volPassword);
- infoPtr->uamNameOffset = offsetof(MyAFPXVolMountInfo, uamName);
- infoPtr->alternateAddressOffset = offsetof(MyAFPXVolMountInfo, alternateAddress);
-
- BlockMoveData(zoneName, infoPtr->zoneName, sizeof(Str32));
- BlockMoveData(serverName, infoPtr->serverName, sizeof(Str32));
- BlockMoveData(volName, infoPtr->volName, sizeof(Str27));
- BlockMoveData(userName, infoPtr->userName, sizeof(Str31));
- BlockMoveData(userPassword, infoPtr->userPassword, sizeof(Str8));
- BlockMoveData(volPassword, infoPtr->volPassword, sizeof(Str8));
- BlockMoveData(uamName, infoPtr->uamName, sizeof(Str32));
- BlockMoveData(alternateAddress, infoPtr->alternateAddress, alternateAddressLength);
-
- *afpXInfoPtr = (AFPXVolMountInfoPtr)infoPtr;
- error = noErr;
- }
- else
- {
- error = memFullErr;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr RetrieveAFPXVolMountInfo(AFPXVolMountInfoPtr afpXInfoPtr,
- short *flags,
- short *uamType,
- StringPtr zoneName,
- StringPtr serverName,
- StringPtr volName,
- StringPtr userName,
- StringPtr uamName,
- unsigned long *alternateAddressLength,
- AFPAlternateAddress **alternateAddress)
-{
- StringPtr tempPtr;
- Ptr alternateAddressStart;
- Ptr alternateAddressEnd;
- Size alternateAddressDataSize;
- OSErr error;
- UInt8 addressCount;
-
- /* Retrieve the AFP mounting information from an AFPVolMountInfo record. */
- if ( afpXInfoPtr->media == AppleShareMediaType )
- {
- /* default to noErr */
- error = noErr;
-
- /* Is this an extended record? */
- if ( (afpXInfoPtr->flags & volMountExtendedFlagsMask) != 0 )
- {
- if ( ((afpXInfoPtr->extendedFlags & kAFPExtendedFlagsAlternateAddressMask) != 0) &&
- (afpXInfoPtr->alternateAddressOffset != 0) )
- {
-
- alternateAddressStart = (Ptr)((long)afpXInfoPtr + afpXInfoPtr->alternateAddressOffset);
- alternateAddressEnd = alternateAddressStart + 1; /* skip over alternate address version byte */
- addressCount = *(UInt8*)alternateAddressEnd; /* get the address count */
- ++alternateAddressEnd; /* skip over alternate address count byte */
- /* alternateAddressEnd now equals &AFPAlternateAddress.fAddressList[0] */
- while ( addressCount != 0 )
- {
- /* parse the address list to find the end */
- alternateAddressEnd += *(UInt8*)alternateAddressEnd; /* add length of each AFPTagData record */
- --addressCount;
- }
- /* get the size of the alternateAddressData */
- alternateAddressDataSize = alternateAddressEnd - alternateAddressStart;
- /* allocate memory for it */
- *alternateAddress = (AFPAlternateAddress *)NewPtr(alternateAddressDataSize);
- if ( *alternateAddress != NULL )
- {
- /* and return the data */
- BlockMoveData(alternateAddressStart, *alternateAddress, alternateAddressDataSize);
- *alternateAddressLength = alternateAddressDataSize;
- }
- else
- {
- /* no memory - fail now */
- error = memFullErr;
- }
- }
-
- if ( error == noErr ) /* fill in more output parameters if everything is OK */
- {
- if ( afpXInfoPtr->uamNameOffset != 0 )
- {
- tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->uamNameOffset);
- BlockMoveData(tempPtr, uamName, tempPtr[0] + 1);
- }
- }
- }
-
- if ( error == noErr ) /* fill in more output parameters if everything is OK */
- {
- *flags = afpXInfoPtr->flags;
- *uamType = afpXInfoPtr->uamType;
-
- if ( afpXInfoPtr->zoneNameOffset != 0 )
- {
- tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->zoneNameOffset);
- BlockMoveData(tempPtr, zoneName, tempPtr[0] + 1);
- }
-
- if ( afpXInfoPtr->serverNameOffset != 0 )
- {
- tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->serverNameOffset);
- BlockMoveData(tempPtr, serverName, tempPtr[0] + 1);
- }
-
- if ( afpXInfoPtr->volNameOffset != 0 )
- {
- tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->volNameOffset);
- BlockMoveData(tempPtr, volName, tempPtr[0] + 1);
- }
-
- if ( afpXInfoPtr->userNameOffset != 0 )
- {
- tempPtr = (StringPtr)((long)afpXInfoPtr + afpXInfoPtr->userNameOffset);
- BlockMoveData(tempPtr, userName, tempPtr[0] + 1);
- }
- }
- }
- else
- {
- error = paramErr;
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr GetUGEntries(short objType,
- UGEntryPtr entries,
- long reqEntryCount,
- long *actEntryCount,
- long *objID)
-{
- HParamBlockRec pb;
- OSErr error = noErr;
- UGEntry *endEntryArray;
-
- pb.objParam.ioObjType = objType;
- *actEntryCount = 0;
- for ( endEntryArray = entries + reqEntryCount; (entries < endEntryArray) && (error == noErr); ++entries )
- {
- pb.objParam.ioObjNamePtr = (StringPtr)entries->name;
- pb.objParam.ioObjID = *objID;
- /* Files.h in the universal interfaces, PBGetUGEntrySync takes a CMovePBPtr */
- /* as the parameter. Inside Macintosh and the original glue used HParmBlkPtr. */
- /* A CMovePBPtr works OK, but this will be changed in the future back to */
- /* HParmBlkPtr, so I'm just casting it here. */
- error = PBGetUGEntrySync(&pb);
- if ( error == noErr )
- {
- entries->objID = *objID = pb.objParam.ioObjID;
- entries->objType = objType;
- ++*actEntryCount;
- }
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
+++ /dev/null
-/*
- File: MoreFilesExtras.h
-
- Contains: A collection of useful high-level File Manager routines.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-#ifndef __MOREFILESEXTRAS__
-#define __MOREFILESEXTRAS__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-/*
-** Bit masks and macros to get common information out of ioACUser returned
-** by PBGetCatInfo (remember to clear ioACUser before calling PBGetCatInfo
-** since some file systems don't bother to set this field).
-**
-** Use the GetDirAccessRestrictions or FSpGetDirAccessRestrictions
-** functions to retrieve the ioACUser access restrictions byte for
-** a folder.
-**
-** Note: The access restriction byte returned by PBGetCatInfo is the
-** 2's complement of the user's privileges byte returned in
-** ioACAccess by PBHGetDirAccess.
-*/
-
-enum {
- /* mask for just the access restriction bits */
- acUserAccessMask = (kioACUserNoSeeFolderMask + kioACUserNoSeeFilesMask + kioACUserNoMakeChangesMask), /* common access privilege settings */
- acUserFull = 0x00, /* no access restiction bits on */
- acUserNone = acUserAccessMask, /* all access restiction bits on */
- acUserDropBox = kioACUserNoSeeFolderMask + kioACUserNoSeeFilesMask, /* make changes, but not see files or folders */
- acUserBulletinBoard = kioACUserNoMakeChangesMask /* see files and folders, but not make changes */
-};
-
-
-/*****************************************************************************/
-
-/*
-** Deny mode permissions for use with the HOpenAware, HOpenRFAware,
-** FSpOpenAware, and FSpOpenRFAware functions.
-** Note: Common settings are the ones with comments.
-*/
-
-enum {
- dmNone = 0x0000,
- dmNoneDenyRd = fsRdDenyPerm,
- dmNoneDenyWr = fsWrDenyPerm,
- dmNoneDenyRdWr = (fsRdDenyPerm + fsWrDenyPerm),
- dmRd = fsRdPerm, /* Single writer, multiple readers; the readers */
- dmRdDenyRd = (fsRdPerm + fsRdDenyPerm),
- dmRdDenyWr = (fsRdPerm + fsWrDenyPerm), /* Browsing - equivalent to fsRdPerm */
- dmRdDenyRdWr = (fsRdPerm + fsRdDenyPerm + fsWrDenyPerm),
- dmWr = fsWrPerm,
- dmWrDenyRd = (fsWrPerm + fsRdDenyPerm),
- dmWrDenyWr = (fsWrPerm + fsWrDenyPerm),
- dmWrDenyRdWr = (fsWrPerm + fsRdDenyPerm + fsWrDenyPerm),
- dmRdWr = fsRdWrPerm, /* Shared access - equivalent to fsRdWrShPerm */
- dmRdWrDenyRd = (fsRdWrPerm + fsRdDenyPerm),
- dmRdWrDenyWr = (fsRdWrPerm + fsWrDenyPerm), /* Single writer, multiple readers; the writer */
- dmRdWrDenyRdWr = (fsRdWrPerm + fsRdDenyPerm + fsWrDenyPerm) /* Exclusive access - equivalent to fsRdWrPerm */
-};
-
-
-/*****************************************************************************/
-
-/*
-** For those times where you need to use more than one kind of File Manager parameter
-** block but don't feel like wasting stack space, here's a parameter block you can reuse.
-*/
-
-
-union UniversalFMPB {
- ParamBlockRec PB;
- CInfoPBRec ciPB;
- DTPBRec dtPB;
- HParamBlockRec hPB;
- CMovePBRec cmPB;
- WDPBRec wdPB;
- FCBPBRec fcbPB;
- XVolumeParam xPB;
-};
-typedef union UniversalFMPB UniversalFMPB;
-typedef UniversalFMPB * UniversalFMPBPtr;
-typedef UniversalFMPBPtr * UniversalFMPBHandle;
-
-/*
-** Used by GetUGEntries to return user or group lists
-*/
-
-struct UGEntry {
- short objType; /* object type: -1 = group; 0 = user */
- long objID; /* the user or group ID */
- Str31 name; /* the user or group name */
-};
-typedef struct UGEntry UGEntry;
-typedef UGEntry * UGEntryPtr;
-typedef UGEntryPtr * UGEntryHandle;
-
-/*
-** I use the following records instead of the AFPVolMountInfo and AFPXVolMountInfo structures in Files.h
-*/
-typedef unsigned char Str8[9];
-
-struct MyAFPVolMountInfo {
- short length; /* length of this record */
- VolumeType media; /* type of media, always AppleShareMediaType */
- short flags; /* 0 = normal mount; set bit 0 to inhibit greeting messages */
- char nbpInterval; /* NBP interval parameter; 7 is a good choice */
- char nbpCount; /* NBP count parameter; 5 is a good choice */
- short uamType; /* User Authentication Method */
- short zoneNameOffset; /* offset from start of record to zoneName */
- short serverNameOffset; /* offset from start of record to serverName */
- short volNameOffset; /* offset from start of record to volName */
- short userNameOffset; /* offset from start of record to userName */
- short userPasswordOffset; /* offset from start of record to userPassword */
- short volPasswordOffset; /* offset from start of record to volPassword */
- Str32 zoneName; /* server's AppleTalk zone name */
- char filler1; /* to word align volPassword */
- Str32 serverName; /* server name */
- char filler2; /* to word align volPassword */
- Str27 volName; /* volume name */
- Str31 userName; /* user name (zero length Pascal string for guest) */
- Str8 userPassword; /* user password (zero length Pascal string if no user password) */
- char filler3; /* to word align volPassword */
- Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */
- char filler4; /* to end record on word boundry */
-};
-typedef struct MyAFPVolMountInfo MyAFPVolMountInfo;
-typedef MyAFPVolMountInfo * MyAFPVolMountInfoPtr;
-typedef MyAFPVolMountInfoPtr * MyAFPVolMountInfoHandle;
-
-struct MyAFPXVolMountInfo {
- short length; /* length of this record */
- VolumeType media; /* type of media, always AppleShareMediaType */
- short flags; /* bits for no messages, no reconnect, etc */
- char nbpInterval; /* NBP interval parameter; 7 is a good choice */
- char nbpCount; /* NBP count parameter; 5 is a good choice */
- short uamType; /* User Authentication Method */
- short zoneNameOffset; /* offset from start of record to zoneName */
- short serverNameOffset; /* offset from start of record to serverName */
- short volNameOffset; /* offset from start of record to volName */
- short userNameOffset; /* offset from start of record to userName */
- short userPasswordOffset; /* offset from start of record to userPassword */
- short volPasswordOffset; /* offset from start of record to volPassword */
- short extendedFlags; /* extended flags word */
- short uamNameOffset; /* offset to a pascal UAM name string */
- short alternateAddressOffset; /* offset to Alternate Addresses in tagged format */
- Str32 zoneName; /* server's AppleTalk zone name */
- char filler1; /* to word align volPassword */
- Str32 serverName; /* server name */
- char filler2; /* to word align volPassword */
- Str27 volName; /* volume name */
- Str31 userName; /* user name (zero length Pascal string for guest) */
- Str8 userPassword; /* user password (zero length Pascal string if no user password) */
- char filler3; /* to word align volPassword */
- Str8 volPassword; /* volume password (zero length Pascal string if no volume password) */
- char filler4; /* to word align uamNameOffset */
- Str32 uamName; /* UAM name */
- char filler5; /* to word align alternateAddress */
- char alternateAddress[1]; /* AFPAlternateAddress */
-};
-typedef struct MyAFPXVolMountInfo MyAFPXVolMountInfo;
-typedef MyAFPXVolMountInfo * MyAFPXVolMountInfoPtr;
-typedef MyAFPXVolMountInfoPtr * MyAFPXVolMountInfoHandle;
-
-/*****************************************************************************/
-
-/* Functions to get information out of GetVolParmsInfoBuffer. */
-
-/* version 1 field getters */
-
-EXTERN_API( short )
-GetVolParmsInfoVersion(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( long )
-GetVolParmsInfoAttrib(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Handle )
-GetVolParmsInfoLocalHand(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( long )
-GetVolParmsInfoServerAdr(const GetVolParmsInfoBuffer * volParms);
-
-
-
-/* version 2 field getters (assume zero result if version < 2) */
-
-EXTERN_API( long )
-GetVolParmsInfoVolumeGrade(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( long )
-GetVolParmsInfoForeignPrivID(const GetVolParmsInfoBuffer * volParms);
-
-
-
-/* version 3 field getters (assume zero result if version < 3) */
-
-EXTERN_API( long )
-GetVolParmsInfoExtendedAttributes(const GetVolParmsInfoBuffer * volParms);
-
-
-
-/* attribute bits supported by all versions of GetVolParmsInfoBuffer */
-
-EXTERN_API( Boolean )
-isNetworkVolume(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasLimitFCBs(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasLocalWList(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasNoMiniFndr(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasNoVNEdit(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasNoLclSync(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasTrshOffLine(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasNoSwitchTo(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasNoDeskItems(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasNoBootBlks(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasAccessCntl(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasNoSysDir(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasExtFSVol(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasOpenDeny(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasCopyFile(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasMoveRename(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasDesktopMgr(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasShortName(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasFolderLock(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasPersonalAccessPrivileges(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasUserGroupList(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasCatSearch(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasFileIDs(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasBTreeMgr(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-hasBlankAccessPrivileges(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-supportsAsyncRequests(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-supportsTrashVolumeCache(const GetVolParmsInfoBuffer * volParms);
-
-
-
-/* attribute bits supported by version 3 and greater versions of GetVolParmsInfoBuffer */
-
-EXTERN_API( Boolean )
-volIsEjectable(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volSupportsHFSPlusAPIs(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volSupportsFSCatalogSearch(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volSupportsFSExchangeObjects(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volSupports2TBFiles(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volSupportsLongNames(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volSupportsMultiScriptNames(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volSupportsNamedForks(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volSupportsSubtreeIterators(const GetVolParmsInfoBuffer * volParms);
-
-
-EXTERN_API( Boolean )
-volL2PCanMapFileBlocks(const GetVolParmsInfoBuffer * volParms);
-
-
-
-/*****************************************************************************/
-
-/* Functions for testing ioACUser bits. */
-
-EXTERN_API( Boolean )
-userIsOwner(SInt8 ioACUser);
-
-
-EXTERN_API( Boolean )
-userHasFullAccess(SInt8 ioACUser);
-
-
-EXTERN_API( Boolean )
-userHasDropBoxAccess(SInt8 ioACUser);
-
-
-EXTERN_API( Boolean )
-userHasBulletinBoard(SInt8 ioACUser);
-
-
-EXTERN_API( Boolean )
-userHasNoAccess(SInt8 ioACUser);
-
-
-
-/*****************************************************************************/
-
-EXTERN_API( void )
-TruncPString(
- StringPtr destination,
- ConstStr255Param source,
- short maxLength);
-
-
-/*
- The TruncPString function copies up to maxLength characters from
- the source Pascal string to the destination Pascal string. TruncPString
- ensures that the truncated string ends on a single-byte character, or on
- the last byte of a multi-byte character.
-
- destination output: destination Pascal string.
- source input: source Pascal string.
- maxLength output: The maximum allowable length of the destination
- string.
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( Ptr )
-GetTempBuffer(
- long buffReqSize,
- long * buffActSize);
-
-
-/*
- The GetTempBuffer function allocates a temporary buffer for file system
- operations which is at least 1024 bytes (1K) and a multiple of
- 1024 bytes.
-
- buffReqSize input: Size you'd like the buffer to be.
- buffActSize output: Size of buffer allocated.
- function result output: Pointer to memory allocated or nil if no memory
- was available. The caller is responsible for
- disposing of this buffer with DisposePtr.
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetVolumeInfoNoName(
- ConstStr255Param pathname,
- short vRefNum,
- HParmBlkPtr pb);
-
-
-/*
- GetVolumeInfoNoName uses pathname and vRefNum to call PBHGetVInfoSync
- in cases where the returned volume name is not needed by the caller.
- The pathname and vRefNum parameters are not touched, and the pb
- parameter is initialized by PBHGetVInfoSync except that ioNamePtr in
- the parameter block is always returned as NULL (since it might point
- to GetVolumeInfoNoName's local variable tempPathname).
-
- I noticed using this code in several places, so here it is once.
- This reduces the code size of MoreFiles.
-
- pathName input: Pointer to a full pathname or nil. If you pass in a
- partial pathname, it is ignored. A full pathname to a
- volume must end with a colon character (:).
- vRefNum input: Volume specification (volume reference number, working
- directory number, drive number, or 0).
- pb input: A pointer to HParamBlockRec.
- output: The parameter block as filled in by PBHGetVInfoSync
- except that ioNamePtr will always be NULL.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume, or pb was NULL
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-XGetVolumeInfoNoName(
- ConstStr255Param pathname,
- short vRefNum,
- XVolumeParamPtr pb);
-
-
-/*
- XGetVolumeInfoNoName uses pathname and vRefNum to call PBXGetVolInfoSync
- in cases where the returned volume name is not needed by the caller.
- The pathname and vRefNum parameters are not touched, and the pb
- parameter is initialized by PBXGetVolInfoSync except that ioNamePtr in
- the parameter block is always returned as NULL (since it might point
- to XGetVolumeInfoNoName's local variable tempPathname).
-
- pathName input: Pointer to a full pathname or nil. If you pass in a
- partial pathname, it is ignored. A full pathname to a
- volume must end with a colon character (:).
- vRefNum input: Volume specification (volume reference number, working
- directory number, drive number, or 0).
- pb input: A pointer to HParamBlockRec.
- output: The parameter block as filled in by PBXGetVolInfoSync
- except that ioNamePtr will always be NULL.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume, or pb was NULL
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetCatInfoNoName(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- CInfoPBPtr pb);
-
-
-/*
- GetCatInfoNoName uses vRefNum, dirID and name to call PBGetCatInfoSync
- in cases where the returned object is not needed by the caller.
- The vRefNum, dirID and name parameters are not touched, and the pb
- parameter is initialized by PBGetCatInfoSync except that ioNamePtr in
- the parameter block is always returned as NULL (since it might point
- to GetCatInfoNoName's local variable tempName).
-
- I noticed using this code in several places, so here it is once.
- This reduces the code size of MoreFiles.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- pb input: A pointer to CInfoPBRec.
- output: The parameter block as filled in by
- PBGetCatInfoSync except that ioNamePtr will
- always be NULL.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DetermineVRefNum(
- ConstStr255Param pathname,
- short vRefNum,
- short * realVRefNum);
-
-
-/*
- The DetermineVRefNum function determines the volume reference number of
- a volume from a pathname, a volume specification, or a combination
- of the two.
- WARNING: Volume names on the Macintosh are *not* unique -- Multiple
- mounted volumes can have the same name. For this reason, the use of a
- volume name or full pathname to identify a specific volume may not
- produce the results you expect. If more than one volume has the same
- name and a volume name or full pathname is used, the File Manager
- currently uses the first volume it finds with a matching name in the
- volume queue.
-
- pathName input: Pointer to a full pathname or nil. If you pass in a
- partial pathname, it is ignored. A full pathname to a
- volume must end with a colon character (:).
- vRefNum input: Volume specification (volume reference number, working
- directory number, drive number, or 0).
- realVRefNum output: The real volume reference number.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HGetVInfo(
- short volReference,
- StringPtr volName,
- short * vRefNum,
- unsigned long * freeBytes,
- unsigned long * totalBytes);
-
-
-/*
- The HGetVInfo function returns the name, volume reference number,
- available space (in bytes), and total space (in bytes) for the
- specified volume. You can specify the volume by providing its drive
- number, volume reference number, or 0 for the default volume.
- This routine is compatible with volumes up to 4 gigabytes.
-
- volReference input: The drive number, volume reference number,
- or 0 for the default volume.
- volName input: A pointer to a buffer (minimum Str27) where
- the volume name is to be returned or must
- be nil.
- output: The volume name.
- vRefNum output: The volume reference number.
- freeBytes output: The number of free bytes on the volume.
- freeBytes is an unsigned long value.
- totalBytes output: The total number of bytes on the volume.
- totalBytes is an unsigned long value.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume
-
- __________
-
- Also see: XGetVInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-XGetVInfo(
- short volReference,
- StringPtr volName,
- short * vRefNum,
- UInt64 * freeBytes,
- UInt64 * totalBytes);
-
-
-/*
- The XGetVInfo function returns the name, volume reference number,
- available space (in bytes), and total space (in bytes) for the
- specified volume. You can specify the volume by providing its drive
- number, volume reference number, or 0 for the default volume.
- This routine is compatible with volumes up to 2 terabytes.
-
- volReference input: The drive number, volume reference number,
- or 0 for the default volume.
- volName input: A pointer to a buffer (minimum Str27) where
- the volume name is to be returned or must
- be nil.
- output: The volume name.
- vRefNum output: The volume reference number.
- freeBytes output: The number of free bytes on the volume.
- freeBytes is an UnsignedWide value.
- totalBytes output: The total number of bytes on the volume.
- totalBytes is an UnsignedWide value.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume
-
- __________
-
- Also see: HGetVInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-CheckVolLock(
- ConstStr255Param pathname,
- short vRefNum);
-
-
-/*
- The CheckVolLock function determines if a volume is locked - either by
- hardware or by software. If CheckVolLock returns noErr, then the volume
- is not locked.
-
- pathName input: Pointer to a full pathname or nil. If you pass in a
- partial pathname, it is ignored. A full pathname to a
- volume must end with a colon character (:).
- vRefNum input: Volume specification (volume reference number, working
- directory number, drive number, or 0).
-
- Result Codes
- noErr 0 No error - volume not locked
- nsvErr -35 No such volume
- wPrErr -44 Volume locked by hardware
- vLckdErr -46 Volume locked by software
- paramErr -50 No default volume
-*/
-
-/*****************************************************************************/
-/*
-** The following routines call Mac OS routines that are not supported by
-** Carbon:
-**
-** GetDriverName
-** FindDrive
-** GetDiskBlocks
-** GetVolState
-*/
-
-#if !TARGET_API_MAC_CARBON // {
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetDriverName(
- short driverRefNum,
- Str255 driverName);
-
-
-/*
- The GetDriverName function returns a device driver's name.
-
- driverRefNum input: The driver reference number.
- driverName output: The driver's name.
-
- Result Codes
- noErr 0 No error
- badUnitErr -21 Bad driver reference number
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FindDrive(
- ConstStr255Param pathname,
- short vRefNum,
- DrvQElPtr * driveQElementPtr);
-
-
-/*
- The FindDrive function returns a pointer to a mounted volume's
- drive queue element.
-
- pathName input: Pointer to a full pathname or nil. If you
- pass in a partial pathname, it is ignored.
- A full pathname to a volume must end with
- a colon character (:).
- vRefNum input: Volume specification (volume reference
- number, working directory number, drive
- number, or 0).
- driveQElementPtr output: Pointer to a volume's drive queue element
- in the drive queue. DO NOT change the
- DrvQEl.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume
- nsDrvErr -56 No such drive
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetDiskBlocks(
- ConstStr255Param pathname,
- short vRefNum,
- unsigned long * numBlocks);
-
-
-/*
- The GetDiskBlocks function returns the number of physical disk
- blocks on a disk drive. NOTE: This is not the same as volume
- allocation blocks!
-
- pathName input: Pointer to a full pathname or nil. If you
- pass in a partial pathname, it is ignored.
- A full pathname to a volume must end with
- a colon character (:).
- vRefNum input: Volume specification (volume reference
- number, working directory number, drive
- number, or 0).
- numBlocks output: The number of physical disk blocks on the disk drive.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume, driver reference
- number is zero, ReturnFormatList
- returned zero blocks, DriveStatus
- returned an unknown value, or
- driveQElementPtr->qType is unknown
- nsDrvErr -56 No such drive
- statusErr Ð18 Driver does not respond to this
- status request
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies
- a nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetVolState(
- ConstStr255Param pathname,
- short vRefNum,
- Boolean * volumeOnline,
- Boolean * volumeEjected,
- Boolean * driveEjectable,
- Boolean * driverWantsEject);
-
-
-/*
- The GetVolState function determines if a volume is online or offline,
- if an offline volume is ejected, and if the volume's driver is
- ejectable or wants eject calls.
-
- pathName input: Pointer to a full pathname or nil.
- vRefNum input: Volume specification (volume reference number,
- working directory number, drive number, or 0).
- volumeOnline output: True if the volume is online;
- False if the volume is offline.
- volumeEjected output: True if the volume is ejected (ejected
- volumes are always offline); False if the
- volume is not ejected.
- driveEjectable output: True if the volume's drive is ejectable;
- False if the volume's drive is not ejectable.
- driverWantsEject output: True if the volume's driver wants an Eject
- request after unmount (even if the drive
- is not ejectable); False if the volume's
- driver does not need an eject request.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume, or pb was NULL
-*/
-
-/*****************************************************************************/
-
-#endif // } !TARGET_API_MAC_CARBON
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetVolFileSystemID(
- ConstStr255Param pathname,
- short vRefNum,
- short * fileSystemID);
-
-
-/*
- The GetVolFileSystemID function returned the file system ID of
- a mounted volume. The file system ID identifies the file system
- that handles requests to a particular volume. Here's a partial list
- of file system ID numbers (only Apple's file systems are listed):
- FSID File System
- ----- -----------------------------------------------------
- $0000 Macintosh HFS or MFS
- $0100 ProDOS File System
- $0101 PowerTalk Mail Enclosures
- $4147 ISO 9660 File Access (through Foreign File Access)
- $4242 High Sierra File Access (through Foreign File Access)
- $464D QuickTake File System (through Foreign File Access)
- $4953 Macintosh PC Exchange (MS-DOS)
- $4A48 Audio CD Access (through Foreign File Access)
- $4D4B Apple Photo Access (through Foreign File Access)
-
- See the Technical Note "FL 35 - Determining Which File System
- Is Active" and the "Guide to the File System Manager" for more
- information.
-
- pathName input: Pointer to a full pathname or nil. If you pass
- in a partial pathname, it is ignored. A full
- pathname to a volume must contain at least
- one colon character (:) and must not start with
- a colon character.
- vRefNum input: Volume specification (volume reference number,
- working directory number, drive number, or 0).
- fileSystemID output: The volume's file system ID.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- paramErr -50 No default volume, or pb was NULL
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-UnmountAndEject(
- ConstStr255Param pathname,
- short vRefNum);
-
-
-/*
- The UnmountAndEject function unmounts and ejects a volume. The volume
- is ejected only if it is ejectable and not already ejected.
-
- pathName input: Pointer to a full pathname or nil. If you pass in a
- partial pathname, it is ignored. A full pathname to a
- volume must end with a colon character (:).
- vRefNum input: Volume specification (volume reference number, working
- directory number, drive number, or 0).
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad volume name
- fBsyErr -47 One or more files are open
- paramErr -50 No default volume
- nsDrvErr -56 No such drive
- extFSErr -58 External file system error - no file
- system claimed this call.
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-OnLine(
- FSSpecPtr volumes,
- short reqVolCount,
- short * actVolCount,
- short * volIndex);
-
-
-/*
- The OnLine function returns the list of volumes currently mounted in
- an array of FSSpec records.
-
- A noErr result indicates that the volumes array was filled
- (actVolCount == reqVolCount) and there may be additional volumes
- mounted. A nsvErr result indicates that the end of the volume list
- was found and actVolCount volumes were actually found this time.
-
- volumes input: Pointer to array of FSSpec where the volume list
- is returned.
- reqVolCount input: Maximum number of volumes to return (the number of
- elements in the volumes array).
- actVolCount output: The number of volumes actually returned.
- volIndex input: The current volume index position. Set to 1 to
- start with the first volume.
- output: The volume index position to get the next volume.
- Pass this value the next time you call OnLine to
- start where you left off.
-
- Result Codes
- noErr 0 No error, but there are more volumes
- to list
- nsvErr -35 No more volumes to be listed
- paramErr -50 volIndex was <= 0
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-SetDefault(
- short newVRefNum,
- long newDirID,
- short * oldVRefNum,
- long * oldDirID);
-
-
-/*
- The SetDefault function sets the default volume and directory to the
- volume specified by newVRefNum and the directory specified by newDirID.
- The current default volume reference number and directory ID are
- returned in oldVRefNum and oldDir and must be used to restore the
- default volume and directory to their previous state *as soon as
- possible* with the RestoreDefault function. These two functions are
- designed to be used as a wrapper around Standard I/O routines where
- the location of the file is implied to be the default volume and
- directory. In other words, this is how you should use these functions:
-
- error = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID);
- if ( error == noErr )
- {
- // call the Stdio functions like remove, rename, tmpfile,
- // fopen, freopen, etc. or non-ANSI extensions like
- // fdopen,fsetfileinfo, -- create, open, unlink, etc. here!
-
- error = RestoreDefault(oldVRefNum, oldDirID);
- }
-
- By using these functions as a wrapper, you won't need to open a working
- directory (because SetDefault and RestoreDefault use HSetVol) and you
- won't have to worry about the effects of using HSetVol (documented in
- Technical Note "FL 11 - PBHSetVol is Dangerous" and in the
- Inside Macintosh: Files book in the description of the HSetVol and
- PBHSetVol functions) because the default volume/directory is restored
- before giving up control to code that might be affected by HSetVol.
-
- newVRefNum input: Volume specification (volume reference number,
- working directory number, drive number, or 0) of
- the new default volume.
- newDirID input: Directory ID of the new default directory.
- oldVRefNum output: The volume specification to save for use with
- RestoreDefault.
- oldDirID output: The directory ID to save for use with
- RestoreDefault.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- bdNamErr -37 Bad volume name
- fnfErr -43 Directory not found
- paramErr -50 No default volume
- afpAccessDenied -5000 User does not have access to the directory
-
- __________
-
- Also see: RestoreDefault
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-RestoreDefault(
- short oldVRefNum,
- long oldDirID);
-
-
-/*
- The RestoreDefault function restores the default volume and directory
- to the volume specified by oldVRefNum and the directory specified by
- oldDirID. The oldVRefNum and oldDirID parameters were previously
- obtained from the SetDefault function. These two functions are designed
- to be used as a wrapper around Standard C I/O routines where the
- location of the file is implied to be the default volume and directory.
- In other words, this is how you should use these functions:
-
- error = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID);
- if ( error == noErr )
- {
- // call the Stdio functions like remove, rename, tmpfile,
- // fopen, freopen, etc. or non-ANSI extensions like
- // fdopen,fsetfileinfo, -- create, open, unlink, etc. here!
-
- error = RestoreDefault(oldVRefNum, oldDirID);
- }
-
- By using these functions as a wrapper, you won't need to open a working
- directory (because SetDefault and RestoreDefault use HSetVol) and you
- won't have to worry about the effects of using HSetVol (documented in
- Technical Note "FL 11 - PBHSetVol is Dangerous" and in the
- Inside Macintosh: Files book in the description of the HSetVol and
- PBHSetVol functions) because the default volume/directory is restored
- before giving up control to code that might be affected by HSetVol.
-
- oldVRefNum input: The volume specification to restore.
- oldDirID input: The directory ID to restore.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- bdNamErr -37 Bad volume name
- fnfErr -43 Directory not found
- paramErr -50 No default volume
- rfNumErr -51 Bad working directory reference number
- afpAccessDenied -5000 User does not have access to the directory
-
- __________
-
- Also see: SetDefault
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetDInfo(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- DInfo * fndrInfo);
-
-
-/*
- The GetDInfo function gets the finder information for a directory.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- fndrInfo output: If the object is a directory, then its DInfo.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: FSpGetDInfo, FSpGetFInfoCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpGetDInfo(
- const FSSpec * spec,
- DInfo * fndrInfo);
-
-
-/*
- The FSpGetDInfo function gets the finder information for a directory.
-
- spec input: An FSSpec record specifying the directory.
- fndrInfo output: If the object is a directory, then its DInfo.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: FSpGetFInfoCompat, GetDInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-SetDInfo(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- const DInfo * fndrInfo);
-
-
-/*
- The SetDInfo function sets the finder information for a directory.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- fndrInfo input: The DInfo.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: FSpSetDInfo, FSpSetFInfoCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetDInfo(
- const FSSpec * spec,
- const DInfo * fndrInfo);
-
-
-/*
- The FSpSetDInfo function sets the finder information for a directory.
-
- spec input: An FSSpec record specifying the directory.
- fndrInfo input: The DInfo.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: FSpSetFInfoCompat, SetDInfo
-*/
-
-/*****************************************************************************/
-
-#if OLDROUTINENAMES
- #define GetDirID(vRefNum, dirID, name, theDirID, isDirectory) GetDirectoryID(vRefNum, dirID, name, theDirID, isDirectory)
-#endif
-EXTERN_API( OSErr )
-GetDirectoryID(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- long * theDirID,
- Boolean * isDirectory);
-
-
-/*
- The GetDirectoryID function gets the directory ID number of the
- directory specified. If a file is specified, then the parent
- directory of the file is returned and isDirectory is false. If
- a directory is specified, then that directory's ID number is
- returned and isDirectory is true.
- WARNING: Volume names on the Macintosh are *not* unique -- Multiple
- mounted volumes can have the same name. For this reason, the use of a
- volume name or full pathname to identify a specific volume may not
- produce the results you expect. If more than one volume has the same
- name and a volume name or full pathname is used, the File Manager
- currently uses the first volume it finds with a matching name in the
- volume queue.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- theDirID output: If the object is a file, then its parent directory
- ID. If the object is a directory, then its ID.
- isDirectory output: True if object is a directory; false if
- object is a file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-*/
-
-/*****************************************************************************/
-
-#if OLDROUTINENAMES
- #define DirIDFromFSSpec(spec, theDirID, isDirectory) FSpGetDirectoryID(spec, theDirID, isDirectory)
-#endif
-EXTERN_API( OSErr )
-FSpGetDirectoryID(
- const FSSpec * spec,
- long * theDirID,
- Boolean * isDirectory);
-
-
-/*
- The FSpGetDirectoryID function gets the directory ID number of the
- directory specified by spec. If spec is to a file, then the parent
- directory of the file is returned and isDirectory is false. If
- spec is to a directory, then that directory's ID number is
- returned and isDirectory is true.
-
- spec input: An FSSpec record specifying the directory.
- theDirID output: The directory ID.
- isDirectory output: True if object is a directory; false if
- object is a file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetDirName(
- short vRefNum,
- long dirID,
- Str31 name);
-
-
-/*
- The GetDirName function gets the name of a directory from its
- directory ID.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name output: Points to a Str31 where the directory name is to be
- returned.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume or
- name parameter was NULL
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetIOACUser(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- SInt8 * ioACUser);
-
-
-/*
- GetIOACUser returns a directory's access restrictions byte.
- Use the masks and macro defined in MoreFilesExtras to check for
- specific access priviledges.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- ioACUser output: The access restriction byte
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpGetIOACUser(
- const FSSpec * spec,
- SInt8 * ioACUser);
-
-
-/*
- FSpGetIOACUser returns a directory's access restrictions byte.
- Use the masks and macro defined in MoreFilesExtras to check for
- specific access priviledges.
-
- spec input: An FSSpec record specifying the directory.
- ioACUser output: The access restriction byte
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetParentID(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- long * parID);
-
-
-/*
- The GetParentID function gets the parent directory ID number of the
- specified object.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
- parID output: The parent directory ID of the specified object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetFilenameFromPathname(
- ConstStr255Param pathname,
- Str255 filename);
-
-
-/*
- The GetFilenameFromPathname function gets the file (or directory) name
- from the end of a full or partial pathname. Returns notAFileErr if the
- pathname is nil, the pathname is empty, or the pathname cannot refer to
- a filename (with a noErr result, the pathname could still refer to a
- directory).
-
- pathname input: A full or partial pathname.
- filename output: The file (or directory) name.
-
- Result Codes
- noErr 0 No error
- notAFileErr -1302 The pathname is nil, the pathname
- is empty, or the pathname cannot refer
- to a filename
-
- __________
-
- See also: GetObjectLocation.
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetObjectLocation(
- short vRefNum,
- long dirID,
- ConstStr255Param pathname,
- short * realVRefNum,
- long * realParID,
- Str255 realName,
- Boolean * isDirectory);
-
-
-/*
- The GetObjectLocation function gets a file system object's location -
- that is, its real volume reference number, real parent directory ID,
- and name. While we're at it, determine if the object is a file or directory.
- If GetObjectLocation returns fnfErr, then the location information
- returned is valid, but it describes an object that doesn't exist.
- You can use the location information for another operation, such as
- creating a file or directory.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- pathname input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
- realVRefNum output: The real volume reference number.
- realParID output: The parent directory ID of the specified object.
- realName output: The name of the specified object (the case of the
- object name may not be the same as the object's
- catalog entry on disk - since the Macintosh file
- system is not case sensitive, it shouldn't matter).
- isDirectory output: True if object is a directory; false if object
- is a file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- notAFileErr -1302 The pathname is nil, the pathname
- is empty, or the pathname cannot refer
- to a filename
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSMakeFSSpecCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetDirItems(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- Boolean getFiles,
- Boolean getDirectories,
- FSSpecPtr items,
- short reqItemCount,
- short * actItemCount,
- short * itemIndex);
-
-
-/*
- The GetDirItems function returns a list of items in the specified
- directory in an array of FSSpec records. File, subdirectories, or
- both can be returned in the list.
-
- A noErr result indicates that the items array was filled
- (actItemCount == reqItemCount) and there may be additional items
- left in the directory. A fnfErr result indicates that the end of
- the directory list was found and actItemCount items were actually
- found this time.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID
- specifies a directory that's the object.
- getFiles input: Pass true to have files added to the items list.
- getDirectories input: Pass true to have directories added to the
- items list.
- items input: Pointer to array of FSSpec where the item list
- is returned.
- reqItemCount input: Maximum number of items to return (the number
- of elements in the items array).
- actItemCount output: The number of items actually returned.
- itemIndex input: The current item index position. Set to 1 to
- start with the first item in the directory.
- output: The item index position to get the next item.
- Pass this value the next time you call
- GetDirItems to start where you left off.
-
- Result Codes
- noErr 0 No error, but there are more items
- to list
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found, there are no more items
- to be listed.
- paramErr -50 No default volume or itemIndex was <= 0
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DeleteDirectoryContents(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The DeleteDirectoryContents function deletes the contents of a directory.
- All files and subdirectories in the specified directory are deleted.
- If a locked file or directory is encountered, it is unlocked and then
- deleted. If any unexpected errors are encountered,
- DeleteDirectoryContents quits and returns to the caller.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Software volume lock
- fBsyErr -47 File busy, directory not empty, or working directory control block open
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: DeleteDirectory
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-DeleteDirectory(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The DeleteDirectory function deletes a directory and its contents.
- All files and subdirectories in the specified directory are deleted.
- If a locked file or directory is encountered, it is unlocked and then
- deleted. After deleting the directories contents, the directory is
- deleted. If any unexpected errors are encountered, DeleteDirectory
- quits and returns to the caller.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to directory name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Software volume lock
- fBsyErr -47 File busy, directory not empty, or working directory control block open
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: DeleteDirectoryContents
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-CheckObjectLock(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The CheckObjectLock function determines if a file or directory is locked.
- If CheckObjectLock returns noErr, then the file or directory
- is not locked. If CheckObjectLock returns fLckdErr, the it is locked.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: FSpCheckObjectLock
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpCheckObjectLock(const FSSpec * spec);
-
-
-/*
- The FSpCheckObjectLock function determines if a file or directory is locked.
- If FSpCheckObjectLock returns noErr, then the file or directory
- is not locked.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- Also see: CheckObjectLock
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetFileSize(
- short vRefNum,
- long dirID,
- ConstStr255Param fileName,
- long * dataSize,
- long * rsrcSize);
-
-
-/*
- The GetFileSize function returns the logical size of a file's
- data and resource fork.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: The name of the file.
- dataSize output: The number of bytes in the file's data fork.
- rsrcSize output: The number of bytes in the file's resource fork.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpGetFileSize
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpGetFileSize(
- const FSSpec * spec,
- long * dataSize,
- long * rsrcSize);
-
-
-/*
- The FSpGetFileSize function returns the logical size of a file's
- data and resource fork.
-
- spec input: An FSSpec record specifying the file.
- dataSize output: The number of bytes in the file's data fork.
- rsrcSize output: The number of bytes in the file's resource fork.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- paramErr -50 No default volume
- dirNFErrdirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: GetFileSize
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-BumpDate(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The BumpDate function changes the modification date of a file or
- directory to the current date/time. If the modification date is already
- equal to the current date/time, then add one second to the
- modification date.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpBumpDate
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpBumpDate(const FSSpec * spec);
-
-
-/*
- The FSpBumpDate function changes the modification date of a file or
- directory to the current date/time. If the modification date is already
- equal to the current date/time, then add one second to the
- modification date.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: BumpDate
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ChangeCreatorType(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- OSType creator,
- OSType fileType);
-
-
-/*
- The ChangeCreatorType function changes the creator or file type of a file.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: The name of the file.
- creator input: The new creator type or 0x00000000 to leave
- the creator type alone.
- fileType input: The new file type or 0x00000000 to leave the
- file type alone.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- notAFileErr -1302 Name was not a file
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpChangeCreatorType
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpChangeCreatorType(
- const FSSpec * spec,
- OSType creator,
- OSType fileType);
-
-
-/*
- The FSpChangeCreatorType function changes the creator or file type of a file.
-
- spec input: An FSSpec record specifying the file.
- creator input: The new creator type or 0x00000000 to leave
- the creator type alone.
- fileType input: The new file type or 0x00000000 to leave the
- file type alone.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- notAFileErr -1302 Name was not a file
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: ChangeCreatorType
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ChangeFDFlags(
- short vRefNum,
- long dirID,
- ConstStr255Param name,
- Boolean setBits,
- unsigned short flagBits);
-
-
-/*
- The ChangeFDFlags function sets or clears Finder Flag bits in the
- fdFlags field of a file or directory's FInfo record.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
- setBits input: If true, then set the bits specified in flagBits.
- If false, then clear the bits specified in flagBits.
- flagBits input: The flagBits parameter specifies which Finder Flag
- bits to set or clear. If a bit in flagBits is set,
- then the same bit in fdFlags is either set or
- cleared depending on the state of the setBits
- parameter.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpChangeFDFlags
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpChangeFDFlags(
- const FSSpec * spec,
- Boolean setBits,
- unsigned short flagBits);
-
-
-/*
- The FSpChangeFDFlags function sets or clears Finder Flag bits in the
- fdFlags field of a file or directory's FInfo record.
-
- spec input: An FSSpec record specifying the object.
- setBits input: If true, then set the bits specified in flagBits.
- If false, then clear the bits specified in flagBits.
- flagBits input: The flagBits parameter specifies which Finder Flag
- bits to set or clear. If a bit in flagBits is set,
- then the same bit in fdFlags is either set or
- cleared depending on the state of the setBits
- parameter.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: ChangeFDFlags
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-SetIsInvisible(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The SetIsInvisible function sets the invisible bit in the fdFlags
- word of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpSetIsInvisible, ClearIsInvisible, FSpClearIsInvisible
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetIsInvisible(const FSSpec * spec);
-
-
-/*
- The FSpSetIsInvisible function sets the invisible bit in the fdFlags
- word of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetIsInvisible, ClearIsInvisible, FSpClearIsInvisible
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ClearIsInvisible(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The ClearIsInvisible function clears the invisible bit in the fdFlags
- word of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetIsInvisible, FSpSetIsInvisible, FSpClearIsInvisible
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpClearIsInvisible(const FSSpec * spec);
-
-
-/*
- The FSpClearIsInvisible function clears the invisible bit in the fdFlags
- word of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetIsInvisible, FSpSetIsInvisible, ClearIsInvisible
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-SetNameLocked(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The SetNameLocked function sets the nameLocked bit in the fdFlags word
- of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpSetNameLocked, ClearNameLocked, FSpClearNameLocked
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetNameLocked(const FSSpec * spec);
-
-
-/*
- The FSpSetNameLocked function sets the nameLocked bit in the fdFlags word
- of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetNameLocked, ClearNameLocked, FSpClearNameLocked
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ClearNameLocked(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The ClearNameLocked function clears the nameLocked bit in the fdFlags
- word of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetNameLocked, FSpSetNameLocked, FSpClearNameLocked
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpClearNameLocked(const FSSpec * spec);
-
-
-/*
- The FSpClearNameLocked function clears the nameLocked bit in the fdFlags
- word of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetNameLocked, FSpSetNameLocked, ClearNameLocked
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-SetIsStationery(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The SetIsStationery function sets the isStationery bit in the
- fdFlags word of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpSetIsStationery, ClearIsStationery, FSpClearIsStationery
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetIsStationery(const FSSpec * spec);
-
-
-/*
- The FSpSetIsStationery function sets the isStationery bit in the
- fdFlags word of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetIsStationery, ClearIsStationery, FSpClearIsStationery
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ClearIsStationery(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The ClearIsStationery function clears the isStationery bit in the
- fdFlags word of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetIsStationery, FSpSetIsStationery, FSpClearIsStationery
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpClearIsStationery(const FSSpec * spec);
-
-
-/*
- The FSpClearIsStationery function clears the isStationery bit in the
- fdFlags word of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetIsStationery, FSpSetIsStationery, ClearIsStationery
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-SetHasCustomIcon(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The SetHasCustomIcon function sets the hasCustomIcon bit in the
- fdFlags word of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpSetHasCustomIcon, ClearHasCustomIcon, FSpClearHasCustomIcon
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpSetHasCustomIcon(const FSSpec * spec);
-
-
-/*
- The FSpSetHasCustomIcon function sets the hasCustomIcon bit in the
- fdFlags word of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetHasCustomIcon, ClearHasCustomIcon, FSpClearHasCustomIcon
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ClearHasCustomIcon(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The ClearHasCustomIcon function clears the hasCustomIcon bit in the
- fdFlags word of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetHasCustomIcon, FSpSetHasCustomIcon, FSpClearHasCustomIcon
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpClearHasCustomIcon(const FSSpec * spec);
-
-
-/*
- The FSpClearHasCustomIcon function clears the hasCustomIcon bit in the
- fdFlags word of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: SetHasCustomIcon, FSpSetHasCustomIcon, ClearHasCustomIcon
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-ClearHasBeenInited(
- short vRefNum,
- long dirID,
- ConstStr255Param name);
-
-
-/*
- The ClearHasBeenInited function clears the hasBeenInited bit in the
- fdFlags word of the specified file or directory's finder information.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- name input: Pointer to object name, or nil when dirID specifies
- a directory that's the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpClearHasBeenInited
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpClearHasBeenInited(const FSSpec * spec);
-
-
-/*
- The FSpClearHasBeenInited function clears the hasBeenInited bit in the
- fdFlags word of the specified file or directory's finder information.
-
- spec input: An FSSpec record specifying the object.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: ClearHasBeenInited
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-CopyFileMgrAttributes(
- short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName,
- Boolean copyLockBit);
-
-
-/*
- The CopyFileMgrAttributes function copies all File Manager attributes
- from the source file or directory to the destination file or directory.
- If copyLockBit is true, then set the locked state of the destination
- to match the source.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Pointer to source object name, or nil when
- srcDirID specifies a directory that's the object.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstName input: Pointer to destination object name, or nil when
- dstDirID specifies a directory that's the object.
- copyLockBit input: If true, set the locked state of the destination
- to match the source.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: FSpCopyFileMgrAttributes
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpCopyFileMgrAttributes(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec,
- Boolean copyLockBit);
-
-
-/*
- The FSpCopyFileMgrAttributes function copies all File Manager attributes
- from the source file or directory to the destination file or directory.
- If copyLockBit is true, then set the locked state of the destination
- to match the source.
-
- srcSpec input: An FSSpec record specifying the source object.
- dstSpec input: An FSSpec record specifying the destination object.
- copyLockBit input: If true, set the locked state of the destination
- to match the source.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- ioErr -36 I/O error
- bdNamErr -37 Bad filename
- fnfErr -43 File not found
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 No default volume
- dirNFErr -120 Directory not found or incomplete pathname
- afpAccessDenied -5000 User does not have the correct access
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
-
- __________
-
- See also: CopyFileMgrAttributes
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HOpenAware(
- short vRefNum,
- long dirID,
- ConstStr255Param fileName,
- short denyModes,
- short * refNum);
-
-
-/*
- The HOpenAware function opens the data fork of a file using deny mode
- permissions instead the normal File Manager permissions. If OpenDeny
- is not available, then HOpenAware translates the deny modes to the
- closest File Manager permissions and tries to open the file with
- OpenDF first, and then Open if OpenDF isn't available. By using
- HOpenAware with deny mode permissions, a program can be "AppleShare
- aware" and fall back on the standard File Manager open calls
- automatically.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- fileName input: The name of the file.
- denyModes input: The deny modes access under which to open the file.
- refNum output: The file reference number of the opened file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- tmfoErr -42 Too many files open
- fnfErr -43 File not found
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- opWrErr -49 File already open for writing
- paramErr -50 No default volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- afpAccessDenied -5000 User does not have the correct access to the file
- afpDenyConflict -5006 Requested access permission not possible
-
- __________
-
- See also: FSpOpenAware, HOpenRFAware, FSpOpenRFAware
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpOpenAware(
- const FSSpec * spec,
- short denyModes,
- short * refNum);
-
-
-/*
- The FSpOpenAware function opens the data fork of a file using deny mode
- permissions instead the normal File Manager permissions. If OpenDeny
- is not available, then FSpOpenAware translates the deny modes to the
- closest File Manager permissions and tries to open the file with
- OpenDF first, and then Open if OpenDF isn't available. By using
- FSpOpenAware with deny mode permissions, a program can be "AppleShare
- aware" and fall back on the standard File Manager open calls
- automatically.
-
- spec input: An FSSpec record specifying the file.
- denyModes input: The deny modes access under which to open the file.
- refNum output: The file reference number of the opened file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- tmfoErr -42 Too many files open
- fnfErr -43 File not found
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- opWrErr -49 File already open for writing
- paramErr -50 No default volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- afpAccessDenied -5000 User does not have the correct access to the file
- afpDenyConflict -5006 Requested access permission not possible
-
- __________
-
- See also: HOpenAware, HOpenRFAware, FSpOpenRFAware
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HOpenRFAware(
- short vRefNum,
- long dirID,
- ConstStr255Param fileName,
- short denyModes,
- short * refNum);
-
-
-/*
- The HOpenRFAware function opens the resource fork of a file using deny
- mode permissions instead the normal File Manager permissions. If
- OpenRFDeny is not available, then HOpenRFAware translates the deny
- modes to the closest File Manager permissions and tries to open the
- file with OpenRF. By using HOpenRFAware with deny mode permissions,
- a program can be "AppleShare aware" and fall back on the standard
- File Manager open calls automatically.
-
- vRefNum input: Volume specification.
- dirID input: Directory ID.
- fileName input: The name of the file.
- denyModes input: The deny modes access under which to open the file.
- refNum output: The file reference number of the opened file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- tmfoErr -42 Too many files open
- fnfErr -43 File not found
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- opWrErr -49 File already open for writing
- paramErr -50 No default volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- afpAccessDenied -5000 User does not have the correct access to the file
- afpDenyConflict -5006 Requested access permission not possible
-
- __________
-
- See also: HOpenAware, FSpOpenAware, FSpOpenRFAware
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpOpenRFAware(
- const FSSpec * spec,
- short denyModes,
- short * refNum);
-
-
-/*
- The FSpOpenRFAware function opens the resource fork of a file using deny
- mode permissions instead the normal File Manager permissions. If
- OpenRFDeny is not available, then FSpOpenRFAware translates the deny
- modes to the closest File Manager permissions and tries to open the
- file with OpenRF. By using FSpOpenRFAware with deny mode permissions,
- a program can be "AppleShare aware" and fall back on the standard
- File Manager open calls automatically.
-
- spec input: An FSSpec record specifying the file.
- denyModes input: The deny modes access under which to open the file.
- refNum output: The file reference number of the opened file.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 No such volume
- tmfoErr -42 Too many files open
- fnfErr -43 File not found
- wPrErr -44 Volume locked by hardware
- fLckdErr -45 File is locked
- vLckdErr -46 Volume is locked or read-only
- opWrErr -49 File already open for writing
- paramErr -50 No default volume
- permErr -54 File is already open and cannot be opened using specified deny modes
- afpAccessDenied -5000 User does not have the correct access to the file
- afpDenyConflict -5006 Requested access permission not possible
-
- __________
-
- See also: HOpenAware, FSpOpenAware, HOpenRFAware
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSReadNoCache(
- short refNum,
- long * count,
- void * buffPtr);
-
-
-/*
- The FSReadNoCache function reads any number of bytes from an open file
- while asking the file system to bypass its cache mechanism.
-
- refNum input: The file reference number of an open file.
- count input: The number of bytes to read.
- output: The number of bytes actually read.
- buffPtr input: A pointer to the data buffer into which the bytes are
- to be read.
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- ioErr Ð36 Data does not match in read-verify mode
- fnOpnErr -38 File not open
- rfNumErr -51 Bad reference number
- afpAccessDenied -5000 User does not have the correct access to
- the file
-
- __________
-
- See also: FSWriteNoCache
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSWriteNoCache(
- short refNum,
- long * count,
- const void * buffPtr);
-
-
-/*
- The FSReadNoCache function writes any number of bytes to an open file
- while asking the file system to bypass its cache mechanism.
-
- refNum input: The file reference number of an open file.
- count input: The number of bytes to write to the file.
- output: The number of bytes actually written.
- buffPtr input: A pointer to the data buffer from which the bytes are
- to be written.
-
- Result Codes
- noErr 0 No error
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Disk full
- ioErr Ð36 Data does not match in read-verify mode
- fnOpnErr -38 File not open
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Software volume lock
- rfNumErr -51 Bad reference number
- wrPermErr -61 Read/write permission doesnÕt
- allow writing
- afpAccessDenied -5000 User does not have the correct access to
- the file
-
- __________
-
- See also: FSReadNoCache
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSWriteVerify(
- short refNum,
- long * count,
- const void * buffPtr);
-
-
-/*
- The FSWriteVerify function writes any number of bytes to an open file
- and then verifies that the data was actually written to the device.
-
- refNum input: The file reference number of an open file.
- count input: The number of bytes to write to the file.
- output: The number of bytes actually written and verified.
- buffPtr input: A pointer to the data buffer from which the bytes are
- to be written.
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Disk full
- ioErr Ð36 Data does not match in read-verify mode
- fnOpnErr -38 File not open
- eofErr -39 Logical end-of-file reached
- posErr -40 Attempt to position mark before start
- of file
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Software volume lock
- rfNumErr -51 Bad reference number
- gfpErr -52 Error during GetFPos
- wrPermErr -61 Read/write permission doesnÕt
- allow writing
- memFullErr -108 Not enough room in heap zone to allocate
- verify buffer
- afpAccessDenied -5000 User does not have the correct access to
- the file
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-CopyFork(
- short srcRefNum,
- short dstRefNum,
- void * copyBufferPtr,
- long copyBufferSize);
-
-
-/*
- The CopyFork function copies all data from the source fork to the
- destination fork of open file forks and makes sure the destination EOF
- is equal to the source EOF.
-
- srcRefNum input: The source file reference number.
- dstRefNum input: The destination file reference number.
- copyBufferPtr input: Pointer to buffer to use during copy. The
- buffer should be at least 512-bytes minimum.
- The larger the buffer, the faster the copy.
- copyBufferSize input: The size of the copy buffer.
-
- Result Codes
- noErr 0 No error
- readErr Ð19 Driver does not respond to read requests
- writErr Ð20 Driver does not respond to write requests
- badUnitErr Ð21 Driver reference number does not
- match unit table
- unitEmptyErr Ð22 Driver reference number specifies a
- nil handle in unit table
- abortErr Ð27 Request aborted by KillIO
- notOpenErr Ð28 Driver not open
- dskFulErr -34 Disk full
- ioErr Ð36 Data does not match in read-verify mode
- fnOpnErr -38 File not open
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Software volume lock
- rfNumErr -51 Bad reference number
- wrPermErr -61 Read/write permission doesnÕt
- allow writing
- afpAccessDenied -5000 User does not have the correct access to
- the file
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetFileLocation(
- short refNum,
- short * vRefNum,
- long * dirID,
- StringPtr fileName);
-
-
-/*
- The GetFileLocation function gets the location (volume reference number,
- directory ID, and fileName) of an open file.
-
- refNum input: The file reference number of an open file.
- vRefNum output: The volume reference number.
- dirID output: The parent directory ID.
- fileName input: Points to a buffer (minimum Str63) where the
- filename is to be returned or must be nil.
- output: The filename.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Specified volume doesnÕt exist
- fnOpnErr -38 File not open
- rfNumErr -51 Reference number specifies nonexistent
- access path
-
- __________
-
- See also: FSpGetFileLocation
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpGetFileLocation(
- short refNum,
- FSSpec * spec);
-
-
-/*
- The FSpGetFileLocation function gets the location of an open file in
- an FSSpec record.
-
- refNum input: The file reference number of an open file.
- spec output: FSSpec record containing the file name and location.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Specified volume doesnÕt exist
- fnOpnErr -38 File not open
- rfNumErr -51 Reference number specifies nonexistent
- access path
-
- __________
-
- See also: GetFileLocation
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-CopyDirectoryAccess(
- short srcVRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- short dstVRefNum,
- long dstDirID,
- ConstStr255Param dstName);
-
-
-/*
- The CopyDirectoryAccess function copies the AFP directory access
- privileges from one directory to another. Both directories must be on
- the same file server, but not necessarily on the same server volume.
-
- srcVRefNum input: Source volume specification.
- srcDirID input: Source directory ID.
- srcName input: Pointer to source directory name, or nil when
- srcDirID specifies the directory.
- dstVRefNum input: Destination volume specification.
- dstDirID input: Destination directory ID.
- dstName input: Pointer to destination directory name, or nil when
- dstDirID specifies the directory.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- fnfErr -43 Directory not found
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 Volume doesn't support this function
- afpAccessDenied -5000 User does not have the correct access
- to the directory
- afpObjectTypeErr -5025 Object is a file, not a directory
-
- __________
-
- See also: FSpCopyDirectoryAccess
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpCopyDirectoryAccess(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec);
-
-
-/*
- The FSpCopyDirectoryAccess function copies the AFP directory access
- privileges from one directory to another. Both directories must be on
- the same file server, but not necessarily on the same server volume.
-
- srcSpec input: An FSSpec record specifying the source directory.
- dstSpec input: An FSSpec record specifying the destination directory.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- fnfErr -43 Directory not found
- vLckdErr -46 Volume is locked or read-only
- paramErr -50 Volume doesn't support this function
- afpAccessDenied -5000 User does not have the correct access
- to the directory
- afpObjectTypeErr -5025 Object is a file, not a directory
-
- __________
-
- See also: CopyDirectoryAccess
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-HMoveRenameCompat(
- short vRefNum,
- long srcDirID,
- ConstStr255Param srcName,
- long dstDirID,
- ConstStr255Param dstpathName,
- ConstStr255Param copyName);
-
-
-/*
- The HMoveRenameCompat function moves a file or directory and optionally
- renames it. The source and destination locations must be on the same
- volume. This routine works even if the volume doesn't support MoveRename.
-
- vRefNum input: Volume specification.
- srcDirID input: Source directory ID.
- srcName input: The source object name.
- dstDirID input: Destination directory ID.
- dstName input: Pointer to destination directory name, or
- nil when dstDirID specifies a directory.
- copyName input: Points to the new name if the object is to be
- renamed or nil if the object isn't to be renamed.
-
- Result Codes
- noErr 0 No error
- dirFulErr -33 File directory full
- dskFulErr -34 Disk is full
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- bdNamErr -37 Bad filename or attempt to move into
- a file
- fnfErr -43 Source file or directory not found
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 File busy, directory not empty, or
- working directory control block open
- dupFNErr -48 Destination already exists
- paramErr -50 Volume doesn't support this function,
- no default volume, or source and
- volOfflinErr -53 Volume is offline
- fsRnErr -59 Problem during rename
- dirNFErr -120 Directory not found or incomplete pathname
- badMovErr -122 Attempted to move directory into
- offspring
- wrgVolTypErr -123 Not an HFS volume (it's a MFS volume)
- notAFileErr -1302 The pathname is nil, the pathname
- is empty, or the pathname cannot refer
- to a filename
- diffVolErr -1303 Files on different volumes
- afpAccessDenied -5000 The user does not have the right to
- move the file or directory
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
- afpSameObjectErr -5038 Source and destination files are the same
-
- __________
-
- See also: FSpMoveRenameCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-FSpMoveRenameCompat(
- const FSSpec * srcSpec,
- const FSSpec * dstSpec,
- ConstStr255Param copyName);
-
-
-/*
- The FSpMoveRenameCompat function moves a file or directory and optionally
- renames it. The source and destination locations must be on the same
- volume. This routine works even if the volume doesn't support MoveRename.
-
- srcSpec input: An FSSpec record specifying the source object.
- dstSpec input: An FSSpec record specifying the destination
- directory.
- copyName input: Points to the new name if the object is to be
- renamed or nil if the object isn't to be renamed.
-
- Result Codes
- noErr 0 No error
- dirFulErr -33 File directory full
- dskFulErr -34 Disk is full
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- bdNamErr -37 Bad filename or attempt to move into
- a file
- fnfErr -43 Source file or directory not found
- wPrErr -44 Hardware volume lock
- fLckdErr -45 File is locked
- vLckdErr -46 Destination volume is read-only
- fBsyErr -47 File busy, directory not empty, or
- working directory control block open
- dupFNErr -48 Destination already exists
- paramErr -50 Volume doesn't support this function,
- no default volume, or source and
- volOfflinErr -53 Volume is offline
- fsRnErr -59 Problem during rename
- dirNFErr -120 Directory not found or incomplete pathname
- badMovErr -122 Attempted to move directory into
- offspring
- wrgVolTypErr -123 Not an HFS volume (it's a MFS volume)
- notAFileErr -1302 The pathname is nil, the pathname
- is empty, or the pathname cannot refer
- to a filename
- diffVolErr -1303 Files on different volumes
- afpAccessDenied -5000 The user does not have the right to
- move the file or directory
- afpObjectTypeErr -5025 Directory not found or incomplete pathname
- afpSameObjectErr -5038 Source and destination files are the same
-
- __________
-
- See also: HMoveRenameCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-BuildAFPVolMountInfo(
- short flags,
- char nbpInterval,
- char nbpCount,
- short uamType,
- Str32 zoneName,
- Str31 serverName,
- Str27 volName,
- Str31 userName,
- Str8 userPassword,
- Str8 volPassword,
- AFPVolMountInfoPtr * afpInfoPtr);
-
-
-/*
- The BuildAFPVolMountInfo function allocates and initializes the fields
- of an AFPVolMountInfo record before using that record to call
- the VolumeMount function.
-
- flags input: The AFP mounting flags. 0 = normal mount;
- set bit 0 to inhibit greeting messages.
- nbpInterval input: The interval used for VolumeMount's
- NBP Lookup call. 7 is a good choice.
- nbpCount input: The retry count used for VolumeMount's
- NBP Lookup call. 5 is a good choice.
- uamType input: The user authentication method to use.
- zoneName input: The AppleTalk zone name of the server.
- serverName input: The AFP server name.
- volName input: The AFP volume name.
- userName input: The user name (zero length Pascal string for
- guest).
- userPassWord input: The user password (zero length Pascal string
- if no user password)
- volPassWord input: The volume password (zero length Pascal string
- if no volume password)
- afpInfoPtr output: A pointer to the newly created and initialized
- AFPVolMountInfo record. If the function fails to
- create an AFPVolMountInfo record, it sets
- afpInfoPtr to NULL and the function result is
- memFullErr. Your program is responsible
- for disposing of this pointer when it is finished
- with it.
-
- Result Codes
- noErr 0 No error
- memFullErr -108 memory full error
-
- __________
-
- Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount,
- RetrieveAFPVolMountInfo, BuildAFPXVolMountInfo,
- RetrieveAFPXVolMountInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-RetrieveAFPVolMountInfo(
- AFPVolMountInfoPtr afpInfoPtr,
- short * flags,
- short * uamType,
- StringPtr zoneName,
- StringPtr serverName,
- StringPtr volName,
- StringPtr userName);
-
-
-/*
- The RetrieveAFPVolMountInfo function retrieves the AFP mounting
- information returned in an AFPVolMountInfo record by the
- GetVolMountInfo function.
-
- afpInfoPtr input: Pointer to AFPVolMountInfo record that contains
- the AFP mounting information.
- flags output: The AFP mounting flags.
- uamType output: The user authentication method used.
- zoneName output: The AppleTalk zone name of the server.
- serverName output: The AFP server name.
- volName output: The AFP volume name.
- userName output: The user name (zero length Pascal string for
- guest).
-
- Result Codes
- noErr 0 No error
- paramErr -50 media field in AFP mounting information
- was not AppleShareMediaType
-
- __________
-
- Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount,
- BuildAFPVolMountInfo, BuildAFPXVolMountInfo,
- RetrieveAFPXVolMountInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-BuildAFPXVolMountInfo(
- short flags,
- char nbpInterval,
- char nbpCount,
- short uamType,
- Str32 zoneName,
- Str31 serverName,
- Str27 volName,
- Str31 userName,
- Str8 userPassword,
- Str8 volPassword,
- Str32 uamName,
- unsigned long alternateAddressLength,
- void * alternateAddress,
- AFPXVolMountInfoPtr * afpXInfoPtr);
-
-
-/*
- The BuildAFPXVolMountInfo function allocates and initializes the fields
- of an AFPXVolMountInfo record before using that record to call
- the VolumeMount function.
-
- flags input: The AFP mounting flags.
- nbpInterval input: The interval used for VolumeMount's
- NBP Lookup call. 7 is a good choice.
- nbpCount input: The retry count used for VolumeMount's
- NBP Lookup call. 5 is a good choice.
- uamType input: The user authentication method to use.
- zoneName input: The AppleTalk zone name of the server.
- serverName input: The AFP server name.
- volName input: The AFP volume name.
- userName input: The user name (zero length Pascal string
- for guest).
- userPassWord input: The user password (zero length Pascal
- string if no user password)
- volPassWord input: The volume password (zero length Pascal
- string if no volume password)
- uamName input: The User Authentication Method name.
- alternateAddressLength input: Length of alternateAddress data.
- alternateAddress input The AFPAlternateAddress (variable length)
- afpXInfoPtr output: A pointer to the newly created and
- initialized AFPVolMountInfo record.
- If the function fails to create an
- AFPVolMountInfo record, it sets
- afpInfoPtr to NULL and the function
- result is memFullErr. Your program is
- responsible for disposing of this pointer
- when it is finished with it.
-
- Result Codes
- noErr 0 No error
- memFullErr -108 memory full error
-
- __________
-
- Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount,
- BuildAFPVolMountInfo, RetrieveAFPVolMountInfo,
- RetrieveAFPXVolMountInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-RetrieveAFPXVolMountInfo(
- AFPXVolMountInfoPtr afpXInfoPtr,
- short * flags,
- short * uamType,
- StringPtr zoneName,
- StringPtr serverName,
- StringPtr volName,
- StringPtr userName,
- StringPtr uamName,
- unsigned long * alternateAddressLength,
- AFPAlternateAddress ** alternateAddress);
-
-
-/*
- The RetrieveAFPXVolMountInfo function retrieves the AFP mounting
- information returned in an AFPXVolMountInfo record by the
- GetVolMountInfo function.
-
- afpXInfoPtr input: Pointer to AFPXVolMountInfo record that
- contains the AFP mounting information.
- flags output: The AFP mounting flags.
- uamType output: The user authentication method used.
- zoneName output: The AppleTalk zone name of the server.
- serverName output: The AFP server name.
- volName output: The AFP volume name.
- userName output: The user name (zero length Pascal
- string for guest).
- uamName output: The User Authentication Method name.
- alternateAddressLength output: Length of alternateAddress data returned.
- alternateAddress: output: A pointer to the newly created and
- AFPAlternateAddress record (a variable
- length record). If the function fails to
- create an AFPAlternateAddress record,
- it sets alternateAddress to NULL and the
- function result is memFullErr. Your
- program is responsible for disposing of
- this pointer when it is finished with it.
-
- Result Codes
- noErr 0 No error
- paramErr -50 media field in AFP mounting information
- was not AppleShareMediaType
- memFullErr -108 memory full error
-
- __________
-
- Also see: GetVolMountInfoSize, GetVolMountInfo, VolumeMount,
- BuildAFPVolMountInfo, RetrieveAFXVolMountInfo,
- BuildAFPXVolMountInfo
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-GetUGEntries(
- short objType,
- UGEntryPtr entries,
- long reqEntryCount,
- long * actEntryCount,
- long * objID);
-
-
-/*
- The GetUGEntries functions retrieves a list of user or group entries
- from the local file server.
-
- objType input: The object type: -1 = group; 0 = user
- UGEntries input: Pointer to array of UGEntry records where the list
- is returned.
- reqEntryCount input: The number of elements in the UGEntries array.
- actEntryCount output: The number of entries returned.
- objID input: The current index position. Set to 0 to start with
- the first entry.
- output: The index position to get the next entry. Pass this
- value the next time you call GetUGEntries to start
- where you left off.
-
- Result Codes
- noErr 0 No error
- fnfErr -43 No more users or groups
- paramErr -50 Function not supported; or, ioObjID is
- negative
-
- __________
-
- Also see: GetUGEntry
-*/
-
-/*****************************************************************************/
-
-
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MOREFILESEXTRAS__ */
-
+++ /dev/null
-/*
- File: Optimization.h
-
- Contains: Defines that let you make MoreFiles code more efficient.
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <1> 2/7/01 JL first checked in
-*/
-
-/*
- The Optimization changes to MoreFiles source and header files, along with
- this file and OptimizationEnd.h, let you optimize the code produced
- by MoreFiles in several ways.
-
- 1 -- MoreFiles contains extra code so that many routines can run under
- Mac OS systems back to System 6. If your program requires a specific
- version of Mac OS and your program checks for that version before
- calling MoreFiles routines, then you can remove a lot of compatibility
- code by defining one of the following to 1:
-
- __MACOSSEVENFIVEONEORLATER // assume Mac OS 7.5.1 or later
- __MACOSSEVENFIVEORLATER // assume Mac OS 7.5 or later
- __MACOSSEVENORLATER // assume Mac OS 7.0 or later
-
- If you're compiling 68K code, the default is to include all compatibility code.
- If you're compiling PowerPC code (TARGET_RT_MAC_CFM), the default is __MACOSSEVENORLATER
- If you're compiling for Carbon code (TARGET_API_MAC_CARBON), the default is __MACOSSEVENFIVEONEORLATER
-
- 2 -- You may disable Pascal calling conventions in all MoreFiles routines
- except for system callbacks that require Pascal calling conventions.
- This will make 68K C programs both smaller and faster.
- (PowerPC compilers ignore pascal calling conventions.)
- Just define __WANTPASCALELIMINATION to be 1 to turn this optimization on
- when building MoreFiles for use from C programs (you'll need to keep
- Pascal calling conventions when linking MoreFiles routines with Pascal
- programs).
-
- 3 -- If Metrowerks compiler is used, "#pragma internal on" may help produce
- better code. However, this option can also cause problems if you're
- trying to build MoreFiles as a shared library, so it is by default not used.
- Just define __USEPRAGMAINTERNAL to be 1 to turn this optimization on.
-
- Original changes supplied by Fabrizio Oddone
-*/
-
-#include <ConditionalMacros.h>
-
-// if we're compiling for Carbon, then we're running on Mac OS 8.1 or later
-#ifndef __MACOSSEVENFIVEONEORLATER
- #define __MACOSSEVENFIVEONEORLATER TARGET_API_MAC_CARBON
-#endif
-
-#ifndef __MACOSSEVENFIVEORLATER
- #define __MACOSSEVENFIVEORLATER __MACOSSEVENFIVEONEORLATER
-#endif
-
-#ifndef __MACOSSEVENORLATER
- #if TARGET_RT_MAC_CFM
- #define __MACOSSEVENORLATER 1
- #else
- #define __MACOSSEVENORLATER __MACOSSEVENFIVEORLATER
- #endif
-#endif
-
-
-#ifndef __WANTPASCALELIMINATION
- #define __WANTPASCALELIMINATION 0
-#endif
-
-#if __WANTPASCALELIMINATION
- #define pascal
-#endif
-
-
-#ifndef __USEPRAGMAINTERNAL
- #define __USEPRAGMAINTERNAL 0
-#endif
-
-#if __USEPRAGMAINTERNAL
- #if defined(__MWERKS__)
- #pragma internal on
- #endif
-#endif
+++ /dev/null
-/*
- File: OptimizationEnd.h
-
- Contains: Defines that let you make MoreFiles code more efficient.
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Apple Macintosh Developer Technical Support
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <1> 2/7/01 JL first checked in
-*/
-
-/*
- The Optimization changes to MoreFiles source and header files, along with
- this file and Optimization.h, let you optimize the code produced by MoreFiles
- in several ways.
-
- Original changes supplied by Fabrizio Oddone
-*/
-
-
-#if __USEPRAGMAINTERNAL
- #if defined(__MWERKS__)
- #pragma internal reset
- #endif
-#endif
-
-
-#if __WANTPASCALELIMINATION
- #ifndef __COMPILINGMOREFILES
- #undef pascal
- #endif
-#endif
+++ /dev/null
-/*
- File: Search.c
-
- Contains: IndexedSearch and the PBCatSearch compatibility function.
-
- Version: MoreFiles
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- File Ownership:
-
- DRI: Jim Luther
-
- Other Contact: Apple Macintosh Developer Technical Support
- <http://developer.apple.com/bugreporter/>
-
- Technology: DTS Sample Code
-
- Writers:
-
- (JL) Jim Luther
-
- Change History (most recent first):
-
- <2> 2/7/01 JL Added standard header. Updated names of includes. Updated
- various routines to use new calling convention of the
- MoreFilesExtras accessor functions. Added TARGET_API_MAC_CARBON
- conditional checks around TimeOutTask.
- <1> 12/06/99 JL MoreFiles 1.5.
-*/
-
-#include <MacTypes.h>
-#include <Gestalt.h>
-#include <Timer.h>
-#include <MacErrors.h>
-#include <MacMemory.h>
-#include <Files.h>
-#include <TextUtils.h>
-
-#define __COMPILINGMOREFILES
-
-#include "MoreFiles.h"
-#include "MoreFilesExtras.h"
-
-#include "Search.h"
-
-/*****************************************************************************/
-
-enum
-{
- /* Number of LevelRecs to add each time the searchStack is grown */
- /* 20 levels is probably more than reasonable for most volumes. */
- /* If more are needed, they are allocated 20 levels at a time. */
- kAdditionalLevelRecs = 20
-};
-
-/*****************************************************************************/
-
-/*
-** LevelRecs are used to store the directory ID and index whenever
-** IndexedSearch needs to either scan a sub-directory, or return control
-** to the caller because the call has timed out or the number of
-** matches requested has been found. LevelRecs are stored in an array
-** used as a stack.
-*/
-struct LevelRec
-{
- long dirModDate; /* for detecting most (but not all) catalog changes */
- long dirID;
- short index;
-};
-typedef struct LevelRec LevelRec;
-typedef LevelRec *LevelRecPtr, **LevelRecHandle;
-
-
-/*
-** SearchPositionRec is my version of a CatPositionRec. It holds the
-** information I need to resuming searching.
-*/
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=mac68k
-#endif
-struct SearchPositionRec
-{
- long initialize; /* Goofy checksum of volume information used to make */
- /* sure we're resuming a search on the same volume. */
- unsigned short stackDepth; /* Current depth on searchStack. */
- short priv[11]; /* For future use... */
-};
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=reset
-#endif
-typedef struct SearchPositionRec SearchPositionRec;
-typedef SearchPositionRec *SearchPositionRecPtr;
-
-
-/*
-** ExtendedTMTask is a TMTask record extended to hold the timer flag.
-*/
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=mac68k
-#endif
-struct ExtendedTMTask
-{
- TMTask theTask;
- Boolean stopSearch; /* the Time Mgr task will set stopSearch to */
- /* true when the timer expires */
-};
-#if PRAGMA_STRUCT_ALIGN
-#pragma options align=reset
-#endif
-typedef struct ExtendedTMTask ExtendedTMTask;
-typedef ExtendedTMTask *ExtendedTMTaskPtr;
-
-/*****************************************************************************/
-
-static OSErr CheckVol(ConstStr255Param pathname,
- short vRefNum,
- short *realVRefNum,
- long *volID);
-
-static OSErr CheckStack(unsigned short stackDepth,
- LevelRecHandle searchStack,
- Size *searchStackSize);
-
-static OSErr VerifyUserPB(CSParamPtr userPB,
- Boolean *includeFiles,
- Boolean *includeDirs,
- Boolean *includeNames);
-
-static Boolean IsSubString(ConstStr255Param aStringPtr,
- ConstStr255Param subStringPtr);
-
-static Boolean CompareMasked(const long *data1,
- const long *data2,
- const long *mask,
- short longsToCompare);
-
-static void CheckForMatches(CInfoPBPtr cPB,
- CSParamPtr userPB,
- const Str63 matchName,
- Boolean includeFiles,
- Boolean includeDirs);
-
-#if __WANTPASCALELIMINATION
-#undef pascal
-#endif
-
-#if TARGET_RT_MAC_CFM || TARGET_API_MAC_CARBON
-
-static pascal void TimeOutTask(TMTaskPtr tmTaskPtr);
-
-#else
-
-static pascal TMTaskPtr GetTMTaskPtr(void);
-
-static void TimeOutTask(void);
-
-#endif
-
-#if __WANTPASCALELIMINATION
-#define pascal
-#endif
-
-static long GetDirModDate(short vRefNum,
- long dirID);
-
-/*****************************************************************************/
-
-/*
-** CheckVol gets the volume's real vRefNum and builds a volID. The volID
-** is used to help insure that calls to resume searching with IndexedSearch
-** are to the same volume as the last call to IndexedSearch.
-*/
-static OSErr CheckVol(ConstStr255Param pathname,
- short vRefNum,
- short *realVRefNum,
- long *volID)
-{
- HParamBlockRec pb;
- OSErr error;
-
- error = GetVolumeInfoNoName(pathname, vRefNum, &pb);
- if ( error == noErr )
- {
- /* Return the real vRefNum */
- *realVRefNum = pb.volumeParam.ioVRefNum;
-
- /* Add together a bunch of things that aren't supposed to change on */
- /* a mounted volume that's being searched and that should come up with */
- /* a fairly unique number */
- *volID = pb.volumeParam.ioVCrDate +
- pb.volumeParam.ioVRefNum +
- pb.volumeParam.ioVNmAlBlks +
- pb.volumeParam.ioVAlBlkSiz +
- pb.volumeParam.ioVFSID;
- }
- return ( error );
-}
-
-/*****************************************************************************/
-
-/*
-** CheckStack checks the size of the search stack (array) to see if there's
-** room to push another LevelRec. If not, CheckStack grows the stack by
-** another kAdditionalLevelRecs elements.
-*/
-static OSErr CheckStack(unsigned short stackDepth,
- LevelRecHandle searchStack,
- Size *searchStackSize)
-{
- OSErr result;
-
- if ( (*searchStackSize / sizeof(LevelRec)) == (stackDepth + 1) )
- {
- /* Time to grow stack */
- SetHandleSize((Handle)searchStack, *searchStackSize + (kAdditionalLevelRecs * sizeof(LevelRec)));
- result = MemError(); /* should be noErr */
- *searchStackSize = GetHandleSize((Handle)searchStack);
- }
- else
- {
- result = noErr;
- }
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-/*
-** VerifyUserPB makes sure the parameter block passed to IndexedSearch has
-** valid parameters. By making this check once, we don't have to worry about
-** things like NULL pointers, strings being too long, etc.
-** VerifyUserPB also determines if the search includes files and/or
-** directories, and determines if a full or partial name search was requested.
-*/
-static OSErr VerifyUserPB(CSParamPtr userPB,
- Boolean *includeFiles,
- Boolean *includeDirs,
- Boolean *includeNames)
-{
- CInfoPBPtr searchInfo1;
- CInfoPBPtr searchInfo2;
-
- searchInfo1 = userPB->ioSearchInfo1;
- searchInfo2 = userPB->ioSearchInfo2;
-
- /* ioMatchPtr cannot be NULL */
- if ( userPB->ioMatchPtr == NULL )
- {
- goto ParamErrExit;
- }
-
- /* ioSearchInfo1 cannot be NULL */
- if ( searchInfo1 == NULL )
- {
- goto ParamErrExit;
- }
-
- /* If any bits except partialName, fullName, or negate are set, then */
- /* ioSearchInfo2 cannot be NULL because information in ioSearchInfo2 is required */
- if ( ((userPB->ioSearchBits & ~(fsSBPartialName | fsSBFullName | fsSBNegate)) != 0) &&
- ( searchInfo2 == NULL ))
- {
- goto ParamErrExit;
- }
-
- *includeFiles = false;
- *includeDirs = false;
- *includeNames = false;
-
- if ( (userPB->ioSearchBits & (fsSBPartialName | fsSBFullName)) != 0 )
- {
- /* If any kind of name matching is requested, then ioNamePtr in */
- /* ioSearchInfo1 cannot be NULL or a zero-length string */
- if ( (searchInfo1->hFileInfo.ioNamePtr == NULL) ||
- (searchInfo1->hFileInfo.ioNamePtr[0] == 0) ||
- (searchInfo1->hFileInfo.ioNamePtr[0] > (sizeof(Str63) - 1)) )
- {
- goto ParamErrExit;
- }
-
- *includeNames = true;
- }
-
- if ( (userPB->ioSearchBits & fsSBFlAttrib) != 0 )
- {
- /* The only attributes you can search on are the directory flag */
- /* and the locked flag. */
- if ( (searchInfo2->hFileInfo.ioFlAttrib & ~(kioFlAttribDirMask | kioFlAttribLockedMask)) != 0 )
- {
- goto ParamErrExit;
- }
-
- /* interested in the directory bit? */
- if ( (searchInfo2->hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* yes, so do they want just directories or just files? */
- if ( (searchInfo1->hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- *includeDirs = true;
- }
- else
- {
- *includeFiles = true;
- }
- }
- else
- {
- /* no interest in directory bit - get both files and directories */
- *includeDirs = true;
- *includeFiles = true;
- }
- }
- else
- {
- /* no attribute checking - get both files and directories */
- *includeDirs = true;
- *includeFiles = true;
- }
-
- /* If directories are included in the search, */
- /* then the locked attribute cannot be requested. */
- if ( *includeDirs &&
- ((userPB->ioSearchBits & fsSBFlAttrib) != 0) &&
- ((searchInfo2->hFileInfo.ioFlAttrib & kioFlAttribLockedMask) != 0) )
- {
- goto ParamErrExit;
- }
-
- /* If files are included in the search, then there cannot be */
- /* a search on the number of files. */
- if ( *includeFiles &&
- ((userPB->ioSearchBits & fsSBDrNmFls) != 0) )
- {
- goto ParamErrExit;
- }
-
- /* If directories are included in the search, then there cannot */
- /* be a search on file lengths. */
- if ( *includeDirs &&
- ((userPB->ioSearchBits & (fsSBFlLgLen | fsSBFlPyLen | fsSBFlRLgLen | fsSBFlRPyLen)) != 0) )
- {
- goto ParamErrExit;
- }
-
- return ( noErr );
-
-ParamErrExit:
- return ( paramErr );
-}
-
-/*****************************************************************************/
-
-/*
-** IsSubString checks to see if a string is a substring of another string.
-** Both input strings have already been converted to all uppercase using
-** UprString (the same non-international call the File Manager uses).
-*/
-static Boolean IsSubString(ConstStr255Param aStringPtr,
- ConstStr255Param subStringPtr)
-{
- short strLength; /* length of string */
- short subStrLength; /* length of subString */
- Boolean found; /* result of test */
- short index; /* current index into string */
-
- found = false;
- strLength = aStringPtr[0];
- subStrLength = subStringPtr[0];
-
- if ( subStrLength <= strLength)
- {
- register short count; /* search counter */
- register short strIndex; /* running index into string */
- register short subStrIndex; /* running index into subString */
-
- /* start looking at first character */
- index = 1;
-
- /* continue looking until remaining string is shorter than substring */
- count = strLength - subStrLength + 1;
-
- do
- {
- strIndex = index; /* start string index at index */
- subStrIndex = 1; /* start subString index at 1 */
-
- while ( !found && (aStringPtr[strIndex] == subStringPtr[subStrIndex]) )
- {
- if ( subStrIndex == subStrLength )
- {
- /* all characters in subString were found */
- found = true;
- }
- else
- {
- /* check next character of substring against next character of string */
- ++subStrIndex;
- ++strIndex;
- }
- }
-
- if ( !found )
- {
- /* start substring search again at next string character */
- ++index;
- --count;
- }
- } while ( count != 0 && (!found) );
- }
-
- return ( found );
-}
-
-/*****************************************************************************/
-
-/*
-** CompareMasked does a bitwise comparison with mask on 1 or more longs.
-** data1 and data2 are first exclusive-ORed together resulting with bits set
-** where they are different. That value is then ANDed with the mask resulting
-** with bits set if the test fails. true is returned if the tests pass.
-*/
-static Boolean CompareMasked(const long *data1,
- const long *data2,
- const long *mask,
- short longsToCompare)
-{
- Boolean result = true;
-
- while ( (longsToCompare != 0) && (result == true) )
- {
- /* (*data1 ^ *data2) = bits that are different, so... */
- /* ((*data1 ^ *data2) & *mask) = bits that are different that we're interested in */
-
- if ( ((*data1 ^ *data2) & *mask) != 0 )
- result = false;
-
- ++data1;
- ++data2;
- ++mask;
- --longsToCompare;
- }
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-/*
-** Check for matches compares the search criteria in userPB to the file
-** system object in cPB. If there's a match, then the information in cPB is
-** is added to the match array and the actual match count is incremented.
-*/
-static void CheckForMatches(CInfoPBPtr cPB,
- CSParamPtr userPB,
- const Str63 matchName,
- Boolean includeFiles,
- Boolean includeDirs)
-{
- long searchBits;
- CInfoPBPtr searchInfo1;
- CInfoPBPtr searchInfo2;
- Str63 itemName; /* copy of object's name for partial name matching */
- Boolean foundMatch;
-
- foundMatch = false; /* default to no match */
-
- searchBits = userPB->ioSearchBits;
- searchInfo1 = userPB->ioSearchInfo1;
- searchInfo2 = userPB->ioSearchInfo2;
-
- /* Into the if statements that go on forever... */
-
- if ( (cPB->hFileInfo.ioFlAttrib & kioFlAttribDirMask) == 0 )
- {
- if (!includeFiles)
- {
- goto Failed;
- }
- }
- else
- {
- if (!includeDirs)
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBPartialName) != 0 )
- {
- if ( (cPB->hFileInfo.ioNamePtr[0] > 0) &&
- (cPB->hFileInfo.ioNamePtr[0] <= (sizeof(Str63) - 1)) )
- {
- /* Make uppercase copy of object name */
- BlockMoveData(cPB->hFileInfo.ioNamePtr,
- itemName,
- cPB->hFileInfo.ioNamePtr[0] + 1);
- /* Use the same non-international call the File Manager uses */
- UpperString(itemName, true);
- }
- else
- {
- goto Failed;
- }
-
- {
- if ( !IsSubString(itemName, matchName) )
- {
- goto Failed;
- }
- else if ( searchBits == fsSBPartialName )
- {
- /* optimize for name matching only since it is most common way to search */
- goto Hit;
- }
- }
- }
-
- if ( (searchBits & fsSBFullName) != 0 )
- {
- /* Use the same non-international call the File Manager uses */
- if ( !EqualString(cPB->hFileInfo.ioNamePtr, matchName, false, true) )
- {
- goto Failed;
- }
- else if ( searchBits == fsSBFullName )
- {
- /* optimize for name matching only since it is most common way to search */
- goto Hit;
- }
- }
-
- if ( (searchBits & fsSBFlParID) != 0 )
- {
- if ( ((unsigned long)(cPB->hFileInfo.ioFlParID) < (unsigned long)(searchInfo1->hFileInfo.ioFlParID)) ||
- ((unsigned long)(cPB->hFileInfo.ioFlParID) > (unsigned long)(searchInfo2->hFileInfo.ioFlParID)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlAttrib) != 0 )
- {
- if ( ((cPB->hFileInfo.ioFlAttrib ^ searchInfo1->hFileInfo.ioFlAttrib) &
- searchInfo2->hFileInfo.ioFlAttrib) != 0 )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBDrNmFls) != 0 )
- {
- if ( ((unsigned long)(cPB->dirInfo.ioDrNmFls) < (unsigned long)(searchInfo1->dirInfo.ioDrNmFls)) ||
- ((unsigned long)(cPB->dirInfo.ioDrNmFls) > (unsigned long)(searchInfo2->dirInfo.ioDrNmFls)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlFndrInfo) != 0 ) /* fsSBFlFndrInfo is same as fsSBDrUsrWds */
- {
- if ( !CompareMasked((long *)&(cPB->hFileInfo.ioFlFndrInfo),
- (long *)&(searchInfo1->hFileInfo.ioFlFndrInfo),
- (long *)&(searchInfo2->hFileInfo.ioFlFndrInfo),
- sizeof(FInfo) / sizeof(long)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlXFndrInfo) != 0 ) /* fsSBFlXFndrInfo is same as fsSBDrFndrInfo */
- {
- if ( !CompareMasked((long *)&(cPB->hFileInfo.ioFlXFndrInfo),
- (long *)&(searchInfo1->hFileInfo.ioFlXFndrInfo),
- (long *)&(searchInfo2->hFileInfo.ioFlXFndrInfo),
- sizeof(FXInfo) / sizeof(long)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlLgLen) != 0 )
- {
- if ( ((unsigned long)(cPB->hFileInfo.ioFlLgLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlLgLen)) ||
- ((unsigned long)(cPB->hFileInfo.ioFlLgLen) > (unsigned long)(searchInfo2->hFileInfo.ioFlLgLen)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlPyLen) != 0 )
- {
- if ( ((unsigned long)(cPB->hFileInfo.ioFlPyLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlPyLen)) ||
- ((unsigned long)(cPB->hFileInfo.ioFlPyLen) > (unsigned long)(searchInfo2->hFileInfo.ioFlPyLen)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlRLgLen) != 0 )
- {
- if ( ((unsigned long)(cPB->hFileInfo.ioFlRLgLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlRLgLen)) ||
- ((unsigned long)(cPB->hFileInfo.ioFlRLgLen) > (unsigned long)(searchInfo2->hFileInfo.ioFlRLgLen)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlRPyLen) != 0 )
- {
- if ( ((unsigned long)(cPB->hFileInfo.ioFlRPyLen) < (unsigned long)(searchInfo1->hFileInfo.ioFlRPyLen)) ||
- ((unsigned long)(cPB->hFileInfo.ioFlRPyLen) > (unsigned long)(searchInfo2->hFileInfo.ioFlRPyLen)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlCrDat) != 0 ) /* fsSBFlCrDat is same as fsSBDrCrDat */
- {
- if ( ((unsigned long)(cPB->hFileInfo.ioFlCrDat) < (unsigned long)(searchInfo1->hFileInfo.ioFlCrDat)) ||
- ((unsigned long)(cPB->hFileInfo.ioFlCrDat) > (unsigned long)(searchInfo2->hFileInfo.ioFlCrDat)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlMdDat) != 0 ) /* fsSBFlMdDat is same as fsSBDrMdDat */
- {
- if ( ((unsigned long)(cPB->hFileInfo.ioFlMdDat) < (unsigned long)(searchInfo1->hFileInfo.ioFlMdDat)) ||
- ((unsigned long)(cPB->hFileInfo.ioFlMdDat) > (unsigned long)(searchInfo2->hFileInfo.ioFlMdDat)) )
- {
- goto Failed;
- }
- }
-
- if ( (searchBits & fsSBFlBkDat) != 0 ) /* fsSBFlBkDat is same as fsSBDrBkDat */
- {
- if ( ((unsigned long)(cPB->hFileInfo.ioFlBkDat) < (unsigned long)(searchInfo1->hFileInfo.ioFlBkDat)) ||
- ((unsigned long)(cPB->hFileInfo.ioFlBkDat) > (unsigned long)(searchInfo2->hFileInfo.ioFlBkDat)) )
- {
- goto Failed;
- }
- }
-
- /* Hey, we passed all of the tests! */
-
-Hit:
- foundMatch = true;
-
-/* foundMatch is false if code jumps to Failed */
-Failed:
- /* Do we reverse our findings? */
- if ( (searchBits & fsSBNegate) != 0 )
- {
- foundMatch = !foundMatch; /* matches are not, not matches are */
- }
-
- if ( foundMatch )
- {
-
- /* Move the match into the match buffer */
- userPB->ioMatchPtr[userPB->ioActMatchCount].vRefNum = cPB->hFileInfo.ioVRefNum;
- userPB->ioMatchPtr[userPB->ioActMatchCount].parID = cPB->hFileInfo.ioFlParID;
- if ( cPB->hFileInfo.ioNamePtr[0] > 63 )
- {
- cPB->hFileInfo.ioNamePtr[0] = 63;
- }
- BlockMoveData(cPB->hFileInfo.ioNamePtr,
- userPB->ioMatchPtr[userPB->ioActMatchCount].name,
- cPB->hFileInfo.ioNamePtr[0] + 1);
-
- /* increment the actual count */
- ++(userPB->ioActMatchCount);
- }
-}
-
-/*****************************************************************************/
-
-/*
-** TimeOutTask is executed when the timer goes off. It simply sets the
-** stopSearch field to true. After each object is found and possibly added
-** to the matches buffer, stopSearch is checked to see if the search should
-** continue.
-*/
-
-#if __WANTPASCALELIMINATION
-#undef pascal
-#endif
-
-#if TARGET_RT_MAC_CFM || TARGET_API_MAC_CARBON
-
-static pascal void TimeOutTask(TMTaskPtr tmTaskPtr)
-{
- ((ExtendedTMTaskPtr)tmTaskPtr)->stopSearch = true;
-}
-
-#else
-
-static pascal TMTaskPtr GetTMTaskPtr(void)
- ONEWORDINLINE(0x2e89); /* MOVE.L A1,(SP) */
-
-static void TimeOutTask(void)
-{
- ((ExtendedTMTaskPtr)GetTMTaskPtr())->stopSearch = true;
-}
-
-#endif
-
-#if __WANTPASCALELIMINATION
-#define pascal
-#endif
-
-/*****************************************************************************/
-
-/*
-** GetDirModDate returns the modification date of a directory. If there is
-** an error getting the modification date, -1 is returned to indicate
-** something went wrong.
-*/
-static long GetDirModDate(short vRefNum,
- long dirID)
-{
- CInfoPBRec pb;
- Str31 tempName;
- long modDate;
-
- /* Protection against File Sharing problem */
- tempName[0] = 0;
- pb.dirInfo.ioNamePtr = tempName;
- pb.dirInfo.ioVRefNum = vRefNum;
- pb.dirInfo.ioDrDirID = dirID;
- pb.dirInfo.ioFDirIndex = -1; /* use ioDrDirID */
-
- if ( PBGetCatInfoSync(&pb) == noErr )
- {
- modDate = pb.dirInfo.ioDrMdDat;
- }
- else
- {
- modDate = -1;
- }
-
- return ( modDate );
-}
-
-/*****************************************************************************/
-
-pascal OSErr IndexedSearch(CSParamPtr pb,
- long dirID)
-{
- static LevelRecHandle searchStack = NULL; /* static handle to LevelRec stack */
- static Size searchStackSize = 0; /* size of static handle */
- SearchPositionRecPtr catPosition;
- long modDate;
- short index = -1 ;
- ExtendedTMTask timerTask;
- OSErr result;
- short realVRefNum;
- Str63 itemName;
- CInfoPBRec cPB;
- long tempLong;
- Boolean includeFiles;
- Boolean includeDirs;
- Boolean includeNames;
- Str63 upperName;
-
- timerTask.stopSearch = false; /* don't stop yet! */
-
- /* If request has a timeout, install a Time Manager task. */
- if ( pb->ioSearchTime != 0 )
- {
- /* Start timer */
- timerTask.theTask.tmAddr = NewTimerUPP(TimeOutTask);
- InsTime((QElemPtr)&(timerTask.theTask));
- PrimeTime((QElemPtr)&(timerTask.theTask), pb->ioSearchTime);
- }
-
- /* Check the parameter block passed for things that we don't want to assume */
- /* are OK later in the code. For example, make sure pointers to data structures */
- /* and buffers are not NULL. And while we're in there, see if the request */
- /* specified searching for files, directories, or both, and see if the search */
- /* was by full or partial name. */
- result = VerifyUserPB(pb, &includeFiles, &includeDirs, &includeNames);
- if ( result == noErr )
- {
- pb->ioActMatchCount = 0; /* no matches yet */
-
- if ( includeNames )
- {
- /* The search includes seach by full or partial name. */
- /* Make an upper case copy of the match string to pass to */
- /* CheckForMatches. */
- BlockMoveData(pb->ioSearchInfo1->hFileInfo.ioNamePtr,
- upperName,
- pb->ioSearchInfo1->hFileInfo.ioNamePtr[0] + 1);
- /* Use the same non-international call the File Manager uses */
- UpperString(upperName, true);
- }
-
- /* Prevent casting to my type throughout code */
- catPosition = (SearchPositionRecPtr)&pb->ioCatPosition;
-
- /* Create searchStack first time called */
- if ( searchStack == NULL )
- {
- searchStack = (LevelRecHandle)NewHandle(kAdditionalLevelRecs * sizeof(LevelRec));
- }
-
- /* Make sure searchStack really exists */
- if ( searchStack != NULL )
- {
- searchStackSize = GetHandleSize((Handle)searchStack);
-
- /* See if the search is a new search or a resumed search. */
- if ( catPosition->initialize == 0 )
- {
- /* New search. */
-
- /* Get the real vRefNum and fill in catPosition->initialize. */
- result = CheckVol(pb->ioNamePtr, pb->ioVRefNum, &realVRefNum, &catPosition->initialize);
- if ( result == noErr )
- {
- /* clear searchStack */
- catPosition->stackDepth = 0;
-
- /* use dirID parameter passed and... */
- index = -1; /* start with the passed directory itself! */
- }
- }
- else
- {
- /* We're resuming a search. */
-
- /* Get the real vRefNum and make sure catPosition->initialize is valid. */
- result = CheckVol(pb->ioNamePtr, pb->ioVRefNum, &realVRefNum, &tempLong);
- if ( result == noErr )
- {
- /* Make sure the resumed search is to the same volume! */
- if ( catPosition->initialize == tempLong )
- {
- /* For resume, catPosition->stackDepth > 0 */
- if ( catPosition->stackDepth > 0 )
- {
- /* Position catPosition->stackDepth to access last saved level */
- --(catPosition->stackDepth);
-
- /* Get the dirID and index for the next item */
- dirID = (*searchStack)[catPosition->stackDepth].dirID;
- index = (*searchStack)[catPosition->stackDepth].index;
-
- /* Check the dir's mod date against the saved mode date on our "stack" */
- modDate = GetDirModDate(realVRefNum, dirID);
- if ( modDate != (*searchStack)[catPosition->stackDepth].dirModDate )
- {
- result = catChangedErr;
- }
- }
- else
- {
- /* Invalid catPosition record was passed */
- result = paramErr;
- }
- }
- else
- {
- /* The volume is not the same */
- result = catChangedErr;
- }
- }
- }
-
- if ( result == noErr )
- {
- /* ioNamePtr and ioVRefNum only need to be set up once. */
- cPB.hFileInfo.ioNamePtr = itemName;
- cPB.hFileInfo.ioVRefNum = realVRefNum;
-
- /*
- ** Here's the loop that:
- ** Finds the next item on the volume.
- ** If noErr, calls the code to check for matches and add matches
- ** to the match buffer.
- ** Sets up dirID and index for to find the next item on the volume.
- **
- ** The looping ends when:
- ** (a) an unexpected error is returned by PBGetCatInfo. All that
- ** is expected is noErr and fnfErr (after the last item in a
- ** directory is found).
- ** (b) the caller specified a timeout and our Time Manager task
- ** has fired.
- ** (c) the number of matches requested by the caller has been found.
- ** (d) the last item on the volume was found.
- */
- do
- {
- /* get the next item */
- cPB.hFileInfo.ioFDirIndex = index;
- cPB.hFileInfo.ioDirID = dirID;
- result = PBGetCatInfoSync(&cPB);
- if ( index != -1 )
- {
- if ( result == noErr )
- {
- /* We found something */
-
- CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs);
-
- ++index;
- if ( (cPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0 )
- {
- /* It's a directory */
-
- result = CheckStack(catPosition->stackDepth, searchStack, &searchStackSize);
- if ( result == noErr )
- {
- /* Save the current state on the searchStack */
- /* when we come back, this is where we'll start */
- (*searchStack)[catPosition->stackDepth].dirID = dirID;
- (*searchStack)[catPosition->stackDepth].index = index;
- (*searchStack)[catPosition->stackDepth].dirModDate = GetDirModDate(realVRefNum, dirID);
-
- /* position catPosition->stackDepth for next saved level */
- ++(catPosition->stackDepth);
-
- /* The next item to get is the 1st item in the child directory */
- dirID = cPB.dirInfo.ioDrDirID;
- index = 1;
- }
- }
- /* else do nothing for files */
- }
- else
- {
- /* End of directory found (or we had some error and that */
- /* means we have to drop out of this directory). */
- /* Restore last thing put on stack and */
- /* see if we need to continue or quit. */
- if ( catPosition->stackDepth > 0 )
- {
- /* position catPosition->stackDepth to access last saved level */
- --(catPosition->stackDepth);
-
- dirID = (*searchStack)[catPosition->stackDepth].dirID;
- index = (*searchStack)[catPosition->stackDepth].index;
-
- /* Check the dir's mod date against the saved mode date on our "stack" */
- modDate = GetDirModDate(realVRefNum, dirID);
- if ( modDate != (*searchStack)[catPosition->stackDepth].dirModDate )
- {
- result = catChangedErr;
- }
- else
- {
- /* Going back to ancestor directory. */
- /* Clear error so we can continue. */
- result = noErr;
- }
- }
- else
- {
- /* We hit the bottom of the stack, so we'll let the */
- /* the eofErr drop us out of the loop. */
- result = eofErr;
- }
- }
- }
- else
- {
- /* Special case for index == -1; that means that we're starting */
- /* a new search and so the first item to check is the directory */
- /* passed to us. */
- if ( result == noErr )
- {
- /* We found something */
-
- CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs);
-
- /* Now, set the index to 1 and then we're ready to look inside */
- /* the passed directory. */
- index = 1;
- }
- }
- } while ( (!timerTask.stopSearch) && /* timer hasn't fired */
- (result == noErr) && /* no unexpected errors */
- (pb->ioReqMatchCount > pb->ioActMatchCount) ); /* we haven't found our limit */
-
- /* Did we drop out of the loop because of timeout or */
- /* ioReqMatchCount was found? */
- if ( result == noErr )
- {
- result = CheckStack(catPosition->stackDepth, searchStack, &searchStackSize);
- if ( result == noErr )
- {
- /* Either there was a timeout or ioReqMatchCount was reached. */
- /* Save the dirID and index for the next time we're called. */
-
- (*searchStack)[catPosition->stackDepth].dirID = dirID;
- (*searchStack)[catPosition->stackDepth].index = index;
- (*searchStack)[catPosition->stackDepth].dirModDate = GetDirModDate(realVRefNum, dirID);
-
- /* position catPosition->stackDepth for next saved level */
-
- ++(catPosition->stackDepth);
- }
- }
- }
- }
- else
- {
- /* searchStack Handle could not be allocated */
- result = memFullErr;
- }
- }
-
- if ( pb->ioSearchTime != 0 )
- {
- /* Stop Time Manager task here if it was installed */
- RmvTime((QElemPtr)&(timerTask.theTask));
- DisposeTimerUPP(timerTask.theTask.tmAddr);
- }
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr PBCatSearchSyncCompat(CSParamPtr paramBlock)
-{
- OSErr result;
- Boolean supportsCatSearch;
- GetVolParmsInfoBuffer volParmsInfo;
- long infoSize;
-#if !__MACOSSEVENORLATER
- static Boolean fullExtFSDispatchingtested = false;
- static Boolean hasFullExtFSDispatching = false;
- long response;
-#endif
-
- result = noErr;
-
-#if !__MACOSSEVENORLATER
- /* See if File Manager will pass CatSearch requests to external file systems */
- /* we'll store the results in a static variable so we don't have to call Gestalt */
- /* everytime we're called. (System 7.0 and later always do this) */
- if ( !fullExtFSDispatchingtested )
- {
- fullExtFSDispatchingtested = true;
- if ( Gestalt(gestaltFSAttr, &response) == noErr )
- {
- hasFullExtFSDispatching = ((response & (1L << gestaltFullExtFSDispatching)) != 0);
- }
- }
-#endif
-
- /* CatSearch is a per volume attribute, so we have to check each time we're */
- /* called to see if it is available on the volume specified. */
- supportsCatSearch = false;
-#if !__MACOSSEVENORLATER
- if ( hasFullExtFSDispatching )
-#endif
- {
- infoSize = sizeof(GetVolParmsInfoBuffer);
- result = HGetVolParms(paramBlock->ioNamePtr, paramBlock->ioVRefNum,
- &volParmsInfo, &infoSize);
- if ( result == noErr )
- {
- supportsCatSearch = hasCatSearch(&volParmsInfo);
- }
- }
-
- /* noErr or paramErr is OK here. */
- /* paramErr just means that GetVolParms isn't supported by this volume */
- if ( (result == noErr) || (result == paramErr) )
- {
- if ( supportsCatSearch )
- {
- /* Volume supports CatSearch so use it. */
- /* CatSearch is faster than an indexed search. */
- result = PBCatSearchSync(paramBlock);
- }
- else
- {
- /* Volume doesn't support CatSearch so */
- /* search using IndexedSearch from root directory. */
- result = IndexedSearch(paramBlock, fsRtDirID);
- }
- }
-
- return ( result );
-}
-
-/*****************************************************************************/
-
-pascal OSErr NameFileSearch(ConstStr255Param volName,
- short vRefNum,
- ConstStr255Param fileName,
- FSSpecPtr matches,
- long reqMatchCount,
- long *actMatchCount,
- Boolean newSearch,
- Boolean partial)
-{
- CInfoPBRec searchInfo1, searchInfo2;
- HParamBlockRec pb;
- OSErr error;
- static CatPositionRec catPosition;
- static short lastVRefNum = 0;
-
- /* get the real volume reference number */
- error = DetermineVRefNum(volName, vRefNum, &vRefNum);
- if ( error != noErr )
- return ( error );
-
- pb.csParam.ioNamePtr = NULL;
- pb.csParam.ioVRefNum = vRefNum;
- pb.csParam.ioMatchPtr = matches;
- pb.csParam.ioReqMatchCount = reqMatchCount;
- if ( partial ) /* tell CatSearch what we're looking for: */
- {
- pb.csParam.ioSearchBits = fsSBPartialName + fsSBFlAttrib; /* partial name file matches or */
- }
- else
- {
- pb.csParam.ioSearchBits = fsSBFullName + fsSBFlAttrib; /* full name file matches */
- }
- pb.csParam.ioSearchInfo1 = &searchInfo1;
- pb.csParam.ioSearchInfo2 = &searchInfo2;
- pb.csParam.ioSearchTime = 0;
- if ( (newSearch) || /* If caller specified new search */
- (lastVRefNum != vRefNum) ) /* or if last search was to another volume, */
- {
- catPosition.initialize = 0; /* then search from beginning of catalog */
- }
- pb.csParam.ioCatPosition = catPosition;
- pb.csParam.ioOptBuffer = GetTempBuffer(0x00004000, &pb.csParam.ioOptBufSize);
-
- /* search for fileName */
- searchInfo1.hFileInfo.ioNamePtr = (StringPtr)fileName;
- searchInfo2.hFileInfo.ioNamePtr = NULL;
-
- /* only match files (not directories) */
- searchInfo1.hFileInfo.ioFlAttrib = 0x00;
- searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask;
-
- error = PBCatSearchSyncCompat((CSParamPtr)&pb);
-
- if ( (error == noErr) || /* If no errors or the end of catalog was */
- (error == eofErr) ) /* found, then the call was successful so */
- {
- *actMatchCount = pb.csParam.ioActMatchCount; /* return the match count */
- }
- else
- {
- *actMatchCount = 0; /* else no matches found */
- }
-
- if ( (error == noErr) || /* If no errors */
- (error == catChangedErr) ) /* or there was a change in the catalog */
- {
- catPosition = pb.csParam.ioCatPosition;
- lastVRefNum = vRefNum;
- /* we can probably start the next search where we stopped this time */
- }
- else
- {
- catPosition.initialize = 0;
- /* start the next search from beginning of catalog */
- }
-
- if ( pb.csParam.ioOptBuffer != NULL )
- {
- DisposePtr(pb.csParam.ioOptBuffer);
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
-
-pascal OSErr CreatorTypeFileSearch(ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- OSType fileType,
- FSSpecPtr matches,
- long reqMatchCount,
- long *actMatchCount,
- Boolean newSearch)
-{
- CInfoPBRec searchInfo1, searchInfo2;
- HParamBlockRec pb;
- OSErr error;
- static CatPositionRec catPosition;
- static short lastVRefNum = 0;
-
- /* get the real volume reference number */
- error = DetermineVRefNum(volName, vRefNum, &vRefNum);
- if ( error != noErr )
- return ( error );
-
- pb.csParam.ioNamePtr = NULL;
- pb.csParam.ioVRefNum = vRefNum;
- pb.csParam.ioMatchPtr = matches;
- pb.csParam.ioReqMatchCount = reqMatchCount;
- pb.csParam.ioSearchBits = fsSBFlAttrib + fsSBFlFndrInfo; /* Looking for finder info file matches */
- pb.csParam.ioSearchInfo1 = &searchInfo1;
- pb.csParam.ioSearchInfo2 = &searchInfo2;
- pb.csParam.ioSearchTime = 0;
- if ( (newSearch) || /* If caller specified new search */
- (lastVRefNum != vRefNum) ) /* or if last search was to another volume, */
- {
- catPosition.initialize = 0; /* then search from beginning of catalog */
- }
- pb.csParam.ioCatPosition = catPosition;
- pb.csParam.ioOptBuffer = GetTempBuffer(0x00004000, &pb.csParam.ioOptBufSize);
-
- /* no fileName */
- searchInfo1.hFileInfo.ioNamePtr = NULL;
- searchInfo2.hFileInfo.ioNamePtr = NULL;
-
- /* only match files (not directories) */
- searchInfo1.hFileInfo.ioFlAttrib = 0x00;
- searchInfo2.hFileInfo.ioFlAttrib = kioFlAttribDirMask;
-
- /* search for creator; if creator = 0x00000000, ignore creator */
- searchInfo1.hFileInfo.ioFlFndrInfo.fdCreator = creator;
- if ( creator == (OSType)0x00000000 )
- {
- searchInfo2.hFileInfo.ioFlFndrInfo.fdCreator = (OSType)0x00000000;
- }
- else
- {
- searchInfo2.hFileInfo.ioFlFndrInfo.fdCreator = (OSType)0xffffffff;
- }
-
- /* search for fileType; if fileType = 0x00000000, ignore fileType */
- searchInfo1.hFileInfo.ioFlFndrInfo.fdType = fileType;
- if ( fileType == (OSType)0x00000000 )
- {
- searchInfo2.hFileInfo.ioFlFndrInfo.fdType = (OSType)0x00000000;
- }
- else
- {
- searchInfo2.hFileInfo.ioFlFndrInfo.fdType = (OSType)0xffffffff;
- }
-
- /* zero all other FInfo fields */
- searchInfo1.hFileInfo.ioFlFndrInfo.fdFlags = 0;
- searchInfo1.hFileInfo.ioFlFndrInfo.fdLocation.v = 0;
- searchInfo1.hFileInfo.ioFlFndrInfo.fdLocation.h = 0;
- searchInfo1.hFileInfo.ioFlFndrInfo.fdFldr = 0;
-
- searchInfo2.hFileInfo.ioFlFndrInfo.fdFlags = 0;
- searchInfo2.hFileInfo.ioFlFndrInfo.fdLocation.v = 0;
- searchInfo2.hFileInfo.ioFlFndrInfo.fdLocation.h = 0;
- searchInfo2.hFileInfo.ioFlFndrInfo.fdFldr = 0;
-
- error = PBCatSearchSyncCompat((CSParamPtr)&pb);
-
- if ( (error == noErr) || /* If no errors or the end of catalog was */
- (error == eofErr) ) /* found, then the call was successful so */
- {
- *actMatchCount = pb.csParam.ioActMatchCount; /* return the match count */
- }
- else
- {
- *actMatchCount = 0; /* else no matches found */
- }
-
- if ( (error == noErr) || /* If no errors */
- (error == catChangedErr) ) /* or there was a change in the catalog */
- {
- catPosition = pb.csParam.ioCatPosition;
- lastVRefNum = vRefNum;
- /* we can probably start the next search where we stopped this time */
- }
- else
- {
- catPosition.initialize = 0;
- /* start the next search from beginning of catalog */
- }
-
- if ( pb.csParam.ioOptBuffer != NULL )
- {
- DisposePtr(pb.csParam.ioOptBuffer);
- }
-
- return ( error );
-}
-
-/*****************************************************************************/
+++ /dev/null
-/*
- File: Search.h
-
- Contains: IndexedSearch and the PBCatSearch compatibility function.
-
- Version: Technology: MoreFiles
- Release: 1.5.2
-
- Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: For bug reports, consult the following page on
- the World Wide Web:
-
- http://developer.apple.com/bugreporter/
-
-*/
-
-/*
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-*/
-
-#ifndef __SEARCH__
-#define __SEARCH__
-
-#ifndef __MACTYPES__
-#include <MacTypes.h>
-#endif
-
-#ifndef __FILES__
-#include <Files.h>
-#endif
-
-#include "Optimization.h"
-
-
-#if PRAGMA_ONCE
-#pragma once
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if PRAGMA_IMPORT
-#pragma import on
-#endif
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=mac68k
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(push, 2)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack(2)
-#endif
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-IndexedSearch(
- CSParamPtr pb,
- long dirID);
-
-
-/*
- The IndexedSearch function performs an indexed search in and below the
- specified directory using the same parameters (in pb) as is passed to
- PBCatSearch. See Inside Macintosh: Files for a description of the
- parameter block.
-
- pb input: A CSParamPtr record specifying the volume to search
- and the search criteria.
- output: Fields in the parameter block are returned indicating
- the number of matches found, the matches, and if the
- search ended with noErr, the CatPosition record that
- lets you resume a search where the last search left
- off.
- dirID input: The directory to search. If fsRtDirID is passed,
- the entire volume is searched.
-
- Note: If you use a high-level debugger and use ioSearchTime to limit
- the length of time to run the search, you'll want to step over
- calls to IndexedSearch because it installs a Time Manager task.
- Most high-level debuggers don't deal gracefully with interrupt
- driven code.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- eofErr -39 End of catalog found (this is normal!)
- paramErr -50 Parameter block has invalid parameters
- (see source for VerifyUserPB) or
- invalid catPosition record was passed
- extFSErr -58 External file system error - no file
- system claimed this call.
- memFullErr -108 Memory could not be allocated in heap
- catChangedErr -1304 Catalog has changed and catalog position
- record may be invalid
-
- __________
-
- See also: PBCatSearch, PBCatSearchSyncCompat
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-PBCatSearchSyncCompat(CSParamPtr paramBlock);
-
-
-/*
- The PBCatSearchSyncCompat function uses PBCatSearch (if available) or
- IndexedSearch (if PBCatSearch is not available) to search a volume
- using a set of search criteria that you specify. It builds a list of all
- files or directories that meet your specifications.
-
- pb input: A CSParamPtr record specifying the volume to search
- and the search criteria.
- output: Fields in the parameter block are returned indicating
- the number of matches found, the matches, and if the
- search ended with noErr, the CatPosition record that
- lets you resume a search where the last search left
- off.
-
- Note: If you use a high-level debugger and use ioSearchTime to limit
- the length of time to run the search, you'll want to step over
- calls to PBCatSearchSyncCompat because it calls IndexedSearch
- which installs a Time Manager task. Most high-level debuggers
- don't deal gracefully with interrupt driven code.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- eofErr -39 End of catalog found (this is normal!)
- paramErr -50 Parameter block has invalid parameters
- (see source for VerifyUserPB) or
- invalid catPosition record was passed
- extFSErr -58 External file system error - no file
- system claimed this call.
- memFullErr -108 Memory could not be allocated in heap
- catChangedErr -1304 Catalog has changed and catalog position
- record may be invalid
- afpCatalogChanged -5037 Catalog has changed and search cannot
- be resumed
-
- __________
-
- See also: PBCatSearch, IndexedSearch
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-NameFileSearch(
- ConstStr255Param volName,
- short vRefNum,
- ConstStr255Param fileName,
- FSSpecPtr matches,
- long reqMatchCount,
- long * actMatchCount,
- Boolean newSearch,
- Boolean partial);
-
-
-/*
- The NameFileSearch function searches for files with a specific file
- name on a volume that supports PBCatSearch.
- Note: A result of catChangedErr means the catalog has changed between
- searches, but the search can be continued with the possiblity that you
- may miss some matches or get duplicate matches. For all other results
- (except for noErr), the search cannot be continued.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- fileName input: The name of the file to search for.
- matches input: Pointer to array of FSSpec where the match list is
- returned.
- reqMatchCount input: Maximum number of matches to return (the number of
- elements in the matches array).
- actMatchCount output: The number of matches actually returned.
- newSearch input: If true, start a new search. If false and if
- vRefNum is the same as the last call to
- NameFileSearch, then start searching at the
- position where the last search left off.
- partial input: If the partial parameter is false, then only files
- that exactly match fileName will be found. If the
- partial parameter is true, then all file names that
- contain fileName will be found.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- eofErr -39 End of catalog found (this is normal!)
- paramErr -50 Parameter block has invalid parameters
- (see source for VerifyUserPB) or
- invalid catPosition record was passed
- extFSErr -58 External file system error - no file
- system claimed this call.
- memFullErr -108 Memory could not be allocated in heap
- catChangedErr -1304 Catalog has changed and catalog position
- record may be invalid
- afpCatalogChanged -5037 Catalog has changed and search cannot
- be resumed
-
- __________
-
- Also see: CreatorTypeFileSearch
-*/
-
-/*****************************************************************************/
-
-EXTERN_API( OSErr )
-CreatorTypeFileSearch(
- ConstStr255Param volName,
- short vRefNum,
- OSType creator,
- OSType fileType,
- FSSpecPtr matches,
- long reqMatchCount,
- long * actMatchCount,
- Boolean newSearch);
-
-
-/*
- The CreatorTypeFileSearch function searches for files with a specific
- creator or fileType on a volume that supports PBCatSearch.
- Note: A result of catChangedErr means the catalog has changed between
- searches, but the search can be continued with the possiblity that you
- may miss some matches or get duplicate matches. For all other results
- (except for noErr), the search cannot be continued.
-
- volName input: A pointer to the name of a mounted volume
- or nil.
- vRefNum input: Volume specification.
- creator input: The creator type of the file to search for.
- To ignore the creator type, pass 0x00000000 in
- this field.
- fileType input: The file type of the file to search for.
- To ignore the file type, pass 0x00000000 in
- this field.
- matches input: Pointer to array of FSSpec where the match list is
- returned.
- reqMatchCount input: Maximum number of matches to return (the number of
- elements in the matches array).
- actMatchCount output: The number of matches actually returned.
- newSearch input: If true, start a new search. If false and if
- vRefNum is the same as the last call to
- CreatorTypeFileSearch, then start searching at the
- position where the last search left off.
-
- Result Codes
- noErr 0 No error
- nsvErr -35 Volume not found
- ioErr -36 I/O error
- eofErr -39 End of catalog found (this is normal!)
- paramErr -50 Parameter block has invalid parameters
- (see source for VerifyUserPB) or
- invalid catPosition record was passed
- extFSErr -58 External file system error - no file
- system claimed this call.
- memFullErr -108 Memory could not be allocated in heap
- catChangedErr -1304 Catalog has changed and catalog position
- record may be invalid
- afpCatalogChanged -5037 Catalog has changed and search cannot
- be resumed
-
- __________
-
- Also see: NameFileSearch
-*/
-
-/*****************************************************************************/
-
-#include "OptimizationEnd.h"
-
-#if PRAGMA_STRUCT_ALIGN
- #pragma options align=reset
-#elif PRAGMA_STRUCT_PACKPUSH
- #pragma pack(pop)
-#elif PRAGMA_STRUCT_PACK
- #pragma pack()
-#endif
-
-#ifdef PRAGMA_IMPORT_OFF
-#pragma import off
-#elif PRAGMA_IMPORT
-#pragma import reset
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SEARCH__ */
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/msgdlg.cpp
-// Purpose: wxMessageDialog
-// Author: Stefan Csomor
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// for compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#include "wx/msgdlg.h"
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/app.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
-
-wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
- long style, const wxPoint& pos)
-{
- m_caption = caption;
- m_message = message;
- m_parent = parent;
- SetMessageDialogStyle(style);
-}
-
-int wxMessageDialog::ShowModal()
-{
- int resultbutton = wxID_CANCEL ;
-
- short result ;
-
- const long style = GetMessageDialogStyle();
-
- wxASSERT_MSG( ( style & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;
-
- AlertType alertType = kAlertPlainAlert ;
- if (style & wxICON_EXCLAMATION)
- alertType = kAlertNoteAlert ;
- else if (style & wxICON_HAND)
- alertType = kAlertStopAlert ;
- else if (style & wxICON_INFORMATION)
- alertType = kAlertNoteAlert ;
- else if (style & wxICON_QUESTION)
- alertType = kAlertCautionAlert ;
-
-#if TARGET_CARBON
- if ( UMAGetSystemVersion() >= 0x1000 )
- {
- AlertStdCFStringAlertParamRec param ;
- wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
- wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;
-
- wxMacCFStringHolder cfTitle(m_caption , m_font.GetEncoding());
- wxMacCFStringHolder cfText(m_message , m_font.GetEncoding());
-
- param.movable = true;
- param.flags = 0 ;
-
- bool skipDialog = false ;
-
- if (style & wxYES_NO)
- {
- if (style & wxCANCEL)
- {
- param.defaultText = cfYesString ;
- param.cancelText = (CFStringRef) kAlertDefaultCancelText;
- param.otherText = cfNoString ;
- param.helpButton = false ;
- param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = kAlertStdAlertCancelButton;
- }
- else
- {
- param.defaultText = cfYesString ;
- param.cancelText = NULL;
- param.otherText = cfNoString ;
- param.helpButton = false ;
- param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
- }
- }
- // the msw implementation even shows an ok button if it is not specified, we'll do the same
- else
- {
- if (style & wxCANCEL)
- {
- // thats a cancel missing
- param.defaultText = (CFStringRef) kAlertDefaultOKText ;
- param.cancelText = (CFStringRef) kAlertDefaultCancelText ;
- param.otherText = NULL;
- param.helpButton = false ;
- param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
- }
- else
- {
- param.defaultText = (CFStringRef) kAlertDefaultOKText ;
- param.cancelText = NULL;
- param.otherText = NULL;
- param.helpButton = false ;
- param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
- }
- }
- /*
- else
- {
- skipDialog = true ;
- }
- */
-
- param.position = kWindowDefaultPosition;
- if ( !skipDialog )
- {
- DialogRef alertRef ;
- CreateStandardAlert( alertType , cfTitle , cfText , ¶m , &alertRef ) ;
- RunStandardAlert( alertRef , NULL , &result ) ;
- }
- if ( skipDialog )
- return wxID_CANCEL ;
- }
- else
-#endif
- {
- AlertStdAlertParamRec param;
-
- Str255 yesPString ;
- Str255 noPString ;
-
- Str255 pascalTitle ;
- Str255 pascalText ;
- wxMacStringToPascal( m_caption , pascalTitle ) ;
- wxMacStringToPascal( _("Yes") , yesPString ) ;
- wxMacStringToPascal( _("No") , noPString ) ;
- wxMacStringToPascal( m_message , pascalText ) ;
-
- param.movable = true;
- param.filterProc = NULL ;
- if (style & wxYES_NO)
- {
- if (style & wxCANCEL)
- {
- param.defaultText = yesPString ;
- param.cancelText = (StringPtr) kAlertDefaultCancelText;
- param.otherText = noPString ;
- param.helpButton = false ;
- param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = kAlertStdAlertCancelButton;
- }
- else
- {
- param.defaultText = yesPString ;
- param.cancelText = NULL;
- param.otherText = noPString ;
- param.helpButton = false ;
- param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
- }
- }
- else if (style & wxOK)
- {
- if (style & wxCANCEL)
- {
- param.defaultText = (StringPtr) kAlertDefaultOKText ;
- param.cancelText = (StringPtr) kAlertDefaultCancelText ;
- param.otherText = NULL;
- param.helpButton = false ;
- param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
- }
- else
- {
- param.defaultText = (StringPtr) kAlertDefaultOKText ;
- param.cancelText = NULL;
- param.otherText = NULL;
- param.helpButton = false ;
- param.defaultButton = kAlertStdAlertOKButton;
- param.cancelButton = 0;
- }
- }
- else
- {
- return resultbutton ;
- }
-
- param.position = 0;
-
- StandardAlert( alertType, pascalTitle, pascalText, ¶m, &result );
- }
-
- if (style & wxOK)
- {
- if (style & wxCANCEL)
- {
- //TODO add Cancelbutton
- switch( result )
- {
- case 1 :
- resultbutton = wxID_OK ;
- break ;
- case 2 :
- break ;
- case 3 :
- break ;
- }
- }
- else
- {
- switch( result )
- {
- case 1 :
- resultbutton = wxID_OK ;
- break ;
- case 2 :
- break ;
- case 3 :
- break ;
- }
- }
- }
- else if (style & wxYES_NO)
- {
- if (style & wxCANCEL)
- {
- switch( result )
- {
- case 1 :
- resultbutton = wxID_YES ;
- break ;
- case 2 :
- resultbutton = wxID_CANCEL ;
- break ;
- case 3 :
- resultbutton = wxID_NO ;
- break ;
- }
- }
- else
- {
- switch( result )
- {
- case 1 :
- resultbutton = wxID_YES ;
- break ;
- case 2 :
- break ;
- case 3 :
- resultbutton = wxID_NO ;
- break ;
- }
- }
- }
-
- return resultbutton ;
-}
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/notebmac.cpp
-// Purpose: implementation of wxNotebook
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#include "wx/notebook.h"
-
-#ifndef WX_PRECOMP
- #include "wx/string.h"
- #include "wx/log.h"
- #include "wx/app.h"
- #include "wx/image.h"
-#endif
-
-#include "wx/imaglist.h"
-#include "wx/mac/uma.h"
-// ----------------------------------------------------------------------------
-// macros
-// ----------------------------------------------------------------------------
-
-// check that the page index is valid
-#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
-
-
-// ----------------------------------------------------------------------------
-// event table
-// ----------------------------------------------------------------------------
-
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
-
-BEGIN_EVENT_TABLE(wxNotebook, wxControl)
- EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
- EVT_MOUSE_EVENTS(wxNotebook::OnMouse)
-
- EVT_SIZE(wxNotebook::OnSize)
- EVT_SET_FOCUS(wxNotebook::OnSetFocus)
- EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
-END_EVENT_TABLE()
-
-IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// The Appearance Manager docs show using tab controls in either edge to edge
-// mode, or inset. I think edge to edge conforms better to the other ports,
-// and inset mode is better accomplished with space around the wxNotebook rather
-// than within it. --Robin
-
-// CS : had to switch off tight spacing due to 10.3 problems
-#define wxMAC_EDGE_TO_EDGE 0
-
-static inline int wxMacTabMargin(long nbStyle, long side)
-{
- static int tabMargin = -1;
- static int otherMargin = -1;
-
- if ( tabMargin == -1)
- {
- if ( UMAHasAquaLayout() )
- {
- tabMargin = 26; // From Appearance Manager docs for small tab control dimensions
-#if wxMAC_EDGE_TO_EDGE
- otherMargin = 0;
-#else
-// otherMargin = 20;
- // JACS - this seems fine on 10.3; 20 is way too much
- otherMargin = 8;
-#endif
- }
- else
- {
- tabMargin = 30;
-#if wxMAC_EDGE_TO_EDGE
- otherMargin = 0;
-#else
- otherMargin = 16;
-#endif
- }
- }
-
- // If the style matches the side asked for then return the tab margin,
- // but we have to special case wxBK_TOP since it is zero...
- if ( side == wxBK_TOP)
- {
- if ( nbStyle != 0 && nbStyle & (wxBK_LEFT|wxBK_RIGHT|wxBK_BOTTOM))
- {
- return otherMargin;
- }
- else
- {
- return tabMargin;
- }
- }
- else if ( nbStyle & side)
- return tabMargin;
- else
- return otherMargin;
-}
-
-static inline int wxMacTabLeftMargin(long style)
-{
- return wxMacTabMargin(style, wxBK_LEFT);
-}
-
-static inline int wxMacTabTopMargin(long style)
-{
- return wxMacTabMargin(style, wxBK_TOP);
-}
-
-static inline int wxMacTabRightMargin(long style)
-{
- return wxMacTabMargin(style, wxBK_RIGHT);
-}
-
-static inline int wxMacTabBottomMargin(long style)
-{
- return wxMacTabMargin(style, wxBK_BOTTOM);
-}
-
-// ----------------------------------------------------------------------------
-// wxNotebook construction
-// ----------------------------------------------------------------------------
-
-// common part of all ctors
-void wxNotebook::Init()
-{
- if ( UMAHasAquaLayout() )
- {
- // Should these depend on wxMAC_EDGE_TO_EDGE too?
- m_macHorizontalBorder = 7;
- m_macVerticalBorder = 8;
- }
-
- m_nSelection = -1;
-}
-
-// default for dynamic class
-wxNotebook::wxNotebook()
-{
- Init();
-}
-
-// the same arguments as for wxControl
-wxNotebook::wxNotebook(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- Init();
-
- Create(parent, id, pos, size, style, name);
-}
-
-// Create() function
-bool wxNotebook::Create(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- if ( !wxNotebookBase::Create(parent, id, pos, size, style, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
- style |= wxBK_TOP;
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, wxDefaultValidator , name , &bounds , title ) ;
-
- int tabstyle = kControlTabSmallNorthProc ;
- if ( HasFlag(wxBK_LEFT) )
- tabstyle = kControlTabSmallWestProc ;
- else if ( HasFlag( wxBK_RIGHT ) )
- tabstyle = kControlTabSmallEastProc ;
- else if ( HasFlag( wxBK_BOTTOM ) )
- tabstyle = kControlTabSmallSouthProc ;
-
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
- tabstyle , (long) this ) ;
-
- MacPostControlCreate() ;
- return true ;
-}
-
-// dtor
-wxNotebook::~wxNotebook()
-{
-}
-
-// ----------------------------------------------------------------------------
-// wxNotebook accessors
-// ----------------------------------------------------------------------------
-
-void wxNotebook::SetPadding(const wxSize& padding)
-{
- // unsupported by OS
-}
-
-void wxNotebook::SetTabSize(const wxSize& sz)
-{
- // unsupported by OS
-}
-
-void wxNotebook::SetPageSize(const wxSize& size)
-{
- SetSize( CalcSizeFromPage( size ) );
-}
-
-wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
-{
- wxSize sizeTotal = sizePage;
- sizeTotal.x += 2 * m_macHorizontalBorder + wxMacTabLeftMargin(GetWindowStyle()) +
- wxMacTabRightMargin(GetWindowStyle()) ;
- sizeTotal.y += 2 * m_macVerticalBorder + wxMacTabTopMargin(GetWindowStyle()) +
- wxMacTabBottomMargin(GetWindowStyle()) ;
-
- return sizeTotal;
-}
-
-wxSize wxNotebook::DoGetBestSize() const
-{
- // calculate the max page size
- wxSize size(0, 0);
-
- size_t count = GetPageCount();
- if ( count )
- {
- for ( size_t n = 0; n < count; n++ )
- {
- wxSize sizePage = m_pages[n]->GetSize();
-
- if ( size.x < sizePage.x )
- size.x = sizePage.x;
- if ( size.y < sizePage.y )
- size.y = sizePage.y;
- }
- }
- else // no pages
- {
- // use some arbitrary default size
- size.x =
- size.y = 100;
- }
-
- return CalcSizeFromPage(size);
-}
-
-int wxNotebook::SetSelection(size_t nPage)
-{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
-
- if ( int(nPage) != m_nSelection )
- {
- wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
- event.SetSelection(nPage);
- event.SetOldSelection(m_nSelection);
- event.SetEventObject(this);
- if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
- {
- // program allows the page change
- event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
- (void)GetEventHandler()->ProcessEvent(event);
-
- ChangePage(m_nSelection, nPage);
- }
- }
-
- return m_nSelection;
-}
-
-bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
-{
- wxASSERT( IS_VALID_PAGE(nPage) );
-
- wxNotebookPage *page = m_pages[nPage];
- page->SetLabel(strText);
- MacSetupTabs();
-
- return true;
-}
-
-wxString wxNotebook::GetPageText(size_t nPage) const
-{
- wxASSERT( IS_VALID_PAGE(nPage) );
-
- wxNotebookPage *page = m_pages[nPage];
- return page->GetLabel();
-}
-
-int wxNotebook::GetPageImage(size_t nPage) const
-{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, _T("invalid notebook page") );
-
- return m_images[nPage];
-}
-
-bool wxNotebook::SetPageImage(size_t nPage, int nImage)
-{
- wxCHECK_MSG( IS_VALID_PAGE(nPage), false, _T("invalid notebook page") );
-
- wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), false,
- _T("invalid image index in SetPageImage()") );
-
- if ( nImage != m_images[nPage] )
- {
- // if the item didn't have an icon before or, on the contrary, did have
- // it but has lost it now, its size will change - but if the icon just
- // changes, it won't
- m_images[nPage] = nImage;
-
- MacSetupTabs() ;
- }
-
- return true;
-}
-
-// ----------------------------------------------------------------------------
-// wxNotebook operations
-// ----------------------------------------------------------------------------
-
-// remove one page from the notebook, without deleting the window
-wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage)
-{
- wxCHECK( IS_VALID_PAGE(nPage), NULL );
- wxNotebookPage* page = m_pages[nPage] ;
- m_pages.RemoveAt(nPage);
-
- MacSetupTabs();
-
- if(m_nSelection >= (int)GetPageCount()) {
- m_nSelection = GetPageCount() - 1;
- }
- if(m_nSelection >= 0) {
- m_pages[m_nSelection]->Show(true);
- }
- InvalidateBestSize();
- return page;
-}
-
-// remove all pages
-bool wxNotebook::DeleteAllPages()
-{
- WX_CLEAR_ARRAY(m_pages) ;
- MacSetupTabs();
- m_nSelection = -1 ;
- InvalidateBestSize();
- return true;
-}
-
-
-// same as AddPage() but does it at given position
-bool wxNotebook::InsertPage(size_t nPage,
- wxNotebookPage *pPage,
- const wxString& strText,
- bool bSelect,
- int imageId)
-{
- if ( !wxNotebookBase::InsertPage(nPage, pPage, strText, bSelect, imageId) )
- return false;
-
- wxASSERT_MSG( pPage->GetParent() == this,
- _T("notebook pages must have notebook as parent") );
-
- // don't show pages by default (we'll need to adjust their size first)
- pPage->Show( false ) ;
-
- pPage->SetLabel(strText);
-
- m_images.Insert(imageId, nPage);
-
- MacSetupTabs();
-
- wxRect rect = GetPageRect() ;
- pPage->SetSize(rect);
- if ( pPage->GetAutoLayout() ) {
- pPage->Layout();
- }
-
-
- // now deal with the selection
- // ---------------------------
-
- // if the inserted page is before the selected one, we must update the
- // index of the selected page
-
- if ( int(nPage) <= m_nSelection )
- {
- m_nSelection++;
- // while this still is the same page showing, we need to update the tabs
- SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ;
- }
-
- // some page should be selected: either this one or the first one if there
- // is still no selection
- int selNew = -1;
- if ( bSelect )
- selNew = nPage;
- else if ( m_nSelection == -1 )
- selNew = 0;
-
- if ( selNew != -1 )
- SetSelection(selNew);
-
- InvalidateBestSize();
- return true;
-}
-
-/* Added by Mark Newsam
-* When a page is added or deleted to the notebook this function updates
-* information held in the m_macControl so that it matches the order
-* the user would expect.
-*/
-void wxNotebook::MacSetupTabs()
-{
- SetControl32BitMaximum( (ControlHandle) m_macControl , GetPageCount() ) ;
-
- wxNotebookPage *page;
- ControlTabInfoRec info;
-
- const size_t countPages = GetPageCount();
- for(size_t ii = 0; ii < countPages; ii++)
- {
- page = m_pages[ii];
- info.version = 0;
- info.iconSuiteID = 0;
- wxMacStringToPascal( page->GetLabel() , info.name ) ;
-
- SetControlData( (ControlHandle) m_macControl, ii+1, kControlTabInfoTag,
- sizeof( ControlTabInfoRec) , (char*) &info ) ;
- SetTabEnabled( (ControlHandle) m_macControl , ii+1 , true ) ;
-#if TARGET_CARBON
- if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
- {
- // tab controls only support very specific types of images, therefore we are doing an odyssee
- // accross the icon worlds (even Apple DTS did not find a shorter path)
- // in order not to pollute the icon registry we put every icon into (OSType) 1 and immediately
- // afterwards Unregister it (IconRef is ref counted, so it will stay on the tab even if we
- // unregister it) in case this will ever lead to having the same icon everywhere add some kind
- // of static counter
- const wxBitmap* bmap = GetImageList()->GetBitmapPtr( GetPageImage(ii ) ) ;
- if ( bmap )
- {
- wxBitmap scaledBitmap ;
- if ( bmap->GetWidth() != 16 || bmap->GetHeight() != 16 )
- {
- scaledBitmap = wxBitmap( bmap->ConvertToImage().Scale(16,16) ) ;
- bmap = &scaledBitmap ;
- }
- ControlButtonContentInfo info ;
- wxMacCreateBitmapButton( &info , *bmap , kControlContentPictHandle) ;
- IconFamilyHandle iconFamily = (IconFamilyHandle) NewHandle(0) ;
- OSErr err = SetIconFamilyData( iconFamily, 'PICT' , (Handle) info.u.picture ) ;
- wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
- IconRef iconRef ;
- err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) 1, iconFamily, &iconRef ) ;
- wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
- info.contentType = kControlContentIconRef ;
- info.u.iconRef = iconRef ;
- SetControlData( (ControlHandle) m_macControl, ii+1,kControlTabImageContentTag,
- sizeof( info ), (Ptr)&info );
- wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;
- if ( UMAGetSystemVersion() < 0x1030 )
- {
- UnregisterIconRef( 'WXNG' , (OSType) 1 ) ;
- }
-
- ReleaseIconRef( iconRef ) ;
- DisposeHandle( (Handle) iconFamily ) ;
- }
- }
-#endif
- }
- Rect bounds;
- GetControlBounds((ControlHandle)m_macControl, &bounds);
- InvalWindowRect((WindowRef)MacGetRootWindow(), &bounds);
-}
-
-wxRect wxNotebook::GetPageRect() const
-{
- // fit the notebook page to the tab control's display area
- int w, h;
- GetSize(&w, &h);
-
- return wxRect(
- wxMacTabLeftMargin(GetWindowStyle()) + m_macHorizontalBorder,
- wxMacTabTopMargin(GetWindowStyle()) + m_macVerticalBorder,
- w - wxMacTabLeftMargin(GetWindowStyle()) - wxMacTabRightMargin(GetWindowStyle()) - 2*m_macHorizontalBorder,
- h - wxMacTabTopMargin(GetWindowStyle()) - wxMacTabBottomMargin(GetWindowStyle()) - 2*m_macVerticalBorder);
-}
-// ----------------------------------------------------------------------------
-// wxNotebook callbacks
-// ----------------------------------------------------------------------------
-
-// @@@ OnSize() is used for setting the font when it's called for the first
-// time because doing it in ::Create() doesn't work (for unknown reasons)
-void wxNotebook::OnSize(wxSizeEvent& event)
-{
-
- unsigned int nCount = m_pages.Count();
- wxRect rect = GetPageRect() ;
- for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
- wxNotebookPage *pPage = m_pages[nPage];
- pPage->SetSize(rect);
- if ( pPage->GetAutoLayout() ) {
- pPage->Layout();
- }
- }
-
- // Processing continues to next OnSize
- event.Skip();
-}
-
-void wxNotebook::OnSelChange(wxNotebookEvent& event)
-{
- // is it our tab control?
- if ( event.GetEventObject() == this )
- ChangePage(event.GetOldSelection(), event.GetSelection());
-
- // we want to give others a chance to process this message as well
- event.Skip();
-}
-
-void wxNotebook::OnSetFocus(wxFocusEvent& event)
-{
- // set focus to the currently selected page if any
- if ( m_nSelection != -1 )
- m_pages[m_nSelection]->SetFocus();
-
- event.Skip();
-}
-
-void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
-{
- if ( event.IsWindowChange() ) {
- // change pages
- AdvanceSelection(event.GetDirection());
- }
- else {
- // we get this event in 2 cases
- //
- // a) one of our pages might have generated it because the user TABbed
- // out from it in which case we should propagate the event upwards and
- // our parent will take care of setting the focus to prev/next sibling
- //
- // or
- //
- // b) the parent panel wants to give the focus to us so that we
- // forward it to our selected page. We can't deal with this in
- // OnSetFocus() because we don't know which direction the focus came
- // from in this case and so can't choose between setting the focus to
- // first or last panel child
- wxWindow *parent = GetParent();
- // the cast is here to fic a GCC ICE
- if ( ((wxWindow*)event.GetEventObject()) == parent )
- {
- // no, it doesn't come from child, case (b): forward to a page
- if ( m_nSelection != -1 )
- {
- // so that the page knows that the event comes from it's parent
- // and is being propagated downwards
- event.SetEventObject(this);
-
- wxWindow *page = m_pages[m_nSelection];
- if ( !page->GetEventHandler()->ProcessEvent(event) )
- {
- page->SetFocus();
- }
- //else: page manages focus inside it itself
- }
- else
- {
- // we have no pages - still have to give focus to _something_
- SetFocus();
- }
- }
- else
- {
- // it comes from our child, case (a), pass to the parent
- if ( parent ) {
- event.SetCurrentFocus(this);
- parent->GetEventHandler()->ProcessEvent(event);
- }
- }
- }
-}
-
-// ----------------------------------------------------------------------------
-// wxNotebook base class virtuals
-// ----------------------------------------------------------------------------
-
-#if wxUSE_CONSTRAINTS
-
-// override these 2 functions to do nothing: everything is done in OnSize
-
-void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
-{
- // don't set the sizes of the pages - their correct size is not yet known
- wxControl::SetConstraintSizes(false);
-}
-
-bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
-{
- return true;
-}
-
-#endif // wxUSE_CONSTRAINTS
-
-void wxNotebook::Command(wxCommandEvent& event)
-{
- wxFAIL_MSG(wxT("wxNotebook::Command not implemented"));
-}
-
-// ----------------------------------------------------------------------------
-// wxNotebook helper functions
-// ----------------------------------------------------------------------------
-
-// hide the currently active panel and show the new one
-void wxNotebook::ChangePage(int nOldSel, int nSel)
-{
- if ( nOldSel != -1 )
- {
- m_pages[nOldSel]->Show(false);
- }
-
- if ( nSel != -1 )
- {
- wxNotebookPage *pPage = m_pages[nSel];
- pPage->Show(true);
- pPage->SetFocus();
- }
-
- m_nSelection = nSel;
- SetControl32BitValue( (ControlHandle) m_macControl , m_nSelection + 1 ) ;
-}
-
-
-void wxNotebook::OnMouse( wxMouseEvent &event )
-{
- if ( (ControlHandle) m_macControl == NULL )
- {
- event.Skip() ;
- return ;
- }
-
- if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
- {
- int x = event.m_x ;
- int y = event.m_y ;
-
- MacClientToRootWindow( &x , &y ) ;
-
- ControlHandle control ;
- Point localwhere ;
- SInt16 controlpart ;
-
- localwhere.h = x ;
- localwhere.v = y ;
-
- short modifiers = 0;
-
- if ( !event.m_leftDown && !event.m_rightDown )
- modifiers |= btnState ;
-
- if ( event.m_shiftDown )
- modifiers |= shiftKey ;
-
- if ( event.m_controlDown )
- modifiers |= controlKey ;
-
- if ( event.m_altDown )
- modifiers |= optionKey ;
-
- if ( event.m_metaDown )
- modifiers |= cmdKey ;
-
- control = (ControlHandle) m_macControl ;
- if ( control && ::IsControlActive( control ) )
- {
- {
- wxNotebookEvent changing(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
- ::GetControl32BitValue(control) - 1, m_nSelection);
- changing.SetEventObject(this);
- GetEventHandler()->ProcessEvent(changing);
-
- if(changing.IsAllowed())
- {
- controlpart = ::HandleControlClick(control, localwhere, modifiers,
- (ControlActionUPP) -1);
- wxTheApp->s_lastMouseDown = 0 ;
-
- wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
- ::GetControl32BitValue(control) - 1, m_nSelection);
- event.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(event);
- }
- }
- }
- }
-}
-
-
-void wxNotebook::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
-{
-#if 0
- wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId , ::GetControl32BitValue((ControlHandle)m_macControl) - 1, m_nSelection);
- event.SetEventObject(this);
-
- ProcessEvent(event);
-#endif
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/palette.cpp
-// Purpose: wxPalette
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_PALETTE
-
-#include "wx/palette.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
-
-/*
- * Palette
- *
- */
-
-wxPaletteRefData::wxPaletteRefData()
-{
- m_palette = NULL ;
- m_count = 0 ;
-}
-
-wxPaletteRefData::~wxPaletteRefData()
-{
- if (m_palette != NULL) {
- delete[] m_palette ;
- m_palette = NULL;
- }
-}
-
-wxPalette::wxPalette()
-{
-}
-
-wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
-{
- Create(n, red, green, blue);
-}
-
-wxPalette::~wxPalette()
-{
-}
-
-bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
-{
- UnRef();
-
- m_refData = new wxPaletteRefData;
-
- M_PALETTEDATA->m_count = n ;
- M_PALETTEDATA->m_palette = new wxColour[n] ;
-
- for ( int i = 0 ; i < n ; ++i)
- {
- M_PALETTEDATA->m_palette[i].Set( red[i] , green[i] , blue[i] ) ;
- }
-
- return false;
-}
-
-int wxPalette::GetPixel(unsigned char red, unsigned char green, unsigned char blue) const
-{
- if ( !m_refData )
- return wxNOT_FOUND;
-
- long bestdiff = 3 * 256 ;
- long bestpos = 0 ;
- long currentdiff ;
-
- for ( int i = 0 ; i < M_PALETTEDATA->m_count ; ++i )
- {
- const wxColour& col = &M_PALETTEDATA->m_palette[i] ;
- currentdiff = abs ( col.Red() - red ) + abs( col.Green() - green ) + abs ( col.Blue() - blue ) ;
- if ( currentdiff < bestdiff )
- {
- bestdiff = currentdiff ;
- bestpos = i ;
- if ( bestdiff == 0 )
- break ;
- }
- }
-
- return bestpos;
-}
-
-bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
-{
- if ( !m_refData )
- return false;
-
- if (index < 0 || index >= M_PALETTEDATA->m_count)
- return false;
-
- const wxColour& col = &M_PALETTEDATA->m_palette[index] ;
- *red = col.Red() ;
- *green = col.Green() ;
- *blue = col.Blue() ;
-
- return true;
-}
-
-#endif
-// wxUSE_PALETTE
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/pen.cpp
-// Purpose: wxPen
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/pen.h"
-
-#ifndef WX_PRECOMP
- #include "wx/utils.h"
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
-
-wxPenRefData::wxPenRefData()
-{
- m_style = wxSOLID;
- m_width = 1;
- m_join = wxJOIN_ROUND ;
- m_cap = wxCAP_ROUND ;
- m_nbDash = 0 ;
- m_dash = 0 ;
-}
-
-wxPenRefData::wxPenRefData(const wxPenRefData& data)
-: wxGDIRefData()
-{
- m_style = data.m_style;
- m_width = data.m_width;
- m_join = data.m_join;
- m_cap = data.m_cap;
- m_nbDash = data.m_nbDash;
- m_dash = data.m_dash;
- m_colour = data.m_colour;
-}
-
-wxPenRefData::~wxPenRefData()
-{
-}
-
-// Pens
-
-wxPen::wxPen()
-{
-}
-
-wxPen::~wxPen()
-{
-}
-
-// Should implement Create
-wxPen::wxPen(const wxColour& col, int Width, int Style)
-{
- m_refData = new wxPenRefData;
-
- M_PENDATA->m_colour = col;
- M_PENDATA->m_width = Width;
- M_PENDATA->m_style = Style;
- M_PENDATA->m_join = wxJOIN_ROUND ;
- M_PENDATA->m_cap = wxCAP_ROUND ;
- M_PENDATA->m_nbDash = 0 ;
- M_PENDATA->m_dash = 0 ;
-
- RealizeResource();
-}
-
-wxPen::wxPen(const wxBitmap& stipple, int Width)
-{
- m_refData = new wxPenRefData;
-
- M_PENDATA->m_stipple = stipple;
- M_PENDATA->m_width = Width;
- M_PENDATA->m_style = wxSTIPPLE;
- M_PENDATA->m_join = wxJOIN_ROUND ;
- M_PENDATA->m_cap = wxCAP_ROUND ;
- M_PENDATA->m_nbDash = 0 ;
- M_PENDATA->m_dash = 0 ;
-
- RealizeResource();
-}
-
-void wxPen::Unshare()
-{
- // Don't change shared data
- if (!m_refData)
- {
- m_refData = new wxPenRefData();
- }
- else
- {
- wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
-}
-
-void wxPen::SetColour(const wxColour& col)
-{
- Unshare();
-
- M_PENDATA->m_colour = col;
-
- RealizeResource();
-}
-
-void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
-{
- Unshare();
-
- M_PENDATA->m_colour.Set(r, g, b);
-
- RealizeResource();
-}
-
-void wxPen::SetWidth(int Width)
-{
- Unshare();
-
- M_PENDATA->m_width = Width;
-
- RealizeResource();
-}
-
-void wxPen::SetStyle(int Style)
-{
- Unshare();
-
- M_PENDATA->m_style = Style;
-
- RealizeResource();
-}
-
-void wxPen::SetStipple(const wxBitmap& Stipple)
-{
- Unshare();
-
- M_PENDATA->m_stipple = Stipple;
- M_PENDATA->m_style = wxSTIPPLE;
-
- RealizeResource();
-}
-
-void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
-{
- Unshare();
-
- M_PENDATA->m_nbDash = nb_dashes;
- M_PENDATA->m_dash = (wxDash *)Dash;
-
- RealizeResource();
-}
-
-void wxPen::SetJoin(int Join)
-{
- Unshare();
-
- M_PENDATA->m_join = Join;
-
- RealizeResource();
-}
-
-void wxPen::SetCap(int Cap)
-{
- Unshare();
-
- M_PENDATA->m_cap = Cap;
-
- RealizeResource();
-}
-
-bool wxPen::RealizeResource()
-{
- // nothing to do here for mac
- return true;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: pnghand.cpp
-// Purpose: Implements a PNG reader class + handler
-// Author: Julian Smart
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
-# pragma hdrstop
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#if wxUSE_IOSTREAMH
-# include <fstream.h>
-#else
-# include <fstream>
-#endif
-
-#ifndef __DARWIN__
-# include <windows.h>
-#endif
-#include "wx/msgdlg.h"
-#include "wx/palette.h"
-#include "wx/bitmap.h"
-#include "wx/mac/pnghand.h"
-#include "wx/mac/pngread.h"
-#include "wx/mac/private.h"
-
-extern "C" {
-#include "png.h"
-}
-
-extern "C" void png_read_init PNGARG((png_structp png_ptr));
-extern "C" void png_write_init PNGARG((png_structp png_ptr));
-
-extern CTabHandle wxMacCreateColorTable( int numColors ) ;
-extern void wxMacDestroyColorTable( CTabHandle colors ) ;
-extern void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
-extern GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;
-extern void wxMacDestroyGWorld( GWorldPtr gw ) ;
-
-void
-ima_png_error(png_struct *png_ptr, char *message)
-{
- wxMessageBox(wxString::FromAscii(message), wxT("PNG error"));
- longjmp(png_ptr->jmpbuf, 1);
-}
-
-
-// static wxGifReaderIter* iter;
-wxPalette *wxCopyPalette(const wxPalette *cmap);
-
-wxPNGReader::wxPNGReader(void)
-{
- filetype = 0;
- RawImage = NULL; // Image data
-
- Width = 0; Height = 0; // Dimensions
- Depth = 0; // (bits x pixel)
- ColorType = 0; // Bit 1 = Palette used
- // Bit 2 = Color used
- // Bit 3 = Alpha used
-
- EfeWidth = 0; // Efective Width
-
- lpbi = NULL;
- bgindex = -1;
- m_palette = 0;
- imageOK = FALSE;
-}
-
-wxPNGReader::wxPNGReader ( char* ImageFileName )
-{
- imageOK = FALSE;
- filetype = 0;
- RawImage = NULL; // Image data
-
- Width = 0; Height = 0; // Dimensions
- Depth = 0; // (bits x pixel)
- ColorType = 0; // Bit 1 = m_palette used
- // Bit 2 = Color used
- // Bit 3 = Alpha used
-
- EfeWidth = 0; // Efective Width
-
- lpbi = NULL;
- bgindex = -1;
- m_palette = 0;
-
- imageOK = ReadFile (ImageFileName);
-}
-
-void
-wxPNGReader::Create(int width, int height, int depth, int colortype)
-{
- Width = width; Height = height; Depth = depth;
- ColorType = (colortype>=0) ? colortype: ((Depth>8) ? COLORTYPE_COLOR: 0);
- delete m_palette;
- m_palette = NULL;
- delete[] RawImage;
- RawImage = NULL;
-
- if (lpbi) {
- wxMacDestroyGWorld( (GWorldPtr) lpbi ) ;
- }
- lpbi = wxMacCreateGWorld( Width , Height , Depth);
- if (lpbi)
- {
- EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
- int bitwidth = width ;
- if ( EfeWidth > bitwidth )
- bitwidth = EfeWidth ;
-
- RawImage = (byte*) new char[ ( bitwidth * Height * ((Depth+7)>>3) ) ];
- imageOK = TRUE;
- }
-}
-
-wxPNGReader::~wxPNGReader ( )
-{
- if (RawImage != NULL) {
- delete[] RawImage ;
- RawImage = NULL;
- }
- if (lpbi) {
- wxMacDestroyGWorld( (GWorldPtr) lpbi ) ;
- lpbi = NULL;
- }
- if (m_palette != NULL) {
- delete m_palette;
- m_palette = NULL;
- }
-}
-
-
-int wxPNGReader::GetIndex(int x, int y)
-{
- if (!Inside(x, y) || (Depth>8)) return -1;
-
- ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
- int index = (int)(*ImagePointer);
- return index;
-}
-
-bool wxPNGReader::GetRGB(int x, int y, byte* r, byte* g, byte* b)
-{
- if (!Inside(x, y)) return FALSE;
-
- if (m_palette) {
- return m_palette->GetRGB(GetIndex(x, y), r, g, b);
- /* PALETTEENTRY entry;
- ::GetPaletteEntries((HPALETTE) m_palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
- *r = entry.peRed;
- *g = entry.peGreen;
- *b = entry.peBlue; */
- } else {
- ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
- *b = ImagePointer[0];
- *g = ImagePointer[1];
- *r = ImagePointer[2];
- }
- return TRUE;
-}
-
-
-bool wxPNGReader::SetIndex(int x, int y, int index)
-{
- if (!Inside(x, y) || (Depth>8)) return FALSE;
-
- ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
- *ImagePointer = index;
-
- return TRUE;
-}
-
-bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b)
-{
- if (!Inside(x, y)) return FALSE;
-
- if (ColorType & COLORTYPE_PALETTE)
- {
- if (!m_palette) return FALSE;
- SetIndex(x, y, m_palette->GetPixel(r, g, b));
-
- } else {
- ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3);
- ImagePointer[0] = b;
- ImagePointer[1] = g;
- ImagePointer[2] = r;
- }
-
- return TRUE;
-}
-
-bool wxPNGReader::SetPalette(wxPalette* colourmap)
-{
- delete m_palette ;
- if (!colourmap)
- return FALSE;
- ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
- m_palette = new wxPalette( *colourmap );
- return true ;
- // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
-}
-
-bool
-wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b)
-{
- delete m_palette ;
- m_palette = new wxPalette();
- if (!m_palette)
- return FALSE;
-
- if (!g) g = r;
- if (!b) b = g;
- m_palette->Create(n, r, g, b);
- ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
- return true ;
- // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
-}
-
-bool
-wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct)
-{
- delete m_palette ;
- m_palette = new wxPalette();
- if (!m_palette)
- return FALSE;
-
- byte r[256], g[256], b[256];
-
- for(int i=0; i<n; i++)
- {
- r[i] = rgb_struct[i].red;
- g[i] = rgb_struct[i].green;
- b[i] = rgb_struct[i].blue;
- }
- // Added by JACS copying from Andrew Davison's additions
- // to GIF-reading code
- // Make transparency colour black...
- if (bgindex != -1)
- r[bgindex] = g[bgindex] = b[bgindex] = 0;
-
- m_palette->Create(n, r, g, b);
- ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR);
- return true ;
- // return (DibSetUsage(lpbi, (HPALETTE) m_palette->GetHPALETTE(), WXIMA_COLORS ) != 0);
-}
-
-void wxPNGReader::NullData()
-{
- if (lpbi) {
- wxMacDestroyGWorld( (GWorldPtr) lpbi ) ;
- lpbi = NULL;
- }
- if (m_palette != NULL) {
- delete m_palette;
- m_palette = NULL;
- }
-}
-
-wxBitmap* wxPNGReader::GetBitmap(void)
-{
- wxBitmap *bitmap = new wxBitmap;
- if ( InstantiateBitmap(bitmap) )
- return bitmap;
- else
- {
- delete bitmap;
- return NULL;
- }
-}
-
-bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap)
-{
- if ( lpbi )
- {
- bitmap->SetHBITMAP((WXHBITMAP) lpbi);
- bitmap->SetWidth(GetWidth());
- bitmap->SetHeight(GetHeight());
- bitmap->SetDepth(GetDepth());
- if ( GetDepth() > 1 && m_palette )
- bitmap->SetPalette(*m_palette);
- bitmap->SetOk(TRUE);
-
-
- // Make a mask if appropriate
- /*
- if ( bgindex > -1 )
- {
- wxMask *mask = CreateMask();
- bitmap->SetMask(mask);
- }
- */
- lpbi = NULL ; // bitmap has taken over ownership
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- /*
- HDC dc = ::CreateCompatibleDC(NULL);
-
- if (dc)
- {
- // tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it
- // is a memory dc that must have a bitmap selected into it)
- HDC dc2 = GetDC(NULL);
- HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight());
- ReleaseDC(NULL, dc2);
- HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, tmpBitmap);
-
- if ( m_palette )
- {
- HPALETTE oldPal = ::SelectPalette(dc, (HPALETTE) m_palette->GetHPALETTE(), FALSE);
- ::RealizePalette(dc);
- }
-
- HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
- CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
-
- ::SelectPalette(dc, NULL, TRUE);
- ::SelectObject(dc, oldBitmap);
- ::DeleteObject(tmpBitmap);
- ::DeleteDC(dc);
-
- if ( hBitmap )
- {
- bitmap->SetHBITMAP((WXHBITMAP) hBitmap);
- bitmap->SetWidth(GetWidth());
- bitmap->SetHeight(GetHeight());
- bitmap->SetDepth(GetDepth());
- if ( GetDepth() > 1 && m_palette )
- bitmap->SetPalette(*m_palette);
- bitmap->SetOk(TRUE);
-
-
- // Make a mask if appropriate
- if ( bgindex > -1 )
- {
- wxMask *mask = CreateMask();
- bitmap->SetMask(mask);
- }
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- */
- return false ;
-}
-
-wxPalette *wxCopyPalette(const wxPalette *cmap)
-{
- wxPalette *newCmap = new wxPalette( *cmap ) ;
- return newCmap;
-}
-
-wxMask *wxPNGReader::CreateMask(void)
-{
-/*
-HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL);
-
- HDC dc = ::CreateCompatibleDC(NULL);
- HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap);
-
- int bgIndex = GetBGIndex();
-
- int x,y;
-
- for (x=0; x<GetWidth(); x++)
- {
- for (y=0; y<GetHeight(); y++)
- {
- int index = GetIndex(x, y);
- if ( index == bgIndex )
- ::SetPixel(dc, x, GetHeight() - y - 1, RGB(0, 0, 0));
- else
- ::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255));
-
- }
- }
- ::SelectObject(dc, oldBitmap);
- wxMask *mask = new wxMask;
- mask->SetMaskBitmap((WXHBITMAP) hBitmap);
- return mask;
- */
- return NULL ;
-}
-
-bool wxPNGReader::ReadFile(char * ImageFileName)
-{
- int number_passes;
-
- if (ImageFileName)
- strcpy(filename, ImageFileName);
-
- FILE *fp;
- png_struct *png_ptr;
- png_info *info_ptr;
- wxPNGReaderIter iter(this);
-
- /* open the file */
- fp = fopen( ImageFileName , "rb" );
-
- if (!fp)
- return FALSE;
-
- /* allocate the necessary structures */
- png_ptr = new (png_struct);
- if (!png_ptr)
- {
- fclose(fp);
- return FALSE;
- }
-
- info_ptr = new (png_info);
- if (!info_ptr)
- {
- fclose(fp);
- delete png_ptr;
- return FALSE;
- }
- /* set error handling */
- if (setjmp(png_ptr->jmpbuf))
- {
- png_read_destroy(png_ptr, info_ptr, (png_info *)0);
- fclose(fp);
- delete png_ptr;
- delete info_ptr;
-
- /* If we get here, we had a problem reading the file */
- return FALSE;
- }
- //png_set_error(ima_png_error, NULL);
-
- /* initialize the structures, info first for error handling */
- png_info_init(info_ptr);
- png_read_init(png_ptr);
-
- /* set up the input control */
- png_init_io(png_ptr, fp);
-
- /* read the file information */
- png_read_info(png_ptr, info_ptr);
-
- /* allocate the memory to hold the image using the fields
- of png_info. */
- png_color_16 my_background={ 0, 31, 127, 255, 0 };
-
- if (info_ptr->valid & PNG_INFO_bKGD)
- {
- png_set_background(png_ptr, &(info_ptr->background),
- PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
- if ( info_ptr->num_palette > 0 )
- bgindex = info_ptr->background.index;
- }
- else {
- png_set_background(png_ptr, &my_background,
- PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
-
- // Added by JACS: guesswork!
- if ( info_ptr->num_trans != 0 )
- bgindex = info_ptr->num_trans - 1 ;
- }
-
- /* tell libpng to strip 16 bit depth files down to 8 bits */
- if (info_ptr->bit_depth == 16)
- png_set_strip_16(png_ptr);
-
- int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24;
- Create(info_ptr->width, info_ptr->height, pixel_depth,
- info_ptr->color_type);
-
- if (info_ptr->num_palette>0)
- {
- SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette);
- }
-
- int row_stride = info_ptr->width * ((pixel_depth+7)>>3);
- // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride);
- // printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth);
-
- byte *row_pointers = new byte[row_stride];
-
- /* turn on interlace handling */
- if (info_ptr->interlace_type)
- number_passes = png_set_interlace_handling(png_ptr);
- else
- number_passes = 1;
- // printf("NP = %d ", number_passes);
-
- for (int pass=0; pass< number_passes; pass++)
- {
- iter.upset();
- int y=0;
- CGrafPtr origPort ;
- GDHandle origDevice ;
-
- GetGWorld( &origPort , &origDevice ) ;
- // ignore shapedc
- SetGWorld( (GWorldPtr) lpbi , NULL ) ;
- do
- {
- // (unsigned char *)iter.GetRow();
- if (info_ptr->interlace_type)
- {
- if (pass>0)
- iter.GetRow(row_pointers, row_stride);
- png_read_row(png_ptr, row_pointers, NULL);
- }
- else
- png_read_row(png_ptr, row_pointers, NULL);
-
- if ( info_ptr->palette )
- {
- if ( pixel_depth == 8 )
- {
- for ( size_t i = 0 ; i < info_ptr->width ; ++i )
- {
- png_color_struct* color ;
- RGBColor col ;
-
- int index = row_pointers[i] ;
- color = &info_ptr->palette[index] ;
- col.red = (((int)color->red) << 8) | ((int)color->red) ;
- col.green = (((int)color->green) << 8) | ((int)color->green) ;
- col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
- SetCPixel( i, y, &col);
- }
- /*
- png_color_struct* color ;
- RGBColor col ;
- unsigned char* p = &row_pointers[0] ;
- PenNormal() ;
- MoveTo( 0 , y ) ;
- int index = *p ;
- color = &info_ptr->palette[index] ;
- col.red = (color->red << 8) | color->red ;
- col.green = (color->green << 8) | color->green ;
- col.blue = (color->blue << 8) | color->blue ;
- RGBForeColor( &col ) ;
- col.red = col.green = col.blue = 0xFFFF ;
- RGBBackColor( &col ) ;
- for ( int i = 0 ; i < info_ptr->width ; ++i , ++p)
- {
- if ( *p != index )
- {
- LineTo( i , y ) ;
- index = *p ;
- color = &info_ptr->palette[index] ;
- col.red = (((int)color->red) << 8) | ((int)color->red) ;
- col.green = (((int)color->green) << 8) | ((int)color->green) ;
- col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
- RGBForeColor( &col ) ;
- }
- }
- LineTo( info_ptr->width , y ) ;
- */
- }
- else
- {
- for ( size_t i = 0 ; i < info_ptr->width ; ++i )
- {
- png_color_struct* color ;
- RGBColor col ;
-
- int byte = ( i * pixel_depth ) / 8 ;
- int offset = ( 8 - pixel_depth ) - ( i * pixel_depth ) % 8 ;
-
- int index = ( row_pointers[byte] >> offset ) & ( 0xFF >> ( 8 - pixel_depth ) );
- color = &info_ptr->palette[index] ;
- col.red = (((int)color->red) << 8) | ((int)color->red) ;
- col.green = (((int)color->green) << 8) | ((int)color->green) ;
- col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
- SetCPixel( i, y, &col);
- }
- }
- }
- else
- {
- for ( size_t i = 0 ; i < info_ptr->width ; ++i )
- {
- png_color_struct* color ;
- RGBColor col ;
- color =(png_color_struct*) (&row_pointers[i*3]) ;
- col.red = (((int)color->red) << 8) | ((int)color->red) ;
- col.green = (((int)color->green) << 8) | ((int)color->green) ;
- col.blue = (((int)color->blue) << 8) | ((int)color->blue) ;
- SetCPixel( i, y, &col);
- }
- }
- if (number_passes)
- iter.SetRow(row_pointers, row_stride);
- y++;
- }
- while(iter.PrevRow());
- SetGWorld( origPort , origDevice ) ;
-
- // printf("Y=%d ",y);
- }
- delete[] row_pointers;
-
- /* read the rest of the file, getting any additional chunks
- in info_ptr */
- png_read_end(png_ptr, info_ptr);
-
- /* clean up after the read, and free any memory allocated */
- png_read_destroy(png_ptr, info_ptr, (png_info *)0);
-
- /* free the structures */
- delete png_ptr;
- delete info_ptr;
-
- /* close the file */
- fclose(fp);
-
- /* that's it */
- return TRUE;
-}
-
-
-/* write a png file */
-
-bool wxPNGReader::SaveFile(char * ImageFileName)
-{
- if (ImageFileName)
- strcpy(filename, ImageFileName);
-
- wxPNGReaderIter iter(this);
- FILE *fp;
- png_struct *png_ptr;
- png_info *info_ptr;
-
- /* open the file */
- fp = fopen(filename, "wb");
- if (!fp)
- return FALSE;
-
- /* allocate the necessary structures */
- png_ptr = new (png_struct);
- if (!png_ptr)
- {
- fclose(fp);
- return FALSE;
- }
-
- info_ptr = new (png_info);
- if (!info_ptr)
- {
- fclose(fp);
- delete png_ptr;
- return FALSE;
- }
-
- /* set error handling */
- if (setjmp(png_ptr->jmpbuf))
- {
- png_write_destroy(png_ptr);
- fclose(fp);
- delete png_ptr;
- delete info_ptr;
-
- /* If we get here, we had a problem reading the file */
- return FALSE;
- }
- //png_set_error(ima_png_error, NULL);
-
- // printf("writig pg %s ", filename);
- /* initialize the structures */
- png_info_init(info_ptr);
- png_write_init(png_ptr);
-
- int row_stride = GetWidth() * ((GetDepth()+7)>>3);
- /* set up the output control */
- png_init_io(png_ptr, fp);
-
- /* set the file information here */
- info_ptr->width = GetWidth();
- info_ptr->height = GetHeight();
- info_ptr->pixel_depth = GetDepth();
- info_ptr->channels = (GetDepth()>8) ? 3: 1;
- info_ptr->bit_depth = GetDepth()/info_ptr->channels;
- info_ptr->color_type = GetColorType();
- info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
- info_ptr->valid = 0;
- info_ptr->rowbytes = row_stride;
-
-
- // printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels);
- /* set the palette if there is one */
- if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
- {
- // printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
- info_ptr->valid |= PNG_INFO_PLTE;
- info_ptr->palette = new png_color[256];
- info_ptr->num_palette = 256;
- for (int i=0; i<256; i++)
- GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
- }
- // printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
-
-
- /* optional significant bit chunk */
- // info_ptr->valid |= PNG_INFO_sBIT;
- // info_ptr->sig_bit = true_bit_depth;
-
- /* optional gamma chunk */
- // info_ptr->valid |= PNG_INFO_gAMA;
- // info_ptr->gamma = gamma;
-
- /* other optional chunks */
-
- /* write the file information */
- png_write_info(png_ptr, info_ptr);
-
- /* set up the transformations you want. Note that these are
- all optional. Only call them if you want them */
-
- /* shift the pixels up to a legal bit depth and fill in
- as appropriate to correctly scale the image */
- // png_set_shift(png_ptr, &(info_ptr->sig_bit));
-
- /* pack pixels into bytes */
- // png_set_packing(png_ptr);
-
- /* flip bgr pixels to rgb */
- // png_set_bgr(png_ptr);
-
- /* swap bytes of 16 bit files to most significant bit first */
- // png_set_swap(png_ptr);
-
- /* get rid of filler bytes, pack rgb into 3 bytes */
- // png_set_rgbx(png_ptr);
-
- /* If you are only writing one row at a time, this works */
-
- byte *row_pointers = new byte[row_stride];
- iter.upset();
- do {
- // (unsigned char *)iter.GetRow();
- iter.GetRow(row_pointers, row_stride);
- png_write_row(png_ptr, row_pointers);
- } while(iter.PrevRow());
-
- delete[] row_pointers;
-
- /* write the rest of the file */
- png_write_end(png_ptr, info_ptr);
-
- /* clean up after the write, and free any memory allocated */
- png_write_destroy(png_ptr);
-
- /* if you malloced the palette, free it here */
- if (info_ptr->palette)
- delete[] (info_ptr->palette);
-
- /* free the structures */
- delete png_ptr;
- delete info_ptr;
-
- /* close the file */
- fclose(fp);
-
- /* that's it */
- return TRUE;
-}
-
-static int Power(int x, int y)
-{
- int z = 1;
- int i;
- for ( i = 0; i < y; i++)
- {
- z *= x;
- }
- return z;
-}
-
-static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
-'C', 'D', 'E', 'F' };
-
-static void DecToHex(int dec, char *buf)
-{
- int firstDigit = (int)(dec/16.0);
- int secondDigit = (int)(dec - (firstDigit*16.0));
- buf[0] = hexArray[firstDigit];
- buf[1] = hexArray[secondDigit];
- buf[2] = 0;
-}
-
-
-bool wxPNGReader::SaveXPM(char *filename, char *name)
-{
- char nameStr[256];
- if ( name )
- strcpy(nameStr, name);
- else
- {
- wxString str = wxString::FromAscii(filename) ;
- wxStripExtension( str ) ;
- strcpy(nameStr, str.ToAscii() );
- }
-
- if ( GetDepth() > 4 )
- {
- // Only a depth of 4 and below allowed
- return FALSE;
- }
-
- if ( !GetPalette() )
- return FALSE;
-
- wxSTD ofstream str(filename);
- if ( str.bad() )
- return FALSE;
-
- int noColours = Power(2, GetDepth());
-
- // Output header
- str << "/* XPM */\n";
- str << "static char * " << nameStr << "_xpm[] = {\n";
- str << "\"" << GetWidth() << " " << GetHeight() << " " << noColours << " 1\",\n";
-
- // Output colourmap
- int base = 97 ; // start from 'a'
-
- unsigned char red, green, blue;
- char hexBuf[4];
- int i;
- for ( i = 0; i < noColours; i ++)
- {
- str << "\"" << (char)(base + i) << " c #";
- GetPalette()->GetRGB(i, &red, &green, &blue);
- DecToHex(red, hexBuf);
- str << hexBuf;
- DecToHex(green, hexBuf);
- str << hexBuf;
- DecToHex(blue, hexBuf);
- str << hexBuf;
- str << "\",\n";
- }
-
- // Output the data
- int x, y;
- for ( y = 0; y < GetHeight(); y++)
- {
- str << "\"";
- for ( x = 0; x < GetWidth(); x++)
- {
- int index = GetIndex(x, y);
- str << (char)(base + index) ;
- }
- str << "\",\n";
- }
-
- str << "};\n";
- str.flush();
-
- return TRUE;
-}
-
-
-IMPLEMENT_DYNAMIC_CLASS(wxPNGFileHandler, wxBitmapHandler)
-
-bool wxPNGFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight)
-{
- wxPNGReader reader;
- if (reader.ReadFile( (char*)(const char*) name.ToAscii() ) )
- {
- return reader.InstantiateBitmap(bitmap);
- }
- else
- return FALSE;
-}
-
-bool wxPNGFileHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *pal)
-{
- return FALSE;
-}
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/printdlg.cpp
-// Purpose: wxPrintDialog, wxPageSetupDialog
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#include "wx/printdlg.h"
-
-#ifndef WX_PRECOMP
- #include "wx/object.h"
- #include "wx/dcprint.h"
- #include "wx/msgdlg.h"
-#endif
-
-#include "wx/mac/private/print.h"
-
-// Use generic page setup dialog: use your own native one if one exists.
-
-IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
-IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
-
-wxPrintDialog::wxPrintDialog()
-{
- m_dialogParent = NULL;
- m_printerDC = NULL;
- m_destroyDC = true;
-}
-
-wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
-{
- Create(p, data);
-}
-
-wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data)
-{
- wxPrintDialogData data2;
- if ( data )
- data2 = *data;
-
- Create(p, &data2);
-}
-
-bool wxPrintDialog::Create(wxWindow *p, wxPrintDialogData* data)
-{
- m_dialogParent = p;
- m_printerDC = NULL;
- m_destroyDC = true;
-
- if ( data )
- m_printDialogData = *data;
-
- return true;
-}
-
-wxPrintDialog::~wxPrintDialog()
-{
- if (m_destroyDC && m_printerDC) {
- delete m_printerDC;
- m_printerDC = NULL;
- }
-}
-
-int wxPrintDialog::ShowModal()
-{
- m_printDialogData.ConvertToNative() ;
- int result = m_printDialogData.GetPrintData().m_nativePrintData->ShowPrintDialog() ;
- if ( result == wxID_OK )
- m_printDialogData.ConvertFromNative() ;
-
- return result ;
-}
-
-wxDC *wxPrintDialog::GetPrintDC()
-{
- return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
-}
-
-/*
-* wxPageSetupDialog
-*/
-
-wxPageSetupDialog::wxPageSetupDialog():
-wxDialog()
-{
- m_dialogParent = NULL;
-}
-
-wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data):
-wxDialog()
-{
- Create(p, data);
-}
-
-bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
-{
- m_dialogParent = p;
-
- if (data)
- m_pageSetupData = (*data);
-
- return true;
-}
-
-wxPageSetupDialog::~wxPageSetupDialog()
-{
-}
-
-int wxPageSetupDialog::ShowModal()
-{
- m_pageSetupData.ConvertToNative() ;
- int result = m_pageSetupData.GetPrintData().m_nativePrintData->ShowPageSetupDialog() ;
- if (result == wxID_OK )
- m_pageSetupData.ConvertFromNative() ;
-
- return result ;
-}
-
-
-IMPLEMENT_CLASS(wxMacPageMarginsDialog, wxDialog)
-
-wxMacPageMarginsDialog::wxMacPageMarginsDialog(wxFrame *parent, wxPageSetupData *data) :
- wxDialog(parent, wxID_ANY, wxString(wxT("Page Margins"))),
- m_pageSetupDialogData(data)
- {
- GetMinMargins();
- wxBoxSizer *colSizer = new wxBoxSizer(wxVERTICAL);
- wxFlexGridSizer *gridSizer = new wxFlexGridSizer(4, 5, 5);
- colSizer->Add(gridSizer, wxSizerFlags().Border(wxALL, 5));
- gridSizer->Add(new wxStaticText(this, wxID_ANY, wxT("Left (mm):")), wxSizerFlags().Right());
- gridSizer->Add(m_LeftMargin = new wxTextCtrl(this, wxID_ANY), wxSizerFlags().Left());
- gridSizer->Add(new wxStaticText(this, wxID_ANY, wxT("Top (mm):")), wxSizerFlags().Right());
- gridSizer->Add(m_TopMargin = new wxTextCtrl(this, wxID_ANY), wxSizerFlags().Left());
- gridSizer->Add(new wxStaticText(this, wxID_ANY, wxT("Right (mm):")), wxSizerFlags().Right());
- gridSizer->Add(m_RightMargin = new wxTextCtrl(this, wxID_ANY), wxSizerFlags().Left());
- gridSizer->Add(new wxStaticText(this, wxID_ANY, wxT("Bottom (mm):")), wxSizerFlags().Right());
- gridSizer->Add(m_BottomMargin = new wxTextCtrl(this, wxID_ANY), wxSizerFlags().Left());
- colSizer->Add(new wxStaticLine(this), wxSizerFlags().Expand().Border(wxTOP|wxBOTTOM, 5));
- colSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Expand().Border(wxALL, 5));
- TransferToWindow();
- SetSizerAndFit(colSizer);
- Center(wxBOTH);
- }
-
-bool wxMacPageMarginsDialog::TransferToWindow()
- {
- wxASSERT(m_pageSetupDialogData);
- wxPoint topLeft = m_pageSetupDialogData->GetMarginTopLeft();
- wxPoint bottomRight = m_pageSetupDialogData->GetMarginBottomRight();
- wxPoint minTopLeft = m_pageSetupDialogData->GetMinMarginTopLeft();
- wxPoint minBottomRight = m_pageSetupDialogData->GetMinMarginBottomRight();
- m_LeftMargin->SetValue(wxString::Format(wxT("%d"), wxMax(topLeft.x, minTopLeft.x)));
- m_LeftMargin->SetSelection(-1, -1);
- m_TopMargin->SetValue(wxString::Format(wxT("%d"), wxMax(topLeft.y, minTopLeft.y)));
- m_TopMargin->SetSelection(-1, -1);
- m_RightMargin->SetValue(wxString::Format(wxT("%d"), wxMax(bottomRight.x, minBottomRight.x)));
- m_RightMargin->SetSelection(-1, -1);
- m_BottomMargin->SetValue(wxString::Format(wxT("%d"), wxMax(bottomRight.y, minBottomRight.y)));
- m_BottomMargin->SetSelection(-1, -1);
- m_LeftMargin->SetFocus();
- return true;
- }
-
-bool wxMacPageMarginsDialog::TransferDataFromWindow()
- {
- wxPoint topLeft, bottomRight;
- if (!CheckValue(m_LeftMargin, &topLeft.x, m_MinMarginTopLeft.x, wxT("left margin"))) return false;
- if (!CheckValue(m_TopMargin, &topLeft.y, m_MinMarginTopLeft.y, wxT("top margin"))) return false;
- if (!CheckValue(m_RightMargin, &bottomRight.x, m_MinMarginBottomRight.x, wxT("right margin"))) return false;
- if (!CheckValue(m_BottomMargin, &bottomRight.y, m_MinMarginBottomRight.y, wxT("bottom margin"))) return false;
- m_pageSetupDialogData->SetMarginTopLeft(topLeft);
- m_pageSetupDialogData->SetMarginBottomRight(bottomRight);
- return true;
- }
-
-bool wxMacPageMarginsDialog::CheckValue(wxTextCtrl* textCtrl, int *value, int minValue, const wxString& name)
- {
- long lvalue;
- if (!textCtrl->GetValue().ToLong(&lvalue))
- {
- wxMessageBox(wxString::Format(wxT("Sorry, \"%s\" is not a valid numerical value for the %s"), textCtrl->GetValue().c_str(), name.c_str()), wxT("Page Margin Error"));
- return false;
- }
- if (lvalue < minValue)
- {
- wxMessageBox(wxString::Format(wxT("Sorry, \"%s\" is not a valid value for the %s, which must be >= %d"), textCtrl->GetValue().c_str(), name.c_str(), minValue), wxT("Page Margin Error"));
- textCtrl->SetValue(wxString::Format(wxT("%d"), minValue));
- textCtrl->SetSelection(-1, -1);
- textCtrl->SetFocus();
- return false;
- }
- *value = int(lvalue);
- return true;
- }
-
-void wxMacPageMarginsDialog::GetMinMargins()
- {
- m_MinMarginTopLeft = m_pageSetupDialogData->GetMinMarginTopLeft();
- m_MinMarginBottomRight = m_pageSetupDialogData->GetMinMarginBottomRight();
- }
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/printwin.cpp
-// Purpose: wxMacPrinter framework
-// Author: Julian Smart
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/utils.h"
- #include "wx/dc.h"
- #include "wx/app.h"
- #include "wx/msgdlg.h"
- #include "wx/dcprint.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-#include "wx/mac/printmac.h"
-#include "wx/mac/private/print.h"
-
-#define mm2pt 2.83464566929
-#define pt2mm 0.352777777778
-
-#include "wx/printdlg.h"
-
-#include <stdlib.h>
-
-IMPLEMENT_DYNAMIC_CLASS(wxMacPrinter, wxPrinterBase)
-IMPLEMENT_CLASS(wxMacPrintPreview, wxPrintPreviewBase)
-
-#if TARGET_CARBON
-
-wxNativePrintData* wxNativePrintData::Create()
-{
- return new wxMacCarbonPrintData() ;
-}
-
-wxMacCarbonPrintData::wxMacCarbonPrintData()
-{
- m_macPageFormat = kPMNoPageFormat;
- m_macPrintSettings = kPMNoPrintSettings;
- m_macPrintSession = kPMNoReference ;
- ValidateOrCreate() ;
-}
-
-wxMacCarbonPrintData::~wxMacCarbonPrintData()
-{
- if (m_macPageFormat != kPMNoPageFormat)
- {
- (void)PMRelease(m_macPageFormat);
- m_macPageFormat = kPMNoPageFormat;
- }
-
- if (m_macPrintSettings != kPMNoPrintSettings)
- {
- (void)PMRelease(m_macPrintSettings);
- m_macPrintSettings = kPMNoPrintSettings;
- }
-
- if ( m_macPrintSession != kPMNoReference )
- {
- (void)PMRelease(m_macPrintSession);
- m_macPrintSession = kPMNoReference;
- }
-}
-
-void wxMacCarbonPrintData::ValidateOrCreate()
-{
- OSStatus err = noErr ;
- if ( m_macPrintSession == kPMNoReference )
- {
- err = PMCreateSession( (PMPrintSession *) &m_macPrintSession ) ;
- }
- // Set up a valid PageFormat object.
- if ( m_macPageFormat == kPMNoPageFormat)
- {
- err = PMCreatePageFormat((PMPageFormat *) &m_macPageFormat);
-
- // Note that PMPageFormat is not session-specific, but calling
- // PMSessionDefaultPageFormat assigns values specific to the printer
- // associated with the current printing session.
- if ((err == noErr) &&
- ( m_macPageFormat != kPMNoPageFormat))
- {
- err = PMSessionDefaultPageFormat((PMPrintSession) m_macPrintSession,
- (PMPageFormat) m_macPageFormat);
- }
- }
- else
- {
- err = PMSessionValidatePageFormat((PMPrintSession) m_macPrintSession,
- (PMPageFormat) m_macPageFormat,
- kPMDontWantBoolean);
- }
-
- // Set up a valid PrintSettings object.
- if ( m_macPrintSettings == kPMNoPrintSettings)
- {
- err = PMCreatePrintSettings((PMPrintSettings *) &m_macPrintSettings);
-
- // Note that PMPrintSettings is not session-specific, but calling
- // PMSessionDefaultPrintSettings assigns values specific to the printer
- // associated with the current printing session.
- if ((err == noErr) &&
- ( m_macPrintSettings != kPMNoPrintSettings))
- {
- err = PMSessionDefaultPrintSettings((PMPrintSession) m_macPrintSession,
- (PMPrintSettings) m_macPrintSettings);
- }
- }
- else
- {
- err = PMSessionValidatePrintSettings((PMPrintSession) m_macPrintSession,
- (PMPrintSettings) m_macPrintSettings,
- kPMDontWantBoolean);
- }
-}
-
-void wxMacCarbonPrintData::TransferFrom( wxPrintData* data )
-{
- ValidateOrCreate() ;
- PMSetCopies( (PMPrintSettings) m_macPrintSettings , data->GetNoCopies() , false ) ;
- PMSetOrientation( (PMPageFormat) m_macPageFormat , ( data->GetOrientation() == wxLANDSCAPE ) ?
- kPMLandscape : kPMPortrait , false ) ;
- // collate cannot be set
-#if 0 // not yet tested
- if ( !m_printerName.empty() )
- PMSessionSetCurrentPrinter( (PMPrintSession) m_macPrintSession , wxMacCFStringHolder( m_printerName , wxFont::GetDefaultEncoding() ) ) ;
-#endif
- PMColorMode color ;
- PMGetColorMode( (PMPrintSettings) m_macPrintSettings, &color ) ;
- if ( data->GetColour() )
- {
- if ( color == kPMBlackAndWhite )
- PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMColor ) ;
- }
- else
- PMSetColorMode( (PMPrintSettings) m_macPrintSettings, kPMBlackAndWhite ) ;
-
- // PMDuplexMode not yet accessible via API
- // PMQualityMode not yet accessible via API
- // todo paperSize
-}
-
-void wxMacCarbonPrintData::TransferTo( wxPrintData* data )
-{
- OSStatus err = noErr ;
-
- UInt32 copies ;
- err = PMGetCopies( m_macPrintSettings , &copies ) ;
- if ( err == noErr )
- data->SetNoCopies( copies ) ;
-
- PMOrientation orientation ;
- err = PMGetOrientation( m_macPageFormat , &orientation ) ;
- if ( err == noErr )
- {
- if ( orientation == kPMPortrait || orientation == kPMReversePortrait )
- data->SetOrientation( wxPORTRAIT );
- else
- data->SetOrientation( wxLANDSCAPE );
- }
-
- // collate cannot be set
-#if 0
- {
- wxMacCFStringHolder name ;
- PMPrinter printer ;
- PMSessionGetCurrentPrinter( m_macPrintSession ,
- &printer ) ;
- m_printerName = name.AsString() ;
- }
-#endif
-
- PMColorMode color ;
- err = PMGetColorMode( m_macPrintSettings, &color ) ;
- if ( err == noErr )
- data->SetColour( !(color == kPMBlackAndWhite) ) ;
-
- // PMDuplexMode not yet accessible via API
- // PMQualityMode not yet accessible via API
- // todo paperSize
- PMRect rPaper;
- err = PMGetUnadjustedPaperRect( m_macPageFormat, &rPaper);
- if ( err == noErr )
- {
- data->SetPaperSize( wxSize (
- (int)(( rPaper.right - rPaper.left ) * pt2mm + 0.5 ) ,
- (int)(( rPaper.bottom - rPaper.top ) * pt2mm + 0.5 ) ) );
- }
-}
-
-void wxMacCarbonPrintData::TransferFrom( wxPageSetupData *data )
-{
- // should we setup the page rect here ?
- // since MacOS sometimes has two same paper rects with different
- // page rects we could make it roundtrip safe perhaps
-#if TARGET_CARBON
-#else
-#endif
-}
-
-void wxMacCarbonPrintData::TransferTo( wxPageSetupData* data )
-{
- PMRect rPaper;
- OSStatus err = PMGetUnadjustedPaperRect(m_macPageFormat, &rPaper);
- if ( err == noErr )
- {
- PMRect rPage ;
- err = PMGetUnadjustedPageRect(m_macPageFormat , &rPage ) ;
- if ( err == noErr )
- {
- data->SetMinMarginTopLeft( wxPoint (
- (int)(((double) rPage.left - rPaper.left ) * pt2mm) ,
- (int)(((double) rPage.top - rPaper.top ) * pt2mm) ) ) ;
-
- data->SetMinMarginBottomRight( wxPoint (
- (wxCoord)(((double) rPaper.right - rPage.right ) * pt2mm),
- (wxCoord)(((double) rPaper.bottom - rPage.bottom ) * pt2mm)) ) ;
- }
- }
-}
-
-void wxMacCarbonPrintData::TransferTo( wxPrintDialogData* data )
-{
- UInt32 minPage , maxPage ;
- PMGetPageRange( m_macPrintSettings , &minPage , &maxPage ) ;
- data->SetMinPage( minPage ) ;
- data->SetMaxPage( maxPage ) ;
- UInt32 copies ;
- PMGetCopies( m_macPrintSettings , &copies ) ;
- data->SetNoCopies( copies ) ;
- UInt32 from , to ;
- PMGetFirstPage( m_macPrintSettings , &from ) ;
- PMGetLastPage( m_macPrintSettings , &to ) ;
- data->SetFromPage( from ) ;
- data->SetToPage( to ) ;
-}
-
-void wxMacCarbonPrintData::TransferFrom( wxPrintDialogData* data )
-{
- PMSetPageRange( m_macPrintSettings , data->GetMinPage() , data->GetMaxPage() ) ;
- PMSetCopies( m_macPrintSettings , data->GetNoCopies() , false ) ;
- PMSetFirstPage( m_macPrintSettings , data->GetFromPage() , false ) ;
-
- int toPage = data->GetToPage();
- if (toPage < 1)
- toPage = data->GetFromPage();
- PMSetLastPage( m_macPrintSettings , toPage , false ) ;
-}
-
-void wxMacCarbonPrintData::CopyFrom( wxNativePrintData* d )
-{
- wxMacCarbonPrintData *data = (wxMacCarbonPrintData*) d ;
- if ( data->m_macPrintSession != kPMNoReference )
- PMRetain( data->m_macPrintSession ) ;
- if ( m_macPrintSession != kPMNoReference )
- {
- PMRelease( m_macPrintSession ) ;
- m_macPrintSession = kPMNoReference ;
- }
- if ( data->m_macPrintSession != kPMNoReference )
- m_macPrintSession = data->m_macPrintSession ;
-
- if ( data->m_macPrintSettings != kPMNoPrintSettings )
- PMRetain( data->m_macPrintSettings ) ;
- if ( m_macPrintSettings != kPMNoPrintSettings )
- {
- PMRelease( m_macPrintSettings ) ;
- m_macPrintSettings = kPMNoPrintSettings ;
- }
- if ( data->m_macPrintSettings != kPMNoPrintSettings )
- m_macPrintSettings = data->m_macPrintSettings ;
-
- if ( data->m_macPageFormat != kPMNoPageFormat )
- PMRetain( data->m_macPageFormat ) ;
- if ( m_macPageFormat != kPMNoPageFormat )
- {
- PMRelease( m_macPageFormat ) ;
- m_macPageFormat = kPMNoPageFormat ;
- }
- if ( data->m_macPageFormat != kPMNoPageFormat )
- m_macPageFormat = data->m_macPageFormat ;
-}
-
-int wxMacCarbonPrintData::ShowPrintDialog()
-{
- int result = wxID_CANCEL ;
- OSErr err = noErr ;
- wxString message ;
-
- Boolean accepted;
-
- {
- // Display the Print dialog.
- if (err == noErr)
- {
- err = PMSessionPrintDialog( m_macPrintSession,
- m_macPrintSettings,
- m_macPageFormat,
- &accepted);
- if ((err == noErr) && !accepted)
- {
- err = kPMCancel; // user clicked Cancel button
- }
- }
- if ( err == noErr )
- {
- result = wxID_OK ;
- }
- }
- if ((err != noErr) && (err != kPMCancel))
- {
- message.Printf( wxT("Print Error %d"), err ) ;
- wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
- dialog.ShowModal();
- }
-
- return result ;
-}
-
-int wxMacCarbonPrintData::ShowPageSetupDialog()
-{
- int result = wxID_CANCEL ;
- OSErr err = noErr ;
- wxString message ;
-
- Boolean accepted;
- {
- // Display the Page Setup dialog.
- if (err == noErr)
- {
- err = PMSessionPageSetupDialog( m_macPrintSession,
- m_macPageFormat,
- &accepted);
- if ((err == noErr) && !accepted)
- {
- err = kPMCancel; // user clicked Cancel button
- }
- }
-
- // If the user did not cancel, flatten and save the PageFormat object
- // with our document.
- if (err == noErr) {
- result = wxID_OK ;
- }
- }
- if ((err != noErr) && (err != kPMCancel))
- {
- message.Printf( wxT("Print Error %d"), err ) ;
- wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
- dialog.ShowModal();
- }
-
- return result ;
-}
-
-#else
-
-wxNativePrintData* wxNativePrintData::Create()
-{
- return new wxMacClassicPrintData() ;
-}
-
-wxMacClassicPrintData::wxMacClassicPrintData()
-{
- m_macPrintSettings = NULL ;
- ValidateOrCreate() ;
-}
-
-wxMacClassicPrintData::~wxMacClassicPrintData()
-{
- wxASSERT( m_macPrintSettings );
- DisposeHandle( (Handle) m_macPrintSettings ) ;
-}
-
-void wxMacClassicPrintData::ValidateOrCreate()
-{
- if ( m_macPrintSettings == NULL )
- {
- m_macPrintSettings = (THPrint) NewHandleClear( sizeof( TPrint ) );
- (**m_macPrintSettings).iPrVersion = 0; // something invalid
-
- (**m_macPrintSettings).prInfo.iHRes = 72;
- (**m_macPrintSettings).prInfo.iVRes = 72;
- Rect r1 = { 0, 0, 8*72 - 2 * 18, 11*72 - 2 * 36 };
- (**m_macPrintSettings).prInfo.rPage = r1;// must have its top left & (0,0)
-
- Rect r2 = { -18, -36, 8*72 - 18, 11*72 - 36 };
- (**m_macPrintSettings).rPaper = r2;
- (**m_macPrintSettings).prStl.iPageV = 11 * 120 ; // 11 inches in 120th of an inch
- (**m_macPrintSettings).prStl.iPageH = 8 * 120 ; // 8 inches in 120th of an inch
- }
- else
- {
- }
-}
-
-void wxMacClassicPrintData::TransferFrom( wxPrintData* data )
-{
- ValidateOrCreate() ;
- (**m_macPrintSettings).prJob.iCopies = data->GetNoCopies() ;
- // on mac the paper rect has a negative top left corner, because the page rect (printable area) is at 0,0
- // if all printing data is consolidated in on structure we will be able to set additional infos about pages
-}
-
-void wxMacClassicPrintData::TransferTo( wxPrintData* data )
-{
- data->SetNoCopies( (**m_macPrintSettings).prJob.iCopies );
- data->SetPaperSize( wxSize(
- ((double) (**m_macPrintSettings).rPaper.right - (**m_macPrintSettings).rPaper.left ) * pt2mm ,
- ((double) (**m_macPrintSettings).rPaper.bottom - (**m_macPrintSettings).rPaper.top ) * pt2mm ) ) ;
-}
-
-void wxMacClassicPrintData::TransferFrom( wxPageSetupData *data )
-{
-}
-
-void wxMacClassicPrintData::TransferTo( wxPageSetupData* data )
-{
- data->SetMinMarginTopLeft( wxPoint(
- ((double) (**m_macPrintSettings).prInfo.rPage.left -(**m_macPrintSettings).rPaper.left ) * pt2mm ,
- ((double) (**m_macPrintSettings).prInfo.rPage.top -(**m_macPrintSettings).rPaper.top ) * pt2mm ) ) ;
- data->SetMinMarginBottomRight( wxPoint(
- ((double) (**m_macPrintSettings).rPaper.right - (**m_macPrintSettings).prInfo.rPage.right ) * pt2mm ,
- ((double)(**m_macPrintSettings).rPaper.bottom - (**m_macPrintSettings).prInfo.rPage.bottom ) * pt2mm ) ) ;
-}
-
-void wxMacClassicPrintData::TransferFrom( wxPrintDialogData* data )
-{
- int toPage = data->GetToPage();
- if (toPage < 1)
- toPage = data->GetFromPage();
- (**m_macPrintSettings).prJob.iFstPage = data->GetFromPage() ;
- (**m_macPrintSettings).prJob.iLstPage = toPage;
-}
-
-void wxMacClassicPrintData::TransferTo( wxPrintDialogData* data )
-{
- data->SetFromPage( (**m_macPrintSettings).prJob.iFstPage ) ;
- data->SetToPage( (**m_macPrintSettings).prJob.iLstPage ) ;
-}
-
-void wxMacClassicPrintData::CopyFrom( wxNativePrintData* data )
-{
- DisposeHandle( (Handle) m_macPrintSettings ) ;
- m_macPrintSettings = ((wxMacClassicPrintData*)data)->m_macPrintSettings;
- HandToHand( (Handle*) &m_macPrintSettings );
-}
-
-int wxMacClassicPrintData::ShowPrintDialog()
-{
- int result = wxID_CANCEL ;
- OSErr err = noErr ;
- wxString message ;
-
- err = ::UMAPrOpen() ;
- if ( err == noErr )
- {
- if ( ::PrJobDialog( m_macPrintSettings ) )
- {
- result = wxID_OK ;
- }
-
- }
- else
- {
- message.Printf( wxT("Print Error %d"), err ) ;
- wxMessageDialog dialog( NULL , message , wxEmptyString, wxICON_HAND | wxOK) ;
- dialog.ShowModal();
- }
- ::UMAPrClose() ;
-
- return result ;
-}
-
-int wxMacClassicPrintData::ShowPageSetupDialog()
-{
- int result = wxID_CANCEL ;
- OSErr err = noErr ;
- wxString message ;
-
- err = ::UMAPrOpen() ;
- if ( err == noErr )
- {
- if ( ::PrStlDialog( m_macPrintSettings ) )
- {
- result = wxID_OK ;
- }
-
- }
- else
- {
- message.Printf( wxT("Print Error %d"), err ) ;
- wxMessageDialog dialog( NULL , message , wxEmptyString , wxICON_HAND | wxOK) ;
- dialog.ShowModal();
- }
- ::UMAPrClose() ;
- return result ;
-}
-
-#endif
-
-/*
-* Printer
-*/
-
-wxMacPrinter::wxMacPrinter(wxPrintDialogData *data):
-wxPrinterBase(data)
-{
-}
-
-wxMacPrinter::~wxMacPrinter(void)
-{
-}
-
-bool wxMacPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
-{
- sm_abortIt = false;
- sm_abortWindow = NULL;
-
- if (!printout)
- return false;
-
- printout->SetIsPreview(false);
- if (m_printDialogData.GetMinPage() < 1)
- m_printDialogData.SetMinPage(1);
- if (m_printDialogData.GetMaxPage() < 1)
- m_printDialogData.SetMaxPage(9999);
-
- // Create a suitable device context
- wxPrinterDC *dc = NULL;
- if (prompt)
- {
- wxPrintDialog dialog(parent, & m_printDialogData);
- if (dialog.ShowModal() == wxID_OK)
- {
- dc = dialog.GetPrintDC();
- m_printDialogData = dialog.GetPrintDialogData();
- }
- }
- else
- {
- dc = new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
- }
-
- // May have pressed cancel.
- if (!dc || !dc->Ok())
- {
- if (dc) delete dc;
- return false;
- }
-
- // on the mac we have always pixels as addressing mode with 72 dpi
- printout->SetPPIScreen(72, 72);
- printout->SetPPIPrinter(72, 72);
-
- // Set printout parameters
- printout->SetDC(dc);
-
- int w, h;
- wxCoord ww, hh;
- dc->GetSize(&w, &h);
- printout->SetPageSizePixels((int)w, (int)h);
- printout->SetPaperRectPixels(dc->GetPaperRect());
- dc->GetSizeMM(&ww, &hh);
- printout->SetPageSizeMM((int)ww, (int)hh);
-
- // Create an abort window
- wxBeginBusyCursor();
-
- printout->OnPreparePrinting();
-
- // Get some parameters from the printout, if defined
- int fromPage, toPage;
- int minPage, maxPage;
- printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
-
- if (maxPage == 0)
- {
- wxEndBusyCursor();
- return false;
- }
-
- // Only set min and max, because from and to have been
- // set by the user
- m_printDialogData.SetMinPage(minPage);
- m_printDialogData.SetMaxPage(maxPage);
-
- wxWindow *win = CreateAbortWindow(parent, printout);
- wxSafeYield(win,true);
-
- if (!win)
- {
- wxEndBusyCursor();
- wxMessageBox(wxT("Sorry, could not create an abort dialog."), wxT("Print Error"), wxOK, parent);
- delete dc;
- return false;
- }
- sm_abortWindow = win;
- sm_abortWindow->Show(true);
- wxSafeYield(win,true);
-
- printout->OnBeginPrinting();
-
- bool keepGoing = true;
-
- int copyCount;
- for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++)
- {
- if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
- {
- wxEndBusyCursor();
- wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent);
- break;
- }
- if (sm_abortIt)
- break;
-
- int pn;
- for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn);
- pn++)
- {
- if (sm_abortIt)
- {
- keepGoing = false;
- break;
- }
- else
- {
-#if TARGET_CARBON
- if ( UMAGetSystemVersion() >= 0x1000 )
-#endif
- {
- GrafPtr thePort ;
- GetPort( &thePort ) ;
- wxSafeYield(win,true);
- SetPort( thePort ) ;
- }
- dc->StartPage();
- keepGoing = printout->OnPrintPage(pn);
- dc->EndPage();
- }
- }
- printout->OnEndDocument();
- }
-
- printout->OnEndPrinting();
-
- if (sm_abortWindow)
- {
- sm_abortWindow->Show(false);
- delete sm_abortWindow;
- sm_abortWindow = NULL;
- }
-
- wxEndBusyCursor();
-
- delete dc;
-
- return true;
-}
-
-wxDC* wxMacPrinter::PrintDialog(wxWindow *parent)
-{
- wxDC* dc = (wxDC*) NULL;
-
- wxPrintDialog dialog(parent, & m_printDialogData);
- int ret = dialog.ShowModal();
-
- if (ret == wxID_OK)
- {
- dc = dialog.GetPrintDC();
- m_printDialogData = dialog.GetPrintDialogData();
- }
-
- return dc;
-}
-
-bool wxMacPrinter::Setup(wxWindow *parent)
-{
-#if 0
- wxPrintDialog dialog(parent, & m_printDialogData);
- dialog.GetPrintDialogData().SetSetupDialog(true);
-
- int ret = dialog.ShowModal();
-
- if (ret == wxID_OK)
- {
- m_printDialogData = dialog.GetPrintDialogData();
- }
-
- return (ret == wxID_OK);
-#endif
- return wxID_CANCEL;
-}
-
-/*
-* Print preview
-*/
-
-wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout,
- wxPrintout *printoutForPrinting,
- wxPrintDialogData *data)
- : wxPrintPreviewBase(printout, printoutForPrinting, data)
-{
- DetermineScaling();
-}
-
-wxMacPrintPreview::wxMacPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data):
-wxPrintPreviewBase(printout, printoutForPrinting, data)
-{
- DetermineScaling();
-}
-
-wxMacPrintPreview::~wxMacPrintPreview(void)
-{
-}
-
-bool wxMacPrintPreview::Print(bool interactive)
-{
- if (!m_printPrintout)
- return false;
- wxMacPrinter printer(&m_printDialogData);
- return printer.Print(m_previewFrame, m_printPrintout, interactive);
-}
-
-void wxMacPrintPreview::DetermineScaling(void)
-{
- int screenWidth , screenHeight ;
- wxDisplaySize( &screenWidth , &screenHeight ) ;
-
- wxSize ppiScreen( 72 , 72 ) ;
- wxSize ppiPrinter( 72 , 72 ) ;
-
- m_previewPrintout->SetPPIScreen( ppiScreen.x , ppiScreen.y ) ;
-
- wxCoord w , h ;
- wxCoord ww, hh;
- wxRect paperRect;
-
- // Get a device context for the currently selected printer
- wxPrinterDC printerDC(m_printDialogData.GetPrintData());
- if (printerDC.Ok())
- {
- printerDC.GetSizeMM(&ww, &hh);
- printerDC.GetSize( &w , &h ) ;
- ppiPrinter = printerDC.GetPPI() ;
- paperRect = printerDC.GetPaperRect();
- m_isOk = true ;
- }
- else
- {
- // use some defaults
- w = 8 * 72 ;
- h = 11 * 72 ;
- ww = (wxCoord) (w * 25.4 / ppiPrinter.x) ;
- hh = (wxCoord) (h * 25.4 / ppiPrinter.y) ;
- paperRect = wxRect(0, 0, w, h);
- m_isOk = false ;
- }
- m_previewPrintout->SetPageSizeMM(ww, hh);
- m_previewPrintout->SetPageSizePixels(w , h) ;
- m_previewPrintout->SetPaperRectPixels(paperRect);
- m_pageWidth = w;
- m_pageHeight = h;
- m_previewPrintout->SetPPIPrinter( ppiPrinter.x , ppiPrinter.y ) ;
-
- m_previewScaleX = float(ppiScreen.x) / ppiPrinter.x;
- m_previewScaleY = float(ppiScreen.y) / ppiPrinter.y;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/radiobox.cpp
-// Purpose: wxRadioBox
-// Author: Stefan Csomor
-// Modified by: JS Lair (99/11/15) first implementation
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-//-------------------------------------------------------------------------------------
-// headers
-//-------------------------------------------------------------------------------------
-
-#include "wx/wxprec.h"
-
-#if wxUSE_RADIOBOX
-
-#include "wx/radiobox.h"
-
-#ifndef WX_PRECOMP
- #include "wx/radiobut.h"
- #include "wx/arrstr.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
-
-//-------------------------------------------------------------------------------------
-// ¥ wxRadioBox()
-//-------------------------------------------------------------------------------------
-// Default constructor
-BEGIN_EVENT_TABLE(wxRadioBox, wxControl)
- EVT_RADIOBUTTON( wxID_ANY , wxRadioBox::OnRadioButton )
-END_EVENT_TABLE()
-
-void wxRadioBox::OnRadioButton( wxCommandEvent &outer )
-{
- if ( outer.IsChecked() )
- {
- wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId);
- int i = GetSelection() ;
- event.SetInt( i );
- event.SetString(GetString(i));
- event.SetEventObject( this );
- ProcessCommand(event);
- }
-}
-
-wxRadioBox::wxRadioBox()
-{
- m_noItems = 0;
- m_noRowsOrCols = 0;
- m_radioButtonCycle = NULL;
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&,
-// const wxSize&, int, const wxString[], int, long,
-// const wxValidator&, const wxString&)
-//-------------------------------------------------------------------------------------
-// Contructor, creating and showing a radiobox
-//
-// inline defined
-//
-
-//-------------------------------------------------------------------------------------
-// ¥ ~wxRadioBox
-//-------------------------------------------------------------------------------------
-// Destructor, destroying the radiobox item
-
-wxRadioBox::~wxRadioBox()
-{
- m_isBeingDeleted = true;
-
- wxRadioButton *next,*current;
-
- current=m_radioButtonCycle->NextInCycle();
- next=current->NextInCycle();
- while (current!=m_radioButtonCycle) {
- delete current;
- current=next;
- next=current->NextInCycle();
- }
- delete current;
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ Create
-//-------------------------------------------------------------------------------------
-// Create the radiobox for two-step construction
-
-bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
- const wxPoint& pos, const wxSize& size,
- const wxArrayString& choices,
- int majorDim, long style,
- const wxValidator& val, const wxString& name)
-{
- wxCArrayString chs(choices);
-
- return Create(parent, id, label, pos, size, chs.GetCount(),
- chs.GetStrings(), majorDim, style, val, name);
-}
-
-bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
- const wxPoint& pos, const wxSize& size,
- int n, const wxString choices[],
- int majorDim, long style,
- const wxValidator& val, const wxString& name)
-{
- if ( !wxControl::Create(parent, id, pos, size, style, val, name) )
- return false;
-
- int i;
-
- m_noItems = (unsigned int)n;
- m_noRowsOrCols = majorDim;
- m_radioButtonCycle = NULL;
-
- SetMajorDim(majorDim == 0 ? n : majorDim, style);
-
- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ;
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
- kControlGroupBoxTextTitleProc , (long) this ) ;
-
- for (i = 0; i < n; i++)
- {
- wxRadioButton *radBtn = new wxRadioButton
- (
- this,
- wxID_ANY,
- wxStripMenuCodes(choices[i]),
- wxPoint(5,20*i+10),
- wxDefaultSize,
- i == 0 ? wxRB_GROUP : 0
- );
- if ( i == 0 )
- m_radioButtonCycle = radBtn ;
- // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle);
- }
-
- SetSelection(0);
- MacPostControlCreate() ;
-
- return true;
-}
-
-
-//-------------------------------------------------------------------------------------
-// ¥ Enable(bool)
-//-------------------------------------------------------------------------------------
-// Enables or disables the entire radiobox
-
-bool wxRadioBox::Enable(bool enable)
-{
- if (!wxControl::Enable(enable))
- return false;
-
- wxRadioButton *current = m_radioButtonCycle;
- for (unsigned int i = 0; i < m_noItems; i++)
- {
- current->Enable(enable);
- current = current->NextInCycle();
- }
- return true;
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ Enable(unsigned int, bool)
-//-------------------------------------------------------------------------------------
-// Enables or disables an given button
-
-bool wxRadioBox::Enable(unsigned int item, bool enable)
-{
- if (!IsValid(item))
- return false;
-
- unsigned int i = 0;
- wxRadioButton *current = m_radioButtonCycle;
- while (i != item)
- {
- i++;
- current = current->NextInCycle();
- }
- return current->Enable(enable);
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ GetLabel()
-//-------------------------------------------------------------------------------------
-// Returns the radiobox label
-
-wxString wxRadioBox::GetLabel() const
-{
- return wxControl::GetLabel();
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ GetLabel(int)
-//-------------------------------------------------------------------------------------
-// Returns the label for the given button
-
-wxString wxRadioBox::GetString(unsigned int item) const
-{
- wxRadioButton *current;
-
- if (!IsValid(item))
- return wxEmptyString;
-
- unsigned int i = 0;
- current = m_radioButtonCycle;
- while (i != item) {
- i++;
- current = current->NextInCycle();
- }
- return current->GetLabel();
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ GetSelection
-//-------------------------------------------------------------------------------------
-// Returns the zero-based position of the selected button
-
-int wxRadioBox::GetSelection() const
-{
- int i;
- wxRadioButton *current;
-
- i=0;
- current=m_radioButtonCycle;
- while (!current->GetValue()) {
- i++;
- current=current->NextInCycle();
- }
-
- return i;
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ Number
-//-------------------------------------------------------------------------------------
-// Returns the number of buttons in the radiobox
-//
-// inline defined
-//
-
-//-------------------------------------------------------------------------------------
-// ¥ SetLabel(const wxString&)
-//-------------------------------------------------------------------------------------
-// Sets the radiobox label
-
-void wxRadioBox::SetLabel(const wxString& label)
-{
- return wxControl::SetLabel(label);
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ SetLabel(int, const wxString&)
-//-------------------------------------------------------------------------------------
-// Sets the label of a given button
-
-void wxRadioBox::SetString(unsigned int item,const wxString& label)
-{
- if (!IsValid(item))
- return;
-
- unsigned int i=0;
- wxRadioButton *current=m_radioButtonCycle;
- while (i!=item)
- {
- i++;
- current=current->NextInCycle();
- }
- return current->SetLabel(label);
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ SetSelection
-//-------------------------------------------------------------------------------------
-// Sets a button by passing the desired position. This does not cause
-// wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted
-
-void wxRadioBox::SetSelection(int item)
-{
- int i;
- wxRadioButton *current;
-
- if (!IsValid(item))
- return;
- i=0;
- current=m_radioButtonCycle;
- while (i!=item) {
- i++;
- current=current->NextInCycle();
- }
- current->SetValue(true);
-
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ Show(bool)
-//-------------------------------------------------------------------------------------
-// Shows or hides the entire radiobox
-
-bool wxRadioBox::Show(bool show)
-{
- wxRadioButton *current;
-
- wxControl::Show(show);
-
- current=m_radioButtonCycle;
- for (unsigned int i=0; i<m_noItems; i++)
- {
- current->Show(show);
- current=current->NextInCycle();
- }
- return true;
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ Show(unsigned int, bool)
-//-------------------------------------------------------------------------------------
-// Shows or hides the given button
-
-bool wxRadioBox::Show(unsigned int item, bool show)
-{
- if (!IsValid(item))
- return false;
-
- unsigned int i = 0;
- wxRadioButton *current=m_radioButtonCycle;
- while (i!=item) {
- i++;
- current=current->NextInCycle();
- }
- return current->Show(show);
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ Command
-//-------------------------------------------------------------------------------------
-// Simulates the effect of the user issuing a command to the item
-
-void wxRadioBox::Command (wxCommandEvent & event)
-{
- SetSelection (event.GetInt());
- ProcessCommand (event);
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ SetFocus
-//-------------------------------------------------------------------------------------
-// Sets the selected button to receive keyboard input
-
-void wxRadioBox::SetFocus()
-{
- int i;
- wxRadioButton *current;
-
- i=0;
- current=m_radioButtonCycle;
- while (!current->GetValue()) {
- i++;
- current=current->NextInCycle();
- }
- current->SetFocus();
-}
-
-
-//-------------------------------------------------------------------------------------
-// ¥ DoSetSize
-//-------------------------------------------------------------------------------------
-// Simulates the effect of the user issuing a command to the item
-
-#define RADIO_SIZE 20
-
-void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
-{
- unsigned int i;
- wxRadioButton *current;
-
- // define the position
-
- int x_current, y_current;
- int x_offset,y_offset;
- int widthOld, heightOld;
- GetSize(&widthOld, &heightOld);
-
- x_offset = x;
- y_offset = y;
- GetPosition(&x_current, &y_current);
- if ((x == wxDefaultCoord) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- x_offset = x_current;
- if ((y == wxDefaultCoord)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- y_offset = y_current;
-
- // define size
-
- int charWidth,charHeight;
- int maxWidth,maxHeight;
- int eachWidth[128],eachHeight[128];
- int totWidth,totHeight;
-
- SetFont(GetParent()->GetFont());
- GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight);
- charWidth/=52;
-
- maxWidth=-1;
- maxHeight=-1;
- for (i = 0 ; i < m_noItems; i++)
- {
- GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i]);
- eachWidth[i] = (int)(eachWidth[i] + RADIO_SIZE);
- eachHeight[i] = (int)((3*eachHeight[i])/2);
- if (maxWidth<eachWidth[i]) maxWidth = eachWidth[i];
- if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i];
- }
-
- totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ;
- totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth;
-
- // only change our width/height if asked for
- if ( width == wxDefaultCoord )
- {
- if ( sizeFlags & wxSIZE_AUTO_WIDTH )
- width = totWidth ;
- else
- width = widthOld;
- }
-
- if ( height == wxDefaultCoord )
- {
- if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
- height = totHeight ;
- else
- height = heightOld;
- }
-
- wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO);
-
- // arrange radiobuttons
-
- int x_start,y_start;
-
-
- x_start = charWidth;
- y_start = 15 ;
- if ( UMAGetSystemVersion() >= 0x1030 )
- {
- //need to add a few more pixels for the top border on panther
- y_start = y_start + 5; //how many exactly should this be to meet the HIG?
- }
- x_offset = x_start;
- y_offset = y_start;
-
- current=m_radioButtonCycle;
- for ( i = 0 ; i < m_noItems; i++)
- {
- if (i&&((i%GetMajorDim())==0)) // not to do for the zero button!
- {
- if (m_windowStyle & wxRA_VERTICAL)
- {
- x_offset += maxWidth + charWidth;
- y_offset = y_start;
- }
- else
- {
- x_offset = x_start;
- y_offset += maxHeight ; /*+ charHeight/2;*/
- }
- }
-
- current->SetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]);
- current=current->NextInCycle();
-
- if (m_windowStyle & wxRA_SPECIFY_ROWS)
- y_offset += maxHeight ; /*+ charHeight/2;*/
- else
- x_offset += maxWidth + charWidth;
- }
-}
-
-wxSize wxRadioBox::DoGetBestSize() const
-{
- int charWidth, charHeight;
- int maxWidth, maxHeight;
- int eachWidth, eachHeight;
- int totWidth, totHeight;
-
- wxFont font = GetParent()->GetFont();
- GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
- &charWidth, &charHeight, NULL, NULL, &font);
- charWidth /= 52;
-
- maxWidth = -1;
- maxHeight = -1;
-
- for (unsigned int i = 0 ; i < m_noItems; i++)
- {
- GetTextExtent(GetString(i), &eachWidth, &eachHeight);
- eachWidth = (int)(eachWidth + RADIO_SIZE) ;
- eachHeight = (int)((3 * eachHeight) / 2);
- if (maxWidth < eachWidth) maxWidth = eachWidth;
- if (maxHeight < eachHeight) maxHeight = eachHeight;
- }
-
- totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ;
- totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth;
-
- if ( UMAGetSystemVersion() >= 0x1030 )
- {
- //need to add a few more pixels for the static boxborder on panther
- totHeight = totHeight + 10; //how many exactly should this be to meet the HIG?
- }
- // handle radio box title as well
- GetTextExtent(GetLabel(), &eachWidth, NULL);
- eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ;
- if (totWidth < eachWidth)
- totWidth = eachWidth;
-
- return wxSize(totWidth, totHeight);
-}
-
-#endif // wxUSE_RADIOBOX
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/radiobut.cpp
-// Purpose: wxRadioButton
-// Author: AUTHOR
-// Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox
-// Created: ??/??/98
-// RCS-ID: $Id$
-// Copyright: (c) AUTHOR
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/radiobut.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
-
-#include "wx/mac/uma.h"
-
-bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
- kControlRadioButtonProc , (long) this ) ;
-
- MacPostControlCreate() ;
-
- m_cycle = this ;
-
- 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();
- 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)
-{
- wxRadioButton *cycle;
- if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val )
- return ;
-
- ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ;
- if (val)
- {
- cycle=this->NextInCycle();
- if (cycle!=NULL) {
- while (cycle!=this) {
- cycle->SetValue(false);
- cycle=cycle->NextInCycle();
- }
- }
- }
- MacRedrawControl() ;
-}
-
-bool wxRadioButton::GetValue() const
-{
- return ::GetControl32BitValue( (ControlHandle) m_macControl ) ;
-}
-
-void wxRadioButton::Command (wxCommandEvent & event)
-{
- SetValue ( (event.GetInt() != 0) );
- ProcessCommand (event);
-}
-
-void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
-{
- if ( GetValue() )
- return ;
-
- wxRadioButton *cycle, *old = NULL ;
- cycle=this->NextInCycle();
- if (cycle!=NULL) {
- while (cycle!=this) {
- if ( cycle->GetValue() ) {
- old = cycle ;
- cycle->SetValue(false);
- }
- cycle=cycle->NextInCycle();
- }
- }
-
- SetValue(true) ;
-
- if ( old ) {
- wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, old->m_windowId );
- event.SetEventObject(old);
- event.SetInt( false );
- old->ProcessCommand(event);
- }
- wxCommandEvent event2(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
- event2.SetEventObject(this);
- event2.SetInt( true );
- ProcessCommand(event2);
-}
-
-wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
-{
- wxRadioButton *next,*current;
-
- if (cycle==NULL) {
- m_cycle=this;
- return(this);
- }
- else {
- current=cycle;
- while ((next=current->m_cycle)!=cycle)
- current=current->m_cycle;
- m_cycle=cycle;
- current->m_cycle=this;
- return(cycle);
- }
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// File: src/mac/classic/region.cpp
-// Purpose: Region class
-// Author: Stefan Csomor
-// Created: Fri Oct 24 10:46:34 MET 1997
-// RCS-ID: $Id$
-// Copyright: (c) 1997 Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/region.h"
-
-#ifndef WX_PRECOMP
- #include "wx/gdicmn.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
-IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
-
-//-----------------------------------------------------------------------------
-// wxRegionRefData implementation
-//-----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxRegionRefData : public wxGDIRefData {
-public:
- wxRegionRefData()
- {
- m_macRgn = NewRgn() ;
- }
-
- wxRegionRefData(const wxRegionRefData& data)
- : wxGDIRefData()
- {
- m_macRgn = NewRgn() ;
- CopyRgn( data.m_macRgn , m_macRgn ) ;
- }
-
- virtual ~wxRegionRefData()
- {
- DisposeRgn( m_macRgn ) ;
- }
- RgnHandle m_macRgn ;
-};
-
-#define M_REGION (((wxRegionRefData*)m_refData)->m_macRgn)
-#define OTHER_M_REGION(a) (((wxRegionRefData*)(a.m_refData))->m_macRgn)
-
-//-----------------------------------------------------------------------------
-// wxRegion
-//-----------------------------------------------------------------------------
-
-/*!
- * Create an empty region.
- */
-wxRegion::wxRegion()
-{
- m_refData = new wxRegionRefData;
-}
-
-wxRegion::wxRegion(WXHRGN hRegion )
-{
- m_refData = new wxRegionRefData;
- CopyRgn( (RgnHandle) hRegion , (RgnHandle) M_REGION ) ;
-}
-
-wxRegion::wxRegion(long x, long y, long w, long h)
-{
- m_refData = new wxRegionRefData;
- SetRectRgn( (RgnHandle) M_REGION , x , y , x+w , y+h ) ;
-}
-
-wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
-{
- m_refData = new wxRegionRefData;
- SetRectRgn( (RgnHandle) M_REGION , topLeft.x , topLeft.y , bottomRight.x , bottomRight.y ) ;
-}
-
-wxRegion::wxRegion(const wxRect& rect)
-{
- m_refData = new wxRegionRefData;
- SetRectRgn( (RgnHandle) M_REGION , rect.x , rect.y , rect.x+rect.width , rect.y+rect.height ) ;
-}
-
-/*!
- * Destroy the region.
- */
-wxRegion::~wxRegion()
-{
- // m_refData unrefed in ~wxObject
-}
-
-//-----------------------------------------------------------------------------
-//# Modify region
-//-----------------------------------------------------------------------------
-
-//! Clear current region
-void wxRegion::Clear()
-{
- UnRef();
-}
-
-//! Combine rectangle (x, y, w, h) with this.
-bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op)
-{
- // Don't change shared data
- if (!m_refData)
- {
- m_refData = new wxRegionRefData();
- }
- else if (m_refData->GetRefCount() > 1)
- {
- wxRegionRefData* ref = (wxRegionRefData*)m_refData;
- UnRef();
- m_refData = new wxRegionRefData(*ref);
- }
- RgnHandle rgn = NewRgn() ;
- SetRectRgn( rgn , x , y, x+width,y + height ) ;
-
- switch (op)
- {
- case wxRGN_AND:
- SectRgn( M_REGION , rgn , M_REGION ) ;
- break ;
- case wxRGN_OR:
- UnionRgn( M_REGION , rgn , M_REGION ) ;
- break ;
- case wxRGN_XOR:
- XorRgn( M_REGION , rgn , M_REGION ) ;
- break ;
- case wxRGN_DIFF:
- DiffRgn( M_REGION , rgn , M_REGION ) ;
- break ;
- case wxRGN_COPY:
- default:
- CopyRgn( rgn ,M_REGION ) ;
- break ;
- }
-
- DisposeRgn( rgn ) ;
-
- return true;
-}
-
-//! Union /e region with this.
-bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
-{
- if (region.Empty())
- return false;
-
- // Don't change shared data
- if (!m_refData) {
- m_refData = new wxRegionRefData();
- }
- else if (m_refData->GetRefCount() > 1)
- {
- wxRegionRefData* ref = (wxRegionRefData*)m_refData;
- UnRef();
- m_refData = new wxRegionRefData(*ref);
- }
-
- switch (op)
- {
- case wxRGN_AND:
- SectRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
- break ;
- case wxRGN_OR:
- UnionRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
- break ;
- case wxRGN_XOR:
- XorRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
- break ;
- case wxRGN_DIFF:
- DiffRgn( M_REGION , OTHER_M_REGION(region) , M_REGION ) ;
- break ;
- case wxRGN_COPY:
- default:
- CopyRgn( OTHER_M_REGION(region) ,M_REGION ) ;
- break ;
- }
-
- return true;
-}
-
-bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
-{
- return Combine(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), op);
-}
-
-//-----------------------------------------------------------------------------
-//# Information on region
-//-----------------------------------------------------------------------------
-
-// Outer bounds of region
-void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const
-{
- if (m_refData)
- {
- Rect box ;
- GetRegionBounds( M_REGION , &box ) ;
- x = box.left ;
- y = box.top ;
- w = box.right - box.left ;
- h = box.bottom - box.top ;
- }
- else
- {
- x = y = w = h = 0;
- }
-}
-
-wxRect wxRegion::GetBox() const
-{
- wxCoord x, y, w, h;
- GetBox(x, y, w, h);
- return wxRect(x, y, w, h);
-}
-
-// Is region empty?
-bool wxRegion::Empty() const
-{
- return EmptyRgn( M_REGION ) ;
-}
-
-const WXHRGN wxRegion::GetWXHRGN() const
-{
- return M_REGION ;
-}
-
-//-----------------------------------------------------------------------------
-//# Tests
-//-----------------------------------------------------------------------------
-
-// Does the region contain the point (x,y)?
-wxRegionContain wxRegion::Contains(long x, long y) const
-{
- if (!m_refData)
- return wxOutRegion;
-
- // TODO. Return wxInRegion if within region.
- if (0)
- return wxInRegion;
- return wxOutRegion;
-}
-
-// Does the region contain the point pt?
-wxRegionContain wxRegion::Contains(const wxPoint& pt) const
-{
- if (!m_refData)
- return wxOutRegion;
-
- Point p = { pt.y , pt.x } ;
- if (PtInRgn( p , M_REGION ) )
- return wxInRegion;
-
- return wxOutRegion;
-}
-
-// Does the region contain the rectangle (x, y, w, h)?
-wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const
-{
- if (!m_refData)
- return wxOutRegion;
-
- Rect rect = { y , x , y + h , x + w } ;
- if (RectInRgn( &rect , M_REGION ) )
- return wxInRegion;
- else
- return wxOutRegion;
-}
-
-// Does the region contain the rectangle rect
-wxRegionContain wxRegion::Contains(const wxRect& rect) const
-{
- if (!m_refData)
- return wxOutRegion;
-
- long x, y, w, h;
- x = rect.x;
- y = rect.y;
- w = rect.GetWidth();
- h = rect.GetHeight();
- return Contains(x, y, w, h);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// //
-// wxRegionIterator //
-// //
-///////////////////////////////////////////////////////////////////////////////
-
-/*!
- * Initialize empty iterator
- */
-wxRegionIterator::wxRegionIterator()
- : m_current(0), m_numRects(0), m_rects(NULL)
-{
-}
-
-wxRegionIterator::~wxRegionIterator()
-{
- if (m_rects) {
- delete[] m_rects;
- m_rects = NULL;
- }
-}
-
-wxRegionIterator::wxRegionIterator(const wxRegionIterator& iterator)
- : wxObject()
- , m_current(iterator.m_current)
- , m_numRects(0)
- , m_rects(NULL)
-{
- SetRects(iterator.m_numRects, iterator.m_rects);
-}
-
-wxRegionIterator& wxRegionIterator::operator=(const wxRegionIterator& iterator)
-{
- m_current = iterator.m_current;
- SetRects(iterator.m_numRects, iterator.m_rects);
- return *this;
-}
-
-/*!
- * Set iterator rects for region
- */
-void wxRegionIterator::SetRects(long numRects, wxRect *rects)
-{
- if (m_rects) {
- delete[] m_rects;
- m_rects = NULL;
- }
- if (rects)
- {
- int i;
- m_rects = new wxRect[numRects];
- for (i = 0; i < numRects; i++)
- m_rects[i] = rects[i];
- }
- m_numRects = numRects;
-}
-
-/*!
- * Initialize iterator for region
- */
-wxRegionIterator::wxRegionIterator(const wxRegion& region)
-{
- m_rects = NULL;
-
- Reset(region);
-}
-
-/*!
- * Reset iterator for a new /e region.
- */
-void wxRegionIterator::Reset(const wxRegion& region)
-{
- m_current = 0;
- m_region = region;
-
- if (m_rects) {
- delete[] m_rects;
- m_rects = NULL;
- }
-
- if (m_region.Empty())
- m_numRects = 0;
- else
- {
- // we cannot dissolve it into rects on mac
- m_rects = new wxRect[1];
- Rect rect ;
- GetRegionBounds( OTHER_M_REGION( region ) , &rect ) ;
- m_rects[0].x = rect.left;
- m_rects[0].y = rect.top;
- m_rects[0].width = rect.right - rect.left;
- m_rects[0].height = rect.bottom - rect.top;
- m_numRects = 1;
- }
-}
-
-/*!
- * Increment iterator. The rectangle returned is the one after the
- * incrementation.
- */
-wxRegionIterator& wxRegionIterator::operator ++ ()
-{
- if (m_current < m_numRects)
- ++m_current;
- return *this;
-}
-
-/*!
- * Increment iterator. The rectangle returned is the one before the
- * incrementation.
- */
-wxRegionIterator wxRegionIterator::operator ++ (int)
-{
- wxRegionIterator previous(*this);
-
- if (m_current < m_numRects)
- ++m_current;
-
- return previous;
-}
-
-long wxRegionIterator::GetX() const
-{
- if (m_current < m_numRects)
- return m_rects[m_current].x;
- return 0;
-}
-
-long wxRegionIterator::GetY() const
-{
- if (m_current < m_numRects)
- return m_rects[m_current].y;
- return 0;
-}
-
-long wxRegionIterator::GetW() const
-{
- if (m_current < m_numRects)
- return m_rects[m_current].width ;
- return 0;
-}
-
-long wxRegionIterator::GetH() const
-{
- if (m_current < m_numRects)
- return m_rects[m_current].height;
- return 0;
-}
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: mac/renderer.cpp
-// Purpose: implementation of wxRendererNative for Mac
-// Author: Vadim Zeitlin
-// Modified by:
-// Created: 20.07.2003
-// RCS-ID: $Id$
-// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
-// License: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// for compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/string.h"
- #include "wx/dc.h"
- #include "wx/bitmap.h"
- #include "wx/settings.h"
-#endif //WX_PRECOMP
-
-#include "wx/renderer.h"
-
-// ----------------------------------------------------------------------------
-// wxRendererMac: our wxRendererNative implementation
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxRendererMac : public wxDelegateRendererNative
-{
-public:
- // draw the header control button (used by wxListCtrl)
- virtual void DrawHeaderButton(wxWindow *win,
- wxDC& dc,
- const wxRect& rect,
- int flags = 0);
-
- // draw the expanded/collapsed icon for a tree control item
- virtual void DrawTreeItemButton(wxWindow *win,
- wxDC& dc,
- const wxRect& rect,
- int flags = 0);
-
- // draw a (vertical) sash
- virtual void DrawSplitterSash(wxWindow *win,
- wxDC& dc,
- const wxSize& size,
- wxCoord position,
- wxOrientation orient,
- int flags = 0);
-
-private:
- // the tree buttons
- wxBitmap m_bmpTreeExpanded,
- m_bmpTreeCollapsed;
-};
-
-// ----------------------------------------------------------------------------
-// Aqua arrows
-// ----------------------------------------------------------------------------
-
-/* XPM */
-static const char *aqua_arrow_right_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"13 11 4 1",
-" c None",
-"b c #C0C0C0",
-"c c #707070",
-"d c #A0A0A0",
-/* pixels */
-" b ",
-" ddb ",
-" cccdb ",
-" cccccd ",
-" ccccccdb ",
-" ccccccccd",
-" ccccccdb ",
-" cccccb ",
-" cccdb ",
-" ddb ",
-" b "
-};
-
-/* XPM */
-static const char *aqua_arrow_down_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"13 11 4 1",
-" c None",
-"b c #C0C0C0",
-"c c #707070",
-"d c #A0A0A0",
-/* pixels */
-" ",
-" ",
-" bdcccccccdb ",
-" dcccccccd ",
-" bcccccccb ",
-" dcccccd ",
-" bcccccb ",
-" bcccd ",
-" dcd ",
-" bcb ",
-" d "
-};
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-/* static */
-wxRendererNative& wxRendererNative::GetDefault()
-{
- static wxRendererMac s_rendererMac;
-
- return s_rendererMac;
-}
-
-void
-wxRendererMac::DrawHeaderButton(wxWindow *win,
- wxDC& dc,
- const wxRect& rect,
- int WXUNUSED(flags))
-{
- const int CORNER = 1;
-
- const wxCoord x = rect.x-1,
- y = rect.y-1,
- w = rect.width,
- h = rect.height;
-
- int major,minor;
- wxGetOsVersion( &major, &minor );
-
- dc.SetBrush( *wxTRANSPARENT_BRUSH );
-
- if (major >= 10)
- {
- dc.SetPen( wxPen( wxColour( 0xC5 , 0xC5 , 0xC5 ) , 1 , wxSOLID ) );
- dc.DrawRectangle( x, y+CORNER, 1, h-CORNER ); // left
- // The right border is overdrawn by the left border of the right neighbouring
- // header (to maintain a proper single pixel border). Except for the
- // rightmost header of the listctrl.
- dc.DrawRectangle( x+w+(CORNER*2), y+CORNER, 1, h-CORNER ); // right
- dc.SetPen( wxPen( wxColour( 0xB1 , 0xB1 , 0xB1 ) , 1 , wxSOLID ) );
- dc.DrawRectangle( x, y+h, w+(CORNER*3), 1 ); // bottom
- dc.DrawRectangle( x, y, w+(CORNER*3), 1 ); // top
-
- // Do a fill of the interior for background:
- dc.SetPen( wxPen( wxColour( 0xF6 , 0xF6 , 0xF6 ) , 1 , wxSOLID ) );
- dc.DrawRectangle( x+CORNER, y+CORNER, w+CORNER, h-CORNER );
-
- // Do the gradient fill:
- static int grayValues[] =
- {
- 0xF6, 0xF2, 0xEF, 0xED, 0xED, 0xEB, 0xEA, 0xEA, 0xE8,
- 0xE8, 0xE2, 0xE5, 0xE8, 0xEB, 0xEF, 0xF2, 0xFD
- };
- int i;
- for (i=0; i < h && i < (int)WXSIZEOF(grayValues); i++)
- {
- dc.SetPen( wxPen( wxColour( grayValues[i] , grayValues[i] , grayValues[i] ),
- 1 , wxSOLID ) );
- dc.DrawRectangle( x+CORNER, y+CORNER+i, w+CORNER, 1 );
- }
- }
- else
- {
- dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ) , 1 , wxSOLID ) );
- dc.DrawLine( x+w-CORNER+1, y, x+w, y+h ); // right (outer)
- dc.DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer)
-
- wxPen pen( wxColour( 0x88 , 0x88 , 0x88 ), 1, wxSOLID );
-
- dc.SetPen( pen );
- dc.DrawLine( x+w-CORNER, y, x+w-1, y+h ); // right (inner)
- dc.DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner)
-
- dc.SetPen( *wxWHITE_PEN );
- dc.DrawRectangle( x, y, w-CORNER+1, 1 ); // top (outer)
- dc.DrawRectangle( x, y, 1, h ); // left (outer)
- dc.DrawLine( x, y+h-1, x+1, y+h-1 );
- dc.DrawLine( x+w-1, y, x+w-1, y+1 );
- }
-}
-
-void
-wxRendererMac::DrawTreeItemButton(wxWindow *win,
- wxDC& dc,
- const wxRect& rect,
- int flags)
-{
- // init the buttons on demand
- if ( !m_bmpTreeExpanded.Ok() )
- {
- m_bmpTreeExpanded = wxBitmap(aqua_arrow_down_xpm);
- m_bmpTreeCollapsed = wxBitmap(aqua_arrow_right_xpm);
- }
-
- // draw them
-
- // VZ: this is the old code from treectlg.cpp which apparently doesn't work
- // but I kept it here just in case it is needed -- if not, please
- // remove it
-#if 0 // def __WXMAC__
- wxMacPortSetter helper(&dc) ;
- wxMacWindowClipper clipper(this) ;
- wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
-
- int loc_x = x - 5 ;
- int loc_y = y_mid - 6 ;
- MacWindowToRootWindow( & loc_x , & loc_y ) ;
- Rect bounds = { loc_y , loc_x , loc_y + 18 , loc_x + 12 } ;
- ThemeButtonDrawInfo info = { kThemeStateActive , item->IsExpanded() ? kThemeDisclosureDown : kThemeDisclosureRight ,
- kThemeAdornmentNone };
- DrawThemeButton( &bounds, kThemeDisclosureButton ,
- &info , NULL , NULL , NULL , NULL ) ;
-#else // 1
- dc.DrawBitmap(flags & wxCONTROL_EXPANDED ? m_bmpTreeExpanded
- : m_bmpTreeCollapsed,
- rect.x, rect.y, true /* use mask */);
-#endif // 0/1
-}
-
-void
-wxRendererMac::DrawSplitterSash(wxWindow *win,
- wxDC& dc,
- const wxSize& size,
- wxCoord position,
- wxOrientation orient,
- int WXUNUSED(flags))
-{
- // VZ: we have to somehow determine if we're drawing a normal sash or
- // a brushed metal one as they look quite differently... this is
- // completely bogus anyhow, of course (TODO)
-
-#if 0
- dc.SetPen(*wxLIGHT_GREY_PEN);
- dc.SetBrush(*wxWHITE_BRUSH);
- if ( orient == wxVERTICAL )
- dc.DrawRectangle(position, 0, 7, size.y);
- else
- dc.DrawRectangle(0, position, size.x, 7);
-#else
- // Do the gradient fill:
- static int grayValues[] =
- {
- 0xA0, 0xF6, 0xED, 0xE4, 0xE2, 0xD0, 0xA0
- };
- dc.SetBrush( *wxTRANSPARENT_BRUSH );
- if ( orient == wxVERTICAL )
- {
- int i;
- for (i=0; i < (int)WXSIZEOF(grayValues); i++)
- {
- dc.SetPen( wxPen( wxColour( grayValues[i] , grayValues[i] , grayValues[i] ),
- 1 , wxSOLID ) );
- dc.DrawRectangle( position+i, 0, 1, size.y );
- }
- }
- else
- {
- int i;
- for (i=0; i < (int)WXSIZEOF(grayValues); i++)
- {
- dc.SetPen( wxPen( wxColour( grayValues[i] , grayValues[i] , grayValues[i] ),
- 1 , wxSOLID ) );
- dc.DrawRectangle( 0, position+i, size.x, 1 );
- }
- }
-#endif
-}
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/scrolbar.cpp
-// Purpose: wxScrollBar
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/scrolbar.h"
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/log.h"
-#endif // WX_PRECOMP
-
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
-
-BEGIN_EVENT_TABLE(wxScrollBar, wxControl)
-END_EVENT_TABLE()
-
-extern ControlActionUPP wxMacLiveScrollbarActionUPP ;
-
-// Scrollbar
-bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
-
- m_macControl = (WXWidget) ::NewControl(MAC_WXHWND(parent->MacGetRootWindow()) ,
- &bounds , title , false , 0 , 0 , 100,
- kControlScrollBarLiveProc , (long) this) ;
-
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-
- ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ;
-
- MacPostControlCreate() ;
-
- return true;
-}
-
-wxScrollBar::~wxScrollBar()
-{
-}
-
-void wxScrollBar::SetThumbPosition(int viewStart)
-{
- ::SetControl32BitValue( (ControlHandle) m_macControl , viewStart ) ;
-}
-
-int wxScrollBar::GetThumbPosition() const
-{
- return ::GetControl32BitValue( (ControlHandle) m_macControl ) ;
-}
-
-void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize,
- bool refresh)
-{
- m_pageSize = pageSize;
- m_viewSize = thumbSize;
- m_objectSize = range;
-
- int range1 = wxMax((m_objectSize - m_viewSize), 0) ;
-
- SetControl32BitMaximum( (ControlHandle) m_macControl , range1 ) ;
- SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ;
- SetControl32BitValue( (ControlHandle) m_macControl , position ) ;
-
- if ( UMAGetAppearanceVersion() >= 0x0110 )
- {
- if ( SetControlViewSize != (void*) kUnresolvedCFragSymbolAddress )
- {
- SetControlViewSize( (ControlHandle) m_macControl , m_viewSize ) ;
- }
- }
- if ( refresh )
- MacRedrawControl() ;
-}
-
-
-void wxScrollBar::Command(wxCommandEvent& event)
-{
- SetThumbPosition(event.GetInt());
- ProcessCommand(event);
-}
-
-void wxScrollBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown )
-{
- if ( (ControlHandle) m_macControl == NULL )
- return ;
-
- int position = GetControl32BitValue( (ControlHandle) m_macControl) ;
- int minPos = GetControl32BitMinimum( (ControlHandle) m_macControl) ;
- int maxPos = GetControl32BitMaximum( (ControlHandle) m_macControl) ;
-
- wxEventType scrollEvent = wxEVT_NULL;
- int nScrollInc = 0;
-
- // all events have already been reported during mouse down, except for THUMBRELEASE
- if ( !mouseStillDown && controlpart !=kControlIndicatorPart )
- return ;
-
- switch( controlpart )
- {
- case kControlUpButtonPart :
- nScrollInc = -1;
- scrollEvent = wxEVT_SCROLL_LINEUP;
- break ;
- case kControlDownButtonPart :
- nScrollInc = 1;
- scrollEvent = wxEVT_SCROLL_LINEDOWN;
- break ;
- case kControlPageUpPart :
- nScrollInc = -m_pageSize;
- scrollEvent = wxEVT_SCROLL_PAGEUP;
- break ;
- case kControlPageDownPart :
- nScrollInc = m_pageSize;
- scrollEvent = wxEVT_SCROLL_PAGEDOWN;
- break ;
- case kControlIndicatorPart :
- nScrollInc = 0 ;
- if ( mouseStillDown )
- scrollEvent = wxEVT_SCROLL_THUMBTRACK;
- else
- scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
- break ;
- default :
- wxFAIL_MSG(wxT("illegal scrollbar selector"));
- break ;
- }
-
- int new_pos = position + nScrollInc;
-
- if (new_pos < minPos)
- new_pos = minPos;
- if (new_pos > maxPos)
- new_pos = maxPos;
- if ( nScrollInc )
- SetThumbPosition(new_pos);
-
- wxScrollEvent event(scrollEvent, m_windowId);
- if ( m_windowStyle & wxHORIZONTAL )
- {
- event.SetOrientation( wxHORIZONTAL ) ;
- }
- else
- {
- event.SetOrientation( wxVERTICAL ) ;
- }
- event.SetPosition(new_pos);
- event.SetEventObject( this );
- wxWindow* window = GetParent() ;
- if (window && window->MacIsWindowScrollbar(this) )
- {
- // this is hardcoded
- window->MacOnScroll(event);
- }
- else
- GetEventHandler()->ProcessEvent(event);
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/settings.cpp
-// Purpose: wxSettings
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/settings.h"
-
-#ifndef WX_PRECOMP
- #include "wx/utils.h"
- #include "wx/gdicmn.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-// ----------------------------------------------------------------------------
-// wxSystemSettingsNative
-// ----------------------------------------------------------------------------
-
-// ----------------------------------------------------------------------------
-// colours
-// ----------------------------------------------------------------------------
-
-wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
-{
- int major,minor;
- wxGetOsVersion( &major, &minor );
-
- switch( index )
- {
- case wxSYS_COLOUR_SCROLLBAR :
- case wxSYS_COLOUR_BACKGROUND:
- case wxSYS_COLOUR_ACTIVECAPTION:
- case wxSYS_COLOUR_INACTIVECAPTION:
- case wxSYS_COLOUR_MENU:
- case wxSYS_COLOUR_WINDOW:
- case wxSYS_COLOUR_WINDOWFRAME:
- case wxSYS_COLOUR_ACTIVEBORDER:
- case wxSYS_COLOUR_INACTIVEBORDER:
- case wxSYS_COLOUR_BTNFACE:
- case wxSYS_COLOUR_MENUBAR:
- return wxColor( 0xDD , 0xDD , 0xDD ) ;
- break ;
-
- case wxSYS_COLOUR_LISTBOX :
- {
- if (major >= 10)
- return *wxWHITE ;
- else
- return wxColor( 0xEE , 0xEE , 0xEE ) ;
- break ;
- }
- case wxSYS_COLOUR_BTNSHADOW:
- if (major >= 10)
- return wxColor( 0xBE , 0xBE , 0xBE ) ;
- else
- return wxColor( 0x44 , 0x44 , 0x44 ) ;
- break ;
-
- case wxSYS_COLOUR_BTNTEXT:
- case wxSYS_COLOUR_MENUTEXT:
- case wxSYS_COLOUR_WINDOWTEXT:
- case wxSYS_COLOUR_CAPTIONTEXT:
- case wxSYS_COLOUR_INFOTEXT:
- case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
- return *wxBLACK;
- break ;
- case wxSYS_COLOUR_HIGHLIGHT:
- {
- RGBColor hilite ;
- LMGetHiliteRGB(&hilite) ;
- return wxColor( hilite.red >> 8 , hilite.green >> 8 , hilite.blue >> 8 ) ;
- }
- break ;
- case wxSYS_COLOUR_BTNHIGHLIGHT:
- case wxSYS_COLOUR_GRAYTEXT:
- return wxColor( 0xCC , 0xCC , 0xCC ) ;
- break ;
-
- case wxSYS_COLOUR_3DDKSHADOW:
- return wxColor( 0x44 , 0x44 , 0x44 ) ;
- break ;
- case wxSYS_COLOUR_3DLIGHT:
- return wxColor( 0xCC , 0xCC , 0xCC ) ;
- break ;
- case wxSYS_COLOUR_HIGHLIGHTTEXT :
- {
- RGBColor hilite ;
- LMGetHiliteRGB(&hilite) ;
- if ( ( hilite.red + hilite.green + hilite.blue ) == 0 )
- return *wxWHITE ;
- else
- return *wxBLACK ;
- }
- break ;
- case wxSYS_COLOUR_INFOBK :
- case wxSYS_COLOUR_APPWORKSPACE:
- return *wxWHITE ;
- break ;
-
- case wxSYS_COLOUR_HOTLIGHT:
- case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
- case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
- case wxSYS_COLOUR_MENUHILIGHT:
- // TODO
- return *wxBLACK;
-
- case wxSYS_COLOUR_MAX:
- wxFAIL_MSG( _T("unknown system colour index") );
- break ;
- }
- return *wxWHITE;
-}
-
-// ----------------------------------------------------------------------------
-// fonts
-// ----------------------------------------------------------------------------
-
-wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
-{
- switch (index)
- {
- case wxSYS_ANSI_VAR_FONT :
- case wxSYS_SYSTEM_FONT :
- case wxSYS_DEVICE_DEFAULT_FONT :
- case wxSYS_DEFAULT_GUI_FONT :
- {
- return *wxSMALL_FONT ;
- } ;
- break ;
- case wxSYS_OEM_FIXED_FONT :
- case wxSYS_ANSI_FIXED_FONT :
- case wxSYS_SYSTEM_FIXED_FONT :
- default :
- {
- return *wxNORMAL_FONT ;
- } ;
- break ;
- }
- return *wxNORMAL_FONT;
-}
-
-// ----------------------------------------------------------------------------
-// system metrics/features
-// ----------------------------------------------------------------------------
-
-// Get a system metric, e.g. scrollbar size
-int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
-{
- int value;
-
- switch ( index)
- {
- case wxSYS_MOUSE_BUTTONS:
- // we emulate a two button mouse (ctrl + click = right button )
- return 2;
-
- // TODO case wxSYS_BORDER_X:
- // TODO case wxSYS_BORDER_Y:
- // TODO case wxSYS_CURSOR_X:
- // TODO case wxSYS_CURSOR_Y:
- // TODO case wxSYS_DCLICK_X:
- // TODO case wxSYS_DCLICK_Y:
- // TODO case wxSYS_DRAG_X:
- // TODO case wxSYS_DRAG_Y:
- // TODO case wxSYS_EDGE_X:
- // TODO case wxSYS_EDGE_Y:
-
- case wxSYS_HSCROLL_ARROW_X:
- return 16;
- case wxSYS_HSCROLL_ARROW_Y:
- return 16;
- case wxSYS_HTHUMB_X:
- return 16;
-
- // TODO case wxSYS_ICON_X:
- // TODO case wxSYS_ICON_Y:
- // TODO case wxSYS_ICONSPACING_X:
- // TODO case wxSYS_ICONSPACING_Y:
- // TODO case wxSYS_WINDOWMIN_X:
- // TODO case wxSYS_WINDOWMIN_Y:
-
- case wxSYS_SCREEN_X:
- wxDisplaySize(&value, NULL);
- return value;
- case wxSYS_SCREEN_Y:
- wxDisplaySize(NULL, &value);
- return value;
-
- // TODO case wxSYS_FRAMESIZE_X:
- // TODO case wxSYS_FRAMESIZE_Y:
- // TODO case wxSYS_SMALLICON_X:
- // TODO case wxSYS_SMALLICON_Y:
-
- case wxSYS_HSCROLL_Y:
- return 16;
- case wxSYS_VSCROLL_X:
- return 16;
- case wxSYS_VSCROLL_ARROW_X:
- return 16;
- case wxSYS_VSCROLL_ARROW_Y:
- return 16;
- case wxSYS_VTHUMB_Y:
- return 16;
-
- // TODO case wxSYS_CAPTION_Y:
- // TODO case wxSYS_MENU_Y:
- // TODO case wxSYS_NETWORK_PRESENT:
-
- case wxSYS_PENWINDOWS_PRESENT:
- return 0;
-
- // TODO case wxSYS_SHOW_SOUNDS:
-
- case wxSYS_SWAP_BUTTONS:
- return 0;
-
- default:
- return -1; // unsupported metric
- }
- return 0;
-}
-
-bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
-{
- switch (index)
- {
- case wxSYS_CAN_ICONIZE_FRAME:
- case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
- return true;
-
- default:
- return false;
- }
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/slider.cpp
-// Purpose: wxSlider
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_SLIDER
-
-#include "wx/slider.h"
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxSlider, wxControl)
-
-BEGIN_EVENT_TABLE(wxSlider, wxControl)
-END_EVENT_TABLE()
-
- // The dimensions of the different styles of sliders (From Aqua document)
-#define wxSLIDER_DIMENSIONACROSS 15
-#define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24
-#define wxSLIDER_DIMENSIONACROSS_ARROW 18
-
-// Distance between slider and text
-#define wxSLIDER_BORDERTEXT 5
-
-/* NB! The default orientation for a slider is horizontal however if the user specifies
- * some slider styles but dosen't specify the orientation we have to assume he wants a
- * horizontal one. Therefore in this file when testing for the sliders orientation
- * vertical is tested for if this is not set then we use the horizontal one
- * eg. if(GetWindowStyle() & wxSL_VERTICAL) {} else { horizontal case }>
- */
-
- // Slider
- wxSlider::wxSlider()
-{
- m_pageSize = 1;
- m_lineSize = 1;
- m_rangeMax = 0;
- m_rangeMin = 0;
- m_tickFreq = 0;
-}
-
-extern ControlActionUPP wxMacLiveScrollbarActionUPP ;
-
-bool wxSlider::Create(wxWindow *parent, wxWindowID id,
- int value, int minValue, int maxValue,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
- SInt16 procID;
-
- m_macMinimumStatic = NULL ;
- m_macMaximumStatic = NULL ;
- m_macValueStatic = NULL ;
-
-
- m_lineSize = 1;
- m_tickFreq = 0;
-
- m_rangeMax = maxValue;
- m_rangeMin = minValue;
-
- m_pageSize = (int)((maxValue-minValue)/10);
-
- MacPreControlCreate( parent, id, wxEmptyString, pos, size, style,
- validator, name, &bounds, title );
-
- procID = kControlSliderProc + kControlSliderLiveFeedback;
- if(style & wxSL_AUTOTICKS) {
- procID += kControlSliderHasTickMarks;
- }
-
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, title, false,
- value, minValue, maxValue, procID, (long) this);
-
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-
- ::SetControlAction( (ControlHandle) m_macControl , wxMacLiveScrollbarActionUPP ) ;
-
- if(style & wxSL_LABELS)
- {
- m_macMinimumStatic = new wxStaticText( this, wxID_ANY, wxEmptyString );
- m_macMaximumStatic = new wxStaticText( this, wxID_ANY, wxEmptyString );
- m_macValueStatic = new wxStaticText( this, wxID_ANY, wxEmptyString );
- SetRange(minValue, maxValue);
- SetValue(value);
- }
-
- else {
- m_macMinimumStatic = NULL ;
- m_macMaximumStatic = NULL ;
- m_macValueStatic = NULL ;
- }
-
- if(style & wxSL_VERTICAL) {
- SetSizeHints(10, -1, 10, -1); // Forces SetSize to use the proper width
- }
- else {
- SetSizeHints(-1, 10, -1, 10); // Forces SetSize to use the proper height
- }
- // NB! SetSizeHints is overloaded by wxSlider and will substitute 10 with the
- // proper dimensions, it also means other people cannot bugger the slider with
- // other values
-
- MacPostControlCreate() ;
-
- return true;
-}
-
-wxSlider::~wxSlider()
-{
-}
-
-int wxSlider::GetValue() const
-{
- return GetControl32BitValue( (ControlHandle) m_macControl) ;
-}
-
-void wxSlider::SetValue(int value)
-{
- wxString valuestring ;
- valuestring.Printf( wxT("%d") , value ) ;
- if ( m_macValueStatic )
- m_macValueStatic->SetLabel( valuestring ) ;
- SetControl32BitValue( (ControlHandle) m_macControl , value ) ;
-}
-
-void wxSlider::SetRange(int minValue, int maxValue)
-{
- wxString value;
-
- m_rangeMin = minValue;
- m_rangeMax = maxValue;
-
- SetControl32BitMinimum( (ControlHandle) m_macControl, m_rangeMin);
- SetControl32BitMaximum( (ControlHandle) m_macControl, m_rangeMax);
-
- if(m_macMinimumStatic) {
- value.Printf(wxT("%d"), m_rangeMin);
- m_macMinimumStatic->SetLabel(value);
- }
- if(m_macMaximumStatic) {
- value.Printf(wxT("%d"), m_rangeMax);
- m_macMaximumStatic->SetLabel(value);
- }
- SetValue(m_rangeMin);
-}
-
-// For trackbars only
-void wxSlider::SetTickFreq(int n, int pos)
-{
- // TODO
- m_tickFreq = n;
-}
-
-void wxSlider::SetPageSize(int pageSize)
-{
- // TODO
- m_pageSize = pageSize;
-}
-
-int wxSlider::GetPageSize() const
-{
- return m_pageSize;
-}
-
-void wxSlider::ClearSel()
-{
- // TODO
-}
-
-void wxSlider::ClearTicks()
-{
- // TODO
-}
-
-void wxSlider::SetLineSize(int lineSize)
-{
- m_lineSize = lineSize;
- // TODO
-}
-
-int wxSlider::GetLineSize() const
-{
- // TODO
- return 0;
-}
-
-int wxSlider::GetSelEnd() const
-{
- // TODO
- return 0;
-}
-
-int wxSlider::GetSelStart() const
-{
- // TODO
- return 0;
-}
-
-void wxSlider::SetSelection(int minPos, int maxPos)
-{
- // TODO
-}
-
-void wxSlider::SetThumbLength(int len)
-{
- // TODO
-}
-
-int wxSlider::GetThumbLength() const
-{
- // TODO
- return 0;
-}
-
-void wxSlider::SetTick(int tickPos)
-{
- // TODO
-}
-
-void wxSlider::Command (wxCommandEvent & event)
-{
- SetValue (event.GetInt());
- ProcessCommand (event);
-}
-
-void wxSlider::MacHandleControlClick( WXWidget control , wxInt16 controlpart, bool mouseStillDown )
-{
- SInt16 value = ::GetControl32BitValue( (ControlHandle) m_macControl ) ;
-
- SetValue( value ) ;
-
- wxEventType scrollEvent = wxEVT_NULL ;
-
- if ( mouseStillDown )
- scrollEvent = wxEVT_SCROLL_THUMBTRACK;
- else
- scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
-
- wxScrollEvent event(scrollEvent, m_windowId);
- event.SetPosition(value);
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
-
- wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, m_windowId );
- cevent.SetInt( value );
- cevent.SetEventObject( this );
-
- GetEventHandler()->ProcessEvent( cevent );
-}
-
-/* This is overloaded in wxSlider so that the proper width/height will always be used
-* for the slider different values would cause redrawing and mouse detection problems */
-void wxSlider::DoSetSizeHints( int minW, int minH,
- int maxW , int maxH ,
- int incW , int incH )
-{
- wxSize size = GetBestSize();
-
- if(GetWindowStyle() & wxSL_VERTICAL) {
- wxWindow::DoSetSizeHints(size.x, minH, size.x, maxH, incW, incH);
- }
- else {
- wxWindow::DoSetSizeHints(minW, size.y, maxW, size.y, incW, incH);
- }
-}
-
-wxSize wxSlider::DoGetBestSize() const
-{
- wxSize size;
- int textwidth, textheight;
-
- if(GetWindowStyle() & wxSL_LABELS)
- {
- wxString text;
- int ht, wd;
-
- // Get maximum text label width and height
- text.Printf(wxT("%d"), m_rangeMin);
- GetTextExtent(text, &textwidth, &textheight);
- text.Printf(wxT("%d"), m_rangeMax);
- GetTextExtent(text, &wd, &ht);
- if(ht > textheight) {
- textheight = ht;
- }
- if (wd > textwidth) {
- textwidth = wd;
- }
- }
-
- if(GetWindowStyle() & wxSL_VERTICAL)
- {
- if(GetWindowStyle() & wxSL_AUTOTICKS) {
- size.x = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
- }
- else {
- size.x = wxSLIDER_DIMENSIONACROSS_ARROW;
- }
- if(GetWindowStyle() & wxSL_LABELS) {
- size.x += textwidth + wxSLIDER_BORDERTEXT;
- }
- size.y = 150;
- }
- else
- {
- if(GetWindowStyle() & wxSL_AUTOTICKS) {
- size.y = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
- }
- else {
- size.y = wxSLIDER_DIMENSIONACROSS_ARROW;
- }
- if(GetWindowStyle() & wxSL_LABELS) {
- size.y += textheight + wxSLIDER_BORDERTEXT;
- }
- size.x = 150;
- }
- return size;
-}
-
-void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags)
-{
- wxControl::DoSetSize( x, y , width , height ,sizeFlags ) ;
-}
-
-void wxSlider::MacUpdateDimensions()
-{
- // actually in the current systems this should never be possible, but later reparenting
- // may become a reality
-
- if ( (ControlHandle) m_macControl == NULL )
- return ;
-
- if ( GetParent() == NULL )
- return ;
-
- WindowRef rootwindow = (WindowRef) MacGetRootWindow() ;
- if ( rootwindow == NULL )
- return ;
-
- int xborder, yborder;
- int minValWidth, maxValWidth, textwidth, textheight;
- int sliderBreadth;
-
- xborder = yborder = 0;
-
- if (GetWindowStyle() & wxSL_LABELS)
- {
- wxString text;
- int ht;
-
- // Get maximum text label width and height
- text.Printf(wxT("%d"), m_rangeMin);
- GetTextExtent(text, &minValWidth, &textheight);
- text.Printf(wxT("%d"), m_rangeMax);
- GetTextExtent(text, &maxValWidth, &ht);
- if(ht > textheight) {
- textheight = ht;
- }
- textwidth = (minValWidth > maxValWidth ? minValWidth : maxValWidth);
-
- xborder = textwidth + wxSLIDER_BORDERTEXT;
- yborder = textheight + wxSLIDER_BORDERTEXT;
-
- // Get slider breadth
- if(GetWindowStyle() & wxSL_AUTOTICKS) {
- sliderBreadth = wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS;
- }
- else {
- sliderBreadth = wxSLIDER_DIMENSIONACROSS_ARROW;
- }
-
- if(GetWindowStyle() & wxSL_VERTICAL)
- {
- m_macMinimumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT,
- m_height - yborder - textheight);
- m_macMaximumStatic->Move(sliderBreadth + wxSLIDER_BORDERTEXT, 0);
- m_macValueStatic->Move(0, m_height - textheight);
- }
- else
- {
- m_macMinimumStatic->Move(0, sliderBreadth + wxSLIDER_BORDERTEXT);
- m_macMaximumStatic->Move(m_width - xborder - maxValWidth / 2,
- sliderBreadth + wxSLIDER_BORDERTEXT);
- m_macValueStatic->Move(m_width - textwidth, 0);
- }
- }
-
- Rect oldBounds ;
- GetControlBounds( (ControlHandle) m_macControl , &oldBounds ) ;
-
- int new_x = m_x + MacGetLeftBorderSize() + m_macHorizontalBorder ;
- int new_y = m_y + MacGetTopBorderSize() + m_macVerticalBorder ;
- int new_width = m_width - MacGetLeftBorderSize() - MacGetRightBorderSize() - 2 * m_macHorizontalBorder - xborder ;
- int new_height = m_height - MacGetTopBorderSize() - MacGetBottomBorderSize() - 2 * m_macVerticalBorder - yborder ;
-
- GetParent()->MacWindowToRootWindow( & new_x , & new_y ) ;
- bool doMove = new_x != oldBounds.left || new_y != oldBounds.top ;
- bool doResize = ( oldBounds.right - oldBounds.left ) != new_width || (oldBounds.bottom - oldBounds.top ) != new_height ;
- if ( doMove || doResize )
- {
- InvalWindowRect( rootwindow, &oldBounds ) ;
- if ( doMove )
- {
- UMAMoveControl( (ControlHandle) m_macControl , new_x , new_y ) ;
- }
- if ( doResize )
- {
- UMASizeControl( (ControlHandle) m_macControl , new_width , new_height ) ;
- }
- }
-}
-
-void wxSlider::DoMoveWindow(int x, int y, int width, int height)
-{
- wxControl::DoMoveWindow(x,y,width,height) ;
-}
-
-#endif // wxUSE_SLIDER
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/sound.cpp
-// Purpose: wxSound class implementation: optional
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#if wxUSE_SOUND
-
-#include "wx/sound.h"
-
-#ifndef WX_PRECOMP
- #include "wx/object.h"
- #include "wx/string.h"
-#endif
-
-#ifdef __WXMAC__
-#include "wx/mac/private.h"
-#ifndef __DARWIN__
-#include <Sound.h>
-#endif
-#endif
-
-wxSound::wxSound()
- : m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(true)
-{
-}
-
-wxSound::wxSound(const wxString& sFileName, bool isResource)
- : m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(true)
-{
- Create(sFileName, isResource);
-}
-
-
-wxSound::~wxSound()
-{
- FreeData();
-}
-
-wxSound::wxSound(int size, const wxByte* data)
- : m_sndChan(0), m_hSnd(NULL), m_waveLength(0), m_isResource(false)
-{
- //TODO convert data
-}
-
-bool wxSound::Create(const wxString& fileName, bool isResource)
-{
- bool ret = false;
- m_sndname = fileName;
- m_isResource = isResource;
-
- if (m_isResource)
- ret = true;
- else
- { /*
- if (sndChan)
- { // we're playing
- FSClose(SndRefNum);
- SndRefNum = 0;
- SndDisposeChannel(sndChan, TRUE);
- free(sndChan);
- sndChan = 0;
- KillTimer(0,timerID);
- }
-
- if (!lpSnd)
- return true;
-
- if (_access(lpSnd,0)) // no file, no service
- return false;
-
- // Allocate SndChannel
- sndChan = (SndChannelPtr) malloc (sizeof(SndChannel));
-
- if (!sndChan)
- return false;
-
- sndChan->qLength = 128;
-
- if (noErr != SndNewChannel (&sndChan, sampledSynth, initMono | initNoInterp, 0))
- {
- free(sndChan);
- sndChan = 0;
- return false;
- }
-
- if (!(SndRefNum = MacOpenSndFile ((char *)lpSnd)))
- {
- SndDisposeChannel(sndChan, TRUE);
- free(sndChan);
- sndChan = 0;
-
- return false;
- }
-
- bool async = false;
-
- if (fdwSound & SND_ASYNC)
- async = true;
-
- if (SndStartFilePlay(sndChan, SndRefNum, 0, 81920, 0, 0, 0, async) != noErr)
- {
- FSClose (SndRefNum);
- SndRefNum = 0;
- SndDisposeChannel (sndChan, TRUE);
- free (sndChan);
- sndChan = 0;
- return false;
- }
-
- if (async)
- { // haven't finish yet
- timerID = SetTimer(0, 0, 250, TimerCallBack);
- }
- else
- {
- FSClose (SndRefNum);
- SndRefNum = 0;
- SndDisposeChannel (sndChan, TRUE);
- free (sndChan);
- sndChan = 0;
- }*/
- }
-
- return ret;
-}
-
-
-//don't know what to do with looped, wth
-bool wxSound::DoPlay(unsigned flags) const
-{
- bool ret = false;
-
- if (m_isResource)
- {
- Str255 snd ;
- wxMacStringToPascal( m_sndname , snd ) ;
- SndListHandle hSnd;
-
- hSnd = (SndListHandle) GetNamedResource('snd ', snd);
-
- if ((hSnd != NULL) && (SndPlay((SndChannelPtr)m_sndChan, (SndListHandle) hSnd, (flags & wxSOUND_ASYNC)) == noErr))
- ret = true;
- }
-
- return ret;
-}
-
-
-bool wxSound::FreeData()
-{
- bool ret = false;
-
- if (m_isResource)
- {
- m_sndname.Empty();
- ret = true;
- }
- else
- {
- //TODO,
- }
-
- return ret;
-}
-
-
-//code below is from an old implementation used for telinfo with MSVC crossplatform support
-//technology proceeds, so it would be the wisest to drop this code, but it's left here just
-//for the sake of a reference. BTW: Wave files can now be played with QT, starting from V3
-
-/*static short MacOpenSndFile (char * path)
-{
- VolumeParam vp;
- FSSpec fspec;
- Str255 name;
- char *c;
-
- // first, get the volume reference number for the file. Start by
- // making a Pstring with just the volume name
- strcpy ((char *) name, path);
- if (c = strchr ((char *) name, ':'))
- {
- c++;
- *c = '\0';
- }
-
- c2pstr ((char *) name);
- vp.ioCompletion = 0;
- vp.ioVolIndex = -1;
- vp.ioNamePtr = name;
- vp.ioVRefNum = 0;
-
- if (PBGetVInfo((ParamBlockRec *)&vp, 0) != noErr)
- return 0;
-
- // next, buld an FSSpec for the file
- strcpy ((char *) name, path);
- c2pstr ((char *) name);
- if (FSMakeFSSpec (vp.ioVRefNum, 0, name, &fspec) != noErr)
- return 0;
-
- short frefnum;
- // now open the file, and return it's reference number
- if (FSpOpenDF(&fspec, fsRdPerm, &frefnum) != noErr)
- return 0;
-
- return frefnum;
-}
-
-
-void TimerCallBack(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
-{
- if(!sndChan)
- {
- KillTimer(0,timerID);
- return;
- }
-
- SCStatus scstat;
-
- if (noErr == SndChannelStatus (sndChan, sizeof (SCStatus), &scstat)) {
- if (scstat.scChannelPaused || scstat.scChannelBusy)
- return; // not done yet
- }
-
- // either error or done.
- FSClose (SndRefNum);
- SndRefNum = 0;
- SndDisposeChannel (sndChan, TRUE);
- free (sndChan);
- sndChan = 0;
- KillTimer(0,timerID);
-}*/
-
-#endif // wxUSE_SOUND
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/spinbutt.cpp
-// Purpose: wxSpinButton
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_SPINBTN
-
-#include "wx/spinbutt.h"
-#include "wx/mac/uma.h"
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxWin macros
-// ----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
-
-wxSpinButton::wxSpinButton()
- : wxSpinButtonBase()
-{
-}
-
-bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
- long style, const wxString& name)
-{
- if ( !wxSpinButtonBase::Create(parent, id, pos, size,
- style, wxDefaultValidator, name) )
- return false;
-
- m_min = 0;
- m_max = 100;
-
- if (!parent)
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style,*( (wxValidator*) NULL ) , name , &bounds , title ) ;
-
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 100,
- kControlLittleArrowsProc , (long) this ) ;
-
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-
- MacPostControlCreate() ;
-
- return true;
-}
-
-wxSpinButton::~wxSpinButton()
-{
-}
-
-// Attributes
-////////////////////////////////////////////////////////////////////////////
-
-int wxSpinButton::GetMin() const
-{
- return m_min;
-}
-
-int wxSpinButton::GetMax() const
-{
- return m_max;
-}
-
-int wxSpinButton::GetValue() const
-{
- int n = m_value;
-
- if (n < m_min) n = m_min;
- if (n > m_max) n = m_max;
-
- return n;
-}
-
-void wxSpinButton::SetValue(int val)
-{
- m_value = val ;
-}
-
-void wxSpinButton::SetRange(int minVal, int maxVal)
-{
- m_min = minVal;
- m_max = maxVal;
- SetControl32BitMaximum( (ControlHandle) m_macControl , maxVal ) ;
- SetControl32BitMinimum((ControlHandle) m_macControl , minVal ) ;
-}
-
-void wxSpinButton::MacHandleValueChanged( int inc )
-{
-
- wxEventType scrollEvent = wxEVT_NULL;
- int oldValue = m_value ;
-
- m_value = oldValue + inc;
-
- if (m_value < m_min)
- {
- if ( m_windowStyle & wxSP_WRAP )
- m_value = m_max;
- else
- m_value = m_min;
- }
-
- if (m_value > m_max)
- {
- if ( m_windowStyle & wxSP_WRAP )
- m_value = m_min;
- else
- m_value = m_max;
- }
-
- if ( m_value - oldValue == -1 )
- scrollEvent = wxEVT_SCROLL_LINEDOWN ;
- else if ( m_value - oldValue == 1 )
- scrollEvent = wxEVT_SCROLL_LINEUP ;
- else
- scrollEvent = wxEVT_SCROLL_THUMBTRACK ;
-
- wxSpinEvent event(scrollEvent, m_windowId);
-
- event.SetPosition(m_value);
- event.SetEventObject( this );
- if ((GetEventHandler()->ProcessEvent( event )) &&
- !event.IsAllowed() )
- {
- m_value = oldValue ;
- }
- SetControl32BitValue( (ControlHandle) m_macControl , m_value ) ;
-
- /* always send a thumbtrack event */
- if (scrollEvent != wxEVT_SCROLL_THUMBTRACK)
- {
- scrollEvent = wxEVT_SCROLL_THUMBTRACK;
- wxSpinEvent event2( scrollEvent, GetId());
- event2.SetPosition( m_value );
- event2.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event2 );
- }
-}
-
-void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
-{
- if ( (ControlHandle) m_macControl == NULL )
- return ;
-
- int nScrollInc = 0;
-
- switch( controlpart )
- {
- case kControlUpButtonPart :
- nScrollInc = 1;
- break ;
- case kControlDownButtonPart :
- nScrollInc = -1;
- break ;
- }
- MacHandleValueChanged( nScrollInc ) ;
-
-}
-
-// ----------------------------------------------------------------------------
-// size calculation
-// ----------------------------------------------------------------------------
-
-wxSize wxSpinButton::DoGetBestSize() const
-{
- return wxSize(16,24);
-}
-
-#endif // wxUSE_SPINBTN
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/spinbutt.cpp
-// Purpose: wxSpinCtrl
-// Author: Robert
-// Modified by: Mark Newsam (Based on GTK file)
-// RCS-ID: $Id$
-// Copyright: (c) Robert Roebling
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_SPINCTRL
-
-#include "wx/spinctrl.h"
-
-#ifndef WX_PRECOMP
- #include "wx/textctrl.h"
-#endif //WX_PRECOMP
-
-#include "wx/spinbutt.h"
-
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-// the margin between the text control and the spin
-static const wxCoord MARGIN = 2;
-
-// ----------------------------------------------------------------------------
-// wxSpinCtrlText: text control used by spin control
-// ----------------------------------------------------------------------------
-
-class wxSpinCtrlText : public wxTextCtrl
-{
-public:
- wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value)
- : wxTextCtrl(spin , -1, value)
- {
- m_spin = spin;
- }
-
-protected:
- void OnTextChange(wxCommandEvent& event)
- {
- int val;
- if ( m_spin->GetTextValue(&val) )
- {
- m_spin->GetSpinButton()->SetValue(val);
- }
-
- event.Skip();
- }
-
- bool ProcessEvent(wxEvent &event)
- {
- // Hand button down events to wxSpinCtrl. Doesn't work.
- if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event ))
- return true;
-
- return wxTextCtrl::ProcessEvent( event );
- }
-
-private:
- wxSpinCtrl *m_spin;
-
- DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(wxSpinCtrlText, wxTextCtrl)
- EVT_TEXT(-1, wxSpinCtrlText::OnTextChange)
-END_EVENT_TABLE()
-
-// ----------------------------------------------------------------------------
-// wxSpinCtrlButton: spin button used by spin control
-// ----------------------------------------------------------------------------
-
-class wxSpinCtrlButton : public wxSpinButton
-{
-public:
- wxSpinCtrlButton(wxSpinCtrl *spin, int style)
- : wxSpinButton(spin )
- {
- m_spin = spin;
-
- SetWindowStyle(style | wxSP_VERTICAL);
- }
-
-protected:
- void OnSpinButton(wxSpinEvent& eventSpin)
- {
-#if defined(__WXMAC__) || defined(__WXMOTIF__)
- m_spin->SetTextValue(eventSpin.GetPosition());
-
- wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, m_spin->GetId());
- event.SetEventObject(m_spin);
- event.SetInt(eventSpin.GetPosition());
-
- m_spin->GetEventHandler()->ProcessEvent(event);
-#else
- m_spin->SetTextValue(eventSpin.GetPosition());
- eventSpin.Skip();
-#endif
- }
-
-private:
- wxSpinCtrl *m_spin;
-
- DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton)
- EVT_SPIN(-1, wxSpinCtrlButton::OnSpinButton)
-END_EVENT_TABLE()
-
-IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxSpinCtrl creation
-// ----------------------------------------------------------------------------
-
-void wxSpinCtrl::Init()
-{
- m_text = NULL;
- m_btn = NULL;
-}
-
-bool wxSpinCtrl::Create(wxWindow *parent,
- wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- int min,
- int max,
- int initial,
- const wxString& name)
-{
- if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style,
- wxDefaultValidator, name) )
- {
- return false;
- }
-
- // the string value overrides the numeric one (for backwards compatibility
- // reasons and also because it is simpler to satisfy the string value which
- // comes much sooner in the list of arguments and leave the initial
- // parameter unspecified)
- if ( !value.empty() )
- {
- long l;
- if ( value.ToLong(&l) )
- initial = l;
- }
-
- wxSize csize = size ;
- m_text = new wxSpinCtrlText(this, value);
- m_btn = new wxSpinCtrlButton(this, style);
-
- m_btn->SetRange(min, max);
- m_btn->SetValue(initial);
-
- if ( size.y == -1 ) {
- csize.y = m_text->GetSize().y ;
- }
- DoSetSize(pos.x , pos.y , csize.x, csize.y);
-
- return true;
-}
-
-wxSpinCtrl::~wxSpinCtrl()
-{
- // delete the controls now, don't leave them alive even though they would
- // still be eventually deleted by our parent - but it will be too late, the
- // user code expects them to be gone now
- delete m_text;
- m_text = NULL ;
- delete m_btn;
- m_btn = NULL ;
-}
-
-// ----------------------------------------------------------------------------
-// geometry
-// ----------------------------------------------------------------------------
-
-wxSize wxSpinCtrl::DoGetBestSize() const
-{
- wxSize sizeBtn = m_btn->GetBestSize(),
- sizeText = m_text->GetBestSize();
-
- return wxSize(sizeBtn.x + sizeText.x + MARGIN, sizeText.y);
-}
-
-void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
-{
- wxControl::DoMoveWindow(x, y, width, height);
-
- // position the subcontrols inside the client area
- wxSize sizeBtn = m_btn->GetSize();
-
- wxCoord wText = width - sizeBtn.x;
- m_text->SetSize(0, 0, wText, height);
- m_btn->SetSize(0 + wText + MARGIN, 0, -1, -1);
-}
-
-// ----------------------------------------------------------------------------
-// operations forwarded to the subcontrols
-// ----------------------------------------------------------------------------
-
-bool wxSpinCtrl::Enable(bool enable)
-{
- if ( !wxControl::Enable(enable) )
- return false;
- return true;
-}
-
-bool wxSpinCtrl::Show(bool show)
-{
- if ( !wxControl::Show(show) )
- return false;
- return true;
-}
-
-// ----------------------------------------------------------------------------
-// value and range access
-// ----------------------------------------------------------------------------
-
-bool wxSpinCtrl::GetTextValue(int *val) const
-{
- long l;
- if ( !m_text->GetValue().ToLong(&l) )
- {
- // not a number at all
- return false;
- }
-
- if ( l < GetMin() || l > GetMax() )
- {
- // out of range
- return false;
- }
-
- *val = l;
-
- return true;
-}
-
-int wxSpinCtrl::GetValue() const
-{
- return m_btn ? m_btn->GetValue() : 0;
-}
-
-int wxSpinCtrl::GetMin() const
-{
- return m_btn ? m_btn->GetMin() : 0;
-}
-
-int wxSpinCtrl::GetMax() const
-{
- return m_btn ? m_btn->GetMax() : 0;
-}
-
-// ----------------------------------------------------------------------------
-// changing value and range
-// ----------------------------------------------------------------------------
-
-void wxSpinCtrl::SetTextValue(int val)
-{
- wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetTextValue") );
-
- m_text->SetValue(wxString::Format(_T("%d"), val));
-
- // select all text
- m_text->SetSelection(0, -1);
-
- // and give focus to the control!
- // m_text->SetFocus(); Why???? TODO.
-}
-
-void wxSpinCtrl::SetValue(int val)
-{
- wxCHECK_RET( m_btn, _T("invalid call to wxSpinCtrl::SetValue") );
-
- SetTextValue(val);
-
- m_btn->SetValue(val);
-}
-
-void wxSpinCtrl::SetValue(const wxString& text)
-{
- wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetValue") );
-
- long val;
- if ( text.ToLong(&val) && ((val > INT_MIN) && (val < INT_MAX)) )
- {
- SetValue((int)val);
- }
- else // not a number at all or out of range
- {
- m_text->SetValue(text);
- m_text->SetSelection(0, -1);
- }
-}
-
-void wxSpinCtrl::SetRange(int min, int max)
-{
- wxCHECK_RET( m_btn, _T("invalid call to wxSpinCtrl::SetRange") );
-
- m_btn->SetRange(min, max);
-}
-
-void wxSpinCtrl::SetSelection(long from, long to)
-{
- // if from and to are both -1, it means (in wxWidgets) that all text should
- // be selected
- if ( (from == -1) && (to == -1) )
- {
- from = 0;
- }
- m_text->SetSelection(from, to);
-}
-
-#endif // wxUSE_SPINCTRL
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/statbmp.cpp
-// Purpose: wxStaticBitmap
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/statbmp.h"
-
-#ifndef WX_PRECOMP
- #include "wx/dcclient.h"
-#endif
-
-IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
-
-/*
- * wxStaticBitmap
- */
-
-BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
- EVT_PAINT(wxStaticBitmap::OnPaint)
-END_EVENT_TABLE()
-
-bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
- const wxBitmap& bitmap,
- const wxPoint& pos,
- const wxSize& s,
- long style,
- const wxString& name)
-{
- SetName(name);
- wxSize size = s ;
- if ( bitmap.Ok() )
- {
- if ( size.x == -1 )
- size.x = bitmap.GetWidth() ;
- if ( size.y == -1 )
- size.y = bitmap.GetHeight() ;
- }
-
- m_backgroundColour = parent->GetBackgroundColour() ;
- m_foregroundColour = parent->GetForegroundColour() ;
-
- m_bitmap = bitmap;
- if ( id == wxID_ANY )
- m_windowId = (int)NewControlId();
- else
- m_windowId = id;
-
- m_windowStyle = style;
-
- bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
- SetInitialSize( size ) ;
-
- return ret;
-}
-
-void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
-{
- m_bitmap = bitmap;
- InvalidateBestSize();
- SetSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight()));
- Refresh() ;
-}
-
-void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
-{
- wxPaintDC dc(this);
- PrepareDC(dc);
-
- dc.DrawBitmap( m_bitmap , 0 , 0 , true ) ;
-}
-
-wxSize wxStaticBitmap::DoGetBestSize() const
-{
- return wxWindow::DoGetBestSize() ;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/statbox.cpp
-// Purpose: wxStaticBox
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/statbox.h"
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
-
-BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
- EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
-END_EVENT_TABLE()
-
-/*
- * Static box
- */
-
-bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- if ( !wxControl::Create(parent, id, pos, size,
- style, wxDefaultValidator, name) )
- return false;
-
- Rect bounds ;
- Str255 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,
- kControlGroupBoxTextTitleProc , (long) this ) ;
-
- MacPostControlCreate() ;
-
- return true;
-}
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/statbar.cpp
-// Purpose: native implementation of wxStatusBar (optional)
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) 1998 Stefan Csomor
-// Licence: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#include "wx/statusbr.h"
-
-#ifndef WX_PRECOMP
- #include "wx/dc.h"
- #include "wx/dcclient.h"
-#endif
-
-BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
- EVT_PAINT(wxStatusBarMac::OnPaint)
-END_EVENT_TABLE()
-
-#ifdef __WXMAC__
- #include "wx/mac/private.h"
-#endif
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxStatusBarMac class
-// ----------------------------------------------------------------------------
-
-wxStatusBarMac::wxStatusBarMac()
-{
- SetParent(NULL);
-}
-
-wxStatusBarMac::~wxStatusBarMac()
-{
-}
-
-bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
- long style ,
- const wxString& name)
-{
- return wxStatusBarGeneric::Create( parent , id , style , name ) ;
-}
-
-void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
-{
- int leftMargin = 2;
-
- wxRect rect;
- GetFieldRect(i, rect);
-
- if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
- {
- dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
- }
-
- wxString text(GetStatusText(i));
-
- long x, y;
-
- dc.GetTextExtent(text, &x, &y);
-
- int xpos = rect.x + leftMargin + 1 ;
- int ypos = 1 ;
-
- dc.SetClippingRegion(rect.x, 0, rect.width, m_height);
-
- dc.DrawText(text, xpos, ypos);
-
- dc.DestroyClippingRegion();
-}
-
-void wxStatusBarMac::DrawField(wxDC& dc, int i)
-{
- DrawFieldText(dc, i);
-}
-
-void wxStatusBarMac::SetStatusText(const wxString& text, int number)
-{
- wxCHECK_RET( (number >= 0) && (number < m_nFields),
- _T("invalid status bar field index") );
-
- m_statusStrings[number] = text;
- wxRect rect;
- GetFieldRect(number, rect);
- rect.y=0;
- rect.height = m_height ;
- Refresh( true , &rect ) ;
- Update();
-}
-
-void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
-{
- wxPaintDC dc(this);
- dc.Clear() ;
-
- int major,minor;
- wxGetOsVersion( &major, &minor );
-
- if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
- {
- wxPen white( wxWHITE , 1 , wxSOLID ) ;
- if (major >= 10)
- {
- //Finder statusbar border color: (Project builder similar is 9B9B9B)
- dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
- }
- else
- {
- wxPen black( wxBLACK , 1 , wxSOLID ) ;
- dc.SetPen(black);
- }
- dc.DrawLine(0, 0 ,
- m_width , 0);
- dc.SetPen(white);
- dc.DrawLine(0, 1 ,
- m_width , 1);
- }
- else
- {
- if (major >= 10)
- //Finder statusbar border color: (Project builder similar is 9B9B9B)
- dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
- else
- dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
-
- dc.DrawLine(0, 0 ,
- m_width , 0);
- }
-
- int i;
- if ( GetFont().Ok() )
- dc.SetFont(GetFont());
- dc.SetBackgroundMode(wxTRANSPARENT);
-
- for ( i = 0; i < m_nFields; i ++ )
- DrawField(dc, i);
-}
-
-void wxStatusBarMac::MacSuperEnabled( bool enabled )
-{
- Refresh(false) ;
- wxWindow::MacSuperEnabled( enabled ) ;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/statline.cpp
-// Purpose: wxStaticLine class
-// Author: Vadim Zeitlin
-// Created: 28.06.99
-// Version: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/statline.h"
-
-#ifndef WX_PRECOMP
- #include "wx/statbox.h"
-#endif
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl)
-
-// ----------------------------------------------------------------------------
-// wxStaticLine
-// ----------------------------------------------------------------------------
-
-bool wxStaticLine::Create( wxWindow *parent,
- wxWindowID id,
- const wxPoint &pos,
- const wxSize &size,
- long style,
- const wxString &name)
-{
- if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
- return false;
-
- // ok, this is ugly but it's better than nothing: use a thin static box to
- // emulate static line
-
- wxSize sizeReal = AdjustSize(size);
-
-// m_statbox = new wxStaticBox(parent, id, wxT(""), pos, sizeReal, style, name);
-
- return true;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/statlmac.cpp
-// Purpose: a generic wxStaticLine class
-// Author: Vadim Zeitlin
-// Created: 28.06.99
-// Version: $Id$
-// Copyright: (c) 1998 Vadim Zeitlin
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/statline.h"
-
-#ifndef WX_PRECOMP
- #include "wx/statbox.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl)
-
-// ----------------------------------------------------------------------------
-// wxStaticLine
-// ----------------------------------------------------------------------------
-
-bool wxStaticLine::Create( wxWindow *parent,
- wxWindowID id,
- const wxPoint &pos,
- const wxSize &size,
- long style,
- const wxString &name)
-{
- if ( !wxStaticLineBase::Create(parent, id, pos, size,
- style, wxDefaultValidator, name) )
- return false;
-
- Rect bounds ;
- Str255 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,
- kControlSeparatorLineProc , (long) this ) ;
-
- MacPostControlCreate() ;
-
- return true;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/stattext.cpp
-// Purpose: wxStaticText
-// Author: Stefan Csomor
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/stattext.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/utils.h"
- #include "wx/dc.h"
- #include "wx/dcclient.h"
- #include "wx/settings.h"
-#endif
-
-#include "wx/notebook.h"
-#include "wx/tabctrl.h"
-
-#include <stdio.h>
-
-IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
-
-#include "wx/mac/uma.h"
-
-BEGIN_EVENT_TABLE(wxStaticText, wxStaticTextBase)
- EVT_PAINT(wxStaticText::OnPaint)
-END_EVENT_TABLE()
-
-bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- m_label = wxStripMenuCodes(label) ;
-
- if ( !wxControl::Create( parent, id, pos, size, style,
- wxDefaultValidator , name ) )
- {
- return false;
- }
-
- SetInitialSize( size ) ;
-
- return true;
-}
-
-const wxString punct = wxT(" ,.-;:!?");
-
-void wxStaticText::DrawParagraph(wxDC &dc, wxString paragraph, int &y)
-{
- long width, height ;
-
- if (paragraph.length() == 0)
- {
- // empty line
- dc.GetTextExtent( wxT("H"), &width, &height );
- y += height;
-
- return;
- }
-
- int x = 0 ;
-
- bool linedrawn = true;
- while( paragraph.length() > 0 )
- {
- dc.GetTextExtent( paragraph , &width , &height ) ;
-
- if ( width > m_width )
- {
- for ( size_t p = paragraph.length() - 1 ; p > 0 ; --p )
- {
- if ((punct.Find(paragraph[p]) != wxNOT_FOUND) || !linedrawn)
- {
- int blank = (paragraph[p] == ' ') ? 0 : 1;
-
- dc.GetTextExtent( paragraph.Left(p + blank) , &width , &height ) ;
-
- if ( width <= m_width )
- {
- int pos = x ;
- if ( HasFlag( wxALIGN_CENTER ) )
- {
- pos += ( m_width - width ) / 2 ;
- }
- else if ( HasFlag( wxALIGN_RIGHT ) )
- {
- pos += ( m_width - width ) ;
- }
-
- dc.DrawText( paragraph.Left(p + blank), pos , y) ;
- y += height ;
- paragraph = paragraph.Mid(p+1) ;
- linedrawn = true;
- break ;
- }
- }
- }
-
- linedrawn = false;
- }
- else
- {
- int pos = x ;
- if ( HasFlag( wxALIGN_CENTER ) )
- {
- pos += ( m_width - width ) / 2 ;
- }
- else if ( HasFlag( wxALIGN_RIGHT ) )
- {
- pos += ( m_width - width ) ;
- }
-
- dc.DrawText( paragraph, pos , y) ;
- paragraph=wxEmptyString;
- y += height ;
- }
- }
-}
-
-void wxStaticText::OnDraw( wxDC &dc )
-{
- if (m_width <= 0 || m_height <= 0)
- return;
- /*
- dc.Clear() ;
- wxRect rect(0,0,m_width,m_height) ;
- dc.SetFont(*wxSMALL_FONT) ;
-
- dc.DrawRectangle(rect) ;
- */
- if ( !IsWindowHilited( (WindowRef) MacGetRootWindow() ) &&
- ( GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE )
- || GetBackgroundColour() == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) ) )
- {
- dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
- }
- else
- {
- dc.SetTextForeground( GetForegroundColour() ) ;
- }
-
- wxString paragraph;
- size_t i = 0 ;
- wxString text = m_label;
- int y = 0 ;
- while (i < text.length())
- {
-
- if (text[i] == 13 || text[i] == 10)
- {
- DrawParagraph(dc, paragraph,y);
- paragraph = wxEmptyString ;
- }
- else
- {
- paragraph += text[i];
- }
- ++i;
- }
- if (paragraph.length() > 0)
- DrawParagraph(dc, paragraph,y);
-}
-
-void wxStaticText::OnPaint( wxPaintEvent & WXUNUSED(event) )
-{
- wxPaintDC dc(this);
- OnDraw( dc ) ;
-}
-
-wxSize wxStaticText::DoGetBestSize() const
-{
- int widthTextMax = 0, widthLine,
- heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
-
- wxString curLine;
- for ( const wxChar *pc = m_label; ; pc++ )
- {
- if ( *pc == wxT('\n') || *pc == wxT('\r') || *pc == wxT('\0') )
- {
- if ( !curLine )
- {
- // we can't use GetTextExtent - it will return 0 for both width
- // and height and an empty line should count in height
- // calculation
- if ( !heightLineDefault )
- heightLineDefault = heightLine;
- if ( !heightLineDefault )
- GetTextExtent(_T("W"), NULL, &heightLineDefault);
-
- heightTextTotal += heightLineDefault;
-
- heightTextTotal++; // FIXME: why is this necessary?
- }
- else
- {
- GetTextExtent(curLine, &widthLine, &heightLine);
- if ( widthLine > widthTextMax )
- widthTextMax = widthLine;
- heightTextTotal += heightLine;
-
- heightTextTotal++; // FIXME: why is this necessary?
- }
-
- if ( *pc == wxT('\n') || *pc == wxT('\r')) {
- curLine.Empty();
- }
- else {
- // the end of string
- break;
- }
- }
- else {
- curLine += *pc;
- }
- }
-
- return wxSize(widthTextMax, heightTextTotal);
-}
-
-void wxStaticText::SetLabel(const wxString& st )
-{
- wxStaticTextBase::SetLabel( st ) ;
- m_label = st ;
- if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
- {
- // temporary fix until layout measurement and drawing are in synch again
- Refresh() ;
- InvalidateBestSize();
- SetSize( GetBestSize() ) ;
- }
- Refresh() ;
- Update() ;
-}
-
-bool wxStaticText::SetFont(const wxFont& font)
-{
- bool ret = wxControl::SetFont(font);
-
- if ( ret )
- {
- // adjust the size of the window to fit to the label unless autoresizing is
- // disabled
- if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
- {
- // temporary fix until layout measurement and drawing are in synch again
- Refresh() ;
- InvalidateBestSize();
- SetSize( GetBestSize() );
- }
- }
-
- return ret;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/tabctrl.cpp
-// Purpose: wxTabCtrl
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_TAB_DIALOG
-
-#include "wx/tabctrl.h"
-
-#ifndef WX_PRECOMP
- #include "wx/control.h"
-#endif
-
-#include "wx/mac/uma.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
-
-BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
-END_EVENT_TABLE()
-
-wxTabCtrl::wxTabCtrl()
-{
- m_imageList = NULL;
-}
-
-bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
- long style, const wxString& name)
-{
- if ( !wxControl::Create(parent, id, pos, size,
- style, wxDefaultValidator, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- m_imageList = NULL;
-
- 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,
- kControlTabSmallProc , (long) this ) ;
-
- MacPostControlCreate() ;
- return true ;
-}
-
-wxTabCtrl::~wxTabCtrl()
-{
-}
-
-void wxTabCtrl::Command(wxCommandEvent& event)
-{
-}
-
-// Delete all items
-bool wxTabCtrl::DeleteAllItems()
-{
- // TODO
- return false;
-}
-
-// Delete an item
-bool wxTabCtrl::DeleteItem(int item)
-{
- // TODO
- return false;
-}
-
-// Get the selection
-int wxTabCtrl::GetSelection() const
-{
- // TODO
- return 0;
-}
-
-// Get the tab with the current keyboard focus
-int wxTabCtrl::GetCurFocus() const
-{
- // TODO
- return 0;
-}
-
-// Get the associated image list
-wxImageList* wxTabCtrl::GetImageList() const
-{
- return m_imageList;
-}
-
-// Get the number of items
-int wxTabCtrl::GetItemCount() const
-{
- // TODO
- return 0;
-}
-
-// Get the rect corresponding to the tab
-bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const
-{
- // TODO
- return false;
-}
-
-// Get the number of rows
-int wxTabCtrl::GetRowCount() const
-{
- // TODO
- return 0;
-}
-
-// Get the item text
-wxString wxTabCtrl::GetItemText(int item) const
-{
- // TODO
- return wxEmptyString;
-}
-
-// Get the item image
-int wxTabCtrl::GetItemImage(int item) const
-{
- // TODO
- return 0;
-}
-
-// Get the item data
-void* wxTabCtrl::GetItemData(int item) const
-{
- // TODO
- return NULL;
-}
-
-// Hit test
-int wxTabCtrl::HitTest(const wxPoint& pt, long& flags)
-{
- // TODO
- return 0;
-}
-
-// Insert an item
-bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data)
-{
- // TODO
- return false;
-}
-
-// Set the selection
-int wxTabCtrl::SetSelection(int item)
-{
- // TODO
- return 0;
-}
-
-// Set the image list
-void wxTabCtrl::SetImageList(wxImageList* imageList)
-{
- // TODO
-}
-
-// Set the text for an item
-bool wxTabCtrl::SetItemText(int item, const wxString& text)
-{
- // TODO
- return false;
-}
-
-// Set the image for an item
-bool wxTabCtrl::SetItemImage(int item, int image)
-{
- // TODO
- return false;
-}
-
-// Set the data for an item
-bool wxTabCtrl::SetItemData(int item, void* data)
-{
- // TODO
- return false;
-}
-
-// Set the size for a fixed-width tab control
-void wxTabCtrl::SetItemSize(const wxSize& size)
-{
- // TODO
-}
-
-// Set the padding between tabs
-void wxTabCtrl::SetPadding(const wxSize& padding)
-{
- // TODO
-}
-
-// Tab event
-IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
-
-wxTabEvent::wxTabEvent(wxEventType commandType, int id):
- wxCommandEvent(commandType, id)
-{
-}
-
-#endif // wxUSE_TAB_DIALOG
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/textctrl.cpp
-// Purpose: wxTextCtrl
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_TEXTCTRL
-
-#include "wx/textctrl.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/utils.h"
- #include "wx/dc.h"
- #include "wx/button.h"
- #include "wx/settings.h"
- #include "wx/msgdlg.h"
- #include "wx/toplevel.h"
-#endif
-
-#ifdef __DARWIN__
- #include <sys/types.h>
- #include <sys/stat.h>
-#else
- #include <stat.h>
-#endif
-
-#if wxUSE_STD_IOSTREAM
- #if wxUSE_IOSTREAMH
- #include <fstream.h>
- #else
- #include <fstream>
- #endif
-#endif
-
-#include "wx/notebook.h"
-#include "wx/tabctrl.h"
-#include "wx/filefn.h"
-
-#if defined(__BORLANDC__) && !defined(__WIN32__)
- #include <alloc.h>
-#elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__DARWIN__)
- #include <malloc.h>
-#endif
-
-#ifndef __DARWIN__
-#include <Scrap.h>
-#endif
-#include <MacTextEditor.h>
-#include <ATSUnicode.h>
-#include <TextCommon.h>
-#include <TextEncodingConverter.h>
-#include "wx/mac/uma.h"
-
-#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
-
-extern wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ;
-
-// CS:TODO we still have a problem getting properly at the text events of a control because under Carbon
-// the MLTE engine registers itself for the key events thus the normal flow never occurs, the only measure for the
-// moment is to avoid setting the true focus on the control, the proper solution at the end would be to have
-// an alternate path for carbon key events that routes automatically into the same wx flow of events
-
-/* part codes */
-
-/* kmUPTextPart is the part code we return to indicate the user has clicked
- in the text area of our control */
-#define kmUPTextPart 1
-
-/* kmUPScrollPart is the part code we return to indicate the user has clicked
- in the scroll bar part of the control. */
-#define kmUPScrollPart 2
-
-
-/* routines for using existing user pane controls.
- These routines are useful for cases where you would like to use an
- existing user pane control in, say, a dialog window as a scrolling
- text edit field.*/
-
-/* mUPOpenControl initializes a user pane control so it will be drawn
- and will behave as a scrolling text edit field inside of a window.
- This routine performs all of the initialization steps necessary,
- except it does not create the user pane control itself. theControl
- should refer to a user pane control that you have either created
- yourself or extracted from a dialog's control heirarchy using
- the GetDialogItemAsControl routine. */
-OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle);
-
-/* Utility Routines */
-
-enum {
- kShiftKeyCode = 56
-};
-
-/* kUserClickedToFocusPart is a part code we pass to the SetKeyboardFocus
- routine. In our focus switching routine this part code is understood
- as meaning 'the user has clicked in the control and we need to switch
- the current focus to ourselves before we can continue'. */
-#define kUserClickedToFocusPart 100
-
-
-/* kmUPClickScrollDelayTicks is a time measurement in ticks used to
- slow the speed of 'auto scrolling' inside of our clickloop routine.
- This value prevents the text from wizzzzzing by while the mouse
- is being held down inside of the text area. */
-#define kmUPClickScrollDelayTicks 3
-
-
-/* STPTextPaneVars is a structure used for storing the the mUP Control's
- internal variables and state information. A handle to this record is
- stored in the pane control's reference value field using the
- SetControlReference routine. */
-
-typedef struct {
- /* OS records referenced */
- TXNObject fTXNRec; /* the txn record */
- TXNFrameID fTXNFrame; /* the txn frame ID */
- ControlHandle fUserPaneRec; /* handle to the user pane control */
- WindowPtr fOwner; /* window containing control */
- GrafPtr fDrawingEnvironment; /* grafport where control is drawn */
- /* flags */
- Boolean fInFocus; /* true while the focus rect is drawn around the control */
- Boolean fIsActive; /* true while the control is drawn in the active state */
- Boolean fTEActive; /* reflects the activation state of the text edit record */
- Boolean fInDialogWindow; /* true if displayed in a dialog window */
- /* calculated locations */
- Rect fRTextArea; /* area where the text is drawn */
- Rect fRFocusOutline; /* rectangle used to draw the focus box */
- Rect fRTextOutline; /* rectangle used to draw the border */
- RgnHandle fTextBackgroundRgn; /* background region for the text, erased before calling TEUpdate */
- /* our focus advance override routine */
- EventHandlerUPP handlerUPP;
- EventHandlerRef handlerRef;
- bool fMultiline ;
-} STPTextPaneVars;
-
-
-
-
-/* Univerals Procedure Pointer variables used by the
- mUP Control. These variables are set up
- the first time that mUPOpenControl is called. */
-ControlUserPaneDrawUPP gTPDrawProc = NULL;
-ControlUserPaneHitTestUPP gTPHitProc = NULL;
-ControlUserPaneTrackingUPP gTPTrackProc = NULL;
-ControlUserPaneIdleUPP gTPIdleProc = NULL;
-ControlUserPaneKeyDownUPP gTPKeyProc = NULL;
-ControlUserPaneActivateUPP gTPActivateProc = NULL;
-ControlUserPaneFocusUPP gTPFocusProc = NULL;
-
-/* TPActivatePaneText activates or deactivates the text edit record
- according to the value of setActive. The primary purpose of this
- routine is to ensure each call is only made once. */
-static void TPActivatePaneText(STPTextPaneVars **tpvars, Boolean setActive) {
- STPTextPaneVars *varsp;
- varsp = *tpvars;
- if (varsp->fTEActive != setActive) {
-
- varsp->fTEActive = setActive;
-
- TXNActivate(varsp->fTXNRec, varsp->fTXNFrame, varsp->fTEActive);
-
- if (varsp->fInFocus)
- TXNFocus( varsp->fTXNRec, varsp->fTEActive);
- }
-}
-
-
-/* TPFocusPaneText set the focus state for the text record. */
-static void TPFocusPaneText(STPTextPaneVars **tpvars, Boolean setFocus) {
- STPTextPaneVars *varsp;
- varsp = *tpvars;
- if (varsp->fInFocus != setFocus) {
- varsp->fInFocus = setFocus;
- TXNFocus( varsp->fTXNRec, varsp->fInFocus);
- }
-}
-
-
-/* TPPaneDrawProc is called to redraw the control and for update events
- referring to the control. This routine erases the text area's background,
- and redraws the text. This routine assumes the scroll bar has been
- redrawn by a call to DrawControls. */
-static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart) {
- STPTextPaneVars **tpvars, *varsp;
- char state;
- Rect bounds;
- /* set up our globals */
-
- tpvars = (STPTextPaneVars **) GetControlReference(theControl);
- if (tpvars != NULL) {
- state = HGetState((Handle) tpvars);
- HLock((Handle) tpvars);
- varsp = *tpvars;
-
- /* save the drawing state */
- SetPort((**tpvars).fDrawingEnvironment);
- /* verify our boundary */
- GetControlBounds(theControl, &bounds);
-
- wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
- if ( ! EqualRect(&bounds, &varsp->fRFocusOutline) ) {
- // scrollbar is on the border, we add one
- Rect oldbounds = varsp->fRFocusOutline ;
- InsetRect( &oldbounds , -1 , -1 ) ;
-
- if ( IsControlVisible( theControl ) )
- InvalWindowRect( GetControlOwner( theControl ) , &oldbounds ) ;
- SetRect(&varsp->fRFocusOutline, bounds.left, bounds.top, bounds.right, bounds.bottom);
- SetRect(&varsp->fRTextOutline, bounds.left, bounds.top, bounds.right, bounds.bottom);
- SetRect(&varsp->fRTextArea, bounds.left + 2 , bounds.top + (varsp->fMultiline ? 0 : 2) ,
- bounds.right - (varsp->fMultiline ? 0 : 2), bounds.bottom - (varsp->fMultiline ? 0 : 2));
- RectRgn(varsp->fTextBackgroundRgn, &varsp->fRTextOutline);
- if ( IsControlVisible( theControl ) )
- TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top, varsp->fRTextArea.left,
- varsp->fRTextArea.bottom, varsp->fRTextArea.right, varsp->fTXNFrame);
- else
- TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top + 30000 , varsp->fRTextArea.left + 30000 ,
- varsp->fRTextArea.bottom + 30000 , varsp->fRTextArea.right + 30000 , varsp->fTXNFrame);
-
- }
-
- if ( IsControlVisible( theControl ) )
- {
- /* update the text region */
- RGBColor white = { 65535 , 65535 , 65535 } ;
- RGBBackColor( &white ) ;
- EraseRgn(varsp->fTextBackgroundRgn);
- TXNDraw(varsp->fTXNRec, NULL);
- /* restore the drawing environment */
- /* draw the text frame and focus frame (if necessary) */
- DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive);
- if ((**tpvars).fIsActive && varsp->fInFocus)
- DrawThemeFocusRect(&varsp->fRFocusOutline, true);
- /* release our globals */
- HSetState((Handle) tpvars, state);
- }
- }
-}
-
-
-/* TPPaneHitTestProc is called when the control manager would
- like to determine what part of the control the mouse resides over.
- We also call this routine from our tracking proc to determine how
- to handle mouse clicks. */
-static pascal ControlPartCode TPPaneHitTestProc(ControlHandle theControl, Point where) {
- STPTextPaneVars **tpvars;
- ControlPartCode result;
- char state;
- /* set up our locals and lock down our globals*/
- result = 0;
- tpvars = (STPTextPaneVars **) GetControlReference(theControl);
- if (tpvars != NULL && IsControlVisible( theControl) ) {
- state = HGetState((Handle) tpvars);
- HLock((Handle) tpvars);
- /* find the region where we clicked */
- if (PtInRect(where, &(**tpvars).fRTextArea)) {
- result = kmUPTextPart;
- } else result = 0;
- /* release oure globals */
- HSetState((Handle) tpvars, state);
- }
- return result;
-}
-
-
-
-
-
-/* TPPaneTrackingProc is called when the mouse is being held down
- over our control. This routine handles clicks in the text area
- and in the scroll bar. */
-static pascal ControlPartCode TPPaneTrackingProc(ControlHandle theControl, Point startPt, ControlActionUPP actionProc) {
- STPTextPaneVars **tpvars, *varsp;
- char state;
- ControlPartCode partCodeResult;
- /* make sure we have some variables... */
- partCodeResult = 0;
- tpvars = (STPTextPaneVars **) GetControlReference(theControl);
- if (tpvars != NULL && IsControlVisible( theControl ) ) {
- /* lock 'em down */
- state = HGetState((Handle) tpvars);
- HLock((Handle) tpvars);
- varsp = *tpvars;
- /* we don't do any of these functions unless we're in focus */
- if ( ! varsp->fInFocus) {
- WindowPtr owner;
- owner = GetControlOwner(theControl);
- ClearKeyboardFocus(owner);
- SetKeyboardFocus(owner, theControl, kUserClickedToFocusPart);
- }
- /* find the location for the click */
- switch (TPPaneHitTestProc(theControl, startPt)) {
-
- /* handle clicks in the text part */
- case kmUPTextPart:
- { SetPort((**tpvars).fDrawingEnvironment);
- wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
-#if !TARGET_CARBON
- TXNClick( varsp->fTXNRec, (const EventRecord*) wxTheApp->MacGetCurrentEvent());
-#else
- EventRecord rec ;
- ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ;
- TXNClick( varsp->fTXNRec, &rec );
-#endif
- }
- break;
-
- }
-
- HSetState((Handle) tpvars, state);
- }
- return partCodeResult;
-}
-
-
-/* TPPaneIdleProc is our user pane idle routine. When our text field
- is active and in focus, we use this routine to set the cursor. */
-static pascal void TPPaneIdleProc(ControlHandle theControl) {
- STPTextPaneVars **tpvars, *varsp;
- /* set up locals */
- tpvars = (STPTextPaneVars **) GetControlReference(theControl);
- if (tpvars != NULL && IsControlVisible( theControl ) ) {
- /* if we're not active, then we have nothing to say about the cursor */
- if ((**tpvars).fIsActive) {
- char state;
- Rect bounds;
- Point mousep;
- /* lock down the globals */
- state = HGetState((Handle) tpvars);
- HLock((Handle) tpvars);
- varsp = *tpvars;
- /* get the current mouse coordinates (in our window) */
- SetPortWindowPort(GetControlOwner(theControl));
- wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
- GetMouse(&mousep);
- /* there's a 'focus thing' and an 'unfocused thing' */
- if (varsp->fInFocus) {
- /* flash the cursor */
- SetPort((**tpvars).fDrawingEnvironment);
- TXNIdle(varsp->fTXNRec);
- /* set the cursor */
- if (PtInRect(mousep, &varsp->fRTextArea)) {
- RgnHandle theRgn;
- RectRgn((theRgn = NewRgn()), &varsp->fRTextArea);
- TXNAdjustCursor(varsp->fTXNRec, theRgn);
- DisposeRgn(theRgn);
- }
- else
- {
- // SetThemeCursor(kThemeArrowCursor);
- }
- } else {
- /* if it's in our bounds, set the cursor */
- GetControlBounds(theControl, &bounds);
- if (PtInRect(mousep, &bounds))
- {
- // SetThemeCursor(kThemeArrowCursor);
- }
- }
-
- HSetState((Handle) tpvars, state);
- }
- }
-}
-
-
-/* TPPaneKeyDownProc is called whenever a keydown event is directed
- at our control. Here, we direct the keydown event to the text
- edit record and redraw the scroll bar and text field as appropriate. */
-static pascal ControlPartCode TPPaneKeyDownProc(ControlHandle theControl,
- SInt16 keyCode, SInt16 charCode, SInt16 modifiers) {
- STPTextPaneVars **tpvars;
- tpvars = (STPTextPaneVars **) GetControlReference(theControl);
- if (tpvars != NULL) {
- if ((**tpvars).fInFocus) {
- /* turn autoscrolling on and send the key event to text edit */
- SetPort((**tpvars).fDrawingEnvironment);
- wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
- EventRecord ev ;
- memset( &ev , 0 , sizeof( ev ) ) ;
- ev.what = keyDown ;
- ev.modifiers = modifiers ;
- ev.message = (( keyCode << 8 ) & keyCodeMask ) + ( charCode & charCodeMask ) ;
- TXNKeyDown( (**tpvars).fTXNRec, &ev);
- }
- }
- return kControlEntireControl;
-}
-
-
-/* TPPaneActivateProc is called when the window containing
- the user pane control receives activate events. Here, we redraw
- the control and it's text as necessary for the activation state. */
-static pascal void TPPaneActivateProc(ControlHandle theControl, Boolean activating) {
- Rect bounds;
- STPTextPaneVars **tpvars, *varsp;
- char state;
- /* set up locals */
- tpvars = (STPTextPaneVars **) GetControlReference(theControl);
- if (tpvars != NULL) {
- state = HGetState((Handle) tpvars);
- HLock((Handle) tpvars);
- varsp = *tpvars;
- /* de/activate the text edit record */
- SetPort((**tpvars).fDrawingEnvironment);
- wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
- GetControlBounds(theControl, &bounds);
- varsp->fIsActive = activating;
- TPActivatePaneText(tpvars, varsp->fIsActive && varsp->fInFocus);
- /* redraw the frame */
- if ( IsControlVisible( theControl ) )
- {
- DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive);
- if (varsp->fInFocus)
- DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fIsActive);
- }
- HSetState((Handle) tpvars, state);
- }
-}
-
-
-/* TPPaneFocusProc is called when every the focus changes to or
- from our control. Herein, switch the focus appropriately
- according to the parameters and redraw the control as
- necessary. */
-static pascal ControlPartCode TPPaneFocusProc(ControlHandle theControl, ControlFocusPart action) {
- ControlPartCode focusResult;
- STPTextPaneVars **tpvars, *varsp;
- char state;
- /* set up locals */
- focusResult = kControlFocusNoPart;
- tpvars = (STPTextPaneVars **) GetControlReference(theControl);
- if (tpvars != NULL ) {
- state = HGetState((Handle) tpvars);
- HLock((Handle) tpvars);
- varsp = *tpvars;
- /* if kControlFocusPrevPart and kControlFocusNextPart are received when the user is
- tabbing forwards (or shift tabbing backwards) through the items in the dialog,
- and kControlFocusNextPart will be received. When the user clicks in our field
- and it is not the current focus, then the constant kUserClickedToFocusPart will
- be received. The constant kControlFocusNoPart will be received when our control
- is the current focus and the user clicks in another control. In your focus routine,
- you should respond to these codes as follows:
-
- kControlFocusNoPart - turn off focus and return kControlFocusNoPart. redraw
- the control and the focus rectangle as necessary.
-
- kControlFocusPrevPart or kControlFocusNextPart - toggle focus on or off
- depending on its current state. redraw the control and the focus rectangle
- as appropriate for the new focus state. If the focus state is 'off', return the constant
- kControlFocusNoPart, otherwise return a non-zero part code.
- kUserClickedToFocusPart - is a constant defined for this example. You should
- define your own value for handling click-to-focus type events. */
- /* calculate the next highlight state */
- switch (action) {
- default:
- case kControlFocusNoPart:
- TPFocusPaneText(tpvars, false);
- focusResult = kControlFocusNoPart;
- break;
- case kUserClickedToFocusPart:
- TPFocusPaneText(tpvars, true);
- focusResult = 1;
- break;
- case kControlFocusPrevPart:
- case kControlFocusNextPart:
- TPFocusPaneText(tpvars, ( ! varsp->fInFocus));
- focusResult = varsp->fInFocus ? 1 : kControlFocusNoPart;
- break;
- }
- TPActivatePaneText(tpvars, varsp->fIsActive && varsp->fInFocus);
- /* redraw the text fram and focus rectangle to indicate the
- new focus state */
- if ( IsControlVisible( theControl ) )
- {
- /* save the drawing state */
- SetPort((**tpvars).fDrawingEnvironment);
- wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
- DrawThemeEditTextFrame(&varsp->fRTextOutline, varsp->fIsActive ? kThemeStateActive: kThemeStateInactive);
- DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fIsActive && varsp->fInFocus);
- }
- /* done */
- HSetState((Handle) tpvars, state);
- }
- return focusResult;
-}
-
-
-/* mUPOpenControl initializes a user pane control so it will be drawn
- and will behave as a scrolling text edit field inside of a window.
- This routine performs all of the initialization steps necessary,
- except it does not create the user pane control itself. theControl
- should refer to a user pane control that you have either created
- yourself or extracted from a dialog's control heirarchy using
- the GetDialogItemAsControl routine. */
-OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle )
-{
- Rect bounds;
- WindowRef theWindow;
- STPTextPaneVars **tpvars, *varsp;
- OSStatus err = noErr ;
- RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
- TXNBackground tback;
-
- /* set up our globals */
- if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
- if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
- if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
- if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
- if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
- if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
- if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
-
- /* allocate our private storage */
- tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
- SetControlReference(theControl, (long) tpvars);
- HLock((Handle) tpvars);
- varsp = *tpvars;
- /* set the initial settings for our private data */
- varsp->fMultiline = wxStyle & wxTE_MULTILINE ;
- varsp->fInFocus = false;
- varsp->fIsActive = true;
- varsp->fTEActive = true; // in order to get a deactivate
- varsp->fUserPaneRec = theControl;
- theWindow = varsp->fOwner = GetControlOwner(theControl);
-
- varsp->fDrawingEnvironment = (GrafPtr) GetWindowPort(theWindow);
-
- varsp->fInDialogWindow = ( GetWindowKind(varsp->fOwner) == kDialogWindowKind );
- /* set up the user pane procedures */
- SetControlData(theControl, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(gTPDrawProc), &gTPDrawProc);
- SetControlData(theControl, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(gTPHitProc), &gTPHitProc);
- SetControlData(theControl, kControlEntireControl, kControlUserPaneTrackingProcTag, sizeof(gTPTrackProc), &gTPTrackProc);
- SetControlData(theControl, kControlEntireControl, kControlUserPaneIdleProcTag, sizeof(gTPIdleProc), &gTPIdleProc);
- SetControlData(theControl, kControlEntireControl, kControlUserPaneKeyDownProcTag, sizeof(gTPKeyProc), &gTPKeyProc);
- SetControlData(theControl, kControlEntireControl, kControlUserPaneActivateProcTag, sizeof(gTPActivateProc), &gTPActivateProc);
- SetControlData(theControl, kControlEntireControl, kControlUserPaneFocusProcTag, sizeof(gTPFocusProc), &gTPFocusProc);
- /* calculate the rectangles used by the control */
- GetControlBounds(theControl, &bounds);
- SetRect(&varsp->fRFocusOutline, bounds.left, bounds.top, bounds.right, bounds.bottom);
- SetRect(&varsp->fRTextOutline, bounds.left, bounds.top, bounds.right, bounds.bottom);
- SetRect(&varsp->fRTextArea, bounds.left + 2 , bounds.top + (varsp->fMultiline ? 0 : 2) ,
- bounds.right - (varsp->fMultiline ? 0 : 2), bounds.bottom - (varsp->fMultiline ? 0 : 2));
- /* calculate the background region for the text. In this case, it's kindof
- and irregular region because we're setting the scroll bar a little ways inside
- of the text area. */
- RectRgn((varsp->fTextBackgroundRgn = NewRgn()), &varsp->fRTextOutline);
-
- /* set up the drawing environment */
- SetPort(varsp->fDrawingEnvironment);
-
- /* create the new edit field */
-
- TXNFrameOptions frameOptions =
- kTXNDontDrawCaretWhenInactiveMask ;
- if ( ! ( wxStyle & wxTE_NOHIDESEL ) )
- frameOptions |= kTXNDontDrawSelectionWhenInactiveMask ;
-
- if ( wxStyle & wxTE_MULTILINE )
- {
- if ( ! ( wxStyle & wxTE_DONTWRAP ) )
- frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
- else
- {
- frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
- frameOptions |= kTXNWantHScrollBarMask ;
- }
-
- if ( !(wxStyle & wxTE_NO_VSCROLL ) )
- frameOptions |= kTXNWantVScrollBarMask ;
- }
- else
- frameOptions |= kTXNSingleLineOnlyMask ;
-
- if ( wxStyle & wxTE_READONLY )
- frameOptions |= kTXNReadOnlyMask ;
-
- TXNNewObject(NULL, varsp->fOwner, &varsp->fRTextArea,
- frameOptions ,
- kTXNTextEditStyleFrameType,
- kTXNTextensionFile,
- kTXNSystemDefaultEncoding,
- &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars);
-
- if ( !IsControlVisible( theControl ) )
- TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top + 30000 , varsp->fRTextArea.left + 30000 ,
- varsp->fRTextArea.bottom + 30000 , varsp->fRTextArea.right + 30000 , varsp->fTXNFrame);
-
-
- if ( (wxStyle & wxTE_MULTILINE) && (wxStyle & wxTE_DONTWRAP) )
- {
- TXNControlTag tag = kTXNWordWrapStateTag ;
- TXNControlData dat ;
- dat.uValue = kTXNNoAutoWrap ;
- TXNSetTXNObjectControls( varsp->fTXNRec , false , 1 , &tag , &dat ) ;
- }
- Str255 fontName ;
- SInt16 fontSize ;
- Style fontStyle ;
-
- GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
-
- TXNTypeAttributes typeAttr[] =
- {
- { kTXNQDFontNameAttribute , kTXNQDFontNameAttributeSize , { (void*) fontName } } ,
- { kTXNQDFontSizeAttribute , kTXNFontSizeAttributeSize , { (void*) (fontSize << 16) } } ,
- { kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } ,
- } ;
-
- err = TXNSetTypeAttributes (varsp->fTXNRec, sizeof( typeAttr ) / sizeof(TXNTypeAttributes) , typeAttr,
- kTXNStartOffset,
- kTXNEndOffset);
- /* set the field's background */
-
- tback.bgType = kTXNBackgroundTypeRGB;
- tback.bg.color = rgbWhite;
- TXNSetBackground( varsp->fTXNRec, &tback);
-
- /* unlock our storage */
- HUnlock((Handle) tpvars);
- /* perform final activations and setup for our text field. Here,
- we assume that the window is going to be the 'active' window. */
- TPActivatePaneText(tpvars, varsp->fIsActive && varsp->fInFocus);
- /* all done */
- return err;
-}
-
-
-
-
-IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
-
-BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
- EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
- EVT_CHAR(wxTextCtrl::OnChar)
- EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
- EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
- EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
- EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
- EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
-
- EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
- EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
- EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
- EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
- EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
-END_EVENT_TABLE()
-
-static void SetTXNData( TXNObject txn , const wxString& st , TXNOffset start , TXNOffset end )
-{
-#if wxUSE_UNICODE
-#if SIZEOF_WCHAR_T == 2
- size_t len = st.length() ;
- TXNSetData( txn , kTXNUnicodeTextData, (void*)st.wc_str(), len * 2,
- start, end);
-#else
- wxMBConvUTF16BE converter ;
- ByteCount byteBufferLen = converter.WC2MB( NULL , st.wc_str() , 0 ) ;
- UniChar *unibuf = (UniChar*) malloc(byteBufferLen) ;
- converter.WC2MB( (char*) unibuf , st.wc_str() , byteBufferLen ) ;
- TXNSetData( txn , kTXNUnicodeTextData, (void*)unibuf, byteBufferLen ,
- start, end);
- free( unibuf ) ;
-#endif
-#else
- wxCharBuffer text = st.mb_str(wxConvLocal) ;
- TXNSetData( txn , kTXNTextData, (void*)text.data(), strlen( text ) ,
- start, end);
-#endif
-}
-
-// Text item
-void wxTextCtrl::Init()
-{
- m_macTE = NULL ;
- m_macTXN = NULL ;
- m_macTXNvars = NULL ;
- m_macUsesTXN = false ;
-
- m_editable = true ;
- m_dirty = false;
-
- m_maxLength = TE_UNLIMITED_LENGTH ;
-}
-
-wxTextCtrl::~wxTextCtrl()
-{
- if ( m_macUsesTXN )
- {
- SetControlReference((ControlHandle)m_macControl, 0) ;
- TXNDeleteObject((TXNObject)m_macTXN);
- /* delete our private storage */
- DisposeHandle((Handle) m_macTXNvars);
- /* zero the control reference */
- }
-}
-
-const short kVerticalMargin = 2 ;
-const short kHorizontalMargin = 2 ;
-
-bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
- const wxString& str,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- m_macTE = NULL ;
- m_macTXN = NULL ;
- m_macTXNvars = NULL ;
- m_macUsesTXN = false ;
- m_editable = true ;
-
- m_macUsesTXN = ! (style & wxTE_PASSWORD ) ;
-
- m_macUsesTXN &= (TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress) ;
-
- // base initialization
- if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) )
- return false;
-
- wxSize mySize = size ;
- if ( m_macUsesTXN )
- {
- m_macHorizontalBorder = 5 ; // additional pixels around the real control
- m_macVerticalBorder = 3 ;
- }
- else
- {
- m_macHorizontalBorder = 5 ; // additional pixels around the real control
- m_macVerticalBorder = 5 ;
- }
-
-
- Rect bounds ;
- Str255 title ;
- /*
- if ( mySize.y == -1 )
- {
- mySize.y = 13 ;
- if ( m_windowStyle & wxTE_MULTILINE )
- mySize.y *= 5 ;
-
- mySize.y += 2 * m_macVerticalBorder ;
- }
- */
- MacPreControlCreate( parent , id , wxEmptyString , pos , mySize ,style, validator , name , &bounds , title ) ;
-
- if ( m_windowStyle & wxTE_MULTILINE )
- {
- wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER),
- wxT("wxTE_PROCESS_ENTER style is ignored for multiline text controls (they always process it)") );
-
- m_windowStyle |= wxTE_PROCESS_ENTER;
- }
-
- if ( m_windowStyle & wxTE_READONLY)
- {
- m_editable = false ;
- }
-
- wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
- if ( !m_macUsesTXN )
- {
- m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , false , 0 , 0 , 1,
- (style & wxTE_PASSWORD) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ;
- long size ;
- ::GetControlData((ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*)((TEHandle *)&m_macTE) , &size ) ;
-
- }
- else
- {
- short featurSet;
-
- featurSet = kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle
- | kControlWantsActivate | kControlHandlesTracking | kControlHasSpecialBackground
- | kControlGetsFocusOnClick | kControlSupportsLiveFeedback;
- /* create the control */
- m_macControl = (WXWidget) ::NewControl(MAC_WXHWND(parent->MacGetRootWindow()), &bounds, "\p", false , featurSet, 0, featurSet, kControlUserPaneProc, 0);
- /* set up the mUP specific features and data */
- mUPOpenControl((ControlHandle) m_macControl, m_windowStyle );
- }
- MacPostControlCreate() ;
-
- if ( !m_macUsesTXN )
- {
- wxCharBuffer text = st.mb_str(wxConvLocal) ;
- ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ;
- }
- else
- {
- STPTextPaneVars **tpvars;
- /* set up locals */
- tpvars = (STPTextPaneVars **) GetControlReference((ControlHandle) m_macControl);
- /* set the text in the record */
- m_macTXN = (**tpvars).fTXNRec ;
- SetTXNData( (TXNObject) m_macTXN , st , kTXNStartOffset, kTXNEndOffset ) ;
- m_macTXNvars = tpvars ;
- m_macUsesTXN = true ;
- TXNSetSelection( (TXNObject) m_macTXN, 0, 0);
- TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
- }
-
- return true;
-}
-
-wxString wxTextCtrl::GetValue() const
-{
- Size actualSize = 0;
- wxString result ;
- OSStatus err ;
- if ( !m_macUsesTXN )
- {
- err = ::GetControlDataSize((ControlHandle) m_macControl, 0,
- ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag, &actualSize ) ;
-
- if ( err )
- return wxEmptyString ;
-
- if ( actualSize > 0 )
- {
- wxCharBuffer buf(actualSize) ;
- ::GetControlData( (ControlHandle) m_macControl, 0,
- ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag,
- actualSize , buf.data() , &actualSize ) ;
- result = wxString( buf , wxConvLocal) ;
- }
- }
- else
- {
-#if wxUSE_UNICODE
- Handle theText ;
- err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNUnicodeTextData );
- // all done
- if ( err )
- {
- actualSize = 0 ;
- }
- else
- {
- actualSize = GetHandleSize( theText ) / sizeof( UniChar) ;
- if ( actualSize > 0 )
- {
- wxChar *ptr = result.GetWriteBuf(actualSize*sizeof(wxChar)) ;
-#if SIZEOF_WCHAR_T == 2
- wxStrncpy( ptr , (wxChar*) *theText , actualSize ) ;
-#else
- wxMBConvUTF16BE converter ;
- HLock( theText ) ;
- converter.MB2WC( ptr , (const char*)*theText , actualSize ) ;
- HUnlock( theText ) ;
-#endif
- ptr[actualSize] = 0 ;
- result.UngetWriteBuf( actualSize *sizeof(wxChar) ) ;
- }
- DisposeHandle( theText ) ;
- }
-#else
- Handle theText ;
- err = TXNGetDataEncoded( ((TXNObject) m_macTXN), kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
- // all done
- if ( err )
- {
- actualSize = 0 ;
- }
- else
- {
- actualSize = GetHandleSize( theText ) ;
- if ( actualSize > 0 )
- {
- HLock( theText ) ;
- result = wxString( *theText , wxConvLocal , actualSize ) ;
- HUnlock( theText ) ;
- }
- DisposeHandle( theText ) ;
- }
-#endif
- }
- wxMacConvertNewlines10To13( &result ) ;
- return result ;
-}
-
-void wxTextCtrl::GetSelection(long* from, long* to) const
-{
- if ( !m_macUsesTXN )
- {
- *from = (**((TEHandle) m_macTE)).selStart;
- *to = (**((TEHandle) m_macTE)).selEnd;
- }
- else
- {
- TXNGetSelection( (TXNObject) m_macTXN , (TXNOffset*) from , (TXNOffset*) to ) ;
- }
-}
-
-void wxTextCtrl::SetValue(const wxString& str)
-{
- wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
- if ( !m_macUsesTXN )
- {
- wxCharBuffer text = st.mb_str(wxConvLocal) ;
- ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , strlen(text) , text ) ;
- }
- else
- {
- bool formerEditable = m_editable ;
- if ( !formerEditable )
- SetEditable(true) ;
- SetTXNData( (TXNObject) m_macTXN , st , kTXNStartOffset, kTXNEndOffset ) ;
- TXNSetSelection( (TXNObject) m_macTXN, 0, 0);
- TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
- if ( !formerEditable )
- SetEditable(formerEditable) ;
- }
- MacRedrawControl() ;
-}
-
-void wxTextCtrl::SetMaxLength(unsigned long len)
-{
- m_maxLength = len ;
-}
-
-bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
-{
- if ( m_macUsesTXN )
- {
- bool formerEditable = m_editable ;
- if ( !formerEditable )
- SetEditable(true) ;
- TXNTypeAttributes typeAttr[4] ;
- Str255 fontName = "\pMonaco" ;
- SInt16 fontSize = 12 ;
- Style fontStyle = normal ;
- RGBColor color ;
- int attrCounter = 0 ;
- if ( style.HasFont() )
- {
- const wxFont &font = style.GetFont() ;
- wxMacStringToPascal( font.GetFaceName() , fontName ) ;
- fontSize = font.GetPointSize() ;
- if ( font.GetUnderlined() )
- fontStyle |= underline ;
- if ( font.GetWeight() == wxBOLD )
- fontStyle |= bold ;
- if ( font.GetStyle() == wxITALIC )
- fontStyle |= italic ;
-
- typeAttr[attrCounter].tag = kTXNQDFontNameAttribute ;
- typeAttr[attrCounter].size = kTXNQDFontNameAttributeSize ;
- typeAttr[attrCounter].data.dataPtr = (void*) fontName ;
- typeAttr[attrCounter+1].tag = kTXNQDFontSizeAttribute ;
- typeAttr[attrCounter+1].size = kTXNFontSizeAttributeSize ;
- typeAttr[attrCounter+1].data.dataValue = (fontSize << 16) ;
- typeAttr[attrCounter+2].tag = kTXNQDFontStyleAttribute ;
- typeAttr[attrCounter+2].size = kTXNQDFontStyleAttributeSize ;
- typeAttr[attrCounter+2].data.dataValue = fontStyle ;
- attrCounter += 3 ;
-
- }
- if ( style.HasTextColour() )
- {
- typeAttr[attrCounter].tag = kTXNQDFontColorAttribute ;
- typeAttr[attrCounter].size = kTXNQDFontColorAttributeSize ;
- typeAttr[attrCounter].data.dataPtr = (void*) &color ;
- color = MAC_WXCOLORREF(style.GetTextColour().GetPixel()) ;
- attrCounter += 1 ;
- }
-
- if ( attrCounter > 0 )
- {
-#ifdef __WXDEBUG__
- OSStatus status =
-#endif // __WXDEBUG__
- TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr, start,end);
- wxASSERT_MSG( status == noErr , wxT("Couldn't set text attributes") ) ;
- }
- if ( !formerEditable )
- SetEditable(formerEditable) ;
- }
- return true ;
-}
-
-bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style)
-{
- wxTextCtrlBase::SetDefaultStyle( style ) ;
- SetStyle( kTXNUseCurrentSelection , kTXNUseCurrentSelection , GetDefaultStyle() ) ;
- return true ;
-}
-
-// Clipboard operations
-void wxTextCtrl::Copy()
-{
- if (CanCopy())
- {
- if ( !m_macUsesTXN )
- {
- TECopy( ((TEHandle) m_macTE) ) ;
- ClearCurrentScrap();
- TEToScrap() ;
- MacRedrawControl() ;
- }
- else
- {
- ClearCurrentScrap();
- TXNCopy((TXNObject)m_macTXN);
- TXNConvertToPublicScrap();
- }
- }
-}
-
-void wxTextCtrl::Cut()
-{
- if (CanCut())
- {
- if ( !m_macUsesTXN )
- {
- TECut( ((TEHandle) m_macTE) ) ;
- ClearCurrentScrap();
- TEToScrap() ;
- MacRedrawControl() ;
- }
- else
- {
- ClearCurrentScrap();
- TXNCut((TXNObject)m_macTXN);
- TXNConvertToPublicScrap();
- }
- wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
- }
-}
-
-void wxTextCtrl::Paste()
-{
- if (CanPaste())
- {
- if ( !m_macUsesTXN )
- {
- TEFromScrap() ;
- TEPaste( (TEHandle) m_macTE ) ;
- MacRedrawControl() ;
- }
- else
- {
- TXNConvertFromPublicScrap();
- TXNPaste((TXNObject)m_macTXN);
- SetStyle( kTXNUseCurrentSelection , kTXNUseCurrentSelection , GetDefaultStyle() ) ;
- }
- wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
- }
-}
-
-bool wxTextCtrl::CanCopy() const
-{
- // Can copy if there's a selection
- long from, to;
- GetSelection(& from, & to);
- return (from != to);
-}
-
-bool wxTextCtrl::CanCut() const
-{
- if ( !IsEditable() )
- {
- return false ;
- }
- // Can cut if there's a selection
- long from, to;
- GetSelection(& from, & to);
- return (from != to);
-}
-
-bool wxTextCtrl::CanPaste() const
-{
- if (!IsEditable())
- return false;
-
-#if TARGET_CARBON
- OSStatus err = noErr;
- ScrapRef scrapRef;
-
- err = GetCurrentScrap( &scrapRef );
- if ( err != noTypeErr && err != memFullErr )
- {
- ScrapFlavorFlags flavorFlags;
- Size byteCount;
-
- if (( err = GetScrapFlavorFlags( scrapRef, 'TEXT', &flavorFlags )) == noErr)
- {
- if (( err = GetScrapFlavorSize( scrapRef, 'TEXT', &byteCount )) == noErr)
- {
- return true ;
- }
- }
- }
- return false;
-
-#else
- long offset ;
- if ( GetScrap( NULL , 'TEXT' , &offset ) > 0 )
- {
- return true ;
- }
-#endif
- return false ;
-}
-
-void wxTextCtrl::SetEditable(bool editable)
-{
- if ( editable != m_editable )
- {
- m_editable = editable ;
- if ( !m_macUsesTXN )
- {
- if ( editable )
- UMAActivateControl( (ControlHandle) m_macControl ) ;
- else
- UMADeactivateControl((ControlHandle) m_macControl ) ;
- }
- else
- {
- TXNControlTag tag[] = { kTXNIOPrivilegesTag } ;
- TXNControlData data[] = { { editable ? kTXNReadWrite : kTXNReadOnly } } ;
- TXNSetTXNObjectControls( (TXNObject) m_macTXN , false , sizeof(tag) / sizeof (TXNControlTag) , tag , data ) ;
- }
- }
-}
-
-void wxTextCtrl::SetInsertionPoint(long pos)
-{
- SetSelection( pos , pos ) ;
-}
-
-void wxTextCtrl::SetInsertionPointEnd()
-{
- wxTextPos pos = GetLastPosition();
- SetInsertionPoint(pos);
-}
-
-long wxTextCtrl::GetInsertionPoint() const
-{
- long begin,end ;
- GetSelection( &begin , &end ) ;
- return begin ;
-}
-
-wxTextPos wxTextCtrl::GetLastPosition() const
-{
- if ( !m_macUsesTXN )
- {
- return (**((TEHandle) m_macTE)).teLength ;
- }
- else
- {
- Handle theText ;
- long actualsize ;
- OSErr err = TXNGetDataEncoded( (TXNObject) m_macTXN, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
- /* all done */
- if ( err )
- {
- actualsize = 0 ;
- }
- else
- {
- actualsize = GetHandleSize( theText ) ;
- DisposeHandle( theText ) ;
- }
- return actualsize ;
- }
-}
-
-void wxTextCtrl::Replace(long from, long to, const wxString& str)
-{
- wxString value = str ;
- wxMacConvertNewlines13To10( &value ) ;
- if ( !m_macUsesTXN )
- {
- ControlEditTextSelectionRec selection ;
-
- selection.selStart = from ;
- selection.selEnd = to ;
- ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
- TESetSelect( from , to , ((TEHandle) m_macTE) ) ;
- TEDelete( ((TEHandle) m_macTE) ) ;
- TEInsert( value , value.length() , ((TEHandle) m_macTE) ) ;
- }
- else
- {
- bool formerEditable = m_editable ;
- if ( !formerEditable )
- SetEditable(true) ;
- TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
- TXNClear( ((TXNObject) m_macTXN) ) ;
- SetTXNData( (TXNObject) m_macTXN , str , kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ;
- if ( !formerEditable )
- SetEditable( formerEditable ) ;
- }
- Refresh() ;
-}
-
-void wxTextCtrl::Remove(long from, long to)
-{
- if ( !m_macUsesTXN )
- {
- ControlEditTextSelectionRec selection ;
-
- selection.selStart = from ;
- selection.selEnd = to ;
- ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
- TEDelete( ((TEHandle) m_macTE) ) ;
- }
- else
- {
- bool formerEditable = m_editable ;
- if ( !formerEditable )
- SetEditable(true) ;
- TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
- TXNClear( ((TXNObject) m_macTXN) ) ;
- if ( !formerEditable )
- SetEditable( formerEditable ) ;
- }
- Refresh() ;
-}
-
-void wxTextCtrl::SetSelection(long from, long to)
-{
- if ( !m_macUsesTXN )
- {
- ControlEditTextSelectionRec selection ;
- if ((from == -1) && (to == -1))
- {
- selection.selStart = 0 ;
- selection.selEnd = 32767 ;
- }
- else
- {
- selection.selStart = from ;
- selection.selEnd = to ;
- }
-
- TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ;
- ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
- }
- else
- {
- STPTextPaneVars **tpvars;
- /* set up our locals */
- tpvars = (STPTextPaneVars **) GetControlReference((ControlHandle) m_macControl);
- /* and our drawing environment as the operation
- may force a redraw in the text area. */
- SetPort((**tpvars).fDrawingEnvironment);
- /* change the selection */
- if ((from == -1) && (to == -1))
- TXNSelectAll((TXNObject) m_macTXN);
- else
- TXNSetSelection( (**tpvars).fTXNRec, from, to);
- TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
- }
-}
-
-void wxTextCtrl::WriteText(const wxString& str)
-{
- wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
- if ( !m_macUsesTXN )
- {
- wxCharBuffer text = st.mb_str(wxConvLocal) ;
- TEInsert( text , strlen(text) , ((TEHandle) m_macTE) ) ;
- }
- else
- {
- bool formerEditable = m_editable ;
- if ( !formerEditable )
- SetEditable(true) ;
- long start , end , dummy ;
- GetSelection( &start , &dummy ) ;
- SetTXNData( (TXNObject) m_macTXN , st , kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ;
- GetSelection( &dummy , &end ) ;
- SetStyle( start , end , GetDefaultStyle() ) ;
- if ( !formerEditable )
- SetEditable( formerEditable ) ;
- }
- MacRedrawControl() ;
-}
-
-void wxTextCtrl::AppendText(const wxString& text)
-{
- SetInsertionPointEnd();
- WriteText(text);
-}
-
-void wxTextCtrl::Clear()
-{
- if ( !m_macUsesTXN )
- {
- ::SetControlData((ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , 0 , (char*) ((const char*)NULL) ) ;
- }
- else
- {
- TXNSetSelection( (TXNObject)m_macTXN , kTXNStartOffset , kTXNEndOffset ) ;
- TXNClear((TXNObject)m_macTXN);
- }
- Refresh() ;
-}
-
-bool wxTextCtrl::IsModified() const
-{
- return m_dirty;
-}
-
-bool wxTextCtrl::IsEditable() const
-{
- return IsEnabled() && m_editable ;
-}
-
-bool wxTextCtrl::AcceptsFocus() const
-{
- // we don't want focus if we can't be edited
- return /*IsEditable() && */ wxControl::AcceptsFocus();
-}
-
-wxSize wxTextCtrl::DoGetBestSize() const
-{
- int wText = 100 ;
-
- int hText;
- if ( m_macUsesTXN )
- {
- hText = 17 ;
- }
- else
- {
- hText = 13 ;
- }
-/*
- int cx, cy;
- wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
-
- int wText = DEFAULT_ITEM_WIDTH;
-
- int hText = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
-
- return wxSize(wText, hText);
-*/
- if ( m_windowStyle & wxTE_MULTILINE )
- {
- hText *= 5 ;
- }
- hText += 2 * m_macVerticalBorder ;
- wText += 2 * m_macHorizontalBorder ;
- //else: for single line control everything is ok
- return wxSize(wText, hText);
-}
-
-// ----------------------------------------------------------------------------
-// Undo/redo
-// ----------------------------------------------------------------------------
-
-void wxTextCtrl::Undo()
-{
- if (CanUndo())
- {
- if ( m_macUsesTXN )
- {
- TXNUndo((TXNObject)m_macTXN);
- }
- }
-}
-
-void wxTextCtrl::Redo()
-{
- if (CanRedo())
- {
- if ( m_macUsesTXN )
- {
- TXNRedo((TXNObject)m_macTXN);
- }
- }
-}
-
-bool wxTextCtrl::CanUndo() const
-{
- if ( !IsEditable() )
- {
- return false ;
- }
- if ( m_macUsesTXN )
- {
- return TXNCanUndo((TXNObject)m_macTXN,NULL);
- }
- return false ;
-}
-
-bool wxTextCtrl::CanRedo() const
-{
- if ( !IsEditable() )
- {
- return false ;
- }
- if ( m_macUsesTXN )
- {
- return TXNCanRedo((TXNObject)m_macTXN,NULL);
- }
- return false ;
-}
-
-// Makes modifie or unmodified
-void wxTextCtrl::MarkDirty()
-{
- m_dirty = true;
-}
-
-void wxTextCtrl::DiscardEdits()
-{
- m_dirty = false;
-}
-
-int wxTextCtrl::GetNumberOfLines() const
-{
- if ( m_macUsesTXN )
- {
- ItemCount lines ;
- TXNGetLineCount((TXNObject)m_macTXN, &lines ) ;
- return lines ;
- }
- else
- {
- wxString content = GetValue() ;
-
- int count = 1;
- for (size_t i = 0; i < content.length() ; i++)
- {
- if (content[i] == '\r') count++;
- }
- return count;
- }
-}
-
-long wxTextCtrl::XYToPosition(long x, long y) const
-{
- // TODO
- return 0;
-}
-
-bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
-{
- return false ;
-}
-
-void wxTextCtrl::ShowPosition(long pos)
-{
-#if TARGET_RT_MAC_MACHO && defined(AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER)
- if ( m_macUsesTXN )
- {
- Point current ;
- Point desired ;
- TXNOffset selstart , selend ;
- TXNGetSelection( (TXNObject) m_macTXN , &selstart , &selend) ;
- TXNOffsetToPoint( (TXNObject) m_macTXN, selstart , ¤t);
- TXNOffsetToPoint( (TXNObject) m_macTXN, pos , &desired);
- //TODO use HIPoints for 10.3 and above
- if ( (UInt32) TXNScroll != (UInt32) kUnresolvedCFragSymbolAddress )
- {
- OSErr theErr = noErr;
- SInt32 dv = desired.v - current.v ;
- SInt32 dh = desired.h - current.h ;
- TXNShowSelection( (TXNObject) m_macTXN , true ) ;
- theErr = TXNScroll( (TXNObject) m_macTXN, kTXNScrollUnitsInPixels , kTXNScrollUnitsInPixels , &dv , &dh );
- wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") );
- }
- }
-#endif
-}
-
-int wxTextCtrl::GetLineLength(long lineNo) const
-{
- // TODO change this if possible to reflect real lines
- wxString content = GetValue() ;
-
- // Find line first
- int count = 0;
- for (size_t i = 0; i < content.length() ; i++)
- {
- if (count == lineNo)
- {
- // Count chars in line then
- count = 0;
- for (size_t j = i; j < content.length(); j++)
- {
- count++;
- if (content[j] == '\n') return count;
- }
-
- return count;
- }
- if (content[i] == '\n') count++;
- }
- return 0;
-}
-
-wxString wxTextCtrl::GetLineText(long lineNo) const
-{
- // TODO change this if possible to reflect real lines
- wxString content = GetValue() ;
-
- // Find line first
- int count = 0;
- for (size_t i = 0; i < content.length() ; i++)
- {
- if (count == lineNo)
- {
- // Add chars in line then
- wxString tmp;
-
- for (size_t j = i; j < content.length(); j++)
- {
- if (content[j] == '\n')
- return tmp;
-
- tmp += content[j];
- }
-
- return tmp;
- }
- if (content[i] == '\n') count++;
- }
- return wxEmptyString ;
-}
-
-/*
- * Text item
- */
-
-void wxTextCtrl::Command(wxCommandEvent & event)
-{
- SetValue (event.GetString());
- ProcessCommand (event);
-}
-
-void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
-{
- // By default, load the first file into the text window.
- if (event.GetNumberOfFiles() > 0)
- {
- LoadFile(event.GetFiles()[0]);
- }
-}
-
-void wxTextCtrl::OnChar(wxKeyEvent& event)
-{
- int key = event.GetKeyCode() ;
- bool eat_key = false ;
-
- if ( key == 'c' && event.MetaDown() )
- {
- if ( CanCopy() )
- Copy() ;
- return ;
- }
-
- if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
- !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
-/* && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END */
- )
- {
- // eat it
- return ;
- }
-
- // assume that any key not processed yet is going to modify the control
- m_dirty = true;
-
- if ( key == 'v' && event.MetaDown() )
- {
- if ( CanPaste() )
- Paste() ;
- return ;
- }
- if ( key == 'x' && event.MetaDown() )
- {
- if ( CanCut() )
- Cut() ;
- return ;
- }
- switch ( key )
- {
- case WXK_RETURN:
- if (m_windowStyle & wxTE_PROCESS_ENTER)
- {
- wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
- event.SetEventObject( this );
- event.SetString( GetValue() );
- if ( GetEventHandler()->ProcessEvent(event) )
- return;
- }
- if ( !(m_windowStyle & wxTE_MULTILINE) )
- {
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
- if ( tlw && tlw->GetDefaultItem() )
- {
- wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
- if ( def && def->IsEnabled() )
- {
- wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
- event.SetEventObject(def);
- def->Command(event);
- return ;
- }
- }
-
- // this will make wxWidgets eat the ENTER key so that
- // we actually prevent line wrapping in a single line
- // text control
- eat_key = true;
- }
-
- break;
-
- case WXK_TAB:
- if ( !(m_windowStyle & wxTE_PROCESS_TAB))
- {
- int flags = 0;
- if (!event.ShiftDown())
- flags |= wxNavigationKeyEvent::IsForward ;
- if (event.ControlDown())
- flags |= wxNavigationKeyEvent::WinChange ;
- Navigate(flags);
- return;
- }
- else
- {
- // This is necessary (don't know why) or the tab will not
- // be inserted.
- WriteText(wxT("\t"));
- }
- break;
- }
-
- if (!eat_key)
- {
- // perform keystroke handling
-#if TARGET_CARBON
- if ( m_macUsesTXN && wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL )
- CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
- else
- {
- EventRecord rec ;
- if ( wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) )
- {
- EventRecord *ev = &rec ;
- short keycode ;
- short keychar ;
- keychar = short(ev->message & charCodeMask);
- keycode = short(ev->message & keyCodeMask) >> 8 ;
-
- ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
- }
- }
-#else
- EventRecord *ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;
- short keycode ;
- short keychar ;
- keychar = short(ev->message & charCodeMask);
- keycode = short(ev->message & keyCodeMask) >> 8 ;
-
- ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
-#endif
- }
- if ( ( key >= 0x20 && key < WXK_START ) ||
- key == WXK_RETURN ||
- key == WXK_DELETE ||
- key == WXK_BACK)
- {
- wxCommandEvent event1(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
- event1.SetEventObject( this );
- wxPostEvent(GetEventHandler(),event1);
- }
-}
-
-void wxTextCtrl::MacSuperShown( bool show )
-{
- bool former = m_macControlIsShown ;
- wxControl::MacSuperShown( show ) ;
- if ( (former != m_macControlIsShown) && m_macUsesTXN )
- {
- if ( m_macControlIsShown )
- TXNSetFrameBounds( (TXNObject) m_macTXN, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.top, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.left,
- (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.bottom,(**(STPTextPaneVars **)m_macTXNvars).fRTextArea.right, (**(STPTextPaneVars **)m_macTXNvars).fTXNFrame);
- else
- TXNSetFrameBounds( (TXNObject) m_macTXN, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.top + 30000, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.left,
- (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.bottom + 30000, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.right, (**(STPTextPaneVars **)m_macTXNvars).fTXNFrame);
- }
-}
-
-bool wxTextCtrl::Show(bool show)
-{
- bool former = m_macControlIsShown ;
-
- bool retval = wxControl::Show( show ) ;
-
- if ( former != m_macControlIsShown && m_macUsesTXN )
- {
- if ( m_macControlIsShown )
- TXNSetFrameBounds( (TXNObject) m_macTXN, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.top, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.left,
- (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.bottom,(**(STPTextPaneVars **)m_macTXNvars).fRTextArea.right, (**(STPTextPaneVars **)m_macTXNvars).fTXNFrame);
- else
- TXNSetFrameBounds( (TXNObject) m_macTXN, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.top + 30000, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.left,
- (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.bottom + 30000, (**(STPTextPaneVars **)m_macTXNvars).fRTextArea.right, (**(STPTextPaneVars **)m_macTXNvars).fTXNFrame);
- }
-
- return retval ;
-}
-
-// ----------------------------------------------------------------------------
-// standard handlers for standard edit menu events
-// ----------------------------------------------------------------------------
-
-void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
-{
- Cut();
-}
-
-void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
-{
- Copy();
-}
-
-void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
-{
- Paste();
-}
-
-void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
-{
- Undo();
-}
-
-void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
-{
- Redo();
-}
-
-void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
-{
- event.Enable( CanCut() );
-}
-
-void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
-{
- event.Enable( CanCopy() );
-}
-
-void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
-{
- event.Enable( CanPaste() );
-}
-
-void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
-{
- event.Enable( CanUndo() );
-}
-
-void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
-{
- event.Enable( CanRedo() );
-}
-
-bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
-{
- if ( m_macUsesTXN )
- return true ;
- else
- return wxWindow::MacSetupCursor( pt ) ;
-}
-
-#endif
- // wxUSE_TEXTCTRL
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/tglbtn.cpp
-// Purpose: Definition of the wxToggleButton class, which implements a
-// toggle button under wxMac.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 08.02.01
-// RCS-ID: $Id$
-// Copyright: (c) 2000 Johnny C. Norris II
-// License: Rocketeer license
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-// ============================================================================
-// declatations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#include "wx/tglbtn.h"
-
-#if wxUSE_TOGGLEBTN
-
-#include "wx/mac/uma.h"
-// Button
-
-static const int kMacOSXHorizontalBorder = 2 ;
-static const int kMacOSXVerticalBorder = 4 ;
-
-// ----------------------------------------------------------------------------
-// macros
-// ----------------------------------------------------------------------------
-
-IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxToggleButton
-// ----------------------------------------------------------------------------
-
-// Single check box item
-bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
- return false;
-
- Rect bounds ;
- Str255 title ;
-
- if ( UMAHasAquaLayout() )
- {
- m_macHorizontalBorder = kMacOSXHorizontalBorder;
- m_macVerticalBorder = kMacOSXVerticalBorder;
- }
-
- MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
-
- m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , kControlBehaviorToggles , 1,
- kControlBevelButtonNormalBevelProc , (long) this ) ;
- wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
-
- MacPostControlCreate() ;
-
- return true;
-}
-
-wxSize wxToggleButton::DoGetBestSize() const
-{
- int wBtn = 70 ;
- int hBtn = 20 ;
-
- int lBtn = m_label.Length() * 8 + 12 ;
- if (lBtn > wBtn)
- wBtn = lBtn;
-
- if ( UMAHasAquaLayout() )
- {
- wBtn += 2 * kMacOSXHorizontalBorder ;
- hBtn += 2 * kMacOSXVerticalBorder ;
- }
- return wxSize ( wBtn , hBtn ) ;
-}
-
-void wxToggleButton::SetValue(bool val)
-{
- ::SetControl32BitValue( (ControlHandle) m_macControl , val ) ;
-}
-
-bool wxToggleButton::GetValue() const
-{
- return GetControl32BitValue( (ControlHandle) m_macControl ) ;
-}
-
-void wxToggleButton::Command(wxCommandEvent & event)
-{
- SetValue((event.GetInt() != 0));
- ProcessCommand(event);
-}
-
-void wxToggleButton::MacHandleControlClick( WXWidget WXUNUSED(control) , wxInt16 controlpart , bool WXUNUSED(mouseStillDown) )
-{
- if ( controlpart != kControlNoPart )
- {
- wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
- event.SetInt(GetValue());
- event.SetEventObject(this);
- ProcessCommand(event);
- }
-}
-
-#endif // wxUSE_TOGGLEBTN
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/thread.cpp
-// Purpose: wxThread Implementation
-// Author: Original from Wolfram Gloger/Guilhem Lavaux/Vadim Zeitlin
-// Modified by: Stefan Csomor
-// Created: 04/22/98
-// RCS-ID: $Id$
-// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998),
-// Vadim Zeitlin (1999) , Stefan Csomor (2000)
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#if defined(__BORLANDC__)
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/wx.h"
- #include "wx/module.h"
-#endif
-
-#if wxUSE_THREADS
-
-#include "wx/thread.h"
-
-#ifdef __WXMAC__
-#include <Threads.h>
-#include "wx/mac/uma.h"
-#include "wx/mac/macnotfy.h"
-#include <Timer.h>
-#endif
-
-#define INFINITE 0xFFFFFFFF
-
-
-// ----------------------------------------------------------------------------
-// constants
-// ----------------------------------------------------------------------------
-
-// the possible states of the thread ("=>" shows all possible transitions from
-// this state)
-enum wxThreadState
-{
- STATE_NEW, // didn't start execution yet (=> RUNNING)
- STATE_RUNNING, // thread is running (=> PAUSED, CANCELED)
- STATE_PAUSED, // thread is temporarily suspended (=> RUNNING)
- STATE_CANCELED, // thread should terminate a.s.a.p. (=> EXITED)
- STATE_EXITED // thread is terminating
-};
-
-// ----------------------------------------------------------------------------
-// this module globals
-// ----------------------------------------------------------------------------
-
-static ThreadID gs_idMainThread = kNoThreadID ;
-static bool gs_waitingForThread = false ;
-size_t g_numberOfThreads = 0;
-
-// ============================================================================
-// MacOS implementation of thread classes
-// ============================================================================
-
-class wxMacStCritical
-{
-public :
- wxMacStCritical()
- {
- if ( UMASystemIsInitialized() )
- {
- OSErr err = ThreadBeginCritical() ;
- wxASSERT( err == noErr ) ;
- }
- }
- ~wxMacStCritical()
- {
- if ( UMASystemIsInitialized() )
- {
- OSErr err = ThreadEndCritical() ;
- wxASSERT( err == noErr ) ;
- }
- }
-};
-
-// ----------------------------------------------------------------------------
-// wxMutex implementation
-// ----------------------------------------------------------------------------
-
-class wxMutexInternal
-{
-public:
- wxMutexInternal(wxMutexType WXUNUSED(mutexType))
- {
- m_owner = kNoThreadID ;
- m_locked = 0;
- }
-
- ~wxMutexInternal()
- {
- if ( m_locked > 0 )
- {
- wxLogDebug(_T("Warning: freeing a locked mutex (%ld locks)."), m_locked);
- }
- }
-
- bool IsOk() const { return true; }
-
- wxMutexError Lock() ;
- wxMutexError TryLock() ;
- wxMutexError Unlock();
-public:
- ThreadID m_owner ;
- wxArrayLong m_waiters ;
- long m_locked ;
-};
-
-wxMutexError wxMutexInternal::Lock()
-{
- wxMacStCritical critical ;
- if ( UMASystemIsInitialized() )
- {
- OSErr err ;
- ThreadID current = kNoThreadID;
- err = ::MacGetCurrentThread(¤t);
- // if we are not the owner, add this thread to the list of waiting threads, stop this thread
- // and invoke the scheduler to continue executing the owner's thread
- while ( m_owner != kNoThreadID && m_owner != current)
- {
- m_waiters.Add(current);
- err = ::SetThreadStateEndCritical(kCurrentThreadID, kStoppedThreadState, m_owner);
- err = ::ThreadBeginCritical();
- wxASSERT( err == noErr ) ;
- }
- m_owner = current;
- }
- m_locked++;
-
- return wxMUTEX_NO_ERROR;
-}
-
-wxMutexError wxMutexInternal::TryLock()
-{
- wxMacStCritical critical ;
- if ( UMASystemIsInitialized() )
- {
- ThreadID current = kNoThreadID;
- ::MacGetCurrentThread(¤t);
- // if we are not the owner, give an error back
- if ( m_owner != kNoThreadID && m_owner != current )
- return wxMUTEX_BUSY;
-
- m_owner = current;
- }
- m_locked++;
-
- return wxMUTEX_NO_ERROR;
-}
-
-wxMutexError wxMutexInternal::Unlock()
-{
- if ( UMASystemIsInitialized() )
- {
- OSErr err;
- err = ::ThreadBeginCritical();
- wxASSERT( err == noErr ) ;
-
- if (m_locked > 0)
- m_locked--;
-
- // this mutex is not owned by anybody anmore
- m_owner = kNoThreadID;
-
- // now pass on to the first waiting thread
- ThreadID firstWaiting = kNoThreadID;
- bool found = false;
- while (!m_waiters.IsEmpty() && !found)
- {
- firstWaiting = m_waiters[0];
- err = ::SetThreadState(firstWaiting, kReadyThreadState, kNoThreadID);
- // in case this was not successful (dead thread), we just loop on and reset the id
- found = (err != threadNotFoundErr);
- if ( !found )
- firstWaiting = kNoThreadID ;
- m_waiters.RemoveAt(0) ;
- }
- // now we have a valid firstWaiting thread, which has been scheduled to run next, just end the
- // critical section and invoke the scheduler
- err = ::SetThreadStateEndCritical(kCurrentThreadID, kReadyThreadState, firstWaiting);
- }
- else
- {
- if (m_locked > 0)
- m_locked--;
- }
- return wxMUTEX_NO_ERROR;
-}
-
-// --------------------------------------------------------------------------
-// wxSemaphore
-// --------------------------------------------------------------------------
-
-// TODO not yet implemented
-
-class wxSemaphoreInternal
-{
-public:
- wxSemaphoreInternal(int initialcount, int maxcount);
- ~wxSemaphoreInternal();
-
- bool IsOk() const { return true ; }
-
- wxSemaError Wait() { return WaitTimeout(INFINITE); }
- wxSemaError TryWait() { return WaitTimeout(0); }
- wxSemaError WaitTimeout(unsigned long milliseconds);
-
- wxSemaError Post();
-
-private:
-};
-
-wxSemaphoreInternal::wxSemaphoreInternal(int initialcount, int maxcount)
-{
- if ( maxcount == 0 )
- {
- // make it practically infinite
- maxcount = INT_MAX;
- }
-}
-
-wxSemaphoreInternal::~wxSemaphoreInternal()
-{
-}
-
-wxSemaError wxSemaphoreInternal::WaitTimeout(unsigned long milliseconds)
-{
- return wxSEMA_MISC_ERROR;
-}
-
-wxSemaError wxSemaphoreInternal::Post()
-{
- return wxSEMA_MISC_ERROR;
-}
-
-// ----------------------------------------------------------------------------
-// wxCondition implementation
-// ----------------------------------------------------------------------------
-
-// TODO this is not yet completed
-
-class wxConditionInternal
-{
-public:
- wxConditionInternal(wxMutex& mutex) : m_mutex(mutex)
- {
- m_excessSignals = 0 ;
- }
- ~wxConditionInternal()
- {
- }
-
- bool IsOk() const { return m_mutex.IsOk() ; }
-
- wxCondError Wait()
- {
- return WaitTimeout(0xFFFFFFFF );
- }
-
- wxCondError WaitTimeout(unsigned long msectimeout)
- {
- wxMacStCritical critical ;
- if ( m_excessSignals > 0 )
- {
- --m_excessSignals ;
- return wxCOND_NO_ERROR ;
- }
- else if ( msectimeout == 0 )
- {
- return wxCOND_MISC_ERROR ;
- }
- else
- {
- }
- /*
- waiters++;
-
- // FIXME this should be MsgWaitForMultipleObjects() as well probably
- DWORD rc = ::WaitForSingleObject(event, timeout);
-
- waiters--;
-
- return rc != WAIT_TIMEOUT;
- */
- return wxCOND_NO_ERROR ;
- }
- wxCondError Signal()
- {
- wxMacStCritical critical ;
- return wxCOND_NO_ERROR;
- }
-
- wxCondError Broadcast()
- {
- wxMacStCritical critical ;
- return wxCOND_NO_ERROR;
- }
-
- wxArrayLong m_waiters ;
- wxInt32 m_excessSignals ;
- wxMutex& m_mutex;
-};
-
-// ----------------------------------------------------------------------------
-// wxCriticalSection implementation
-// ----------------------------------------------------------------------------
-
-// it's implemented as a mutex on mac os, so it is defined in the headers
-
-// ----------------------------------------------------------------------------
-// wxThread implementation
-// ----------------------------------------------------------------------------
-
-// wxThreadInternal class
-// ----------------------
-
-class wxThreadInternal
-{
-public:
- wxThreadInternal()
- {
- m_tid = kNoThreadID ;
- m_state = STATE_NEW;
- m_priority = WXTHREAD_DEFAULT_PRIORITY;
- }
-
- ~wxThreadInternal()
- {
- }
-
- void Free()
- {
- }
-
- // create a new (suspended) thread (for the given thread object)
- bool Create(wxThread *thread, unsigned int stackSize);
-
- // suspend/resume/terminate
- bool Suspend();
- bool Resume();
- void Cancel() { m_state = STATE_CANCELED; }
-
- // thread state
- void SetState(wxThreadState state) { m_state = state; }
- wxThreadState GetState() const { return m_state; }
-
- // thread priority
- void SetPriority(unsigned int priority);
- unsigned int GetPriority() const { return m_priority; }
-
- void SetResult( void *res ) { m_result = res ; }
- void *GetResult() { return m_result ; }
-
- // thread handle and id
- ThreadID GetId() const { return m_tid; }
-
- // thread function
- static pascal void* MacThreadStart(wxThread* arg);
-
-private:
- wxThreadState m_state; // state, see wxThreadState enum
- unsigned int m_priority; // thread priority in "wx" units
- ThreadID m_tid; // thread id
- void* m_result;
- static ThreadEntryUPP s_threadEntry ;
-};
-
-static wxArrayPtrVoid s_threads ;
-
-ThreadEntryUPP wxThreadInternal::s_threadEntry = NULL ;
-pascal void* wxThreadInternal::MacThreadStart(wxThread *thread)
-{
- // first of all, check whether we hadn't been cancelled already
- if ( thread->m_internal->GetState() == STATE_EXITED )
- {
- return (void*)-1;
- }
-
- void* rc = thread->Entry();
-
- // enter m_critsect before changing the thread state
- thread->m_critsect.Enter();
- bool wasCancelled = thread->m_internal->GetState() == STATE_CANCELED;
- thread->m_internal->SetState(STATE_EXITED);
- thread->m_critsect.Leave();
-
- thread->OnExit();
-
- // if the thread was cancelled (from Delete()), then it the handle is still
- // needed there
- if ( thread->IsDetached() && !wasCancelled )
- {
- // auto delete
- delete thread;
- }
- //else: the joinable threads handle will be closed when Wait() is done
-
- return rc;
-}
-void wxThreadInternal::SetPriority(unsigned int priority)
-{
- // Priorities don't exist on Mac
-}
-
-bool wxThreadInternal::Create(wxThread *thread, unsigned int stackSize)
-{
- if ( s_threadEntry == NULL )
- {
- s_threadEntry = NewThreadEntryUPP( (ThreadEntryProcPtr) MacThreadStart ) ;
- }
- OSErr err = NewThread( kCooperativeThread,
- s_threadEntry,
- (void*) thread,
- stackSize,
- kNewSuspend,
- &m_result,
- &m_tid );
-
- if ( err != noErr )
- {
- wxLogSysError(_("Can't create thread"));
- return false;
- }
-
- if ( m_priority != WXTHREAD_DEFAULT_PRIORITY )
- {
- SetPriority(m_priority);
- }
-
- m_state = STATE_NEW;
-
- return true;
-}
-
-bool wxThreadInternal::Suspend()
-{
- OSErr err ;
-
- err = ::ThreadBeginCritical();
- wxASSERT( err == noErr ) ;
-
- if ( m_state != STATE_RUNNING )
- {
- err = ::ThreadEndCritical() ;
- wxASSERT( err == noErr ) ;
- wxLogSysError(_("Can not suspend thread %x"), m_tid);
- return false;
- }
-
- m_state = STATE_PAUSED;
-
- err = ::SetThreadStateEndCritical(m_tid, kStoppedThreadState, kNoThreadID);
-
- return true;
-}
-
-bool wxThreadInternal::Resume()
-{
- ThreadID current ;
- OSErr err ;
- err = MacGetCurrentThread( ¤t ) ;
-
- wxASSERT( err == noErr ) ;
- wxASSERT( current != m_tid ) ;
-
- err = ::ThreadBeginCritical();
- wxASSERT( err == noErr ) ;
-
- if ( m_state != STATE_PAUSED && m_state != STATE_NEW )
- {
- err = ::ThreadEndCritical() ;
- wxASSERT( err == noErr ) ;
- wxLogSysError(_("Can not resume thread %x"), m_tid);
- return false;
-
- }
- err = ::SetThreadStateEndCritical(m_tid, kReadyThreadState, kNoThreadID);
-
- m_state = STATE_RUNNING;
- err = ::ThreadEndCritical() ;
- wxASSERT( err == noErr ) ;
- ::YieldToAnyThread() ;
- return true;
-}
-
-// static functions
-// ----------------
-wxThread *wxThread::This()
-{
- wxMacStCritical critical ;
-
- ThreadID current ;
- OSErr err ;
-
- err = MacGetCurrentThread( ¤t ) ;
-
- for ( size_t i = 0 ; i < s_threads.Count() ; ++i )
- {
- if ( ( (wxThread*) s_threads[i] )->GetId() == current )
- return (wxThread*) s_threads[i] ;
- }
-
- wxLogSysError(_("Couldn't get the current thread pointer"));
- return NULL;
-}
-
-bool wxThread::IsMain()
-{
- ThreadID current ;
- OSErr err ;
-
- err = MacGetCurrentThread( ¤t ) ;
- return current == gs_idMainThread;
-}
-
-#ifdef Yield
-#undef Yield
-#endif
-
-void wxThread::Yield()
-{
- ::YieldToAnyThread() ;
-}
-
-void wxThread::Sleep(unsigned long milliseconds)
-{
- UnsignedWide start, now;
-
- Microseconds(&start);
-
- double mssleep = milliseconds * 1000 ;
- double msstart, msnow ;
- msstart = (start.hi * 4294967296.0 + start.lo) ;
-
- do
- {
- YieldToAnyThread();
- Microseconds(&now);
- msnow = (now.hi * 4294967296.0 + now.lo) ;
- } while( msnow - msstart < mssleep );
-}
-
-int wxThread::GetCPUCount()
-{
- // we will use whatever MP API will be used for the new MP Macs
- return 1;
-}
-
-unsigned long wxThread::GetCurrentId()
-{
- ThreadID current ;
- MacGetCurrentThread( ¤t ) ;
- return (unsigned long)current;
-}
-
-bool wxThread::SetConcurrency(size_t level)
-{
- wxASSERT_MSG( IsMain(), _T("should only be called from the main thread") );
-
- // ok only for the default one
- if ( level == 0 )
- return 0;
-
- // how many CPUs have we got?
- if ( GetCPUCount() == 1 )
- {
- // don't bother with all this complicated stuff - on a single
- // processor system it doesn't make much sense anyhow
- return level == 1;
- }
-
- return true ;
-}
-
-// ctor and dtor
-// -------------
-
-wxThread::wxThread(wxThreadKind kind)
-{
- g_numberOfThreads++;
- m_internal = new wxThreadInternal();
-
- m_isDetached = kind == wxTHREAD_DETACHED;
- s_threads.Add( (void*) this ) ;
-}
-
-wxThread::~wxThread()
-{
- if (g_numberOfThreads>0)
- {
- g_numberOfThreads--;
- }
-#ifdef __WXDEBUG__
- else
- {
- wxFAIL_MSG(wxT("More threads deleted than created."));
- }
-#endif
-
- s_threads.Remove( (void*) this ) ;
- if (m_internal != NULL) {
- delete m_internal;
- m_internal = NULL;
- }
-}
-
-// create/start thread
-// -------------------
-
-wxThreadError wxThread::Create(unsigned int stackSize)
-{
- wxCriticalSectionLocker lock(m_critsect);
-
- if ( !m_internal->Create(this, stackSize) )
- return wxTHREAD_NO_RESOURCE;
-
- return wxTHREAD_NO_ERROR;
-}
-
-wxThreadError wxThread::Run()
-{
- wxCriticalSectionLocker lock(m_critsect);
-
- if ( m_internal->GetState() != STATE_NEW )
- {
- // actually, it may be almost any state at all, not only STATE_RUNNING
- return wxTHREAD_RUNNING;
- }
-
- // the thread has just been created and is still suspended - let it run
- return Resume();
-}
-
-// suspend/resume thread
-// ---------------------
-
-wxThreadError wxThread::Pause()
-{
- wxCriticalSectionLocker lock(m_critsect);
-
- return m_internal->Suspend() ? wxTHREAD_NO_ERROR : wxTHREAD_MISC_ERROR;
-}
-
-wxThreadError wxThread::Resume()
-{
- wxCriticalSectionLocker lock(m_critsect);
-
- return m_internal->Resume() ? wxTHREAD_NO_ERROR : wxTHREAD_MISC_ERROR;
-}
-
-// stopping thread
-// ---------------
-
-wxThread::ExitCode wxThread::Wait()
-{
- // although under MacOS we can wait for any thread, it's an error to
- // wait for a detached one in wxWin API
- wxCHECK_MSG( !IsDetached(), (ExitCode)-1,
- _T("can't wait for detached thread") );
-
- ExitCode rc = (ExitCode)-1;
-
- (void)Delete(&rc);
-
- m_internal->Free();
-
- return rc;
-}
-
-wxThreadError wxThread::Delete(ExitCode *pRc)
-{
- ExitCode rc = 0;
-
- // Delete() is always safe to call, so consider all possible states
-
- // has the thread started to run?
- bool shouldResume = false;
-
- {
- wxCriticalSectionLocker lock(m_critsect);
-
- if ( m_internal->GetState() == STATE_NEW )
- {
- // WinThreadStart() will see it and terminate immediately
- m_internal->SetState(STATE_EXITED);
-
- shouldResume = true;
- }
- }
-
- // is the thread paused?
- if ( shouldResume || IsPaused() )
- Resume();
-
- // does is still run?
- if ( IsRunning() )
- {
- if ( IsMain() )
- {
- // set flag for wxIsWaitingForThread()
- gs_waitingForThread = true;
-
-#if wxUSE_GUI
- wxBeginBusyCursor();
-#endif // wxUSE_GUI
- }
-
- // ask the thread to terminate
- {
- wxCriticalSectionLocker lock(m_critsect);
-
- m_internal->Cancel();
- }
-
-#if wxUSE_GUI
- // simply wait for the thread to terminate
- while( TestDestroy() )
- {
- ::YieldToAnyThread() ;
- }
-#else // !wxUSE_GUI
- // simply wait for the thread to terminate
- while( TestDestroy() )
- {
- ::YieldToAnyThread() ;
- }
-#endif // wxUSE_GUI/!wxUSE_GUI
-
- if ( IsMain() )
- {
- gs_waitingForThread = false;
-
-#if wxUSE_GUI
- wxEndBusyCursor();
-#endif // wxUSE_GUI
- }
- }
-
- if ( IsDetached() )
- {
- // if the thread exits normally, this is done in WinThreadStart, but in
- // this case it would have been too early because
- // MsgWaitForMultipleObject() would fail if the therad handle was
- // closed while we were waiting on it, so we must do it here
- delete this;
- }
-
- if ( pRc )
- *pRc = rc;
-
- return rc == (ExitCode)-1 ? wxTHREAD_MISC_ERROR : wxTHREAD_NO_ERROR;
-}
-
-wxThreadError wxThread::Kill()
-{
- if ( !IsRunning() )
- return wxTHREAD_NOT_RUNNING;
-
-// if ( !::TerminateThread(m_internal->GetHandle(), (DWORD)-1) )
- {
- wxLogSysError(_("Couldn't terminate thread"));
-
- return wxTHREAD_MISC_ERROR;
- }
-
- m_internal->Free();
-
- if ( IsDetached() )
- {
- delete this;
- }
-
- return wxTHREAD_NO_ERROR;
-}
-
-void wxThread::Exit(ExitCode status)
-{
- m_internal->Free();
-
- if ( IsDetached() )
- {
- delete this;
- }
-
- m_internal->SetResult( status ) ;
-
-/*
-#if defined(__VISUALC__) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x500))
- _endthreadex((unsigned)status);
-#else // !VC++
- ::ExitThread((DWORD)status);
-#endif // VC++/!VC++
-*/
- wxFAIL_MSG(wxT("Couldn't return from ExitThread()!"));
-}
-
-// priority setting
-// ----------------
-
-// since all these calls are execute cooperatively we don't have to use the critical section
-
-void wxThread::SetPriority(unsigned int prio)
-{
- m_internal->SetPriority(prio);
-}
-
-unsigned int wxThread::GetPriority() const
-{
- return m_internal->GetPriority();
-}
-
-unsigned long wxThread::GetId() const
-{
- return (unsigned long)m_internal->GetId();
-}
-
-bool wxThread::IsRunning() const
-{
- return m_internal->GetState() == STATE_RUNNING;
-}
-
-bool wxThread::IsAlive() const
-{
- return (m_internal->GetState() == STATE_RUNNING) ||
- (m_internal->GetState() == STATE_PAUSED);
-}
-
-bool wxThread::IsPaused() const
-{
- return m_internal->GetState() == STATE_PAUSED;
-}
-
-bool wxThread::TestDestroy()
-{
- return m_internal->GetState() == STATE_CANCELED;
-}
-
-// ----------------------------------------------------------------------------
-// Automatic initialization for thread module
-// ----------------------------------------------------------------------------
-
-class wxThreadModule : public wxModule
-{
-public:
- virtual bool OnInit();
- virtual void OnExit();
-
-private:
- DECLARE_DYNAMIC_CLASS(wxThreadModule)
-};
-
-IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
-
-bool wxThreadModule::OnInit()
-{
- long response;
- bool hasThreadManager ;
- hasThreadManager = Gestalt( gestaltThreadMgrAttr, &response) == noErr && response & 1;
-#if !TARGET_CARBON
-#if GENERATINGCFM
- // verify presence of shared library
- hasThreadManager = hasThreadManager && ((Ptr)NewThread != (Ptr)kUnresolvedCFragSymbolAddress);
-#endif
-#endif
- if ( !hasThreadManager )
- {
- wxLogSysError( wxT("Thread Support is not available on this System") );
- return false ;
- }
-
- // no error return for GetCurrentThreadId()
- MacGetCurrentThread( &gs_idMainThread ) ;
-
- return true;
-}
-
-void wxThreadModule::OnExit()
-{
-}
-
-// ----------------------------------------------------------------------------
-// under MacOS we don't have currently preemptive threads, so any thread may access
-// the GUI at any time
-// ----------------------------------------------------------------------------
-
-void WXDLLEXPORT wxMutexGuiEnter()
-{
-}
-
-void WXDLLEXPORT wxMutexGuiLeave()
-{
-}
-
-void WXDLLEXPORT wxMutexGuiLeaveOrEnter()
-{
-}
-
-bool WXDLLEXPORT wxGuiOwnedByMainThread()
-{
- return false ;
-}
-
-// wake up the main thread
-void WXDLLEXPORT wxWakeUpMainThread()
-{
- wxMacWakeUp() ;
-}
-
-bool WXDLLEXPORT wxIsWaitingForThread()
-{
- return false ;
-}
-
-#include "wx/thrimpl.cpp"
-
-#endif // wxUSE_THREADS
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/timer.cpp
-// Purpose: wxTimer implementation
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// for compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#include "wx/timer.h"
-
-#ifndef WX_PRECOMP
- #include "wx/dynarray.h"
-#endif
-
-IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler)
-
-#ifdef __WXMAC__
-#include "wx/mac/private.h"
-#endif
-#ifndef __DARWIN__
-#include <Timer.h>
-#endif
-
-typedef struct MacTimerInfo
-{
- TMTask m_task;
- wxMacNotifierTableRef m_table ;
- wxTimer* m_timer ;
-} ;
-
-static void wxProcessTimer( unsigned long event , void *data ) ;
-
-static pascal void MacTimerProc( TMTask * t )
-{
- MacTimerInfo * tm = (MacTimerInfo*) t ;
- wxMacAddEvent( tm->m_table , wxProcessTimer, 0 , (void*) tm->m_timer , TRUE ) ;
-}
-
-// we need this array to track timers that are being deleted within the Notify procedure
-// adding the timer before the Notify call and checking after whether it still is in there
-// as the destructor would have removed it from the array
-
-wxArrayPtrVoid gTimersInProcess ;
-
-static void wxProcessTimer( unsigned long event , void *data )
-{
- if ( !data )
- return ;
-
- wxTimer* timer = (wxTimer*) data ;
-
- if ( timer->IsOneShot() )
- timer->Stop() ;
-
- gTimersInProcess.Add( timer ) ;
-
- timer->Notify();
-
- int index = gTimersInProcess.Index( timer ) ;
-
- if ( index != wxNOT_FOUND )
- {
- gTimersInProcess.RemoveAt( index ) ;
-
- if ( !timer->IsOneShot() && timer->m_info->m_task.tmAddr )
- {
- PrimeTime( (QElemPtr) &timer->m_info->m_task , timer->GetInterval() ) ;
- }
- }
-}
-
-void wxTimer::Init()
-{
- m_info = new MacTimerInfo() ;
- m_info->m_task.tmAddr = NULL ;
- m_info->m_task.tmWakeUp = 0 ;
- m_info->m_task.tmReserved = 0 ;
- m_info->m_task.qType = 0 ;
- m_info->m_table = wxMacGetNotifierTable() ;
- m_info->m_timer = this ;
-}
-
-bool wxTimer::IsRunning() const
-{
- // as the qType may already indicate it is elapsed, but it
- // was not handled internally yet
- return ( m_info->m_task.tmAddr != NULL ) ;
-}
-
-wxTimer::~wxTimer()
-{
- Stop();
- if (m_info != NULL) {
- delete m_info ;
- m_info = NULL ;
- }
- int index = gTimersInProcess.Index( this ) ;
- if ( index != wxNOT_FOUND )
- gTimersInProcess.RemoveAt( index ) ;
-}
-
-bool wxTimer::Start(int milliseconds,bool mode)
-{
- (void)wxTimerBase::Start(milliseconds, mode);
-
- wxCHECK_MSG( m_milli > 0, false, wxT("invalid value for timer timeout") );
- wxCHECK_MSG( m_info->m_task.tmAddr == NULL , false, wxT("attempting to restart a timer") );
-
-#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
- m_info->m_task.tmAddr = NewTimerUPP( MacTimerProc ) ;
-#else
- m_info->m_task.tmAddr = NewTimerProc( MacTimerProc ) ;
-#endif
- m_info->m_task.tmWakeUp = 0 ;
- m_info->m_task.tmReserved = 0 ;
- m_info->m_task.qType = 0 ;
- m_info->m_timer = this ;
- InsXTime((QElemPtr) &m_info->m_task ) ;
- PrimeTime( (QElemPtr) &m_info->m_task , m_milli ) ;
- return true;
-}
-
-void wxTimer::Stop()
-{
- if ( m_info->m_task.tmAddr )
- {
- RmvTime( (QElemPtr) &m_info->m_task ) ;
- DisposeTimerUPP(m_info->m_task.tmAddr) ;
- m_info->m_task.tmAddr = NULL ;
- }
- wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/toolbar.cpp
-// Purpose: wxToolBar
-// Author: Stefan Csomor
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: The wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#if wxUSE_TOOLBAR
-
-#include "wx/toolbar.h"
-
-#ifndef WX_PRECOMP
- #include "wx/wx.h"
-#endif
-
-#include "wx/notebook.h"
-#include "wx/tabctrl.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
-
-BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
- EVT_MOUSE_EVENTS( wxToolBar::OnMouse )
- EVT_PAINT( wxToolBar::OnPaint )
-END_EVENT_TABLE()
-
-#include "wx/mac/uma.h"
-#include "wx/geometry.h"
-// ----------------------------------------------------------------------------
-// private classes
-// ----------------------------------------------------------------------------
-
-class wxToolBarTool : public wxToolBarToolBase
-{
-public:
- wxToolBarTool(wxToolBar *tbar,
- int id,
- const wxString& label,
- const wxBitmap& bmpNormal,
- const wxBitmap& bmpDisabled,
- wxItemKind kind,
- wxObject *clientData,
- const wxString& shortHelp,
- const wxString& longHelp) ;
-
- wxToolBarTool(wxToolBar *tbar, wxControl *control)
- : wxToolBarToolBase(tbar, control)
- {
- Init() ;
- }
-
- virtual ~wxToolBarTool()
- {
- if ( m_controlHandle )
- DisposeControl( m_controlHandle ) ;
- }
-
- ControlHandle GetControlHandle() { return m_controlHandle ; }
- void SetControlHandle( ControlHandle handle ) { m_controlHandle = handle ; }
-
- void SetSize(const wxSize& size) ;
- void SetPosition( const wxPoint& position ) ;
- wxSize GetSize() const
- {
- if ( IsControl() )
- {
- return GetControl()->GetSize() ;
- }
- else if ( IsButton() )
- {
- return GetToolBar()->GetToolSize() ;
- }
- else
- {
- wxSize sz = GetToolBar()->GetToolSize() ;
- sz.x /= 4 ;
- sz.y /= 4 ;
- return sz ;
- }
- }
- wxPoint GetPosition() const
- {
- return wxPoint(m_x, m_y);
- }
-private :
- void Init()
- {
- m_controlHandle = NULL ;
- }
- ControlHandle m_controlHandle ;
-
- wxCoord m_x;
- wxCoord m_y;
-};
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxToolBarTool
-// ----------------------------------------------------------------------------
-
-void wxToolBarTool::SetSize(const wxSize& size)
-{
- if ( IsControl() )
- {
- GetControl()->SetSize( size ) ;
- }
-}
-
-void wxToolBarTool::SetPosition(const wxPoint& position)
-{
- m_x = position.x;
- m_y = position.y;
-
- if ( IsButton() )
- {
- int x , y ;
- x = y = 0 ;
- WindowRef rootwindow = (WindowRef) GetToolBar()->MacGetRootWindow() ;
- GetToolBar()->MacWindowToRootWindow( &x , &y ) ;
- int mac_x = x + position.x ;
- int mac_y = y + position.y ;
-
-
- Rect contrlRect ;
- GetControlBounds( m_controlHandle , &contrlRect ) ;
- int former_mac_x = contrlRect.left ;
- int former_mac_y = contrlRect.top ;
- wxSize sz = GetToolBar()->GetToolSize() ;
-
- if ( mac_x != former_mac_x || mac_y != former_mac_y )
- {
- {
- Rect inval = { former_mac_y , former_mac_x , former_mac_y + sz.y , former_mac_x + sz.x } ;
- InvalWindowRect( rootwindow , &inval ) ;
- }
- UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
- {
- Rect inval = { mac_y , mac_x , mac_y + sz.y , mac_x + sz.x } ;
- InvalWindowRect( rootwindow , &inval ) ;
- }
- }
- }
- else if ( IsControl() )
- {
- GetControl()->Move( position ) ;
- }
-}
-
-const short kwxMacToolBarToolDefaultWidth = 24 ;
-const short kwxMacToolBarToolDefaultHeight = 22 ;
-const short kwxMacToolBarTopMargin = 2 ;
-const short kwxMacToolBarLeftMargin = 2 ;
-
-wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
- int id,
- const wxString& label,
- const wxBitmap& bmpNormal,
- const wxBitmap& bmpDisabled,
- wxItemKind kind,
- wxObject *clientData,
- const wxString& shortHelp,
- const wxString& longHelp)
- : wxToolBarToolBase(tbar, id, label, bmpNormal, bmpDisabled, kind,
- clientData, shortHelp, longHelp)
-{
- Init();
-
- if (id == wxID_SEPARATOR) return;
-
- WindowRef window = (WindowRef) tbar->MacGetRootWindow() ;
- wxSize toolSize = tbar->GetToolSize() ;
- Rect toolrect = { 0, 0 , toolSize.y , toolSize.x } ;
-
- ControlButtonContentInfo info ;
- wxMacCreateBitmapButton( &info , GetNormalBitmap() ) ;
-
- SInt16 behaviour = kControlBehaviorOffsetContents ;
- if ( CanBeToggled() )
- behaviour += kControlBehaviorToggles ;
-
- if ( info.contentType != kControlNoContent )
- {
- m_controlHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
- behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
-
- ::SetControlData( m_controlHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
- }
- else
- {
- m_controlHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
- behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
- }
- UMAShowControl( m_controlHandle ) ;
- if ( !IsEnabled() )
- {
- UMADeactivateControl( m_controlHandle ) ;
- }
- if ( CanBeToggled() && IsToggled() )
- {
- ::SetControl32BitValue( m_controlHandle , 1 ) ;
- }
- else
- {
- ::SetControl32BitValue( m_controlHandle , 0 ) ;
- }
-
- ControlHandle container = (ControlHandle) tbar->MacGetContainerForEmbedding() ;
- wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
- ::EmbedControl( m_controlHandle , container ) ;
-}
-
-
-wxToolBarToolBase *wxToolBar::CreateTool(int id,
- const wxString& label,
- const wxBitmap& bmpNormal,
- const wxBitmap& bmpDisabled,
- wxItemKind kind,
- wxObject *clientData,
- const wxString& shortHelp,
- const wxString& longHelp)
-{
- return new wxToolBarTool(this, id, label, bmpNormal, bmpDisabled, kind,
- clientData, shortHelp, longHelp);
-}
-
-wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
-{
- return new wxToolBarTool(this, control);
-}
-
-void wxToolBar::Init()
-{
- m_maxWidth = -1;
- m_maxHeight = -1;
- m_defaultWidth = kwxMacToolBarToolDefaultWidth;
- m_defaultHeight = kwxMacToolBarToolDefaultHeight;
-}
-
-bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
- long style, const wxString& name)
-{
- int x = pos.x;
- int y = pos.y;
- int width = size.x;
- int height = size.y;
-
- if (width <= 0)
- width = 100;
- if (height <= 0)
- height = 30;
- if (x < 0)
- x = 0;
- if (y < 0)
- y = 0;
-
- SetName(name);
-
- m_windowStyle = style;
- parent->AddChild(this);
-
- m_backgroundColour = parent->GetBackgroundColour() ;
- m_foregroundColour = parent->GetForegroundColour() ;
-
- if (id == wxID_ANY)
- m_windowId = NewControlId();
- else
- m_windowId = id;
-
- {
- m_width = size.x ;
- m_height = size.y ;
- int x = pos.x ;
- int y = pos.y ;
- AdjustForParentClientOrigin(x, y, wxSIZE_USE_EXISTING);
- m_x = x ;
- m_y = y ;
- }
-
- return true;
-}
-
-wxToolBar::~wxToolBar()
-{
- // we must refresh the frame size when the toolbar is deleted but the frame
- // is not - otherwise toolbar leaves a hole in the place it used to occupy
-}
-
-bool wxToolBar::Realize()
-{
- if (m_tools.GetCount() == 0)
- return false;
-
- int x = m_xMargin + kwxMacToolBarLeftMargin ;
- int y = m_yMargin + kwxMacToolBarTopMargin ;
-
- int tw, th;
- GetSize(& tw, & th);
-
- int maxWidth = 0 ;
- int maxHeight = 0 ;
-
- int maxToolWidth = 0;
- int maxToolHeight = 0;
-
- // Find the maximum tool width and height
- wxToolBarToolsList::Node *node = m_tools.GetFirst();
- while ( node )
- {
- wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
- wxSize sz = tool->GetSize() ;
-
- if ( sz.x > maxToolWidth )
- maxToolWidth = sz.x ;
- if (sz.y> maxToolHeight)
- maxToolHeight = sz.y;
-
- node = node->GetNext();
- }
-
- node = m_tools.GetFirst();
- while (node)
- {
- wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
- wxSize cursize = tool->GetSize() ;
-
- // for the moment we just do a single row/column alignement
- if ( x + cursize.x > maxWidth )
- maxWidth = x + cursize.x ;
- if ( y + cursize.y > maxHeight )
- maxHeight = y + cursize.y ;
-
- tool->SetPosition( wxPoint( x , y ) ) ;
-
- if ( GetWindowStyleFlag() & wxTB_VERTICAL )
- {
- y += cursize.y ;
- }
- else
- {
- x += cursize.x ;
- }
-
- node = node->GetNext();
- }
-
- if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
- {
- if ( m_maxRows == 0 )
- {
- // if not set yet, only one row
- SetRows(1);
- }
- maxWidth = tw ;
- maxHeight += m_yMargin + kwxMacToolBarTopMargin;
- m_maxHeight = maxHeight ;
- }
- else
- {
- if ( GetToolsCount() > 0 && m_maxRows == 0 )
- {
- // if not set yet, have one column
- SetRows(GetToolsCount());
- }
- maxHeight = th ;
- maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
- m_maxWidth = maxWidth ;
- }
-
- SetSize(maxWidth, maxHeight);
- InvalidateBestSize();
-
- return true;
-}
-
-void wxToolBar::SetToolBitmapSize(const wxSize& size)
-{
- m_defaultWidth = size.x+4; m_defaultHeight = size.y+4;
-}
-
-// The button size is bigger than the bitmap size
-wxSize wxToolBar::GetToolSize() const
-{
- return wxSize(m_defaultWidth + 4, m_defaultHeight + 4);
-}
-
-void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
-{
- wxToolBarToolsList::Node *node;
- for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
- {
- wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ;
- if ( tool->IsButton() )
- {
- if( (WXWidget) tool->GetControlHandle() == control )
- {
- if ( tool->CanBeToggled() )
- {
- tool->Toggle( GetControl32BitValue( (ControlHandle) control ) ) ;
- }
- OnLeftClick( tool->GetId() , tool -> IsToggled() ) ;
- break ;
- }
- }
- }
-}
-
-void wxToolBar::SetRows(int nRows)
-{
- if ( nRows == m_maxRows )
- {
- // avoid resizing the frame uselessly
- return;
- }
-
- m_maxRows = nRows;
-}
-
-void wxToolBar::MacSuperChangedPosition()
-{
- wxWindow::MacSuperChangedPosition() ;
- Realize() ;
-}
-
-wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
-{
- wxToolBarToolsList::Node *node = m_tools.GetFirst();
- while (node)
- {
- wxToolBarTool *tool = (wxToolBarTool *)node->GetData() ;
- wxRect2DInt r( tool->GetPosition() , tool->GetSize() ) ;
- if ( r.Contains( wxPoint( x , y ) ) )
- {
- return tool;
- }
-
- node = node->GetNext();
- }
-
- return (wxToolBarToolBase *)NULL;
-}
-
-wxString wxToolBar::MacGetToolTipString( wxPoint &pt )
-{
- wxToolBarToolBase* tool = FindToolForPosition( pt.x , pt.y ) ;
- if ( tool )
- {
- return tool->GetShortHelp() ;
- }
- return wxEmptyString ;
-}
-
-void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
-{
- if (!IsShown())
- return ;
-
- wxToolBarTool *tool = (wxToolBarTool *)t;
- if ( tool->IsControl() )
- {
- tool->GetControl()->Enable( enable ) ;
- }
- else if ( tool->IsButton() )
- {
- if ( enable )
- UMAActivateControl( tool->GetControlHandle() ) ;
- else
- UMADeactivateControl( tool->GetControlHandle() ) ;
- }
-}
-
-void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
-{
- if (!IsShown())
- return ;
-
- wxToolBarTool *tool = (wxToolBarTool *)t;
- if ( tool->IsButton() )
- {
- ::SetControl32BitValue( tool->GetControlHandle() , toggle ) ;
- }
-}
-
-bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
- wxToolBarToolBase *tool)
-{
- // nothing special to do here - we relayout in Realize() later
- tool->Attach(this);
- InvalidateBestSize();
-
- return true;
-}
-
-void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle))
-{
- wxFAIL_MSG( _T("not implemented") );
-}
-
-bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
-{
- wxToolBarToolsList::Node *node;
- for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
- {
- wxToolBarToolBase *tool2 = node->GetData();
- if ( tool2 == tool )
- {
- // let node point to the next node in the list
- node = node->GetNext();
-
- break;
- }
- }
-
- wxSize sz = ((wxToolBarTool*)tool)->GetSize() ;
-
- tool->Detach();
-
- // and finally reposition all the controls after this one
-
- for ( /* node -> first after deleted */ ; node; node = node->GetNext() )
- {
- wxToolBarTool *tool2 = (wxToolBarTool*) node->GetData();
- wxPoint pt = tool2->GetPosition() ;
-
- if ( GetWindowStyleFlag() & wxTB_VERTICAL )
- {
- pt.y -= sz.y ;
- }
- else
- {
- pt.x -= sz.x ;
- }
- tool2->SetPosition( pt ) ;
- }
-
- InvalidateBestSize();
- return true ;
-}
-
-void wxToolBar::OnPaint(wxPaintEvent& event)
-{
- wxPaintDC dc(this) ;
- wxMacPortSetter helper(&dc) ;
-
- Rect toolbarrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) ,
- dc.YLOG2DEVMAC(m_height) , dc.XLOG2DEVMAC(m_width) } ;
- UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
- {
- wxToolBarToolsList::Node *node;
- for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
- {
- wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ;
- if ( tool->IsButton() )
- {
- UMADrawControl( tool->GetControlHandle() ) ;
- }
- }
- }
-}
-
-void wxToolBar::OnMouse( wxMouseEvent &event )
-{
- if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK )
- {
-
- int x = event.m_x ;
- int y = event.m_y ;
-
- MacClientToRootWindow( &x , &y ) ;
-
- ControlHandle control ;
- Point localwhere ;
- SInt16 controlpart ;
- WindowRef window = (WindowRef) MacGetRootWindow() ;
-
- localwhere.h = x ;
- localwhere.v = y ;
-
- short modifiers = 0;
-
- if ( !event.m_leftDown && !event.m_rightDown )
- modifiers |= btnState ;
-
- if ( event.m_shiftDown )
- modifiers |= shiftKey ;
-
- if ( event.m_controlDown )
- modifiers |= controlKey ;
-
- if ( event.m_altDown )
- modifiers |= optionKey ;
-
- if ( event.m_metaDown )
- modifiers |= cmdKey ;
-
- controlpart = ::FindControl( localwhere , window , &control ) ;
- {
- if ( control && ::IsControlActive( control ) )
- {
- {
- controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ;
- wxTheApp->s_lastMouseDown = 0 ;
- if ( control && controlpart != kControlNoPart ) // otherwise we will get the event twice
- {
- MacHandleControlClick( (WXWidget) control , controlpart , false /* not down anymore */ ) ;
- }
- }
- }
- }
- }
-}
-
-#endif // wxUSE_TOOLBAR
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/tooltip.cpp
-// Purpose: wxToolTip implementation
-// Author: Robert Roebling
-// Id: $Id$
-// Copyright: (c) 1998 Robert Roebling
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_TOOLTIPS
-
-#include "wx/tooltip.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/window.h"
- #include "wx/dc.h"
- #include "wx/timer.h"
-#endif
-
-#include "wx/geometry.h"
-#include "wx/mac/uma.h"
-
-//-----------------------------------------------------------------------------
-// global data
-//-----------------------------------------------------------------------------
-
-class wxMacToolTipTimer ;
-
-class wxMacToolTip
-{
- public :
- wxMacToolTip( ) ;
- ~wxMacToolTip() ;
-
- void Setup( WindowRef window , const wxString& text , wxPoint localPosition ) ;
- long GetMark() { return m_mark ; }
- void Draw() ;
- void Clear() ;
- bool IsShown() { return m_shown ; }
- private :
-
- wxString m_label ;
- wxPoint m_position ;
- Rect m_rect ;
- WindowRef m_window ;
- PicHandle m_backpict ;
- bool m_shown ;
- long m_mark ;
- wxMacToolTipTimer* m_timer ;
-#if TARGET_CARBON
- wxMacCFStringHolder m_helpTextRef ;
-#endif
-} ;
-
-class wxMacToolTipTimer : public wxTimer
-{
-public:
- wxMacToolTipTimer() {} ;
- wxMacToolTipTimer(wxMacToolTip* tip, int iMilliseconds) ;
- virtual ~wxMacToolTipTimer() {} ;
- void Notify()
- {
- if ( m_mark == m_tip->GetMark() )
- m_tip->Draw() ;
- }
-protected:
- wxMacToolTip* m_tip;
- long m_mark ;
-};
-
-//-----------------------------------------------------------------------------
-// wxToolTip
-//-----------------------------------------------------------------------------
-static long s_ToolTipDelay = 500 ;
-static bool s_ShowToolTips = true ;
-static wxMacToolTip s_ToolTip ;
-static wxWindow* s_LastWindowEntered = NULL ;
-static wxRect2DInt s_ToolTipArea ;
-static WindowRef s_ToolTipWindowRef = NULL ;
-
-IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject)
-
-wxToolTip::wxToolTip( const wxString &tip )
-{
- m_text = tip;
- m_window = (wxWindow*) NULL;
-}
-
-wxToolTip::~wxToolTip()
-{
-}
-
-void wxToolTip::SetTip( const wxString &tip )
-{
- m_text = tip;
-
- if ( m_window )
- {
- /*
- // update it immediately
- wxToolInfo ti(GetHwndOf(m_window));
- ti.lpszText = (wxChar *)m_text.c_str();
-
- (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);
- */
- }
-}
-
-void wxToolTip::SetWindow( wxWindow *win )
-{
- m_window = win ;
-}
-
-void wxToolTip::Enable( bool flag )
-{
- if ( s_ShowToolTips != flag )
- {
- s_ShowToolTips = flag ;
- if ( s_ShowToolTips )
- {
- }
- else
- {
- s_ToolTip.Clear() ;
- }
- }
-}
-
-void wxToolTip::SetDelay( long msecs )
-{
- s_ToolTipDelay = msecs ;
-}
-
-void wxToolTip::RelayEvent( wxWindow *win , wxMouseEvent &event )
-{
- if ( s_ShowToolTips )
- {
- if ( event.GetEventType() == wxEVT_LEAVE_WINDOW )
- {
- s_ToolTip.Clear() ;
- }
- else if (event.GetEventType() == wxEVT_ENTER_WINDOW || event.GetEventType() == wxEVT_MOTION )
- {
- wxPoint2DInt where( event.m_x , event.m_y ) ;
- if ( s_LastWindowEntered == win && s_ToolTipArea.Contains( where ) )
- {
- }
- else
- {
- s_ToolTip.Clear() ;
- s_ToolTipArea = wxRect2DInt( event.m_x - 2 , event.m_y - 2 , 4 , 4 ) ;
- s_LastWindowEntered = win ;
-
- WindowRef window = MAC_WXHWND( win->MacGetRootWindow() ) ;
- int x = event.m_x ;
- int y = event.m_y ;
- wxPoint local( x , y ) ;
- win->MacClientToRootWindow( &x, &y ) ;
- wxPoint windowlocal( x , y ) ;
- s_ToolTip.Setup( window , win->MacGetToolTipString( local ) , windowlocal ) ;
- }
- }
- }
-}
-
-void wxToolTip::RemoveToolTips()
-{
- s_ToolTip.Clear() ;
-}
-// --- mac specific
-
-wxMacToolTipTimer::wxMacToolTipTimer( wxMacToolTip *tip , int msec )
-{
- m_tip = tip;
- m_mark = tip->GetMark() ;
- Start(msec, true);
-}
-
-wxMacToolTip::wxMacToolTip()
-{
- m_window = NULL ;
- m_backpict = NULL ;
- m_mark = 0 ;
- m_shown = false ;
- m_timer = NULL ;
-}
-
-void wxMacToolTip::Setup( WindowRef win , const wxString& text , wxPoint localPosition )
-{
- m_mark++ ;
- Clear() ;
- m_position = localPosition ;
- m_label = text ;
- m_window =win;
- s_ToolTipWindowRef = m_window ;
- m_backpict = NULL ;
- if ( m_timer )
- delete m_timer ;
- m_timer = new wxMacToolTipTimer( this , s_ToolTipDelay ) ;
-}
-
-wxMacToolTip::~wxMacToolTip()
-{
- if ( m_timer ) {
- delete m_timer ;
- m_timer = NULL;
- }
- if ( m_backpict )
- Clear() ;
-}
-
-const short kTipBorder = 2 ;
-const short kTipOffset = 5 ;
-
-void wxMacToolTip::Draw()
-{
- if ( m_label.empty() )
- return ;
-
- if ( m_window == s_ToolTipWindowRef )
- {
- m_shown = true ;
-#if TARGET_CARBON
- HMHelpContentRec tag ;
- tag.version = kMacHelpVersion;
- SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ;
- GrafPtr port ;
- GetPort( &port ) ;
- SetPortWindowPort(m_window) ;
- LocalToGlobal( (Point *) &tag.absHotRect.top );
- LocalToGlobal( (Point *) &tag.absHotRect.bottom );
- SetPort( port );
- m_helpTextRef.Assign( m_label , wxFONTENCODING_DEFAULT ) ;
- tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ;
- tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ;
- tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ;
- tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ;
- tag.tagSide = kHMDefaultSide;
- HMDisplayTag( &tag );
-#else
- wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) );
- FontFamilyID fontId ;
- Str255 fontName ;
- SInt16 fontSize ;
- Style fontStyle ;
- GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
- GetFNum( fontName, &fontId );
-
- TextFont( fontId ) ;
- TextSize( fontSize ) ;
- TextFace( fontStyle ) ;
- FontInfo fontInfo;
- ::GetFontInfo(&fontInfo);
- short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
- short height = 0 ;
-
- int i = 0 ;
- int length = m_label.length() ;
- int width = 0 ;
- int thiswidth = 0 ;
- int laststop = 0 ;
- wxCharBuffer text = m_label.mb_str( wxConvLocal) ;
-
- while( i < length )
- {
- if( text[i] == 13 || text[i] == 10)
- {
- thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
- if ( thiswidth > width )
- width = thiswidth ;
-
- height += lineh ;
- laststop = i+1 ;
- }
- i++ ;
- }
- if ( i - laststop > 0 )
- {
- thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
- if ( thiswidth > width )
- width = thiswidth ;
- height += lineh ;
- }
-
- m_rect.left = m_position.x + kTipOffset;
- m_rect.top = m_position.y + kTipOffset;
- m_rect.right = m_rect.left + width + 2 * kTipBorder;
-
- m_rect.bottom = m_rect.top + height + 2 * kTipBorder;
- Rect r ;
- GetPortBounds( GetWindowPort( m_window ) , &r ) ;
- if ( m_rect.top < 0 )
- {
- m_rect.bottom += -m_rect.top ;
- m_rect.top = 0 ;
- }
- if ( m_rect.left < 0 )
- {
- m_rect.right += -m_rect.left ;
- m_rect.left = 0 ;
- }
- if ( m_rect.right > r.right )
- {
- m_rect.left -= (m_rect.right - r.right ) ;
- m_rect.right = r.right ;
- }
- if ( m_rect.bottom > r.bottom )
- {
- m_rect.top -= (m_rect.bottom - r.bottom) ;
- m_rect.bottom = r.bottom ;
- }
- ClipRect( &m_rect ) ;
- BackColor( whiteColor ) ;
- ForeColor(blackColor ) ;
- GWorldPtr port ;
- NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ;
- CGrafPtr origPort ;
- GDHandle origDevice ;
-
- GetGWorld( &origPort , &origDevice ) ;
- SetGWorld( port , NULL ) ;
-
- m_backpict = OpenPicture(&m_rect);
-
- CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)),
- GetPortBitMapForCopyBits(port),
- &m_rect,
- &m_rect,
- srcCopy,
- NULL);
- ClosePicture();
- SetGWorld( origPort , origDevice ) ;
- DisposeGWorld( port ) ;
- PenNormal() ;
-
- RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ;
- BackColor( whiteColor ) ;
- RGBForeColor( &tooltipbackground ) ;
-
- PaintRect( &m_rect ) ;
- ForeColor(blackColor ) ;
- FrameRect( &m_rect ) ;
- SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ;
- ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder);
-
- i = 0 ;
- laststop = 0 ;
- height = 0 ;
-
- while( i < length )
- {
- if( text[i] == 13 || text[i] == 10)
- {
- ::DrawText( text , laststop , i - laststop ) ;
- height += lineh ;
- ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height );
- laststop = i+1 ;
- }
- i++ ;
- }
- ::DrawText( text , laststop , i - laststop ) ;
- ::TextMode( srcOr ) ;
-#endif
- }
-}
-
-void wxToolTip::NotifyWindowDelete( WXHWND win )
-{
- if ( win == s_ToolTipWindowRef )
- {
- s_ToolTipWindowRef = NULL ;
- }
-}
-
-void wxMacToolTip::Clear()
-{
- m_mark++ ;
- if ( m_timer )
- {
- delete m_timer ;
- m_timer = NULL ;
- }
- if ( !m_shown )
- return ;
-#if TARGET_CARBON
- HMHideTag() ;
- m_helpTextRef.Release() ;
-#else
- if ( m_window == s_ToolTipWindowRef && m_backpict )
- {
- wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ;
-
- m_shown = false ;
-
- BackColor( whiteColor ) ;
- ForeColor(blackColor ) ;
- DrawPicture(m_backpict, &m_rect);
- KillPicture(m_backpict);
- m_backpict = NULL ;
- }
-#endif
-}
-
-#endif // wxUSE_TOOLTIPS
+++ /dev/null
-///////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/toplevel.cpp
-// Purpose: implements wxTopLevelWindow for Mac
-// Author: Stefan Csomor
-// Modified by:
-// Created: 24.09.01
-// RCS-ID: $Id$
-// Copyright: (c) 2001-2004 Stefan Csomor
-// License: wxWindows licence
-///////////////////////////////////////////////////////////////////////////////
-
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#include "wx/toplevel.h"
-
-#ifndef WX_PRECOMP
- #include "wx/app.h"
- #include "wx/frame.h"
- #include "wx/string.h"
- #include "wx/log.h"
- #include "wx/intl.h"
-#endif //WX_PRECOMP
-
-#include "wx/mac/uma.h"
-#include "wx/mac/aga.h"
-#include "wx/tooltip.h"
-#include "wx/dnd.h"
-#if wxUSE_SYSTEM_OPTIONS
- #include "wx/sysopt.h"
-#endif
-
-#include <ToolUtils.h>
-
-
-#define wxMAC_DEBUG_REDRAW 0
-#ifndef wxMAC_DEBUG_REDRAW
-#define wxMAC_DEBUG_REDRAW 0
-#endif
-
-// ----------------------------------------------------------------------------
-// globals
-// ----------------------------------------------------------------------------
-
-// list of all frames and modeless dialogs
-wxWindowList wxModelessWindows;
-
-// double click testing
-static Point gs_lastWhere;
-static long gs_lastWhen = 0;
-
-
-#if TARGET_CARBON
-static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param);
-#endif
-
-// ============================================================================
-// wxTopLevelWindowMac implementation
-// ============================================================================
-
-// ---------------------------------------------------------------------------
-// Carbon Events
-// ---------------------------------------------------------------------------
-
-#if TARGET_CARBON
-
-extern long wxMacTranslateKey(unsigned char key, unsigned char code) ;
-
-static const EventTypeSpec eventList[] =
-{
- { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } ,
-
- { kEventClassKeyboard, kEventRawKeyDown } ,
- { kEventClassKeyboard, kEventRawKeyRepeat } ,
- { kEventClassKeyboard, kEventRawKeyUp } ,
- { kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
-
- { kEventClassWindow , kEventWindowShown } ,
- { kEventClassWindow , kEventWindowUpdate } ,
- { kEventClassWindow , kEventWindowActivated } ,
- { kEventClassWindow , kEventWindowDeactivated } ,
- { kEventClassWindow , kEventWindowBoundsChanging } ,
- { kEventClassWindow , kEventWindowBoundsChanged } ,
- { kEventClassWindow , kEventWindowClose } ,
-
- { kEventClassMouse , kEventMouseDown } ,
- { kEventClassMouse , kEventMouseUp } ,
- { kEventClassMouse , kEventMouseWheelMoved } ,
- { kEventClassMouse , kEventMouseMoved } ,
- { kEventClassMouse , kEventMouseDragged } ,
-
-} ;
-
-static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- wxWindow* focus = wxWindow::FindFocus() ;
- char charCode ;
- UInt32 keyCode ;
- UInt32 modifiers ;
- Point point ;
-
- EventRef rawEvent ;
-
- GetEventParameter( event , kEventParamTextInputSendKeyboardEvent ,typeEventRef,NULL,sizeof(rawEvent),NULL,&rawEvent ) ;
-
- GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
- GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
- GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
- GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL,
- sizeof( Point ), NULL, &point );
-
- switch ( GetEventKind( event ) )
- {
- case kEventTextInputUnicodeForKeyEvent :
- // this is only called when no default handler has jumped in, eg a wxControl on a floater window does not
- // get its own kEventTextInputUnicodeForKeyEvent, so we route back the
- wxControl* control = wxDynamicCast( focus , wxControl ) ;
- if ( control )
- {
- ControlHandle macControl = (ControlHandle) control->GetMacControl() ;
- if ( macControl )
- {
- ::HandleControlKey( macControl , keyCode , charCode , modifiers ) ;
- result = noErr ;
- }
- }
- /*
- // this may lead to double events sent to a window in case all handlers have skipped the key down event
- UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
- UInt32 message = (keyCode << 8) + charCode;
-
- if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
- focus , message , modifiers , when , point.h , point.v ) )
- {
- result = noErr ;
- }
- */
- break ;
- }
-
- return result ;
-}
-
-static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- wxWindow* focus = wxWindow::FindFocus() ;
- char charCode ;
- UInt32 keyCode ;
- UInt32 modifiers ;
- Point point ;
- UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
-
- GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
- GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
- GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
- GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
- sizeof( Point ), NULL, &point );
-
- UInt32 message = (keyCode << 8) + charCode;
- switch( GetEventKind( event ) )
- {
- case kEventRawKeyRepeat :
- case kEventRawKeyDown :
- {
- WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
- WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
- wxTheApp->MacSetCurrentEvent( event , handler ) ;
- if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
- focus , message , modifiers , when , point.h , point.v ) )
- {
- result = noErr ;
- }
- wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ;
- }
- break ;
- case kEventRawKeyUp :
- if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent(
- focus , message , modifiers , when , point.h , point.v ) )
- {
- result = noErr ;
- }
- break ;
- case kEventRawKeyModifiersChanged :
- {
- wxKeyEvent event(wxEVT_KEY_DOWN);
-
- event.m_shiftDown = modifiers & shiftKey;
- event.m_controlDown = modifiers & controlKey;
- event.m_altDown = modifiers & optionKey;
- event.m_metaDown = modifiers & cmdKey;
-
- event.m_x = point.h;
- event.m_y = point.v;
- event.SetTimestamp(when);
- wxWindow* focus = wxWindow::FindFocus() ;
- event.SetEventObject(focus);
-
- if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey )
- {
- event.m_keyCode = WXK_CONTROL ;
- event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & shiftKey )
- {
- event.m_keyCode = WXK_SHIFT ;
- event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & optionKey )
- {
- event.m_keyCode = WXK_ALT ;
- event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & cmdKey )
- {
- event.m_keyCode = WXK_COMMAND ;
- event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
- focus->GetEventHandler()->ProcessEvent( event ) ;
- }
- wxTheApp->s_lastModifiers = modifiers ;
- }
- break ;
- }
-
- return result ;
-}
-
-pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
- Point point ;
- UInt32 modifiers = 0;
- EventMouseButton button = 0 ;
- UInt32 click = 0 ;
-
- GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
- sizeof( Point ), NULL, &point );
- GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL,
- sizeof( UInt32 ), NULL, &modifiers );
- GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL,
- sizeof( EventMouseButton ), NULL, &button );
- GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL,
- sizeof( UInt32 ), NULL, &click );
-
- if ( button == 0 || GetEventKind( event ) == kEventMouseUp )
- modifiers += btnState ;
-
- // temporary hack to support true two button mouse
- if ( button == kEventMouseButtonSecondary )
- {
- modifiers |= controlKey ;
- }
- WindowRef window ;
- short windowPart = ::FindWindow(point, &window);
-
- // either we really are active or we are capturing mouse events
-
- if ( (IsWindowActive(window) && windowPart == inContent) ||
- (wxTheApp->s_captureWindow && wxTheApp->s_captureWindow->MacGetTopLevelWindow() == toplevelWindow) )
- {
- switch ( GetEventKind( event ) )
- {
- case kEventMouseDown :
- toplevelWindow->MacFireMouseEvent( mouseDown , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
- result = noErr ;
- break ;
- case kEventMouseUp :
- toplevelWindow->MacFireMouseEvent( mouseUp , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
- result = noErr ;
- break ;
- case kEventMouseMoved :
- wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
- result = noErr ;
- break ;
- case kEventMouseDragged :
- toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
- result = noErr ;
- break ;
- case kEventMouseWheelMoved :
- {
- //bClearTooltip = false;
- EventMouseWheelAxis axis = kEventMouseWheelAxisY;
- SInt32 delta = 0;
- Point mouseLoc = {0, 0};
- if (::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis,
- NULL, sizeof(EventMouseWheelAxis), NULL, &axis) == noErr &&
- ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger,
- NULL, sizeof(SInt32), NULL, &delta) == noErr &&
- ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint,
- NULL, sizeof(Point), NULL, &mouseLoc) == noErr)
- {
- wxMouseEvent wheelEvent(wxEVT_MOUSEWHEEL);
-
- wheelEvent.m_x = mouseLoc.h;
- wheelEvent.m_y = mouseLoc.v;
-
- wheelEvent.m_wheelRotation = delta;
- wheelEvent.m_wheelDelta = 1;
- wheelEvent.m_linesPerAction = 1;
-
- wxWindow* currentMouseWindow = NULL;
- wxWindow::MacGetWindowFromPoint(wxPoint(mouseLoc.h, mouseLoc.v), ¤tMouseWindow);
-
- if (currentMouseWindow)
- {
- currentMouseWindow->GetEventHandler()->ProcessEvent(wheelEvent);
- result = noErr;
- }
- }
- }
- break ;
- default :
- break ;
- }
- }
-
- return result ;
-
-
-}
-static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
- OSStatus err = noErr ;
-
- UInt32 attributes;
- WindowRef windowRef ;
- wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
-
- GetEventParameter( event, kEventParamDirectObject, typeWindowRef, NULL,
- sizeof( WindowRef ), NULL, &windowRef );
-
- switch( GetEventKind( event ) )
- {
- case kEventWindowUpdate :
- if ( !wxPendingDelete.Member(toplevelWindow) )
- toplevelWindow->MacUpdate( EventTimeToTicks( GetEventTime( event ) ) ) ;
- result = noErr ;
- break ;
- case kEventWindowActivated :
- toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , true) ;
- result = noErr ;
- break ;
- case kEventWindowDeactivated :
- toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , false) ;
- result = noErr ;
- break ;
- case kEventWindowShown :
- toplevelWindow->Refresh() ;
- result = noErr ;
- break ;
- case kEventWindowClose :
- toplevelWindow->Close() ;
- result = noErr ;
- break ;
- case kEventWindowBoundsChanged :
- err = GetEventParameter( event, kEventParamAttributes, typeUInt32,
- NULL, sizeof( UInt32 ), NULL, &attributes );
- if ( err == noErr )
- {
- Rect newContentRect ;
-
- GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL,
- sizeof( newContentRect ), NULL, &newContentRect );
-
- toplevelWindow->SetSize( newContentRect.left , newContentRect.top ,
- newContentRect.right - newContentRect.left ,
- newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING);
-
- result = noErr;
- }
- break ;
- case kEventWindowBoundsChanging :
- err = GetEventParameter( event, kEventParamAttributes, typeUInt32,
- NULL, sizeof( UInt32 ), NULL, &attributes );
- if ( err == noErr )
- {
- Rect newContentRect ;
-
- GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL,
- sizeof( newContentRect ), NULL, &newContentRect );
-
- wxSize formerSize = toplevelWindow->GetSize() ;
-
- if ( (attributes & kWindowBoundsChangeSizeChanged ) ||
- ( attributes & kWindowBoundsChangeOriginChanged ) )
- toplevelWindow->SetSize( newContentRect.left , newContentRect.top ,
- newContentRect.right - newContentRect.left ,
- newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING);
-
- int x , y , w , h ;
- toplevelWindow->GetPosition( &x , &y ) ;
- toplevelWindow->GetSize( &w , &h ) ;
- Rect adjustedRect = { y , x , y + h , x + w } ;
-
- if ( !EqualRect( &newContentRect , &adjustedRect ) )
- {
- SetEventParameter( event , kEventParamCurrentBounds , typeQDRectangle, sizeof( adjustedRect ) , &adjustedRect ) ;
- }
-
- if ( toplevelWindow->GetSize() != formerSize )
- toplevelWindow->Update() ;
-
- result = noErr ;
- }
- break ;
- default :
- break ;
- }
- return result ;
-}
-
-pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- switch ( GetEventClass( event ) )
- {
- case kEventClassKeyboard :
- result = KeyboardEventHandler( handler, event , data ) ;
- break ;
- case kEventClassTextInput :
- result = TextInputEventHandler( handler, event , data ) ;
- break ;
- case kEventClassWindow :
- result = WindowEventHandler( handler, event , data ) ;
- break ;
- case kEventClassMouse :
- result = MouseEventHandler( handler, event , data ) ;
- break ;
- default :
- break ;
- }
- return result ;
-}
-
-DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
-
-#endif
-
-// ---------------------------------------------------------------------------
-// wxWindowMac utility functions
-// ---------------------------------------------------------------------------
-
-// Find an item given the Macintosh Window Reference
-
-wxList *wxWinMacWindowList = NULL;
-wxTopLevelWindowMac *wxFindWinFromMacWindow(WXWindow inWindowRef)
-{
- if ( wxWinMacWindowList == NULL )
- return NULL ;
- wxNode *node = wxWinMacWindowList->Find((long)inWindowRef);
- if (!node)
- return NULL;
- return (wxTopLevelWindowMac *)node->GetData();
-}
-
-void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win);
-void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win)
-{
- // adding NULL WindowRef is (first) surely a result of an error and
- // (secondly) breaks menu command processing
- wxCHECK_RET( inWindowRef != (WindowRef) NULL, wxT("attempt to add a NULL WindowRef to window list") );
-
- if ( !wxWinMacWindowList->Find((long)inWindowRef) )
- wxWinMacWindowList->Append((long)inWindowRef, win);
-}
-
-void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win)
-{
- wxWinMacWindowList->DeleteObject(win);
-}
-
-
-// ----------------------------------------------------------------------------
-// wxTopLevelWindowMac creation
-// ----------------------------------------------------------------------------
-
-WXWindow wxTopLevelWindowMac::s_macWindowInUpdate = NULL;
-wxTopLevelWindowMac *wxTopLevelWindowMac::s_macDeactivateWindow = NULL;
-bool wxTopLevelWindowMac::s_macWindowCompositing = false;
-
-void wxTopLevelWindowMac::Init()
-{
- m_iconized =
- m_maximizeOnShow = false;
- m_macNoEraseUpdateRgn = NewRgn() ;
- m_macNeedsErasing = false ;
- m_macWindow = NULL ;
- m_macUsesCompositing = false ;
-#if TARGET_CARBON
- m_macEventHandler = NULL ;
-#endif
-}
-
-class wxMacDeferredWindowDeleter : public wxObject
-{
-public :
- wxMacDeferredWindowDeleter( WindowRef windowRef )
- {
- m_macWindow = windowRef ;
- }
- virtual ~wxMacDeferredWindowDeleter()
- {
- UMADisposeWindow( (WindowRef) m_macWindow ) ;
- }
- protected :
- WindowRef m_macWindow ;
-} ;
-
-bool wxTopLevelWindowMac::Create(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- // init our fields
- Init();
-
- m_windowStyle = style;
-
- SetName(name);
-
- m_windowId = id == -1 ? NewControlId() : id;
-
- wxTopLevelWindows.Append(this);
-
- if ( parent )
- parent->AddChild(this);
-
- return true;
-}
-
-wxTopLevelWindowMac::~wxTopLevelWindowMac()
-{
- if ( m_macWindow )
- {
- wxToolTip::NotifyWindowDelete(m_macWindow) ;
- wxPendingDelete.Append( new wxMacDeferredWindowDeleter( (WindowRef) m_macWindow ) ) ;
- }
-
-#if TARGET_CARBON
- if ( m_macEventHandler )
- {
- ::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
- m_macEventHandler = NULL ;
- }
-#endif
-
- wxRemoveMacWindowAssociation( this ) ;
-
- if ( wxModelessWindows.Find(this) )
- wxModelessWindows.DeleteObject(this);
-
- DisposeRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ;
-}
-
-
-// ----------------------------------------------------------------------------
-// wxTopLevelWindowMac maximize/minimize
-// ----------------------------------------------------------------------------
-
-void wxTopLevelWindowMac::Maximize(bool maximize)
-{
- wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
- wxMacWindowClipper clip (this);
- ZoomWindow( (WindowRef)m_macWindow , maximize ? inZoomOut : inZoomIn , false ) ;
-
- Rect tempRect ;
- GrafPtr port ;
- GetPort( &port ) ;
- Point pt = { 0, 0 } ;
- SetPortWindowPort((WindowRef)m_macWindow) ;
- LocalToGlobal( &pt ) ;
- SetPort( port ) ;
-
- GetWindowPortBounds((WindowRef)m_macWindow, &tempRect ) ;
- SetSize( pt.h , pt.v , tempRect.right-tempRect.left ,
- tempRect.bottom-tempRect.top, wxSIZE_USE_EXISTING);
-}
-
-bool wxTopLevelWindowMac::IsMaximized() const
-{
- return IsWindowInStandardState( (WindowRef)m_macWindow , NULL , NULL ) ;
-}
-
-void wxTopLevelWindowMac::Iconize(bool iconize)
-{
- if ( IsWindowCollapsable((WindowRef)m_macWindow) )
- CollapseWindow((WindowRef)m_macWindow , iconize ) ;
-}
-
-bool wxTopLevelWindowMac::IsIconized() const
-{
- return IsWindowCollapsed((WindowRef)m_macWindow ) ;
-}
-
-void wxTopLevelWindowMac::Restore()
-{
- // not available on mac
-}
-
-// ----------------------------------------------------------------------------
-// wxTopLevelWindowMac misc
-// ----------------------------------------------------------------------------
-
-void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
-{
- // this sets m_icon
- wxTopLevelWindowBase::SetIcon(icon);
-}
-
-void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name )
-{
- OSStatus err = noErr ;
- SetName(name);
- m_windowStyle = style;
- m_isShown = false;
-
- // create frame.
-
- Rect theBoundsRect;
-
- m_x = (int)pos.x;
- m_y = (int)pos.y;
- if ( m_y < 50 )
- m_y = 50 ;
- if ( m_x < 20 )
- m_x = 20 ;
-
- m_width = WidthDefault(size.x);
- m_height = HeightDefault(size.y);
-
- ::SetRect(&theBoundsRect, m_x, m_y , m_x + m_width, m_y + m_height);
-
- // translate the window attributes in the appropriate window class and attributes
-
- WindowClass wclass = 0;
- WindowAttributes attr = kWindowNoAttributes ;
-
- if ( HasFlag( wxFRAME_TOOL_WINDOW) )
- {
- if (
- HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||
- HasFlag( wxSYSTEM_MENU ) || HasFlag( wxCAPTION ) ||
- HasFlag(wxTINY_CAPTION_HORIZ) || HasFlag(wxTINY_CAPTION_VERT)
- )
- {
- wclass = kFloatingWindowClass ;
- if ( HasFlag(wxTINY_CAPTION_VERT) )
- {
- attr |= kWindowSideTitlebarAttribute ;
- }
- }
- else
- {
-#if TARGET_CARBON
- wclass = kPlainWindowClass ;
-#else
- wclass = kFloatingWindowClass ;
-#endif
- }
- }
- else if ( HasFlag( wxCAPTION ) )
- {
- wclass = kDocumentWindowClass ;
- }
- else
- {
- if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||
- HasFlag( wxCLOSE_BOX ) || HasFlag( wxSYSTEM_MENU ) )
- {
- wclass = kDocumentWindowClass ;
- }
- else
- {
-#if TARGET_CARBON
- wclass = kPlainWindowClass ;
-#else
- wclass = kModalWindowClass ;
-#endif
- }
- }
-
- if ( HasFlag( wxMINIMIZE_BOX ) )
- {
- attr |= kWindowCollapseBoxAttribute ;
- }
- if ( HasFlag( wxMAXIMIZE_BOX ) )
- {
- attr |= kWindowFullZoomAttribute ;
- }
- if ( HasFlag( wxRESIZE_BORDER ) )
- {
- attr |= kWindowResizableAttribute ;
- }
- if ( HasFlag( wxCLOSE_BOX) )
- {
- attr |= kWindowCloseBoxAttribute ;
- }
-
- if (UMAGetSystemVersion() >= 0x1000)
- {
- //turn on live resizing (OS X only)
- attr |= kWindowLiveResizeAttribute;
- }
-
-#if TARGET_CARBON
-#if 0 // having problems right now with that
- if (HasFlag(wxSTAY_ON_TOP))
- wclass = kUtilityWindowClass;
-#endif
-#endif
-
- //this setup lets us have compositing and non-compositing
- //windows in the same application.
-
-#if UNIVERSAL_INTERFACES_VERSION >= 0x0400
- if ( wxTopLevelWindowMac::s_macWindowCompositing )
- {
- attr |= kWindowCompositingAttribute;
- m_macUsesCompositing = true;
- }
- else
-#endif
- {
- m_macUsesCompositing = false;
- }
-
-#if TARGET_CARBON
- if ( HasFlag(wxFRAME_SHAPED) )
- {
- WindowDefSpec customWindowDefSpec;
- customWindowDefSpec.defType = kWindowDefProcPtr;
- customWindowDefSpec.u.defProc = NewWindowDefUPP(wxShapedMacWindowDef);
-
- err = ::CreateCustomWindow( &customWindowDefSpec, wclass,
- attr, &theBoundsRect,
- (WindowRef*) &m_macWindow);
- }
- else
-#endif
- {
- err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
- }
-
- wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") );
- wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ;
- UMASetWTitle( (WindowRef)m_macWindow , title , m_font.GetEncoding() ) ;
- if ( wxTopLevelWindowMac::s_macWindowCompositing )
- {
- ::GetRootControl( (WindowRef)m_macWindow, (ControlHandle*)&m_macRootControl ) ;
- }
- else
- {
- ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ;
- }
-#if TARGET_CARBON
- InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
- InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(),
- GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler);
-#endif
- m_macFocus = NULL ;
-
-
-#if TARGET_CARBON
- if ( HasFlag(wxFRAME_SHAPED) )
- {
- // default shape matches the window size
- wxRegion rgn(0, 0, m_width, m_height);
- SetShape(rgn);
- }
-#endif
-
- wxWindowCreateEvent event(this);
- GetEventHandler()->ProcessEvent(event);
-}
-
-bool wxTopLevelWindowMac::MacEnableCompositing( bool useCompositing )
-{
- bool oldval = s_macWindowCompositing;
- s_macWindowCompositing = useCompositing;
- return oldval;
-}
-
-void wxTopLevelWindowMac::MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR clipRect, WXWindow *window , wxWindowMac** rootwin)
-{
- ((Point*)localOrigin)->h = 0;
- ((Point*)localOrigin)->v = 0;
- ((Rect*)clipRect)->left = 0;
- ((Rect*)clipRect)->top = 0;
- ((Rect*)clipRect)->right = m_width;
- ((Rect*)clipRect)->bottom = m_height;
- *window = m_macWindow ;
- *rootwin = this ;
-}
-
-void wxTopLevelWindowMac::ClearBackground()
-{
- wxWindow::ClearBackground() ;
-}
-
-WXWidget wxTopLevelWindowMac::MacGetContainerForEmbedding()
-{
- return m_macRootControl ;
-}
-
-
-void wxTopLevelWindowMac::MacUpdate( long timestamp)
-{
- wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
-
- RgnHandle visRgn = NewRgn() ;
- GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), visRgn );
- BeginUpdate( (WindowRef)m_macWindow ) ;
-
- RgnHandle updateRgn = NewRgn();
- RgnHandle diffRgn = NewRgn() ;
-
- if ( updateRgn && diffRgn )
- {
-#if 1
- // macos internal control redraws clean up areas we'd like to redraw ourselves
- // therefore we pick the boundary rect and make sure we can redraw it
- // this has to be intersected by the visRgn in order to avoid drawing over its own
- // boundaries
- RgnHandle trueUpdateRgn = NewRgn() ;
- Rect trueUpdateRgnBoundary ;
- GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), trueUpdateRgn );
- GetRegionBounds( trueUpdateRgn , &trueUpdateRgnBoundary ) ;
- RectRgn( updateRgn , &trueUpdateRgnBoundary ) ;
- SectRgn( updateRgn , visRgn , updateRgn ) ;
- if ( trueUpdateRgn )
- DisposeRgn( trueUpdateRgn ) ;
- SetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn ) ;
-#else
- GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn );
-#endif
- DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ;
- if ( !EmptyRgn( updateRgn ) )
- {
- MacRedraw( updateRgn , timestamp , m_macNeedsErasing || !EmptyRgn( diffRgn ) ) ;
- }
- }
- if ( updateRgn )
- DisposeRgn( updateRgn );
- if ( diffRgn )
- DisposeRgn( diffRgn );
- if ( visRgn )
- DisposeRgn( visRgn ) ;
-
- EndUpdate( (WindowRef)m_macWindow ) ;
- SetEmptyRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ;
- m_macNeedsErasing = false ;
-}
-
-
-// Raise the window to the top of the Z order
-void wxTopLevelWindowMac::Raise()
-{
- ::SelectWindow( (WindowRef)m_macWindow ) ;
-}
-
-// Lower the window to the bottom of the Z order
-void wxTopLevelWindowMac::Lower()
-{
- ::SendBehind( (WindowRef)m_macWindow , NULL ) ;
-}
-
-void wxTopLevelWindowMac::MacFireMouseEvent(
- wxUint16 kind , wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp )
-{
- wxMouseEvent event(wxEVT_LEFT_DOWN);
- bool isDown = !(modifiers & btnState) ; // 1 is for up
- bool controlDown = modifiers & controlKey ; // for simulating right mouse
-
- event.m_leftDown = isDown && !controlDown;
-
- event.m_middleDown = false;
- event.m_rightDown = isDown && controlDown;
-
- if ( kind == mouseDown )
- {
- if ( controlDown )
- event.SetEventType(wxEVT_RIGHT_DOWN ) ;
- else
- event.SetEventType(wxEVT_LEFT_DOWN ) ;
- }
- else if ( kind == mouseUp )
- {
- if ( controlDown )
- event.SetEventType(wxEVT_RIGHT_UP ) ;
- else
- event.SetEventType(wxEVT_LEFT_UP ) ;
- }
- else
- {
- event.SetEventType(wxEVT_MOTION ) ;
- }
-
- event.m_shiftDown = modifiers & shiftKey;
- event.m_controlDown = modifiers & controlKey;
- event.m_altDown = modifiers & optionKey;
- event.m_metaDown = modifiers & cmdKey;
-
- Point localwhere ;
- localwhere.h = x ;
- localwhere.v = y ;
-
- GrafPtr port ;
- ::GetPort( &port ) ;
- ::SetPort( UMAGetWindowPort( (WindowRef)m_macWindow ) ) ;
- ::GlobalToLocal( &localwhere ) ;
- ::SetPort( port ) ;
-
- if ( kind == mouseDown )
- {
- if ( timestamp - gs_lastWhen <= (long) GetDblTime() )
- {
- if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 )
- {
- // This is not right if the second mouse down
- // event occurred in a different window. We
- // correct this in MacDispatchMouseEvent.
- if ( controlDown )
- event.SetEventType(wxEVT_RIGHT_DCLICK ) ;
- else
- event.SetEventType(wxEVT_LEFT_DCLICK ) ;
- }
- gs_lastWhen = 0 ;
- }
- else
- {
- gs_lastWhen = timestamp ;
- }
- gs_lastWhere = localwhere ;
- }
-
- event.m_x = localwhere.h;
- event.m_y = localwhere.v;
- event.m_x += m_x;
- event.m_y += m_y;
-
- event.SetTimestamp(timestamp);
- event.SetEventObject(this);
- if ( wxTheApp->s_captureWindow )
- {
- int x = event.m_x ;
- int y = event.m_y ;
- wxTheApp->s_captureWindow->ScreenToClient( &x , &y ) ;
- event.m_x = x ;
- event.m_y = y ;
- event.SetEventObject( wxTheApp->s_captureWindow ) ;
- wxTheApp->s_captureWindow->GetEventHandler()->ProcessEvent( event ) ;
-
- if ( kind == mouseUp )
- {
- wxTheApp->s_captureWindow = NULL ;
- if ( !wxIsBusy() )
- {
- m_cursor.MacInstall() ;
- }
- }
- }
- else
- {
- MacDispatchMouseEvent( event ) ;
- }
-}
-
-#if !TARGET_CARBON
-
-void wxTopLevelWindowMac::MacMouseDown( WXEVENTREF ev , short part)
-{
- MacFireMouseEvent( mouseDown , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v ,
- ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ;
-}
-
-void wxTopLevelWindowMac::MacMouseUp( WXEVENTREF ev , short part)
-{
- switch (part)
- {
- case inContent:
- {
- MacFireMouseEvent( mouseUp , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v ,
- ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ;
- }
- break ;
- }
-}
-
-void wxTopLevelWindowMac::MacMouseMoved( WXEVENTREF ev , short part)
-{
- switch (part)
- {
- case inContent:
- {
- MacFireMouseEvent( nullEvent /*moved*/ , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v ,
- ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ;
- }
- break ;
- }
-}
-
-#endif
-
-void wxTopLevelWindowMac::MacDelayedDeactivation(long timestamp)
-{
- if(s_macDeactivateWindow)
- {
- wxLogDebug(wxT("Doing delayed deactivation of %p"),s_macDeactivateWindow);
- s_macDeactivateWindow->MacActivate(timestamp, false);
- }
-}
-
-void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating )
-{
- // wxLogDebug(wxT("TopLevel=%p::MacActivate"),this);
-
- if(s_macDeactivateWindow==this)
- s_macDeactivateWindow=NULL;
- MacDelayedDeactivation(timestamp);
- wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
- event.SetTimestamp(timestamp);
- event.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(event);
-
- UMAHighlightAndActivateWindow( (WindowRef)m_macWindow , inIsActivating ) ;
-
- // Early versions of MacOS X don't refresh backgrounds properly,
- // so refresh the whole window on activation and deactivation.
- long osVersion = UMAGetSystemVersion();
- if (osVersion >= 0x1000 && osVersion < 0x1020 )
- {
- Refresh(true);
- }
- else
- {
- // for the moment we have to resolve some redrawing issues like this
- // the OS is stealing some redrawing areas as soon as it draws a control
- Refresh(true);
- }
-}
-
-#if !TARGET_CARBON
-
-void wxTopLevelWindowMac::MacKeyDown( WXEVENTREF ev )
-{
-}
-
-#endif
-
-void wxTopLevelWindowMac::SetTitle(const wxString& title)
-{
- wxWindow::SetLabel( title ) ;
- UMASetWTitle( (WindowRef)m_macWindow , title , m_font.GetEncoding() ) ;
-}
-
-wxString wxTopLevelWindowMac::GetTitle() const
-{
- return wxWindow::GetLabel();
-}
-
-bool wxTopLevelWindowMac::Show(bool show)
-{
- if ( !wxWindow::Show(show) )
- return false;
-
- if (show)
- {
- #if wxUSE_SYSTEM_OPTIONS //code contributed by Ryan Wilcox December 18, 2003
- if ( (wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) ) && ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1) )
- {
- ::ShowWindow( (WindowRef)m_macWindow );
- }
- else
- #endif
- {
- ::TransitionWindow((WindowRef)m_macWindow,kWindowZoomTransitionEffect,kWindowShowTransitionAction,nil);
- }
- ::SelectWindow( (WindowRef)m_macWindow ) ;
- // no need to generate events here, they will get them triggered by macos
- // actually they should be , but apparently they are not
- wxSize size(m_width, m_height);
- wxSizeEvent event(size, m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
- }
- else
- {
- #if wxUSE_SYSTEM_OPTIONS
- if ( (wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) ) && ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1) )
- {
- ::HideWindow((WindowRef) m_macWindow );
- }
- else
- #endif
- {
- ::TransitionWindow((WindowRef)m_macWindow,kWindowZoomTransitionEffect,kWindowHideTransitionAction,nil);
- }
- }
-
- if ( !show )
- {
- }
- else
- {
- Refresh() ;
- }
-
- return true;
-}
-
-void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height)
-{
- wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
- wxMacWindowClipper clip (this);
-
- int former_x = m_x ;
- int former_y = m_y ;
- int former_w = m_width ;
- int former_h = m_height ;
-
- int actualWidth = width;
- int actualHeight = height;
- int actualX = x;
- int actualY = y;
-
- if ((m_minWidth != -1) && (actualWidth < m_minWidth))
- actualWidth = m_minWidth;
- if ((m_minHeight != -1) && (actualHeight < m_minHeight))
- actualHeight = m_minHeight;
- if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
- actualWidth = m_maxWidth;
- if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
- actualHeight = m_maxHeight;
-
- bool doMove = false ;
- bool doResize = false ;
-
- if ( actualX != former_x || actualY != former_y )
- {
- doMove = true ;
- }
- if ( actualWidth != former_w || actualHeight != former_h )
- {
- doResize = true ;
- }
-
- if ( doMove || doResize )
- {
- m_x = actualX ;
- m_y = actualY ;
-
- if ( doMove )
- ::MoveWindow((WindowRef)m_macWindow, m_x, m_y , false); // don't make frontmost
-
- m_width = actualWidth ;
- m_height = actualHeight ;
-
- if ( doResize )
- ::SizeWindow((WindowRef)m_macWindow, m_width, m_height , true);
-
- // the OS takes care of invalidating and erasing the new area so we only have to
- // take care of refreshing for full repaints
-
- if ( doResize && HasFlag(wxFULL_REPAINT_ON_RESIZE) )
- Refresh() ;
-
-
- if ( IsKindOf( CLASSINFO( wxFrame ) ) )
- {
- wxFrame* frame = (wxFrame*) this ;
-#if wxUSE_STATUSBAR
- frame->PositionStatusBar();
-#endif
-#if wxUSE_TOOLBAR
- frame->PositionToolBar();
-#endif
- }
- if ( doMove )
- wxWindowMac::MacTopLevelWindowChangedPosition() ; // like this only children will be notified
-
- MacRepositionScrollBars() ;
- if ( doMove )
- {
- wxPoint point(m_x, m_y);
- wxMoveEvent event(point, m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event) ;
- }
- if ( doResize )
- {
- MacRepositionScrollBars() ;
- wxSize size(m_width, m_height);
- wxSizeEvent event(size, m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
- }
- }
-
-}
-
-/*
- * Invalidation Mechanism
- *
- * The update mechanism reflects exactely the windows mechanism
- * the rect gets added to the window invalidate region, if the eraseBackground flag
- * has been true for any part of the update rgn the background is erased in the entire region
- * not just in the specified rect.
- *
- * In order to achive this, we also have an internal m_macNoEraseUpdateRgn, all rects that have
- * the eraseBackground flag set to false are also added to this rgn. upon receiving an update event
- * the update rgn is compared to the m_macNoEraseUpdateRgn and in case they differ, every window
- * will get the eraseBackground event first
- */
-
-void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackground )
-{
- GrafPtr formerPort ;
- GetPort( &formerPort ) ;
- SetPortWindowPort( (WindowRef)m_macWindow ) ;
-
- m_macNeedsErasing |= eraseBackground ;
-
- // if we already know that we will have to erase, there's no need to track the rest
- if ( !m_macNeedsErasing)
- {
- // we end only here if eraseBackground is false
- // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn
- // we will have to erase anyway
-
- RgnHandle updateRgn = NewRgn();
- RgnHandle diffRgn = NewRgn() ;
- if ( updateRgn && diffRgn )
- {
- GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn );
- Point pt = {0,0} ;
- LocalToGlobal( &pt ) ;
- OffsetRgn( updateRgn , -pt.h , -pt.v ) ;
- DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ;
- if ( !EmptyRgn( diffRgn ) )
- {
- m_macNeedsErasing = true ;
- }
- }
- if ( updateRgn )
- DisposeRgn( updateRgn );
- if ( diffRgn )
- DisposeRgn( diffRgn );
-
- if ( !m_macNeedsErasing )
- {
- RgnHandle rectRgn = NewRgn() ;
- SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ;
- UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ;
- DisposeRgn( rectRgn ) ;
- }
- }
- InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ;
- // turn this on to debug the refreshing cycle
-#if wxMAC_DEBUG_REDRAW
- PaintRect( rect ) ;
-#endif
- SetPort( formerPort ) ;
-}
-
-
-bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
-{
- wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
- _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
-
-#if TARGET_CARBON
- // The empty region signifies that the shape should be removed from the
- // window.
- if ( region.IsEmpty() )
- {
- wxSize sz = GetClientSize();
- wxRegion rgn(0, 0, sz.x, sz.y);
- return SetShape(rgn);
- }
-
- // Make a copy of the region
- RgnHandle shapeRegion = NewRgn();
- CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );
-
- // Dispose of any shape region we may already have
- RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)MacGetWindowRef() );
- if ( oldRgn )
- DisposeRgn(oldRgn);
-
- // Save the region so we can use it later
- SetWRefCon((WindowRef)MacGetWindowRef(), (SInt32)shapeRegion);
-
- // Tell the window manager that the window has changed shape
- ReshapeCustomWindow((WindowRef)MacGetWindowRef());
- return true;
-#else
- return false;
-#endif
-}
-
-// ---------------------------------------------------------------------------
-// Support functions for shaped windows, based on Apple's CustomWindow sample at
-// http://developer.apple.com/samplecode/Sample_Code/Human_Interface_Toolbox/Mac_OS_High_Level_Toolbox/CustomWindow.htm
-// ---------------------------------------------------------------------------
-
-#if TARGET_CARBON
-
-static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect)
-{
- GetWindowPortBounds(window, inRect);
- Point pt = {inRect->left, inRect->top};
- SetPort((GrafPtr) GetWindowPort(window));
- LocalToGlobal(&pt);
- inRect->top = pt.v;
- inRect->left = pt.h;
- inRect->bottom += pt.v;
- inRect->right += pt.h;
-}
-
-
-static SInt32 wxShapedMacWindowGetFeatures(WindowRef window, SInt32 param)
-{
- /*------------------------------------------------------
- Define which options your custom window supports.
- --------------------------------------------------------*/
- //just enable everything for our demo
- *(OptionBits*)param=//kWindowCanGrow|
- //kWindowCanZoom|
- //kWindowCanCollapse|
- //kWindowCanGetWindowRegion|
- //kWindowHasTitleBar|
- //kWindowSupportsDragHilite|
- kWindowCanDrawInCurrentPort|
- //kWindowCanMeasureTitle|
- kWindowWantsDisposeAtProcessDeath|
- kWindowSupportsSetGrowImageRegion|
- kWindowDefSupportsColorGrafPort;
- return 1;
-}
-
-// The content region is left as a rectangle matching the window size, this is
-// so the origin in the paint event, and etc. still matches what the
-// programmer expects.
-static void wxShapedMacWindowContentRegion(WindowRef window, RgnHandle rgn)
-{
- SetEmptyRgn(rgn);
- wxTopLevelWindowMac* win = wxFindWinFromMacWindow(window);
- if (win)
- {
- wxRect r = win->GetRect();
- SetRectRgn(rgn, r.GetLeft(), r.GetTop(), r.GetRight(), r.GetBottom());
- }
-}
-
-// The structure region is set to the shape given to the SetShape method.
-static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn)
-{
- RgnHandle cachedRegion = (RgnHandle) GetWRefCon(window);
-
- SetEmptyRgn(rgn);
- if (cachedRegion)
- {
- Rect windowRect;
- wxShapedMacWindowGetPos(window, &windowRect); //how big is the window
- CopyRgn(cachedRegion, rgn); //make a copy of our cached region
- OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window
- //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size
- }
-}
-
-
-
-static SInt32 wxShapedMacWindowGetRegion(WindowRef window, SInt32 param)
-{
- GetWindowRegionPtr rgnRec=(GetWindowRegionPtr)param;
-
- switch(rgnRec->regionCode)
- {
- case kWindowStructureRgn:
- wxShapedMacWindowStructureRegion(window, rgnRec->winRgn);
- break;
- case kWindowContentRgn:
- wxShapedMacWindowContentRegion(window, rgnRec->winRgn);
- break;
- default:
- SetEmptyRgn(rgnRec->winRgn);
- } //switch
-
- return noErr;
-}
-
-
-static SInt32 wxShapedMacWindowHitTest(WindowRef window,SInt32 param)
-{
- /*------------------------------------------------------
- Determine the region of the window which was hit
- --------------------------------------------------------*/
- Point hitPoint;
- static RgnHandle tempRgn=nil;
-
- if(!tempRgn)
- tempRgn=NewRgn();
-
- SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked
-
- //Mac OS 8.5 or later
- wxShapedMacWindowStructureRegion(window, tempRgn);
- if (PtInRgn(hitPoint, tempRgn)) //in window content region?
- return wInContent;
-
- return wNoHit;//no significant area was hit.
-}
-
-
-static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param)
-{
- switch(message)
- {
- case kWindowMsgHitTest:
- return wxShapedMacWindowHitTest(window,param);
-
- case kWindowMsgGetFeatures:
- return wxShapedMacWindowGetFeatures(window,param);
-
- // kWindowMsgGetRegion is sent during CreateCustomWindow and ReshapeCustomWindow
- case kWindowMsgGetRegion:
- return wxShapedMacWindowGetRegion(window,param);
- }
-
- return 0;
-}
-
-#endif
-// ---------------------------------------------------------------------------
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/treectrl.cpp
-// Purpose: wxTreeCtrl. See also Robert's generic wxTreeCtrl.
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/stubs/textctrl.h"
-#include "wx/treebase.h"
-#include "wx/stubs/treectrl.h"
-
-IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
-
-wxTreeCtrl::wxTreeCtrl()
-{
- m_imageListNormal = NULL;
- m_imageListState = NULL;
- m_textCtrl = NULL;
-}
-
-bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
- long style, const wxValidator& validator, const wxString& name)
-{
- SetName(name);
- SetValidator(validator);
-
- m_imageListNormal = NULL;
- m_imageListState = NULL;
- m_textCtrl = NULL;
-
- m_windowStyle = style;
-
- SetParent(parent);
-
- m_windowId = (id == wxID_ANY) ? NewControlId() : id;
-
- if (parent) parent->AddChild(this);
-
- // TODO create tree control
-
- return false;
-}
-
-wxTreeCtrl::~wxTreeCtrl()
-{
- if (m_textCtrl)
- {
- delete m_textCtrl;
- }
-}
-
-// Attributes
-unsigned int wxTreeCtrl::GetCount() const
-{
- // TODO
- return 0;
-}
-
-int wxTreeCtrl::GetIndent() const
-{
- // TODO
- return 0;
-}
-
-void wxTreeCtrl::SetIndent(int indent)
-{
- // TODO
-}
-
-wxImageList *wxTreeCtrl::GetImageList(int which) const
-{
- if ( which == wxIMAGE_LIST_NORMAL )
- {
- return m_imageListNormal;
- }
- else if ( which == wxIMAGE_LIST_STATE )
- {
- return m_imageListState;
- }
- return NULL;
-}
-
-void wxTreeCtrl::SetImageList(wxImageList *imageList, int which)
-{
- if ( which == wxIMAGE_LIST_NORMAL )
- {
- m_imageListNormal = imageList;
- }
- else if ( which == wxIMAGE_LIST_STATE )
- {
- m_imageListState = imageList;
- }
- // TODO
-}
-
-long wxTreeCtrl::GetNextItem(long item, int code) const
-{
- // TODO
- return 0;
-}
-
-bool wxTreeCtrl::ItemHasChildren(long item) const
-{
- // TODO
- return false;
-}
-
-long wxTreeCtrl::GetChild(long item) const
-{
- // TODO
- return 0;
-}
-
-long wxTreeCtrl::GetItemParent(long item) const
-{
- // TODO
- return 0;
-}
-
-long wxTreeCtrl::GetFirstVisibleItem() const
-{
- // TODO
- return 0;
-}
-
-long wxTreeCtrl::GetNextVisibleItem(long item) const
-{
- // TODO
- return 0;
-}
-
-long wxTreeCtrl::GetSelection() const
-{
- // TODO
- return 0;
-}
-
-long wxTreeCtrl::GetRootItem() const
-{
- // TODO
- return 0;
-}
-
-bool wxTreeCtrl::GetItem(wxTreeItem& info) const
-{
- // TODO
- return false;
-}
-
-bool wxTreeCtrl::SetItem(wxTreeItem& info)
-{
- // TODO
- return false;
-}
-
-int wxTreeCtrl::GetItemState(long item, long stateMask) const
-{
- wxTreeItem info;
-
- info.m_mask = wxTREE_MASK_STATE ;
- info.m_stateMask = stateMask;
- info.m_itemId = item;
-
- if (!GetItem(info))
- return 0;
-
- return info.m_state;
-}
-
-bool wxTreeCtrl::SetItemState(long item, long state, long stateMask)
-{
- wxTreeItem info;
-
- info.m_mask = wxTREE_MASK_STATE ;
- info.m_state = state;
- info.m_stateMask = stateMask;
- info.m_itemId = item;
-
- return SetItem(info);
-}
-
-bool wxTreeCtrl::SetItemImage(long item, int image, int selImage)
-{
- wxTreeItem info;
-
- info.m_mask = wxTREE_MASK_IMAGE ;
- info.m_image = image;
- if ( selImage > -1)
- {
- info.m_selectedImage = selImage;
- info.m_mask |= wxTREE_MASK_SELECTED_IMAGE;
- }
- info.m_itemId = item;
-
- return SetItem(info);
-}
-
-wxString wxTreeCtrl::GetItemText(long item) const
-{
- wxTreeItem info;
-
- info.m_mask = wxTREE_MASK_TEXT ;
- info.m_itemId = item;
-
- if (!GetItem(info))
- return wxEmptyString;
- return info.m_text;
-}
-
-void wxTreeCtrl::SetItemText(long item, const wxString& str)
-{
- wxTreeItem info;
-
- info.m_mask = wxTREE_MASK_TEXT ;
- info.m_itemId = item;
- info.m_text = str;
-
- SetItem(info);
-}
-
-long wxTreeCtrl::GetItemData(long item) const
-{
- wxTreeItem info;
-
- info.m_mask = wxTREE_MASK_DATA ;
- info.m_itemId = item;
-
- if (!GetItem(info))
- return 0;
- return info.m_data;
-}
-
-bool wxTreeCtrl::SetItemData(long item, long data)
-{
- wxTreeItem info;
-
- info.m_mask = wxTREE_MASK_DATA ;
- info.m_itemId = item;
- info.m_data = data;
-
- return SetItem(info);
-}
-
-bool wxTreeCtrl::GetItemRect(long item, wxRect& rect, bool textOnly) const
-{
- // TODO
- return false;
-}
-
-wxTextCtrl* wxTreeCtrl::GetEditControl() const
-{
- return m_textCtrl;
-}
-
-// Operations
-bool wxTreeCtrl::DeleteItem(long item)
-{
- // TODO
- return false;
-}
-
-bool wxTreeCtrl::ExpandItem(long item, int action)
-{
- // TODO
- switch ( action )
- {
- case wxTREE_EXPAND_EXPAND:
- break;
-
- case wxTREE_EXPAND_COLLAPSE:
- break;
-
- case wxTREE_EXPAND_COLLAPSE_RESET:
- break;
-
- case wxTREE_EXPAND_TOGGLE:
- break;
-
- default:
- wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem");
- }
-
- bool bOk = false; // TODO expand item
-
- // May not send messages, so emulate them
- if ( bOk ) {
- wxTreeEvent event(wxEVT_NULL, m_windowId);
- event.m_item.m_itemId = item;
- event.m_item.m_mask =
- event.m_item.m_stateMask = 0xffff; // get all
- GetItem(event.m_item);
-
- bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0;
-
- event.m_code = action;
- event.SetEventObject(this);
-
- // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded
- event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDING
- : wxEVT_COMMAND_TREE_ITEM_COLLAPSING);
- GetEventHandler()->ProcessEvent(event);
-
- event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDED
- : wxEVT_COMMAND_TREE_ITEM_COLLAPSED);
- GetEventHandler()->ProcessEvent(event);
- }
-
- return bOk;
-}
-
-long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter)
-{
- // TODO
- return 0;
-}
-
-long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image, int selImage,
- long insertAfter)
-{
- wxTreeItem info;
- info.m_text = label;
- info.m_mask = wxTREE_MASK_TEXT;
- if ( image > -1 )
- {
- info.m_mask |= wxTREE_MASK_IMAGE | wxTREE_MASK_SELECTED_IMAGE;
- info.m_image = image;
- if ( selImage == -1 )
- info.m_selectedImage = image;
- else
- info.m_selectedImage = selImage;
- }
-
- return InsertItem(parent, info, insertAfter);
-}
-
-bool wxTreeCtrl::SelectItem(long item)
-{
- // TODO
- return false;
-}
-
-bool wxTreeCtrl::ScrollTo(long item)
-{
- // TODO
- return false;
-}
-
-bool wxTreeCtrl::DeleteAllItems()
-{
- // TODO
- return false;
-}
-
-wxTextCtrl* wxTreeCtrl::EditLabel(long item, wxClassInfo* textControlClass)
-{
- // TODO
- return NULL;
-}
-
-// End label editing, optionally cancelling the edit
-bool wxTreeCtrl::EndEditLabel(bool cancel)
-{
- // TODO
- return false;
-}
-
-long wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
-{
- // TODO
- return 0;
-}
-
-bool wxTreeCtrl::SortChildren(long item)
-{
- // TODO
- return false;
-}
-
-bool wxTreeCtrl::EnsureVisible(long item)
-{
- // TODO
- return false;
-}
-
-// Tree item structure
-wxTreeItem::wxTreeItem()
-{
- m_mask = 0;
- m_itemId = 0;
- m_state = 0;
- m_stateMask = 0;
- m_image = -1;
- m_selectedImage = -1;
- m_children = 0;
- m_data = 0;
-}
-
-// Tree event
-IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent)
-
-wxTreeEvent::wxTreeEvent(wxEventType commandType, int id):
- wxCommandEvent(commandType, id)
-{
- m_code = 0;
- m_oldItem = 0;
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/uma.cpp
-// Purpose: UMA support
-// Author: Stefan Csomor
-// Modified by:
-// Created: 04/01/98
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: The wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#if wxUSE_GUI
-
-#include "wx/dc.h"
-#include <MacTextEditor.h>
-
-#ifndef __DARWIN__
-# include <Navigation.h>
-# if defined(TARGET_CARBON)
-# if PM_USE_SESSION_APIS
-# include <PMCore.h>
-# endif
-# include <PMApplication.h>
-# else
-# include <Printing.h>
-# endif
-#endif
-
-#ifndef __DARWIN__
-#include <Scrap.h>
-#endif
-#include "wx/mac/uma.h"
-
-
-// since we have decided that we only support 8.6 upwards we are
-// checking for these minimum requirements in the startup code of
-// the application so all wxWidgets code can safely assume that appearance 1.1
-// windows manager, control manager, navigation services etc. are
-// present
-
-static bool sUMAHasAppearance = false ;
-static long sUMAAppearanceVersion = 0 ;
-static long sUMASystemVersion = 0 ;
-static bool sUMAHasAquaLayout = false ;
-
-static bool sUMAHasInittedAppearance = false;
-
-extern int gAGABackgroundColor ;
-bool UMAHasAppearance() { return sUMAHasAppearance ; }
-long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; }
-long UMAGetSystemVersion() { return sUMASystemVersion ; }
-
-static bool sUMAHasWindowManager = false ;
-static long sUMAWindowManagerAttr = 0 ;
-
-bool UMAHasWindowManager() { return sUMAHasWindowManager ; }
-long UMAGetWindowManagerAttr() { return sUMAWindowManagerAttr ; }
-bool UMAHasAquaLayout() { return sUMAHasAquaLayout ; }
-
-
-void UMACleanupToolbox()
-{
- if (sUMAHasInittedAppearance)
- {
- UnregisterAppearanceClient() ;
- }
- if ( NavServicesAvailable() )
- {
- NavUnload() ;
- }
- if ( TXNTerminateTextension != (void*) kUnresolvedCFragSymbolAddress )
- TXNTerminateTextension( ) ;
-}
-void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded )
-{
-#if !TARGET_CARBON
- ::MaxApplZone();
- for (long i = 1; i <= inMoreMastersCalls; i++)
- ::MoreMasters();
-
- if (!isEmbedded)
- {
- ::InitGraf(&qd.thePort);
- ::InitFonts();
- ::InitMenus();
- ::TEInit();
- ::InitDialogs(0L);
- ::FlushEvents(everyEvent, 0);
- }
-
- long total,contig;
- PurgeSpace(&total, &contig);
-#endif
-
- ::InitCursor();
-
- if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr)
- sUMASystemVersion = 0x0000 ;
-
- long theAppearance ;
- if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
- {
- sUMAHasAppearance = true ;
- OSStatus status = RegisterAppearanceClient();
- // If status equals appearanceProcessRegisteredErr it means the
- // appearance client already was registered (For example if we run
- // embedded, the host might have registered it). In such a case
- // we don't unregister it later on.
- if (status != appearanceProcessRegisteredErr)
- {
- // Appearance client wasn't registered yet.
- sUMAHasInittedAppearance = true;
- }
-
- if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
- {
- sUMAAppearanceVersion = theAppearance ;
- }
- else
- {
- sUMAAppearanceVersion = 0x0100 ;
- }
- }
- if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr )
- {
- sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ;
- }
-
-#if TARGET_CARBON
-// Call currently implicitely done : InitFloatingWindows() ;
-#else
- if (!isEmbedded)
- {
- if ( sUMAHasWindowManager )
- InitFloatingWindows() ;
- else
- InitWindows();
- }
-#endif
-
- if ( NavServicesAvailable() )
- {
- NavLoad() ;
- }
-
- long menuMgrAttr ;
- Gestalt( gestaltMenuMgrAttr , &menuMgrAttr ) ;
- if ( menuMgrAttr & gestaltMenuMgrAquaLayoutMask )
- sUMAHasAquaLayout = true ;
-
- if ( TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress )
- {
- FontFamilyID fontId ;
- Str255 fontName ;
- SInt16 fontSize ;
- Style fontStyle ;
- GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
- GetFNum( fontName, &fontId );
-
- TXNMacOSPreferredFontDescription fontDescriptions[] =
- {
- { fontId , (fontSize << 16) ,kTXNDefaultFontStyle, kTXNSystemDefaultEncoding }
- } ;
- int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ;
-
- // kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke
-#if 0
- // leads to unexpected content for clients, TODO configurable
- OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ;
-#else
- OptionBits options = 0 ;
-#endif
-
-#if TARGET_CARBON
- if ( !UMAHasAquaLayout() )
-#endif
- {
- options |= kTXNAlwaysUseQuickDrawTextMask ;
- }
- TXNInitTextension(fontDescriptions, noOfFontDescriptions, options );
- }
-
-
- UMASetSystemIsInitialized(true);
-
-}
-
-/*
-Boolean CanUseATSUI()
- {
- long result;
- OSErr err = Gestalt(gestaltATSUVersion, &result);
- return (err == noErr);
- }
-*/
-// process manager
-long UMAGetProcessMode()
-{
- OSErr err ;
- ProcessInfoRec processinfo;
- ProcessSerialNumber procno ;
-
- procno.highLongOfPSN = NULL ;
- procno.lowLongOfPSN = kCurrentProcess ;
- processinfo.processInfoLength = sizeof(ProcessInfoRec);
- processinfo.processName = NULL;
- processinfo.processAppSpec = NULL;
-
- err = ::GetProcessInformation( &procno , &processinfo ) ;
- wxASSERT( err == noErr ) ;
- return processinfo.processMode ;
-}
-
-bool UMAGetProcessModeDoesActivateOnFGSwitch()
-{
- return UMAGetProcessMode() & modeDoesActivateOnFGSwitch ;
-}
-
-// menu manager
-
-MenuRef UMANewMenu( SInt16 id , const wxString& title , wxFontEncoding encoding )
-{
- wxString str = wxStripMenuCodes( title ) ;
- MenuRef menu ;
-#if TARGET_CARBON
- CreateNewMenu( id , 0 , &menu ) ;
- SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str , encoding ) ) ;
-#else
- Str255 ptitle ;
- wxMacStringToPascal( str , ptitle ) ;
- menu = ::NewMenu( id , ptitle ) ;
-#endif
- return menu ;
-}
-
-void UMASetMenuTitle( MenuRef menu , const wxString& title , wxFontEncoding encoding)
-{
- wxString str = wxStripMenuCodes( title ) ;
-#if TARGET_CARBON
- SetMenuTitleWithCFString( menu , wxMacCFStringHolder(str , encoding) ) ;
-#else
- Str255 ptitle ;
- wxMacStringToPascal( str , ptitle ) ;
- SetMenuTitle( menu , ptitle ) ;
-#endif
-}
-
-void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title , wxFontEncoding encoding)
-{
- wxString str = wxStripMenuCodes( title ) ;
-#if TARGET_CARBON
- SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str , encoding) ) ;
-#else
- Str255 ptitle ;
- wxMacStringToPascal( str , ptitle ) ;
- SetMenuItemText( menu , item , ptitle ) ;
-#endif
-}
-
-
-UInt32 UMAMenuEvent( EventRecord *inEvent )
-{
- return MenuEvent( inEvent ) ;
-}
-
-void UMAEnableMenuItem( MenuRef inMenu , MenuItemIndex inItem , bool enable)
-{
- if ( enable )
- EnableMenuItem( inMenu , inItem ) ;
- else
- DisableMenuItem( inMenu , inItem ) ;
-}
-
-void UMAAppendSubMenuItem( MenuRef menu , const wxString& title, wxFontEncoding encoding , SInt16 id )
-{
- MacAppendMenu(menu, "\pA");
- UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title , encoding );
- SetMenuItemHierarchicalID( menu , CountMenuItems( menu ) , id ) ;
-}
-
-void UMAInsertSubMenuItem( MenuRef menu , const wxString& title, wxFontEncoding encoding , MenuItemIndex item , SInt16 id )
-{
- MacInsertMenuItem(menu, "\pA" , item);
- UMASetMenuItemText(menu, item , title , encoding);
- SetMenuItemHierarchicalID( menu , item , id ) ;
-}
-
-void UMASetMenuItemShortcut( MenuRef menu , MenuItemIndex item , wxAcceleratorEntry *entry )
-{
- if ( !entry )
- return ;
-
- UInt8 modifiers = 0 ;
- SInt16 key = entry->GetKeyCode() ;
- if ( key )
- {
- bool explicitCommandKey = false ;
-
- if ( entry->GetFlags() & wxACCEL_CTRL )
- {
- explicitCommandKey = true ;
- }
-
- if (entry->GetFlags() & wxACCEL_ALT )
- {
- modifiers |= kMenuOptionModifier ;
- }
-
- if (entry->GetFlags() & wxACCEL_SHIFT)
- {
- modifiers |= kMenuShiftModifier ;
- }
-
- SInt16 glyph = 0 ;
- SInt16 macKey = key ;
- if ( key >= WXK_F1 && key <= WXK_F15 )
- {
- // for some reasons this must be 0 right now
- // everything else leads to just the first function key item
- // to be selected. Thanks to Ryan Wilcox for finding out.
- macKey = 0 ;
- glyph = kMenuF1Glyph + ( key - WXK_F1 ) ;
- if ( key >= WXK_F13 )
- glyph += 13 ;
- if ( !explicitCommandKey )
- modifiers |= kMenuNoCommandModifier ;
- }
- else
- {
- switch( key )
- {
- case WXK_BACK :
- macKey = kBackspaceCharCode ;
- glyph = kMenuDeleteLeftGlyph ;
- break ;
- case WXK_TAB :
- macKey = kTabCharCode ;
- glyph = kMenuTabRightGlyph ;
- break ;
- case kEnterCharCode :
- macKey = kEnterCharCode ;
- glyph = kMenuEnterGlyph ;
- break ;
- case WXK_RETURN :
- macKey = kReturnCharCode ;
- glyph = kMenuReturnGlyph ;
- break ;
- case WXK_ESCAPE :
- macKey = kEscapeCharCode ;
- glyph = kMenuEscapeGlyph ;
- break ;
- case WXK_SPACE :
- macKey = ' ' ;
- glyph = kMenuSpaceGlyph ;
- break ;
- case WXK_DELETE :
- macKey = kDeleteCharCode ;
- glyph = kMenuDeleteRightGlyph ;
- break ;
- case WXK_CLEAR :
- macKey = kClearCharCode ;
- glyph = kMenuClearGlyph ;
- break ;
- case WXK_PAGEUP :
- macKey = kPageUpCharCode ;
- glyph = kMenuPageUpGlyph ;
- break ;
- case WXK_PAGEDOWN :
- macKey = kPageDownCharCode ;
- glyph = kMenuPageDownGlyph ;
- break ;
- case WXK_LEFT :
- macKey = kLeftArrowCharCode ;
- glyph = kMenuLeftArrowGlyph ;
- break ;
- case WXK_UP :
- macKey = kUpArrowCharCode ;
- glyph = kMenuUpArrowGlyph ;
- break ;
- case WXK_RIGHT :
- macKey = kRightArrowCharCode ;
- glyph = kMenuRightArrowGlyph ;
- break ;
- case WXK_DOWN :
- macKey = kDownArrowCharCode ;
- glyph = kMenuDownArrowGlyph ;
- break ;
- }
- }
-
- SetItemCmd( menu, item , macKey );
- SetMenuItemModifiers(menu, item , modifiers ) ;
-
- if ( glyph )
- SetMenuItemKeyGlyph(menu, item , glyph ) ;
- }
-}
-
-void UMAAppendMenuItem( MenuRef menu , const wxString& title, wxFontEncoding encoding , wxAcceleratorEntry *entry )
-{
- MacAppendMenu(menu, "\pA");
- UMASetMenuItemText(menu, (SInt16) ::CountMenuItems(menu), title , encoding );
- UMASetMenuItemShortcut( menu , (SInt16) ::CountMenuItems(menu), entry ) ;
-}
-
-void UMAInsertMenuItem( MenuRef menu , const wxString& title, wxFontEncoding encoding , MenuItemIndex item , wxAcceleratorEntry *entry )
-{
- MacInsertMenuItem( menu , "\pA" , item) ;
- UMASetMenuItemText(menu, item+1 , title , encoding );
- UMASetMenuItemShortcut( menu , item+1 , entry ) ;
-}
-
-// quickdraw
-
-#if !TARGET_CARBON
-
-int gPrOpenCounter = 0 ;
-
-OSStatus UMAPrOpen()
-{
- OSErr err = noErr ;
- ++gPrOpenCounter ;
- if ( gPrOpenCounter == 1 )
- {
- PrOpen() ;
- err = PrError() ;
- wxASSERT( err == noErr ) ;
- }
- return err ;
-}
-
-OSStatus UMAPrClose()
-{
- OSErr err = noErr ;
- wxASSERT( gPrOpenCounter >= 1 ) ;
- if ( gPrOpenCounter == 1 )
- {
- PrClose() ;
- err = PrError() ;
- wxASSERT( err == noErr ) ;
- }
- --gPrOpenCounter ;
- return err ;
-}
-
-pascal QDGlobalsPtr GetQDGlobalsPtr (void) ;
-pascal QDGlobalsPtr GetQDGlobalsPtr (void)
-{
- return QDGlobalsPtr (* (Ptr*) LMGetCurrentA5 ( ) - 0xCA);
-}
-
-#endif
-
-void UMAShowWatchCursor()
-{
- OSErr err = noErr;
-
- CursHandle watchFob = GetCursor (watchCursor);
-
- if (!watchFob)
- err = nilHandleErr;
- else
- {
- #if TARGET_CARBON
-// Cursor preservedArrow;
-// GetQDGlobalsArrow (&preservedArrow);
-// SetQDGlobalsArrow (*watchFob);
-// InitCursor ( );
-// SetQDGlobalsArrow (&preservedArrow);
- SetCursor (*watchFob);
- #else
- SetCursor (*watchFob);
- #endif
- }
-}
-
-void UMAShowArrowCursor()
-{
-#if TARGET_CARBON
- Cursor arrow;
- SetCursor (GetQDGlobalsArrow (&arrow));
-#else
- SetCursor (&(qd.arrow));
-#endif
-}
-
-// window manager
-
-GrafPtr UMAGetWindowPort( WindowRef inWindowRef )
-{
- wxASSERT( inWindowRef != NULL ) ;
-#if TARGET_CARBON
- return (GrafPtr) GetWindowPort( inWindowRef ) ;
-#else
- return (GrafPtr) inWindowRef ;
-#endif
-}
-
-void UMADisposeWindow( WindowRef inWindowRef )
-{
- wxASSERT( inWindowRef != NULL ) ;
- DisposeWindow( inWindowRef ) ;
-}
-
-void UMASetWTitle( WindowRef inWindowRef , const wxString& title , wxFontEncoding encoding)
-{
-#if TARGET_CARBON
- SetWindowTitleWithCFString( inWindowRef , wxMacCFStringHolder(title , encoding) ) ;
-#else
- Str255 ptitle ;
- wxMacStringToPascal( title , ptitle ) ;
- SetWTitle( inWindowRef , ptitle ) ;
-#endif
-}
-
-// appearance additions
-
-void UMASetControlTitle( ControlHandle inControl , const wxString& title , wxFontEncoding encoding)
-{
-#if TARGET_CARBON
- SetControlTitleWithCFString( inControl , wxMacCFStringHolder(title , encoding) ) ;
-#else
- Str255 ptitle ;
- wxMacStringToPascal( title , ptitle ) ;
- SetControlTitle( inControl , ptitle ) ;
-#endif
-}
-
-void UMAActivateControl( ControlHandle inControl )
-{
- // we have to add the control after again to the update rgn
- // otherwise updates get lost
- if ( !IsControlActive( inControl ) )
- {
- bool visible = IsControlVisible( inControl ) ;
- if ( visible )
- SetControlVisibility( inControl , false , false ) ;
- ::ActivateControl( inControl ) ;
- if ( visible ) {
- SetControlVisibility( inControl , true , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
- }
- }
-}
-
-void UMADrawControl( ControlHandle inControl )
-{
- WindowRef theWindow = GetControlOwner(inControl) ;
- wxMacPortStateHelper help( (GrafPtr) GetWindowPort(theWindow) ) ;
- RgnHandle updateRgn = NewRgn() ;
- GetWindowUpdateRgn( theWindow , updateRgn ) ;
- Point zero = { 0 , 0 } ;
- LocalToGlobal( &zero ) ;
- OffsetRgn( updateRgn , -zero.h , -zero.v ) ;
- ::DrawControlInCurrentPort( inControl ) ;
- InvalWindowRgn( theWindow, updateRgn) ;
- DisposeRgn( updateRgn ) ;
-}
-
-void UMAMoveControl( ControlHandle inControl , short x , short y )
-{
- bool visible = IsControlVisible( inControl ) ;
- if ( visible ) {
- SetControlVisibility( inControl , false , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
- }
- ::MoveControl( inControl , x , y ) ;
- if ( visible ) {
- SetControlVisibility( inControl , true , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
- }
-}
-
-void UMASizeControl( ControlHandle inControl , short x , short y )
-{
- bool visible = IsControlVisible( inControl ) ;
- if ( visible ) {
- SetControlVisibility( inControl , false , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
- }
- ::SizeControl( inControl , x , y ) ;
- if ( visible ) {
- SetControlVisibility( inControl , true , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
- }
-}
-
-void UMADeactivateControl( ControlHandle inControl )
-{
- // we have to add the control after again to the update rgn
- // otherwise updates get lost
- bool visible = IsControlVisible( inControl ) ;
- if ( visible )
- SetControlVisibility( inControl , false , false ) ;
- ::DeactivateControl( inControl ) ;
- if ( visible ) {
- SetControlVisibility( inControl , true , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
- }
-}
-// shows the control and adds the region to the update region
-void UMAShowControl (ControlHandle inControl)
-{
- SetControlVisibility( inControl , true , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
-}
-
-// shows the control and adds the region to the update region
-void UMAHideControl (ControlHandle inControl)
-{
- SetControlVisibility( inControl , false , false ) ;
- Rect ctrlBounds ;
- InvalWindowRect(GetControlOwner(inControl),GetControlBounds(inControl,&ctrlBounds) ) ;
-}
-// keyboard focus
-OSErr UMASetKeyboardFocus (WindowPtr inWindow,
- ControlHandle inControl,
- ControlFocusPart inPart)
-{
- OSErr err = noErr;
- GrafPtr port ;
- GetPort( &port ) ;
-
- SetPortWindowPort( inWindow ) ;
-
- err = SetKeyboardFocus( inWindow , inControl , inPart ) ;
- SetPort( port ) ;
- return err ;
-}
-
-
-// events
-void UMAUpdateControls( WindowPtr inWindow , RgnHandle inRgn )
-{
- wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) inWindow) ) ;
- RgnHandle updateRgn = NewRgn() ;
- GetWindowUpdateRgn( inWindow , updateRgn ) ;
-
- Point zero = { 0 , 0 } ;
- LocalToGlobal( &zero ) ;
- OffsetRgn( updateRgn , -zero.h , -zero.v ) ;
-
- UpdateControls( inWindow , inRgn ) ;
- InvalWindowRgn( inWindow, updateRgn) ;
- DisposeRgn( updateRgn ) ;
-}
-
-bool UMAIsWindowFloating( WindowRef inWindow )
-{
- WindowClass cl ;
-
- GetWindowClass( inWindow , &cl ) ;
- return cl == kFloatingWindowClass ;
-}
-
-bool UMAIsWindowModal( WindowRef inWindow )
-{
- WindowClass cl ;
-
- GetWindowClass( inWindow , &cl ) ;
- return cl < kFloatingWindowClass ;
-}
-
-// others
-
-void UMAHighlightAndActivateWindow( WindowRef inWindowRef , bool inActivate )
-{
- if ( inWindowRef )
- {
-// bool isHighlighted = IsWindowHighlited( inWindowRef ) ;
-// if ( inActivate != isHightlited )
- GrafPtr port ;
- GetPort( &port ) ;
- SetPortWindowPort( inWindowRef ) ;
- HiliteWindow( inWindowRef , inActivate ) ;
- ControlHandle control = NULL ;
- ::GetRootControl( inWindowRef , & control ) ;
- if ( control )
- {
- if ( inActivate )
- UMAActivateControl( control ) ;
- else
- UMADeactivateControl( control ) ;
- }
- SetPort( port ) ;
- }
-}
-
-OSStatus UMADrawThemePlacard( const Rect *inRect , ThemeDrawState inState )
-{
- return ::DrawThemePlacard( inRect , inState ) ;
-}
-
-#if !TARGET_CARBON
-static OSStatus helpMenuStatus = noErr ;
-static MenuItemIndex firstCustomItemIndex = 0 ;
-#endif
-
-OSStatus UMAGetHelpMenu(
- MenuRef * outHelpMenu,
- MenuItemIndex * outFirstCustomItemIndex)
-{
-#if TARGET_CARBON
- return HMGetHelpMenu( outHelpMenu , outFirstCustomItemIndex ) ;
-#else
- MenuRef helpMenuHandle ;
- helpMenuStatus = HMGetHelpMenuHandle( &helpMenuHandle ) ;
- if ( firstCustomItemIndex == 0 && helpMenuStatus == noErr )
- {
- firstCustomItemIndex = CountMenuItems( helpMenuHandle ) + 1 ;
- }
- if ( outFirstCustomItemIndex )
- {
- *outFirstCustomItemIndex = firstCustomItemIndex ;
- }
- *outHelpMenu = helpMenuHandle ;
- return helpMenuStatus ;
-#endif
-}
-
-wxMacPortStateHelper::wxMacPortStateHelper( GrafPtr newport)
-{
- m_clip = NULL ;
- Setup( newport ) ;
-}
-
-wxMacPortStateHelper::wxMacPortStateHelper()
-{
- m_clip = NULL ;
-}
-
-void wxMacPortStateHelper::Setup( GrafPtr newport )
-{
- GetPort( &m_oldPort ) ;
- SetPort( newport ) ;
- SetOrigin(0,0);
- wxASSERT_MSG( m_clip == NULL , wxT("Cannot call setup twice") ) ;
- m_clip = NewRgn() ;
- GetClip( m_clip );
- m_textFont = GetPortTextFont( (CGrafPtr) newport);
- m_textSize = GetPortTextSize( (CGrafPtr) newport);
- m_textStyle = GetPortTextFace( (CGrafPtr) newport);
- m_textMode = GetPortTextMode( (CGrafPtr) newport);
- GetThemeDrawingState( &m_drawingState ) ;
- m_currentPort = newport ;
-}
-void wxMacPortStateHelper::Clear()
-{
- if ( m_clip )
- {
- DisposeRgn( m_clip ) ;
- DisposeThemeDrawingState( m_drawingState ) ;
- m_clip = NULL ;
- }
-}
-
-wxMacPortStateHelper::~wxMacPortStateHelper()
-{
- if ( m_clip )
- {
- SetPort( m_currentPort ) ;
- SetClip( m_clip ) ;
- DisposeRgn( m_clip ) ;
- TextFont( m_textFont );
- TextSize( m_textSize );
- TextFace( m_textStyle );
- TextMode( m_textMode );
- SetThemeDrawingState( m_drawingState , true ) ;
- SetPort( m_oldPort ) ;
- }
-}
-
-OSStatus UMAPutScrap( Size size , OSType type , void *data )
-{
- OSStatus err = noErr ;
-#if !TARGET_CARBON
- err = PutScrap( size , type , data ) ;
-#else
- ScrapRef scrap;
- err = GetCurrentScrap (&scrap);
- if ( !err )
- {
- err = PutScrapFlavor (scrap, type , 0, size, data);
- }
-#endif
- return err ;
-}
-
-#endif // wxUSE_GUI
-
-#if wxUSE_BASE
-
-static bool sUMASystemInitialized = false ;
-
-bool UMASystemIsInitialized()
-{
- return sUMASystemInitialized ;
-}
-
-void UMASetSystemIsInitialized(bool val)
-{
- sUMASystemInitialized = val;
-}
-
-
-#endif // wxUSE_BASE
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/utils.cpp
-// Purpose: Various utilities
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/utils.h"
-
-#ifndef WX_PRECOMP
- #include "wx/intl.h"
- #include "wx/app.h"
- #if wxUSE_GUI
- #include "wx/font.h"
- #endif
-#endif
-
-#include "wx/apptrait.h"
-
-#if wxUSE_GUI
- #include "wx/mac/uma.h"
-#endif
-
-#include <ctype.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-
-#ifdef __DARWIN__
-# include "MoreFilesX.h"
-#else
-# include "MoreFiles.h"
-# include "MoreFilesExtras.h"
-#endif
-
-#ifndef __DARWIN__
-#include <Threads.h>
-#include <Sound.h>
-#endif
-
-#include <ATSUnicode.h>
-#include <TextCommon.h>
-#include <TextEncodingConverter.h>
-
-#include "wx/mac/private.h" // includes mac headers
-
-#if defined(__MWERKS__) && wxUSE_UNICODE
- #include <wtime.h>
-#endif
-
-#if wxUSE_BASE
-
-// our OS version is the same in non GUI and GUI cases
-wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
-{
- long theSystem;
- Gestalt(gestaltSystemVersion, &theSystem);
-
- if ( majorVsn != NULL )
- *majorVsn = (theSystem >> 8);
-
- if ( minorVsn != NULL )
- *minorVsn = (theSystem & 0xFF);
-
-
-#if defined( __DARWIN__ )
- return wxOS_MAC_OSX_DARWIN;
-#else
- return wxOS_MAC_OS;
-#endif
-}
-
-#ifndef __DARWIN__
-// defined in unix/utilsunx.cpp for Mac OS X
-
-// get full hostname (with domain name if possible)
-bool wxGetFullHostName(wxChar *buf, int maxSize)
-{
- return wxGetHostName(buf, maxSize);
-}
-
-// Get hostname only (without domain name)
-bool wxGetHostName(wxChar *buf, int maxSize)
-{
- // Gets Chooser name of user by examining a System resource.
-
- const short kComputerNameID = -16413;
-
- short oldResFile = CurResFile() ;
- UseResFile(0);
- StringHandle chooserName = (StringHandle)::GetString(kComputerNameID);
- UseResFile(oldResFile);
-
- if (chooserName && *chooserName)
- {
- HLock( (Handle) chooserName ) ;
- wxString name = wxMacMakeStringFromPascal( *chooserName ) ;
- HUnlock( (Handle) chooserName ) ;
- ReleaseResource( (Handle) chooserName ) ;
- wxStrncpy( buf , name , maxSize - 1 ) ;
- }
- else
- buf[0] = 0 ;
-
- return true;
-}
-
-// Get user ID e.g. jacs
-bool wxGetUserId(wxChar *buf, int maxSize)
-{
- return wxGetUserName( buf , maxSize ) ;
-}
-
-const wxChar* wxGetHomeDir(wxString *pstr)
-{
- *pstr = wxMacFindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder ) ;
- return pstr->c_str() ;
-}
-
-// Get user name e.g. Stefan Csomor
-bool wxGetUserName(wxChar *buf, int maxSize)
-{
- // Gets Chooser name of user by examining a System resource.
-
- const short kChooserNameID = -16096;
-
- short oldResFile = CurResFile() ;
- UseResFile(0);
- StringHandle chooserName = (StringHandle)::GetString(kChooserNameID);
- UseResFile(oldResFile);
-
- if (chooserName && *chooserName)
- {
- HLock( (Handle) chooserName ) ;
- wxString name = wxMacMakeStringFromPascal( *chooserName ) ;
- HUnlock( (Handle) chooserName ) ;
- ReleaseResource( (Handle) chooserName ) ;
- wxStrncpy( buf , name , maxSize - 1 ) ;
- }
- else
- buf[0] = 0 ;
-
- return true;
-}
-
-int wxKill(long pid, wxSignal sig , wxKillError *rc, int flags)
-{
- // TODO
- return 0;
-}
-
-WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value)
-{
- // TODO : under classic there is no environement support, under X yes
- return false ;
-}
-
-// set the env var name to the given value, return true on success
-WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value)
-{
- // TODO : under classic there is no environement support, under X yes
- return false ;
-}
-
-//
-// Execute a program in an Interactive Shell
-//
-bool wxShell(const wxString& command)
-{
- // TODO
- return false;
-}
-
-// Shutdown or reboot the PC
-bool wxShutdown(wxShutdownFlags wFlags)
-{
- // TODO
- return false;
-}
-
-// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
-wxMemorySize wxGetFreeMemory()
-{
- return (wxMemorySize)FreeMem() ;
-}
-
-void wxUsleep(unsigned long milliseconds)
-{
- clock_t start = clock() ;
- do
- {
- YieldToAnyThread() ;
- } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ;
-}
-
-void wxSleep(int nSecs)
-{
- wxUsleep(1000*nSecs);
-}
-
-// Consume all events until no more left
-void wxFlushEvents()
-{
-}
-
-#endif // !__DARWIN__
-
-// Emit a beeeeeep
-void wxBell()
-{
- SysBeep(30);
-}
-
-#endif // wxUSE_BASE
-
-#if wxUSE_GUI
-
-wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
-{
- // We suppose that toolkit version is the same as OS version under Mac
- wxGetOsVersion(verMaj, verMin);
-
- return wxPORT_MAC;
-}
-
-// Reading and writing resources (eg WIN.INI, .Xdefaults)
-#if wxUSE_RESOURCES
-bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
-{
- // TODO
- return false;
-}
-
-bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
-{
- wxString buf;
- buf.Printf(wxT("%.4f"), value);
-
- return wxWriteResource(section, entry, buf, file);
-}
-
-bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
-{
- wxString buf;
- buf.Printf(wxT("%ld"), value);
-
- return wxWriteResource(section, entry, buf, file);
-}
-
-bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
-{
- wxString buf;
- buf.Printf(wxT("%d"), value);
-
- return wxWriteResource(section, entry, buf, file);
-}
-
-bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
-{
- // TODO
- return false;
-}
-
-bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
-{
- char *s = NULL;
- bool succ = wxGetResource(section, entry, (char **)&s, file);
- if (succ)
- {
- *value = (float)strtod(s, NULL);
- delete[] s;
- return true;
- }
- else return false;
-}
-
-bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
-{
- char *s = NULL;
- bool succ = wxGetResource(section, entry, (char **)&s, file);
- if (succ)
- {
- *value = strtol(s, NULL, 10);
- delete[] s;
- return true;
- }
- else return false;
-}
-
-bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
-{
- char *s = NULL;
- bool succ = wxGetResource(section, entry, (char **)&s, file);
- if (succ)
- {
- *value = (int)strtol(s, NULL, 10);
- delete[] s;
- return true;
- }
- else return false;
-}
-#endif // wxUSE_RESOURCES
-
-int gs_wxBusyCursorCount = 0;
-extern wxCursor gMacCurrentCursor ;
-wxCursor gMacStoredActiveCursor ;
-
-// Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(const wxCursor *cursor)
-{
- if (gs_wxBusyCursorCount++ == 0)
- {
- gMacStoredActiveCursor = gMacCurrentCursor ;
- cursor->MacInstall() ;
- }
- //else: nothing to do, already set
-}
-
-// Restore cursor to normal
-void wxEndBusyCursor()
-{
- wxCHECK_RET( gs_wxBusyCursorCount > 0,
- wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
-
- if (--gs_wxBusyCursorCount == 0)
- {
- gMacStoredActiveCursor.MacInstall() ;
- gMacStoredActiveCursor = wxNullCursor ;
- }
-}
-
-// true if we're between the above two calls
-bool wxIsBusy()
-{
- return (gs_wxBusyCursorCount > 0);
-}
-
-#endif // wxUSE_GUI
-
-#if wxUSE_BASE
-
-wxString wxMacFindFolderNoSeparator( short vol,
- OSType folderType,
- Boolean createFolder)
-{
- short vRefNum ;
- long dirID ;
- wxString strDir ;
-
- if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr)
- {
- FSSpec file ;
- if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
- {
- strDir = wxMacFSSpec2MacFilename( &file );
- }
- }
- return strDir ;
-}
-
-wxString wxMacFindFolder( short vol,
- OSType folderType,
- Boolean createFolder)
-{
- return wxMacFindFolderNoSeparator(vol, folderType, createFolder) + wxFILE_SEP_PATH;
-}
-
-#endif // wxUSE_BASE
-
-#if wxUSE_GUI
-
-// Check whether this window wants to process messages, e.g. Stop button
-// in long calculations.
-bool wxCheckForInterrupt(wxWindow *wnd)
-{
- // TODO
- return false;
-}
-
-void wxGetMousePosition( int* x, int* y )
-{
- Point pt ;
-
- GetMouse( &pt ) ;
- LocalToGlobal( &pt ) ;
- *x = pt.h ;
- *y = pt.v ;
-};
-
-// Return true if we have a colour display
-bool wxColourDisplay()
-{
- return true;
-}
-
-// Returns depth of screen
-int wxDisplayDepth()
-{
- Rect globRect ;
- SetRect(&globRect, -32760, -32760, 32760, 32760);
- GDHandle theMaxDevice;
-
- int theDepth = 8;
- theMaxDevice = GetMaxDevice(&globRect);
- if (theMaxDevice != nil)
- theDepth = (**(**theMaxDevice).gdPMap).pixelSize;
-
- return theDepth ;
-}
-
-// Get size of display
-void wxDisplaySize(int *width, int *height)
-{
- BitMap screenBits;
- GetQDGlobalsScreenBits( &screenBits );
-
- if (width != NULL) {
- *width = screenBits.bounds.right - screenBits.bounds.left ;
- }
- if (height != NULL) {
- *height = screenBits.bounds.bottom - screenBits.bounds.top ;
- }
-}
-
-void wxDisplaySizeMM(int *width, int *height)
-{
- wxDisplaySize(width, height);
- // on mac 72 is fixed (at least now ;-)
- float cvPt2Mm = 25.4 / 72;
-
- if (width != NULL) {
- *width = int( *width * cvPt2Mm );
- }
- if (height != NULL) {
- *height = int( *height * cvPt2Mm );
- }
-}
-
-void wxClientDisplayRect(int *x, int *y, int *width, int *height)
-{
-#if TARGET_CARBON
- Rect r ;
- GetAvailableWindowPositioningBounds( GetMainDevice() , &r ) ;
- if ( x )
- *x = r.left ;
- if ( y )
- *y = r.top ;
- if ( width )
- *width = r.right - r.left ;
- if ( height )
- *height = r.bottom - r.top ;
-#else
- BitMap screenBits;
- GetQDGlobalsScreenBits( &screenBits );
-
- if (x) *x = 0;
- if (y) *y = 0;
-
- if (width != NULL) {
- *width = screenBits.bounds.right - screenBits.bounds.left ;
- }
- if (height != NULL) {
- *height = screenBits.bounds.bottom - screenBits.bounds.top ;
- }
-
- SInt16 mheight ;
-#if TARGET_CARBON
- GetThemeMenuBarHeight( &mheight ) ;
-#else
- mheight = LMGetMBarHeight() ;
-#endif
- if (height != NULL) {
- *height -= mheight ;
- }
- if (y)
- *y = mheight ;
-#endif
-}
-
-wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
-{
- return wxGenericFindWindowAtPoint(pt);
-}
-
-#endif // wxUSE_GUI
-
-#if wxUSE_BASE
-
-wxString wxGetOsDescription()
-{
-#ifdef WXWIN_OS_DESCRIPTION
- // use configure generated description if available
- return wxString(wxT("MacOS (")) + wxT(WXWIN_OS_DESCRIPTION) + wxString(wxT(")"));
-#else
- return wxT("MacOS") ; //TODO:define further
-#endif
-}
-
-#ifndef __DARWIN__
-wxChar *wxGetUserHome (const wxString& user)
-{
- // TODO
- return NULL;
-}
-
-bool wxGetDiskSpace(const wxString& path, wxDiskspaceSize_t *pTotal, wxDiskspaceSize_t *pFree)
-{
- if ( path.empty() )
- return false;
-
- wxString p = path ;
- if (p[0u] == ':' ) {
- p = wxGetCwd() + p ;
- }
-
- int pos = p.Find(':') ;
- if ( pos != wxNOT_FOUND ) {
- p = p.Mid(1,pos) ;
- }
-
- p = p + wxT(":") ;
-
- Str255 volumeName ;
- XVolumeParam pb ;
-
- wxMacStringToPascal( p , volumeName ) ;
- OSErr err = XGetVolumeInfoNoName( volumeName , 0 , &pb ) ;
- if ( err == noErr ) {
- if ( pTotal ) {
- (*pTotal) = wxDiskspaceSize_t( pb.ioVTotalBytes ) ;
- }
- if ( pFree ) {
- (*pFree) = wxDiskspaceSize_t( pb.ioVFreeBytes ) ;
- }
- }
-
- return err == noErr ;
-}
-#endif // !__DARWIN__
-
-//---------------------------------------------------------------------------
-// wxMac Specific utility functions
-//---------------------------------------------------------------------------
-
-void wxMacStringToPascal( const wxString&from , StringPtr to )
-{
- wxCharBuffer buf = from.mb_str( wxConvLocal ) ;
- int len = strlen(buf) ;
-
- if ( len > 255 )
- len = 255 ;
- to[0] = len ;
- memcpy( (char*) &to[1] , buf , len ) ;
-}
-
-wxString wxMacMakeStringFromPascal( ConstStringPtr from )
-{
- return wxString( (char*) &from[1] , wxConvLocal , from[0] ) ;
-}
-
-
-wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding)
-{
- TextEncodingBase enc = 0 ;
- if ( encoding == wxFONTENCODING_DEFAULT )
- {
-#if wxUSE_GUI
- encoding = wxFont::GetDefaultEncoding() ;
-#else
- encoding = wxLocale::GetSystemEncoding() ;
-#endif
- }
-
- switch( encoding)
- {
- case wxFONTENCODING_ISO8859_1 :
- enc = kTextEncodingISOLatin1 ;
- break ;
- case wxFONTENCODING_ISO8859_2 :
- enc = kTextEncodingISOLatin2;
- break ;
- case wxFONTENCODING_ISO8859_3 :
- enc = kTextEncodingISOLatin3 ;
- break ;
- case wxFONTENCODING_ISO8859_4 :
- enc = kTextEncodingISOLatin4;
- break ;
- case wxFONTENCODING_ISO8859_5 :
- enc = kTextEncodingISOLatinCyrillic;
- break ;
- case wxFONTENCODING_ISO8859_6 :
- enc = kTextEncodingISOLatinArabic;
- break ;
- case wxFONTENCODING_ISO8859_7 :
- enc = kTextEncodingISOLatinGreek;
- break ;
- case wxFONTENCODING_ISO8859_8 :
- enc = kTextEncodingISOLatinHebrew;
- break ;
- case wxFONTENCODING_ISO8859_9 :
- enc = kTextEncodingISOLatin5;
- break ;
- case wxFONTENCODING_ISO8859_10 :
- enc = kTextEncodingISOLatin6;
- break ;
- case wxFONTENCODING_ISO8859_13 :
- enc = kTextEncodingISOLatin7;
- break ;
- case wxFONTENCODING_ISO8859_14 :
- enc = kTextEncodingISOLatin8;
- break ;
- case wxFONTENCODING_ISO8859_15 :
- enc = kTextEncodingISOLatin9;
- break ;
-
- case wxFONTENCODING_KOI8 :
- enc = kTextEncodingKOI8_R;
- break ;
- case wxFONTENCODING_ALTERNATIVE : // MS-DOS CP866
- enc = kTextEncodingDOSRussian;
- break ;
-/*
- case wxFONTENCODING_BULGARIAN :
- enc = ;
- break ;
-*/
- case wxFONTENCODING_CP437 :
- enc =kTextEncodingDOSLatinUS ;
- break ;
- case wxFONTENCODING_CP850 :
- enc = kTextEncodingDOSLatin1;
- break ;
- case wxFONTENCODING_CP852 :
- enc = kTextEncodingDOSLatin2;
- break ;
- case wxFONTENCODING_CP855 :
- enc = kTextEncodingDOSCyrillic;
- break ;
- case wxFONTENCODING_CP866 :
- enc =kTextEncodingDOSRussian ;
- break ;
- case wxFONTENCODING_CP874 :
- enc = kTextEncodingDOSThai;
- break ;
- case wxFONTENCODING_CP932 :
- enc = kTextEncodingDOSJapanese;
- break ;
- case wxFONTENCODING_CP936 :
- enc =kTextEncodingDOSChineseSimplif ;
- break ;
- case wxFONTENCODING_CP949 :
- enc = kTextEncodingDOSKorean;
- break ;
- case wxFONTENCODING_CP950 :
- enc = kTextEncodingDOSChineseTrad;
- break ;
-
- case wxFONTENCODING_CP1250 :
- enc = kTextEncodingWindowsLatin2;
- break ;
- case wxFONTENCODING_CP1251 :
- enc =kTextEncodingWindowsCyrillic ;
- break ;
- case wxFONTENCODING_CP1252 :
- enc =kTextEncodingWindowsLatin1 ;
- break ;
- case wxFONTENCODING_CP1253 :
- enc = kTextEncodingWindowsGreek;
- break ;
- case wxFONTENCODING_CP1254 :
- enc = kTextEncodingWindowsLatin5;
- break ;
- case wxFONTENCODING_CP1255 :
- enc =kTextEncodingWindowsHebrew ;
- break ;
- case wxFONTENCODING_CP1256 :
- enc =kTextEncodingWindowsArabic ;
- break ;
- case wxFONTENCODING_CP1257 :
- enc = kTextEncodingWindowsBalticRim;
- break ;
-
- case wxFONTENCODING_UTF7 :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicodeUTF7Format) ;
- break ;
- case wxFONTENCODING_UTF8 :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicodeUTF8Format) ;
- break ;
- case wxFONTENCODING_EUC_JP :
- enc = kTextEncodingEUC_JP;
- break ;
- case wxFONTENCODING_UTF16BE :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
- break ;
- case wxFONTENCODING_UTF16LE :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
- break ;
- case wxFONTENCODING_UTF32BE :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode32BitFormat) ;
- break ;
- case wxFONTENCODING_UTF32LE :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode32BitFormat) ;
- break ;
-
- case wxFONTENCODING_MACROMAN :
- enc = kTextEncodingMacRoman ;
- break ;
- case wxFONTENCODING_MACJAPANESE :
- enc = kTextEncodingMacJapanese ;
- break ;
- case wxFONTENCODING_MACCHINESETRAD :
- enc = kTextEncodingMacChineseTrad ;
- break ;
- case wxFONTENCODING_MACKOREAN :
- enc = kTextEncodingMacKorean ;
- break ;
- case wxFONTENCODING_MACARABIC :
- enc = kTextEncodingMacArabic ;
- break ;
- case wxFONTENCODING_MACHEBREW :
- enc = kTextEncodingMacHebrew ;
- break ;
- case wxFONTENCODING_MACGREEK :
- enc = kTextEncodingMacGreek ;
- break ;
- case wxFONTENCODING_MACCYRILLIC :
- enc = kTextEncodingMacCyrillic ;
- break ;
- case wxFONTENCODING_MACDEVANAGARI :
- enc = kTextEncodingMacDevanagari ;
- break ;
- case wxFONTENCODING_MACGURMUKHI :
- enc = kTextEncodingMacGurmukhi ;
- break ;
- case wxFONTENCODING_MACGUJARATI :
- enc = kTextEncodingMacGujarati ;
- break ;
- case wxFONTENCODING_MACORIYA :
- enc = kTextEncodingMacOriya ;
- break ;
- case wxFONTENCODING_MACBENGALI :
- enc = kTextEncodingMacBengali ;
- break ;
- case wxFONTENCODING_MACTAMIL :
- enc = kTextEncodingMacTamil ;
- break ;
- case wxFONTENCODING_MACTELUGU :
- enc = kTextEncodingMacTelugu ;
- break ;
- case wxFONTENCODING_MACKANNADA :
- enc = kTextEncodingMacKannada ;
- break ;
- case wxFONTENCODING_MACMALAJALAM :
- enc = kTextEncodingMacMalayalam ;
- break ;
- case wxFONTENCODING_MACSINHALESE :
- enc = kTextEncodingMacSinhalese ;
- break ;
- case wxFONTENCODING_MACBURMESE :
- enc = kTextEncodingMacBurmese ;
- break ;
- case wxFONTENCODING_MACKHMER :
- enc = kTextEncodingMacKhmer ;
- break ;
- case wxFONTENCODING_MACTHAI :
- enc = kTextEncodingMacThai ;
- break ;
- case wxFONTENCODING_MACLAOTIAN :
- enc = kTextEncodingMacLaotian ;
- break ;
- case wxFONTENCODING_MACGEORGIAN :
- enc = kTextEncodingMacGeorgian ;
- break ;
- case wxFONTENCODING_MACARMENIAN :
- enc = kTextEncodingMacArmenian ;
- break ;
- case wxFONTENCODING_MACCHINESESIMP :
- enc = kTextEncodingMacChineseSimp ;
- break ;
- case wxFONTENCODING_MACTIBETAN :
- enc = kTextEncodingMacTibetan ;
- break ;
- case wxFONTENCODING_MACMONGOLIAN :
- enc = kTextEncodingMacMongolian ;
- break ;
- case wxFONTENCODING_MACETHIOPIC :
- enc = kTextEncodingMacEthiopic ;
- break ;
- case wxFONTENCODING_MACCENTRALEUR :
- enc = kTextEncodingMacCentralEurRoman ;
- break ;
- case wxFONTENCODING_MACVIATNAMESE :
- enc = kTextEncodingMacVietnamese ;
- break ;
- case wxFONTENCODING_MACARABICEXT :
- enc = kTextEncodingMacExtArabic ;
- break ;
- case wxFONTENCODING_MACSYMBOL :
- enc = kTextEncodingMacSymbol ;
- break ;
- case wxFONTENCODING_MACDINGBATS :
- enc = kTextEncodingMacDingbats ;
- break ;
- case wxFONTENCODING_MACTURKISH :
- enc = kTextEncodingMacTurkish ;
- break ;
- case wxFONTENCODING_MACCROATIAN :
- enc = kTextEncodingMacCroatian ;
- break ;
- case wxFONTENCODING_MACICELANDIC :
- enc = kTextEncodingMacIcelandic ;
- break ;
- case wxFONTENCODING_MACROMANIAN :
- enc = kTextEncodingMacRomanian ;
- break ;
- case wxFONTENCODING_MACCELTIC :
- enc = kTextEncodingMacCeltic ;
- break ;
- case wxFONTENCODING_MACGAELIC :
- enc = kTextEncodingMacGaelic ;
- break ;
- case wxFONTENCODING_MACKEYBOARD :
- enc = kTextEncodingMacKeyboardGlyphs ;
- break ;
- default :
- // to make gcc happy
- break ;
- } ;
- return enc ;
-}
-
-wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding)
-{
- wxFontEncoding enc = wxFONTENCODING_DEFAULT ;
-
- switch( encoding)
- {
- case kTextEncodingISOLatin1 :
- enc = wxFONTENCODING_ISO8859_1 ;
- break ;
- case kTextEncodingISOLatin2 :
- enc = wxFONTENCODING_ISO8859_2;
- break ;
- case kTextEncodingISOLatin3 :
- enc = wxFONTENCODING_ISO8859_3 ;
- break ;
- case kTextEncodingISOLatin4 :
- enc = wxFONTENCODING_ISO8859_4;
- break ;
- case kTextEncodingISOLatinCyrillic :
- enc = wxFONTENCODING_ISO8859_5;
- break ;
- case kTextEncodingISOLatinArabic :
- enc = wxFONTENCODING_ISO8859_6;
- break ;
- case kTextEncodingISOLatinGreek :
- enc = wxFONTENCODING_ISO8859_7;
- break ;
- case kTextEncodingISOLatinHebrew :
- enc = wxFONTENCODING_ISO8859_8;
- break ;
- case kTextEncodingISOLatin5 :
- enc = wxFONTENCODING_ISO8859_9;
- break ;
- case kTextEncodingISOLatin6 :
- enc = wxFONTENCODING_ISO8859_10;
- break ;
- case kTextEncodingISOLatin7 :
- enc = wxFONTENCODING_ISO8859_13;
- break ;
- case kTextEncodingISOLatin8 :
- enc = wxFONTENCODING_ISO8859_14;
- break ;
- case kTextEncodingISOLatin9 :
- enc =wxFONTENCODING_ISO8859_15 ;
- break ;
-
- case kTextEncodingKOI8_R :
- enc = wxFONTENCODING_KOI8;
- break ;
-/*
- case :
- enc = wxFONTENCODING_BULGARIAN;
- break ;
-*/
- case kTextEncodingDOSLatinUS :
- enc = wxFONTENCODING_CP437;
- break ;
- case kTextEncodingDOSLatin1 :
- enc = wxFONTENCODING_CP850;
- break ;
- case kTextEncodingDOSLatin2 :
- enc =wxFONTENCODING_CP852 ;
- break ;
- case kTextEncodingDOSCyrillic :
- enc = wxFONTENCODING_CP855;
- break ;
- case kTextEncodingDOSRussian :
- enc = wxFONTENCODING_CP866;
- break ;
- case kTextEncodingDOSThai :
- enc =wxFONTENCODING_CP874 ;
- break ;
- case kTextEncodingDOSJapanese :
- enc = wxFONTENCODING_CP932;
- break ;
- case kTextEncodingDOSChineseSimplif :
- enc = wxFONTENCODING_CP936;
- break ;
- case kTextEncodingDOSKorean :
- enc = wxFONTENCODING_CP949;
- break ;
- case kTextEncodingDOSChineseTrad :
- enc = wxFONTENCODING_CP950;
- break ;
-
- case kTextEncodingWindowsLatin2 :
- enc = wxFONTENCODING_CP1250;
- break ;
- case kTextEncodingWindowsCyrillic :
- enc = wxFONTENCODING_CP1251;
- break ;
- case kTextEncodingWindowsLatin1 :
- enc = wxFONTENCODING_CP1252;
- break ;
- case kTextEncodingWindowsGreek :
- enc = wxFONTENCODING_CP1253;
- break ;
- case kTextEncodingWindowsLatin5 :
- enc = wxFONTENCODING_CP1254;
- break ;
- case kTextEncodingWindowsHebrew :
- enc = wxFONTENCODING_CP1255;
- break ;
- case kTextEncodingWindowsArabic :
- enc = wxFONTENCODING_CP1256;
- break ;
- case kTextEncodingWindowsBalticRim :
- enc =wxFONTENCODING_CP1257 ;
- break ;
- case kTextEncodingEUC_JP :
- enc = wxFONTENCODING_EUC_JP;
- break ;
- /*
- case wxFONTENCODING_UTF7 :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicodeUTF7Format) ;
- break ;
- case wxFONTENCODING_UTF8 :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicodeUTF8Format) ;
- break ;
- case wxFONTENCODING_UTF16BE :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
- break ;
- case wxFONTENCODING_UTF16LE :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode16BitFormat) ;
- break ;
- case wxFONTENCODING_UTF32BE :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode32BitFormat) ;
- break ;
- case wxFONTENCODING_UTF32LE :
- enc = CreateTextEncoding(kTextEncodingUnicodeDefault,0,kUnicode32BitFormat) ;
- break ;
- */
- case kTextEncodingMacRoman :
- enc = wxFONTENCODING_MACROMAN ;
- break ;
- case kTextEncodingMacJapanese :
- enc = wxFONTENCODING_MACJAPANESE ;
- break ;
- case kTextEncodingMacChineseTrad :
- enc = wxFONTENCODING_MACCHINESETRAD ;
- break ;
- case kTextEncodingMacKorean :
- enc = wxFONTENCODING_MACKOREAN ;
- break ;
- case kTextEncodingMacArabic :
- enc =wxFONTENCODING_MACARABIC ;
- break ;
- case kTextEncodingMacHebrew :
- enc = wxFONTENCODING_MACHEBREW ;
- break ;
- case kTextEncodingMacGreek :
- enc = wxFONTENCODING_MACGREEK ;
- break ;
- case kTextEncodingMacCyrillic :
- enc = wxFONTENCODING_MACCYRILLIC ;
- break ;
- case kTextEncodingMacDevanagari :
- enc = wxFONTENCODING_MACDEVANAGARI ;
- break ;
- case kTextEncodingMacGurmukhi :
- enc = wxFONTENCODING_MACGURMUKHI ;
- break ;
- case kTextEncodingMacGujarati :
- enc = wxFONTENCODING_MACGUJARATI ;
- break ;
- case kTextEncodingMacOriya :
- enc =wxFONTENCODING_MACORIYA ;
- break ;
- case kTextEncodingMacBengali :
- enc =wxFONTENCODING_MACBENGALI ;
- break ;
- case kTextEncodingMacTamil :
- enc = wxFONTENCODING_MACTAMIL ;
- break ;
- case kTextEncodingMacTelugu :
- enc = wxFONTENCODING_MACTELUGU ;
- break ;
- case kTextEncodingMacKannada :
- enc = wxFONTENCODING_MACKANNADA ;
- break ;
- case kTextEncodingMacMalayalam :
- enc = wxFONTENCODING_MACMALAJALAM ;
- break ;
- case kTextEncodingMacSinhalese :
- enc = wxFONTENCODING_MACSINHALESE ;
- break ;
- case kTextEncodingMacBurmese :
- enc = wxFONTENCODING_MACBURMESE ;
- break ;
- case kTextEncodingMacKhmer :
- enc = wxFONTENCODING_MACKHMER ;
- break ;
- case kTextEncodingMacThai :
- enc = wxFONTENCODING_MACTHAI ;
- break ;
- case kTextEncodingMacLaotian :
- enc = wxFONTENCODING_MACLAOTIAN ;
- break ;
- case kTextEncodingMacGeorgian :
- enc = wxFONTENCODING_MACGEORGIAN ;
- break ;
- case kTextEncodingMacArmenian :
- enc = wxFONTENCODING_MACARMENIAN ;
- break ;
- case kTextEncodingMacChineseSimp :
- enc = wxFONTENCODING_MACCHINESESIMP ;
- break ;
- case kTextEncodingMacTibetan :
- enc = wxFONTENCODING_MACTIBETAN ;
- break ;
- case kTextEncodingMacMongolian :
- enc = wxFONTENCODING_MACMONGOLIAN ;
- break ;
- case kTextEncodingMacEthiopic :
- enc = wxFONTENCODING_MACETHIOPIC ;
- break ;
- case kTextEncodingMacCentralEurRoman:
- enc = wxFONTENCODING_MACCENTRALEUR ;
- break ;
- case kTextEncodingMacVietnamese:
- enc = wxFONTENCODING_MACVIATNAMESE ;
- break ;
- case kTextEncodingMacExtArabic :
- enc = wxFONTENCODING_MACARABICEXT ;
- break ;
- case kTextEncodingMacSymbol :
- enc = wxFONTENCODING_MACSYMBOL ;
- break ;
- case kTextEncodingMacDingbats :
- enc = wxFONTENCODING_MACDINGBATS ;
- break ;
- case kTextEncodingMacTurkish :
- enc = wxFONTENCODING_MACTURKISH ;
- break ;
- case kTextEncodingMacCroatian :
- enc = wxFONTENCODING_MACCROATIAN ;
- break ;
- case kTextEncodingMacIcelandic :
- enc = wxFONTENCODING_MACICELANDIC ;
- break ;
- case kTextEncodingMacRomanian :
- enc = wxFONTENCODING_MACROMANIAN ;
- break ;
- case kTextEncodingMacCeltic :
- enc = wxFONTENCODING_MACCELTIC ;
- break ;
- case kTextEncodingMacGaelic :
- enc = wxFONTENCODING_MACGAELIC ;
- break ;
- case kTextEncodingMacKeyboardGlyphs :
- enc = wxFONTENCODING_MACKEYBOARD ;
- break ;
- } ;
- return enc ;
-}
-
-#endif // wxUSE_BASE
-
-#if wxUSE_GUI
-
-
-//
-// CFStringRefs (Carbon only)
-//
-
-#if TARGET_CARBON
-
-// converts this string into a carbon foundation string with optional pc 2 mac encoding
-void wxMacCFStringHolder::Assign( const wxString &st , wxFontEncoding encoding )
-{
- Release() ;
-
- wxString str = st ;
- wxMacConvertNewlines13To10( &str ) ;
-#if wxUSE_UNICODE
-#if SIZEOF_WCHAR_T == 2
- m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault,
- (UniChar*)str.wc_str() , str.Len() );
-#else
- wxMBConvUTF16BE converter ;
- size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
- UniChar *unibuf = new UniChar[ unicharlen / sizeof(UniChar) + 1 ] ;
- converter.WC2MB( (char*)unibuf , str.wc_str() , unicharlen ) ;
- m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault ,
- unibuf , unicharlen / sizeof(UniChar) ) ;
- delete[] unibuf ;
-#endif
-#else // not wxUSE_UNICODE
- m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() ,
- wxMacGetSystemEncFromFontEnc( encoding ) ) ;
-#endif
- m_release = true ;
-}
-
-wxString wxMacCFStringHolder::AsString(wxFontEncoding encoding)
-{
- Size cflen = CFStringGetLength( m_cfs ) ;
- size_t noChars ;
- wxChar* buf = NULL ;
-
-#if wxUSE_UNICODE
-#if SIZEOF_WCHAR_T == 2
- buf = new wxChar[ cflen + 1 ] ;
- CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) buf ) ;
- noChars = cflen ;
-#else
- UniChar* unibuf = new UniChar[ cflen + 1 ] ;
- CFStringGetCharacters( m_cfs , CFRangeMake( 0 , cflen ) , (UniChar*) unibuf ) ;
- unibuf[cflen] = 0 ;
- wxMBConvUTF16BE converter ;
- noChars = converter.MB2WC( NULL , (const char*)unibuf , 0 ) ;
- buf = new wxChar[ noChars + 1 ] ;
- converter.MB2WC( buf , (const char*)unibuf , noChars ) ;
- delete[] unibuf ;
-#endif
-#else
- CFIndex cStrLen ;
- CFStringGetBytes( m_cfs , CFRangeMake(0, cflen) , wxMacGetSystemEncFromFontEnc( encoding ) ,
- '?' , false , NULL , 0 , &cStrLen ) ;
- buf = new wxChar[ cStrLen + 1 ] ;
- CFStringGetBytes( m_cfs , CFRangeMake(0, cflen) , wxMacGetSystemEncFromFontEnc( encoding ) ,
- '?' , false , (unsigned char*) buf , cStrLen , &cStrLen) ;
- noChars = cStrLen ;
-#endif
-
- buf[noChars] = 0 ;
- wxMacConvertNewlines10To13( buf ) ;
- wxString result(buf) ;
- delete[] buf ;
- return result ;
-}
-
-#endif //TARGET_CARBON
-
-void wxMacConvertNewlines13To10( char * data )
-{
- char * buf = data ;
- while( (buf=strchr(buf,0x0d)) != NULL )
- {
- *buf = 0x0a ;
- buf++ ;
- }
-}
-
-void wxMacConvertNewlines10To13( char * data )
-{
- char * buf = data ;
- while( (buf=strchr(buf,0x0a)) != NULL )
- {
- *buf = 0x0d ;
- buf++ ;
- }
-}
-
-void wxMacConvertNewlines13To10( wxString * data )
-{
- size_t len = data->length() ;
-
- if ( len == 0 || wxStrchr(data->c_str(),0x0d)==NULL)
- return ;
-
- wxString temp(*data) ;
- wxStringBuffer buf(*data,len ) ;
- memcpy( buf , temp.c_str() , (len+1)*sizeof(wxChar) ) ;
-
- wxMacConvertNewlines13To10( buf ) ;
-}
-
-void wxMacConvertNewlines10To13( wxString * data )
-{
- size_t len = data->length() ;
-
- if ( data->empty() || wxStrchr(data->c_str(),0x0a)==NULL)
- return ;
-
- wxString temp(*data) ;
- wxStringBuffer buf(*data,len ) ;
- memcpy( buf , temp.c_str() , (len+1)*sizeof(wxChar) ) ;
- wxMacConvertNewlines10To13( buf ) ;
-}
-
-
-#if wxUSE_UNICODE
-void wxMacConvertNewlines13To10( wxChar * data )
-{
- wxChar * buf = data ;
- while( (buf=wxStrchr(buf,0x0d)) != NULL )
- {
- *buf = 0x0a ;
- buf++ ;
- }
-}
-
-void wxMacConvertNewlines10To13( wxChar * data )
-{
- wxChar * buf = data ;
- while( (buf=wxStrchr(buf,0x0a)) != NULL )
- {
- *buf = 0x0d ;
- buf++ ;
- }
-}
-#endif
-
-// ----------------------------------------------------------------------------
-// debugging support
-// ----------------------------------------------------------------------------
-
-#if defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
-
-// MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds...
-
-#ifndef __MetroNubUtils__
-#include "MetroNubUtils.h"
-#endif
-
-#ifndef __GESTALT__
-#include <Gestalt.h>
-#endif
-
-#if TARGET_API_MAC_CARBON
-
- #include <CodeFragments.h>
-
- extern "C" long CallUniversalProc(UniversalProcPtr theProcPtr, ProcInfoType procInfo, ...);
-
- ProcPtr gCallUniversalProc_Proc = NULL;
-
-#endif
-
-static MetroNubUserEntryBlock* gMetroNubEntry = NULL;
-
-static long fRunOnce = false;
-
-/* ---------------------------------------------------------------------------
- IsMetroNubInstalled
- --------------------------------------------------------------------------- */
-
-Boolean IsMetroNubInstalled()
-{
- if (!fRunOnce)
- {
- long result, value;
-
- fRunOnce = true;
- gMetroNubEntry = NULL;
-
- if (Gestalt(gestaltSystemVersion, &value) == noErr && value < 0x1000)
- {
- /* look for MetroNub's Gestalt selector */
- if (Gestalt(kMetroNubUserSignature, &result) == noErr)
- {
-
- #if TARGET_API_MAC_CARBON
- if (gCallUniversalProc_Proc == NULL)
- {
- CFragConnectionID connectionID;
- Ptr mainAddress;
- Str255 errorString;
- ProcPtr symbolAddress;
- OSErr err;
- CFragSymbolClass symbolClass;
-
- symbolAddress = NULL;
- err = GetSharedLibrary("\pInterfaceLib", kPowerPCCFragArch, kFindCFrag,
- &connectionID, &mainAddress, errorString);
-
- if (err != noErr)
- {
- gCallUniversalProc_Proc = NULL;
- goto end;
- }
-
- err = FindSymbol(connectionID, "\pCallUniversalProc",
- (Ptr *) &gCallUniversalProc_Proc, &symbolClass);
-
- if (err != noErr)
- {
- gCallUniversalProc_Proc = NULL;
- goto end;
- }
- }
- #endif
-
- {
- MetroNubUserEntryBlock* block = (MetroNubUserEntryBlock *)result;
-
- /* make sure the version of the API is compatible */
- if (block->apiLowVersion <= kMetroNubUserAPIVersion &&
- kMetroNubUserAPIVersion <= block->apiHiVersion)
- gMetroNubEntry = block; /* success! */
- }
-
- }
- }
- }
-
-end:
-
-#if TARGET_API_MAC_CARBON
- return (gMetroNubEntry != NULL && gCallUniversalProc_Proc != NULL);
-#else
- return (gMetroNubEntry != NULL);
-#endif
-}
-
-/* ---------------------------------------------------------------------------
- IsMWDebuggerRunning [v1 API]
- --------------------------------------------------------------------------- */
-
-Boolean IsMWDebuggerRunning()
-{
- if (IsMetroNubInstalled())
- return CallIsDebuggerRunningProc(gMetroNubEntry->isDebuggerRunning);
- else
- return false;
-}
-
-/* ---------------------------------------------------------------------------
- AmIBeingMWDebugged [v1 API]
- --------------------------------------------------------------------------- */
-
-Boolean AmIBeingMWDebugged()
-{
- if (IsMetroNubInstalled())
- return CallAmIBeingDebuggedProc(gMetroNubEntry->amIBeingDebugged);
- else
- return false;
-}
-
-extern bool WXDLLEXPORT wxIsDebuggerRunning()
-{
- return IsMWDebuggerRunning() && AmIBeingMWDebugged();
-}
-
-#else
-
-extern bool WXDLLEXPORT wxIsDebuggerRunning()
-{
- return false;
-}
-
-#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400)
-
-#endif // wxUSE_GUI
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/utilsexec.cpp
-// Purpose: Execution-related utilities
-// Author: Stefan Csomor
-// Modified by: David Elliott
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/utils.h"
-
-#ifndef WX_PRECOMP
- #include "wx/log.h"
-#endif
-
-#ifdef __DARWIN__
-#include "wx/unix/execute.h"
-#include <unistd.h>
-#include <sys/wait.h>
-extern "C" {
-#include <mach/mach.h>
-}
-#include <CoreFoundation/CFMachPort.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef __DARWIN__
-#define wxEXECUTE_WIN_MESSAGE 10000
-
-#include "wx/mac/private.h"
-
-/*
-Below FinderLaunch function comes from:
-http://developer.apple.com/technotes/tn/tn1002.html#fndrask
-*/
- /* FinderLaunch converts a list of nTargets FSSpec records
- pointed to by the targetList parameter and converts the
- list to an Apple Event. It then sends that event to the
- Finder. The array of FSSpec records pointed to by the
- targetList parameter may contain references to files,
- folders, or applications. The net effect of this command
- is equivalent to the user selecting an icon in one of the
- Finder's windows and then choosing the open command from
- the Finder's file menu. */
-static OSErr FinderLaunch(long nTargets, FSSpec *targetList) {
- OSErr err;
- AppleEvent theAEvent, theReply;
- AEAddressDesc fndrAddress;
- AEDescList targetListDesc;
- OSType fndrCreator;
- Boolean wasChanged;
- AliasHandle targetAlias;
- long index;
-
- /* set up locals */
- AECreateDesc(typeNull, NULL, 0, &theAEvent);
- AECreateDesc(typeNull, NULL, 0, &fndrAddress);
- AECreateDesc(typeNull, NULL, 0, &theReply);
- AECreateDesc(typeNull, NULL, 0, &targetListDesc);
- targetAlias = NULL;
- fndrCreator = 'MACS';
-
- /* verify parameters */
- if ((nTargets == 0) || (targetList == NULL)) {
- err = paramErr;
- goto bail;
- }
-
- /* create an open documents event targeting the
- finder */
- err = AECreateDesc(typeApplSignature, (Ptr) &fndrCreator,
- sizeof(fndrCreator), &fndrAddress);
- if (err != noErr) goto bail;
- err = AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments,
- &fndrAddress, kAutoGenerateReturnID,
- kAnyTransactionID, &theAEvent);
- if (err != noErr) goto bail;
-
- /* create the list of files to open */
- err = AECreateList(NULL, 0, false, &targetListDesc);
- if (err != noErr) goto bail;
- for ( index=0; index < nTargets; index++) {
- if (targetAlias == NULL)
- err = NewAlias(NULL, (targetList + index),
- &targetAlias);
- else err = UpdateAlias(NULL, (targetList + index),
- targetAlias, &wasChanged);
- if (err != noErr) goto bail;
- HLock((Handle) targetAlias);
- err = AEPutPtr(&targetListDesc, (index + 1),
- typeAlias, *targetAlias,
- GetHandleSize((Handle) targetAlias));
- HUnlock((Handle) targetAlias);
- if (err != noErr) goto bail;
- }
-
- /* add the file list to the Apple Event */
- err = AEPutParamDesc(&theAEvent, keyDirectObject,
- &targetListDesc);
- if (err != noErr) goto bail;
-
- /* send the event to the Finder */
- err = AESend(&theAEvent, &theReply, kAENoReply,
- kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
-
- /* clean up and leave */
-bail:
- if (targetAlias != NULL) DisposeHandle((Handle) targetAlias);
- AEDisposeDesc(&targetListDesc);
- AEDisposeDesc(&theAEvent);
- AEDisposeDesc(&fndrAddress);
- AEDisposeDesc(&theReply);
- return err;
-}
-
-long wxExecute(const wxString& command, int flags, wxProcess *WXUNUSED(handler))
-{
- wxASSERT_MSG( flags == wxEXEC_ASYNC,
- wxT("wxExecute: Only wxEXEC_ASYNC is supported") );
-
- FSSpec fsSpec;
- wxMacFilename2FSSpec(command, &fsSpec);
-
- // 0 means execution failed. Returning non-zero is a PID, but not
- // on Mac where PIDs are 64 bits and won't fit in a long, so we
- // return a dummy value for now.
- return ( FinderLaunch(1 /*one file*/, &fsSpec) == noErr ) ? -1 : 0;
-}
-
-#endif
-
-#ifdef __DARWIN__
-void wxMAC_MachPortEndProcessDetect(CFMachPortRef port, void *data)
-{
- wxEndProcessData *proc_data = (wxEndProcessData*)data;
- wxLogDebug(wxT("Wow.. this actually worked!"));
- int status = 0;
- int rc = waitpid(abs(proc_data->pid), &status, WNOHANG);
- if(!rc)
- {
- wxLogDebug(wxT("Mach port was invalidated, but process hasn't terminated!"));
- return;
- }
- if((rc != -1) && WIFEXITED(status))
- proc_data->exitcode = WEXITSTATUS(status);
- else
- proc_data->exitcode = -1;
- wxHandleProcessTermination(proc_data);
-}
-
-int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid)
-{
- if(pid < 1)
- return -1;
- kern_return_t kernResult;
- mach_port_t taskOfOurProcess;
- mach_port_t machPortForProcess;
- taskOfOurProcess = mach_task_self();
- if(taskOfOurProcess == MACH_PORT_NULL)
- {
- wxLogDebug(wxT("No mach_task_self()"));
- return -1;
- }
- wxLogDebug(wxT("pid=%d"),pid);
- kernResult = task_for_pid(taskOfOurProcess,pid, &machPortForProcess);
- if(kernResult != KERN_SUCCESS)
- {
- wxLogDebug(wxT("no task_for_pid()"));
- // try seeing if it is already dead or something
- // FIXME: a better method would be to call the callback function
- // from idle time until the process terminates. Of course, how
- // likely is it that it will take more than 0.1 seconds for the
- // mach terminate event to make its way to the BSD subsystem?
- usleep(100); // sleep for 0.1 seconds
- wxMAC_MachPortEndProcessDetect(NULL, (void*)proc_data);
- return -1;
- }
- CFMachPortContext termcb_contextinfo;
- termcb_contextinfo.version = NULL;
- termcb_contextinfo.info = (void*)proc_data;
- termcb_contextinfo.retain = NULL;
- termcb_contextinfo.release = NULL;
- termcb_contextinfo.copyDescription = NULL;
- CFMachPortRef CFMachPortForProcess;
- Boolean ShouldFreePort;
- CFMachPortForProcess = CFMachPortCreateWithPort(NULL, machPortForProcess, NULL, &termcb_contextinfo, &ShouldFreePort);
- if(!CFMachPortForProcess)
- {
- wxLogDebug(wxT("No CFMachPortForProcess"));
- mach_port_deallocate(taskOfOurProcess, machPortForProcess);
- return -1;
- }
- if(ShouldFreePort)
- {
- kernResult = mach_port_deallocate(taskOfOurProcess, machPortForProcess);
- if(kernResult!=KERN_SUCCESS)
- {
- wxLogDebug(wxT("Couldn't deallocate mach port"));
- return -1;
- }
- }
- CFMachPortSetInvalidationCallBack(CFMachPortForProcess, &wxMAC_MachPortEndProcessDetect);
- CFRunLoopSourceRef runloopsource;
- runloopsource = CFMachPortCreateRunLoopSource(NULL,CFMachPortForProcess, (CFIndex)0);
- if(!runloopsource)
- {
- wxLogDebug(wxT("Couldn't create runloopsource"));
- return -1;
- }
-
- CFRelease(CFMachPortForProcess);
-
- CFRunLoopAddSource(CFRunLoopGetCurrent(),runloopsource,kCFRunLoopDefaultMode);
- CFRelease(runloopsource);
- wxLogDebug(wxT("Successfully added notification to the runloop"));
- return 0;
-}
-#endif
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: src/mac/classic/window.cpp
-// Purpose: wxWindowMac
-// Author: Stefan Csomor
-// Modified by:
-// Created: 1998-01-01
-// RCS-ID: $Id$
-// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-#include "wx/wxprec.h"
-
-#include "wx/window.h"
-
-#ifndef WX_PRECOMP
- #include "wx/log.h"
- #include "wx/app.h"
- #include "wx/utils.h"
- #include "wx/panel.h"
- #include "wx/frame.h"
- #include "wx/dc.h"
- #include "wx/dcclient.h"
- #include "wx/button.h"
- #include "wx/menu.h"
- #include "wx/dialog.h"
- #include "wx/settings.h"
- #include "wx/msgdlg.h"
- #include "wx/scrolbar.h"
- #include "wx/statbox.h"
- #include "wx/listbox.h"
- #include "wx/layout.h"
- #include "wx/statusbr.h"
- #include "wx/menuitem.h"
-#endif
-
-#include "wx/notebook.h"
-#include "wx/tabctrl.h"
-#include "wx/tooltip.h"
-#include "wx/spinctrl.h"
-#include "wx/geometry.h"
-
-#if wxUSE_CARET
- #include "wx/caret.h"
-#endif // wxUSE_CARET
-
-#define wxWINDOW_HSCROLL 5998
-#define wxWINDOW_VSCROLL 5997
-#define MAC_SCROLLBAR_SIZE 16
-
-#include "wx/mac/uma.h"
-#ifndef __DARWIN__
-#include <Windows.h>
-#include <ToolUtils.h>
-#endif
-
-#if wxUSE_DRAG_AND_DROP
-#include "wx/dnd.h"
-#endif
-
-#include <string.h>
-
-wxWindowMac* gFocusWindow = NULL ;
-
-#ifdef __WXUNIVERSAL__
- IMPLEMENT_ABSTRACT_CLASS(wxWindowMac, wxWindowBase)
-#else // __WXMAC__
- IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
-#endif // __WXUNIVERSAL__/__WXMAC__
-
-BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
- EVT_NC_PAINT(wxWindowMac::OnNcPaint)
- EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
- EVT_SET_FOCUS(wxWindowMac::OnSetFocus)
- EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
-END_EVENT_TABLE()
-
-#define wxMAC_DEBUG_REDRAW 0
-#ifndef wxMAC_DEBUG_REDRAW
-#define wxMAC_DEBUG_REDRAW 0
-#endif
-
-#define wxMAC_USE_THEME_BORDER 0
-
-
-// ===========================================================================
-// implementation
-// ===========================================================================
-
-
-// ----------------------------------------------------------------------------
-// constructors and such
-// ----------------------------------------------------------------------------
-
-void wxWindowMac::Init()
-{
- m_backgroundTransparent = false;
-
- // as all windows are created with WS_VISIBLE style...
- m_isShown = true;
-
- m_x = 0;
- m_y = 0 ;
- m_width = 0 ;
- m_height = 0 ;
-
- m_hScrollBar = NULL ;
- m_vScrollBar = NULL ;
-}
-
-// Destructor
-wxWindowMac::~wxWindowMac()
-{
- SendDestroyEvent();
-
- // deleting a window while it is shown invalidates the region
- if ( IsShown() ) {
- wxWindowMac* iter = this ;
- while( iter ) {
- if ( iter->IsTopLevel() )
- {
- Refresh() ;
- break ;
- }
- iter = iter->GetParent() ;
-
- }
- }
-
- m_isBeingDeleted = true;
-
-#ifndef __WXUNIVERSAL__
- // VS: make sure there's no wxFrame with last focus set to us:
- for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
- {
- wxFrame *frame = wxDynamicCast(win, wxFrame);
- if ( frame )
- {
- if ( frame->GetLastFocus() == this )
- {
- frame->SetLastFocus((wxWindow*)NULL);
- }
- break;
- }
- }
-#endif // __WXUNIVERSAL__
-
- if ( s_lastMouseWindow == this )
- {
- s_lastMouseWindow = NULL ;
- }
-
- wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ;
- if ( frame )
- {
- if ( frame->GetLastFocus() == this )
- frame->SetLastFocus( NULL ) ;
- }
-
- if ( gFocusWindow == this )
- {
- gFocusWindow = NULL ;
- }
-
- DestroyChildren();
-
- // delete our drop target if we've got one
-#if wxUSE_DRAG_AND_DROP
- if ( m_dropTarget != NULL )
- {
- delete m_dropTarget;
- m_dropTarget = NULL;
- }
-#endif // wxUSE_DRAG_AND_DROP
-}
-
-// Constructor
-bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
-{
- wxCHECK_MSG( parent, false, wxT("can't create wxWindowMac without parent") );
-
-#if wxUSE_STATBOX
- // wxGTK doesn't allow to create controls with static box as the parent so
- // this will result in a crash when the program is ported to wxGTK - warn
- // about it
- //
- // the correct solution is to create the controls as siblings of the
- // static box
- wxASSERT_MSG( !wxDynamicCast(parent, wxStaticBox),
- _T("wxStaticBox can't be used as a window parent!") );
-#endif // wxUSE_STATBOX
-
- if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
- return false;
-
- parent->AddChild(this);
-
- m_x = (int)pos.x;
- m_y = (int)pos.y;
- AdjustForParentClientOrigin(m_x, m_y, wxSIZE_USE_EXISTING);
- m_width = WidthDefault( size.x );
- m_height = HeightDefault( size.y ) ;
-#ifndef __WXUNIVERSAL__
- // Don't give scrollbars to wxControls unless they ask for them
- if ( (! IsKindOf(CLASSINFO(wxControl)) && ! IsKindOf(CLASSINFO(wxStatusBar))) ||
- (IsKindOf(CLASSINFO(wxControl)) && ( style & wxHSCROLL || style & wxVSCROLL)))
- {
- MacCreateScrollBars( style ) ;
- }
-#endif
-
- wxWindowCreateEvent event(this);
- GetEventHandler()->AddPendingEvent(event);
-
- return true;
-}
-
-void wxWindowMac::SetFocus()
-{
- if ( gFocusWindow == this )
- return ;
-
- if ( AcceptsFocus() )
- {
- if (gFocusWindow )
- {
-#if wxUSE_CARET
- // Deal with caret
- if ( gFocusWindow->m_caret )
- {
- gFocusWindow->m_caret->OnKillFocus();
- }
-#endif // wxUSE_CARET
-#ifndef __WXUNIVERSAL__
- wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
- if ( control && control->GetMacControl() )
- {
- UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl() , kControlFocusNoPart ) ;
- control->MacRedrawControl() ;
- }
-#endif
- // Without testing the window id, for some reason
- // a kill focus event can still be sent to
- // the control just being focussed.
- int thisId = this->m_windowId;
- int gFocusWindowId = gFocusWindow->m_windowId;
- if (gFocusWindowId != thisId)
- {
- wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId);
- event.SetEventObject(gFocusWindow);
- gFocusWindow->GetEventHandler()->ProcessEvent(event) ;
- }
- }
- gFocusWindow = this ;
- {
- #if wxUSE_CARET
- // Deal with caret
- if ( m_caret )
- {
- m_caret->OnSetFocus();
- }
- #endif // wxUSE_CARET
- // panel wants to track the window which was the last to have focus in it
- wxChildFocusEvent eventFocus(this);
- GetEventHandler()->ProcessEvent(eventFocus);
-
-#ifndef __WXUNIVERSAL__
- wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
- if ( control && control->GetMacControl() )
- {
- UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl() , kControlFocusNextPart ) ;
- }
-#endif
- wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event) ;
- }
- }
-}
-
-bool wxWindowMac::Enable(bool enable)
-{
- if ( !wxWindowBase::Enable(enable) )
- return false;
-
- MacSuperEnabled( enable ) ;
-
- return true;
-}
-
-void wxWindowMac::DoCaptureMouse()
-{
- wxTheApp->s_captureWindow = this ;
-}
-
-wxWindow* wxWindowBase::GetCapture()
-{
- return wxTheApp->s_captureWindow ;
-}
-
-void wxWindowMac::DoReleaseMouse()
-{
- wxTheApp->s_captureWindow = NULL ;
-}
-
-#if wxUSE_DRAG_AND_DROP
-
-void wxWindowMac::SetDropTarget(wxDropTarget *pDropTarget)
-{
- if ( m_dropTarget != 0 ) {
- delete m_dropTarget;
- }
-
- m_dropTarget = pDropTarget;
- if ( m_dropTarget != 0 )
- {
- // TODO
- }
-}
-
-#endif
-
-// Old style file-manager drag&drop
-void wxWindowMac::DragAcceptFiles(bool accept)
-{
- // TODO
-}
-
-// Get total size
-void wxWindowMac::DoGetSize(int *x, int *y) const
-{
- if(x) *x = m_width ;
- if(y) *y = m_height ;
-}
-
-void wxWindowMac::DoGetPosition(int *x, int *y) const
-{
- int xx,yy;
-
- xx = m_x ;
- yy = m_y ;
- if ( !IsTopLevel() && GetParent())
- {
- wxPoint pt(GetParent()->GetClientAreaOrigin());
- xx -= pt.x;
- yy -= pt.y;
- }
- if(x) *x = xx;
- if(y) *y = yy;
-}
-
-#if wxUSE_MENUS
-bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
-{
- menu->SetInvokingWindow(this);
- menu->UpdateUI();
-
- if ( x == -1 && y == -1 )
- {
- wxPoint mouse = wxGetMousePosition();
- x = mouse.x; y = mouse.y;
- }
- else
- {
- ClientToScreen( &x , &y ) ;
- }
-
- menu->MacBeforeDisplay( true ) ;
- long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ;
- if ( HiWord(menuResult) != 0 )
- {
- MenuCommand id ;
- GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ;
- wxMenuItem* item = NULL ;
- wxMenu* realmenu ;
- item = menu->FindItem(id, &realmenu) ;
- if (item->IsCheckable())
- {
- item->Check( !item->IsChecked() ) ;
- }
- menu->SendEvent( id , item->IsCheckable() ? item->IsChecked() : -1 ) ;
- }
- menu->MacAfterDisplay( true ) ;
-
- menu->SetInvokingWindow(NULL);
-
- return true;
-}
-#endif
-
-void wxWindowMac::DoScreenToClient(int *x, int *y) const
-{
- WindowRef window = (WindowRef) MacGetRootWindow() ;
-
- Point localwhere = {0,0} ;
-
- if(x) localwhere.h = * x ;
- if(y) localwhere.v = * y ;
-
- GrafPtr port ;
- ::GetPort( &port ) ;
- ::SetPort( UMAGetWindowPort( window ) ) ;
- ::GlobalToLocal( &localwhere ) ;
- ::SetPort( port ) ;
-
- if(x) *x = localwhere.h ;
- if(y) *y = localwhere.v ;
-
- MacRootWindowToWindow( x , y ) ;
- if ( x )
- *x -= MacGetLeftBorderSize() ;
- if ( y )
- *y -= MacGetTopBorderSize() ;
-}
-
-void wxWindowMac::DoClientToScreen(int *x, int *y) const
-{
- WindowRef window = (WindowRef) MacGetRootWindow() ;
-
- if ( x )
- *x += MacGetLeftBorderSize() ;
- if ( y )
- *y += MacGetTopBorderSize() ;
-
- MacWindowToRootWindow( x , y ) ;
-
- Point localwhere = { 0,0 };
- if(x) localwhere.h = * x ;
- if(y) localwhere.v = * y ;
-
- GrafPtr port ;
- ::GetPort( &port ) ;
- ::SetPort( UMAGetWindowPort( window ) ) ;
-
- ::LocalToGlobal( &localwhere ) ;
- ::SetPort( port ) ;
- if(x) *x = localwhere.h ;
- if(y) *y = localwhere.v ;
-}
-
-void wxWindowMac::MacClientToRootWindow( int *x , int *y ) const
-{
- wxPoint origin = GetClientAreaOrigin() ;
- if(x) *x += origin.x ;
- if(y) *y += origin.y ;
-
- MacWindowToRootWindow( x , y ) ;
-}
-
-void wxWindowMac::MacRootWindowToClient( int *x , int *y ) const
-{
- wxPoint origin = GetClientAreaOrigin() ;
- MacRootWindowToWindow( x , y ) ;
- if(x) *x -= origin.x ;
- if(y) *y -= origin.y ;
-}
-
-void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const
-{
- if ( !IsTopLevel() )
- {
- if(x) *x += m_x ;
- if(y) *y += m_y ;
- GetParent()->MacWindowToRootWindow( x , y ) ;
- }
-}
-
-void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const
-{
- if ( !IsTopLevel() )
- {
- if(x) *x -= m_x ;
- if(y) *y -= m_y ;
- GetParent()->MacRootWindowToWindow( x , y ) ;
- }
-}
-
-bool wxWindowMac::SetCursor(const wxCursor& cursor)
-{
- if (m_cursor == cursor)
- return false;
-
- if (wxNullCursor == cursor)
- {
- if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) )
- return false ;
- }
- else
- {
- if ( ! wxWindowBase::SetCursor( cursor ) )
- return false ;
- }
-
- wxASSERT_MSG( m_cursor.Ok(),
- wxT("cursor must be valid after call to the base version"));
-
- Point pt ;
- wxWindowMac *mouseWin ;
- GetMouse( &pt ) ;
-
- // Change the cursor NOW if we're within the correct window
-
- if ( MacGetWindowFromPoint( wxPoint( pt.h , pt.v ) , &mouseWin ) )
- {
- if ( mouseWin == this && !wxIsBusy() )
- {
- m_cursor.MacInstall() ;
- }
- }
-
- return true ;
-}
-
-
-// Get size *available for subwindows* i.e. excluding menu bar etc.
-void wxWindowMac::DoGetClientSize(int *x, int *y) const
-{
- int ww, hh;
- ww = m_width ;
- hh = m_height ;
-
- ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
- hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
-
- if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) )
- {
- int x1 = 0 ;
- int y1 = 0 ;
- int w = m_width ;
- int h = m_height ;
-
- MacClientToRootWindow( &x1 , &y1 ) ;
- MacClientToRootWindow( &w , &h ) ;
-
- wxWindowMac *iter = (wxWindowMac*)this ;
-
- int totW = 10000 , totH = 10000;
- while( iter )
- {
- if ( iter->IsTopLevel() )
- {
- totW = iter->m_width ;
- totH = iter->m_height ;
- break ;
- }
-
- iter = iter->GetParent() ;
- }
-
- if (m_hScrollBar && m_hScrollBar->IsShown() )
- {
- hh -= MAC_SCROLLBAR_SIZE;
- if ( h-y1 >= totH )
- {
- hh += 1 ;
- }
- }
- if (m_vScrollBar && m_vScrollBar->IsShown() )
- {
- ww -= MAC_SCROLLBAR_SIZE;
- if ( w-x1 >= totW )
- {
- ww += 1 ;
- }
- }
- }
- if(x) *x = ww;
- if(y) *y = hh;
-}
-
-
-// ----------------------------------------------------------------------------
-// tooltips
-// ----------------------------------------------------------------------------
-
-#if wxUSE_TOOLTIPS
-
-void wxWindowMac::DoSetToolTip(wxToolTip *tooltip)
-{
- wxWindowBase::DoSetToolTip(tooltip);
-
- if ( m_tooltip )
- m_tooltip->SetWindow(this);
-}
-
-#endif // wxUSE_TOOLTIPS
-
-void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
-{
- int former_x = m_x ;
- int former_y = m_y ;
- int former_w = m_width ;
- int former_h = m_height ;
-
- int actualWidth = width;
- int actualHeight = height;
- int actualX = x;
- int actualY = y;
-
- if ((m_minWidth != -1) && (actualWidth < m_minWidth))
- actualWidth = m_minWidth;
- if ((m_minHeight != -1) && (actualHeight < m_minHeight))
- actualHeight = m_minHeight;
- if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
- actualWidth = m_maxWidth;
- if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
- actualHeight = m_maxHeight;
-
- bool doMove = false ;
- bool doResize = false ;
-
- if ( actualX != former_x || actualY != former_y )
- {
- doMove = true ;
- }
- if ( actualWidth != former_w || actualHeight != former_h )
- {
- doResize = true ;
- }
-
- if ( doMove || doResize )
- {
- // erase former position
-
- bool partialRepaint = false ;
-
- if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) )
- {
- wxPoint oldPos( m_x , m_y ) ;
- wxPoint newPos( actualX , actualY ) ;
- MacWindowToRootWindow( &oldPos.x , &oldPos.y ) ;
- MacWindowToRootWindow( &newPos.x , &newPos.y ) ;
- if ( oldPos == newPos )
- {
- partialRepaint = true ;
- RgnHandle oldRgn,newRgn,diffRgn ;
- oldRgn = NewRgn() ;
- newRgn = NewRgn() ;
- diffRgn = NewRgn() ;
-
- // invalidate the differences between the old and the new area
-
- SetRectRgn(oldRgn , oldPos.x , oldPos.y , oldPos.x + m_width , oldPos.y + m_height ) ;
- SetRectRgn(newRgn , newPos.x , newPos.y , newPos.x + actualWidth , newPos.y + actualHeight ) ;
- DiffRgn( newRgn , oldRgn , diffRgn ) ;
- InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
- DiffRgn( oldRgn , newRgn , diffRgn ) ;
- InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
-
- // we also must invalidate the border areas, someone might optimize this one day to invalidate only the really
- // changing pixels...
-
- if ( MacGetLeftBorderSize() != 0 || MacGetRightBorderSize() != 0 ||
- MacGetTopBorderSize() != 0 || MacGetBottomBorderSize() != 0 )
- {
- RgnHandle innerOldRgn, innerNewRgn ;
- innerOldRgn = NewRgn() ;
- innerNewRgn = NewRgn() ;
-
- SetRectRgn(innerOldRgn , oldPos.x + MacGetLeftBorderSize() , oldPos.y + MacGetTopBorderSize() ,
- oldPos.x + m_width - MacGetRightBorderSize() , oldPos.y + m_height - MacGetBottomBorderSize() ) ;
- DiffRgn( oldRgn , innerOldRgn , diffRgn ) ;
- InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
-
- SetRectRgn(innerNewRgn , newPos.x + MacGetLeftBorderSize() , newPos.y + MacGetTopBorderSize() ,
- newPos.x + actualWidth - MacGetRightBorderSize() , newPos.y + actualHeight - MacGetBottomBorderSize() ) ;
- DiffRgn( newRgn , innerNewRgn , diffRgn ) ;
- InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
-
- DisposeRgn( innerOldRgn ) ;
- DisposeRgn( innerNewRgn ) ;
- }
-
- DisposeRgn(oldRgn) ;
- DisposeRgn(newRgn) ;
- DisposeRgn(diffRgn) ;
- }
- }
-
- if ( !partialRepaint )
- Refresh() ;
-
- m_x = actualX ;
- m_y = actualY ;
- m_width = actualWidth ;
- m_height = actualHeight ;
-
- // update any low-level frame-relative positions
-
- MacUpdateDimensions() ;
- // erase new position
-
- if ( !partialRepaint )
- Refresh() ;
- if ( doMove )
- wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
-
- MacRepositionScrollBars() ;
- if ( doMove )
- {
- wxPoint point(m_x, m_y);
- wxMoveEvent event(point, m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event) ;
- }
- if ( doResize )
- {
- MacRepositionScrollBars() ;
- wxSize size(m_width, m_height);
- wxSizeEvent event(size, m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
- }
- }
-
-}
-
-// set the size of the window: if the dimensions are positive, just use them,
-// but if any of them is equal to -1, it means that we must find the value for
-// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
-// which case -1 is a valid value for x and y)
-//
-// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
-// the width/height to best suit our contents, otherwise we reuse the current
-// width/height
-void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags)
-{
- // get the current size and position...
- int currentX, currentY;
- GetPosition(¤tX, ¤tY);
-
- int currentW,currentH;
- GetSize(¤tW, ¤tH);
-
- // ... and don't do anything (avoiding flicker) if it's already ok
- if ( x == currentX && y == currentY &&
- width == currentW && height == currentH )
- {
- MacRepositionScrollBars() ; // we might have a real position shift
- return;
- }
-
- if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
- x = currentX;
- if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
- y = currentY;
-
- AdjustForParentClientOrigin(x, y, sizeFlags);
-
- wxSize size(-1, -1);
- if ( width == -1 )
- {
- if ( sizeFlags & wxSIZE_AUTO_WIDTH )
- {
- size = DoGetBestSize();
- width = size.x;
- }
- else
- {
- // just take the current one
- width = currentW;
- }
- }
-
- if ( height == -1 )
- {
- if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
- {
- if ( size.x == -1 )
- {
- size = DoGetBestSize();
- }
- //else: already called DoGetBestSize() above
-
- height = size.y;
- }
- else
- {
- // just take the current one
- height = currentH;
- }
- }
-
- DoMoveWindow(x, y, width, height);
-
-}
-// For implementation purposes - sometimes decorations make the client area
-// smaller
-
-wxPoint wxWindowMac::GetClientAreaOrigin() const
-{
- return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
-}
-
-void wxWindowMac::SetLabel(const wxString& label)
-{
- m_label = label ;
-}
-
-wxString wxWindowMac::GetLabel() const
-{
- return m_label ;
-}
-
-bool wxWindowMac::Show(bool show)
-{
- if ( !wxWindowBase::Show(show) )
- return false;
-
- MacSuperShown( show ) ;
- Refresh() ;
-
- return true;
-}
-
-void wxWindowMac::MacSuperShown( bool show )
-{
- wxWindowListNode *node = GetChildren().GetFirst();
- while ( node )
- {
- wxWindowMac *child = node->GetData();
- if ( child->m_isShown )
- child->MacSuperShown( show ) ;
- node = node->GetNext();
- }
-}
-
-void wxWindowMac::MacSuperEnabled( bool enabled )
-{
- if ( !IsTopLevel() )
- {
- // to be absolutely correct we'd have to invalidate (with eraseBkground
- // because unter MacOSX the frames are drawn with an addXXX mode)
- // the borders area
- }
- wxWindowListNode *node = GetChildren().GetFirst();
- while ( node )
- {
- wxWindowMac *child = (wxWindowMac *)node->GetData();
- if ( child->m_isShown )
- child->MacSuperEnabled( enabled ) ;
- node = node->GetNext();
- }
-}
-
-bool wxWindowMac::MacIsReallyShown() const
-{
- if ( m_isShown && (m_parent != NULL && !IsTopLevel() ) ) {
- return m_parent->MacIsReallyShown();
- }
- return m_isShown;
-/*
- bool status = m_isShown ;
- wxWindowMac * win = this ;
- while ( status && win->m_parent != NULL )
- {
- win = win->m_parent ;
- status = win->m_isShown ;
- }
- return status ;
-*/
-}
-
-int wxWindowMac::GetCharHeight() const
-{
- wxClientDC dc ( (wxWindowMac*)this ) ;
- return dc.GetCharHeight() ;
-}
-
-int wxWindowMac::GetCharWidth() const
-{
- wxClientDC dc ( (wxWindowMac*)this ) ;
- return dc.GetCharWidth() ;
-}
-
-void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont ) const
-{
- const wxFont *fontToUse = theFont;
- if ( !fontToUse )
- fontToUse = &m_font;
-
- wxClientDC dc( (wxWindowMac*) this ) ;
- long lx,ly,ld,le ;
- dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
- if ( externalLeading )
- *externalLeading = le ;
- if ( descent )
- *descent = ld ;
- if ( x )
- *x = lx ;
- if ( y )
- *y = ly ;
-}
-
-/*
- * Rect is given in client coordinates, for further reading, read wxTopLevelWindowMac::InvalidateRect
- * we always intersect with the entire window, not only with the client area
- */
-
-void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect)
-{
- if ( MacGetTopLevelWindow() == NULL )
- return ;
-
- if ( !MacIsReallyShown() )
- return ;
-
- wxPoint client = GetClientAreaOrigin();
- int x1 = -client.x;
- int y1 = -client.y;
- int x2 = m_width - client.x;
- int y2 = m_height - client.y;
-
- if (IsKindOf( CLASSINFO(wxButton)))
- {
- // buttons have an "aura"
- y1 -= 5;
- x1 -= 5;
- y2 += 5;
- x2 += 5;
- }
-
- Rect clientrect = { y1, x1, y2, x2 };
-
- if ( rect )
- {
- Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ;
- SectRect( &clientrect , &r , &clientrect ) ;
- }
-
- if ( !EmptyRect( &clientrect ) )
- {
- int top = 0 , left = 0 ;
-
- MacClientToRootWindow( &left , &top ) ;
- OffsetRect( &clientrect , left , top ) ;
-
- MacGetTopLevelWindow()->MacInvalidate( &clientrect , eraseBack ) ;
- }
-}
-
-wxWindowMac *wxGetActiveWindow()
-{
- // actually this is a windows-only concept
- return NULL;
-}
-
-// Coordinates relative to the window
-void wxWindowMac::WarpPointer (int x_pos, int y_pos)
-{
- // We really don't move the mouse programmatically under Mac.
-}
-
-const wxBrush& wxWindowMac::MacGetBackgroundBrush()
-{
- if ( m_backgroundColour == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) )
- {
- m_macBackgroundBrush.SetMacTheme( kThemeBrushDocumentWindowBackground ) ;
- }
- else if ( m_backgroundColour == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
- {
- // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
- // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
- // either a non gray background color or a non control window
-
- WindowRef window = (WindowRef) MacGetRootWindow() ;
-
- wxWindowMac* parent = GetParent() ;
- while( parent )
- {
- if ( parent->MacGetRootWindow() != (WXWindow) window )
- {
- // we are in a different window on the mac system
- parent = NULL ;
- break ;
- }
-
- {
- if ( parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE )
- && parent->m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) )
- {
- // if we have any other colours in the hierarchy
- m_macBackgroundBrush.SetColour( parent->m_backgroundColour ) ;
- break ;
- }
- // if we have the normal colours in the hierarchy but another control etc. -> use it's background
- if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
- {
- Rect extent = { 0 , 0 , 0 , 0 } ;
- int x , y ;
- x = y = 0 ;
- wxSize size = parent->GetSize() ;
- parent->MacClientToRootWindow( &x , &y ) ;
- extent.left = x ;
- extent.top = y ;
- extent.top-- ;
- extent.right = x + size.x ;
- extent.bottom = y + size.y ;
- m_macBackgroundBrush.SetMacThemeBackground( kThemeBackgroundTabPane , (WXRECTPTR) &extent ) ; // todo eventually change for inactive
- break ;
- }
- }
- parent = parent->GetParent() ;
- }
- if ( !parent )
- {
- m_macBackgroundBrush.SetMacTheme( kThemeBrushDialogBackgroundActive ) ; // todo eventually change for inactive
- }
- }
- else
- {
- m_macBackgroundBrush.SetColour( m_backgroundColour ) ;
- }
-
- return m_macBackgroundBrush ;
-}
-
-void wxWindowMac::OnEraseBackground(wxEraseEvent& event)
-{
- event.GetDC()->Clear() ;
-}
-
-void wxWindowMac::OnNcPaint( wxNcPaintEvent& event )
-{
- wxWindowDC dc(this) ;
- wxMacPortSetter helper(&dc) ;
-
- MacPaintBorders( dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y) ;
-}
-
-int wxWindowMac::GetScrollPos(int orient) const
-{
- if ( orient == wxHORIZONTAL )
- {
- if ( m_hScrollBar )
- return m_hScrollBar->GetThumbPosition() ;
- }
- else
- {
- if ( m_vScrollBar )
- return m_vScrollBar->GetThumbPosition() ;
- }
- return 0;
-}
-
-// This now returns the whole range, not just the number
-// of positions that we can scroll.
-int wxWindowMac::GetScrollRange(int orient) const
-{
- if ( orient == wxHORIZONTAL )
- {
- if ( m_hScrollBar )
- return m_hScrollBar->GetRange() ;
- }
- else
- {
- if ( m_vScrollBar )
- return m_vScrollBar->GetRange() ;
- }
- return 0;
-}
-
-int wxWindowMac::GetScrollThumb(int orient) const
-{
- if ( orient == wxHORIZONTAL )
- {
- if ( m_hScrollBar )
- return m_hScrollBar->GetThumbSize() ;
- }
- else
- {
- if ( m_vScrollBar )
- return m_vScrollBar->GetThumbSize() ;
- }
- return 0;
-}
-
-void wxWindowMac::SetScrollPos(int orient, int pos, bool refresh)
-{
- if ( orient == wxHORIZONTAL )
- {
- if ( m_hScrollBar )
- m_hScrollBar->SetThumbPosition( pos ) ;
- }
- else
- {
- if ( m_vScrollBar )
- m_vScrollBar->SetThumbPosition( pos ) ;
- }
-}
-
-void wxWindowMac::MacPaintBorders( int left , int top )
-{
- if( IsTopLevel() )
- return ;
-
- int major,minor;
- wxGetOsVersion( &major, &minor );
-
- RGBColor white = { 0xFFFF, 0xFFFF , 0xFFFF } ;
- RGBColor face = { 0xDDDD, 0xDDDD , 0xDDDD } ;
-
- RGBColor darkShadow = { 0x0000, 0x0000 , 0x0000 } ;
- RGBColor lightShadow = { 0x4444, 0x4444 , 0x4444 } ;
- // OS X has lighter border edges than classic:
- if (major >= 10)
- {
- darkShadow.red = 0x8E8E;
- darkShadow.green = 0x8E8E;
- darkShadow.blue = 0x8E8E;
- lightShadow.red = 0xBDBD;
- lightShadow.green = 0xBDBD;
- lightShadow.blue = 0xBDBD;
- }
-
- PenNormal() ;
-
- if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
- {
-#if wxMAC_USE_THEME_BORDER
- Rect rect = { top , left , m_height + top , m_width + left } ;
- SInt32 border = 0 ;
- /*
- GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
- InsetRect( &rect , border , border );
- DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
- */
-
- DrawThemePrimaryGroup(&rect ,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
-#else
- bool sunken = HasFlag( wxSUNKEN_BORDER ) ;
- RGBForeColor( &face );
- MoveTo( left + 0 , top + m_height - 2 );
- LineTo( left + 0 , top + 0 );
- LineTo( left + m_width - 2 , top + 0 );
-
- MoveTo( left + 2 , top + m_height - 3 );
- LineTo( left + m_width - 3 , top + m_height - 3 );
- LineTo( left + m_width - 3 , top + 2 );
-
- RGBForeColor( sunken ? &face : &darkShadow );
- MoveTo( left + 0 , top + m_height - 1 );
- LineTo( left + m_width - 1 , top + m_height - 1 );
- LineTo( left + m_width - 1 , top + 0 );
-
- RGBForeColor( sunken ? &lightShadow : &white );
- MoveTo( left + 1 , top + m_height - 3 );
- LineTo( left + 1, top + 1 );
- LineTo( left + m_width - 3 , top + 1 );
-
- RGBForeColor( sunken ? &white : &lightShadow );
- MoveTo( left + 1 , top + m_height - 2 );
- LineTo( left + m_width - 2 , top + m_height - 2 );
- LineTo( left + m_width - 2 , top + 1 );
-
- RGBForeColor( sunken ? &darkShadow : &face );
- MoveTo( left + 2 , top + m_height - 4 );
- LineTo( left + 2 , top + 2 );
- LineTo( left + m_width - 4 , top + 2 );
-#endif
- }
- else if (HasFlag(wxSIMPLE_BORDER))
- {
- Rect rect = { top , left , m_height + top , m_width + left } ;
- RGBForeColor( &darkShadow ) ;
- FrameRect( &rect ) ;
- }
-}
-
-void wxWindowMac::RemoveChild( wxWindowBase *child )
-{
- if ( child == m_hScrollBar )
- m_hScrollBar = NULL ;
- if ( child == m_vScrollBar )
- m_vScrollBar = NULL ;
-
- wxWindowBase::RemoveChild( child ) ;
-}
-
-// New function that will replace some of the above.
-void wxWindowMac::SetScrollbar(int orient, int pos, int thumbVisible,
- int range, bool refresh)
-{
- if ( orient == wxHORIZONTAL )
- {
- if ( m_hScrollBar )
- {
- if ( range == 0 || thumbVisible >= range )
- {
- if ( m_hScrollBar->IsShown() )
- m_hScrollBar->Show(false) ;
- }
- else
- {
- if ( !m_hScrollBar->IsShown() )
- m_hScrollBar->Show(true) ;
- m_hScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ;
- }
- }
- }
- else
- {
- if ( m_vScrollBar )
- {
- if ( range == 0 || thumbVisible >= range )
- {
- if ( m_vScrollBar->IsShown() )
- m_vScrollBar->Show(false) ;
- }
- else
- {
- if ( !m_vScrollBar->IsShown() )
- m_vScrollBar->Show(true) ;
- m_vScrollBar->SetScrollbar( pos , thumbVisible , range , thumbVisible , refresh ) ;
- }
- }
- }
- MacRepositionScrollBars() ;
-}
-
-// Does a physical scroll
-void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
-{
- if( dx == 0 && dy ==0 )
- return ;
-
-
- {
- wxClientDC dc(this) ;
- wxMacPortSetter helper(&dc) ;
-
- int width , height ;
- GetClientSize( &width , &height ) ;
-
- Rect scrollrect = { dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) , dc.YLOG2DEVMAC(height) , dc.XLOG2DEVMAC(width) } ;
- RgnHandle updateRgn = NewRgn() ;
- ClipRect( &scrollrect ) ;
- if ( rect )
- {
- Rect r = { dc.YLOG2DEVMAC(rect->y) , dc.XLOG2DEVMAC(rect->x) , dc.YLOG2DEVMAC(rect->y + rect->height) ,
- dc.XLOG2DEVMAC(rect->x + rect->width) } ;
- SectRect( &scrollrect , &r , &scrollrect ) ;
- }
- ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
- // we also have to scroll the update rgn in this rectangle
- // in order not to loose updates
- WindowRef rootWindow = (WindowRef) MacGetRootWindow() ;
- RgnHandle formerUpdateRgn = NewRgn() ;
- RgnHandle scrollRgn = NewRgn() ;
- RectRgn( scrollRgn , &scrollrect ) ;
- GetWindowUpdateRgn( rootWindow , formerUpdateRgn ) ;
- Point pt = {0,0} ;
- LocalToGlobal( &pt ) ;
- OffsetRgn( formerUpdateRgn , -pt.h , -pt.v ) ;
- SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
- if ( !EmptyRgn( formerUpdateRgn ) )
- {
- MacOffsetRgn( formerUpdateRgn , dx , dy ) ;
- SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
- InvalWindowRgn(rootWindow , formerUpdateRgn ) ;
- }
- InvalWindowRgn(rootWindow , updateRgn ) ;
- DisposeRgn( updateRgn ) ;
- DisposeRgn( formerUpdateRgn ) ;
- DisposeRgn( scrollRgn ) ;
- }
-
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
- {
- wxWindowMac *child = node->GetData();
- if (child == m_vScrollBar) continue;
- if (child == m_hScrollBar) continue;
- if (child->IsTopLevel()) continue;
-
- int x,y;
- child->GetPosition( &x, &y );
- int w,h;
- child->GetSize( &w, &h );
- if (rect)
- {
- wxRect rc(x,y,w,h);
- if (rect->Intersects(rc))
- child->SetSize( x+dx, y+dy, w, h );
- }
- else
- {
- child->SetSize( x+dx, y+dy, w, h );
- }
- }
-
- Update() ;
-
-}
-
-void wxWindowMac::MacOnScroll(wxScrollEvent &event )
-{
- if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar )
- {
- wxScrollWinEvent wevent;
- wevent.SetPosition(event.GetPosition());
- wevent.SetOrientation(event.GetOrientation());
- wevent.SetEventObject(this);
-
- if (event.GetEventType() == wxEVT_SCROLL_TOP)
- wevent.SetEventType( wxEVT_SCROLLWIN_TOP );
- else if (event.GetEventType() == wxEVT_SCROLL_BOTTOM)
- wevent.SetEventType( wxEVT_SCROLLWIN_BOTTOM );
- else if (event.GetEventType() == wxEVT_SCROLL_LINEUP)
- wevent.SetEventType( wxEVT_SCROLLWIN_LINEUP );
- else if (event.GetEventType() == wxEVT_SCROLL_LINEDOWN)
- wevent.SetEventType( wxEVT_SCROLLWIN_LINEDOWN );
- else if (event.GetEventType() == wxEVT_SCROLL_PAGEUP)
- wevent.SetEventType( wxEVT_SCROLLWIN_PAGEUP );
- else if (event.GetEventType() == wxEVT_SCROLL_PAGEDOWN)
- wevent.SetEventType( wxEVT_SCROLLWIN_PAGEDOWN );
- else if (event.GetEventType() == wxEVT_SCROLL_THUMBTRACK)
- wevent.SetEventType( wxEVT_SCROLLWIN_THUMBTRACK );
- else if (event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE)
- wevent.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE );
-
- GetEventHandler()->ProcessEvent(wevent);
- }
-}
-
-// Get the window with the focus
-wxWindowMac *wxWindowBase::DoFindFocus()
-{
- return gFocusWindow ;
-}
-
-void wxWindowMac::OnSetFocus(wxFocusEvent& event)
-{
- // panel wants to track the window which was the last to have focus in it,
- // so we want to set ourselves as the window which last had focus
- //
- // notice that it's also important to do it upwards the tree becaus
- // otherwise when the top level panel gets focus, it won't set it back to
- // us, but to some other sibling
-
- // CS:don't know if this is still needed:
- //wxChildFocusEvent eventFocus(this);
- //(void)GetEventHandler()->ProcessEvent(eventFocus);
-
- event.Skip();
-}
-
-// Setup background and foreground colours correctly
-void wxWindowMac::SetupColours()
-{
- if ( GetParent() )
- SetBackgroundColour(GetParent()->GetBackgroundColour());
-}
-
-void wxWindowMac::OnInternalIdle()
-{
- // This calls the UI-update mechanism (querying windows for
- // menu/toolbar/control state information)
- if (wxUpdateUIEvent::CanUpdate(this))
- UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
-}
-
-// Raise the window to the top of the Z order
-void wxWindowMac::Raise()
-{
-}
-
-// Lower the window to the bottom of the Z order
-void wxWindowMac::Lower()
-{
-}
-
-void wxWindowMac::DoSetClientSize(int width, int height)
-{
- if ( width != -1 || height != -1 )
- {
-
- if ( width != -1 && m_vScrollBar )
- width += MAC_SCROLLBAR_SIZE ;
- if ( height != -1 && m_vScrollBar )
- height += MAC_SCROLLBAR_SIZE ;
-
- width += MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
- height += MacGetTopBorderSize( ) + MacGetBottomBorderSize( ) ;
-
- DoSetSize( -1 , -1 , width , height ) ;
- }
-}
-
-
-wxWindowMac* wxWindowMac::s_lastMouseWindow = NULL ;
-
-bool wxWindowMac::MacGetWindowFromPointSub( const wxPoint &point , wxWindowMac** outWin )
-{
- if ( IsTopLevel() )
- {
- if ((point.x < 0) || (point.y < 0) ||
- (point.x > (m_width)) || (point.y > (m_height)))
- return false;
- }
- else
- {
- if ((point.x < m_x) || (point.y < m_y) ||
- (point.x > (m_x + m_width)) || (point.y > (m_y + m_height)))
- return false;
- }
-
- WindowRef window = (WindowRef) MacGetRootWindow() ;
-
- wxPoint newPoint( point ) ;
-
- if ( !IsTopLevel() )
- {
- newPoint.x -= m_x;
- newPoint.y -= m_y;
- }
-
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
- {
- wxWindowMac *child = node->GetData();
- // added the m_isShown test --dmazzoni
- if ( child->MacGetRootWindow() == (WXWindow) window && child->m_isShown )
- {
- if (child->MacGetWindowFromPointSub(newPoint , outWin ))
- return true;
- }
- }
-
- *outWin = this ;
- return true;
-}
-
-bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMac** outWin )
-{
- WindowRef window ;
-
- Point pt = { screenpoint.y , screenpoint.x } ;
- if ( ::FindWindow( pt , &window ) == 3 )
- {
-
- wxWindowMac* win = wxFindWinFromMacWindow( (WXWindow) window ) ;
- if ( win )
- {
- // No, this yields the CLIENT are, we need the whole frame. RR.
- // point = win->ScreenToClient( point ) ;
-
- GrafPtr port;
- ::GetPort( &port ) ;
- ::SetPort( UMAGetWindowPort( window ) ) ;
- ::GlobalToLocal( &pt ) ;
- ::SetPort( port ) ;
-
- wxPoint point( pt.h, pt.v ) ;
-
- return win->MacGetWindowFromPointSub( point , outWin ) ;
- }
- }
- return false ;
-}
-
-static wxWindow *gs_lastWhich = NULL;
-
-bool wxWindowMac::MacSetupCursor( const wxPoint& pt)
-{
- // first trigger a set cursor event
-
- wxPoint clientorigin = GetClientAreaOrigin() ;
- wxSize clientsize = GetClientSize() ;
- wxCursor cursor ;
- if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) )
- {
- wxSetCursorEvent event( pt.x , pt.y );
-
- bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event);
- if ( processedEvtSetCursor && event.HasCursor() )
- {
- cursor = event.GetCursor() ;
- }
- else
- {
-
- // the test for processedEvtSetCursor is here to prevent using m_cursor
- // if the user code caught EVT_SET_CURSOR() and returned nothing from
- // it - this is a way to say that our cursor shouldn't be used for this
- // point
- if ( !processedEvtSetCursor && m_cursor.Ok() )
- {
- cursor = m_cursor ;
- }
- if ( wxIsBusy() )
- {
- }
- else
- {
- if ( !GetParent() )
- cursor = *wxSTANDARD_CURSOR ;
- }
- }
- if ( cursor.Ok() )
- cursor.MacInstall() ;
- }
- return cursor.Ok() ;
-}
-
-bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
-{
- if ((event.m_x < m_x) || (event.m_y < m_y) ||
- (event.m_x > (m_x + m_width)) || (event.m_y > (m_y + m_height)))
- return false;
-
-
- if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) /* || IsKindOf( CLASSINFO( wxSpinCtrl ) ) */)
- return false ;
-
- WindowRef window = (WindowRef) MacGetRootWindow() ;
-
- event.m_x -= m_x;
- event.m_y -= m_y;
-
- int x = event.m_x ;
- int y = event.m_y ;
-
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
- {
- wxWindowMac *child = node->GetData();
- if ( child->MacGetRootWindow() == (WXWindow) window && child->IsShown() && child->IsEnabled() )
- {
- if (child->MacDispatchMouseEvent(event))
- return true;
- }
- }
-
- wxWindow* cursorTarget = this ;
- wxPoint cursorPoint( x , y ) ;
-
- while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) )
- {
- cursorTarget = cursorTarget->GetParent() ;
- if ( cursorTarget )
- cursorPoint += cursorTarget->GetPosition() ;
- }
- event.m_x = x ;
- event.m_y = y ;
- event.SetEventObject( this ) ;
-
- if ( event.GetEventType() == wxEVT_LEFT_DOWN )
- {
- // set focus to this window
- if (AcceptsFocus() && FindFocus()!=this)
- SetFocus();
- }
-
-#if wxUSE_TOOLTIPS
- if ( event.GetEventType() == wxEVT_MOTION
- || event.GetEventType() == wxEVT_ENTER_WINDOW
- || event.GetEventType() == wxEVT_LEAVE_WINDOW )
- wxToolTip::RelayEvent( this , event);
-#endif // wxUSE_TOOLTIPS
-
- if (gs_lastWhich != this)
- {
- gs_lastWhich = this;
-
- // Double clicks must always occur on the same window
- if (event.GetEventType() == wxEVT_LEFT_DCLICK)
- event.SetEventType( wxEVT_LEFT_DOWN );
- if (event.GetEventType() == wxEVT_RIGHT_DCLICK)
- event.SetEventType( wxEVT_RIGHT_DOWN );
-
- // Same for mouse up events
- if (event.GetEventType() == wxEVT_LEFT_UP)
- return true;
- if (event.GetEventType() == wxEVT_RIGHT_UP)
- return true;
- }
-
- GetEventHandler()->ProcessEvent( event ) ;
-
- return true;
-}
-
-wxString wxWindowMac::MacGetToolTipString( wxPoint &pt )
-{
- if ( m_tooltip )
- {
- return m_tooltip->GetTip() ;
- }
- return wxEmptyString ;
-}
-
-void wxWindowMac::Update()
-{
- wxRegion visRgn = MacGetVisibleRegion( false ) ;
- int top = 0 , left = 0 ;
- MacWindowToRootWindow( &left , &top ) ;
- WindowRef rootWindow = (WindowRef) MacGetRootWindow() ;
- RgnHandle updateRgn = NewRgn() ;
- // getting the update region in macos local coordinates
- GetWindowUpdateRgn( rootWindow , updateRgn ) ;
- GrafPtr port ;
- ::GetPort( &port ) ;
- ::SetPort( UMAGetWindowPort( rootWindow ) ) ;
- Point pt = {0,0} ;
- LocalToGlobal( &pt ) ;
- ::SetPort( port ) ;
- OffsetRgn( updateRgn , -pt.h , -pt.v ) ;
- // translate to window local coordinates
- OffsetRgn( updateRgn , -left , -top ) ;
- SectRgn( updateRgn , (RgnHandle) visRgn.GetWXHRGN() , updateRgn ) ;
- MacRedraw( updateRgn , 0 , true ) ;
- // for flushing and validating we need macos-local coordinates again
- OffsetRgn( updateRgn , left , top ) ;
-#if TARGET_API_MAC_CARBON
- if ( QDIsPortBuffered( GetWindowPort( rootWindow ) ) )
- {
- QDFlushPortBuffer( GetWindowPort( rootWindow ) , updateRgn ) ;
- }
-#endif
- ValidWindowRgn( rootWindow , updateRgn ) ;
- DisposeRgn( updateRgn ) ;
-}
-
-wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const
-{
- wxTopLevelWindowMac* win = NULL ;
- WindowRef window = (WindowRef) MacGetRootWindow() ;
- if ( window )
- {
- win = wxFindWinFromMacWindow( (WXWindow) window ) ;
- }
- return win ;
-}
-
-const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSiblings )
-{
- RgnHandle visRgn = NewRgn() ;
- RgnHandle tempRgn = NewRgn() ;
- RgnHandle tempStaticBoxRgn = NewRgn() ;
-
- if ( MacIsReallyShown() )
- {
- SetRectRgn( visRgn , 0 , 0 , m_width , m_height ) ;
-
- //TODO : as soon as the new scheme has proven to work correctly, move this to wxStaticBox
- if ( IsKindOf( CLASSINFO( wxStaticBox ) ) )
- {
- int borderTop = 14 ;
- int borderOther = 4 ;
- if ( UMAGetSystemVersion() >= 0x1030 )
- borderTop += 2 ;
-
- SetRectRgn( tempStaticBoxRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ;
- DiffRgn( visRgn , tempStaticBoxRgn , visRgn ) ;
- }
-
- if ( !IsTopLevel() )
- {
- wxWindow* parent = GetParent() ;
- while( parent )
- {
- wxSize size = parent->GetSize() ;
- int x , y ;
- x = y = 0 ;
- parent->MacWindowToRootWindow( &x, &y ) ;
- MacRootWindowToWindow( &x , &y ) ;
-
- SetRectRgn( tempRgn ,
- x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() ,
- x + size.x - parent->MacGetRightBorderSize(),
- y + size.y - parent->MacGetBottomBorderSize()) ;
-
- SectRgn( visRgn , tempRgn , visRgn ) ;
- if ( parent->IsTopLevel() )
- break ;
- parent = parent->GetParent() ;
- }
- }
- if ( respectChildrenAndSiblings )
- {
- if ( GetWindowStyle() & wxCLIP_CHILDREN )
- {
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
- {
- wxWindowMac *child = node->GetData();
-
- if ( !child->IsTopLevel() && child->IsShown() )
- {
- SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
- if ( child->IsKindOf( CLASSINFO( wxStaticBox ) ) )
- {
- int borderTop = 14 ;
- int borderOther = 4 ;
- if ( UMAGetSystemVersion() >= 0x1030 )
- borderTop += 2 ;
-
- SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ;
- DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ;
- }
- DiffRgn( visRgn , tempRgn , visRgn ) ;
- }
- }
- }
-
- if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() )
- {
- bool thisWindowThrough = false ;
- for (wxWindowListNode *node = GetParent()->GetChildren().GetFirst(); node; node = node->GetNext())
- {
- wxWindowMac *sibling = node->GetData();
- if ( sibling == this )
- {
- thisWindowThrough = true ;
- continue ;
- }
- if( !thisWindowThrough )
- {
- continue ;
- }
-
- if ( !sibling->IsTopLevel() && sibling->IsShown() )
- {
- SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ;
- if ( sibling->IsKindOf( CLASSINFO( wxStaticBox ) ) )
- {
- int borderTop = 14 ;
- int borderOther = 4 ;
- if ( UMAGetSystemVersion() >= 0x1030 )
- borderTop += 2 ;
-
- SetRectRgn( tempStaticBoxRgn , sibling->m_x - m_x + borderOther , sibling->m_y - m_y + borderTop , sibling->m_x + sibling->m_width - m_x - borderOther , sibling->m_y + sibling->m_height - m_y - borderOther ) ;
- DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ;
- }
- DiffRgn( visRgn , tempRgn , visRgn ) ;
- }
- }
- }
- }
- }
- m_macVisibleRegion = visRgn ;
- DisposeRgn( visRgn ) ;
- DisposeRgn( tempRgn ) ;
- DisposeRgn( tempStaticBoxRgn ) ;
- return m_macVisibleRegion ;
-}
-
-void wxWindowMac::MacRedraw( WXHRGN updatergnr , long time, bool erase)
-{
- RgnHandle updatergn = (RgnHandle) updatergnr ;
- // updatergn is always already clipped to our boundaries
- // it is in window coordinates, not in client coordinates
-
- WindowRef window = (WindowRef) MacGetRootWindow() ;
-
- {
- // ownUpdateRgn is the area that this window has to repaint, it is in window coordinates
- RgnHandle ownUpdateRgn = NewRgn() ;
- CopyRgn( updatergn , ownUpdateRgn ) ;
-
- SectRgn( ownUpdateRgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , ownUpdateRgn ) ;
-
- // newupdate is the update region in client coordinates
- RgnHandle newupdate = NewRgn() ;
- wxSize point = GetClientSize() ;
- wxPoint origin = GetClientAreaOrigin() ;
- SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y+point.y ) ;
- SectRgn( newupdate , ownUpdateRgn , newupdate ) ;
- OffsetRgn( newupdate , -origin.x , -origin.y ) ;
- m_updateRegion = newupdate ;
- DisposeRgn( newupdate ) ; // it's been cloned to m_updateRegion
-
- if ( erase && !EmptyRgn(ownUpdateRgn) )
- {
- wxWindowDC dc(this);
- if (!EmptyRgn(ownUpdateRgn))
- dc.SetClippingRegion(wxRegion(ownUpdateRgn));
- wxEraseEvent eevent( GetId(), &dc );
- eevent.SetEventObject( this );
- GetEventHandler()->ProcessEvent( eevent );
-
- wxNcPaintEvent eventNc( GetId() );
- eventNc.SetEventObject( this );
- GetEventHandler()->ProcessEvent( eventNc );
- }
- DisposeRgn( ownUpdateRgn ) ;
- if ( !m_updateRegion.Empty() )
- {
- wxWindowList hiddenWindows ;
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
- {
- wxControl *child = wxDynamicCast( ( wxWindow*)node->GetData() , wxControl ) ;
-
- if ( child && child->MacGetRootWindow() == (WXWindow) window && child->IsShown() && child->GetMacControl() )
- {
- SetControlVisibility( (ControlHandle) child->GetMacControl() , false , false ) ;
- hiddenWindows.Append( child ) ;
- }
- }
-
- wxPaintEvent event;
- event.SetTimestamp(time);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
-
- for (wxWindowListNode *node = hiddenWindows.GetFirst(); node; node = node->GetNext())
- {
- wxControl *child = wxDynamicCast( ( wxWindow*)node->GetData() , wxControl ) ;
-
- if ( child && child->GetMacControl() )
- {
- SetControlVisibility( (ControlHandle) child->GetMacControl() , true , false ) ;
- }
- }
- }
- }
-
- // now intersect for each of the children their rect with the updateRgn and call MacRedraw recursively
-
- RgnHandle childupdate = NewRgn() ;
- for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
- {
- // calculate the update region for the child windows by intersecting the window rectangle with our own
- // passed in update region and then offset it to be client-wise window coordinates again
- wxWindowMac *child = node->GetData();
- SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
- SectRgn( childupdate , updatergn , childupdate ) ;
- OffsetRgn( childupdate , -child->m_x , -child->m_y ) ;
- if ( child->MacGetRootWindow() == (WXWindow) window && child->IsShown() && !EmptyRgn( childupdate ) )
- {
- // because dialogs may also be children
- child->MacRedraw( childupdate , time , erase ) ;
- }
- }
- DisposeRgn( childupdate ) ;
- // eventually a draw grow box here
-
-}
-
-WXWindow wxWindowMac::MacGetRootWindow() const
-{
- wxWindowMac *iter = (wxWindowMac*)this ;
-
- while( iter )
- {
- if ( iter->IsTopLevel() )
- return ((wxTopLevelWindow*)iter)->MacGetWindowRef() ;
-
- iter = iter->GetParent() ;
- }
- wxASSERT_MSG( 1 , wxT("No valid mac root window") ) ;
- return NULL ;
-}
-
-void wxWindowMac::MacCreateScrollBars( long style )
-{
- wxASSERT_MSG( m_vScrollBar == NULL && m_hScrollBar == NULL , wxT("attempt to create window twice") ) ;
-
- bool hasBoth = ( style & wxVSCROLL ) && ( style & wxHSCROLL ) ;
- int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1: 0 ;
- int width, height ;
- GetClientSize( &width , &height ) ;
-
- wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ;
- wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ;
- wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ;
- wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ;
-
- m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, vPoint,
- vSize , wxVERTICAL);
-
- if ( style & wxVSCROLL )
- {
-
- }
- else
- {
- m_vScrollBar->Show(false) ;
- }
- m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, hPoint,
- hSize , wxHORIZONTAL);
- if ( style & wxHSCROLL )
- {
- }
- else
- {
- m_hScrollBar->Show(false) ;
- }
-
- // because the create does not take into account the client area origin
- MacRepositionScrollBars() ; // we might have a real position shift
-}
-
-void wxWindowMac::MacRepositionScrollBars()
-{
- bool hasBoth = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ;
- int adjust = hasBoth ? MAC_SCROLLBAR_SIZE - 1 : 0 ;
-
- // get real client area
-
- int width = m_width ;
- int height = m_height ;
-
- width -= MacGetLeftBorderSize() + MacGetRightBorderSize();
- height -= MacGetTopBorderSize() + MacGetBottomBorderSize();
-
- wxPoint vPoint(width-MAC_SCROLLBAR_SIZE, 0) ;
- wxSize vSize(MAC_SCROLLBAR_SIZE, height - adjust) ;
- wxPoint hPoint(0 , height-MAC_SCROLLBAR_SIZE ) ;
- wxSize hSize( width - adjust, MAC_SCROLLBAR_SIZE) ;
-
- int x = 0 ;
- int y = 0 ;
- int w = m_width ;
- int h = m_height ;
-
- MacClientToRootWindow( &x , &y ) ;
- MacClientToRootWindow( &w , &h ) ;
-
- wxWindowMac *iter = (wxWindowMac*)this ;
-
- int totW = 10000 , totH = 10000;
- while( iter )
- {
- if ( iter->IsTopLevel() )
- {
- totW = iter->m_width ;
- totH = iter->m_height ;
- break ;
- }
-
- iter = iter->GetParent() ;
- }
-
- if ( x == 0 )
- {
- hPoint.x = -1 ;
- hSize.x += 1 ;
- }
- if ( y == 0 )
- {
- vPoint.y = -1 ;
- vSize.y += 1 ;
- }
-
- if ( w-x >= totW )
- {
- hSize.x += 1 ;
- vPoint.x += 1 ;
- }
-
- if ( h-y >= totH )
- {
- vSize.y += 1 ;
- hPoint.y += 1 ;
- }
-
- if ( m_vScrollBar )
- {
- m_vScrollBar->SetSize( vPoint.x , vPoint.y, vSize.x, vSize.y , wxSIZE_ALLOW_MINUS_ONE);
- }
- if ( m_hScrollBar )
- {
- m_hScrollBar->SetSize( hPoint.x , hPoint.y, hSize.x, hSize.y, wxSIZE_ALLOW_MINUS_ONE);
- }
-}
-
-bool wxWindowMac::AcceptsFocus() const
-{
- return MacCanFocus() && wxWindowBase::AcceptsFocus();
-}
-
-WXWidget wxWindowMac::MacGetContainerForEmbedding()
-{
- return GetParent()->MacGetContainerForEmbedding() ;
-}
-
-void wxWindowMac::MacSuperChangedPosition()
-{
- // only window-absolute structures have to be moved i.e. controls
-
- wxWindowListNode *node = GetChildren().GetFirst();
- while ( node )
- {
- wxWindowMac *child = node->GetData();
- child->MacSuperChangedPosition() ;
- node = node->GetNext();
- }
-}
-
-void wxWindowMac::MacTopLevelWindowChangedPosition()
-{
- // only screen-absolute structures have to be moved i.e. glcanvas
-
- wxWindowListNode *node = GetChildren().GetFirst();
- while ( node )
- {
- wxWindowMac *child = node->GetData();
- child->MacTopLevelWindowChangedPosition() ;
- node = node->GetNext();
- }
-}
-long wxWindowMac::MacGetLeftBorderSize( ) const
-{
- if( IsTopLevel() )
- return 0 ;
-
- if (m_windowStyle & wxRAISED_BORDER || m_windowStyle & wxSUNKEN_BORDER )
- {
- SInt32 border = 3 ;
-#if wxMAC_USE_THEME_BORDER
-#if TARGET_CARBON
- GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
-#endif
-#endif
- return border ;
- }
- else if ( m_windowStyle &wxDOUBLE_BORDER)
- {
- SInt32 border = 3 ;
-#if wxMAC_USE_THEME_BORDER
-#if TARGET_CARBON
- GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
-#endif
-#endif
- return border ;
- }
- else if (m_windowStyle &wxSIMPLE_BORDER)
- {
- return 1 ;
- }
- return 0 ;
-}
-
-long wxWindowMac::MacGetRightBorderSize( ) const
-{
- // they are all symmetric in mac themes
- return MacGetLeftBorderSize() ;
-}
-
-long wxWindowMac::MacGetTopBorderSize( ) const
-{
- // they are all symmetric in mac themes
- return MacGetLeftBorderSize() ;
-}
-
-long wxWindowMac::MacGetBottomBorderSize( ) const
-{
- // they are all symmetric in mac themes
- return MacGetLeftBorderSize() ;
-}
-
-long wxWindowMac::MacRemoveBordersFromStyle( long style )
-{
- return style & ~( wxDOUBLE_BORDER | wxSUNKEN_BORDER | wxRAISED_BORDER | wxBORDER | wxSTATIC_BORDER ) ;
-}
-
-// Find the wxWindowMac at the current mouse position, returning the mouse
-// position.
-wxWindowMac* wxFindWindowAtPointer(wxPoint& pt)
-{
- pt = wxGetMousePosition();
- wxWindowMac* found = wxFindWindowAtPoint(pt);
- return found;
-}
-
-// Get the current mouse position.
-wxPoint wxGetMousePosition()
-{
- int x, y;
- wxGetMousePosition(& x, & y);
- return wxPoint(x, y);
-}
-
-void wxWindowMac::OnMouseEvent( wxMouseEvent &event )
-{
- if ( event.GetEventType() == wxEVT_RIGHT_DOWN )
- {
- // copied from wxGTK : CS
- // generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
- // except that:
- //
- // (a) it's a command event and so is propagated to the parent
- // (b) under MSW it can be generated from kbd too
- // (c) it uses screen coords (because of (a))
- wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU,
- this->GetId(),
- this->ClientToScreen(event.GetPosition()));
- if ( ! GetEventHandler()->ProcessEvent(evtCtx) )
- event.Skip() ;
- }
- else
- {
- event.Skip() ;
- }
-}