]> git.saurik.com Git - wxWidgets.git/commitdiff
Same as last one..
authorRobert Roebling <robert@roebling.de>
Sat, 30 May 1998 17:11:51 +0000 (17:11 +0000)
committerRobert Roebling <robert@roebling.de>
Sat, 30 May 1998 17:11:51 +0000 (17:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

15 files changed:
include/wx/gtk/combobox.h
include/wx/gtk1/combobox.h
include/wx/msw/tabctrl.h
src/Makefile.in
src/common/event.cpp
src/gtk/app.cpp
src/gtk/choice.cpp
src/gtk/tabctrl.cpp [new file with mode: 0644]
src/gtk/textctrl.cpp
src/gtk/window.cpp
src/gtk1/app.cpp
src/gtk1/choice.cpp
src/gtk1/tabctrl.cpp [new file with mode: 0644]
src/gtk1/textctrl.cpp
src/gtk1/window.cpp

index 355d08728114cc9ea220935c78e18e8aff08e15d..d63ebd233ec13cafd7e07c5cdc078f9633b60f43 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "wx/defs.h"
 #include "wx/object.h"
-#include "wx/list.h"
 #include "wx/control.h"
 
 //-----------------------------------------------------------------------------
 
 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__
index 355d08728114cc9ea220935c78e18e8aff08e15d..d63ebd233ec13cafd7e07c5cdc078f9633b60f43 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "wx/defs.h"
 #include "wx/object.h"
-#include "wx/list.h"
 #include "wx/control.h"
 
 //-----------------------------------------------------------------------------
 
 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__
index ff35c3ebcdd22b359499eeedd18af72f595e6c65..814f9cccf8b237a4634672f8c704e3d7770c7992 100644 (file)
@@ -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__
index 876e27bd9249c620e58ed7798fea902c23f612c8..ffa4beb64f4271262e3ffd4182c444fa6ec9068f 100644 (file)
@@ -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 \
index 25e3750a39221deb3f465bad3831c6add3572a4a..c6f1a9023b4efd9a21c03de3c370af148f1c055b 100644 (file)
@@ -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();
     }
index 391f5a8d1c7219b01508f0d4c4a3f43dda16ba42..8081fc3c04a7c53f2ea087095985355e01105fa0 100644 (file)
@@ -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
 
index a7c5ff028beceb3cea2b50f81b96cbc11325ac96..17535c188aa58027f36ea82f3fde7f323b0cec62 100644 (file)
@@ -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 (file)
index 0000000..a12cf6c
--- /dev/null
@@ -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
index 890393380a23f194868b134fee872e5b80737b38..01b1d4477f1bb43c363fdf85679a5019b0904e38 100644 (file)
@@ -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
index 1811e8892b8d4cb5837ed4ceb20c2c9cbac7a937..9b8cc2ee02eb970b92ed3fabb534381411b86439 100644 (file)
@@ -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 <math.h>
 #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)))
   {
index 391f5a8d1c7219b01508f0d4c4a3f43dda16ba42..8081fc3c04a7c53f2ea087095985355e01105fa0 100644 (file)
@@ -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
 
index a7c5ff028beceb3cea2b50f81b96cbc11325ac96..17535c188aa58027f36ea82f3fde7f323b0cec62 100644 (file)
@@ -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 (file)
index 0000000..a12cf6c
--- /dev/null
@@ -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
index 890393380a23f194868b134fee872e5b80737b38..01b1d4477f1bb43c363fdf85679a5019b0904e38 100644 (file)
@@ -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
index 1811e8892b8d4cb5837ed4ceb20c2c9cbac7a937..9b8cc2ee02eb970b92ed3fabb534381411b86439 100644 (file)
@@ -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 <math.h>
 #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)))
   {