Changed wxRootWindow from a global to a staic variable with an

accessor function that initializes if on first use.  This prevents
core dumps for apps that try to create wxBitmaps before the wxApp
object is initialized.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10129 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-05-11 17:55:28 +00:00
parent a90c95aa8e
commit c2fa61e833
12 changed files with 234 additions and 210 deletions

View File

@@ -52,7 +52,7 @@ extern bool g_isIdle;
bool g_mainThreadLocked = FALSE; bool g_mainThreadLocked = FALSE;
gint g_pendingTag = 0; gint g_pendingTag = 0;
GtkWidget *wxRootWindow = (GtkWidget*) NULL; static GtkWidget *gs_RootWindow = (GtkWidget*) NULL;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// local functions // local functions
@@ -92,11 +92,11 @@ bool wxYield()
} }
#endif // wxUSE_THREADS #endif // wxUSE_THREADS
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
if (gs_inYield) if (gs_inYield)
wxFAIL_MSG( wxT("wxYield called recursively" ) ); wxFAIL_MSG( wxT("wxYield called recursively" ) );
#endif #endif
gs_inYield = TRUE; gs_inYield = TRUE;
if (!g_isIdle) if (!g_isIdle)
@@ -137,8 +137,8 @@ bool wxYieldIfNeeded()
{ {
if (gs_inYield) if (gs_inYield)
return FALSE; return FALSE;
return wxYield(); return wxYield();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -168,7 +168,7 @@ void wxWakeUpIdle()
gint wxapp_pending_callback( gpointer WXUNUSED(data) ) gint wxapp_pending_callback( gpointer WXUNUSED(data) )
{ {
if (!wxTheApp) return TRUE; if (!wxTheApp) return TRUE;
// when getting called from GDK's time-out handler // when getting called from GDK's time-out handler
// we are no longer within GDK's grab on the GUI // we are no longer within GDK's grab on the GUI
// thread so we must lock it here ourselves // thread so we must lock it here ourselves
@@ -195,7 +195,7 @@ gint wxapp_pending_callback( gpointer WXUNUSED(data) )
gint wxapp_idle_callback( gpointer WXUNUSED(data) ) gint wxapp_idle_callback( gpointer WXUNUSED(data) )
{ {
if (!wxTheApp) return TRUE; if (!wxTheApp) return TRUE;
// when getting called from GDK's time-out handler // when getting called from GDK's time-out handler
// we are no longer within GDK's grab on the GUI // we are no longer within GDK's grab on the GUI
// thread so we must lock it here ourselves // thread so we must lock it here ourselves
@@ -228,7 +228,7 @@ void wxapp_install_idle_handler()
if (g_pendingTag == 0) if (g_pendingTag == 0)
g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL );
/* This routine gets called by all event handlers /* This routine gets called by all event handlers
indicating that the idle is over. It may also indicating that the idle is over. It may also
get called from other thread for sending events get called from other thread for sending events
@@ -245,7 +245,7 @@ static int g_threadUninstallLevel = 0;
void wxapp_install_thread_wakeup() void wxapp_install_thread_wakeup()
{ {
g_threadUninstallLevel++; g_threadUninstallLevel++;
if (g_threadUninstallLevel != 1) return; if (g_threadUninstallLevel != 1) return;
if (wxTheApp->m_wakeUpTimerTag) return; if (wxTheApp->m_wakeUpTimerTag) return;
@@ -256,7 +256,7 @@ void wxapp_install_thread_wakeup()
void wxapp_uninstall_thread_wakeup() void wxapp_uninstall_thread_wakeup()
{ {
g_threadUninstallLevel--; g_threadUninstallLevel--;
if (g_threadUninstallLevel != 0) return; if (g_threadUninstallLevel != 0) return;
if (!wxTheApp->m_wakeUpTimerTag) return; if (!wxTheApp->m_wakeUpTimerTag) return;
@@ -626,6 +626,19 @@ void wxApp::CleanUp()
#endif // wxUSE_LOG #endif // wxUSE_LOG
} }
//-----------------------------------------------------------------------------
// Access to the root window global
//-----------------------------------------------------------------------------
GtkWidget* wxGetRootWindow()
{
if (gs_RootWindow == NULL) {
gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_widget_realize( gs_RootWindow );
}
return gs_RootWindow;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxEntry // wxEntry
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -676,6 +689,7 @@ int wxEntryStart( int argc, char *argv[] )
return 0; return 0;
} }
int wxEntryInitGui() int wxEntryInitGui()
{ {
int retValue = 0; int retValue = 0;
@@ -683,8 +697,7 @@ int wxEntryInitGui()
if ( !wxTheApp->OnInitGui() ) if ( !wxTheApp->OnInitGui() )
retValue = -1; retValue = -1;
wxRootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL ); wxGetRootWindow();
gtk_widget_realize( wxRootWindow );
return retValue; return retValue;
} }

View File

@@ -40,7 +40,7 @@ extern void gdk_wx_draw_bitmap (GdkDrawable *drawable,
// data // data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMask // wxMask
@@ -89,7 +89,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
wxImage image( bitmap ); wxImage image( bitmap );
if (!image.Ok()) return FALSE; if (!image.Ok()) return FALSE;
m_bitmap = gdk_pixmap_new( wxRootWindow->window, image.GetWidth(), image.GetHeight(), 1 ); m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
GdkGC *gc = gdk_gc_new( m_bitmap ); GdkGC *gc = gdk_gc_new( m_bitmap );
GdkColor color; GdkColor color;
@@ -108,9 +108,9 @@ bool wxMask::Create( const wxBitmap& bitmap,
unsigned char green = colour.Green(); unsigned char green = colour.Green();
unsigned char blue = colour.Blue(); unsigned char blue = colour.Blue();
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
int bpp = visual->depth; int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp == 15) if (bpp == 15)
@@ -170,7 +170,7 @@ bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
wxPalette *pal = bitmap.GetPalette(); wxPalette *pal = bitmap.GetPalette();
wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") ); wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") );
pal->GetRGB(paletteIndex, &r, &g, &b); pal->GetRGB(paletteIndex, &r, &g, &b);
return Create(bitmap, wxColour(r, g, b)); return Create(bitmap, wxColour(r, g, b));
@@ -188,7 +188,7 @@ bool wxMask::Create( const wxBitmap& bitmap )
wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") ); wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") );
m_bitmap = gdk_pixmap_new( wxRootWindow->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 ); m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
if (!m_bitmap) return FALSE; if (!m_bitmap) return FALSE;
@@ -268,7 +268,7 @@ bool wxBitmap::Create( int width, int height, int depth )
wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") ) wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") )
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
if (depth == -1) depth = visual->depth; if (depth == -1) depth = visual->depth;
@@ -282,12 +282,12 @@ bool wxBitmap::Create( int width, int height, int depth )
M_BMPDATA->m_height = height; M_BMPDATA->m_height = height;
if (depth == 1) if (depth == 1)
{ {
M_BMPDATA->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 ); M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
M_BMPDATA->m_bpp = 1; M_BMPDATA->m_bpp = 1;
} }
else else
{ {
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxRootWindow->window, width, height, depth ); M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth );
M_BMPDATA->m_bpp = visual->depth; M_BMPDATA->m_bpp = visual->depth;
} }
@@ -298,14 +298,14 @@ bool wxBitmap::CreateFromXpm( const char **bits )
{ {
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") ) wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL; GdkBitmap *mask = (GdkBitmap*) NULL;
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxRootWindow->window, &mask, NULL, (gchar **) bits ); M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits );
wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") ); wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") );
@@ -318,13 +318,12 @@ bool wxBitmap::CreateFromXpm( const char **bits )
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = visual->depth; // ? M_BMPDATA->m_bpp = visual->depth; // ?
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
return TRUE; return TRUE;
} }
extern GtkWidget *wxRootWindow;
bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
{ {
@@ -332,7 +331,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") ) wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
// ------ // ------
@@ -346,11 +345,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetHeight( height ); SetHeight( height );
SetWidth( width ); SetWidth( width );
SetBitmap( gdk_pixmap_new( wxRootWindow->window, width, height, 1 ) ); SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
SetDepth( 1 ); SetDepth( 1 );
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
// Create picture image // Create picture image
@@ -371,7 +370,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
mask_image = gdk_image_new_bitmap( visual, mask_data, width, height ); mask_image = gdk_image_new_bitmap( visual, mask_data, width, height );
wxMask *mask = new wxMask(); wxMask *mask = new wxMask();
mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 ); mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
SetMask( mask ); SetMask( mask );
} }
@@ -431,7 +430,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
gdk_gc_unref( mask_gc ); gdk_gc_unref( mask_gc );
} }
} }
// ------ // ------
// convertion to colour bitmap: // convertion to colour bitmap:
// ------ // ------
@@ -443,11 +442,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetHeight( height ); SetHeight( height );
SetWidth( width ); SetWidth( width );
SetPixmap( gdk_pixmap_new( wxRootWindow->window, width, height, -1 ) ); SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
// Retrieve depth // Retrieve depth
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
int bpp = visual->depth; int bpp = visual->depth;
@@ -501,7 +500,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
mask_image = gdk_image_new_bitmap( visual, mask_data, width, height ); mask_image = gdk_image_new_bitmap( visual, mask_data, width, height );
wxMask *mask = new wxMask(); wxMask *mask = new wxMask();
mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 ); mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
SetMask( mask ); SetMask( mask );
} }
@@ -636,7 +635,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
wxImage wxBitmap::ConvertToImage() const wxImage wxBitmap::ConvertToImage() const
{ {
wxImage image; wxImage image;
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
GdkImage *gdk_image = (GdkImage*) NULL; GdkImage *gdk_image = (GdkImage*) NULL;
@@ -657,7 +656,7 @@ wxImage wxBitmap::ConvertToImage() const
} }
wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") ); wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") );
image.Create( GetWidth(), GetHeight() ); image.Create( GetWidth(), GetHeight() );
char unsigned *data = image.GetData(); char unsigned *data = image.GetData();
@@ -691,7 +690,7 @@ wxImage wxBitmap::ConvertToImage() const
{ {
GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); GdkVisual *visual = gdk_window_get_visual( GetPixmap() );
if (visual == NULL) visual = gdk_window_get_visual( wxRootWindow->window ); if (visual == NULL) visual = gdk_window_get_visual( wxGetRootWindow()->window );
bpp = visual->depth; bpp = visual->depth;
if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec; if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
red_shift_right = visual->red_shift; red_shift_right = visual->red_shift;
@@ -765,7 +764,7 @@ wxImage wxBitmap::ConvertToImage() const
} }
gdk_image_destroy( gdk_image ); gdk_image_destroy( gdk_image );
if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); if (gdk_image_mask) gdk_image_destroy( gdk_image_mask );
return image; return image;
} }
@@ -790,7 +789,7 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth
M_BMPDATA->m_mask = (wxMask *) NULL; M_BMPDATA->m_mask = (wxMask *) NULL;
M_BMPDATA->m_bitmap = M_BMPDATA->m_bitmap =
gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) bits, width, height ); gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height );
M_BMPDATA->m_width = width; M_BMPDATA->m_width = width;
M_BMPDATA->m_height = height; M_BMPDATA->m_height = height;
M_BMPDATA->m_bpp = 1; M_BMPDATA->m_bpp = 1;
@@ -890,7 +889,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
if (GetMask()) if (GetMask())
{ {
wxMask *mask = new wxMask; wxMask *mask = new wxMask;
mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, rect.width, rect.height, 1 ); mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, rect.width, rect.height, 1 );
GdkGC *gc = gdk_gc_new( mask->m_bitmap ); GdkGC *gc = gdk_gc_new( mask->m_bitmap );
gdk_wx_draw_bitmap( mask->m_bitmap, gc, M_BMPDATA->m_mask->m_bitmap, 0, 0, rect.x, rect.y, rect.width, rect.height ); gdk_wx_draw_bitmap( mask->m_bitmap, gc, M_BMPDATA->m_mask->m_bitmap, 0, 0, rect.x, rect.y, rect.width, rect.height );
@@ -921,16 +920,16 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
if (!wxFileExists(name)) return FALSE; if (!wxFileExists(name)) return FALSE;
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
if (type == wxBITMAP_TYPE_XPM) if (type == wxBITMAP_TYPE_XPM)
{ {
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL; GdkBitmap *mask = (GdkBitmap*) NULL;
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( wxRootWindow->window, &mask, NULL, name.fn_str() ); M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( wxGetRootWindow()->window, &mask, NULL, name.fn_str() );
if (mask) if (mask)
{ {
@@ -939,7 +938,7 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
} }
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = visual->depth; M_BMPDATA->m_bpp = visual->depth;
} }
else // try if wxImage can load it else // try if wxImage can load it

View File

@@ -110,7 +110,7 @@ wxCursor::wxCursor( int cursorId )
M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur );
} }
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
wxCursor::wxCursor(const char bits[], int width, int height, wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY, int hotSpotX, int hotSpotY,
@@ -127,8 +127,8 @@ wxCursor::wxCursor(const char bits[], int width, int height,
if (hotSpotY < 0 || hotSpotY >= height) if (hotSpotY < 0 || hotSpotY >= height)
hotSpotY = 0; hotSpotY = 0;
GdkBitmap *data = gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) bits, width, height ); GdkBitmap *data = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height );
GdkBitmap *mask = gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) maskBits, width, height); GdkBitmap *mask = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) maskBits, width, height);
m_refData = new wxCursorRefData; m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap( M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(

View File

@@ -54,7 +54,7 @@
static GdkPixmap *hatches[num_hatches]; static GdkPixmap *hatches[num_hatches];
static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL; static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL;
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// constants // constants
@@ -415,7 +415,7 @@ bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
memdc.SelectObject(bitmap); memdc.SelectObject(bitmap);
memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1); memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1);
memdc.SelectObject(wxNullBitmap); memdc.SelectObject(wxNullBitmap);
wxImage image(bitmap); wxImage image(bitmap);
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0)); col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
return TRUE; return TRUE;
@@ -1021,7 +1021,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
{ {
GdkColor col; GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, ww, hh, 1 ); new_mask = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, 1 );
GdkGC *gc = gdk_gc_new( new_mask ); GdkGC *gc = gdk_gc_new( new_mask );
col.pixel = 0; col.pixel = 0;
gdk_gc_set_foreground( gc, &col ); gdk_gc_set_foreground( gc, &col );
@@ -1206,7 +1206,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
{ {
GdkColor col; GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, bm_ww, bm_hh, 1 ); new_mask = gdk_pixmap_new( wxGetRootWindow()->window, bm_ww, bm_hh, 1 );
GdkGC *gc = gdk_gc_new( new_mask ); GdkGC *gc = gdk_gc_new( new_mask );
col.pixel = 0; col.pixel = 0;
gdk_gc_set_foreground( gc, &col ); gdk_gc_set_foreground( gc, &col );

View File

@@ -37,7 +37,7 @@ extern bool g_isIdle;
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// local functions // local functions
@@ -47,7 +47,7 @@ extern GtkWidget *wxRootWindow;
static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h ) static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h )
{ {
int org_x = 0; int org_x = 0;
int org_y = 0; int org_y = 0;
gdk_window_get_origin( widget->window, &org_x, &org_y ); gdk_window_get_origin( widget->window, &org_x, &org_y );
x += org_x; x += org_x;
@@ -56,7 +56,7 @@ static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h )
GdkGC *gc = gdk_gc_new( GDK_ROOT_PARENT() ); GdkGC *gc = gdk_gc_new( GDK_ROOT_PARENT() );
gdk_gc_set_subwindow( gc, GDK_INCLUDE_INFERIORS ); gdk_gc_set_subwindow( gc, GDK_INCLUDE_INFERIORS );
gdk_gc_set_function( gc, GDK_INVERT ); gdk_gc_set_function( gc, GDK_INVERT );
gdk_draw_rectangle( GDK_ROOT_PARENT(), gc, FALSE, x, y, w, h ); gdk_draw_rectangle( GDK_ROOT_PARENT(), gc, FALSE, x, y, w, h );
gdk_gc_unref( gc ); gdk_gc_unref( gc );
} }
@@ -71,10 +71,10 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
if (gdk_event->count > 0) return; if (gdk_event->count > 0) return;
GtkPizza *pizza = GTK_PIZZA(widget); GtkPizza *pizza = GTK_PIZZA(widget);
gtk_draw_shadow( widget->style, gtk_draw_shadow( widget->style,
pizza->bin_window, pizza->bin_window,
GTK_STATE_NORMAL, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, GTK_SHADOW_OUT,
@@ -82,26 +82,26 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
win->m_width, win->m_height ); win->m_width, win->m_height );
if (!win->m_title.IsEmpty() && if (!win->m_title.IsEmpty() &&
((win->GetWindowStyle() & wxCAPTION) || ((win->GetWindowStyle() & wxCAPTION) ||
(win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
(win->GetWindowStyle() & wxTINY_CAPTION_VERT))) (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
{ {
GdkGC *gc = gdk_gc_new( pizza->bin_window ); GdkGC *gc = gdk_gc_new( pizza->bin_window );
GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
gdk_draw_rectangle( pizza->bin_window, gc, TRUE, gdk_draw_rectangle( pizza->bin_window, gc, TRUE,
3, 3,
3, 3,
win->m_width - 7, win->m_width - 7,
font->ascent + font->descent+1 ); font->ascent + font->descent+1 );
gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] ); gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] );
gdk_draw_string( pizza->bin_window, font, gc, gdk_draw_string( pizza->bin_window, font, gc,
6, 6,
3+font->ascent, 3+font->ascent,
win->m_title.mb_str() ); win->m_title.mb_str() );
gdk_gc_unref( gc ); gdk_gc_unref( gc );
} }
} }
@@ -115,37 +115,37 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU
if (g_isIdle) wxapp_install_idle_handler(); if (g_isIdle) wxapp_install_idle_handler();
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
GtkPizza *pizza = GTK_PIZZA(widget); GtkPizza *pizza = GTK_PIZZA(widget);
gtk_draw_shadow( widget->style, gtk_draw_shadow( widget->style,
pizza->bin_window, pizza->bin_window,
GTK_STATE_NORMAL, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, GTK_SHADOW_OUT,
0, 0, 0, 0,
win->m_width, win->m_height ); win->m_width, win->m_height );
if (!win->m_title.IsEmpty() && if (!win->m_title.IsEmpty() &&
((win->GetWindowStyle() & wxCAPTION) || ((win->GetWindowStyle() & wxCAPTION) ||
(win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
(win->GetWindowStyle() & wxTINY_CAPTION_VERT))) (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
{ {
GdkGC *gc = gdk_gc_new( pizza->bin_window ); GdkGC *gc = gdk_gc_new( pizza->bin_window );
GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
gdk_draw_rectangle( pizza->bin_window, gc, TRUE, gdk_draw_rectangle( pizza->bin_window, gc, TRUE,
3, 3,
3, 3,
win->m_width - 7, win->m_width - 7,
font->ascent + font->descent+1 ); font->ascent + font->descent+1 );
gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] ); gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] );
gdk_draw_string( pizza->bin_window, font, gc, gdk_draw_string( pizza->bin_window, font, gc,
6, 6,
3+font->ascent, 3+font->ascent,
win->m_title.mb_str() ); win->m_title.mb_str() );
gdk_gc_unref( gc ); gdk_gc_unref( gc );
} }
} }
@@ -165,7 +165,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
if (win->m_isDragging) return TRUE; if (win->m_isDragging) return TRUE;
gdk_window_raise( win->m_widget->window ); gdk_window_raise( win->m_widget->window );
gdk_pointer_grab( widget->window, FALSE, gdk_pointer_grab( widget->window, FALSE,
(GdkEventMask) (GdkEventMask)
(GDK_BUTTON_PRESS_MASK | (GDK_BUTTON_PRESS_MASK |
@@ -177,13 +177,13 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
(GdkWindow *) NULL, (GdkWindow *) NULL,
(GdkCursor *) NULL, (GdkCursor *) NULL,
(unsigned int) GDK_CURRENT_TIME ); (unsigned int) GDK_CURRENT_TIME );
win->m_diffX = (int)gdk_event->x; win->m_diffX = (int)gdk_event->x;
win->m_diffY = (int)gdk_event->y; win->m_diffY = (int)gdk_event->y;
DrawFrame( widget, 0, 0, win->m_width, win->m_height ); DrawFrame( widget, 0, 0, win->m_width, win->m_height );
win->m_oldX = 0; win->m_oldX = 0;
win->m_oldY = 0; win->m_oldY = 0;
win->m_isDragging = TRUE; win->m_isDragging = TRUE;
return TRUE; return TRUE;
@@ -202,15 +202,15 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
if (g_blockEventsOnScroll) return TRUE; if (g_blockEventsOnScroll) return TRUE;
if (!win->m_isDragging) return TRUE; if (!win->m_isDragging) return TRUE;
win->m_isDragging = FALSE; win->m_isDragging = FALSE;
int x = (int)gdk_event->x; int x = (int)gdk_event->x;
int y = (int)gdk_event->y; int y = (int)gdk_event->y;
DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME ); gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME );
int org_x = 0; int org_x = 0;
int org_y = 0; int org_y = 0;
gdk_window_get_origin( widget->window, &org_x, &org_y ); gdk_window_get_origin( widget->window, &org_x, &org_y );
x += org_x - win->m_diffX; x += org_x - win->m_diffX;
@@ -235,7 +235,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
if (g_blockEventsOnScroll) return TRUE; if (g_blockEventsOnScroll) return TRUE;
if (!win->m_isDragging) return TRUE; if (!win->m_isDragging) return TRUE;
if (gdk_event->is_hint) if (gdk_event->is_hint)
{ {
int x = 0; int x = 0;
@@ -251,7 +251,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
win->m_oldX = (int)gdk_event->x - win->m_diffX; win->m_oldX = (int)gdk_event->x - win->m_diffX;
win->m_oldY = (int)gdk_event->y - win->m_diffY; win->m_oldY = (int)gdk_event->y - win->m_diffY;
DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
return TRUE; return TRUE;
} }
@@ -307,47 +307,47 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title
if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT)) if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))
m_miniTitle = 13; m_miniTitle = 13;
m_miniEdge = 3; m_miniEdge = 3;
m_isDragging = FALSE; m_isDragging = FALSE;
m_oldX = -1; m_oldX = -1;
m_oldY = -1; m_oldY = -1;
m_diffX = 0; m_diffX = 0;
m_diffY = 0; m_diffY = 0;
wxFrame::Create( parent, id, title, pos, size, style, name ); wxFrame::Create( parent, id, title, pos, size, style, name );
if ((style & wxSYSTEM_MENU) && if ((style & wxSYSTEM_MENU) &&
((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT)))
{ {
GdkBitmap *mask = (GdkBitmap*) NULL; GdkBitmap *mask = (GdkBitmap*) NULL;
GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( wxRootWindow->window, &mask, NULL, cross_xpm ); GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, cross_xpm );
GtkWidget *pw = gtk_pixmap_new( pixmap, mask ); GtkWidget *pw = gtk_pixmap_new( pixmap, mask );
gdk_bitmap_unref( mask ); gdk_bitmap_unref( mask );
gdk_pixmap_unref( pixmap ); gdk_pixmap_unref( pixmap );
gtk_widget_show( pw ); gtk_widget_show( pw );
GtkWidget *close_button = gtk_button_new(); GtkWidget *close_button = gtk_button_new();
gtk_container_add( GTK_CONTAINER(close_button), pw ); gtk_container_add( GTK_CONTAINER(close_button), pw );
gtk_pizza_put( GTK_PIZZA(m_mainWidget), gtk_pizza_put( GTK_PIZZA(m_mainWidget),
close_button, close_button,
size.x-16, 4, 11, 11 ); size.x-16, 4, 11, 11 );
gtk_widget_show( close_button ); gtk_widget_show( close_button );
gtk_signal_connect( GTK_OBJECT(close_button), "clicked", gtk_signal_connect( GTK_OBJECT(close_button), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
} }
/* these are called when the borders are drawn */ /* these are called when the borders are drawn */
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
/* these are required for dragging the mini frame around */ /* these are required for dragging the mini frame around */
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event",
GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this );

View File

@@ -46,7 +46,7 @@
// data // data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// misc. // misc.
@@ -117,7 +117,7 @@ bool wxColourDisplay()
int wxDisplayDepth() int wxDisplayDepth()
{ {
return gdk_window_get_visual( wxRootWindow->window )->depth; return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
} }
int wxGetOsVersion(int *majorVsn, int *minorVsn) int wxGetOsVersion(int *majorVsn, int *minorVsn)

View File

@@ -52,7 +52,7 @@ extern bool g_isIdle;
bool g_mainThreadLocked = FALSE; bool g_mainThreadLocked = FALSE;
gint g_pendingTag = 0; gint g_pendingTag = 0;
GtkWidget *wxRootWindow = (GtkWidget*) NULL; static GtkWidget *gs_RootWindow = (GtkWidget*) NULL;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// local functions // local functions
@@ -92,11 +92,11 @@ bool wxYield()
} }
#endif // wxUSE_THREADS #endif // wxUSE_THREADS
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
if (gs_inYield) if (gs_inYield)
wxFAIL_MSG( wxT("wxYield called recursively" ) ); wxFAIL_MSG( wxT("wxYield called recursively" ) );
#endif #endif
gs_inYield = TRUE; gs_inYield = TRUE;
if (!g_isIdle) if (!g_isIdle)
@@ -137,8 +137,8 @@ bool wxYieldIfNeeded()
{ {
if (gs_inYield) if (gs_inYield)
return FALSE; return FALSE;
return wxYield(); return wxYield();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -168,7 +168,7 @@ void wxWakeUpIdle()
gint wxapp_pending_callback( gpointer WXUNUSED(data) ) gint wxapp_pending_callback( gpointer WXUNUSED(data) )
{ {
if (!wxTheApp) return TRUE; if (!wxTheApp) return TRUE;
// when getting called from GDK's time-out handler // when getting called from GDK's time-out handler
// we are no longer within GDK's grab on the GUI // we are no longer within GDK's grab on the GUI
// thread so we must lock it here ourselves // thread so we must lock it here ourselves
@@ -195,7 +195,7 @@ gint wxapp_pending_callback( gpointer WXUNUSED(data) )
gint wxapp_idle_callback( gpointer WXUNUSED(data) ) gint wxapp_idle_callback( gpointer WXUNUSED(data) )
{ {
if (!wxTheApp) return TRUE; if (!wxTheApp) return TRUE;
// when getting called from GDK's time-out handler // when getting called from GDK's time-out handler
// we are no longer within GDK's grab on the GUI // we are no longer within GDK's grab on the GUI
// thread so we must lock it here ourselves // thread so we must lock it here ourselves
@@ -228,7 +228,7 @@ void wxapp_install_idle_handler()
if (g_pendingTag == 0) if (g_pendingTag == 0)
g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL );
/* This routine gets called by all event handlers /* This routine gets called by all event handlers
indicating that the idle is over. It may also indicating that the idle is over. It may also
get called from other thread for sending events get called from other thread for sending events
@@ -245,7 +245,7 @@ static int g_threadUninstallLevel = 0;
void wxapp_install_thread_wakeup() void wxapp_install_thread_wakeup()
{ {
g_threadUninstallLevel++; g_threadUninstallLevel++;
if (g_threadUninstallLevel != 1) return; if (g_threadUninstallLevel != 1) return;
if (wxTheApp->m_wakeUpTimerTag) return; if (wxTheApp->m_wakeUpTimerTag) return;
@@ -256,7 +256,7 @@ void wxapp_install_thread_wakeup()
void wxapp_uninstall_thread_wakeup() void wxapp_uninstall_thread_wakeup()
{ {
g_threadUninstallLevel--; g_threadUninstallLevel--;
if (g_threadUninstallLevel != 0) return; if (g_threadUninstallLevel != 0) return;
if (!wxTheApp->m_wakeUpTimerTag) return; if (!wxTheApp->m_wakeUpTimerTag) return;
@@ -626,6 +626,19 @@ void wxApp::CleanUp()
#endif // wxUSE_LOG #endif // wxUSE_LOG
} }
//-----------------------------------------------------------------------------
// Access to the root window global
//-----------------------------------------------------------------------------
GtkWidget* wxGetRootWindow()
{
if (gs_RootWindow == NULL) {
gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_widget_realize( gs_RootWindow );
}
return gs_RootWindow;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxEntry // wxEntry
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -676,6 +689,7 @@ int wxEntryStart( int argc, char *argv[] )
return 0; return 0;
} }
int wxEntryInitGui() int wxEntryInitGui()
{ {
int retValue = 0; int retValue = 0;
@@ -683,8 +697,7 @@ int wxEntryInitGui()
if ( !wxTheApp->OnInitGui() ) if ( !wxTheApp->OnInitGui() )
retValue = -1; retValue = -1;
wxRootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL ); wxGetRootWindow();
gtk_widget_realize( wxRootWindow );
return retValue; return retValue;
} }

View File

@@ -40,7 +40,7 @@ extern void gdk_wx_draw_bitmap (GdkDrawable *drawable,
// data // data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMask // wxMask
@@ -89,7 +89,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
wxImage image( bitmap ); wxImage image( bitmap );
if (!image.Ok()) return FALSE; if (!image.Ok()) return FALSE;
m_bitmap = gdk_pixmap_new( wxRootWindow->window, image.GetWidth(), image.GetHeight(), 1 ); m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
GdkGC *gc = gdk_gc_new( m_bitmap ); GdkGC *gc = gdk_gc_new( m_bitmap );
GdkColor color; GdkColor color;
@@ -108,9 +108,9 @@ bool wxMask::Create( const wxBitmap& bitmap,
unsigned char green = colour.Green(); unsigned char green = colour.Green();
unsigned char blue = colour.Blue(); unsigned char blue = colour.Blue();
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
int bpp = visual->depth; int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp == 15) if (bpp == 15)
@@ -170,7 +170,7 @@ bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
wxPalette *pal = bitmap.GetPalette(); wxPalette *pal = bitmap.GetPalette();
wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") ); wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") );
pal->GetRGB(paletteIndex, &r, &g, &b); pal->GetRGB(paletteIndex, &r, &g, &b);
return Create(bitmap, wxColour(r, g, b)); return Create(bitmap, wxColour(r, g, b));
@@ -188,7 +188,7 @@ bool wxMask::Create( const wxBitmap& bitmap )
wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") ); wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") );
m_bitmap = gdk_pixmap_new( wxRootWindow->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 ); m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
if (!m_bitmap) return FALSE; if (!m_bitmap) return FALSE;
@@ -268,7 +268,7 @@ bool wxBitmap::Create( int width, int height, int depth )
wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") ) wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") )
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
if (depth == -1) depth = visual->depth; if (depth == -1) depth = visual->depth;
@@ -282,12 +282,12 @@ bool wxBitmap::Create( int width, int height, int depth )
M_BMPDATA->m_height = height; M_BMPDATA->m_height = height;
if (depth == 1) if (depth == 1)
{ {
M_BMPDATA->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 ); M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
M_BMPDATA->m_bpp = 1; M_BMPDATA->m_bpp = 1;
} }
else else
{ {
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxRootWindow->window, width, height, depth ); M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth );
M_BMPDATA->m_bpp = visual->depth; M_BMPDATA->m_bpp = visual->depth;
} }
@@ -298,14 +298,14 @@ bool wxBitmap::CreateFromXpm( const char **bits )
{ {
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") ) wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL; GdkBitmap *mask = (GdkBitmap*) NULL;
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxRootWindow->window, &mask, NULL, (gchar **) bits ); M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits );
wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") ); wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") );
@@ -318,13 +318,12 @@ bool wxBitmap::CreateFromXpm( const char **bits )
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = visual->depth; // ? M_BMPDATA->m_bpp = visual->depth; // ?
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
return TRUE; return TRUE;
} }
extern GtkWidget *wxRootWindow;
bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
{ {
@@ -332,7 +331,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") ) wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
// ------ // ------
@@ -346,11 +345,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetHeight( height ); SetHeight( height );
SetWidth( width ); SetWidth( width );
SetBitmap( gdk_pixmap_new( wxRootWindow->window, width, height, 1 ) ); SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
SetDepth( 1 ); SetDepth( 1 );
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
// Create picture image // Create picture image
@@ -371,7 +370,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
mask_image = gdk_image_new_bitmap( visual, mask_data, width, height ); mask_image = gdk_image_new_bitmap( visual, mask_data, width, height );
wxMask *mask = new wxMask(); wxMask *mask = new wxMask();
mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 ); mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
SetMask( mask ); SetMask( mask );
} }
@@ -431,7 +430,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
gdk_gc_unref( mask_gc ); gdk_gc_unref( mask_gc );
} }
} }
// ------ // ------
// convertion to colour bitmap: // convertion to colour bitmap:
// ------ // ------
@@ -443,11 +442,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetHeight( height ); SetHeight( height );
SetWidth( width ); SetWidth( width );
SetPixmap( gdk_pixmap_new( wxRootWindow->window, width, height, -1 ) ); SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
// Retrieve depth // Retrieve depth
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
int bpp = visual->depth; int bpp = visual->depth;
@@ -501,7 +500,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
mask_image = gdk_image_new_bitmap( visual, mask_data, width, height ); mask_image = gdk_image_new_bitmap( visual, mask_data, width, height );
wxMask *mask = new wxMask(); wxMask *mask = new wxMask();
mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 ); mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
SetMask( mask ); SetMask( mask );
} }
@@ -636,7 +635,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
wxImage wxBitmap::ConvertToImage() const wxImage wxBitmap::ConvertToImage() const
{ {
wxImage image; wxImage image;
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
GdkImage *gdk_image = (GdkImage*) NULL; GdkImage *gdk_image = (GdkImage*) NULL;
@@ -657,7 +656,7 @@ wxImage wxBitmap::ConvertToImage() const
} }
wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") ); wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") );
image.Create( GetWidth(), GetHeight() ); image.Create( GetWidth(), GetHeight() );
char unsigned *data = image.GetData(); char unsigned *data = image.GetData();
@@ -691,7 +690,7 @@ wxImage wxBitmap::ConvertToImage() const
{ {
GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); GdkVisual *visual = gdk_window_get_visual( GetPixmap() );
if (visual == NULL) visual = gdk_window_get_visual( wxRootWindow->window ); if (visual == NULL) visual = gdk_window_get_visual( wxGetRootWindow()->window );
bpp = visual->depth; bpp = visual->depth;
if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec; if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
red_shift_right = visual->red_shift; red_shift_right = visual->red_shift;
@@ -765,7 +764,7 @@ wxImage wxBitmap::ConvertToImage() const
} }
gdk_image_destroy( gdk_image ); gdk_image_destroy( gdk_image );
if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); if (gdk_image_mask) gdk_image_destroy( gdk_image_mask );
return image; return image;
} }
@@ -790,7 +789,7 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth
M_BMPDATA->m_mask = (wxMask *) NULL; M_BMPDATA->m_mask = (wxMask *) NULL;
M_BMPDATA->m_bitmap = M_BMPDATA->m_bitmap =
gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) bits, width, height ); gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height );
M_BMPDATA->m_width = width; M_BMPDATA->m_width = width;
M_BMPDATA->m_height = height; M_BMPDATA->m_height = height;
M_BMPDATA->m_bpp = 1; M_BMPDATA->m_bpp = 1;
@@ -890,7 +889,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
if (GetMask()) if (GetMask())
{ {
wxMask *mask = new wxMask; wxMask *mask = new wxMask;
mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, rect.width, rect.height, 1 ); mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, rect.width, rect.height, 1 );
GdkGC *gc = gdk_gc_new( mask->m_bitmap ); GdkGC *gc = gdk_gc_new( mask->m_bitmap );
gdk_wx_draw_bitmap( mask->m_bitmap, gc, M_BMPDATA->m_mask->m_bitmap, 0, 0, rect.x, rect.y, rect.width, rect.height ); gdk_wx_draw_bitmap( mask->m_bitmap, gc, M_BMPDATA->m_mask->m_bitmap, 0, 0, rect.x, rect.y, rect.width, rect.height );
@@ -921,16 +920,16 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
if (!wxFileExists(name)) return FALSE; if (!wxFileExists(name)) return FALSE;
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual ); wxASSERT( visual );
if (type == wxBITMAP_TYPE_XPM) if (type == wxBITMAP_TYPE_XPM)
{ {
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL; GdkBitmap *mask = (GdkBitmap*) NULL;
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( wxRootWindow->window, &mask, NULL, name.fn_str() ); M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( wxGetRootWindow()->window, &mask, NULL, name.fn_str() );
if (mask) if (mask)
{ {
@@ -939,7 +938,7 @@ bool wxBitmap::LoadFile( const wxString &name, int type )
} }
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = visual->depth; M_BMPDATA->m_bpp = visual->depth;
} }
else // try if wxImage can load it else // try if wxImage can load it

View File

@@ -110,7 +110,7 @@ wxCursor::wxCursor( int cursorId )
M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur );
} }
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
wxCursor::wxCursor(const char bits[], int width, int height, wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY, int hotSpotX, int hotSpotY,
@@ -127,8 +127,8 @@ wxCursor::wxCursor(const char bits[], int width, int height,
if (hotSpotY < 0 || hotSpotY >= height) if (hotSpotY < 0 || hotSpotY >= height)
hotSpotY = 0; hotSpotY = 0;
GdkBitmap *data = gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) bits, width, height ); GdkBitmap *data = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height );
GdkBitmap *mask = gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) maskBits, width, height); GdkBitmap *mask = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) maskBits, width, height);
m_refData = new wxCursorRefData; m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap( M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(

View File

@@ -54,7 +54,7 @@
static GdkPixmap *hatches[num_hatches]; static GdkPixmap *hatches[num_hatches];
static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL; static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL;
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// constants // constants
@@ -415,7 +415,7 @@ bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
memdc.SelectObject(bitmap); memdc.SelectObject(bitmap);
memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1); memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1);
memdc.SelectObject(wxNullBitmap); memdc.SelectObject(wxNullBitmap);
wxImage image(bitmap); wxImage image(bitmap);
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0)); col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
return TRUE; return TRUE;
@@ -1021,7 +1021,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
{ {
GdkColor col; GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, ww, hh, 1 ); new_mask = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, 1 );
GdkGC *gc = gdk_gc_new( new_mask ); GdkGC *gc = gdk_gc_new( new_mask );
col.pixel = 0; col.pixel = 0;
gdk_gc_set_foreground( gc, &col ); gdk_gc_set_foreground( gc, &col );
@@ -1206,7 +1206,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
{ {
GdkColor col; GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, bm_ww, bm_hh, 1 ); new_mask = gdk_pixmap_new( wxGetRootWindow()->window, bm_ww, bm_hh, 1 );
GdkGC *gc = gdk_gc_new( new_mask ); GdkGC *gc = gdk_gc_new( new_mask );
col.pixel = 0; col.pixel = 0;
gdk_gc_set_foreground( gc, &col ); gdk_gc_set_foreground( gc, &col );

View File

@@ -37,7 +37,7 @@ extern bool g_isIdle;
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// local functions // local functions
@@ -47,7 +47,7 @@ extern GtkWidget *wxRootWindow;
static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h ) static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h )
{ {
int org_x = 0; int org_x = 0;
int org_y = 0; int org_y = 0;
gdk_window_get_origin( widget->window, &org_x, &org_y ); gdk_window_get_origin( widget->window, &org_x, &org_y );
x += org_x; x += org_x;
@@ -56,7 +56,7 @@ static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h )
GdkGC *gc = gdk_gc_new( GDK_ROOT_PARENT() ); GdkGC *gc = gdk_gc_new( GDK_ROOT_PARENT() );
gdk_gc_set_subwindow( gc, GDK_INCLUDE_INFERIORS ); gdk_gc_set_subwindow( gc, GDK_INCLUDE_INFERIORS );
gdk_gc_set_function( gc, GDK_INVERT ); gdk_gc_set_function( gc, GDK_INVERT );
gdk_draw_rectangle( GDK_ROOT_PARENT(), gc, FALSE, x, y, w, h ); gdk_draw_rectangle( GDK_ROOT_PARENT(), gc, FALSE, x, y, w, h );
gdk_gc_unref( gc ); gdk_gc_unref( gc );
} }
@@ -71,10 +71,10 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
if (gdk_event->count > 0) return; if (gdk_event->count > 0) return;
GtkPizza *pizza = GTK_PIZZA(widget); GtkPizza *pizza = GTK_PIZZA(widget);
gtk_draw_shadow( widget->style, gtk_draw_shadow( widget->style,
pizza->bin_window, pizza->bin_window,
GTK_STATE_NORMAL, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, GTK_SHADOW_OUT,
@@ -82,26 +82,26 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g
win->m_width, win->m_height ); win->m_width, win->m_height );
if (!win->m_title.IsEmpty() && if (!win->m_title.IsEmpty() &&
((win->GetWindowStyle() & wxCAPTION) || ((win->GetWindowStyle() & wxCAPTION) ||
(win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
(win->GetWindowStyle() & wxTINY_CAPTION_VERT))) (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
{ {
GdkGC *gc = gdk_gc_new( pizza->bin_window ); GdkGC *gc = gdk_gc_new( pizza->bin_window );
GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
gdk_draw_rectangle( pizza->bin_window, gc, TRUE, gdk_draw_rectangle( pizza->bin_window, gc, TRUE,
3, 3,
3, 3,
win->m_width - 7, win->m_width - 7,
font->ascent + font->descent+1 ); font->ascent + font->descent+1 );
gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] ); gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] );
gdk_draw_string( pizza->bin_window, font, gc, gdk_draw_string( pizza->bin_window, font, gc,
6, 6,
3+font->ascent, 3+font->ascent,
win->m_title.mb_str() ); win->m_title.mb_str() );
gdk_gc_unref( gc ); gdk_gc_unref( gc );
} }
} }
@@ -115,37 +115,37 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU
if (g_isIdle) wxapp_install_idle_handler(); if (g_isIdle) wxapp_install_idle_handler();
if (!win->m_hasVMT) return; if (!win->m_hasVMT) return;
GtkPizza *pizza = GTK_PIZZA(widget); GtkPizza *pizza = GTK_PIZZA(widget);
gtk_draw_shadow( widget->style, gtk_draw_shadow( widget->style,
pizza->bin_window, pizza->bin_window,
GTK_STATE_NORMAL, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, GTK_SHADOW_OUT,
0, 0, 0, 0,
win->m_width, win->m_height ); win->m_width, win->m_height );
if (!win->m_title.IsEmpty() && if (!win->m_title.IsEmpty() &&
((win->GetWindowStyle() & wxCAPTION) || ((win->GetWindowStyle() & wxCAPTION) ||
(win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
(win->GetWindowStyle() & wxTINY_CAPTION_VERT))) (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
{ {
GdkGC *gc = gdk_gc_new( pizza->bin_window ); GdkGC *gc = gdk_gc_new( pizza->bin_window );
GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0);
gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] );
gdk_draw_rectangle( pizza->bin_window, gc, TRUE, gdk_draw_rectangle( pizza->bin_window, gc, TRUE,
3, 3,
3, 3,
win->m_width - 7, win->m_width - 7,
font->ascent + font->descent+1 ); font->ascent + font->descent+1 );
gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] ); gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] );
gdk_draw_string( pizza->bin_window, font, gc, gdk_draw_string( pizza->bin_window, font, gc,
6, 6,
3+font->ascent, 3+font->ascent,
win->m_title.mb_str() ); win->m_title.mb_str() );
gdk_gc_unref( gc ); gdk_gc_unref( gc );
} }
} }
@@ -165,7 +165,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
if (win->m_isDragging) return TRUE; if (win->m_isDragging) return TRUE;
gdk_window_raise( win->m_widget->window ); gdk_window_raise( win->m_widget->window );
gdk_pointer_grab( widget->window, FALSE, gdk_pointer_grab( widget->window, FALSE,
(GdkEventMask) (GdkEventMask)
(GDK_BUTTON_PRESS_MASK | (GDK_BUTTON_PRESS_MASK |
@@ -177,13 +177,13 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
(GdkWindow *) NULL, (GdkWindow *) NULL,
(GdkCursor *) NULL, (GdkCursor *) NULL,
(unsigned int) GDK_CURRENT_TIME ); (unsigned int) GDK_CURRENT_TIME );
win->m_diffX = (int)gdk_event->x; win->m_diffX = (int)gdk_event->x;
win->m_diffY = (int)gdk_event->y; win->m_diffY = (int)gdk_event->y;
DrawFrame( widget, 0, 0, win->m_width, win->m_height ); DrawFrame( widget, 0, 0, win->m_width, win->m_height );
win->m_oldX = 0; win->m_oldX = 0;
win->m_oldY = 0; win->m_oldY = 0;
win->m_isDragging = TRUE; win->m_isDragging = TRUE;
return TRUE; return TRUE;
@@ -202,15 +202,15 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
if (g_blockEventsOnScroll) return TRUE; if (g_blockEventsOnScroll) return TRUE;
if (!win->m_isDragging) return TRUE; if (!win->m_isDragging) return TRUE;
win->m_isDragging = FALSE; win->m_isDragging = FALSE;
int x = (int)gdk_event->x; int x = (int)gdk_event->x;
int y = (int)gdk_event->y; int y = (int)gdk_event->y;
DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME ); gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME );
int org_x = 0; int org_x = 0;
int org_y = 0; int org_y = 0;
gdk_window_get_origin( widget->window, &org_x, &org_y ); gdk_window_get_origin( widget->window, &org_x, &org_y );
x += org_x - win->m_diffX; x += org_x - win->m_diffX;
@@ -235,7 +235,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
if (g_blockEventsOnScroll) return TRUE; if (g_blockEventsOnScroll) return TRUE;
if (!win->m_isDragging) return TRUE; if (!win->m_isDragging) return TRUE;
if (gdk_event->is_hint) if (gdk_event->is_hint)
{ {
int x = 0; int x = 0;
@@ -251,7 +251,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
win->m_oldX = (int)gdk_event->x - win->m_diffX; win->m_oldX = (int)gdk_event->x - win->m_diffX;
win->m_oldY = (int)gdk_event->y - win->m_diffY; win->m_oldY = (int)gdk_event->y - win->m_diffY;
DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
return TRUE; return TRUE;
} }
@@ -307,47 +307,47 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title
if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT)) if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))
m_miniTitle = 13; m_miniTitle = 13;
m_miniEdge = 3; m_miniEdge = 3;
m_isDragging = FALSE; m_isDragging = FALSE;
m_oldX = -1; m_oldX = -1;
m_oldY = -1; m_oldY = -1;
m_diffX = 0; m_diffX = 0;
m_diffY = 0; m_diffY = 0;
wxFrame::Create( parent, id, title, pos, size, style, name ); wxFrame::Create( parent, id, title, pos, size, style, name );
if ((style & wxSYSTEM_MENU) && if ((style & wxSYSTEM_MENU) &&
((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT)))
{ {
GdkBitmap *mask = (GdkBitmap*) NULL; GdkBitmap *mask = (GdkBitmap*) NULL;
GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( wxRootWindow->window, &mask, NULL, cross_xpm ); GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, cross_xpm );
GtkWidget *pw = gtk_pixmap_new( pixmap, mask ); GtkWidget *pw = gtk_pixmap_new( pixmap, mask );
gdk_bitmap_unref( mask ); gdk_bitmap_unref( mask );
gdk_pixmap_unref( pixmap ); gdk_pixmap_unref( pixmap );
gtk_widget_show( pw ); gtk_widget_show( pw );
GtkWidget *close_button = gtk_button_new(); GtkWidget *close_button = gtk_button_new();
gtk_container_add( GTK_CONTAINER(close_button), pw ); gtk_container_add( GTK_CONTAINER(close_button), pw );
gtk_pizza_put( GTK_PIZZA(m_mainWidget), gtk_pizza_put( GTK_PIZZA(m_mainWidget),
close_button, close_button,
size.x-16, 4, 11, 11 ); size.x-16, 4, 11, 11 );
gtk_widget_show( close_button ); gtk_widget_show( close_button );
gtk_signal_connect( GTK_OBJECT(close_button), "clicked", gtk_signal_connect( GTK_OBJECT(close_button), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
} }
/* these are called when the borders are drawn */ /* these are called when the borders are drawn */
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw",
GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
/* these are required for dragging the mini frame around */ /* these are required for dragging the mini frame around */
gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event", gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event",
GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this );

View File

@@ -46,7 +46,7 @@
// data // data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
extern GtkWidget *wxRootWindow; extern GtkWidget *wxGetRootWindow();
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// misc. // misc.
@@ -117,7 +117,7 @@ bool wxColourDisplay()
int wxDisplayDepth() int wxDisplayDepth()
{ {
return gdk_window_get_visual( wxRootWindow->window )->depth; return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
} }
int wxGetOsVersion(int *majorVsn, int *minorVsn) int wxGetOsVersion(int *majorVsn, int *minorVsn)