bool g_mainThreadLocked = FALSE;
gint g_pendingTag = 0;
-GtkWidget *wxRootWindow = (GtkWidget*) NULL;
+static GtkWidget *gs_RootWindow = (GtkWidget*) NULL;
//-----------------------------------------------------------------------------
// local functions
}
#endif // wxUSE_THREADS
-#ifdef __WXDEBUG__
+#ifdef __WXDEBUG__
if (gs_inYield)
wxFAIL_MSG( wxT("wxYield called recursively" ) );
#endif
-
+
gs_inYield = TRUE;
if (!g_isIdle)
{
if (gs_inYield)
return FALSE;
-
- return wxYield();
+
+ return wxYield();
}
//-----------------------------------------------------------------------------
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
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
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
void wxapp_install_thread_wakeup()
{
g_threadUninstallLevel++;
-
+
if (g_threadUninstallLevel != 1) return;
if (wxTheApp->m_wakeUpTimerTag) return;
void wxapp_uninstall_thread_wakeup()
{
g_threadUninstallLevel--;
-
+
if (g_threadUninstallLevel != 0) return;
if (!wxTheApp->m_wakeUpTimerTag) return;
#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
//-----------------------------------------------------------------------------
return 0;
}
+
int wxEntryInitGui()
{
int retValue = 0;
if ( !wxTheApp->OnInitGui() )
retValue = -1;
- wxRootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_widget_realize( wxRootWindow );
+ wxGetRootWindow();
return retValue;
}
// data
//-----------------------------------------------------------------------------
-extern GtkWidget *wxRootWindow;
+extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// wxMask
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;
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)
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));
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;
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;
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;
}
{
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") );
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 )
{
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
m_refData = new wxBitmapRefData();
-
+
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
// ------
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
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 );
}
gdk_gc_unref( mask_gc );
}
}
-
+
// ------
// convertion to colour bitmap:
// ------
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;
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 );
}
wxImage wxBitmap::ConvertToImage() const
{
wxImage image;
-
+
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
GdkImage *gdk_image = (GdkImage*) NULL;
}
wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") );
-
+
image.Create( GetWidth(), GetHeight() );
char unsigned *data = image.GetData();
{
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;
}
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;
}
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;
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 );
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)
{
}
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
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,
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(
static GdkPixmap *hatches[num_hatches];
static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL;
-extern GtkWidget *wxRootWindow;
+extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// constants
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;
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 );
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 );
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
-extern GtkWidget *wxRootWindow;
+extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// local functions
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;
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 );
}
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,
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 );
}
}
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 );
}
}
if (win->m_isDragging) return TRUE;
gdk_window_raise( win->m_widget->window );
-
+
gdk_pointer_grab( widget->window, FALSE,
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
(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;
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;
if (g_blockEventsOnScroll) return TRUE;
if (!win->m_isDragging) return TRUE;
-
+
if (gdk_event->is_hint)
{
int x = 0;
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;
}
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 );
// data
//-----------------------------------------------------------------------------
-extern GtkWidget *wxRootWindow;
+extern GtkWidget *wxGetRootWindow();
//----------------------------------------------------------------------------
// misc.
int wxDisplayDepth()
{
- return gdk_window_get_visual( wxRootWindow->window )->depth;
+ return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
}
int wxGetOsVersion(int *majorVsn, int *minorVsn)
bool g_mainThreadLocked = FALSE;
gint g_pendingTag = 0;
-GtkWidget *wxRootWindow = (GtkWidget*) NULL;
+static GtkWidget *gs_RootWindow = (GtkWidget*) NULL;
//-----------------------------------------------------------------------------
// local functions
}
#endif // wxUSE_THREADS
-#ifdef __WXDEBUG__
+#ifdef __WXDEBUG__
if (gs_inYield)
wxFAIL_MSG( wxT("wxYield called recursively" ) );
#endif
-
+
gs_inYield = TRUE;
if (!g_isIdle)
{
if (gs_inYield)
return FALSE;
-
- return wxYield();
+
+ return wxYield();
}
//-----------------------------------------------------------------------------
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
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
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
void wxapp_install_thread_wakeup()
{
g_threadUninstallLevel++;
-
+
if (g_threadUninstallLevel != 1) return;
if (wxTheApp->m_wakeUpTimerTag) return;
void wxapp_uninstall_thread_wakeup()
{
g_threadUninstallLevel--;
-
+
if (g_threadUninstallLevel != 0) return;
if (!wxTheApp->m_wakeUpTimerTag) return;
#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
//-----------------------------------------------------------------------------
return 0;
}
+
int wxEntryInitGui()
{
int retValue = 0;
if ( !wxTheApp->OnInitGui() )
retValue = -1;
- wxRootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
- gtk_widget_realize( wxRootWindow );
+ wxGetRootWindow();
return retValue;
}
// data
//-----------------------------------------------------------------------------
-extern GtkWidget *wxRootWindow;
+extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// wxMask
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;
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)
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));
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;
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;
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;
}
{
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") );
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 )
{
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
m_refData = new wxBitmapRefData();
-
+
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
// ------
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
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 );
}
gdk_gc_unref( mask_gc );
}
}
-
+
// ------
// convertion to colour bitmap:
// ------
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;
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 );
}
wxImage wxBitmap::ConvertToImage() const
{
wxImage image;
-
+
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
GdkImage *gdk_image = (GdkImage*) NULL;
}
wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") );
-
+
image.Create( GetWidth(), GetHeight() );
char unsigned *data = image.GetData();
{
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;
}
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;
}
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;
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 );
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)
{
}
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
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,
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(
static GdkPixmap *hatches[num_hatches];
static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL;
-extern GtkWidget *wxRootWindow;
+extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// constants
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;
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 );
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 );
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
-extern GtkWidget *wxRootWindow;
+extern GtkWidget *wxGetRootWindow();
//-----------------------------------------------------------------------------
// local functions
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;
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 );
}
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,
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 );
}
}
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 );
}
}
if (win->m_isDragging) return TRUE;
gdk_window_raise( win->m_widget->window );
-
+
gdk_pointer_grab( widget->window, FALSE,
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
(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;
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;
if (g_blockEventsOnScroll) return TRUE;
if (!win->m_isDragging) return TRUE;
-
+
if (gdk_event->is_hint)
{
int x = 0;
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;
}
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 );
// data
//-----------------------------------------------------------------------------
-extern GtkWidget *wxRootWindow;
+extern GtkWidget *wxGetRootWindow();
//----------------------------------------------------------------------------
// misc.
int wxDisplayDepth()
{
- return gdk_window_get_visual( wxRootWindow->window )->depth;
+ return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
}
int wxGetOsVersion(int *majorVsn, int *minorVsn)