2007-12-30 16:41:49 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
gmainwindow.cpp
|
|
|
|
|
|
|
|
(c) 2004-2006 - Daniel Campos Fernández <dcamposf@gmail.com>
|
2009-08-17 10:41:51 +00:00
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-08-17 10:41:51 +00:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 16:41:49 +00:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "widgets.h"
|
|
|
|
#include "widgets_private.h"
|
|
|
|
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
#endif
|
|
|
|
|
2008-04-18 23:43:38 +00:00
|
|
|
#include "x11.h"
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
#include "gapplication.h"
|
|
|
|
#include "gdesktop.h"
|
|
|
|
#include "gkey.h"
|
|
|
|
#include "gmenu.h"
|
|
|
|
#include "gmessage.h"
|
|
|
|
#include "gdialog.h"
|
|
|
|
#include "gmainwindow.h"
|
|
|
|
|
|
|
|
static gboolean win_frame(GtkWidget *widget,GdkEventWindowState *event,gMainWindow *data)
|
|
|
|
{
|
|
|
|
data->performArrange();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cb_show (GtkWidget *widget, gMainWindow *data)
|
|
|
|
{
|
|
|
|
data->emitOpen();
|
|
|
|
if (data->opened)
|
|
|
|
{
|
|
|
|
//data->performArrange();
|
|
|
|
data->emit(SIGNAL(data->onShow));
|
|
|
|
data->_not_spontaneous = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cb_hide (GtkWidget *widget, gMainWindow *data)
|
|
|
|
{
|
|
|
|
data->emit(SIGNAL(data->onHide));
|
|
|
|
data->_not_spontaneous = false;
|
2008-06-26 09:49:06 +00:00
|
|
|
if (data == gDesktop::activeWindow())
|
|
|
|
gMainWindow::setActiveWindow(NULL);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean win_close(GtkWidget *widget,GdkEvent *event,gMainWindow *data)
|
|
|
|
{
|
2010-01-24 14:23:51 +00:00
|
|
|
if (!gMainWindow::_current || data == gMainWindow::_current)
|
|
|
|
data->doClose();
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean resize_later(gMainWindow *data)
|
|
|
|
{
|
|
|
|
data->bufW = data->_next_w;
|
|
|
|
data->bufH = data->_next_h;
|
|
|
|
data->_next_timer = 0;
|
2009-06-22 11:16:34 +00:00
|
|
|
data->configure();
|
2007-12-30 16:41:49 +00:00
|
|
|
data->performArrange();
|
|
|
|
|
|
|
|
if (data->onResize)
|
|
|
|
data->onResize(data);
|
|
|
|
|
|
|
|
data->refresh();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-02-21 13:14:16 +00:00
|
|
|
static gboolean cb_configure(GtkWidget *widget, GdkEventConfigure *event, gMainWindow *data)
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
2008-02-21 13:14:16 +00:00
|
|
|
gint x, y;
|
2007-12-30 16:41:49 +00:00
|
|
|
//fprintf(stderr, "cb_configure: %p\n", data);
|
|
|
|
|
|
|
|
if (data->opened)
|
|
|
|
{
|
2008-02-21 13:14:16 +00:00
|
|
|
if (data->isTopLevel())
|
|
|
|
gtk_window_get_position(GTK_WINDOW(data->border), &x, &y);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = event->x;
|
|
|
|
y = event->y;
|
|
|
|
}
|
|
|
|
if (x != data->bufX || y != data->bufY)
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
2008-02-21 13:14:16 +00:00
|
|
|
data->bufX = x;
|
|
|
|
data->bufY = y;
|
2007-12-30 16:41:49 +00:00
|
|
|
if (data->onMove) data->onMove(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (event->width!=data->bufW) || (event->height!=data->bufH) || (data->_resized) || !event->window )
|
|
|
|
{
|
|
|
|
data->_next_w = event->width;
|
|
|
|
data->_next_h = event->height;
|
|
|
|
/* data->bufW=event->width;
|
|
|
|
data->bufH=event->height;
|
|
|
|
//g_debug("gMainWindow: cb_configure: %d", event->send_event);
|
|
|
|
data->performArrange();
|
|
|
|
if (data->onResize) data->onResize(data);*/
|
2008-10-21 09:28:34 +00:00
|
|
|
//if (data->_resized || data->parent())
|
|
|
|
//{
|
2007-12-30 16:41:49 +00:00
|
|
|
data->_resized = false;
|
|
|
|
resize_later(data);
|
2008-10-21 09:28:34 +00:00
|
|
|
/*}
|
2007-12-30 16:41:49 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
//resize_later(data);
|
|
|
|
if (!data->_next_timer)
|
|
|
|
data->_next_timer = g_timeout_add(50, (GSourceFunc)resize_later, data);
|
2008-10-21 09:28:34 +00:00
|
|
|
}*/
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cb_open(GtkWidget *widget, GdkEvent *e, gMainWindow *data)
|
|
|
|
{
|
|
|
|
data->emitOpen();
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean cb_expose(GtkWidget *wid, GdkEventExpose *e, gMainWindow *data)
|
|
|
|
{
|
|
|
|
if (data->_background)
|
|
|
|
{
|
|
|
|
gdk_window_clear(data->border->window);
|
|
|
|
gdk_window_clear(GTK_LAYOUT(data->widget)->bin_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GList *gMainWindow::windows = NULL;
|
|
|
|
gMainWindow *gMainWindow::_active = NULL;
|
|
|
|
gMainWindow *gMainWindow::_current = NULL;
|
|
|
|
|
|
|
|
void gMainWindow::initialize()
|
|
|
|
{
|
|
|
|
//fprintf(stderr, "new window: %p in %p\n", this, parent());
|
|
|
|
|
|
|
|
opened = false;
|
|
|
|
sticky = false;
|
|
|
|
persistent = false;
|
|
|
|
stack = 0;
|
2009-02-15 23:49:07 +00:00
|
|
|
_type = 0;
|
2007-12-30 16:41:49 +00:00
|
|
|
_mask = false;
|
|
|
|
_masked = false;
|
|
|
|
_resized = false;
|
|
|
|
accel = NULL;
|
|
|
|
_default = NULL;
|
|
|
|
_cancel = NULL;
|
|
|
|
menuBar = NULL;
|
2009-06-22 11:16:34 +00:00
|
|
|
layout = NULL;
|
2007-12-30 16:41:49 +00:00
|
|
|
top_only = false;
|
|
|
|
_icon = NULL;
|
|
|
|
_picture = NULL;
|
|
|
|
focus = 0;
|
|
|
|
_closing = false;
|
|
|
|
_title = NULL;
|
|
|
|
_not_spontaneous = false;
|
|
|
|
_skip_taskbar = false;
|
|
|
|
_current = NULL;
|
|
|
|
_background = NULL;
|
|
|
|
_style = NULL;
|
2008-05-10 15:17:07 +00:00
|
|
|
_next_timer = 0;
|
2008-05-21 09:41:25 +00:00
|
|
|
_xembed = false;
|
2008-11-10 17:01:48 +00:00
|
|
|
_activate = false;
|
2008-12-28 19:01:39 +00:00
|
|
|
_hidden = false;
|
2009-06-22 11:16:34 +00:00
|
|
|
_hideMenuBar = false;
|
|
|
|
_showMenuBar = true;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
onOpen = NULL;
|
|
|
|
onShow = NULL;
|
|
|
|
onHide = NULL;
|
|
|
|
onMove = NULL;
|
|
|
|
onResize = NULL;
|
|
|
|
onActivate = NULL;
|
|
|
|
onDeactivate = NULL;
|
|
|
|
|
|
|
|
accel = gtk_accel_group_new();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::initWindow()
|
|
|
|
{
|
|
|
|
//resize(200,150);
|
|
|
|
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel())
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
|
|
|
g_signal_connect(G_OBJECT(border), "show", G_CALLBACK(cb_show), (gpointer)this);
|
|
|
|
g_signal_connect(G_OBJECT(border), "configure-event", G_CALLBACK(cb_configure), (gpointer)this);
|
|
|
|
g_signal_connect_after(G_OBJECT(border), "map-event", G_CALLBACK(cb_open), (gpointer)this);
|
|
|
|
g_signal_connect(G_OBJECT(border),"show",G_CALLBACK(cb_show),(gpointer)this);
|
|
|
|
g_signal_connect(G_OBJECT(border),"hide",G_CALLBACK(cb_hide),(gpointer)this);
|
|
|
|
//g_signal_connect_after(G_OBJECT(border), "size-allocate", G_CALLBACK(cb_configure), (gpointer)this);
|
2008-09-26 02:25:29 +00:00
|
|
|
g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(cb_expose), (gpointer)this);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//g_signal_connect(G_OBJECT(border),"size-request",G_CALLBACK(cb_realize),(gpointer)this);
|
|
|
|
g_signal_connect(G_OBJECT(border), "show",G_CALLBACK(cb_show),(gpointer)this);
|
|
|
|
g_signal_connect(G_OBJECT(border), "hide",G_CALLBACK(cb_hide),(gpointer)this);
|
|
|
|
g_signal_connect(G_OBJECT(border), "configure-event",G_CALLBACK(cb_configure),(gpointer)this);
|
|
|
|
g_signal_connect(G_OBJECT(border), "delete-event",G_CALLBACK(win_close),(gpointer)this);
|
|
|
|
g_signal_connect(G_OBJECT(border), "window-state-event",G_CALLBACK(win_frame),(gpointer)this);
|
2008-09-26 02:25:29 +00:00
|
|
|
|
|
|
|
gtk_widget_add_events(widget,GDK_BUTTON_MOTION_MASK);
|
2007-12-30 16:41:49 +00:00
|
|
|
g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(cb_expose), (gpointer)this);
|
|
|
|
}
|
|
|
|
|
2008-04-21 23:15:48 +00:00
|
|
|
//GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
|
[DEVELOPMENT ENVIRONMENT]
* BUG: Use TextEdit.RichText insted of TextEdit.Text.
* BUG: END SUB can be the end of a method. The class analyze now takes
that into account.
[HELP]
* BUG: Fixed the generated treeview.
[COMPILER]
* OPT: The NOT operator used just at the beginning of a conditional
expression is optimized. Consequently, an expression like 'IF NOT 2' is
now equivalent to 'IF 2 = 0' and not to 'IF (NOT 2) <> 0' as before. In
other words, the boolean conversion is now done before the NOT, and not
after. The following instructions are concerned: IF, WHILE, UNTIL.
* NEW: BYREF is new keyword that is a more readable synonymous of '@'.
[GB.DB.FORM]
* BUG: Correctly manage data controls inside TabStrip-like containers.
* BUG: Setting the focus on a non-initialized DataControl does not raise
an error anymore.
[GB.GTK]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Window arrangement is done before the Open event is raised, as in
gb.qt.
* BUG: Keyboard, focus and mouse events now work correctly on Window and
DrawingArea controls.
[GB.QT]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Many warning fixes.
* BUG: Now the Control.Visible property works like in gb.gtk, i.e. it
returns if the control was not explicitely hidden.
git-svn-id: svn://localhost/gambas/trunk@1060 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-02-06 00:25:48 +00:00
|
|
|
//gtk_widget_add_events(widget, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
|
|
|
|
|
|
|
|
/* GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK
|
|
|
|
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
|
|
|
|
| GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_POINTER_MOTION_MASK);*/
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(topLevel()->border), accel);
|
2008-06-11 10:44:50 +00:00
|
|
|
|
2008-09-26 02:25:29 +00:00
|
|
|
have_cursor = true; //parent() == 0 && !_xembed;
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gMainWindow::gMainWindow(int plug) : gContainer(NULL)
|
|
|
|
{
|
|
|
|
initialize();
|
|
|
|
g_typ = Type_gMainWindow;
|
|
|
|
|
|
|
|
windows = g_list_append(windows, (gpointer)this);
|
|
|
|
|
2008-05-21 09:41:25 +00:00
|
|
|
_xembed = plug != 0;
|
|
|
|
|
|
|
|
if (_xembed)
|
2007-12-30 16:41:49 +00:00
|
|
|
border = gtk_plug_new(plug);
|
|
|
|
else
|
|
|
|
border = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
|
|
|
|
widget = gtk_layout_new(0,0);
|
|
|
|
|
|
|
|
realize(false);
|
[DEVELOPMENT ENVIRONMENT]
* BUG: Use TextEdit.RichText insted of TextEdit.Text.
* BUG: END SUB can be the end of a method. The class analyze now takes
that into account.
[HELP]
* BUG: Fixed the generated treeview.
[COMPILER]
* OPT: The NOT operator used just at the beginning of a conditional
expression is optimized. Consequently, an expression like 'IF NOT 2' is
now equivalent to 'IF 2 = 0' and not to 'IF (NOT 2) <> 0' as before. In
other words, the boolean conversion is now done before the NOT, and not
after. The following instructions are concerned: IF, WHILE, UNTIL.
* NEW: BYREF is new keyword that is a more readable synonymous of '@'.
[GB.DB.FORM]
* BUG: Correctly manage data controls inside TabStrip-like containers.
* BUG: Setting the focus on a non-initialized DataControl does not raise
an error anymore.
[GB.GTK]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Window arrangement is done before the Open event is raised, as in
gb.qt.
* BUG: Keyboard, focus and mouse events now work correctly on Window and
DrawingArea controls.
[GB.QT]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Many warning fixes.
* BUG: Now the Control.Visible property works like in gb.gtk, i.e. it
returns if the control was not explicitely hidden.
git-svn-id: svn://localhost/gambas/trunk@1060 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-02-06 00:25:48 +00:00
|
|
|
initWindow();
|
2007-12-30 16:41:49 +00:00
|
|
|
|
[DEVELOPMENT ENVIRONMENT]
* BUG: Use TextEdit.RichText insted of TextEdit.Text.
* BUG: END SUB can be the end of a method. The class analyze now takes
that into account.
[HELP]
* BUG: Fixed the generated treeview.
[COMPILER]
* OPT: The NOT operator used just at the beginning of a conditional
expression is optimized. Consequently, an expression like 'IF NOT 2' is
now equivalent to 'IF 2 = 0' and not to 'IF (NOT 2) <> 0' as before. In
other words, the boolean conversion is now done before the NOT, and not
after. The following instructions are concerned: IF, WHILE, UNTIL.
* NEW: BYREF is new keyword that is a more readable synonymous of '@'.
[GB.DB.FORM]
* BUG: Correctly manage data controls inside TabStrip-like containers.
* BUG: Setting the focus on a non-initialized DataControl does not raise
an error anymore.
[GB.GTK]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Window arrangement is done before the Open event is raised, as in
gb.qt.
* BUG: Keyboard, focus and mouse events now work correctly on Window and
DrawingArea controls.
[GB.QT]
* BUG: HSplitter.Layout and VSplitter.Layout now work correctly. It is a
list of children widths, hidden children having a zero width.
* BUG: Many warning fixes.
* BUG: Now the Control.Visible property works like in gb.gtk, i.e. it
returns if the control was not explicitely hidden.
git-svn-id: svn://localhost/gambas/trunk@1060 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2008-02-06 00:25:48 +00:00
|
|
|
gtk_widget_realize(border);
|
2007-12-30 16:41:49 +00:00
|
|
|
gtk_widget_show(widget);
|
|
|
|
|
|
|
|
gtk_widget_set_size_request(border, 4, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
gMainWindow::gMainWindow(gContainer *par) : gContainer(par)
|
|
|
|
{
|
|
|
|
initialize();
|
|
|
|
g_typ = Type_gMainWindow;
|
|
|
|
|
2008-09-26 02:25:29 +00:00
|
|
|
border = gtk_event_box_new();
|
|
|
|
widget = gtk_layout_new(0,0);
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
realize(false);
|
|
|
|
|
|
|
|
initWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
gMainWindow::~gMainWindow()
|
|
|
|
{
|
|
|
|
//fprintf(stderr, "delete window %p %s\n", this, name());
|
|
|
|
|
|
|
|
if (opened)
|
|
|
|
{
|
|
|
|
emit(SIGNAL(onClose));
|
|
|
|
opened = false;
|
2008-12-28 19:01:39 +00:00
|
|
|
if (GTK_IS_WINDOW(border) && modal())
|
2009-09-06 15:57:54 +00:00
|
|
|
gApplication::exitLoop(this);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_next_timer)
|
|
|
|
g_source_remove(_next_timer);
|
|
|
|
|
|
|
|
gPicture::assign(&_picture);
|
|
|
|
gPicture::assign(&_icon);
|
|
|
|
if (_title) g_free(_title);
|
|
|
|
g_object_unref(accel);
|
|
|
|
if (_background) g_object_unref(_background);
|
|
|
|
if (_style) g_object_unref(_style);
|
|
|
|
|
|
|
|
windows = g_list_remove(windows, (gpointer)this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::getSticky()
|
|
|
|
{
|
|
|
|
return sticky;
|
|
|
|
}
|
|
|
|
|
|
|
|
int gMainWindow::getStacking()
|
|
|
|
{
|
|
|
|
return stack;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setSticky(bool vl)
|
|
|
|
{
|
|
|
|
sticky=vl;
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
if (vl) gtk_window_stick(GTK_WINDOW(border));
|
|
|
|
else gtk_window_unstick(GTK_WINDOW(border));
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setStacking(int vl)
|
|
|
|
{
|
|
|
|
stack=vl;
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
switch (vl)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
gtk_window_set_keep_below(GTK_WINDOW(border),FALSE);
|
|
|
|
gtk_window_set_keep_above(GTK_WINDOW(border),FALSE);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
gtk_window_set_keep_below(GTK_WINDOW(border),FALSE);
|
|
|
|
gtk_window_set_keep_above(GTK_WINDOW(border),TRUE);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
gtk_window_set_keep_above(GTK_WINDOW(border),FALSE);
|
|
|
|
gtk_window_set_keep_below(GTK_WINDOW(border),TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setRealBackground(gColor color)
|
|
|
|
{
|
|
|
|
if (!_picture)
|
|
|
|
gControl::setRealBackground(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::move(int x, int y)
|
|
|
|
{
|
2008-02-21 13:14:16 +00:00
|
|
|
if (isTopLevel())
|
|
|
|
{
|
|
|
|
if (x == bufX && y == bufY)
|
|
|
|
return;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
2008-02-21 13:14:16 +00:00
|
|
|
bufX = x;
|
|
|
|
bufY = y;
|
|
|
|
gtk_window_move(GTK_WINDOW(border), x, y);
|
|
|
|
}
|
|
|
|
else
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
|
|
|
gContainer::move(x,y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gMainWindow::resize(int w, int h)
|
|
|
|
{
|
|
|
|
if (isTopLevel())
|
|
|
|
{
|
|
|
|
if (w == bufW && h == bufH)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_resized=true;
|
|
|
|
bufW = w;
|
|
|
|
bufH = h;
|
|
|
|
|
|
|
|
//gdk_window_enable_synchronized_configure (border->window);
|
|
|
|
|
2009-02-04 22:51:20 +00:00
|
|
|
if (w < 1 || h < 1)
|
|
|
|
{
|
|
|
|
if (visible)
|
|
|
|
gtk_widget_hide(border);
|
|
|
|
}
|
2007-12-30 16:41:49 +00:00
|
|
|
else
|
2009-02-04 22:51:20 +00:00
|
|
|
{
|
|
|
|
if (gtk_window_get_resizable(GTK_WINDOW(border)))
|
|
|
|
gtk_window_resize(GTK_WINDOW(border),w,h);
|
|
|
|
else
|
|
|
|
gtk_widget_set_size_request(border, w, h);
|
|
|
|
|
|
|
|
if (visible)
|
|
|
|
gtk_widget_show(border);
|
|
|
|
}
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//fprintf(stderr, "resize %p -> (%d %d) (%d %d)\n", this, bufW, bufH, w, h);
|
|
|
|
gContainer::resize(w, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::emitOpen()
|
|
|
|
{
|
|
|
|
if (!opened)
|
|
|
|
{
|
|
|
|
//fprintf(stderr, "emit Open: %p (%d %d)\n", this, width(), height());
|
|
|
|
opened = true;
|
|
|
|
gtk_widget_realize(border);
|
|
|
|
performArrange();
|
|
|
|
emit(SIGNAL(onOpen));
|
|
|
|
if (opened)
|
|
|
|
{
|
|
|
|
//fprintf(stderr, "emit Move & Resize: %p\n", this);
|
|
|
|
emit(SIGNAL(onMove));
|
|
|
|
emit(SIGNAL(onResize));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-10 17:01:48 +00:00
|
|
|
void gMainWindow::afterShow()
|
|
|
|
{
|
|
|
|
if (_activate)
|
|
|
|
{
|
|
|
|
gtk_window_present(GTK_WINDOW(border));
|
|
|
|
_activate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
void gMainWindow::setVisible(bool vl)
|
|
|
|
{
|
2008-04-18 23:43:38 +00:00
|
|
|
gMainWindow *active;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
if (vl)
|
|
|
|
{
|
|
|
|
emitOpen();
|
|
|
|
if (!opened)
|
|
|
|
return;
|
|
|
|
|
2008-05-21 09:41:25 +00:00
|
|
|
if (isTopLevel() && !_xembed)
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
|
|
|
//fprintf(stderr, "adding window %p to group %p\n", this, group);
|
2009-09-12 23:42:11 +00:00
|
|
|
gtk_window_group_add_window(gApplication::currentGroup(), GTK_WINDOW(border));
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_not_spontaneous = !visible;
|
|
|
|
visible = true;
|
2008-12-28 19:01:39 +00:00
|
|
|
_hidden = false;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
if (isTopLevel())
|
|
|
|
{
|
|
|
|
if (!_title || !*_title)
|
|
|
|
gtk_window_set_title(GTK_WINDOW(border), gApplication::defaultTitle());
|
2008-04-18 23:43:38 +00:00
|
|
|
|
|
|
|
active = gDesktop::activeWindow();
|
|
|
|
if (active && active != this)
|
|
|
|
gtk_window_set_transient_for(GTK_WINDOW(border), GTK_WINDOW(active->border));
|
|
|
|
|
2009-05-15 17:57:29 +00:00
|
|
|
gtk_window_move(GTK_WINDOW(border), bufX, bufY);
|
2009-07-21 19:55:22 +00:00
|
|
|
gtk_window_present(GTK_WINDOW(border));
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_show(border);
|
|
|
|
parent()->performArrange();
|
|
|
|
}
|
|
|
|
|
2008-09-26 02:25:29 +00:00
|
|
|
drawMask();
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
if (focus)
|
|
|
|
{
|
2008-09-26 02:25:29 +00:00
|
|
|
//fprintf(stderr, "focus = %s\n", focus->name());
|
2007-12-30 16:41:49 +00:00
|
|
|
focus->setFocus();
|
|
|
|
focus = 0;
|
|
|
|
}
|
2008-11-10 17:01:48 +00:00
|
|
|
|
|
|
|
if (skipTaskBar())
|
|
|
|
_activate = true;
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-26 09:49:06 +00:00
|
|
|
if (this == _active)
|
|
|
|
focus = gDesktop::activeControl();
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
_not_spontaneous = visible;
|
2008-12-28 19:01:39 +00:00
|
|
|
_hidden = true;
|
2007-12-30 16:41:49 +00:00
|
|
|
gControl::setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gMainWindow::setMinimized(bool vl)
|
|
|
|
{
|
|
|
|
if (vl) gtk_window_iconify(GTK_WINDOW(border));
|
|
|
|
else gtk_window_deiconify(GTK_WINDOW(border));
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setMaximized(bool vl)
|
|
|
|
{
|
|
|
|
if (vl) gtk_window_maximize(GTK_WINDOW(border));
|
|
|
|
else gtk_window_unmaximize(GTK_WINDOW(border));
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setFullscreen(bool vl)
|
|
|
|
{
|
|
|
|
if (vl) gtk_window_fullscreen(GTK_WINDOW(border));
|
|
|
|
else gtk_window_unfullscreen(GTK_WINDOW(border));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::minimized()
|
|
|
|
{
|
|
|
|
return (bool)(gdk_window_get_state(border->window) & GDK_WINDOW_STATE_ICONIFIED);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::maximized()
|
|
|
|
{
|
|
|
|
return (bool)(gdk_window_get_state(border->window) & GDK_WINDOW_STATE_MAXIMIZED);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::fullscreen()
|
|
|
|
{
|
|
|
|
return (bool)(gdk_window_get_state(border->window) & GDK_WINDOW_STATE_FULLSCREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::center()
|
|
|
|
{
|
|
|
|
int myx,myy;
|
|
|
|
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
myx=(gDesktop::width()/2)-(width()/2);
|
|
|
|
myy=(gDesktop::height()/2)-(height()/2);
|
|
|
|
|
|
|
|
move(myx,myy);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::modal()
|
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return false;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
return gtk_window_get_modal (GTK_WINDOW(border));
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::showModal()
|
|
|
|
{
|
|
|
|
gMainWindow *save;
|
|
|
|
|
|
|
|
if (!isTopLevel()) return;
|
|
|
|
if (modal()) return;
|
|
|
|
|
|
|
|
save = _current;
|
|
|
|
_current = this;
|
|
|
|
|
|
|
|
gtk_window_set_modal(GTK_WINDOW(border), true);
|
|
|
|
|
|
|
|
center();
|
2009-09-27 09:28:52 +00:00
|
|
|
//show();
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
//fprintf(stderr, "showModal: begin %p\n", this);
|
|
|
|
|
2009-09-27 09:28:52 +00:00
|
|
|
gApplication::enterLoop(this, true);
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
//fprintf(stderr, "showModal: end %p\n", this);
|
|
|
|
|
|
|
|
_current = save;
|
|
|
|
|
2008-12-08 01:22:08 +00:00
|
|
|
gtk_window_set_modal(GTK_WINDOW(border), false);
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
if (!persistent)
|
|
|
|
destroyNow();
|
|
|
|
else
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::raise()
|
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) { gControl::raise(); return; }
|
2007-12-30 16:41:49 +00:00
|
|
|
gtk_window_present(GTK_WINDOW(border));
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* gMainWindow::text()
|
|
|
|
{
|
|
|
|
return _title;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::skipTaskBar()
|
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel())
|
2007-12-30 16:41:49 +00:00
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return _skip_taskbar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gMainWindow::setText(const char *txt)
|
|
|
|
{
|
|
|
|
if (_title) g_free(_title);
|
|
|
|
_title = g_strdup(txt);
|
|
|
|
|
|
|
|
if (isTopLevel())
|
|
|
|
gtk_window_set_title(GTK_WINDOW(border), txt);
|
|
|
|
}
|
|
|
|
|
2008-04-18 23:43:38 +00:00
|
|
|
bool gMainWindow::hasBorder()
|
|
|
|
{
|
|
|
|
return gtk_window_get_decorated(GTK_WINDOW(border));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::isResizable()
|
|
|
|
{
|
|
|
|
return gtk_window_get_resizable(GTK_WINDOW(border));
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setBorder(bool b)
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel())
|
2008-04-18 23:43:38 +00:00
|
|
|
return;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
2008-04-18 23:43:38 +00:00
|
|
|
gtk_window_set_decorated(GTK_WINDOW(border), b);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 23:43:38 +00:00
|
|
|
void gMainWindow::setResizable(bool b)
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel())
|
2008-04-18 23:43:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (b == isResizable())
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_window_set_resizable(GTK_WINDOW(border), b);
|
|
|
|
|
|
|
|
if (b)
|
|
|
|
gtk_widget_set_size_request(border, 1, 1);
|
|
|
|
else
|
|
|
|
gtk_widget_set_size_request(border, bufW, bufH);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
2008-04-18 23:43:38 +00:00
|
|
|
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
void gMainWindow::setSkipTaskBar(bool b)
|
|
|
|
{
|
|
|
|
_skip_taskbar = b;
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return;
|
2007-12-30 16:41:49 +00:00
|
|
|
gtk_window_set_skip_taskbar_hint (GTK_WINDOW(border), b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*gPicture* gMainWindow::icon()
|
|
|
|
{
|
|
|
|
GdkPixbuf *buf;
|
|
|
|
gPicture *pic;
|
|
|
|
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return NULL;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
buf=gtk_window_get_icon(GTK_WINDOW(border));
|
|
|
|
if (!buf) return NULL;
|
|
|
|
|
|
|
|
pic=gPicture::fromPixbuf(buf);
|
|
|
|
|
|
|
|
return pic;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
void gMainWindow::setIcon(gPicture *pic)
|
|
|
|
{
|
|
|
|
gPicture::assign(&_icon, pic);
|
|
|
|
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return;
|
2007-12-30 16:41:49 +00:00
|
|
|
gtk_window_set_icon(GTK_WINDOW(border), pic ? pic->getPixbuf() : NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::topOnly()
|
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return false;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
return top_only;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setTopOnly(bool vl)
|
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel()) return;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
|
|
|
gtk_window_set_keep_above (GTK_WINDOW(border),vl);
|
|
|
|
top_only=vl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void gMainWindow::setMask(bool vl)
|
|
|
|
{
|
|
|
|
if (_mask == vl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_mask = vl;
|
|
|
|
drawMask();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setPicture(gPicture *pic)
|
|
|
|
{
|
|
|
|
gPicture::assign(&_picture, pic);
|
|
|
|
drawMask();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::remap()
|
|
|
|
{
|
|
|
|
if (!isVisible())
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_widget_unmap(border);
|
|
|
|
gtk_widget_map(border);
|
|
|
|
|
|
|
|
if (_skip_taskbar) { setSkipTaskBar(false); setSkipTaskBar(true); }
|
|
|
|
if (top_only) { setTopOnly(false); setTopOnly(true); }
|
|
|
|
if (sticky) { setSticky(false); setSticky(true); }
|
|
|
|
if (stack) { setStacking(0); setStacking(stack); }
|
2009-02-15 23:49:07 +00:00
|
|
|
X11_set_window_type(handle(), _type);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::drawMask()
|
|
|
|
{
|
|
|
|
GdkBitmap *mask;
|
|
|
|
GdkPixmap *back;
|
|
|
|
bool do_remap = false;
|
|
|
|
|
|
|
|
/*if (win_style)
|
|
|
|
{
|
|
|
|
g_object_unref(win_style);
|
|
|
|
win_style = NULL;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
/*if (_picture)
|
|
|
|
{
|
|
|
|
back = _picture->getPixmap();
|
|
|
|
g_object_ref(back);
|
|
|
|
win_style = gtk_style_copy(widget->style);
|
|
|
|
win_style->bg_pixmap[GTK_STATE_NORMAL] = back;
|
|
|
|
gtk_widget_set_style(widget, win_style);
|
|
|
|
//gdk_window_invalidate_rect(border->window,NULL,true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_set_style(widget, NULL);
|
|
|
|
}*/
|
|
|
|
|
|
|
|
if (!isVisible())
|
|
|
|
return;
|
|
|
|
|
|
|
|
//if (_background)
|
|
|
|
// g_object_unref(_background);
|
|
|
|
|
|
|
|
mask = (_mask && _picture) ? _picture->getMask() : NULL;
|
|
|
|
do_remap = !mask && _masked;
|
|
|
|
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
XShapeCombineMask(GDK_WINDOW_XDISPLAY(border->window), GDK_WINDOW_XID(border->window), ShapeBounding, 0, 0,
|
|
|
|
mask ? GDK_PIXMAP_XID(mask) : None, ShapeSet);
|
|
|
|
#else
|
|
|
|
//gdk_window_shape_combine_mask(border->window, mask, 0, 0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
back = _picture ? _picture->getPixmap() : NULL;
|
|
|
|
gtk_widget_set_double_buffered(border, back == NULL);
|
|
|
|
gtk_widget_set_double_buffered(widget, back == NULL);
|
|
|
|
|
|
|
|
if (back)
|
|
|
|
{
|
2008-09-26 02:25:29 +00:00
|
|
|
gtk_widget_realize(border);
|
|
|
|
gtk_widget_realize(widget);
|
2007-12-30 16:41:49 +00:00
|
|
|
gdk_window_set_back_pixmap(border->window, back, FALSE);
|
|
|
|
gdk_window_set_back_pixmap(GTK_LAYOUT(widget)->bin_window, back, FALSE);
|
|
|
|
gdk_window_clear(border->window);
|
|
|
|
gdk_window_clear(GTK_LAYOUT(widget)->bin_window);
|
|
|
|
gtk_widget_set_app_paintable(border, true);
|
|
|
|
gtk_widget_set_app_paintable(widget, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setRealBackground(background());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_background)
|
|
|
|
g_object_unref(_background);
|
|
|
|
_background = back;
|
|
|
|
if (_background)
|
|
|
|
g_object_ref(_background);
|
|
|
|
|
|
|
|
_masked = mask != NULL;
|
|
|
|
|
|
|
|
if (do_remap)
|
|
|
|
remap();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!_skip_taskbar)
|
|
|
|
{
|
|
|
|
setSkipTaskBar(true);
|
|
|
|
setSkipTaskBar(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//gtk_widget_queue_draw(border);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
GdkBitmap *map=NULL;
|
|
|
|
GdkPixmap *pix=NULL;
|
|
|
|
GdkColor black;
|
|
|
|
gint pw,ph;
|
|
|
|
GdkPixbuf *buf_mask = _picture ? _picture->getPixbuf() : NULL;
|
|
|
|
|
|
|
|
if (win_style) {
|
|
|
|
g_object_unref(win_style);
|
|
|
|
win_style=NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buf_mask)
|
|
|
|
{
|
|
|
|
pw=gdk_pixbuf_get_width(buf_mask);
|
|
|
|
ph=gdk_pixbuf_get_height(buf_mask);
|
|
|
|
|
|
|
|
map=gdk_pixmap_new(NULL,pw,ph,1);
|
|
|
|
gdk_pixbuf_render_threshold_alpha(buf_mask,map,0,0,0,0,pw,ph,128);
|
|
|
|
|
|
|
|
pix=gdk_pixmap_new(border->window,pw,ph,-1);
|
|
|
|
GdkGC* gc=gdk_gc_new(border->window);
|
|
|
|
fill_gdk_color(&black,0);
|
|
|
|
gdk_gc_set_foreground (gc,&black);
|
|
|
|
gdk_gc_set_background (gc,&black);
|
|
|
|
gdk_draw_rectangle(pix,gc,true,0,0,pw,ph);
|
|
|
|
gdk_draw_pixbuf(pix,gc,buf_mask,0,0,0,0,pw,ph,GDK_RGB_DITHER_MAX,0,0);
|
|
|
|
g_object_unref(G_OBJECT(gc));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buf_mask && _mask) gtk_widget_shape_combine_mask(border,map,0,0);
|
|
|
|
else gtk_widget_shape_combine_mask(border,NULL,0,0);
|
|
|
|
|
|
|
|
if (map)
|
|
|
|
{
|
|
|
|
win_style=gtk_style_copy(widget->style);
|
|
|
|
win_style->bg_pixmap[GTK_STATE_NORMAL]=pix;
|
|
|
|
gtk_widget_set_style(widget,win_style);
|
|
|
|
gdk_window_invalidate_rect( border->window,NULL,true);
|
|
|
|
g_object_unref(G_OBJECT(map));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_set_style(widget,NULL);
|
|
|
|
if (border->window) //GTK_WIDGET_REALIZED(widget))
|
|
|
|
{
|
|
|
|
gtk_widget_reset_shapes(border);
|
|
|
|
gdk_window_invalidate_rect(border->window,NULL,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int gMainWindow::menuCount()
|
|
|
|
{
|
|
|
|
if (!menuBar) return 0;
|
|
|
|
return gMenu::winChildCount(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setPersistent(bool vl)
|
|
|
|
{
|
|
|
|
persistent = vl;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::doClose()
|
|
|
|
{
|
|
|
|
if (_closing)
|
|
|
|
return false;
|
2009-09-06 15:57:54 +00:00
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
if (opened)
|
|
|
|
{
|
2009-09-06 15:57:54 +00:00
|
|
|
if (modal() && !gApplication::hasLoop(this))
|
|
|
|
return true;
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
_closing = true;
|
|
|
|
if (onClose)
|
|
|
|
{
|
|
|
|
if (!onClose(this))
|
|
|
|
opened = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
opened = false;
|
|
|
|
_closing = false;
|
2008-12-08 01:22:08 +00:00
|
|
|
|
|
|
|
if (modal())
|
2009-09-06 15:57:54 +00:00
|
|
|
gApplication::exitLoop(this);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!opened) // && !modal())
|
|
|
|
{
|
|
|
|
if (!modal())
|
|
|
|
{
|
|
|
|
if (persistent)
|
|
|
|
hide();
|
|
|
|
else
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return opened;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool gMainWindow::close()
|
|
|
|
{
|
|
|
|
return doClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::reparent(gContainer *newpr, int x, int y)
|
|
|
|
{
|
|
|
|
GtkWidget *new_border;
|
2008-06-11 10:44:50 +00:00
|
|
|
int w, h;
|
2009-03-15 11:32:01 +00:00
|
|
|
gColor fg, bg;
|
2008-06-11 10:44:50 +00:00
|
|
|
|
|
|
|
if (_xembed)
|
|
|
|
return;
|
2007-12-30 16:41:49 +00:00
|
|
|
|
2009-03-15 11:32:01 +00:00
|
|
|
bg = background();
|
|
|
|
fg = foreground();
|
|
|
|
|
2008-12-28 19:01:39 +00:00
|
|
|
if (isTopLevel() && newpr)
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
|
|
|
gtk_window_remove_accel_group(GTK_WINDOW(topLevel()->border), accel);
|
2008-06-11 10:44:50 +00:00
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
new_border = gtk_event_box_new();
|
|
|
|
gtk_widget_reparent(widget, new_border);
|
2009-06-22 11:16:34 +00:00
|
|
|
embedMenuBar(new_border);
|
2007-12-30 16:41:49 +00:00
|
|
|
_no_delete = true;
|
|
|
|
gtk_widget_destroy(border);
|
|
|
|
_no_delete = false;
|
2009-09-12 23:42:11 +00:00
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
border = new_border;
|
2009-09-12 23:42:11 +00:00
|
|
|
registerControl();
|
2008-06-11 10:44:50 +00:00
|
|
|
|
|
|
|
setParent(newpr);
|
|
|
|
connectParent();
|
|
|
|
borderSignals();
|
|
|
|
initWindow();
|
2009-09-12 23:42:11 +00:00
|
|
|
|
2009-03-15 11:32:01 +00:00
|
|
|
setBackground(bg);
|
|
|
|
setForeground(fg);
|
2009-04-03 23:06:45 +00:00
|
|
|
setFont(font());
|
2008-06-11 10:44:50 +00:00
|
|
|
|
2009-06-22 11:16:34 +00:00
|
|
|
checkMenuBar();
|
2009-06-04 21:34:57 +00:00
|
|
|
|
2008-06-11 10:44:50 +00:00
|
|
|
move(x, y);
|
|
|
|
gtk_widget_set_size_request(border, width(), height());
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
2008-12-28 19:01:39 +00:00
|
|
|
else if (!isTopLevel() && !newpr)
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
|
|
|
gtk_window_remove_accel_group(GTK_WINDOW(topLevel()->border), accel);
|
|
|
|
// TODO: test that
|
|
|
|
new_border = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_widget_reparent(widget, new_border);
|
2009-06-22 11:16:34 +00:00
|
|
|
embedMenuBar(new_border);
|
2007-12-30 16:41:49 +00:00
|
|
|
_no_delete = true;
|
|
|
|
gtk_widget_destroy(border);
|
|
|
|
_no_delete = false;
|
2009-09-12 23:42:11 +00:00
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
border = new_border;
|
2009-09-12 23:42:11 +00:00
|
|
|
registerControl();
|
2008-06-11 10:44:50 +00:00
|
|
|
|
|
|
|
parent()->remove(this);
|
2009-03-15 11:32:01 +00:00
|
|
|
parent()->arrange();
|
2008-06-11 10:44:50 +00:00
|
|
|
setParent(NULL);
|
2007-12-30 16:41:49 +00:00
|
|
|
initWindow();
|
2008-06-11 10:44:50 +00:00
|
|
|
borderSignals();
|
2009-03-15 11:32:01 +00:00
|
|
|
setBackground(bg);
|
|
|
|
setForeground(fg);
|
2009-04-03 23:06:45 +00:00
|
|
|
setFont(font());
|
2008-06-11 10:44:50 +00:00
|
|
|
|
|
|
|
move(x, y);
|
|
|
|
w = width();
|
|
|
|
h = height();
|
|
|
|
bufW = bufH = -1;
|
|
|
|
resize(w, h);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
2008-06-11 10:44:50 +00:00
|
|
|
else
|
|
|
|
gControl::reparent(newpr, x, y);
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int gMainWindow::controlCount()
|
|
|
|
{
|
|
|
|
GList *list = gControl::controlList();
|
|
|
|
gControl *ctrl;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
ctrl = (gControl *)list->data;
|
|
|
|
if (ctrl->window() == this)
|
|
|
|
n++;
|
|
|
|
list = g_list_next(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
gControl *gMainWindow::getControl(char *name)
|
|
|
|
{
|
|
|
|
GList *list = gControl::controlList();
|
|
|
|
gControl *ctrl;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
ctrl = (gControl *)list->data;
|
|
|
|
if (ctrl->window() == this && !strcasecmp(ctrl->name(), name))
|
|
|
|
return ctrl;
|
|
|
|
list = g_list_next(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gControl *gMainWindow::getControl(int index)
|
|
|
|
{
|
|
|
|
GList *list = gControl::controlList();
|
|
|
|
gControl *ctrl;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
ctrl = (gControl *)list->data;
|
|
|
|
if (ctrl->window() == this)
|
|
|
|
{
|
|
|
|
if (i == index)
|
|
|
|
return ctrl;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
list = g_list_next(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int gMainWindow::clientX()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-04 22:51:20 +00:00
|
|
|
int gMainWindow::containerX()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
int gMainWindow::clientY()
|
|
|
|
{
|
|
|
|
GtkRequisition req;
|
|
|
|
|
2008-12-08 01:22:08 +00:00
|
|
|
if (menuBar && GTK_WIDGET_VISIBLE(GTK_WIDGET(menuBar)))
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
|
|
|
gtk_widget_size_request(GTK_WIDGET(menuBar), &req);
|
|
|
|
return req.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-04 22:51:20 +00:00
|
|
|
int gMainWindow::containerY()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-30 16:41:49 +00:00
|
|
|
int gMainWindow::clientWidth()
|
|
|
|
{
|
|
|
|
return width();
|
|
|
|
}
|
|
|
|
|
2009-06-22 11:16:34 +00:00
|
|
|
|
|
|
|
int gMainWindow::menuBarHeight()
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
|
|
|
GtkRequisition req;
|
|
|
|
int h = 0;
|
|
|
|
|
2009-06-22 11:16:34 +00:00
|
|
|
if (menuBar)
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
|
|
|
gtk_widget_size_request(GTK_WIDGET(menuBar), &req);
|
|
|
|
h = req.height;
|
|
|
|
}
|
|
|
|
|
2009-06-22 11:16:34 +00:00
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
int gMainWindow::clientHeight()
|
|
|
|
{
|
|
|
|
if (isMenuBarVisible())
|
|
|
|
return height() - menuBarHeight();
|
|
|
|
else
|
|
|
|
return height();
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setActiveWindow(gControl *control)
|
|
|
|
{
|
|
|
|
gMainWindow *window = control ? control->window() : NULL;
|
|
|
|
gMainWindow *old = _active;
|
|
|
|
|
|
|
|
if (window == _active)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_active = window;
|
|
|
|
|
|
|
|
if (old)
|
|
|
|
old->emit(SIGNAL(old->onDeactivate));
|
|
|
|
|
|
|
|
if (window)
|
|
|
|
window->emit(SIGNAL(window->onActivate));
|
|
|
|
}
|
|
|
|
|
2008-04-18 23:43:38 +00:00
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
int gMainWindow::getType()
|
2007-12-30 16:41:49 +00:00
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel())
|
2008-04-18 23:43:38 +00:00
|
|
|
return 0;
|
2009-02-15 23:49:07 +00:00
|
|
|
return _type; //X11_get_window_type(handle());
|
2008-04-18 23:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::setType(int type)
|
|
|
|
{
|
2008-12-28 19:01:39 +00:00
|
|
|
if (!isTopLevel())
|
2008-04-18 23:43:38 +00:00
|
|
|
return;
|
|
|
|
X11_set_window_type(handle(), type);
|
2009-02-15 23:49:07 +00:00
|
|
|
_type = type;
|
2008-04-18 23:43:38 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
int gMainWindow::getType()
|
|
|
|
{
|
|
|
|
return 0;
|
2007-12-30 16:41:49 +00:00
|
|
|
}
|
2008-04-18 23:43:38 +00:00
|
|
|
|
|
|
|
void gMainWindow::setType()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-06-22 11:16:34 +00:00
|
|
|
void gMainWindow::configure()
|
|
|
|
{
|
|
|
|
int h;
|
|
|
|
|
|
|
|
h = menuBarHeight();
|
|
|
|
|
|
|
|
if (isMenuBarVisible())
|
|
|
|
{
|
|
|
|
gtk_fixed_move(layout, GTK_WIDGET(menuBar), 0, 0);
|
|
|
|
gtk_widget_set_size_request(GTK_WIDGET(menuBar), width(), h);
|
|
|
|
gtk_fixed_move(layout, widget, 0, h);
|
|
|
|
gtk_widget_set_size_request(widget, width(), height() - h);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (layout)
|
|
|
|
{
|
|
|
|
if (menuBar)
|
|
|
|
gtk_fixed_move(layout, GTK_WIDGET(menuBar), 0, -h);
|
|
|
|
gtk_fixed_move(layout, widget, 0, 0);
|
|
|
|
gtk_widget_set_size_request(widget, width(), height());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-23 12:31:41 +00:00
|
|
|
void gMainWindow::setMenuBarVisible(bool v)
|
|
|
|
{
|
2009-06-22 11:16:34 +00:00
|
|
|
_showMenuBar = v;
|
2008-11-23 12:31:41 +00:00
|
|
|
|
|
|
|
if (!menuBar)
|
|
|
|
return;
|
2009-06-22 11:16:34 +00:00
|
|
|
|
|
|
|
configure();
|
2008-11-23 12:31:41 +00:00
|
|
|
performArrange();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gMainWindow::isMenuBarVisible()
|
|
|
|
{
|
2009-06-22 11:16:34 +00:00
|
|
|
return menuBar && !_hideMenuBar && _showMenuBar; //|| (menuBar && GTK_WIDGET_MAPPED(GTK_WIDGET(menuBar)));
|
2008-11-23 12:31:41 +00:00
|
|
|
}
|
|
|
|
|
2009-03-15 11:32:01 +00:00
|
|
|
void gMainWindow::setFont(gFont *ft)
|
|
|
|
{
|
|
|
|
gContainer::setFont(ft);
|
|
|
|
gMenu::updateFont(this);
|
|
|
|
}
|
2009-06-22 11:16:34 +00:00
|
|
|
|
|
|
|
void gMainWindow::checkMenuBar()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
gMenu *menu;
|
|
|
|
|
|
|
|
if (menuBar)
|
|
|
|
{
|
|
|
|
_hideMenuBar = true;
|
|
|
|
for (i = 0;; i++)
|
|
|
|
{
|
|
|
|
menu = gMenu::winChildMenu(this, i);
|
|
|
|
if (!menu)
|
|
|
|
break;
|
|
|
|
if (menu->isVisible() && !menu->isSeparator())
|
|
|
|
{
|
|
|
|
_hideMenuBar = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
configure();
|
|
|
|
}
|
|
|
|
|
|
|
|
void gMainWindow::embedMenuBar(GtkWidget *border)
|
|
|
|
{
|
|
|
|
if (menuBar)
|
|
|
|
{
|
|
|
|
// layout is automatically destructed ?
|
|
|
|
layout = GTK_FIXED(gtk_fixed_new());
|
|
|
|
|
|
|
|
g_object_ref(G_OBJECT(menuBar));
|
|
|
|
|
|
|
|
if (gtk_widget_get_parent(GTK_WIDGET(menuBar)))
|
|
|
|
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(GTK_WIDGET(menuBar))), GTK_WIDGET(menuBar));
|
|
|
|
|
|
|
|
gtk_fixed_put(layout, GTK_WIDGET(menuBar), 0, 0);
|
|
|
|
|
|
|
|
g_object_unref(G_OBJECT(menuBar));
|
|
|
|
|
|
|
|
gtk_widget_reparent(widget, GTK_WIDGET(layout));
|
|
|
|
gtk_container_add(GTK_CONTAINER(border), GTK_WIDGET(layout));
|
|
|
|
|
|
|
|
gtk_widget_show_all(GTK_WIDGET(layout));
|
|
|
|
//gtk_widget_show(GTK_WIDGET(par->menuBar));
|
|
|
|
set_gdk_fg_color(GTK_WIDGET(menuBar), foreground());
|
|
|
|
set_gdk_bg_color(GTK_WIDGET(menuBar), background());
|
|
|
|
//gtk_widget_modify_font(GTK_WIDGET(menuBar), font()->desc());
|
|
|
|
|
|
|
|
checkMenuBar();
|
|
|
|
}
|
|
|
|
}
|