mac adaptions

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4458 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
1999-11-09 15:24:52 +00:00
parent eff869aad2
commit e75491071d
66 changed files with 4803 additions and 5220 deletions

View File

@@ -176,11 +176,16 @@ class WXDLLEXPORT wxPrintData: public wxObject
void ConvertFromNative();
void* GetNativeData() const { return m_devMode; }
void SetNativeData(void* data) { m_devMode = data; }
#elif defined( __WXMAC__)
void ConvertToNative();
void ConvertFromNative();
#endif
public:
#ifdef __WXMSW__
void* m_devMode;
#elif defined( __WXMAC__ )
THPrint m_macPrintInfo ;
#endif
private:
@@ -270,10 +275,15 @@ class WXDLLEXPORT wxPrintDialogData: public wxObject
void ConvertFromNative();
void SetOwnerWindow(wxWindow* win);
void* GetNativeData() const { return m_printDlgData; }
#elif defined( __WXMAC__)
void ConvertToNative();
void ConvertFromNative();
#endif
#ifdef __WXMSW__
void* m_printDlgData;
#elif defined( __WXMAC__ )
THPrint m_macPrintInfo ;
#endif
private:
@@ -356,6 +366,9 @@ public:
void ConvertFromNative();
void SetOwnerWindow(wxWindow* win);
void* GetNativeData() const { return m_pageSetupData; }
#elif defined( __WXMAC__)
void ConvertToNative();
void ConvertFromNative();
#endif
// Use paper size defined in this object to set the wxPrintData
@@ -373,6 +386,8 @@ public:
#if defined(__WIN95__)
void* m_pageSetupData;
#elif defined( __WXMAC__ )
THPrint m_macPageSetupInfo ;
#endif
private:

View File

@@ -79,6 +79,8 @@ public:
#include "wx/motif/dataform.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dataform.h"
#elif defined(__WXMAC__)
#include "wx/mac/dataform.h"
#elif defined(__WXPM__)
#include "wx/os2/dataform.h"
#endif
@@ -159,7 +161,7 @@ public:
#elif defined(__WXQT__)
#include "wx/qt/dnd.h"
#elif defined(__WXMAC__)
#include "wx/mac/dnd.h"
#include "wx/mac/dataobj.h"
#elif defined(__WXPM__)
#include "wx/os2/dataobj.h"
#elif defined(__WXSTUBS__)

View File

@@ -69,6 +69,15 @@
typedef double SDOUBLE;
typedef unsigned int UINT;
#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
#define ODBCVER 0x0250
#include <sql.h>
@@ -82,6 +91,7 @@
# ifndef stricmp
# define stricmp strcasecmp
# endif
#elif defined(__WXMAC__)
#else
# include <io.h>
#endif

View File

@@ -7,6 +7,9 @@
#if defined(__WXPM__)
#include "wx/os2/dcprint.h"
#endif
#if defined(__WXMAC__)
#include "wx/mac/dcprint.h"
#endif
#endif
// _WX_DCPRINT_H_BASE_

View File

@@ -84,9 +84,12 @@ WXDLLEXPORT void wxUnix2DosFilename(wxChar *s);
#define Unix2DosFilename wxUnix2DosFilename
#ifdef __WXMAC__
WXDLLEXPORT void wxMacPathToFSSpec( const wxChar *path , FSSpec *spec ) ;
WXDLLEXPORT void wxMac2UnixFilename(wxChar *s);
WXDLLEXPORT void wxUnix2MacFilename(wxChar *s);
WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
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
// Strip the extension, in situ

View File

@@ -43,8 +43,12 @@ class WXDLLEXPORT wxButton: public wxControl
const wxString& name = wxButtonNameStr);
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
static wxSize GetDefaultSize();
virtual void SetDefault();
virtual void Command(wxCommandEvent& event);
protected:
virtual wxSize DoGetBestSize();
};
#endif

View File

@@ -19,75 +19,87 @@
#pragma interface "clipbrd.h"
#endif
#include "wx/defs.h"
#include "wx/setup.h"
#if wxUSE_CLIPBOARD
#include "wx/list.h"
#include "wx/module.h"
#include "wx/dataobj.h" // for wxDataFormat
/* A clipboard client holds data belonging to the clipboard.
For plain text, a client is not necessary. */
class WXDLLEXPORT wxClipboardClient : public wxObject
{
DECLARE_ABSTRACT_CLASS(wxClipboardClient)
// These functions superceded by wxClipboard, but retained in order to
// implement wxClipboard, and for compatibility.
public:
/* This list should be filled in with strings indicating the formats
this client can provide. Almost all clients will provide "TEXT".
Format names should be 4 characters long, so things will work
out on the Macintosh */
wxStringList formats;
// open/close the clipboard
WXDLLEXPORT bool wxOpenClipboard();
WXDLLEXPORT bool wxIsClipboardOpened();
#define wxClipboardOpen wxIsClipboardOpened
WXDLLEXPORT bool wxCloseClipboard();
/* This method is called when the client is losing the selection. */
virtual void BeingReplaced() = 0;
// get/set data
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
supplying to the clipboard. "format" is a string indicating the
format of the data - one of the strings from the "formats"
list. "*size" should be filled with the size of the resulting
data. In the case of text, "*size" does not count the
NULL terminator. */
virtual char *GetData(char *format, long *size) = 0;
};
// clipboard formats
WXDLLEXPORT bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
WXDLLEXPORT wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat);
WXDLLEXPORT int wxRegisterClipboardFormat(wxChar *formatName);
WXDLLEXPORT bool wxGetClipboardFormatName(wxDataFormat dataFormat,
wxChar *formatName,
int maxCount);
/* ONE instance of this class: */
//-----------------------------------------------------------------------------
// wxClipboard
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxDataObject;
class WXDLLEXPORT wxClipboard : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxClipboard)
public:
wxClipboardClient *clipOwner;
char *cbString, *sentString, *receivedString;
void *receivedTargets;
long receivedLength;
public:
wxClipboard();
~wxClipboard();
/* Set the clipboard data owner. "time" comes from the event record. */
void SetClipboardClient(wxClipboardClient *, long time);
// open the clipboard before SetData() and GetData()
virtual bool Open();
/* Set the clipboard string; does not require a client. */
void SetClipboardString(char *, long time);
// close the clipboard after SetData() and GetData()
virtual void Close();
/* Get data from the clipboard in the format "TEXT". */
char *GetClipboardString(long time);
// query whether the clipboard is opened
virtual bool IsOpened() const;
/* Get data from the clipboard */
char *GetClipboardData(char *format, long *length, long time);
// set the clipboard data. all other formats will be deleted.
virtual bool SetData( wxDataObject *data );
/* Get the clipboard client directly. Will be NULL if clipboard data
is a string, or if some other application owns the clipboard.
This can be useful for shortcutting data translation, if the
clipboard user can check for a specific client. (This is used
by the wxMediaEdit class.) */
wxClipboardClient *GetClipboardClient();
// add to the clipboard data.
virtual bool AddData( wxDataObject *data );
// ask if data in correct format is available
virtual bool IsSupported( wxDataFormat format );
// fill data with data on the clipboard (if available)
virtual bool GetData( wxDataObject& data );
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear();
// flushes the clipboard: this means that the data which is currently on
// clipboard will stay available even after the application exits (possibly
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush();
// X11 has two clipboards which get selected by this call. Empty on MSW.
void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
private:
bool m_clearOnExit;
};
/* Initialize wxTheClipboard. Can be called repeatedly */
void WXDLLEXPORT wxInitClipboard();
/* The clipboard */
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
#endif // wxUSE_CLIPBOARD
#endif
// _WX_CLIPBRD_H_

View File

@@ -64,7 +64,7 @@ public:
unsigned char Blue() const { return m_blue; }
// comparison
bool operator == (const wxColour& colour)
bool operator == (const wxColour& colour) const
{
return (m_red == colour.m_red &&
m_green == colour.m_green &&

View File

@@ -33,12 +33,36 @@ public:
// Calls the callback and appropriate event handlers
bool ProcessCommand(wxCommandEvent& event);
virtual void SetLabel(const wxString& title) ;
wxList& GetSubcontrols() { return m_subControls; }
void OnEraseBackground(wxEraseEvent& event);
virtual bool Enable(bool 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
virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
wxColour* GetButtonColour() const { return NULL; }
@@ -59,18 +83,13 @@ protected:
protected:
// For controls like radiobuttons which are really composite
ControlHandle m_macControl ;
int m_macHorizontalBorder ;
int m_macVerticalBorder ;
wxList m_subControls;
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:
DECLARE_EVENT_TABLE()
};

View File

@@ -20,27 +20,32 @@
WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr;
class WXDLLEXPORT wxMacToolTip ;
// Dialog boxes
class WXDLLEXPORT wxDialog: public wxPanel
class WXDLLEXPORT wxDialog : public wxDialogBase
{
DECLARE_DYNAMIC_CLASS(wxDialog)
public:
public:
wxDialog();
// Constructor with a modal flag, but no window id - the old convention
inline wxDialog(wxWindow *parent,
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);
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height),
style | modalStyle, name);
}
// Constructor with no modal flag - the new convention.
inline wxDialog(wxWindow *parent, wxWindowID id,
wxDialog(wxWindow *parent, wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
@@ -51,7 +56,7 @@ public:
}
bool Create(wxWindow *parent, wxWindowID id,
const wxString& title, // bool modal = FALSE, // TODO make this a window style?
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
@@ -60,19 +65,37 @@ public:
~wxDialog();
virtual bool Destroy();
bool Show(bool show);
void Fit();
virtual void DoSetClientSize(int width, int height);
virtual void GetPosition(int *x, int *y) const;
bool Show(bool show);
bool IsShown() const;
void Iconize(bool iconize);
#if WXWIN_COMPATIBILITY
bool Iconized() const { return IsIconized(); };
#endif
virtual bool IsIconized() const;
void Fit();
void SetTitle(const wxString& title);
wxString GetTitle() const ;
void OnSize(wxSizeEvent& event);
bool OnClose();
void OnCharHook(wxKeyEvent& event);
void OnPaint(wxPaintEvent& event);
void OnCloseWindow(wxCloseEvent& event);
void SetModal(bool flag);
virtual bool IsModal() const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
virtual void Centre(int direction = wxBOTH);
virtual bool IsModal() const;
// For now, same as Show(TRUE) but returns return code
virtual int ShowModal();
virtual void EndModal(int retCode);
@@ -81,18 +104,27 @@ public:
void OnApply(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
void OnSize(wxSizeEvent& event) ;
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
// splits text up at newlines and places the
// lines into a vertical wxBoxSizer
wxSizer *CreateTextSizer( const wxString &message );
// implementation
// --------------
// places buttons into a horizontal wxBoxSizer
wxSizer *CreateButtonSizer( long flags );
bool IsModalShowing() const { return m_modalShowing; }
DECLARE_EVENT_TABLE()
// 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

View File

@@ -16,15 +16,66 @@
#pragma interface "font.h"
#endif
// ----------------------------------------------------------------------------
// public functions
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
{
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
// 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)
extern int wxCharsetFromEncoding(wxFontEncoding encoding, bool *exact = NULL);
wxFontRefData(const wxFontRefData& data)
{
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
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
// ----------------------------------------------------------------------------
@@ -87,6 +138,7 @@ public:
virtual bool RealizeResource();
virtual WXHANDLE GetResourceHandle();
virtual bool FreeResource(bool force = FALSE);
void MacInstall() const ;
/*
virtual bool UseResource();
virtual bool ReleaseResource();

View File

@@ -124,9 +124,10 @@ public:
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Query app for menu item updates (called from OnIdle)
// Query app for menu item updates (called from OnIdle)
void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu);
void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
// Checks if there is a toolbar, and returns the first free client position
virtual wxPoint GetClientAreaOrigin() const;
@@ -136,7 +137,8 @@ public:
// tooltip management
#if wxUSE_TOOLTIPS
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
protected:

View File

@@ -44,6 +44,8 @@ public:
// Copy constructors
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 wxString& name, long flags = wxBITMAP_TYPE_ICON_RESOURCE,
int desiredWidth = -1, int desiredHeight = -1);

View File

@@ -9,34 +9,44 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LISTBOX_H_
#define _WX_LISTBOX_H_
#ifdef __GNUG__
#pragma interface "listbox.h"
#pragma interface "listbox.h"
#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()
class WXDLLEXPORT wxArrayInt;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
class wxArrayInt;
// List box item
WX_DEFINE_ARRAY( char * , wxListDataArray ) ;
class WXDLLEXPORT wxListBox: public wxControl
{
DECLARE_DYNAMIC_CLASS(wxListBox)
public:
// ----------------------------------------------------------------------------
// List box control
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxListBox : public wxListBoxBase
{
public:
// ctors and such
wxListBox();
inline wxListBox(wxWindow *parent, wxWindowID id,
wxListBox(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
@@ -55,47 +65,60 @@ class WXDLLEXPORT wxListBox: public wxControl
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
~wxListBox();
virtual ~wxListBox();
virtual void Append(const wxString& item);
virtual void Append(const wxString& item, char *clientData);
virtual void Set(int n, const wxString* choices, char **clientData = NULL);
virtual int FindString(const wxString& s) const ;
// implement base class pure virtuals
virtual void Clear();
virtual void SetSelection(int n, bool select = TRUE);
virtual void Deselect(int n);
// For single choice list item only
virtual int GetSelection() const ;
virtual void Delete(int n);
virtual char *GetClientData(int n) const ;
virtual void SetClientData(int n, char *clientData);
virtual int GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual int FindString(const wxString& s) const;
// For single or multiple choice list item
virtual bool IsSelected(int n) const;
virtual void SetSelection(int n, bool select = TRUE);
virtual int GetSelection() const;
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
// or scroll to max range.
virtual void SetFirstItem(int n) ;
virtual void SetFirstItem(const wxString& s) ;
virtual int DoAppend(const wxString& item);
virtual void DoInsertItems(const wxArrayString& items, int pos);
virtual void DoSetItems(const wxArrayString& items, void **clientData);
virtual void InsertItems(int nItems, const wxString items[], int pos);
virtual void DoSetFirstItem(int n);
virtual wxString GetStringSelection() const ;
virtual bool SetStringSelection(const wxString& s, bool flag = TRUE);
virtual int Number() const ;
virtual void DoSetItemClientData(int n, void* clientData);
virtual void* DoGetItemClientData(int n) const;
virtual void DoSetItemClientObject(int n, wxClientData* clientData);
virtual wxClientData* DoGetItemClientObject(int n) const;
void Command(wxCommandEvent& event);
// wxCheckListBox support
#if wxUSE_OWNER_DRAWN
// plug-in for derived classes
virtual wxOwnerDrawn *CreateItem(size_t n);
// allows to get the item and use SetXXX functions to set it's appearance
wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
// get the index of the given item
int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
#endif // wxUSE_OWNER_DRAWN
// Windows-specific code to set the horizontal extent of the listbox, if
// necessary. If s is non-NULL, it's used to calculate the horizontal
// extent. Otherwise, all strings are used.
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:
int m_noItems;
int m_selected;
protected:
void MacDestroy() ;
void MacDelete( int n ) ;
void MacInsert( int n , const char * text) ;
@@ -111,13 +134,25 @@ class WXDLLEXPORT wxListBox: public wxControl
void MacDoClick() ;
void MacDoDoubleClick() ;
public :
ListHandle m_macList ;
wxArrayString m_stringArray ;
wxListDataArray m_dataArray ;
// do we have multiple selections?
bool HasMultipleSelection() const;
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
DECLARE_EVENT_TABLE()
// free memory (common part of Clear() and dtor)
void Free();
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

View File

@@ -16,168 +16,193 @@
#pragma interface "menu.h"
#endif
#include "wx/defs.h"
#include "wx/event.h"
#if wxUSE_ACCEL
#include "wx/accel.h"
#include "wx/dynarray.h"
class WXDLLEXPORT wxMenuItem;
class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxMenu;
WX_DEFINE_EXPORTED_ARRAY(wxAcceleratorEntry *, wxAcceleratorArray);
#endif // wxUSE_ACCEL
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
class WXDLLEXPORT wxFrame;
// ----------------------------------------------------------------------------
// Menu
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxMenu: public wxEvtHandler
class WXDLLEXPORT wxMenu : public wxMenuBase
{
DECLARE_DYNAMIC_CLASS(wxMenu)
public:
// ctor & dtor
wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
~wxMenu();
// ctors & dtor
wxMenu(const wxString& title, long style = 0)
: wxMenuBase(title, style) { Init(); }
// construct menu
// 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);
wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
// menu item control
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); };
virtual ~wxMenu();
// Client data
inline void SetClientData(void* clientData) { m_clientData = clientData; }
inline void* GetClientData() const { return m_clientData; }
// implement base class virtuals
virtual bool DoAppend(wxMenuItem *item);
virtual bool DoInsert(size_t pos, wxMenuItem *item);
virtual wxMenuItem *DoRemove(wxMenuItem *item);
// item properties
// 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 ;
virtual void Break();
// find item
// 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;
virtual void SetTitle(const wxString& title);
void ProcessCommand(wxCommandEvent& event);
inline void Callback(const wxFunction func) { m_callback = func; }
// MSW-specific
bool ProcessCommand(wxCommandEvent& event);
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
#if WXWIN_COMPATIBILITY
wxMenu(const wxString& title, const wxFunction func)
: wxMenuBase(title)
{
Callback(func);
}
#endif // WXWIN_COMPATIBILITY
inline wxList& GetItems() const { return (wxList&) m_menuItems; }
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
wxWindow * GetInvokingWindow() const { return m_pInvokingWindow; }
// implementation only from now on
// -------------------------------
bool MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ;
public:
wxFunction m_callback;
int m_noItems;
wxString m_title;
wxMenuBar * m_menuBar;
wxList m_menuItems;
wxEvtHandler * m_parent;
wxEvtHandler * m_eventHandler;
wxWindow* m_pInvokingWindow;
void* m_clientData;
MenuHandle m_macMenuHandle;
short m_macMenuId;
bool m_macMenuEnabled ;
// void MacSetTitle(const wxString& title);
int MacGetIndexFromId( int id ) ;
int MacGetIndexFromItem( wxMenuItem *pItem ) ;
void MacEnableMenu( bool bDoEnable ) ;
static short s_macNextMenuId ;
// semi-private accessors
// get the window which contains this menu
wxWindow *GetWindow() const;
// get the menu handle
WXHMENU GetHMenu() const { return m_hMenu; }
protected:
// attach/detach menu to/from wxMenuBar
void Attach(wxMenuBar *menubar);
void Detach();
short MacGetMenuId() { return m_macMenuId ; }
#if wxUSE_ACCEL
// called by wxMenuBar to build its accel table from the accels of all menus
bool HasAccels() const { return !m_accels.IsEmpty(); }
size_t GetAccelCount() const { return m_accels.GetCount(); }
size_t CopyAccels(wxAcceleratorEntry *accels) const;
// called by wxMenuItem when its accels changes
void UpdateAccel(wxMenuItem *item);
// helper used by wxMenu itself (returns the index in m_accels)
int FindAccel(int id) const;
#endif // wxUSE_ACCEL
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)
// ----------------------------------------------------------------------------
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[]);
~wxMenuBar();
virtual ~wxMenuBar();
void Append(wxMenu *menu, const wxString& title);
// Must only be used AFTER menu has been attached to frame,
// otherwise use individual menus to enable/disable items
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);
// menubar construction
virtual bool Append( wxMenu *menu, const wxString &title );
virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
virtual wxMenu *Remove(size_t pos);
virtual void SetHelpString(int Id, const wxString& helpString);
virtual wxString GetHelpString(int Id) const ;
virtual int FindMenuItem(const wxString& menuString,
const wxString& itemString) const;
virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ;
virtual void EnableTop( size_t pos, bool flag );
virtual void SetLabelTop( size_t pos, const wxString& label );
virtual wxString GetLabelTop( size_t pos ) const;
// Find wxMenuItem for item ID, and return item's
// menu too if itemMenu is non-NULL.
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
// compatibility: these functions are deprecated
#if WXWIN_COMPATIBILITY
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
bool Enabled(int id) const { return IsEnabled(id); }
bool Checked(int id) const { return IsChecked(id); }
#endif // WXWIN_COMPATIBILITY
inline int GetMenuCount() const { return m_menuCount; }
inline wxMenu* GetMenu(int i) const { return m_menus[i]; }
// implementation from now on
WXHMENU Create();
int FindMenu(const wxString& title);
void Detach();
// returns TRUE if we're attached to a frame
bool IsAttached() const { return m_menuBarFrame != NULL; }
// get the frame we live in
wxFrame *GetFrame() const { return m_menuBarFrame; }
// attach to a frame
void Attach(wxFrame *frame);
#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 MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, int macMenuItemNum) ;
static wxMenuBar* MacGetInstalledMenuBar() { return s_macInstalledMenuBar ; }
public:
wxEvtHandler * m_eventHandler;
int m_menuCount;
wxMenu ** m_menus;
wxString * m_titles;
wxFrame * m_menuBarFrame;
protected:
// common part of all ctors
void Init();
#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 ;
DECLARE_DYNAMIC_CLASS(wxMenuBar)
};
#endif // _WX_MENU_H_

View File

@@ -11,46 +11,4 @@
#ifndef _WX_PRINT_H_
#define _WX_PRINT_H_
#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_

View File

@@ -33,18 +33,21 @@ class WXDLLEXPORT wxPrintDialog: public wxDialog
public:
wxPrintDialog();
wxPrintDialog(wxWindow *parent, wxPrintData* data = NULL);
wxPrintDialog(wxWindow *parent, wxPrintDialogData* data = NULL);
wxPrintDialog(wxWindow *parent, wxPrintData* data );
~wxPrintDialog();
bool Create(wxWindow *parent, wxPrintData* data = NULL);
bool Create(wxWindow *parent, wxPrintDialogData* data = NULL);
virtual int ShowModal();
inline wxPrintData& GetPrintData() { return m_printData; }
wxPrintDialogData& GetPrintDialogData() { return m_printDialogData; }
wxPrintData& GetPrintData() { return m_printDialogData.GetPrintData(); }
virtual wxDC *GetPrintDC();
private:
wxPrintData m_printData;
wxPrintDialogData m_printDialogData;
wxDC* m_printerDC;
bool m_destroyDC;
wxWindow* m_dialogParent;
};
@@ -52,9 +55,6 @@ class WXDLLEXPORT wxPageSetupDialog: public wxDialog
{
DECLARE_DYNAMIC_CLASS(wxPageSetupDialog)
private:
wxPageSetupData m_pageSetupData;
wxWindow* m_dialogParent;
public:
wxPageSetupDialog();
wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL);
@@ -64,6 +64,9 @@ class WXDLLEXPORT wxPageSetupDialog: public wxDialog
virtual int ShowModal();
inline wxPageSetupData& GetPageSetupData() { return m_pageSetupData; }
private:
wxPageSetupData m_pageSetupData;
wxWindow* m_dialogParent;
};
#endif

View File

@@ -16,71 +16,109 @@
* 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
// Use wxConfig, with CreateConfig in wxApp
#define _WX_GOODCOMPILER__
// gcc can have problems, but Windows compilers
// are generally OK.
#define WXWIN_COMPATIBILITY 0
// Compatibility with 1.66 API.
// Level 0: no backward compatibility, all new features
// Level 1: wxDC, OnSize (etc.) compatibility, but
// some new features such as event tables
#define wxUSE_AUTOTRANS 0
// Define wxTString
#define wxUSE_POSTSCRIPT 0
// 0 for no PostScript device context
#define wxUSE_AFM_FOR_POSTSCRIPT 0
// 1 to use font metric files in GetTextExtent
#define wxUSE_METAFILE 1
// 0 for no Metafile and metafile device context
#define wxUSE_FORM 0
// 0 for no wxForm
#define wxUSE_IPC 0
// 0 for no interprocess comms
#define wxUSE_HELP 0
// 0 for no help facility
#define wxUSE_RESOURCES 1
// 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
// 0 for no clipboard functions
#define wxUSE_SPLINES 0
// 0 for no splines
#define wxUSE_XFIG_SPLINE_CODE 0
// 1 for XFIG spline code, 0 for AIAI spline code.
// AIAI spline code is slower, but freer of copyright issues.
#define wxUSE_SPLINES 1
// 0 for no splines
#define wxUSE_TOOLBAR 1
// Use toolbars
#define wxUSE_DRAG_AND_DROP 0
// 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
// 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
// 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
// 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
// under Windows (just use Windows printing).
#define wxUSE_DYNAMIC_CLASSES 1
@@ -88,19 +126,19 @@
// NOW MANDATORY: don't change.
#define wxUSE_MEMORY_TRACING 1
// 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
// if alignment is an issue.
#define wxUSE_DEBUG_CONTEXT 1
// If 1, enables wxDebugContext, for
// 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.
// It's recommended to set this to 1,
// since you may well need to output
// an error log in a production
// 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.
// If this causes problems (e.g. link errors), set this to 0.
@@ -108,17 +146,17 @@
// In debug mode, causes new to be defined to
// be WXDEBUG_NEW (see object.h).
// 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
// Set this to 0 if your compiler can't cope
// with omission of prototype parameters.
#define wxUSE_C_MAIN 0
// Set to 1 to use main.c instead of main.cpp (UNIX only)
#define wxUSE_ODBC 0
#define wxUSE_ODBC 1
// Define 1 to use ODBC classes
#define wxODBC_FWD_ONLY_CURSORS 1
// Some databases/ODBC drivers only allow forward scrolling cursors.
// Unless you specifically want to use backward scrolling
@@ -129,27 +167,58 @@
#ifndef __MWERKS__
#define wxUSE_IOSTREAMH 0
#else
#define wxUSE_IOSTREAMH 1
#endif
// VC++ 4.2 and above allows <iostream> and <iostream.h>
// but you can't mix them. Set to 1 for <iostream.h>,
// 0 for <iostream>
#define wxUSE_ZIPSTREAM 1
#define wxUSE_FS_ZIP 1
#define wxUSE_FS_INET 1
#define wxUSE_STREAMS 1
// If enabled (1), compiles wxWindows streams classes
#define wxUSE_STD_IOSTREAM 1
// Use standard C++ streams if 1. If 0, use wxWin
// streams implementation.
#define wxUSE_WXCONFIG 0
#define wxUSE_WXCONFIG 1
// if enabled, compiles built-in OS independent wxConfig
// class and it's file (any platform) and registry (Win)
// 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
*
@@ -184,8 +253,6 @@
// text entry dialog and wxGetTextFromUser function
#define wxUSE_TEXTDLG 1
#define wxUSE_STATLINE 1
// wxToolBar class
#define wxUSE_TOOLBAR 1
@@ -198,5 +265,68 @@
// wxDirDlg class for getting a directory name from user
#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
// _WX_SETUP_H_

View File

@@ -29,71 +29,48 @@
wxSP_WRAP: value wraps at either end
*/
class WXDLLEXPORT wxSpinButton: public wxControl
class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase
{
DECLARE_DYNAMIC_CLASS(wxSpinButton)
public:
/*
* Public interface
*/
public:
// construction
wxSpinButton() { }
wxSpinButton();
inline wxSpinButton(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "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);
}
~wxSpinButton();
bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton");
virtual ~wxSpinButton();
bool Create(wxWindow *parent,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
const wxString& name = "wxSpinButton");
// Attributes
////////////////////////////////////////////////////////////////////////////
// accessors
virtual int GetValue() const;
virtual void SetValue(int val);
virtual void SetRange(int minVal, int maxVal);
int GetValue() const ;
void SetValue(int val) ;
void SetRange(int minVal, int maxVal) ;
inline int GetMin() const { return m_min; }
inline int GetMax() const { return m_max; }
// implementation
// Operations
////////////////////////////////////////////////////////////////////////////
void Command(wxCommandEvent& event) { ProcessCommand(event); };
virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ;
protected:
int m_min;
int m_max;
virtual wxSize DoGetBestSize();
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
// _WX_SPINBUTT_H_

View File

@@ -21,6 +21,7 @@
// ---------------------------------------------------------------------------
class WXDLLEXPORT wxButton;
class WXDLLEXPORT wxScrollBar;
// ---------------------------------------------------------------------------
// constants
@@ -169,9 +170,9 @@ public:
// simple accessors
// ----------------
WXHWND GetHWND() const { return m_hWnd; }
void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
virtual WXWidget GetHandle() const { return (WXWidget) GetHWND(); }
// WXHWND GetHWND() const { return m_hWnd; }
// void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
virtual WXWidget GetHandle() const { return (WXWidget) NULL ; }
bool GetUseCtl3D() const { return m_useCtl3D; }
bool GetTransparentBackground() const { return m_backgroundTransparent; }
@@ -226,12 +227,57 @@ public:
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
protected:
// the window handle
WXHWND m_hWnd;
public :
static bool MacGetWindowFromPoint( const wxPoint &point , wxWindow** outWin ) ;
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)
WXFARPROC m_oldWndProc;
virtual void MacFireMouseEvent( EventRecord *ev ) ;
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
bool m_useCtl3D:1; // Using CTL3D for this control
@@ -244,10 +290,7 @@ protected:
int m_xThumbSize;
int m_yThumbSize;
WXHMENU m_hMenu; // Menu, if any
// the return value of WM_GETDLGCODE handler
long m_lDlgCode;
// WXHMENU m_hMenu; // Menu, if any
// implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const;

View File

@@ -102,7 +102,7 @@ typedef void (wxEvtHandler::*wxNotebookEventFunction)(wxNotebookEvent&);
#elif defined(__WXQT__)
#include "wx/qt/notebook.h"
#elif defined(__WXMAC__)
#include "wx/mac/notebook.h"
#include "wx/generic/notebook.h"
#elif defined(__WXPM__)
#include "wx/os2/notebook.h"
#elif defined(__WXSTUBS__)

View File

@@ -1,11 +1,11 @@
///////////////////////////////////////////////////////////////////////////////
// Name: os2/dataform.h
// Name: mac/dataform.h
// Purpose: declaration of the wxDataFormat class
// Author: David Webster (lifted from dnd.h)
// Author: Stefan Csomor
// Modified by:
// Created: 10/21/99
// RCS-ID: $Id$
// Copyright: (c) 1999 David Webster
// Copyright: (c) 1999 Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// Name: os2/dataobj.h
// Name: mac/dataobj.h
// Purpose: declaration of the wxDataObject
// Author: David Webster (adapted from Robert Roebling's gtk port)
// Author: Stefan Csomor
// Modified by:
// Created: 10/21/99
// RCS-ID: $Id$
@@ -9,8 +9,8 @@
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_DATAOBJ_H_
#define _WX_GTK_DATAOBJ_H_
#ifndef _WX_MAC_DATAOBJ_H_
#define _WX_MAC_DATAOBJ_H_
#ifdef __GNUG__
#pragma interface "dataobj.h"
@@ -28,5 +28,5 @@ public:
virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
};
#endif // _WX_GTK_DATAOBJ_H_
#endif // _WX_MAC_DATAOBJ_H_

View File

@@ -11,6 +11,17 @@
#define wxPrintPreview wxWindowsPrintPreview
#endif
#elif defined(__WXMAC__)
#include "wx/mac/printmac.h"
#ifndef wxPrinter
#define wxPrinter wxMacPrinter
#endif
#ifndef wxPrintPreview
#define wxPrintPreview wxMacPrintPreview
#endif
#else
#include "wx/generic/printps.h"

View File

@@ -137,6 +137,9 @@ private:
#if defined(__WXMSW__) || defined(__WXPM__)
class WXDLLEXPORT wxCriticalSectionInternal;
#define WXCRITICAL_INLINE
#elif defined(__WXMAC__)
class WXDLLEXPORT wxCriticalSectionInternal;
#define WXCRITICAL_INLINE
#else // !MSW && !PM
#define WXCRITICAL_INLINE inline
#endif // MSW/!MSW
@@ -160,7 +163,7 @@ private:
wxCriticalSection(const wxCriticalSection&);
wxCriticalSection& operator=(const wxCriticalSection&);
#if defined(__WXMSW__) || defined(__WXPM__)
#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__)
wxCriticalSectionInternal *m_critsect;
#else // !MSW
wxMutex m_mutex;
@@ -396,6 +399,18 @@ public:
// 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:
// 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:
// wxApp then should block all "dangerous" messages
extern bool WXDLLEXPORT wxIsWaitingForThread();

View File

@@ -96,6 +96,19 @@ DbList WXDLLEXPORT *PtrBegDbList = 0;
extern wxList TablesInUse;
#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
enum sqlLog SQLLOGstate = sqlLogOFF;

View File

@@ -81,6 +81,18 @@
#include "wx/dbtable.h"
#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__
// The HPUX preprocessor lines below were commented out on 8/20/97
// because macros.h currently redefines DEBUG and is unneeded.

View File

@@ -112,10 +112,14 @@
#define _MAXPATHLEN 500
extern char *wxBuffer;
#ifdef __WXMAC__
extern wxChar gwxMacFileName[] ;
extern wxChar gwxMacFileName2[] ;
extern wxChar gwxMacFileName3[] ;
#include "morefile.h"
#include "moreextr.h"
#include "fullpath.h"
#include "fspcompa.h"
#endif
#if !USE_SHARED_LIBRARIES
@@ -262,9 +266,7 @@ wxFileExists (const wxString& filename)
return TRUE;
#elif defined(__WXMAC__)
struct stat stbuf;
wxStrcpy( gwxMacFileName , filename ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
if (gwxMacFileName && stat (WXSTRINGCAST gwxMacFileName, &stbuf) == 0)
if (filename && stat (wxUnix2MacFilename(filename), &stbuf) == 0 )
return TRUE;
return FALSE ;
#else
@@ -824,78 +826,129 @@ wxString wxPathOnly (const wxString& path)
// Also, convert to lower case, since case is significant in UNIX.
#ifdef __WXMAC__
void
wxMac2UnixFilename (wxChar *s)
static char sMacFileNameConversion[ 1000 ] ;
wxString wxMac2UnixFilename (const char *str)
{
char *s = sMacFileNameConversion ;
strcpy( s , str ) ;
if (s)
{
memmove( s+1 , s ,(strlen( s ) + 1)*sizeof(wxChar)) ;
if ( *s == wxT(':') )
*s = wxT('.') ;
memmove( s+1 , s ,strlen( s ) + 1) ;
if ( *s == ':' )
*s = '.' ;
else
*s = wxT('/') ;
*s = '/' ;
while (*s)
{
if (*s == wxT(':'))
*s = wxT('/');
if (*s == ':')
*s = '/';
else
*s = wxTolower(*s); // Case INDEPENDENT
*s = wxTolower (*s); // Case INDEPENDENT
s++;
}
}
return wxString (sMacFileNameConversion) ;
}
void
wxUnix2MacFilename (wxChar *s)
wxString wxUnix2MacFilename (const char *str)
{
char *s = sMacFileNameConversion ;
strcpy( s , str ) ;
if (s)
{
if ( *s == wxT('.') )
if ( *s == '.' )
{
// relative path , since it goes on with slash which is translated to a :
memmove( s , s+1 ,strlen( s )*sizeof(wxChar) ) ;
memmove( s , s+1 ,strlen( s ) ) ;
}
else if ( *s == wxT('/') )
else if ( *s == '/' )
{
// absolute path -> on mac just start with the drive name
memmove( s , s+1 ,strlen( s )*sizeof(wxChar) ) ;
memmove( s , s+1 ,strlen( s ) ) ;
}
else
{
wxASSERT_MSG( 1 , wxT("unknown path beginning") ) ;
wxASSERT_MSG( 1 , "unkown path beginning" ) ;
}
while (*s)
{
if (*s == wxT('/') || *s == wxT('\\'))
*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++ ;
}
}
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
void
wxDos2UnixFilename (wxChar *s)
wxDos2UnixFilename (char *s)
{
if (s)
while (*s)
{
if (*s == wxT('\\'))
*s = wxT('/');
#if defined(__WXMSW__) || defined(__WXPM__)
if (*s == '\\')
*s = '/';
#ifdef __WXMSW__
else
*s = wxTolower(*s); // Case INDEPENDENT
*s = wxTolower (*s); // Case INDEPENDENT
#endif
s++;
}
}
void
#if defined(__WXMSW__) || defined(__WXPM__)
wxUnix2DosFilename (wxChar *s)
#ifdef __WXMSW__
wxUnix2DosFilename (char *s)
#else
wxUnix2DosFilename (wxChar *WXUNUSED(s))
wxUnix2DosFilename (char *WXUNUSED(s) )
#endif
{
// 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;
// Open the inputs and outputs
#ifdef __WXMAC__
wxStrcpy( gwxMacFileName , file1 ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
wxStrcpy( gwxMacFileName2 , file2) ;
wxUnix2MacFilename( gwxMacFileName2 ) ;
wxStrcpy( gwxMacFileName3 , outfile) ;
wxUnix2MacFilename( gwxMacFileName3 ) ;
if ((fp1 = fopen (gwxMacFileName, "rb")) == NULL ||
(fp2 = fopen (gwxMacFileName2, "rb")) == NULL ||
(fp3 = fopen (gwxMacFileName3, "wb")) == NULL)
if ((fp1 = fopen (wxUnix2MacFilename( file1 ), "rb")) == NULL ||
(fp2 = fopen (wxUnix2MacFilename( file2 ), "rb")) == NULL ||
(fp3 = fopen (wxUnix2MacFilename( outfile ), "wb")) == NULL)
#else
if ((fp1 = fopen (wxFNSTRINGCAST file1.fn_str(), "rb")) == NULL ||
(fp2 = fopen (wxFNSTRINGCAST file2.fn_str(), "rb")) == NULL ||
(fp3 = fopen (wxFNCONV(outfile), "wb")) == NULL)
if ((fp1 = fopen (WXSTRINGCAST file1, "rb")) == NULL ||
(fp2 = fopen (WXSTRINGCAST file2, "rb")) == NULL ||
(fp3 = fopen (outfile, "wb")) == NULL)
#endif
{
if (fp1)
@@ -970,18 +1016,13 @@ wxCopyFile (const wxString& file1, const wxString& file2)
int ch;
#ifdef __WXMAC__
wxStrcpy( gwxMacFileName , file1 ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
wxStrcpy( gwxMacFileName2 , file2) ;
wxUnix2MacFilename( gwxMacFileName2 ) ;
if ((fd1 = fopen (gwxMacFileName, "rb")) == NULL)
if ((fd1 = fopen (wxUnix2MacFilename( file1 ), "rb")) == NULL)
return FALSE;
if ((fd2 = fopen (gwxMacFileName2, "wb")) == NULL)
if ((fd2 = fopen (wxUnix2MacFilename( file2 ), "wb")) == NULL)
#else
if ((fd1 = fopen (wxFNSTRINGCAST file1.fn_str(), "rb")) == NULL)
if ((fd1 = fopen (WXSTRINGCAST file1, "rb")) == NULL)
return FALSE;
if ((fd2 = fopen (wxFNSTRINGCAST file2.fn_str(), "wb")) == NULL)
if ((fd2 = fopen (WXSTRINGCAST file2, "wb")) == NULL)
#endif
{
fclose (fd1);
@@ -1000,12 +1041,7 @@ bool
wxRenameFile (const wxString& file1, const wxString& file2)
{
#ifdef __WXMAC__
wxStrcpy( gwxMacFileName , file1 ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
wxStrcpy( gwxMacFileName2 , file2) ;
wxUnix2MacFilename( gwxMacFileName2 ) ;
if (0 == rename (gwxMacFileName, gwxMacFileName2))
if (0 == rename (wxUnix2MacFilename( file1 ), wxUnix2MacFilename( file2 )))
return TRUE;
#else
// Normal system call
@@ -1026,9 +1062,7 @@ bool wxRemoveFile(const wxString& file)
#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
int flag = remove(wxFNSTRINGCAST file.fn_str());
#elif defined( __WXMAC__ )
wxStrcpy( gwxMacFileName , file ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
int flag = unlink(gwxMacFileName);
int flag = unlink(wxUnix2MacFilename( file ));
#else
int flag = unlink(wxFNSTRINGCAST file.fn_str());
#endif
@@ -1038,12 +1072,9 @@ bool wxRemoveFile(const wxString& file)
bool wxMkdir(const wxString& dir, int perm)
{
#if defined( __WXMAC__ )
wxStrcpy( gwxMacFileName , dir ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
const wxChar *dirname = gwxMacFileName;
return (mkdir(wxUnix2MacFilename( dir ) , 0 ) == 0);
#else // !Mac
const wxChar *dirname = dir.c_str();
#endif // Mac/!Mac
// assume mkdir() has 2 args on non Windows-OS/2 platforms and on Windows too
// for the GNU compiler
@@ -1059,6 +1090,7 @@ bool wxMkdir(const wxString& dir, int perm)
}
return TRUE;
#endif // Mac/!Mac
}
bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
@@ -1066,9 +1098,7 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
#ifdef __VMS__
return FALSE;
#elif defined( __WXMAC__ )
wxStrcpy( gwxMacFileName , dir ) ;
wxUnix2MacFilename( gwxMacFileName ) ;
return (rmdir(WXSTRINGCAST gwxMacFileName) == 0);
return (rmdir(wxUnix2MacFilename( dir )) == 0);
#else
#ifdef __SALFORDC__
@@ -1481,6 +1511,17 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
char *cbuf = new char[sz+1];
#ifdef _MSC_VER
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
if (getcwd(cbuf, sz) == NULL) {
#endif

View File

@@ -1338,8 +1338,8 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
else
{
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
if ( frontwindow && wxMenuBar::s_macInstalledMenuBar )
wxMenuBar::s_macInstalledMenuBar->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
}
HiliteMenu(0);
}

View File

@@ -47,10 +47,19 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
void wxButton::SetDefault()
{
wxWindow *parent = (wxWindow *)GetParent();
if (parent)
parent->SetDefaultItem(this);
wxWindow *parent = GetParent();
wxButton *btnOldDefault = NULL;
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 )
{
UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ;

View File

@@ -1338,8 +1338,8 @@ void wxApp::MacHandleMenuSelect( int macMenuId , int macMenuItemNum )
else
{
wxWindow* frontwindow = wxFindWinFromMacWindow( ::FrontWindow() ) ;
if ( frontwindow && wxMenuBar::s_macInstalledMenuBar )
wxMenuBar::s_macInstalledMenuBar->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
if ( frontwindow && wxMenuBar::MacGetInstalledMenuBar() )
wxMenuBar::MacGetInstalledMenuBar()->MacMenuSelect( frontwindow->GetEventHandler() , 0 , macMenuId , macMenuItemNum ) ;
}
HiliteMenu(0);
}

View File

@@ -47,10 +47,19 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
void wxButton::SetDefault()
{
wxWindow *parent = (wxWindow *)GetParent();
if (parent)
parent->SetDefaultItem(this);
wxWindow *parent = GetParent();
wxButton *btnOldDefault = NULL;
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 )
{
UMASetControlData( m_macControl , kControlButtonPart , kControlPushButtonDefaultTag , sizeof( Boolean ) , (char*)((Boolean)1) ) ;

View File

@@ -23,11 +23,6 @@
#include <string.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
#endif
bool wxOpenClipboard()
{
return TRUE;
@@ -90,26 +85,36 @@ bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
* Generalized clipboard implementation by Matthew Flatt
*/
wxClipboard *wxTheClipboard = NULL;
void wxInitClipboard()
{
if (!wxTheClipboard)
wxTheClipboard = new wxClipboard;
}
wxClipboard::wxClipboard()
{
clipOwner = NULL;
cbString = NULL;
m_clearOnExit = FALSE;
}
wxClipboard::~wxClipboard()
{
if (clipOwner)
clipOwner->BeingReplaced();
if (cbString)
delete[] cbString;
if ( m_clearOnExit )
{
Clear();
}
}
void wxClipboard::Clear()
{
}
bool wxClipboard::Flush()
{
return FALSE;
}
bool wxClipboard::Open()
{
return wxOpenClipboard();
}
bool wxClipboard::IsOpened() const
{
return wxIsClipboardOpened();
}
static int FormatStringToID(char *str)
@@ -120,6 +125,129 @@ static int FormatStringToID(char *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)
{
bool got_selection;
@@ -167,7 +295,7 @@ wxClipboardClient *wxClipboard::GetClipboardClient()
}
void wxClipboard::SetClipboardString(char *str, long time)
{/*
{
bool got_selection;
if (clipOwner) {
@@ -193,9 +321,7 @@ void wxClipboard::SetClipboardString(char *str, long time)
delete[] cbString;
cbString = NULL;
}
*/
}
char *wxClipboard::GetClipboardString(long time)
{
char *str;
@@ -210,6 +336,7 @@ char *wxClipboard::GetClipboardString(long time)
return str;
}
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
{
if (clipOwner) {
@@ -233,4 +360,5 @@ char *wxClipboard::GetClipboardData(char *format, long *length, long time)
return receivedString;
}
}
*/

View File

@@ -53,7 +53,9 @@ wxControl::wxControl()
m_macVerticalBorder = 0 ;
m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK;
#if WXWIN_COMPATIBILITY
m_callback = 0;
#endif // WXWIN_COMPATIBILITY
if ( wxMacLiveScrollbarActionUPP == NULL )
{
@@ -63,13 +65,14 @@ wxControl::wxControl()
wxControl::~wxControl()
{
m_isBeingDeleted = TRUE;
// If we delete an item, we should initialize the parent panel,
// because it could now be invalid.
wxWindow *parent = (wxWindow *)GetParent();
if (parent)
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
if ( panel )
{
if (parent->GetDefaultItem() == (wxButton*) this)
parent->SetDefaultItem(NULL);
if (panel->GetDefaultItem() == (wxButton*) this)
panel->SetDefaultItem(NULL);
}
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 )
{
Str255 maclabel ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )
label = wxMacMakeMacStringFromPC( title ) ;
else
label = title ;
strcpy( (char*) maclabel , label ) ;
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:
// 1) A callback function (to become obsolete)
// 2) OnCommand, starting at this window and working up parent hierarchy
// 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
#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;
wxControl *wxFindControlFromMacControl(ControlHandle inControl )
@@ -352,6 +336,7 @@ void wxControl::MacSuperChangedPosition()
void wxControl::MacSuperEnabled( bool enabled )
{
/*
if ( m_macControl )
{
if ( UMAHasAppearance() )
@@ -380,10 +365,12 @@ void wxControl::MacSuperEnabled( bool enabled )
}
}
wxWindow::MacSuperEnabled( enabled ) ;
*/
}
void wxControl::MacSuperShown( bool show )
{
/*
if ( m_macControl )
{
if ( !show )
@@ -398,6 +385,7 @@ void wxControl::MacSuperShown( bool show )
}
wxWindow::MacSuperShown( show ) ;
*/
}
void wxControl::DoSetSize(int x, int y,
@@ -503,34 +491,28 @@ void wxControl::DoSetSize(int x, int y,
}
}
void wxControl::DoSetClientSize(int width, int height)
{
DoSetSize( -1 , -1 , width , height ) ;
}
bool wxControl::Show(bool show)
{
if ( m_macControl == NULL )
return wxWindow::Show( show ) ;
if ( m_macShown == show )
return TRUE ;
if ( !wxWindow::Show( show ) )
return FALSE ;
if ( m_macControl )
{
if ( show )
::UMAShowControl( m_macControl ) ;
else
::UMAHideControl( m_macControl ) ;
return wxWindow::Show( show ) ;
}
return TRUE ;
}
void wxControl::Enable(bool enable)
bool wxControl::Enable(bool enable)
{
if ( m_macControl == NULL )
return wxWindow::Enable( enable ) ;
if ( !wxWindow::Enable(enable) )
return FALSE;
if ( m_macEnabled == enable )
return ;
if ( m_macControl )
{
if ( UMAHasAppearance() )
{
@@ -546,8 +528,8 @@ void wxControl::Enable(bool enable)
else
::HiliteControl( m_macControl , 255 ) ;
}
return wxWindow::Enable( enable ) ;
}
return TRUE ;
}
void wxControl::Refresh(bool eraseBack, const wxRect *rect)
@@ -579,9 +561,9 @@ void wxControl::OnPaint(wxPaintEvent& event)
wxWindow* parent = GetParent() ;
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 ;
}
@@ -596,13 +578,13 @@ void wxControl::OnPaint(wxPaintEvent& event)
}
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
{
wxWindow::OnPaint( event ) ;
// wxWindow::OnPaint( event ) ;
}
}

View File

@@ -108,7 +108,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
m_macWindowData->m_macFocus = NULL ;
m_macShown = false ;
return TRUE;
}
@@ -127,8 +126,11 @@ void wxDialog::SetModal(bool flag)
wxDialog::~wxDialog()
{
m_isBeingDeleted = TRUE ;
wxTopLevelWindows.DeleteObject(this);
m_modalShowing = FALSE;
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
wxModelessWindows.DeleteObject(this);
@@ -176,18 +178,45 @@ extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show)
{
if ( m_macShown == show )
return TRUE ;
m_isShown = show;
m_macShown = show ;
if (show)
InitDialog();
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 )
{
s_macIsInModalLoop = true ;
if (show)
{
if (m_modalShowing)
{
// BringWindowToTop((HWND) GetHWND());
return TRUE;
}
m_modalShowing = TRUE;
// 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
@@ -334,125 +363,3 @@ void wxDialog::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;
}

View File

@@ -22,39 +22,42 @@
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
#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_pointSize = 0;
m_family = 0;
m_style = 0;
m_weight = 0;
m_underlined = 0;
m_faceName = "";
m_style = style;
m_pointSize = pointSize;
m_family = family;
m_style = style;
m_weight = weight;
m_underlined = underlined;
m_faceName = faceName;
m_encoding = encoding;
m_macFontSize = m_pointSize ;
m_macFontNum = systemFont ;
m_macFontStyle = normal ;
}
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 ;
m_macFontNum = 0 ;
m_macFontSize = 0;
m_macFontStyle = 0;
m_fontId = 0;
}
wxFontRefData::~wxFontRefData()
{
// TODO: delete font data
}
void wxFontRefData::MacFindFont()
@@ -107,31 +110,27 @@ void wxFontRefData::MacFindFont()
m_macFontSize = m_pointSize ;
}
wxFont::wxFont()
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
void wxFont::Init()
{
if ( wxTheFontList )
wxTheFontList->Append(this);
}
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
{
Create(pointSize, family, style, weight, underlined, faceName);
if ( wxTheFontList )
wxTheFontList->Append(this);
}
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
bool wxFont::Create(int pointSize,
int family,
int style,
int weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
{
UnRef();
m_refData = new wxFontRefData;
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;
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, faceName, encoding);
RealizeResource();
@@ -219,78 +218,50 @@ void wxFont::SetUnderlined(bool underlined)
RealizeResource();
}
wxString wxFont::GetFamilyString() const
// ----------------------------------------------------------------------------
// accessors
// ----------------------------------------------------------------------------
int wxFont::GetPointSize() const
{
wxString fam("");
switch (GetFamily())
{
case wxDECORATIVE:
fam = "wxDECORATIVE";
break;
case wxROMAN:
fam = "wxROMAN";
break;
case wxSCRIPT:
fam = "wxSCRIPT";
break;
case wxSWISS:
fam = "wxSWISS";
break;
case wxMODERN:
fam = "wxMODERN";
break;
case wxTELETYPE:
fam = "wxTELETYPE";
break;
default:
fam = "wxDEFAULT";
break;
}
return fam;
return M_FONTDATA->m_pointSize;
}
int wxFont::GetFamily() const
{
return M_FONTDATA->m_family;
}
int wxFont::GetFontId() const
{
return M_FONTDATA->m_fontId;
}
int wxFont::GetStyle() const
{
return M_FONTDATA->m_style;
}
int wxFont::GetWeight() const
{
return M_FONTDATA->m_weight;
}
bool wxFont::GetUnderlined() const
{
return M_FONTDATA->m_underlined;
}
/* New font system */
wxString wxFont::GetFaceName() const
{
wxString str("");
if (M_FONTDATA)
wxString str;
if ( M_FONTDATA )
str = M_FONTDATA->m_faceName ;
return str;
}
wxString wxFont::GetStyleString() const
wxFontEncoding wxFont::GetEncoding() const
{
wxString styl("");
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;
return M_FONTDATA->m_encoding;
}

View File

@@ -52,12 +52,10 @@ wxFrame::wxFrame()
#if wxUSE_TOOLBAR
m_frameToolBar = NULL ;
#endif
m_macShown = false ;
// in order to be able to give size events on show
m_frameMenuBar = NULL;
m_frameStatusBar = NULL;
m_windowParent = NULL;
m_iconized = FALSE;
}
@@ -147,7 +145,6 @@ bool wxFrame::Create(wxWindow *parent,
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
m_macWindowData->m_macFocus = NULL ;
m_macShown = false ;
return TRUE;
}

View File

@@ -106,57 +106,120 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
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 ) ;
}
void wxListBox::SetFirstItem(const wxString& s)
{
MacScrollTo( FindString( s ) ) ;
}
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_noItems --;
MacDelete( N ) ;
SetHorizontalExtent("");
}
void wxListBox::Append(const wxString& item)
{
Append( item , NULL ) ;
}
void wxListBox::Append(const wxString& item, char *Client_data)
int wxListBox::DoAppend(const wxString& item)
{
int index = m_noItems ;
if( wxApp::s_macDefaultEncodingIsPC )
{
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
}
else
m_stringArray.Add( item ) ;
m_dataArray.Add( Client_data ) ;
m_noItems ++;
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() ;
int n = choices.GetCount();
for( int i = 0 ; i < n ; ++i )
{
if ( clientData )
{
#if wxUSE_OWNER_DRAWN
wxASSERT_MSG(clientData[i] == NULL,
wxT("Can't use client data with owner-drawn listboxes"));
#else // !wxUSE_OWNER_DRAWN
Append( choices[i] , clientData[0] ) ;
#endif
}
else
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
@@ -192,10 +255,12 @@ int wxListBox::FindString(const wxString& st) const
void wxListBox::Clear()
{
Free();
m_noItems = 0;
m_stringArray.Empty() ;
m_dataArray.Empty() ;
MacClear() ;
SetHorizontalExtent();
}
void wxListBox::SetSelection(int N, bool select)
@@ -205,7 +270,7 @@ void wxListBox::SetSelection(int N, bool select)
MacSetSelection( N , select ) ;
}
bool wxListBox::Selected(int N) const
bool wxListBox::IsSelected(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
"invalid index in wxListBox::Selected" );
@@ -213,28 +278,33 @@ bool wxListBox::Selected(int N) const
return MacIsSelected( N ) ;
}
void wxListBox::Deselect(int N)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
"invalid index in wxListBox::Deselect" );
SetSelection( N , false ) ;
}
char *wxListBox::GetClientData(int N) const
void *wxListBox::DoGetItemClientData(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
"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,
"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
@@ -277,8 +347,13 @@ wxString wxListBox::GetString(int N) const
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++ )
{
m_stringArray.Insert( items[i] , pos + i ) ;
@@ -295,46 +370,11 @@ void wxListBox::SetString(int N, const wxString& 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
@@ -484,29 +524,27 @@ void wxListBox::MacSetRedraw( bool doDraw )
void wxListBox::MacDoClick()
{
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
event.SetEventObject( this );
wxArrayInt aSelections;
int count = GetSelections(aSelections);
int n, count = GetSelections(aSelections);
if ( count > 0 )
{
event.m_commandInt = aSelections[0] ;
event.m_clientData = GetClientData(event.m_commandInt);
wxString str(GetString(event.m_commandInt));
if (str != "")
event.m_commandString = copystring((char *)(const char *)str);
if ( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );
else if ( HasClientUntypedData() )
event.SetClientData( GetClientData(n) );
event.SetString( GetString(n) );
}
else
{
return ;
/*
event.m_commandInt = -1 ;
event.m_commandString = copystring("") ;
*/
n = -1;
}
event.SetEventObject( this );
ProcessCommand(event);
if (event.m_commandString)
delete[] event.m_commandString ;
event.m_commandInt = n;
GetEventHandler()->ProcessEvent(event);
}
void wxListBox::MacDoDoubleClick()

View File

@@ -82,17 +82,7 @@ void wxMDIParentFrame::GetClientSize(int *x, int *y) const
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
{
// TODO
if (!menu_bar)
{
m_frameMenuBar = NULL;
return;
}
if (menu_bar->m_menuBarFrame)
return;
m_frameMenuBar = menu_bar;
wxFrame::SetMenuBar( menu_bar ) ;
}
void wxMDIParentFrame::OnSize(wxSizeEvent& event)
@@ -211,16 +201,7 @@ void wxMDIChildFrame::GetPosition(int *x, int *y) const
void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
{
// TODO
if (!menu_bar)
{
m_frameMenuBar = NULL;
return;
}
if (menu_bar->m_menuBarFrame)
return;
m_frameMenuBar = menu_bar;
return wxFrame::SetMenuBar( menu_bar ) ;
}
// MDI operations

File diff suppressed because it is too large Load Diff

View File

@@ -37,23 +37,25 @@
// -----------
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
const wxString& strName, const wxString& strHelp,
const wxString& text, const wxString& strHelp,
bool bCheckable,
wxMenu *pSubMenu) :
m_bCheckable(bCheckable),
m_strName(strName),
m_strHelp(strHelp)
wxMenu *pSubMenu)
{
wxASSERT( pParentMenu != NULL );
m_pParentMenu = pParentMenu;
m_pSubMenu = pSubMenu;
m_idItem = id;
m_bEnabled = TRUE;
m_parentMenu = pParentMenu;
m_subMenu = pSubMenu;
m_isEnabled = 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" ;
}
}
@@ -64,53 +66,57 @@ wxMenuItem::~wxMenuItem()
// misc
// ----
/*
// delete the sub menu
void wxMenuItem::DeleteSubMenu()
{
wxASSERT( m_pSubMenu != NULL );
wxASSERT( m_subMenu != NULL );
delete m_pSubMenu;
m_pSubMenu = NULL;
delete m_subMenu;
m_subMenu = NULL;
}
*/
// change item state
// -----------------
void wxMenuItem::Enable(bool bDoEnable)
{
if ( m_bEnabled != bDoEnable ) {
if ( m_pSubMenu == NULL )
if ( m_isEnabled != bDoEnable ) {
if ( m_subMenu == NULL )
{
// 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 ( bDoEnable )
UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
UMAEnableMenuItem( m_parentMenu->GetHMenu() , index ) ;
else
UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
UMADisableMenuItem( m_parentMenu->GetHMenu() , index ) ;
}
}
}
else
{
// 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 ( bDoEnable )
UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
UMAEnableMenuItem( m_parentMenu->GetHMenu() , index ) ;
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" );
if ( m_bChecked != bDoCheck )
if ( m_isChecked != bDoCheck )
{
m_bChecked = bDoCheck;
if ( m_pParentMenu->m_macMenuHandle )
m_isChecked = bDoCheck;
if ( m_parentMenu->GetHMenu() )
{
int index = m_pParentMenu->MacGetIndexFromItem( this ) ;
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
if ( index >= 1 )
{
if ( bDoCheck )
::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0x12 ) ; // checkmark
::SetItemMark( m_parentMenu->GetHMenu() , index , 0x12 ) ; // checkmark
else
::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0 ) ; // no mark
::SetItemMark( m_parentMenu->GetHMenu() , index , 0 ) ; // no mark
}
}
}

View File

@@ -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
}

View File

@@ -14,7 +14,7 @@
#endif
#include "wx/object.h"
#include "wx/mac/printdlg.h"
#include "wx/printdlg.h"
#include "wx/dcprint.h"
// 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)
#endif
wxPrintDialog::wxPrintDialog():
wxDialog()
wxPrintDialog::wxPrintDialog()
{
m_dialogParent = NULL;
m_printerDC = NULL;
m_destroyDC = TRUE;
}
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data):
wxDialog()
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* 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_printerDC = NULL;
m_destroyDC = TRUE;
if ( data )
m_printData = *data;
m_printDialogData = *data;
return TRUE;
}
wxPrintDialog::~wxPrintDialog()
{
if (m_destroyDC && m_printerDC)
delete m_printerDC;
}
int wxPrintDialog::ShowModal()
@@ -60,10 +73,10 @@ int wxPrintDialog::ShowModal()
if ( !err )
{
m_printData.ConvertToNative() ;
if ( m_printData.macPrintInfo && ::PrJobDialog( m_printData.macPrintInfo ) )
m_printDialogData.ConvertToNative() ;
if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) )
{
m_printData.ConvertFromNative() ;
m_printDialogData.ConvertFromNative() ;
result = wxID_OK ;
}
@@ -80,7 +93,7 @@ int wxPrintDialog::ShowModal()
wxDC *wxPrintDialog::GetPrintDC()
{
return new wxPrinterDC( m_printData ) ;
return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
}
/*

View File

@@ -67,17 +67,6 @@ wxRadioBox::~wxRadioBox()
// 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
{
// TODO
@@ -106,28 +95,28 @@ wxString wxRadioBox::GetString(int n) const
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
{
// TODO
wxControl::GetSize( width , height ) ;
}
void wxRadioBox::GetPosition(int *x, int *y) const
{
// TODO
wxControl::GetPosition( x , y ) ;
}
wxString wxRadioBox::GetLabel() const
wxString wxRadioBox::GetLabel( int item ) const
{
// TODO
return wxString("");
}
void wxRadioBox::SetLabel(const wxString& label)
void wxRadioBox::SetLabel(int item , const wxString& label)
{
// TODO
}
@@ -139,23 +128,18 @@ void wxRadioBox::SetFocus()
bool wxRadioBox::Show(bool show)
{
// TODO
return wxWindow::Show( show ) ;
return wxControl::Show( show ) ;
}
// Enable a specific button
void wxRadioBox::Enable(int item, bool enable)
{
wxControl::Enable(enable);
// TODO
}
// Enable all controls
void wxRadioBox::Enable(bool enable)
bool wxRadioBox::Enable(bool enable)
{
wxControl::Enable(enable);
// TODO
return wxControl::Enable(enable);
}
// Show a specific button

View File

@@ -16,15 +16,18 @@
#include "wx/spinbutt.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
#endif
// ============================================================================
// implementation
// ============================================================================
wxSpinButton::wxSpinButton()
{
m_min = 0;
m_max = 100;
}
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
#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,
long style, const wxString& name)
@@ -78,14 +81,6 @@ void wxSpinButton::SetRange(int minVal, int 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 )
{
if ( m_macControl == NULL )

View File

@@ -47,7 +47,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
void wxStaticText::SetLabel(const wxString& st , bool resize )
{
m_label = st ;
SetTitle( st ) ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )

View File

@@ -409,42 +409,29 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
bool handleIt = true ;
switch( event.KeyCode() )
{
case WXK_RETURN:
{
/* Oh yes it will, because we also specify DLGC_WANTCHARS
wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER,
"this text ctrl should never receive return" );
*/
if ( !(m_windowStyle & wxTE_MULTILINE) )
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject( this );
if ( GetEventHandler()->ProcessEvent(event) )
return;
}
//else: multiline controls need Enter for themselves
if ( (m_windowStyle & wxTE_MULTILINE) == 0 )
{
wxWindow* parent = GetParent() ;
while( parent )
{
if ( parent->GetDefaultItem() )
{
wxButton *defaultBtn = parent->GetDefaultItem() ;
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, defaultBtn->GetId() );
event.SetEventObject(defaultBtn);
defaultBtn->Command(event);
return ;
}
parent = parent->GetParent() ;
} ;
}
break;
}
case WXK_TAB:
// only produce navigation event if we don't process TAB ourself or
// if it's a Shift-Tab keypress (we assume nobody will ever need
// this key combo for himself)
// always produce navigation event - even if we process TAB
// ourselves the fact that we got here means that the user code
// 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
// handled by Windows
if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) )
{
wxNavigationKeyEvent eventNav;
eventNav.SetDirection(!event.ShiftDown());
@@ -455,27 +442,18 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
return;
}
break;
default:
event.Skip();
return;
}
if ( handleIt )
{
EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
short keycode ;
short keychar ;
keychar = short(ev->message & charCodeMask);
keycode = short(ev->message & keyCodeMask) >> 8 ;
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);
}
}
}
// don't just call event.Skip() because this will cause TABs and ENTERs
// be passed upwards and we don't always want this - instead process it
// right here
// FIXME
event.Skip();
}
// 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

View File

@@ -1,71 +1,146 @@
/////////////////////////////////////////////////////////////////////////////
// Name: thread.cpp
// Purpose: wxThread Implementation. For Unix ports, see e.g. src/gtk
// Purpose: wxThread Implementation
// Author: Original from Wolfram Gloger/Guilhem Lavaux
// Modified by:
// Modified by: Vadim Zeitlin to make it work :-)
// Created: 04/22/98
// 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
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "thread.h"
#pragma implementation "thread.h"
#endif
#include "wx/module.h"
#include "wx/thread.h"
#include "wx/utils.h"
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
enum thread_state {
STATE_IDLE = 0,
STATE_RUNNING,
STATE_CANCELED,
STATE_EXITED
};
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if wxUSE_THREADS
/////////////////////////////////////////////////////////////////////////////
// Static variables
/////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
wxMutex *wxMainMutex; // controls access to all GUI functions
#include <windows.h>
/////////////////////////////////////////////////////////////////////////////
// Windows implementation
/////////////////////////////////////////////////////////////////////////////
#include "wx/module.h"
#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:
// TODO: internal mutex handle
Handle p_mutex;
};
wxMutex::wxMutex()
{
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;
}
wxMutex::~wxMutex()
{
if (m_locked > 0)
wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked);
// TODO: free internal mutext handle
wxLogDebug(wxT("Warning: freeing a locked mutex (%d locks)."), m_locked);
// CloseHandle(p_internal->p_mutex);
}
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++;
return wxMUTEX_NO_ERROR;
}
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++;
*/
return wxMUTEX_NO_ERROR;
}
@@ -73,192 +148,715 @@ wxMutexError wxMutex::Unlock()
{
if (m_locked > 0)
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;
}
class wxConditionInternal {
// ----------------------------------------------------------------------------
// wxCondition implementation
// ----------------------------------------------------------------------------
class wxConditionInternal
{
public:
// TODO: internal handle
Handle event;
int waiters;
};
wxCondition::wxCondition()
{
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;
}
wxCondition::~wxCondition()
{
// TODO: destroy internal handle
// CloseHandle(p_internal->event);
}
void wxCondition::Wait(wxMutex& mutex)
{
mutex.Unlock();
p_internal->waiters++;
// TODO wait here
// WaitForSingleObject(p_internal->event, INFINITE);
p_internal->waiters--;
mutex.Lock();
}
bool wxCondition::Wait(wxMutex& mutex, unsigned long sec,
bool wxCondition::Wait(wxMutex& mutex,
unsigned long sec,
unsigned long nsec)
{
// DWORD ret;
mutex.Unlock();
p_internal->waiters++;
// TODO wait here
// ret = WaitForSingleObject(p_internal->event, (sec*1000)+(nsec/1000000));
p_internal->waiters--;
mutex.Lock();
return FALSE;
return TRUE; // false for timeout
}
void wxCondition::Signal()
{
// TODO
// SetEvent(p_internal->event);
}
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:
// 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()
{
// TODO
if ( !p_internal->Create(this) )
return wxTHREAD_NO_RESOURCE;
return wxTHREAD_NO_ERROR;
}
wxThreadError wxThread::Destroy()
wxThreadError wxThread::Run()
{
// TODO
return wxTHREAD_NO_ERROR;
wxCriticalSectionLocker lock(m_critsect);
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()
{
// TODO
return wxTHREAD_NO_ERROR;
wxCriticalSectionLocker lock(m_critsect);
return p_internal->Suspend() ? wxTHREAD_NO_ERROR : wxTHREAD_MISC_ERROR;
}
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;
}
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
return 0;
}
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
void wxThread::DeferDestroy(bool on)
{
// TODO
}
void wxThread::TestDestroy()
{
// TODO
}
void *wxThread::Join()
{
// TODO
return (void*) NULL;
return p_internal->GetPriority();
}
unsigned long wxThread::GetID() const
{
// TODO
return 0;
}
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
/* is this needed somewhere ?
wxThread *wxThread::GetThreadFromID(unsigned long id)
{
// TODO
return NULL;
}
*/
bool wxThread::IsAlive() const
{
// TODO
return FALSE;
return (unsigned long)p_internal->GetId();
}
bool wxThread::IsRunning() const
{
// TODO
return FALSE;
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
return p_internal->GetState() == STATE_RUNNING;
}
bool wxThread::IsMain()
bool wxThread::IsAlive() const
{
// TODO
return FALSE;
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
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()
{
p_internal = new wxThreadInternal();
// TODO
}
wxThread::~wxThread()
{
Destroy();
Join();
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:
virtual bool OnInit() {
/* TODO p_mainid = GetCurrentThread(); */
wxMainMutex = new wxMutex();
wxMainMutex->Lock();
return TRUE;
}
virtual bool OnInit();
virtual void OnExit();
// Global cleanup
virtual void OnExit() {
wxMainMutex->Unlock();
delete wxMainMutex;
}
private:
DECLARE_DYNAMIC_CLASS(wxThreadModule)
};
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

View File

@@ -23,11 +23,6 @@
#include <string.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
#endif
bool wxOpenClipboard()
{
return TRUE;
@@ -90,26 +85,36 @@ bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
* Generalized clipboard implementation by Matthew Flatt
*/
wxClipboard *wxTheClipboard = NULL;
void wxInitClipboard()
{
if (!wxTheClipboard)
wxTheClipboard = new wxClipboard;
}
wxClipboard::wxClipboard()
{
clipOwner = NULL;
cbString = NULL;
m_clearOnExit = FALSE;
}
wxClipboard::~wxClipboard()
{
if (clipOwner)
clipOwner->BeingReplaced();
if (cbString)
delete[] cbString;
if ( m_clearOnExit )
{
Clear();
}
}
void wxClipboard::Clear()
{
}
bool wxClipboard::Flush()
{
return FALSE;
}
bool wxClipboard::Open()
{
return wxOpenClipboard();
}
bool wxClipboard::IsOpened() const
{
return wxIsClipboardOpened();
}
static int FormatStringToID(char *str)
@@ -120,6 +125,129 @@ static int FormatStringToID(char *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)
{
bool got_selection;
@@ -167,7 +295,7 @@ wxClipboardClient *wxClipboard::GetClipboardClient()
}
void wxClipboard::SetClipboardString(char *str, long time)
{/*
{
bool got_selection;
if (clipOwner) {
@@ -193,9 +321,7 @@ void wxClipboard::SetClipboardString(char *str, long time)
delete[] cbString;
cbString = NULL;
}
*/
}
char *wxClipboard::GetClipboardString(long time)
{
char *str;
@@ -210,6 +336,7 @@ char *wxClipboard::GetClipboardString(long time)
return str;
}
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
{
if (clipOwner) {
@@ -233,4 +360,5 @@ char *wxClipboard::GetClipboardData(char *format, long *length, long time)
return receivedString;
}
}
*/

View File

@@ -53,7 +53,9 @@ wxControl::wxControl()
m_macVerticalBorder = 0 ;
m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK;
#if WXWIN_COMPATIBILITY
m_callback = 0;
#endif // WXWIN_COMPATIBILITY
if ( wxMacLiveScrollbarActionUPP == NULL )
{
@@ -63,13 +65,14 @@ wxControl::wxControl()
wxControl::~wxControl()
{
m_isBeingDeleted = TRUE;
// If we delete an item, we should initialize the parent panel,
// because it could now be invalid.
wxWindow *parent = (wxWindow *)GetParent();
if (parent)
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
if ( panel )
{
if (parent->GetDefaultItem() == (wxButton*) this)
parent->SetDefaultItem(NULL);
if (panel->GetDefaultItem() == (wxButton*) this)
panel->SetDefaultItem(NULL);
}
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 )
{
Str255 maclabel ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )
label = wxMacMakeMacStringFromPC( title ) ;
else
label = title ;
strcpy( (char*) maclabel , label ) ;
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:
// 1) A callback function (to become obsolete)
// 2) OnCommand, starting at this window and working up parent hierarchy
// 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
#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;
wxControl *wxFindControlFromMacControl(ControlHandle inControl )
@@ -352,6 +336,7 @@ void wxControl::MacSuperChangedPosition()
void wxControl::MacSuperEnabled( bool enabled )
{
/*
if ( m_macControl )
{
if ( UMAHasAppearance() )
@@ -380,10 +365,12 @@ void wxControl::MacSuperEnabled( bool enabled )
}
}
wxWindow::MacSuperEnabled( enabled ) ;
*/
}
void wxControl::MacSuperShown( bool show )
{
/*
if ( m_macControl )
{
if ( !show )
@@ -398,6 +385,7 @@ void wxControl::MacSuperShown( bool show )
}
wxWindow::MacSuperShown( show ) ;
*/
}
void wxControl::DoSetSize(int x, int y,
@@ -503,34 +491,28 @@ void wxControl::DoSetSize(int x, int y,
}
}
void wxControl::DoSetClientSize(int width, int height)
{
DoSetSize( -1 , -1 , width , height ) ;
}
bool wxControl::Show(bool show)
{
if ( m_macControl == NULL )
return wxWindow::Show( show ) ;
if ( m_macShown == show )
return TRUE ;
if ( !wxWindow::Show( show ) )
return FALSE ;
if ( m_macControl )
{
if ( show )
::UMAShowControl( m_macControl ) ;
else
::UMAHideControl( m_macControl ) ;
return wxWindow::Show( show ) ;
}
return TRUE ;
}
void wxControl::Enable(bool enable)
bool wxControl::Enable(bool enable)
{
if ( m_macControl == NULL )
return wxWindow::Enable( enable ) ;
if ( !wxWindow::Enable(enable) )
return FALSE;
if ( m_macEnabled == enable )
return ;
if ( m_macControl )
{
if ( UMAHasAppearance() )
{
@@ -546,8 +528,8 @@ void wxControl::Enable(bool enable)
else
::HiliteControl( m_macControl , 255 ) ;
}
return wxWindow::Enable( enable ) ;
}
return TRUE ;
}
void wxControl::Refresh(bool eraseBack, const wxRect *rect)
@@ -579,9 +561,9 @@ void wxControl::OnPaint(wxPaintEvent& event)
wxWindow* parent = GetParent() ;
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 ;
}
@@ -596,13 +578,13 @@ void wxControl::OnPaint(wxPaintEvent& event)
}
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
{
wxWindow::OnPaint( event ) ;
// wxWindow::OnPaint( event ) ;
}
}

View File

@@ -108,7 +108,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDialogBackgroundActive ;
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
m_macWindowData->m_macFocus = NULL ;
m_macShown = false ;
return TRUE;
}
@@ -127,8 +126,11 @@ void wxDialog::SetModal(bool flag)
wxDialog::~wxDialog()
{
m_isBeingDeleted = TRUE ;
wxTopLevelWindows.DeleteObject(this);
m_modalShowing = FALSE;
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
wxModelessWindows.DeleteObject(this);
@@ -176,18 +178,45 @@ extern bool s_macIsInModalLoop ;
bool wxDialog::Show(bool show)
{
if ( m_macShown == show )
return TRUE ;
m_isShown = show;
m_macShown = show ;
if (show)
InitDialog();
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 )
{
s_macIsInModalLoop = true ;
if (show)
{
if (m_modalShowing)
{
// BringWindowToTop((HWND) GetHWND());
return TRUE;
}
m_modalShowing = TRUE;
// 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
@@ -334,125 +363,3 @@ void wxDialog::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;
}

View File

@@ -22,39 +22,42 @@
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
#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_pointSize = 0;
m_family = 0;
m_style = 0;
m_weight = 0;
m_underlined = 0;
m_faceName = "";
m_style = style;
m_pointSize = pointSize;
m_family = family;
m_style = style;
m_weight = weight;
m_underlined = underlined;
m_faceName = faceName;
m_encoding = encoding;
m_macFontSize = m_pointSize ;
m_macFontNum = systemFont ;
m_macFontStyle = normal ;
}
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 ;
m_macFontNum = 0 ;
m_macFontSize = 0;
m_macFontStyle = 0;
m_fontId = 0;
}
wxFontRefData::~wxFontRefData()
{
// TODO: delete font data
}
void wxFontRefData::MacFindFont()
@@ -107,31 +110,27 @@ void wxFontRefData::MacFindFont()
m_macFontSize = m_pointSize ;
}
wxFont::wxFont()
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
void wxFont::Init()
{
if ( wxTheFontList )
wxTheFontList->Append(this);
}
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
{
Create(pointSize, family, style, weight, underlined, faceName);
if ( wxTheFontList )
wxTheFontList->Append(this);
}
bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
bool wxFont::Create(int pointSize,
int family,
int style,
int weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
{
UnRef();
m_refData = new wxFontRefData;
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;
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, faceName, encoding);
RealizeResource();
@@ -219,78 +218,50 @@ void wxFont::SetUnderlined(bool underlined)
RealizeResource();
}
wxString wxFont::GetFamilyString() const
// ----------------------------------------------------------------------------
// accessors
// ----------------------------------------------------------------------------
int wxFont::GetPointSize() const
{
wxString fam("");
switch (GetFamily())
{
case wxDECORATIVE:
fam = "wxDECORATIVE";
break;
case wxROMAN:
fam = "wxROMAN";
break;
case wxSCRIPT:
fam = "wxSCRIPT";
break;
case wxSWISS:
fam = "wxSWISS";
break;
case wxMODERN:
fam = "wxMODERN";
break;
case wxTELETYPE:
fam = "wxTELETYPE";
break;
default:
fam = "wxDEFAULT";
break;
}
return fam;
return M_FONTDATA->m_pointSize;
}
int wxFont::GetFamily() const
{
return M_FONTDATA->m_family;
}
int wxFont::GetFontId() const
{
return M_FONTDATA->m_fontId;
}
int wxFont::GetStyle() const
{
return M_FONTDATA->m_style;
}
int wxFont::GetWeight() const
{
return M_FONTDATA->m_weight;
}
bool wxFont::GetUnderlined() const
{
return M_FONTDATA->m_underlined;
}
/* New font system */
wxString wxFont::GetFaceName() const
{
wxString str("");
if (M_FONTDATA)
wxString str;
if ( M_FONTDATA )
str = M_FONTDATA->m_faceName ;
return str;
}
wxString wxFont::GetStyleString() const
wxFontEncoding wxFont::GetEncoding() const
{
wxString styl("");
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;
return M_FONTDATA->m_encoding;
}

View File

@@ -52,12 +52,10 @@ wxFrame::wxFrame()
#if wxUSE_TOOLBAR
m_frameToolBar = NULL ;
#endif
m_macShown = false ;
// in order to be able to give size events on show
m_frameMenuBar = NULL;
m_frameStatusBar = NULL;
m_windowParent = NULL;
m_iconized = FALSE;
}
@@ -147,7 +145,6 @@ bool wxFrame::Create(wxWindow *parent,
UMACreateRootControl( m_macWindowData->m_macWindow , &m_macWindowData->m_macRootControl ) ;
m_macWindowData->m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ;
m_macWindowData->m_macFocus = NULL ;
m_macShown = false ;
return TRUE;
}

View File

@@ -106,57 +106,120 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
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 ) ;
}
void wxListBox::SetFirstItem(const wxString& s)
{
MacScrollTo( FindString( s ) ) ;
}
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_noItems --;
MacDelete( N ) ;
SetHorizontalExtent("");
}
void wxListBox::Append(const wxString& item)
{
Append( item , NULL ) ;
}
void wxListBox::Append(const wxString& item, char *Client_data)
int wxListBox::DoAppend(const wxString& item)
{
int index = m_noItems ;
if( wxApp::s_macDefaultEncodingIsPC )
{
m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
}
else
m_stringArray.Add( item ) ;
m_dataArray.Add( Client_data ) ;
m_noItems ++;
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() ;
int n = choices.GetCount();
for( int i = 0 ; i < n ; ++i )
{
if ( clientData )
{
#if wxUSE_OWNER_DRAWN
wxASSERT_MSG(clientData[i] == NULL,
wxT("Can't use client data with owner-drawn listboxes"));
#else // !wxUSE_OWNER_DRAWN
Append( choices[i] , clientData[0] ) ;
#endif
}
else
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
@@ -192,10 +255,12 @@ int wxListBox::FindString(const wxString& st) const
void wxListBox::Clear()
{
Free();
m_noItems = 0;
m_stringArray.Empty() ;
m_dataArray.Empty() ;
MacClear() ;
SetHorizontalExtent();
}
void wxListBox::SetSelection(int N, bool select)
@@ -205,7 +270,7 @@ void wxListBox::SetSelection(int N, bool select)
MacSetSelection( N , select ) ;
}
bool wxListBox::Selected(int N) const
bool wxListBox::IsSelected(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
"invalid index in wxListBox::Selected" );
@@ -213,28 +278,33 @@ bool wxListBox::Selected(int N) const
return MacIsSelected( N ) ;
}
void wxListBox::Deselect(int N)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
"invalid index in wxListBox::Deselect" );
SetSelection( N , false ) ;
}
char *wxListBox::GetClientData(int N) const
void *wxListBox::DoGetItemClientData(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
"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,
"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
@@ -277,8 +347,13 @@ wxString wxListBox::GetString(int N) const
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++ )
{
m_stringArray.Insert( items[i] , pos + i ) ;
@@ -295,46 +370,11 @@ void wxListBox::SetString(int N, const wxString& 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
@@ -484,29 +524,27 @@ void wxListBox::MacSetRedraw( bool doDraw )
void wxListBox::MacDoClick()
{
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
event.SetEventObject( this );
wxArrayInt aSelections;
int count = GetSelections(aSelections);
int n, count = GetSelections(aSelections);
if ( count > 0 )
{
event.m_commandInt = aSelections[0] ;
event.m_clientData = GetClientData(event.m_commandInt);
wxString str(GetString(event.m_commandInt));
if (str != "")
event.m_commandString = copystring((char *)(const char *)str);
if ( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );
else if ( HasClientUntypedData() )
event.SetClientData( GetClientData(n) );
event.SetString( GetString(n) );
}
else
{
return ;
/*
event.m_commandInt = -1 ;
event.m_commandString = copystring("") ;
*/
n = -1;
}
event.SetEventObject( this );
ProcessCommand(event);
if (event.m_commandString)
delete[] event.m_commandString ;
event.m_commandInt = n;
GetEventHandler()->ProcessEvent(event);
}
void wxListBox::MacDoDoubleClick()

View File

@@ -82,17 +82,7 @@ void wxMDIParentFrame::GetClientSize(int *x, int *y) const
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
{
// TODO
if (!menu_bar)
{
m_frameMenuBar = NULL;
return;
}
if (menu_bar->m_menuBarFrame)
return;
m_frameMenuBar = menu_bar;
wxFrame::SetMenuBar( menu_bar ) ;
}
void wxMDIParentFrame::OnSize(wxSizeEvent& event)
@@ -211,16 +201,7 @@ void wxMDIChildFrame::GetPosition(int *x, int *y) const
void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
{
// TODO
if (!menu_bar)
{
m_frameMenuBar = NULL;
return;
}
if (menu_bar->m_menuBarFrame)
return;
m_frameMenuBar = menu_bar;
return wxFrame::SetMenuBar( menu_bar ) ;
}
// MDI operations

File diff suppressed because it is too large Load Diff

View File

@@ -37,23 +37,25 @@
// -----------
wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
const wxString& strName, const wxString& strHelp,
const wxString& text, const wxString& strHelp,
bool bCheckable,
wxMenu *pSubMenu) :
m_bCheckable(bCheckable),
m_strName(strName),
m_strHelp(strHelp)
wxMenu *pSubMenu)
{
wxASSERT( pParentMenu != NULL );
m_pParentMenu = pParentMenu;
m_pSubMenu = pSubMenu;
m_idItem = id;
m_bEnabled = TRUE;
m_parentMenu = pParentMenu;
m_subMenu = pSubMenu;
m_isEnabled = 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" ;
}
}
@@ -64,53 +66,57 @@ wxMenuItem::~wxMenuItem()
// misc
// ----
/*
// delete the sub menu
void wxMenuItem::DeleteSubMenu()
{
wxASSERT( m_pSubMenu != NULL );
wxASSERT( m_subMenu != NULL );
delete m_pSubMenu;
m_pSubMenu = NULL;
delete m_subMenu;
m_subMenu = NULL;
}
*/
// change item state
// -----------------
void wxMenuItem::Enable(bool bDoEnable)
{
if ( m_bEnabled != bDoEnable ) {
if ( m_pSubMenu == NULL )
if ( m_isEnabled != bDoEnable ) {
if ( m_subMenu == NULL )
{
// 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 ( bDoEnable )
UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
UMAEnableMenuItem( m_parentMenu->GetHMenu() , index ) ;
else
UMADisableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
UMADisableMenuItem( m_parentMenu->GetHMenu() , index ) ;
}
}
}
else
{
// 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 ( bDoEnable )
UMAEnableMenuItem( m_pParentMenu->m_macMenuHandle , index ) ;
UMAEnableMenuItem( m_parentMenu->GetHMenu() , index ) ;
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" );
if ( m_bChecked != bDoCheck )
if ( m_isChecked != bDoCheck )
{
m_bChecked = bDoCheck;
if ( m_pParentMenu->m_macMenuHandle )
m_isChecked = bDoCheck;
if ( m_parentMenu->GetHMenu() )
{
int index = m_pParentMenu->MacGetIndexFromItem( this ) ;
int index = m_parentMenu->MacGetIndexFromItem( this ) ;
if ( index >= 1 )
{
if ( bDoCheck )
::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0x12 ) ; // checkmark
::SetItemMark( m_parentMenu->GetHMenu() , index , 0x12 ) ; // checkmark
else
::SetItemMark( m_pParentMenu->m_macMenuHandle , index , 0 ) ; // no mark
::SetItemMark( m_parentMenu->GetHMenu() , index , 0 ) ; // no mark
}
}
}

View File

@@ -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
}

View File

@@ -14,7 +14,7 @@
#endif
#include "wx/object.h"
#include "wx/mac/printdlg.h"
#include "wx/printdlg.h"
#include "wx/dcprint.h"
// 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)
#endif
wxPrintDialog::wxPrintDialog():
wxDialog()
wxPrintDialog::wxPrintDialog()
{
m_dialogParent = NULL;
m_printerDC = NULL;
m_destroyDC = TRUE;
}
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintData* data):
wxDialog()
wxPrintDialog::wxPrintDialog(wxWindow *p, wxPrintDialogData* 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_printerDC = NULL;
m_destroyDC = TRUE;
if ( data )
m_printData = *data;
m_printDialogData = *data;
return TRUE;
}
wxPrintDialog::~wxPrintDialog()
{
if (m_destroyDC && m_printerDC)
delete m_printerDC;
}
int wxPrintDialog::ShowModal()
@@ -60,10 +73,10 @@ int wxPrintDialog::ShowModal()
if ( !err )
{
m_printData.ConvertToNative() ;
if ( m_printData.macPrintInfo && ::PrJobDialog( m_printData.macPrintInfo ) )
m_printDialogData.ConvertToNative() ;
if ( m_printDialogData.m_macPrintInfo && ::PrJobDialog( m_printDialogData.m_macPrintInfo ) )
{
m_printData.ConvertFromNative() ;
m_printDialogData.ConvertFromNative() ;
result = wxID_OK ;
}
@@ -80,7 +93,7 @@ int wxPrintDialog::ShowModal()
wxDC *wxPrintDialog::GetPrintDC()
{
return new wxPrinterDC( m_printData ) ;
return new wxPrinterDC( m_printDialogData.GetPrintData() ) ;
}
/*

View File

@@ -67,17 +67,6 @@ wxRadioBox::~wxRadioBox()
// 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
{
// TODO
@@ -106,28 +95,28 @@ wxString wxRadioBox::GetString(int n) const
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
{
// TODO
wxControl::GetSize( width , height ) ;
}
void wxRadioBox::GetPosition(int *x, int *y) const
{
// TODO
wxControl::GetPosition( x , y ) ;
}
wxString wxRadioBox::GetLabel() const
wxString wxRadioBox::GetLabel( int item ) const
{
// TODO
return wxString("");
}
void wxRadioBox::SetLabel(const wxString& label)
void wxRadioBox::SetLabel(int item , const wxString& label)
{
// TODO
}
@@ -139,23 +128,18 @@ void wxRadioBox::SetFocus()
bool wxRadioBox::Show(bool show)
{
// TODO
return wxWindow::Show( show ) ;
return wxControl::Show( show ) ;
}
// Enable a specific button
void wxRadioBox::Enable(int item, bool enable)
{
wxControl::Enable(enable);
// TODO
}
// Enable all controls
void wxRadioBox::Enable(bool enable)
bool wxRadioBox::Enable(bool enable)
{
wxControl::Enable(enable);
// TODO
return wxControl::Enable(enable);
}
// Show a specific button

View File

@@ -16,15 +16,18 @@
#include "wx/spinbutt.h"
#include "wx/mac/uma.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
#endif
// ============================================================================
// implementation
// ============================================================================
wxSpinButton::wxSpinButton()
{
m_min = 0;
m_max = 100;
}
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
#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,
long style, const wxString& name)
@@ -78,14 +81,6 @@ void wxSpinButton::SetRange(int minVal, int 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 )
{
if ( m_macControl == NULL )

View File

@@ -47,7 +47,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
void wxStaticText::SetLabel(const wxString& st , bool resize )
{
m_label = st ;
SetTitle( st ) ;
wxString label ;
if( wxApp::s_macDefaultEncodingIsPC )

View File

@@ -409,42 +409,29 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
bool handleIt = true ;
switch( event.KeyCode() )
{
case WXK_RETURN:
{
/* Oh yes it will, because we also specify DLGC_WANTCHARS
wxASSERT_MSG( m_windowStyle & wxTE_PROCESS_ENTER,
"this text ctrl should never receive return" );
*/
if ( !(m_windowStyle & wxTE_MULTILINE) )
{
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject( this );
if ( GetEventHandler()->ProcessEvent(event) )
return;
}
//else: multiline controls need Enter for themselves
if ( (m_windowStyle & wxTE_MULTILINE) == 0 )
{
wxWindow* parent = GetParent() ;
while( parent )
{
if ( parent->GetDefaultItem() )
{
wxButton *defaultBtn = parent->GetDefaultItem() ;
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, defaultBtn->GetId() );
event.SetEventObject(defaultBtn);
defaultBtn->Command(event);
return ;
}
parent = parent->GetParent() ;
} ;
}
break;
}
case WXK_TAB:
// only produce navigation event if we don't process TAB ourself or
// if it's a Shift-Tab keypress (we assume nobody will ever need
// this key combo for himself)
// always produce navigation event - even if we process TAB
// ourselves the fact that we got here means that the user code
// 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
// handled by Windows
if ( event.ShiftDown() || !(m_windowStyle & wxTE_PROCESS_TAB) )
{
wxNavigationKeyEvent eventNav;
eventNav.SetDirection(!event.ShiftDown());
@@ -455,27 +442,18 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
return;
}
break;
default:
event.Skip();
return;
}
if ( handleIt )
{
EventRecord *ev = wxTheApp->MacGetCurrentEvent() ;
short keycode ;
short keychar ;
keychar = short(ev->message & charCodeMask);
keycode = short(ev->message & keyCodeMask) >> 8 ;
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);
}
}
}
// don't just call event.Skip() because this will cause TABs and ENTERs
// be passed upwards and we don't always want this - instead process it
// right here
// FIXME
event.Skip();
}
// 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

View File

@@ -1,71 +1,146 @@
/////////////////////////////////////////////////////////////////////////////
// Name: thread.cpp
// Purpose: wxThread Implementation. For Unix ports, see e.g. src/gtk
// Purpose: wxThread Implementation
// Author: Original from Wolfram Gloger/Guilhem Lavaux
// Modified by:
// Modified by: Vadim Zeitlin to make it work :-)
// Created: 04/22/98
// 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
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "thread.h"
#pragma implementation "thread.h"
#endif
#include "wx/module.h"
#include "wx/thread.h"
#include "wx/utils.h"
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
enum thread_state {
STATE_IDLE = 0,
STATE_RUNNING,
STATE_CANCELED,
STATE_EXITED
};
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if wxUSE_THREADS
/////////////////////////////////////////////////////////////////////////////
// Static variables
/////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
wxMutex *wxMainMutex; // controls access to all GUI functions
#include <windows.h>
/////////////////////////////////////////////////////////////////////////////
// Windows implementation
/////////////////////////////////////////////////////////////////////////////
#include "wx/module.h"
#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:
// TODO: internal mutex handle
Handle p_mutex;
};
wxMutex::wxMutex()
{
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;
}
wxMutex::~wxMutex()
{
if (m_locked > 0)
wxDebugMsg("wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked);
// TODO: free internal mutext handle
wxLogDebug(wxT("Warning: freeing a locked mutex (%d locks)."), m_locked);
// CloseHandle(p_internal->p_mutex);
}
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++;
return wxMUTEX_NO_ERROR;
}
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++;
*/
return wxMUTEX_NO_ERROR;
}
@@ -73,192 +148,715 @@ wxMutexError wxMutex::Unlock()
{
if (m_locked > 0)
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;
}
class wxConditionInternal {
// ----------------------------------------------------------------------------
// wxCondition implementation
// ----------------------------------------------------------------------------
class wxConditionInternal
{
public:
// TODO: internal handle
Handle event;
int waiters;
};
wxCondition::wxCondition()
{
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;
}
wxCondition::~wxCondition()
{
// TODO: destroy internal handle
// CloseHandle(p_internal->event);
}
void wxCondition::Wait(wxMutex& mutex)
{
mutex.Unlock();
p_internal->waiters++;
// TODO wait here
// WaitForSingleObject(p_internal->event, INFINITE);
p_internal->waiters--;
mutex.Lock();
}
bool wxCondition::Wait(wxMutex& mutex, unsigned long sec,
bool wxCondition::Wait(wxMutex& mutex,
unsigned long sec,
unsigned long nsec)
{
// DWORD ret;
mutex.Unlock();
p_internal->waiters++;
// TODO wait here
// ret = WaitForSingleObject(p_internal->event, (sec*1000)+(nsec/1000000));
p_internal->waiters--;
mutex.Lock();
return FALSE;
return TRUE; // false for timeout
}
void wxCondition::Signal()
{
// TODO
// SetEvent(p_internal->event);
}
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:
// 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()
{
// TODO
if ( !p_internal->Create(this) )
return wxTHREAD_NO_RESOURCE;
return wxTHREAD_NO_ERROR;
}
wxThreadError wxThread::Destroy()
wxThreadError wxThread::Run()
{
// TODO
return wxTHREAD_NO_ERROR;
wxCriticalSectionLocker lock(m_critsect);
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()
{
// TODO
return wxTHREAD_NO_ERROR;
wxCriticalSectionLocker lock(m_critsect);
return p_internal->Suspend() ? wxTHREAD_NO_ERROR : wxTHREAD_MISC_ERROR;
}
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;
}
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
return 0;
}
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
void wxThread::DeferDestroy(bool on)
{
// TODO
}
void wxThread::TestDestroy()
{
// TODO
}
void *wxThread::Join()
{
// TODO
return (void*) NULL;
return p_internal->GetPriority();
}
unsigned long wxThread::GetID() const
{
// TODO
return 0;
}
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
/* is this needed somewhere ?
wxThread *wxThread::GetThreadFromID(unsigned long id)
{
// TODO
return NULL;
}
*/
bool wxThread::IsAlive() const
{
// TODO
return FALSE;
return (unsigned long)p_internal->GetId();
}
bool wxThread::IsRunning() const
{
// TODO
return FALSE;
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
return p_internal->GetState() == STATE_RUNNING;
}
bool wxThread::IsMain()
bool wxThread::IsAlive() const
{
// TODO
return FALSE;
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
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()
{
p_internal = new wxThreadInternal();
// TODO
}
wxThread::~wxThread()
{
Destroy();
Join();
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:
virtual bool OnInit() {
/* TODO p_mainid = GetCurrentThread(); */
wxMainMutex = new wxMutex();
wxMainMutex->Lock();
return TRUE;
}
virtual bool OnInit();
virtual void OnExit();
// Global cleanup
virtual void OnExit() {
wxMainMutex->Unlock();
delete wxMainMutex;
}
private:
DECLARE_DYNAMIC_CLASS(wxThreadModule)
};
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