SetEventData for a few widgets

Re-installed wxBitmaps::LoafFile


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@964 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-11-06 08:50:52 +00:00
parent 3572173c01
commit fd0eed647d
32 changed files with 3663 additions and 2706 deletions

View File

@@ -309,8 +309,8 @@ class WXDLLEXPORT wxCommandEvent: public wxEvent
*/ */
// Set/Get listbox/choice client data // Set/Get listbox/choice client data
inline void SetClientData(char* clientData) { m_clientData = clientData; } inline void SetClientData(void* clientData) { m_clientData = clientData; }
inline char *GetClientData() const { return m_clientData; } inline void *GetClientData() const { return m_clientData; }
// Get listbox selection if single-choice // Get listbox selection if single-choice
inline int GetSelection() const { return m_commandInt; } inline int GetSelection() const { return m_commandInt; }
@@ -335,7 +335,7 @@ class WXDLLEXPORT wxCommandEvent: public wxEvent
char* m_commandString; // String event argument char* m_commandString; // String event argument
int m_commandInt; int m_commandInt;
long m_extraLong; // Additional information (e.g. select/deselect) long m_extraLong; // Additional information (e.g. select/deselect)
char* m_clientData; // Arbitrary client data void* m_clientData; // Arbitrary client data
}; };
// Scroll event class // Scroll event class

View File

@@ -69,7 +69,7 @@ public:
// Because the objects of this class are deleted by the tree, they should // Because the objects of this class are deleted by the tree, they should
// always be allocated on the heap! // always be allocated on the heap!
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeItemData class WXDLLEXPORT wxTreeItemData: public wxClientData
{ {
friend class wxTreeCtrl; friend class wxTreeCtrl;
public: public:
@@ -80,11 +80,6 @@ public:
// default copy ctor/assignment operator are ok // default copy ctor/assignment operator are ok
// dtor is virtual and all the items are deleted by the tree control
// when it's deleted, so you normally don't have to care about freeing
// memory allocated in your wxTreeItemData-derived class
virtual ~wxTreeItemData() { }
// accessor: get the item associated with us // accessor: get the item associated with us
const wxTreeItemId& GetId() const { return m_pItem; } const wxTreeItemId& GetId() const { return m_pItem; }
void SetId(const wxTreeItemId& id) { m_pItem = id; } void SetId(const wxTreeItemId& id) { m_pItem = id; }

View File

@@ -37,7 +37,6 @@ class wxMask: public wxObject
DECLARE_DYNAMIC_CLASS(wxMask) DECLARE_DYNAMIC_CLASS(wxMask)
public: public:
wxMask(); wxMask();
wxMask( const wxBitmap& bitmap, const wxColour& colour ); wxMask( const wxBitmap& bitmap, const wxColour& colour );
wxMask( const wxBitmap& bitmap, int paletteIndex ); wxMask( const wxBitmap& bitmap, int paletteIndex );
@@ -46,14 +45,8 @@ class wxMask: public wxObject
// implementation // implementation
GdkBitmap *GetBitmap() const;
protected:
friend wxBitmap;
GdkBitmap *m_bitmap; GdkBitmap *m_bitmap;
GdkBitmap *GetBitmap() const;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -65,7 +58,6 @@ class wxBitmap: public wxObject
DECLARE_DYNAMIC_CLASS(wxBitmap) DECLARE_DYNAMIC_CLASS(wxBitmap)
public: public:
wxBitmap(); wxBitmap();
wxBitmap( int width, int height, int depth = -1 ); wxBitmap( int width, int height, int depth = -1 );
wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 );

View File

@@ -42,7 +42,7 @@ class wxButton: public wxControl
public: public:
wxButton(void); wxButton();
inline wxButton(wxWindow *parent, wxWindowID id, const wxString& label, inline wxButton(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
@@ -51,19 +51,19 @@ class wxButton: public wxControl
{ {
Create(parent, id, label, pos, size, style, validator, name); Create(parent, id, label, pos, size, style, validator, name);
} }
~wxButton();
bool Create(wxWindow *parent, wxWindowID id, const wxString& label, bool Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr); const wxString& name = wxButtonNameStr);
void SetDefault(void); void SetDefault();
void SetLabel( const wxString &label ); void SetLabel( const wxString &label );
void Enable( bool enable ); void Enable( bool enable );
// implementation // implementation
void ApplyWidgetStyle(); void ApplyWidgetStyle();
}; };
#endif // __GTKBUTTONH__ #endif // __GTKBUTTONH__

View File

@@ -42,7 +42,7 @@ class wxChoice: public wxControl
public: public:
wxChoice(void); wxChoice();
inline wxChoice( wxWindow *parent, wxWindowID id, inline wxChoice( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -53,6 +53,7 @@ class wxChoice: public wxControl
{ {
Create(parent, id, pos, size, n, choices, style, validator, name); Create(parent, id, pos, size, n, choices, style, validator, name);
} }
~wxChoice();
bool Create( wxWindow *parent, wxWindowID id, bool Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -60,21 +61,34 @@ class wxChoice: public wxControl
long style = 0, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr ); const wxString& name = wxChoiceNameStr );
void Append( const wxString &item ); void Append( const wxString &item );
void Clear(void); void Append( const wxString &item, void* clientData );
void Append( const wxString &item, wxClientData* clientData );
void SetClientData( int n, void* clientData );
void* GetClientData( int n );
void SetClientObject( int n, wxClientData* clientData );
wxClientData* GetClientObject( int n );
void Clear();
void Delete(int n); void Delete(int n);
int FindString( const wxString &string ) const; int FindString( const wxString &string ) const;
int GetColumns(void) const; int GetColumns() const;
int GetSelection(void); int GetSelection();
wxString GetString( int n ) const; wxString GetString( int n ) const;
wxString GetStringSelection(void) const; wxString GetStringSelection() const;
int Number(void) const; int Number() const;
void SetColumns( int n = 1 ); void SetColumns( int n = 1 );
void SetSelection( int n ); void SetSelection( int n );
void SetStringSelection( const wxString &string ); void SetStringSelection( const wxString &string );
// implementation // implementation
wxList m_clientDataList;
void AppendCommon( const wxString &item );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
}; };

View File

@@ -42,8 +42,8 @@ class wxComboBox: public wxControl
DECLARE_DYNAMIC_CLASS(wxComboBox) DECLARE_DYNAMIC_CLASS(wxComboBox)
public: public:
inline wxComboBox(void) {}
inline wxComboBox() {}
inline wxComboBox(wxWindow *parent, wxWindowID id, inline wxComboBox(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString, const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -55,6 +55,7 @@ class wxComboBox: public wxControl
{ {
Create(parent, id, value, pos, size, n, choices, style, validator, name); Create(parent, id, value, pos, size, n, choices, style, validator, name);
} }
~wxComboBox();
bool Create(wxWindow *parent, wxWindowID id, bool Create(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString, const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -64,30 +65,36 @@ class wxComboBox: public wxControl
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr); const wxString& name = wxComboBoxNameStr);
void Clear(void);
void Append( const wxString &item ); void Append( const wxString &item );
void Append( const wxString &item, char* clientData ); void Append( const wxString &item, void* clientData );
void Append( const wxString &item, wxClientData* clientData );
void SetClientData( int n, void* clientData );
void* GetClientData( int n );
void SetClientObject( int n, wxClientData* clientData );
wxClientData* GetClientObject( int n );
void Clear();
void Delete( int n ); void Delete( int n );
int FindString( const wxString &item ); int FindString( const wxString &item );
char* GetClientData( int n ); int GetSelection() const;
void SetClientData( int n, char * clientData );
int GetSelection(void) const;
wxString GetString( int n ) const; wxString GetString( int n ) const;
wxString GetStringSelection(void) const; wxString GetStringSelection() const;
int Number(void) const; int Number() const;
void SetSelection( int n ); void SetSelection( int n );
void SetStringSelection( const wxString &string ); void SetStringSelection( const wxString &string );
wxString GetValue(void) const ; wxString GetValue() const;
void SetValue(const wxString& value); void SetValue(const wxString& value);
void Copy(void); void Copy();
void Cut(void); void Cut();
void Paste(void); void Paste();
void SetInsertionPoint( long pos ); void SetInsertionPoint( long pos );
void SetInsertionPointEnd(void); void SetInsertionPointEnd();
long GetInsertionPoint(void) const ; long GetInsertionPoint() const;
long GetLastPosition(void) const ; long GetLastPosition() const;
void Replace( long from, long to, const wxString& value ); void Replace( long from, long to, const wxString& value );
void Remove( long from, long to ); void Remove( long from, long to );
void SetSelection( long from, long to ); void SetSelection( long from, long to );
@@ -98,9 +105,10 @@ class wxComboBox: public wxControl
// implementation // implementation
bool m_alreadySent; bool m_alreadySent;
wxList m_clientData; wxList m_clientDataList;
GtkWidget* GetConnectWidget(void); void AppendCommon( const wxString &item );
GtkWidget* GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle(); void ApplyWidgetStyle();

View File

@@ -43,7 +43,7 @@ class wxListBox: public wxControl
public: public:
wxListBox(void); wxListBox();
inline wxListBox( wxWindow *parent, wxWindowID id, inline wxListBox( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -54,6 +54,7 @@ class wxListBox: public wxControl
{ {
Create(parent, id, pos, size, n, choices, style, validator, name); Create(parent, id, pos, size, n, choices, style, validator, name);
} }
~wxListBox();
bool Create( wxWindow *parent, wxWindowID id, bool Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -61,21 +62,28 @@ class wxListBox: public wxControl
long style = 0, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr ); const wxString& name = wxListBoxNameStr );
void Append( const wxString &item ); void Append( const wxString &item );
void Append( const wxString &item, char *clientData ); void Append( const wxString &item, void* clientData );
void Clear(void); void Append( const wxString &item, wxClientData* clientData );
void SetClientData( int n, void* clientData );
void* GetClientData( int n );
void SetClientObject( int n, wxClientData* clientData );
wxClientData* GetClientObject( int n );
void Clear();
void Delete( int n ); void Delete( int n );
void Deselect( int n ); void Deselect( int n );
int FindString( const wxString &item ) const; int FindString( const wxString &item ) const;
char *GetClientData( int n ) const;
int GetSelection(void) const; int GetSelection(void) const;
int GetSelections( class wxArrayInt &) const; int GetSelections( class wxArrayInt &) const;
wxString GetString( int n ) const; wxString GetString( int n ) const;
wxString GetStringSelection(void) const; wxString GetStringSelection(void) const;
int Number(void); int Number();
bool Selected( int n ); bool Selected( int n );
void Set( int n, const wxString *choices ); void Set( int n, const wxString *choices );
void SetClientData( int n, char *clientData );
void SetFirstItem( int n ); void SetFirstItem( int n );
void SetFirstItem( const wxString &item ); void SetFirstItem( const wxString &item );
void SetSelection( int n, bool select = TRUE ); void SetSelection( int n, bool select = TRUE );
@@ -86,14 +94,14 @@ class wxListBox: public wxControl
// implementation // implementation
void AppendCommon( const wxString &item );
int GetIndex( GtkWidget *item ) const; int GetIndex( GtkWidget *item ) const;
GtkWidget *GetConnectWidget(void); GtkWidget *GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
GtkList *m_list; GtkList *m_list;
wxList m_clientData; wxList m_clientDataList;
}; };
#endif // __GTKLISTBOXH__ #endif // __GTKLISTBOXH__

View File

@@ -43,11 +43,12 @@ class wxSizer;
class wxResourceTable; class wxResourceTable;
class wxItemResource; class wxItemResource;
class wxClientData;
class wxVoidClientData;
class wxWindow; class wxWindow;
class wxCanvas;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// callback definition for inserting a window // callback definition for inserting a window (internal)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* ); typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
@@ -60,6 +61,49 @@ extern const char *wxPanelNameStr;
extern const wxSize wxDefaultSize; extern const wxSize wxDefaultSize;
extern const wxPoint wxDefaultPosition; extern const wxPoint wxDefaultPosition;
//-----------------------------------------------------------------------------
// wxClientData
//-----------------------------------------------------------------------------
class wxClientData
{
public:
wxClientData() { }
virtual ~wxClientData() { }
};
//-----------------------------------------------------------------------------
// wxVoidClientData
//-----------------------------------------------------------------------------
class wxVoidClientData : public wxClientData
{
public:
wxVoidClientData() { m_data = NULL; }
wxVoidClientData( void *data ) { m_data = data; }
void SetData( void* data ) { m_data = data; }
void *GetData() const { return m_data; }
private:
void *m_data;
};
//-----------------------------------------------------------------------------
// wxStringClientData
//-----------------------------------------------------------------------------
class wxStringClientData: public wxClientData
{
public:
wxStringClientData() { }
wxStringClientData( wxString &data ) { m_data = data; }
void SetData( wxString &data ) { m_data = data; }
wxString GetData() const { return m_data; }
private:
wxString m_data;
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxWindow // wxWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -122,7 +166,7 @@ public:
virtual void Enable( bool enable ); virtual void Enable( bool enable );
virtual void MakeModal( bool modal ); virtual void MakeModal( bool modal );
virtual bool IsEnabled() const { return m_isEnabled; } virtual bool IsEnabled() const { return m_isEnabled; }
inline bool Enabled(void) const { return IsEnabled(); } inline bool Enabled() const { return IsEnabled(); }
virtual void SetFocus(); virtual void SetFocus();
virtual bool OnClose(); virtual bool OnClose();
@@ -133,7 +177,7 @@ public:
int GetReturnCode(); int GetReturnCode();
wxWindow *GetParent() const wxWindow *GetParent() const
{ return m_parent; } { return m_parent; }
wxWindow *GetGrandParent(void) const wxWindow *GetGrandParent() const
{ return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); } { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
void SetParent( wxWindow *p ) void SetParent( wxWindow *p )
{ m_parent = p; } { m_parent = p; }
@@ -146,6 +190,13 @@ public:
virtual wxValidator *GetValidator(); virtual wxValidator *GetValidator();
virtual void SetValidator( const wxValidator &validator ); virtual void SetValidator( const wxValidator &validator );
virtual void SetClientObject( wxClientData *data );
virtual wxClientData *GetClientObject();
virtual void SetClientData( void *data );
virtual void *GetClientData();
virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
@@ -170,8 +221,8 @@ public:
virtual wxColour GetForegroundColour() const; virtual wxColour GetForegroundColour() const;
virtual void SetForegroundColour( const wxColour &colour ); virtual void SetForegroundColour( const wxColour &colour );
virtual int GetCharHeight(void) const; virtual int GetCharHeight() const;
virtual int GetCharWidth(void) const; virtual int GetCharWidth() const;
virtual void GetTextExtent( const wxString& string, int *x, int *y, virtual void GetTextExtent( const wxString& string, int *x, int *y,
int *descent = (int *) NULL, int *descent = (int *) NULL,
int *externalLeading = (int *) NULL, int *externalLeading = (int *) NULL,
@@ -179,15 +230,19 @@ public:
virtual void SetFont( const wxFont &font ); virtual void SetFont( const wxFont &font );
virtual wxFont *GetFont(); virtual wxFont *GetFont();
// For backward compatibility // For backward compatibility
inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
inline virtual wxFont *GetLabelFont() { return GetFont(); }; inline virtual wxFont *GetLabelFont() { return GetFont(); };
inline virtual wxFont *GetButtonFont() { return GetFont(); }; inline virtual wxFont *GetButtonFont() { return GetFont(); };
virtual void SetWindowStyleFlag( long flag ); virtual void SetWindowStyleFlag( long flag );
virtual long GetWindowStyleFlag() const; virtual long GetWindowStyleFlag() const;
virtual void CaptureMouse(); virtual void CaptureMouse();
virtual void ReleaseMouse(); virtual void ReleaseMouse();
virtual void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );
virtual wxString GetTitle() const; virtual wxString GetTitle() const;
virtual void SetName( const wxString &name ); virtual void SetName( const wxString &name );
@@ -198,14 +253,16 @@ public:
virtual bool IsShown() const; virtual bool IsShown() const;
virtual void Raise(void); virtual void Raise();
virtual void Lower(void); virtual void Lower();
virtual bool IsRetained(); virtual bool IsRetained();
virtual wxWindow *FindWindow( long id ); virtual wxWindow *FindWindow( long id );
virtual wxWindow *FindWindow( const wxString& name ); virtual wxWindow *FindWindow( const wxString& name );
void AllowDoubleClick( bool WXUNUSED(allow) ) {}; void AllowDoubleClick( bool WXUNUSED(allow) ) {};
void SetDoubleClick( bool WXUNUSED(allow) ) {}; void SetDoubleClick( bool WXUNUSED(allow) ) {};
virtual void ClientToScreen( int *x, int *y ); virtual void ClientToScreen( int *x, int *y );
virtual void ScreenToClient( int *x, int *y ); virtual void ScreenToClient( int *x, int *y );
@@ -229,19 +286,20 @@ public:
virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL ); virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
virtual bool AcceptsFocus() const; virtual bool AcceptsFocus() const;
void UpdateWindowUI(); void UpdateWindowUI();
// implementation // implementation
virtual GtkWidget *GetConnectWidget(void); void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name );
void PostCreation();
virtual GtkWidget *GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window ); virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget ); void ConnectWidget( GtkWidget *widget );
void ConnectDnDWidget( GtkWidget *widget ); void ConnectDnDWidget( GtkWidget *widget );
void DisconnectDnDWidget( GtkWidget *widget ); void DisconnectDnDWidget( GtkWidget *widget );
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name );
void PostCreation();
bool HasVMT(); bool HasVMT();
virtual void ImplementSetSize(); virtual void ImplementSetSize();
@@ -264,7 +322,7 @@ public:
int m_retCode; int m_retCode;
wxEvtHandler *m_eventHandler; wxEvtHandler *m_eventHandler;
wxValidator *m_windowValidator; wxValidator *m_windowValidator;
wxDropTarget *m_pDropTarget; wxDropTarget *m_dropTarget;
wxWindowID m_windowId; wxWindowID m_windowId;
wxCursor *m_cursor; wxCursor *m_cursor;
wxFont m_font; wxFont m_font;
@@ -276,6 +334,7 @@ public:
bool m_isEnabled; bool m_isEnabled;
wxString m_windowName; wxString m_windowName;
wxAcceleratorTable m_acceleratorTable; wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientData;
GtkWidget *m_widget; GtkWidget *m_widget;
GtkWidget *m_wxwindow; GtkWidget *m_wxwindow;

View File

@@ -37,7 +37,6 @@ class wxMask: public wxObject
DECLARE_DYNAMIC_CLASS(wxMask) DECLARE_DYNAMIC_CLASS(wxMask)
public: public:
wxMask(); wxMask();
wxMask( const wxBitmap& bitmap, const wxColour& colour ); wxMask( const wxBitmap& bitmap, const wxColour& colour );
wxMask( const wxBitmap& bitmap, int paletteIndex ); wxMask( const wxBitmap& bitmap, int paletteIndex );
@@ -46,14 +45,8 @@ class wxMask: public wxObject
// implementation // implementation
GdkBitmap *GetBitmap() const;
protected:
friend wxBitmap;
GdkBitmap *m_bitmap; GdkBitmap *m_bitmap;
GdkBitmap *GetBitmap() const;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -65,7 +58,6 @@ class wxBitmap: public wxObject
DECLARE_DYNAMIC_CLASS(wxBitmap) DECLARE_DYNAMIC_CLASS(wxBitmap)
public: public:
wxBitmap(); wxBitmap();
wxBitmap( int width, int height, int depth = -1 ); wxBitmap( int width, int height, int depth = -1 );
wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 );

View File

@@ -42,7 +42,7 @@ class wxButton: public wxControl
public: public:
wxButton(void); wxButton();
inline wxButton(wxWindow *parent, wxWindowID id, const wxString& label, inline wxButton(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
@@ -51,19 +51,19 @@ class wxButton: public wxControl
{ {
Create(parent, id, label, pos, size, style, validator, name); Create(parent, id, label, pos, size, style, validator, name);
} }
~wxButton();
bool Create(wxWindow *parent, wxWindowID id, const wxString& label, bool Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr); const wxString& name = wxButtonNameStr);
void SetDefault(void); void SetDefault();
void SetLabel( const wxString &label ); void SetLabel( const wxString &label );
void Enable( bool enable ); void Enable( bool enable );
// implementation // implementation
void ApplyWidgetStyle(); void ApplyWidgetStyle();
}; };
#endif // __GTKBUTTONH__ #endif // __GTKBUTTONH__

View File

@@ -42,7 +42,7 @@ class wxChoice: public wxControl
public: public:
wxChoice(void); wxChoice();
inline wxChoice( wxWindow *parent, wxWindowID id, inline wxChoice( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -53,6 +53,7 @@ class wxChoice: public wxControl
{ {
Create(parent, id, pos, size, n, choices, style, validator, name); Create(parent, id, pos, size, n, choices, style, validator, name);
} }
~wxChoice();
bool Create( wxWindow *parent, wxWindowID id, bool Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -60,21 +61,34 @@ class wxChoice: public wxControl
long style = 0, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr ); const wxString& name = wxChoiceNameStr );
void Append( const wxString &item ); void Append( const wxString &item );
void Clear(void); void Append( const wxString &item, void* clientData );
void Append( const wxString &item, wxClientData* clientData );
void SetClientData( int n, void* clientData );
void* GetClientData( int n );
void SetClientObject( int n, wxClientData* clientData );
wxClientData* GetClientObject( int n );
void Clear();
void Delete(int n); void Delete(int n);
int FindString( const wxString &string ) const; int FindString( const wxString &string ) const;
int GetColumns(void) const; int GetColumns() const;
int GetSelection(void); int GetSelection();
wxString GetString( int n ) const; wxString GetString( int n ) const;
wxString GetStringSelection(void) const; wxString GetStringSelection() const;
int Number(void) const; int Number() const;
void SetColumns( int n = 1 ); void SetColumns( int n = 1 );
void SetSelection( int n ); void SetSelection( int n );
void SetStringSelection( const wxString &string ); void SetStringSelection( const wxString &string );
// implementation // implementation
wxList m_clientDataList;
void AppendCommon( const wxString &item );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
}; };

View File

@@ -42,8 +42,8 @@ class wxComboBox: public wxControl
DECLARE_DYNAMIC_CLASS(wxComboBox) DECLARE_DYNAMIC_CLASS(wxComboBox)
public: public:
inline wxComboBox(void) {}
inline wxComboBox() {}
inline wxComboBox(wxWindow *parent, wxWindowID id, inline wxComboBox(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString, const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -55,6 +55,7 @@ class wxComboBox: public wxControl
{ {
Create(parent, id, value, pos, size, n, choices, style, validator, name); Create(parent, id, value, pos, size, n, choices, style, validator, name);
} }
~wxComboBox();
bool Create(wxWindow *parent, wxWindowID id, bool Create(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString, const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -64,30 +65,36 @@ class wxComboBox: public wxControl
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr); const wxString& name = wxComboBoxNameStr);
void Clear(void);
void Append( const wxString &item ); void Append( const wxString &item );
void Append( const wxString &item, char* clientData ); void Append( const wxString &item, void* clientData );
void Append( const wxString &item, wxClientData* clientData );
void SetClientData( int n, void* clientData );
void* GetClientData( int n );
void SetClientObject( int n, wxClientData* clientData );
wxClientData* GetClientObject( int n );
void Clear();
void Delete( int n ); void Delete( int n );
int FindString( const wxString &item ); int FindString( const wxString &item );
char* GetClientData( int n ); int GetSelection() const;
void SetClientData( int n, char * clientData );
int GetSelection(void) const;
wxString GetString( int n ) const; wxString GetString( int n ) const;
wxString GetStringSelection(void) const; wxString GetStringSelection() const;
int Number(void) const; int Number() const;
void SetSelection( int n ); void SetSelection( int n );
void SetStringSelection( const wxString &string ); void SetStringSelection( const wxString &string );
wxString GetValue(void) const ; wxString GetValue() const;
void SetValue(const wxString& value); void SetValue(const wxString& value);
void Copy(void); void Copy();
void Cut(void); void Cut();
void Paste(void); void Paste();
void SetInsertionPoint( long pos ); void SetInsertionPoint( long pos );
void SetInsertionPointEnd(void); void SetInsertionPointEnd();
long GetInsertionPoint(void) const ; long GetInsertionPoint() const;
long GetLastPosition(void) const ; long GetLastPosition() const;
void Replace( long from, long to, const wxString& value ); void Replace( long from, long to, const wxString& value );
void Remove( long from, long to ); void Remove( long from, long to );
void SetSelection( long from, long to ); void SetSelection( long from, long to );
@@ -98,9 +105,10 @@ class wxComboBox: public wxControl
// implementation // implementation
bool m_alreadySent; bool m_alreadySent;
wxList m_clientData; wxList m_clientDataList;
GtkWidget* GetConnectWidget(void); void AppendCommon( const wxString &item );
GtkWidget* GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle(); void ApplyWidgetStyle();

View File

@@ -43,7 +43,7 @@ class wxListBox: public wxControl
public: public:
wxListBox(void); wxListBox();
inline wxListBox( wxWindow *parent, wxWindowID id, inline wxListBox( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -54,6 +54,7 @@ class wxListBox: public wxControl
{ {
Create(parent, id, pos, size, n, choices, style, validator, name); Create(parent, id, pos, size, n, choices, style, validator, name);
} }
~wxListBox();
bool Create( wxWindow *parent, wxWindowID id, bool Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -61,21 +62,28 @@ class wxListBox: public wxControl
long style = 0, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr ); const wxString& name = wxListBoxNameStr );
void Append( const wxString &item ); void Append( const wxString &item );
void Append( const wxString &item, char *clientData ); void Append( const wxString &item, void* clientData );
void Clear(void); void Append( const wxString &item, wxClientData* clientData );
void SetClientData( int n, void* clientData );
void* GetClientData( int n );
void SetClientObject( int n, wxClientData* clientData );
wxClientData* GetClientObject( int n );
void Clear();
void Delete( int n ); void Delete( int n );
void Deselect( int n ); void Deselect( int n );
int FindString( const wxString &item ) const; int FindString( const wxString &item ) const;
char *GetClientData( int n ) const;
int GetSelection(void) const; int GetSelection(void) const;
int GetSelections( class wxArrayInt &) const; int GetSelections( class wxArrayInt &) const;
wxString GetString( int n ) const; wxString GetString( int n ) const;
wxString GetStringSelection(void) const; wxString GetStringSelection(void) const;
int Number(void); int Number();
bool Selected( int n ); bool Selected( int n );
void Set( int n, const wxString *choices ); void Set( int n, const wxString *choices );
void SetClientData( int n, char *clientData );
void SetFirstItem( int n ); void SetFirstItem( int n );
void SetFirstItem( const wxString &item ); void SetFirstItem( const wxString &item );
void SetSelection( int n, bool select = TRUE ); void SetSelection( int n, bool select = TRUE );
@@ -86,14 +94,14 @@ class wxListBox: public wxControl
// implementation // implementation
void AppendCommon( const wxString &item );
int GetIndex( GtkWidget *item ) const; int GetIndex( GtkWidget *item ) const;
GtkWidget *GetConnectWidget(void); GtkWidget *GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
GtkList *m_list; GtkList *m_list;
wxList m_clientData; wxList m_clientDataList;
}; };
#endif // __GTKLISTBOXH__ #endif // __GTKLISTBOXH__

View File

@@ -43,11 +43,12 @@ class wxSizer;
class wxResourceTable; class wxResourceTable;
class wxItemResource; class wxItemResource;
class wxClientData;
class wxVoidClientData;
class wxWindow; class wxWindow;
class wxCanvas;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// callback definition for inserting a window // callback definition for inserting a window (internal)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* ); typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
@@ -60,6 +61,49 @@ extern const char *wxPanelNameStr;
extern const wxSize wxDefaultSize; extern const wxSize wxDefaultSize;
extern const wxPoint wxDefaultPosition; extern const wxPoint wxDefaultPosition;
//-----------------------------------------------------------------------------
// wxClientData
//-----------------------------------------------------------------------------
class wxClientData
{
public:
wxClientData() { }
virtual ~wxClientData() { }
};
//-----------------------------------------------------------------------------
// wxVoidClientData
//-----------------------------------------------------------------------------
class wxVoidClientData : public wxClientData
{
public:
wxVoidClientData() { m_data = NULL; }
wxVoidClientData( void *data ) { m_data = data; }
void SetData( void* data ) { m_data = data; }
void *GetData() const { return m_data; }
private:
void *m_data;
};
//-----------------------------------------------------------------------------
// wxStringClientData
//-----------------------------------------------------------------------------
class wxStringClientData: public wxClientData
{
public:
wxStringClientData() { }
wxStringClientData( wxString &data ) { m_data = data; }
void SetData( wxString &data ) { m_data = data; }
wxString GetData() const { return m_data; }
private:
wxString m_data;
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxWindow // wxWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -122,7 +166,7 @@ public:
virtual void Enable( bool enable ); virtual void Enable( bool enable );
virtual void MakeModal( bool modal ); virtual void MakeModal( bool modal );
virtual bool IsEnabled() const { return m_isEnabled; } virtual bool IsEnabled() const { return m_isEnabled; }
inline bool Enabled(void) const { return IsEnabled(); } inline bool Enabled() const { return IsEnabled(); }
virtual void SetFocus(); virtual void SetFocus();
virtual bool OnClose(); virtual bool OnClose();
@@ -133,7 +177,7 @@ public:
int GetReturnCode(); int GetReturnCode();
wxWindow *GetParent() const wxWindow *GetParent() const
{ return m_parent; } { return m_parent; }
wxWindow *GetGrandParent(void) const wxWindow *GetGrandParent() const
{ return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); } { return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
void SetParent( wxWindow *p ) void SetParent( wxWindow *p )
{ m_parent = p; } { m_parent = p; }
@@ -146,6 +190,13 @@ public:
virtual wxValidator *GetValidator(); virtual wxValidator *GetValidator();
virtual void SetValidator( const wxValidator &validator ); virtual void SetValidator( const wxValidator &validator );
virtual void SetClientObject( wxClientData *data );
virtual wxClientData *GetClientObject();
virtual void SetClientData( void *data );
virtual void *GetClientData();
virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ); virtual void SetAcceleratorTable( const wxAcceleratorTable& accel );
virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; } virtual wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
@@ -170,8 +221,8 @@ public:
virtual wxColour GetForegroundColour() const; virtual wxColour GetForegroundColour() const;
virtual void SetForegroundColour( const wxColour &colour ); virtual void SetForegroundColour( const wxColour &colour );
virtual int GetCharHeight(void) const; virtual int GetCharHeight() const;
virtual int GetCharWidth(void) const; virtual int GetCharWidth() const;
virtual void GetTextExtent( const wxString& string, int *x, int *y, virtual void GetTextExtent( const wxString& string, int *x, int *y,
int *descent = (int *) NULL, int *descent = (int *) NULL,
int *externalLeading = (int *) NULL, int *externalLeading = (int *) NULL,
@@ -179,15 +230,19 @@ public:
virtual void SetFont( const wxFont &font ); virtual void SetFont( const wxFont &font );
virtual wxFont *GetFont(); virtual wxFont *GetFont();
// For backward compatibility // For backward compatibility
inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); } inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); } inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
inline virtual wxFont *GetLabelFont() { return GetFont(); }; inline virtual wxFont *GetLabelFont() { return GetFont(); };
inline virtual wxFont *GetButtonFont() { return GetFont(); }; inline virtual wxFont *GetButtonFont() { return GetFont(); };
virtual void SetWindowStyleFlag( long flag ); virtual void SetWindowStyleFlag( long flag );
virtual long GetWindowStyleFlag() const; virtual long GetWindowStyleFlag() const;
virtual void CaptureMouse(); virtual void CaptureMouse();
virtual void ReleaseMouse(); virtual void ReleaseMouse();
virtual void SetTitle( const wxString &title ); virtual void SetTitle( const wxString &title );
virtual wxString GetTitle() const; virtual wxString GetTitle() const;
virtual void SetName( const wxString &name ); virtual void SetName( const wxString &name );
@@ -198,14 +253,16 @@ public:
virtual bool IsShown() const; virtual bool IsShown() const;
virtual void Raise(void); virtual void Raise();
virtual void Lower(void); virtual void Lower();
virtual bool IsRetained(); virtual bool IsRetained();
virtual wxWindow *FindWindow( long id ); virtual wxWindow *FindWindow( long id );
virtual wxWindow *FindWindow( const wxString& name ); virtual wxWindow *FindWindow( const wxString& name );
void AllowDoubleClick( bool WXUNUSED(allow) ) {}; void AllowDoubleClick( bool WXUNUSED(allow) ) {};
void SetDoubleClick( bool WXUNUSED(allow) ) {}; void SetDoubleClick( bool WXUNUSED(allow) ) {};
virtual void ClientToScreen( int *x, int *y ); virtual void ClientToScreen( int *x, int *y );
virtual void ScreenToClient( int *x, int *y ); virtual void ScreenToClient( int *x, int *y );
@@ -229,19 +286,20 @@ public:
virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL ); virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL );
virtual bool AcceptsFocus() const; virtual bool AcceptsFocus() const;
void UpdateWindowUI(); void UpdateWindowUI();
// implementation // implementation
virtual GtkWidget *GetConnectWidget(void); void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name );
void PostCreation();
virtual GtkWidget *GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window ); virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget ); void ConnectWidget( GtkWidget *widget );
void ConnectDnDWidget( GtkWidget *widget ); void ConnectDnDWidget( GtkWidget *widget );
void DisconnectDnDWidget( GtkWidget *widget ); void DisconnectDnDWidget( GtkWidget *widget );
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
const wxSize &size, long style, const wxString &name );
void PostCreation();
bool HasVMT(); bool HasVMT();
virtual void ImplementSetSize(); virtual void ImplementSetSize();
@@ -264,7 +322,7 @@ public:
int m_retCode; int m_retCode;
wxEvtHandler *m_eventHandler; wxEvtHandler *m_eventHandler;
wxValidator *m_windowValidator; wxValidator *m_windowValidator;
wxDropTarget *m_pDropTarget; wxDropTarget *m_dropTarget;
wxWindowID m_windowId; wxWindowID m_windowId;
wxCursor *m_cursor; wxCursor *m_cursor;
wxFont m_font; wxFont m_font;
@@ -276,6 +334,7 @@ public:
bool m_isEnabled; bool m_isEnabled;
wxString m_windowName; wxString m_windowName;
wxAcceleratorTable m_acceleratorTable; wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientData;
GtkWidget *m_widget; GtkWidget *m_widget;
GtkWidget *m_wxwindow; GtkWidget *m_wxwindow;

View File

@@ -96,6 +96,7 @@ public:
virtual bool LoadFile( wxImage *image, const wxString& name ); virtual bool LoadFile( wxImage *image, const wxString& name );
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxImage // wxImage
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -151,6 +152,7 @@ public:
static wxImageHandler *FindHandler( long imageType ); static wxImageHandler *FindHandler( long imageType );
static void CleanUpHandlers(); static void CleanUpHandlers();
static void InitStandardHandlers();
protected: protected:

View File

@@ -30,8 +30,8 @@
class wxImageRefData: public wxObjectRefData class wxImageRefData: public wxObjectRefData
{ {
public:
public:
wxImageRefData(void); wxImageRefData(void);
~wxImageRefData(void); ~wxImageRefData(void);
@@ -288,6 +288,12 @@ wxImageHandler *wxImage::FindHandler( long bitmapType )
return NULL; return NULL;
} }
void wxImage::InitStandardHandlers()
{
AddHandler( new wxBMPHandler );
AddHandler( new wxPNGHandler );
}
void wxImage::CleanUpHandlers() void wxImage::CleanUpHandlers()
{ {
wxNode *node = sm_handlers.First(); wxNode *node = sm_handlers.First();

View File

@@ -323,30 +323,14 @@ void wxApp::CommonInit(void)
wxInitializeResourceSystem(); wxInitializeResourceSystem();
// For PostScript printing wxImage::InitStandardHandlers();
#if wxUSE_POSTSCRIPT
/* Now done in wxPostScriptModule
wxInitializePrintSetupData();
wxThePrintPaperDatabase = new wxPrintPaperDatabase;
wxThePrintPaperDatabase->CreateDatabase();
*/
#endif
// g_globalCursor = new wxCursor;
/*
wxBitmap::InitStandardHandlers();
g_globalCursor = new wxCursor;
*/
} }
void wxApp::CommonCleanUp(void) void wxApp::CommonCleanUp(void)
{ {
wxDELETE(wxTheColourDatabase); wxDELETE(wxTheColourDatabase);
/* Now done in wxPostScriptModule
wxDELETE(wxThePrintPaperDatabase);
wxDELETE(wxThePrintSetupData);
*/
wxDELETE(wxTheFontNameDirectory); wxDELETE(wxTheFontNameDirectory);
wxDeleteStockObjects(); wxDeleteStockObjects();
@@ -358,6 +342,8 @@ void wxApp::CommonCleanUp(void)
wxCleanUpResourceSystem(); wxCleanUpResourceSystem();
wxImage::CleanUpHandlers();
wxSystemSettings::Done(); wxSystemSettings::Done();
} }

View File

@@ -13,6 +13,7 @@
#include "wx/bitmap.h" #include "wx/bitmap.h"
#include "wx/icon.h" #include "wx/icon.h"
#include "wx/filefn.h"
#include "gdk/gdkprivate.h" #include "gdk/gdkprivate.h"
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
@@ -56,7 +57,6 @@ GdkBitmap *wxMask::GetBitmap(void) const
class wxBitmapRefData: public wxObjectRefData class wxBitmapRefData: public wxObjectRefData
{ {
public: public:
wxBitmapRefData(void); wxBitmapRefData(void);
~wxBitmapRefData(void); ~wxBitmapRefData(void);
@@ -287,8 +287,7 @@ void wxBitmap::SetMask( wxMask *mask )
M_BMPDATA->m_mask = mask; M_BMPDATA->m_mask = mask;
} }
bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type), bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) )
wxPalette *WXUNUSED(palette) )
{ {
if (!Ok()) if (!Ok())
{ {
@@ -296,20 +295,57 @@ bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type),
return FALSE; return FALSE;
} }
return FALSE; if (type == wxBITMAP_TYPE_PNG)
}
bool wxBitmap::LoadFile( const wxString &WXUNUSED(name), int WXUNUSED(type) )
{ {
if (!Ok()) wxImage image = ConvertToImage();
{ if (image.Ok()) return image.SaveFile( name, type );
wxFAIL_MSG( "invalid bitmap" );
return FALSE;
} }
return FALSE; return FALSE;
} }
bool wxBitmap::LoadFile( const wxString &name, int type )
{
UnRef();
if (!wxFileExists(name)) return FALSE;
if (type == wxBITMAP_TYPE_XPM)
{
m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL;
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( parent, &mask, NULL, name );
if (mask)
{
M_BMPDATA->m_mask = new wxMask();
M_BMPDATA->m_mask->m_bitmap = mask;
}
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
}
else if (type == wxBITMAP_TYPE_PNG)
{
wxImage image;
image.LoadFile( name, type );
if (image.Ok()) *this = wxBitmap( image );
}
else if (type == wxBITMAP_TYPE_BMP)
{
wxImage image;
image.LoadFile( name, type );
if (image.Ok()) *this = wxBitmap( image );
}
else
return FALSE;
return TRUE;
}
wxPalette *wxBitmap::GetPalette(void) const wxPalette *wxBitmap::GetPalette(void) const
{ {
if (!Ok()) return (wxPalette *) NULL; if (!Ok()) return (wxPalette *) NULL;
@@ -383,7 +419,7 @@ wxBitmap::wxBitmap( const wxImage &image )
// Render // Render
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
byte_order b_o; byte_order b_o = RGB;
if (render_depth >= 24) if (render_depth >= 24)
{ {
@@ -404,6 +440,7 @@ wxBitmap::wxBitmap( const wxImage &image )
int index = 0; int index = 0;
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
int r = data[index]; int r = data[index];
@@ -472,7 +509,8 @@ wxBitmap::wxBitmap( const wxImage &image )
} }
default: break; default: break;
} }
} } // for
} // for
// Blit picture // Blit picture
@@ -494,7 +532,6 @@ wxBitmap::wxBitmap( const wxImage &image )
gdk_image_destroy( mask_image ); gdk_image_destroy( mask_image );
gdk_gc_unref( mask_gc ); gdk_gc_unref( mask_gc );
} }
} }
wxImage wxBitmap::ConvertToImage() const wxImage wxBitmap::ConvertToImage() const
@@ -514,7 +551,6 @@ wxImage wxBitmap::ConvertToImage() const
image.Create( M_BMPDATA->m_width, M_BMPDATA->m_height ); image.Create( M_BMPDATA->m_width, M_BMPDATA->m_height );
char unsigned *data = image.GetData(); char unsigned *data = image.GetData();
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap ); GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
int bpp = visual->depth; int bpp = visual->depth;

View File

@@ -45,14 +45,20 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *
IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl)
wxButton::wxButton(void) wxButton::wxButton()
{ {
} }
wxButton::~wxButton()
{
if (m_clientData) delete m_clientData;
}
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxValidator& validator, const wxString &name ) long style, const wxValidator& validator, const wxString &name )
{ {
m_clientData = (wxClientData*) NULL;
m_needParent = TRUE; m_needParent = TRUE;
wxSize newSize = size; wxSize newSize = size;
@@ -118,3 +124,4 @@ void wxButton::ApplyWidgetStyle()
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle ); gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
} }

View File

@@ -43,7 +43,7 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *
IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl)
wxChoice::wxChoice(void) wxChoice::wxChoice()
{ {
} }
@@ -69,6 +69,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
m_clientDataList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] ); GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_menu_append( GTK_MENU(menu), item ); gtk_menu_append( GTK_MENU(menu), item );
@@ -96,7 +98,19 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
return TRUE; return TRUE;
} }
void wxChoice::Append( const wxString &item ) wxChoice::~wxChoice()
{
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
}
void wxChoice::AppendCommon( const wxString &item )
{ {
wxCHECK_RET( m_widget != NULL, "invalid choice" ); wxCHECK_RET( m_widget != NULL, "invalid choice" );
@@ -116,13 +130,100 @@ void wxChoice::Append( const wxString &item )
gtk_widget_show( menu_item ); gtk_widget_show( menu_item );
} }
void wxChoice::Clear(void) void wxChoice::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxChoice::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxChoice::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
AppendCommon( item );
}
void wxChoice::SetClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
}
void* wxChoice::GetClientData( int n )
{
wxCHECK_MSG( m_widget != NULL, NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
}
void wxChoice::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
node->SetData( (wxObject*) clientData );
}
wxClientData* wxChoice::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
}
void wxChoice::Clear()
{ {
wxCHECK_RET( m_widget != NULL, "invalid choice" ); wxCHECK_RET( m_widget != NULL, "invalid choice" );
gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) ); gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) );
GtkWidget *menu = gtk_menu_new(); GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxChoice::Delete( int WXUNUSED(n) ) void wxChoice::Delete( int WXUNUSED(n) )
@@ -159,12 +260,12 @@ int wxChoice::FindString( const wxString &string ) const
return -1; return -1;
} }
int wxChoice::GetColumns(void) const int wxChoice::GetColumns() const
{ {
return 1; return 1;
} }
int wxChoice::GetSelection(void) int wxChoice::GetSelection()
{ {
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" ); wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
@@ -213,7 +314,7 @@ wxString wxChoice::GetString( int n ) const
return ""; return "";
} }
wxString wxChoice::GetStringSelection(void) const wxString wxChoice::GetStringSelection() const
{ {
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" ); wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
@@ -224,7 +325,7 @@ wxString wxChoice::GetStringSelection(void) const
return label->label; return label->label;
} }
int wxChoice::Number(void) const int wxChoice::Number() const
{ {
wxCHECK_MSG( m_widget != NULL, 0, "invalid choice" ); wxCHECK_MSG( m_widget != NULL, 0, "invalid choice" );

View File

@@ -19,6 +19,9 @@
wxClipboard *wxTheClipboard = (wxClipboard*) NULL; wxClipboard *wxTheClipboard = (wxClipboard*) NULL;
GdkAtom g_textAtom = 0;
GdkAtom g_clipboardAtom = 0;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// functions // functions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -39,11 +42,59 @@ void wxDoneClipboard()
// "selection_received" // "selection_received"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/* static void
static void selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointer data ) selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointer data )
{ {
} }
*/
//-----------------------------------------------------------------------------
// "selection_clear"
//-----------------------------------------------------------------------------
static gint
selection_clear( GtkWidget *widget, GdkEventSelection *event )
{
/* The clipboard is no longer in our hands. We can delete the
* clipboard data. I hope I got that one right... */
if (!wxTheClipboard) return TRUE;
wxTheClipboard->SetData( (wxDataObject*) NULL );
return TRUE;
}
//-----------------------------------------------------------------------------
// selection handler for supplying data
//-----------------------------------------------------------------------------
static void
selection_handler( GtkWidget *WXUNUSED(widget), GtkSelectionData *selection_data, gpointer WXUNUSED(data) )
{
if (!wxTheClipboard) return;
wxDataObject *data_object = wxTheClipboard->m_data;
if (!data_object) return;
if (data_object->GetDataSize() == 0) return;
gint len = data_object->GetDataSize();
guchar *bin_data = (guchar*) malloc( len );
data_object->GetDataHere( (void*)bin_data );
if (selection_data->target == GDK_SELECTION_TYPE_STRING)
{
gtk_selection_data_set(
selection_data, GDK_SELECTION_TYPE_STRING, 8*sizeof(gchar), bin_data, len );
}
else if (selection_data->target == g_textAtom)
{
gtk_selection_data_set(
selection_data, g_textAtom, 8*sizeof(gchar), bin_data, len );
}
free( bin_data );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxClipboard // wxClipboard
@@ -56,11 +107,26 @@ wxClipboard::wxClipboard()
m_data = (wxDataObject*) NULL; m_data = (wxDataObject*) NULL;
m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP ); m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
gtk_widget_realize( m_clipboardWidget ); gtk_widget_realize( m_clipboardWidget );
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_clear_event",
GTK_SIGNAL_FUNC( selection_clear ),
(gpointer) NULL );
if (!g_clipboardAtom) g_clipboardAtom = gdk_atom_intern( "CLIPBOARD", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
} }
wxClipboard::~wxClipboard() wxClipboard::~wxClipboard()
{ {
if (m_data) delete m_data; /* As we have data we also own the clipboard. Once we no longer own
it, clear_selection is called which will set m_data to zero */
if (m_data)
{
delete m_data;
gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
}
if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget ); if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
} }
@@ -68,6 +134,38 @@ void wxClipboard::SetData( wxDataObject *data )
{ {
if (m_data) delete m_data; if (m_data) delete m_data;
m_data = data; m_data = data;
if (!m_data) return;
if (!gtk_selection_owner_set( m_clipboardWidget,
g_clipboardAtom,
GDK_CURRENT_TIME))
{
delete m_data;
m_data = (wxDataObject*) NULL;
return;
}
switch (m_data->GetPreferredFormat())
{
/*
case wxDF_STRING:
gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
GDK_TARGET_STRING,
selection_handler,
NULL );
break;
*/
case wxDF_TEXT:
gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
g_textAtom,
selection_handler,
NULL );
break;
default:
break;
}
} }
void *wxClipboard::GetData( wxDataFormat format, size_t *length ) void *wxClipboard::GetData( wxDataFormat format, size_t *length )

View File

@@ -58,7 +58,8 @@ END_EVENT_TABLE()
bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
long style, const wxValidator& validator, const wxString& name ) long style, const wxValidator& validator,
const wxString& name )
{ {
m_alreadySent = FALSE; m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
@@ -80,7 +81,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
{ {
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] ); GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
m_clientData.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_container_add( GTK_CONTAINER(list), list_item );
@@ -115,24 +116,19 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
return TRUE; return TRUE;
} }
void wxComboBox::Clear(void) wxComboBox::~wxComboBox()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxNode *node = m_clientDataList.First();
while (node)
GtkWidget *list = GTK_COMBO(m_widget)->list; {
gtk_list_clear_items( GTK_LIST(list), 0, Number() ); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientData.Clear(); node = node->Next();
}
m_clientDataList.Clear();
} }
void wxComboBox::Append( const wxString &item ) void wxComboBox::AppendCommon( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
Append( item, (char*)NULL );
}
void wxComboBox::Append( const wxString &item, char *clientData )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -143,8 +139,6 @@ void wxComboBox::Append( const wxString &item, char *clientData )
gtk_signal_connect( GTK_OBJECT(list_item), "select", gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
m_clientData.Append( (wxObject*)clientData );
gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_container_add( GTK_CONTAINER(list), list_item );
if (m_widgetStyle) ApplyWidgetStyle(); if (m_widgetStyle) ApplyWidgetStyle();
@@ -152,6 +146,100 @@ void wxComboBox::Append( const wxString &item, char *clientData )
gtk_widget_show( list_item ); gtk_widget_show( list_item );
} }
void wxComboBox::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxComboBox::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxComboBox::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
AppendCommon( item );
}
void wxComboBox::SetClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
}
void* wxComboBox::GetClientData( int n )
{
wxCHECK_MSG( m_widget != NULL, NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
}
void wxComboBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
node->SetData( (wxObject*) clientData );
}
wxClientData* wxComboBox::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
}
void wxComboBox::Clear()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() );
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
}
void wxComboBox::Delete( int n ) void wxComboBox::Delete( int n )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -170,13 +258,17 @@ void wxComboBox::Delete( int n )
gtk_list_remove_items( listbox, list ); gtk_list_remove_items( listbox, list );
g_list_free( list ); g_list_free( list );
wxNode *node = m_clientData.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) if (!node)
{ {
wxFAIL_MSG( "wrong index" ); wxFAIL_MSG( "wrong index" );
} }
else else
m_clientData.DeleteNode( node ); {
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientDataList.DeleteNode( node );
}
} }
int wxComboBox::FindString( const wxString &item ) int wxComboBox::FindString( const wxString &item )
@@ -201,29 +293,7 @@ int wxComboBox::FindString( const wxString &item )
return -1; return -1;
} }
char* wxComboBox::GetClientData( int n ) int wxComboBox::GetSelection() const
{
wxCHECK_MSG( m_widget != NULL, (char*)NULL, "invalid combobox" );
wxNode *node = m_clientData.Nth( n );
if (node) return (char*)node->Data();
wxFAIL_MSG( "wxComboBox: wrong index" );
return (char *) NULL;
}
void wxComboBox::SetClientData( int n, char * clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientData.Nth( n );
if (node) node->SetData( (wxObject*) clientData );
wxFAIL_MSG( "wxComboBox: wrong index" );
}
int wxComboBox::GetSelection(void) const
{ {
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" ); wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
@@ -266,7 +336,7 @@ wxString wxComboBox::GetString( int n ) const
return ""; return "";
} }
wxString wxComboBox::GetStringSelection(void) const wxString wxComboBox::GetStringSelection() const
{ {
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" ); wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
@@ -285,7 +355,7 @@ wxString wxComboBox::GetStringSelection(void) const
return ""; return "";
} }
int wxComboBox::Number(void) const int wxComboBox::Number() const
{ {
wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" ); wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" );
@@ -314,7 +384,7 @@ void wxComboBox::SetStringSelection( const wxString &string )
SetSelection( res ); SetSelection( res );
} }
wxString wxComboBox::GetValue(void) const wxString wxComboBox::GetValue() const
{ {
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;
wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) ); wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) );
@@ -331,7 +401,7 @@ void wxComboBox::SetValue( const wxString& value )
gtk_entry_set_text( GTK_ENTRY(entry), tmp ); gtk_entry_set_text( GTK_ENTRY(entry), tmp );
} }
void wxComboBox::Copy(void) void wxComboBox::Copy()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -343,7 +413,7 @@ void wxComboBox::Copy(void)
#endif #endif
} }
void wxComboBox::Cut(void) void wxComboBox::Cut()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -355,7 +425,7 @@ void wxComboBox::Cut(void)
#endif #endif
} }
void wxComboBox::Paste(void) void wxComboBox::Paste()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -376,7 +446,7 @@ void wxComboBox::SetInsertionPoint( long pos )
gtk_entry_set_position( GTK_ENTRY(entry), tmp ); gtk_entry_set_position( GTK_ENTRY(entry), tmp );
} }
void wxComboBox::SetInsertionPointEnd(void) void wxComboBox::SetInsertionPointEnd()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -385,13 +455,13 @@ void wxComboBox::SetInsertionPointEnd(void)
SetInsertionPoint( pos-1 ); SetInsertionPoint( pos-1 );
} }
long wxComboBox::GetInsertionPoint(void) const long wxComboBox::GetInsertionPoint() const
{ {
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;
return (long) GTK_EDITABLE(entry)->current_pos; return (long) GTK_EDITABLE(entry)->current_pos;
} }
long wxComboBox::GetLastPosition(void) const long wxComboBox::GetLastPosition() const
{ {
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int pos = GTK_ENTRY(entry)->text_length; int pos = GTK_ENTRY(entry)->text_length;
@@ -432,7 +502,6 @@ void wxComboBox::OnSize( wxSizeEvent &event )
wxControl::OnSize( event ); wxControl::OnSize( event );
int w = 21; int w = 21;
gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height ); gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y ); gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y );
@@ -460,7 +529,7 @@ void wxComboBox::ApplyWidgetStyle()
} }
} }
GtkWidget* wxComboBox::GetConnectWidget(void) GtkWidget* wxComboBox::GetConnectWidget()
{ {
return GTK_COMBO(m_widget)->entry; return GTK_COMBO(m_widget)->entry;
} }

View File

@@ -41,8 +41,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
event.m_commandInt = aSelections[0] ; event.m_commandInt = aSelections[0] ;
event.m_clientData = listbox->GetClientData( event.m_commandInt ); event.m_clientData = listbox->GetClientData( event.m_commandInt );
wxString str(listbox->GetString(event.m_commandInt)); wxString str(listbox->GetString(event.m_commandInt));
if (str != "") if (str != "") event.m_commandString = copystring((char *)(const char *)str);
event.m_commandString = copystring((char *)(const char *)str);
} }
else else
{ {
@@ -62,7 +61,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl)
wxListBox::wxListBox(void) wxListBox::wxListBox()
{ {
m_list = (GtkList *) NULL; m_list = (GtkList *) NULL;
} }
@@ -116,7 +115,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
ConnectWidget( list_item ); ConnectWidget( list_item );
m_clientData.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
} }
@@ -137,12 +136,19 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
return TRUE; return TRUE;
} }
void wxListBox::Append( const wxString &item ) wxListBox::~wxListBox()
{ {
Append( item, (char*)NULL ); wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxListBox::Append( const wxString &item, char *clientData ) void wxListBox::AppendCommon( const wxString &item )
{ {
wxCHECK_RET( m_list != NULL, "invalid listbox" ); wxCHECK_RET( m_list != NULL, "invalid listbox" );
@@ -155,10 +161,6 @@ void wxListBox::Append( const wxString &item, char *clientData )
gtk_signal_connect( GTK_OBJECT(list_item), "deselect", gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
ConnectWidget( list_item );
m_clientData.Append( (wxObject*)clientData );
gtk_container_add( GTK_CONTAINER(m_list), list_item ); gtk_container_add( GTK_CONTAINER(m_list), list_item );
if (m_widgetStyle) ApplyWidgetStyle(); if (m_widgetStyle) ApplyWidgetStyle();
@@ -170,13 +172,97 @@ void wxListBox::Append( const wxString &item, char *clientData )
ConnectDnDWidget( list_item ); ConnectDnDWidget( list_item );
} }
void wxListBox::Clear(void) void wxListBox::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
AppendCommon( item );
}
void wxListBox::SetClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
}
void* wxListBox::GetClientData( int n )
{
wxCHECK_MSG( m_widget != NULL, NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
}
void wxListBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
node->SetData( (wxObject*) clientData );
}
wxClientData* wxListBox::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
}
void wxListBox::Clear()
{ {
wxCHECK_RET( m_list != NULL, "invalid listbox" ); wxCHECK_RET( m_list != NULL, "invalid listbox" );
gtk_list_clear_items( m_list, 0, Number() ); gtk_list_clear_items( m_list, 0, Number() );
m_clientData.Clear(); wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxListBox::Delete( int n ) void wxListBox::Delete( int n )
@@ -195,13 +281,17 @@ void wxListBox::Delete( int n )
gtk_list_remove_items( m_list, list ); gtk_list_remove_items( m_list, list );
g_list_free( list ); g_list_free( list );
wxNode *node = m_clientData.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) if (!node)
{ {
wxFAIL_MSG("wrong listbox index"); wxFAIL_MSG( "wrong index" );
} }
else else
m_clientData.DeleteNode( node ); {
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientDataList.DeleteNode( node );
}
} }
void wxListBox::Deselect( int n ) void wxListBox::Deselect( int n )
@@ -226,25 +316,12 @@ int wxListBox::FindString( const wxString &item ) const
child = child->next; child = child->next;
} }
// it's not an error if the string is not found - this function may be used to // it's not an error if the string is not found -> no wxCHECK
// test for existence of the string in the listbox, so don't give any
// errors/assert failures.
return -1; return -1;
} }
char *wxListBox::GetClientData( int n ) const int wxListBox::GetSelection() const
{
wxCHECK_MSG( m_list != NULL, (char*) NULL, "invalid listbox" );
wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data());
wxFAIL_MSG("wrong listbox index");
return (char *) NULL;
}
int wxListBox::GetSelection(void) const
{ {
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" ); wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
@@ -274,7 +351,8 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const
aSelections.Empty(); aSelections.Empty();
if ( count > 0 ) { if (count > 0)
{
// now fill the list // now fill the list
aSelections.Alloc(count); // optimization attempt aSelections.Alloc(count); // optimization attempt
int i = 0; int i = 0;
@@ -303,7 +381,7 @@ wxString wxListBox::GetString( int n ) const
return ""; return "";
} }
wxString wxListBox::GetStringSelection(void) const wxString wxListBox::GetStringSelection() const
{ {
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" ); wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
@@ -318,7 +396,7 @@ wxString wxListBox::GetStringSelection(void) const
return ""; return "";
} }
int wxListBox::Number(void) int wxListBox::Number()
{ {
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" ); wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
@@ -351,21 +429,6 @@ void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
wxFAIL_MSG("wxListBox::Set not implemented"); wxFAIL_MSG("wxListBox::Set not implemented");
} }
void wxListBox::SetClientData( int n, char *clientData )
{
wxCHECK_RET( m_list != NULL, "invalid listbox" );
wxNode *node = m_clientData.Nth( n );
if (node)
{
node->SetData( (wxObject*)clientData );
}
else
{
wxFAIL_MSG("wrong listbox index");
}
}
void wxListBox::SetFirstItem( int WXUNUSED(n) ) void wxListBox::SetFirstItem( int WXUNUSED(n) )
{ {
wxFAIL_MSG("wxListBox::SetFirstItem not implemented"); wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
@@ -447,7 +510,7 @@ void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
} }
} }
GtkWidget *wxListBox::GetConnectWidget(void) GtkWidget *wxListBox::GetConnectWidget()
{ {
return GTK_WIDGET(m_list); return GTK_WIDGET(m_list);
} }

View File

@@ -933,7 +933,7 @@ wxWindow::wxWindow()
m_oldVerticalPos = 0.0; m_oldVerticalPos = 0.0;
m_isShown = FALSE; m_isShown = FALSE;
m_isEnabled = TRUE; m_isEnabled = TRUE;
m_pDropTarget = (wxDropTarget *) NULL; m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE; m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL; m_widgetStyle = (GtkStyle*) NULL;
@@ -1059,7 +1059,7 @@ wxWindow::~wxWindow()
{ {
m_hasVMT = FALSE; m_hasVMT = FALSE;
if (m_pDropTarget) delete m_pDropTarget; if (m_dropTarget) delete m_dropTarget;
if (m_parent) m_parent->RemoveChild( this ); if (m_parent) m_parent->RemoveChild( this );
if (m_widget) Show( FALSE ); if (m_widget) Show( FALSE );
@@ -1114,6 +1114,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
wxFatalError( "Need complete parent.", name ); wxFatalError( "Need complete parent.", name );
m_widget = (GtkWidget *) NULL; m_widget = (GtkWidget *) NULL;
m_wxwindow = (GtkWidget *) NULL;
m_hasVMT = FALSE; m_hasVMT = FALSE;
m_parent = parent; m_parent = parent;
m_children.DeleteContents( FALSE ); m_children.DeleteContents( FALSE );
@@ -1148,7 +1149,6 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_eventHandler = this; m_eventHandler = this;
m_windowId = id; m_windowId = id;
m_sizeSet = FALSE; m_sizeSet = FALSE;
if (m_cursor == NULL)
m_cursor = new wxCursor( wxCURSOR_ARROW ); m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT; m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE; // m_backgroundColour = wxWHITE;
@@ -1162,7 +1162,13 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_autoLayout = FALSE; m_autoLayout = FALSE;
m_hasScrolling = FALSE; m_hasScrolling = FALSE;
m_isScrolling = FALSE; m_isScrolling = FALSE;
m_pDropTarget = (wxDropTarget *) NULL; m_hAdjust = (GtkAdjustment *) NULL;
m_vAdjust = (GtkAdjustment *) NULL;
m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE; m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL; m_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
@@ -1839,6 +1845,36 @@ void wxWindow::SetValidator( const wxValidator& validator )
if (m_windowValidator) m_windowValidator->SetWindow(this); if (m_windowValidator) m_windowValidator->SetWindow(this);
} }
void wxWindow::SetClientObject( wxClientData *data )
{
if (m_clientData) delete m_clientData;
m_clientData = data;
}
wxClientData *wxWindow::GetClientObject()
{
return m_clientData;
}
void wxWindow::SetClientData( void *data )
{
if (m_clientData) delete m_clientData;
if (data)
m_clientData = new wxVoidClientData( data );
else
m_clientData = (wxClientData*) NULL;
}
void *wxWindow::GetClientData()
{
if (!m_clientData) return NULL;
wxVoidClientData *vd = (wxVoidClientData*) m_clientData;
return vd->GetData();
}
bool wxWindow::IsBeingDeleted() bool wxWindow::IsBeingDeleted()
{ {
return FALSE; return FALSE;
@@ -2149,22 +2185,22 @@ void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
DisconnectDnDWidget( dnd_widget ); DisconnectDnDWidget( dnd_widget );
if (m_pDropTarget) delete m_pDropTarget; if (m_dropTarget) delete m_dropTarget;
m_pDropTarget = dropTarget; m_dropTarget = dropTarget;
ConnectDnDWidget( dnd_widget ); ConnectDnDWidget( dnd_widget );
} }
wxDropTarget *wxWindow::GetDropTarget() const wxDropTarget *wxWindow::GetDropTarget() const
{ {
return m_pDropTarget; return m_dropTarget;
} }
void wxWindow::ConnectDnDWidget( GtkWidget *widget ) void wxWindow::ConnectDnDWidget( GtkWidget *widget )
{ {
if (!m_pDropTarget) return; if (!m_dropTarget) return;
m_pDropTarget->RegisterWidget( widget ); m_dropTarget->RegisterWidget( widget );
gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event", gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event",
GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
@@ -2172,12 +2208,12 @@ void wxWindow::ConnectDnDWidget( GtkWidget *widget )
void wxWindow::DisconnectDnDWidget( GtkWidget *widget ) void wxWindow::DisconnectDnDWidget( GtkWidget *widget )
{ {
if (!m_pDropTarget) return; if (!m_dropTarget) return;
gtk_signal_disconnect_by_func( GTK_OBJECT(widget), gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
m_pDropTarget->UnregisterWidget( widget ); m_dropTarget->UnregisterWidget( widget );
} }
GtkWidget* wxWindow::GetConnectWidget() GtkWidget* wxWindow::GetConnectWidget()

View File

@@ -323,30 +323,14 @@ void wxApp::CommonInit(void)
wxInitializeResourceSystem(); wxInitializeResourceSystem();
// For PostScript printing wxImage::InitStandardHandlers();
#if wxUSE_POSTSCRIPT
/* Now done in wxPostScriptModule
wxInitializePrintSetupData();
wxThePrintPaperDatabase = new wxPrintPaperDatabase;
wxThePrintPaperDatabase->CreateDatabase();
*/
#endif
// g_globalCursor = new wxCursor;
/*
wxBitmap::InitStandardHandlers();
g_globalCursor = new wxCursor;
*/
} }
void wxApp::CommonCleanUp(void) void wxApp::CommonCleanUp(void)
{ {
wxDELETE(wxTheColourDatabase); wxDELETE(wxTheColourDatabase);
/* Now done in wxPostScriptModule
wxDELETE(wxThePrintPaperDatabase);
wxDELETE(wxThePrintSetupData);
*/
wxDELETE(wxTheFontNameDirectory); wxDELETE(wxTheFontNameDirectory);
wxDeleteStockObjects(); wxDeleteStockObjects();
@@ -358,6 +342,8 @@ void wxApp::CommonCleanUp(void)
wxCleanUpResourceSystem(); wxCleanUpResourceSystem();
wxImage::CleanUpHandlers();
wxSystemSettings::Done(); wxSystemSettings::Done();
} }

View File

@@ -13,6 +13,7 @@
#include "wx/bitmap.h" #include "wx/bitmap.h"
#include "wx/icon.h" #include "wx/icon.h"
#include "wx/filefn.h"
#include "gdk/gdkprivate.h" #include "gdk/gdkprivate.h"
#include "gdk/gdkx.h" #include "gdk/gdkx.h"
@@ -56,7 +57,6 @@ GdkBitmap *wxMask::GetBitmap(void) const
class wxBitmapRefData: public wxObjectRefData class wxBitmapRefData: public wxObjectRefData
{ {
public: public:
wxBitmapRefData(void); wxBitmapRefData(void);
~wxBitmapRefData(void); ~wxBitmapRefData(void);
@@ -287,8 +287,7 @@ void wxBitmap::SetMask( wxMask *mask )
M_BMPDATA->m_mask = mask; M_BMPDATA->m_mask = mask;
} }
bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type), bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) )
wxPalette *WXUNUSED(palette) )
{ {
if (!Ok()) if (!Ok())
{ {
@@ -296,20 +295,57 @@ bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type),
return FALSE; return FALSE;
} }
return FALSE; if (type == wxBITMAP_TYPE_PNG)
}
bool wxBitmap::LoadFile( const wxString &WXUNUSED(name), int WXUNUSED(type) )
{ {
if (!Ok()) wxImage image = ConvertToImage();
{ if (image.Ok()) return image.SaveFile( name, type );
wxFAIL_MSG( "invalid bitmap" );
return FALSE;
} }
return FALSE; return FALSE;
} }
bool wxBitmap::LoadFile( const wxString &name, int type )
{
UnRef();
if (!wxFileExists(name)) return FALSE;
if (type == wxBITMAP_TYPE_XPM)
{
m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL;
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( parent, &mask, NULL, name );
if (mask)
{
M_BMPDATA->m_mask = new wxMask();
M_BMPDATA->m_mask->m_bitmap = mask;
}
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
}
else if (type == wxBITMAP_TYPE_PNG)
{
wxImage image;
image.LoadFile( name, type );
if (image.Ok()) *this = wxBitmap( image );
}
else if (type == wxBITMAP_TYPE_BMP)
{
wxImage image;
image.LoadFile( name, type );
if (image.Ok()) *this = wxBitmap( image );
}
else
return FALSE;
return TRUE;
}
wxPalette *wxBitmap::GetPalette(void) const wxPalette *wxBitmap::GetPalette(void) const
{ {
if (!Ok()) return (wxPalette *) NULL; if (!Ok()) return (wxPalette *) NULL;
@@ -383,7 +419,7 @@ wxBitmap::wxBitmap( const wxImage &image )
// Render // Render
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
byte_order b_o; byte_order b_o = RGB;
if (render_depth >= 24) if (render_depth >= 24)
{ {
@@ -404,6 +440,7 @@ wxBitmap::wxBitmap( const wxImage &image )
int index = 0; int index = 0;
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
int r = data[index]; int r = data[index];
@@ -472,7 +509,8 @@ wxBitmap::wxBitmap( const wxImage &image )
} }
default: break; default: break;
} }
} } // for
} // for
// Blit picture // Blit picture
@@ -494,7 +532,6 @@ wxBitmap::wxBitmap( const wxImage &image )
gdk_image_destroy( mask_image ); gdk_image_destroy( mask_image );
gdk_gc_unref( mask_gc ); gdk_gc_unref( mask_gc );
} }
} }
wxImage wxBitmap::ConvertToImage() const wxImage wxBitmap::ConvertToImage() const
@@ -514,7 +551,6 @@ wxImage wxBitmap::ConvertToImage() const
image.Create( M_BMPDATA->m_width, M_BMPDATA->m_height ); image.Create( M_BMPDATA->m_width, M_BMPDATA->m_height );
char unsigned *data = image.GetData(); char unsigned *data = image.GetData();
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap ); GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
int bpp = visual->depth; int bpp = visual->depth;

View File

@@ -45,14 +45,20 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *
IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl)
wxButton::wxButton(void) wxButton::wxButton()
{ {
} }
wxButton::~wxButton()
{
if (m_clientData) delete m_clientData;
}
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxValidator& validator, const wxString &name ) long style, const wxValidator& validator, const wxString &name )
{ {
m_clientData = (wxClientData*) NULL;
m_needParent = TRUE; m_needParent = TRUE;
wxSize newSize = size; wxSize newSize = size;
@@ -118,3 +124,4 @@ void wxButton::ApplyWidgetStyle()
gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle ); gtk_widget_set_style( GTK_BUTTON(m_widget)->child, m_widgetStyle );
} }

View File

@@ -43,7 +43,7 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *
IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl)
wxChoice::wxChoice(void) wxChoice::wxChoice()
{ {
} }
@@ -69,6 +69,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
{ {
m_clientDataList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] ); GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_menu_append( GTK_MENU(menu), item ); gtk_menu_append( GTK_MENU(menu), item );
@@ -96,7 +98,19 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
return TRUE; return TRUE;
} }
void wxChoice::Append( const wxString &item ) wxChoice::~wxChoice()
{
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
}
void wxChoice::AppendCommon( const wxString &item )
{ {
wxCHECK_RET( m_widget != NULL, "invalid choice" ); wxCHECK_RET( m_widget != NULL, "invalid choice" );
@@ -116,13 +130,100 @@ void wxChoice::Append( const wxString &item )
gtk_widget_show( menu_item ); gtk_widget_show( menu_item );
} }
void wxChoice::Clear(void) void wxChoice::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxChoice::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxChoice::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
AppendCommon( item );
}
void wxChoice::SetClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
}
void* wxChoice::GetClientData( int n )
{
wxCHECK_MSG( m_widget != NULL, NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
}
void wxChoice::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
node->SetData( (wxObject*) clientData );
}
wxClientData* wxChoice::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
}
void wxChoice::Clear()
{ {
wxCHECK_RET( m_widget != NULL, "invalid choice" ); wxCHECK_RET( m_widget != NULL, "invalid choice" );
gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) ); gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) );
GtkWidget *menu = gtk_menu_new(); GtkWidget *menu = gtk_menu_new();
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxChoice::Delete( int WXUNUSED(n) ) void wxChoice::Delete( int WXUNUSED(n) )
@@ -159,12 +260,12 @@ int wxChoice::FindString( const wxString &string ) const
return -1; return -1;
} }
int wxChoice::GetColumns(void) const int wxChoice::GetColumns() const
{ {
return 1; return 1;
} }
int wxChoice::GetSelection(void) int wxChoice::GetSelection()
{ {
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" ); wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
@@ -213,7 +314,7 @@ wxString wxChoice::GetString( int n ) const
return ""; return "";
} }
wxString wxChoice::GetStringSelection(void) const wxString wxChoice::GetStringSelection() const
{ {
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" ); wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
@@ -224,7 +325,7 @@ wxString wxChoice::GetStringSelection(void) const
return label->label; return label->label;
} }
int wxChoice::Number(void) const int wxChoice::Number() const
{ {
wxCHECK_MSG( m_widget != NULL, 0, "invalid choice" ); wxCHECK_MSG( m_widget != NULL, 0, "invalid choice" );

View File

@@ -19,6 +19,9 @@
wxClipboard *wxTheClipboard = (wxClipboard*) NULL; wxClipboard *wxTheClipboard = (wxClipboard*) NULL;
GdkAtom g_textAtom = 0;
GdkAtom g_clipboardAtom = 0;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// functions // functions
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -39,11 +42,59 @@ void wxDoneClipboard()
// "selection_received" // "selection_received"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/* static void
static void selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointer data ) selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointer data )
{ {
} }
*/
//-----------------------------------------------------------------------------
// "selection_clear"
//-----------------------------------------------------------------------------
static gint
selection_clear( GtkWidget *widget, GdkEventSelection *event )
{
/* The clipboard is no longer in our hands. We can delete the
* clipboard data. I hope I got that one right... */
if (!wxTheClipboard) return TRUE;
wxTheClipboard->SetData( (wxDataObject*) NULL );
return TRUE;
}
//-----------------------------------------------------------------------------
// selection handler for supplying data
//-----------------------------------------------------------------------------
static void
selection_handler( GtkWidget *WXUNUSED(widget), GtkSelectionData *selection_data, gpointer WXUNUSED(data) )
{
if (!wxTheClipboard) return;
wxDataObject *data_object = wxTheClipboard->m_data;
if (!data_object) return;
if (data_object->GetDataSize() == 0) return;
gint len = data_object->GetDataSize();
guchar *bin_data = (guchar*) malloc( len );
data_object->GetDataHere( (void*)bin_data );
if (selection_data->target == GDK_SELECTION_TYPE_STRING)
{
gtk_selection_data_set(
selection_data, GDK_SELECTION_TYPE_STRING, 8*sizeof(gchar), bin_data, len );
}
else if (selection_data->target == g_textAtom)
{
gtk_selection_data_set(
selection_data, g_textAtom, 8*sizeof(gchar), bin_data, len );
}
free( bin_data );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxClipboard // wxClipboard
@@ -56,11 +107,26 @@ wxClipboard::wxClipboard()
m_data = (wxDataObject*) NULL; m_data = (wxDataObject*) NULL;
m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP ); m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
gtk_widget_realize( m_clipboardWidget ); gtk_widget_realize( m_clipboardWidget );
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_clear_event",
GTK_SIGNAL_FUNC( selection_clear ),
(gpointer) NULL );
if (!g_clipboardAtom) g_clipboardAtom = gdk_atom_intern( "CLIPBOARD", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "TEXT", FALSE );
} }
wxClipboard::~wxClipboard() wxClipboard::~wxClipboard()
{ {
if (m_data) delete m_data; /* As we have data we also own the clipboard. Once we no longer own
it, clear_selection is called which will set m_data to zero */
if (m_data)
{
delete m_data;
gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
}
if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget ); if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
} }
@@ -68,6 +134,38 @@ void wxClipboard::SetData( wxDataObject *data )
{ {
if (m_data) delete m_data; if (m_data) delete m_data;
m_data = data; m_data = data;
if (!m_data) return;
if (!gtk_selection_owner_set( m_clipboardWidget,
g_clipboardAtom,
GDK_CURRENT_TIME))
{
delete m_data;
m_data = (wxDataObject*) NULL;
return;
}
switch (m_data->GetPreferredFormat())
{
/*
case wxDF_STRING:
gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
GDK_TARGET_STRING,
selection_handler,
NULL );
break;
*/
case wxDF_TEXT:
gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
g_textAtom,
selection_handler,
NULL );
break;
default:
break;
}
} }
void *wxClipboard::GetData( wxDataFormat format, size_t *length ) void *wxClipboard::GetData( wxDataFormat format, size_t *length )

View File

@@ -58,7 +58,8 @@ END_EVENT_TABLE()
bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
long style, const wxValidator& validator, const wxString& name ) long style, const wxValidator& validator,
const wxString& name )
{ {
m_alreadySent = FALSE; m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
@@ -80,7 +81,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
{ {
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] ); GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
m_clientData.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_container_add( GTK_CONTAINER(list), list_item );
@@ -115,24 +116,19 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
return TRUE; return TRUE;
} }
void wxComboBox::Clear(void) wxComboBox::~wxComboBox()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxNode *node = m_clientDataList.First();
while (node)
GtkWidget *list = GTK_COMBO(m_widget)->list; {
gtk_list_clear_items( GTK_LIST(list), 0, Number() ); wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientData.Clear(); node = node->Next();
}
m_clientDataList.Clear();
} }
void wxComboBox::Append( const wxString &item ) void wxComboBox::AppendCommon( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
Append( item, (char*)NULL );
}
void wxComboBox::Append( const wxString &item, char *clientData )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -143,8 +139,6 @@ void wxComboBox::Append( const wxString &item, char *clientData )
gtk_signal_connect( GTK_OBJECT(list_item), "select", gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
m_clientData.Append( (wxObject*)clientData );
gtk_container_add( GTK_CONTAINER(list), list_item ); gtk_container_add( GTK_CONTAINER(list), list_item );
if (m_widgetStyle) ApplyWidgetStyle(); if (m_widgetStyle) ApplyWidgetStyle();
@@ -152,6 +146,100 @@ void wxComboBox::Append( const wxString &item, char *clientData )
gtk_widget_show( list_item ); gtk_widget_show( list_item );
} }
void wxComboBox::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxComboBox::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxComboBox::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
AppendCommon( item );
}
void wxComboBox::SetClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
}
void* wxComboBox::GetClientData( int n )
{
wxCHECK_MSG( m_widget != NULL, NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
}
void wxComboBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
node->SetData( (wxObject*) clientData );
}
wxClientData* wxComboBox::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
}
void wxComboBox::Clear()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, Number() );
wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
}
void wxComboBox::Delete( int n ) void wxComboBox::Delete( int n )
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -170,13 +258,17 @@ void wxComboBox::Delete( int n )
gtk_list_remove_items( listbox, list ); gtk_list_remove_items( listbox, list );
g_list_free( list ); g_list_free( list );
wxNode *node = m_clientData.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) if (!node)
{ {
wxFAIL_MSG( "wrong index" ); wxFAIL_MSG( "wrong index" );
} }
else else
m_clientData.DeleteNode( node ); {
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientDataList.DeleteNode( node );
}
} }
int wxComboBox::FindString( const wxString &item ) int wxComboBox::FindString( const wxString &item )
@@ -201,29 +293,7 @@ int wxComboBox::FindString( const wxString &item )
return -1; return -1;
} }
char* wxComboBox::GetClientData( int n ) int wxComboBox::GetSelection() const
{
wxCHECK_MSG( m_widget != NULL, (char*)NULL, "invalid combobox" );
wxNode *node = m_clientData.Nth( n );
if (node) return (char*)node->Data();
wxFAIL_MSG( "wxComboBox: wrong index" );
return (char *) NULL;
}
void wxComboBox::SetClientData( int n, char * clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientData.Nth( n );
if (node) node->SetData( (wxObject*) clientData );
wxFAIL_MSG( "wxComboBox: wrong index" );
}
int wxComboBox::GetSelection(void) const
{ {
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" ); wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
@@ -266,7 +336,7 @@ wxString wxComboBox::GetString( int n ) const
return ""; return "";
} }
wxString wxComboBox::GetStringSelection(void) const wxString wxComboBox::GetStringSelection() const
{ {
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" ); wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
@@ -285,7 +355,7 @@ wxString wxComboBox::GetStringSelection(void) const
return ""; return "";
} }
int wxComboBox::Number(void) const int wxComboBox::Number() const
{ {
wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" ); wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" );
@@ -314,7 +384,7 @@ void wxComboBox::SetStringSelection( const wxString &string )
SetSelection( res ); SetSelection( res );
} }
wxString wxComboBox::GetValue(void) const wxString wxComboBox::GetValue() const
{ {
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;
wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) ); wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) );
@@ -331,7 +401,7 @@ void wxComboBox::SetValue( const wxString& value )
gtk_entry_set_text( GTK_ENTRY(entry), tmp ); gtk_entry_set_text( GTK_ENTRY(entry), tmp );
} }
void wxComboBox::Copy(void) void wxComboBox::Copy()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -343,7 +413,7 @@ void wxComboBox::Copy(void)
#endif #endif
} }
void wxComboBox::Cut(void) void wxComboBox::Cut()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -355,7 +425,7 @@ void wxComboBox::Cut(void)
#endif #endif
} }
void wxComboBox::Paste(void) void wxComboBox::Paste()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -376,7 +446,7 @@ void wxComboBox::SetInsertionPoint( long pos )
gtk_entry_set_position( GTK_ENTRY(entry), tmp ); gtk_entry_set_position( GTK_ENTRY(entry), tmp );
} }
void wxComboBox::SetInsertionPointEnd(void) void wxComboBox::SetInsertionPointEnd()
{ {
wxCHECK_RET( m_widget != NULL, "invalid combobox" ); wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -385,13 +455,13 @@ void wxComboBox::SetInsertionPointEnd(void)
SetInsertionPoint( pos-1 ); SetInsertionPoint( pos-1 );
} }
long wxComboBox::GetInsertionPoint(void) const long wxComboBox::GetInsertionPoint() const
{ {
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;
return (long) GTK_EDITABLE(entry)->current_pos; return (long) GTK_EDITABLE(entry)->current_pos;
} }
long wxComboBox::GetLastPosition(void) const long wxComboBox::GetLastPosition() const
{ {
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int pos = GTK_ENTRY(entry)->text_length; int pos = GTK_ENTRY(entry)->text_length;
@@ -432,7 +502,6 @@ void wxComboBox::OnSize( wxSizeEvent &event )
wxControl::OnSize( event ); wxControl::OnSize( event );
int w = 21; int w = 21;
gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height ); gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y ); gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y );
@@ -460,7 +529,7 @@ void wxComboBox::ApplyWidgetStyle()
} }
} }
GtkWidget* wxComboBox::GetConnectWidget(void) GtkWidget* wxComboBox::GetConnectWidget()
{ {
return GTK_COMBO(m_widget)->entry; return GTK_COMBO(m_widget)->entry;
} }

View File

@@ -41,8 +41,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
event.m_commandInt = aSelections[0] ; event.m_commandInt = aSelections[0] ;
event.m_clientData = listbox->GetClientData( event.m_commandInt ); event.m_clientData = listbox->GetClientData( event.m_commandInt );
wxString str(listbox->GetString(event.m_commandInt)); wxString str(listbox->GetString(event.m_commandInt));
if (str != "") if (str != "") event.m_commandString = copystring((char *)(const char *)str);
event.m_commandString = copystring((char *)(const char *)str);
} }
else else
{ {
@@ -62,7 +61,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl)
wxListBox::wxListBox(void) wxListBox::wxListBox()
{ {
m_list = (GtkList *) NULL; m_list = (GtkList *) NULL;
} }
@@ -116,7 +115,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
ConnectWidget( list_item ); ConnectWidget( list_item );
m_clientData.Append( (wxObject*)NULL ); m_clientDataList.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
} }
@@ -137,12 +136,19 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
return TRUE; return TRUE;
} }
void wxListBox::Append( const wxString &item ) wxListBox::~wxListBox()
{ {
Append( item, (char*)NULL ); wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxListBox::Append( const wxString &item, char *clientData ) void wxListBox::AppendCommon( const wxString &item )
{ {
wxCHECK_RET( m_list != NULL, "invalid listbox" ); wxCHECK_RET( m_list != NULL, "invalid listbox" );
@@ -155,10 +161,6 @@ void wxListBox::Append( const wxString &item, char *clientData )
gtk_signal_connect( GTK_OBJECT(list_item), "deselect", gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
ConnectWidget( list_item );
m_clientData.Append( (wxObject*)clientData );
gtk_container_add( GTK_CONTAINER(m_list), list_item ); gtk_container_add( GTK_CONTAINER(m_list), list_item );
if (m_widgetStyle) ApplyWidgetStyle(); if (m_widgetStyle) ApplyWidgetStyle();
@@ -170,13 +172,97 @@ void wxListBox::Append( const wxString &item, char *clientData )
ConnectDnDWidget( list_item ); ConnectDnDWidget( list_item );
} }
void wxListBox::Clear(void) void wxListBox::Append( const wxString &item )
{
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, void *clientData )
{
if (clientData)
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
else
m_clientDataList.Append( (wxObject*)NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, wxClientData *clientData )
{
m_clientDataList.Append( (wxObject*) clientData );
AppendCommon( item );
}
void wxListBox::SetClientData( int n, void* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
if (clientData)
node->SetData( (wxObject*) new wxVoidClientData(clientData) );
else
node->SetData( (wxObject*) NULL );
}
void* wxListBox::GetClientData( int n )
{
wxCHECK_MSG( m_widget != NULL, NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
wxVoidClientData *cd = (wxVoidClientData*) node->Data();
if (cd)
return cd->GetData();
else
return (void*) NULL;
}
void wxListBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
if (cd) delete cd;
node->SetData( (wxObject*) clientData );
}
wxClientData* wxListBox::GetClientObject( int n )
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
wxNode *node = m_clientDataList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
}
void wxListBox::Clear()
{ {
wxCHECK_RET( m_list != NULL, "invalid listbox" ); wxCHECK_RET( m_list != NULL, "invalid listbox" );
gtk_list_clear_items( m_list, 0, Number() ); gtk_list_clear_items( m_list, 0, Number() );
m_clientData.Clear(); wxNode *node = m_clientDataList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
m_clientDataList.Clear();
} }
void wxListBox::Delete( int n ) void wxListBox::Delete( int n )
@@ -195,13 +281,17 @@ void wxListBox::Delete( int n )
gtk_list_remove_items( m_list, list ); gtk_list_remove_items( m_list, list );
g_list_free( list ); g_list_free( list );
wxNode *node = m_clientData.Nth( n ); wxNode *node = m_clientDataList.Nth( n );
if (!node) if (!node)
{ {
wxFAIL_MSG("wrong listbox index"); wxFAIL_MSG( "wrong index" );
} }
else else
m_clientData.DeleteNode( node ); {
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientDataList.DeleteNode( node );
}
} }
void wxListBox::Deselect( int n ) void wxListBox::Deselect( int n )
@@ -226,25 +316,12 @@ int wxListBox::FindString( const wxString &item ) const
child = child->next; child = child->next;
} }
// it's not an error if the string is not found - this function may be used to // it's not an error if the string is not found -> no wxCHECK
// test for existence of the string in the listbox, so don't give any
// errors/assert failures.
return -1; return -1;
} }
char *wxListBox::GetClientData( int n ) const int wxListBox::GetSelection() const
{
wxCHECK_MSG( m_list != NULL, (char*) NULL, "invalid listbox" );
wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data());
wxFAIL_MSG("wrong listbox index");
return (char *) NULL;
}
int wxListBox::GetSelection(void) const
{ {
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" ); wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
@@ -274,7 +351,8 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const
aSelections.Empty(); aSelections.Empty();
if ( count > 0 ) { if (count > 0)
{
// now fill the list // now fill the list
aSelections.Alloc(count); // optimization attempt aSelections.Alloc(count); // optimization attempt
int i = 0; int i = 0;
@@ -303,7 +381,7 @@ wxString wxListBox::GetString( int n ) const
return ""; return "";
} }
wxString wxListBox::GetStringSelection(void) const wxString wxListBox::GetStringSelection() const
{ {
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" ); wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
@@ -318,7 +396,7 @@ wxString wxListBox::GetStringSelection(void) const
return ""; return "";
} }
int wxListBox::Number(void) int wxListBox::Number()
{ {
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" ); wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
@@ -351,21 +429,6 @@ void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
wxFAIL_MSG("wxListBox::Set not implemented"); wxFAIL_MSG("wxListBox::Set not implemented");
} }
void wxListBox::SetClientData( int n, char *clientData )
{
wxCHECK_RET( m_list != NULL, "invalid listbox" );
wxNode *node = m_clientData.Nth( n );
if (node)
{
node->SetData( (wxObject*)clientData );
}
else
{
wxFAIL_MSG("wrong listbox index");
}
}
void wxListBox::SetFirstItem( int WXUNUSED(n) ) void wxListBox::SetFirstItem( int WXUNUSED(n) )
{ {
wxFAIL_MSG("wxListBox::SetFirstItem not implemented"); wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
@@ -447,7 +510,7 @@ void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
} }
} }
GtkWidget *wxListBox::GetConnectWidget(void) GtkWidget *wxListBox::GetConnectWidget()
{ {
return GTK_WIDGET(m_list); return GTK_WIDGET(m_list);
} }

View File

@@ -933,7 +933,7 @@ wxWindow::wxWindow()
m_oldVerticalPos = 0.0; m_oldVerticalPos = 0.0;
m_isShown = FALSE; m_isShown = FALSE;
m_isEnabled = TRUE; m_isEnabled = TRUE;
m_pDropTarget = (wxDropTarget *) NULL; m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE; m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL; m_widgetStyle = (GtkStyle*) NULL;
@@ -1059,7 +1059,7 @@ wxWindow::~wxWindow()
{ {
m_hasVMT = FALSE; m_hasVMT = FALSE;
if (m_pDropTarget) delete m_pDropTarget; if (m_dropTarget) delete m_dropTarget;
if (m_parent) m_parent->RemoveChild( this ); if (m_parent) m_parent->RemoveChild( this );
if (m_widget) Show( FALSE ); if (m_widget) Show( FALSE );
@@ -1114,6 +1114,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
wxFatalError( "Need complete parent.", name ); wxFatalError( "Need complete parent.", name );
m_widget = (GtkWidget *) NULL; m_widget = (GtkWidget *) NULL;
m_wxwindow = (GtkWidget *) NULL;
m_hasVMT = FALSE; m_hasVMT = FALSE;
m_parent = parent; m_parent = parent;
m_children.DeleteContents( FALSE ); m_children.DeleteContents( FALSE );
@@ -1148,7 +1149,6 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_eventHandler = this; m_eventHandler = this;
m_windowId = id; m_windowId = id;
m_sizeSet = FALSE; m_sizeSet = FALSE;
if (m_cursor == NULL)
m_cursor = new wxCursor( wxCURSOR_ARROW ); m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT; m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE; // m_backgroundColour = wxWHITE;
@@ -1162,7 +1162,13 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_autoLayout = FALSE; m_autoLayout = FALSE;
m_hasScrolling = FALSE; m_hasScrolling = FALSE;
m_isScrolling = FALSE; m_isScrolling = FALSE;
m_pDropTarget = (wxDropTarget *) NULL; m_hAdjust = (GtkAdjustment *) NULL;
m_vAdjust = (GtkAdjustment *) NULL;
m_oldHorizontalPos = 0.0;
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE; m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL; m_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL; m_scrollGC = (GdkGC*) NULL;
@@ -1839,6 +1845,36 @@ void wxWindow::SetValidator( const wxValidator& validator )
if (m_windowValidator) m_windowValidator->SetWindow(this); if (m_windowValidator) m_windowValidator->SetWindow(this);
} }
void wxWindow::SetClientObject( wxClientData *data )
{
if (m_clientData) delete m_clientData;
m_clientData = data;
}
wxClientData *wxWindow::GetClientObject()
{
return m_clientData;
}
void wxWindow::SetClientData( void *data )
{
if (m_clientData) delete m_clientData;
if (data)
m_clientData = new wxVoidClientData( data );
else
m_clientData = (wxClientData*) NULL;
}
void *wxWindow::GetClientData()
{
if (!m_clientData) return NULL;
wxVoidClientData *vd = (wxVoidClientData*) m_clientData;
return vd->GetData();
}
bool wxWindow::IsBeingDeleted() bool wxWindow::IsBeingDeleted()
{ {
return FALSE; return FALSE;
@@ -2149,22 +2185,22 @@ void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
DisconnectDnDWidget( dnd_widget ); DisconnectDnDWidget( dnd_widget );
if (m_pDropTarget) delete m_pDropTarget; if (m_dropTarget) delete m_dropTarget;
m_pDropTarget = dropTarget; m_dropTarget = dropTarget;
ConnectDnDWidget( dnd_widget ); ConnectDnDWidget( dnd_widget );
} }
wxDropTarget *wxWindow::GetDropTarget() const wxDropTarget *wxWindow::GetDropTarget() const
{ {
return m_pDropTarget; return m_dropTarget;
} }
void wxWindow::ConnectDnDWidget( GtkWidget *widget ) void wxWindow::ConnectDnDWidget( GtkWidget *widget )
{ {
if (!m_pDropTarget) return; if (!m_dropTarget) return;
m_pDropTarget->RegisterWidget( widget ); m_dropTarget->RegisterWidget( widget );
gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event", gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event",
GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
@@ -2172,12 +2208,12 @@ void wxWindow::ConnectDnDWidget( GtkWidget *widget )
void wxWindow::DisconnectDnDWidget( GtkWidget *widget ) void wxWindow::DisconnectDnDWidget( GtkWidget *widget )
{ {
if (!m_pDropTarget) return; if (!m_dropTarget) return;
gtk_signal_disconnect_by_func( GTK_OBJECT(widget), gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
m_pDropTarget->UnregisterWidget( widget ); m_dropTarget->UnregisterWidget( widget );
} }
GtkWidget* wxWindow::GetConnectWidget() GtkWidget* wxWindow::GetConnectWidget()