mac adaptions
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4458 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -176,11 +176,16 @@ class WXDLLEXPORT wxPrintData: public wxObject
|
|||||||
void ConvertFromNative();
|
void ConvertFromNative();
|
||||||
void* GetNativeData() const { return m_devMode; }
|
void* GetNativeData() const { return m_devMode; }
|
||||||
void SetNativeData(void* data) { m_devMode = data; }
|
void SetNativeData(void* data) { m_devMode = data; }
|
||||||
|
#elif defined( __WXMAC__)
|
||||||
|
void ConvertToNative();
|
||||||
|
void ConvertFromNative();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
void* m_devMode;
|
void* m_devMode;
|
||||||
|
#elif defined( __WXMAC__ )
|
||||||
|
THPrint m_macPrintInfo ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -270,10 +275,15 @@ class WXDLLEXPORT wxPrintDialogData: public wxObject
|
|||||||
void ConvertFromNative();
|
void ConvertFromNative();
|
||||||
void SetOwnerWindow(wxWindow* win);
|
void SetOwnerWindow(wxWindow* win);
|
||||||
void* GetNativeData() const { return m_printDlgData; }
|
void* GetNativeData() const { return m_printDlgData; }
|
||||||
|
#elif defined( __WXMAC__)
|
||||||
|
void ConvertToNative();
|
||||||
|
void ConvertFromNative();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
void* m_printDlgData;
|
void* m_printDlgData;
|
||||||
|
#elif defined( __WXMAC__ )
|
||||||
|
THPrint m_macPrintInfo ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -356,6 +366,9 @@ public:
|
|||||||
void ConvertFromNative();
|
void ConvertFromNative();
|
||||||
void SetOwnerWindow(wxWindow* win);
|
void SetOwnerWindow(wxWindow* win);
|
||||||
void* GetNativeData() const { return m_pageSetupData; }
|
void* GetNativeData() const { return m_pageSetupData; }
|
||||||
|
#elif defined( __WXMAC__)
|
||||||
|
void ConvertToNative();
|
||||||
|
void ConvertFromNative();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use paper size defined in this object to set the wxPrintData
|
// Use paper size defined in this object to set the wxPrintData
|
||||||
@@ -373,6 +386,8 @@ public:
|
|||||||
|
|
||||||
#if defined(__WIN95__)
|
#if defined(__WIN95__)
|
||||||
void* m_pageSetupData;
|
void* m_pageSetupData;
|
||||||
|
#elif defined( __WXMAC__ )
|
||||||
|
THPrint m_macPageSetupInfo ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -79,6 +79,8 @@ public:
|
|||||||
#include "wx/motif/dataform.h"
|
#include "wx/motif/dataform.h"
|
||||||
#elif defined(__WXGTK__)
|
#elif defined(__WXGTK__)
|
||||||
#include "wx/gtk/dataform.h"
|
#include "wx/gtk/dataform.h"
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
#include "wx/mac/dataform.h"
|
||||||
#elif defined(__WXPM__)
|
#elif defined(__WXPM__)
|
||||||
#include "wx/os2/dataform.h"
|
#include "wx/os2/dataform.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -159,7 +161,7 @@ public:
|
|||||||
#elif defined(__WXQT__)
|
#elif defined(__WXQT__)
|
||||||
#include "wx/qt/dnd.h"
|
#include "wx/qt/dnd.h"
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
#include "wx/mac/dnd.h"
|
#include "wx/mac/dataobj.h"
|
||||||
#elif defined(__WXPM__)
|
#elif defined(__WXPM__)
|
||||||
#include "wx/os2/dataobj.h"
|
#include "wx/os2/dataobj.h"
|
||||||
#elif defined(__WXSTUBS__)
|
#elif defined(__WXSTUBS__)
|
||||||
|
@@ -69,19 +69,29 @@
|
|||||||
typedef double SDOUBLE;
|
typedef double SDOUBLE;
|
||||||
typedef unsigned int UINT;
|
typedef unsigned int UINT;
|
||||||
#define ULONG UDWORD
|
#define ULONG UDWORD
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
extern "C" {
|
||||||
|
#include "../../src/iodbc/isql.h"
|
||||||
|
#include "../../src/iodbc/isqlext.h"
|
||||||
|
}
|
||||||
|
typedef float SFLOAT;
|
||||||
|
typedef double SDOUBLE;
|
||||||
|
typedef unsigned int UINT;
|
||||||
|
#define ULONG UDWORD
|
||||||
#else // msw
|
#else // msw
|
||||||
#define ODBCVER 0x0250
|
#define ODBCVER 0x0250
|
||||||
#include <sql.h>
|
#include <sql.h>
|
||||||
#include <sqlext.h>
|
#include <sqlext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
# ifndef strnicmp
|
# ifndef strnicmp
|
||||||
# define strnicmp strncasecmp
|
# define strnicmp strncasecmp
|
||||||
# endif
|
# endif
|
||||||
# ifndef stricmp
|
# ifndef stricmp
|
||||||
# define stricmp strcasecmp
|
# define stricmp strcasecmp
|
||||||
# endif
|
# endif
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
#else
|
#else
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
@@ -7,6 +7,9 @@
|
|||||||
#if defined(__WXPM__)
|
#if defined(__WXPM__)
|
||||||
#include "wx/os2/dcprint.h"
|
#include "wx/os2/dcprint.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__WXMAC__)
|
||||||
|
#include "wx/mac/dcprint.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_DCPRINT_H_BASE_
|
// _WX_DCPRINT_H_BASE_
|
||||||
|
@@ -84,9 +84,12 @@ WXDLLEXPORT void wxUnix2DosFilename(wxChar *s);
|
|||||||
#define Unix2DosFilename wxUnix2DosFilename
|
#define Unix2DosFilename wxUnix2DosFilename
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
WXDLLEXPORT void wxMacPathToFSSpec( const wxChar *path , FSSpec *spec ) ;
|
WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
|
||||||
WXDLLEXPORT void wxMac2UnixFilename(wxChar *s);
|
WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
|
||||||
WXDLLEXPORT void wxUnix2MacFilename(wxChar *s);
|
WXDLLEXPORT void wxUnixFilename2FSSpec( const char *path , FSSpec *spec ) ;
|
||||||
|
WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
|
||||||
|
WXDLLEXPORT wxString wxMac2UnixFilename( const char *s) ;
|
||||||
|
WXDLLEXPORT wxString wxUnix2MacFilename( const char *s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Strip the extension, in situ
|
// Strip the extension, in situ
|
||||||
|
@@ -43,8 +43,12 @@ class WXDLLEXPORT wxButton: public wxControl
|
|||||||
const wxString& name = wxButtonNameStr);
|
const wxString& name = wxButtonNameStr);
|
||||||
|
|
||||||
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
|
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
|
||||||
|
static wxSize GetDefaultSize();
|
||||||
|
|
||||||
virtual void SetDefault();
|
virtual void SetDefault();
|
||||||
virtual void Command(wxCommandEvent& event);
|
virtual void Command(wxCommandEvent& event);
|
||||||
|
protected:
|
||||||
|
virtual wxSize DoGetBestSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -19,75 +19,87 @@
|
|||||||
#pragma interface "clipbrd.h"
|
#pragma interface "clipbrd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#if wxUSE_CLIPBOARD
|
||||||
#include "wx/setup.h"
|
|
||||||
|
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
|
#include "wx/module.h"
|
||||||
|
#include "wx/dataobj.h" // for wxDataFormat
|
||||||
|
|
||||||
/* A clipboard client holds data belonging to the clipboard.
|
// These functions superceded by wxClipboard, but retained in order to
|
||||||
For plain text, a client is not necessary. */
|
// implement wxClipboard, and for compatibility.
|
||||||
class WXDLLEXPORT wxClipboardClient : public wxObject
|
|
||||||
{
|
|
||||||
DECLARE_ABSTRACT_CLASS(wxClipboardClient)
|
|
||||||
|
|
||||||
public:
|
// open/close the clipboard
|
||||||
/* This list should be filled in with strings indicating the formats
|
WXDLLEXPORT bool wxOpenClipboard();
|
||||||
this client can provide. Almost all clients will provide "TEXT".
|
WXDLLEXPORT bool wxIsClipboardOpened();
|
||||||
Format names should be 4 characters long, so things will work
|
#define wxClipboardOpen wxIsClipboardOpened
|
||||||
out on the Macintosh */
|
WXDLLEXPORT bool wxCloseClipboard();
|
||||||
wxStringList formats;
|
|
||||||
|
|
||||||
/* This method is called when the client is losing the selection. */
|
// get/set data
|
||||||
virtual void BeingReplaced() = 0;
|
WXDLLEXPORT bool wxEmptyClipboard();
|
||||||
|
WXDLLEXPORT bool wxSetClipboardData(wxDataFormat dataFormat,
|
||||||
|
const void *data,
|
||||||
|
int width = 0, int height = 0);
|
||||||
|
WXDLLEXPORT void* wxGetClipboardData(wxDataFormat dataFormat,
|
||||||
|
long *len = NULL);
|
||||||
|
|
||||||
/* This method is called when someone wants the data this client is
|
// clipboard formats
|
||||||
supplying to the clipboard. "format" is a string indicating the
|
WXDLLEXPORT bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
|
||||||
format of the data - one of the strings from the "formats"
|
WXDLLEXPORT wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat);
|
||||||
list. "*size" should be filled with the size of the resulting
|
WXDLLEXPORT int wxRegisterClipboardFormat(wxChar *formatName);
|
||||||
data. In the case of text, "*size" does not count the
|
WXDLLEXPORT bool wxGetClipboardFormatName(wxDataFormat dataFormat,
|
||||||
NULL terminator. */
|
wxChar *formatName,
|
||||||
virtual char *GetData(char *format, long *size) = 0;
|
int maxCount);
|
||||||
};
|
|
||||||
|
|
||||||
/* ONE instance of this class: */
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxClipboard
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxDataObject;
|
||||||
class WXDLLEXPORT wxClipboard : public wxObject
|
class WXDLLEXPORT wxClipboard : public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxClipboard)
|
DECLARE_DYNAMIC_CLASS(wxClipboard)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxClipboardClient *clipOwner;
|
wxClipboard();
|
||||||
char *cbString, *sentString, *receivedString;
|
~wxClipboard();
|
||||||
void *receivedTargets;
|
|
||||||
long receivedLength;
|
|
||||||
|
|
||||||
wxClipboard();
|
// open the clipboard before SetData() and GetData()
|
||||||
~wxClipboard();
|
virtual bool Open();
|
||||||
|
|
||||||
/* Set the clipboard data owner. "time" comes from the event record. */
|
// close the clipboard after SetData() and GetData()
|
||||||
void SetClipboardClient(wxClipboardClient *, long time);
|
virtual void Close();
|
||||||
|
|
||||||
/* Set the clipboard string; does not require a client. */
|
// query whether the clipboard is opened
|
||||||
void SetClipboardString(char *, long time);
|
virtual bool IsOpened() const;
|
||||||
|
|
||||||
/* Get data from the clipboard in the format "TEXT". */
|
// set the clipboard data. all other formats will be deleted.
|
||||||
char *GetClipboardString(long time);
|
virtual bool SetData( wxDataObject *data );
|
||||||
|
|
||||||
/* Get data from the clipboard */
|
// add to the clipboard data.
|
||||||
char *GetClipboardData(char *format, long *length, long time);
|
virtual bool AddData( wxDataObject *data );
|
||||||
|
|
||||||
/* Get the clipboard client directly. Will be NULL if clipboard data
|
// ask if data in correct format is available
|
||||||
is a string, or if some other application owns the clipboard.
|
virtual bool IsSupported( wxDataFormat format );
|
||||||
This can be useful for shortcutting data translation, if the
|
|
||||||
clipboard user can check for a specific client. (This is used
|
// fill data with data on the clipboard (if available)
|
||||||
by the wxMediaEdit class.) */
|
virtual bool GetData( wxDataObject& data );
|
||||||
wxClipboardClient *GetClipboardClient();
|
|
||||||
|
// 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:
|
||||||
|
bool m_clearOnExit;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Initialize wxTheClipboard. Can be called repeatedly */
|
#endif // wxUSE_CLIPBOARD
|
||||||
void WXDLLEXPORT wxInitClipboard();
|
|
||||||
|
|
||||||
/* The clipboard */
|
|
||||||
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_CLIPBRD_H_
|
// _WX_CLIPBRD_H_
|
||||||
|
@@ -64,7 +64,7 @@ public:
|
|||||||
unsigned char Blue() const { return m_blue; }
|
unsigned char Blue() const { return m_blue; }
|
||||||
|
|
||||||
// comparison
|
// comparison
|
||||||
bool operator == (const wxColour& colour)
|
bool operator == (const wxColour& colour) const
|
||||||
{
|
{
|
||||||
return (m_red == colour.m_red &&
|
return (m_red == colour.m_red &&
|
||||||
m_green == colour.m_green &&
|
m_green == colour.m_green &&
|
||||||
|
@@ -33,12 +33,36 @@ public:
|
|||||||
|
|
||||||
// Calls the callback and appropriate event handlers
|
// Calls the callback and appropriate event handlers
|
||||||
bool ProcessCommand(wxCommandEvent& event);
|
bool ProcessCommand(wxCommandEvent& event);
|
||||||
|
virtual void SetLabel(const wxString& title) ;
|
||||||
|
|
||||||
wxList& GetSubcontrols() { return m_subControls; }
|
wxList& GetSubcontrols() { return m_subControls; }
|
||||||
|
|
||||||
void OnEraseBackground(wxEraseEvent& event);
|
void OnEraseBackground(wxEraseEvent& event);
|
||||||
|
|
||||||
|
virtual bool Enable(bool enabled) ;
|
||||||
|
virtual bool Show(bool show) ;
|
||||||
|
|
||||||
|
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
|
||||||
|
virtual void MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString label ,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size, long style,
|
||||||
|
const wxValidator& validator,
|
||||||
|
const wxString& name , Rect *outBounds , StringPtr maclabel ) ;
|
||||||
|
virtual void MacPostControlCreate() ;
|
||||||
|
virtual void MacAdjustControlRect() ;
|
||||||
|
virtual ControlHandle MacGetContainerForEmbedding() ;
|
||||||
|
virtual void MacSuperChangedPosition() ;
|
||||||
|
virtual void MacSuperEnabled( bool enabled ) ;
|
||||||
|
virtual void MacSuperShown( bool show ) ;
|
||||||
|
virtual bool MacCanFocus() const ;
|
||||||
|
|
||||||
|
void DoSetSize(int x, int y,int width, int height,int sizeFlags ) ;
|
||||||
|
virtual void OnKeyDown( wxKeyEvent &event ) ;
|
||||||
|
virtual void OnMouseEvent( wxMouseEvent &event ) ;
|
||||||
|
virtual void OnPaint(wxPaintEvent& event) ;
|
||||||
|
virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL) ;
|
||||||
|
ControlHandle GetMacControl() { return m_macControl ;}
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY
|
#if WXWIN_COMPATIBILITY
|
||||||
virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
|
virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
|
||||||
wxColour* GetButtonColour() const { return NULL; }
|
wxColour* GetButtonColour() const { return NULL; }
|
||||||
@@ -59,18 +83,13 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// For controls like radiobuttons which are really composite
|
// For controls like radiobuttons which are really composite
|
||||||
|
ControlHandle m_macControl ;
|
||||||
|
int m_macHorizontalBorder ;
|
||||||
|
int m_macVerticalBorder ;
|
||||||
wxList m_subControls;
|
wxList m_subControls;
|
||||||
|
|
||||||
virtual wxSize DoGetBestSize();
|
virtual wxSize DoGetBestSize();
|
||||||
|
|
||||||
// create the control of the given class with the given style, returns FALSE
|
|
||||||
// if creation failed
|
|
||||||
bool MSWCreateControl(const wxChar *classname, WXDWORD style);
|
|
||||||
|
|
||||||
// determine the extended styles combination for this window (may slightly
|
|
||||||
// modify styl parameter)
|
|
||||||
WXDWORD GetExStyle(WXDWORD& style) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
@@ -20,79 +20,111 @@
|
|||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr;
|
WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr;
|
||||||
|
|
||||||
|
WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr;
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxMacToolTip ;
|
||||||
|
|
||||||
// Dialog boxes
|
// Dialog boxes
|
||||||
class WXDLLEXPORT wxDialog: public wxPanel
|
class WXDLLEXPORT wxDialog : public wxDialogBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
wxDialog();
|
||||||
|
|
||||||
wxDialog();
|
// 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)
|
||||||
|
{
|
||||||
|
long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ;
|
||||||
|
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height),
|
||||||
|
style | modalStyle, name);
|
||||||
|
}
|
||||||
|
|
||||||
// Constructor with a modal flag, but no window id - the old convention
|
// Constructor with no modal flag - the new convention.
|
||||||
inline wxDialog(wxWindow *parent,
|
wxDialog(wxWindow *parent, wxWindowID id,
|
||||||
const wxString& title, bool modal,
|
const wxString& title,
|
||||||
int x = -1, int y= -1, int width = 500, int height = 500,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
long style = wxDEFAULT_DIALOG_STYLE,
|
const wxSize& size = wxDefaultSize,
|
||||||
const wxString& name = wxDialogNameStr)
|
long style = wxDEFAULT_DIALOG_STYLE,
|
||||||
{
|
const wxString& name = wxDialogNameStr)
|
||||||
long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ;
|
{
|
||||||
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), style|modalStyle, name);
|
Create(parent, id, title, pos, size, style, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor with no modal flag - the new convention.
|
bool Create(wxWindow *parent, wxWindowID id,
|
||||||
inline wxDialog(wxWindow *parent, wxWindowID id,
|
const wxString& title,
|
||||||
const wxString& title,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxSize& size = wxDefaultSize,
|
||||||
const wxSize& size = wxDefaultSize,
|
long style = wxDEFAULT_DIALOG_STYLE,
|
||||||
long style = wxDEFAULT_DIALOG_STYLE,
|
const wxString& name = wxDialogNameStr);
|
||||||
const wxString& name = wxDialogNameStr)
|
|
||||||
{
|
|
||||||
Create(parent, id, title, pos, size, style, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxWindowID id,
|
~wxDialog();
|
||||||
const wxString& title, // bool modal = FALSE, // TODO make this a window style?
|
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
|
||||||
const wxSize& size = wxDefaultSize,
|
|
||||||
long style = wxDEFAULT_DIALOG_STYLE,
|
|
||||||
const wxString& name = wxDialogNameStr);
|
|
||||||
|
|
||||||
~wxDialog();
|
virtual bool Destroy();
|
||||||
|
|
||||||
virtual bool Destroy();
|
virtual void DoSetClientSize(int width, int height);
|
||||||
bool Show(bool show);
|
|
||||||
void Fit();
|
|
||||||
|
|
||||||
void Iconize(bool iconize);
|
virtual void GetPosition(int *x, int *y) const;
|
||||||
|
|
||||||
virtual bool IsIconized() const;
|
bool Show(bool show);
|
||||||
void OnCharHook(wxKeyEvent& event);
|
bool IsShown() const;
|
||||||
void OnCloseWindow(wxCloseEvent& event);
|
void Iconize(bool iconize);
|
||||||
|
|
||||||
void SetModal(bool flag);
|
#if WXWIN_COMPATIBILITY
|
||||||
|
bool Iconized() const { return IsIconized(); };
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual bool IsModal() const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
|
virtual bool IsIconized() const;
|
||||||
|
void Fit();
|
||||||
|
|
||||||
virtual int ShowModal();
|
void SetTitle(const wxString& title);
|
||||||
virtual void EndModal(int retCode);
|
wxString GetTitle() const ;
|
||||||
|
|
||||||
// Standard buttons
|
void OnSize(wxSizeEvent& event);
|
||||||
void OnOK(wxCommandEvent& event);
|
bool OnClose();
|
||||||
void OnApply(wxCommandEvent& event);
|
void OnCharHook(wxKeyEvent& event);
|
||||||
void OnCancel(wxCommandEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
void OnCloseWindow(wxCloseEvent& event);
|
||||||
|
|
||||||
void OnSize(wxSizeEvent& event) ;
|
void SetModal(bool flag);
|
||||||
// Responds to colour changes
|
|
||||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
|
||||||
|
|
||||||
// splits text up at newlines and places the
|
virtual void Centre(int direction = wxBOTH);
|
||||||
// lines into a vertical wxBoxSizer
|
virtual bool IsModal() const;
|
||||||
wxSizer *CreateTextSizer( const wxString &message );
|
|
||||||
|
|
||||||
// places buttons into a horizontal wxBoxSizer
|
|
||||||
wxSizer *CreateButtonSizer( long flags );
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
// For now, same as Show(TRUE) but returns return code
|
||||||
|
virtual int ShowModal();
|
||||||
|
virtual void EndModal(int retCode);
|
||||||
|
|
||||||
|
// Standard buttons
|
||||||
|
void OnOK(wxCommandEvent& event);
|
||||||
|
void OnApply(wxCommandEvent& event);
|
||||||
|
void OnCancel(wxCommandEvent& event);
|
||||||
|
|
||||||
|
// Responds to colour changes
|
||||||
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||||
|
|
||||||
|
// implementation
|
||||||
|
// --------------
|
||||||
|
|
||||||
|
bool IsModalShowing() const { return m_modalShowing; }
|
||||||
|
|
||||||
|
// tooltip management
|
||||||
|
#if wxUSE_TOOLTIPS
|
||||||
|
wxMacToolTip* GetToolTipCtrl() const { return m_hwndToolTip; }
|
||||||
|
void SetToolTipCtrl(wxMacToolTip *tt) { m_hwndToolTip = tt; }
|
||||||
|
wxMacToolTip* m_hwndToolTip ;
|
||||||
|
#endif // tooltips
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_modalShowing;
|
||||||
|
WXHWND m_hwndOldFocus; // the window which had focus before we were shown
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -16,15 +16,66 @@
|
|||||||
#pragma interface "font.h"
|
#pragma interface "font.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
||||||
// public functions
|
{
|
||||||
// ----------------------------------------------------------------------------
|
friend class WXDLLEXPORT wxFont;
|
||||||
|
public:
|
||||||
|
wxFontRefData()
|
||||||
|
{
|
||||||
|
Init(12, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
|
||||||
|
"", wxFONTENCODING_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
// convert wxFontEncoding into one of Windows XXX_CHARSET constants (fill exact
|
wxFontRefData(const wxFontRefData& data)
|
||||||
// parameter if it's not NULL with TRUE if encoding is realyl supported under
|
{
|
||||||
// Windows and FALSE if not and we just chose something close to it)
|
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
||||||
extern int wxCharsetFromEncoding(wxFontEncoding encoding, bool *exact = NULL);
|
data.m_underlined, data.m_faceName, data.m_encoding);
|
||||||
|
|
||||||
|
m_macFontNum = data.m_macFontNum ;
|
||||||
|
m_macFontSize = data.m_macFontSize;
|
||||||
|
m_macFontStyle = data.m_macFontStyle;
|
||||||
|
m_fontId = data.m_fontId;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFontRefData(int size,
|
||||||
|
int family,
|
||||||
|
int style,
|
||||||
|
int weight,
|
||||||
|
bool underlined,
|
||||||
|
const wxString& faceName,
|
||||||
|
wxFontEncoding encoding)
|
||||||
|
{
|
||||||
|
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~wxFontRefData();
|
||||||
|
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;
|
||||||
|
|
||||||
|
public :
|
||||||
|
short m_macFontNum ;
|
||||||
|
short m_macFontSize ;
|
||||||
|
Style m_macFontStyle ;
|
||||||
|
public :
|
||||||
|
void MacFindFont() ;
|
||||||
|
};
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxFont
|
// wxFont
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -87,6 +138,7 @@ public:
|
|||||||
virtual bool RealizeResource();
|
virtual bool RealizeResource();
|
||||||
virtual WXHANDLE GetResourceHandle();
|
virtual WXHANDLE GetResourceHandle();
|
||||||
virtual bool FreeResource(bool force = FALSE);
|
virtual bool FreeResource(bool force = FALSE);
|
||||||
|
void MacInstall() const ;
|
||||||
/*
|
/*
|
||||||
virtual bool UseResource();
|
virtual bool UseResource();
|
||||||
virtual bool ReleaseResource();
|
virtual bool ReleaseResource();
|
||||||
|
@@ -125,8 +125,9 @@ public:
|
|||||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||||
|
|
||||||
// Query app for menu item updates (called from OnIdle)
|
// Query app for menu item updates (called from OnIdle)
|
||||||
void DoMenuUpdates();
|
// Query app for menu item updates (called from OnIdle)
|
||||||
void DoMenuUpdates(wxMenu* menu);
|
void DoMenuUpdates();
|
||||||
|
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
|
||||||
|
|
||||||
// Checks if there is a toolbar, and returns the first free client position
|
// Checks if there is a toolbar, and returns the first free client position
|
||||||
virtual wxPoint GetClientAreaOrigin() const;
|
virtual wxPoint GetClientAreaOrigin() const;
|
||||||
@@ -136,7 +137,8 @@ public:
|
|||||||
// tooltip management
|
// tooltip management
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
wxMacToolTip* GetToolTipCtrl() const { return m_hwndToolTip; }
|
wxMacToolTip* GetToolTipCtrl() const { return m_hwndToolTip; }
|
||||||
void SetToolTipCtrl(wxMacToolTip *tt) { m_hwndToolTip = wxMacToolTip; }
|
void SetToolTipCtrl(wxMacToolTip *tt) { m_hwndToolTip = tt; }
|
||||||
|
wxMacToolTip* m_hwndToolTip ;
|
||||||
#endif // tooltips
|
#endif // tooltips
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -44,6 +44,8 @@ public:
|
|||||||
// Copy constructors
|
// Copy constructors
|
||||||
inline wxIcon(const wxIcon& icon) { Ref(icon); }
|
inline wxIcon(const wxIcon& icon) { Ref(icon); }
|
||||||
|
|
||||||
|
wxIcon( const char **bits, int width=-1, int height=-1 );
|
||||||
|
wxIcon( char **bits, int width=-1, int height=-1 );
|
||||||
wxIcon(const char bits[], int width, int height);
|
wxIcon(const char bits[], int width, int height);
|
||||||
wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
int desiredWidth = -1, int desiredHeight = -1);
|
||||||
|
@@ -9,93 +9,116 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WX_LISTBOX_H_
|
#ifndef _WX_LISTBOX_H_
|
||||||
#define _WX_LISTBOX_H_
|
#define _WX_LISTBOX_H_
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "listbox.h"
|
#pragma interface "listbox.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/control.h"
|
// ----------------------------------------------------------------------------
|
||||||
#include "wx/dynarray.h"
|
// simple types
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr;
|
#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()
|
// forward decl for GetSelections()
|
||||||
class WXDLLEXPORT wxArrayInt;
|
class wxArrayInt;
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
|
|
||||||
|
|
||||||
// List box item
|
// List box item
|
||||||
|
|
||||||
WX_DEFINE_ARRAY( char * , wxListDataArray ) ;
|
WX_DEFINE_ARRAY( char * , wxListDataArray ) ;
|
||||||
|
|
||||||
class WXDLLEXPORT wxListBox: public wxControl
|
// ----------------------------------------------------------------------------
|
||||||
|
// List box control
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxListBox : public wxListBoxBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxListBox)
|
public:
|
||||||
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();
|
bool Create(wxWindow *parent, wxWindowID id,
|
||||||
inline wxListBox(wxWindow *parent, wxWindowID id,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxSize& size = wxDefaultSize,
|
||||||
const wxSize& size = wxDefaultSize,
|
int n = 0, const wxString choices[] = NULL,
|
||||||
int n = 0, const wxString choices[] = NULL,
|
long style = 0,
|
||||||
long style = 0,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxString& name = wxListBoxNameStr);
|
||||||
const wxString& name = wxListBoxNameStr)
|
|
||||||
{
|
|
||||||
Create(parent, id, pos, size, n, choices, style, validator, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxWindowID id,
|
virtual ~wxListBox();
|
||||||
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);
|
|
||||||
|
|
||||||
~wxListBox();
|
// implement base class pure virtuals
|
||||||
|
virtual void Clear();
|
||||||
|
virtual void Delete(int n);
|
||||||
|
|
||||||
virtual void Append(const wxString& item);
|
virtual int GetCount() const;
|
||||||
virtual void Append(const wxString& item, char *clientData);
|
virtual wxString GetString(int n) const;
|
||||||
virtual void Set(int n, const wxString* choices, char **clientData = NULL);
|
virtual void SetString(int n, const wxString& s);
|
||||||
virtual int FindString(const wxString& s) const ;
|
virtual int FindString(const wxString& s) const;
|
||||||
virtual void Clear();
|
|
||||||
virtual void SetSelection(int n, bool select = TRUE);
|
|
||||||
|
|
||||||
virtual void Deselect(int n);
|
virtual bool IsSelected(int n) const;
|
||||||
|
virtual void SetSelection(int n, bool select = TRUE);
|
||||||
|
virtual int GetSelection() const;
|
||||||
|
virtual int GetSelections(wxArrayInt& aSelections) const;
|
||||||
|
|
||||||
// For single choice list item only
|
virtual int DoAppend(const wxString& item);
|
||||||
virtual int GetSelection() const ;
|
virtual void DoInsertItems(const wxArrayString& items, int pos);
|
||||||
virtual void Delete(int n);
|
virtual void DoSetItems(const wxArrayString& items, void **clientData);
|
||||||
virtual char *GetClientData(int n) const ;
|
|
||||||
virtual void SetClientData(int n, char *clientData);
|
|
||||||
virtual void SetString(int n, const wxString& s);
|
|
||||||
|
|
||||||
// For single or multiple choice list item
|
virtual void DoSetFirstItem(int n);
|
||||||
virtual int GetSelections(wxArrayInt& aSelections) const;
|
|
||||||
virtual bool Selected(int n) const ;
|
|
||||||
virtual wxString GetString(int n) const ;
|
|
||||||
|
|
||||||
// Set the specified item at the first visible item
|
virtual void DoSetItemClientData(int n, void* clientData);
|
||||||
// or scroll to max range.
|
virtual void* DoGetItemClientData(int n) const;
|
||||||
virtual void SetFirstItem(int n) ;
|
virtual void DoSetItemClientObject(int n, wxClientData* clientData);
|
||||||
virtual void SetFirstItem(const wxString& s) ;
|
virtual wxClientData* DoGetItemClientObject(int n) const;
|
||||||
|
|
||||||
virtual void InsertItems(int nItems, const wxString items[], int pos);
|
// wxCheckListBox support
|
||||||
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
// plug-in for derived classes
|
||||||
|
virtual wxOwnerDrawn *CreateItem(size_t n);
|
||||||
|
|
||||||
virtual wxString GetStringSelection() const ;
|
// allows to get the item and use SetXXX functions to set it's appearance
|
||||||
virtual bool SetStringSelection(const wxString& s, bool flag = TRUE);
|
wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
|
||||||
virtual int Number() const ;
|
|
||||||
|
|
||||||
void Command(wxCommandEvent& event);
|
// get the index of the given item
|
||||||
|
int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
|
||||||
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
|
|
||||||
void MacSetRedraw( bool doDraw ) ;
|
// Windows-specific code to set the horizontal extent of the listbox, if
|
||||||
protected:
|
// necessary. If s is non-NULL, it's used to calculate the horizontal
|
||||||
int m_noItems;
|
// extent. Otherwise, all strings are used.
|
||||||
int m_selected;
|
virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
|
||||||
|
|
||||||
|
// Windows callbacks
|
||||||
|
|
||||||
|
virtual void SetupColours();
|
||||||
|
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
|
||||||
|
|
||||||
|
ListHandle m_macList ;
|
||||||
|
wxArrayString m_stringArray ;
|
||||||
|
wxListDataArray m_dataArray ;
|
||||||
|
void MacSetRedraw( bool doDraw ) ;
|
||||||
|
protected:
|
||||||
void MacDestroy() ;
|
void MacDestroy() ;
|
||||||
void MacDelete( int n ) ;
|
void MacDelete( int n ) ;
|
||||||
void MacInsert( int n , const char * text) ;
|
void MacInsert( int n , const char * text) ;
|
||||||
@@ -111,13 +134,25 @@ class WXDLLEXPORT wxListBox: public wxControl
|
|||||||
void MacDoClick() ;
|
void MacDoClick() ;
|
||||||
void MacDoDoubleClick() ;
|
void MacDoDoubleClick() ;
|
||||||
|
|
||||||
public :
|
// do we have multiple selections?
|
||||||
ListHandle m_macList ;
|
bool HasMultipleSelection() const;
|
||||||
wxArrayString m_stringArray ;
|
|
||||||
wxListDataArray m_dataArray ;
|
// free memory (common part of Clear() and dtor)
|
||||||
|
void Free();
|
||||||
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
|
|
||||||
DECLARE_EVENT_TABLE()
|
int m_noItems;
|
||||||
|
int m_selected;
|
||||||
|
|
||||||
|
virtual wxSize DoGetBestSize();
|
||||||
|
|
||||||
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
// control items
|
||||||
|
wxListBoxItemsArray m_aItems;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxListBox)
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -16,168 +16,193 @@
|
|||||||
#pragma interface "menu.h"
|
#pragma interface "menu.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#if wxUSE_ACCEL
|
||||||
#include "wx/event.h"
|
#include "wx/accel.h"
|
||||||
|
#include "wx/dynarray.h"
|
||||||
|
|
||||||
class WXDLLEXPORT wxMenuItem;
|
WX_DEFINE_EXPORTED_ARRAY(wxAcceleratorEntry *, wxAcceleratorArray);
|
||||||
class WXDLLEXPORT wxMenuBar;
|
#endif // wxUSE_ACCEL
|
||||||
class WXDLLEXPORT wxMenu;
|
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
|
class WXDLLEXPORT wxFrame;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Menu
|
// Menu
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
class WXDLLEXPORT wxMenu: public wxEvtHandler
|
|
||||||
|
class WXDLLEXPORT wxMenu : public wxMenuBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMenu)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// ctor & dtor
|
// ctors & dtor
|
||||||
wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
|
wxMenu(const wxString& title, long style = 0)
|
||||||
~wxMenu();
|
: wxMenuBase(title, style) { Init(); }
|
||||||
|
|
||||||
// construct menu
|
wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
|
||||||
// append items to the menu
|
|
||||||
// separator line
|
|
||||||
void AppendSeparator();
|
|
||||||
// normal item
|
|
||||||
void Append(int id, const wxString& Label, const wxString& helpString = wxEmptyString,
|
|
||||||
bool checkable = FALSE);
|
|
||||||
// a submenu
|
|
||||||
void Append(int id, const wxString& Label, wxMenu *SubMenu,
|
|
||||||
const wxString& helpString = wxEmptyString);
|
|
||||||
// the most generic form (create wxMenuItem first and use it's functions)
|
|
||||||
void Append(wxMenuItem *pItem);
|
|
||||||
// insert a break in the menu
|
|
||||||
void Break();
|
|
||||||
// delete an item
|
|
||||||
void Delete(int id);
|
|
||||||
|
|
||||||
// menu item control
|
virtual ~wxMenu();
|
||||||
void Enable(int id, bool Flag);
|
|
||||||
bool Enabled(int id) const;
|
|
||||||
inline bool IsEnabled(int id) const { return Enabled(id); };
|
|
||||||
void Check(int id, bool Flag);
|
|
||||||
bool Checked(int id) const;
|
|
||||||
inline bool IsChecked(int id) const { return IsChecked(id); };
|
|
||||||
|
|
||||||
// Client data
|
// implement base class virtuals
|
||||||
inline void SetClientData(void* clientData) { m_clientData = clientData; }
|
virtual bool DoAppend(wxMenuItem *item);
|
||||||
inline void* GetClientData() const { return m_clientData; }
|
virtual bool DoInsert(size_t pos, wxMenuItem *item);
|
||||||
|
virtual wxMenuItem *DoRemove(wxMenuItem *item);
|
||||||
|
|
||||||
// item properties
|
virtual void Break();
|
||||||
// title
|
|
||||||
void SetTitle(const wxString& label);
|
|
||||||
const wxString GetTitle() const;
|
|
||||||
// label
|
|
||||||
void SetLabel(int id, const wxString& label);
|
|
||||||
wxString GetLabel(int id) const;
|
|
||||||
// help string
|
|
||||||
virtual void SetHelpString(int id, const wxString& helpString);
|
|
||||||
virtual wxString GetHelpString(int id) const ;
|
|
||||||
|
|
||||||
// find item
|
virtual void SetTitle(const wxString& title);
|
||||||
// Finds the item id matching the given string, -1 if not found.
|
|
||||||
virtual int FindItem(const wxString& itemString) const ;
|
|
||||||
// Find wxMenuItem by ID, and item's menu too if itemMenu is !NULL.
|
|
||||||
wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;
|
|
||||||
|
|
||||||
void ProcessCommand(wxCommandEvent& event);
|
// MSW-specific
|
||||||
inline void Callback(const wxFunction func) { m_callback = func; }
|
bool ProcessCommand(wxCommandEvent& event);
|
||||||
|
|
||||||
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
|
#if WXWIN_COMPATIBILITY
|
||||||
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
wxMenu(const wxString& title, const wxFunction func)
|
||||||
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
: wxMenuBase(title)
|
||||||
|
{
|
||||||
|
Callback(func);
|
||||||
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
inline wxList& GetItems() const { return (wxList&) m_menuItems; }
|
// implementation only from now on
|
||||||
|
// -------------------------------
|
||||||
|
|
||||||
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
|
bool MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ;
|
||||||
wxWindow * GetInvokingWindow() const { return m_pInvokingWindow; }
|
int MacGetIndexFromId( int id ) ;
|
||||||
|
int MacGetIndexFromItem( wxMenuItem *pItem ) ;
|
||||||
|
void MacEnableMenu( bool bDoEnable ) ;
|
||||||
|
|
||||||
bool MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ;
|
// semi-private accessors
|
||||||
public:
|
// get the window which contains this menu
|
||||||
wxFunction m_callback;
|
wxWindow *GetWindow() const;
|
||||||
|
// get the menu handle
|
||||||
|
WXHMENU GetHMenu() const { return m_hMenu; }
|
||||||
|
|
||||||
int m_noItems;
|
// attach/detach menu to/from wxMenuBar
|
||||||
wxString m_title;
|
void Attach(wxMenuBar *menubar);
|
||||||
wxMenuBar * m_menuBar;
|
void Detach();
|
||||||
wxList m_menuItems;
|
short MacGetMenuId() { return m_macMenuId ; }
|
||||||
wxEvtHandler * m_parent;
|
#if wxUSE_ACCEL
|
||||||
wxEvtHandler * m_eventHandler;
|
// called by wxMenuBar to build its accel table from the accels of all menus
|
||||||
wxWindow* m_pInvokingWindow;
|
bool HasAccels() const { return !m_accels.IsEmpty(); }
|
||||||
void* m_clientData;
|
size_t GetAccelCount() const { return m_accels.GetCount(); }
|
||||||
|
size_t CopyAccels(wxAcceleratorEntry *accels) const;
|
||||||
MenuHandle m_macMenuHandle;
|
|
||||||
short m_macMenuId;
|
|
||||||
bool m_macMenuEnabled ;
|
|
||||||
|
|
||||||
// void MacSetTitle(const wxString& title);
|
// called by wxMenuItem when its accels changes
|
||||||
int MacGetIndexFromId( int id ) ;
|
void UpdateAccel(wxMenuItem *item);
|
||||||
int MacGetIndexFromItem( wxMenuItem *pItem ) ;
|
|
||||||
void MacEnableMenu( bool bDoEnable ) ;
|
|
||||||
|
|
||||||
static short s_macNextMenuId ;
|
// helper used by wxMenu itself (returns the index in m_accels)
|
||||||
|
int FindAccel(int id) const;
|
||||||
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
protected:
|
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);
|
||||||
|
|
||||||
|
// if TRUE, insert a breal before appending the next item
|
||||||
|
bool m_doBreak;
|
||||||
|
|
||||||
|
// the menu handle of this menu
|
||||||
|
WXHMENU m_hMenu;
|
||||||
|
|
||||||
|
short m_macMenuId;
|
||||||
|
|
||||||
|
static short s_macNextMenuId ;
|
||||||
|
#if wxUSE_ACCEL
|
||||||
|
// the accelerators for our menu items
|
||||||
|
wxAcceleratorArray m_accels;
|
||||||
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxMenu)
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Menu Bar (a la Windows)
|
// Menu Bar (a la Windows)
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
class WXDLLEXPORT wxFrame;
|
|
||||||
class WXDLLEXPORT wxMenuBar: public wxEvtHandler
|
class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
public:
|
||||||
|
// ctors & dtor
|
||||||
|
// default constructor
|
||||||
|
wxMenuBar();
|
||||||
|
// unused under MSW
|
||||||
|
wxMenuBar(long style);
|
||||||
|
// menubar takes ownership of the menus arrays but copies the titles
|
||||||
|
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
|
||||||
|
virtual ~wxMenuBar();
|
||||||
|
|
||||||
wxMenuBar();
|
// menubar construction
|
||||||
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
|
virtual bool Append( wxMenu *menu, const wxString &title );
|
||||||
~wxMenuBar();
|
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);
|
||||||
|
|
||||||
void Append(wxMenu *menu, const wxString& title);
|
virtual int FindMenuItem(const wxString& menuString,
|
||||||
// Must only be used AFTER menu has been attached to frame,
|
const wxString& itemString) const;
|
||||||
// otherwise use individual menus to enable/disable items
|
virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
|
||||||
void Enable(int Id, bool Flag);
|
|
||||||
bool Enabled(int Id) const ;
|
|
||||||
inline bool IsEnabled(int Id) const { return Enabled(Id); };
|
|
||||||
void EnableTop(int pos, bool Flag);
|
|
||||||
void Check(int id, bool Flag);
|
|
||||||
bool Checked(int id) const ;
|
|
||||||
inline bool IsChecked(int Id) const { return Checked(Id); };
|
|
||||||
void SetLabel(int id, const wxString& label) ;
|
|
||||||
wxString GetLabel(int id) const ;
|
|
||||||
void SetLabelTop(int pos, const wxString& label) ;
|
|
||||||
wxString GetLabelTop(int pos) const ;
|
|
||||||
virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
|
|
||||||
virtual bool OnAppend(wxMenu *menu, const char *title);
|
|
||||||
virtual bool OnDelete(wxMenu *menu, int index);
|
|
||||||
|
|
||||||
virtual void SetHelpString(int Id, const wxString& helpString);
|
virtual void EnableTop( size_t pos, bool flag );
|
||||||
virtual wxString GetHelpString(int Id) const ;
|
virtual void SetLabelTop( size_t pos, const wxString& label );
|
||||||
|
virtual wxString GetLabelTop( size_t pos ) const;
|
||||||
|
|
||||||
virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ;
|
// compatibility: these functions are deprecated
|
||||||
|
#if WXWIN_COMPATIBILITY
|
||||||
|
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||||
|
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||||
|
|
||||||
// Find wxMenuItem for item ID, and return item's
|
bool Enabled(int id) const { return IsEnabled(id); }
|
||||||
// menu too if itemMenu is non-NULL.
|
bool Checked(int id) const { return IsChecked(id); }
|
||||||
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
// implementation from now on
|
||||||
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
WXHMENU Create();
|
||||||
|
int FindMenu(const wxString& title);
|
||||||
|
void Detach();
|
||||||
|
|
||||||
inline int GetMenuCount() const { return m_menuCount; }
|
// returns TRUE if we're attached to a frame
|
||||||
inline wxMenu* GetMenu(int i) const { return m_menus[i]; }
|
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);
|
||||||
|
|
||||||
|
#if wxUSE_ACCEL
|
||||||
|
// get the accel table for all the menus
|
||||||
|
const wxAcceleratorTable& GetAccelTable() const { return m_accelTable; }
|
||||||
|
|
||||||
|
// update the accel table (must be called after adding/deletign a menu)
|
||||||
|
void RebuildAccelTable();
|
||||||
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
|
// if the menubar is modified, the display is not updated automatically,
|
||||||
|
// call this function to update it (m_menuBarFrame should be !NULL)
|
||||||
|
void Refresh();
|
||||||
|
|
||||||
void MacInstallMenuBar() ;
|
void MacInstallMenuBar() ;
|
||||||
void MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ;
|
void MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ;
|
||||||
|
static wxMenuBar* MacGetInstalledMenuBar() { return s_macInstalledMenuBar ; }
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
wxEvtHandler * m_eventHandler;
|
// common part of all ctors
|
||||||
int m_menuCount;
|
void Init();
|
||||||
wxMenu ** m_menus;
|
|
||||||
wxString * m_titles;
|
|
||||||
wxFrame * m_menuBarFrame;
|
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY
|
||||||
|
wxEvtHandler *m_eventHandler;
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
|
wxArrayString m_titles;
|
||||||
|
|
||||||
|
wxFrame *m_menuBarFrame;
|
||||||
|
|
||||||
|
#if wxUSE_ACCEL
|
||||||
|
// the accelerator table for all accelerators in all our menus
|
||||||
|
wxAcceleratorTable m_accelTable;
|
||||||
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
|
private:
|
||||||
static wxMenuBar* s_macInstalledMenuBar ;
|
static wxMenuBar* s_macInstalledMenuBar ;
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_MENU_H_
|
#endif // _WX_MENU_H_
|
||||||
|
@@ -11,46 +11,4 @@
|
|||||||
|
|
||||||
#ifndef _WX_PRINT_H_
|
#ifndef _WX_PRINT_H_
|
||||||
#define _WX_PRINT_H_
|
#define _WX_PRINT_H_
|
||||||
|
#endif
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface "print.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/prntbase.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Represents the printer: manages printing a wxPrintout object
|
|
||||||
*/
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxPrinter: public wxPrinterBase
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxPrinter)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxPrinter(wxPrintData *data = NULL);
|
|
||||||
~wxPrinter();
|
|
||||||
|
|
||||||
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
|
|
||||||
virtual bool PrintDialog(wxWindow *parent);
|
|
||||||
virtual bool Setup(wxWindow *parent);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* wxPrintPreview
|
|
||||||
* Programmer creates an object of this class to preview a wxPrintout.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxPrintPreview: public wxPrintPreviewBase
|
|
||||||
{
|
|
||||||
DECLARE_CLASS(wxPrintPreview)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintData *data = NULL);
|
|
||||||
~wxPrintPreview();
|
|
||||||
|
|
||||||
virtual bool Print(bool interactive);
|
|
||||||
virtual void DetermineScaling();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// _WX_PRINT_H_
|
|
@@ -33,18 +33,21 @@ class WXDLLEXPORT wxPrintDialog: public wxDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
wxPrintDialog();
|
wxPrintDialog();
|
||||||
wxPrintDialog(wxWindow *parent, wxPrintData* data = NULL);
|
wxPrintDialog(wxWindow *parent, wxPrintDialogData* data = NULL);
|
||||||
|
wxPrintDialog(wxWindow *parent, wxPrintData* data );
|
||||||
~wxPrintDialog();
|
~wxPrintDialog();
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxPrintData* data = NULL);
|
bool Create(wxWindow *parent, wxPrintDialogData* data = NULL);
|
||||||
virtual int ShowModal();
|
virtual int ShowModal();
|
||||||
|
|
||||||
inline wxPrintData& GetPrintData() { return m_printData; }
|
wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; }
|
||||||
|
wxPrintData& GetPrintData() { return m_printDialogData.GetPrintData(); }
|
||||||
virtual wxDC *GetPrintDC();
|
virtual wxDC *GetPrintDC();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxPrintData m_printData;
|
wxPrintDialogData m_printDialogData;
|
||||||
wxDC* m_printerDC;
|
wxDC* m_printerDC;
|
||||||
|
bool m_destroyDC;
|
||||||
wxWindow* m_dialogParent;
|
wxWindow* m_dialogParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,9 +55,6 @@ class WXDLLEXPORT wxPageSetupDialog: public wxDialog
|
|||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxPageSetupDialog)
|
DECLARE_DYNAMIC_CLASS(wxPageSetupDialog)
|
||||||
|
|
||||||
private:
|
|
||||||
wxPageSetupData m_pageSetupData;
|
|
||||||
wxWindow* m_dialogParent;
|
|
||||||
public:
|
public:
|
||||||
wxPageSetupDialog();
|
wxPageSetupDialog();
|
||||||
wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL);
|
wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL);
|
||||||
@@ -64,6 +64,9 @@ class WXDLLEXPORT wxPageSetupDialog: public wxDialog
|
|||||||
virtual int ShowModal();
|
virtual int ShowModal();
|
||||||
|
|
||||||
inline wxPageSetupData& GetPageSetupData() { return m_pageSetupData; }
|
inline wxPageSetupData& GetPageSetupData() { return m_pageSetupData; }
|
||||||
|
private:
|
||||||
|
wxPageSetupData m_pageSetupData;
|
||||||
|
wxWindow* m_dialogParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -16,71 +16,109 @@
|
|||||||
* General features
|
* General features
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define wxUSE_BUSYINFO 1
|
|
||||||
|
|
||||||
#define WORDS_BIGENDIAN 1
|
|
||||||
|
|
||||||
#define wxUSE_LIBPNG 1
|
|
||||||
// Use PNG bitmap code
|
|
||||||
#define wxUSE_LIBJPEG 1
|
|
||||||
// Use JPEG bitmap code
|
|
||||||
#define wxUSE_STREAMS 1
|
|
||||||
|
|
||||||
#define wxUSE_ZLIB 1
|
|
||||||
#define wxUSE_ZIPSTREAM 1
|
|
||||||
#define wxUSE_SOCKETS 1
|
|
||||||
|
|
||||||
#define wxUSE_CONSTRAINTS 1
|
|
||||||
// Use constraints mechanism
|
|
||||||
#define wxUSE_CONFIG 1
|
#define wxUSE_CONFIG 1
|
||||||
// Use wxConfig, with CreateConfig in wxApp
|
// Use wxConfig, with CreateConfig in wxApp
|
||||||
#define _WX_GOODCOMPILER__
|
|
||||||
// gcc can have problems, but Windows compilers
|
|
||||||
// are generally OK.
|
|
||||||
#define WXWIN_COMPATIBILITY 0
|
#define WXWIN_COMPATIBILITY 0
|
||||||
// Compatibility with 1.66 API.
|
// Compatibility with 1.66 API.
|
||||||
// Level 0: no backward compatibility, all new features
|
// Level 0: no backward compatibility, all new features
|
||||||
// Level 1: wxDC, OnSize (etc.) compatibility, but
|
// Level 1: wxDC, OnSize (etc.) compatibility, but
|
||||||
// some new features such as event tables
|
// some new features such as event tables
|
||||||
|
|
||||||
#define wxUSE_AUTOTRANS 0
|
|
||||||
// Define wxTString
|
|
||||||
#define wxUSE_POSTSCRIPT 0
|
#define wxUSE_POSTSCRIPT 0
|
||||||
// 0 for no PostScript device context
|
// 0 for no PostScript device context
|
||||||
#define wxUSE_AFM_FOR_POSTSCRIPT 0
|
#define wxUSE_AFM_FOR_POSTSCRIPT 0
|
||||||
// 1 to use font metric files in GetTextExtent
|
// 1 to use font metric files in GetTextExtent
|
||||||
#define wxUSE_METAFILE 1
|
#define wxUSE_METAFILE 1
|
||||||
// 0 for no Metafile and metafile device context
|
// 0 for no Metafile and metafile device context
|
||||||
#define wxUSE_FORM 0
|
|
||||||
// 0 for no wxForm
|
|
||||||
#define wxUSE_IPC 0
|
#define wxUSE_IPC 0
|
||||||
// 0 for no interprocess comms
|
// 0 for no interprocess comms
|
||||||
#define wxUSE_HELP 0
|
#define wxUSE_HELP 0
|
||||||
// 0 for no help facility
|
// 0 for no help facility
|
||||||
#define wxUSE_RESOURCES 1
|
#define wxUSE_RESOURCES 1
|
||||||
// 0 for no wxGetResource/wxWriteResource
|
// 0 for no wxGetResource/wxWriteResource
|
||||||
|
#define wxUSE_CONSTRAINTS 1
|
||||||
|
// Use constraints mechanism
|
||||||
|
#define wxUSE_TIMEDATE 1
|
||||||
|
// 0 for no wxTime/wxDate classes
|
||||||
|
|
||||||
#define wxUSE_CLIPBOARD 1
|
#define wxUSE_CLIPBOARD 1
|
||||||
// 0 for no clipboard functions
|
// 0 for no clipboard functions
|
||||||
#define wxUSE_SPLINES 0
|
|
||||||
// 0 for no splines
|
#define wxUSE_SPLINES 1
|
||||||
#define wxUSE_XFIG_SPLINE_CODE 0
|
// 0 for no splines
|
||||||
// 1 for XFIG spline code, 0 for AIAI spline code.
|
|
||||||
// AIAI spline code is slower, but freer of copyright issues.
|
|
||||||
// 0 for no splines
|
|
||||||
|
|
||||||
#define wxUSE_TOOLBAR 1
|
|
||||||
// Use toolbars
|
|
||||||
#define wxUSE_DRAG_AND_DROP 0
|
#define wxUSE_DRAG_AND_DROP 0
|
||||||
// 0 for no drag and drop
|
// 0 for no drag and drop
|
||||||
|
|
||||||
|
#define wxUSE_TOOLBAR 1
|
||||||
|
// Define 1 to use toolbar classes
|
||||||
|
#define wxUSE_BUTTONBAR 1
|
||||||
|
// Define 1 to use buttonbar classes (enhanced toolbar
|
||||||
|
// for MS Windows)
|
||||||
|
#define wxUSE_GAUGE 1
|
||||||
|
// Define 1 to use Microsoft's gauge (Windows)
|
||||||
|
// or Bull's gauge (Motif) library (both in contrib).
|
||||||
|
#define wxUSE_COMBOBOX 1
|
||||||
|
// Define 1 to use COMBOXBOX control (Windows)
|
||||||
|
// or FWW's ComboBox widget (Motif).
|
||||||
|
#define wxUSE_CHOICE 1
|
||||||
|
// Define 1 to use CHOICE
|
||||||
|
|
||||||
|
#define wxUSE_RADIOBUTTON 1
|
||||||
|
// Define 1 to use radio button control
|
||||||
|
#define wxUSE_RADIOBTN 1
|
||||||
|
// Unfortunately someone introduced this one, too
|
||||||
|
|
||||||
|
#define wxUSE_SCROLLBAR 1
|
||||||
|
// Define 1 to compile contributed wxScrollBar class
|
||||||
|
|
||||||
|
#define wxUSE_CHECKBOX 1
|
||||||
|
// Define 1 to compile checkbox
|
||||||
|
|
||||||
|
#define wxUSE_LISTBOX 1
|
||||||
|
// Define 1 to compile listbox
|
||||||
|
|
||||||
|
#define wxUSE_SPINBTN 1
|
||||||
|
// Define 1 to compile spin button
|
||||||
|
|
||||||
|
// use wxStaticLine class (separator line in the dialog)?
|
||||||
|
#define wxUSE_STATLINE 1
|
||||||
|
|
||||||
|
#define wxUSE_CHECKLISTBOX 1
|
||||||
|
// Define 1 to compile check listbox
|
||||||
|
|
||||||
|
#define wxUSE_CHOICE 1
|
||||||
|
// Define 1 to compile choice
|
||||||
|
|
||||||
|
#define wxUSE_CARET 1
|
||||||
|
// Define 1 to use wxCaret class
|
||||||
|
#define wxUSE_XPM_IN_MSW 1
|
||||||
|
// Define 1 to support the XPM package in wxBitmap.
|
||||||
|
#define wxUSE_IMAGE_LOADING_IN_MSW 1
|
||||||
|
// Use dynamic DIB loading/saving code in utils/dib under MSW.
|
||||||
|
#define wxUSE_RESOURCE_LOADING_IN_MSW 1
|
||||||
|
// Use dynamic icon/cursor loading/saving code
|
||||||
|
// under MSW.
|
||||||
#define wxUSE_WX_RESOURCES 1
|
#define wxUSE_WX_RESOURCES 1
|
||||||
// Use .wxr resource mechanism (requires PrologIO library)
|
// Use .wxr resource mechanism (requires PrologIO library)
|
||||||
|
|
||||||
|
// support for startup tips (wxShowTip &c)
|
||||||
|
#define wxUSE_STARTUP_TIPS 1
|
||||||
|
|
||||||
|
// BC++/Win16 can't cope with the amount of data in resource.cpp
|
||||||
|
#if defined(__WIN16__) && defined(__BORLANDC__)
|
||||||
|
#undef wxUSE_WX_RESOURCES
|
||||||
|
#define wxUSE_WX_RESOURCES 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define wxUSE_DOC_VIEW_ARCHITECTURE 1
|
#define wxUSE_DOC_VIEW_ARCHITECTURE 1
|
||||||
// Set to 0 to disable document/view architecture
|
// Set to 0 to disable document/view architecture
|
||||||
|
#define wxUSE_MDI_ARCHITECTURE 1
|
||||||
|
// Set to 0 to disable MDI document/view architecture
|
||||||
#define wxUSE_PRINTING_ARCHITECTURE 1
|
#define wxUSE_PRINTING_ARCHITECTURE 1
|
||||||
// Set to 0 to disable print/preview architecture code
|
// Set to 0 to disable print/preview architecture code
|
||||||
#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 0
|
#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 1
|
||||||
// Set to 0 to disable PostScript print/preview architecture code
|
// Set to 0 to disable PostScript print/preview architecture code
|
||||||
// under Windows (just use Windows printing).
|
// under Windows (just use Windows printing).
|
||||||
#define wxUSE_DYNAMIC_CLASSES 1
|
#define wxUSE_DYNAMIC_CLASSES 1
|
||||||
@@ -88,19 +126,19 @@
|
|||||||
// NOW MANDATORY: don't change.
|
// NOW MANDATORY: don't change.
|
||||||
#define wxUSE_MEMORY_TRACING 1
|
#define wxUSE_MEMORY_TRACING 1
|
||||||
// If 1, enables debugging versions of wxObject::new and
|
// If 1, enables debugging versions of wxObject::new and
|
||||||
// wxObject::delete *IF* WXDEBUG is also defined.
|
// wxObject::delete *IF* __WXDEBUG__ is also defined.
|
||||||
// WARNING: this code may not work with all architectures, especially
|
// WARNING: this code may not work with all architectures, especially
|
||||||
// if alignment is an issue.
|
// if alignment is an issue.
|
||||||
#define wxUSE_DEBUG_CONTEXT 1
|
#define wxUSE_DEBUG_CONTEXT 1
|
||||||
// If 1, enables wxDebugContext, for
|
// If 1, enables wxDebugContext, for
|
||||||
// writing error messages to file, etc.
|
// writing error messages to file, etc.
|
||||||
// If WXDEBUG is not defined, will still use
|
// If __WXDEBUG__ is not defined, will still use
|
||||||
// normal memory operators.
|
// normal memory operators.
|
||||||
// It's recommended to set this to 1,
|
// It's recommended to set this to 1,
|
||||||
// since you may well need to output
|
// since you may well need to output
|
||||||
// an error log in a production
|
// an error log in a production
|
||||||
// version (or non-debugging beta)
|
// version (or non-debugging beta)
|
||||||
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
|
#define wxUSE_GLOBAL_MEMORY_OPERATORS 1
|
||||||
// In debug mode, cause new and delete to be redefined globally.
|
// In debug mode, cause new and delete to be redefined globally.
|
||||||
// If this causes problems (e.g. link errors), set this to 0.
|
// If this causes problems (e.g. link errors), set this to 0.
|
||||||
|
|
||||||
@@ -108,16 +146,16 @@
|
|||||||
// In debug mode, causes new to be defined to
|
// In debug mode, causes new to be defined to
|
||||||
// be WXDEBUG_NEW (see object.h).
|
// be WXDEBUG_NEW (see object.h).
|
||||||
// If this causes problems (e.g. link errors), set this to 0.
|
// If this causes problems (e.g. link errors), set this to 0.
|
||||||
|
// You may need to set this to 0 if using templates (at least
|
||||||
|
// for VC++).
|
||||||
|
|
||||||
#define REMOVE_UNUSED_ARG 1
|
#define REMOVE_UNUSED_ARG 1
|
||||||
// Set this to 0 if your compiler can't cope
|
// Set this to 0 if your compiler can't cope
|
||||||
// with omission of prototype parameters.
|
// with omission of prototype parameters.
|
||||||
|
|
||||||
#define wxUSE_C_MAIN 0
|
#define wxUSE_ODBC 1
|
||||||
// Set to 1 to use main.c instead of main.cpp (UNIX only)
|
// Define 1 to use ODBC classes
|
||||||
|
|
||||||
#define wxUSE_ODBC 0
|
|
||||||
// Define 1 to use ODBC classes
|
|
||||||
|
|
||||||
#define wxODBC_FWD_ONLY_CURSORS 1
|
#define wxODBC_FWD_ONLY_CURSORS 1
|
||||||
// Some databases/ODBC drivers only allow forward scrolling cursors.
|
// Some databases/ODBC drivers only allow forward scrolling cursors.
|
||||||
@@ -129,36 +167,67 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __MWERKS__
|
||||||
#define wxUSE_IOSTREAMH 0
|
#define wxUSE_IOSTREAMH 0
|
||||||
|
#else
|
||||||
|
#define wxUSE_IOSTREAMH 1
|
||||||
|
#endif
|
||||||
// VC++ 4.2 and above allows <iostream> and <iostream.h>
|
// VC++ 4.2 and above allows <iostream> and <iostream.h>
|
||||||
// but you can't mix them. Set to 1 for <iostream.h>,
|
// but you can't mix them. Set to 1 for <iostream.h>,
|
||||||
// 0 for <iostream>
|
// 0 for <iostream>
|
||||||
|
|
||||||
#define wxUSE_ZIPSTREAM 1
|
|
||||||
|
|
||||||
#define wxUSE_FS_ZIP 1
|
|
||||||
|
|
||||||
#define wxUSE_FS_INET 1
|
|
||||||
|
|
||||||
#define wxUSE_STREAMS 1
|
#define wxUSE_STREAMS 1
|
||||||
// If enabled (1), compiles wxWindows streams classes
|
// If enabled (1), compiles wxWindows streams classes
|
||||||
|
|
||||||
#define wxUSE_STD_IOSTREAM 1
|
#define wxUSE_STD_IOSTREAM 1
|
||||||
// Use standard C++ streams if 1. If 0, use wxWin
|
// Use standard C++ streams if 1. If 0, use wxWin
|
||||||
// streams implementation.
|
// streams implementation.
|
||||||
#define wxUSE_WXCONFIG 0
|
|
||||||
|
#define wxUSE_WXCONFIG 1
|
||||||
// if enabled, compiles built-in OS independent wxConfig
|
// if enabled, compiles built-in OS independent wxConfig
|
||||||
// class and it's file (any platform) and registry (Win)
|
// class and it's file (any platform) and registry (Win)
|
||||||
// based implementations
|
// based implementations
|
||||||
|
#define wxUSE_THREADS 1
|
||||||
|
// support for multithreaded applications: if
|
||||||
|
// 1, compile in thread classes (thread.h)
|
||||||
|
// and make the library thread safe
|
||||||
|
#define wxUSE_ZLIB 1
|
||||||
|
// Use zlib for compression in streams and PNG code
|
||||||
|
#define wxUSE_LIBPNG 1
|
||||||
|
// Use PNG bitmap code
|
||||||
|
#define wxUSE_LIBJPEG 0
|
||||||
|
// Use JPEG bitmap code
|
||||||
|
#define wxUSE_SERIAL 0
|
||||||
|
// Use serialization (requires utils/serialize)
|
||||||
|
#define wxUSE_DYNLIB_CLASS 0
|
||||||
|
// Compile in wxLibrary class for run-time
|
||||||
|
// DLL loading and function calling
|
||||||
|
#define wxUSE_TOOLTIPS 1
|
||||||
|
// Define to use wxToolTip class and
|
||||||
|
// wxWindow::SetToolTip() method
|
||||||
|
#define wxUSE_SOCKETS 1 // 0
|
||||||
|
// Set to 1 to use socket classes
|
||||||
|
#define wxUSE_HTML 1 // 0
|
||||||
|
// Set to 1 to use wxHTML sub-library
|
||||||
|
#define wxUSE_FS_ZIP 1 // 0
|
||||||
|
#define wxUSE_FS_INET 1 // 0 // Set to 1 to enable virtual file systems
|
||||||
|
|
||||||
|
#define wxUSE_BUSYINFO 1 // 0
|
||||||
|
// wxBusyInfo displays window with message
|
||||||
|
// when app is busy. Works in same way as
|
||||||
|
// wxBusyCursor
|
||||||
|
#define wxUSE_ZIPSTREAM 1 // 0
|
||||||
|
// input stream for reading from zip archives
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finer detail
|
* Finer detail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define wxUSE_APPLE_IEEE 1
|
#define wxUSE_APPLE_IEEE 1
|
||||||
// if enabled, the float codec written by Apple
|
// if enabled, the float codec written by Apple
|
||||||
// will be used to write, in a portable way,
|
// will be used to write, in a portable way,
|
||||||
// float on the disk
|
// float on the disk
|
||||||
|
|
||||||
// use wxFile class - required by i18n code, wxConfig and others - recommended
|
// use wxFile class - required by i18n code, wxConfig and others - recommended
|
||||||
#define wxUSE_FILE 1
|
#define wxUSE_FILE 1
|
||||||
@@ -184,8 +253,6 @@
|
|||||||
// text entry dialog and wxGetTextFromUser function
|
// text entry dialog and wxGetTextFromUser function
|
||||||
#define wxUSE_TEXTDLG 1
|
#define wxUSE_TEXTDLG 1
|
||||||
|
|
||||||
#define wxUSE_STATLINE 1
|
|
||||||
|
|
||||||
// wxToolBar class
|
// wxToolBar class
|
||||||
#define wxUSE_TOOLBAR 1
|
#define wxUSE_TOOLBAR 1
|
||||||
|
|
||||||
@@ -198,5 +265,68 @@
|
|||||||
// wxDirDlg class for getting a directory name from user
|
// wxDirDlg class for getting a directory name from user
|
||||||
#define wxUSE_DIRDLG 1
|
#define wxUSE_DIRDLG 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MS Windows/Windows NT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define wxUSE_OLE 1
|
||||||
|
// drag-and-drop, clipboard, OLE Automation
|
||||||
|
|
||||||
|
#if defined(__WIN95__)
|
||||||
|
#define wxUSE_CTL3D 0
|
||||||
|
#else
|
||||||
|
#define wxUSE_CTL3D 1
|
||||||
|
// Define 1 to use Microsoft CTL3D library.
|
||||||
|
// See note above about using FAFA and CTL3D.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define wxUSE_COMMON_DIALOGS 1
|
||||||
|
// On rare occasions (e.g. using DJGPP) may want
|
||||||
|
// to omit common dialogs
|
||||||
|
// (e.g. file selector, printer dialog).
|
||||||
|
// Switching this off also switches off
|
||||||
|
// the printing architecture and interactive
|
||||||
|
// wxPrinterDC.
|
||||||
|
#define wxUSE_ITSY_BITSY 1
|
||||||
|
// Define 1 to use Microsoft's ItsyBitsy
|
||||||
|
// small title bar library, for wxMiniFrame
|
||||||
|
#define wxUSE_BITMAP_MESSAGE 1
|
||||||
|
// Define 1 to use bitmap messages.
|
||||||
|
#define wxUSE_PORTABLE_FONTS_IN_MSW 0
|
||||||
|
// Define 1 to use new portable font scheme in Windows
|
||||||
|
// (used by default under X)
|
||||||
|
#define wxFONT_SIZE_COMPATIBILITY 0
|
||||||
|
// Define 1 for font size to be backward compatible
|
||||||
|
// to 1.63 and earlier. 1.64 and later define point
|
||||||
|
// sizes to be compatible with Windows.
|
||||||
|
#define wxUSE_GENERIC_DIALOGS_IN_MSW 1
|
||||||
|
// Define 1 to use generic dialogs in Windows, even though
|
||||||
|
// they duplicate native common dialog (e.g. wxColourDialog)
|
||||||
|
#define wxUSE_PENWINDOWS 0
|
||||||
|
// Set to 1 to use PenWindows
|
||||||
|
|
||||||
|
#define wxUSE_OWNER_DRAWN 1
|
||||||
|
// Owner-drawn menus and listboxes
|
||||||
|
|
||||||
|
#define wxUSE_NATIVE_STATUSBAR 1
|
||||||
|
// Set to 0 to use cross-platform wxStatusBar
|
||||||
|
#define wxUSE_DBWIN32 1
|
||||||
|
// Use Andrew Tucker's OutputDebugString implementation
|
||||||
|
// (required on Win95 only). See utils.cpp.
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Any platform
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define wxUSE_TYPEDEFS 1
|
||||||
|
// Use typedefs not classes for wxPoint
|
||||||
|
// and others, to reduce overhead and avoid
|
||||||
|
// MS C7 memory bug. Bounds checker
|
||||||
|
// complains about deallocating
|
||||||
|
// arrays of wxPoints if wxPoint is a class.
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_SETUP_H_
|
// _WX_SETUP_H_
|
||||||
|
@@ -29,71 +29,48 @@
|
|||||||
wxSP_WRAP: value wraps at either end
|
wxSP_WRAP: value wraps at either end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class WXDLLEXPORT wxSpinButton: public wxControl
|
class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxSpinButton)
|
public:
|
||||||
public:
|
// construction
|
||||||
/*
|
wxSpinButton() { }
|
||||||
* Public interface
|
|
||||||
*/
|
|
||||||
|
|
||||||
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 = "wxSpinButton")
|
||||||
|
{
|
||||||
|
Create(parent, id, pos, size, style, name);
|
||||||
|
}
|
||||||
|
|
||||||
inline wxSpinButton(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
virtual ~wxSpinButton();
|
||||||
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
|
|
||||||
{
|
|
||||||
Create(parent, id, pos, size, style, name);
|
|
||||||
}
|
|
||||||
~wxSpinButton();
|
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
bool Create(wxWindow *parent,
|
||||||
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton");
|
wxWindowID id = -1,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
|
||||||
|
const wxString& name = "wxSpinButton");
|
||||||
|
|
||||||
|
|
||||||
// Attributes
|
// accessors
|
||||||
////////////////////////////////////////////////////////////////////////////
|
virtual int GetValue() const;
|
||||||
|
virtual void SetValue(int val);
|
||||||
|
virtual void SetRange(int minVal, int maxVal);
|
||||||
|
|
||||||
int GetValue() const ;
|
// implementation
|
||||||
void SetValue(int val) ;
|
|
||||||
void SetRange(int minVal, int maxVal) ;
|
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
|
||||||
inline int GetMin() const { return m_min; }
|
|
||||||
inline int GetMax() const { return m_max; }
|
|
||||||
|
|
||||||
// Operations
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void Command(wxCommandEvent& event) { ProcessCommand(event); };
|
|
||||||
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_min;
|
virtual wxSize DoGetBestSize();
|
||||||
int m_max;
|
int m_value ;
|
||||||
int m_value ;
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxSpinButton)
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxSpinEvent: public wxScrollEvent
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxSpinEvent)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
|
|
||||||
|
|
||||||
// Spin events
|
|
||||||
|
|
||||||
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
|
|
||||||
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
|
|
||||||
|
|
||||||
#define EVT_SPIN(id, func) \
|
|
||||||
{ wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
|
|
||||||
{ wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
|
|
||||||
{ wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
|
|
||||||
{ wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
|
|
||||||
{ wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
|
|
||||||
{ wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
|
|
||||||
{ wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_SPINBUTT_H_
|
// _WX_SPINBUTT_H_
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxButton;
|
class WXDLLEXPORT wxButton;
|
||||||
|
class WXDLLEXPORT wxScrollBar;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
@@ -169,9 +170,9 @@ public:
|
|||||||
// simple accessors
|
// simple accessors
|
||||||
// ----------------
|
// ----------------
|
||||||
|
|
||||||
WXHWND GetHWND() const { return m_hWnd; }
|
// WXHWND GetHWND() const { return m_hWnd; }
|
||||||
void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
|
// void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
|
||||||
virtual WXWidget GetHandle() const { return (WXWidget) GetHWND(); }
|
virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
|
||||||
|
|
||||||
bool GetUseCtl3D() const { return m_useCtl3D; }
|
bool GetUseCtl3D() const { return m_useCtl3D; }
|
||||||
bool GetTransparentBackground() const { return m_backgroundTransparent; }
|
bool GetTransparentBackground() const { return m_backgroundTransparent; }
|
||||||
@@ -226,12 +227,57 @@ public:
|
|||||||
// Responds to colour changes: passes event on to children.
|
// Responds to colour changes: passes event on to children.
|
||||||
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
||||||
|
|
||||||
protected:
|
public :
|
||||||
// the window handle
|
static bool MacGetWindowFromPoint( const wxPoint &point , wxWindow** outWin ) ;
|
||||||
WXHWND m_hWnd;
|
virtual void MacActivate( EventRecord *ev , bool inIsActivating ) ;
|
||||||
|
virtual void MacUpdate( EventRecord *ev ) ;
|
||||||
|
virtual void MacUpdateImmediately() ;
|
||||||
|
virtual void MacRedraw( RgnHandle updatergn , long time) ;
|
||||||
|
virtual void MacMouseDown( EventRecord *ev , short windowPart ) ;
|
||||||
|
virtual void MacMouseUp( EventRecord *ev , short windowPart ) ;
|
||||||
|
virtual void MacMouseMoved( EventRecord *ev , short windowPart ) ;
|
||||||
|
virtual void MacKeyDown( EventRecord *ev ) ;
|
||||||
|
virtual bool MacCanFocus() const { return true ; }
|
||||||
|
|
||||||
// the old window proc (we subclass all windows)
|
virtual void MacFireMouseEvent( EventRecord *ev ) ;
|
||||||
WXFARPROC m_oldWndProc;
|
virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
|
||||||
|
virtual void MacEraseBackground( Rect *rect ) ;
|
||||||
|
WindowRef GetMacRootWindow() const ;
|
||||||
|
|
||||||
|
virtual ControlHandle MacGetContainerForEmbedding() ;
|
||||||
|
virtual void MacSuperChangedPosition() ;
|
||||||
|
|
||||||
|
bool MacSetupFocusPort() ;
|
||||||
|
bool MacSetupDrawingPort() ;
|
||||||
|
bool MacSetupFocusClientPort() ;
|
||||||
|
bool MacSetupDrawingClientPort() ;
|
||||||
|
|
||||||
|
virtual bool MacSetPortFocusParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* rootwin ) ;
|
||||||
|
virtual bool MacSetPortDrawingParams( const Point & localOrigin, const Rect & clipRect, WindowRef window , wxWindow* rootwin ) ;
|
||||||
|
|
||||||
|
virtual void MacGetPortParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin ) ;
|
||||||
|
virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
|
||||||
|
MacWindowData* MacGetWindowData() { return m_macWindowData ; }
|
||||||
|
static WindowRef MacGetWindowInUpdate() { return s_macWindowInUpdate ; }
|
||||||
|
static wxWindow* s_lastMouseWindow ;
|
||||||
|
private:
|
||||||
|
virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindow** outWin ) ;
|
||||||
|
protected:
|
||||||
|
|
||||||
|
MacWindowData* m_macWindowData ;
|
||||||
|
static WindowRef s_macWindowInUpdate ;
|
||||||
|
|
||||||
|
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() ;
|
||||||
|
|
||||||
// additional (MSW specific) flags
|
// additional (MSW specific) flags
|
||||||
bool m_useCtl3D:1; // Using CTL3D for this control
|
bool m_useCtl3D:1; // Using CTL3D for this control
|
||||||
@@ -244,10 +290,7 @@ protected:
|
|||||||
int m_xThumbSize;
|
int m_xThumbSize;
|
||||||
int m_yThumbSize;
|
int m_yThumbSize;
|
||||||
|
|
||||||
WXHMENU m_hMenu; // Menu, if any
|
// WXHMENU m_hMenu; // Menu, if any
|
||||||
|
|
||||||
// the return value of WM_GETDLGCODE handler
|
|
||||||
long m_lDlgCode;
|
|
||||||
|
|
||||||
// implement the base class pure virtuals
|
// implement the base class pure virtuals
|
||||||
virtual void DoClientToScreen( int *x, int *y ) const;
|
virtual void DoClientToScreen( int *x, int *y ) const;
|
||||||
|
@@ -102,7 +102,7 @@ typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
|
|||||||
#elif defined(__WXQT__)
|
#elif defined(__WXQT__)
|
||||||
#include "wx/qt/notebook.h"
|
#include "wx/qt/notebook.h"
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
#include "wx/mac/notebook.h"
|
#include "wx/generic/notebook.h"
|
||||||
#elif defined(__WXPM__)
|
#elif defined(__WXPM__)
|
||||||
#include "wx/os2/notebook.h"
|
#include "wx/os2/notebook.h"
|
||||||
#elif defined(__WXSTUBS__)
|
#elif defined(__WXSTUBS__)
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: os2/dataform.h
|
// Name: mac/dataform.h
|
||||||
// Purpose: declaration of the wxDataFormat class
|
// Purpose: declaration of the wxDataFormat class
|
||||||
// Author: David Webster (lifted from dnd.h)
|
// Author: Stefan Csomor
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 10/21/99
|
// Created: 10/21/99
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 1999 David Webster
|
// Copyright: (c) 1999 Stefan Csomor
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: os2/dataobj.h
|
// Name: mac/dataobj.h
|
||||||
// Purpose: declaration of the wxDataObject
|
// Purpose: declaration of the wxDataObject
|
||||||
// Author: David Webster (adapted from Robert Roebling's gtk port)
|
// Author: Stefan Csomor
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 10/21/99
|
// Created: 10/21/99
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_GTK_DATAOBJ_H_
|
#ifndef _WX_MAC_DATAOBJ_H_
|
||||||
#define _WX_GTK_DATAOBJ_H_
|
#define _WX_MAC_DATAOBJ_H_
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "dataobj.h"
|
#pragma interface "dataobj.h"
|
||||||
@@ -28,5 +28,5 @@ public:
|
|||||||
virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
|
virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_GTK_DATAOBJ_H_
|
#endif // _WX_MAC_DATAOBJ_H_
|
||||||
|
|
||||||
|
@@ -11,6 +11,17 @@
|
|||||||
#define wxPrintPreview wxWindowsPrintPreview
|
#define wxPrintPreview wxWindowsPrintPreview
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
|
||||||
|
#include "wx/mac/printmac.h"
|
||||||
|
|
||||||
|
#ifndef wxPrinter
|
||||||
|
#define wxPrinter wxMacPrinter
|
||||||
|
#endif
|
||||||
|
#ifndef wxPrintPreview
|
||||||
|
#define wxPrintPreview wxMacPrintPreview
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include "wx/generic/printps.h"
|
#include "wx/generic/printps.h"
|
||||||
|
|
||||||
|
@@ -137,6 +137,9 @@ private:
|
|||||||
#if defined(__WXMSW__) || defined(__WXPM__)
|
#if defined(__WXMSW__) || defined(__WXPM__)
|
||||||
class WXDLLEXPORT wxCriticalSectionInternal;
|
class WXDLLEXPORT wxCriticalSectionInternal;
|
||||||
#define WXCRITICAL_INLINE
|
#define WXCRITICAL_INLINE
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
class WXDLLEXPORT wxCriticalSectionInternal;
|
||||||
|
#define WXCRITICAL_INLINE
|
||||||
#else // !MSW && !PM
|
#else // !MSW && !PM
|
||||||
#define WXCRITICAL_INLINE inline
|
#define WXCRITICAL_INLINE inline
|
||||||
#endif // MSW/!MSW
|
#endif // MSW/!MSW
|
||||||
@@ -160,7 +163,7 @@ private:
|
|||||||
wxCriticalSection(const wxCriticalSection&);
|
wxCriticalSection(const wxCriticalSection&);
|
||||||
wxCriticalSection& operator=(const wxCriticalSection&);
|
wxCriticalSection& operator=(const wxCriticalSection&);
|
||||||
|
|
||||||
#if defined(__WXMSW__) || defined(__WXPM__)
|
#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__)
|
||||||
wxCriticalSectionInternal *m_critsect;
|
wxCriticalSectionInternal *m_critsect;
|
||||||
#else // !MSW
|
#else // !MSW
|
||||||
wxMutex m_mutex;
|
wxMutex m_mutex;
|
||||||
@@ -396,6 +399,18 @@ public:
|
|||||||
// wakes up the main thread if it's sleeping inside ::GetMessage()
|
// wakes up the main thread if it's sleeping inside ::GetMessage()
|
||||||
extern void WXDLLEXPORT wxWakeUpMainThread();
|
extern void WXDLLEXPORT wxWakeUpMainThread();
|
||||||
|
|
||||||
|
// return TRUE if the main thread is waiting for some other to terminate:
|
||||||
|
// wxApp then should block all "dangerous" messages
|
||||||
|
extern bool WXDLLEXPORT wxIsWaitingForThread();
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
extern void WXDLLEXPORT wxMutexGuiLeaveOrEnter();
|
||||||
|
|
||||||
|
// returns TRUE if the main thread has GUI lock
|
||||||
|
extern bool WXDLLEXPORT wxGuiOwnedByMainThread();
|
||||||
|
|
||||||
|
// wakes up the main thread if it's sleeping inside ::GetMessage()
|
||||||
|
extern void WXDLLEXPORT wxWakeUpMainThread();
|
||||||
|
|
||||||
// return TRUE if the main thread is waiting for some other to terminate:
|
// return TRUE if the main thread is waiting for some other to terminate:
|
||||||
// wxApp then should block all "dangerous" messages
|
// wxApp then should block all "dangerous" messages
|
||||||
extern bool WXDLLEXPORT wxIsWaitingForThread();
|
extern bool WXDLLEXPORT wxIsWaitingForThread();
|
||||||
|
@@ -96,6 +96,19 @@ DbList WXDLLEXPORT *PtrBegDbList = 0;
|
|||||||
extern wxList TablesInUse;
|
extern wxList TablesInUse;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __MWERKS__
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
#define stricmp _stricmp
|
||||||
|
#define strnicmp _strnicmp
|
||||||
|
#else //__WXMSW_
|
||||||
|
int strcasecmp(const char *str_1, const char *str_2) ;
|
||||||
|
int strncasecmp(const char *str_1, const char *str_2, size_t maxchar) ;
|
||||||
|
#define stricmp strcasecmp
|
||||||
|
#define strnicmp strncasecmp
|
||||||
|
#endif
|
||||||
|
#endif //__MWERKS__
|
||||||
|
|
||||||
// SQL Log defaults to be used by GetDbConnection
|
// SQL Log defaults to be used by GetDbConnection
|
||||||
enum sqlLog SQLLOGstate = sqlLogOFF;
|
enum sqlLog SQLLOGstate = sqlLogOFF;
|
||||||
|
|
||||||
|
@@ -81,6 +81,18 @@
|
|||||||
#include "wx/dbtable.h"
|
#include "wx/dbtable.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __MWERKS__
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
#define stricmp _stricmp
|
||||||
|
#define strnicmp _strnicmp
|
||||||
|
#else
|
||||||
|
int strcasecmp(const char *str_1, const char *str_2) ;
|
||||||
|
int strncasecmp(const char *str_1, const char *str_2, size_t maxchar) ;
|
||||||
|
#define stricmp strcasecmp
|
||||||
|
#define strnicmp strncasecmp
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __UNIX__
|
#ifdef __UNIX__
|
||||||
// The HPUX preprocessor lines below were commented out on 8/20/97
|
// The HPUX preprocessor lines below were commented out on 8/20/97
|
||||||
// because macros.h currently redefines DEBUG and is unneeded.
|
// because macros.h currently redefines DEBUG and is unneeded.
|
||||||
|
@@ -112,10 +112,14 @@
|
|||||||
|
|
||||||
#define _MAXPATHLEN 500
|
#define _MAXPATHLEN 500
|
||||||
|
|
||||||
|
extern char *wxBuffer;
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
extern wxChar gwxMacFileName[] ;
|
|
||||||
extern wxChar gwxMacFileName2[] ;
|
#include "morefile.h"
|
||||||
extern wxChar gwxMacFileName3[] ;
|
#include "moreextr.h"
|
||||||
|
#include "fullpath.h"
|
||||||
|
#include "fspcompa.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARIES
|
#if !USE_SHARED_LIBRARIES
|
||||||
@@ -262,10 +266,8 @@ wxFileExists (const wxString& filename)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
wxStrcpy( gwxMacFileName , filename ) ;
|
if (filename && stat (wxUnix2MacFilename(filename), &stbuf) == 0 )
|
||||||
wxUnix2MacFilename( gwxMacFileName ) ;
|
return TRUE;
|
||||||
if (gwxMacFileName && stat (WXSTRINGCAST gwxMacFileName, &stbuf) == 0)
|
|
||||||
return TRUE;
|
|
||||||
return FALSE ;
|
return FALSE ;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -824,78 +826,129 @@ wxString wxPathOnly (const wxString& path)
|
|||||||
// Also, convert to lower case, since case is significant in UNIX.
|
// Also, convert to lower case, since case is significant in UNIX.
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
void
|
|
||||||
wxMac2UnixFilename (wxChar *s)
|
|
||||||
{
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
memmove( s+1 , s ,(strlen( s ) + 1)*sizeof(wxChar)) ;
|
|
||||||
if ( *s == wxT(':') )
|
|
||||||
*s = wxT('.') ;
|
|
||||||
else
|
|
||||||
*s = wxT('/') ;
|
|
||||||
|
|
||||||
while (*s)
|
static char sMacFileNameConversion[ 1000 ] ;
|
||||||
{
|
|
||||||
if (*s == wxT(':'))
|
wxString wxMac2UnixFilename (const char *str)
|
||||||
*s = wxT('/');
|
{
|
||||||
else
|
char *s = sMacFileNameConversion ;
|
||||||
*s = wxTolower(*s); // Case INDEPENDENT
|
strcpy( s , str ) ;
|
||||||
s++;
|
if (s)
|
||||||
}
|
{
|
||||||
}
|
memmove( s+1 , s ,strlen( s ) + 1) ;
|
||||||
|
if ( *s == ':' )
|
||||||
|
*s = '.' ;
|
||||||
|
else
|
||||||
|
*s = '/' ;
|
||||||
|
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
if (*s == ':')
|
||||||
|
*s = '/';
|
||||||
|
else
|
||||||
|
*s = wxTolower (*s); // Case INDEPENDENT
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return wxString (sMacFileNameConversion) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
wxString wxUnix2MacFilename (const char *str)
|
||||||
wxUnix2MacFilename (wxChar *s)
|
|
||||||
{
|
{
|
||||||
if (s)
|
char *s = sMacFileNameConversion ;
|
||||||
{
|
strcpy( s , str ) ;
|
||||||
if ( *s == wxT('.') )
|
if (s)
|
||||||
{
|
{
|
||||||
// relative path , since it goes on with slash which is translated to a :
|
if ( *s == '.' )
|
||||||
memmove( s , s+1 ,strlen( s )*sizeof(wxChar) ) ;
|
{
|
||||||
}
|
// relative path , since it goes on with slash which is translated to a :
|
||||||
else if ( *s == wxT('/') )
|
memmove( s , s+1 ,strlen( s ) ) ;
|
||||||
{
|
}
|
||||||
// absolute path -> on mac just start with the drive name
|
else if ( *s == '/' )
|
||||||
memmove( s , s+1 ,strlen( s )*sizeof(wxChar) ) ;
|
{
|
||||||
}
|
// absolute path -> on mac just start with the drive name
|
||||||
else
|
memmove( s , s+1 ,strlen( s ) ) ;
|
||||||
{
|
}
|
||||||
wxASSERT_MSG( 1 , wxT("unknown path beginning") ) ;
|
else
|
||||||
}
|
{
|
||||||
while (*s)
|
wxASSERT_MSG( 1 , "unkown path beginning" ) ;
|
||||||
{
|
}
|
||||||
if (*s == wxT('/') || *s == wxT('\\'))
|
while (*s)
|
||||||
*s = wxT(':');
|
{
|
||||||
|
if (*s == '/' || *s == '\\')
|
||||||
|
{
|
||||||
|
// convert any back-directory situations
|
||||||
|
if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) )
|
||||||
|
{
|
||||||
|
*s = ':';
|
||||||
|
memmove( s+1 , s+3 ,strlen( s+3 ) + 1 ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*s = ':';
|
||||||
|
}
|
||||||
|
|
||||||
s++ ;
|
s++ ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return wxString (sMacFileNameConversion) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
|
||||||
|
{
|
||||||
|
Handle myPath ;
|
||||||
|
short length ;
|
||||||
|
|
||||||
|
FSpGetFullPath( spec , &length , &myPath ) ;
|
||||||
|
::SetHandleSize( myPath , length + 1 ) ;
|
||||||
|
::HLock( myPath ) ;
|
||||||
|
(*myPath)[length] = 0 ;
|
||||||
|
if ( length > 0 && (*myPath)[length-1] ==':' )
|
||||||
|
(*myPath)[length-1] = 0 ;
|
||||||
|
|
||||||
|
wxString result( (char*) *myPath ) ;
|
||||||
|
::HUnlock( myPath ) ;
|
||||||
|
::DisposeHandle( myPath ) ;
|
||||||
|
return result ;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxMacFSSpec2UnixFilename( const FSSpec *spec )
|
||||||
|
{
|
||||||
|
return wxMac2UnixFilename( wxMacFSSpec2MacFilename( spec) ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
|
||||||
|
{
|
||||||
|
FSpLocationFromFullPath( strlen(path ) , path , spec ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxUnixFilename2FSSpec( const char *path , FSSpec *spec )
|
||||||
|
{
|
||||||
|
wxString var = wxUnix2MacFilename( path ) ;
|
||||||
|
wxMacFilename2FSSpec( var , spec ) ;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
void
|
void
|
||||||
wxDos2UnixFilename (wxChar *s)
|
wxDos2UnixFilename (char *s)
|
||||||
{
|
{
|
||||||
if (s)
|
if (s)
|
||||||
while (*s)
|
while (*s)
|
||||||
{
|
{
|
||||||
if (*s == wxT('\\'))
|
if (*s == '\\')
|
||||||
*s = wxT('/');
|
*s = '/';
|
||||||
#if defined(__WXMSW__) || defined(__WXPM__)
|
#ifdef __WXMSW__
|
||||||
else
|
else
|
||||||
*s = wxTolower(*s); // Case INDEPENDENT
|
*s = wxTolower (*s); // Case INDEPENDENT
|
||||||
#endif
|
#endif
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
#if defined(__WXMSW__) || defined(__WXPM__)
|
#ifdef __WXMSW__
|
||||||
wxUnix2DosFilename (wxChar *s)
|
wxUnix2DosFilename (char *s)
|
||||||
#else
|
#else
|
||||||
wxUnix2DosFilename (wxChar *WXUNUSED(s))
|
wxUnix2DosFilename (char *WXUNUSED(s) )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Yes, I really mean this to happen under DOS only! JACS
|
// Yes, I really mean this to happen under DOS only! JACS
|
||||||
@@ -921,20 +974,13 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil
|
|||||||
FILE *fp3 = (FILE *) NULL;
|
FILE *fp3 = (FILE *) NULL;
|
||||||
// Open the inputs and outputs
|
// Open the inputs and outputs
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
wxStrcpy( gwxMacFileName , file1 ) ;
|
if ((fp1 = fopen (wxUnix2MacFilename( file1 ), "rb")) == NULL ||
|
||||||
wxUnix2MacFilename( gwxMacFileName ) ;
|
(fp2 = fopen (wxUnix2MacFilename( file2 ), "rb")) == NULL ||
|
||||||
wxStrcpy( gwxMacFileName2 , file2) ;
|
(fp3 = fopen (wxUnix2MacFilename( outfile ), "wb")) == NULL)
|
||||||
wxUnix2MacFilename( gwxMacFileName2 ) ;
|
|
||||||
wxStrcpy( gwxMacFileName3 , outfile) ;
|
|
||||||
wxUnix2MacFilename( gwxMacFileName3 ) ;
|
|
||||||
|
|
||||||
if ((fp1 = fopen (gwxMacFileName, "rb")) == NULL ||
|
|
||||||
(fp2 = fopen (gwxMacFileName2, "rb")) == NULL ||
|
|
||||||
(fp3 = fopen (gwxMacFileName3, "wb")) == NULL)
|
|
||||||
#else
|
#else
|
||||||
if ((fp1 = fopen (wxFNSTRINGCAST file1.fn_str(), "rb")) == NULL ||
|
if ((fp1 = fopen (WXSTRINGCAST file1, "rb")) == NULL ||
|
||||||
(fp2 = fopen (wxFNSTRINGCAST file2.fn_str(), "rb")) == NULL ||
|
(fp2 = fopen (WXSTRINGCAST file2, "rb")) == NULL ||
|
||||||
(fp3 = fopen (wxFNCONV(outfile), "wb")) == NULL)
|
(fp3 = fopen (outfile, "wb")) == NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (fp1)
|
if (fp1)
|
||||||
@@ -970,18 +1016,13 @@ wxCopyFile (const wxString& file1, const wxString& file2)
|
|||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
wxStrcpy( gwxMacFileName , file1 ) ;
|
if ((fd1 = fopen (wxUnix2MacFilename( file1 ), "rb")) == NULL)
|
||||||
wxUnix2MacFilename( gwxMacFileName ) ;
|
|
||||||
wxStrcpy( gwxMacFileName2 , file2) ;
|
|
||||||
wxUnix2MacFilename( gwxMacFileName2 ) ;
|
|
||||||
|
|
||||||
if ((fd1 = fopen (gwxMacFileName, "rb")) == NULL)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if ((fd2 = fopen (gwxMacFileName2, "wb")) == NULL)
|
if ((fd2 = fopen (wxUnix2MacFilename( file2 ), "wb")) == NULL)
|
||||||
#else
|
#else
|
||||||
if ((fd1 = fopen (wxFNSTRINGCAST file1.fn_str(), "rb")) == NULL)
|
if ((fd1 = fopen (WXSTRINGCAST file1, "rb")) == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if ((fd2 = fopen (wxFNSTRINGCAST file2.fn_str(), "wb")) == NULL)
|
if ((fd2 = fopen (WXSTRINGCAST file2, "wb")) == NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fclose (fd1);
|
fclose (fd1);
|
||||||
@@ -1000,12 +1041,7 @@ bool
|
|||||||
wxRenameFile (const wxString& file1, const wxString& file2)
|
wxRenameFile (const wxString& file1, const wxString& file2)
|
||||||
{
|
{
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
wxStrcpy( gwxMacFileName , file1 ) ;
|
if (0 == rename (wxUnix2MacFilename( file1 ), wxUnix2MacFilename( file2 )))
|
||||||
wxUnix2MacFilename( gwxMacFileName ) ;
|
|
||||||
wxStrcpy( gwxMacFileName2 , file2) ;
|
|
||||||
wxUnix2MacFilename( gwxMacFileName2 ) ;
|
|
||||||
|
|
||||||
if (0 == rename (gwxMacFileName, gwxMacFileName2))
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else
|
#else
|
||||||
// Normal system call
|
// Normal system call
|
||||||
@@ -1026,9 +1062,7 @@ bool wxRemoveFile(const wxString& file)
|
|||||||
#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
|
#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
|
||||||
int flag = remove(wxFNSTRINGCAST file.fn_str());
|
int flag = remove(wxFNSTRINGCAST file.fn_str());
|
||||||
#elif defined( __WXMAC__ )
|
#elif defined( __WXMAC__ )
|
||||||
wxStrcpy( gwxMacFileName , file ) ;
|
int flag = unlink(wxUnix2MacFilename( file ));
|
||||||
wxUnix2MacFilename( gwxMacFileName ) ;
|
|
||||||
int flag = unlink(gwxMacFileName);
|
|
||||||
#else
|
#else
|
||||||
int flag = unlink(wxFNSTRINGCAST file.fn_str());
|
int flag = unlink(wxFNSTRINGCAST file.fn_str());
|
||||||
#endif
|
#endif
|
||||||
@@ -1038,12 +1072,9 @@ bool wxRemoveFile(const wxString& file)
|
|||||||
bool wxMkdir(const wxString& dir, int perm)
|
bool wxMkdir(const wxString& dir, int perm)
|
||||||
{
|
{
|
||||||
#if defined( __WXMAC__ )
|
#if defined( __WXMAC__ )
|
||||||
wxStrcpy( gwxMacFileName , dir ) ;
|
return (mkdir(wxUnix2MacFilename( dir ) , 0 ) == 0);
|
||||||
wxUnix2MacFilename( gwxMacFileName ) ;
|
|
||||||
const wxChar *dirname = gwxMacFileName;
|
|
||||||
#else // !Mac
|
#else // !Mac
|
||||||
const wxChar *dirname = dir.c_str();
|
const wxChar *dirname = dir.c_str();
|
||||||
#endif // Mac/!Mac
|
|
||||||
|
|
||||||
// assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
|
// assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
|
||||||
// for the GNU compiler
|
// for the GNU compiler
|
||||||
@@ -1059,6 +1090,7 @@ bool wxMkdir(const wxString& dir, int perm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#endif // Mac/!Mac
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
|
bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
|
||||||
@@ -1066,9 +1098,7 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
|
|||||||
#ifdef __VMS__
|
#ifdef __VMS__
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#elif defined( __WXMAC__ )
|
#elif defined( __WXMAC__ )
|
||||||
wxStrcpy( gwxMacFileName , dir ) ;
|
return (rmdir(wxUnix2MacFilename( dir )) == 0);
|
||||||
wxUnix2MacFilename( gwxMacFileName ) ;
|
|
||||||
return (rmdir(WXSTRINGCAST gwxMacFileName) == 0);
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef __SALFORDC__
|
#ifdef __SALFORDC__
|
||||||
@@ -1481,6 +1511,17 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
|
|||||||
char *cbuf = new char[sz+1];
|
char *cbuf = new char[sz+1];
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
if (_getcwd(cbuf, sz) == NULL) {
|
if (_getcwd(cbuf, sz) == NULL) {
|
||||||
|
#elif defined( __WXMAC__)
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SFSaveDisk = 0x214, CurDirStore = 0x398
|
||||||
|
};
|
||||||
|
FSSpec cwdSpec ;
|
||||||
|
|
||||||
|
FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
|
||||||
|
wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
|
||||||
|
strcpy( buf , res ) ;
|
||||||
|
if (0)
|
||||||
#else
|
#else
|
||||||
if (getcwd(cbuf, sz) == NULL) {
|
if (getcwd(cbuf, sz) == NULL) {
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1338,8 +1338,8 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
||||||
if ( frontwindow && wxMenuBar::s_macInstalledMenuBar )
|
if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
|
||||||
wxMenuBar::s_macInstalledMenuBar->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
|
wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
|
||||||
}
|
}
|
||||||
HiliteMenu(0);
|
HiliteMenu(0);
|
||||||
}
|
}
|
||||||
|
@@ -47,14 +47,23 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
|||||||
|
|
||||||
void wxButton::SetDefault()
|
void wxButton::SetDefault()
|
||||||
{
|
{
|
||||||
wxWindow *parent = (wxWindow *)GetParent();
|
wxWindow *parent = GetParent();
|
||||||
if (parent)
|
wxButton *btnOldDefault = NULL;
|
||||||
parent->SetDefaultItem(this);
|
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
||||||
|
if ( panel )
|
||||||
|
{
|
||||||
|
btnOldDefault = panel->GetDefaultItem();
|
||||||
|
panel->SetDefaultItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( btnOldDefault && btnOldDefault->m_macControl )
|
||||||
|
{
|
||||||
|
UMASetControlData( btnOldDefault->m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)0) ) ;
|
||||||
|
}
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ;
|
UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxButton::Command (wxCommandEvent & event)
|
void wxButton::Command (wxCommandEvent & event)
|
||||||
|
@@ -1338,8 +1338,8 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
|
||||||
if ( frontwindow && wxMenuBar::s_macInstalledMenuBar )
|
if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
|
||||||
wxMenuBar::s_macInstalledMenuBar->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
|
wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
|
||||||
}
|
}
|
||||||
HiliteMenu(0);
|
HiliteMenu(0);
|
||||||
}
|
}
|
||||||
|
@@ -47,14 +47,23 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
|||||||
|
|
||||||
void wxButton::SetDefault()
|
void wxButton::SetDefault()
|
||||||
{
|
{
|
||||||
wxWindow *parent = (wxWindow *)GetParent();
|
wxWindow *parent = GetParent();
|
||||||
if (parent)
|
wxButton *btnOldDefault = NULL;
|
||||||
parent->SetDefaultItem(this);
|
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
||||||
|
if ( panel )
|
||||||
|
{
|
||||||
|
btnOldDefault = panel->GetDefaultItem();
|
||||||
|
panel->SetDefaultItem(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( btnOldDefault && btnOldDefault->m_macControl )
|
||||||
|
{
|
||||||
|
UMASetControlData( btnOldDefault->m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)0) ) ;
|
||||||
|
}
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ;
|
UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxButton::Command (wxCommandEvent & event)
|
void wxButton::Command (wxCommandEvent & event)
|
||||||
|
@@ -23,11 +23,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool wxOpenClipboard()
|
bool wxOpenClipboard()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -90,26 +85,36 @@ bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
|
|||||||
* Generalized clipboard implementation by Matthew Flatt
|
* Generalized clipboard implementation by Matthew Flatt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wxClipboard *wxTheClipboard = NULL;
|
|
||||||
|
|
||||||
void wxInitClipboard()
|
|
||||||
{
|
|
||||||
if (!wxTheClipboard)
|
|
||||||
wxTheClipboard = new wxClipboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxClipboard::wxClipboard()
|
wxClipboard::wxClipboard()
|
||||||
{
|
{
|
||||||
clipOwner = NULL;
|
m_clearOnExit = FALSE;
|
||||||
cbString = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxClipboard::~wxClipboard()
|
wxClipboard::~wxClipboard()
|
||||||
{
|
{
|
||||||
if (clipOwner)
|
if ( m_clearOnExit )
|
||||||
clipOwner->BeingReplaced();
|
{
|
||||||
if (cbString)
|
Clear();
|
||||||
delete[] cbString;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxClipboard::Clear()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::Flush()
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::Open()
|
||||||
|
{
|
||||||
|
return wxOpenClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::IsOpened() const
|
||||||
|
{
|
||||||
|
return wxIsClipboardOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int FormatStringToID(char *str)
|
static int FormatStringToID(char *str)
|
||||||
@@ -120,6 +125,129 @@ static int FormatStringToID(char *str)
|
|||||||
return wxRegisterClipboardFormat(str);
|
return wxRegisterClipboardFormat(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::SetData( wxDataObject *data )
|
||||||
|
{
|
||||||
|
(void)wxEmptyClipboard();
|
||||||
|
|
||||||
|
if ( data )
|
||||||
|
return AddData(data);
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::AddData( wxDataObject *data )
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( data, FALSE, wxT("data is invalid") );
|
||||||
|
|
||||||
|
#if wxUSE_DATAOBJ
|
||||||
|
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
|
||||||
|
|
||||||
|
wxDataFormat format = data->GetFormat();
|
||||||
|
|
||||||
|
switch ( format )
|
||||||
|
{
|
||||||
|
case wxDF_TEXT:
|
||||||
|
case wxDF_OEMTEXT:
|
||||||
|
{
|
||||||
|
wxTextDataObject* textDataObject = (wxTextDataObject*) data;
|
||||||
|
wxString str(textDataObject->GetText());
|
||||||
|
return wxSetClipboardData(format, str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
case wxDF_BITMAP:
|
||||||
|
case wxDF_DIB:
|
||||||
|
{
|
||||||
|
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
|
||||||
|
wxBitmap bitmap(bitmapDataObject->GetBitmap());
|
||||||
|
return wxSetClipboardData(data->GetFormat(), &bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if wxUSE_METAFILE
|
||||||
|
case wxDF_METAFILE:
|
||||||
|
{
|
||||||
|
wxMetafileDataObject* metaFileDataObject =
|
||||||
|
(wxMetafileDataObject*) data;
|
||||||
|
wxMetafile metaFile = metaFileDataObject->GetMetafile();
|
||||||
|
return wxSetClipboardData(wxDF_METAFILE, &metaFile,
|
||||||
|
metaFileDataObject->GetWidth(),
|
||||||
|
metaFileDataObject->GetHeight());
|
||||||
|
}
|
||||||
|
#endif // wxUSE_METAFILE
|
||||||
|
|
||||||
|
default:
|
||||||
|
return wxSetClipboardData(data);
|
||||||
|
}
|
||||||
|
#else // !wxUSE_DATAOBJ
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxClipboard::Close()
|
||||||
|
{
|
||||||
|
wxCloseClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::IsSupported( wxDataFormat format )
|
||||||
|
{
|
||||||
|
return wxIsClipboardFormatAvailable(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::GetData( wxDataObject& data )
|
||||||
|
{
|
||||||
|
#if wxUSE_DATAOBJ
|
||||||
|
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
|
||||||
|
|
||||||
|
wxDataFormat format = data.GetFormat();
|
||||||
|
switch ( format )
|
||||||
|
{
|
||||||
|
case wxDF_TEXT:
|
||||||
|
case wxDF_OEMTEXT:
|
||||||
|
{
|
||||||
|
wxTextDataObject& textDataObject = (wxTextDataObject &)data;
|
||||||
|
char* s = (char*)wxGetClipboardData(format);
|
||||||
|
if ( !s )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
textDataObject.SetText(s);
|
||||||
|
delete [] s;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wxDF_BITMAP:
|
||||||
|
case wxDF_DIB:
|
||||||
|
{
|
||||||
|
wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
|
||||||
|
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetFormat());
|
||||||
|
if ( !bitmap )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
bitmapDataObject.SetBitmap(*bitmap);
|
||||||
|
delete bitmap;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#if wxUSE_METAFILE
|
||||||
|
case wxDF_METAFILE:
|
||||||
|
{
|
||||||
|
wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;
|
||||||
|
wxMetafile* metaFile = (wxMetafile *)wxGetClipboardData(wxDF_METAFILE);
|
||||||
|
if ( !metaFile )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
metaFileDataObject.SetMetafile(*metaFile);
|
||||||
|
delete metaFile;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif // wxUSE_METAFILE
|
||||||
|
}
|
||||||
|
#else // !wxUSE_DATAOBJ
|
||||||
|
wxFAIL_MSG( wxT("no clipboard implementation") );
|
||||||
|
#endif
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
/*
|
||||||
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
|
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
|
||||||
{
|
{
|
||||||
bool got_selection;
|
bool got_selection;
|
||||||
@@ -167,7 +295,7 @@ wxClipboardClient *wxClipboard::GetClipboardClient()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxClipboard::SetClipboardString(char *str, long time)
|
void wxClipboard::SetClipboardString(char *str, long time)
|
||||||
{/*
|
{
|
||||||
bool got_selection;
|
bool got_selection;
|
||||||
|
|
||||||
if (clipOwner) {
|
if (clipOwner) {
|
||||||
@@ -193,9 +321,7 @@ void wxClipboard::SetClipboardString(char *str, long time)
|
|||||||
delete[] cbString;
|
delete[] cbString;
|
||||||
cbString = NULL;
|
cbString = NULL;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *wxClipboard::GetClipboardString(long time)
|
char *wxClipboard::GetClipboardString(long time)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
@@ -210,6 +336,7 @@ char *wxClipboard::GetClipboardString(long time)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
|
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
|
||||||
{
|
{
|
||||||
if (clipOwner) {
|
if (clipOwner) {
|
||||||
@@ -233,4 +360,5 @@ char *wxClipboard::GetClipboardData(char *format, long *length, long time)
|
|||||||
return receivedString;
|
return receivedString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@@ -53,7 +53,9 @@ wxControl::wxControl()
|
|||||||
m_macVerticalBorder = 0 ;
|
m_macVerticalBorder = 0 ;
|
||||||
m_backgroundColour = *wxWHITE;
|
m_backgroundColour = *wxWHITE;
|
||||||
m_foregroundColour = *wxBLACK;
|
m_foregroundColour = *wxBLACK;
|
||||||
m_callback = 0;
|
#if WXWIN_COMPATIBILITY
|
||||||
|
m_callback = 0;
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
if ( wxMacLiveScrollbarActionUPP == NULL )
|
if ( wxMacLiveScrollbarActionUPP == NULL )
|
||||||
{
|
{
|
||||||
@@ -63,13 +65,14 @@ wxControl::wxControl()
|
|||||||
|
|
||||||
wxControl::~wxControl()
|
wxControl::~wxControl()
|
||||||
{
|
{
|
||||||
|
m_isBeingDeleted = TRUE;
|
||||||
// If we delete an item, we should initialize the parent panel,
|
// If we delete an item, we should initialize the parent panel,
|
||||||
// because it could now be invalid.
|
// because it could now be invalid.
|
||||||
wxWindow *parent = (wxWindow *)GetParent();
|
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
||||||
if (parent)
|
if ( panel )
|
||||||
{
|
{
|
||||||
if (parent->GetDefaultItem() == (wxButton*) this)
|
if (panel->GetDefaultItem() == (wxButton*) this)
|
||||||
parent->SetDefaultItem(NULL);
|
panel->SetDefaultItem(NULL);
|
||||||
}
|
}
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
@@ -78,13 +81,19 @@ wxControl::~wxControl()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::SetLabel(const wxString& label)
|
void wxControl::SetLabel(const wxString& title)
|
||||||
{
|
{
|
||||||
m_label = label ;
|
m_label = title ;
|
||||||
|
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
Str255 maclabel ;
|
Str255 maclabel ;
|
||||||
|
wxString label ;
|
||||||
|
|
||||||
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
|
label = wxMacMakeMacStringFromPC( title ) ;
|
||||||
|
else
|
||||||
|
label = title ;
|
||||||
|
|
||||||
strcpy( (char*) maclabel , label ) ;
|
strcpy( (char*) maclabel , label ) ;
|
||||||
c2pstr( (char*) maclabel ) ;
|
c2pstr( (char*) maclabel ) ;
|
||||||
@@ -93,56 +102,31 @@ void wxControl::SetLabel(const wxString& label)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxControl::GetLabel() const
|
wxSize wxControl::DoGetBestSize()
|
||||||
{
|
{
|
||||||
return m_label ;
|
return wxSize(20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::ProcessCommand (wxCommandEvent & event)
|
bool wxControl::ProcessCommand (wxCommandEvent & event)
|
||||||
{
|
{
|
||||||
// Tries:
|
// Tries:
|
||||||
// 1) A callback function (to become obsolete)
|
// 1) A callback function (to become obsolete)
|
||||||
// 2) OnCommand, starting at this window and working up parent hierarchy
|
// 2) OnCommand, starting at this window and working up parent hierarchy
|
||||||
// 3) OnCommand then calls ProcessEvent to search the event tables.
|
// 3) OnCommand then calls ProcessEvent to search the event tables.
|
||||||
if (m_callback)
|
#if WXWIN_COMPATIBILITY
|
||||||
|
if ( m_callback )
|
||||||
{
|
{
|
||||||
(void) (*(m_callback)) (*this, event);
|
(void)(*m_callback)(this, event);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
{
|
{
|
||||||
GetEventHandler()->OnCommand(*this, event);
|
return GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::Centre (int direction)
|
|
||||||
{
|
|
||||||
int x, y, width, height, panel_width, panel_height, new_x, new_y;
|
|
||||||
|
|
||||||
wxWindow *parent = (wxWindow *) GetParent ();
|
|
||||||
if (!parent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
parent->GetClientSize (&panel_width, &panel_height);
|
|
||||||
GetSize (&width, &height);
|
|
||||||
GetPosition (&x, &y);
|
|
||||||
|
|
||||||
new_x = x;
|
|
||||||
new_y = y;
|
|
||||||
|
|
||||||
if (direction & wxHORIZONTAL)
|
|
||||||
new_x = (int) ((panel_width - width) / 2);
|
|
||||||
|
|
||||||
if (direction & wxVERTICAL)
|
|
||||||
new_y = (int) ((panel_height - height) / 2);
|
|
||||||
|
|
||||||
SetSize (new_x, new_y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxControl::SetClientSize (int width, int height)
|
|
||||||
{
|
|
||||||
SetSize (-1, -1, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
wxList *wxWinMacControlList = NULL;
|
wxList *wxWinMacControlList = NULL;
|
||||||
wxControl *wxFindControlFromMacControl(ControlHandle inControl )
|
wxControl *wxFindControlFromMacControl(ControlHandle inControl )
|
||||||
@@ -352,6 +336,7 @@ void wxControl::MacSuperChangedPosition()
|
|||||||
|
|
||||||
void wxControl::MacSuperEnabled( bool enabled )
|
void wxControl::MacSuperEnabled( bool enabled )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
if ( UMAHasAppearance() )
|
if ( UMAHasAppearance() )
|
||||||
@@ -380,10 +365,12 @@ void wxControl::MacSuperEnabled( bool enabled )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wxWindow::MacSuperEnabled( enabled ) ;
|
wxWindow::MacSuperEnabled( enabled ) ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacSuperShown( bool show )
|
void wxControl::MacSuperShown( bool show )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
if ( !show )
|
if ( !show )
|
||||||
@@ -398,6 +385,7 @@ void wxControl::MacSuperShown( bool show )
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxWindow::MacSuperShown( show ) ;
|
wxWindow::MacSuperShown( show ) ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::DoSetSize(int x, int y,
|
void wxControl::DoSetSize(int x, int y,
|
||||||
@@ -503,51 +491,45 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::DoSetClientSize(int width, int height)
|
|
||||||
{
|
|
||||||
DoSetSize( -1 , -1 , width , height ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxControl::Show(bool show)
|
bool wxControl::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( m_macControl == NULL )
|
if ( !wxWindow::Show( show ) )
|
||||||
return wxWindow::Show( show ) ;
|
return FALSE ;
|
||||||
|
|
||||||
if ( m_macShown == show )
|
if ( m_macControl )
|
||||||
return TRUE ;
|
{
|
||||||
|
if ( show )
|
||||||
if ( show )
|
::UMAShowControl( m_macControl ) ;
|
||||||
::UMAShowControl( m_macControl ) ;
|
else
|
||||||
else
|
::UMAHideControl( m_macControl ) ;
|
||||||
::UMAHideControl( m_macControl ) ;
|
}
|
||||||
|
return TRUE ;
|
||||||
return wxWindow::Show( show ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::Enable(bool enable)
|
bool wxControl::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if ( m_macControl == NULL )
|
if ( !wxWindow::Enable(enable) )
|
||||||
return wxWindow::Enable( enable ) ;
|
return FALSE;
|
||||||
|
|
||||||
if ( m_macEnabled == enable )
|
|
||||||
return ;
|
|
||||||
|
|
||||||
if ( UMAHasAppearance() )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
if ( enable )
|
|
||||||
::ActivateControl( m_macControl ) ;
|
if ( UMAHasAppearance() )
|
||||||
|
{
|
||||||
|
if ( enable )
|
||||||
|
::ActivateControl( m_macControl ) ;
|
||||||
|
else
|
||||||
|
::DeactivateControl( m_macControl ) ;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
::DeactivateControl( m_macControl ) ;
|
{
|
||||||
|
if ( enable )
|
||||||
|
::HiliteControl( m_macControl , 0 ) ;
|
||||||
|
else
|
||||||
|
::HiliteControl( m_macControl , 255 ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
return TRUE ;
|
||||||
{
|
|
||||||
if ( enable )
|
|
||||||
::HiliteControl( m_macControl , 0 ) ;
|
|
||||||
else
|
|
||||||
::HiliteControl( m_macControl , 255 ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return wxWindow::Enable( enable ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::Refresh(bool eraseBack, const wxRect *rect)
|
void wxControl::Refresh(bool eraseBack, const wxRect *rect)
|
||||||
@@ -579,9 +561,9 @@ void wxControl::OnPaint(wxPaintEvent& event)
|
|||||||
wxWindow* parent = GetParent() ;
|
wxWindow* parent = GetParent() ;
|
||||||
while ( parent )
|
while ( parent )
|
||||||
{
|
{
|
||||||
if( parent->m_macWindowData )
|
if( parent->MacGetWindowData() )
|
||||||
{
|
{
|
||||||
UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,13 +578,13 @@ void wxControl::OnPaint(wxPaintEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
UMADrawControl( m_macControl ) ;
|
UMADrawControl( m_macControl ) ;
|
||||||
UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
|
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxWindow::OnPaint( event ) ;
|
// wxWindow::OnPaint( event ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,7 +108,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
|
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
|
||||||
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
||||||
m_macWindowData->m_macFocus = NULL ;
|
m_macWindowData->m_macFocus = NULL ;
|
||||||
m_macShown = false ;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,10 +126,13 @@ void wxDialog::SetModal(bool flag)
|
|||||||
|
|
||||||
wxDialog::~wxDialog()
|
wxDialog::~wxDialog()
|
||||||
{
|
{
|
||||||
|
m_isBeingDeleted = TRUE ;
|
||||||
wxTopLevelWindows.DeleteObject(this);
|
wxTopLevelWindows.DeleteObject(this);
|
||||||
|
|
||||||
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
|
m_modalShowing = FALSE;
|
||||||
wxModelessWindows.DeleteObject(this);
|
|
||||||
|
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
|
||||||
|
wxModelessWindows.DeleteObject(this);
|
||||||
|
|
||||||
// If this is the last top-level window, exit.
|
// If this is the last top-level window, exit.
|
||||||
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
||||||
@@ -176,37 +178,64 @@ extern bool s_macIsInModalLoop ;
|
|||||||
|
|
||||||
bool wxDialog::Show(bool show)
|
bool wxDialog::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( m_macShown == show )
|
m_isShown = show;
|
||||||
return TRUE ;
|
|
||||||
|
|
||||||
m_macShown = show ;
|
if (show)
|
||||||
|
InitDialog();
|
||||||
|
|
||||||
bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
|
bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
|
||||||
|
|
||||||
|
#if WXGARBAGE_COLLECTION_ON /* MATTHEW: GC */
|
||||||
|
if (!modal)
|
||||||
|
{
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
if (!wxModelessWindows.Find(this))
|
||||||
|
wxModelessWindows.Append(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
wxModelessWindows.DeleteObject(this);
|
||||||
|
}
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
if (!wxTopLevelWindows.Find(this))
|
||||||
|
wxTopLevelWindows.Append(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
wxTopLevelWindows.DeleteObject(this);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( modal )
|
if ( modal )
|
||||||
{
|
{
|
||||||
s_macIsInModalLoop = true ;
|
s_macIsInModalLoop = true ;
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
// if we don't do it, some window might be deleted while we have pointers
|
if (m_modalShowing)
|
||||||
// to them in our disabledWindows list and the program will crash when it
|
{
|
||||||
// will try to reenable them after the modal dialog end
|
// BringWindowToTop((HWND) GetHWND());
|
||||||
wxTheApp->DeletePendingObjects();
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
UMAShowWindow( m_macWindowData->m_macWindow ) ;
|
m_modalShowing = TRUE;
|
||||||
UMASelectWindow( m_macWindowData->m_macWindow ) ;
|
// if we don't do it, some window might be deleted while we have pointers
|
||||||
|
// to them in our disabledWindows list and the program will crash when it
|
||||||
|
// will try to reenable them after the modal dialog end
|
||||||
|
wxTheApp->DeletePendingObjects();
|
||||||
|
|
||||||
if (!wxModalDialogs.Member(this))
|
UMAShowWindow( m_macWindowData->m_macWindow ) ;
|
||||||
wxModalDialogs.Append(this);
|
UMASelectWindow( m_macWindowData->m_macWindow ) ;
|
||||||
|
|
||||||
while (wxModalDialogs.Member(this) )
|
if (!wxModalDialogs.Member(this))
|
||||||
{
|
wxModalDialogs.Append(this);
|
||||||
wxTheApp->MacDoOneEvent() ;
|
|
||||||
}
|
while (wxModalDialogs.Member(this) )
|
||||||
|
{
|
||||||
|
wxTheApp->MacDoOneEvent() ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxModalDialogs.DeleteObject(this);
|
wxModalDialogs.DeleteObject(this);
|
||||||
UMAHideWindow( m_macWindowData->m_macWindow ) ;
|
UMAHideWindow( m_macWindowData->m_macWindow ) ;
|
||||||
}
|
}
|
||||||
s_macIsInModalLoop = false ;
|
s_macIsInModalLoop = false ;
|
||||||
@@ -334,125 +363,3 @@ void wxDialog::Fit()
|
|||||||
wxWindow::Fit();
|
wxWindow::Fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSizer *wxDialog::CreateTextSizer( const wxString &message )
|
|
||||||
{
|
|
||||||
wxBoxSizer *box = new wxBoxSizer( wxVERTICAL );
|
|
||||||
|
|
||||||
// get line height for empty lines
|
|
||||||
int y = 0;
|
|
||||||
wxFont new_font( GetFont() );
|
|
||||||
if (!new_font.Ok()) new_font = *wxSWISS_FONT;
|
|
||||||
GetTextExtent( "H", (int*)NULL, &y, (int*)NULL, (int*)NULL, &new_font );
|
|
||||||
|
|
||||||
wxString line;
|
|
||||||
for (size_t pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( this, -1, line );
|
|
||||||
box->Add( s1 );
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
box->Add( 5, y );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remaining text behind last '\n'
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( this, -1, line );
|
|
||||||
box->Add( s2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSizer *wxDialog::CreateButtonSizer( long flags )
|
|
||||||
{
|
|
||||||
wxBoxSizer *box = new wxBoxSizer( wxHORIZONTAL );
|
|
||||||
|
|
||||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
|
||||||
int margin = 6;
|
|
||||||
#else
|
|
||||||
int margin = 10;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
wxButton *yes = (wxButton *) NULL;
|
|
||||||
wxButton *no = (wxButton *) NULL;
|
|
||||||
|
|
||||||
// always show an OK button, unless only YES_NO is given
|
|
||||||
if ((flags & wxYES_NO) == 0) flags = flags | wxOK;
|
|
||||||
|
|
||||||
if (flags & wxYES_NO)
|
|
||||||
{
|
|
||||||
yes = new wxButton( this, wxID_YES, _("Yes") );
|
|
||||||
box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
no = new wxButton( this, wxID_NO, _("No") );
|
|
||||||
box->Add( no, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
} else
|
|
||||||
if (flags & wxYES)
|
|
||||||
{
|
|
||||||
yes = new wxButton( this, wxID_YES, _("Yes") );
|
|
||||||
box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
} else
|
|
||||||
if (flags & wxNO)
|
|
||||||
{
|
|
||||||
no = new wxButton( this, wxID_NO, _("No") );
|
|
||||||
box->Add( no, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK") );
|
|
||||||
box->Add( ok, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & wxFORWARD)
|
|
||||||
box->Add( new wxButton( this, wxID_FORWARD, _("Forward") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxBACKWARD)
|
|
||||||
box->Add( new wxButton( this, wxID_BACKWARD, _("Backward") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxSETUP)
|
|
||||||
box->Add( new wxButton( this, wxID_SETUP, _("Setup") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxMORE)
|
|
||||||
box->Add( new wxButton( this, wxID_MORE, _("More...") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxHELP)
|
|
||||||
box->Add( new wxButton( this, wxID_HELP, _("Help") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
|
||||||
box->Add( cancel, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & wxNO_DEFAULT) == 0)
|
|
||||||
{
|
|
||||||
if (ok)
|
|
||||||
{
|
|
||||||
ok->SetDefault();
|
|
||||||
ok->SetFocus();
|
|
||||||
}
|
|
||||||
else if (yes)
|
|
||||||
{
|
|
||||||
yes->SetDefault();
|
|
||||||
yes->SetFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -22,39 +22,42 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxFontRefData::wxFontRefData()
|
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxFontRefData
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxFontRefData::Init(int pointSize,
|
||||||
|
int family,
|
||||||
|
int style,
|
||||||
|
int weight,
|
||||||
|
bool underlined,
|
||||||
|
const wxString& faceName,
|
||||||
|
wxFontEncoding encoding)
|
||||||
{
|
{
|
||||||
m_style = 0;
|
m_style = style;
|
||||||
m_pointSize = 0;
|
m_pointSize = pointSize;
|
||||||
m_family = 0;
|
m_family = family;
|
||||||
m_style = 0;
|
m_style = style;
|
||||||
m_weight = 0;
|
m_weight = weight;
|
||||||
m_underlined = 0;
|
m_underlined = underlined;
|
||||||
m_faceName = "";
|
m_faceName = faceName;
|
||||||
|
m_encoding = encoding;
|
||||||
|
|
||||||
m_macFontSize = m_pointSize ;
|
m_macFontNum = 0 ;
|
||||||
m_macFontNum = systemFont ;
|
m_macFontSize = 0;
|
||||||
m_macFontStyle = normal ;
|
m_macFontStyle = 0;
|
||||||
}
|
m_fontId = 0;
|
||||||
|
|
||||||
wxFontRefData::wxFontRefData(const wxFontRefData& data)
|
|
||||||
{
|
|
||||||
m_style = data.m_style;
|
|
||||||
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_macFontSize = m_pointSize ;
|
|
||||||
m_macFontNum = systemFont ;
|
|
||||||
m_macFontStyle = normal ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontRefData::~wxFontRefData()
|
wxFontRefData::~wxFontRefData()
|
||||||
{
|
{
|
||||||
// TODO: delete font data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontRefData::MacFindFont()
|
void wxFontRefData::MacFindFont()
|
||||||
@@ -107,31 +110,27 @@ void wxFontRefData::MacFindFont()
|
|||||||
m_macFontSize = m_pointSize ;
|
m_macFontSize = m_pointSize ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont::wxFont()
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxFont
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxFont::Init()
|
||||||
{
|
{
|
||||||
if ( wxTheFontList )
|
if ( wxTheFontList )
|
||||||
wxTheFontList->Append(this);
|
wxTheFontList->Append(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
|
bool wxFont::Create(int pointSize,
|
||||||
{
|
int family,
|
||||||
Create(pointSize, family, style, weight, underlined, faceName);
|
int style,
|
||||||
|
int weight,
|
||||||
if ( wxTheFontList )
|
bool underlined,
|
||||||
wxTheFontList->Append(this);
|
const wxString& faceName,
|
||||||
}
|
wxFontEncoding encoding)
|
||||||
|
|
||||||
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
|
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
m_refData = new wxFontRefData;
|
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||||
|
underlined, faceName, encoding);
|
||||||
M_FONTDATA->m_family = family;
|
|
||||||
M_FONTDATA->m_style = style;
|
|
||||||
M_FONTDATA->m_weight = weight;
|
|
||||||
M_FONTDATA->m_pointSize = pointSize;
|
|
||||||
M_FONTDATA->m_underlined = underlined;
|
|
||||||
M_FONTDATA->m_faceName = faceName;
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
|
|
||||||
@@ -219,78 +218,50 @@ void wxFont::SetUnderlined(bool underlined)
|
|||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFont::GetFamilyString() const
|
// ----------------------------------------------------------------------------
|
||||||
|
// accessors
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int wxFont::GetPointSize() const
|
||||||
{
|
{
|
||||||
wxString fam("");
|
return M_FONTDATA->m_pointSize;
|
||||||
switch (GetFamily())
|
}
|
||||||
{
|
|
||||||
case wxDECORATIVE:
|
int wxFont::GetFamily() const
|
||||||
fam = "wxDECORATIVE";
|
{
|
||||||
break;
|
return M_FONTDATA->m_family;
|
||||||
case wxROMAN:
|
}
|
||||||
fam = "wxROMAN";
|
|
||||||
break;
|
int wxFont::GetFontId() const
|
||||||
case wxSCRIPT:
|
{
|
||||||
fam = "wxSCRIPT";
|
return M_FONTDATA->m_fontId;
|
||||||
break;
|
}
|
||||||
case wxSWISS:
|
|
||||||
fam = "wxSWISS";
|
int wxFont::GetStyle() const
|
||||||
break;
|
{
|
||||||
case wxMODERN:
|
return M_FONTDATA->m_style;
|
||||||
fam = "wxMODERN";
|
}
|
||||||
break;
|
|
||||||
case wxTELETYPE:
|
int wxFont::GetWeight() const
|
||||||
fam = "wxTELETYPE";
|
{
|
||||||
break;
|
return M_FONTDATA->m_weight;
|
||||||
default:
|
}
|
||||||
fam = "wxDEFAULT";
|
|
||||||
break;
|
bool wxFont::GetUnderlined() const
|
||||||
}
|
{
|
||||||
return fam;
|
return M_FONTDATA->m_underlined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* New font system */
|
|
||||||
wxString wxFont::GetFaceName() const
|
wxString wxFont::GetFaceName() const
|
||||||
{
|
{
|
||||||
wxString str("");
|
wxString str;
|
||||||
if (M_FONTDATA)
|
if ( M_FONTDATA )
|
||||||
str = M_FONTDATA->m_faceName ;
|
str = M_FONTDATA->m_faceName ;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFont::GetStyleString() const
|
wxFontEncoding wxFont::GetEncoding() const
|
||||||
{
|
{
|
||||||
wxString styl("");
|
return M_FONTDATA->m_encoding;
|
||||||
switch (GetStyle())
|
|
||||||
{
|
|
||||||
case wxITALIC:
|
|
||||||
styl = "wxITALIC";
|
|
||||||
break;
|
|
||||||
case wxSLANT:
|
|
||||||
styl = "wxSLANT";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
styl = "wxNORMAL";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return styl;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString wxFont::GetWeightString() const
|
|
||||||
{
|
|
||||||
wxString w("");
|
|
||||||
switch (GetWeight())
|
|
||||||
{
|
|
||||||
case wxBOLD:
|
|
||||||
w = "wxBOLD";
|
|
||||||
break;
|
|
||||||
case wxLIGHT:
|
|
||||||
w = "wxLIGHT";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
w = "wxNORMAL";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,12 +52,10 @@ wxFrame::wxFrame()
|
|||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
m_frameToolBar = NULL ;
|
m_frameToolBar = NULL ;
|
||||||
#endif
|
#endif
|
||||||
m_macShown = false ;
|
|
||||||
// in order to be able to give size events on show
|
// in order to be able to give size events on show
|
||||||
m_frameMenuBar = NULL;
|
m_frameMenuBar = NULL;
|
||||||
m_frameStatusBar = NULL;
|
m_frameStatusBar = NULL;
|
||||||
|
|
||||||
m_windowParent = NULL;
|
|
||||||
m_iconized = FALSE;
|
m_iconized = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +145,6 @@ bool wxFrame::Create(wxWindow *parent,
|
|||||||
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
||||||
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
|
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
|
||||||
m_macWindowData->m_macFocus = NULL ;
|
m_macWindowData->m_macFocus = NULL ;
|
||||||
m_macShown = false ;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,57 +106,120 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
wxListBox::~wxListBox()
|
wxListBox::~wxListBox()
|
||||||
{
|
{
|
||||||
// DisposeExtLDEFInfo( m_macList ) ;
|
Free() ;
|
||||||
|
DisposeExtLDEFInfo( m_macList ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetFirstItem(int N)
|
void wxListBox::Free()
|
||||||
|
{
|
||||||
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
if ( m_windowStyle & wxLB_OWNERDRAW )
|
||||||
|
{
|
||||||
|
size_t uiCount = m_aItems.Count();
|
||||||
|
while ( uiCount-- != 0 ) {
|
||||||
|
delete m_aItems[uiCount];
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aItems.Clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
{
|
||||||
|
for ( size_t n = 0; n < (size_t)m_noItems; n++ )
|
||||||
|
{
|
||||||
|
delete GetClientObject(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListBox::DoSetFirstItem(int N)
|
||||||
{
|
{
|
||||||
MacScrollTo( N ) ;
|
MacScrollTo( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetFirstItem(const wxString& s)
|
|
||||||
{
|
|
||||||
MacScrollTo( FindString( s ) ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxListBox::Delete(int N)
|
void wxListBox::Delete(int N)
|
||||||
{
|
{
|
||||||
m_dataArray.Remove( N ) ;
|
wxCHECK_RET( N >= 0 && N < m_noItems,
|
||||||
|
wxT("invalid index in wxListBox::Delete") );
|
||||||
|
|
||||||
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
delete m_aItems[N];
|
||||||
|
m_aItems.Remove(N);
|
||||||
|
#else // !wxUSE_OWNER_DRAWN
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
{
|
||||||
|
delete GetClientObject(N);
|
||||||
|
}
|
||||||
|
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
||||||
m_stringArray.Remove( N ) ;
|
m_stringArray.Remove( N ) ;
|
||||||
m_noItems --;
|
m_noItems --;
|
||||||
|
|
||||||
MacDelete( N ) ;
|
MacDelete( N ) ;
|
||||||
|
SetHorizontalExtent("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Append(const wxString& item)
|
int wxListBox::DoAppend(const wxString& item)
|
||||||
{
|
|
||||||
Append( item , NULL ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxListBox::Append(const wxString& item, char *Client_data)
|
|
||||||
{
|
{
|
||||||
|
int index = m_noItems ;
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
|
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_stringArray.Add( item ) ;
|
m_stringArray.Add( item ) ;
|
||||||
m_dataArray.Add( Client_data ) ;
|
m_noItems ++;
|
||||||
m_noItems ++;
|
|
||||||
|
|
||||||
MacAppend( item ) ;
|
MacAppend( item ) ;
|
||||||
|
|
||||||
|
SetHorizontalExtent(item);
|
||||||
|
|
||||||
|
return index ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Set(int n, const wxString *choices, char** clientData)
|
void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
||||||
{
|
{
|
||||||
|
MacSetRedraw( false ) ;
|
||||||
Clear() ;
|
Clear() ;
|
||||||
|
int n = choices.GetCount();
|
||||||
|
|
||||||
for( int i = 0 ; i < n ; ++i )
|
for( int i = 0 ; i < n ; ++i )
|
||||||
{
|
{
|
||||||
if ( clientData )
|
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[0] ) ;
|
Append( choices[i] , clientData[0] ) ;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Append( choices[i] ) ;
|
Append( choices[i] ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
if ( m_windowStyle & wxLB_OWNERDRAW ) {
|
||||||
|
// first delete old items
|
||||||
|
size_t ui = m_aItems.Count();
|
||||||
|
while ( ui-- != 0 ) {
|
||||||
|
delete m_aItems[ui];
|
||||||
|
}
|
||||||
|
m_aItems.Empty();
|
||||||
|
|
||||||
|
// then create new ones
|
||||||
|
for ( ui = 0; ui < (size_t)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& st) const
|
int wxListBox::FindString(const wxString& st) const
|
||||||
@@ -192,10 +255,12 @@ int wxListBox::FindString(const wxString& st) const
|
|||||||
|
|
||||||
void wxListBox::Clear()
|
void wxListBox::Clear()
|
||||||
{
|
{
|
||||||
|
Free();
|
||||||
m_noItems = 0;
|
m_noItems = 0;
|
||||||
m_stringArray.Empty() ;
|
m_stringArray.Empty() ;
|
||||||
m_dataArray.Empty() ;
|
m_dataArray.Empty() ;
|
||||||
MacClear() ;
|
MacClear() ;
|
||||||
|
SetHorizontalExtent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetSelection(int N, bool select)
|
void wxListBox::SetSelection(int N, bool select)
|
||||||
@@ -205,7 +270,7 @@ void wxListBox::SetSelection(int N, bool select)
|
|||||||
MacSetSelection( N , select ) ;
|
MacSetSelection( N , select ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxListBox::Selected(int N) const
|
bool wxListBox::IsSelected(int N) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
|
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
|
||||||
"invalid index in wxListBox::Selected" );
|
"invalid index in wxListBox::Selected" );
|
||||||
@@ -213,28 +278,33 @@ bool wxListBox::Selected(int N) const
|
|||||||
return MacIsSelected( N ) ;
|
return MacIsSelected( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Deselect(int N)
|
void *wxListBox::DoGetItemClientData(int N) const
|
||||||
{
|
|
||||||
wxCHECK_RET( N >= 0 && N < m_noItems,
|
|
||||||
"invalid index in wxListBox::Deselect" );
|
|
||||||
|
|
||||||
SetSelection( N , false ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *wxListBox::GetClientData(int N) const
|
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
|
wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
|
||||||
"invalid index in wxListBox::GetClientData" );
|
"invalid index in wxListBox::GetClientData" );
|
||||||
|
|
||||||
return m_dataArray[N];
|
return (void *)m_dataArray[N];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetClientData(int N, char *Client_data)
|
void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( N >= 0 && N < m_noItems,
|
wxCHECK_RET( N >= 0 && N < m_noItems,
|
||||||
"invalid index in wxListBox::SetClientData" );
|
"invalid index in wxListBox::SetClientData" );
|
||||||
|
|
||||||
m_dataArray[N] = Client_data ;
|
#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
|
||||||
|
m_dataArray[N] = (char*) Client_data ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
|
||||||
|
{
|
||||||
|
DoSetItemClientData(n, clientData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return number of selections and an array of selected integers
|
// Return number of selections and an array of selected integers
|
||||||
@@ -277,8 +347,13 @@ wxString wxListBox::GetString(int N) const
|
|||||||
return m_stringArray[N] ;
|
return m_stringArray[N] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
|
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( pos >= 0 && pos <= m_noItems,
|
||||||
|
wxT("invalid index in wxListBox::InsertItems") );
|
||||||
|
|
||||||
|
int nItems = items.GetCount();
|
||||||
|
|
||||||
for ( int i = 0 ; i < nItems ; i++ )
|
for ( int i = 0 ; i < nItems ; i++ )
|
||||||
{
|
{
|
||||||
m_stringArray.Insert( items[i] , pos + i ) ;
|
m_stringArray.Insert( items[i] , pos + i ) ;
|
||||||
@@ -295,46 +370,11 @@ void wxListBox::SetString(int N, const wxString& s)
|
|||||||
MacSet( N , s ) ;
|
MacSet( N , s ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListBox::Number () const
|
wxSize wxListBox::DoGetBestSize()
|
||||||
{
|
{
|
||||||
return m_noItems;
|
return wxSize(100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For single selection items only
|
|
||||||
wxString wxListBox::GetStringSelection () const
|
|
||||||
{
|
|
||||||
int sel = GetSelection ();
|
|
||||||
if (sel > -1)
|
|
||||||
{
|
|
||||||
return GetString (sel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return wxString("");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxListBox::SetStringSelection (const wxString& s, bool flag)
|
|
||||||
{
|
|
||||||
int sel = FindString (s);
|
|
||||||
if (sel > -1)
|
|
||||||
{
|
|
||||||
SetSelection (sel, flag);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxListBox::Command (wxCommandEvent & event)
|
|
||||||
{
|
|
||||||
if (event.m_extraLong)
|
|
||||||
SetSelection (event.m_commandInt);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Deselect (event.m_commandInt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProcessCommand (event);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// list box control implementation
|
// list box control implementation
|
||||||
@@ -484,29 +524,27 @@ void wxListBox::MacSetRedraw( bool doDraw )
|
|||||||
void wxListBox::MacDoClick()
|
void wxListBox::MacDoClick()
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
||||||
|
event.SetEventObject( this );
|
||||||
|
|
||||||
wxArrayInt aSelections;
|
wxArrayInt aSelections;
|
||||||
int count = GetSelections(aSelections);
|
int n, count = GetSelections(aSelections);
|
||||||
if ( count > 0 )
|
if ( count > 0 )
|
||||||
{
|
{
|
||||||
event.m_commandInt = aSelections[0] ;
|
event.m_commandInt = aSelections[0] ;
|
||||||
event.m_clientData = GetClientData(event.m_commandInt);
|
if ( HasClientObjectData() )
|
||||||
wxString str(GetString(event.m_commandInt));
|
event.SetClientObject( GetClientObject(n) );
|
||||||
if (str != "")
|
else if ( HasClientUntypedData() )
|
||||||
event.m_commandString = copystring((char *)(const char *)str);
|
event.SetClientData( GetClientData(n) );
|
||||||
|
event.SetString( GetString(n) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ;
|
n = -1;
|
||||||
/*
|
|
||||||
event.m_commandInt = -1 ;
|
|
||||||
event.m_commandString = copystring("") ;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.SetEventObject( this );
|
event.m_commandInt = n;
|
||||||
ProcessCommand(event);
|
|
||||||
if (event.m_commandString)
|
GetEventHandler()->ProcessEvent(event);
|
||||||
delete[] event.m_commandString ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacDoDoubleClick()
|
void wxListBox::MacDoDoubleClick()
|
||||||
|
@@ -82,17 +82,7 @@ void wxMDIParentFrame::GetClientSize(int *x, int *y) const
|
|||||||
|
|
||||||
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
|
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
|
||||||
{
|
{
|
||||||
// TODO
|
wxFrame::SetMenuBar( menu_bar ) ;
|
||||||
if (!menu_bar)
|
|
||||||
{
|
|
||||||
m_frameMenuBar = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menu_bar->m_menuBarFrame)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_frameMenuBar = menu_bar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMDIParentFrame::OnSize(wxSizeEvent& event)
|
void wxMDIParentFrame::OnSize(wxSizeEvent& event)
|
||||||
@@ -211,16 +201,7 @@ void wxMDIChildFrame::GetPosition(int *x, int *y) const
|
|||||||
|
|
||||||
void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
|
void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
|
||||||
{
|
{
|
||||||
// TODO
|
return wxFrame::SetMenuBar( menu_bar ) ;
|
||||||
if (!menu_bar)
|
|
||||||
{
|
|
||||||
m_frameMenuBar = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menu_bar->m_menuBarFrame)
|
|
||||||
return;
|
|
||||||
m_frameMenuBar = menu_bar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MDI operations
|
// MDI operations
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -37,24 +37,26 @@
|
|||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
|
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
|
||||||
const wxString& strName, const wxString& strHelp,
|
const wxString& text, const wxString& strHelp,
|
||||||
bool bCheckable,
|
bool bCheckable,
|
||||||
wxMenu *pSubMenu) :
|
wxMenu *pSubMenu)
|
||||||
m_bCheckable(bCheckable),
|
|
||||||
m_strName(strName),
|
|
||||||
m_strHelp(strHelp)
|
|
||||||
{
|
{
|
||||||
wxASSERT( pParentMenu != NULL );
|
wxASSERT( pParentMenu != NULL );
|
||||||
|
|
||||||
m_pParentMenu = pParentMenu;
|
m_parentMenu = pParentMenu;
|
||||||
m_pSubMenu = pSubMenu;
|
m_subMenu = pSubMenu;
|
||||||
m_idItem = id;
|
m_isEnabled = TRUE;
|
||||||
m_bEnabled = TRUE;
|
m_isChecked = FALSE;
|
||||||
|
m_id = id;
|
||||||
|
m_text = text;
|
||||||
|
m_isCheckable = bCheckable;
|
||||||
|
m_help = strHelp;
|
||||||
|
|
||||||
if ( m_strName == "E&xit" ||m_strName == "Exit" )
|
|
||||||
{
|
if ( m_text == "E&xit" ||m_text == "Exit" )
|
||||||
m_strName = "Quit\tCtrl+Q" ;
|
{
|
||||||
}
|
m_text = "Quit\tCtrl+Q" ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuItem::~wxMenuItem()
|
wxMenuItem::~wxMenuItem()
|
||||||
@@ -64,53 +66,57 @@ wxMenuItem::~wxMenuItem()
|
|||||||
// misc
|
// misc
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
// delete the sub menu
|
// delete the sub menu
|
||||||
void wxMenuItem::DeleteSubMenu()
|
void wxMenuItem::DeleteSubMenu()
|
||||||
{
|
{
|
||||||
wxASSERT( m_pSubMenu != NULL );
|
wxASSERT( m_subMenu != NULL );
|
||||||
|
|
||||||
delete m_pSubMenu;
|
delete m_subMenu;
|
||||||
m_pSubMenu = NULL;
|
m_subMenu = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
// change item state
|
// change item state
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
void wxMenuItem::Enable(bool bDoEnable)
|
void wxMenuItem::Enable(bool bDoEnable)
|
||||||
{
|
{
|
||||||
if ( m_bEnabled != bDoEnable ) {
|
if ( m_isEnabled != bDoEnable ) {
|
||||||
if ( m_pSubMenu == NULL )
|
if ( m_subMenu == NULL )
|
||||||
{
|
{
|
||||||
// normal menu item
|
// normal menu item
|
||||||
if ( m_pParentMenu->m_macMenuHandle )
|
if ( m_parentMenu->GetHMenu() )
|
||||||
{
|
{
|
||||||
int index = m_pParentMenu->MacGetIndexFromItem( this ) ;
|
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
||||||
if ( index >= 1 )
|
if ( index >= 1 )
|
||||||
{
|
{
|
||||||
if ( bDoEnable )
|
if ( bDoEnable )
|
||||||
UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
|
UMAEnableMenuItem( m_parentMenu->GetHMenu() , index ) ;
|
||||||
else
|
else
|
||||||
UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
|
UMADisableMenuItem( m_parentMenu->GetHMenu() , index ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// submenu
|
// submenu
|
||||||
if ( m_pParentMenu->m_macMenuHandle )
|
if ( m_parentMenu->GetHMenu() )
|
||||||
{
|
{
|
||||||
int index = m_pParentMenu->MacGetIndexFromItem( this ) ;
|
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
||||||
if ( index >= 1 )
|
if ( index >= 1 )
|
||||||
{
|
{
|
||||||
if ( bDoEnable )
|
if ( bDoEnable )
|
||||||
UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
|
UMAEnableMenuItem( m_parentMenu->GetHMenu() , index ) ;
|
||||||
else
|
else
|
||||||
UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
|
UMADisableMenuItem( m_parentMenu->GetHMenu() , index ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bEnabled = bDoEnable;
|
m_isEnabled = bDoEnable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,18 +124,18 @@ void wxMenuItem::Check(bool bDoCheck)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
|
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
|
||||||
|
|
||||||
if ( m_bChecked != bDoCheck )
|
if ( m_isChecked != bDoCheck )
|
||||||
{
|
{
|
||||||
m_bChecked = bDoCheck;
|
m_isChecked = bDoCheck;
|
||||||
if ( m_pParentMenu->m_macMenuHandle )
|
if ( m_parentMenu->GetHMenu() )
|
||||||
{
|
{
|
||||||
int index = m_pParentMenu->MacGetIndexFromItem( this ) ;
|
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
||||||
if ( index >= 1 )
|
if ( index >= 1 )
|
||||||
{
|
{
|
||||||
if ( bDoCheck )
|
if ( bDoCheck )
|
||||||
::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0x12 ) ; // checkmark
|
::SetItemMark( m_parentMenu->GetHMenu() , index , 0x12 ) ; // checkmark
|
||||||
else
|
else
|
||||||
::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0 ) ; // no mark
|
::SetItemMark( m_parentMenu->GetHMenu() , index , 0 ) ; // no mark
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,82 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: print.cpp
|
|
||||||
// Purpose: Print framework
|
|
||||||
// Author: AUTHOR
|
|
||||||
// Modified by:
|
|
||||||
// Created: ??/??/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) AUTHOR
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "print.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/mac/print.h"
|
|
||||||
#include "wx/mac/printdlg.h"
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPrinter, wxPrinterBase)
|
|
||||||
IMPLEMENT_CLASS(wxPrintPreview, wxPrintPreviewBase)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Printer
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxPrinter::wxPrinter(wxPrintData *data):
|
|
||||||
wxPrinterBase(data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPrinter::~wxPrinter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
|
||||||
{
|
|
||||||
// TODO. See wxPostScriptPrinter::Print for hints.
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxPrinter::PrintDialog(wxWindow *parent)
|
|
||||||
{
|
|
||||||
wxPrintDialog dialog(parent, & m_printData);
|
|
||||||
return (dialog.ShowModal() == wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxPrinter::Setup(wxWindow *parent)
|
|
||||||
{
|
|
||||||
wxPrintDialog dialog(parent, & m_printData);
|
|
||||||
dialog.GetPrintData().SetSetupDialog(TRUE);
|
|
||||||
return (dialog.ShowModal() == wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print preview
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxPrintPreview::wxPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data):
|
|
||||||
wxPrintPreviewBase(printout, printoutForPrinting, data)
|
|
||||||
{
|
|
||||||
DetermineScaling();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPrintPreview::~wxPrintPreview()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxPrintPreview::Print(bool interactive)
|
|
||||||
{
|
|
||||||
if (!m_printPrintout)
|
|
||||||
return FALSE;
|
|
||||||
wxPrinter printer(&m_printData);
|
|
||||||
return printer.Print(m_previewFrame, m_printPrintout, interactive);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxPrintPreview::DetermineScaling()
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/object.h"
|
#include "wx/object.h"
|
||||||
#include "wx/mac/printdlg.h"
|
#include "wx/printdlg.h"
|
||||||
#include "wx/dcprint.h"
|
#include "wx/dcprint.h"
|
||||||
|
|
||||||
// Use generic page setup dialog: use your own native one if one exists.
|
// Use generic page setup dialog: use your own native one if one exists.
|
||||||
@@ -24,30 +24,43 @@ IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
|
|||||||
IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
|
IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxPrintDialog::wxPrintDialog():
|
wxPrintDialog::wxPrintDialog()
|
||||||
wxDialog()
|
|
||||||
{
|
{
|
||||||
m_dialogParent = NULL;
|
m_dialogParent = NULL;
|
||||||
|
m_printerDC = NULL;
|
||||||
|
m_destroyDC = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data):
|
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
|
||||||
wxDialog()
|
|
||||||
{
|
{
|
||||||
Create(p, data);
|
Create(p, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPrintDialog::Create(wxWindow *p, wxPrintData* 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_dialogParent = p;
|
||||||
|
m_printerDC = NULL;
|
||||||
|
m_destroyDC = TRUE;
|
||||||
|
|
||||||
if ( data )
|
if ( data )
|
||||||
m_printData = *data;
|
m_printDialogData = *data;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintDialog::~wxPrintDialog()
|
wxPrintDialog::~wxPrintDialog()
|
||||||
{
|
{
|
||||||
|
if (m_destroyDC && m_printerDC)
|
||||||
|
delete m_printerDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxPrintDialog::ShowModal()
|
int wxPrintDialog::ShowModal()
|
||||||
@@ -60,10 +73,10 @@ int wxPrintDialog::ShowModal()
|
|||||||
|
|
||||||
if ( !err )
|
if ( !err )
|
||||||
{
|
{
|
||||||
m_printData.ConvertToNative() ;
|
m_printDialogData.ConvertToNative() ;
|
||||||
if ( m_printData.macPrintInfo && ::PrJobDialog( m_printData.macPrintInfo ) )
|
if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) )
|
||||||
{
|
{
|
||||||
m_printData.ConvertFromNative() ;
|
m_printDialogData.ConvertFromNative() ;
|
||||||
result = wxID_OK ;
|
result = wxID_OK ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +93,7 @@ int wxPrintDialog::ShowModal()
|
|||||||
|
|
||||||
wxDC *wxPrintDialog::GetPrintDC()
|
wxDC *wxPrintDialog::GetPrintDC()
|
||||||
{
|
{
|
||||||
return new wxPrinterDC( m_printData ) ;
|
return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -67,17 +67,6 @@ wxRadioBox::~wxRadioBox()
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRadioBox::GetLabel(int item) const
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return wxString("");
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxRadioBox::SetLabel(int item, const wxString& label)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxRadioBox::FindString(const wxString& s) const
|
int wxRadioBox::FindString(const wxString& s) const
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
@@ -106,28 +95,28 @@ wxString wxRadioBox::GetString(int n) const
|
|||||||
return wxString("");
|
return wxString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
|
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
{
|
{
|
||||||
wxControl::SetSize( x , y , width , height , sizeFlags ) ;
|
wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::GetSize(int *width, int *height) const
|
void wxRadioBox::GetSize(int *width, int *height) const
|
||||||
{
|
{
|
||||||
// TODO
|
wxControl::GetSize( width , height ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::GetPosition(int *x, int *y) const
|
void wxRadioBox::GetPosition(int *x, int *y) const
|
||||||
{
|
{
|
||||||
// TODO
|
wxControl::GetPosition( x , y ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRadioBox::GetLabel() const
|
wxString wxRadioBox::GetLabel( int item ) const
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return wxString("");
|
return wxString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SetLabel(const wxString& label)
|
void wxRadioBox::SetLabel(int item , const wxString& label)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@@ -139,23 +128,18 @@ void wxRadioBox::SetFocus()
|
|||||||
|
|
||||||
bool wxRadioBox::Show(bool show)
|
bool wxRadioBox::Show(bool show)
|
||||||
{
|
{
|
||||||
// TODO
|
return wxControl::Show( show ) ;
|
||||||
return wxWindow::Show( show ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable a specific button
|
// Enable a specific button
|
||||||
void wxRadioBox::Enable(int item, bool enable)
|
void wxRadioBox::Enable(int item, bool enable)
|
||||||
{
|
{
|
||||||
wxControl::Enable(enable);
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable all controls
|
// Enable all controls
|
||||||
void wxRadioBox::Enable(bool enable)
|
bool wxRadioBox::Enable(bool enable)
|
||||||
{
|
{
|
||||||
wxControl::Enable(enable);
|
return wxControl::Enable(enable);
|
||||||
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a specific button
|
// Show a specific button
|
||||||
|
@@ -16,15 +16,18 @@
|
|||||||
#include "wx/spinbutt.h"
|
#include "wx/spinbutt.h"
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
// ============================================================================
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
|
// implementation
|
||||||
#endif
|
// ============================================================================
|
||||||
|
|
||||||
wxSpinButton::wxSpinButton()
|
// ----------------------------------------------------------------------------
|
||||||
{
|
// wxWin macros
|
||||||
m_min = 0;
|
// ----------------------------------------------------------------------------
|
||||||
m_max = 100;
|
|
||||||
}
|
#if !USE_SHARED_LIBRARY
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||||
long style, const wxString& name)
|
long style, const wxString& name)
|
||||||
@@ -78,14 +81,6 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
|
|||||||
m_max = maxVal;
|
m_max = maxVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spin event
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
|
|
||||||
|
|
||||||
wxSpinEvent::wxSpinEvent(wxEventType commandType, int id):
|
|
||||||
wxScrollEvent(commandType, id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxSpinButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
void wxSpinButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||||
{
|
{
|
||||||
if ( m_macControl == NULL )
|
if ( m_macControl == NULL )
|
||||||
|
@@ -47,7 +47,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
void wxStaticText::SetLabel(const wxString& st , bool resize )
|
void wxStaticText::SetLabel(const wxString& st , bool resize )
|
||||||
{
|
{
|
||||||
m_label = st ;
|
SetTitle( st ) ;
|
||||||
wxString label ;
|
wxString label ;
|
||||||
|
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
|
@@ -409,73 +409,51 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
|
|||||||
|
|
||||||
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
bool handleIt = true ;
|
|
||||||
switch( event.KeyCode() )
|
switch( event.KeyCode() )
|
||||||
{
|
{
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
{
|
{
|
||||||
/* Oh yes it will, because we also specify DLGC_WANTCHARS
|
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||||
wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER,
|
|
||||||
"this text ctrl should never receive return" );
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( (m_windowStyle & wxTE_MULTILINE) == 0 )
|
|
||||||
{
|
{
|
||||||
wxWindow* parent = GetParent() ;
|
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
|
||||||
while( parent )
|
event.SetEventObject( this );
|
||||||
{
|
if ( GetEventHandler()->ProcessEvent(event) )
|
||||||
if ( parent->GetDefaultItem() )
|
return;
|
||||||
{
|
|
||||||
wxButton *defaultBtn = parent->GetDefaultItem() ;
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, defaultBtn->GetId() );
|
|
||||||
event.SetEventObject(defaultBtn);
|
|
||||||
defaultBtn->Command(event);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
parent = parent->GetParent() ;
|
|
||||||
} ;
|
|
||||||
}
|
}
|
||||||
|
//else: multiline controls need Enter for themselves
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
// only produce navigation event if we don't process TAB ourself or
|
// always produce navigation event - even if we process TAB
|
||||||
// if it's a Shift-Tab keypress (we assume nobody will ever need
|
// ourselves the fact that we got here means that the user code
|
||||||
// this key combo for himself)
|
// decided to skip processing of this TAB - probably to let it
|
||||||
|
// do its default job.
|
||||||
//
|
//
|
||||||
// NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
|
// NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
|
||||||
// handled by Windows
|
// handled by Windows
|
||||||
if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) )
|
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent eventNav;
|
wxNavigationKeyEvent eventNav;
|
||||||
eventNav.SetDirection(!event.ShiftDown());
|
eventNav.SetDirection(!event.ShiftDown());
|
||||||
eventNav.SetWindowChange(FALSE);
|
eventNav.SetWindowChange(FALSE);
|
||||||
eventNav.SetEventObject(this);
|
eventNav.SetEventObject(this);
|
||||||
|
|
||||||
if ( GetEventHandler()->ProcessEvent(eventNav) )
|
if ( GetEventHandler()->ProcessEvent(eventNav) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
event.Skip();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if ( handleIt )
|
|
||||||
{
|
// don't just call event.Skip() because this will cause TABs and ENTERs
|
||||||
EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
|
// be passed upwards and we don't always want this - instead process it
|
||||||
short keycode ;
|
// right here
|
||||||
short keychar ;
|
|
||||||
keychar = short(ev->message & charCodeMask);
|
// FIXME
|
||||||
keycode = short(ev->message & keyCodeMask) >> 8 ;
|
event.Skip();
|
||||||
UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ;
|
|
||||||
if ( keychar >= 0x20 )
|
|
||||||
{
|
|
||||||
{
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
|
|
||||||
wxString val(GetValue());
|
|
||||||
if ( !val.IsNull() )
|
|
||||||
event.m_commandString = WXSTRINGCAST val;
|
|
||||||
event.SetEventObject( this );
|
|
||||||
ProcessCommand(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// The streambuf code was partly taken from chapter 3 by Jerry Schwarz of
|
// The streambuf code was partly taken from chapter 3 by Jerry Schwarz of
|
||||||
// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
|
// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
|
||||||
|
@@ -1,71 +1,146 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: thread.cpp
|
// Name: thread.cpp
|
||||||
// Purpose: wxThread Implementation. For Unix ports, see e.g. src/gtk
|
// Purpose: wxThread Implementation
|
||||||
// Author: Original from Wolfram Gloger/Guilhem Lavaux
|
// Author: Original from Wolfram Gloger/Guilhem Lavaux
|
||||||
// Modified by:
|
// Modified by: Vadim Zeitlin to make it work :-)
|
||||||
// Created: 04/22/98
|
// Created: 04/22/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
|
// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998),
|
||||||
|
// Vadim Zeitlin (1999)
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "thread.h"
|
#pragma implementation "thread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/module.h"
|
// ----------------------------------------------------------------------------
|
||||||
#include "wx/thread.h"
|
// headers
|
||||||
#include "wx/utils.h"
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
enum thread_state {
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
STATE_IDLE = 0,
|
#include "wx/wxprec.h"
|
||||||
STATE_RUNNING,
|
|
||||||
STATE_CANCELED,
|
#if defined(__BORLANDC__)
|
||||||
STATE_EXITED
|
#pragma hdrstop
|
||||||
};
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
#include <stdio.h>
|
||||||
// Static variables
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
wxMutex *wxMainMutex; // controls access to all GUI functions
|
#include <windows.h>
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
#include "wx/module.h"
|
||||||
// Windows implementation
|
#include "wx/thread.h"
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class wxMutexInternal {
|
// 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
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// static variables
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// if it's FALSE, some secondary thread is holding the GUI lock
|
||||||
|
static bool s_bGuiOwnedByMainThread = TRUE;
|
||||||
|
|
||||||
|
// critical section which controls access to all GUI functions: any secondary
|
||||||
|
// thread (i.e. except the main one) must enter this crit section before doing
|
||||||
|
// any GUI calls
|
||||||
|
static wxCriticalSection *s_critsectGui = NULL;
|
||||||
|
|
||||||
|
// critical section which protects s_nWaitingForGui variable
|
||||||
|
static wxCriticalSection *s_critsectWaitingForGui = NULL;
|
||||||
|
|
||||||
|
// number of threads waiting for GUI in wxMutexGuiEnter()
|
||||||
|
static size_t s_nWaitingForGui = 0;
|
||||||
|
|
||||||
|
// are we waiting for a thread termination?
|
||||||
|
static bool s_waitingForThread = FALSE;
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// Windows implementation of thread classes
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxMutex implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
class wxMutexInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO: internal mutex handle
|
Handle p_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxMutex::wxMutex()
|
wxMutex::wxMutex()
|
||||||
{
|
{
|
||||||
p_internal = new wxMutexInternal;
|
p_internal = new wxMutexInternal;
|
||||||
// TODO: create internal mutext handle
|
// p_internal->p_mutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
|
if ( !p_internal->p_mutex )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not create mutex."));
|
||||||
|
}
|
||||||
|
|
||||||
m_locked = 0;
|
m_locked = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutex::~wxMutex()
|
wxMutex::~wxMutex()
|
||||||
{
|
{
|
||||||
if (m_locked > 0)
|
if (m_locked > 0)
|
||||||
wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked);
|
wxLogDebug(wxT("Warning: freeing a locked mutex (%d locks)."), m_locked);
|
||||||
// TODO: free internal mutext handle
|
// CloseHandle(p_internal->p_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutexError wxMutex::Lock()
|
wxMutexError wxMutex::Lock()
|
||||||
{
|
{
|
||||||
// TODO
|
/*
|
||||||
|
DWORD ret;
|
||||||
|
|
||||||
|
ret = WaitForSingleObject(p_internal->p_mutex, INFINITE);
|
||||||
|
switch ( ret )
|
||||||
|
{
|
||||||
|
case WAIT_ABANDONED:
|
||||||
|
return wxMUTEX_BUSY;
|
||||||
|
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
// ok
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAIT_FAILED:
|
||||||
|
wxLogSysError(_("Couldn't acquire a mutex lock"));
|
||||||
|
return wxMUTEX_MISC_ERROR;
|
||||||
|
|
||||||
|
case WAIT_TIMEOUT:
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(wxT("impossible return value in wxMutex::Lock"));
|
||||||
|
}
|
||||||
|
*/
|
||||||
m_locked++;
|
m_locked++;
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutexError wxMutex::TryLock()
|
wxMutexError wxMutex::TryLock()
|
||||||
{
|
{
|
||||||
// TODO
|
/*
|
||||||
|
DWORD ret;
|
||||||
|
|
||||||
|
ret = WaitForSingleObject(p_internal->p_mutex, 0);
|
||||||
|
if (ret == WAIT_TIMEOUT || ret == WAIT_ABANDONED)
|
||||||
|
return wxMUTEX_BUSY;
|
||||||
|
|
||||||
m_locked++;
|
m_locked++;
|
||||||
|
*/
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,192 +148,715 @@ wxMutexError wxMutex::Unlock()
|
|||||||
{
|
{
|
||||||
if (m_locked > 0)
|
if (m_locked > 0)
|
||||||
m_locked--;
|
m_locked--;
|
||||||
|
/*
|
||||||
// TODO
|
BOOL ret = ReleaseMutex(p_internal->p_mutex);
|
||||||
|
if ( ret == 0 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Couldn't release a mutex"));
|
||||||
|
return wxMUTEX_MISC_ERROR;
|
||||||
|
}
|
||||||
|
*/
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
class wxConditionInternal {
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxCondition implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxConditionInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO: internal handle
|
Handle event;
|
||||||
int waiters;
|
int waiters;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxCondition::wxCondition()
|
wxCondition::wxCondition()
|
||||||
{
|
{
|
||||||
p_internal = new wxConditionInternal;
|
p_internal = new wxConditionInternal;
|
||||||
// TODO: create internal handle
|
// p_internal->event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
if ( !p_internal->event )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not create event object."));
|
||||||
|
}
|
||||||
|
|
||||||
p_internal->waiters = 0;
|
p_internal->waiters = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCondition::~wxCondition()
|
wxCondition::~wxCondition()
|
||||||
{
|
{
|
||||||
// TODO: destroy internal handle
|
// CloseHandle(p_internal->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Wait(wxMutex& mutex)
|
void wxCondition::Wait(wxMutex& mutex)
|
||||||
{
|
{
|
||||||
mutex.Unlock();
|
mutex.Unlock();
|
||||||
p_internal->waiters++;
|
p_internal->waiters++;
|
||||||
// TODO wait here
|
// WaitForSingleObject(p_internal->event, INFINITE);
|
||||||
p_internal->waiters--;
|
p_internal->waiters--;
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxCondition::Wait(wxMutex& mutex, unsigned long sec,
|
bool wxCondition::Wait(wxMutex& mutex,
|
||||||
|
unsigned long sec,
|
||||||
unsigned long nsec)
|
unsigned long nsec)
|
||||||
{
|
{
|
||||||
|
// DWORD ret;
|
||||||
|
|
||||||
mutex.Unlock();
|
mutex.Unlock();
|
||||||
p_internal->waiters++;
|
p_internal->waiters++;
|
||||||
|
// ret = WaitForSingleObject(p_internal->event, (sec*1000)+(nsec/1000000));
|
||||||
// TODO wait here
|
|
||||||
p_internal->waiters--;
|
p_internal->waiters--;
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
|
|
||||||
return FALSE;
|
return TRUE; // false for timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Signal()
|
void wxCondition::Signal()
|
||||||
{
|
{
|
||||||
// TODO
|
// SetEvent(p_internal->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Broadcast()
|
void wxCondition::Broadcast()
|
||||||
{
|
{
|
||||||
// TODO
|
int i;
|
||||||
|
|
||||||
|
for (i=0;i<p_internal->waiters;i++)
|
||||||
|
{
|
||||||
|
// if ( SetEvent(p_internal->event) == 0 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Couldn't change the state of event object."));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class wxThreadInternal {
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxCriticalSection implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxCriticalSectionInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO
|
// init the critical section object
|
||||||
|
wxCriticalSectionInternal()
|
||||||
|
{ /* ::InitializeCriticalSection(&m_data);*/ }
|
||||||
|
|
||||||
|
// implicit cast to the associated data
|
||||||
|
operator Handle *() { return &m_data; }
|
||||||
|
|
||||||
|
// free the associated ressources
|
||||||
|
~wxCriticalSectionInternal()
|
||||||
|
{ /* ::DeleteCriticalSection(&m_data); */}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Handle m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxCriticalSection::wxCriticalSection()
|
||||||
|
{
|
||||||
|
m_critsect = new wxCriticalSectionInternal;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCriticalSection::~wxCriticalSection()
|
||||||
|
{
|
||||||
|
delete m_critsect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxCriticalSection::Enter()
|
||||||
|
{
|
||||||
|
// ::EnterCriticalSection(*m_critsect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxCriticalSection::Leave()
|
||||||
|
{
|
||||||
|
// ::LeaveCriticalSection(*m_critsect);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxThread implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// wxThreadInternal class
|
||||||
|
// ----------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
class wxThreadInternal
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxThreadInternal()
|
||||||
|
{
|
||||||
|
m_hThread = 0;
|
||||||
|
m_state = STATE_NEW;
|
||||||
|
m_priority = WXTHREAD_DEFAULT_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a new (suspended) thread (for the given thread object)
|
||||||
|
bool Create(wxThread *thread);
|
||||||
|
|
||||||
|
// 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) { m_priority = priority; }
|
||||||
|
unsigned int GetPriority() const { return m_priority; }
|
||||||
|
|
||||||
|
// thread handle and id
|
||||||
|
HANDLE GetHandle() const { return m_hThread; }
|
||||||
|
DWORD GetId() const { return m_tid; }
|
||||||
|
|
||||||
|
// thread function
|
||||||
|
static DWORD WinThreadStart(wxThread *thread);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Handle m_hThread; // handle of the thread
|
||||||
|
wxThreadState m_state; // state, see wxThreadState enum
|
||||||
|
unsigned int m_priority; // thread priority in "wx" units
|
||||||
|
ThreadId m_tid; // thread id
|
||||||
|
};
|
||||||
|
|
||||||
|
DWORD wxThreadInternal::WinThreadStart(wxThread *thread)
|
||||||
|
{
|
||||||
|
// store the thread object in the TLS
|
||||||
|
if ( !::TlsSetValue(s_tlsThisThread, thread) )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not start thread: error writing TLS."));
|
||||||
|
|
||||||
|
return (DWORD)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD ret = (DWORD)thread->Entry();
|
||||||
|
thread->p_internal->SetState(STATE_EXITED);
|
||||||
|
thread->OnExit();
|
||||||
|
|
||||||
|
delete thread;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThreadInternal::Create(wxThread *thread)
|
||||||
|
{
|
||||||
|
m_hThread = ::CreateThread
|
||||||
|
(
|
||||||
|
NULL, // default security
|
||||||
|
0, // default stack size
|
||||||
|
(LPTHREAD_START_ROUTINE) // thread entry point
|
||||||
|
wxThreadInternal::WinThreadStart, //
|
||||||
|
(LPVOID)thread, // parameter
|
||||||
|
CREATE_SUSPENDED, // flags
|
||||||
|
&m_tid // [out] thread id
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( m_hThread == NULL )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can't create thread"));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// translate wxWindows priority to the Windows one
|
||||||
|
int win_priority;
|
||||||
|
if (m_priority <= 20)
|
||||||
|
win_priority = THREAD_PRIORITY_LOWEST;
|
||||||
|
else if (m_priority <= 40)
|
||||||
|
win_priority = THREAD_PRIORITY_BELOW_NORMAL;
|
||||||
|
else if (m_priority <= 60)
|
||||||
|
win_priority = THREAD_PRIORITY_NORMAL;
|
||||||
|
else if (m_priority <= 80)
|
||||||
|
win_priority = THREAD_PRIORITY_ABOVE_NORMAL;
|
||||||
|
else if (m_priority <= 100)
|
||||||
|
win_priority = THREAD_PRIORITY_HIGHEST;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxFAIL_MSG(wxT("invalid value of thread priority parameter"));
|
||||||
|
win_priority = THREAD_PRIORITY_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ::SetThreadPriority(m_hThread, win_priority) == 0 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can't set thread priority"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThreadInternal::Suspend()
|
||||||
|
{
|
||||||
|
DWORD nSuspendCount = ::SuspendThread(m_hThread);
|
||||||
|
if ( nSuspendCount == (DWORD)-1 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not suspend thread %x"), m_hThread);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_state = STATE_PAUSED;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThreadInternal::Resume()
|
||||||
|
{
|
||||||
|
DWORD nSuspendCount = ::ResumeThread(m_hThread);
|
||||||
|
if ( nSuspendCount == (DWORD)-1 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not resume thread %x"), m_hThread);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_state = STATE_RUNNING;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// static functions
|
||||||
|
// ----------------
|
||||||
|
|
||||||
|
wxThread *wxThread::This()
|
||||||
|
{
|
||||||
|
wxThread *thread = (wxThread *)::TlsGetValue(s_tlsThisThread);
|
||||||
|
|
||||||
|
// be careful, 0 may be a valid return value as well
|
||||||
|
if ( !thread && (::GetLastError() != NO_ERROR) )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Couldn't get the current thread pointer"));
|
||||||
|
|
||||||
|
// return NULL...
|
||||||
|
}
|
||||||
|
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThread::IsMain()
|
||||||
|
{
|
||||||
|
return ::GetCurrentThreadId() == s_idMainThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Yield
|
||||||
|
#undef Yield
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void wxThread::Yield()
|
||||||
|
{
|
||||||
|
// 0 argument to Sleep() is special
|
||||||
|
::Sleep(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxThread::Sleep(unsigned long milliseconds)
|
||||||
|
{
|
||||||
|
::Sleep(milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create/start thread
|
||||||
|
// -------------------
|
||||||
|
|
||||||
wxThreadError wxThread::Create()
|
wxThreadError wxThread::Create()
|
||||||
{
|
{
|
||||||
// TODO
|
if ( !p_internal->Create(this) )
|
||||||
|
return wxTHREAD_NO_RESOURCE;
|
||||||
|
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThreadError wxThread::Destroy()
|
wxThreadError wxThread::Run()
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
return wxTHREAD_NO_ERROR;
|
|
||||||
|
if ( p_internal->GetState() != STATE_NEW )
|
||||||
|
{
|
||||||
|
// actually, it may be almost any state at all, not only STATE_RUNNING
|
||||||
|
return wxTHREAD_RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// suspend/resume thread
|
||||||
|
// ---------------------
|
||||||
|
|
||||||
wxThreadError wxThread::Pause()
|
wxThreadError wxThread::Pause()
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
return wxTHREAD_NO_ERROR;
|
|
||||||
|
return p_internal->Suspend() ? wxTHREAD_NO_ERROR : wxTHREAD_MISC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThreadError wxThread::Resume()
|
wxThreadError wxThread::Resume()
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
|
|
||||||
|
return p_internal->Resume() ? wxTHREAD_NO_ERROR : wxTHREAD_MISC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stopping thread
|
||||||
|
// ---------------
|
||||||
|
|
||||||
|
wxThread::ExitCode wxThread::Delete()
|
||||||
|
{
|
||||||
|
ExitCode rc = 0;
|
||||||
|
|
||||||
|
// Delete() is always safe to call, so consider all possible states
|
||||||
|
if ( IsPaused() )
|
||||||
|
Resume();
|
||||||
|
|
||||||
|
if ( IsRunning() )
|
||||||
|
{
|
||||||
|
if ( IsMain() )
|
||||||
|
{
|
||||||
|
// set flag for wxIsWaitingForThread()
|
||||||
|
s_waitingForThread = TRUE;
|
||||||
|
|
||||||
|
wxBeginBusyCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE hThread;
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
|
|
||||||
|
p_internal->Cancel();
|
||||||
|
hThread = p_internal->GetHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// we can't just wait for the thread to terminate because it might be
|
||||||
|
// calling some GUI functions and so it will never terminate before we
|
||||||
|
// process the Windows messages that result from these functions
|
||||||
|
DWORD result;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
result = ::MsgWaitForMultipleObjects
|
||||||
|
(
|
||||||
|
1, // number of objects to wait for
|
||||||
|
&hThread, // the objects
|
||||||
|
FALSE, // don't wait for all objects
|
||||||
|
INFINITE, // no timeout
|
||||||
|
QS_ALLEVENTS // return as soon as there are any events
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ( result )
|
||||||
|
{
|
||||||
|
case 0xFFFFFFFF:
|
||||||
|
// error
|
||||||
|
wxLogSysError(_("Can not wait for thread termination"));
|
||||||
|
Kill();
|
||||||
|
return (ExitCode)-1;
|
||||||
|
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
// thread we're waiting for terminated
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAIT_OBJECT_0 + 1:
|
||||||
|
// new message arrived, process it
|
||||||
|
if ( !wxTheApp->DoMessage() )
|
||||||
|
{
|
||||||
|
// WM_QUIT received: kill the thread
|
||||||
|
Kill();
|
||||||
|
|
||||||
|
return (ExitCode)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IsMain() )
|
||||||
|
{
|
||||||
|
// give the thread we're waiting for chance to exit
|
||||||
|
// from the GUI call it might have been in
|
||||||
|
if ( (s_nWaitingForGui > 0) && wxGuiOwnedByMainThread() )
|
||||||
|
{
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(wxT("unexpected result of MsgWaitForMultipleObject"));
|
||||||
|
}
|
||||||
|
} while ( result != WAIT_OBJECT_0 );
|
||||||
|
|
||||||
|
if ( IsMain() )
|
||||||
|
{
|
||||||
|
s_waitingForThread = FALSE;
|
||||||
|
|
||||||
|
wxEndBusyCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !::GetExitCodeThread(hThread, (LPDWORD)&rc) )
|
||||||
|
{
|
||||||
|
wxLogLastError("GetExitCodeThread");
|
||||||
|
|
||||||
|
rc = (ExitCode)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxASSERT_MSG( (LPVOID)rc != (LPVOID)STILL_ACTIVE,
|
||||||
|
wxT("thread must be already terminated.") );
|
||||||
|
|
||||||
|
::CloseHandle(hThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxThreadError wxThread::Kill()
|
||||||
|
{
|
||||||
|
if ( !IsRunning() )
|
||||||
|
return wxTHREAD_NOT_RUNNING;
|
||||||
|
|
||||||
|
if ( !::TerminateThread(p_internal->GetHandle(), (DWORD)-1) )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Couldn't terminate thread"));
|
||||||
|
|
||||||
|
return wxTHREAD_MISC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxThread::Exit(void *status)
|
void wxThread::Exit(void *status)
|
||||||
{
|
{
|
||||||
// TODO
|
delete this;
|
||||||
|
|
||||||
|
::ExitThread((DWORD)status);
|
||||||
|
|
||||||
|
wxFAIL_MSG(wxT("Couldn't return from ExitThread()!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxThread::SetPriority(int prio)
|
void wxThread::SetPriority(unsigned int prio)
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
|
|
||||||
|
p_internal->SetPriority(prio);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxThread::GetPriority() const
|
unsigned int wxThread::GetPriority() const
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxThread::DeferDestroy(bool on)
|
return p_internal->GetPriority();
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxThread::TestDestroy()
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void *wxThread::Join()
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return (void*) NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxThread::GetID() const
|
unsigned long wxThread::GetID() const
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is this needed somewhere ?
|
return (unsigned long)p_internal->GetId();
|
||||||
wxThread *wxThread::GetThreadFromID(unsigned long id)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool wxThread::IsAlive() const
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::IsRunning() const
|
bool wxThread::IsRunning() const
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
return FALSE;
|
|
||||||
|
return p_internal->GetState() == STATE_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::IsMain()
|
bool wxThread::IsAlive() const
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
return FALSE;
|
|
||||||
|
return (p_internal->GetState() == STATE_RUNNING) ||
|
||||||
|
(p_internal->GetState() == STATE_PAUSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThread::IsPaused() const
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
|
|
||||||
|
return (p_internal->GetState() == STATE_PAUSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThread::TestDestroy()
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
|
|
||||||
|
return p_internal->GetState() == STATE_CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThread::wxThread()
|
wxThread::wxThread()
|
||||||
{
|
{
|
||||||
p_internal = new wxThreadInternal();
|
p_internal = new wxThreadInternal();
|
||||||
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThread::~wxThread()
|
wxThread::~wxThread()
|
||||||
{
|
{
|
||||||
Destroy();
|
|
||||||
Join();
|
|
||||||
delete p_internal;
|
delete p_internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default callback just joins the thread and throws away the result.
|
// ----------------------------------------------------------------------------
|
||||||
void wxThread::OnExit()
|
// Automatic initialization for thread module
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxThreadModule : public wxModule
|
||||||
{
|
{
|
||||||
Join();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Automatic initialization
|
|
||||||
class wxThreadModule : public wxModule {
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
|
||||||
public:
|
public:
|
||||||
virtual bool OnInit() {
|
virtual bool OnInit();
|
||||||
/* TODO p_mainid = GetCurrentThread(); */
|
virtual void OnExit();
|
||||||
wxMainMutex = new wxMutex();
|
|
||||||
wxMainMutex->Lock();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Global cleanup
|
private:
|
||||||
virtual void OnExit() {
|
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
||||||
wxMainMutex->Unlock();
|
|
||||||
delete wxMainMutex;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
||||||
|
|
||||||
#endif
|
bool wxThreadModule::OnInit()
|
||||||
|
{
|
||||||
|
// allocate TLS index for storing the pointer to the current thread
|
||||||
|
s_tlsThisThread = ::TlsAlloc();
|
||||||
|
if ( s_tlsThisThread == 0xFFFFFFFF )
|
||||||
|
{
|
||||||
|
// in normal circumstances it will only happen if all other
|
||||||
|
// TLS_MINIMUM_AVAILABLE (>= 64) indices are already taken - in other
|
||||||
|
// words, this should never happen
|
||||||
|
wxLogSysError(_("Thread module initialization failed: "
|
||||||
|
"impossible to allocate index in thread "
|
||||||
|
"local storage"));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// main thread doesn't have associated wxThread object, so store 0 in the
|
||||||
|
// TLS instead
|
||||||
|
if ( !::TlsSetValue(s_tlsThisThread, (LPVOID)0) )
|
||||||
|
{
|
||||||
|
::TlsFree(s_tlsThisThread);
|
||||||
|
s_tlsThisThread = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
wxLogSysError(_("Thread module initialization failed: "
|
||||||
|
"can not store value in thread local storage"));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_critsectWaitingForGui = new wxCriticalSection();
|
||||||
|
|
||||||
|
s_critsectGui = new wxCriticalSection();
|
||||||
|
s_critsectGui->Enter();
|
||||||
|
|
||||||
|
// no error return for GetCurrentThreadId()
|
||||||
|
s_idMainThread = ::GetCurrentThreadId();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxThreadModule::OnExit()
|
||||||
|
{
|
||||||
|
if ( !::TlsFree(s_tlsThisThread) )
|
||||||
|
{
|
||||||
|
wxLogLastError("TlsFree failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s_critsectGui )
|
||||||
|
{
|
||||||
|
s_critsectGui->Leave();
|
||||||
|
delete s_critsectGui;
|
||||||
|
s_critsectGui = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDELETE(s_critsectWaitingForGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// under Windows, these functions are implemented usign a critical section and
|
||||||
|
// not a mutex, so the names are a bit confusing
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void WXDLLEXPORT wxMutexGuiEnter()
|
||||||
|
{
|
||||||
|
// this would dead lock everything...
|
||||||
|
wxASSERT_MSG( !wxThread::IsMain(),
|
||||||
|
wxT("main thread doesn't want to block in wxMutexGuiEnter()!") );
|
||||||
|
|
||||||
|
// the order in which we enter the critical sections here is crucial!!
|
||||||
|
|
||||||
|
// set the flag telling to the main thread that we want to do some GUI
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker enter(*s_critsectWaitingForGui);
|
||||||
|
|
||||||
|
s_nWaitingForGui++;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxWakeUpMainThread();
|
||||||
|
|
||||||
|
// now we may block here because the main thread will soon let us in
|
||||||
|
// (during the next iteration of OnIdle())
|
||||||
|
s_critsectGui->Enter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WXDLLEXPORT wxMutexGuiLeave()
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker enter(*s_critsectWaitingForGui);
|
||||||
|
|
||||||
|
if ( wxThread::IsMain() )
|
||||||
|
{
|
||||||
|
s_bGuiOwnedByMainThread = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// decrement the number of waiters now
|
||||||
|
wxASSERT_MSG( s_nWaitingForGui > 0,
|
||||||
|
wxT("calling wxMutexGuiLeave() without entering it first?") );
|
||||||
|
|
||||||
|
s_nWaitingForGui--;
|
||||||
|
|
||||||
|
wxWakeUpMainThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
s_critsectGui->Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WXDLLEXPORT wxMutexGuiLeaveOrEnter()
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( wxThread::IsMain(),
|
||||||
|
wxT("only main thread may call wxMutexGuiLeaveOrEnter()!") );
|
||||||
|
|
||||||
|
wxCriticalSectionLocker enter(*s_critsectWaitingForGui);
|
||||||
|
|
||||||
|
if ( s_nWaitingForGui == 0 )
|
||||||
|
{
|
||||||
|
// no threads are waiting for GUI - so we may acquire the lock without
|
||||||
|
// any danger (but only if we don't already have it)
|
||||||
|
if ( !wxGuiOwnedByMainThread() )
|
||||||
|
{
|
||||||
|
s_critsectGui->Enter();
|
||||||
|
|
||||||
|
s_bGuiOwnedByMainThread = TRUE;
|
||||||
|
}
|
||||||
|
//else: already have it, nothing to do
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// some threads are waiting, release the GUI lock if we have it
|
||||||
|
if ( wxGuiOwnedByMainThread() )
|
||||||
|
{
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
}
|
||||||
|
//else: some other worker thread is doing GUI
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WXDLLEXPORT wxGuiOwnedByMainThread()
|
||||||
|
{
|
||||||
|
return s_bGuiOwnedByMainThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wake up the main thread if it's in ::GetMessage()
|
||||||
|
void WXDLLEXPORT wxWakeUpMainThread()
|
||||||
|
{
|
||||||
|
// sending any message would do - hopefully WM_NULL is harmless enough
|
||||||
|
if ( !::PostThreadMessage(s_idMainThread, WM_NULL, 0, 0) )
|
||||||
|
{
|
||||||
|
// should never happen
|
||||||
|
wxLogLastError("PostThreadMessage(WM_NULL)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WXDLLEXPORT wxIsWaitingForThread()
|
||||||
|
{
|
||||||
|
return s_waitingForThread;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif // wxUSE_THREADS
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -23,11 +23,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
|
||||||
IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool wxOpenClipboard()
|
bool wxOpenClipboard()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -90,26 +85,36 @@ bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
|
|||||||
* Generalized clipboard implementation by Matthew Flatt
|
* Generalized clipboard implementation by Matthew Flatt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
wxClipboard *wxTheClipboard = NULL;
|
|
||||||
|
|
||||||
void wxInitClipboard()
|
|
||||||
{
|
|
||||||
if (!wxTheClipboard)
|
|
||||||
wxTheClipboard = new wxClipboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxClipboard::wxClipboard()
|
wxClipboard::wxClipboard()
|
||||||
{
|
{
|
||||||
clipOwner = NULL;
|
m_clearOnExit = FALSE;
|
||||||
cbString = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxClipboard::~wxClipboard()
|
wxClipboard::~wxClipboard()
|
||||||
{
|
{
|
||||||
if (clipOwner)
|
if ( m_clearOnExit )
|
||||||
clipOwner->BeingReplaced();
|
{
|
||||||
if (cbString)
|
Clear();
|
||||||
delete[] cbString;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxClipboard::Clear()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::Flush()
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::Open()
|
||||||
|
{
|
||||||
|
return wxOpenClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::IsOpened() const
|
||||||
|
{
|
||||||
|
return wxIsClipboardOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int FormatStringToID(char *str)
|
static int FormatStringToID(char *str)
|
||||||
@@ -120,6 +125,129 @@ static int FormatStringToID(char *str)
|
|||||||
return wxRegisterClipboardFormat(str);
|
return wxRegisterClipboardFormat(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::SetData( wxDataObject *data )
|
||||||
|
{
|
||||||
|
(void)wxEmptyClipboard();
|
||||||
|
|
||||||
|
if ( data )
|
||||||
|
return AddData(data);
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::AddData( wxDataObject *data )
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( data, FALSE, wxT("data is invalid") );
|
||||||
|
|
||||||
|
#if wxUSE_DATAOBJ
|
||||||
|
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
|
||||||
|
|
||||||
|
wxDataFormat format = data->GetFormat();
|
||||||
|
|
||||||
|
switch ( format )
|
||||||
|
{
|
||||||
|
case wxDF_TEXT:
|
||||||
|
case wxDF_OEMTEXT:
|
||||||
|
{
|
||||||
|
wxTextDataObject* textDataObject = (wxTextDataObject*) data;
|
||||||
|
wxString str(textDataObject->GetText());
|
||||||
|
return wxSetClipboardData(format, str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
case wxDF_BITMAP:
|
||||||
|
case wxDF_DIB:
|
||||||
|
{
|
||||||
|
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
|
||||||
|
wxBitmap bitmap(bitmapDataObject->GetBitmap());
|
||||||
|
return wxSetClipboardData(data->GetFormat(), &bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if wxUSE_METAFILE
|
||||||
|
case wxDF_METAFILE:
|
||||||
|
{
|
||||||
|
wxMetafileDataObject* metaFileDataObject =
|
||||||
|
(wxMetafileDataObject*) data;
|
||||||
|
wxMetafile metaFile = metaFileDataObject->GetMetafile();
|
||||||
|
return wxSetClipboardData(wxDF_METAFILE, &metaFile,
|
||||||
|
metaFileDataObject->GetWidth(),
|
||||||
|
metaFileDataObject->GetHeight());
|
||||||
|
}
|
||||||
|
#endif // wxUSE_METAFILE
|
||||||
|
|
||||||
|
default:
|
||||||
|
return wxSetClipboardData(data);
|
||||||
|
}
|
||||||
|
#else // !wxUSE_DATAOBJ
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxClipboard::Close()
|
||||||
|
{
|
||||||
|
wxCloseClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::IsSupported( wxDataFormat format )
|
||||||
|
{
|
||||||
|
return wxIsClipboardFormatAvailable(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxClipboard::GetData( wxDataObject& data )
|
||||||
|
{
|
||||||
|
#if wxUSE_DATAOBJ
|
||||||
|
wxCHECK_MSG( wxIsClipboardOpened(), FALSE, wxT("clipboard not open") );
|
||||||
|
|
||||||
|
wxDataFormat format = data.GetFormat();
|
||||||
|
switch ( format )
|
||||||
|
{
|
||||||
|
case wxDF_TEXT:
|
||||||
|
case wxDF_OEMTEXT:
|
||||||
|
{
|
||||||
|
wxTextDataObject& textDataObject = (wxTextDataObject &)data;
|
||||||
|
char* s = (char*)wxGetClipboardData(format);
|
||||||
|
if ( !s )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
textDataObject.SetText(s);
|
||||||
|
delete [] s;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case wxDF_BITMAP:
|
||||||
|
case wxDF_DIB:
|
||||||
|
{
|
||||||
|
wxBitmapDataObject& bitmapDataObject = (wxBitmapDataObject &)data;
|
||||||
|
wxBitmap* bitmap = (wxBitmap *)wxGetClipboardData(data->GetFormat());
|
||||||
|
if ( !bitmap )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
bitmapDataObject.SetBitmap(*bitmap);
|
||||||
|
delete bitmap;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#if wxUSE_METAFILE
|
||||||
|
case wxDF_METAFILE:
|
||||||
|
{
|
||||||
|
wxMetafileDataObject& metaFileDataObject = (wxMetafileDataObject &)data;
|
||||||
|
wxMetafile* metaFile = (wxMetafile *)wxGetClipboardData(wxDF_METAFILE);
|
||||||
|
if ( !metaFile )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
metaFileDataObject.SetMetafile(*metaFile);
|
||||||
|
delete metaFile;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif // wxUSE_METAFILE
|
||||||
|
}
|
||||||
|
#else // !wxUSE_DATAOBJ
|
||||||
|
wxFAIL_MSG( wxT("no clipboard implementation") );
|
||||||
|
#endif
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
/*
|
||||||
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
|
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
|
||||||
{
|
{
|
||||||
bool got_selection;
|
bool got_selection;
|
||||||
@@ -167,7 +295,7 @@ wxClipboardClient *wxClipboard::GetClipboardClient()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxClipboard::SetClipboardString(char *str, long time)
|
void wxClipboard::SetClipboardString(char *str, long time)
|
||||||
{/*
|
{
|
||||||
bool got_selection;
|
bool got_selection;
|
||||||
|
|
||||||
if (clipOwner) {
|
if (clipOwner) {
|
||||||
@@ -193,9 +321,7 @@ void wxClipboard::SetClipboardString(char *str, long time)
|
|||||||
delete[] cbString;
|
delete[] cbString;
|
||||||
cbString = NULL;
|
cbString = NULL;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *wxClipboard::GetClipboardString(long time)
|
char *wxClipboard::GetClipboardString(long time)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
@@ -210,6 +336,7 @@ char *wxClipboard::GetClipboardString(long time)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
|
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
|
||||||
{
|
{
|
||||||
if (clipOwner) {
|
if (clipOwner) {
|
||||||
@@ -233,4 +360,5 @@ char *wxClipboard::GetClipboardData(char *format, long *length, long time)
|
|||||||
return receivedString;
|
return receivedString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@@ -53,7 +53,9 @@ wxControl::wxControl()
|
|||||||
m_macVerticalBorder = 0 ;
|
m_macVerticalBorder = 0 ;
|
||||||
m_backgroundColour = *wxWHITE;
|
m_backgroundColour = *wxWHITE;
|
||||||
m_foregroundColour = *wxBLACK;
|
m_foregroundColour = *wxBLACK;
|
||||||
m_callback = 0;
|
#if WXWIN_COMPATIBILITY
|
||||||
|
m_callback = 0;
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
if ( wxMacLiveScrollbarActionUPP == NULL )
|
if ( wxMacLiveScrollbarActionUPP == NULL )
|
||||||
{
|
{
|
||||||
@@ -63,13 +65,14 @@ wxControl::wxControl()
|
|||||||
|
|
||||||
wxControl::~wxControl()
|
wxControl::~wxControl()
|
||||||
{
|
{
|
||||||
|
m_isBeingDeleted = TRUE;
|
||||||
// If we delete an item, we should initialize the parent panel,
|
// If we delete an item, we should initialize the parent panel,
|
||||||
// because it could now be invalid.
|
// because it could now be invalid.
|
||||||
wxWindow *parent = (wxWindow *)GetParent();
|
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
||||||
if (parent)
|
if ( panel )
|
||||||
{
|
{
|
||||||
if (parent->GetDefaultItem() == (wxButton*) this)
|
if (panel->GetDefaultItem() == (wxButton*) this)
|
||||||
parent->SetDefaultItem(NULL);
|
panel->SetDefaultItem(NULL);
|
||||||
}
|
}
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
@@ -78,13 +81,19 @@ wxControl::~wxControl()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::SetLabel(const wxString& label)
|
void wxControl::SetLabel(const wxString& title)
|
||||||
{
|
{
|
||||||
m_label = label ;
|
m_label = title ;
|
||||||
|
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
Str255 maclabel ;
|
Str255 maclabel ;
|
||||||
|
wxString label ;
|
||||||
|
|
||||||
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
|
label = wxMacMakeMacStringFromPC( title ) ;
|
||||||
|
else
|
||||||
|
label = title ;
|
||||||
|
|
||||||
strcpy( (char*) maclabel , label ) ;
|
strcpy( (char*) maclabel , label ) ;
|
||||||
c2pstr( (char*) maclabel ) ;
|
c2pstr( (char*) maclabel ) ;
|
||||||
@@ -93,56 +102,31 @@ void wxControl::SetLabel(const wxString& label)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxControl::GetLabel() const
|
wxSize wxControl::DoGetBestSize()
|
||||||
{
|
{
|
||||||
return m_label ;
|
return wxSize(20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::ProcessCommand (wxCommandEvent & event)
|
bool wxControl::ProcessCommand (wxCommandEvent & event)
|
||||||
{
|
{
|
||||||
// Tries:
|
// Tries:
|
||||||
// 1) A callback function (to become obsolete)
|
// 1) A callback function (to become obsolete)
|
||||||
// 2) OnCommand, starting at this window and working up parent hierarchy
|
// 2) OnCommand, starting at this window and working up parent hierarchy
|
||||||
// 3) OnCommand then calls ProcessEvent to search the event tables.
|
// 3) OnCommand then calls ProcessEvent to search the event tables.
|
||||||
if (m_callback)
|
#if WXWIN_COMPATIBILITY
|
||||||
|
if ( m_callback )
|
||||||
{
|
{
|
||||||
(void) (*(m_callback)) (*this, event);
|
(void)(*m_callback)(this, event);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
{
|
{
|
||||||
GetEventHandler()->OnCommand(*this, event);
|
return GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::Centre (int direction)
|
|
||||||
{
|
|
||||||
int x, y, width, height, panel_width, panel_height, new_x, new_y;
|
|
||||||
|
|
||||||
wxWindow *parent = (wxWindow *) GetParent ();
|
|
||||||
if (!parent)
|
|
||||||
return;
|
|
||||||
|
|
||||||
parent->GetClientSize (&panel_width, &panel_height);
|
|
||||||
GetSize (&width, &height);
|
|
||||||
GetPosition (&x, &y);
|
|
||||||
|
|
||||||
new_x = x;
|
|
||||||
new_y = y;
|
|
||||||
|
|
||||||
if (direction & wxHORIZONTAL)
|
|
||||||
new_x = (int) ((panel_width - width) / 2);
|
|
||||||
|
|
||||||
if (direction & wxVERTICAL)
|
|
||||||
new_y = (int) ((panel_height - height) / 2);
|
|
||||||
|
|
||||||
SetSize (new_x, new_y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxControl::SetClientSize (int width, int height)
|
|
||||||
{
|
|
||||||
SetSize (-1, -1, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------
|
// ------------------------
|
||||||
wxList *wxWinMacControlList = NULL;
|
wxList *wxWinMacControlList = NULL;
|
||||||
wxControl *wxFindControlFromMacControl(ControlHandle inControl )
|
wxControl *wxFindControlFromMacControl(ControlHandle inControl )
|
||||||
@@ -352,6 +336,7 @@ void wxControl::MacSuperChangedPosition()
|
|||||||
|
|
||||||
void wxControl::MacSuperEnabled( bool enabled )
|
void wxControl::MacSuperEnabled( bool enabled )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
if ( UMAHasAppearance() )
|
if ( UMAHasAppearance() )
|
||||||
@@ -380,10 +365,12 @@ void wxControl::MacSuperEnabled( bool enabled )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wxWindow::MacSuperEnabled( enabled ) ;
|
wxWindow::MacSuperEnabled( enabled ) ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::MacSuperShown( bool show )
|
void wxControl::MacSuperShown( bool show )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if ( m_macControl )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
if ( !show )
|
if ( !show )
|
||||||
@@ -398,6 +385,7 @@ void wxControl::MacSuperShown( bool show )
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxWindow::MacSuperShown( show ) ;
|
wxWindow::MacSuperShown( show ) ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::DoSetSize(int x, int y,
|
void wxControl::DoSetSize(int x, int y,
|
||||||
@@ -503,51 +491,45 @@ void wxControl::DoSetSize(int x, int y,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::DoSetClientSize(int width, int height)
|
|
||||||
{
|
|
||||||
DoSetSize( -1 , -1 , width , height ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxControl::Show(bool show)
|
bool wxControl::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( m_macControl == NULL )
|
if ( !wxWindow::Show( show ) )
|
||||||
return wxWindow::Show( show ) ;
|
return FALSE ;
|
||||||
|
|
||||||
if ( m_macShown == show )
|
if ( m_macControl )
|
||||||
return TRUE ;
|
{
|
||||||
|
if ( show )
|
||||||
if ( show )
|
::UMAShowControl( m_macControl ) ;
|
||||||
::UMAShowControl( m_macControl ) ;
|
else
|
||||||
else
|
::UMAHideControl( m_macControl ) ;
|
||||||
::UMAHideControl( m_macControl ) ;
|
}
|
||||||
|
return TRUE ;
|
||||||
return wxWindow::Show( show ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::Enable(bool enable)
|
bool wxControl::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if ( m_macControl == NULL )
|
if ( !wxWindow::Enable(enable) )
|
||||||
return wxWindow::Enable( enable ) ;
|
return FALSE;
|
||||||
|
|
||||||
if ( m_macEnabled == enable )
|
|
||||||
return ;
|
|
||||||
|
|
||||||
if ( UMAHasAppearance() )
|
if ( m_macControl )
|
||||||
{
|
{
|
||||||
if ( enable )
|
|
||||||
::ActivateControl( m_macControl ) ;
|
if ( UMAHasAppearance() )
|
||||||
|
{
|
||||||
|
if ( enable )
|
||||||
|
::ActivateControl( m_macControl ) ;
|
||||||
|
else
|
||||||
|
::DeactivateControl( m_macControl ) ;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
::DeactivateControl( m_macControl ) ;
|
{
|
||||||
|
if ( enable )
|
||||||
|
::HiliteControl( m_macControl , 0 ) ;
|
||||||
|
else
|
||||||
|
::HiliteControl( m_macControl , 255 ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
return TRUE ;
|
||||||
{
|
|
||||||
if ( enable )
|
|
||||||
::HiliteControl( m_macControl , 0 ) ;
|
|
||||||
else
|
|
||||||
::HiliteControl( m_macControl , 255 ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return wxWindow::Enable( enable ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxControl::Refresh(bool eraseBack, const wxRect *rect)
|
void wxControl::Refresh(bool eraseBack, const wxRect *rect)
|
||||||
@@ -579,9 +561,9 @@ void wxControl::OnPaint(wxPaintEvent& event)
|
|||||||
wxWindow* parent = GetParent() ;
|
wxWindow* parent = GetParent() ;
|
||||||
while ( parent )
|
while ( parent )
|
||||||
{
|
{
|
||||||
if( parent->m_macWindowData )
|
if( parent->MacGetWindowData() )
|
||||||
{
|
{
|
||||||
UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , kThemeBrushDialogBackgroundActive , false ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,13 +578,13 @@ void wxControl::OnPaint(wxPaintEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
UMADrawControl( m_macControl ) ;
|
UMADrawControl( m_macControl ) ;
|
||||||
UMASetThemeWindowBackground( win->m_macWindowData->m_macWindow , win->m_macWindowData->m_macWindowBackgroundTheme , false ) ;
|
UMASetThemeWindowBackground( win->MacGetWindowData()->m_macWindow , win->MacGetWindowData()->m_macWindowBackgroundTheme , false ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxWindow::OnPaint( event ) ;
|
// wxWindow::OnPaint( event ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,7 +108,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
|
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
|
||||||
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
||||||
m_macWindowData->m_macFocus = NULL ;
|
m_macWindowData->m_macFocus = NULL ;
|
||||||
m_macShown = false ;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,10 +126,13 @@ void wxDialog::SetModal(bool flag)
|
|||||||
|
|
||||||
wxDialog::~wxDialog()
|
wxDialog::~wxDialog()
|
||||||
{
|
{
|
||||||
|
m_isBeingDeleted = TRUE ;
|
||||||
wxTopLevelWindows.DeleteObject(this);
|
wxTopLevelWindows.DeleteObject(this);
|
||||||
|
|
||||||
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
|
m_modalShowing = FALSE;
|
||||||
wxModelessWindows.DeleteObject(this);
|
|
||||||
|
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
|
||||||
|
wxModelessWindows.DeleteObject(this);
|
||||||
|
|
||||||
// If this is the last top-level window, exit.
|
// If this is the last top-level window, exit.
|
||||||
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
||||||
@@ -176,37 +178,64 @@ extern bool s_macIsInModalLoop ;
|
|||||||
|
|
||||||
bool wxDialog::Show(bool show)
|
bool wxDialog::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( m_macShown == show )
|
m_isShown = show;
|
||||||
return TRUE ;
|
|
||||||
|
|
||||||
m_macShown = show ;
|
if (show)
|
||||||
|
InitDialog();
|
||||||
|
|
||||||
bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
|
bool modal = ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL) ;
|
||||||
|
|
||||||
|
#if WXGARBAGE_COLLECTION_ON /* MATTHEW: GC */
|
||||||
|
if (!modal)
|
||||||
|
{
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
if (!wxModelessWindows.Find(this))
|
||||||
|
wxModelessWindows.Append(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
wxModelessWindows.DeleteObject(this);
|
||||||
|
}
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
if (!wxTopLevelWindows.Find(this))
|
||||||
|
wxTopLevelWindows.Append(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
wxTopLevelWindows.DeleteObject(this);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( modal )
|
if ( modal )
|
||||||
{
|
{
|
||||||
s_macIsInModalLoop = true ;
|
s_macIsInModalLoop = true ;
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
// if we don't do it, some window might be deleted while we have pointers
|
if (m_modalShowing)
|
||||||
// to them in our disabledWindows list and the program will crash when it
|
{
|
||||||
// will try to reenable them after the modal dialog end
|
// BringWindowToTop((HWND) GetHWND());
|
||||||
wxTheApp->DeletePendingObjects();
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
UMAShowWindow( m_macWindowData->m_macWindow ) ;
|
m_modalShowing = TRUE;
|
||||||
UMASelectWindow( m_macWindowData->m_macWindow ) ;
|
// if we don't do it, some window might be deleted while we have pointers
|
||||||
|
// to them in our disabledWindows list and the program will crash when it
|
||||||
|
// will try to reenable them after the modal dialog end
|
||||||
|
wxTheApp->DeletePendingObjects();
|
||||||
|
|
||||||
if (!wxModalDialogs.Member(this))
|
UMAShowWindow( m_macWindowData->m_macWindow ) ;
|
||||||
wxModalDialogs.Append(this);
|
UMASelectWindow( m_macWindowData->m_macWindow ) ;
|
||||||
|
|
||||||
while (wxModalDialogs.Member(this) )
|
if (!wxModalDialogs.Member(this))
|
||||||
{
|
wxModalDialogs.Append(this);
|
||||||
wxTheApp->MacDoOneEvent() ;
|
|
||||||
}
|
while (wxModalDialogs.Member(this) )
|
||||||
|
{
|
||||||
|
wxTheApp->MacDoOneEvent() ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxModalDialogs.DeleteObject(this);
|
wxModalDialogs.DeleteObject(this);
|
||||||
UMAHideWindow( m_macWindowData->m_macWindow ) ;
|
UMAHideWindow( m_macWindowData->m_macWindow ) ;
|
||||||
}
|
}
|
||||||
s_macIsInModalLoop = false ;
|
s_macIsInModalLoop = false ;
|
||||||
@@ -334,125 +363,3 @@ void wxDialog::Fit()
|
|||||||
wxWindow::Fit();
|
wxWindow::Fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSizer *wxDialog::CreateTextSizer( const wxString &message )
|
|
||||||
{
|
|
||||||
wxBoxSizer *box = new wxBoxSizer( wxVERTICAL );
|
|
||||||
|
|
||||||
// get line height for empty lines
|
|
||||||
int y = 0;
|
|
||||||
wxFont new_font( GetFont() );
|
|
||||||
if (!new_font.Ok()) new_font = *wxSWISS_FONT;
|
|
||||||
GetTextExtent( "H", (int*)NULL, &y, (int*)NULL, (int*)NULL, &new_font );
|
|
||||||
|
|
||||||
wxString line;
|
|
||||||
for (size_t pos = 0; pos < message.Len(); pos++)
|
|
||||||
{
|
|
||||||
if (message[pos] == _T('\n'))
|
|
||||||
{
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s1 = new wxStaticText( this, -1, line );
|
|
||||||
box->Add( s1 );
|
|
||||||
line = _T("");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
box->Add( 5, y );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
line += message[pos];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remaining text behind last '\n'
|
|
||||||
if (!line.IsEmpty())
|
|
||||||
{
|
|
||||||
wxStaticText *s2 = new wxStaticText( this, -1, line );
|
|
||||||
box->Add( s2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxSizer *wxDialog::CreateButtonSizer( long flags )
|
|
||||||
{
|
|
||||||
wxBoxSizer *box = new wxBoxSizer( wxHORIZONTAL );
|
|
||||||
|
|
||||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
|
||||||
int margin = 6;
|
|
||||||
#else
|
|
||||||
int margin = 10;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxButton *ok = (wxButton *) NULL;
|
|
||||||
wxButton *cancel = (wxButton *) NULL;
|
|
||||||
wxButton *yes = (wxButton *) NULL;
|
|
||||||
wxButton *no = (wxButton *) NULL;
|
|
||||||
|
|
||||||
// always show an OK button, unless only YES_NO is given
|
|
||||||
if ((flags & wxYES_NO) == 0) flags = flags | wxOK;
|
|
||||||
|
|
||||||
if (flags & wxYES_NO)
|
|
||||||
{
|
|
||||||
yes = new wxButton( this, wxID_YES, _("Yes") );
|
|
||||||
box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
no = new wxButton( this, wxID_NO, _("No") );
|
|
||||||
box->Add( no, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
} else
|
|
||||||
if (flags & wxYES)
|
|
||||||
{
|
|
||||||
yes = new wxButton( this, wxID_YES, _("Yes") );
|
|
||||||
box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
} else
|
|
||||||
if (flags & wxNO)
|
|
||||||
{
|
|
||||||
no = new wxButton( this, wxID_NO, _("No") );
|
|
||||||
box->Add( no, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & wxOK)
|
|
||||||
{
|
|
||||||
ok = new wxButton( this, wxID_OK, _("OK") );
|
|
||||||
box->Add( ok, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & wxFORWARD)
|
|
||||||
box->Add( new wxButton( this, wxID_FORWARD, _("Forward") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxBACKWARD)
|
|
||||||
box->Add( new wxButton( this, wxID_BACKWARD, _("Backward") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxSETUP)
|
|
||||||
box->Add( new wxButton( this, wxID_SETUP, _("Setup") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxMORE)
|
|
||||||
box->Add( new wxButton( this, wxID_MORE, _("More...") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxHELP)
|
|
||||||
box->Add( new wxButton( this, wxID_HELP, _("Help") ), 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
|
|
||||||
if (flags & wxCANCEL)
|
|
||||||
{
|
|
||||||
cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
|
|
||||||
box->Add( cancel, 0, wxLEFT|wxRIGHT, margin );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((flags & wxNO_DEFAULT) == 0)
|
|
||||||
{
|
|
||||||
if (ok)
|
|
||||||
{
|
|
||||||
ok->SetDefault();
|
|
||||||
ok->SetFocus();
|
|
||||||
}
|
|
||||||
else if (yes)
|
|
||||||
{
|
|
||||||
yes->SetDefault();
|
|
||||||
yes->SetFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
189
src/mac/font.cpp
189
src/mac/font.cpp
@@ -22,39 +22,42 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxFontRefData::wxFontRefData()
|
|
||||||
|
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxFontRefData
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxFontRefData::Init(int pointSize,
|
||||||
|
int family,
|
||||||
|
int style,
|
||||||
|
int weight,
|
||||||
|
bool underlined,
|
||||||
|
const wxString& faceName,
|
||||||
|
wxFontEncoding encoding)
|
||||||
{
|
{
|
||||||
m_style = 0;
|
m_style = style;
|
||||||
m_pointSize = 0;
|
m_pointSize = pointSize;
|
||||||
m_family = 0;
|
m_family = family;
|
||||||
m_style = 0;
|
m_style = style;
|
||||||
m_weight = 0;
|
m_weight = weight;
|
||||||
m_underlined = 0;
|
m_underlined = underlined;
|
||||||
m_faceName = "";
|
m_faceName = faceName;
|
||||||
|
m_encoding = encoding;
|
||||||
|
|
||||||
m_macFontSize = m_pointSize ;
|
m_macFontNum = 0 ;
|
||||||
m_macFontNum = systemFont ;
|
m_macFontSize = 0;
|
||||||
m_macFontStyle = normal ;
|
m_macFontStyle = 0;
|
||||||
}
|
m_fontId = 0;
|
||||||
|
|
||||||
wxFontRefData::wxFontRefData(const wxFontRefData& data)
|
|
||||||
{
|
|
||||||
m_style = data.m_style;
|
|
||||||
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_macFontSize = m_pointSize ;
|
|
||||||
m_macFontNum = systemFont ;
|
|
||||||
m_macFontStyle = normal ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontRefData::~wxFontRefData()
|
wxFontRefData::~wxFontRefData()
|
||||||
{
|
{
|
||||||
// TODO: delete font data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontRefData::MacFindFont()
|
void wxFontRefData::MacFindFont()
|
||||||
@@ -107,31 +110,27 @@ void wxFontRefData::MacFindFont()
|
|||||||
m_macFontSize = m_pointSize ;
|
m_macFontSize = m_pointSize ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont::wxFont()
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxFont
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxFont::Init()
|
||||||
{
|
{
|
||||||
if ( wxTheFontList )
|
if ( wxTheFontList )
|
||||||
wxTheFontList->Append(this);
|
wxTheFontList->Append(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
|
bool wxFont::Create(int pointSize,
|
||||||
{
|
int family,
|
||||||
Create(pointSize, family, style, weight, underlined, faceName);
|
int style,
|
||||||
|
int weight,
|
||||||
if ( wxTheFontList )
|
bool underlined,
|
||||||
wxTheFontList->Append(this);
|
const wxString& faceName,
|
||||||
}
|
wxFontEncoding encoding)
|
||||||
|
|
||||||
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
|
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
m_refData = new wxFontRefData;
|
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||||
|
underlined, faceName, encoding);
|
||||||
M_FONTDATA->m_family = family;
|
|
||||||
M_FONTDATA->m_style = style;
|
|
||||||
M_FONTDATA->m_weight = weight;
|
|
||||||
M_FONTDATA->m_pointSize = pointSize;
|
|
||||||
M_FONTDATA->m_underlined = underlined;
|
|
||||||
M_FONTDATA->m_faceName = faceName;
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
|
|
||||||
@@ -219,78 +218,50 @@ void wxFont::SetUnderlined(bool underlined)
|
|||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFont::GetFamilyString() const
|
// ----------------------------------------------------------------------------
|
||||||
|
// accessors
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int wxFont::GetPointSize() const
|
||||||
{
|
{
|
||||||
wxString fam("");
|
return M_FONTDATA->m_pointSize;
|
||||||
switch (GetFamily())
|
}
|
||||||
{
|
|
||||||
case wxDECORATIVE:
|
int wxFont::GetFamily() const
|
||||||
fam = "wxDECORATIVE";
|
{
|
||||||
break;
|
return M_FONTDATA->m_family;
|
||||||
case wxROMAN:
|
}
|
||||||
fam = "wxROMAN";
|
|
||||||
break;
|
int wxFont::GetFontId() const
|
||||||
case wxSCRIPT:
|
{
|
||||||
fam = "wxSCRIPT";
|
return M_FONTDATA->m_fontId;
|
||||||
break;
|
}
|
||||||
case wxSWISS:
|
|
||||||
fam = "wxSWISS";
|
int wxFont::GetStyle() const
|
||||||
break;
|
{
|
||||||
case wxMODERN:
|
return M_FONTDATA->m_style;
|
||||||
fam = "wxMODERN";
|
}
|
||||||
break;
|
|
||||||
case wxTELETYPE:
|
int wxFont::GetWeight() const
|
||||||
fam = "wxTELETYPE";
|
{
|
||||||
break;
|
return M_FONTDATA->m_weight;
|
||||||
default:
|
}
|
||||||
fam = "wxDEFAULT";
|
|
||||||
break;
|
bool wxFont::GetUnderlined() const
|
||||||
}
|
{
|
||||||
return fam;
|
return M_FONTDATA->m_underlined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* New font system */
|
|
||||||
wxString wxFont::GetFaceName() const
|
wxString wxFont::GetFaceName() const
|
||||||
{
|
{
|
||||||
wxString str("");
|
wxString str;
|
||||||
if (M_FONTDATA)
|
if ( M_FONTDATA )
|
||||||
str = M_FONTDATA->m_faceName ;
|
str = M_FONTDATA->m_faceName ;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxFont::GetStyleString() const
|
wxFontEncoding wxFont::GetEncoding() const
|
||||||
{
|
{
|
||||||
wxString styl("");
|
return M_FONTDATA->m_encoding;
|
||||||
switch (GetStyle())
|
|
||||||
{
|
|
||||||
case wxITALIC:
|
|
||||||
styl = "wxITALIC";
|
|
||||||
break;
|
|
||||||
case wxSLANT:
|
|
||||||
styl = "wxSLANT";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
styl = "wxNORMAL";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return styl;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString wxFont::GetWeightString() const
|
|
||||||
{
|
|
||||||
wxString w("");
|
|
||||||
switch (GetWeight())
|
|
||||||
{
|
|
||||||
case wxBOLD:
|
|
||||||
w = "wxBOLD";
|
|
||||||
break;
|
|
||||||
case wxLIGHT:
|
|
||||||
w = "wxLIGHT";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
w = "wxNORMAL";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,12 +52,10 @@ wxFrame::wxFrame()
|
|||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
m_frameToolBar = NULL ;
|
m_frameToolBar = NULL ;
|
||||||
#endif
|
#endif
|
||||||
m_macShown = false ;
|
|
||||||
// in order to be able to give size events on show
|
// in order to be able to give size events on show
|
||||||
m_frameMenuBar = NULL;
|
m_frameMenuBar = NULL;
|
||||||
m_frameStatusBar = NULL;
|
m_frameStatusBar = NULL;
|
||||||
|
|
||||||
m_windowParent = NULL;
|
|
||||||
m_iconized = FALSE;
|
m_iconized = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +145,6 @@ bool wxFrame::Create(wxWindow *parent,
|
|||||||
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
|
||||||
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
|
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
|
||||||
m_macWindowData->m_macFocus = NULL ;
|
m_macWindowData->m_macFocus = NULL ;
|
||||||
m_macShown = false ;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,57 +106,120 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
wxListBox::~wxListBox()
|
wxListBox::~wxListBox()
|
||||||
{
|
{
|
||||||
// DisposeExtLDEFInfo( m_macList ) ;
|
Free() ;
|
||||||
|
DisposeExtLDEFInfo( m_macList ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetFirstItem(int N)
|
void wxListBox::Free()
|
||||||
|
{
|
||||||
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
if ( m_windowStyle & wxLB_OWNERDRAW )
|
||||||
|
{
|
||||||
|
size_t uiCount = m_aItems.Count();
|
||||||
|
while ( uiCount-- != 0 ) {
|
||||||
|
delete m_aItems[uiCount];
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aItems.Clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
{
|
||||||
|
for ( size_t n = 0; n < (size_t)m_noItems; n++ )
|
||||||
|
{
|
||||||
|
delete GetClientObject(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListBox::DoSetFirstItem(int N)
|
||||||
{
|
{
|
||||||
MacScrollTo( N ) ;
|
MacScrollTo( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetFirstItem(const wxString& s)
|
|
||||||
{
|
|
||||||
MacScrollTo( FindString( s ) ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxListBox::Delete(int N)
|
void wxListBox::Delete(int N)
|
||||||
{
|
{
|
||||||
m_dataArray.Remove( N ) ;
|
wxCHECK_RET( N >= 0 && N < m_noItems,
|
||||||
|
wxT("invalid index in wxListBox::Delete") );
|
||||||
|
|
||||||
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
delete m_aItems[N];
|
||||||
|
m_aItems.Remove(N);
|
||||||
|
#else // !wxUSE_OWNER_DRAWN
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
{
|
||||||
|
delete GetClientObject(N);
|
||||||
|
}
|
||||||
|
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
||||||
m_stringArray.Remove( N ) ;
|
m_stringArray.Remove( N ) ;
|
||||||
m_noItems --;
|
m_noItems --;
|
||||||
|
|
||||||
MacDelete( N ) ;
|
MacDelete( N ) ;
|
||||||
|
SetHorizontalExtent("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Append(const wxString& item)
|
int wxListBox::DoAppend(const wxString& item)
|
||||||
{
|
|
||||||
Append( item , NULL ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxListBox::Append(const wxString& item, char *Client_data)
|
|
||||||
{
|
{
|
||||||
|
int index = m_noItems ;
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
{
|
{
|
||||||
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
|
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_stringArray.Add( item ) ;
|
m_stringArray.Add( item ) ;
|
||||||
m_dataArray.Add( Client_data ) ;
|
m_noItems ++;
|
||||||
m_noItems ++;
|
|
||||||
|
|
||||||
MacAppend( item ) ;
|
MacAppend( item ) ;
|
||||||
|
|
||||||
|
SetHorizontalExtent(item);
|
||||||
|
|
||||||
|
return index ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Set(int n, const wxString *choices, char** clientData)
|
void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
|
||||||
{
|
{
|
||||||
|
MacSetRedraw( false ) ;
|
||||||
Clear() ;
|
Clear() ;
|
||||||
|
int n = choices.GetCount();
|
||||||
|
|
||||||
for( int i = 0 ; i < n ; ++i )
|
for( int i = 0 ; i < n ; ++i )
|
||||||
{
|
{
|
||||||
if ( clientData )
|
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[0] ) ;
|
Append( choices[i] , clientData[0] ) ;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Append( choices[i] ) ;
|
Append( choices[i] ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_OWNER_DRAWN
|
||||||
|
if ( m_windowStyle & wxLB_OWNERDRAW ) {
|
||||||
|
// first delete old items
|
||||||
|
size_t ui = m_aItems.Count();
|
||||||
|
while ( ui-- != 0 ) {
|
||||||
|
delete m_aItems[ui];
|
||||||
|
}
|
||||||
|
m_aItems.Empty();
|
||||||
|
|
||||||
|
// then create new ones
|
||||||
|
for ( ui = 0; ui < (size_t)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& st) const
|
int wxListBox::FindString(const wxString& st) const
|
||||||
@@ -192,10 +255,12 @@ int wxListBox::FindString(const wxString& st) const
|
|||||||
|
|
||||||
void wxListBox::Clear()
|
void wxListBox::Clear()
|
||||||
{
|
{
|
||||||
|
Free();
|
||||||
m_noItems = 0;
|
m_noItems = 0;
|
||||||
m_stringArray.Empty() ;
|
m_stringArray.Empty() ;
|
||||||
m_dataArray.Empty() ;
|
m_dataArray.Empty() ;
|
||||||
MacClear() ;
|
MacClear() ;
|
||||||
|
SetHorizontalExtent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetSelection(int N, bool select)
|
void wxListBox::SetSelection(int N, bool select)
|
||||||
@@ -205,7 +270,7 @@ void wxListBox::SetSelection(int N, bool select)
|
|||||||
MacSetSelection( N , select ) ;
|
MacSetSelection( N , select ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxListBox::Selected(int N) const
|
bool wxListBox::IsSelected(int N) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
|
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
|
||||||
"invalid index in wxListBox::Selected" );
|
"invalid index in wxListBox::Selected" );
|
||||||
@@ -213,28 +278,33 @@ bool wxListBox::Selected(int N) const
|
|||||||
return MacIsSelected( N ) ;
|
return MacIsSelected( N ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::Deselect(int N)
|
void *wxListBox::DoGetItemClientData(int N) const
|
||||||
{
|
|
||||||
wxCHECK_RET( N >= 0 && N < m_noItems,
|
|
||||||
"invalid index in wxListBox::Deselect" );
|
|
||||||
|
|
||||||
SetSelection( N , false ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *wxListBox::GetClientData(int N) const
|
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
|
wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
|
||||||
"invalid index in wxListBox::GetClientData" );
|
"invalid index in wxListBox::GetClientData" );
|
||||||
|
|
||||||
return m_dataArray[N];
|
return (void *)m_dataArray[N];
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetClientData(int N, char *Client_data)
|
void wxListBox::DoSetItemClientData(int N, void *Client_data)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( N >= 0 && N < m_noItems,
|
wxCHECK_RET( N >= 0 && N < m_noItems,
|
||||||
"invalid index in wxListBox::SetClientData" );
|
"invalid index in wxListBox::SetClientData" );
|
||||||
|
|
||||||
m_dataArray[N] = Client_data ;
|
#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
|
||||||
|
m_dataArray[N] = (char*) Client_data ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
|
||||||
|
{
|
||||||
|
DoSetItemClientData(n, clientData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return number of selections and an array of selected integers
|
// Return number of selections and an array of selected integers
|
||||||
@@ -277,8 +347,13 @@ wxString wxListBox::GetString(int N) const
|
|||||||
return m_stringArray[N] ;
|
return m_stringArray[N] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
|
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( pos >= 0 && pos <= m_noItems,
|
||||||
|
wxT("invalid index in wxListBox::InsertItems") );
|
||||||
|
|
||||||
|
int nItems = items.GetCount();
|
||||||
|
|
||||||
for ( int i = 0 ; i < nItems ; i++ )
|
for ( int i = 0 ; i < nItems ; i++ )
|
||||||
{
|
{
|
||||||
m_stringArray.Insert( items[i] , pos + i ) ;
|
m_stringArray.Insert( items[i] , pos + i ) ;
|
||||||
@@ -295,46 +370,11 @@ void wxListBox::SetString(int N, const wxString& s)
|
|||||||
MacSet( N , s ) ;
|
MacSet( N , s ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxListBox::Number () const
|
wxSize wxListBox::DoGetBestSize()
|
||||||
{
|
{
|
||||||
return m_noItems;
|
return wxSize(100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For single selection items only
|
|
||||||
wxString wxListBox::GetStringSelection () const
|
|
||||||
{
|
|
||||||
int sel = GetSelection ();
|
|
||||||
if (sel > -1)
|
|
||||||
{
|
|
||||||
return GetString (sel);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return wxString("");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxListBox::SetStringSelection (const wxString& s, bool flag)
|
|
||||||
{
|
|
||||||
int sel = FindString (s);
|
|
||||||
if (sel > -1)
|
|
||||||
{
|
|
||||||
SetSelection (sel, flag);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxListBox::Command (wxCommandEvent & event)
|
|
||||||
{
|
|
||||||
if (event.m_extraLong)
|
|
||||||
SetSelection (event.m_commandInt);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Deselect (event.m_commandInt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProcessCommand (event);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// list box control implementation
|
// list box control implementation
|
||||||
@@ -484,29 +524,27 @@ void wxListBox::MacSetRedraw( bool doDraw )
|
|||||||
void wxListBox::MacDoClick()
|
void wxListBox::MacDoClick()
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
|
||||||
|
event.SetEventObject( this );
|
||||||
|
|
||||||
wxArrayInt aSelections;
|
wxArrayInt aSelections;
|
||||||
int count = GetSelections(aSelections);
|
int n, count = GetSelections(aSelections);
|
||||||
if ( count > 0 )
|
if ( count > 0 )
|
||||||
{
|
{
|
||||||
event.m_commandInt = aSelections[0] ;
|
event.m_commandInt = aSelections[0] ;
|
||||||
event.m_clientData = GetClientData(event.m_commandInt);
|
if ( HasClientObjectData() )
|
||||||
wxString str(GetString(event.m_commandInt));
|
event.SetClientObject( GetClientObject(n) );
|
||||||
if (str != "")
|
else if ( HasClientUntypedData() )
|
||||||
event.m_commandString = copystring((char *)(const char *)str);
|
event.SetClientData( GetClientData(n) );
|
||||||
|
event.SetString( GetString(n) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ;
|
n = -1;
|
||||||
/*
|
|
||||||
event.m_commandInt = -1 ;
|
|
||||||
event.m_commandString = copystring("") ;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.SetEventObject( this );
|
event.m_commandInt = n;
|
||||||
ProcessCommand(event);
|
|
||||||
if (event.m_commandString)
|
GetEventHandler()->ProcessEvent(event);
|
||||||
delete[] event.m_commandString ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::MacDoDoubleClick()
|
void wxListBox::MacDoDoubleClick()
|
||||||
|
@@ -82,17 +82,7 @@ void wxMDIParentFrame::GetClientSize(int *x, int *y) const
|
|||||||
|
|
||||||
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
|
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
|
||||||
{
|
{
|
||||||
// TODO
|
wxFrame::SetMenuBar( menu_bar ) ;
|
||||||
if (!menu_bar)
|
|
||||||
{
|
|
||||||
m_frameMenuBar = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menu_bar->m_menuBarFrame)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_frameMenuBar = menu_bar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMDIParentFrame::OnSize(wxSizeEvent& event)
|
void wxMDIParentFrame::OnSize(wxSizeEvent& event)
|
||||||
@@ -211,16 +201,7 @@ void wxMDIChildFrame::GetPosition(int *x, int *y) const
|
|||||||
|
|
||||||
void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
|
void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
|
||||||
{
|
{
|
||||||
// TODO
|
return wxFrame::SetMenuBar( menu_bar ) ;
|
||||||
if (!menu_bar)
|
|
||||||
{
|
|
||||||
m_frameMenuBar = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menu_bar->m_menuBarFrame)
|
|
||||||
return;
|
|
||||||
m_frameMenuBar = menu_bar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MDI operations
|
// MDI operations
|
||||||
|
856
src/mac/menu.cpp
856
src/mac/menu.cpp
File diff suppressed because it is too large
Load Diff
@@ -37,24 +37,26 @@
|
|||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
|
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
|
||||||
const wxString& strName, const wxString& strHelp,
|
const wxString& text, const wxString& strHelp,
|
||||||
bool bCheckable,
|
bool bCheckable,
|
||||||
wxMenu *pSubMenu) :
|
wxMenu *pSubMenu)
|
||||||
m_bCheckable(bCheckable),
|
|
||||||
m_strName(strName),
|
|
||||||
m_strHelp(strHelp)
|
|
||||||
{
|
{
|
||||||
wxASSERT( pParentMenu != NULL );
|
wxASSERT( pParentMenu != NULL );
|
||||||
|
|
||||||
m_pParentMenu = pParentMenu;
|
m_parentMenu = pParentMenu;
|
||||||
m_pSubMenu = pSubMenu;
|
m_subMenu = pSubMenu;
|
||||||
m_idItem = id;
|
m_isEnabled = TRUE;
|
||||||
m_bEnabled = TRUE;
|
m_isChecked = FALSE;
|
||||||
|
m_id = id;
|
||||||
|
m_text = text;
|
||||||
|
m_isCheckable = bCheckable;
|
||||||
|
m_help = strHelp;
|
||||||
|
|
||||||
if ( m_strName == "E&xit" ||m_strName == "Exit" )
|
|
||||||
{
|
if ( m_text == "E&xit" ||m_text == "Exit" )
|
||||||
m_strName = "Quit\tCtrl+Q" ;
|
{
|
||||||
}
|
m_text = "Quit\tCtrl+Q" ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuItem::~wxMenuItem()
|
wxMenuItem::~wxMenuItem()
|
||||||
@@ -64,53 +66,57 @@ wxMenuItem::~wxMenuItem()
|
|||||||
// misc
|
// misc
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
// delete the sub menu
|
// delete the sub menu
|
||||||
void wxMenuItem::DeleteSubMenu()
|
void wxMenuItem::DeleteSubMenu()
|
||||||
{
|
{
|
||||||
wxASSERT( m_pSubMenu != NULL );
|
wxASSERT( m_subMenu != NULL );
|
||||||
|
|
||||||
delete m_pSubMenu;
|
delete m_subMenu;
|
||||||
m_pSubMenu = NULL;
|
m_subMenu = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
// change item state
|
// change item state
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
void wxMenuItem::Enable(bool bDoEnable)
|
void wxMenuItem::Enable(bool bDoEnable)
|
||||||
{
|
{
|
||||||
if ( m_bEnabled != bDoEnable ) {
|
if ( m_isEnabled != bDoEnable ) {
|
||||||
if ( m_pSubMenu == NULL )
|
if ( m_subMenu == NULL )
|
||||||
{
|
{
|
||||||
// normal menu item
|
// normal menu item
|
||||||
if ( m_pParentMenu->m_macMenuHandle )
|
if ( m_parentMenu->GetHMenu() )
|
||||||
{
|
{
|
||||||
int index = m_pParentMenu->MacGetIndexFromItem( this ) ;
|
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
||||||
if ( index >= 1 )
|
if ( index >= 1 )
|
||||||
{
|
{
|
||||||
if ( bDoEnable )
|
if ( bDoEnable )
|
||||||
UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
|
UMAEnableMenuItem( m_parentMenu->GetHMenu() , index ) ;
|
||||||
else
|
else
|
||||||
UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
|
UMADisableMenuItem( m_parentMenu->GetHMenu() , index ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// submenu
|
// submenu
|
||||||
if ( m_pParentMenu->m_macMenuHandle )
|
if ( m_parentMenu->GetHMenu() )
|
||||||
{
|
{
|
||||||
int index = m_pParentMenu->MacGetIndexFromItem( this ) ;
|
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
||||||
if ( index >= 1 )
|
if ( index >= 1 )
|
||||||
{
|
{
|
||||||
if ( bDoEnable )
|
if ( bDoEnable )
|
||||||
UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
|
UMAEnableMenuItem( m_parentMenu->GetHMenu() , index ) ;
|
||||||
else
|
else
|
||||||
UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
|
UMADisableMenuItem( m_parentMenu->GetHMenu() , index ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bEnabled = bDoEnable;
|
m_isEnabled = bDoEnable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,18 +124,18 @@ void wxMenuItem::Check(bool bDoCheck)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
|
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
|
||||||
|
|
||||||
if ( m_bChecked != bDoCheck )
|
if ( m_isChecked != bDoCheck )
|
||||||
{
|
{
|
||||||
m_bChecked = bDoCheck;
|
m_isChecked = bDoCheck;
|
||||||
if ( m_pParentMenu->m_macMenuHandle )
|
if ( m_parentMenu->GetHMenu() )
|
||||||
{
|
{
|
||||||
int index = m_pParentMenu->MacGetIndexFromItem( this ) ;
|
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
||||||
if ( index >= 1 )
|
if ( index >= 1 )
|
||||||
{
|
{
|
||||||
if ( bDoCheck )
|
if ( bDoCheck )
|
||||||
::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0x12 ) ; // checkmark
|
::SetItemMark( m_parentMenu->GetHMenu() , index , 0x12 ) ; // checkmark
|
||||||
else
|
else
|
||||||
::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0 ) ; // no mark
|
::SetItemMark( m_parentMenu->GetHMenu() , index , 0 ) ; // no mark
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,82 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: print.cpp
|
|
||||||
// Purpose: Print framework
|
|
||||||
// Author: AUTHOR
|
|
||||||
// Modified by:
|
|
||||||
// Created: ??/??/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) AUTHOR
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "print.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/mac/print.h"
|
|
||||||
#include "wx/mac/printdlg.h"
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPrinter, wxPrinterBase)
|
|
||||||
IMPLEMENT_CLASS(wxPrintPreview, wxPrintPreviewBase)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Printer
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxPrinter::wxPrinter(wxPrintData *data):
|
|
||||||
wxPrinterBase(data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPrinter::~wxPrinter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
|
|
||||||
{
|
|
||||||
// TODO. See wxPostScriptPrinter::Print for hints.
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxPrinter::PrintDialog(wxWindow *parent)
|
|
||||||
{
|
|
||||||
wxPrintDialog dialog(parent, & m_printData);
|
|
||||||
return (dialog.ShowModal() == wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxPrinter::Setup(wxWindow *parent)
|
|
||||||
{
|
|
||||||
wxPrintDialog dialog(parent, & m_printData);
|
|
||||||
dialog.GetPrintData().SetSetupDialog(TRUE);
|
|
||||||
return (dialog.ShowModal() == wxID_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print preview
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxPrintPreview::wxPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data):
|
|
||||||
wxPrintPreviewBase(printout, printoutForPrinting, data)
|
|
||||||
{
|
|
||||||
DetermineScaling();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPrintPreview::~wxPrintPreview()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxPrintPreview::Print(bool interactive)
|
|
||||||
{
|
|
||||||
if (!m_printPrintout)
|
|
||||||
return FALSE;
|
|
||||||
wxPrinter printer(&m_printData);
|
|
||||||
return printer.Print(m_previewFrame, m_printPrintout, interactive);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxPrintPreview::DetermineScaling()
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/object.h"
|
#include "wx/object.h"
|
||||||
#include "wx/mac/printdlg.h"
|
#include "wx/printdlg.h"
|
||||||
#include "wx/dcprint.h"
|
#include "wx/dcprint.h"
|
||||||
|
|
||||||
// Use generic page setup dialog: use your own native one if one exists.
|
// Use generic page setup dialog: use your own native one if one exists.
|
||||||
@@ -24,30 +24,43 @@ IMPLEMENT_DYNAMIC_CLASS(wxPrintDialog, wxDialog)
|
|||||||
IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
|
IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxPrintDialog::wxPrintDialog():
|
wxPrintDialog::wxPrintDialog()
|
||||||
wxDialog()
|
|
||||||
{
|
{
|
||||||
m_dialogParent = NULL;
|
m_dialogParent = NULL;
|
||||||
|
m_printerDC = NULL;
|
||||||
|
m_destroyDC = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data):
|
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* data)
|
||||||
wxDialog()
|
|
||||||
{
|
{
|
||||||
Create(p, data);
|
Create(p, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPrintDialog::Create(wxWindow *p, wxPrintData* 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_dialogParent = p;
|
||||||
|
m_printerDC = NULL;
|
||||||
|
m_destroyDC = TRUE;
|
||||||
|
|
||||||
if ( data )
|
if ( data )
|
||||||
m_printData = *data;
|
m_printDialogData = *data;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPrintDialog::~wxPrintDialog()
|
wxPrintDialog::~wxPrintDialog()
|
||||||
{
|
{
|
||||||
|
if (m_destroyDC && m_printerDC)
|
||||||
|
delete m_printerDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxPrintDialog::ShowModal()
|
int wxPrintDialog::ShowModal()
|
||||||
@@ -60,10 +73,10 @@ int wxPrintDialog::ShowModal()
|
|||||||
|
|
||||||
if ( !err )
|
if ( !err )
|
||||||
{
|
{
|
||||||
m_printData.ConvertToNative() ;
|
m_printDialogData.ConvertToNative() ;
|
||||||
if ( m_printData.macPrintInfo && ::PrJobDialog( m_printData.macPrintInfo ) )
|
if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) )
|
||||||
{
|
{
|
||||||
m_printData.ConvertFromNative() ;
|
m_printDialogData.ConvertFromNative() ;
|
||||||
result = wxID_OK ;
|
result = wxID_OK ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +93,7 @@ int wxPrintDialog::ShowModal()
|
|||||||
|
|
||||||
wxDC *wxPrintDialog::GetPrintDC()
|
wxDC *wxPrintDialog::GetPrintDC()
|
||||||
{
|
{
|
||||||
return new wxPrinterDC( m_printData ) ;
|
return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -67,17 +67,6 @@ wxRadioBox::~wxRadioBox()
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRadioBox::GetLabel(int item) const
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return wxString("");
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxRadioBox::SetLabel(int item, const wxString& label)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxRadioBox::FindString(const wxString& s) const
|
int wxRadioBox::FindString(const wxString& s) const
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
@@ -106,28 +95,28 @@ wxString wxRadioBox::GetString(int n) const
|
|||||||
return wxString("");
|
return wxString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SetSize(int x, int y, int width, int height, int sizeFlags)
|
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
{
|
{
|
||||||
wxControl::SetSize( x , y , width , height , sizeFlags ) ;
|
wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::GetSize(int *width, int *height) const
|
void wxRadioBox::GetSize(int *width, int *height) const
|
||||||
{
|
{
|
||||||
// TODO
|
wxControl::GetSize( width , height ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::GetPosition(int *x, int *y) const
|
void wxRadioBox::GetPosition(int *x, int *y) const
|
||||||
{
|
{
|
||||||
// TODO
|
wxControl::GetPosition( x , y ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRadioBox::GetLabel() const
|
wxString wxRadioBox::GetLabel( int item ) const
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return wxString("");
|
return wxString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SetLabel(const wxString& label)
|
void wxRadioBox::SetLabel(int item , const wxString& label)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@@ -139,23 +128,18 @@ void wxRadioBox::SetFocus()
|
|||||||
|
|
||||||
bool wxRadioBox::Show(bool show)
|
bool wxRadioBox::Show(bool show)
|
||||||
{
|
{
|
||||||
// TODO
|
return wxControl::Show( show ) ;
|
||||||
return wxWindow::Show( show ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable a specific button
|
// Enable a specific button
|
||||||
void wxRadioBox::Enable(int item, bool enable)
|
void wxRadioBox::Enable(int item, bool enable)
|
||||||
{
|
{
|
||||||
wxControl::Enable(enable);
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable all controls
|
// Enable all controls
|
||||||
void wxRadioBox::Enable(bool enable)
|
bool wxRadioBox::Enable(bool enable)
|
||||||
{
|
{
|
||||||
wxControl::Enable(enable);
|
return wxControl::Enable(enable);
|
||||||
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a specific button
|
// Show a specific button
|
||||||
|
@@ -16,15 +16,18 @@
|
|||||||
#include "wx/spinbutt.h"
|
#include "wx/spinbutt.h"
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
// ============================================================================
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
|
// implementation
|
||||||
#endif
|
// ============================================================================
|
||||||
|
|
||||||
wxSpinButton::wxSpinButton()
|
// ----------------------------------------------------------------------------
|
||||||
{
|
// wxWin macros
|
||||||
m_min = 0;
|
// ----------------------------------------------------------------------------
|
||||||
m_max = 100;
|
|
||||||
}
|
#if !USE_SHARED_LIBRARY
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||||
long style, const wxString& name)
|
long style, const wxString& name)
|
||||||
@@ -78,14 +81,6 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
|
|||||||
m_max = maxVal;
|
m_max = maxVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spin event
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
|
|
||||||
|
|
||||||
wxSpinEvent::wxSpinEvent(wxEventType commandType, int id):
|
|
||||||
wxScrollEvent(commandType, id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxSpinButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
void wxSpinButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
|
||||||
{
|
{
|
||||||
if ( m_macControl == NULL )
|
if ( m_macControl == NULL )
|
||||||
|
@@ -47,7 +47,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
void wxStaticText::SetLabel(const wxString& st , bool resize )
|
void wxStaticText::SetLabel(const wxString& st , bool resize )
|
||||||
{
|
{
|
||||||
m_label = st ;
|
SetTitle( st ) ;
|
||||||
wxString label ;
|
wxString label ;
|
||||||
|
|
||||||
if( wxApp::s_macDefaultEncodingIsPC )
|
if( wxApp::s_macDefaultEncodingIsPC )
|
||||||
|
@@ -409,73 +409,51 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
|
|||||||
|
|
||||||
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||||
{
|
{
|
||||||
bool handleIt = true ;
|
|
||||||
switch( event.KeyCode() )
|
switch( event.KeyCode() )
|
||||||
{
|
{
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
{
|
{
|
||||||
/* Oh yes it will, because we also specify DLGC_WANTCHARS
|
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||||
wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER,
|
|
||||||
"this text ctrl should never receive return" );
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( (m_windowStyle & wxTE_MULTILINE) == 0 )
|
|
||||||
{
|
{
|
||||||
wxWindow* parent = GetParent() ;
|
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
|
||||||
while( parent )
|
event.SetEventObject( this );
|
||||||
{
|
if ( GetEventHandler()->ProcessEvent(event) )
|
||||||
if ( parent->GetDefaultItem() )
|
return;
|
||||||
{
|
|
||||||
wxButton *defaultBtn = parent->GetDefaultItem() ;
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, defaultBtn->GetId() );
|
|
||||||
event.SetEventObject(defaultBtn);
|
|
||||||
defaultBtn->Command(event);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
parent = parent->GetParent() ;
|
|
||||||
} ;
|
|
||||||
}
|
}
|
||||||
|
//else: multiline controls need Enter for themselves
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
// only produce navigation event if we don't process TAB ourself or
|
// always produce navigation event - even if we process TAB
|
||||||
// if it's a Shift-Tab keypress (we assume nobody will ever need
|
// ourselves the fact that we got here means that the user code
|
||||||
// this key combo for himself)
|
// decided to skip processing of this TAB - probably to let it
|
||||||
|
// do its default job.
|
||||||
//
|
//
|
||||||
// NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
|
// NB: Notice that Ctrl-Tab is handled elsewhere and Alt-Tab is
|
||||||
// handled by Windows
|
// handled by Windows
|
||||||
if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) )
|
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent eventNav;
|
wxNavigationKeyEvent eventNav;
|
||||||
eventNav.SetDirection(!event.ShiftDown());
|
eventNav.SetDirection(!event.ShiftDown());
|
||||||
eventNav.SetWindowChange(FALSE);
|
eventNav.SetWindowChange(FALSE);
|
||||||
eventNav.SetEventObject(this);
|
eventNav.SetEventObject(this);
|
||||||
|
|
||||||
if ( GetEventHandler()->ProcessEvent(eventNav) )
|
if ( GetEventHandler()->ProcessEvent(eventNav) )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
event.Skip();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if ( handleIt )
|
|
||||||
{
|
// don't just call event.Skip() because this will cause TABs and ENTERs
|
||||||
EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
|
// be passed upwards and we don't always want this - instead process it
|
||||||
short keycode ;
|
// right here
|
||||||
short keychar ;
|
|
||||||
keychar = short(ev->message & charCodeMask);
|
// FIXME
|
||||||
keycode = short(ev->message & keyCodeMask) >> 8 ;
|
event.Skip();
|
||||||
UMAHandleControlKey( m_macControl , keycode , keychar , ev->modifiers ) ;
|
|
||||||
if ( keychar >= 0x20 )
|
|
||||||
{
|
|
||||||
{
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
|
|
||||||
wxString val(GetValue());
|
|
||||||
if ( !val.IsNull() )
|
|
||||||
event.m_commandString = WXSTRINGCAST val;
|
|
||||||
event.SetEventObject( this );
|
|
||||||
ProcessCommand(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// The streambuf code was partly taken from chapter 3 by Jerry Schwarz of
|
// The streambuf code was partly taken from chapter 3 by Jerry Schwarz of
|
||||||
// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
|
// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
|
||||||
|
@@ -1,71 +1,146 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: thread.cpp
|
// Name: thread.cpp
|
||||||
// Purpose: wxThread Implementation. For Unix ports, see e.g. src/gtk
|
// Purpose: wxThread Implementation
|
||||||
// Author: Original from Wolfram Gloger/Guilhem Lavaux
|
// Author: Original from Wolfram Gloger/Guilhem Lavaux
|
||||||
// Modified by:
|
// Modified by: Vadim Zeitlin to make it work :-)
|
||||||
// Created: 04/22/98
|
// Created: 04/22/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998)
|
// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998),
|
||||||
|
// Vadim Zeitlin (1999)
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "thread.h"
|
#pragma implementation "thread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/module.h"
|
// ----------------------------------------------------------------------------
|
||||||
#include "wx/thread.h"
|
// headers
|
||||||
#include "wx/utils.h"
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
enum thread_state {
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
STATE_IDLE = 0,
|
#include "wx/wxprec.h"
|
||||||
STATE_RUNNING,
|
|
||||||
STATE_CANCELED,
|
#if defined(__BORLANDC__)
|
||||||
STATE_EXITED
|
#pragma hdrstop
|
||||||
};
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
#include <stdio.h>
|
||||||
// Static variables
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
wxMutex *wxMainMutex; // controls access to all GUI functions
|
#include <windows.h>
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
#include "wx/module.h"
|
||||||
// Windows implementation
|
#include "wx/thread.h"
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class wxMutexInternal {
|
// 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
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// static variables
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// if it's FALSE, some secondary thread is holding the GUI lock
|
||||||
|
static bool s_bGuiOwnedByMainThread = TRUE;
|
||||||
|
|
||||||
|
// critical section which controls access to all GUI functions: any secondary
|
||||||
|
// thread (i.e. except the main one) must enter this crit section before doing
|
||||||
|
// any GUI calls
|
||||||
|
static wxCriticalSection *s_critsectGui = NULL;
|
||||||
|
|
||||||
|
// critical section which protects s_nWaitingForGui variable
|
||||||
|
static wxCriticalSection *s_critsectWaitingForGui = NULL;
|
||||||
|
|
||||||
|
// number of threads waiting for GUI in wxMutexGuiEnter()
|
||||||
|
static size_t s_nWaitingForGui = 0;
|
||||||
|
|
||||||
|
// are we waiting for a thread termination?
|
||||||
|
static bool s_waitingForThread = FALSE;
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// Windows implementation of thread classes
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxMutex implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
class wxMutexInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO: internal mutex handle
|
Handle p_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxMutex::wxMutex()
|
wxMutex::wxMutex()
|
||||||
{
|
{
|
||||||
p_internal = new wxMutexInternal;
|
p_internal = new wxMutexInternal;
|
||||||
// TODO: create internal mutext handle
|
// p_internal->p_mutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
|
if ( !p_internal->p_mutex )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not create mutex."));
|
||||||
|
}
|
||||||
|
|
||||||
m_locked = 0;
|
m_locked = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutex::~wxMutex()
|
wxMutex::~wxMutex()
|
||||||
{
|
{
|
||||||
if (m_locked > 0)
|
if (m_locked > 0)
|
||||||
wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked);
|
wxLogDebug(wxT("Warning: freeing a locked mutex (%d locks)."), m_locked);
|
||||||
// TODO: free internal mutext handle
|
// CloseHandle(p_internal->p_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutexError wxMutex::Lock()
|
wxMutexError wxMutex::Lock()
|
||||||
{
|
{
|
||||||
// TODO
|
/*
|
||||||
|
DWORD ret;
|
||||||
|
|
||||||
|
ret = WaitForSingleObject(p_internal->p_mutex, INFINITE);
|
||||||
|
switch ( ret )
|
||||||
|
{
|
||||||
|
case WAIT_ABANDONED:
|
||||||
|
return wxMUTEX_BUSY;
|
||||||
|
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
// ok
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAIT_FAILED:
|
||||||
|
wxLogSysError(_("Couldn't acquire a mutex lock"));
|
||||||
|
return wxMUTEX_MISC_ERROR;
|
||||||
|
|
||||||
|
case WAIT_TIMEOUT:
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(wxT("impossible return value in wxMutex::Lock"));
|
||||||
|
}
|
||||||
|
*/
|
||||||
m_locked++;
|
m_locked++;
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMutexError wxMutex::TryLock()
|
wxMutexError wxMutex::TryLock()
|
||||||
{
|
{
|
||||||
// TODO
|
/*
|
||||||
|
DWORD ret;
|
||||||
|
|
||||||
|
ret = WaitForSingleObject(p_internal->p_mutex, 0);
|
||||||
|
if (ret == WAIT_TIMEOUT || ret == WAIT_ABANDONED)
|
||||||
|
return wxMUTEX_BUSY;
|
||||||
|
|
||||||
m_locked++;
|
m_locked++;
|
||||||
|
*/
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,192 +148,715 @@ wxMutexError wxMutex::Unlock()
|
|||||||
{
|
{
|
||||||
if (m_locked > 0)
|
if (m_locked > 0)
|
||||||
m_locked--;
|
m_locked--;
|
||||||
|
/*
|
||||||
// TODO
|
BOOL ret = ReleaseMutex(p_internal->p_mutex);
|
||||||
|
if ( ret == 0 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Couldn't release a mutex"));
|
||||||
|
return wxMUTEX_MISC_ERROR;
|
||||||
|
}
|
||||||
|
*/
|
||||||
return wxMUTEX_NO_ERROR;
|
return wxMUTEX_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
class wxConditionInternal {
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxCondition implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxConditionInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO: internal handle
|
Handle event;
|
||||||
int waiters;
|
int waiters;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxCondition::wxCondition()
|
wxCondition::wxCondition()
|
||||||
{
|
{
|
||||||
p_internal = new wxConditionInternal;
|
p_internal = new wxConditionInternal;
|
||||||
// TODO: create internal handle
|
// p_internal->event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
if ( !p_internal->event )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not create event object."));
|
||||||
|
}
|
||||||
|
|
||||||
p_internal->waiters = 0;
|
p_internal->waiters = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCondition::~wxCondition()
|
wxCondition::~wxCondition()
|
||||||
{
|
{
|
||||||
// TODO: destroy internal handle
|
// CloseHandle(p_internal->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Wait(wxMutex& mutex)
|
void wxCondition::Wait(wxMutex& mutex)
|
||||||
{
|
{
|
||||||
mutex.Unlock();
|
mutex.Unlock();
|
||||||
p_internal->waiters++;
|
p_internal->waiters++;
|
||||||
// TODO wait here
|
// WaitForSingleObject(p_internal->event, INFINITE);
|
||||||
p_internal->waiters--;
|
p_internal->waiters--;
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxCondition::Wait(wxMutex& mutex, unsigned long sec,
|
bool wxCondition::Wait(wxMutex& mutex,
|
||||||
|
unsigned long sec,
|
||||||
unsigned long nsec)
|
unsigned long nsec)
|
||||||
{
|
{
|
||||||
|
// DWORD ret;
|
||||||
|
|
||||||
mutex.Unlock();
|
mutex.Unlock();
|
||||||
p_internal->waiters++;
|
p_internal->waiters++;
|
||||||
|
// ret = WaitForSingleObject(p_internal->event, (sec*1000)+(nsec/1000000));
|
||||||
// TODO wait here
|
|
||||||
p_internal->waiters--;
|
p_internal->waiters--;
|
||||||
mutex.Lock();
|
mutex.Lock();
|
||||||
|
|
||||||
return FALSE;
|
return TRUE; // false for timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Signal()
|
void wxCondition::Signal()
|
||||||
{
|
{
|
||||||
// TODO
|
// SetEvent(p_internal->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCondition::Broadcast()
|
void wxCondition::Broadcast()
|
||||||
{
|
{
|
||||||
// TODO
|
int i;
|
||||||
|
|
||||||
|
for (i=0;i<p_internal->waiters;i++)
|
||||||
|
{
|
||||||
|
// if ( SetEvent(p_internal->event) == 0 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Couldn't change the state of event object."));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class wxThreadInternal {
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxCriticalSection implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxCriticalSectionInternal
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
// TODO
|
// init the critical section object
|
||||||
|
wxCriticalSectionInternal()
|
||||||
|
{ /* ::InitializeCriticalSection(&m_data);*/ }
|
||||||
|
|
||||||
|
// implicit cast to the associated data
|
||||||
|
operator Handle *() { return &m_data; }
|
||||||
|
|
||||||
|
// free the associated ressources
|
||||||
|
~wxCriticalSectionInternal()
|
||||||
|
{ /* ::DeleteCriticalSection(&m_data); */}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Handle m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxCriticalSection::wxCriticalSection()
|
||||||
|
{
|
||||||
|
m_critsect = new wxCriticalSectionInternal;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCriticalSection::~wxCriticalSection()
|
||||||
|
{
|
||||||
|
delete m_critsect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxCriticalSection::Enter()
|
||||||
|
{
|
||||||
|
// ::EnterCriticalSection(*m_critsect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxCriticalSection::Leave()
|
||||||
|
{
|
||||||
|
// ::LeaveCriticalSection(*m_critsect);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxThread implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// wxThreadInternal class
|
||||||
|
// ----------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
class wxThreadInternal
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxThreadInternal()
|
||||||
|
{
|
||||||
|
m_hThread = 0;
|
||||||
|
m_state = STATE_NEW;
|
||||||
|
m_priority = WXTHREAD_DEFAULT_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a new (suspended) thread (for the given thread object)
|
||||||
|
bool Create(wxThread *thread);
|
||||||
|
|
||||||
|
// 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) { m_priority = priority; }
|
||||||
|
unsigned int GetPriority() const { return m_priority; }
|
||||||
|
|
||||||
|
// thread handle and id
|
||||||
|
HANDLE GetHandle() const { return m_hThread; }
|
||||||
|
DWORD GetId() const { return m_tid; }
|
||||||
|
|
||||||
|
// thread function
|
||||||
|
static DWORD WinThreadStart(wxThread *thread);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Handle m_hThread; // handle of the thread
|
||||||
|
wxThreadState m_state; // state, see wxThreadState enum
|
||||||
|
unsigned int m_priority; // thread priority in "wx" units
|
||||||
|
ThreadId m_tid; // thread id
|
||||||
|
};
|
||||||
|
|
||||||
|
DWORD wxThreadInternal::WinThreadStart(wxThread *thread)
|
||||||
|
{
|
||||||
|
// store the thread object in the TLS
|
||||||
|
if ( !::TlsSetValue(s_tlsThisThread, thread) )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not start thread: error writing TLS."));
|
||||||
|
|
||||||
|
return (DWORD)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD ret = (DWORD)thread->Entry();
|
||||||
|
thread->p_internal->SetState(STATE_EXITED);
|
||||||
|
thread->OnExit();
|
||||||
|
|
||||||
|
delete thread;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThreadInternal::Create(wxThread *thread)
|
||||||
|
{
|
||||||
|
m_hThread = ::CreateThread
|
||||||
|
(
|
||||||
|
NULL, // default security
|
||||||
|
0, // default stack size
|
||||||
|
(LPTHREAD_START_ROUTINE) // thread entry point
|
||||||
|
wxThreadInternal::WinThreadStart, //
|
||||||
|
(LPVOID)thread, // parameter
|
||||||
|
CREATE_SUSPENDED, // flags
|
||||||
|
&m_tid // [out] thread id
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( m_hThread == NULL )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can't create thread"));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// translate wxWindows priority to the Windows one
|
||||||
|
int win_priority;
|
||||||
|
if (m_priority <= 20)
|
||||||
|
win_priority = THREAD_PRIORITY_LOWEST;
|
||||||
|
else if (m_priority <= 40)
|
||||||
|
win_priority = THREAD_PRIORITY_BELOW_NORMAL;
|
||||||
|
else if (m_priority <= 60)
|
||||||
|
win_priority = THREAD_PRIORITY_NORMAL;
|
||||||
|
else if (m_priority <= 80)
|
||||||
|
win_priority = THREAD_PRIORITY_ABOVE_NORMAL;
|
||||||
|
else if (m_priority <= 100)
|
||||||
|
win_priority = THREAD_PRIORITY_HIGHEST;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxFAIL_MSG(wxT("invalid value of thread priority parameter"));
|
||||||
|
win_priority = THREAD_PRIORITY_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ::SetThreadPriority(m_hThread, win_priority) == 0 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can't set thread priority"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThreadInternal::Suspend()
|
||||||
|
{
|
||||||
|
DWORD nSuspendCount = ::SuspendThread(m_hThread);
|
||||||
|
if ( nSuspendCount == (DWORD)-1 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not suspend thread %x"), m_hThread);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_state = STATE_PAUSED;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThreadInternal::Resume()
|
||||||
|
{
|
||||||
|
DWORD nSuspendCount = ::ResumeThread(m_hThread);
|
||||||
|
if ( nSuspendCount == (DWORD)-1 )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Can not resume thread %x"), m_hThread);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_state = STATE_RUNNING;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// static functions
|
||||||
|
// ----------------
|
||||||
|
|
||||||
|
wxThread *wxThread::This()
|
||||||
|
{
|
||||||
|
wxThread *thread = (wxThread *)::TlsGetValue(s_tlsThisThread);
|
||||||
|
|
||||||
|
// be careful, 0 may be a valid return value as well
|
||||||
|
if ( !thread && (::GetLastError() != NO_ERROR) )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Couldn't get the current thread pointer"));
|
||||||
|
|
||||||
|
// return NULL...
|
||||||
|
}
|
||||||
|
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThread::IsMain()
|
||||||
|
{
|
||||||
|
return ::GetCurrentThreadId() == s_idMainThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Yield
|
||||||
|
#undef Yield
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void wxThread::Yield()
|
||||||
|
{
|
||||||
|
// 0 argument to Sleep() is special
|
||||||
|
::Sleep(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxThread::Sleep(unsigned long milliseconds)
|
||||||
|
{
|
||||||
|
::Sleep(milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// create/start thread
|
||||||
|
// -------------------
|
||||||
|
|
||||||
wxThreadError wxThread::Create()
|
wxThreadError wxThread::Create()
|
||||||
{
|
{
|
||||||
// TODO
|
if ( !p_internal->Create(this) )
|
||||||
|
return wxTHREAD_NO_RESOURCE;
|
||||||
|
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThreadError wxThread::Destroy()
|
wxThreadError wxThread::Run()
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
return wxTHREAD_NO_ERROR;
|
|
||||||
|
if ( p_internal->GetState() != STATE_NEW )
|
||||||
|
{
|
||||||
|
// actually, it may be almost any state at all, not only STATE_RUNNING
|
||||||
|
return wxTHREAD_RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// suspend/resume thread
|
||||||
|
// ---------------------
|
||||||
|
|
||||||
wxThreadError wxThread::Pause()
|
wxThreadError wxThread::Pause()
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
return wxTHREAD_NO_ERROR;
|
|
||||||
|
return p_internal->Suspend() ? wxTHREAD_NO_ERROR : wxTHREAD_MISC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThreadError wxThread::Resume()
|
wxThreadError wxThread::Resume()
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
|
|
||||||
|
return p_internal->Resume() ? wxTHREAD_NO_ERROR : wxTHREAD_MISC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stopping thread
|
||||||
|
// ---------------
|
||||||
|
|
||||||
|
wxThread::ExitCode wxThread::Delete()
|
||||||
|
{
|
||||||
|
ExitCode rc = 0;
|
||||||
|
|
||||||
|
// Delete() is always safe to call, so consider all possible states
|
||||||
|
if ( IsPaused() )
|
||||||
|
Resume();
|
||||||
|
|
||||||
|
if ( IsRunning() )
|
||||||
|
{
|
||||||
|
if ( IsMain() )
|
||||||
|
{
|
||||||
|
// set flag for wxIsWaitingForThread()
|
||||||
|
s_waitingForThread = TRUE;
|
||||||
|
|
||||||
|
wxBeginBusyCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
HANDLE hThread;
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
|
|
||||||
|
p_internal->Cancel();
|
||||||
|
hThread = p_internal->GetHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// we can't just wait for the thread to terminate because it might be
|
||||||
|
// calling some GUI functions and so it will never terminate before we
|
||||||
|
// process the Windows messages that result from these functions
|
||||||
|
DWORD result;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
result = ::MsgWaitForMultipleObjects
|
||||||
|
(
|
||||||
|
1, // number of objects to wait for
|
||||||
|
&hThread, // the objects
|
||||||
|
FALSE, // don't wait for all objects
|
||||||
|
INFINITE, // no timeout
|
||||||
|
QS_ALLEVENTS // return as soon as there are any events
|
||||||
|
);
|
||||||
|
|
||||||
|
switch ( result )
|
||||||
|
{
|
||||||
|
case 0xFFFFFFFF:
|
||||||
|
// error
|
||||||
|
wxLogSysError(_("Can not wait for thread termination"));
|
||||||
|
Kill();
|
||||||
|
return (ExitCode)-1;
|
||||||
|
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
|
// thread we're waiting for terminated
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WAIT_OBJECT_0 + 1:
|
||||||
|
// new message arrived, process it
|
||||||
|
if ( !wxTheApp->DoMessage() )
|
||||||
|
{
|
||||||
|
// WM_QUIT received: kill the thread
|
||||||
|
Kill();
|
||||||
|
|
||||||
|
return (ExitCode)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IsMain() )
|
||||||
|
{
|
||||||
|
// give the thread we're waiting for chance to exit
|
||||||
|
// from the GUI call it might have been in
|
||||||
|
if ( (s_nWaitingForGui > 0) && wxGuiOwnedByMainThread() )
|
||||||
|
{
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(wxT("unexpected result of MsgWaitForMultipleObject"));
|
||||||
|
}
|
||||||
|
} while ( result != WAIT_OBJECT_0 );
|
||||||
|
|
||||||
|
if ( IsMain() )
|
||||||
|
{
|
||||||
|
s_waitingForThread = FALSE;
|
||||||
|
|
||||||
|
wxEndBusyCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !::GetExitCodeThread(hThread, (LPDWORD)&rc) )
|
||||||
|
{
|
||||||
|
wxLogLastError("GetExitCodeThread");
|
||||||
|
|
||||||
|
rc = (ExitCode)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxASSERT_MSG( (LPVOID)rc != (LPVOID)STILL_ACTIVE,
|
||||||
|
wxT("thread must be already terminated.") );
|
||||||
|
|
||||||
|
::CloseHandle(hThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxThreadError wxThread::Kill()
|
||||||
|
{
|
||||||
|
if ( !IsRunning() )
|
||||||
|
return wxTHREAD_NOT_RUNNING;
|
||||||
|
|
||||||
|
if ( !::TerminateThread(p_internal->GetHandle(), (DWORD)-1) )
|
||||||
|
{
|
||||||
|
wxLogSysError(_("Couldn't terminate thread"));
|
||||||
|
|
||||||
|
return wxTHREAD_MISC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
|
||||||
return wxTHREAD_NO_ERROR;
|
return wxTHREAD_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxThread::Exit(void *status)
|
void wxThread::Exit(void *status)
|
||||||
{
|
{
|
||||||
// TODO
|
delete this;
|
||||||
|
|
||||||
|
::ExitThread((DWORD)status);
|
||||||
|
|
||||||
|
wxFAIL_MSG(wxT("Couldn't return from ExitThread()!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxThread::SetPriority(int prio)
|
void wxThread::SetPriority(unsigned int prio)
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock(m_critsect);
|
||||||
|
|
||||||
|
p_internal->SetPriority(prio);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxThread::GetPriority() const
|
unsigned int wxThread::GetPriority() const
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxThread::DeferDestroy(bool on)
|
return p_internal->GetPriority();
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxThread::TestDestroy()
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void *wxThread::Join()
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return (void*) NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long wxThread::GetID() const
|
unsigned long wxThread::GetID() const
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is this needed somewhere ?
|
return (unsigned long)p_internal->GetId();
|
||||||
wxThread *wxThread::GetThreadFromID(unsigned long id)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool wxThread::IsAlive() const
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::IsRunning() const
|
bool wxThread::IsRunning() const
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
return FALSE;
|
|
||||||
|
return p_internal->GetState() == STATE_RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxThread::IsMain()
|
bool wxThread::IsAlive() const
|
||||||
{
|
{
|
||||||
// TODO
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
return FALSE;
|
|
||||||
|
return (p_internal->GetState() == STATE_RUNNING) ||
|
||||||
|
(p_internal->GetState() == STATE_PAUSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThread::IsPaused() const
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
|
|
||||||
|
return (p_internal->GetState() == STATE_PAUSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxThread::TestDestroy()
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||||
|
|
||||||
|
return p_internal->GetState() == STATE_CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThread::wxThread()
|
wxThread::wxThread()
|
||||||
{
|
{
|
||||||
p_internal = new wxThreadInternal();
|
p_internal = new wxThreadInternal();
|
||||||
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxThread::~wxThread()
|
wxThread::~wxThread()
|
||||||
{
|
{
|
||||||
Destroy();
|
|
||||||
Join();
|
|
||||||
delete p_internal;
|
delete p_internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default callback just joins the thread and throws away the result.
|
// ----------------------------------------------------------------------------
|
||||||
void wxThread::OnExit()
|
// Automatic initialization for thread module
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxThreadModule : public wxModule
|
||||||
{
|
{
|
||||||
Join();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Automatic initialization
|
|
||||||
class wxThreadModule : public wxModule {
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
|
||||||
public:
|
public:
|
||||||
virtual bool OnInit() {
|
virtual bool OnInit();
|
||||||
/* TODO p_mainid = GetCurrentThread(); */
|
virtual void OnExit();
|
||||||
wxMainMutex = new wxMutex();
|
|
||||||
wxMainMutex->Lock();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Global cleanup
|
private:
|
||||||
virtual void OnExit() {
|
DECLARE_DYNAMIC_CLASS(wxThreadModule)
|
||||||
wxMainMutex->Unlock();
|
|
||||||
delete wxMainMutex;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
|
||||||
|
|
||||||
#endif
|
bool wxThreadModule::OnInit()
|
||||||
|
{
|
||||||
|
// allocate TLS index for storing the pointer to the current thread
|
||||||
|
s_tlsThisThread = ::TlsAlloc();
|
||||||
|
if ( s_tlsThisThread == 0xFFFFFFFF )
|
||||||
|
{
|
||||||
|
// in normal circumstances it will only happen if all other
|
||||||
|
// TLS_MINIMUM_AVAILABLE (>= 64) indices are already taken - in other
|
||||||
|
// words, this should never happen
|
||||||
|
wxLogSysError(_("Thread module initialization failed: "
|
||||||
|
"impossible to allocate index in thread "
|
||||||
|
"local storage"));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// main thread doesn't have associated wxThread object, so store 0 in the
|
||||||
|
// TLS instead
|
||||||
|
if ( !::TlsSetValue(s_tlsThisThread, (LPVOID)0) )
|
||||||
|
{
|
||||||
|
::TlsFree(s_tlsThisThread);
|
||||||
|
s_tlsThisThread = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
wxLogSysError(_("Thread module initialization failed: "
|
||||||
|
"can not store value in thread local storage"));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_critsectWaitingForGui = new wxCriticalSection();
|
||||||
|
|
||||||
|
s_critsectGui = new wxCriticalSection();
|
||||||
|
s_critsectGui->Enter();
|
||||||
|
|
||||||
|
// no error return for GetCurrentThreadId()
|
||||||
|
s_idMainThread = ::GetCurrentThreadId();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxThreadModule::OnExit()
|
||||||
|
{
|
||||||
|
if ( !::TlsFree(s_tlsThisThread) )
|
||||||
|
{
|
||||||
|
wxLogLastError("TlsFree failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s_critsectGui )
|
||||||
|
{
|
||||||
|
s_critsectGui->Leave();
|
||||||
|
delete s_critsectGui;
|
||||||
|
s_critsectGui = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDELETE(s_critsectWaitingForGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// under Windows, these functions are implemented usign a critical section and
|
||||||
|
// not a mutex, so the names are a bit confusing
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void WXDLLEXPORT wxMutexGuiEnter()
|
||||||
|
{
|
||||||
|
// this would dead lock everything...
|
||||||
|
wxASSERT_MSG( !wxThread::IsMain(),
|
||||||
|
wxT("main thread doesn't want to block in wxMutexGuiEnter()!") );
|
||||||
|
|
||||||
|
// the order in which we enter the critical sections here is crucial!!
|
||||||
|
|
||||||
|
// set the flag telling to the main thread that we want to do some GUI
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker enter(*s_critsectWaitingForGui);
|
||||||
|
|
||||||
|
s_nWaitingForGui++;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxWakeUpMainThread();
|
||||||
|
|
||||||
|
// now we may block here because the main thread will soon let us in
|
||||||
|
// (during the next iteration of OnIdle())
|
||||||
|
s_critsectGui->Enter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WXDLLEXPORT wxMutexGuiLeave()
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker enter(*s_critsectWaitingForGui);
|
||||||
|
|
||||||
|
if ( wxThread::IsMain() )
|
||||||
|
{
|
||||||
|
s_bGuiOwnedByMainThread = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// decrement the number of waiters now
|
||||||
|
wxASSERT_MSG( s_nWaitingForGui > 0,
|
||||||
|
wxT("calling wxMutexGuiLeave() without entering it first?") );
|
||||||
|
|
||||||
|
s_nWaitingForGui--;
|
||||||
|
|
||||||
|
wxWakeUpMainThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
s_critsectGui->Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WXDLLEXPORT wxMutexGuiLeaveOrEnter()
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( wxThread::IsMain(),
|
||||||
|
wxT("only main thread may call wxMutexGuiLeaveOrEnter()!") );
|
||||||
|
|
||||||
|
wxCriticalSectionLocker enter(*s_critsectWaitingForGui);
|
||||||
|
|
||||||
|
if ( s_nWaitingForGui == 0 )
|
||||||
|
{
|
||||||
|
// no threads are waiting for GUI - so we may acquire the lock without
|
||||||
|
// any danger (but only if we don't already have it)
|
||||||
|
if ( !wxGuiOwnedByMainThread() )
|
||||||
|
{
|
||||||
|
s_critsectGui->Enter();
|
||||||
|
|
||||||
|
s_bGuiOwnedByMainThread = TRUE;
|
||||||
|
}
|
||||||
|
//else: already have it, nothing to do
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// some threads are waiting, release the GUI lock if we have it
|
||||||
|
if ( wxGuiOwnedByMainThread() )
|
||||||
|
{
|
||||||
|
wxMutexGuiLeave();
|
||||||
|
}
|
||||||
|
//else: some other worker thread is doing GUI
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WXDLLEXPORT wxGuiOwnedByMainThread()
|
||||||
|
{
|
||||||
|
return s_bGuiOwnedByMainThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wake up the main thread if it's in ::GetMessage()
|
||||||
|
void WXDLLEXPORT wxWakeUpMainThread()
|
||||||
|
{
|
||||||
|
// sending any message would do - hopefully WM_NULL is harmless enough
|
||||||
|
if ( !::PostThreadMessage(s_idMainThread, WM_NULL, 0, 0) )
|
||||||
|
{
|
||||||
|
// should never happen
|
||||||
|
wxLogLastError("PostThreadMessage(WM_NULL)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WXDLLEXPORT wxIsWaitingForThread()
|
||||||
|
{
|
||||||
|
return s_waitingForThread;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif // wxUSE_THREADS
|
||||||
|
1241
src/mac/window.cpp
1241
src/mac/window.cpp
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user