It's possible now to save to a PNG. OK, I still
have performance problems, but it's a start. Updated install.txt. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@662 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4,11 +4,20 @@
|
|||||||
If you compile wxWindows on Unix for the first time and don't like
|
If you compile wxWindows on Unix for the first time and don't like
|
||||||
to read install instructions just do (in the base dir):
|
to read install instructions just do (in the base dir):
|
||||||
|
|
||||||
./configure --with-gtk --with-shared --without-threads
|
./configure --without-threads
|
||||||
make
|
make
|
||||||
|
|
||||||
and drink 10 coffees.
|
and drink 10 coffees. Then you may log in as root and type
|
||||||
|
|
||||||
|
make install
|
||||||
|
|
||||||
|
You can leave out the --without-threads option if you have a NEW
|
||||||
|
Linux distribution based on glibc (e.g. RedHat 5.1) or any other
|
||||||
|
Unix that comes with Posix threads or SGI threads.
|
||||||
|
|
||||||
|
Now create your super-application myfoo.app and compile anywhere with
|
||||||
|
|
||||||
|
gcc -o -c myfoo.cpp -I/usr/local/include -L/usr/local/lib -lwx_gtk
|
||||||
|
|
||||||
* General
|
* General
|
||||||
-----------------------
|
-----------------------
|
||||||
@@ -141,8 +150,10 @@ not been defined. And Make in some circumstances as well...
|
|||||||
* General options
|
* General options
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Obviously, you have to choose a toolkit. You must do this by
|
Normally, you won't have to choose a toolkit, because when
|
||||||
running configure with either of
|
you download wxGTK, it will default to --with-gtk etc. But
|
||||||
|
if you use all of our CVS repository you have to choose a
|
||||||
|
toolkit. You must do this by running configure with either of:
|
||||||
|
|
||||||
--with-gtk Use the GIMP ToolKit (GTK)
|
--with-gtk Use the GIMP ToolKit (GTK)
|
||||||
|
|
||||||
@@ -155,7 +166,7 @@ The following options handle the kind of library you want to build.
|
|||||||
|
|
||||||
--without-threads Compile without thread support.
|
--without-threads Compile without thread support.
|
||||||
|
|
||||||
--with-shared Create shared libraries.
|
--without-shared Do not create shared libraries.
|
||||||
|
|
||||||
--without-optimise Do not optimise the code.
|
--without-optimise Do not optimise the code.
|
||||||
|
|
||||||
@@ -191,25 +202,21 @@ implemented.
|
|||||||
-------------
|
-------------
|
||||||
|
|
||||||
The following must be done in the base directory (e.g. ~/wxGTK
|
The following must be done in the base directory (e.g. ~/wxGTK
|
||||||
or ~/wxWin)
|
or ~/wxWin or whatever)
|
||||||
|
|
||||||
First you have to create all makefiles in all subdirectories:
|
|
||||||
|
|
||||||
make Makefiles
|
|
||||||
|
|
||||||
Dependencies are generated automatically using
|
Dependencies are generated automatically using
|
||||||
|
|
||||||
make depend
|
make depend
|
||||||
|
|
||||||
(For some reason, this doesn't seem to work completely.)
|
(For some reason, this doesn't seem to work.)
|
||||||
|
|
||||||
Now the makefiles are created you can compile everything is as simple
|
Now the makefiles are created you can compile everything is as simple
|
||||||
as typing:
|
as typing:
|
||||||
|
|
||||||
make
|
make
|
||||||
|
|
||||||
make yourself some coffee, as it will try to compile
|
make yourself some coffee, as it will try to compile ALL the
|
||||||
ALL the files in this distribution.
|
files in this distribution.
|
||||||
|
|
||||||
if you want to be more selective:
|
if you want to be more selective:
|
||||||
|
|
||||||
@@ -219,6 +226,13 @@ if you want to be more selective:
|
|||||||
make other will build the other samples
|
make other will build the other samples
|
||||||
make user will build the files in the directory other
|
make user will build the files in the directory other
|
||||||
|
|
||||||
|
Then you may install the library and it's header files under
|
||||||
|
/usr/local/include/wx and /usr/local/lib respectively. You
|
||||||
|
have to log in as root (i.e. run "su" and enter the root
|
||||||
|
password) and type
|
||||||
|
|
||||||
|
make install
|
||||||
|
|
||||||
Depending on the configuration of some files, the libraries
|
Depending on the configuration of some files, the libraries
|
||||||
and binaries will be placed in different directories.
|
and binaries will be placed in different directories.
|
||||||
The "global" binaries and libraries will be placed in:
|
The "global" binaries and libraries will be placed in:
|
||||||
@@ -242,8 +256,10 @@ will do the work for you.
|
|||||||
* Creating a new Project
|
* Creating a new Project
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
I propose to put all contributed programs in the directory
|
There are two ways to create your own project. The first creates
|
||||||
"~/wxWin/user", with a directory of its own.
|
a project within the source code directories of wxWindows: In this
|
||||||
|
case I propose to put all contributed programs in the directory
|
||||||
|
"/user", with a directory of its own.
|
||||||
|
|
||||||
This directory then should include the following files:
|
This directory then should include the following files:
|
||||||
|
|
||||||
@@ -258,6 +274,13 @@ Makefile.in (This is the base application-Makefile template, from
|
|||||||
put ALL your source code along with all the other stuff you need for
|
put ALL your source code along with all the other stuff you need for
|
||||||
your application in this directory (subdirectories are welcome).
|
your application in this directory (subdirectories are welcome).
|
||||||
|
|
||||||
|
The other way uses the installed libraries and header files in
|
||||||
|
/usr/local/include/wx and /usr/local/lib. In this case, just
|
||||||
|
compile your program like this:
|
||||||
|
|
||||||
|
gcc -o -c myfoo.cpp -I/usr/local/include -L/usr/local/lib -lwx_gtk
|
||||||
|
|
||||||
|
|
||||||
** Something about Makefiles
|
** Something about Makefiles
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ class wxDC: public wxObject
|
|||||||
void BeginDrawing(void) {};
|
void BeginDrawing(void) {};
|
||||||
void EndDrawing(void) {};
|
void EndDrawing(void) {};
|
||||||
|
|
||||||
virtual bool Ok(void) const { return m_ok; };
|
virtual bool Ok(void) const;
|
||||||
|
|
||||||
virtual void FloodFill( long x1, long y1, wxColour *col, int style=wxFLOOD_SURFACE ) = 0;
|
virtual void FloodFill( long x1, long y1, wxColour *col, int style=wxFLOOD_SURFACE ) = 0;
|
||||||
virtual bool GetPixel( long x1, long y1, wxColour *col ) const = 0;
|
virtual bool GetPixel( long x1, long y1, wxColour *col ) const = 0;
|
||||||
|
@@ -66,7 +66,7 @@ class wxDC: public wxObject
|
|||||||
void BeginDrawing(void) {};
|
void BeginDrawing(void) {};
|
||||||
void EndDrawing(void) {};
|
void EndDrawing(void) {};
|
||||||
|
|
||||||
virtual bool Ok(void) const { return m_ok; };
|
virtual bool Ok(void) const;
|
||||||
|
|
||||||
virtual void FloodFill( long x1, long y1, wxColour *col, int style=wxFLOOD_SURFACE ) = 0;
|
virtual void FloodFill( long x1, long y1, wxColour *col, int style=wxFLOOD_SURFACE ) = 0;
|
||||||
virtual bool GetPixel( long x1, long y1, wxColour *col ) const = 0;
|
virtual bool GetPixel( long x1, long y1, wxColour *col ) const = 0;
|
||||||
|
@@ -52,6 +52,7 @@ bool MyApp::OnInit(void)
|
|||||||
wxMenu *help_menu = new wxMenu;
|
wxMenu *help_menu = new wxMenu;
|
||||||
|
|
||||||
file_menu->Append(PNGDEMO_LOAD_FILE, "&Load file", "Load file");
|
file_menu->Append(PNGDEMO_LOAD_FILE, "&Load file", "Load file");
|
||||||
|
file_menu->Append(PNGDEMO_SAVE_FILE, "&Save file", "Save file");
|
||||||
file_menu->Append(PNGDEMO_QUIT, "E&xit", "Quit program");
|
file_menu->Append(PNGDEMO_QUIT, "E&xit", "Quit program");
|
||||||
help_menu->Append(PNGDEMO_ABOUT, "&About", "About PNG demo");
|
help_menu->Append(PNGDEMO_ABOUT, "&About", "About PNG demo");
|
||||||
|
|
||||||
@@ -80,6 +81,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(PNGDEMO_QUIT, MyFrame::OnQuit)
|
EVT_MENU(PNGDEMO_QUIT, MyFrame::OnQuit)
|
||||||
EVT_MENU(PNGDEMO_ABOUT, MyFrame::OnAbout)
|
EVT_MENU(PNGDEMO_ABOUT, MyFrame::OnAbout)
|
||||||
EVT_MENU(PNGDEMO_LOAD_FILE, MyFrame::OnLoadFile)
|
EVT_MENU(PNGDEMO_LOAD_FILE, MyFrame::OnLoadFile)
|
||||||
|
EVT_MENU(PNGDEMO_SAVE_FILE, MyFrame::OnSaveFile)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// Define my frame constructor
|
// Define my frame constructor
|
||||||
@@ -100,6 +102,33 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|||||||
"About PNG Demo", wxOK);
|
"About PNG Demo", wxOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnSaveFile(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
char *f = wxFileSelector( "Save Image", (const char *)NULL, (const char *)NULL,
|
||||||
|
"png", "PNG files (*.png)|*.png" );
|
||||||
|
|
||||||
|
if (!f) return;
|
||||||
|
|
||||||
|
wxBitmap *backstore = new wxBitmap( 150, 150 );
|
||||||
|
|
||||||
|
wxMemoryDC memDC;
|
||||||
|
memDC.SelectObject( *backstore );
|
||||||
|
memDC.Clear();
|
||||||
|
memDC.SetBrush( *wxBLACK_BRUSH );
|
||||||
|
memDC.SetPen( *wxWHITE_PEN );
|
||||||
|
memDC.DrawRectangle( 0, 0, 150, 150 );
|
||||||
|
memDC.SetPen( *wxBLACK_PEN );
|
||||||
|
memDC.DrawLine( 0, 0, 0, 10 );
|
||||||
|
memDC.SetTextForeground( *wxWHITE );
|
||||||
|
memDC.DrawText( "This is a memory dc.", 10, 10 );
|
||||||
|
|
||||||
|
memDC.SelectObject( wxNullBitmap );
|
||||||
|
|
||||||
|
backstore->SaveFile( f, wxBITMAP_TYPE_PNG, (wxPalette*)NULL );
|
||||||
|
|
||||||
|
delete backstore;
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
// Show file selector.
|
// Show file selector.
|
||||||
|
@@ -35,6 +35,7 @@ class MyFrame: public wxFrame
|
|||||||
bool OnClose(void);
|
bool OnClose(void);
|
||||||
void OnActivate(bool) {}
|
void OnActivate(bool) {}
|
||||||
void OnLoadFile(wxCommandEvent& event);
|
void OnLoadFile(wxCommandEvent& event);
|
||||||
|
void OnSaveFile(wxCommandEvent& event);
|
||||||
void OnQuit(wxCommandEvent& event);
|
void OnQuit(wxCommandEvent& event);
|
||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
@@ -54,4 +55,5 @@ DECLARE_EVENT_TABLE()
|
|||||||
#define PNGDEMO_QUIT 100
|
#define PNGDEMO_QUIT 100
|
||||||
#define PNGDEMO_ABOUT 101
|
#define PNGDEMO_ABOUT 101
|
||||||
#define PNGDEMO_LOAD_FILE 102
|
#define PNGDEMO_LOAD_FILE 102
|
||||||
|
#define PNGDEMO_SAVE_FILE 103
|
||||||
|
|
||||||
|
@@ -17,7 +17,12 @@
|
|||||||
#include "gdk/gdkprivate.h"
|
#include "gdk/gdkprivate.h"
|
||||||
|
|
||||||
#ifdef USE_GDK_IMLIB
|
#ifdef USE_GDK_IMLIB
|
||||||
|
|
||||||
#include "../gdk_imlib/gdk_imlib.h"
|
#include "../gdk_imlib/gdk_imlib.h"
|
||||||
|
#include "gdk/gdkx.h" // GDK_DISPLAY
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -223,7 +228,8 @@ bool wxBitmap::operator != ( const wxBitmap& bmp )
|
|||||||
|
|
||||||
bool wxBitmap::Ok(void) const
|
bool wxBitmap::Ok(void) const
|
||||||
{
|
{
|
||||||
return m_refData != NULL;
|
wxASSERT_MSG( m_refData != NULL, "invalid bitmap" );
|
||||||
|
return (m_refData != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxBitmap::GetHeight(void) const
|
int wxBitmap::GetHeight(void) const
|
||||||
@@ -247,18 +253,27 @@ int wxBitmap::GetDepth(void) const
|
|||||||
void wxBitmap::SetHeight( int height )
|
void wxBitmap::SetHeight( int height )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::SetHeight not implemented" );
|
||||||
|
|
||||||
M_BMPDATA->m_height = height;
|
M_BMPDATA->m_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::SetWidth( int width )
|
void wxBitmap::SetWidth( int width )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::SetWidth not implemented" );
|
||||||
|
|
||||||
M_BMPDATA->m_width = width;
|
M_BMPDATA->m_width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::SetDepth( int depth )
|
void wxBitmap::SetDepth( int depth )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::SetDepth not implemented" );
|
||||||
|
|
||||||
M_BMPDATA->m_bpp = depth;
|
M_BMPDATA->m_bpp = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,6 +289,7 @@ void wxBitmap::SetMask( wxMask *mask )
|
|||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
|
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
|
||||||
|
|
||||||
M_BMPDATA->m_mask = mask;
|
M_BMPDATA->m_mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,6 +314,10 @@ void wxBitmap::Resize( int height, int width )
|
|||||||
|
|
||||||
Render();
|
Render();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::Resize not implemented without GdkImlib" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,6 +332,10 @@ bool wxBitmap::SaveFile( const wxString &name, int WXUNUSED(type),
|
|||||||
|
|
||||||
return gdk_imlib_save_image( M_BMPDATA->m_image, WXSTRINGCAST name, (GdkImlibSaveInfo *) NULL );
|
return gdk_imlib_save_image( M_BMPDATA->m_image, WXSTRINGCAST name, (GdkImlibSaveInfo *) NULL );
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::SaveFile not implemented without GdkImlib" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -338,6 +362,11 @@ bool wxBitmap::LoadFile( const wxString &name, int WXUNUSED(type) )
|
|||||||
M_BMPDATA->m_bpp = 24; // ?
|
M_BMPDATA->m_bpp = 24; // ?
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::LoadFile not implemented without GdkImlib" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -352,6 +381,9 @@ wxPalette *wxBitmap::GetPalette(void) const
|
|||||||
GdkPixmap *wxBitmap::GetPixmap(void) const
|
GdkPixmap *wxBitmap::GetPixmap(void) const
|
||||||
{
|
{
|
||||||
if (!Ok()) return (GdkPixmap *) NULL;
|
if (!Ok()) return (GdkPixmap *) NULL;
|
||||||
|
|
||||||
|
// if (!M_BMPDATA->m_image) RecreateImage();
|
||||||
|
|
||||||
return M_BMPDATA->m_pixmap;
|
return M_BMPDATA->m_pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,6 +407,53 @@ void wxBitmap::DestroyImage(void)
|
|||||||
|
|
||||||
void wxBitmap::RecreateImage(void)
|
void wxBitmap::RecreateImage(void)
|
||||||
{
|
{
|
||||||
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
#ifdef USE_GDK_IMLIB
|
||||||
|
|
||||||
|
DestroyImage();
|
||||||
|
|
||||||
|
wxCHECK_RET( M_BMPDATA->m_pixmap != NULL, "invalid bitmap" );
|
||||||
|
|
||||||
|
long size = (long)(M_BMPDATA->m_width)*(long)(M_BMPDATA->m_height)*(long)3;
|
||||||
|
unsigned char *data = new unsigned char[size];
|
||||||
|
for (long i = 0; i < size; i++) data[i] = 100;
|
||||||
|
|
||||||
|
GdkImage *image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height );
|
||||||
|
|
||||||
|
long pos = 0;
|
||||||
|
for (int j = 0; j < M_BMPDATA->m_height; j++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < M_BMPDATA->m_width; i++)
|
||||||
|
{
|
||||||
|
XColor xcol;
|
||||||
|
xcol.pixel = gdk_image_get_pixel( image, i, j );
|
||||||
|
Colormap cm = ((GdkColormapPrivate*)gdk_imlib_get_colormap())->xcolormap;
|
||||||
|
XQueryColor( gdk_display, cm, &xcol );
|
||||||
|
|
||||||
|
data[pos] = xcol.red;
|
||||||
|
data[pos+1] = xcol.green;
|
||||||
|
data[pos+2] = xcol.blue;
|
||||||
|
pos += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCHECK_RET( M_BMPDATA->m_pixmap != NULL, "invalid bitmap" );
|
||||||
|
|
||||||
|
M_BMPDATA->m_image = gdk_imlib_create_image_from_data(
|
||||||
|
data, (unsigned char*)NULL, M_BMPDATA->m_width, M_BMPDATA->m_height );
|
||||||
|
|
||||||
|
delete[] data;
|
||||||
|
|
||||||
|
gdk_image_destroy( image );
|
||||||
|
|
||||||
|
Render();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::RecreateImage not implemented without GdkImlib" );
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::Render(void)
|
void wxBitmap::Render(void)
|
||||||
@@ -383,10 +462,26 @@ void wxBitmap::Render(void)
|
|||||||
|
|
||||||
#ifdef USE_GDK_IMLIB
|
#ifdef USE_GDK_IMLIB
|
||||||
|
|
||||||
|
if (!M_BMPDATA->m_image) RecreateImage();
|
||||||
|
|
||||||
|
if (M_BMPDATA->m_pixmap)
|
||||||
|
{
|
||||||
|
gdk_imlib_free_pixmap( M_BMPDATA->m_pixmap );
|
||||||
|
M_BMPDATA->m_pixmap = (GdkPixmap*) NULL;
|
||||||
|
}
|
||||||
|
if (M_BMPDATA->m_mask)
|
||||||
|
{
|
||||||
|
delete M_BMPDATA->m_mask;
|
||||||
|
M_BMPDATA->m_mask = (wxMask*) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
gdk_imlib_render( M_BMPDATA->m_image, M_BMPDATA->m_image->rgb_width, M_BMPDATA->m_image->rgb_height );
|
gdk_imlib_render( M_BMPDATA->m_image, M_BMPDATA->m_image->rgb_width, M_BMPDATA->m_image->rgb_height );
|
||||||
M_BMPDATA->m_width = M_BMPDATA->m_image->rgb_width;
|
M_BMPDATA->m_width = M_BMPDATA->m_image->rgb_width;
|
||||||
M_BMPDATA->m_height = M_BMPDATA->m_image->rgb_height;
|
M_BMPDATA->m_height = M_BMPDATA->m_image->rgb_height;
|
||||||
M_BMPDATA->m_pixmap = gdk_imlib_move_image( M_BMPDATA->m_image );
|
M_BMPDATA->m_pixmap = gdk_imlib_move_image( M_BMPDATA->m_image );
|
||||||
|
|
||||||
|
wxCHECK_RET( M_BMPDATA->m_pixmap != NULL, "pixmap rendering failed" )
|
||||||
|
|
||||||
GdkBitmap *mask = gdk_imlib_move_mask( M_BMPDATA->m_image );
|
GdkBitmap *mask = gdk_imlib_move_mask( M_BMPDATA->m_image );
|
||||||
if (mask)
|
if (mask)
|
||||||
{
|
{
|
||||||
@@ -394,6 +489,10 @@ void wxBitmap::Render(void)
|
|||||||
M_BMPDATA->m_mask->m_bitmap = mask;
|
M_BMPDATA->m_mask->m_bitmap = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::Render not implemented without GdkImlib" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,6 +83,12 @@ wxDC::~wxDC(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxDC::Ok(void) const
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( !ok, "invalid display context" );
|
||||||
|
return m_ok;
|
||||||
|
}
|
||||||
|
|
||||||
void wxDC::DrawArc( long WXUNUSED(x1), long WXUNUSED(y1), long WXUNUSED(x2), long WXUNUSED(y2),
|
void wxDC::DrawArc( long WXUNUSED(x1), long WXUNUSED(y1), long WXUNUSED(x2), long WXUNUSED(y2),
|
||||||
double WXUNUSED(xc), double WXUNUSED(yc) )
|
double WXUNUSED(xc), double WXUNUSED(yc) )
|
||||||
{
|
{
|
||||||
|
@@ -124,10 +124,12 @@ wxPaintDC::~wxPaintDC(void)
|
|||||||
void wxPaintDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1),
|
void wxPaintDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1),
|
||||||
wxColour *WXUNUSED(col), int WXUNUSED(style) )
|
wxColour *WXUNUSED(col), int WXUNUSED(style) )
|
||||||
{
|
{
|
||||||
|
wxFAIL_MSG( "wxPaintDC::FloodFill not implemented" );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPaintDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const
|
bool wxPaintDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const
|
||||||
{
|
{
|
||||||
|
wxFAIL_MSG( "wxPaintDC::GetPixel not implemented" );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +137,8 @@ void wxPaintDC::DrawLine( long x1, long y1, long x2, long y2 )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
gdk_draw_line( m_window, m_penGC,
|
gdk_draw_line( m_window, m_penGC,
|
||||||
@@ -146,6 +150,8 @@ void wxPaintDC::CrossHair( long x, long y )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
int w = 0;
|
int w = 0;
|
||||||
@@ -164,6 +170,8 @@ void wxPaintDC::DrawArc( long x1, long y1, long x2, long y2, double xc, double y
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
long xx1 = XLOG2DEV(x1);
|
long xx1 = XLOG2DEV(x1);
|
||||||
long yy1 = YLOG2DEV(y1);
|
long yy1 = YLOG2DEV(y1);
|
||||||
long xx2 = XLOG2DEV(x2);
|
long xx2 = XLOG2DEV(x2);
|
||||||
@@ -212,6 +220,8 @@ void wxPaintDC::DrawEllipticArc( long x, long y, long width, long height, double
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
long xx = XLOG2DEV(x);
|
long xx = XLOG2DEV(x);
|
||||||
long yy = YLOG2DEV(y);
|
long yy = YLOG2DEV(y);
|
||||||
long ww = m_signX * XLOG2DEVREL(width);
|
long ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -234,6 +244,8 @@ void wxPaintDC::DrawPoint( long x, long y )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) );
|
gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) );
|
||||||
}
|
}
|
||||||
@@ -242,6 +254,8 @@ void wxPaintDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() == wxTRANSPARENT) return;
|
if (m_pen.GetStyle() == wxTRANSPARENT) return;
|
||||||
|
|
||||||
for (int i = 0; i < n-1; i++)
|
for (int i = 0; i < n-1; i++)
|
||||||
@@ -258,6 +272,8 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() == wxTRANSPARENT) return;
|
if (m_pen.GetStyle() == wxTRANSPARENT) return;
|
||||||
|
|
||||||
wxNode *node = points->First();
|
wxNode *node = points->First();
|
||||||
@@ -274,10 +290,12 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPaintDC::DrawPolygon( int n, wxPoint points[],
|
void wxPaintDC::DrawPolygon( int n, wxPoint points[], long xoffset, long yoffset, int WXUNUSED(fillStyle) )
|
||||||
long xoffset, long yoffset, int WXUNUSED(fillStyle) )
|
{
|
||||||
{
|
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (!n) return; // Nothing to draw
|
if (!n) return; // Nothing to draw
|
||||||
GdkPoint *gdkpoints = new GdkPoint[n+1];
|
GdkPoint *gdkpoints = new GdkPoint[n+1];
|
||||||
int i;
|
int i;
|
||||||
@@ -299,12 +317,13 @@ void wxPaintDC::DrawPolygon( int n, wxPoint points[],
|
|||||||
delete[] gdkpoints;
|
delete[] gdkpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPaintDC::DrawPolygon( wxList *lines, long xoffset,
|
void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, long yoffset, int WXUNUSED(fillStyle))
|
||||||
long yoffset, int WXUNUSED(fillStyle))
|
{
|
||||||
{
|
|
||||||
int n = lines->Number();
|
|
||||||
|
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
|
int n = lines->Number();
|
||||||
GdkPoint *gdkpoints = new GdkPoint[n];
|
GdkPoint *gdkpoints = new GdkPoint[n];
|
||||||
wxNode *node = lines->First();
|
wxNode *node = lines->First();
|
||||||
int cnt=0;
|
int cnt=0;
|
||||||
@@ -336,6 +355,8 @@ void wxPaintDC::DrawRectangle( long x, long y, long width, long height )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
long xx = XLOG2DEV(x);
|
long xx = XLOG2DEV(x);
|
||||||
long yy = YLOG2DEV(y);
|
long yy = YLOG2DEV(y);
|
||||||
long ww = m_signX * XLOG2DEVREL(width);
|
long ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -359,6 +380,8 @@ void wxPaintDC::DrawRoundedRectangle( long x, long y, long width, long height, d
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
|
if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
|
||||||
|
|
||||||
long xx = XLOG2DEV(x);
|
long xx = XLOG2DEV(x);
|
||||||
@@ -424,6 +447,8 @@ void wxPaintDC::DrawEllipse( long x, long y, long width, long height )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
long xx = XLOG2DEV(x);
|
long xx = XLOG2DEV(x);
|
||||||
long yy = YLOG2DEV(y);
|
long yy = YLOG2DEV(y);
|
||||||
long ww = m_signX * XLOG2DEVREL(width);
|
long ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -451,6 +476,8 @@ void wxPaintDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask )
|
|||||||
|
|
||||||
if (!icon.Ok()) return;
|
if (!icon.Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
int xx = XLOG2DEV(x);
|
int xx = XLOG2DEV(x);
|
||||||
int yy = YLOG2DEV(y);
|
int yy = YLOG2DEV(y);
|
||||||
|
|
||||||
@@ -478,6 +505,8 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
|
|||||||
{
|
{
|
||||||
if (!Ok()) return FALSE;
|
if (!Ok()) return FALSE;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
// CMB 20/5/98: add blitting of bitmaps
|
// CMB 20/5/98: add blitting of bitmaps
|
||||||
if (source->IsKindOf(CLASSINFO(wxMemoryDC)))
|
if (source->IsKindOf(CLASSINFO(wxMemoryDC)))
|
||||||
{
|
{
|
||||||
@@ -485,14 +514,13 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
|
|||||||
GdkBitmap* bmap = srcDC->m_selected.GetBitmap();
|
GdkBitmap* bmap = srcDC->m_selected.GetBitmap();
|
||||||
if (bmap)
|
if (bmap)
|
||||||
{
|
{
|
||||||
gdk_draw_bitmap (
|
gdk_draw_bitmap( m_window, m_textGC, bmap,
|
||||||
m_window,
|
source->DeviceToLogicalX(xsrc),
|
||||||
m_textGC,
|
source->DeviceToLogicalY(ysrc),
|
||||||
bmap,
|
XLOG2DEV(xdest),
|
||||||
source->DeviceToLogicalX(xsrc), source->DeviceToLogicalY(ysrc),
|
YLOG2DEV(ydest),
|
||||||
XLOG2DEV(xdest), YLOG2DEV(ydest),
|
source->DeviceToLogicalXRel(width),
|
||||||
source->DeviceToLogicalXRel(width), source->DeviceToLogicalYRel(height)
|
source->DeviceToLogicalYRel(height) );
|
||||||
);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,6 +547,8 @@ void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(us
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
GdkFont *font = m_font.GetInternalFont( m_scaleY );
|
GdkFont *font = m_font.GetInternalFont( m_scaleY );
|
||||||
|
|
||||||
x = XLOG2DEV(x);
|
x = XLOG2DEV(x);
|
||||||
@@ -588,7 +618,7 @@ void wxPaintDC::Clear(void)
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
// DestroyClippingRegion();
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_isDrawable)
|
if (m_isDrawable)
|
||||||
{
|
{
|
||||||
|
@@ -14,6 +14,10 @@
|
|||||||
|
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
|
|
||||||
|
#ifdef USE_GDK_IMLIB
|
||||||
|
#include "../gdk_imlib/gdk_imlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxMemoryDC
|
// wxMemoryDC
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -23,13 +27,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
|
|||||||
wxMemoryDC::wxMemoryDC(void)
|
wxMemoryDC::wxMemoryDC(void)
|
||||||
{
|
{
|
||||||
m_ok = FALSE;
|
m_ok = FALSE;
|
||||||
|
|
||||||
|
#ifdef USE_GDK_IMLIB
|
||||||
|
m_cmap = gdk_imlib_get_colormap();
|
||||||
|
#else
|
||||||
m_cmap = gdk_colormap_get_system();
|
m_cmap = gdk_colormap_get_system();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||||
{
|
{
|
||||||
m_ok = FALSE;
|
m_ok = FALSE;
|
||||||
|
|
||||||
|
#ifdef USE_GDK_IMLIB
|
||||||
|
m_cmap = gdk_imlib_get_colormap();
|
||||||
|
#else
|
||||||
m_cmap = gdk_colormap_get_system();
|
m_cmap = gdk_colormap_get_system();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMemoryDC::~wxMemoryDC(void)
|
wxMemoryDC::~wxMemoryDC(void)
|
||||||
|
@@ -150,7 +150,7 @@ bool wxMenuBar::Enabled( int id ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxMenu
|
// "activate"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
||||||
@@ -161,7 +161,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
|
|
||||||
if (!menu->IsEnabled(id)) return;
|
if (!menu->IsEnabled(id)) return;
|
||||||
|
|
||||||
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, id );
|
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
event.SetInt(id );
|
event.SetInt(id );
|
||||||
|
|
||||||
@@ -177,6 +177,38 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
if (win) win->GetEventHandler()->ProcessEvent( event );
|
if (win) win->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// "select"
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
|
||||||
|
{
|
||||||
|
int id = menu->FindMenuIdByMenuItem(widget);
|
||||||
|
|
||||||
|
wxASSERT( id != -1 ); // should find it!
|
||||||
|
|
||||||
|
if (!menu->IsEnabled(id)) return;
|
||||||
|
|
||||||
|
wxCommandEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
||||||
|
event.SetEventObject( menu );
|
||||||
|
event.SetInt(id );
|
||||||
|
|
||||||
|
if (menu->m_callback)
|
||||||
|
{
|
||||||
|
(void) (*(menu->m_callback)) (*menu, event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu->GetEventHandler()->ProcessEvent(event)) return;
|
||||||
|
|
||||||
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
|
if (win) win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxMenu
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject)
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem()
|
wxMenuItem::wxMenuItem()
|
||||||
@@ -283,6 +315,10 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool
|
|||||||
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
|
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
|
||||||
(gpointer*)this );
|
(gpointer*)this );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(menuItem), "select",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
|
||||||
|
(gpointer*)this );
|
||||||
|
|
||||||
gtk_menu_append( GTK_MENU(m_menu), menuItem );
|
gtk_menu_append( GTK_MENU(m_menu), menuItem );
|
||||||
gtk_widget_show( menuItem );
|
gtk_widget_show( menuItem );
|
||||||
m_items.Append( mitem );
|
m_items.Append( mitem );
|
||||||
|
@@ -17,7 +17,12 @@
|
|||||||
#include "gdk/gdkprivate.h"
|
#include "gdk/gdkprivate.h"
|
||||||
|
|
||||||
#ifdef USE_GDK_IMLIB
|
#ifdef USE_GDK_IMLIB
|
||||||
|
|
||||||
#include "../gdk_imlib/gdk_imlib.h"
|
#include "../gdk_imlib/gdk_imlib.h"
|
||||||
|
#include "gdk/gdkx.h" // GDK_DISPLAY
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -223,7 +228,8 @@ bool wxBitmap::operator != ( const wxBitmap& bmp )
|
|||||||
|
|
||||||
bool wxBitmap::Ok(void) const
|
bool wxBitmap::Ok(void) const
|
||||||
{
|
{
|
||||||
return m_refData != NULL;
|
wxASSERT_MSG( m_refData != NULL, "invalid bitmap" );
|
||||||
|
return (m_refData != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxBitmap::GetHeight(void) const
|
int wxBitmap::GetHeight(void) const
|
||||||
@@ -247,18 +253,27 @@ int wxBitmap::GetDepth(void) const
|
|||||||
void wxBitmap::SetHeight( int height )
|
void wxBitmap::SetHeight( int height )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::SetHeight not implemented" );
|
||||||
|
|
||||||
M_BMPDATA->m_height = height;
|
M_BMPDATA->m_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::SetWidth( int width )
|
void wxBitmap::SetWidth( int width )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::SetWidth not implemented" );
|
||||||
|
|
||||||
M_BMPDATA->m_width = width;
|
M_BMPDATA->m_width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::SetDepth( int depth )
|
void wxBitmap::SetDepth( int depth )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::SetDepth not implemented" );
|
||||||
|
|
||||||
M_BMPDATA->m_bpp = depth;
|
M_BMPDATA->m_bpp = depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,6 +289,7 @@ void wxBitmap::SetMask( wxMask *mask )
|
|||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
|
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
|
||||||
|
|
||||||
M_BMPDATA->m_mask = mask;
|
M_BMPDATA->m_mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,6 +314,10 @@ void wxBitmap::Resize( int height, int width )
|
|||||||
|
|
||||||
Render();
|
Render();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::Resize not implemented without GdkImlib" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,6 +332,10 @@ bool wxBitmap::SaveFile( const wxString &name, int WXUNUSED(type),
|
|||||||
|
|
||||||
return gdk_imlib_save_image( M_BMPDATA->m_image, WXSTRINGCAST name, (GdkImlibSaveInfo *) NULL );
|
return gdk_imlib_save_image( M_BMPDATA->m_image, WXSTRINGCAST name, (GdkImlibSaveInfo *) NULL );
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::SaveFile not implemented without GdkImlib" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -338,6 +362,11 @@ bool wxBitmap::LoadFile( const wxString &name, int WXUNUSED(type) )
|
|||||||
M_BMPDATA->m_bpp = 24; // ?
|
M_BMPDATA->m_bpp = 24; // ?
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::LoadFile not implemented without GdkImlib" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -352,6 +381,9 @@ wxPalette *wxBitmap::GetPalette(void) const
|
|||||||
GdkPixmap *wxBitmap::GetPixmap(void) const
|
GdkPixmap *wxBitmap::GetPixmap(void) const
|
||||||
{
|
{
|
||||||
if (!Ok()) return (GdkPixmap *) NULL;
|
if (!Ok()) return (GdkPixmap *) NULL;
|
||||||
|
|
||||||
|
// if (!M_BMPDATA->m_image) RecreateImage();
|
||||||
|
|
||||||
return M_BMPDATA->m_pixmap;
|
return M_BMPDATA->m_pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,6 +407,53 @@ void wxBitmap::DestroyImage(void)
|
|||||||
|
|
||||||
void wxBitmap::RecreateImage(void)
|
void wxBitmap::RecreateImage(void)
|
||||||
{
|
{
|
||||||
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
#ifdef USE_GDK_IMLIB
|
||||||
|
|
||||||
|
DestroyImage();
|
||||||
|
|
||||||
|
wxCHECK_RET( M_BMPDATA->m_pixmap != NULL, "invalid bitmap" );
|
||||||
|
|
||||||
|
long size = (long)(M_BMPDATA->m_width)*(long)(M_BMPDATA->m_height)*(long)3;
|
||||||
|
unsigned char *data = new unsigned char[size];
|
||||||
|
for (long i = 0; i < size; i++) data[i] = 100;
|
||||||
|
|
||||||
|
GdkImage *image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height );
|
||||||
|
|
||||||
|
long pos = 0;
|
||||||
|
for (int j = 0; j < M_BMPDATA->m_height; j++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < M_BMPDATA->m_width; i++)
|
||||||
|
{
|
||||||
|
XColor xcol;
|
||||||
|
xcol.pixel = gdk_image_get_pixel( image, i, j );
|
||||||
|
Colormap cm = ((GdkColormapPrivate*)gdk_imlib_get_colormap())->xcolormap;
|
||||||
|
XQueryColor( gdk_display, cm, &xcol );
|
||||||
|
|
||||||
|
data[pos] = xcol.red;
|
||||||
|
data[pos+1] = xcol.green;
|
||||||
|
data[pos+2] = xcol.blue;
|
||||||
|
pos += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCHECK_RET( M_BMPDATA->m_pixmap != NULL, "invalid bitmap" );
|
||||||
|
|
||||||
|
M_BMPDATA->m_image = gdk_imlib_create_image_from_data(
|
||||||
|
data, (unsigned char*)NULL, M_BMPDATA->m_width, M_BMPDATA->m_height );
|
||||||
|
|
||||||
|
delete[] data;
|
||||||
|
|
||||||
|
gdk_image_destroy( image );
|
||||||
|
|
||||||
|
Render();
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::RecreateImage not implemented without GdkImlib" );
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::Render(void)
|
void wxBitmap::Render(void)
|
||||||
@@ -383,10 +462,26 @@ void wxBitmap::Render(void)
|
|||||||
|
|
||||||
#ifdef USE_GDK_IMLIB
|
#ifdef USE_GDK_IMLIB
|
||||||
|
|
||||||
|
if (!M_BMPDATA->m_image) RecreateImage();
|
||||||
|
|
||||||
|
if (M_BMPDATA->m_pixmap)
|
||||||
|
{
|
||||||
|
gdk_imlib_free_pixmap( M_BMPDATA->m_pixmap );
|
||||||
|
M_BMPDATA->m_pixmap = (GdkPixmap*) NULL;
|
||||||
|
}
|
||||||
|
if (M_BMPDATA->m_mask)
|
||||||
|
{
|
||||||
|
delete M_BMPDATA->m_mask;
|
||||||
|
M_BMPDATA->m_mask = (wxMask*) NULL;
|
||||||
|
}
|
||||||
|
|
||||||
gdk_imlib_render( M_BMPDATA->m_image, M_BMPDATA->m_image->rgb_width, M_BMPDATA->m_image->rgb_height );
|
gdk_imlib_render( M_BMPDATA->m_image, M_BMPDATA->m_image->rgb_width, M_BMPDATA->m_image->rgb_height );
|
||||||
M_BMPDATA->m_width = M_BMPDATA->m_image->rgb_width;
|
M_BMPDATA->m_width = M_BMPDATA->m_image->rgb_width;
|
||||||
M_BMPDATA->m_height = M_BMPDATA->m_image->rgb_height;
|
M_BMPDATA->m_height = M_BMPDATA->m_image->rgb_height;
|
||||||
M_BMPDATA->m_pixmap = gdk_imlib_move_image( M_BMPDATA->m_image );
|
M_BMPDATA->m_pixmap = gdk_imlib_move_image( M_BMPDATA->m_image );
|
||||||
|
|
||||||
|
wxCHECK_RET( M_BMPDATA->m_pixmap != NULL, "pixmap rendering failed" )
|
||||||
|
|
||||||
GdkBitmap *mask = gdk_imlib_move_mask( M_BMPDATA->m_image );
|
GdkBitmap *mask = gdk_imlib_move_mask( M_BMPDATA->m_image );
|
||||||
if (mask)
|
if (mask)
|
||||||
{
|
{
|
||||||
@@ -394,6 +489,10 @@ void wxBitmap::Render(void)
|
|||||||
M_BMPDATA->m_mask->m_bitmap = mask;
|
M_BMPDATA->m_mask->m_bitmap = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxBitmap::Render not implemented without GdkImlib" );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,6 +83,12 @@ wxDC::~wxDC(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxDC::Ok(void) const
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( !ok, "invalid display context" );
|
||||||
|
return m_ok;
|
||||||
|
}
|
||||||
|
|
||||||
void wxDC::DrawArc( long WXUNUSED(x1), long WXUNUSED(y1), long WXUNUSED(x2), long WXUNUSED(y2),
|
void wxDC::DrawArc( long WXUNUSED(x1), long WXUNUSED(y1), long WXUNUSED(x2), long WXUNUSED(y2),
|
||||||
double WXUNUSED(xc), double WXUNUSED(yc) )
|
double WXUNUSED(xc), double WXUNUSED(yc) )
|
||||||
{
|
{
|
||||||
|
@@ -124,10 +124,12 @@ wxPaintDC::~wxPaintDC(void)
|
|||||||
void wxPaintDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1),
|
void wxPaintDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1),
|
||||||
wxColour *WXUNUSED(col), int WXUNUSED(style) )
|
wxColour *WXUNUSED(col), int WXUNUSED(style) )
|
||||||
{
|
{
|
||||||
|
wxFAIL_MSG( "wxPaintDC::FloodFill not implemented" );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPaintDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const
|
bool wxPaintDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const
|
||||||
{
|
{
|
||||||
|
wxFAIL_MSG( "wxPaintDC::GetPixel not implemented" );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +137,8 @@ void wxPaintDC::DrawLine( long x1, long y1, long x2, long y2 )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
gdk_draw_line( m_window, m_penGC,
|
gdk_draw_line( m_window, m_penGC,
|
||||||
@@ -146,6 +150,8 @@ void wxPaintDC::CrossHair( long x, long y )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
int w = 0;
|
int w = 0;
|
||||||
@@ -164,6 +170,8 @@ void wxPaintDC::DrawArc( long x1, long y1, long x2, long y2, double xc, double y
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
long xx1 = XLOG2DEV(x1);
|
long xx1 = XLOG2DEV(x1);
|
||||||
long yy1 = YLOG2DEV(y1);
|
long yy1 = YLOG2DEV(y1);
|
||||||
long xx2 = XLOG2DEV(x2);
|
long xx2 = XLOG2DEV(x2);
|
||||||
@@ -212,6 +220,8 @@ void wxPaintDC::DrawEllipticArc( long x, long y, long width, long height, double
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
long xx = XLOG2DEV(x);
|
long xx = XLOG2DEV(x);
|
||||||
long yy = YLOG2DEV(y);
|
long yy = YLOG2DEV(y);
|
||||||
long ww = m_signX * XLOG2DEVREL(width);
|
long ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -234,6 +244,8 @@ void wxPaintDC::DrawPoint( long x, long y )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() != wxTRANSPARENT)
|
if (m_pen.GetStyle() != wxTRANSPARENT)
|
||||||
gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) );
|
gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) );
|
||||||
}
|
}
|
||||||
@@ -242,6 +254,8 @@ void wxPaintDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() == wxTRANSPARENT) return;
|
if (m_pen.GetStyle() == wxTRANSPARENT) return;
|
||||||
|
|
||||||
for (int i = 0; i < n-1; i++)
|
for (int i = 0; i < n-1; i++)
|
||||||
@@ -258,6 +272,8 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_pen.GetStyle() == wxTRANSPARENT) return;
|
if (m_pen.GetStyle() == wxTRANSPARENT) return;
|
||||||
|
|
||||||
wxNode *node = points->First();
|
wxNode *node = points->First();
|
||||||
@@ -274,10 +290,12 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPaintDC::DrawPolygon( int n, wxPoint points[],
|
void wxPaintDC::DrawPolygon( int n, wxPoint points[], long xoffset, long yoffset, int WXUNUSED(fillStyle) )
|
||||||
long xoffset, long yoffset, int WXUNUSED(fillStyle) )
|
{
|
||||||
{
|
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (!n) return; // Nothing to draw
|
if (!n) return; // Nothing to draw
|
||||||
GdkPoint *gdkpoints = new GdkPoint[n+1];
|
GdkPoint *gdkpoints = new GdkPoint[n+1];
|
||||||
int i;
|
int i;
|
||||||
@@ -299,12 +317,13 @@ void wxPaintDC::DrawPolygon( int n, wxPoint points[],
|
|||||||
delete[] gdkpoints;
|
delete[] gdkpoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPaintDC::DrawPolygon( wxList *lines, long xoffset,
|
void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, long yoffset, int WXUNUSED(fillStyle))
|
||||||
long yoffset, int WXUNUSED(fillStyle))
|
{
|
||||||
{
|
|
||||||
int n = lines->Number();
|
|
||||||
|
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
|
int n = lines->Number();
|
||||||
GdkPoint *gdkpoints = new GdkPoint[n];
|
GdkPoint *gdkpoints = new GdkPoint[n];
|
||||||
wxNode *node = lines->First();
|
wxNode *node = lines->First();
|
||||||
int cnt=0;
|
int cnt=0;
|
||||||
@@ -336,6 +355,8 @@ void wxPaintDC::DrawRectangle( long x, long y, long width, long height )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
long xx = XLOG2DEV(x);
|
long xx = XLOG2DEV(x);
|
||||||
long yy = YLOG2DEV(y);
|
long yy = YLOG2DEV(y);
|
||||||
long ww = m_signX * XLOG2DEVREL(width);
|
long ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -359,6 +380,8 @@ void wxPaintDC::DrawRoundedRectangle( long x, long y, long width, long height, d
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
|
if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
|
||||||
|
|
||||||
long xx = XLOG2DEV(x);
|
long xx = XLOG2DEV(x);
|
||||||
@@ -424,6 +447,8 @@ void wxPaintDC::DrawEllipse( long x, long y, long width, long height )
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
long xx = XLOG2DEV(x);
|
long xx = XLOG2DEV(x);
|
||||||
long yy = YLOG2DEV(y);
|
long yy = YLOG2DEV(y);
|
||||||
long ww = m_signX * XLOG2DEVREL(width);
|
long ww = m_signX * XLOG2DEVREL(width);
|
||||||
@@ -451,6 +476,8 @@ void wxPaintDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask )
|
|||||||
|
|
||||||
if (!icon.Ok()) return;
|
if (!icon.Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
int xx = XLOG2DEV(x);
|
int xx = XLOG2DEV(x);
|
||||||
int yy = YLOG2DEV(y);
|
int yy = YLOG2DEV(y);
|
||||||
|
|
||||||
@@ -478,6 +505,8 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
|
|||||||
{
|
{
|
||||||
if (!Ok()) return FALSE;
|
if (!Ok()) return FALSE;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
// CMB 20/5/98: add blitting of bitmaps
|
// CMB 20/5/98: add blitting of bitmaps
|
||||||
if (source->IsKindOf(CLASSINFO(wxMemoryDC)))
|
if (source->IsKindOf(CLASSINFO(wxMemoryDC)))
|
||||||
{
|
{
|
||||||
@@ -485,14 +514,13 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
|
|||||||
GdkBitmap* bmap = srcDC->m_selected.GetBitmap();
|
GdkBitmap* bmap = srcDC->m_selected.GetBitmap();
|
||||||
if (bmap)
|
if (bmap)
|
||||||
{
|
{
|
||||||
gdk_draw_bitmap (
|
gdk_draw_bitmap( m_window, m_textGC, bmap,
|
||||||
m_window,
|
source->DeviceToLogicalX(xsrc),
|
||||||
m_textGC,
|
source->DeviceToLogicalY(ysrc),
|
||||||
bmap,
|
XLOG2DEV(xdest),
|
||||||
source->DeviceToLogicalX(xsrc), source->DeviceToLogicalY(ysrc),
|
YLOG2DEV(ydest),
|
||||||
XLOG2DEV(xdest), YLOG2DEV(ydest),
|
source->DeviceToLogicalXRel(width),
|
||||||
source->DeviceToLogicalXRel(width), source->DeviceToLogicalYRel(height)
|
source->DeviceToLogicalYRel(height) );
|
||||||
);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,6 +547,8 @@ void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(us
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
GdkFont *font = m_font.GetInternalFont( m_scaleY );
|
GdkFont *font = m_font.GetInternalFont( m_scaleY );
|
||||||
|
|
||||||
x = XLOG2DEV(x);
|
x = XLOG2DEV(x);
|
||||||
@@ -588,7 +618,7 @@ void wxPaintDC::Clear(void)
|
|||||||
{
|
{
|
||||||
if (!Ok()) return;
|
if (!Ok()) return;
|
||||||
|
|
||||||
// DestroyClippingRegion();
|
if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
|
||||||
|
|
||||||
if (m_isDrawable)
|
if (m_isDrawable)
|
||||||
{
|
{
|
||||||
|
@@ -14,6 +14,10 @@
|
|||||||
|
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
|
|
||||||
|
#ifdef USE_GDK_IMLIB
|
||||||
|
#include "../gdk_imlib/gdk_imlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxMemoryDC
|
// wxMemoryDC
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -23,13 +27,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxPaintDC)
|
|||||||
wxMemoryDC::wxMemoryDC(void)
|
wxMemoryDC::wxMemoryDC(void)
|
||||||
{
|
{
|
||||||
m_ok = FALSE;
|
m_ok = FALSE;
|
||||||
|
|
||||||
|
#ifdef USE_GDK_IMLIB
|
||||||
|
m_cmap = gdk_imlib_get_colormap();
|
||||||
|
#else
|
||||||
m_cmap = gdk_colormap_get_system();
|
m_cmap = gdk_colormap_get_system();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||||
{
|
{
|
||||||
m_ok = FALSE;
|
m_ok = FALSE;
|
||||||
|
|
||||||
|
#ifdef USE_GDK_IMLIB
|
||||||
|
m_cmap = gdk_imlib_get_colormap();
|
||||||
|
#else
|
||||||
m_cmap = gdk_colormap_get_system();
|
m_cmap = gdk_colormap_get_system();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMemoryDC::~wxMemoryDC(void)
|
wxMemoryDC::~wxMemoryDC(void)
|
||||||
|
@@ -150,7 +150,7 @@ bool wxMenuBar::Enabled( int id ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxMenu
|
// "activate"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
||||||
@@ -161,7 +161,7 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
|
|
||||||
if (!menu->IsEnabled(id)) return;
|
if (!menu->IsEnabled(id)) return;
|
||||||
|
|
||||||
wxCommandEvent event( wxEVENT_TYPE_MENU_COMMAND, id );
|
wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, id );
|
||||||
event.SetEventObject( menu );
|
event.SetEventObject( menu );
|
||||||
event.SetInt(id );
|
event.SetInt(id );
|
||||||
|
|
||||||
@@ -177,6 +177,38 @@ static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu )
|
|||||||
if (win) win->GetEventHandler()->ProcessEvent( event );
|
if (win) win->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// "select"
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu )
|
||||||
|
{
|
||||||
|
int id = menu->FindMenuIdByMenuItem(widget);
|
||||||
|
|
||||||
|
wxASSERT( id != -1 ); // should find it!
|
||||||
|
|
||||||
|
if (!menu->IsEnabled(id)) return;
|
||||||
|
|
||||||
|
wxCommandEvent event( wxEVT_MENU_HIGHLIGHT, id );
|
||||||
|
event.SetEventObject( menu );
|
||||||
|
event.SetInt(id );
|
||||||
|
|
||||||
|
if (menu->m_callback)
|
||||||
|
{
|
||||||
|
(void) (*(menu->m_callback)) (*menu, event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu->GetEventHandler()->ProcessEvent(event)) return;
|
||||||
|
|
||||||
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
|
if (win) win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxMenu
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem,wxObject)
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem()
|
wxMenuItem::wxMenuItem()
|
||||||
@@ -283,6 +315,10 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool
|
|||||||
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
|
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
|
||||||
(gpointer*)this );
|
(gpointer*)this );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(menuItem), "select",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
|
||||||
|
(gpointer*)this );
|
||||||
|
|
||||||
gtk_menu_append( GTK_MENU(m_menu), menuItem );
|
gtk_menu_append( GTK_MENU(m_menu), menuItem );
|
||||||
gtk_widget_show( menuItem );
|
gtk_widget_show( menuItem );
|
||||||
m_items.Append( mitem );
|
m_items.Append( mitem );
|
||||||
|
Reference in New Issue
Block a user