// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
-#include "wx/minifram.h"
-
#if wxUSE_MINIFRAME
-#include "wx/dcscreen.h"
+#include "wx/minifram.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/dcscreen.h"
+#endif
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
extern bool g_blockEventsOnScroll;
extern GtkWidget *wxGetRootWindow();
-//-----------------------------------------------------------------------------
-// local functions
-//-----------------------------------------------------------------------------
-
-/* draw XOR rectangle when moving mine frame around */
-
-static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h )
-{
- int org_x = 0;
- int org_y = 0;
- gdk_window_get_origin( widget->window, &org_x, &org_y );
- x += org_x;
- y += org_y;
-
- 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 );
- g_object_unref (G_OBJECT (gc));
-}
-
//-----------------------------------------------------------------------------
// "expose_event" of m_mainWidget
//-----------------------------------------------------------------------------
extern "C" {
-static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxFrame *win )
+static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxMiniFrame *win )
{
if (g_isIdle) wxapp_install_idle_handler();
0, 0,
win->m_width, win->m_height);
+ int style = win->GetWindowStyle();
+
if (!win->GetTitle().empty() &&
- ((win->GetWindowStyle() & wxCAPTION) ||
- (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) ||
- (win->GetWindowStyle() & wxTINY_CAPTION_VERT)))
+ ((style & wxCAPTION) ||
+ (style & wxTINY_CAPTION_HORIZ) ||
+ (style & wxTINY_CAPTION_VERT)))
{
wxClientDC dc(win);
dc.SetFont( *wxSMALL_FONT );
3,
win->m_width - 7,
height+1 );
- g_object_unref (G_OBJECT (gc));
+ g_object_unref (gc);
// Hack alert
dc.m_window = pizza->bin_window;
dc.SetTextForeground( *wxWHITE );
dc.DrawText( win->GetTitle(), 6, 3 );
+
+ if (style & wxCLOSE_BOX)
+ dc.DrawBitmap( win->m_closeButton, win->m_width-19, 3, true );
}
}
}
GtkPizza *pizza = GTK_PIZZA(widget);
if (gdk_event->window != pizza->bin_window) return TRUE;
+ int y = (int)gdk_event->y;
+ int x = (int)gdk_event->x;
+
+ int style = win->GetWindowStyle();
+ if ((style & wxCLOSE_BOX) &&
+ ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT)))
+ {
+ if ((y > 3) && (y < 19) && (x > win->m_width-19) && (x < win->m_width-3))
+ {
+ win->Close();
+ return TRUE;
+ }
+ }
+
wxClientDC dc(win);
dc.SetFont( *wxSMALL_FONT );
int height = dc.GetCharHeight() + 1;
- if (gdk_event->y > height) return TRUE;
+
+ if (y > height) return TRUE;
gdk_window_raise( win->m_widget->window );
(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_diffX = x;
+ win->m_diffY = y;
win->m_oldX = 0;
win->m_oldY = 0;
if (!win->m_isDragging) return TRUE;
- win->m_isDragging = FALSE;
+ 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_y = 0;
gdk_event->state = state;
}
- DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
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;
-}
-}
-
-//-----------------------------------------------------------------------------
-// "clicked" of X system button
-//-----------------------------------------------------------------------------
+ int x = (int)gdk_event->x;
+ int y = (int)gdk_event->y;
+
+ int org_x = 0;
+ int org_y = 0;
+ gdk_window_get_origin( widget->window, &org_x, &org_y );
+ x += org_x - win->m_diffX;
+ y += org_y - win->m_diffY;
+ win->m_x = x;
+ win->m_y = y;
+ gtk_window_move( GTK_WINDOW(win->m_widget), x, y );
-extern "C" {
-static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxMiniFrame *mf )
-{
- if (g_isIdle) wxapp_install_idle_handler();
- mf->Close();
+ return TRUE;
}
}
// wxMiniFrame
//-----------------------------------------------------------------------------
-static const char *cross_xpm[] = {
-/* columns rows colors chars-per-pixel */
-"5 5 2 1",
-"# c Gray0",
-" c None",
-/* pixels */
-"# #",
-" # # ",
-" # ",
-" # # ",
-"# #",
-};
+static unsigned char close_bits[]={
+ 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8,
+ 0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef,
+ 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame,wxFrame)
style = style | wxCAPTION;
if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))
- m_miniTitle = 13;
+ m_miniTitle = 16;
m_miniEdge = 3;
m_isDragging = false;
gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) );
}
- if ((style & wxSYSTEM_MENU) &&
+ if ((style & wxCLOSE_BOX) &&
((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT)))
{
- GdkBitmap *mask = (GdkBitmap*) NULL;
- GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d
- (
- wxGetRootWindow()->window,
- &mask,
- NULL,
- (char **)cross_xpm
- );
-
- GtkWidget *pw = gtk_pixmap_new( pixmap, mask );
- g_object_unref (G_OBJECT (mask));
- g_object_unref (G_OBJECT (pixmap));
- gtk_widget_show( pw );
-
- GtkWidget *close_button = gtk_button_new();
-#ifdef __WXGTK24__
- if (!gtk_check_version(2,4,0))
- gtk_button_set_focus_on_click( GTK_BUTTON(close_button), FALSE );
-#endif
- gtk_container_add( GTK_CONTAINER(close_button), pw );
-
- gtk_pizza_put( GTK_PIZZA(m_mainWidget),
- close_button,
- size.x-16, 4, 11, 11 );
-
- gtk_widget_show( close_button );
-
- g_signal_connect (close_button, "clicked",
- G_CALLBACK (gtk_button_clicked_callback),
- this);
+ wxImage img = wxBitmap((const char*)close_bits, 16, 16).ConvertToImage();
+ img.Replace(255,255,255,123,123,123);
+ img.Replace(0,0,0,255,255,255);
+ img.SetMaskColour(123,123,123);
+ m_closeButton = wxBitmap( img );
}
/* these are called when the borders are drawn */
gdk_window_invalidate_rect( GTK_PIZZA(m_mainWidget)->bin_window, NULL, true );
}
-#endif
+#endif // wxUSE_MINIFRAME