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

View File

@ -40,7 +40,7 @@ extern void gdk_wx_draw_bitmap (GdkDrawable *drawable,
// data
//-----------------------------------------------------------------------------
extern GtkWidget *wxRootWindow;
extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// wxMask
@ -89,7 +89,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
wxImage image( bitmap );
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 );
GdkColor color;
@ -108,9 +108,9 @@ bool wxMask::Create( const wxBitmap& bitmap,
unsigned char green = colour.Green();
unsigned char blue = colour.Blue();
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp == 15)
@ -170,7 +170,7 @@ bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
wxPalette *pal = bitmap.GetPalette();
wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") );
pal->GetRGB(paletteIndex, &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") );
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;
@ -268,7 +268,7 @@ bool wxBitmap::Create( int width, int height, int depth )
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 );
if (depth == -1) depth = visual->depth;
@ -282,12 +282,12 @@ bool wxBitmap::Create( int width, int height, int depth )
M_BMPDATA->m_height = height;
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;
}
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;
}
@ -298,14 +298,14 @@ bool wxBitmap::CreateFromXpm( const char **bits )
{
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 );
m_refData = new wxBitmapRefData();
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") );
@ -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) );
M_BMPDATA->m_bpp = visual->depth; // ?
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
return TRUE;
}
extern GtkWidget *wxRootWindow;
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") )
m_refData = new wxBitmapRefData();
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
// ------
@ -346,11 +345,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetHeight( height );
SetWidth( width );
SetBitmap( gdk_pixmap_new( wxRootWindow->window, width, height, 1 ) );
SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
SetDepth( 1 );
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
// 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 );
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 );
}
@ -431,7 +430,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
gdk_gc_unref( mask_gc );
}
}
// ------
// convertion to colour bitmap:
// ------
@ -443,11 +442,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetHeight( height );
SetWidth( width );
SetPixmap( gdk_pixmap_new( wxRootWindow->window, width, height, -1 ) );
SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
// Retrieve depth
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
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 );
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 );
}
@ -636,7 +635,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
wxImage wxBitmap::ConvertToImage() const
{
wxImage image;
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
GdkImage *gdk_image = (GdkImage*) NULL;
@ -657,7 +656,7 @@ wxImage wxBitmap::ConvertToImage() const
}
wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") );
image.Create( GetWidth(), GetHeight() );
char unsigned *data = image.GetData();
@ -691,7 +690,7 @@ wxImage wxBitmap::ConvertToImage() const
{
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;
if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
red_shift_right = visual->red_shift;
@ -765,7 +764,7 @@ wxImage wxBitmap::ConvertToImage() const
}
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;
}
@ -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_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_height = height;
M_BMPDATA->m_bpp = 1;
@ -890,7 +889,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
if (GetMask())
{
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 );
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;
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
if (type == wxBITMAP_TYPE_XPM)
{
m_refData = new wxBitmapRefData();
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)
{
@ -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) );
M_BMPDATA->m_bpp = visual->depth;
}
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 );
}
extern GtkWidget *wxRootWindow;
extern GtkWidget *wxGetRootWindow();
wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY,
@ -127,8 +127,8 @@ wxCursor::wxCursor(const char bits[], int width, int height,
if (hotSpotY < 0 || hotSpotY >= height)
hotSpotY = 0;
GdkBitmap *data = gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) bits, width, height );
GdkBitmap *mask = gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) maskBits, width, height);
GdkBitmap *data = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height );
GdkBitmap *mask = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) maskBits, width, height);
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(

View File

@ -54,7 +54,7 @@
static GdkPixmap *hatches[num_hatches];
static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL;
extern GtkWidget *wxRootWindow;
extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// constants
@ -415,7 +415,7 @@ bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
memdc.SelectObject(bitmap);
memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1);
memdc.SelectObject(wxNullBitmap);
wxImage image(bitmap);
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
return TRUE;
@ -1021,7 +1021,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if (!m_currentClippingRegion.IsNull())
{
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 );
col.pixel = 0;
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())
{
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 );
col.pixel = 0;
gdk_gc_set_foreground( gc, &col );

View File

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

View File

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

View File

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

View File

@ -40,7 +40,7 @@ extern void gdk_wx_draw_bitmap (GdkDrawable *drawable,
// data
//-----------------------------------------------------------------------------
extern GtkWidget *wxRootWindow;
extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// wxMask
@ -89,7 +89,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
wxImage image( bitmap );
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 );
GdkColor color;
@ -108,9 +108,9 @@ bool wxMask::Create( const wxBitmap& bitmap,
unsigned char green = colour.Green();
unsigned char blue = colour.Blue();
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp == 15)
@ -170,7 +170,7 @@ bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
wxPalette *pal = bitmap.GetPalette();
wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") );
pal->GetRGB(paletteIndex, &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") );
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;
@ -268,7 +268,7 @@ bool wxBitmap::Create( int width, int height, int depth )
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 );
if (depth == -1) depth = visual->depth;
@ -282,12 +282,12 @@ bool wxBitmap::Create( int width, int height, int depth )
M_BMPDATA->m_height = height;
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;
}
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;
}
@ -298,14 +298,14 @@ bool wxBitmap::CreateFromXpm( const char **bits )
{
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 );
m_refData = new wxBitmapRefData();
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") );
@ -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) );
M_BMPDATA->m_bpp = visual->depth; // ?
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
return TRUE;
}
extern GtkWidget *wxRootWindow;
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") )
m_refData = new wxBitmapRefData();
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
// ------
@ -346,11 +345,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetHeight( height );
SetWidth( width );
SetBitmap( gdk_pixmap_new( wxRootWindow->window, width, height, 1 ) );
SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
SetDepth( 1 );
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
// 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 );
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 );
}
@ -431,7 +430,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
gdk_gc_unref( mask_gc );
}
}
// ------
// convertion to colour bitmap:
// ------
@ -443,11 +442,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
SetHeight( height );
SetWidth( width );
SetPixmap( gdk_pixmap_new( wxRootWindow->window, width, height, -1 ) );
SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
// Retrieve depth
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
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 );
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 );
}
@ -636,7 +635,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
wxImage wxBitmap::ConvertToImage() const
{
wxImage image;
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
GdkImage *gdk_image = (GdkImage*) NULL;
@ -657,7 +656,7 @@ wxImage wxBitmap::ConvertToImage() const
}
wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") );
image.Create( GetWidth(), GetHeight() );
char unsigned *data = image.GetData();
@ -691,7 +690,7 @@ wxImage wxBitmap::ConvertToImage() const
{
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;
if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
red_shift_right = visual->red_shift;
@ -765,7 +764,7 @@ wxImage wxBitmap::ConvertToImage() const
}
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;
}
@ -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_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_height = height;
M_BMPDATA->m_bpp = 1;
@ -890,7 +889,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
if (GetMask())
{
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 );
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;
GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
GdkVisual *visual = gdk_window_get_visual( wxGetRootWindow()->window );
wxASSERT( visual );
if (type == wxBITMAP_TYPE_XPM)
{
m_refData = new wxBitmapRefData();
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)
{
@ -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) );
M_BMPDATA->m_bpp = visual->depth;
}
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 );
}
extern GtkWidget *wxRootWindow;
extern GtkWidget *wxGetRootWindow();
wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY,
@ -127,8 +127,8 @@ wxCursor::wxCursor(const char bits[], int width, int height,
if (hotSpotY < 0 || hotSpotY >= height)
hotSpotY = 0;
GdkBitmap *data = gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) bits, width, height );
GdkBitmap *mask = gdk_bitmap_create_from_data( wxRootWindow->window, (gchar *) maskBits, width, height);
GdkBitmap *data = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height );
GdkBitmap *mask = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) maskBits, width, height);
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap(

View File

@ -54,7 +54,7 @@
static GdkPixmap *hatches[num_hatches];
static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL;
extern GtkWidget *wxRootWindow;
extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// constants
@ -415,7 +415,7 @@ bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
memdc.SelectObject(bitmap);
memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1);
memdc.SelectObject(wxNullBitmap);
wxImage image(bitmap);
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
return TRUE;
@ -1021,7 +1021,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if (!m_currentClippingRegion.IsNull())
{
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 );
col.pixel = 0;
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())
{
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 );
col.pixel = 0;
gdk_gc_set_foreground( gc, &col );

View File

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

View File

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