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:
@@ -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
|
||||
|
@@ -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; }
|
||||
|
@@ -36,24 +36,17 @@ class wxMask: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||
|
||||
public:
|
||||
public:
|
||||
wxMask();
|
||||
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
||||
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
||||
wxMask( const wxBitmap& bitmap );
|
||||
~wxMask();
|
||||
|
||||
wxMask();
|
||||
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
||||
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
||||
wxMask( const wxBitmap& bitmap );
|
||||
~wxMask();
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
GdkBitmap *GetBitmap() const;
|
||||
|
||||
protected:
|
||||
|
||||
friend wxBitmap;
|
||||
|
||||
GdkBitmap *m_bitmap;
|
||||
|
||||
GdkBitmap *m_bitmap;
|
||||
GdkBitmap *GetBitmap() const;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -64,45 +57,44 @@ 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 );
|
||||
wxBitmap( const wxImage &image );
|
||||
wxBitmap( char **bits );
|
||||
wxBitmap( const wxBitmap& bmp );
|
||||
wxBitmap( const wxBitmap* bmp );
|
||||
wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM);
|
||||
~wxBitmap();
|
||||
wxBitmap& operator = ( const wxBitmap& bmp );
|
||||
bool operator == ( const wxBitmap& bmp );
|
||||
bool operator != ( const wxBitmap& bmp );
|
||||
bool Ok() const;
|
||||
public:
|
||||
wxBitmap();
|
||||
wxBitmap( int width, int height, int depth = -1 );
|
||||
wxBitmap( const char bits[], int width, int height, int depth = 1 );
|
||||
wxBitmap( const wxImage &image );
|
||||
wxBitmap( char **bits );
|
||||
wxBitmap( const wxBitmap& bmp );
|
||||
wxBitmap( const wxBitmap* bmp );
|
||||
wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM );
|
||||
~wxBitmap();
|
||||
wxBitmap& operator = ( const wxBitmap& bmp );
|
||||
bool operator == ( const wxBitmap& bmp );
|
||||
bool operator != ( const wxBitmap& bmp );
|
||||
bool Ok() const;
|
||||
|
||||
wxImage ConvertToImage() const;
|
||||
wxImage ConvertToImage() const;
|
||||
|
||||
int GetHeight() const;
|
||||
int GetWidth() const;
|
||||
int GetDepth() const;
|
||||
void SetHeight( int height );
|
||||
void SetWidth( int width );
|
||||
void SetDepth( int depth );
|
||||
int GetHeight() const;
|
||||
int GetWidth() const;
|
||||
int GetDepth() const;
|
||||
void SetHeight( int height );
|
||||
void SetWidth( int width );
|
||||
void SetDepth( int depth );
|
||||
|
||||
wxMask *GetMask() const;
|
||||
void SetMask( wxMask *mask );
|
||||
wxMask *GetMask() const;
|
||||
void SetMask( wxMask *mask );
|
||||
|
||||
bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL );
|
||||
bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM);
|
||||
bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL );
|
||||
bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM );
|
||||
|
||||
wxPalette *GetPalette() const;
|
||||
wxPalette *GetColourMap() const
|
||||
{ return GetPalette(); };
|
||||
wxPalette *GetPalette() const;
|
||||
wxPalette *GetColourMap() const
|
||||
{ return GetPalette(); };
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
GdkPixmap *GetPixmap() const;
|
||||
GdkBitmap *GetBitmap() const;
|
||||
GdkPixmap *GetPixmap() const;
|
||||
GdkBitmap *GetBitmap() const;
|
||||
|
||||
// no data :-)
|
||||
};
|
||||
|
@@ -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__
|
||||
|
@@ -40,42 +40,56 @@ class wxChoice: public wxControl
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxChoice)
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
wxChoice(void);
|
||||
inline wxChoice( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxChoiceNameStr )
|
||||
{
|
||||
wxChoice();
|
||||
inline wxChoice( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxChoiceNameStr )
|
||||
{
|
||||
Create(parent, id, pos, size, n, choices, style, validator, name);
|
||||
}
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxChoiceNameStr );
|
||||
void Append( const wxString &item );
|
||||
void Clear(void);
|
||||
void Delete(int n);
|
||||
int FindString( const wxString &string ) const;
|
||||
int GetColumns(void) const;
|
||||
int GetSelection(void);
|
||||
wxString GetString( int n ) const;
|
||||
wxString GetStringSelection(void) const;
|
||||
int Number(void) const;
|
||||
void SetColumns( int n = 1 );
|
||||
void SetSelection( int n );
|
||||
void SetStringSelection( const wxString &string );
|
||||
}
|
||||
~wxChoice();
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxChoiceNameStr );
|
||||
|
||||
void Append( const wxString &item );
|
||||
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() const;
|
||||
int GetSelection();
|
||||
wxString GetString( int n ) const;
|
||||
wxString GetStringSelection() const;
|
||||
int Number() const;
|
||||
void SetColumns( int n = 1 );
|
||||
void SetSelection( int n );
|
||||
void SetStringSelection( const wxString &string );
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
void ApplyWidgetStyle();
|
||||
wxList m_clientDataList;
|
||||
|
||||
void AppendCommon( const wxString &item );
|
||||
void ApplyWidgetStyle();
|
||||
};
|
||||
|
||||
#endif // __GTKCHOICEH__
|
||||
|
@@ -37,13 +37,13 @@ extern const char* wxEmptyString;
|
||||
// wxComboBox
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxComboBox: public wxControl
|
||||
class wxComboBox : public wxControl
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||
|
||||
public:
|
||||
inline wxComboBox(void) {}
|
||||
public:
|
||||
|
||||
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,45 +65,52 @@ 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 SetInsertionPoint(long pos);
|
||||
void SetInsertionPointEnd(void);
|
||||
long GetInsertionPoint(void) const ;
|
||||
long GetLastPosition(void) const ;
|
||||
void Replace(long from, long to, const wxString& value);
|
||||
void Remove(long from, long to);
|
||||
void SetSelection(long from, long to);
|
||||
void SetEditable(bool editable);
|
||||
void Copy();
|
||||
void Cut();
|
||||
void Paste();
|
||||
void SetInsertionPoint( long pos );
|
||||
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 );
|
||||
void SetEditable( bool editable );
|
||||
|
||||
void OnSize( wxSizeEvent &event );
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
bool m_alreadySent;
|
||||
wxList m_clientData;
|
||||
bool m_alreadySent;
|
||||
wxList m_clientDataList;
|
||||
|
||||
GtkWidget* GetConnectWidget(void);
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void AppendCommon( const wxString &item );
|
||||
GtkWidget* GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@@ -37,63 +37,71 @@ extern const char *wxListBoxNameStr;
|
||||
// wxListBox
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxListBox: public wxControl
|
||||
class wxListBox : public wxControl
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxListBox)
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
wxListBox(void);
|
||||
inline wxListBox( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxListBoxNameStr )
|
||||
{
|
||||
wxListBox();
|
||||
inline wxListBox( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxListBoxNameStr )
|
||||
{
|
||||
Create(parent, id, pos, size, n, choices, style, validator, name);
|
||||
}
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
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 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);
|
||||
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 );
|
||||
void SetString( int n, const wxString &string );
|
||||
void SetStringSelection( const wxString &string, bool select = TRUE );
|
||||
}
|
||||
~wxListBox();
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxListBoxNameStr );
|
||||
|
||||
void Append( const wxString &item );
|
||||
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;
|
||||
int GetSelection(void) const;
|
||||
int GetSelections( class wxArrayInt &) const;
|
||||
wxString GetString( int n ) const;
|
||||
wxString GetStringSelection(void) const;
|
||||
int Number();
|
||||
bool Selected( int n );
|
||||
void Set( int n, const wxString *choices );
|
||||
void SetFirstItem( int n );
|
||||
void SetFirstItem( const wxString &item );
|
||||
void SetSelection( int n, bool select = TRUE );
|
||||
void SetString( int n, const wxString &string );
|
||||
void SetStringSelection( const wxString &string, bool select = TRUE );
|
||||
|
||||
void SetDropTarget( wxDropTarget *dropTarget );
|
||||
void SetDropTarget( wxDropTarget *dropTarget );
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
int GetIndex( GtkWidget *item ) const;
|
||||
GtkWidget *GetConnectWidget(void);
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
GtkList *m_list;
|
||||
wxList m_clientData;
|
||||
void AppendCommon( const wxString &item );
|
||||
int GetIndex( GtkWidget *item ) const;
|
||||
GtkWidget *GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
GtkList *m_list;
|
||||
wxList m_clientDataList;
|
||||
};
|
||||
|
||||
#endif // __GTKLISTBOXH__
|
||||
|
@@ -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
|
||||
|
||||
// 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;
|
||||
|
@@ -36,24 +36,17 @@ class wxMask: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||
|
||||
public:
|
||||
public:
|
||||
wxMask();
|
||||
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
||||
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
||||
wxMask( const wxBitmap& bitmap );
|
||||
~wxMask();
|
||||
|
||||
wxMask();
|
||||
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
||||
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
||||
wxMask( const wxBitmap& bitmap );
|
||||
~wxMask();
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
GdkBitmap *GetBitmap() const;
|
||||
|
||||
protected:
|
||||
|
||||
friend wxBitmap;
|
||||
|
||||
GdkBitmap *m_bitmap;
|
||||
|
||||
GdkBitmap *m_bitmap;
|
||||
GdkBitmap *GetBitmap() const;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -64,45 +57,44 @@ 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 );
|
||||
wxBitmap( const wxImage &image );
|
||||
wxBitmap( char **bits );
|
||||
wxBitmap( const wxBitmap& bmp );
|
||||
wxBitmap( const wxBitmap* bmp );
|
||||
wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM);
|
||||
~wxBitmap();
|
||||
wxBitmap& operator = ( const wxBitmap& bmp );
|
||||
bool operator == ( const wxBitmap& bmp );
|
||||
bool operator != ( const wxBitmap& bmp );
|
||||
bool Ok() const;
|
||||
public:
|
||||
wxBitmap();
|
||||
wxBitmap( int width, int height, int depth = -1 );
|
||||
wxBitmap( const char bits[], int width, int height, int depth = 1 );
|
||||
wxBitmap( const wxImage &image );
|
||||
wxBitmap( char **bits );
|
||||
wxBitmap( const wxBitmap& bmp );
|
||||
wxBitmap( const wxBitmap* bmp );
|
||||
wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM );
|
||||
~wxBitmap();
|
||||
wxBitmap& operator = ( const wxBitmap& bmp );
|
||||
bool operator == ( const wxBitmap& bmp );
|
||||
bool operator != ( const wxBitmap& bmp );
|
||||
bool Ok() const;
|
||||
|
||||
wxImage ConvertToImage() const;
|
||||
wxImage ConvertToImage() const;
|
||||
|
||||
int GetHeight() const;
|
||||
int GetWidth() const;
|
||||
int GetDepth() const;
|
||||
void SetHeight( int height );
|
||||
void SetWidth( int width );
|
||||
void SetDepth( int depth );
|
||||
int GetHeight() const;
|
||||
int GetWidth() const;
|
||||
int GetDepth() const;
|
||||
void SetHeight( int height );
|
||||
void SetWidth( int width );
|
||||
void SetDepth( int depth );
|
||||
|
||||
wxMask *GetMask() const;
|
||||
void SetMask( wxMask *mask );
|
||||
wxMask *GetMask() const;
|
||||
void SetMask( wxMask *mask );
|
||||
|
||||
bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL );
|
||||
bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM);
|
||||
bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL );
|
||||
bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM );
|
||||
|
||||
wxPalette *GetPalette() const;
|
||||
wxPalette *GetColourMap() const
|
||||
{ return GetPalette(); };
|
||||
wxPalette *GetPalette() const;
|
||||
wxPalette *GetColourMap() const
|
||||
{ return GetPalette(); };
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
GdkPixmap *GetPixmap() const;
|
||||
GdkBitmap *GetBitmap() const;
|
||||
GdkPixmap *GetPixmap() const;
|
||||
GdkBitmap *GetBitmap() const;
|
||||
|
||||
// no data :-)
|
||||
};
|
||||
|
@@ -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__
|
||||
|
@@ -40,42 +40,56 @@ class wxChoice: public wxControl
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxChoice)
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
wxChoice(void);
|
||||
inline wxChoice( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxChoiceNameStr )
|
||||
{
|
||||
wxChoice();
|
||||
inline wxChoice( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxChoiceNameStr )
|
||||
{
|
||||
Create(parent, id, pos, size, n, choices, style, validator, name);
|
||||
}
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxChoiceNameStr );
|
||||
void Append( const wxString &item );
|
||||
void Clear(void);
|
||||
void Delete(int n);
|
||||
int FindString( const wxString &string ) const;
|
||||
int GetColumns(void) const;
|
||||
int GetSelection(void);
|
||||
wxString GetString( int n ) const;
|
||||
wxString GetStringSelection(void) const;
|
||||
int Number(void) const;
|
||||
void SetColumns( int n = 1 );
|
||||
void SetSelection( int n );
|
||||
void SetStringSelection( const wxString &string );
|
||||
}
|
||||
~wxChoice();
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxChoiceNameStr );
|
||||
|
||||
void Append( const wxString &item );
|
||||
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() const;
|
||||
int GetSelection();
|
||||
wxString GetString( int n ) const;
|
||||
wxString GetStringSelection() const;
|
||||
int Number() const;
|
||||
void SetColumns( int n = 1 );
|
||||
void SetSelection( int n );
|
||||
void SetStringSelection( const wxString &string );
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
void ApplyWidgetStyle();
|
||||
wxList m_clientDataList;
|
||||
|
||||
void AppendCommon( const wxString &item );
|
||||
void ApplyWidgetStyle();
|
||||
};
|
||||
|
||||
#endif // __GTKCHOICEH__
|
||||
|
@@ -37,13 +37,13 @@ extern const char* wxEmptyString;
|
||||
// wxComboBox
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxComboBox: public wxControl
|
||||
class wxComboBox : public wxControl
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||
|
||||
public:
|
||||
inline wxComboBox(void) {}
|
||||
public:
|
||||
|
||||
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,45 +65,52 @@ 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 SetInsertionPoint(long pos);
|
||||
void SetInsertionPointEnd(void);
|
||||
long GetInsertionPoint(void) const ;
|
||||
long GetLastPosition(void) const ;
|
||||
void Replace(long from, long to, const wxString& value);
|
||||
void Remove(long from, long to);
|
||||
void SetSelection(long from, long to);
|
||||
void SetEditable(bool editable);
|
||||
void Copy();
|
||||
void Cut();
|
||||
void Paste();
|
||||
void SetInsertionPoint( long pos );
|
||||
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 );
|
||||
void SetEditable( bool editable );
|
||||
|
||||
void OnSize( wxSizeEvent &event );
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
bool m_alreadySent;
|
||||
wxList m_clientData;
|
||||
bool m_alreadySent;
|
||||
wxList m_clientDataList;
|
||||
|
||||
GtkWidget* GetConnectWidget(void);
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void AppendCommon( const wxString &item );
|
||||
GtkWidget* GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@@ -37,63 +37,71 @@ extern const char *wxListBoxNameStr;
|
||||
// wxListBox
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxListBox: public wxControl
|
||||
class wxListBox : public wxControl
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxListBox)
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
wxListBox(void);
|
||||
inline wxListBox( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxListBoxNameStr )
|
||||
{
|
||||
wxListBox();
|
||||
inline wxListBox( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxListBoxNameStr )
|
||||
{
|
||||
Create(parent, id, pos, size, n, choices, style, validator, name);
|
||||
}
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
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 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);
|
||||
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 );
|
||||
void SetString( int n, const wxString &string );
|
||||
void SetStringSelection( const wxString &string, bool select = TRUE );
|
||||
}
|
||||
~wxListBox();
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
int n = 0, const wxString choices[] = (const wxString *) NULL,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxListBoxNameStr );
|
||||
|
||||
void Append( const wxString &item );
|
||||
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;
|
||||
int GetSelection(void) const;
|
||||
int GetSelections( class wxArrayInt &) const;
|
||||
wxString GetString( int n ) const;
|
||||
wxString GetStringSelection(void) const;
|
||||
int Number();
|
||||
bool Selected( int n );
|
||||
void Set( int n, const wxString *choices );
|
||||
void SetFirstItem( int n );
|
||||
void SetFirstItem( const wxString &item );
|
||||
void SetSelection( int n, bool select = TRUE );
|
||||
void SetString( int n, const wxString &string );
|
||||
void SetStringSelection( const wxString &string, bool select = TRUE );
|
||||
|
||||
void SetDropTarget( wxDropTarget *dropTarget );
|
||||
void SetDropTarget( wxDropTarget *dropTarget );
|
||||
|
||||
// implementation
|
||||
// implementation
|
||||
|
||||
int GetIndex( GtkWidget *item ) const;
|
||||
GtkWidget *GetConnectWidget(void);
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
GtkList *m_list;
|
||||
wxList m_clientData;
|
||||
void AppendCommon( const wxString &item );
|
||||
int GetIndex( GtkWidget *item ) const;
|
||||
GtkWidget *GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
|
||||
GtkList *m_list;
|
||||
wxList m_clientDataList;
|
||||
};
|
||||
|
||||
#endif // __GTKLISTBOXH__
|
||||
|
@@ -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
|
||||
|
||||
// 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;
|
||||
|
@@ -66,15 +66,15 @@ class WXDLLEXPORT wxPNGHandler: public wxImageHandler
|
||||
|
||||
public:
|
||||
|
||||
inline wxPNGHandler()
|
||||
{
|
||||
m_name = "PNG file";
|
||||
m_extension = "png";
|
||||
m_type = wxBITMAP_TYPE_PNG;
|
||||
};
|
||||
inline wxPNGHandler()
|
||||
{
|
||||
m_name = "PNG file";
|
||||
m_extension = "png";
|
||||
m_type = wxBITMAP_TYPE_PNG;
|
||||
};
|
||||
|
||||
virtual bool LoadFile( wxImage *image, const wxString& name );
|
||||
virtual bool SaveFile( wxImage *image, const wxString& name );
|
||||
virtual bool LoadFile( wxImage *image, const wxString& name );
|
||||
virtual bool SaveFile( wxImage *image, const wxString& name );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -87,15 +87,16 @@ class WXDLLEXPORT wxBMPHandler: public wxImageHandler
|
||||
|
||||
public:
|
||||
|
||||
inline wxBMPHandler()
|
||||
{
|
||||
m_name = "BMP file";
|
||||
m_extension = "bmp";
|
||||
m_type = wxBITMAP_TYPE_BMP;
|
||||
};
|
||||
inline wxBMPHandler()
|
||||
{
|
||||
m_name = "BMP file";
|
||||
m_extension = "bmp";
|
||||
m_type = wxBITMAP_TYPE_BMP;
|
||||
};
|
||||
|
||||
virtual bool LoadFile( wxImage *image, const wxString& name );
|
||||
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:
|
||||
|
||||
|
@@ -30,34 +30,34 @@
|
||||
|
||||
class wxImageRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
|
||||
public:
|
||||
wxImageRefData(void);
|
||||
~wxImageRefData(void);
|
||||
|
||||
wxImageRefData(void);
|
||||
~wxImageRefData(void);
|
||||
|
||||
int m_width;
|
||||
int m_height;
|
||||
unsigned char *m_data;
|
||||
bool m_hasMask;
|
||||
unsigned char m_maskRed,m_maskGreen,m_maskBlue;
|
||||
bool m_ok;
|
||||
int m_width;
|
||||
int m_height;
|
||||
unsigned char *m_data;
|
||||
bool m_hasMask;
|
||||
unsigned char m_maskRed,m_maskGreen,m_maskBlue;
|
||||
bool m_ok;
|
||||
};
|
||||
|
||||
wxImageRefData::wxImageRefData(void)
|
||||
{
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_data = (unsigned char*) NULL;
|
||||
m_ok = FALSE;
|
||||
m_maskRed = 0;
|
||||
m_maskGreen = 0;
|
||||
m_maskBlue = 0;
|
||||
m_hasMask = FALSE;
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_data = (unsigned char*) NULL;
|
||||
m_ok = FALSE;
|
||||
m_maskRed = 0;
|
||||
m_maskGreen = 0;
|
||||
m_maskBlue = 0;
|
||||
m_hasMask = FALSE;
|
||||
}
|
||||
|
||||
wxImageRefData::~wxImageRefData(void)
|
||||
{
|
||||
if (m_data) free( m_data );
|
||||
if (m_data) free( m_data );
|
||||
}
|
||||
|
||||
wxList wxImage::sm_handlers;
|
||||
@@ -76,58 +76,58 @@ wxImage::wxImage()
|
||||
|
||||
wxImage::wxImage( int width, int height )
|
||||
{
|
||||
Create( width, height );
|
||||
Create( width, height );
|
||||
}
|
||||
|
||||
wxImage::wxImage( const wxString& name, long type )
|
||||
{
|
||||
LoadFile( name, type );
|
||||
LoadFile( name, type );
|
||||
}
|
||||
|
||||
wxImage::wxImage( const wxImage& image )
|
||||
{
|
||||
Ref(image);
|
||||
Ref(image);
|
||||
}
|
||||
|
||||
wxImage::wxImage( const wxImage* image )
|
||||
{
|
||||
if (image) Ref(*image);
|
||||
if (image) Ref(*image);
|
||||
}
|
||||
|
||||
void wxImage::Create( int width, int height )
|
||||
{
|
||||
m_refData = new wxImageRefData();
|
||||
m_refData = new wxImageRefData();
|
||||
|
||||
M_IMGDATA->m_data = (unsigned char *) malloc( width*height*3 );
|
||||
if (M_IMGDATA->m_data)
|
||||
{
|
||||
for (int l = 0; l < width*height*3; l++) M_IMGDATA->m_data[l] = 0;
|
||||
M_IMGDATA->m_data = (unsigned char *) malloc( width*height*3 );
|
||||
if (M_IMGDATA->m_data)
|
||||
{
|
||||
for (int l = 0; l < width*height*3; l++) M_IMGDATA->m_data[l] = 0;
|
||||
|
||||
M_IMGDATA->m_width = width;
|
||||
M_IMGDATA->m_height = height;
|
||||
M_IMGDATA->m_ok = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnRef();
|
||||
}
|
||||
M_IMGDATA->m_width = width;
|
||||
M_IMGDATA->m_height = height;
|
||||
M_IMGDATA->m_ok = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnRef();
|
||||
}
|
||||
}
|
||||
|
||||
void wxImage::Destroy()
|
||||
{
|
||||
UnRef();
|
||||
UnRef();
|
||||
}
|
||||
|
||||
bool wxImage::Ok() const
|
||||
{
|
||||
return (M_IMGDATA && M_IMGDATA->m_ok);
|
||||
return (M_IMGDATA && M_IMGDATA->m_ok);
|
||||
}
|
||||
|
||||
char unsigned *wxImage::GetData() const
|
||||
{
|
||||
if (!Ok()) return (char unsigned *)NULL;
|
||||
if (!Ok()) return (char unsigned *)NULL;
|
||||
|
||||
return M_IMGDATA->m_data;
|
||||
return M_IMGDATA->m_data;
|
||||
}
|
||||
|
||||
void wxImage::SetData( char unsigned *WXUNUSED(data) )
|
||||
@@ -136,96 +136,96 @@ void wxImage::SetData( char unsigned *WXUNUSED(data) )
|
||||
|
||||
void wxImage::SetMaskColour( unsigned char r, unsigned char g, unsigned char b )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
if (!Ok()) return;
|
||||
|
||||
M_IMGDATA->m_maskRed = r;
|
||||
M_IMGDATA->m_maskGreen = g;
|
||||
M_IMGDATA->m_maskBlue = b;
|
||||
M_IMGDATA->m_hasMask = TRUE;
|
||||
M_IMGDATA->m_maskRed = r;
|
||||
M_IMGDATA->m_maskGreen = g;
|
||||
M_IMGDATA->m_maskBlue = b;
|
||||
M_IMGDATA->m_hasMask = TRUE;
|
||||
}
|
||||
|
||||
unsigned char wxImage::GetMaskRed() const
|
||||
{
|
||||
if (!Ok()) return 0;
|
||||
if (!Ok()) return 0;
|
||||
|
||||
return M_IMGDATA->m_maskRed;
|
||||
return M_IMGDATA->m_maskRed;
|
||||
}
|
||||
|
||||
unsigned char wxImage::GetMaskGreen() const
|
||||
{
|
||||
if (!Ok()) return 0;
|
||||
|
||||
return M_IMGDATA->m_maskGreen;
|
||||
if (!Ok()) return 0;
|
||||
|
||||
return M_IMGDATA->m_maskGreen;
|
||||
}
|
||||
|
||||
unsigned char wxImage::GetMaskBlue() const
|
||||
{
|
||||
if (!Ok()) return 0;
|
||||
if (!Ok()) return 0;
|
||||
|
||||
return M_IMGDATA->m_maskBlue;
|
||||
return M_IMGDATA->m_maskBlue;
|
||||
}
|
||||
|
||||
void wxImage::SetMask( bool mask )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
if (!Ok()) return;
|
||||
|
||||
M_IMGDATA->m_hasMask = mask;
|
||||
M_IMGDATA->m_hasMask = mask;
|
||||
}
|
||||
|
||||
bool wxImage::HasMask() const
|
||||
{
|
||||
if (!Ok()) return FALSE;
|
||||
if (!Ok()) return FALSE;
|
||||
|
||||
return M_IMGDATA->m_hasMask;
|
||||
return M_IMGDATA->m_hasMask;
|
||||
}
|
||||
|
||||
int wxImage::GetWidth() const
|
||||
{
|
||||
return (M_IMGDATA ? M_IMGDATA->m_width : 0);
|
||||
return (M_IMGDATA ? M_IMGDATA->m_width : 0);
|
||||
}
|
||||
|
||||
int wxImage::GetHeight() const
|
||||
{
|
||||
return (M_IMGDATA ? M_IMGDATA->m_height : 0);
|
||||
return (M_IMGDATA ? M_IMGDATA->m_height : 0);
|
||||
}
|
||||
|
||||
bool wxImage::LoadFile( const wxString& filename, long type )
|
||||
{
|
||||
UnRef();
|
||||
UnRef();
|
||||
|
||||
if (!wxFileExists(filename))
|
||||
{
|
||||
wxLogWarning( "Image file does not exist." );
|
||||
if (!wxFileExists(filename))
|
||||
{
|
||||
wxLogWarning( "Image file does not exist." );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_refData = new wxImageRefData;
|
||||
m_refData = new wxImageRefData;
|
||||
|
||||
wxImageHandler *handler = FindHandler(type);
|
||||
wxImageHandler *handler = FindHandler(type);
|
||||
|
||||
if (handler == NULL)
|
||||
{
|
||||
wxLogWarning( "No image handler for type %d defined.", type );
|
||||
if (handler == NULL)
|
||||
{
|
||||
wxLogWarning( "No image handler for type %d defined.", type );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return handler->LoadFile( this, filename );
|
||||
return handler->LoadFile( this, filename );
|
||||
}
|
||||
|
||||
bool wxImage::SaveFile( const wxString& filename, int type )
|
||||
{
|
||||
wxImageHandler *handler = FindHandler(type);
|
||||
wxImageHandler *handler = FindHandler(type);
|
||||
|
||||
if (handler == NULL)
|
||||
{
|
||||
wxLogWarning( "No image handler for type %d defined.", type );
|
||||
if (handler == NULL)
|
||||
{
|
||||
wxLogWarning( "No image handler for type %d defined.", type );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return handler->SaveFile( this, filename );
|
||||
return handler->SaveFile( this, filename );
|
||||
}
|
||||
|
||||
void wxImage::AddHandler( wxImageHandler *handler )
|
||||
@@ -240,65 +240,71 @@ void wxImage::InsertHandler( wxImageHandler *handler )
|
||||
|
||||
bool wxImage::RemoveHandler( const wxString& name )
|
||||
{
|
||||
wxImageHandler *handler = FindHandler(name);
|
||||
if (handler)
|
||||
{
|
||||
sm_handlers.DeleteObject(handler);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
wxImageHandler *handler = FindHandler(name);
|
||||
if (handler)
|
||||
{
|
||||
sm_handlers.DeleteObject(handler);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxImageHandler *wxImage::FindHandler( const wxString& name )
|
||||
{
|
||||
wxNode *node = sm_handlers.First();
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler*)node->Data();
|
||||
if (handler->GetName() == name) return handler;
|
||||
node = node->Next();
|
||||
}
|
||||
return (wxImageHandler *)NULL;
|
||||
wxNode *node = sm_handlers.First();
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler*)node->Data();
|
||||
if (handler->GetName() == name) return handler;
|
||||
node = node->Next();
|
||||
}
|
||||
return (wxImageHandler *)NULL;
|
||||
}
|
||||
|
||||
wxImageHandler *wxImage::FindHandler( const wxString& extension, long bitmapType )
|
||||
{
|
||||
wxNode *node = sm_handlers.First();
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler*)node->Data();
|
||||
if ( handler->GetExtension() == extension &&
|
||||
(bitmapType == -1 || handler->GetType() == bitmapType) )
|
||||
return handler;
|
||||
node = node->Next();
|
||||
}
|
||||
return (wxImageHandler*)NULL;
|
||||
wxNode *node = sm_handlers.First();
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler*)node->Data();
|
||||
if ( handler->GetExtension() == extension &&
|
||||
(bitmapType == -1 || handler->GetType() == bitmapType) )
|
||||
return handler;
|
||||
node = node->Next();
|
||||
}
|
||||
return (wxImageHandler*)NULL;
|
||||
}
|
||||
|
||||
wxImageHandler *wxImage::FindHandler( long bitmapType )
|
||||
{
|
||||
wxNode *node = sm_handlers.First();
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler *)node->Data();
|
||||
if (handler->GetType() == bitmapType) return handler;
|
||||
node = node->Next();
|
||||
}
|
||||
return NULL;
|
||||
wxNode *node = sm_handlers.First();
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler *)node->Data();
|
||||
if (handler->GetType() == bitmapType) return handler;
|
||||
node = node->Next();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void wxImage::InitStandardHandlers()
|
||||
{
|
||||
AddHandler( new wxBMPHandler );
|
||||
AddHandler( new wxPNGHandler );
|
||||
}
|
||||
|
||||
void wxImage::CleanUpHandlers()
|
||||
{
|
||||
wxNode *node = sm_handlers.First();
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler *)node->Data();
|
||||
wxNode *next = node->Next();
|
||||
delete handler;
|
||||
delete node;
|
||||
node = next;
|
||||
}
|
||||
wxNode *node = sm_handlers.First();
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler *)node->Data();
|
||||
wxNode *next = node->Next();
|
||||
delete handler;
|
||||
delete node;
|
||||
node = next;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -311,12 +317,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxImageHandler,wxObject)
|
||||
|
||||
bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), const wxString& WXUNUSED(name) )
|
||||
{
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), const wxString& WXUNUSED(name) )
|
||||
{
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@@ -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
|
||||
|
||||
|
||||
/*
|
||||
wxBitmap::InitStandardHandlers();
|
||||
|
||||
g_globalCursor = new wxCursor;
|
||||
*/
|
||||
wxImage::InitStandardHandlers();
|
||||
|
||||
// g_globalCursor = new wxCursor;
|
||||
}
|
||||
|
||||
void wxApp::CommonCleanUp(void)
|
||||
{
|
||||
wxDELETE(wxTheColourDatabase);
|
||||
/* Now done in wxPostScriptModule
|
||||
wxDELETE(wxThePrintPaperDatabase);
|
||||
wxDELETE(wxThePrintSetupData);
|
||||
*/
|
||||
wxDELETE(wxTheFontNameDirectory);
|
||||
wxDeleteStockObjects();
|
||||
|
||||
@@ -357,6 +341,8 @@ void wxApp::CommonCleanUp(void)
|
||||
wxDeleteStockLists();
|
||||
|
||||
wxCleanUpResourceSystem();
|
||||
|
||||
wxImage::CleanUpHandlers();
|
||||
|
||||
wxSystemSettings::Done();
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/icon.h"
|
||||
#include "wx/filefn.h"
|
||||
#include "gdk/gdkprivate.h"
|
||||
#include "gdk/gdkx.h"
|
||||
|
||||
@@ -24,7 +25,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject)
|
||||
|
||||
wxMask::wxMask(void)
|
||||
{
|
||||
m_bitmap = (GdkBitmap *) NULL;
|
||||
m_bitmap = (GdkBitmap *) NULL;
|
||||
}
|
||||
|
||||
wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap), const wxColour& WXUNUSED(colour) )
|
||||
@@ -41,12 +42,12 @@ wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap) )
|
||||
|
||||
wxMask::~wxMask(void)
|
||||
{
|
||||
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
|
||||
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
|
||||
}
|
||||
|
||||
GdkBitmap *wxMask::GetBitmap(void) const
|
||||
{
|
||||
return m_bitmap;
|
||||
return m_bitmap;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -55,37 +56,36 @@ GdkBitmap *wxMask::GetBitmap(void) const
|
||||
|
||||
class wxBitmapRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
public:
|
||||
wxBitmapRefData(void);
|
||||
~wxBitmapRefData(void);
|
||||
|
||||
wxBitmapRefData(void);
|
||||
~wxBitmapRefData(void);
|
||||
|
||||
GdkPixmap *m_pixmap;
|
||||
GdkBitmap *m_bitmap;
|
||||
wxMask *m_mask;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_bpp;
|
||||
wxPalette *m_palette;
|
||||
GdkPixmap *m_pixmap;
|
||||
GdkBitmap *m_bitmap;
|
||||
wxMask *m_mask;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_bpp;
|
||||
wxPalette *m_palette;
|
||||
};
|
||||
|
||||
wxBitmapRefData::wxBitmapRefData(void)
|
||||
{
|
||||
m_pixmap = (GdkPixmap *) NULL;
|
||||
m_bitmap = (GdkBitmap *) NULL;
|
||||
m_mask = (wxMask *) NULL;
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_bpp = 0;
|
||||
m_palette = (wxPalette *) NULL;
|
||||
m_pixmap = (GdkPixmap *) NULL;
|
||||
m_bitmap = (GdkBitmap *) NULL;
|
||||
m_mask = (wxMask *) NULL;
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_bpp = 0;
|
||||
m_palette = (wxPalette *) NULL;
|
||||
}
|
||||
|
||||
wxBitmapRefData::~wxBitmapRefData(void)
|
||||
{
|
||||
if (m_pixmap) gdk_pixmap_unref( m_pixmap );
|
||||
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
|
||||
if (m_mask) delete m_mask;
|
||||
if (m_palette) delete m_palette;
|
||||
if (m_pixmap) gdk_pixmap_unref( m_pixmap );
|
||||
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
|
||||
if (m_mask) delete m_mask;
|
||||
if (m_palette) delete m_palette;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -96,466 +96,502 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject)
|
||||
|
||||
wxBitmap::wxBitmap(void)
|
||||
{
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( int width, int height, int depth )
|
||||
{
|
||||
wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" )
|
||||
wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" )
|
||||
wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" )
|
||||
wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" )
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||
M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
|
||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||
M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( char **bits )
|
||||
{
|
||||
wxCHECK_RET( bits != NULL, "invalid bitmap data" )
|
||||
wxCHECK_RET( bits != NULL, "invalid bitmap data" )
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
GdkBitmap *mask = (GdkBitmap*) NULL;
|
||||
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||
GdkBitmap *mask = (GdkBitmap*) NULL;
|
||||
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
|
||||
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
|
||||
|
||||
if (mask)
|
||||
{
|
||||
M_BMPDATA->m_mask = new wxMask();
|
||||
M_BMPDATA->m_mask->m_bitmap = mask;
|
||||
}
|
||||
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) );
|
||||
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; // ?
|
||||
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const wxBitmap& bmp )
|
||||
{
|
||||
Ref( bmp );
|
||||
Ref( bmp );
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const wxBitmap* bmp )
|
||||
{
|
||||
if (bmp) Ref( *bmp );
|
||||
if (bmp) Ref( *bmp );
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const wxString &filename, int type )
|
||||
{
|
||||
LoadFile( filename, type );
|
||||
LoadFile( filename, type );
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth))
|
||||
{
|
||||
m_refData = new wxBitmapRefData();
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||
M_BMPDATA->m_bitmap =
|
||||
gdk_bitmap_create_from_data( (GdkWindow*) &gdk_root_parent, (gchar *) bits, width, height );
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_bpp = 1;
|
||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||
M_BMPDATA->m_bitmap =
|
||||
gdk_bitmap_create_from_data( (GdkWindow*) &gdk_root_parent, (gchar *) bits, width, height );
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_bpp = 1;
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::~wxBitmap(void)
|
||||
{
|
||||
if (wxTheBitmapList) wxTheBitmapList->DeleteObject(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->DeleteObject(this);
|
||||
}
|
||||
|
||||
wxBitmap& wxBitmap::operator = ( const wxBitmap& bmp )
|
||||
{
|
||||
if (*this == bmp) return (*this);
|
||||
Ref( bmp );
|
||||
return *this;
|
||||
if (*this == bmp) return (*this);
|
||||
Ref( bmp );
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool wxBitmap::operator == ( const wxBitmap& bmp )
|
||||
{
|
||||
return m_refData == bmp.m_refData;
|
||||
return m_refData == bmp.m_refData;
|
||||
}
|
||||
|
||||
bool wxBitmap::operator != ( const wxBitmap& bmp )
|
||||
{
|
||||
return m_refData != bmp.m_refData;
|
||||
return m_refData != bmp.m_refData;
|
||||
}
|
||||
|
||||
bool wxBitmap::Ok(void) const
|
||||
{
|
||||
return (m_refData != NULL);
|
||||
return (m_refData != NULL);
|
||||
}
|
||||
|
||||
int wxBitmap::GetHeight(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_height;
|
||||
return M_BMPDATA->m_height;
|
||||
}
|
||||
|
||||
int wxBitmap::GetWidth(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_width;
|
||||
return M_BMPDATA->m_width;
|
||||
}
|
||||
|
||||
int wxBitmap::GetDepth(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_bpp;
|
||||
return M_BMPDATA->m_bpp;
|
||||
}
|
||||
|
||||
void wxBitmap::SetHeight( int height )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
if (!Ok()) return;
|
||||
|
||||
wxFAIL_MSG( "wxBitmap::SetHeight not implemented" );
|
||||
wxFAIL_MSG( "wxBitmap::SetHeight not implemented" );
|
||||
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_height = height;
|
||||
}
|
||||
|
||||
void wxBitmap::SetWidth( int width )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
if (!Ok()) return;
|
||||
|
||||
wxFAIL_MSG( "wxBitmap::SetWidth not implemented" );
|
||||
wxFAIL_MSG( "wxBitmap::SetWidth not implemented" );
|
||||
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_width = width;
|
||||
}
|
||||
|
||||
void wxBitmap::SetDepth( int depth )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
if (!Ok()) return;
|
||||
|
||||
wxFAIL_MSG( "wxBitmap::SetDepth not implemented" );
|
||||
wxFAIL_MSG( "wxBitmap::SetDepth not implemented" );
|
||||
|
||||
M_BMPDATA->m_bpp = depth;
|
||||
M_BMPDATA->m_bpp = depth;
|
||||
}
|
||||
|
||||
wxMask *wxBitmap::GetMask(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (wxMask *) NULL;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (wxMask *) NULL;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_mask;
|
||||
return M_BMPDATA->m_mask;
|
||||
}
|
||||
|
||||
void wxBitmap::SetMask( wxMask *mask )
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
|
||||
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
|
||||
|
||||
M_BMPDATA->m_mask = 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())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return FALSE;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
if (type == wxBITMAP_TYPE_PNG)
|
||||
{
|
||||
wxImage image = ConvertToImage();
|
||||
if (image.Ok()) return image.SaveFile( name, type );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxBitmap::LoadFile( const wxString &WXUNUSED(name), int WXUNUSED(type) )
|
||||
bool wxBitmap::LoadFile( const wxString &name, int type )
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return FALSE;
|
||||
}
|
||||
UnRef();
|
||||
|
||||
if (!wxFileExists(name)) return FALSE;
|
||||
|
||||
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;
|
||||
return M_BMPDATA->m_palette;
|
||||
if (!Ok()) return (wxPalette *) NULL;
|
||||
return M_BMPDATA->m_palette;
|
||||
}
|
||||
|
||||
GdkPixmap *wxBitmap::GetPixmap(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (GdkPixmap *) NULL;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (GdkPixmap *) NULL;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_pixmap;
|
||||
return M_BMPDATA->m_pixmap;
|
||||
}
|
||||
|
||||
GdkBitmap *wxBitmap::GetBitmap(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (GdkBitmap *) NULL;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (GdkBitmap *) NULL;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_bitmap;
|
||||
return M_BMPDATA->m_bitmap;
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const wxImage &image )
|
||||
{
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
|
||||
if (!image.Ok()) return;
|
||||
if (!image.Ok()) return;
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
M_BMPDATA->m_height = image.GetHeight();
|
||||
M_BMPDATA->m_width = image.GetWidth();
|
||||
int width = image.GetWidth();
|
||||
int height = image.GetHeight();
|
||||
M_BMPDATA->m_height = image.GetHeight();
|
||||
M_BMPDATA->m_width = image.GetWidth();
|
||||
int width = image.GetWidth();
|
||||
int height = image.GetHeight();
|
||||
|
||||
// Create picture
|
||||
// Create picture
|
||||
|
||||
GdkImage *data_image =
|
||||
gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height );
|
||||
GdkImage *data_image =
|
||||
gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height );
|
||||
|
||||
M_BMPDATA->m_pixmap =
|
||||
gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 );
|
||||
M_BMPDATA->m_pixmap =
|
||||
gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 );
|
||||
|
||||
// Create mask
|
||||
// Create mask
|
||||
|
||||
GdkImage *mask_image = (GdkImage*) NULL;
|
||||
GdkImage *mask_image = (GdkImage*) NULL;
|
||||
|
||||
if (image.HasMask())
|
||||
{
|
||||
unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
|
||||
if (image.HasMask())
|
||||
{
|
||||
unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
|
||||
|
||||
mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
|
||||
mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
|
||||
|
||||
M_BMPDATA->m_mask = new wxMask();
|
||||
M_BMPDATA->m_mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
|
||||
}
|
||||
M_BMPDATA->m_mask = new wxMask();
|
||||
M_BMPDATA->m_mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
|
||||
}
|
||||
|
||||
// Retrieve depth
|
||||
// Retrieve depth
|
||||
|
||||
M_BMPDATA->m_bpp = data_image->depth;
|
||||
M_BMPDATA->m_bpp = data_image->depth;
|
||||
|
||||
int render_depth = 8;
|
||||
if (M_BMPDATA->m_bpp > 8) render_depth = M_BMPDATA->m_bpp;
|
||||
int render_depth = 8;
|
||||
if (M_BMPDATA->m_bpp > 8) render_depth = M_BMPDATA->m_bpp;
|
||||
|
||||
// Render
|
||||
// Render
|
||||
|
||||
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
|
||||
byte_order b_o;
|
||||
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
|
||||
byte_order b_o = RGB;
|
||||
|
||||
if (render_depth >= 24)
|
||||
{
|
||||
GdkVisual *visual = gdk_visual_get_system();
|
||||
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
||||
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
|
||||
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
||||
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
||||
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
||||
else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR;
|
||||
}
|
||||
if (render_depth >= 24)
|
||||
{
|
||||
GdkVisual *visual = gdk_visual_get_system();
|
||||
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
||||
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
|
||||
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
||||
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
||||
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
||||
else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR;
|
||||
}
|
||||
|
||||
int r_mask = image.GetMaskRed();
|
||||
int g_mask = image.GetMaskGreen();
|
||||
int b_mask = image.GetMaskBlue();
|
||||
int r_mask = image.GetMaskRed();
|
||||
int g_mask = image.GetMaskGreen();
|
||||
int b_mask = image.GetMaskBlue();
|
||||
|
||||
unsigned char* data = image.GetData();
|
||||
unsigned char* data = image.GetData();
|
||||
|
||||
int index = 0;
|
||||
for (int y = 0; y < height; y++)
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int r = data[index];
|
||||
index++;
|
||||
int g = data[index];
|
||||
index++;
|
||||
int b = data[index];
|
||||
index++;
|
||||
int index = 0;
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int r = data[index];
|
||||
index++;
|
||||
int g = data[index];
|
||||
index++;
|
||||
int b = data[index];
|
||||
index++;
|
||||
|
||||
if (image.HasMask())
|
||||
{
|
||||
if ((r == r_mask) && (b = b_mask) && (g = g_mask))
|
||||
gdk_image_put_pixel( mask_image, x, y, 0 );
|
||||
else
|
||||
gdk_image_put_pixel( mask_image, x, y, 1 );
|
||||
}
|
||||
|
||||
switch (render_depth)
|
||||
{
|
||||
case 8:
|
||||
{
|
||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||
GdkColor *colors = cmap->colors;
|
||||
int max = 3 * (65536);
|
||||
int index = -1;
|
||||
|
||||
for (int i = 0; i < cmap->size; i++)
|
||||
{
|
||||
int rdiff = (r << 8) - colors[i].red;
|
||||
int gdiff = (g << 8) - colors[i].green;
|
||||
int bdiff = (b << 8) - colors[i].blue;
|
||||
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
|
||||
if (sum < max) { index = i; max = sum; }
|
||||
}
|
||||
|
||||
gdk_image_put_pixel( data_image, x, y, index );
|
||||
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
guint32 pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3);
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
guint32 pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3);
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
break;
|
||||
}
|
||||
case 32:
|
||||
case 24:
|
||||
{
|
||||
guint32 pixel = 0;
|
||||
switch (b_o)
|
||||
if (image.HasMask())
|
||||
{
|
||||
case RGB: pixel = (r << 16) | (g << 8) | b; break;
|
||||
case RBG: pixel = (r << 16) | (b << 8) | g; break;
|
||||
case BRG: pixel = (b << 16) | (r << 8) | g; break;
|
||||
case BGR: pixel = (b << 16) | (g << 8) | r; break;
|
||||
case GRB: pixel = (g << 16) | (r << 8) | b; break;
|
||||
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
||||
if ((r == r_mask) && (b = b_mask) && (g = g_mask))
|
||||
gdk_image_put_pixel( mask_image, x, y, 0 );
|
||||
else
|
||||
gdk_image_put_pixel( mask_image, x, y, 1 );
|
||||
}
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// Blit picture
|
||||
|
||||
switch (render_depth)
|
||||
{
|
||||
case 8:
|
||||
{
|
||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||
GdkColor *colors = cmap->colors;
|
||||
int max = 3 * (65536);
|
||||
int index = -1;
|
||||
|
||||
for (int i = 0; i < cmap->size; i++)
|
||||
{
|
||||
int rdiff = (r << 8) - colors[i].red;
|
||||
int gdiff = (g << 8) - colors[i].green;
|
||||
int bdiff = (b << 8) - colors[i].blue;
|
||||
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
|
||||
if (sum < max) { index = i; max = sum; }
|
||||
}
|
||||
|
||||
gdk_image_put_pixel( data_image, x, y, index );
|
||||
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
guint32 pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3);
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
guint32 pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3);
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
break;
|
||||
}
|
||||
case 32:
|
||||
case 24:
|
||||
{
|
||||
guint32 pixel = 0;
|
||||
switch (b_o)
|
||||
{
|
||||
case RGB: pixel = (r << 16) | (g << 8) | b; break;
|
||||
case RBG: pixel = (r << 16) | (b << 8) | g; break;
|
||||
case BRG: pixel = (b << 16) | (r << 8) | g; break;
|
||||
case BGR: pixel = (b << 16) | (g << 8) | r; break;
|
||||
case GRB: pixel = (g << 16) | (r << 8) | b; break;
|
||||
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
||||
}
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
} // for
|
||||
} // for
|
||||
|
||||
// Blit picture
|
||||
|
||||
GdkGC *data_gc = gdk_gc_new( M_BMPDATA->m_pixmap );
|
||||
GdkGC *data_gc = gdk_gc_new( M_BMPDATA->m_pixmap );
|
||||
|
||||
gdk_draw_image( M_BMPDATA->m_pixmap, data_gc, data_image, 0, 0, 0, 0, width, height );
|
||||
gdk_draw_image( M_BMPDATA->m_pixmap, data_gc, data_image, 0, 0, 0, 0, width, height );
|
||||
|
||||
gdk_image_destroy( data_image );
|
||||
gdk_gc_unref( data_gc );
|
||||
gdk_image_destroy( data_image );
|
||||
gdk_gc_unref( data_gc );
|
||||
|
||||
// Blit mask
|
||||
// Blit mask
|
||||
|
||||
if (image.HasMask())
|
||||
{
|
||||
GdkGC *mask_gc = gdk_gc_new( M_BMPDATA->m_mask->m_bitmap );
|
||||
if (image.HasMask())
|
||||
{
|
||||
GdkGC *mask_gc = gdk_gc_new( M_BMPDATA->m_mask->m_bitmap );
|
||||
|
||||
gdk_draw_image( M_BMPDATA->m_mask->m_bitmap, mask_gc, mask_image, 0, 0, 0, 0, width, height );
|
||||
gdk_draw_image( M_BMPDATA->m_mask->m_bitmap, mask_gc, mask_image, 0, 0, 0, 0, width, height );
|
||||
|
||||
gdk_image_destroy( mask_image );
|
||||
gdk_gc_unref( mask_gc );
|
||||
}
|
||||
|
||||
gdk_image_destroy( mask_image );
|
||||
gdk_gc_unref( mask_gc );
|
||||
}
|
||||
}
|
||||
|
||||
wxImage wxBitmap::ConvertToImage() const
|
||||
{
|
||||
wxImage image;
|
||||
wxImage image;
|
||||
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return image;
|
||||
}
|
||||
|
||||
GdkImage *gdk_image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height );
|
||||
|
||||
if (!gdk_image) return image;
|
||||
|
||||
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;
|
||||
|
||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||
|
||||
long pos = 0;
|
||||
for (int j = 0; j < M_BMPDATA->m_height; j++)
|
||||
{
|
||||
for (int i = 0; i < M_BMPDATA->m_width; i++)
|
||||
if (!Ok())
|
||||
{
|
||||
int pixel = gdk_image_get_pixel( gdk_image, i, j );
|
||||
if (bpp <= 8)
|
||||
{
|
||||
data[pos] = cmap->colors[pixel].red >> 8;
|
||||
data[pos+1] = cmap->colors[pixel].green >> 8;
|
||||
data[pos+2] = cmap->colors[pixel].blue >> 8;
|
||||
} else if (bpp == 15)
|
||||
{
|
||||
data[pos] = (pixel >> 7) & 0xf8;
|
||||
data[pos+1] = (pixel >> 2) & 0xf8;
|
||||
data[pos+2] = (pixel << 3) & 0xf8;
|
||||
} else if (bpp == 16)
|
||||
{
|
||||
data[pos] = (pixel >> 8) & 0xf8;
|
||||
data[pos+1] = (pixel >> 3) & 0xfc;
|
||||
data[pos+2] = (pixel << 3) & 0xf8;
|
||||
} else
|
||||
{
|
||||
data[pos] = (pixel >> 16) & 0xff;
|
||||
data[pos+1] = (pixel >> 8) & 0xff;
|
||||
data[pos+2] = pixel & 0xff;
|
||||
}
|
||||
|
||||
pos += 3;
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
gdk_image_destroy( gdk_image );
|
||||
GdkImage *gdk_image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height );
|
||||
|
||||
return image;
|
||||
if (!gdk_image) return image;
|
||||
|
||||
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;
|
||||
|
||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||
|
||||
long pos = 0;
|
||||
for (int j = 0; j < M_BMPDATA->m_height; j++)
|
||||
{
|
||||
for (int i = 0; i < M_BMPDATA->m_width; i++)
|
||||
{
|
||||
int pixel = gdk_image_get_pixel( gdk_image, i, j );
|
||||
if (bpp <= 8)
|
||||
{
|
||||
data[pos] = cmap->colors[pixel].red >> 8;
|
||||
data[pos+1] = cmap->colors[pixel].green >> 8;
|
||||
data[pos+2] = cmap->colors[pixel].blue >> 8;
|
||||
} else if (bpp == 15)
|
||||
{
|
||||
data[pos] = (pixel >> 7) & 0xf8;
|
||||
data[pos+1] = (pixel >> 2) & 0xf8;
|
||||
data[pos+2] = (pixel << 3) & 0xf8;
|
||||
} else if (bpp == 16)
|
||||
{
|
||||
data[pos] = (pixel >> 8) & 0xf8;
|
||||
data[pos+1] = (pixel >> 3) & 0xfc;
|
||||
data[pos+2] = (pixel << 3) & 0xf8;
|
||||
} else
|
||||
{
|
||||
data[pos] = (pixel >> 16) & 0xff;
|
||||
data[pos+1] = (pixel >> 8) & 0xff;
|
||||
data[pos+2] = pixel & 0xff;
|
||||
}
|
||||
|
||||
pos += 3;
|
||||
}
|
||||
}
|
||||
|
||||
gdk_image_destroy( gdk_image );
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -43,200 +43,301 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl)
|
||||
|
||||
wxChoice::wxChoice(void)
|
||||
wxChoice::wxChoice()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxChoice::Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
int n, const wxString choices[],
|
||||
long style, const wxValidator& validator, const wxString &name )
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
int n, const wxString choices[],
|
||||
long style, const wxValidator& validator, const wxString &name )
|
||||
{
|
||||
m_needParent = TRUE;
|
||||
m_needParent = TRUE;
|
||||
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
|
||||
SetValidator( validator );
|
||||
SetValidator( validator );
|
||||
|
||||
m_widget = gtk_option_menu_new();
|
||||
m_widget = gtk_option_menu_new();
|
||||
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 80;
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 80;
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
|
||||
gtk_menu_append( GTK_MENU(menu), item );
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
m_clientDataList.Append( (wxObject*) NULL );
|
||||
|
||||
gtk_widget_realize( item );
|
||||
gtk_widget_realize( GTK_BIN(item)->child );
|
||||
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
|
||||
gtk_menu_append( GTK_MENU(menu), item );
|
||||
|
||||
gtk_widget_show( item );
|
||||
gtk_widget_realize( item );
|
||||
gtk_widget_realize( GTK_BIN(item)->child );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT( item ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
}
|
||||
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
||||
gtk_widget_show( item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT( item ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
}
|
||||
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
||||
|
||||
m_parent->AddChild( this );
|
||||
m_parent->AddChild( this );
|
||||
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation();
|
||||
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
|
||||
Show( TRUE );
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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" );
|
||||
|
||||
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
|
||||
GtkWidget *menu_item = gtk_menu_item_new_with_label( item );
|
||||
|
||||
gtk_menu_append( GTK_MENU(menu), menu_item );
|
||||
|
||||
gtk_widget_realize( menu_item );
|
||||
gtk_widget_realize( GTK_BIN(menu_item)->child );
|
||||
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
|
||||
gtk_widget_show( menu_item );
|
||||
}
|
||||
|
||||
void wxChoice::Append( const wxString &item )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
|
||||
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
|
||||
GtkWidget *menu_item = gtk_menu_item_new_with_label( item );
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
gtk_menu_append( GTK_MENU(menu), menu_item );
|
||||
|
||||
gtk_widget_realize( menu_item );
|
||||
gtk_widget_realize( GTK_BIN(menu_item)->child );
|
||||
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
|
||||
gtk_widget_show( menu_item );
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxChoice::Clear(void)
|
||||
{
|
||||
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 );
|
||||
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) )
|
||||
{
|
||||
wxFAIL_MSG( "wxChoice:Delete not implemented" );
|
||||
wxFAIL_MSG( "wxChoice:Delete not implemented" );
|
||||
}
|
||||
|
||||
int wxChoice::FindString( const wxString &string ) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
|
||||
|
||||
// If you read this code once and you think you understand
|
||||
// it, then you are very wrong. Robert Roebling.
|
||||
// If you read this code once and you think you understand
|
||||
// it, then you are very wrong. Robert Roebling.
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = (GtkLabel *) NULL;
|
||||
if (bin->child) label = GTK_LABEL(bin->child);
|
||||
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = (GtkLabel *) NULL;
|
||||
if (bin->child) label = GTK_LABEL(bin->child);
|
||||
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
|
||||
if (string == label->label) return count;
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
if (string == label->label) return count;
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxChoice: string not found" );
|
||||
wxFAIL_MSG( "wxChoice: string not found" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
if (!bin->child) return count;
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
if (!bin->child) return count;
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxChoice: no selection" );
|
||||
wxFAIL_MSG( "wxChoice: no selection" );
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
wxString wxChoice::GetString( int n ) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
|
||||
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
if (count == n)
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkLabel *label = (GtkLabel *) NULL;
|
||||
if (bin->child) label = GTK_LABEL(bin->child);
|
||||
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
if (count == n)
|
||||
{
|
||||
GtkLabel *label = (GtkLabel *) NULL;
|
||||
if (bin->child) label = GTK_LABEL(bin->child);
|
||||
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
|
||||
return label->label;
|
||||
return label->label;
|
||||
}
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxChoice: string not found" );
|
||||
wxFAIL_MSG( "wxChoice: string not found" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
return count;
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void wxChoice::SetColumns( int WXUNUSED(n) )
|
||||
@@ -245,44 +346,44 @@ void wxChoice::SetColumns( int WXUNUSED(n) )
|
||||
|
||||
void wxChoice::SetSelection( int n )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
|
||||
int tmp = n;
|
||||
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
|
||||
int tmp = n;
|
||||
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
|
||||
|
||||
gtk_choice_clicked_callback( (GtkWidget *) NULL, this );
|
||||
gtk_choice_clicked_callback( (GtkWidget *) NULL, this );
|
||||
}
|
||||
|
||||
void wxChoice::SetStringSelection( const wxString &string )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
|
||||
int n = FindString( string );
|
||||
if (n != -1) SetSelection( n );
|
||||
int n = FindString( string );
|
||||
if (n != -1) SetSelection( n );
|
||||
}
|
||||
|
||||
void wxChoice::ApplyWidgetStyle()
|
||||
{
|
||||
SetWidgetStyle();
|
||||
SetWidgetStyle();
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
|
||||
gtk_widget_set_style( m_widget, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_WIDGET( menu_shell ), m_widgetStyle );
|
||||
gtk_widget_set_style( m_widget, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_WIDGET( menu_shell ), m_widgetStyle );
|
||||
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_WIDGET( child->data ), m_widgetStyle );
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_WIDGET( child->data ), m_widgetStyle );
|
||||
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkWidget *label = (GtkWidget *) NULL;
|
||||
if (bin->child) label = bin->child;
|
||||
if (!label) label = GTK_BUTTON(m_widget)->child;
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkWidget *label = (GtkWidget *) NULL;
|
||||
if (bin->child) label = bin->child;
|
||||
if (!label) label = GTK_BUTTON(m_widget)->child;
|
||||
|
||||
gtk_widget_set_style( label, m_widgetStyle );
|
||||
gtk_widget_set_style( label, m_widgetStyle );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
@@ -53,14 +104,29 @@ IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
|
||||
|
||||
wxClipboard::wxClipboard()
|
||||
{
|
||||
m_data = (wxDataObject*)NULL;
|
||||
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 )
|
||||
|
@@ -26,23 +26,23 @@ extern bool g_blockEventsOnDrag;
|
||||
|
||||
static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
|
||||
{
|
||||
if (!combo->HasVMT()) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
if (!combo->HasVMT()) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
||||
if (combo->m_alreadySent)
|
||||
{
|
||||
combo->m_alreadySent = FALSE;
|
||||
return;
|
||||
}
|
||||
if (combo->m_alreadySent)
|
||||
{
|
||||
combo->m_alreadySent = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
combo->m_alreadySent = TRUE;
|
||||
combo->m_alreadySent = TRUE;
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, combo->GetId());
|
||||
event.SetInt( combo->GetSelection() );
|
||||
wxString tmp( combo->GetStringSelection() );
|
||||
event.SetString( WXSTRINGCAST(tmp) );
|
||||
event.SetEventObject(combo);
|
||||
combo->GetEventHandler()->ProcessEvent(event);
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, combo->GetId());
|
||||
event.SetInt( combo->GetSelection() );
|
||||
wxString tmp( combo->GetStringSelection() );
|
||||
event.SetString( WXSTRINGCAST(tmp) );
|
||||
event.SetEventObject(combo);
|
||||
combo->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -52,421 +52,490 @@ static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxComboBox, wxControl)
|
||||
EVT_SIZE(wxComboBox::OnSize)
|
||||
EVT_SIZE(wxComboBox::OnSize)
|
||||
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 )
|
||||
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 )
|
||||
{
|
||||
m_alreadySent = FALSE;
|
||||
m_needParent = TRUE;
|
||||
m_alreadySent = FALSE;
|
||||
m_needParent = TRUE;
|
||||
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
|
||||
SetValidator( validator );
|
||||
SetValidator( validator );
|
||||
|
||||
m_widget = gtk_combo_new();
|
||||
m_widget = gtk_combo_new();
|
||||
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 100;
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 100;
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
|
||||
for (int i = 0; i < n; 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 );
|
||||
|
||||
gtk_widget_realize( list_item );
|
||||
gtk_widget_realize( GTK_BIN(list_item)->child );
|
||||
gtk_widget_realize( list_item );
|
||||
gtk_widget_realize( GTK_BIN(list_item)->child );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
}
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
}
|
||||
|
||||
m_parent->AddChild( this );
|
||||
m_parent->AddChild( this );
|
||||
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation();
|
||||
|
||||
ConnectWidget( GTK_COMBO(m_widget)->button );
|
||||
ConnectWidget( GTK_COMBO(m_widget)->button );
|
||||
|
||||
if (!value.IsNull()) SetValue( value );
|
||||
if (!value.IsNull()) SetValue( value );
|
||||
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->list );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->entry );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->button );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->list );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->entry );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->button );
|
||||
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
|
||||
Show( TRUE );
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxComboBox::Clear(void)
|
||||
wxComboBox::~wxComboBox()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxNode *node = m_clientDataList.First();
|
||||
while (node)
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->Data();
|
||||
if (cd) delete cd;
|
||||
node = node->Next();
|
||||
}
|
||||
m_clientDataList.Clear();
|
||||
}
|
||||
|
||||
void wxComboBox::AppendCommon( const wxString &item )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_clear_items( GTK_LIST(list), 0, Number() );
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
m_clientData.Clear();
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
}
|
||||
|
||||
void wxComboBox::Append( const wxString &item )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
Append( item, (char*)NULL );
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxComboBox::Append( const wxString &item, char *clientData )
|
||||
void wxComboBox::Append( const wxString &item, void *clientData )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
if (clientData)
|
||||
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
|
||||
else
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxComboBox::Append( const wxString &item, wxClientData *clientData )
|
||||
{
|
||||
m_clientDataList.Append( (wxObject*) clientData );
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( item );
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxComboBox::SetClientData( int n, void* clientData )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
wxNode *node = m_clientDataList.Nth( n );
|
||||
if (!node) return;
|
||||
|
||||
m_clientData.Append( (wxObject*)clientData );
|
||||
wxClientData *cd = (wxClientData*) node->Data();
|
||||
if (cd) delete cd;
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||
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;
|
||||
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
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;
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
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" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
|
||||
GList *child = g_list_nth( listbox->children, n );
|
||||
GList *child = g_list_nth( listbox->children, n );
|
||||
|
||||
if (!child)
|
||||
{
|
||||
wxFAIL_MSG("wrong index");
|
||||
return;
|
||||
}
|
||||
if (!child)
|
||||
{
|
||||
wxFAIL_MSG("wrong index");
|
||||
return;
|
||||
}
|
||||
|
||||
GList *list = g_list_append( NULL, child->data );
|
||||
gtk_list_remove_items( listbox, list );
|
||||
g_list_free( list );
|
||||
GList *list = g_list_append( NULL, child->data );
|
||||
gtk_list_remove_items( listbox, list );
|
||||
g_list_free( list );
|
||||
|
||||
wxNode *node = m_clientData.Nth( n );
|
||||
if (!node)
|
||||
{
|
||||
wxFAIL_MSG( "wrong index" );
|
||||
}
|
||||
else
|
||||
m_clientData.DeleteNode( node );
|
||||
wxNode *node = m_clientDataList.Nth( n );
|
||||
if (!node)
|
||||
{
|
||||
wxFAIL_MSG( "wrong index" );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->Data();
|
||||
if (cd) delete cd;
|
||||
m_clientDataList.DeleteNode( node );
|
||||
}
|
||||
}
|
||||
|
||||
int wxComboBox::FindString( const wxString &item )
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
if (item == label->label) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: string not found" );
|
||||
|
||||
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
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *selection = GTK_LIST(list)->selection;
|
||||
if (selection)
|
||||
{
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (child->data == selection->data) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
if (item == label->label) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||
wxFAIL_MSG( "wxComboBox: string not found" );
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxComboBox::GetSelection() const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *selection = GTK_LIST(list)->selection;
|
||||
if (selection)
|
||||
{
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (child->data == selection->data) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
wxString wxComboBox::GetString( int n ) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
|
||||
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *child = g_list_nth( GTK_LIST(list)->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
return label->label;
|
||||
}
|
||||
GList *child = g_list_nth( GTK_LIST(list)->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
return label->label;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *selection = GTK_LIST(list)->selection;
|
||||
if (selection)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( selection->data );
|
||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||
return tmp;
|
||||
}
|
||||
GList *selection = GTK_LIST(list)->selection;
|
||||
if (selection)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( selection->data );
|
||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
}
|
||||
|
||||
void wxComboBox::SetSelection( int n )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_select_item( GTK_LIST(list), n );
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_select_item( GTK_LIST(list), n );
|
||||
}
|
||||
|
||||
void wxComboBox::SetStringSelection( const wxString &string )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
int res = FindString( string );
|
||||
if (res == -1) return;
|
||||
SetSelection( res );
|
||||
int res = FindString( string );
|
||||
if (res == -1) return;
|
||||
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) );
|
||||
return tmp;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) );
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void wxComboBox::SetValue( const wxString& value )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
wxString tmp = "";
|
||||
if (!value.IsNull()) tmp = value;
|
||||
gtk_entry_set_text( GTK_ENTRY(entry), tmp );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
wxString tmp = "";
|
||||
if (!value.IsNull()) tmp = value;
|
||||
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" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::Cut(void)
|
||||
void wxComboBox::Cut()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::Paste(void)
|
||||
void wxComboBox::Paste()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::SetInsertionPoint( long pos )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int tmp = (int) pos;
|
||||
gtk_entry_set_position( GTK_ENTRY(entry), tmp );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int tmp = (int) pos;
|
||||
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" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int pos = GTK_ENTRY(entry)->text_length;
|
||||
SetInsertionPoint( pos-1 );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int pos = GTK_ENTRY(entry)->text_length;
|
||||
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;
|
||||
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;
|
||||
return (long) pos-1;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int pos = GTK_ENTRY(entry)->text_length;
|
||||
return (long) pos-1;
|
||||
}
|
||||
|
||||
void wxComboBox::Replace( long from, long to, const wxString& value )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||
if (value.IsNull()) return;
|
||||
gint pos = (gint)to;
|
||||
gtk_editable_insert_text( GTK_EDITABLE(entry), value, value.Length(), &pos );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||
if (value.IsNull()) return;
|
||||
gint pos = (gint)to;
|
||||
gtk_editable_insert_text( GTK_EDITABLE(entry), value, value.Length(), &pos );
|
||||
}
|
||||
|
||||
void wxComboBox::Remove(long from, long to)
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||
}
|
||||
|
||||
void wxComboBox::SetSelection( long WXUNUSED(from), long WXUNUSED(to) )
|
||||
{
|
||||
wxFAIL_MSG( "wxComboBox::SetSelection not implemented" );
|
||||
wxFAIL_MSG( "wxComboBox::SetSelection not implemented" );
|
||||
}
|
||||
|
||||
void wxComboBox::SetEditable( bool WXUNUSED(editable) )
|
||||
{
|
||||
wxFAIL_MSG( "wxComboBox::SetEditable not implemented" );
|
||||
wxFAIL_MSG( "wxComboBox::SetEditable not implemented" );
|
||||
}
|
||||
|
||||
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_usize( GTK_COMBO(m_widget)->button, w, m_height );
|
||||
gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y );
|
||||
gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height );
|
||||
}
|
||||
|
||||
void wxComboBox::ApplyWidgetStyle()
|
||||
{
|
||||
SetWidgetStyle();
|
||||
SetWidgetStyle();
|
||||
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
|
||||
|
||||
GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
GList *child = list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
|
||||
GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
GList *child = list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
|
||||
|
||||
GtkBin *bin = GTK_BIN(child->data);
|
||||
gtk_widget_set_style( bin->child, m_widgetStyle );
|
||||
GtkBin *bin = GTK_BIN(child->data);
|
||||
gtk_widget_set_style( bin->child, m_widgetStyle );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget* wxComboBox::GetConnectWidget(void)
|
||||
GtkWidget* wxComboBox::GetConnectWidget()
|
||||
{
|
||||
return GTK_COMBO(m_widget)->entry;
|
||||
return GTK_COMBO(m_widget)->entry;
|
||||
}
|
||||
|
||||
bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
|
||||
{
|
||||
return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) ||
|
||||
(window == GTK_COMBO(m_widget)->button->window ) );
|
||||
return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) ||
|
||||
(window == GTK_COMBO(m_widget)->button->window ) );
|
||||
}
|
||||
|
@@ -29,31 +29,30 @@ extern bool g_blockEventsOnDrag;
|
||||
|
||||
static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox *listbox )
|
||||
{
|
||||
if (!listbox->HasVMT()) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
if (!listbox->HasVMT()) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
|
||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
|
||||
|
||||
wxArrayInt aSelections;
|
||||
int count = listbox->GetSelections(aSelections);
|
||||
if ( count > 0 )
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
event.m_commandInt = -1 ;
|
||||
event.m_commandString = copystring("") ;
|
||||
event.m_commandInt = -1 ;
|
||||
event.m_commandString = copystring("") ;
|
||||
}
|
||||
|
||||
event.SetEventObject( listbox );
|
||||
event.SetEventObject( listbox );
|
||||
|
||||
listbox->GetEventHandler()->ProcessEvent( event );
|
||||
if (event.m_commandString) delete[] event.m_commandString ;
|
||||
listbox->GetEventHandler()->ProcessEvent( event );
|
||||
if (event.m_commandString) delete[] event.m_commandString ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -62,425 +61,489 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl)
|
||||
|
||||
wxListBox::wxListBox(void)
|
||||
wxListBox::wxListBox()
|
||||
{
|
||||
m_list = (GtkList *) NULL;
|
||||
m_list = (GtkList *) NULL;
|
||||
}
|
||||
|
||||
bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
int n, const wxString choices[],
|
||||
long style, const wxValidator& validator, const wxString &name )
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
int n, const wxString choices[],
|
||||
long style, const wxValidator& validator, const wxString &name )
|
||||
{
|
||||
m_needParent = TRUE;
|
||||
m_needParent = TRUE;
|
||||
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
|
||||
SetValidator( validator );
|
||||
SetValidator( validator );
|
||||
|
||||
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
|
||||
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
|
||||
m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL );
|
||||
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
|
||||
|
||||
m_list = GTK_LIST( gtk_list_new() );
|
||||
m_list = GTK_LIST( gtk_list_new() );
|
||||
|
||||
GtkSelectionMode mode = GTK_SELECTION_BROWSE;
|
||||
if (style & wxLB_MULTIPLE)
|
||||
mode = GTK_SELECTION_MULTIPLE;
|
||||
else if (style & wxLB_EXTENDED)
|
||||
mode = GTK_SELECTION_EXTENDED;
|
||||
GtkSelectionMode mode = GTK_SELECTION_BROWSE;
|
||||
if (style & wxLB_MULTIPLE)
|
||||
mode = GTK_SELECTION_MULTIPLE;
|
||||
else if (style & wxLB_EXTENDED)
|
||||
mode = GTK_SELECTION_EXTENDED;
|
||||
|
||||
gtk_list_set_selection_mode( GTK_LIST(m_list), mode );
|
||||
gtk_list_set_selection_mode( GTK_LIST(m_list), mode );
|
||||
|
||||
gtk_container_add (GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
|
||||
gtk_widget_show( GTK_WIDGET(m_list) );
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
|
||||
gtk_widget_show( GTK_WIDGET(m_list) );
|
||||
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 100;
|
||||
if (newSize.y == -1) newSize.y = 110;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 100;
|
||||
if (newSize.y == -1) newSize.y = 110;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
list_item = gtk_list_item_new_with_label( choices[i] );
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
list_item = gtk_list_item_new_with_label( choices[i] );
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
||||
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
if (style & wxLB_MULTIPLE)
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
ConnectWidget( list_item );
|
||||
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
}
|
||||
|
||||
m_parent->AddChild( this );
|
||||
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
gtk_widget_realize( GTK_WIDGET(m_list) );
|
||||
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxListBox::~wxListBox()
|
||||
{
|
||||
wxNode *node = m_clientDataList.First();
|
||||
while (node)
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->Data();
|
||||
if (cd) delete cd;
|
||||
node = node->Next();
|
||||
}
|
||||
m_clientDataList.Clear();
|
||||
}
|
||||
|
||||
void wxListBox::AppendCommon( const wxString &item )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
if (style & wxLB_MULTIPLE)
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
if (GetWindowStyleFlag() & wxLB_MULTIPLE)
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
ConnectWidget( list_item );
|
||||
|
||||
m_clientData.Append( (wxObject*)NULL );
|
||||
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
}
|
||||
|
||||
m_parent->AddChild( this );
|
||||
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
|
||||
PostCreation();
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
gtk_widget_realize( GTK_WIDGET(m_list) );
|
||||
ConnectWidget( list_item );
|
||||
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
ConnectDnDWidget( list_item );
|
||||
}
|
||||
|
||||
void wxListBox::Append( const wxString &item )
|
||||
{
|
||||
Append( item, (char*)NULL );
|
||||
}
|
||||
|
||||
void wxListBox::Append( const wxString &item, char *clientData )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
if (GetWindowStyleFlag() & wxLB_MULTIPLE)
|
||||
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();
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
ConnectWidget( list_item );
|
||||
|
||||
ConnectDnDWidget( list_item );
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxListBox::Clear(void)
|
||||
void wxListBox::Append( const wxString &item, void *clientData )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
if (clientData)
|
||||
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
|
||||
else
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
gtk_list_clear_items( m_list, 0, Number() );
|
||||
void wxListBox::Append( const wxString &item, wxClientData *clientData )
|
||||
{
|
||||
m_clientDataList.Append( (wxObject*) clientData );
|
||||
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
m_clientData.Clear();
|
||||
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() );
|
||||
|
||||
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 )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
|
||||
if (!child)
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return;
|
||||
}
|
||||
if (!child)
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return;
|
||||
}
|
||||
|
||||
GList *list = g_list_append( NULL, child->data );
|
||||
gtk_list_remove_items( m_list, list );
|
||||
g_list_free( list );
|
||||
GList *list = g_list_append( NULL, child->data );
|
||||
gtk_list_remove_items( m_list, list );
|
||||
g_list_free( list );
|
||||
|
||||
wxNode *node = m_clientData.Nth( n );
|
||||
if (!node)
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
}
|
||||
else
|
||||
m_clientData.DeleteNode( node );
|
||||
wxNode *node = m_clientDataList.Nth( n );
|
||||
if (!node)
|
||||
{
|
||||
wxFAIL_MSG( "wrong index" );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->Data();
|
||||
if (cd) delete cd;
|
||||
m_clientDataList.DeleteNode( node );
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::Deselect( int n )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
}
|
||||
|
||||
int wxListBox::FindString( const wxString &item ) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
if (item == label->label) return count;
|
||||
count++;
|
||||
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.
|
||||
|
||||
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
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxListBox::GetSelections(wxArrayInt& aSelections) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
// get the number of selected items first
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
for ( child = m_list->children; child != NULL; child = child->next )
|
||||
{
|
||||
if ( GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED )
|
||||
count++;
|
||||
}
|
||||
|
||||
aSelections.Empty();
|
||||
|
||||
if ( count > 0 ) {
|
||||
// now fill the list
|
||||
aSelections.Alloc(count); // optimization attempt
|
||||
int i = 0;
|
||||
for ( child = m_list->children; child != NULL; child = child->next, i++ )
|
||||
{
|
||||
if ( GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED )
|
||||
aSelections.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
wxString wxListBox::GetString( int n ) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
return label->label;
|
||||
}
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return "";
|
||||
}
|
||||
|
||||
wxString wxListBox::GetStringSelection(void) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
|
||||
|
||||
GList *selection = m_list->selection;
|
||||
if (selection)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( selection->data );
|
||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||
return tmp;
|
||||
}
|
||||
wxFAIL_MSG("no listbox selection available");
|
||||
return "";
|
||||
}
|
||||
|
||||
int wxListBox::Number(void)
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
}
|
||||
|
||||
bool wxListBox::Selected( int n )
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, FALSE, "invalid listbox" );
|
||||
|
||||
GList *target = g_list_nth( m_list->children, n );
|
||||
if (target)
|
||||
{
|
||||
GList *child = m_list->selection;
|
||||
while (child)
|
||||
{
|
||||
if (child->data == target->data) return TRUE;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
|
||||
{
|
||||
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
|
||||
}
|
||||
|
||||
void wxListBox::SetSelection( int n, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
if (select)
|
||||
gtk_list_select_item( m_list, n );
|
||||
else
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
}
|
||||
|
||||
void wxListBox::SetString( int n, const wxString &string )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
gtk_label_set( label, string );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::SetStringSelection( const wxString &string, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
SetSelection( FindString(string), select );
|
||||
}
|
||||
|
||||
int wxListBox::GetIndex( GtkWidget *item ) const
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (GTK_WIDGET(child->data) == item) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
if (item == label->label) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
// it's not an error if the string is not found -> no wxCHECK
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxListBox::GetSelection() const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxListBox::GetSelections( wxArrayInt& aSelections ) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
// get the number of selected items first
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
for (child = m_list->children; child != NULL; child = child->next)
|
||||
{
|
||||
if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED)
|
||||
count++;
|
||||
}
|
||||
|
||||
aSelections.Empty();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
// now fill the list
|
||||
aSelections.Alloc(count); // optimization attempt
|
||||
int i = 0;
|
||||
for (child = m_list->children; child != NULL; child = child->next, i++)
|
||||
{
|
||||
if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED)
|
||||
aSelections.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
wxString wxListBox::GetString( int n ) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
return label->label;
|
||||
}
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return "";
|
||||
}
|
||||
|
||||
wxString wxListBox::GetStringSelection() const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
|
||||
|
||||
GList *selection = m_list->selection;
|
||||
if (selection)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( selection->data );
|
||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||
return tmp;
|
||||
}
|
||||
wxFAIL_MSG("no listbox selection available");
|
||||
return "";
|
||||
}
|
||||
|
||||
int wxListBox::Number()
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
}
|
||||
|
||||
bool wxListBox::Selected( int n )
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, FALSE, "invalid listbox" );
|
||||
|
||||
GList *target = g_list_nth( m_list->children, n );
|
||||
if (target)
|
||||
{
|
||||
GList *child = m_list->selection;
|
||||
while (child)
|
||||
{
|
||||
if (child->data == target->data) return TRUE;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
|
||||
{
|
||||
wxFAIL_MSG("wxListBox::Set not implemented");
|
||||
}
|
||||
|
||||
void wxListBox::SetFirstItem( int WXUNUSED(n) )
|
||||
{
|
||||
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
|
||||
}
|
||||
|
||||
void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
|
||||
{
|
||||
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
|
||||
}
|
||||
|
||||
void wxListBox::SetSelection( int n, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
if (select)
|
||||
gtk_list_select_item( m_list, n );
|
||||
else
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
}
|
||||
|
||||
void wxListBox::SetString( int n, const wxString &string )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
gtk_label_set( label, string );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::SetStringSelection( const wxString &string, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
SetSelection( FindString(string), select );
|
||||
}
|
||||
|
||||
int wxListBox::GetIndex( GtkWidget *item ) const
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (GTK_WIDGET(child->data) == item) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
DisconnectDnDWidget( GTK_WIDGET( child->data ) );
|
||||
child = child->next;
|
||||
}
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
DisconnectDnDWidget( GTK_WIDGET( child->data ) );
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
wxWindow::SetDropTarget( dropTarget );
|
||||
wxWindow::SetDropTarget( dropTarget );
|
||||
|
||||
child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
ConnectDnDWidget( GTK_WIDGET( child->data ) );
|
||||
child = child->next;
|
||||
}
|
||||
child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
ConnectDnDWidget( GTK_WIDGET( child->data ) );
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *wxListBox::GetConnectWidget(void)
|
||||
GtkWidget *wxListBox::GetConnectWidget()
|
||||
{
|
||||
return GTK_WIDGET(m_list);
|
||||
return GTK_WIDGET(m_list);
|
||||
}
|
||||
|
||||
bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
|
||||
{
|
||||
if (wxWindow::IsOwnGtkWindow( window )) return TRUE;
|
||||
if (wxWindow::IsOwnGtkWindow( window )) return TRUE;
|
||||
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
GtkWidget *bin = GTK_WIDGET( child->data );
|
||||
if (bin->window == window) return TRUE;
|
||||
child = child->next;
|
||||
}
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
GtkWidget *bin = GTK_WIDGET( child->data );
|
||||
if (bin->window == window) return TRUE;
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxListBox::ApplyWidgetStyle()
|
||||
{
|
||||
SetWidgetStyle();
|
||||
SetWidgetStyle();
|
||||
|
||||
GdkWindow *window = GTK_WIDGET(m_list)->window;
|
||||
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
||||
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
||||
gdk_window_clear( window );
|
||||
GdkWindow *window = GTK_WIDGET(m_list)->window;
|
||||
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
||||
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
||||
gdk_window_clear( window );
|
||||
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_BIN(child->data)->child, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
|
||||
child = child->next;
|
||||
}
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_BIN(child->data)->child, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
@@ -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,8 +1149,7 @@ 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_cursor = new wxCursor( wxCURSOR_ARROW );
|
||||
m_font = *wxSWISS_FONT;
|
||||
// m_backgroundColour = wxWHITE;
|
||||
// m_foregroundColour = wxBLACK;
|
||||
@@ -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()
|
||||
|
@@ -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
|
||||
|
||||
|
||||
/*
|
||||
wxBitmap::InitStandardHandlers();
|
||||
|
||||
g_globalCursor = new wxCursor;
|
||||
*/
|
||||
wxImage::InitStandardHandlers();
|
||||
|
||||
// g_globalCursor = new wxCursor;
|
||||
}
|
||||
|
||||
void wxApp::CommonCleanUp(void)
|
||||
{
|
||||
wxDELETE(wxTheColourDatabase);
|
||||
/* Now done in wxPostScriptModule
|
||||
wxDELETE(wxThePrintPaperDatabase);
|
||||
wxDELETE(wxThePrintSetupData);
|
||||
*/
|
||||
wxDELETE(wxTheFontNameDirectory);
|
||||
wxDeleteStockObjects();
|
||||
|
||||
@@ -357,6 +341,8 @@ void wxApp::CommonCleanUp(void)
|
||||
wxDeleteStockLists();
|
||||
|
||||
wxCleanUpResourceSystem();
|
||||
|
||||
wxImage::CleanUpHandlers();
|
||||
|
||||
wxSystemSettings::Done();
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/icon.h"
|
||||
#include "wx/filefn.h"
|
||||
#include "gdk/gdkprivate.h"
|
||||
#include "gdk/gdkx.h"
|
||||
|
||||
@@ -24,7 +25,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject)
|
||||
|
||||
wxMask::wxMask(void)
|
||||
{
|
||||
m_bitmap = (GdkBitmap *) NULL;
|
||||
m_bitmap = (GdkBitmap *) NULL;
|
||||
}
|
||||
|
||||
wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap), const wxColour& WXUNUSED(colour) )
|
||||
@@ -41,12 +42,12 @@ wxMask::wxMask( const wxBitmap& WXUNUSED(bitmap) )
|
||||
|
||||
wxMask::~wxMask(void)
|
||||
{
|
||||
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
|
||||
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
|
||||
}
|
||||
|
||||
GdkBitmap *wxMask::GetBitmap(void) const
|
||||
{
|
||||
return m_bitmap;
|
||||
return m_bitmap;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -55,37 +56,36 @@ GdkBitmap *wxMask::GetBitmap(void) const
|
||||
|
||||
class wxBitmapRefData: public wxObjectRefData
|
||||
{
|
||||
public:
|
||||
public:
|
||||
wxBitmapRefData(void);
|
||||
~wxBitmapRefData(void);
|
||||
|
||||
wxBitmapRefData(void);
|
||||
~wxBitmapRefData(void);
|
||||
|
||||
GdkPixmap *m_pixmap;
|
||||
GdkBitmap *m_bitmap;
|
||||
wxMask *m_mask;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_bpp;
|
||||
wxPalette *m_palette;
|
||||
GdkPixmap *m_pixmap;
|
||||
GdkBitmap *m_bitmap;
|
||||
wxMask *m_mask;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_bpp;
|
||||
wxPalette *m_palette;
|
||||
};
|
||||
|
||||
wxBitmapRefData::wxBitmapRefData(void)
|
||||
{
|
||||
m_pixmap = (GdkPixmap *) NULL;
|
||||
m_bitmap = (GdkBitmap *) NULL;
|
||||
m_mask = (wxMask *) NULL;
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_bpp = 0;
|
||||
m_palette = (wxPalette *) NULL;
|
||||
m_pixmap = (GdkPixmap *) NULL;
|
||||
m_bitmap = (GdkBitmap *) NULL;
|
||||
m_mask = (wxMask *) NULL;
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_bpp = 0;
|
||||
m_palette = (wxPalette *) NULL;
|
||||
}
|
||||
|
||||
wxBitmapRefData::~wxBitmapRefData(void)
|
||||
{
|
||||
if (m_pixmap) gdk_pixmap_unref( m_pixmap );
|
||||
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
|
||||
if (m_mask) delete m_mask;
|
||||
if (m_palette) delete m_palette;
|
||||
if (m_pixmap) gdk_pixmap_unref( m_pixmap );
|
||||
if (m_bitmap) gdk_bitmap_unref( m_bitmap );
|
||||
if (m_mask) delete m_mask;
|
||||
if (m_palette) delete m_palette;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -96,466 +96,502 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject)
|
||||
|
||||
wxBitmap::wxBitmap(void)
|
||||
{
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( int width, int height, int depth )
|
||||
{
|
||||
wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" )
|
||||
wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" )
|
||||
wxCHECK_RET( (width > 0) && (height > 0), "invalid bitmap size" )
|
||||
wxCHECK_RET( (depth > 0) || (depth == -1), "invalid bitmap depth" )
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||
M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
|
||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||
M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( char **bits )
|
||||
{
|
||||
wxCHECK_RET( bits != NULL, "invalid bitmap data" )
|
||||
wxCHECK_RET( bits != NULL, "invalid bitmap data" )
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
GdkBitmap *mask = (GdkBitmap*) NULL;
|
||||
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||
GdkBitmap *mask = (GdkBitmap*) NULL;
|
||||
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
|
||||
|
||||
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
|
||||
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
|
||||
|
||||
if (mask)
|
||||
{
|
||||
M_BMPDATA->m_mask = new wxMask();
|
||||
M_BMPDATA->m_mask->m_bitmap = mask;
|
||||
}
|
||||
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) );
|
||||
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; // ?
|
||||
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const wxBitmap& bmp )
|
||||
{
|
||||
Ref( bmp );
|
||||
Ref( bmp );
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const wxBitmap* bmp )
|
||||
{
|
||||
if (bmp) Ref( *bmp );
|
||||
if (bmp) Ref( *bmp );
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const wxString &filename, int type )
|
||||
{
|
||||
LoadFile( filename, type );
|
||||
LoadFile( filename, type );
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth))
|
||||
{
|
||||
m_refData = new wxBitmapRefData();
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||
M_BMPDATA->m_bitmap =
|
||||
gdk_bitmap_create_from_data( (GdkWindow*) &gdk_root_parent, (gchar *) bits, width, height );
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_bpp = 1;
|
||||
M_BMPDATA->m_mask = (wxMask *) NULL;
|
||||
M_BMPDATA->m_bitmap =
|
||||
gdk_bitmap_create_from_data( (GdkWindow*) &gdk_root_parent, (gchar *) bits, width, height );
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_bpp = 1;
|
||||
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::~wxBitmap(void)
|
||||
{
|
||||
if (wxTheBitmapList) wxTheBitmapList->DeleteObject(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->DeleteObject(this);
|
||||
}
|
||||
|
||||
wxBitmap& wxBitmap::operator = ( const wxBitmap& bmp )
|
||||
{
|
||||
if (*this == bmp) return (*this);
|
||||
Ref( bmp );
|
||||
return *this;
|
||||
if (*this == bmp) return (*this);
|
||||
Ref( bmp );
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool wxBitmap::operator == ( const wxBitmap& bmp )
|
||||
{
|
||||
return m_refData == bmp.m_refData;
|
||||
return m_refData == bmp.m_refData;
|
||||
}
|
||||
|
||||
bool wxBitmap::operator != ( const wxBitmap& bmp )
|
||||
{
|
||||
return m_refData != bmp.m_refData;
|
||||
return m_refData != bmp.m_refData;
|
||||
}
|
||||
|
||||
bool wxBitmap::Ok(void) const
|
||||
{
|
||||
return (m_refData != NULL);
|
||||
return (m_refData != NULL);
|
||||
}
|
||||
|
||||
int wxBitmap::GetHeight(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_height;
|
||||
return M_BMPDATA->m_height;
|
||||
}
|
||||
|
||||
int wxBitmap::GetWidth(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_width;
|
||||
return M_BMPDATA->m_width;
|
||||
}
|
||||
|
||||
int wxBitmap::GetDepth(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_bpp;
|
||||
return M_BMPDATA->m_bpp;
|
||||
}
|
||||
|
||||
void wxBitmap::SetHeight( int height )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
if (!Ok()) return;
|
||||
|
||||
wxFAIL_MSG( "wxBitmap::SetHeight not implemented" );
|
||||
wxFAIL_MSG( "wxBitmap::SetHeight not implemented" );
|
||||
|
||||
M_BMPDATA->m_height = height;
|
||||
M_BMPDATA->m_height = height;
|
||||
}
|
||||
|
||||
void wxBitmap::SetWidth( int width )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
if (!Ok()) return;
|
||||
|
||||
wxFAIL_MSG( "wxBitmap::SetWidth not implemented" );
|
||||
wxFAIL_MSG( "wxBitmap::SetWidth not implemented" );
|
||||
|
||||
M_BMPDATA->m_width = width;
|
||||
M_BMPDATA->m_width = width;
|
||||
}
|
||||
|
||||
void wxBitmap::SetDepth( int depth )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
if (!Ok()) return;
|
||||
|
||||
wxFAIL_MSG( "wxBitmap::SetDepth not implemented" );
|
||||
wxFAIL_MSG( "wxBitmap::SetDepth not implemented" );
|
||||
|
||||
M_BMPDATA->m_bpp = depth;
|
||||
M_BMPDATA->m_bpp = depth;
|
||||
}
|
||||
|
||||
wxMask *wxBitmap::GetMask(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (wxMask *) NULL;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (wxMask *) NULL;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_mask;
|
||||
return M_BMPDATA->m_mask;
|
||||
}
|
||||
|
||||
void wxBitmap::SetMask( wxMask *mask )
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
|
||||
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
|
||||
|
||||
M_BMPDATA->m_mask = 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())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return FALSE;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
if (type == wxBITMAP_TYPE_PNG)
|
||||
{
|
||||
wxImage image = ConvertToImage();
|
||||
if (image.Ok()) return image.SaveFile( name, type );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxBitmap::LoadFile( const wxString &WXUNUSED(name), int WXUNUSED(type) )
|
||||
bool wxBitmap::LoadFile( const wxString &name, int type )
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return FALSE;
|
||||
}
|
||||
UnRef();
|
||||
|
||||
if (!wxFileExists(name)) return FALSE;
|
||||
|
||||
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;
|
||||
return M_BMPDATA->m_palette;
|
||||
if (!Ok()) return (wxPalette *) NULL;
|
||||
return M_BMPDATA->m_palette;
|
||||
}
|
||||
|
||||
GdkPixmap *wxBitmap::GetPixmap(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (GdkPixmap *) NULL;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (GdkPixmap *) NULL;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_pixmap;
|
||||
return M_BMPDATA->m_pixmap;
|
||||
}
|
||||
|
||||
GdkBitmap *wxBitmap::GetBitmap(void) const
|
||||
{
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (GdkBitmap *) NULL;
|
||||
}
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return (GdkBitmap *) NULL;
|
||||
}
|
||||
|
||||
return M_BMPDATA->m_bitmap;
|
||||
return M_BMPDATA->m_bitmap;
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap( const wxImage &image )
|
||||
{
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||
|
||||
if (!image.Ok()) return;
|
||||
if (!image.Ok()) return;
|
||||
|
||||
m_refData = new wxBitmapRefData();
|
||||
m_refData = new wxBitmapRefData();
|
||||
|
||||
M_BMPDATA->m_height = image.GetHeight();
|
||||
M_BMPDATA->m_width = image.GetWidth();
|
||||
int width = image.GetWidth();
|
||||
int height = image.GetHeight();
|
||||
M_BMPDATA->m_height = image.GetHeight();
|
||||
M_BMPDATA->m_width = image.GetWidth();
|
||||
int width = image.GetWidth();
|
||||
int height = image.GetHeight();
|
||||
|
||||
// Create picture
|
||||
// Create picture
|
||||
|
||||
GdkImage *data_image =
|
||||
gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height );
|
||||
GdkImage *data_image =
|
||||
gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height );
|
||||
|
||||
M_BMPDATA->m_pixmap =
|
||||
gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 );
|
||||
M_BMPDATA->m_pixmap =
|
||||
gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 );
|
||||
|
||||
// Create mask
|
||||
// Create mask
|
||||
|
||||
GdkImage *mask_image = (GdkImage*) NULL;
|
||||
GdkImage *mask_image = (GdkImage*) NULL;
|
||||
|
||||
if (image.HasMask())
|
||||
{
|
||||
unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
|
||||
if (image.HasMask())
|
||||
{
|
||||
unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
|
||||
|
||||
mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
|
||||
mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
|
||||
|
||||
M_BMPDATA->m_mask = new wxMask();
|
||||
M_BMPDATA->m_mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
|
||||
}
|
||||
M_BMPDATA->m_mask = new wxMask();
|
||||
M_BMPDATA->m_mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
|
||||
}
|
||||
|
||||
// Retrieve depth
|
||||
// Retrieve depth
|
||||
|
||||
M_BMPDATA->m_bpp = data_image->depth;
|
||||
M_BMPDATA->m_bpp = data_image->depth;
|
||||
|
||||
int render_depth = 8;
|
||||
if (M_BMPDATA->m_bpp > 8) render_depth = M_BMPDATA->m_bpp;
|
||||
int render_depth = 8;
|
||||
if (M_BMPDATA->m_bpp > 8) render_depth = M_BMPDATA->m_bpp;
|
||||
|
||||
// Render
|
||||
// Render
|
||||
|
||||
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
|
||||
byte_order b_o;
|
||||
enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
|
||||
byte_order b_o = RGB;
|
||||
|
||||
if (render_depth >= 24)
|
||||
{
|
||||
GdkVisual *visual = gdk_visual_get_system();
|
||||
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
||||
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
|
||||
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
||||
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
||||
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
||||
else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR;
|
||||
}
|
||||
if (render_depth >= 24)
|
||||
{
|
||||
GdkVisual *visual = gdk_visual_get_system();
|
||||
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
||||
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
|
||||
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
||||
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
||||
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
||||
else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR;
|
||||
}
|
||||
|
||||
int r_mask = image.GetMaskRed();
|
||||
int g_mask = image.GetMaskGreen();
|
||||
int b_mask = image.GetMaskBlue();
|
||||
int r_mask = image.GetMaskRed();
|
||||
int g_mask = image.GetMaskGreen();
|
||||
int b_mask = image.GetMaskBlue();
|
||||
|
||||
unsigned char* data = image.GetData();
|
||||
unsigned char* data = image.GetData();
|
||||
|
||||
int index = 0;
|
||||
for (int y = 0; y < height; y++)
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int r = data[index];
|
||||
index++;
|
||||
int g = data[index];
|
||||
index++;
|
||||
int b = data[index];
|
||||
index++;
|
||||
int index = 0;
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
int r = data[index];
|
||||
index++;
|
||||
int g = data[index];
|
||||
index++;
|
||||
int b = data[index];
|
||||
index++;
|
||||
|
||||
if (image.HasMask())
|
||||
{
|
||||
if ((r == r_mask) && (b = b_mask) && (g = g_mask))
|
||||
gdk_image_put_pixel( mask_image, x, y, 0 );
|
||||
else
|
||||
gdk_image_put_pixel( mask_image, x, y, 1 );
|
||||
}
|
||||
|
||||
switch (render_depth)
|
||||
{
|
||||
case 8:
|
||||
{
|
||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||
GdkColor *colors = cmap->colors;
|
||||
int max = 3 * (65536);
|
||||
int index = -1;
|
||||
|
||||
for (int i = 0; i < cmap->size; i++)
|
||||
{
|
||||
int rdiff = (r << 8) - colors[i].red;
|
||||
int gdiff = (g << 8) - colors[i].green;
|
||||
int bdiff = (b << 8) - colors[i].blue;
|
||||
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
|
||||
if (sum < max) { index = i; max = sum; }
|
||||
}
|
||||
|
||||
gdk_image_put_pixel( data_image, x, y, index );
|
||||
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
guint32 pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3);
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
guint32 pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3);
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
break;
|
||||
}
|
||||
case 32:
|
||||
case 24:
|
||||
{
|
||||
guint32 pixel = 0;
|
||||
switch (b_o)
|
||||
if (image.HasMask())
|
||||
{
|
||||
case RGB: pixel = (r << 16) | (g << 8) | b; break;
|
||||
case RBG: pixel = (r << 16) | (b << 8) | g; break;
|
||||
case BRG: pixel = (b << 16) | (r << 8) | g; break;
|
||||
case BGR: pixel = (b << 16) | (g << 8) | r; break;
|
||||
case GRB: pixel = (g << 16) | (r << 8) | b; break;
|
||||
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
||||
if ((r == r_mask) && (b = b_mask) && (g = g_mask))
|
||||
gdk_image_put_pixel( mask_image, x, y, 0 );
|
||||
else
|
||||
gdk_image_put_pixel( mask_image, x, y, 1 );
|
||||
}
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// Blit picture
|
||||
|
||||
switch (render_depth)
|
||||
{
|
||||
case 8:
|
||||
{
|
||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||
GdkColor *colors = cmap->colors;
|
||||
int max = 3 * (65536);
|
||||
int index = -1;
|
||||
|
||||
for (int i = 0; i < cmap->size; i++)
|
||||
{
|
||||
int rdiff = (r << 8) - colors[i].red;
|
||||
int gdiff = (g << 8) - colors[i].green;
|
||||
int bdiff = (b << 8) - colors[i].blue;
|
||||
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
|
||||
if (sum < max) { index = i; max = sum; }
|
||||
}
|
||||
|
||||
gdk_image_put_pixel( data_image, x, y, index );
|
||||
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
guint32 pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3);
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
guint32 pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3);
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
break;
|
||||
}
|
||||
case 32:
|
||||
case 24:
|
||||
{
|
||||
guint32 pixel = 0;
|
||||
switch (b_o)
|
||||
{
|
||||
case RGB: pixel = (r << 16) | (g << 8) | b; break;
|
||||
case RBG: pixel = (r << 16) | (b << 8) | g; break;
|
||||
case BRG: pixel = (b << 16) | (r << 8) | g; break;
|
||||
case BGR: pixel = (b << 16) | (g << 8) | r; break;
|
||||
case GRB: pixel = (g << 16) | (r << 8) | b; break;
|
||||
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
||||
}
|
||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
} // for
|
||||
} // for
|
||||
|
||||
// Blit picture
|
||||
|
||||
GdkGC *data_gc = gdk_gc_new( M_BMPDATA->m_pixmap );
|
||||
GdkGC *data_gc = gdk_gc_new( M_BMPDATA->m_pixmap );
|
||||
|
||||
gdk_draw_image( M_BMPDATA->m_pixmap, data_gc, data_image, 0, 0, 0, 0, width, height );
|
||||
gdk_draw_image( M_BMPDATA->m_pixmap, data_gc, data_image, 0, 0, 0, 0, width, height );
|
||||
|
||||
gdk_image_destroy( data_image );
|
||||
gdk_gc_unref( data_gc );
|
||||
gdk_image_destroy( data_image );
|
||||
gdk_gc_unref( data_gc );
|
||||
|
||||
// Blit mask
|
||||
// Blit mask
|
||||
|
||||
if (image.HasMask())
|
||||
{
|
||||
GdkGC *mask_gc = gdk_gc_new( M_BMPDATA->m_mask->m_bitmap );
|
||||
if (image.HasMask())
|
||||
{
|
||||
GdkGC *mask_gc = gdk_gc_new( M_BMPDATA->m_mask->m_bitmap );
|
||||
|
||||
gdk_draw_image( M_BMPDATA->m_mask->m_bitmap, mask_gc, mask_image, 0, 0, 0, 0, width, height );
|
||||
gdk_draw_image( M_BMPDATA->m_mask->m_bitmap, mask_gc, mask_image, 0, 0, 0, 0, width, height );
|
||||
|
||||
gdk_image_destroy( mask_image );
|
||||
gdk_gc_unref( mask_gc );
|
||||
}
|
||||
|
||||
gdk_image_destroy( mask_image );
|
||||
gdk_gc_unref( mask_gc );
|
||||
}
|
||||
}
|
||||
|
||||
wxImage wxBitmap::ConvertToImage() const
|
||||
{
|
||||
wxImage image;
|
||||
wxImage image;
|
||||
|
||||
if (!Ok())
|
||||
{
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return image;
|
||||
}
|
||||
|
||||
GdkImage *gdk_image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height );
|
||||
|
||||
if (!gdk_image) return image;
|
||||
|
||||
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;
|
||||
|
||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||
|
||||
long pos = 0;
|
||||
for (int j = 0; j < M_BMPDATA->m_height; j++)
|
||||
{
|
||||
for (int i = 0; i < M_BMPDATA->m_width; i++)
|
||||
if (!Ok())
|
||||
{
|
||||
int pixel = gdk_image_get_pixel( gdk_image, i, j );
|
||||
if (bpp <= 8)
|
||||
{
|
||||
data[pos] = cmap->colors[pixel].red >> 8;
|
||||
data[pos+1] = cmap->colors[pixel].green >> 8;
|
||||
data[pos+2] = cmap->colors[pixel].blue >> 8;
|
||||
} else if (bpp == 15)
|
||||
{
|
||||
data[pos] = (pixel >> 7) & 0xf8;
|
||||
data[pos+1] = (pixel >> 2) & 0xf8;
|
||||
data[pos+2] = (pixel << 3) & 0xf8;
|
||||
} else if (bpp == 16)
|
||||
{
|
||||
data[pos] = (pixel >> 8) & 0xf8;
|
||||
data[pos+1] = (pixel >> 3) & 0xfc;
|
||||
data[pos+2] = (pixel << 3) & 0xf8;
|
||||
} else
|
||||
{
|
||||
data[pos] = (pixel >> 16) & 0xff;
|
||||
data[pos+1] = (pixel >> 8) & 0xff;
|
||||
data[pos+2] = pixel & 0xff;
|
||||
}
|
||||
|
||||
pos += 3;
|
||||
wxFAIL_MSG( "invalid bitmap" );
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
gdk_image_destroy( gdk_image );
|
||||
GdkImage *gdk_image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height );
|
||||
|
||||
return image;
|
||||
if (!gdk_image) return image;
|
||||
|
||||
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;
|
||||
|
||||
GdkColormap *cmap = gtk_widget_get_default_colormap();
|
||||
|
||||
long pos = 0;
|
||||
for (int j = 0; j < M_BMPDATA->m_height; j++)
|
||||
{
|
||||
for (int i = 0; i < M_BMPDATA->m_width; i++)
|
||||
{
|
||||
int pixel = gdk_image_get_pixel( gdk_image, i, j );
|
||||
if (bpp <= 8)
|
||||
{
|
||||
data[pos] = cmap->colors[pixel].red >> 8;
|
||||
data[pos+1] = cmap->colors[pixel].green >> 8;
|
||||
data[pos+2] = cmap->colors[pixel].blue >> 8;
|
||||
} else if (bpp == 15)
|
||||
{
|
||||
data[pos] = (pixel >> 7) & 0xf8;
|
||||
data[pos+1] = (pixel >> 2) & 0xf8;
|
||||
data[pos+2] = (pixel << 3) & 0xf8;
|
||||
} else if (bpp == 16)
|
||||
{
|
||||
data[pos] = (pixel >> 8) & 0xf8;
|
||||
data[pos+1] = (pixel >> 3) & 0xfc;
|
||||
data[pos+2] = (pixel << 3) & 0xf8;
|
||||
} else
|
||||
{
|
||||
data[pos] = (pixel >> 16) & 0xff;
|
||||
data[pos+1] = (pixel >> 8) & 0xff;
|
||||
data[pos+2] = pixel & 0xff;
|
||||
}
|
||||
|
||||
pos += 3;
|
||||
}
|
||||
}
|
||||
|
||||
gdk_image_destroy( gdk_image );
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -43,200 +43,301 @@ static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl)
|
||||
|
||||
wxChoice::wxChoice(void)
|
||||
wxChoice::wxChoice()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxChoice::Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
int n, const wxString choices[],
|
||||
long style, const wxValidator& validator, const wxString &name )
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
int n, const wxString choices[],
|
||||
long style, const wxValidator& validator, const wxString &name )
|
||||
{
|
||||
m_needParent = TRUE;
|
||||
m_needParent = TRUE;
|
||||
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
|
||||
SetValidator( validator );
|
||||
SetValidator( validator );
|
||||
|
||||
m_widget = gtk_option_menu_new();
|
||||
m_widget = gtk_option_menu_new();
|
||||
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 80;
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 80;
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
|
||||
gtk_menu_append( GTK_MENU(menu), item );
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
m_clientDataList.Append( (wxObject*) NULL );
|
||||
|
||||
gtk_widget_realize( item );
|
||||
gtk_widget_realize( GTK_BIN(item)->child );
|
||||
GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
|
||||
gtk_menu_append( GTK_MENU(menu), item );
|
||||
|
||||
gtk_widget_show( item );
|
||||
gtk_widget_realize( item );
|
||||
gtk_widget_realize( GTK_BIN(item)->child );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT( item ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
}
|
||||
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
||||
gtk_widget_show( item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT( item ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
}
|
||||
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
||||
|
||||
m_parent->AddChild( this );
|
||||
m_parent->AddChild( this );
|
||||
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation();
|
||||
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
|
||||
Show( TRUE );
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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" );
|
||||
|
||||
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
|
||||
GtkWidget *menu_item = gtk_menu_item_new_with_label( item );
|
||||
|
||||
gtk_menu_append( GTK_MENU(menu), menu_item );
|
||||
|
||||
gtk_widget_realize( menu_item );
|
||||
gtk_widget_realize( GTK_BIN(menu_item)->child );
|
||||
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
|
||||
gtk_widget_show( menu_item );
|
||||
}
|
||||
|
||||
void wxChoice::Append( const wxString &item )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
|
||||
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
|
||||
GtkWidget *menu_item = gtk_menu_item_new_with_label( item );
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
gtk_menu_append( GTK_MENU(menu), menu_item );
|
||||
|
||||
gtk_widget_realize( menu_item );
|
||||
gtk_widget_realize( GTK_BIN(menu_item)->child );
|
||||
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
|
||||
gtk_widget_show( menu_item );
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxChoice::Clear(void)
|
||||
{
|
||||
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 );
|
||||
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) )
|
||||
{
|
||||
wxFAIL_MSG( "wxChoice:Delete not implemented" );
|
||||
wxFAIL_MSG( "wxChoice:Delete not implemented" );
|
||||
}
|
||||
|
||||
int wxChoice::FindString( const wxString &string ) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid choice" );
|
||||
|
||||
// If you read this code once and you think you understand
|
||||
// it, then you are very wrong. Robert Roebling.
|
||||
// If you read this code once and you think you understand
|
||||
// it, then you are very wrong. Robert Roebling.
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = (GtkLabel *) NULL;
|
||||
if (bin->child) label = GTK_LABEL(bin->child);
|
||||
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = (GtkLabel *) NULL;
|
||||
if (bin->child) label = GTK_LABEL(bin->child);
|
||||
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
|
||||
if (string == label->label) return count;
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
if (string == label->label) return count;
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxChoice: string not found" );
|
||||
wxFAIL_MSG( "wxChoice: string not found" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
if (!bin->child) return count;
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
if (!bin->child) return count;
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxChoice: no selection" );
|
||||
wxFAIL_MSG( "wxChoice: no selection" );
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
wxString wxChoice::GetString( int n ) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
|
||||
wxCHECK_MSG( m_widget != NULL, "", "invalid choice" );
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
if (count == n)
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
GtkLabel *label = (GtkLabel *) NULL;
|
||||
if (bin->child) label = GTK_LABEL(bin->child);
|
||||
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
if (count == n)
|
||||
{
|
||||
GtkLabel *label = (GtkLabel *) NULL;
|
||||
if (bin->child) label = GTK_LABEL(bin->child);
|
||||
if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
|
||||
return label->label;
|
||||
return label->label;
|
||||
}
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
child = child->next;
|
||||
count++;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxChoice: string not found" );
|
||||
wxFAIL_MSG( "wxChoice: string not found" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
return count;
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void wxChoice::SetColumns( int WXUNUSED(n) )
|
||||
@@ -245,44 +346,44 @@ void wxChoice::SetColumns( int WXUNUSED(n) )
|
||||
|
||||
void wxChoice::SetSelection( int n )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
|
||||
int tmp = n;
|
||||
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
|
||||
int tmp = n;
|
||||
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
|
||||
|
||||
gtk_choice_clicked_callback( (GtkWidget *) NULL, this );
|
||||
gtk_choice_clicked_callback( (GtkWidget *) NULL, this );
|
||||
}
|
||||
|
||||
void wxChoice::SetStringSelection( const wxString &string )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid choice" );
|
||||
|
||||
int n = FindString( string );
|
||||
if (n != -1) SetSelection( n );
|
||||
int n = FindString( string );
|
||||
if (n != -1) SetSelection( n );
|
||||
}
|
||||
|
||||
void wxChoice::ApplyWidgetStyle()
|
||||
{
|
||||
SetWidgetStyle();
|
||||
SetWidgetStyle();
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
|
||||
gtk_widget_set_style( m_widget, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_WIDGET( menu_shell ), m_widgetStyle );
|
||||
gtk_widget_set_style( m_widget, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_WIDGET( menu_shell ), m_widgetStyle );
|
||||
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_WIDGET( child->data ), m_widgetStyle );
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_WIDGET( child->data ), m_widgetStyle );
|
||||
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkWidget *label = (GtkWidget *) NULL;
|
||||
if (bin->child) label = bin->child;
|
||||
if (!label) label = GTK_BUTTON(m_widget)->child;
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkWidget *label = (GtkWidget *) NULL;
|
||||
if (bin->child) label = bin->child;
|
||||
if (!label) label = GTK_BUTTON(m_widget)->child;
|
||||
|
||||
gtk_widget_set_style( label, m_widgetStyle );
|
||||
gtk_widget_set_style( label, m_widgetStyle );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
@@ -53,14 +104,29 @@ IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
|
||||
|
||||
wxClipboard::wxClipboard()
|
||||
{
|
||||
m_data = (wxDataObject*)NULL;
|
||||
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 )
|
||||
|
@@ -26,23 +26,23 @@ extern bool g_blockEventsOnDrag;
|
||||
|
||||
static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
|
||||
{
|
||||
if (!combo->HasVMT()) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
if (!combo->HasVMT()) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
||||
if (combo->m_alreadySent)
|
||||
{
|
||||
combo->m_alreadySent = FALSE;
|
||||
return;
|
||||
}
|
||||
if (combo->m_alreadySent)
|
||||
{
|
||||
combo->m_alreadySent = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
combo->m_alreadySent = TRUE;
|
||||
combo->m_alreadySent = TRUE;
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, combo->GetId());
|
||||
event.SetInt( combo->GetSelection() );
|
||||
wxString tmp( combo->GetStringSelection() );
|
||||
event.SetString( WXSTRINGCAST(tmp) );
|
||||
event.SetEventObject(combo);
|
||||
combo->GetEventHandler()->ProcessEvent(event);
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, combo->GetId());
|
||||
event.SetInt( combo->GetSelection() );
|
||||
wxString tmp( combo->GetStringSelection() );
|
||||
event.SetString( WXSTRINGCAST(tmp) );
|
||||
event.SetEventObject(combo);
|
||||
combo->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -52,421 +52,490 @@ static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxComboBox, wxControl)
|
||||
EVT_SIZE(wxComboBox::OnSize)
|
||||
EVT_SIZE(wxComboBox::OnSize)
|
||||
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 )
|
||||
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 )
|
||||
{
|
||||
m_alreadySent = FALSE;
|
||||
m_needParent = TRUE;
|
||||
m_alreadySent = FALSE;
|
||||
m_needParent = TRUE;
|
||||
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
|
||||
SetValidator( validator );
|
||||
SetValidator( validator );
|
||||
|
||||
m_widget = gtk_combo_new();
|
||||
m_widget = gtk_combo_new();
|
||||
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 100;
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 100;
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
|
||||
for (int i = 0; i < n; 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 );
|
||||
|
||||
gtk_widget_realize( list_item );
|
||||
gtk_widget_realize( GTK_BIN(list_item)->child );
|
||||
gtk_widget_realize( list_item );
|
||||
gtk_widget_realize( GTK_BIN(list_item)->child );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
}
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
}
|
||||
|
||||
m_parent->AddChild( this );
|
||||
m_parent->AddChild( this );
|
||||
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation();
|
||||
|
||||
ConnectWidget( GTK_COMBO(m_widget)->button );
|
||||
ConnectWidget( GTK_COMBO(m_widget)->button );
|
||||
|
||||
if (!value.IsNull()) SetValue( value );
|
||||
if (!value.IsNull()) SetValue( value );
|
||||
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->list );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->entry );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->button );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->list );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->entry );
|
||||
gtk_widget_realize( GTK_COMBO(m_widget)->button );
|
||||
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
|
||||
Show( TRUE );
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxComboBox::Clear(void)
|
||||
wxComboBox::~wxComboBox()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxNode *node = m_clientDataList.First();
|
||||
while (node)
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->Data();
|
||||
if (cd) delete cd;
|
||||
node = node->Next();
|
||||
}
|
||||
m_clientDataList.Clear();
|
||||
}
|
||||
|
||||
void wxComboBox::AppendCommon( const wxString &item )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_clear_items( GTK_LIST(list), 0, Number() );
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
m_clientData.Clear();
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
}
|
||||
|
||||
void wxComboBox::Append( const wxString &item )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
Append( item, (char*)NULL );
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxComboBox::Append( const wxString &item, char *clientData )
|
||||
void wxComboBox::Append( const wxString &item, void *clientData )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
if (clientData)
|
||||
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
|
||||
else
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxComboBox::Append( const wxString &item, wxClientData *clientData )
|
||||
{
|
||||
m_clientDataList.Append( (wxObject*) clientData );
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( item );
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxComboBox::SetClientData( int n, void* clientData )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
wxNode *node = m_clientDataList.Nth( n );
|
||||
if (!node) return;
|
||||
|
||||
m_clientData.Append( (wxObject*)clientData );
|
||||
wxClientData *cd = (wxClientData*) node->Data();
|
||||
if (cd) delete cd;
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||
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;
|
||||
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
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;
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
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" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
|
||||
GList *child = g_list_nth( listbox->children, n );
|
||||
GList *child = g_list_nth( listbox->children, n );
|
||||
|
||||
if (!child)
|
||||
{
|
||||
wxFAIL_MSG("wrong index");
|
||||
return;
|
||||
}
|
||||
if (!child)
|
||||
{
|
||||
wxFAIL_MSG("wrong index");
|
||||
return;
|
||||
}
|
||||
|
||||
GList *list = g_list_append( NULL, child->data );
|
||||
gtk_list_remove_items( listbox, list );
|
||||
g_list_free( list );
|
||||
GList *list = g_list_append( NULL, child->data );
|
||||
gtk_list_remove_items( listbox, list );
|
||||
g_list_free( list );
|
||||
|
||||
wxNode *node = m_clientData.Nth( n );
|
||||
if (!node)
|
||||
{
|
||||
wxFAIL_MSG( "wrong index" );
|
||||
}
|
||||
else
|
||||
m_clientData.DeleteNode( node );
|
||||
wxNode *node = m_clientDataList.Nth( n );
|
||||
if (!node)
|
||||
{
|
||||
wxFAIL_MSG( "wrong index" );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->Data();
|
||||
if (cd) delete cd;
|
||||
m_clientDataList.DeleteNode( node );
|
||||
}
|
||||
}
|
||||
|
||||
int wxComboBox::FindString( const wxString &item )
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
if (item == label->label) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: string not found" );
|
||||
|
||||
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
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *selection = GTK_LIST(list)->selection;
|
||||
if (selection)
|
||||
{
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (child->data == selection->data) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
if (item == label->label) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||
wxFAIL_MSG( "wxComboBox: string not found" );
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxComboBox::GetSelection() const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *selection = GTK_LIST(list)->selection;
|
||||
if (selection)
|
||||
{
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (child->data == selection->data) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
wxString wxComboBox::GetString( int n ) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
|
||||
wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *child = g_list_nth( GTK_LIST(list)->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
return label->label;
|
||||
}
|
||||
GList *child = g_list_nth( GTK_LIST(list)->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
return label->label;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *selection = GTK_LIST(list)->selection;
|
||||
if (selection)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( selection->data );
|
||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||
return tmp;
|
||||
}
|
||||
GList *selection = GTK_LIST(list)->selection;
|
||||
if (selection)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( selection->data );
|
||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||
|
||||
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" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
}
|
||||
|
||||
void wxComboBox::SetSelection( int n )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_select_item( GTK_LIST(list), n );
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_select_item( GTK_LIST(list), n );
|
||||
}
|
||||
|
||||
void wxComboBox::SetStringSelection( const wxString &string )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
int res = FindString( string );
|
||||
if (res == -1) return;
|
||||
SetSelection( res );
|
||||
int res = FindString( string );
|
||||
if (res == -1) return;
|
||||
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) );
|
||||
return tmp;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) );
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void wxComboBox::SetValue( const wxString& value )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
wxString tmp = "";
|
||||
if (!value.IsNull()) tmp = value;
|
||||
gtk_entry_set_text( GTK_ENTRY(entry), tmp );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
wxString tmp = "";
|
||||
if (!value.IsNull()) tmp = value;
|
||||
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" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::Cut(void)
|
||||
void wxComboBox::Cut()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::Paste(void)
|
||||
void wxComboBox::Paste()
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
#if (GTK_MINOR_VERSION == 1)
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
|
||||
#else
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::SetInsertionPoint( long pos )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int tmp = (int) pos;
|
||||
gtk_entry_set_position( GTK_ENTRY(entry), tmp );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int tmp = (int) pos;
|
||||
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" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int pos = GTK_ENTRY(entry)->text_length;
|
||||
SetInsertionPoint( pos-1 );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int pos = GTK_ENTRY(entry)->text_length;
|
||||
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;
|
||||
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;
|
||||
return (long) pos-1;
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
int pos = GTK_ENTRY(entry)->text_length;
|
||||
return (long) pos-1;
|
||||
}
|
||||
|
||||
void wxComboBox::Replace( long from, long to, const wxString& value )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||
if (value.IsNull()) return;
|
||||
gint pos = (gint)to;
|
||||
gtk_editable_insert_text( GTK_EDITABLE(entry), value, value.Length(), &pos );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||
if (value.IsNull()) return;
|
||||
gint pos = (gint)to;
|
||||
gtk_editable_insert_text( GTK_EDITABLE(entry), value, value.Length(), &pos );
|
||||
}
|
||||
|
||||
void wxComboBox::Remove(long from, long to)
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
|
||||
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||
}
|
||||
|
||||
void wxComboBox::SetSelection( long WXUNUSED(from), long WXUNUSED(to) )
|
||||
{
|
||||
wxFAIL_MSG( "wxComboBox::SetSelection not implemented" );
|
||||
wxFAIL_MSG( "wxComboBox::SetSelection not implemented" );
|
||||
}
|
||||
|
||||
void wxComboBox::SetEditable( bool WXUNUSED(editable) )
|
||||
{
|
||||
wxFAIL_MSG( "wxComboBox::SetEditable not implemented" );
|
||||
wxFAIL_MSG( "wxComboBox::SetEditable not implemented" );
|
||||
}
|
||||
|
||||
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_usize( GTK_COMBO(m_widget)->button, w, m_height );
|
||||
gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y );
|
||||
gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height );
|
||||
}
|
||||
|
||||
void wxComboBox::ApplyWidgetStyle()
|
||||
{
|
||||
SetWidgetStyle();
|
||||
SetWidgetStyle();
|
||||
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
|
||||
|
||||
GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
GList *child = list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
|
||||
GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
GList *child = list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
|
||||
|
||||
GtkBin *bin = GTK_BIN(child->data);
|
||||
gtk_widget_set_style( bin->child, m_widgetStyle );
|
||||
GtkBin *bin = GTK_BIN(child->data);
|
||||
gtk_widget_set_style( bin->child, m_widgetStyle );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget* wxComboBox::GetConnectWidget(void)
|
||||
GtkWidget* wxComboBox::GetConnectWidget()
|
||||
{
|
||||
return GTK_COMBO(m_widget)->entry;
|
||||
return GTK_COMBO(m_widget)->entry;
|
||||
}
|
||||
|
||||
bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
|
||||
{
|
||||
return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) ||
|
||||
(window == GTK_COMBO(m_widget)->button->window ) );
|
||||
return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) ||
|
||||
(window == GTK_COMBO(m_widget)->button->window ) );
|
||||
}
|
||||
|
@@ -29,31 +29,30 @@ extern bool g_blockEventsOnDrag;
|
||||
|
||||
static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox *listbox )
|
||||
{
|
||||
if (!listbox->HasVMT()) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
if (!listbox->HasVMT()) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
|
||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
|
||||
|
||||
wxArrayInt aSelections;
|
||||
int count = listbox->GetSelections(aSelections);
|
||||
if ( count > 0 )
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
event.m_commandInt = -1 ;
|
||||
event.m_commandString = copystring("") ;
|
||||
event.m_commandInt = -1 ;
|
||||
event.m_commandString = copystring("") ;
|
||||
}
|
||||
|
||||
event.SetEventObject( listbox );
|
||||
event.SetEventObject( listbox );
|
||||
|
||||
listbox->GetEventHandler()->ProcessEvent( event );
|
||||
if (event.m_commandString) delete[] event.m_commandString ;
|
||||
listbox->GetEventHandler()->ProcessEvent( event );
|
||||
if (event.m_commandString) delete[] event.m_commandString ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -62,425 +61,489 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl)
|
||||
|
||||
wxListBox::wxListBox(void)
|
||||
wxListBox::wxListBox()
|
||||
{
|
||||
m_list = (GtkList *) NULL;
|
||||
m_list = (GtkList *) NULL;
|
||||
}
|
||||
|
||||
bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
int n, const wxString choices[],
|
||||
long style, const wxValidator& validator, const wxString &name )
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
int n, const wxString choices[],
|
||||
long style, const wxValidator& validator, const wxString &name )
|
||||
{
|
||||
m_needParent = TRUE;
|
||||
m_needParent = TRUE;
|
||||
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
|
||||
SetValidator( validator );
|
||||
SetValidator( validator );
|
||||
|
||||
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
|
||||
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
|
||||
m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL );
|
||||
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
|
||||
|
||||
m_list = GTK_LIST( gtk_list_new() );
|
||||
m_list = GTK_LIST( gtk_list_new() );
|
||||
|
||||
GtkSelectionMode mode = GTK_SELECTION_BROWSE;
|
||||
if (style & wxLB_MULTIPLE)
|
||||
mode = GTK_SELECTION_MULTIPLE;
|
||||
else if (style & wxLB_EXTENDED)
|
||||
mode = GTK_SELECTION_EXTENDED;
|
||||
GtkSelectionMode mode = GTK_SELECTION_BROWSE;
|
||||
if (style & wxLB_MULTIPLE)
|
||||
mode = GTK_SELECTION_MULTIPLE;
|
||||
else if (style & wxLB_EXTENDED)
|
||||
mode = GTK_SELECTION_EXTENDED;
|
||||
|
||||
gtk_list_set_selection_mode( GTK_LIST(m_list), mode );
|
||||
gtk_list_set_selection_mode( GTK_LIST(m_list), mode );
|
||||
|
||||
gtk_container_add (GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
|
||||
gtk_widget_show( GTK_WIDGET(m_list) );
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
|
||||
gtk_widget_show( GTK_WIDGET(m_list) );
|
||||
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 100;
|
||||
if (newSize.y == -1) newSize.y = 110;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
wxSize newSize = size;
|
||||
if (newSize.x == -1) newSize.x = 100;
|
||||
if (newSize.y == -1) newSize.y = 110;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
list_item = gtk_list_item_new_with_label( choices[i] );
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
list_item = gtk_list_item_new_with_label( choices[i] );
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
||||
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
if (style & wxLB_MULTIPLE)
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
ConnectWidget( list_item );
|
||||
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
}
|
||||
|
||||
m_parent->AddChild( this );
|
||||
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
gtk_widget_realize( GTK_WIDGET(m_list) );
|
||||
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxListBox::~wxListBox()
|
||||
{
|
||||
wxNode *node = m_clientDataList.First();
|
||||
while (node)
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->Data();
|
||||
if (cd) delete cd;
|
||||
node = node->Next();
|
||||
}
|
||||
m_clientDataList.Clear();
|
||||
}
|
||||
|
||||
void wxListBox::AppendCommon( const wxString &item )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
if (style & wxLB_MULTIPLE)
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
if (GetWindowStyleFlag() & wxLB_MULTIPLE)
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
ConnectWidget( list_item );
|
||||
|
||||
m_clientData.Append( (wxObject*)NULL );
|
||||
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
}
|
||||
|
||||
m_parent->AddChild( this );
|
||||
|
||||
(m_parent->m_insertCallback)( m_parent, this );
|
||||
if (m_widgetStyle) ApplyWidgetStyle();
|
||||
|
||||
PostCreation();
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
gtk_widget_realize( GTK_WIDGET(m_list) );
|
||||
ConnectWidget( list_item );
|
||||
|
||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||
SetForegroundColour( parent->GetForegroundColour() );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
ConnectDnDWidget( list_item );
|
||||
}
|
||||
|
||||
void wxListBox::Append( const wxString &item )
|
||||
{
|
||||
Append( item, (char*)NULL );
|
||||
}
|
||||
|
||||
void wxListBox::Append( const wxString &item, char *clientData )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
if (GetWindowStyleFlag() & wxLB_MULTIPLE)
|
||||
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();
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
ConnectWidget( list_item );
|
||||
|
||||
ConnectDnDWidget( list_item );
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
void wxListBox::Clear(void)
|
||||
void wxListBox::Append( const wxString &item, void *clientData )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
if (clientData)
|
||||
m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
|
||||
else
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
gtk_list_clear_items( m_list, 0, Number() );
|
||||
void wxListBox::Append( const wxString &item, wxClientData *clientData )
|
||||
{
|
||||
m_clientDataList.Append( (wxObject*) clientData );
|
||||
|
||||
AppendCommon( item );
|
||||
}
|
||||
|
||||
m_clientData.Clear();
|
||||
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() );
|
||||
|
||||
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 )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
|
||||
if (!child)
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return;
|
||||
}
|
||||
if (!child)
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return;
|
||||
}
|
||||
|
||||
GList *list = g_list_append( NULL, child->data );
|
||||
gtk_list_remove_items( m_list, list );
|
||||
g_list_free( list );
|
||||
GList *list = g_list_append( NULL, child->data );
|
||||
gtk_list_remove_items( m_list, list );
|
||||
g_list_free( list );
|
||||
|
||||
wxNode *node = m_clientData.Nth( n );
|
||||
if (!node)
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
}
|
||||
else
|
||||
m_clientData.DeleteNode( node );
|
||||
wxNode *node = m_clientDataList.Nth( n );
|
||||
if (!node)
|
||||
{
|
||||
wxFAIL_MSG( "wrong index" );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxClientData *cd = (wxClientData*)node->Data();
|
||||
if (cd) delete cd;
|
||||
m_clientDataList.DeleteNode( node );
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::Deselect( int n )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
}
|
||||
|
||||
int wxListBox::FindString( const wxString &item ) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
if (item == label->label) return count;
|
||||
count++;
|
||||
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.
|
||||
|
||||
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
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxListBox::GetSelections(wxArrayInt& aSelections) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
// get the number of selected items first
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
for ( child = m_list->children; child != NULL; child = child->next )
|
||||
{
|
||||
if ( GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED )
|
||||
count++;
|
||||
}
|
||||
|
||||
aSelections.Empty();
|
||||
|
||||
if ( count > 0 ) {
|
||||
// now fill the list
|
||||
aSelections.Alloc(count); // optimization attempt
|
||||
int i = 0;
|
||||
for ( child = m_list->children; child != NULL; child = child->next, i++ )
|
||||
{
|
||||
if ( GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED )
|
||||
aSelections.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
wxString wxListBox::GetString( int n ) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
return label->label;
|
||||
}
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return "";
|
||||
}
|
||||
|
||||
wxString wxListBox::GetStringSelection(void) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
|
||||
|
||||
GList *selection = m_list->selection;
|
||||
if (selection)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( selection->data );
|
||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||
return tmp;
|
||||
}
|
||||
wxFAIL_MSG("no listbox selection available");
|
||||
return "";
|
||||
}
|
||||
|
||||
int wxListBox::Number(void)
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
}
|
||||
|
||||
bool wxListBox::Selected( int n )
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, FALSE, "invalid listbox" );
|
||||
|
||||
GList *target = g_list_nth( m_list->children, n );
|
||||
if (target)
|
||||
{
|
||||
GList *child = m_list->selection;
|
||||
while (child)
|
||||
{
|
||||
if (child->data == target->data) return TRUE;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
|
||||
{
|
||||
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
|
||||
}
|
||||
|
||||
void wxListBox::SetSelection( int n, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
if (select)
|
||||
gtk_list_select_item( m_list, n );
|
||||
else
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
}
|
||||
|
||||
void wxListBox::SetString( int n, const wxString &string )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
gtk_label_set( label, string );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::SetStringSelection( const wxString &string, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
SetSelection( FindString(string), select );
|
||||
}
|
||||
|
||||
int wxListBox::GetIndex( GtkWidget *item ) const
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (GTK_WIDGET(child->data) == item) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
if (item == label->label) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
// it's not an error if the string is not found -> no wxCHECK
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxListBox::GetSelection() const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int wxListBox::GetSelections( wxArrayInt& aSelections ) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
// get the number of selected items first
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
for (child = m_list->children; child != NULL; child = child->next)
|
||||
{
|
||||
if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED)
|
||||
count++;
|
||||
}
|
||||
|
||||
aSelections.Empty();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
// now fill the list
|
||||
aSelections.Alloc(count); // optimization attempt
|
||||
int i = 0;
|
||||
for (child = m_list->children; child != NULL; child = child->next, i++)
|
||||
{
|
||||
if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED)
|
||||
aSelections.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
wxString wxListBox::GetString( int n ) const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
return label->label;
|
||||
}
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return "";
|
||||
}
|
||||
|
||||
wxString wxListBox::GetStringSelection() const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, "", "invalid listbox" );
|
||||
|
||||
GList *selection = m_list->selection;
|
||||
if (selection)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( selection->data );
|
||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||
return tmp;
|
||||
}
|
||||
wxFAIL_MSG("no listbox selection available");
|
||||
return "";
|
||||
}
|
||||
|
||||
int wxListBox::Number()
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
}
|
||||
|
||||
bool wxListBox::Selected( int n )
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, FALSE, "invalid listbox" );
|
||||
|
||||
GList *target = g_list_nth( m_list->children, n );
|
||||
if (target)
|
||||
{
|
||||
GList *child = m_list->selection;
|
||||
while (child)
|
||||
{
|
||||
if (child->data == target->data) return TRUE;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
|
||||
{
|
||||
wxFAIL_MSG("wxListBox::Set not implemented");
|
||||
}
|
||||
|
||||
void wxListBox::SetFirstItem( int WXUNUSED(n) )
|
||||
{
|
||||
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
|
||||
}
|
||||
|
||||
void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
|
||||
{
|
||||
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
|
||||
}
|
||||
|
||||
void wxListBox::SetSelection( int n, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
if (select)
|
||||
gtk_list_select_item( m_list, n );
|
||||
else
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
}
|
||||
|
||||
void wxListBox::SetString( int n, const wxString &string )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GList *child = g_list_nth( m_list->children, n );
|
||||
if (child)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN( child->data );
|
||||
GtkLabel *label = GTK_LABEL( bin->child );
|
||||
gtk_label_set( label, string );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG("wrong listbox index");
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::SetStringSelection( const wxString &string, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
SetSelection( FindString(string), select );
|
||||
}
|
||||
|
||||
int wxListBox::GetIndex( GtkWidget *item ) const
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
GList *child = m_list->children;
|
||||
int count = 0;
|
||||
while (child)
|
||||
{
|
||||
if (GTK_WIDGET(child->data) == item) return count;
|
||||
count++;
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
wxCHECK_RET( m_list != NULL, "invalid listbox" );
|
||||
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
DisconnectDnDWidget( GTK_WIDGET( child->data ) );
|
||||
child = child->next;
|
||||
}
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
DisconnectDnDWidget( GTK_WIDGET( child->data ) );
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
wxWindow::SetDropTarget( dropTarget );
|
||||
wxWindow::SetDropTarget( dropTarget );
|
||||
|
||||
child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
ConnectDnDWidget( GTK_WIDGET( child->data ) );
|
||||
child = child->next;
|
||||
}
|
||||
child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
ConnectDnDWidget( GTK_WIDGET( child->data ) );
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *wxListBox::GetConnectWidget(void)
|
||||
GtkWidget *wxListBox::GetConnectWidget()
|
||||
{
|
||||
return GTK_WIDGET(m_list);
|
||||
return GTK_WIDGET(m_list);
|
||||
}
|
||||
|
||||
bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
|
||||
{
|
||||
if (wxWindow::IsOwnGtkWindow( window )) return TRUE;
|
||||
if (wxWindow::IsOwnGtkWindow( window )) return TRUE;
|
||||
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
GtkWidget *bin = GTK_WIDGET( child->data );
|
||||
if (bin->window == window) return TRUE;
|
||||
child = child->next;
|
||||
}
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
GtkWidget *bin = GTK_WIDGET( child->data );
|
||||
if (bin->window == window) return TRUE;
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxListBox::ApplyWidgetStyle()
|
||||
{
|
||||
SetWidgetStyle();
|
||||
SetWidgetStyle();
|
||||
|
||||
GdkWindow *window = GTK_WIDGET(m_list)->window;
|
||||
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
||||
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
||||
gdk_window_clear( window );
|
||||
GdkWindow *window = GTK_WIDGET(m_list)->window;
|
||||
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
|
||||
gdk_window_set_background( window, m_backgroundColour.GetColor() );
|
||||
gdk_window_clear( window );
|
||||
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_BIN(child->data)->child, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
|
||||
child = child->next;
|
||||
}
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_widget_set_style( GTK_BIN(child->data)->child, m_widgetStyle );
|
||||
gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
@@ -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,8 +1149,7 @@ 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_cursor = new wxCursor( wxCURSOR_ARROW );
|
||||
m_font = *wxSWISS_FONT;
|
||||
// m_backgroundColour = wxWHITE;
|
||||
// m_foregroundColour = wxBLACK;
|
||||
@@ -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()
|
||||
|
Reference in New Issue
Block a user