stream compile fixes

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
This commit is contained in:
Robert Roebling
1998-07-12 20:06:59 +00:00
parent 3cacae09fa
commit 219f895a27
25 changed files with 433 additions and 192 deletions

View File

@@ -62,6 +62,8 @@ class wxImageList: public wxObject
private:
wxList m_images;
int m_width;
int m_height;
};
#endif // __IMAGELISTH_G__

View 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 :-)
};

View 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:

View File

@@ -40,10 +40,7 @@ public:
inline wxIcon(const wxIcon& icon) { Ref(icon); }
inline wxIcon(const wxIcon* icon) { if (icon) Ref(*icon); }
// Don't change this. Robert.
wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
wxBitmap( bits ) {};
wxIcon( char **bits, int width=-1, int height=-1 );
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; }

View 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();

View 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 :-)
};

View 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:

View File

@@ -40,10 +40,7 @@ public:
inline wxIcon(const wxIcon& icon) { Ref(icon); }
inline wxIcon(const wxIcon* icon) { if (icon) Ref(*icon); }
// Don't change this. Robert.
wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
wxBitmap( bits ) {};
wxIcon( char **bits, int width=-1, int height=-1 );
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; }

View 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();

View 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)

View 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;

View 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) )

View 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

View File

@@ -14,14 +14,14 @@
#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)

View 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()
{
}

View File

@@ -20,8 +20,10 @@
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;
};

View 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;
};
@@ -127,15 +131,12 @@ wxBitmap::wxBitmap( char **bits )
{
m_refData = new wxBitmapRefData();
#ifndef USE_GDK_IMLIB
GdkBitmap *mask = NULL;
#ifndef USE_GDK_IMLIB
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)
{
@@ -143,6 +144,13 @@ wxBitmap::wxBitmap( char **bits )
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;
M_BMPDATA->m_image = gdk_imlib_load_image( WXSTRINGCAST name );
int res = gdk_imlib_load_file_to_pixmap( WXSTRINGCAST name, &M_BMPDATA->m_pixmap, &mask );
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
};

View 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;

View File

@@ -20,3 +20,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap)
wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
wxBitmap( bits )
{
};

View File

@@ -19,13 +19,40 @@
#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;
};
if (!page->m_client->HasVMT()) return;
//private:
int m_id;
wxString m_text;
int m_image;
GtkNotebookPage *m_page;
GtkLabel *m_label;
wxWindow *m_clientPanel;
/*
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 );
};
//-----------------------------------------------------------------------------
@@ -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,28 +378,35 @@ 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;
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)
{
@@ -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
//-----------------------------------------------------------------------------

View 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;
};
@@ -127,15 +131,12 @@ wxBitmap::wxBitmap( char **bits )
{
m_refData = new wxBitmapRefData();
#ifndef USE_GDK_IMLIB
GdkBitmap *mask = NULL;
#ifndef USE_GDK_IMLIB
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)
{
@@ -143,6 +144,13 @@ wxBitmap::wxBitmap( char **bits )
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;
M_BMPDATA->m_image = gdk_imlib_load_image( WXSTRINGCAST name );
int res = gdk_imlib_load_file_to_pixmap( WXSTRINGCAST name, &M_BMPDATA->m_pixmap, &mask );
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
};

View 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;

View File

@@ -20,3 +20,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap)
wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
wxBitmap( bits )
{
};

View File

@@ -19,13 +19,40 @@
#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;
};
if (!page->m_client->HasVMT()) return;
//private:
int m_id;
wxString m_text;
int m_image;
GtkNotebookPage *m_page;
GtkLabel *m_label;
wxWindow *m_clientPanel;
/*
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 );
};
//-----------------------------------------------------------------------------
@@ -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,28 +378,35 @@ 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;
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)
{
@@ -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
//-----------------------------------------------------------------------------

View 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