]> git.saurik.com Git - wxWidgets.git/commitdiff
stream compile fixes
authorRobert Roebling <robert@roebling.de>
Sun, 12 Jul 1998 20:06:59 +0000 (20:06 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 12 Jul 1998 20:06:59 +0000 (20:06 +0000)
bitmap, icon, imaglist work (broken)
notebook client resize fixed (ugly)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@237 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

25 files changed:
include/wx/generic/imaglist.h
include/wx/gtk/bitmap.h
include/wx/gtk/frame.h
include/wx/gtk/icon.h
include/wx/gtk/notebook.h
include/wx/gtk1/bitmap.h
include/wx/gtk1/frame.h
include/wx/gtk1/icon.h
include/wx/gtk1/notebook.h
include/wx/mstream.h
include/wx/stream.h
samples/controls/controls.cpp
src/common/datstrm.cpp
src/common/mstream.cpp
src/common/stream.cpp
src/generic/imaglist.cpp
src/gtk/bitmap.cpp
src/gtk/frame.cpp
src/gtk/icon.cpp
src/gtk/notebook.cpp
src/gtk1/bitmap.cpp
src/gtk1/frame.cpp
src/gtk1/icon.cpp
src/gtk1/notebook.cpp
user/wxLayout/wxllist.h

index 6bf2ed745525d36af92343bc233f22aebffd47c1..2a0893a3ac18b073195c18c390885d2b35167ad9 100644 (file)
@@ -47,7 +47,7 @@ class wxImageList: public wxObject
   public:
 
     wxImageList::wxImageList() { }
-    wxImageList(int width, int height, bool mask = TRUE, int initialCount = 1);
+    wxImageList( int width, int height, bool mask = TRUE, int initialCount = 1 );
     ~wxImageList();
     bool Create();
     int GetImageCount() const;
@@ -62,6 +62,8 @@ class wxImageList: public wxObject
   private:
 
     wxList  m_images;
+    int     m_width;
+    int     m_height;
 };
 
 #endif  // __IMAGELISTH_G__
index 876eba22490bcf294c5c2d0501e35035bd863c45..94795def8e317e80cd18dc76e87c586d90721abd 100644 (file)
@@ -102,6 +102,8 @@ class wxBitmap: public wxObject
     wxMask *GetMask(void) const;
     void SetMask( wxMask *mask );
     
+    void Resize( int height, int width );
+    
     bool SaveFile( const wxString &name, int type, wxPalette *palette = NULL );
     bool LoadFile( const wxString &name, int type );
 
@@ -121,6 +123,10 @@ class wxBitmap: public wxObject
     GdkPixmap *GetPixmap(void) const;
     GdkBitmap *GetBitmap(void) const;
     
+    void DestroyImage(void);
+    void RecreateImage(void);
+    void Render(void);
+    
     // no data :-)
 };
 
index 42b6adb9a9f3d9c8b1801e7a446950d21d5e1aa5..517edc95069851ef95f9823f62831aff8975edec 100644 (file)
@@ -70,7 +70,9 @@ class wxFrame: public wxWindow
     wxString GetTitle(void) const;
     void OnActivate( wxActivateEvent &WXUNUSED(event) ) {};
     
-    void GtkOnSize( int width, int height );
+  //private:    
+    
+    void GtkOnSize( int x, int y, int width, int height );
     
   private:
   
index 2d9ee3752277c83be0feb14c6632486158535599..a79e4906efbcd2ae00a4d9305feb91ac715e8cc7 100644 (file)
@@ -40,11 +40,8 @@ public:
 
   inline wxIcon(const wxIcon& icon) { Ref(icon); }
   inline wxIcon(const wxIcon* icon) { if (icon) Ref(*icon); }
+  wxIcon( char **bits, int width=-1, int height=-1 );
   
-  // Don't change this. Robert.
-  wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
-    wxBitmap( bits ) {};
-    
   inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
   inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
   inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
index bea1b55ffa33a4149a21c41ce43a8e4752baedba..51b228aee015316e7119a19367c8fe117730de26 100644 (file)
@@ -31,6 +31,7 @@ class wxNotebookPage;
 // ----------------------------------------------------------------------------
 // notebook events
 // ----------------------------------------------------------------------------
+
 class wxNotebookEvent : public wxCommandEvent
 {
 public:
@@ -139,10 +140,6 @@ public:
   // base class virtuals
   virtual void AddChild(wxWindow *child);
 
-protected:
-  // wxWin callbacks
-  void OnSize(wxSizeEvent& event);
-
 private:
   // common part of all ctors
   void Init();
index 876eba22490bcf294c5c2d0501e35035bd863c45..94795def8e317e80cd18dc76e87c586d90721abd 100644 (file)
@@ -102,6 +102,8 @@ class wxBitmap: public wxObject
     wxMask *GetMask(void) const;
     void SetMask( wxMask *mask );
     
+    void Resize( int height, int width );
+    
     bool SaveFile( const wxString &name, int type, wxPalette *palette = NULL );
     bool LoadFile( const wxString &name, int type );
 
@@ -121,6 +123,10 @@ class wxBitmap: public wxObject
     GdkPixmap *GetPixmap(void) const;
     GdkBitmap *GetBitmap(void) const;
     
+    void DestroyImage(void);
+    void RecreateImage(void);
+    void Render(void);
+    
     // no data :-)
 };
 
index 42b6adb9a9f3d9c8b1801e7a446950d21d5e1aa5..517edc95069851ef95f9823f62831aff8975edec 100644 (file)
@@ -70,7 +70,9 @@ class wxFrame: public wxWindow
     wxString GetTitle(void) const;
     void OnActivate( wxActivateEvent &WXUNUSED(event) ) {};
     
-    void GtkOnSize( int width, int height );
+  //private:    
+    
+    void GtkOnSize( int x, int y, int width, int height );
     
   private:
   
index 2d9ee3752277c83be0feb14c6632486158535599..a79e4906efbcd2ae00a4d9305feb91ac715e8cc7 100644 (file)
@@ -40,11 +40,8 @@ public:
 
   inline wxIcon(const wxIcon& icon) { Ref(icon); }
   inline wxIcon(const wxIcon* icon) { if (icon) Ref(*icon); }
+  wxIcon( char **bits, int width=-1, int height=-1 );
   
-  // Don't change this. Robert.
-  wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
-    wxBitmap( bits ) {};
-    
   inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
   inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
   inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
index bea1b55ffa33a4149a21c41ce43a8e4752baedba..51b228aee015316e7119a19367c8fe117730de26 100644 (file)
@@ -31,6 +31,7 @@ class wxNotebookPage;
 // ----------------------------------------------------------------------------
 // notebook events
 // ----------------------------------------------------------------------------
+
 class wxNotebookEvent : public wxCommandEvent
 {
 public:
@@ -139,10 +140,6 @@ public:
   // base class virtuals
   virtual void AddChild(wxWindow *child);
 
-protected:
-  // wxWin callbacks
-  void OnSize(wxSizeEvent& event);
-
 private:
   // common part of all ctors
   void Init();
index 9cc7aab26a5404b167ff5ccf8a1550317af3c0b2..716c8099673a11bfb622d843d533a6f5255042ab 100644 (file)
@@ -11,7 +11,8 @@
 #ifndef __WXMMSTREAM_H__
 #define __WXMMSTREAM_H__
 
-#include <wx/stream.h>
+#include "wx/object.h"
+#include "wx/stream.h"
 
 class wxMemoryStreamBase: public wxStream {
   DECLARE_CLASS(wxMemoryStreamBase)
index a0800e136807160473448c1f67fdba8d6172358c..8ee9d1b8df49f8dd225b5c4078d1558bacb8ca79 100644 (file)
@@ -91,7 +91,7 @@ class wxFilterInputStream: public wxInputStream {
   wxInputStream *m_parent_i_stream;
 };
 
-class wxFilterOuputStream: pubilc wxOutputStream {
+class wxFilterOutputStream: public wxOutputStream {
   DECLARE_CLASS(wxFilterOutputStream)
  public:
   wxFilterOutputStream(wxOutputStream& stream);
@@ -102,8 +102,8 @@ class wxFilterOuputStream: pubilc wxOutputStream {
   virtual size_t SeekO(int pos, wxWhenceType whence = wxBeginPosition)
      { return m_parent_o_stream->SeekO(pos, whence); }
 
-  virtual bool Eof() const { return m_parent_o_sream->Eof(); }
-  virtual size_t LastRead() const { return m_parent_o_stream->LastRead(); }
+  virtual bool Bad() const { return m_parent_o_stream->Bad(); }
+  virtual size_t LastWrite() const { return m_parent_o_stream->LastWrite(); }
 
  protected:
   wxOutputStream *m_parent_o_stream;
index 004eff2b84dabcce5771cde67f542dc5eb8f7741..7db58c82196efc4113d5f4af1cf23e25115bbf2f 100644 (file)
@@ -133,6 +133,8 @@ const  ID_CHOICE_APPEND     = 124;
 
 const  ID_COMBO             = 140;
 
+const  ID_TEXT              = 150;
+
 BEGIN_EVENT_TABLE(MyPanel, wxPanel)
   EVT_SIZE      (                       MyPanel::OnSize)
   EVT_LISTBOX   (ID_LISTBOX,            MyPanel::OnListBox)
@@ -177,6 +179,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   panel = new wxPanel(m_notebook);
   m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 9, choices );
   m_notebook->AddPage(panel, "wxComboBox");
+  
+  wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(0,20), wxSize(120,100), wxTE_MULTILINE );
+  m_notebook->AddPage( text, "wxTextCtrl" );
 }
 
 void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
index f4ccc714a42e19bd0fac37c0e2847186a0e7ea33..15a5ef78a8e74e92e6573546149534cb1364cd6b 100644 (file)
@@ -44,7 +44,7 @@ unsigned long wxDataInputStream::Read32()
 {
   char buf[4];
 
-  if (!m_istream)
+  if (!m_parent_i_stream)
     return 0;
 
   Read(buf, 4);
@@ -59,7 +59,7 @@ unsigned short wxDataInputStream::Read16()
 {
   char buf[2];
 
-  if (!m_istream)
+  if (!m_parent_i_stream)
     return 0;
 
   Read(buf, 2);
@@ -72,7 +72,7 @@ unsigned char wxDataInputStream::Read8()
 {
   char buf;
 
-  if (!m_istream)
+  if (!m_parent_i_stream)
     return 0;
 
   Read(&buf, 1);
@@ -87,7 +87,7 @@ double wxDataInputStream::ReadDouble()
 #if USE_APPLE_IEEE
   char buf[10];
 
-  if (!m_istream)
+  if (!m_parent_i_stream)
     return 0.0;
 
   Read(buf, 10);
@@ -101,7 +101,7 @@ wxString wxDataInputStream::ReadLine()
 {
   char i_strg[255];
 
-  if (!m_istream)
+  if (!m_parent_i_stream)
     return "";
 
   // TODO: Implement ReadLine
@@ -114,7 +114,7 @@ wxString wxDataInputStream::ReadString()
   char *string;
   unsigned long len;
 
-  if (!m_istream)
+  if (!m_parent_i_stream)
     return "";
 
   len = Read32();
@@ -138,7 +138,7 @@ void wxDataOutputStream::Write32(unsigned long i)
 {
   char buf[4];
 
-  if (!m_ostream)
+  if (!m_parent_o_stream)
     return;
 
   buf[0] = i & 0xff;
@@ -152,7 +152,7 @@ void wxDataOutputStream::Write16(unsigned short i)
 {
   char buf[2];
 
-  if (!m_ostream)
+  if (!m_parent_o_stream)
     return;
 
   buf[0] = i & 0xff;
@@ -162,7 +162,7 @@ void wxDataOutputStream::Write16(unsigned short i)
 
 void wxDataOutputStream::Write8(unsigned char i)
 {
-  if (!m_ostream)
+  if (!m_parent_o_stream)
     return;
 
   Write(&i, 1);
@@ -176,7 +176,7 @@ void wxDataOutputStream::WriteLine(const wxString& line)
   wxString tmp_string = line + '\n';
 #endif
 
-  if (!m_ostream)
+  if (!m_parent_o_stream)
     return;
 
   Write((const char *) tmp_string, tmp_string.Length());
@@ -184,7 +184,7 @@ void wxDataOutputStream::WriteLine(const wxString& line)
 
 void wxDataOutputStream::WriteString(const wxString& string)
 {
-  if (!m_ostream)
+  if (!m_parent_o_stream)
     return;
 
   Write32(string.Length());
@@ -198,7 +198,7 @@ void wxDataOutputStream::WriteDouble(double d)
 {
   char buf[10];
 
-  if (!m_ostream)
+  if (!m_parent_o_stream)
     return;
 
 #if USE_APPLE_IEEE
index 7bed3cbf118fc8778eb01faff1a79f24b00ab901..2bfa364e1ea80409943ddad0e0d766d5f03a634c 100644 (file)
 #endif
 
 #include <stdlib.h>
-#include <wx/stream.h>
-#include <wx/mstream.h>
+#include "wx/stream.h"
+#include "wx/mstream.h"
 
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_CLASS(wxMemoryStreamBase, wxStream)
 IMPLEMENT_CLASS(wxMemoryInputStream, wxMemoryStreamBase)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryOutputStream, wxMemoryStreamBase)
-IMPLEMENT_DYNAMIC_CLASS(wxMemoryStream, wxMemoryStreamBase)
+//IMPLEMENT_DYNAMIC_CLASS(wxMemoryOutputStream, wxMemoryStreamBase)
+//IMPLEMENT_DYNAMIC_CLASS(wxMemoryStream, wxMemoryStreamBase)
 #endif
 
 wxMemoryStreamBase::wxMemoryStreamBase(char *data, size_t length, int iolimit)
index fc7bcc8b9af4eafafc2c5f3af304e8bc6655cfa1..b438c2b386b4e525bdd756c200d50a0ab6e6f76a 100644 (file)
@@ -13,8 +13,8 @@
 #pragma implementation "stream.h"
 #endif
 
-#include <wx/object.h>
-#include "stream.h"
+#include "wx/object.h"
+#include "wx/stream.h"
 
 #if !USE_SHARED_LIBRARY
 IMPLEMENT_ABSTRACT_CLASS(wxInputStream, wxObject)
@@ -65,9 +65,19 @@ wxOutputStream& wxOutputStream::Write(wxInputStream& stream_in)
 wxFilterInputStream::wxFilterInputStream(wxInputStream& stream)
   : wxInputStream()
 {
-  m_parent_stream = &stream;
+  m_parent_i_stream = &stream;
 }
 
 wxFilterInputStream::~wxFilterInputStream()
 {
 }
+
+wxFilterOutputStream::wxFilterOutputStream(wxOutputStream& stream)
+  : wxOutputStream()
+{
+  m_parent_o_stream = &stream;
+}
+
+wxFilterOutputStream::~wxFilterOutputStream()
+{
+}
index 103d86d9e5ce8dcddc56130a7479660e011139a4..61819c387aba02e92c09219ef7e689ce7cca33ad 100644 (file)
 
 IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject)
 
-wxImageList::wxImageList(int width, int height, bool mask, int initialCount)
+wxImageList::wxImageList( int width, int height, bool WXUNUSED(mask), int WXUNUSED(initialCount) )
 {
+  m_width = width;
+  m_height = height;
   Create();
 };
 
@@ -81,6 +83,15 @@ bool wxImageList::RemoveAll()
 
 bool wxImageList::GetSize( int index, int &width, int &height ) const
 {
+#ifdef __WXGTK__
+
+  width = m_width;
+  height = m_height;
+  
+  return (m_images.Nth( index ) != NULL);
+  
+#else
+  
   wxNode *node = m_images.Nth( index );
   if (node)
   {
@@ -95,17 +106,33 @@ bool wxImageList::GetSize( int index, int &width, int &height ) const
     height = 0;
     return FALSE;
   };
+
+#endif  
 };
 
-bool wxImageList::Draw( int index, wxDC &dc, 
-                        int x, int y,
-                        int WXUNUSED(flags), bool WXUNUSED(solidBackground) )
+bool wxImageList::Draw( int index, wxDC &dc, int x, int y,
+                        int flags, bool WXUNUSED(solidBackground) )
 {
   wxNode *node = m_images.Nth( index );
   if (!node) return FALSE;
   wxBitmap *bm = (wxBitmap*)node->Data();
+  
+#ifdef __WXGTK__
+
+  // As X doesn't have a standard size for icons, we resize here.
+  // Otherwise we'd simply have to forbid different bitmap sizes.
+
+  if ((m_width != bm->GetWidth()) ||
+      (m_height != bm->GetHeight()))
+  {
+    bm->Resize( m_width, m_height );
+  };
+  
+#endif  
+  
   wxIcon *icon = (wxIcon*)bm;
-  dc.DrawIcon( *icon, x, y );
+  dc.DrawIcon( *icon, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 );
+
   return TRUE;
 };
 
index eb09743ab82a986cbc9b3a59e0a73f5db6cee0d7..05c3136acc931d021e1589e97e9bc9ede7f71add 100644 (file)
@@ -74,6 +74,9 @@ class wxBitmapRefData: public wxObjectRefData
     int             m_width;
     int             m_height;
     int             m_bpp;
+#ifdef USE_GDK_IMLIB
+    GdkImlibImage  *m_image;
+#endif
     wxPalette      *m_palette;
 };
 
@@ -92,10 +95,11 @@ wxBitmapRefData::~wxBitmapRefData(void)
 {
 #ifdef USE_GDK_IMLIB
   if (m_pixmap) gdk_imlib_free_pixmap( m_pixmap );
+  if (m_image) gdk_imlib_destroy_image( m_image );
 #else
   if (m_pixmap) gdk_pixmap_unref( m_pixmap );
-  if (m_bitmap) gdk_bitmap_unref( m_bitmap );
 #endif
+  if (m_bitmap) gdk_bitmap_unref( m_bitmap );
   if (m_mask) delete m_mask;
   if (m_palette) delete m_palette;
 };
@@ -126,22 +130,26 @@ wxBitmap::wxBitmap( int width, int height, int depth )
 wxBitmap::wxBitmap( char **bits )
 {
   m_refData = new wxBitmapRefData();
-  
-  GdkBitmap *mask = NULL;
 
 #ifndef USE_GDK_IMLIB
+
+  GdkBitmap *mask = NULL;
+  
   M_BMPDATA->m_pixmap = 
     gdk_pixmap_create_from_xpm_d( (GdkWindow*) &gdk_root_parent, &mask, NULL, (gchar **) bits );
-#else
-  M_BMPDATA->m_pixmap = NULL;
-  int res = gdk_imlib_data_to_pixmap( bits, &M_BMPDATA->m_pixmap, &mask );
-#endif
-  
+    
   if (mask)
   {
     M_BMPDATA->m_mask = new wxMask();
     M_BMPDATA->m_mask->m_bitmap = mask;
   };
+  
+#else
+
+  M_BMPDATA->m_image = gdk_imlib_create_image_from_xpm_data( bits );
+  Render();
+  
+#endif
                                  
   gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
   M_BMPDATA->m_bpp = 24; // ?
@@ -248,19 +256,57 @@ void wxBitmap::SetDepth( int depth )
 wxMask *wxBitmap::GetMask(void) const
 {
   if (!Ok()) return NULL;
+  
   return M_BMPDATA->m_mask;
 };
 
 void wxBitmap::SetMask( wxMask *mask )
 {
   if (!Ok()) return;
+  
   if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
   M_BMPDATA->m_mask = mask;
 };
 
-bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type), 
+void wxBitmap::Resize( int height, int width )
+{
+  if (!Ok()) return;
+  
+  return;
+  
+#ifdef USE_GDK_IMLIB
+  
+  if (M_BMPDATA->m_bitmap) return;  // not supported for bitmaps
+  
+  if (!M_BMPDATA->m_image) RecreateImage();
+  
+  if (M_BMPDATA->m_pixmap) gdk_imlib_free_pixmap( M_BMPDATA->m_pixmap );
+  if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
+  
+  GdkImlibImage* image = gdk_imlib_clone_scaled_image( M_BMPDATA->m_image, height, width );
+  gdk_imlib_destroy_image( M_BMPDATA->m_image );
+  M_BMPDATA->m_image = image;
+  M_BMPDATA->m_height = height;
+  M_BMPDATA->m_width = width;
+  
+  Render();
+  
+#endif
+};
+
+bool wxBitmap::SaveFile( const wxString &name, int WXUNUSED(type), 
   wxPalette *WXUNUSED(palette) )
 {
+#ifdef USE_GDK_IMLIB
+
+  if (!Ok()) return FALSE;
+  
+  if (!M_BMPDATA->m_image) RecreateImage();
+  
+  return gdk_imlib_save_image( M_BMPDATA->m_image, WXSTRINGCAST name, NULL );
+
+#endif
+
   return FALSE;
 };
 
@@ -270,23 +316,16 @@ bool wxBitmap::LoadFile( const wxString &name, int WXUNUSED(type) )
 
   UnRef();
   m_refData = new wxBitmapRefData();
-  M_BMPDATA->m_mask = NULL;
-
-  GdkBitmap *mask = NULL;
   
-  int res = gdk_imlib_load_file_to_pixmap( WXSTRINGCAST name, &M_BMPDATA->m_pixmap, &mask );
+  M_BMPDATA->m_image = gdk_imlib_load_image( WXSTRINGCAST name );
 
-  if (res != 1)
+  if (!M_BMPDATA->m_image)
   {
     UnRef();
     return FALSE;
   };
 
-  if (mask)
-  {
-    M_BMPDATA->m_mask = new wxMask();
-    M_BMPDATA->m_mask->m_bitmap = mask;
-  }
+  Render();
                                  
   gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
   M_BMPDATA->m_bpp = 24; // ?
@@ -312,6 +351,42 @@ GdkPixmap *wxBitmap::GetPixmap(void) const
 GdkBitmap *wxBitmap::GetBitmap(void) const
 {
   if (!Ok()) return NULL;
+  
   return M_BMPDATA->m_bitmap;
 };
   
+void wxBitmap::DestroyImage(void)
+{
+  if (!Ok()) return;
+  
+  if (M_BMPDATA->m_image)
+  {
+    gdk_imlib_destroy_image( M_BMPDATA->m_image );
+    M_BMPDATA->m_image = NULL;
+  };
+};
+
+void wxBitmap::RecreateImage(void)
+{
+};
+
+void wxBitmap::Render(void)
+{
+  if (!Ok()) return;
+  
+#ifdef USE_GDK_IMLIB
+
+  gdk_imlib_render( M_BMPDATA->m_image, M_BMPDATA->m_image->rgb_width, M_BMPDATA->m_image->rgb_height );
+  
+  M_BMPDATA->m_pixmap = gdk_imlib_move_image( M_BMPDATA->m_image );
+  GdkBitmap *mask = gdk_imlib_move_mask( M_BMPDATA->m_image );
+  if (mask)
+  {
+    M_BMPDATA->m_mask = new wxMask();
+    M_BMPDATA->m_mask->m_bitmap = mask;
+  };
+  
+#endif
+};
+
+
index e78e9679b6b8ad2376e4a9d55221b1d5a6e20455..075ed1e7f6dc0cdc8203806668a78312ede08462 100644 (file)
@@ -42,7 +42,7 @@ void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc,
   printf( ".\n" );
 */
 
-  win->GtkOnSize( alloc->width, alloc->height );
+  win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height );
 };
 
 //-----------------------------------------------------------------------------
@@ -194,8 +194,11 @@ void wxFrame::GetClientSize( int *width, int *height ) const
   };
 };
 
-void wxFrame::GtkOnSize( int width, int height )
+void wxFrame::GtkOnSize( int x, int y, int width, int height )
 {
+  m_x = x;
+  m_y = y;
+
   if ((m_height == height) && (m_width == width) &&
       (m_sizeSet)) return;
   if (!m_mainWindow) return;
index a65627746cd31285c5c35f1010a472c8015c5247..7ab44845375870a4f734f40d79b1ff40c85d8da0 100644 (file)
@@ -20,3 +20,8 @@
 
 IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap)
 
+wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
+    wxBitmap( bits ) 
+{
+};
+    
index eb1ac6d1b55a4f2d56dd689b14493c2564c12113..4021fcaf49d543d9076fc936f5c3eb0a9cf1b943 100644 (file)
 #include "wx/intl.h"
 #include "wx/log.h"
 
+//-----------------------------------------------------------------------------
+// wxNotebookPage
+//-----------------------------------------------------------------------------
+
+class wxNotebookPage: public wxObject
+{
+public:
+  wxNotebookPage()
+  {
+    m_id = -1;
+    m_text = "";
+    m_image = -1;
+    m_page = NULL;
+    m_client = NULL;
+    m_parent = NULL;
+  };
+
+//private:
+  int                m_id;
+  wxString           m_text;
+  int                m_image;
+  GtkNotebookPage   *m_page;
+  GtkLabel          *m_label;
+  wxWindow          *m_client;
+  GtkNotebook       *m_parent;
+};
+
 //-----------------------------------------------------------------------------
 // GTK callbacks
 //-----------------------------------------------------------------------------
 
 // page change callback
-static void gtk_notebook_page_change_callback(GtkNotebook *widget,
-                                              GtkNotebookPage *page,
+static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
+                                              GtkNotebookPage *WXUNUSED(page),
                                               gint nPage,
                                               gpointer data)
 {
@@ -42,29 +69,24 @@ static void gtk_notebook_page_change_callback(GtkNotebook *widget,
   notebook->ProcessEvent(event);
 }
 
-//-----------------------------------------------------------------------------
-// wxNotebookPage
-//-----------------------------------------------------------------------------
-
-class wxNotebookPage: public wxObject
+static void gtk_notebook_client_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, 
+                                               wxNotebookPage *page )
 {
-public:
-  wxNotebookPage()
-  {
-    m_id = -1;
-    m_text = "";
-    m_image = -1;
-    m_page = NULL;
-    m_clientPanel = NULL;
-  };
-
-//private:
-  int                m_id;
-  wxString           m_text;
-  int                m_image;
-  GtkNotebookPage   *m_page;
-  GtkLabel          *m_label;
-  wxWindow          *m_clientPanel;
+  if (!page->m_client->HasVMT()) return;
+
+/*
+  printf( "OnResize from " );
+  if (page->m_client->GetClassInfo() && page->m_client->GetClassInfo()->GetClassName())
+    printf( page->m_client->GetClassInfo()->GetClassName() );
+  printf( ".\n" );
+
+  printf( "  New: X: %d  Y: %d ", alloc->x, alloc->y );
+  printf( "  W: %d  H: %d ", alloc->width, alloc->height );
+  printf( " .\n" );
+*/
+  
+  page->m_client->SetSize( alloc->x, alloc->y+26,
+                           alloc->width, alloc->height );
 };
 
 //-----------------------------------------------------------------------------
@@ -195,7 +217,7 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
     node = node->Next();
   };
 
-  wxLogDebug("Notebook page %d not found!", page);
+  wxLogDebug( "Notebook page %d not found!", page );
 
   return NULL;
 };
@@ -305,7 +327,7 @@ bool wxNotebook::DeletePage( int page )
 
   wxASSERT( child );
 
-  delete nb_page->m_clientPanel;
+  delete nb_page->m_client;
 
 //  Amazingly, this is not necessary
 //  gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page_num );
@@ -328,7 +350,7 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
   while (node)
   {
     page = (wxNotebookPage*)node->Data();
-    if ( page->m_clientPanel == win )
+    if ( page->m_client == win )
       break; // found
     node = node->Next();
   };
@@ -356,29 +378,36 @@ wxWindow *wxNotebook::GetPage( int page ) const
   if (!nb_page)
     return NULL;
   else
-    return nb_page->m_clientPanel;
+    return nb_page->m_client;
 };
 
 void wxNotebook::AddChild( wxWindow *win )
 {
   // @@@ normally done in wxWindow::AddChild but for some reason wxNotebook
   // case is special there (Robert?)
+  // Robert: Don't you think the code below looks different from the one
+  // in wxWindow::AddChild :-)
+  
   m_children.Append(win);
 
+  
   wxNotebookPage *page = new wxNotebookPage();
 
   page->m_id = GetPageCount();
-  page->m_label = (GtkLabel *)gtk_label_new("no caption");
-  page->m_clientPanel = win;
-  gtk_notebook_append_page(GTK_NOTEBOOK(m_widget), win->m_widget,
-                           (GtkWidget *)page->m_label);
+  page->m_label = (GtkLabel *)gtk_label_new("Handle");
+  page->m_client = win;
+  gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget,
+                            (GtkWidget *)page->m_label);
   gtk_misc_set_alignment(GTK_MISC(page->m_label), 0.0, 0.5);
 
-  page->m_page = (GtkNotebookPage*)
-                 (
-                    g_list_last(GTK_NOTEBOOK(m_widget)->children)->data
-                 );
+  page->m_page = 
+    (GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data);
+    
+  page->m_parent = GTK_NOTEBOOK(m_widget);
 
+  gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
+    GTK_SIGNAL_FUNC(gtk_notebook_client_size_callback), (gpointer)page );
+    
   if (!page->m_page)
   {
      wxLogFatalError( "Notebook page creation error" );
@@ -388,22 +417,6 @@ void wxNotebook::AddChild( wxWindow *win )
   m_pages.Append( page );
 };
 
-void wxNotebook::OnSize(wxSizeEvent& event)
-{
-  // forward this event to all pages
-  wxNode *node = m_pages.First();
-  while (node)
-  {
-    wxNotebookPage *page = (wxNotebookPage*)node->Data();
-    // @@@@ This -50 is completely wrong - instead, we should substract
-    //      the height of the tabs
-    page->m_clientPanel->SetSize(event.GetSize().GetX(),
-                                 event.GetSize().GetY() - 50);
-
-    node = node->Next();
-  };
-}
-
 //-----------------------------------------------------------------------------
 // wxNotebookEvent
 //-----------------------------------------------------------------------------
index eb09743ab82a986cbc9b3a59e0a73f5db6cee0d7..05c3136acc931d021e1589e97e9bc9ede7f71add 100644 (file)
@@ -74,6 +74,9 @@ class wxBitmapRefData: public wxObjectRefData
     int             m_width;
     int             m_height;
     int             m_bpp;
+#ifdef USE_GDK_IMLIB
+    GdkImlibImage  *m_image;
+#endif
     wxPalette      *m_palette;
 };
 
@@ -92,10 +95,11 @@ wxBitmapRefData::~wxBitmapRefData(void)
 {
 #ifdef USE_GDK_IMLIB
   if (m_pixmap) gdk_imlib_free_pixmap( m_pixmap );
+  if (m_image) gdk_imlib_destroy_image( m_image );
 #else
   if (m_pixmap) gdk_pixmap_unref( m_pixmap );
-  if (m_bitmap) gdk_bitmap_unref( m_bitmap );
 #endif
+  if (m_bitmap) gdk_bitmap_unref( m_bitmap );
   if (m_mask) delete m_mask;
   if (m_palette) delete m_palette;
 };
@@ -126,22 +130,26 @@ wxBitmap::wxBitmap( int width, int height, int depth )
 wxBitmap::wxBitmap( char **bits )
 {
   m_refData = new wxBitmapRefData();
-  
-  GdkBitmap *mask = NULL;
 
 #ifndef USE_GDK_IMLIB
+
+  GdkBitmap *mask = NULL;
+  
   M_BMPDATA->m_pixmap = 
     gdk_pixmap_create_from_xpm_d( (GdkWindow*) &gdk_root_parent, &mask, NULL, (gchar **) bits );
-#else
-  M_BMPDATA->m_pixmap = NULL;
-  int res = gdk_imlib_data_to_pixmap( bits, &M_BMPDATA->m_pixmap, &mask );
-#endif
-  
+    
   if (mask)
   {
     M_BMPDATA->m_mask = new wxMask();
     M_BMPDATA->m_mask->m_bitmap = mask;
   };
+  
+#else
+
+  M_BMPDATA->m_image = gdk_imlib_create_image_from_xpm_data( bits );
+  Render();
+  
+#endif
                                  
   gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
   M_BMPDATA->m_bpp = 24; // ?
@@ -248,19 +256,57 @@ void wxBitmap::SetDepth( int depth )
 wxMask *wxBitmap::GetMask(void) const
 {
   if (!Ok()) return NULL;
+  
   return M_BMPDATA->m_mask;
 };
 
 void wxBitmap::SetMask( wxMask *mask )
 {
   if (!Ok()) return;
+  
   if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
   M_BMPDATA->m_mask = mask;
 };
 
-bool wxBitmap::SaveFile( const wxString &WXUNUSED(name), int WXUNUSED(type), 
+void wxBitmap::Resize( int height, int width )
+{
+  if (!Ok()) return;
+  
+  return;
+  
+#ifdef USE_GDK_IMLIB
+  
+  if (M_BMPDATA->m_bitmap) return;  // not supported for bitmaps
+  
+  if (!M_BMPDATA->m_image) RecreateImage();
+  
+  if (M_BMPDATA->m_pixmap) gdk_imlib_free_pixmap( M_BMPDATA->m_pixmap );
+  if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
+  
+  GdkImlibImage* image = gdk_imlib_clone_scaled_image( M_BMPDATA->m_image, height, width );
+  gdk_imlib_destroy_image( M_BMPDATA->m_image );
+  M_BMPDATA->m_image = image;
+  M_BMPDATA->m_height = height;
+  M_BMPDATA->m_width = width;
+  
+  Render();
+  
+#endif
+};
+
+bool wxBitmap::SaveFile( const wxString &name, int WXUNUSED(type), 
   wxPalette *WXUNUSED(palette) )
 {
+#ifdef USE_GDK_IMLIB
+
+  if (!Ok()) return FALSE;
+  
+  if (!M_BMPDATA->m_image) RecreateImage();
+  
+  return gdk_imlib_save_image( M_BMPDATA->m_image, WXSTRINGCAST name, NULL );
+
+#endif
+
   return FALSE;
 };
 
@@ -270,23 +316,16 @@ bool wxBitmap::LoadFile( const wxString &name, int WXUNUSED(type) )
 
   UnRef();
   m_refData = new wxBitmapRefData();
-  M_BMPDATA->m_mask = NULL;
-
-  GdkBitmap *mask = NULL;
   
-  int res = gdk_imlib_load_file_to_pixmap( WXSTRINGCAST name, &M_BMPDATA->m_pixmap, &mask );
+  M_BMPDATA->m_image = gdk_imlib_load_image( WXSTRINGCAST name );
 
-  if (res != 1)
+  if (!M_BMPDATA->m_image)
   {
     UnRef();
     return FALSE;
   };
 
-  if (mask)
-  {
-    M_BMPDATA->m_mask = new wxMask();
-    M_BMPDATA->m_mask->m_bitmap = mask;
-  }
+  Render();
                                  
   gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
   M_BMPDATA->m_bpp = 24; // ?
@@ -312,6 +351,42 @@ GdkPixmap *wxBitmap::GetPixmap(void) const
 GdkBitmap *wxBitmap::GetBitmap(void) const
 {
   if (!Ok()) return NULL;
+  
   return M_BMPDATA->m_bitmap;
 };
   
+void wxBitmap::DestroyImage(void)
+{
+  if (!Ok()) return;
+  
+  if (M_BMPDATA->m_image)
+  {
+    gdk_imlib_destroy_image( M_BMPDATA->m_image );
+    M_BMPDATA->m_image = NULL;
+  };
+};
+
+void wxBitmap::RecreateImage(void)
+{
+};
+
+void wxBitmap::Render(void)
+{
+  if (!Ok()) return;
+  
+#ifdef USE_GDK_IMLIB
+
+  gdk_imlib_render( M_BMPDATA->m_image, M_BMPDATA->m_image->rgb_width, M_BMPDATA->m_image->rgb_height );
+  
+  M_BMPDATA->m_pixmap = gdk_imlib_move_image( M_BMPDATA->m_image );
+  GdkBitmap *mask = gdk_imlib_move_mask( M_BMPDATA->m_image );
+  if (mask)
+  {
+    M_BMPDATA->m_mask = new wxMask();
+    M_BMPDATA->m_mask->m_bitmap = mask;
+  };
+  
+#endif
+};
+
+
index e78e9679b6b8ad2376e4a9d55221b1d5a6e20455..075ed1e7f6dc0cdc8203806668a78312ede08462 100644 (file)
@@ -42,7 +42,7 @@ void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc,
   printf( ".\n" );
 */
 
-  win->GtkOnSize( alloc->width, alloc->height );
+  win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height );
 };
 
 //-----------------------------------------------------------------------------
@@ -194,8 +194,11 @@ void wxFrame::GetClientSize( int *width, int *height ) const
   };
 };
 
-void wxFrame::GtkOnSize( int width, int height )
+void wxFrame::GtkOnSize( int x, int y, int width, int height )
 {
+  m_x = x;
+  m_y = y;
+
   if ((m_height == height) && (m_width == width) &&
       (m_sizeSet)) return;
   if (!m_mainWindow) return;
index a65627746cd31285c5c35f1010a472c8015c5247..7ab44845375870a4f734f40d79b1ff40c85d8da0 100644 (file)
@@ -20,3 +20,8 @@
 
 IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap)
 
+wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
+    wxBitmap( bits ) 
+{
+};
+    
index eb1ac6d1b55a4f2d56dd689b14493c2564c12113..4021fcaf49d543d9076fc936f5c3eb0a9cf1b943 100644 (file)
 #include "wx/intl.h"
 #include "wx/log.h"
 
+//-----------------------------------------------------------------------------
+// wxNotebookPage
+//-----------------------------------------------------------------------------
+
+class wxNotebookPage: public wxObject
+{
+public:
+  wxNotebookPage()
+  {
+    m_id = -1;
+    m_text = "";
+    m_image = -1;
+    m_page = NULL;
+    m_client = NULL;
+    m_parent = NULL;
+  };
+
+//private:
+  int                m_id;
+  wxString           m_text;
+  int                m_image;
+  GtkNotebookPage   *m_page;
+  GtkLabel          *m_label;
+  wxWindow          *m_client;
+  GtkNotebook       *m_parent;
+};
+
 //-----------------------------------------------------------------------------
 // GTK callbacks
 //-----------------------------------------------------------------------------
 
 // page change callback
-static void gtk_notebook_page_change_callback(GtkNotebook *widget,
-                                              GtkNotebookPage *page,
+static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
+                                              GtkNotebookPage *WXUNUSED(page),
                                               gint nPage,
                                               gpointer data)
 {
@@ -42,29 +69,24 @@ static void gtk_notebook_page_change_callback(GtkNotebook *widget,
   notebook->ProcessEvent(event);
 }
 
-//-----------------------------------------------------------------------------
-// wxNotebookPage
-//-----------------------------------------------------------------------------
-
-class wxNotebookPage: public wxObject
+static void gtk_notebook_client_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, 
+                                               wxNotebookPage *page )
 {
-public:
-  wxNotebookPage()
-  {
-    m_id = -1;
-    m_text = "";
-    m_image = -1;
-    m_page = NULL;
-    m_clientPanel = NULL;
-  };
-
-//private:
-  int                m_id;
-  wxString           m_text;
-  int                m_image;
-  GtkNotebookPage   *m_page;
-  GtkLabel          *m_label;
-  wxWindow          *m_clientPanel;
+  if (!page->m_client->HasVMT()) return;
+
+/*
+  printf( "OnResize from " );
+  if (page->m_client->GetClassInfo() && page->m_client->GetClassInfo()->GetClassName())
+    printf( page->m_client->GetClassInfo()->GetClassName() );
+  printf( ".\n" );
+
+  printf( "  New: X: %d  Y: %d ", alloc->x, alloc->y );
+  printf( "  W: %d  H: %d ", alloc->width, alloc->height );
+  printf( " .\n" );
+*/
+  
+  page->m_client->SetSize( alloc->x, alloc->y+26,
+                           alloc->width, alloc->height );
 };
 
 //-----------------------------------------------------------------------------
@@ -195,7 +217,7 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
     node = node->Next();
   };
 
-  wxLogDebug("Notebook page %d not found!", page);
+  wxLogDebug( "Notebook page %d not found!", page );
 
   return NULL;
 };
@@ -305,7 +327,7 @@ bool wxNotebook::DeletePage( int page )
 
   wxASSERT( child );
 
-  delete nb_page->m_clientPanel;
+  delete nb_page->m_client;
 
 //  Amazingly, this is not necessary
 //  gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page_num );
@@ -328,7 +350,7 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
   while (node)
   {
     page = (wxNotebookPage*)node->Data();
-    if ( page->m_clientPanel == win )
+    if ( page->m_client == win )
       break; // found
     node = node->Next();
   };
@@ -356,29 +378,36 @@ wxWindow *wxNotebook::GetPage( int page ) const
   if (!nb_page)
     return NULL;
   else
-    return nb_page->m_clientPanel;
+    return nb_page->m_client;
 };
 
 void wxNotebook::AddChild( wxWindow *win )
 {
   // @@@ normally done in wxWindow::AddChild but for some reason wxNotebook
   // case is special there (Robert?)
+  // Robert: Don't you think the code below looks different from the one
+  // in wxWindow::AddChild :-)
+  
   m_children.Append(win);
 
+  
   wxNotebookPage *page = new wxNotebookPage();
 
   page->m_id = GetPageCount();
-  page->m_label = (GtkLabel *)gtk_label_new("no caption");
-  page->m_clientPanel = win;
-  gtk_notebook_append_page(GTK_NOTEBOOK(m_widget), win->m_widget,
-                           (GtkWidget *)page->m_label);
+  page->m_label = (GtkLabel *)gtk_label_new("Handle");
+  page->m_client = win;
+  gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), win->m_widget,
+                            (GtkWidget *)page->m_label);
   gtk_misc_set_alignment(GTK_MISC(page->m_label), 0.0, 0.5);
 
-  page->m_page = (GtkNotebookPage*)
-                 (
-                    g_list_last(GTK_NOTEBOOK(m_widget)->children)->data
-                 );
+  page->m_page = 
+    (GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data);
+    
+  page->m_parent = GTK_NOTEBOOK(m_widget);
 
+  gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
+    GTK_SIGNAL_FUNC(gtk_notebook_client_size_callback), (gpointer)page );
+    
   if (!page->m_page)
   {
      wxLogFatalError( "Notebook page creation error" );
@@ -388,22 +417,6 @@ void wxNotebook::AddChild( wxWindow *win )
   m_pages.Append( page );
 };
 
-void wxNotebook::OnSize(wxSizeEvent& event)
-{
-  // forward this event to all pages
-  wxNode *node = m_pages.First();
-  while (node)
-  {
-    wxNotebookPage *page = (wxNotebookPage*)node->Data();
-    // @@@@ This -50 is completely wrong - instead, we should substract
-    //      the height of the tabs
-    page->m_clientPanel->SetSize(event.GetSize().GetX(),
-                                 event.GetSize().GetY() - 50);
-
-    node = node->Next();
-  };
-}
-
 //-----------------------------------------------------------------------------
 // wxNotebookEvent
 //-----------------------------------------------------------------------------
index d7d5d4b4977b0f15f015b6d03a3945fd06467cd5..37e1e04cad0a6ff7d2b74c6d33dd15d7ac8e566c 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef   MCONFIG_H
 // for testing only:
 #   define WXLAYOUT_DEBUG
-#   cdefine USE_STD_STRING
+#   define USE_STD_STRING
 #endif
 
 #ifdef USE_STD_STRING