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

View File

@@ -69,7 +69,7 @@ public:
// Because the objects of this class are deleted by the tree, they should
// always be allocated on the heap!
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeItemData
class WXDLLEXPORT wxTreeItemData: public wxClientData
{
friend class wxTreeCtrl;
public:
@@ -80,11 +80,6 @@ public:
// 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
const wxTreeItemId& GetId() const { return m_pItem; }
void SetId(const wxTreeItemId& id) { m_pItem = id; }

View File

@@ -37,7 +37,6 @@ class wxMask: public wxObject
DECLARE_DYNAMIC_CLASS(wxMask)
public:
wxMask();
wxMask( const wxBitmap& bitmap, const wxColour& colour );
wxMask( const wxBitmap& bitmap, int paletteIndex );
@@ -46,14 +45,8 @@ class wxMask: public wxObject
// implementation
GdkBitmap *GetBitmap() const;
protected:
friend wxBitmap;
GdkBitmap *m_bitmap;
GdkBitmap *GetBitmap() const;
};
//-----------------------------------------------------------------------------
@@ -65,7 +58,6 @@ class wxBitmap: public wxObject
DECLARE_DYNAMIC_CLASS(wxBitmap)
public:
wxBitmap();
wxBitmap( 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:
wxButton(void);
wxButton();
inline wxButton(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
@@ -51,19 +51,19 @@ class wxButton: public wxControl
{
Create(parent, id, label, pos, size, style, validator, name);
}
~wxButton();
bool Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
void SetDefault(void);
void SetDefault();
void SetLabel( const wxString &label );
void Enable( bool enable );
// implementation
void ApplyWidgetStyle();
};
#endif // __GTKBUTTONH__

View File

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

View File

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

View File

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

View File

@@ -43,11 +43,12 @@ class wxSizer;
class wxResourceTable;
class wxItemResource;
class wxClientData;
class wxVoidClientData;
class wxWindow;
class wxCanvas;
//-----------------------------------------------------------------------------
// callback definition for inserting a window
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
@@ -60,6 +61,49 @@ extern const char *wxPanelNameStr;
extern const wxSize wxDefaultSize;
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
//-----------------------------------------------------------------------------
@@ -122,7 +166,7 @@ public:
virtual void Enable( bool enable );
virtual void MakeModal( bool modal );
virtual bool IsEnabled() const { return m_isEnabled; }
inline bool Enabled(void) const { return IsEnabled(); }
inline bool Enabled() const { return IsEnabled(); }
virtual void SetFocus();
virtual bool OnClose();
@@ -133,7 +177,7 @@ public:
int GetReturnCode();
wxWindow *GetParent() const
{ return m_parent; }
wxWindow *GetGrandParent(void) const
wxWindow *GetGrandParent() const
{ return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
void SetParent( wxWindow *p )
{ m_parent = p; }
@@ -146,6 +190,13 @@ public:
virtual wxValidator *GetValidator();
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 wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
@@ -170,8 +221,8 @@ public:
virtual wxColour GetForegroundColour() const;
virtual void SetForegroundColour( const wxColour &colour );
virtual int GetCharHeight(void) const;
virtual int GetCharWidth(void) const;
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent( const wxString& string, int *x, int *y,
int *descent = (int *) NULL,
int *externalLeading = (int *) NULL,
@@ -179,15 +230,19 @@ public:
virtual void SetFont( const wxFont &font );
virtual wxFont *GetFont();
// For backward compatibility
inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
inline virtual wxFont *GetLabelFont() { return GetFont(); };
inline virtual wxFont *GetButtonFont() { return GetFont(); };
virtual void SetWindowStyleFlag( long flag );
virtual long GetWindowStyleFlag() const;
virtual void CaptureMouse();
virtual void ReleaseMouse();
virtual void SetTitle( const wxString &title );
virtual wxString GetTitle() const;
virtual void SetName( const wxString &name );
@@ -198,14 +253,16 @@ public:
virtual bool IsShown() const;
virtual void Raise(void);
virtual void Lower(void);
virtual void Raise();
virtual void Lower();
virtual bool IsRetained();
virtual wxWindow *FindWindow( long id );
virtual wxWindow *FindWindow( const wxString& name );
void AllowDoubleClick( bool WXUNUSED(allow) ) {};
void SetDoubleClick( bool WXUNUSED(allow) ) {};
virtual void ClientToScreen( 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 bool AcceptsFocus() const;
void UpdateWindowUI();
// 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 );
void ConnectWidget( GtkWidget *widget );
void ConnectDnDWidget( 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();
virtual void ImplementSetSize();
@@ -264,7 +322,7 @@ public:
int m_retCode;
wxEvtHandler *m_eventHandler;
wxValidator *m_windowValidator;
wxDropTarget *m_pDropTarget;
wxDropTarget *m_dropTarget;
wxWindowID m_windowId;
wxCursor *m_cursor;
wxFont m_font;
@@ -276,6 +334,7 @@ public:
bool m_isEnabled;
wxString m_windowName;
wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientData;
GtkWidget *m_widget;
GtkWidget *m_wxwindow;

View File

@@ -37,7 +37,6 @@ class wxMask: public wxObject
DECLARE_DYNAMIC_CLASS(wxMask)
public:
wxMask();
wxMask( const wxBitmap& bitmap, const wxColour& colour );
wxMask( const wxBitmap& bitmap, int paletteIndex );
@@ -46,14 +45,8 @@ class wxMask: public wxObject
// implementation
GdkBitmap *GetBitmap() const;
protected:
friend wxBitmap;
GdkBitmap *m_bitmap;
GdkBitmap *GetBitmap() const;
};
//-----------------------------------------------------------------------------
@@ -65,7 +58,6 @@ class wxBitmap: public wxObject
DECLARE_DYNAMIC_CLASS(wxBitmap)
public:
wxBitmap();
wxBitmap( 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:
wxButton(void);
wxButton();
inline wxButton(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
@@ -51,19 +51,19 @@ class wxButton: public wxControl
{
Create(parent, id, label, pos, size, style, validator, name);
}
~wxButton();
bool Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
void SetDefault(void);
void SetDefault();
void SetLabel( const wxString &label );
void Enable( bool enable );
// implementation
void ApplyWidgetStyle();
};
#endif // __GTKBUTTONH__

View File

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

View File

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

View File

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

View File

@@ -43,11 +43,12 @@ class wxSizer;
class wxResourceTable;
class wxItemResource;
class wxClientData;
class wxVoidClientData;
class wxWindow;
class wxCanvas;
//-----------------------------------------------------------------------------
// callback definition for inserting a window
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
typedef void (*wxInsertChildFunction)( wxWindow*, wxWindow* );
@@ -60,6 +61,49 @@ extern const char *wxPanelNameStr;
extern const wxSize wxDefaultSize;
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
//-----------------------------------------------------------------------------
@@ -122,7 +166,7 @@ public:
virtual void Enable( bool enable );
virtual void MakeModal( bool modal );
virtual bool IsEnabled() const { return m_isEnabled; }
inline bool Enabled(void) const { return IsEnabled(); }
inline bool Enabled() const { return IsEnabled(); }
virtual void SetFocus();
virtual bool OnClose();
@@ -133,7 +177,7 @@ public:
int GetReturnCode();
wxWindow *GetParent() const
{ return m_parent; }
wxWindow *GetGrandParent(void) const
wxWindow *GetGrandParent() const
{ return (m_parent ? m_parent->m_parent : (wxWindow*)NULL); }
void SetParent( wxWindow *p )
{ m_parent = p; }
@@ -146,6 +190,13 @@ public:
virtual wxValidator *GetValidator();
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 wxAcceleratorTable *GetAcceleratorTable() { return &m_acceleratorTable; }
@@ -170,8 +221,8 @@ public:
virtual wxColour GetForegroundColour() const;
virtual void SetForegroundColour( const wxColour &colour );
virtual int GetCharHeight(void) const;
virtual int GetCharWidth(void) const;
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent( const wxString& string, int *x, int *y,
int *descent = (int *) NULL,
int *externalLeading = (int *) NULL,
@@ -179,15 +230,19 @@ public:
virtual void SetFont( const wxFont &font );
virtual wxFont *GetFont();
// For backward compatibility
inline virtual void SetButtonFont(const wxFont& font) { SetFont(font); }
inline virtual void SetLabelFont(const wxFont& font) { SetFont(font); }
inline virtual wxFont *GetLabelFont() { return GetFont(); };
inline virtual wxFont *GetButtonFont() { return GetFont(); };
virtual void SetWindowStyleFlag( long flag );
virtual long GetWindowStyleFlag() const;
virtual void CaptureMouse();
virtual void ReleaseMouse();
virtual void SetTitle( const wxString &title );
virtual wxString GetTitle() const;
virtual void SetName( const wxString &name );
@@ -198,14 +253,16 @@ public:
virtual bool IsShown() const;
virtual void Raise(void);
virtual void Lower(void);
virtual void Raise();
virtual void Lower();
virtual bool IsRetained();
virtual wxWindow *FindWindow( long id );
virtual wxWindow *FindWindow( const wxString& name );
void AllowDoubleClick( bool WXUNUSED(allow) ) {};
void SetDoubleClick( bool WXUNUSED(allow) ) {};
virtual void ClientToScreen( 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 bool AcceptsFocus() const;
void UpdateWindowUI();
// 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 );
void ConnectWidget( GtkWidget *widget );
void ConnectDnDWidget( 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();
virtual void ImplementSetSize();
@@ -264,7 +322,7 @@ public:
int m_retCode;
wxEvtHandler *m_eventHandler;
wxValidator *m_windowValidator;
wxDropTarget *m_pDropTarget;
wxDropTarget *m_dropTarget;
wxWindowID m_windowId;
wxCursor *m_cursor;
wxFont m_font;
@@ -276,6 +334,7 @@ public:
bool m_isEnabled;
wxString m_windowName;
wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientData;
GtkWidget *m_widget;
GtkWidget *m_wxwindow;

View File

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

View File

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

View File

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

View File

@@ -13,6 +13,7 @@
#include "wx/bitmap.h"
#include "wx/icon.h"
#include "wx/filefn.h"
#include "gdk/gdkprivate.h"
#include "gdk/gdkx.h"
@@ -56,7 +57,6 @@ GdkBitmap *wxMask::GetBitmap(void) const
class wxBitmapRefData: public wxObjectRefData
{
public:
wxBitmapRefData(void);
~wxBitmapRefData(void);
@@ -287,8 +287,7 @@ void wxBitmap::SetMask( wxMask *mask )
M_BMPDATA->m_mask = mask;
}
bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type),
wxPalette *WXUNUSED(palette) )
bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) )
{
if (!Ok())
{
@@ -296,20 +295,57 @@ bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type),
return FALSE;
}
return FALSE;
}
bool wxBitmap::LoadFile( const wxString &WXUNUSED(name), int WXUNUSED(type) )
if (type == wxBITMAP_TYPE_PNG)
{
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return FALSE;
wxImage image = ConvertToImage();
if (image.Ok()) return image.SaveFile( name, type );
}
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
{
if (!Ok()) return (wxPalette *) NULL;
@@ -383,7 +419,7 @@ wxBitmap::wxBitmap( const wxImage &image )
// Render
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
byte_order b_o;
byte_order b_o = RGB;
if (render_depth >= 24)
{
@@ -404,6 +440,7 @@ wxBitmap::wxBitmap( const wxImage &image )
int index = 0;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int r = data[index];
@@ -472,7 +509,8 @@ wxBitmap::wxBitmap( const wxImage &image )
}
default: break;
}
}
} // for
} // for
// Blit picture
@@ -494,7 +532,6 @@ wxBitmap::wxBitmap( const wxImage &image )
gdk_image_destroy( mask_image );
gdk_gc_unref( mask_gc );
}
}
wxImage wxBitmap::ConvertToImage() const
@@ -514,7 +551,6 @@ wxImage wxBitmap::ConvertToImage() const
image.Create( M_BMPDATA->m_width, M_BMPDATA->m_height );
char unsigned *data = image.GetData();
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
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)
wxButton::wxButton(void)
wxButton::wxButton()
{
}
wxButton::~wxButton()
{
if (m_clientData) delete m_clientData;
}
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size,
long style, const wxValidator& validator, const wxString &name )
{
m_clientData = (wxClientData*) NULL;
m_needParent = TRUE;
wxSize newSize = size;
@@ -118,3 +124,4 @@ void wxButton::ApplyWidgetStyle()
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)
wxChoice::wxChoice(void)
wxChoice::wxChoice()
{
}
@@ -69,6 +69,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++)
{
m_clientDataList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_menu_append( GTK_MENU(menu), item );
@@ -96,7 +98,19 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
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" );
@@ -116,13 +130,100 @@ void wxChoice::Append( const wxString &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" );
gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) );
GtkWidget *menu = gtk_menu_new();
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) )
@@ -159,12 +260,12 @@ int wxChoice::FindString( const wxString &string ) const
return -1;
}
int wxChoice::GetColumns(void) const
int wxChoice::GetColumns() const
{
return 1;
}
int wxChoice::GetSelection(void)
int wxChoice::GetSelection()
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
@@ -213,7 +314,7 @@ wxString wxChoice::GetString( int n ) const
return "";
}
wxString wxChoice::GetStringSelection(void) const
wxString wxChoice::GetStringSelection() const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
@@ -224,7 +325,7 @@ wxString wxChoice::GetStringSelection(void) const
return label->label;
}
int wxChoice::Number(void) const
int wxChoice::Number() const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid choice" );

View File

@@ -19,6 +19,9 @@
wxClipboard *wxTheClipboard = (wxClipboard*) NULL;
GdkAtom g_textAtom = 0;
GdkAtom g_clipboardAtom = 0;
//-----------------------------------------------------------------------------
// functions
//-----------------------------------------------------------------------------
@@ -39,11 +42,59 @@ void wxDoneClipboard()
// "selection_received"
//-----------------------------------------------------------------------------
/*
static void selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointer data )
static void
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
@@ -56,11 +107,26 @@ wxClipboard::wxClipboard()
m_data = (wxDataObject*) NULL;
m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
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()
{
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 );
}
@@ -68,6 +134,38 @@ void wxClipboard::SetData( wxDataObject *data )
{
if (m_data) delete m_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 )

View File

@@ -58,7 +58,8 @@ END_EVENT_TABLE()
bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[],
long style, const wxValidator& validator, const wxString& name )
long style, const wxValidator& validator,
const wxString& name )
{
m_alreadySent = FALSE;
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] );
m_clientData.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item );
@@ -115,24 +116,19 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
return TRUE;
}
void wxComboBox::Clear(void)
wxComboBox::~wxComboBox()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(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 wxComboBox::Append( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
Append( item, (char*)NULL );
}
void wxComboBox::Append( const wxString &item, char *clientData )
void wxComboBox::AppendCommon( const wxString &item )
{
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_FUNC(gtk_combo_clicked_callback), (gpointer)this );
m_clientData.Append( (wxObject*)clientData );
gtk_container_add( GTK_CONTAINER(list), list_item );
if (m_widgetStyle) ApplyWidgetStyle();
@@ -152,6 +146,100 @@ void wxComboBox::Append( const wxString &item, char *clientData )
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 )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -170,13 +258,17 @@ void wxComboBox::Delete( int n )
gtk_list_remove_items( listbox, list );
g_list_free( list );
wxNode *node = m_clientData.Nth( n );
wxNode *node = m_clientDataList.Nth( n );
if (!node)
{
wxFAIL_MSG( "wrong index" );
}
else
m_clientData.DeleteNode( node );
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientDataList.DeleteNode( node );
}
}
int wxComboBox::FindString( const wxString &item )
@@ -201,29 +293,7 @@ int wxComboBox::FindString( const wxString &item )
return -1;
}
char* wxComboBox::GetClientData( int n )
{
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
int wxComboBox::GetSelection() const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
@@ -266,7 +336,7 @@ wxString wxComboBox::GetString( int n ) const
return "";
}
wxString wxComboBox::GetStringSelection(void) const
wxString wxComboBox::GetStringSelection() const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
@@ -285,7 +355,7 @@ wxString wxComboBox::GetStringSelection(void) const
return "";
}
int wxComboBox::Number(void) const
int wxComboBox::Number() const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" );
@@ -314,7 +384,7 @@ void wxComboBox::SetStringSelection( const wxString &string )
SetSelection( res );
}
wxString wxComboBox::GetValue(void) const
wxString wxComboBox::GetValue() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->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 );
}
void wxComboBox::Copy(void)
void wxComboBox::Copy()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -343,7 +413,7 @@ void wxComboBox::Copy(void)
#endif
}
void wxComboBox::Cut(void)
void wxComboBox::Cut()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -355,7 +425,7 @@ void wxComboBox::Cut(void)
#endif
}
void wxComboBox::Paste(void)
void wxComboBox::Paste()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -376,7 +446,7 @@ void wxComboBox::SetInsertionPoint( long pos )
gtk_entry_set_position( GTK_ENTRY(entry), tmp );
}
void wxComboBox::SetInsertionPointEnd(void)
void wxComboBox::SetInsertionPointEnd()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -385,13 +455,13 @@ void wxComboBox::SetInsertionPointEnd(void)
SetInsertionPoint( pos-1 );
}
long wxComboBox::GetInsertionPoint(void) const
long wxComboBox::GetInsertionPoint() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
return (long) GTK_EDITABLE(entry)->current_pos;
}
long wxComboBox::GetLastPosition(void) const
long wxComboBox::GetLastPosition() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int pos = GTK_ENTRY(entry)->text_length;
@@ -432,7 +502,6 @@ void wxComboBox::OnSize( wxSizeEvent &event )
wxControl::OnSize( event );
int w = 21;
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 );
@@ -460,7 +529,7 @@ void wxComboBox::ApplyWidgetStyle()
}
}
GtkWidget* wxComboBox::GetConnectWidget(void)
GtkWidget* wxComboBox::GetConnectWidget()
{
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_clientData = listbox->GetClientData( event.m_commandInt );
wxString str(listbox->GetString(event.m_commandInt));
if (str != "")
event.m_commandString = copystring((char *)(const char *)str);
if (str != "") event.m_commandString = copystring((char *)(const char *)str);
}
else
{
@@ -62,7 +61,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl)
wxListBox::wxListBox(void)
wxListBox::wxListBox()
{
m_list = (GtkList *) NULL;
}
@@ -116,7 +115,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
ConnectWidget( list_item );
m_clientData.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*)NULL );
gtk_widget_show( list_item );
}
@@ -137,12 +136,19 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
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" );
@@ -155,10 +161,6 @@ void wxListBox::Append( const wxString &item, char *clientData )
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
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 );
if (m_widgetStyle) ApplyWidgetStyle();
@@ -170,13 +172,97 @@ void wxListBox::Append( const wxString &item, char *clientData )
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" );
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 )
@@ -195,13 +281,17 @@ void wxListBox::Delete( int n )
gtk_list_remove_items( m_list, list );
g_list_free( list );
wxNode *node = m_clientData.Nth( n );
wxNode *node = m_clientDataList.Nth( n );
if (!node)
{
wxFAIL_MSG("wrong listbox index");
wxFAIL_MSG( "wrong index" );
}
else
m_clientData.DeleteNode( node );
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientDataList.DeleteNode( node );
}
}
void wxListBox::Deselect( int n )
@@ -226,25 +316,12 @@ int wxListBox::FindString( const wxString &item ) const
child = child->next;
}
// it's not an error if the string is not found - this function may be used to
// test for existence of the string in the listbox, so don't give any
// errors/assert failures.
// it's not an error if the string is not found -> no wxCHECK
return -1;
}
char *wxListBox::GetClientData( int n ) 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
int wxListBox::GetSelection() const
{
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
@@ -274,7 +351,8 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const
aSelections.Empty();
if ( count > 0 ) {
if (count > 0)
{
// now fill the list
aSelections.Alloc(count); // optimization attempt
int i = 0;
@@ -303,7 +381,7 @@ wxString wxListBox::GetString( int n ) const
return "";
}
wxString wxListBox::GetStringSelection(void) const
wxString wxListBox::GetStringSelection() const
{
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
@@ -318,7 +396,7 @@ wxString wxListBox::GetStringSelection(void) const
return "";
}
int wxListBox::Number(void)
int wxListBox::Number()
{
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");
}
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) )
{
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);
}

View File

@@ -933,7 +933,7 @@ wxWindow::wxWindow()
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
m_pDropTarget = (wxDropTarget *) NULL;
m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
@@ -1059,7 +1059,7 @@ wxWindow::~wxWindow()
{
m_hasVMT = FALSE;
if (m_pDropTarget) delete m_pDropTarget;
if (m_dropTarget) delete m_dropTarget;
if (m_parent) m_parent->RemoveChild( this );
if (m_widget) Show( FALSE );
@@ -1114,6 +1114,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
wxFatalError( "Need complete parent.", name );
m_widget = (GtkWidget *) NULL;
m_wxwindow = (GtkWidget *) NULL;
m_hasVMT = FALSE;
m_parent = parent;
m_children.DeleteContents( FALSE );
@@ -1148,7 +1149,6 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_eventHandler = this;
m_windowId = id;
m_sizeSet = FALSE;
if (m_cursor == NULL)
m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE;
@@ -1162,7 +1162,13 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_autoLayout = FALSE;
m_hasScrolling = 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_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL;
@@ -1839,6 +1845,36 @@ void wxWindow::SetValidator( const wxValidator& validator )
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()
{
return FALSE;
@@ -2149,22 +2185,22 @@ void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
DisconnectDnDWidget( dnd_widget );
if (m_pDropTarget) delete m_pDropTarget;
m_pDropTarget = dropTarget;
if (m_dropTarget) delete m_dropTarget;
m_dropTarget = dropTarget;
ConnectDnDWidget( dnd_widget );
}
wxDropTarget *wxWindow::GetDropTarget() const
{
return m_pDropTarget;
return m_dropTarget;
}
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_FUNC(gtk_window_drop_callback), (gpointer)this );
@@ -2172,12 +2208,12 @@ void wxWindow::ConnectDnDWidget( 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_FUNC(gtk_window_drop_callback), (gpointer)this );
m_pDropTarget->UnregisterWidget( widget );
m_dropTarget->UnregisterWidget( widget );
}
GtkWidget* wxWindow::GetConnectWidget()

View File

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

View File

@@ -13,6 +13,7 @@
#include "wx/bitmap.h"
#include "wx/icon.h"
#include "wx/filefn.h"
#include "gdk/gdkprivate.h"
#include "gdk/gdkx.h"
@@ -56,7 +57,6 @@ GdkBitmap *wxMask::GetBitmap(void) const
class wxBitmapRefData: public wxObjectRefData
{
public:
wxBitmapRefData(void);
~wxBitmapRefData(void);
@@ -287,8 +287,7 @@ void wxBitmap::SetMask( wxMask *mask )
M_BMPDATA->m_mask = mask;
}
bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type),
wxPalette *WXUNUSED(palette) )
bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) )
{
if (!Ok())
{
@@ -296,20 +295,57 @@ bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type),
return FALSE;
}
return FALSE;
}
bool wxBitmap::LoadFile( const wxString &WXUNUSED(name), int WXUNUSED(type) )
if (type == wxBITMAP_TYPE_PNG)
{
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return FALSE;
wxImage image = ConvertToImage();
if (image.Ok()) return image.SaveFile( name, type );
}
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
{
if (!Ok()) return (wxPalette *) NULL;
@@ -383,7 +419,7 @@ wxBitmap::wxBitmap( const wxImage &image )
// Render
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
byte_order b_o;
byte_order b_o = RGB;
if (render_depth >= 24)
{
@@ -404,6 +440,7 @@ wxBitmap::wxBitmap( const wxImage &image )
int index = 0;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int r = data[index];
@@ -472,7 +509,8 @@ wxBitmap::wxBitmap( const wxImage &image )
}
default: break;
}
}
} // for
} // for
// Blit picture
@@ -494,7 +532,6 @@ wxBitmap::wxBitmap( const wxImage &image )
gdk_image_destroy( mask_image );
gdk_gc_unref( mask_gc );
}
}
wxImage wxBitmap::ConvertToImage() const
@@ -514,7 +551,6 @@ wxImage wxBitmap::ConvertToImage() const
image.Create( M_BMPDATA->m_width, M_BMPDATA->m_height );
char unsigned *data = image.GetData();
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
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)
wxButton::wxButton(void)
wxButton::wxButton()
{
}
wxButton::~wxButton()
{
if (m_clientData) delete m_clientData;
}
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size,
long style, const wxValidator& validator, const wxString &name )
{
m_clientData = (wxClientData*) NULL;
m_needParent = TRUE;
wxSize newSize = size;
@@ -118,3 +124,4 @@ void wxButton::ApplyWidgetStyle()
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)
wxChoice::wxChoice(void)
wxChoice::wxChoice()
{
}
@@ -69,6 +69,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
for (int i = 0; i < n; i++)
{
m_clientDataList.Append( (wxObject*) NULL );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
gtk_menu_append( GTK_MENU(menu), item );
@@ -96,7 +98,19 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
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" );
@@ -116,13 +130,100 @@ void wxChoice::Append( const wxString &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" );
gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) );
GtkWidget *menu = gtk_menu_new();
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) )
@@ -159,12 +260,12 @@ int wxChoice::FindString( const wxString &string ) const
return -1;
}
int wxChoice::GetColumns(void) const
int wxChoice::GetColumns() const
{
return 1;
}
int wxChoice::GetSelection(void)
int wxChoice::GetSelection()
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
@@ -213,7 +314,7 @@ wxString wxChoice::GetString( int n ) const
return "";
}
wxString wxChoice::GetStringSelection(void) const
wxString wxChoice::GetStringSelection() const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
@@ -224,7 +325,7 @@ wxString wxChoice::GetStringSelection(void) const
return label->label;
}
int wxChoice::Number(void) const
int wxChoice::Number() const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid choice" );

View File

@@ -19,6 +19,9 @@
wxClipboard *wxTheClipboard = (wxClipboard*) NULL;
GdkAtom g_textAtom = 0;
GdkAtom g_clipboardAtom = 0;
//-----------------------------------------------------------------------------
// functions
//-----------------------------------------------------------------------------
@@ -39,11 +42,59 @@ void wxDoneClipboard()
// "selection_received"
//-----------------------------------------------------------------------------
/*
static void selection_received( GtkWidget *widget, GtkSelectionData *selection_data, gpointer data )
static void
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
@@ -56,11 +107,26 @@ wxClipboard::wxClipboard()
m_data = (wxDataObject*) NULL;
m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
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()
{
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 );
}
@@ -68,6 +134,38 @@ void wxClipboard::SetData( wxDataObject *data )
{
if (m_data) delete m_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 )

View File

@@ -58,7 +58,8 @@ END_EVENT_TABLE()
bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[],
long style, const wxValidator& validator, const wxString& name )
long style, const wxValidator& validator,
const wxString& name )
{
m_alreadySent = FALSE;
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] );
m_clientData.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*)NULL );
gtk_container_add( GTK_CONTAINER(list), list_item );
@@ -115,24 +116,19 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
return TRUE;
}
void wxComboBox::Clear(void)
wxComboBox::~wxComboBox()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(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 wxComboBox::Append( const wxString &item )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
Append( item, (char*)NULL );
}
void wxComboBox::Append( const wxString &item, char *clientData )
void wxComboBox::AppendCommon( const wxString &item )
{
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_FUNC(gtk_combo_clicked_callback), (gpointer)this );
m_clientData.Append( (wxObject*)clientData );
gtk_container_add( GTK_CONTAINER(list), list_item );
if (m_widgetStyle) ApplyWidgetStyle();
@@ -152,6 +146,100 @@ void wxComboBox::Append( const wxString &item, char *clientData )
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 )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -170,13 +258,17 @@ void wxComboBox::Delete( int n )
gtk_list_remove_items( listbox, list );
g_list_free( list );
wxNode *node = m_clientData.Nth( n );
wxNode *node = m_clientDataList.Nth( n );
if (!node)
{
wxFAIL_MSG( "wrong index" );
}
else
m_clientData.DeleteNode( node );
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientDataList.DeleteNode( node );
}
}
int wxComboBox::FindString( const wxString &item )
@@ -201,29 +293,7 @@ int wxComboBox::FindString( const wxString &item )
return -1;
}
char* wxComboBox::GetClientData( int n )
{
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
int wxComboBox::GetSelection() const
{
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
@@ -266,7 +336,7 @@ wxString wxComboBox::GetString( int n ) const
return "";
}
wxString wxComboBox::GetStringSelection(void) const
wxString wxComboBox::GetStringSelection() const
{
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
@@ -285,7 +355,7 @@ wxString wxComboBox::GetStringSelection(void) const
return "";
}
int wxComboBox::Number(void) const
int wxComboBox::Number() const
{
wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" );
@@ -314,7 +384,7 @@ void wxComboBox::SetStringSelection( const wxString &string )
SetSelection( res );
}
wxString wxComboBox::GetValue(void) const
wxString wxComboBox::GetValue() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->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 );
}
void wxComboBox::Copy(void)
void wxComboBox::Copy()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -343,7 +413,7 @@ void wxComboBox::Copy(void)
#endif
}
void wxComboBox::Cut(void)
void wxComboBox::Cut()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -355,7 +425,7 @@ void wxComboBox::Cut(void)
#endif
}
void wxComboBox::Paste(void)
void wxComboBox::Paste()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -376,7 +446,7 @@ void wxComboBox::SetInsertionPoint( long pos )
gtk_entry_set_position( GTK_ENTRY(entry), tmp );
}
void wxComboBox::SetInsertionPointEnd(void)
void wxComboBox::SetInsertionPointEnd()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
@@ -385,13 +455,13 @@ void wxComboBox::SetInsertionPointEnd(void)
SetInsertionPoint( pos-1 );
}
long wxComboBox::GetInsertionPoint(void) const
long wxComboBox::GetInsertionPoint() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
return (long) GTK_EDITABLE(entry)->current_pos;
}
long wxComboBox::GetLastPosition(void) const
long wxComboBox::GetLastPosition() const
{
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int pos = GTK_ENTRY(entry)->text_length;
@@ -432,7 +502,6 @@ void wxComboBox::OnSize( wxSizeEvent &event )
wxControl::OnSize( event );
int w = 21;
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 );
@@ -460,7 +529,7 @@ void wxComboBox::ApplyWidgetStyle()
}
}
GtkWidget* wxComboBox::GetConnectWidget(void)
GtkWidget* wxComboBox::GetConnectWidget()
{
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_clientData = listbox->GetClientData( event.m_commandInt );
wxString str(listbox->GetString(event.m_commandInt));
if (str != "")
event.m_commandString = copystring((char *)(const char *)str);
if (str != "") event.m_commandString = copystring((char *)(const char *)str);
}
else
{
@@ -62,7 +61,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl)
wxListBox::wxListBox(void)
wxListBox::wxListBox()
{
m_list = (GtkList *) NULL;
}
@@ -116,7 +115,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
ConnectWidget( list_item );
m_clientData.Append( (wxObject*)NULL );
m_clientDataList.Append( (wxObject*)NULL );
gtk_widget_show( list_item );
}
@@ -137,12 +136,19 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
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" );
@@ -155,10 +161,6 @@ void wxListBox::Append( const wxString &item, char *clientData )
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
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 );
if (m_widgetStyle) ApplyWidgetStyle();
@@ -170,13 +172,97 @@ void wxListBox::Append( const wxString &item, char *clientData )
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" );
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 )
@@ -195,13 +281,17 @@ void wxListBox::Delete( int n )
gtk_list_remove_items( m_list, list );
g_list_free( list );
wxNode *node = m_clientData.Nth( n );
wxNode *node = m_clientDataList.Nth( n );
if (!node)
{
wxFAIL_MSG("wrong listbox index");
wxFAIL_MSG( "wrong index" );
}
else
m_clientData.DeleteNode( node );
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
m_clientDataList.DeleteNode( node );
}
}
void wxListBox::Deselect( int n )
@@ -226,25 +316,12 @@ int wxListBox::FindString( const wxString &item ) const
child = child->next;
}
// it's not an error if the string is not found - this function may be used to
// test for existence of the string in the listbox, so don't give any
// errors/assert failures.
// it's not an error if the string is not found -> no wxCHECK
return -1;
}
char *wxListBox::GetClientData( int n ) 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
int wxListBox::GetSelection() const
{
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
@@ -274,7 +351,8 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const
aSelections.Empty();
if ( count > 0 ) {
if (count > 0)
{
// now fill the list
aSelections.Alloc(count); // optimization attempt
int i = 0;
@@ -303,7 +381,7 @@ wxString wxListBox::GetString( int n ) const
return "";
}
wxString wxListBox::GetStringSelection(void) const
wxString wxListBox::GetStringSelection() const
{
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
@@ -318,7 +396,7 @@ wxString wxListBox::GetStringSelection(void) const
return "";
}
int wxListBox::Number(void)
int wxListBox::Number()
{
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");
}
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) )
{
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);
}

View File

@@ -933,7 +933,7 @@ wxWindow::wxWindow()
m_oldVerticalPos = 0.0;
m_isShown = FALSE;
m_isEnabled = TRUE;
m_pDropTarget = (wxDropTarget *) NULL;
m_dropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
@@ -1059,7 +1059,7 @@ wxWindow::~wxWindow()
{
m_hasVMT = FALSE;
if (m_pDropTarget) delete m_pDropTarget;
if (m_dropTarget) delete m_dropTarget;
if (m_parent) m_parent->RemoveChild( this );
if (m_widget) Show( FALSE );
@@ -1114,6 +1114,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
wxFatalError( "Need complete parent.", name );
m_widget = (GtkWidget *) NULL;
m_wxwindow = (GtkWidget *) NULL;
m_hasVMT = FALSE;
m_parent = parent;
m_children.DeleteContents( FALSE );
@@ -1148,7 +1149,6 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_eventHandler = this;
m_windowId = id;
m_sizeSet = FALSE;
if (m_cursor == NULL)
m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE;
@@ -1162,7 +1162,13 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_autoLayout = FALSE;
m_hasScrolling = 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_windowValidator = (wxValidator *) NULL;
m_scrollGC = (GdkGC*) NULL;
@@ -1839,6 +1845,36 @@ void wxWindow::SetValidator( const wxValidator& validator )
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()
{
return FALSE;
@@ -2149,22 +2185,22 @@ void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
DisconnectDnDWidget( dnd_widget );
if (m_pDropTarget) delete m_pDropTarget;
m_pDropTarget = dropTarget;
if (m_dropTarget) delete m_dropTarget;
m_dropTarget = dropTarget;
ConnectDnDWidget( dnd_widget );
}
wxDropTarget *wxWindow::GetDropTarget() const
{
return m_pDropTarget;
return m_dropTarget;
}
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_FUNC(gtk_window_drop_callback), (gpointer)this );
@@ -2172,12 +2208,12 @@ void wxWindow::ConnectDnDWidget( 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_FUNC(gtk_window_drop_callback), (gpointer)this );
m_pDropTarget->UnregisterWidget( widget );
m_dropTarget->UnregisterWidget( widget );
}
GtkWidget* wxWindow::GetConnectWidget()