From 7f4dc78d358e4f33fbc53d9d4469a735cf0fd19b Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 30 May 1998 17:11:51 +0000 Subject: [PATCH] Same as last one.. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/combobox.h | 71 +++++++- include/wx/gtk1/combobox.h | 71 +++++++- include/wx/msw/tabctrl.h | 6 +- src/Makefile.in | 5 +- src/common/event.cpp | 1 + src/gtk/app.cpp | 2 +- src/gtk/choice.cpp | 2 +- src/gtk/tabctrl.cpp | 329 +++++++++++++++++++++++++++++++++++++ src/gtk/textctrl.cpp | 15 +- src/gtk/window.cpp | 9 + src/gtk1/app.cpp | 2 +- src/gtk1/choice.cpp | 2 +- src/gtk1/tabctrl.cpp | 329 +++++++++++++++++++++++++++++++++++++ src/gtk1/textctrl.cpp | 15 +- src/gtk1/window.cpp | 9 + 15 files changed, 844 insertions(+), 24 deletions(-) create mode 100644 src/gtk/tabctrl.cpp create mode 100644 src/gtk1/tabctrl.cpp diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h index 355d087281..d63ebd233e 100644 --- a/include/wx/gtk/combobox.h +++ b/include/wx/gtk/combobox.h @@ -18,7 +18,6 @@ #include "wx/defs.h" #include "wx/object.h" -#include "wx/list.h" #include "wx/control.h" //----------------------------------------------------------------------------- @@ -27,8 +26,78 @@ class wxComboBox; +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +extern const char* wxComboBoxNameStr; +extern const char* wxEmptyString; + //----------------------------------------------------------------------------- // wxComboBox //----------------------------------------------------------------------------- +class wxComboBox: public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxComboBox) + + public: + inline wxComboBox(void) {} + + inline wxComboBox(wxWindow *parent, const wxWindowID id, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const int n = 0, const wxString choices[] = NULL, + const long style = 0, + const wxString& name = wxComboBoxNameStr) + { + Create(parent, id, value, pos, size, n, choices, style, name); + } + + bool Create(wxWindow *parent, const wxWindowID id, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const int n = 0, const wxString choices[] = NULL, + const long style = 0, + const wxString& name = wxComboBoxNameStr); + + // List functions + void Clear(void); + void Append( const wxString &item ); + void Append( const wxString &item, char* clientData ); + void Delete( const int n ); + int FindString( const wxString &item ); + char* GetClientData( const int n ); + void SetClientData( const int n, char * clientData ); + int GetSelection(void) const; + wxString GetString( const int n ) const; + wxString GetStringSelection(void) const; + int Number(void) const; + void SetSelection( const int n, const bool select = TRUE ); + + // Text field functions + wxString GetValue(void) const ; + void SetValue(const wxString& value); + + // Clipboard operations + void Copy(void); + void Cut(void); + void Paste(void); + void SetInsertionPoint(const long pos); + void SetInsertionPointEnd(void); + long GetInsertionPoint(void) const ; + long GetLastPosition(void) const ; + void Replace(const long from, const long to, const wxString& value); + void Remove(const long from, const long to); + void SetSelection(const long from, const long to); + void SetEditable(const bool editable); + + private: + + wxList m_clientData; + +}; + #endif // __GTKCOMBOBOXH__ diff --git a/include/wx/gtk1/combobox.h b/include/wx/gtk1/combobox.h index 355d087281..d63ebd233e 100644 --- a/include/wx/gtk1/combobox.h +++ b/include/wx/gtk1/combobox.h @@ -18,7 +18,6 @@ #include "wx/defs.h" #include "wx/object.h" -#include "wx/list.h" #include "wx/control.h" //----------------------------------------------------------------------------- @@ -27,8 +26,78 @@ class wxComboBox; +//----------------------------------------------------------------------------- +// global data +//----------------------------------------------------------------------------- + +extern const char* wxComboBoxNameStr; +extern const char* wxEmptyString; + //----------------------------------------------------------------------------- // wxComboBox //----------------------------------------------------------------------------- +class wxComboBox: public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxComboBox) + + public: + inline wxComboBox(void) {} + + inline wxComboBox(wxWindow *parent, const wxWindowID id, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const int n = 0, const wxString choices[] = NULL, + const long style = 0, + const wxString& name = wxComboBoxNameStr) + { + Create(parent, id, value, pos, size, n, choices, style, name); + } + + bool Create(wxWindow *parent, const wxWindowID id, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const int n = 0, const wxString choices[] = NULL, + const long style = 0, + const wxString& name = wxComboBoxNameStr); + + // List functions + void Clear(void); + void Append( const wxString &item ); + void Append( const wxString &item, char* clientData ); + void Delete( const int n ); + int FindString( const wxString &item ); + char* GetClientData( const int n ); + void SetClientData( const int n, char * clientData ); + int GetSelection(void) const; + wxString GetString( const int n ) const; + wxString GetStringSelection(void) const; + int Number(void) const; + void SetSelection( const int n, const bool select = TRUE ); + + // Text field functions + wxString GetValue(void) const ; + void SetValue(const wxString& value); + + // Clipboard operations + void Copy(void); + void Cut(void); + void Paste(void); + void SetInsertionPoint(const long pos); + void SetInsertionPointEnd(void); + long GetInsertionPoint(void) const ; + long GetLastPosition(void) const ; + void Replace(const long from, const long to, const wxString& value); + void Remove(const long from, const long to); + void SetSelection(const long from, const long to); + void SetEditable(const bool editable); + + private: + + wxList m_clientData; + +}; + #endif // __GTKCOMBOBOXH__ diff --git a/include/wx/msw/tabctrl.h b/include/wx/msw/tabctrl.h index ff35c3ebcd..814f9cccf8 100644 --- a/include/wx/msw/tabctrl.h +++ b/include/wx/msw/tabctrl.h @@ -141,8 +141,10 @@ class WXDLLEXPORT wxTabEvent: public wxCommandEvent typedef void (wxEvtHandler::*wxTabEventFunction)(wxTabEvent&); -#define EVT_TAB_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TAB_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn }, -#define EVT_TAB_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TAB_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn }, +#define EVT_TAB_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TAB_SEL_CHANGED, \ + id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn, NULL }, +#define EVT_TAB_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TAB_SEL_CHANGING, \ + id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTabEventFunction) & fn, NULL }, #endif // __TABCTRLH__ diff --git a/src/Makefile.in b/src/Makefile.in index 876e27bd92..ffa4beb64f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -20,8 +20,8 @@ NONE = # define library name LIB_TARGET=wx_gtk -LIB_MAJOR=0 -LIB_MINOR=12 +LIB_MAJOR=1 +LIB_MINOR=90 # define library sources @@ -93,6 +93,7 @@ LIB_CPP_SRC=\ gtk/statbox.cpp \ gtk/statbmp.cpp \ gtk/stattext.cpp \ + gtk/tabctrl.cpp \ gtk/tbargtk.cpp \ gtk/textctrl.cpp \ gtk/timer.cpp \ diff --git a/src/common/event.cpp b/src/common/event.cpp index 25e3750a39..c6f1a9023b 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -269,6 +269,7 @@ wxEvtHandler::~wxEvtHandler(void) while (node) { wxEventTableEntry *entry = (wxEventTableEntry*)node->Data(); + if (entry->m_callbackUserData) delete entry->m_callbackUserData; delete entry; node = node->Next(); } diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 391f5a8d1c..8081fc3c04 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -282,7 +282,7 @@ int wxEntry( int argc, char *argv[] ) // main() //----------------------------------------------------------------------------- -#if defined(AIX) || defined(AIX4) /* || defined(____HPUX__) */ +#if defined(AIX) || defined(AIX4) || defined(____HPUX__) // main in IMPLEMENT_WX_MAIN in IMPLEMENT_APP in app.h diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index a7c5ff028b..17535c188a 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -32,7 +32,7 @@ void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxWindow) +IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl) wxChoice::wxChoice(void) { diff --git a/src/gtk/tabctrl.cpp b/src/gtk/tabctrl.cpp new file mode 100644 index 0000000000..a12cf6ca59 --- /dev/null +++ b/src/gtk/tabctrl.cpp @@ -0,0 +1,329 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tabctrl.cpp +// Purpose: +// Author: Robert Roebling +// Created: 01/02/97 +// Id: +// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "tabctrl.h" +#endif + +#include "wx/tabctrl.h" +#include "wx/utils.h" +#include "wx/imaglist.h" + +#include "wx/gtk/win_gtk.h" + +//----------------------------------------------------------------------------- +// wxTabPage +//----------------------------------------------------------------------------- + +class wxTabPage: public wxObject +{ + public: + + int m_id; + wxString m_text; + int m_image; + void *m_clientData; + GtkNotebookPage *m_page; + GtkWidget *m_wxwindow; + wxList m_children; + + wxTabPage(void) + { + m_id = -1; + m_text = ""; + m_image = -1; + m_clientData = NULL; + m_page = NULL; + m_wxwindow = NULL; + }; + +}; + +//----------------------------------------------------------------------------- +// wxTabCtrl +//----------------------------------------------------------------------------- + +BEGIN_EVENT_TABLE(wxTabCtrl, wxControl) +END_EVENT_TABLE() + +IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl,wxControl) + +wxTabCtrl::wxTabCtrl(void) +{ + m_imageList = NULL; + m_pages.DeleteContents( TRUE ); +}; + +wxTabCtrl::wxTabCtrl( wxWindow *parent, const wxWindowID id, + const wxPoint& pos, const wxSize& size, + const long style, const wxString& name ) +{ + m_imageList = NULL; + m_pages.DeleteContents( TRUE ); + Create( parent, id, pos, size, style, name ); +}; + +wxTabCtrl::~wxTabCtrl(void) +{ + if (m_imageList) delete m_imageList; + DeleteAllItems(); +}; + +bool wxTabCtrl::Create(wxWindow *parent, const wxWindowID id, + const wxPoint& pos, const wxSize& size, + const long style, const wxString& name ) +{ + m_needParent = TRUE; + + PreCreation( parent, id, pos, size, style, name ); + + m_widget = gtk_notebook_new(); + + PostCreation(); + + Show( TRUE ); + + return TRUE; +}; + +int wxTabCtrl::GetSelection(void) const +{ + return gtk_notebook_current_page( GTK_NOTEBOOK(m_widget) ); +}; + +wxImageList* wxTabCtrl::GetImageList(void) const +{ + return m_imageList; +}; + +int wxTabCtrl::GetItemCount(void) const +{ + return m_pages.Number(); +}; + +bool wxTabCtrl::GetItemRect( const int WXUNUSED(item), wxRect& WXUNUSED(rect) ) const +{ + return FALSE; +}; + +int wxTabCtrl::GetRowCount(void) const +{ + return 1; +}; + +wxString wxTabCtrl::GetItemText( const int item ) const +{ + wxNode *node = m_pages.Nth( item ); + if (node) + { + wxTabPage *page = (wxTabPage*)node->Data(); + return page->m_text; + }; + return ""; +}; + +int wxTabCtrl::GetItemImage( const int item ) const +{ + wxNode *node = m_pages.Nth( item ); + if (node) + { + wxTabPage *page = (wxTabPage*)node->Data(); + return page->m_image; + }; + return -1; +}; + +void* wxTabCtrl::GetItemData( const int item ) const +{ + wxNode *node = m_pages.Nth( item ); + if (node) + { + wxTabPage *page = (wxTabPage*)node->Data(); + return page->m_clientData; + }; + return NULL; +}; + +int wxTabCtrl::SetSelection( const int item ) +{ + wxTabPage *page = NULL; + + wxNode *node = m_pages.First(); + while (node) + { + page = (wxTabPage*)node->Data(); + if (page->m_id == item) break; + page = NULL; + node = node->Next(); + }; + if (!page) return -1; + + int page_num = 0; + GList *child = GTK_NOTEBOOK(m_widget)->children; + while (child) + { + if (page->m_page == (GtkNotebookPage*)child->data) break; + page_num++; + child = child->next; + }; + + if (!child) return -1; + + gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page_num ); + + return item; +}; + +void wxTabCtrl::SetImageList( wxImageList* imageList ) +{ + m_imageList = imageList; +}; + +bool wxTabCtrl::SetItemText( const int WXUNUSED(item), const wxString& WXUNUSED(text) ) +{ + return TRUE; +}; + +bool wxTabCtrl::SetItemImage( const int WXUNUSED(item), const int WXUNUSED(image) ) +{ + return TRUE; +}; + +bool wxTabCtrl::SetItemData( const int WXUNUSED(item), void* WXUNUSED(data) ) +{ + return TRUE; +}; + +void wxTabCtrl::SetItemSize( const wxSize &WXUNUSED(size) ) +{ +}; + +void wxTabCtrl::SetPadding( const wxSize &WXUNUSED(padding) ) +{ +}; + +bool wxTabCtrl::DeleteAllItems(void) +{ + wxNode *page_node = m_pages.First(); + while (page_node) + { + wxTabPage *page = (wxTabPage*)page_node->Data(); + + wxNode *node = page->m_children.First(); + while (node) + { + wxWindow *child = (wxWindow*)node->Data(); + delete child; + + node = node->Next(); + }; + + gtk_widget_destroy( page->m_wxwindow ); + + m_pages.DeleteObject( page ); + + page_node = m_pages.First(); + }; + + return TRUE; +}; + +bool wxTabCtrl::DeleteItem( const int item ) +{ + wxTabPage *page = NULL; + + wxNode *node = m_pages.First(); + while (node) + { + page = (wxTabPage*)node->Data(); + if (page->m_id == item) break; + node = node->Next(); + }; + if (!node) return FALSE; + + node = page->m_children.First(); + while (node) + { + wxWindow *child = (wxWindow*)node->Data(); + delete child; + + node = node->Next(); + }; + + gtk_widget_destroy( page->m_wxwindow ); + + m_pages.DeleteObject( page ); + + return TRUE; +}; + +int wxTabCtrl::HitTest( const wxPoint &WXUNUSED(pt), long &WXUNUSED(flags) ) +{ + return wxTAB_HITTEST_NOWHERE; +}; + +int wxTabCtrl::InsertItem( const int item, const wxString &text, const int imageId, void* data ) +{ + wxTabPage *page = new wxTabPage; + + page->m_text = text; + if (page->m_text.IsNull()) page->m_text = ""; + page->m_id = item; + page->m_image = imageId; + page->m_clientData = data; + + GtkWidget *label_widget = gtk_label_new( page->m_text ); + gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 ); + + page->m_wxwindow = gtk_myfixed_new(); + gtk_widget_show( page->m_wxwindow ); + gtk_widget_set_usize( page->m_wxwindow, 100, 100 ); + + gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), page->m_wxwindow, label_widget ); + + page->m_page = GTK_NOTEBOOK(m_widget)->cur_page; + + m_pages.Append( page ); + + return item; +}; + +void wxTabCtrl::AddChild( wxWindow *win ) +{ + GtkNotebookPage *g_page = GTK_NOTEBOOK(m_widget)->cur_page; + + wxTabPage *page = NULL; + + wxNode *node = m_pages.First(); + while (node) + { + page = (wxTabPage*)node->Data(); + if (page->m_page == g_page) break; + node = node->Next(); + }; + + if (!page) wxFatalError( "wxTabCtrl error" ); + + gtk_myfixed_put( GTK_MYFIXED(page->m_wxwindow), win->m_widget, win->m_x, win->m_y ); + gtk_widget_set_usize( win->m_widget, win->m_width, win->m_height ); + + page->m_children.Append( win ); +}; + +//----------------------------------------------------------------------------- +// wxTabEvent +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent) + +wxTabEvent::wxTabEvent( WXTYPE commandType, int id ) : + wxCommandEvent(commandType, id) +{ +}; \ No newline at end of file diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 890393380a..01b1d4477f 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -50,12 +50,6 @@ bool wxTextCtrl::Create( wxWindow *parent, const wxWindowID id, const wxString & else m_widget = gtk_entry_new(); - if (!value.IsNull()) - { - gint tmp = 0; - gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length(), &tmp ); - }; - wxSize newSize = size; if (newSize.x == -1) newSize.x = 80; if (newSize.y == -1) newSize.y = 26; @@ -63,6 +57,12 @@ bool wxTextCtrl::Create( wxWindow *parent, const wxWindowID id, const wxString & PostCreation(); + if (!value.IsNull()) + { + gint tmp = 0; + gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length(), &tmp ); + }; + Show( TRUE ); return TRUE; @@ -103,9 +103,10 @@ void wxTextCtrl::SetValue( const wxString &value ) void wxTextCtrl::WriteText( const wxString &text ) { if (text.IsNull()) return; + if (m_windowStyle & wxTE_MULTILINE) { - gint len = gtk_text_get_length( GTK_TEXT(m_widget) ); + gint len = gtk_text_get_length( GTK_TEXT(m_widget) ) - 1; gtk_editable_insert_text( GTK_EDITABLE(m_widget), text, text.Length(), &len ); } else diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 1811e8892b..9b8cc2ee02 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -25,6 +25,7 @@ #include "wx/dcclient.h" #include "wx/dnd.h" #include "wx/mdi.h" +#include "wx/tabctrl.h" #include "gdk/gdkkeysyms.h" #include #include "wx/gtk/win_gtk.h" @@ -1413,6 +1414,14 @@ void wxWindow::AddChild( wxWindow *child ) }; }; }; + + if (IsKindOf(CLASSINFO(wxTabCtrl))) + { + wxTabCtrl *tab = (wxTabCtrl*)this; + tab->AddChild( child ); + return; + }; + m_children.Append( child ); if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog))) { diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 391f5a8d1c..8081fc3c04 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -282,7 +282,7 @@ int wxEntry( int argc, char *argv[] ) // main() //----------------------------------------------------------------------------- -#if defined(AIX) || defined(AIX4) /* || defined(____HPUX__) */ +#if defined(AIX) || defined(AIX4) || defined(____HPUX__) // main in IMPLEMENT_WX_MAIN in IMPLEMENT_APP in app.h diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index a7c5ff028b..17535c188a 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -32,7 +32,7 @@ void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxWindow) +IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl) wxChoice::wxChoice(void) { diff --git a/src/gtk1/tabctrl.cpp b/src/gtk1/tabctrl.cpp new file mode 100644 index 0000000000..a12cf6ca59 --- /dev/null +++ b/src/gtk1/tabctrl.cpp @@ -0,0 +1,329 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tabctrl.cpp +// Purpose: +// Author: Robert Roebling +// Created: 01/02/97 +// Id: +// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "tabctrl.h" +#endif + +#include "wx/tabctrl.h" +#include "wx/utils.h" +#include "wx/imaglist.h" + +#include "wx/gtk/win_gtk.h" + +//----------------------------------------------------------------------------- +// wxTabPage +//----------------------------------------------------------------------------- + +class wxTabPage: public wxObject +{ + public: + + int m_id; + wxString m_text; + int m_image; + void *m_clientData; + GtkNotebookPage *m_page; + GtkWidget *m_wxwindow; + wxList m_children; + + wxTabPage(void) + { + m_id = -1; + m_text = ""; + m_image = -1; + m_clientData = NULL; + m_page = NULL; + m_wxwindow = NULL; + }; + +}; + +//----------------------------------------------------------------------------- +// wxTabCtrl +//----------------------------------------------------------------------------- + +BEGIN_EVENT_TABLE(wxTabCtrl, wxControl) +END_EVENT_TABLE() + +IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl,wxControl) + +wxTabCtrl::wxTabCtrl(void) +{ + m_imageList = NULL; + m_pages.DeleteContents( TRUE ); +}; + +wxTabCtrl::wxTabCtrl( wxWindow *parent, const wxWindowID id, + const wxPoint& pos, const wxSize& size, + const long style, const wxString& name ) +{ + m_imageList = NULL; + m_pages.DeleteContents( TRUE ); + Create( parent, id, pos, size, style, name ); +}; + +wxTabCtrl::~wxTabCtrl(void) +{ + if (m_imageList) delete m_imageList; + DeleteAllItems(); +}; + +bool wxTabCtrl::Create(wxWindow *parent, const wxWindowID id, + const wxPoint& pos, const wxSize& size, + const long style, const wxString& name ) +{ + m_needParent = TRUE; + + PreCreation( parent, id, pos, size, style, name ); + + m_widget = gtk_notebook_new(); + + PostCreation(); + + Show( TRUE ); + + return TRUE; +}; + +int wxTabCtrl::GetSelection(void) const +{ + return gtk_notebook_current_page( GTK_NOTEBOOK(m_widget) ); +}; + +wxImageList* wxTabCtrl::GetImageList(void) const +{ + return m_imageList; +}; + +int wxTabCtrl::GetItemCount(void) const +{ + return m_pages.Number(); +}; + +bool wxTabCtrl::GetItemRect( const int WXUNUSED(item), wxRect& WXUNUSED(rect) ) const +{ + return FALSE; +}; + +int wxTabCtrl::GetRowCount(void) const +{ + return 1; +}; + +wxString wxTabCtrl::GetItemText( const int item ) const +{ + wxNode *node = m_pages.Nth( item ); + if (node) + { + wxTabPage *page = (wxTabPage*)node->Data(); + return page->m_text; + }; + return ""; +}; + +int wxTabCtrl::GetItemImage( const int item ) const +{ + wxNode *node = m_pages.Nth( item ); + if (node) + { + wxTabPage *page = (wxTabPage*)node->Data(); + return page->m_image; + }; + return -1; +}; + +void* wxTabCtrl::GetItemData( const int item ) const +{ + wxNode *node = m_pages.Nth( item ); + if (node) + { + wxTabPage *page = (wxTabPage*)node->Data(); + return page->m_clientData; + }; + return NULL; +}; + +int wxTabCtrl::SetSelection( const int item ) +{ + wxTabPage *page = NULL; + + wxNode *node = m_pages.First(); + while (node) + { + page = (wxTabPage*)node->Data(); + if (page->m_id == item) break; + page = NULL; + node = node->Next(); + }; + if (!page) return -1; + + int page_num = 0; + GList *child = GTK_NOTEBOOK(m_widget)->children; + while (child) + { + if (page->m_page == (GtkNotebookPage*)child->data) break; + page_num++; + child = child->next; + }; + + if (!child) return -1; + + gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page_num ); + + return item; +}; + +void wxTabCtrl::SetImageList( wxImageList* imageList ) +{ + m_imageList = imageList; +}; + +bool wxTabCtrl::SetItemText( const int WXUNUSED(item), const wxString& WXUNUSED(text) ) +{ + return TRUE; +}; + +bool wxTabCtrl::SetItemImage( const int WXUNUSED(item), const int WXUNUSED(image) ) +{ + return TRUE; +}; + +bool wxTabCtrl::SetItemData( const int WXUNUSED(item), void* WXUNUSED(data) ) +{ + return TRUE; +}; + +void wxTabCtrl::SetItemSize( const wxSize &WXUNUSED(size) ) +{ +}; + +void wxTabCtrl::SetPadding( const wxSize &WXUNUSED(padding) ) +{ +}; + +bool wxTabCtrl::DeleteAllItems(void) +{ + wxNode *page_node = m_pages.First(); + while (page_node) + { + wxTabPage *page = (wxTabPage*)page_node->Data(); + + wxNode *node = page->m_children.First(); + while (node) + { + wxWindow *child = (wxWindow*)node->Data(); + delete child; + + node = node->Next(); + }; + + gtk_widget_destroy( page->m_wxwindow ); + + m_pages.DeleteObject( page ); + + page_node = m_pages.First(); + }; + + return TRUE; +}; + +bool wxTabCtrl::DeleteItem( const int item ) +{ + wxTabPage *page = NULL; + + wxNode *node = m_pages.First(); + while (node) + { + page = (wxTabPage*)node->Data(); + if (page->m_id == item) break; + node = node->Next(); + }; + if (!node) return FALSE; + + node = page->m_children.First(); + while (node) + { + wxWindow *child = (wxWindow*)node->Data(); + delete child; + + node = node->Next(); + }; + + gtk_widget_destroy( page->m_wxwindow ); + + m_pages.DeleteObject( page ); + + return TRUE; +}; + +int wxTabCtrl::HitTest( const wxPoint &WXUNUSED(pt), long &WXUNUSED(flags) ) +{ + return wxTAB_HITTEST_NOWHERE; +}; + +int wxTabCtrl::InsertItem( const int item, const wxString &text, const int imageId, void* data ) +{ + wxTabPage *page = new wxTabPage; + + page->m_text = text; + if (page->m_text.IsNull()) page->m_text = ""; + page->m_id = item; + page->m_image = imageId; + page->m_clientData = data; + + GtkWidget *label_widget = gtk_label_new( page->m_text ); + gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 ); + + page->m_wxwindow = gtk_myfixed_new(); + gtk_widget_show( page->m_wxwindow ); + gtk_widget_set_usize( page->m_wxwindow, 100, 100 ); + + gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), page->m_wxwindow, label_widget ); + + page->m_page = GTK_NOTEBOOK(m_widget)->cur_page; + + m_pages.Append( page ); + + return item; +}; + +void wxTabCtrl::AddChild( wxWindow *win ) +{ + GtkNotebookPage *g_page = GTK_NOTEBOOK(m_widget)->cur_page; + + wxTabPage *page = NULL; + + wxNode *node = m_pages.First(); + while (node) + { + page = (wxTabPage*)node->Data(); + if (page->m_page == g_page) break; + node = node->Next(); + }; + + if (!page) wxFatalError( "wxTabCtrl error" ); + + gtk_myfixed_put( GTK_MYFIXED(page->m_wxwindow), win->m_widget, win->m_x, win->m_y ); + gtk_widget_set_usize( win->m_widget, win->m_width, win->m_height ); + + page->m_children.Append( win ); +}; + +//----------------------------------------------------------------------------- +// wxTabEvent +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent) + +wxTabEvent::wxTabEvent( WXTYPE commandType, int id ) : + wxCommandEvent(commandType, id) +{ +}; \ No newline at end of file diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 890393380a..01b1d4477f 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -50,12 +50,6 @@ bool wxTextCtrl::Create( wxWindow *parent, const wxWindowID id, const wxString & else m_widget = gtk_entry_new(); - if (!value.IsNull()) - { - gint tmp = 0; - gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length(), &tmp ); - }; - wxSize newSize = size; if (newSize.x == -1) newSize.x = 80; if (newSize.y == -1) newSize.y = 26; @@ -63,6 +57,12 @@ bool wxTextCtrl::Create( wxWindow *parent, const wxWindowID id, const wxString & PostCreation(); + if (!value.IsNull()) + { + gint tmp = 0; + gtk_editable_insert_text( GTK_EDITABLE(m_widget), value, value.Length(), &tmp ); + }; + Show( TRUE ); return TRUE; @@ -103,9 +103,10 @@ void wxTextCtrl::SetValue( const wxString &value ) void wxTextCtrl::WriteText( const wxString &text ) { if (text.IsNull()) return; + if (m_windowStyle & wxTE_MULTILINE) { - gint len = gtk_text_get_length( GTK_TEXT(m_widget) ); + gint len = gtk_text_get_length( GTK_TEXT(m_widget) ) - 1; gtk_editable_insert_text( GTK_EDITABLE(m_widget), text, text.Length(), &len ); } else diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 1811e8892b..9b8cc2ee02 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -25,6 +25,7 @@ #include "wx/dcclient.h" #include "wx/dnd.h" #include "wx/mdi.h" +#include "wx/tabctrl.h" #include "gdk/gdkkeysyms.h" #include #include "wx/gtk/win_gtk.h" @@ -1413,6 +1414,14 @@ void wxWindow::AddChild( wxWindow *child ) }; }; }; + + if (IsKindOf(CLASSINFO(wxTabCtrl))) + { + wxTabCtrl *tab = (wxTabCtrl*)this; + tab->AddChild( child ); + return; + }; + m_children.Append( child ); if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog))) { -- 2.45.2