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;
private:
wxList m_images;
+ int m_width;
+ int m_height;
};
#endif // __IMAGELISTH_G__
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 );
GdkPixmap *GetPixmap(void) const;
GdkBitmap *GetBitmap(void) const;
+ void DestroyImage(void);
+ void RecreateImage(void);
+ void Render(void);
+
// no data :-)
};
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:
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; }
// ----------------------------------------------------------------------------
// notebook events
// ----------------------------------------------------------------------------
+
class wxNotebookEvent : public wxCommandEvent
{
public:
// base class virtuals
virtual void AddChild(wxWindow *child);
-protected:
- // wxWin callbacks
- void OnSize(wxSizeEvent& event);
-
private:
// common part of all ctors
void Init();
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 );
GdkPixmap *GetPixmap(void) const;
GdkBitmap *GetBitmap(void) const;
+ void DestroyImage(void);
+ void RecreateImage(void);
+ void Render(void);
+
// no data :-)
};
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:
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; }
// ----------------------------------------------------------------------------
// notebook events
// ----------------------------------------------------------------------------
+
class wxNotebookEvent : public wxCommandEvent
{
public:
// base class virtuals
virtual void AddChild(wxWindow *child);
-protected:
- // wxWin callbacks
- void OnSize(wxSizeEvent& event);
-
private:
// common part of all ctors
void Init();
#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)
wxInputStream *m_parent_i_stream;
};
-class wxFilterOuputStream: pubilc wxOutputStream {
+class wxFilterOutputStream: public wxOutputStream {
DECLARE_CLASS(wxFilterOutputStream)
public:
wxFilterOutputStream(wxOutputStream& stream);
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;
const ID_COMBO = 140;
+const ID_TEXT = 150;
+
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize)
EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox)
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) )
{
char buf[4];
- if (!m_istream)
+ if (!m_parent_i_stream)
return 0;
Read(buf, 4);
{
char buf[2];
- if (!m_istream)
+ if (!m_parent_i_stream)
return 0;
Read(buf, 2);
{
char buf;
- if (!m_istream)
+ if (!m_parent_i_stream)
return 0;
Read(&buf, 1);
#if USE_APPLE_IEEE
char buf[10];
- if (!m_istream)
+ if (!m_parent_i_stream)
return 0.0;
Read(buf, 10);
{
char i_strg[255];
- if (!m_istream)
+ if (!m_parent_i_stream)
return "";
// TODO: Implement ReadLine
char *string;
unsigned long len;
- if (!m_istream)
+ if (!m_parent_i_stream)
return "";
len = Read32();
{
char buf[4];
- if (!m_ostream)
+ if (!m_parent_o_stream)
return;
buf[0] = i & 0xff;
{
char buf[2];
- if (!m_ostream)
+ if (!m_parent_o_stream)
return;
buf[0] = i & 0xff;
void wxDataOutputStream::Write8(unsigned char i)
{
- if (!m_ostream)
+ if (!m_parent_o_stream)
return;
Write(&i, 1);
wxString tmp_string = line + '\n';
#endif
- if (!m_ostream)
+ if (!m_parent_o_stream)
return;
Write((const char *) tmp_string, tmp_string.Length());
void wxDataOutputStream::WriteString(const wxString& string)
{
- if (!m_ostream)
+ if (!m_parent_o_stream)
return;
Write32(string.Length());
{
char buf[10];
- if (!m_ostream)
+ if (!m_parent_o_stream)
return;
#if USE_APPLE_IEEE
#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)
#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)
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()
+{
+}
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();
};
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)
{
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;
};
int m_width;
int m_height;
int m_bpp;
+#ifdef USE_GDK_IMLIB
+ GdkImlibImage *m_image;
+#endif
wxPalette *m_palette;
};
{
#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;
};
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; // ?
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;
};
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; // ?
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
+};
+
+
printf( ".\n" );
*/
- win->GtkOnSize( alloc->width, alloc->height );
+ win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height );
};
//-----------------------------------------------------------------------------
};
};
-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;
IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap)
+wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
+ wxBitmap( bits )
+{
+};
+
#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)
{
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 );
};
//-----------------------------------------------------------------------------
node = node->Next();
};
- wxLogDebug("Notebook page %d not found!", page);
+ wxLogDebug( "Notebook page %d not found!", page );
return NULL;
};
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 );
while (node)
{
page = (wxNotebookPage*)node->Data();
- if ( page->m_clientPanel == win )
+ if ( page->m_client == win )
break; // found
node = node->Next();
};
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" );
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
//-----------------------------------------------------------------------------
int m_width;
int m_height;
int m_bpp;
+#ifdef USE_GDK_IMLIB
+ GdkImlibImage *m_image;
+#endif
wxPalette *m_palette;
};
{
#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;
};
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; // ?
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;
};
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; // ?
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
+};
+
+
printf( ".\n" );
*/
- win->GtkOnSize( alloc->width, alloc->height );
+ win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height );
};
//-----------------------------------------------------------------------------
};
};
-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;
IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap)
+wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
+ wxBitmap( bits )
+{
+};
+
#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)
{
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 );
};
//-----------------------------------------------------------------------------
node = node->Next();
};
- wxLogDebug("Notebook page %d not found!", page);
+ wxLogDebug( "Notebook page %d not found!", page );
return NULL;
};
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 );
while (node)
{
page = (wxNotebookPage*)node->Data();
- if ( page->m_clientPanel == win )
+ if ( page->m_client == win )
break; // found
node = node->Next();
};
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" );
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
//-----------------------------------------------------------------------------
#ifndef MCONFIG_H
// for testing only:
# define WXLAYOUT_DEBUG
-# cdefine USE_STD_STRING
+# define USE_STD_STRING
#endif
#ifdef USE_STD_STRING