Start to rework top-level window layout management.
[GB.GTK] * BUG: Start to rework top-level window layout management. [GB.GTK3] * BUG: Start to rework top-level window layout management.
This commit is contained in:
parent
725f523ebe
commit
104128117d
17 changed files with 178 additions and 219 deletions
|
@ -188,7 +188,7 @@ static bool cb_close(gMainWindow *sender)
|
|||
}
|
||||
}
|
||||
|
||||
if (THIS->embed)
|
||||
if (sender->isEmbedded())
|
||||
{
|
||||
CWINDOW_Embedder = 0;
|
||||
CWINDOW_Embedded = false;
|
||||
|
@ -258,7 +258,7 @@ static void cb_deactivate(gMainWindow *sender)
|
|||
|
||||
***************************************************************************/
|
||||
|
||||
BEGIN_METHOD(CWINDOW_new, GB_OBJECT parent;)
|
||||
BEGIN_METHOD(CWINDOW_new, GB_OBJECT parent)
|
||||
|
||||
gMainWindow *win;
|
||||
GB_CLASS CLASS_container;
|
||||
|
@ -277,28 +277,27 @@ BEGIN_METHOD(CWINDOW_new, GB_OBJECT parent;)
|
|||
if (GB.Conv((GB_VALUE *)(void *)ARG(parent), (GB_TYPE)CLASS_container))
|
||||
return;
|
||||
|
||||
parent=(CWIDGET*)VARG(parent);
|
||||
parent=GetContainer ((CWIDGET*)parent);
|
||||
parent = (CWIDGET*)VARG(parent);
|
||||
parent = GetContainer ((CWIDGET*)parent);
|
||||
}
|
||||
|
||||
if ( CWINDOW_Embedder && (!CWINDOW_Embedded) && (!parent) )
|
||||
{
|
||||
plug=CWINDOW_Embedder;
|
||||
THIS->embed=true;
|
||||
}
|
||||
if (CWINDOW_Embedder && (!CWINDOW_Embedded) && (!parent))
|
||||
plug = CWINDOW_Embedder;
|
||||
|
||||
if (!parent)
|
||||
if (parent)
|
||||
win = new gMainWindow((gContainer *)parent->widget);
|
||||
else if (!plug)
|
||||
win = new gMainWindow();
|
||||
else
|
||||
{
|
||||
win = new gMainWindow(plug);
|
||||
if (plug && !win->border)
|
||||
if (!win->border)
|
||||
{
|
||||
delete win;
|
||||
GB.Error("Embedder control is not supported on this platform");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
win = new gMainWindow((gContainer *)parent->widget);
|
||||
|
||||
THIS->ob.widget = win;
|
||||
InitControl(THIS->ob.widget, (CWIDGET*)THIS);
|
||||
|
|
|
@ -34,7 +34,6 @@ typedef
|
|||
{
|
||||
CWIDGET ob;
|
||||
int ret;
|
||||
unsigned embed : 1;
|
||||
}
|
||||
CWINDOW;
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ static gControl *find_child(gControl *control, int rx, int ry, gControl *button_
|
|||
control = window;
|
||||
|
||||
#ifdef GTK3
|
||||
gtk_widget_get_allocation(window->layout ? GTK_WIDGET(window->layout) : window->widget, &a);
|
||||
gtk_widget_get_allocation(window->frame, &a);
|
||||
//fprintf(stderr, "find_child: %d %d window: %d %d %d %d\n", rx, ry, a.x, a.y, a.width, a.height);
|
||||
rx -= a.x;
|
||||
ry -= a.y;
|
||||
|
|
|
@ -277,7 +277,7 @@ void gComboBox::create(bool readOnly)
|
|||
|
||||
if (first)
|
||||
{
|
||||
realize(false);
|
||||
realize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -161,20 +161,6 @@ struct _GtkLayoutChild {
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef GTK3
|
||||
static gboolean cb_frame_draw(GtkWidget *wid, cairo_t *cr, gControl *control)
|
||||
{
|
||||
control->drawBorder(cr);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
static gboolean cb_frame_expose(GtkWidget *wid, GdkEventExpose *e, gControl *control)
|
||||
{
|
||||
control->drawBorder(e);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GTK3
|
||||
static gboolean cb_background_draw(GtkWidget *wid, cairo_t *cr, gControl *control)
|
||||
{
|
||||
|
@ -189,6 +175,20 @@ static gboolean cb_background_expose(GtkWidget *wid, GdkEventExpose *e, gControl
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef GTK3
|
||||
static gboolean cb_frame_draw(GtkWidget *wid, cairo_t *cr, gControl *control)
|
||||
{
|
||||
control->drawBorder(cr);
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
static gboolean cb_frame_expose(GtkWidget *wid, GdkEventExpose *e, gControl *control)
|
||||
{
|
||||
control->drawBorder(e);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef GTK3
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -213,7 +213,7 @@ gPlugin::gPlugin(gContainer *parent) : gControl(parent)
|
|||
{
|
||||
border = gtk_socket_new();
|
||||
widget = border;
|
||||
realize(false);
|
||||
realize();
|
||||
|
||||
onPlug = NULL;
|
||||
onUnplug = NULL;
|
||||
|
@ -1635,8 +1635,8 @@ void gControl::drawBorder(GdkEventExpose *e)
|
|||
|
||||
border frame widget
|
||||
0 0 W
|
||||
0 F W
|
||||
B 0 W
|
||||
0 F W
|
||||
B F W
|
||||
*/
|
||||
|
||||
|
@ -1864,47 +1864,24 @@ void gControl::setMinimumSize()
|
|||
}
|
||||
|
||||
|
||||
void gControl::realize(bool make_frame)
|
||||
void gControl::realize(bool draw_frame)
|
||||
{
|
||||
if (!_scroll)
|
||||
{
|
||||
if (!make_frame)
|
||||
{
|
||||
frame = widget;
|
||||
}
|
||||
else if (!frame)
|
||||
{
|
||||
#if GTK3
|
||||
frame = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_hexpand(widget, TRUE);
|
||||
#else
|
||||
frame = gtk_alignment_new(0, 0, 1, 1);
|
||||
#endif
|
||||
//gtk_widget_set_redraw_on_allocate(frame, TRUE);
|
||||
}
|
||||
|
||||
if (!border)
|
||||
border = widget;
|
||||
|
||||
//printf("border = %p / frame = %p / widget =%p\n", border, frame, widget);
|
||||
|
||||
if (border != frame)
|
||||
if (frame)
|
||||
{
|
||||
//printf("frame -> border\n");
|
||||
add_container(border, frame);
|
||||
if (border != frame && border != widget)
|
||||
add_container(border, frame);
|
||||
if (frame != widget)
|
||||
add_container(frame, widget);
|
||||
}
|
||||
if (frame != widget && border != widget)
|
||||
{
|
||||
//printf("widget -> frame\n");
|
||||
add_container(frame, widget);
|
||||
}
|
||||
|
||||
if (!make_frame)
|
||||
frame = 0;
|
||||
else if (border != widget)
|
||||
add_container(border, widget);
|
||||
}
|
||||
|
||||
//fprintf(stderr, "realize: %p %p\n", border, widget);
|
||||
|
||||
#ifdef GTK3
|
||||
gt_patch_control(border);
|
||||
if (widget && widget != border)
|
||||
|
@ -1919,15 +1896,9 @@ void gControl::realize(bool make_frame)
|
|||
if (!_no_background && !gtk_widget_get_has_window(border))
|
||||
ON_DRAW_BEFORE(border, this, cb_background_expose, cb_background_draw);
|
||||
|
||||
if (frame)
|
||||
if (draw_frame && frame)
|
||||
ON_DRAW_BEFORE(frame, this, cb_frame_expose, cb_frame_draw);
|
||||
|
||||
/*else if (!isTopLevel())
|
||||
{
|
||||
fprintf(stderr, "clip by parent\n");
|
||||
g_signal_connect(G_OBJECT(border), "expose-event", G_CALLBACK(cb_clip_by_parent), (gpointer)this);
|
||||
}*/
|
||||
|
||||
#ifndef GTK3
|
||||
if (isContainer() && !gtk_widget_get_has_window(widget))
|
||||
g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(cb_clip_children), (gpointer)this);
|
||||
|
@ -1978,7 +1949,7 @@ void gControl::realizeScrolledWindow(GtkWidget *wid, bool doNotRealize)
|
|||
gtk_container_add(GTK_CONTAINER(_scroll), widget);
|
||||
|
||||
if (!doNotRealize)
|
||||
realize(false);
|
||||
realize(true);
|
||||
else
|
||||
registerControl();
|
||||
|
||||
|
@ -2137,7 +2108,7 @@ void gControl::setStyleSheetNode(GString *css, const char *node)
|
|||
|
||||
if (!_has_css_id)
|
||||
{
|
||||
gt_widget_set_name(getStyleSheetWidget());
|
||||
gt_widget_set_name(getStyleSheetWidget(), name());
|
||||
_has_css_id = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ public:
|
|||
void connectParent();
|
||||
void setParent(gContainer *parent) { pr = parent; }
|
||||
void initAll(gContainer *pr);
|
||||
void realize(bool make_frame = false);
|
||||
void realize(bool draw_frame = false);
|
||||
void realizeScrolledWindow(GtkWidget *wid, bool doNotRealize = false);
|
||||
void registerControl();
|
||||
void updateGeometry(bool force = false);
|
||||
|
|
|
@ -187,7 +187,7 @@ void gDrawingArea::create(void)
|
|||
box = NULL;
|
||||
}
|
||||
|
||||
realize(false);
|
||||
realize();
|
||||
|
||||
if (_cached)
|
||||
g_signal_connect(G_OBJECT(border), "size-allocate", G_CALLBACK(cb_size), (gpointer)this);
|
||||
|
|
|
@ -31,6 +31,6 @@ gGLArea::gGLArea(gContainer *parent, void (*init)(GtkWidget *)) : gControl(paren
|
|||
border = widget = gtk_event_box_new();
|
||||
gtk_widget_set_can_focus(widget, TRUE);
|
||||
(*init)(widget);
|
||||
realize(false);
|
||||
realize();
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ gLabel::gLabel(gContainer *parent) : gControl(parent)
|
|||
border = widget = gtk_fixed_new();
|
||||
layout = gtk_widget_create_pango_layout(border, "");
|
||||
|
||||
realize(false);
|
||||
realize();
|
||||
|
||||
ON_DRAW(widget, this, cb_expose, cb_draw);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "gmouse.h"
|
||||
#include "gmainwindow.h"
|
||||
|
||||
//#define DEBUG_RESIZE 1
|
||||
#define DEBUG_RESIZE 1
|
||||
|
||||
GList *gMainWindow::windows = NULL;
|
||||
gMainWindow *gMainWindow::_active = NULL;
|
||||
|
@ -157,6 +157,7 @@ static gboolean cb_close(GtkWidget *widget,GdkEvent *event, gMainWindow *data)
|
|||
|
||||
static gboolean cb_configure(GtkWidget *widget, GdkEventConfigure *event, gMainWindow *data)
|
||||
{
|
||||
#if 0
|
||||
gint x, y, w, h;
|
||||
|
||||
if (data->_opened)
|
||||
|
@ -202,54 +203,59 @@ static gboolean cb_configure(GtkWidget *widget, GdkEventConfigure *event, gMainW
|
|||
data->emitResize();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int x, y;
|
||||
|
||||
if (!data->isOpened())
|
||||
return false;
|
||||
|
||||
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)
|
||||
{
|
||||
data->bufX = x;
|
||||
data->bufY = y;
|
||||
if (data->onMove) data->onMove(data);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "cb_configure: %s: (%d %d %d %d) -> (%d/%d %d/%d %d %d) window = %p resized = %d send_event = %d\n", data->name(), data->bufX, data->bufY, data->bufW, data->bufH, x, event->x, y, event->y, event->width, event->height, event->window, data->_event_resized, event->send_event);
|
||||
#endif
|
||||
|
||||
data->calcCsdSize();
|
||||
|
||||
data->bufW = event->width - data->_csd_w;
|
||||
data->bufH = event->height - data->_csd_h;
|
||||
|
||||
data->emitResize();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
static void cb_resize(GtkWidget *wid, GdkRectangle *a, gMainWindow *data)
|
||||
static void cb_resize_frame(GtkWidget *wid, GdkRectangle *a, gMainWindow *data)
|
||||
{
|
||||
//int w, h;
|
||||
|
||||
if (data->layout)
|
||||
return;
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "---- cb_resize_frame: %s: %d x %d\n", data->name(), a->width, a->height);
|
||||
#endif
|
||||
|
||||
/*w = a->width;
|
||||
h = a->height;*/
|
||||
|
||||
data->calcCsdSize();
|
||||
if (data->_csd_w < 0)
|
||||
return;
|
||||
|
||||
#if 0
|
||||
w -= data->_csd_w;
|
||||
h -= data->_csd_h;
|
||||
data->bufW = a->width;
|
||||
data->bufH = a->height;
|
||||
|
||||
if (w != data->bufW || h != data->bufH || data->_event_resized)
|
||||
{
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "cb_resize: %s: %d %d\n", data->name(), w, h);
|
||||
#endif
|
||||
|
||||
data->_event_resized = false;
|
||||
data->bufW = w;
|
||||
data->bufH = h;
|
||||
data->emitResize(); // later
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_resize_layout(GtkWidget *wid, GdkRectangle *a, gMainWindow *data)
|
||||
{
|
||||
//int w, h;
|
||||
|
||||
if (!data->isTopLevel() || !data->isOpened())
|
||||
return;
|
||||
|
||||
/*w = a->width;
|
||||
h = a->height;*/
|
||||
|
||||
data->calcCsdSize();
|
||||
data->emitResize();
|
||||
|
||||
#if 0
|
||||
if (w != data->bufW || h != data->bufH || data->_event_resized)
|
||||
|
@ -267,6 +273,7 @@ static void cb_resize_layout(GtkWidget *wid, GdkRectangle *a, gMainWindow *data)
|
|||
}
|
||||
|
||||
|
||||
#ifdef GTK3
|
||||
static gboolean cb_draw(GtkWidget *wid, cairo_t *cr, gMainWindow *data)
|
||||
{
|
||||
if (data->isTransparent())
|
||||
|
@ -386,7 +393,6 @@ void gMainWindow::initialize()
|
|||
_default = NULL;
|
||||
_cancel = NULL;
|
||||
menuBar = NULL;
|
||||
layout = NULL;
|
||||
_icon = NULL;
|
||||
_picture = NULL;
|
||||
focus = 0;
|
||||
|
@ -425,6 +431,7 @@ void gMainWindow::initialize()
|
|||
_grab_on_show = false;
|
||||
_is_window = true;
|
||||
_no_background = true;
|
||||
_frame_init = false;
|
||||
|
||||
onOpen = NULL;
|
||||
onShow = NULL;
|
||||
|
@ -441,19 +448,13 @@ void gMainWindow::initialize()
|
|||
|
||||
void gMainWindow::initWindow()
|
||||
{
|
||||
//resize(200,150);
|
||||
|
||||
if (!isTopLevel())
|
||||
{
|
||||
g_signal_connect(G_OBJECT(border), "configure-event", G_CALLBACK(cb_configure), (gpointer)this);
|
||||
#ifdef GTK3
|
||||
g_signal_connect_after(G_OBJECT(border), "size-allocate", G_CALLBACK(cb_resize), (gpointer)this);
|
||||
#endif
|
||||
//g_signal_connect(G_OBJECT(border), "configure-event", G_CALLBACK(cb_configure), (gpointer)this);
|
||||
g_signal_connect_after(G_OBJECT(border), "map", G_CALLBACK(cb_show), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(border),"unmap", G_CALLBACK(cb_hide),(gpointer)this);
|
||||
//g_signal_connect_after(G_OBJECT(border), "size-allocate", G_CALLBACK(cb_configure), (gpointer)this);
|
||||
ON_DRAW_BEFORE(widget, this, cb_expose, cb_draw);
|
||||
gtk_widget_add_events(border, GDK_STRUCTURE_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -465,18 +466,28 @@ void gMainWindow::initWindow()
|
|||
g_signal_connect(G_OBJECT(border), "delete-event", G_CALLBACK(cb_close),(gpointer)this);
|
||||
g_signal_connect(G_OBJECT(border), "window-state-event", G_CALLBACK(cb_frame),(gpointer)this);
|
||||
|
||||
gtk_widget_add_events(widget,GDK_BUTTON_MOTION_MASK | GDK_STRUCTURE_MASK);
|
||||
gtk_widget_add_events(widget, GDK_BUTTON_MOTION_MASK | GDK_STRUCTURE_MASK);
|
||||
ON_DRAW_BEFORE(widget, this, cb_expose, cb_draw);
|
||||
|
||||
g_signal_connect(G_OBJECT(border), "configure-event", G_CALLBACK(cb_configure), (gpointer)this);
|
||||
#ifdef GTK3
|
||||
g_signal_connect_after(G_OBJECT(border), "size-allocate", G_CALLBACK(cb_resize), (gpointer)this);
|
||||
#endif
|
||||
//g_signal_connect(G_OBJECT(border), "configure-event", G_CALLBACK(cb_configure), (gpointer)this);
|
||||
}
|
||||
|
||||
gtk_widget_add_events(border, GDK_STRUCTURE_MASK);
|
||||
g_signal_connect(G_OBJECT(border), "configure-event", G_CALLBACK(cb_configure), (gpointer)this);
|
||||
|
||||
/*if (!_frame_init)
|
||||
{
|
||||
#if DEBUG_RESIZE
|
||||
fprintf(stderr, "init cb_resize_frame: %s\n", name());
|
||||
#endif
|
||||
g_signal_connect_after(G_OBJECT(frame), "size-allocate", G_CALLBACK(cb_resize_frame), (gpointer)this);
|
||||
_frame_init = true;
|
||||
}*/
|
||||
|
||||
gtk_window_add_accel_group(GTK_WINDOW(topLevel()->border), accel);
|
||||
|
||||
have_cursor = true; //parent() == 0 && !_xembed;
|
||||
setCanFocus(true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -493,58 +504,68 @@ static void workaround_accel_management()
|
|||
_init = TRUE;
|
||||
}
|
||||
|
||||
gMainWindow::gMainWindow() : gContainer(NULL)
|
||||
{
|
||||
initialize();
|
||||
|
||||
windows = g_list_append(windows, (gpointer)this);
|
||||
|
||||
border = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
workaround_accel_management();
|
||||
|
||||
frame = gtk_fixed_new();
|
||||
widget = gtk_fixed_new();
|
||||
|
||||
realize();
|
||||
initWindow();
|
||||
|
||||
gtk_widget_show(frame);
|
||||
gtk_widget_show(widget);
|
||||
gtk_window_resize(GTK_WINDOW(border), 1, 1);
|
||||
}
|
||||
|
||||
gMainWindow::gMainWindow(int plug) : gContainer(NULL)
|
||||
{
|
||||
initialize();
|
||||
|
||||
windows = g_list_append(windows, (gpointer)this);
|
||||
|
||||
_xembed = plug != 0;
|
||||
_xembed = true;
|
||||
|
||||
if (_xembed)
|
||||
{
|
||||
#ifdef GTK3
|
||||
border = PLATFORM.CreatePlug(plug);
|
||||
if (!border)
|
||||
return;
|
||||
#else
|
||||
border = gtk_plug_new(plug);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
border = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
workaround_accel_management();
|
||||
}
|
||||
#ifdef GTK3
|
||||
border = PLATFORM.CreatePlug(plug);
|
||||
if (!border)
|
||||
return;
|
||||
#else
|
||||
border = gtk_plug_new(plug);
|
||||
#endif
|
||||
|
||||
widget = gtk_fixed_new(); //gtk_layout_new(0,0);
|
||||
frame = gtk_fixed_new();
|
||||
widget = gtk_fixed_new();
|
||||
|
||||
realize(false);
|
||||
realize();
|
||||
initWindow();
|
||||
|
||||
//gtk_widget_realize(border);
|
||||
gtk_widget_show(frame);
|
||||
gtk_widget_show(widget);
|
||||
gtk_window_resize(GTK_WINDOW(border), 1, 1);
|
||||
//gtk_widget_set_size_request(border, 1, 1);
|
||||
|
||||
setCanFocus(true);
|
||||
}
|
||||
|
||||
gMainWindow::gMainWindow(gContainer *par) : gContainer(par)
|
||||
{
|
||||
initialize();
|
||||
|
||||
#ifdef GTK3
|
||||
border = gtk_fixed_new();
|
||||
#else
|
||||
border = gtk_alignment_new(0, 0, 1, 1);
|
||||
#endif
|
||||
border = gtk_event_box_new();
|
||||
frame = gtk_fixed_new();
|
||||
widget = gtk_fixed_new();
|
||||
|
||||
realize(false);
|
||||
realize();
|
||||
initWindow();
|
||||
|
||||
setCanFocus(true);
|
||||
gtk_widget_show(frame);
|
||||
gtk_widget_show(widget);
|
||||
}
|
||||
|
||||
gMainWindow::~gMainWindow()
|
||||
|
@ -737,9 +758,6 @@ bool gMainWindow::emitOpen()
|
|||
|
||||
gtk_widget_realize(border);
|
||||
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "#2\n");
|
||||
#endif
|
||||
performArrange();
|
||||
emit(SIGNAL(onOpen));
|
||||
if (_closed)
|
||||
|
@ -882,9 +900,6 @@ void gMainWindow::setVisible(bool vl)
|
|||
else
|
||||
{
|
||||
gtk_widget_show(border);
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "#3\n");
|
||||
#endif
|
||||
parent()->performArrange();
|
||||
performArrange();
|
||||
}
|
||||
|
@ -1399,14 +1414,9 @@ static void hide_hidden_children(gContainer *cont)
|
|||
|
||||
void gMainWindow::createWindow(GtkWidget *new_border)
|
||||
{
|
||||
if (layout)
|
||||
gt_widget_reparent(layout, new_border);
|
||||
else
|
||||
gt_widget_reparent(widget, new_border);
|
||||
|
||||
gt_widget_reparent(frame, new_border);
|
||||
createBorder(new_border);
|
||||
registerControl();
|
||||
setCanFocus(true);
|
||||
}
|
||||
|
||||
void gMainWindow::reparent(gContainer *newpr, int x, int y)
|
||||
|
@ -1429,6 +1439,7 @@ void gMainWindow::reparent(gContainer *newpr, int x, int y)
|
|||
setParent(newpr);
|
||||
connectParent();
|
||||
borderSignals();
|
||||
|
||||
initWindow();
|
||||
|
||||
setBackground(bg);
|
||||
|
@ -1460,8 +1471,10 @@ void gMainWindow::reparent(gContainer *newpr, int x, int y)
|
|||
parent()->arrange();
|
||||
setParent(NULL);
|
||||
}
|
||||
initWindow();
|
||||
|
||||
borderSignals();
|
||||
initWindow();
|
||||
|
||||
setBackground(bg);
|
||||
setForeground(fg);
|
||||
setFont(font());
|
||||
|
@ -1724,20 +1737,17 @@ void gMainWindow::configure()
|
|||
|
||||
if (isMenuBarVisible())
|
||||
{
|
||||
gtk_fixed_move(GTK_FIXED(layout), GTK_WIDGET(menuBar), 0, 0);
|
||||
gtk_fixed_move(GTK_FIXED(frame), GTK_WIDGET(menuBar), 0, 0);
|
||||
if (h > 1)
|
||||
gtk_widget_set_size_request(GTK_WIDGET(menuBar), width(), h);
|
||||
gtk_fixed_move(GTK_FIXED(layout), widget, 0, h);
|
||||
gtk_fixed_move(GTK_FIXED(frame), widget, 0, h);
|
||||
gtk_widget_set_size_request(widget, width(), Max(0, height() - h));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (layout)
|
||||
{
|
||||
if (menuBar)
|
||||
gtk_fixed_move(GTK_FIXED(layout), GTK_WIDGET(menuBar), -width(), -h);
|
||||
gtk_fixed_move(GTK_FIXED(layout), widget, 0, 0);
|
||||
}
|
||||
if (menuBar)
|
||||
gtk_fixed_move(GTK_FIXED(frame), GTK_WIDGET(menuBar), -width(), -h);
|
||||
gtk_fixed_move(GTK_FIXED(frame), widget, 0, 0);
|
||||
gtk_widget_set_size_request(widget, width(), height());
|
||||
}
|
||||
}
|
||||
|
@ -1753,9 +1763,6 @@ bool gMainWindow::setMenuBarVisible(bool v)
|
|||
return TRUE;
|
||||
|
||||
configure();
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "#5\n");
|
||||
#endif
|
||||
performArrange();
|
||||
|
||||
return FALSE;
|
||||
|
@ -1798,9 +1805,6 @@ void gMainWindow::checkMenuBar()
|
|||
}
|
||||
|
||||
configure();
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "#6\n");
|
||||
#endif
|
||||
performArrange();
|
||||
}
|
||||
|
||||
|
@ -1808,28 +1812,16 @@ void gMainWindow::embedMenuBar(GtkWidget *border)
|
|||
{
|
||||
if (menuBar)
|
||||
{
|
||||
// layout is automatically destroyed ?
|
||||
layout = gtk_fixed_new();
|
||||
|
||||
#ifdef GTK3
|
||||
g_signal_connect_after(G_OBJECT(layout), "size-allocate", G_CALLBACK(cb_resize_layout), (gpointer)this);
|
||||
#endif
|
||||
|
||||
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(GTK_FIXED(layout), GTK_WIDGET(menuBar), 0, 0);
|
||||
gtk_fixed_put(GTK_FIXED(frame), GTK_WIDGET(menuBar), 0, 0);
|
||||
|
||||
g_object_unref(G_OBJECT(menuBar));
|
||||
|
||||
gt_widget_reparent(widget, layout);
|
||||
gtk_container_add(GTK_CONTAINER(border), layout);
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(menuBar));
|
||||
gtk_widget_show(layout);
|
||||
gtk_widget_show(GTK_WIDGET(widget));
|
||||
|
||||
gMenu::updateFont(this);
|
||||
gMenu::updateColor(this);
|
||||
|
@ -1890,9 +1882,6 @@ void gMainWindow::emitResize()
|
|||
_resize_last_w = bufW;
|
||||
_resize_last_h = bufH;
|
||||
configure();
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "#7\n");
|
||||
#endif
|
||||
performArrange();
|
||||
emit(SIGNAL(onResize));
|
||||
}
|
||||
|
@ -2051,7 +2040,7 @@ void gMainWindow::calcCsdSize()
|
|||
}
|
||||
|
||||
gtk_widget_get_allocation(border, &ba);
|
||||
gtk_widget_get_allocation(layout ? layout : widget, &wa);
|
||||
gtk_widget_get_allocation(frame, &wa);
|
||||
|
||||
if (wa.width == 1 && wa.height == 1)
|
||||
return;
|
||||
|
@ -2060,14 +2049,12 @@ void gMainWindow::calcCsdSize()
|
|||
|
||||
_csd_w = ba.width - wa.width;
|
||||
_csd_h = ba.height - wa.height;
|
||||
if (!layout)
|
||||
_csd_h -= clientY();
|
||||
#ifdef DEBUG_RESIZE
|
||||
fprintf(stderr, "calcCsdSize: %s: csd = %d %d\n", name(), _csd_w, _csd_h);
|
||||
#endif
|
||||
|
||||
if (!isResizable())
|
||||
updateSize();
|
||||
/*if (!isResizable())
|
||||
updateSize();*/
|
||||
}
|
||||
|
||||
void gMainWindow::destroy()
|
||||
|
|
|
@ -29,20 +29,22 @@
|
|||
class gMainWindow : public gContainer
|
||||
{
|
||||
public:
|
||||
gMainWindow(int plug = 0);
|
||||
gMainWindow();
|
||||
gMainWindow(gContainer *parent);
|
||||
gMainWindow(int plug);
|
||||
~gMainWindow();
|
||||
|
||||
//"Properties"
|
||||
bool hasBorder();
|
||||
bool isResizable();
|
||||
bool isUtility() const;
|
||||
bool isEmbedded() const { return _xembed; }
|
||||
gPicture *icon() { return _icon; }
|
||||
gPicture *picture() { return _picture; }
|
||||
bool mask() { return _mask; }
|
||||
int menuCount();
|
||||
bool isModal() const;
|
||||
const char* text();
|
||||
const char *text();
|
||||
bool isTopOnly() const { return isTopLevel() && _top_only; }
|
||||
bool isSkipTaskBar() const { return isTopLevel() && _skip_taskbar; }
|
||||
bool minimized() const { return _minimized; }
|
||||
|
@ -168,7 +170,6 @@ public:
|
|||
GtkWindowGroup *group;
|
||||
GtkAccelGroup *accel;
|
||||
GtkMenuBar *menuBar;
|
||||
GtkWidget *layout;
|
||||
int stack;
|
||||
gPicture *_icon;
|
||||
gPicture *_picture;
|
||||
|
@ -218,6 +219,7 @@ public:
|
|||
unsigned _unmap : 1;
|
||||
unsigned _initMenuBar : 1;
|
||||
unsigned _grab_on_show : 1;
|
||||
unsigned _frame_init : 1;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -74,7 +74,7 @@ void gPanel::create(void)
|
|||
box = NULL;
|
||||
}
|
||||
|
||||
frame = widget;
|
||||
frame = border;
|
||||
realize(true);
|
||||
|
||||
//g_signal_connect(G_OBJECT(border), "size-allocate", G_CALLBACK(cb_size), (gpointer)this);
|
||||
|
|
|
@ -92,6 +92,7 @@ gSlider::gSlider(gContainer *par, bool scrollbar) : gControl(par)
|
|||
_max = 100;
|
||||
_tracking = true;
|
||||
_is_scrollbar = scrollbar;
|
||||
_orientation = ORIENTATION_AUTO;
|
||||
|
||||
/*#ifdef GTK3
|
||||
border = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
|
@ -112,7 +113,7 @@ gSlider::gSlider(gContainer *par, bool scrollbar) : gControl(par)
|
|||
|
||||
init();
|
||||
update();
|
||||
realize(false);
|
||||
realize();
|
||||
//g_signal_connect_after(G_OBJECT(border),"expose-event",G_CALLBACK(slider_Expose),(gpointer)this);
|
||||
}
|
||||
|
||||
|
@ -126,7 +127,7 @@ gScrollBar::gScrollBar(gContainer *par) : gSlider(par, true)
|
|||
|
||||
init();
|
||||
update();
|
||||
realize(false);
|
||||
realize();
|
||||
|
||||
#ifndef GTK3
|
||||
gtk_range_set_update_policy(GTK_RANGE(widget),GTK_UPDATE_CONTINUOUS);
|
||||
|
|
|
@ -2336,11 +2336,11 @@ int gt_find_monitor(GdkMonitor *monitor)
|
|||
#endif
|
||||
|
||||
#ifdef GTK3
|
||||
const char *gt_widget_set_name(GtkWidget *widget)
|
||||
const char *gt_widget_set_name(GtkWidget *widget, const char *suffix)
|
||||
{
|
||||
static int count = 0;
|
||||
|
||||
char buffer[16];
|
||||
char buffer[256];
|
||||
const char *name;
|
||||
|
||||
name = gtk_widget_get_name(widget);
|
||||
|
@ -2348,7 +2348,7 @@ const char *gt_widget_set_name(GtkWidget *widget)
|
|||
return name;
|
||||
|
||||
count++;
|
||||
sprintf(buffer, "g%d", count);
|
||||
sprintf(buffer, "g%d_%s", count, suffix ? suffix : "");
|
||||
gtk_widget_set_name(widget, buffer);
|
||||
return gtk_widget_get_name(widget);
|
||||
}
|
||||
|
@ -2438,7 +2438,7 @@ void gt_widget_update_css(GtkWidget *widget, gFont *font, gColor bg, gColor fg)
|
|||
char *css_str;
|
||||
|
||||
context = gtk_widget_get_style_context(widget);
|
||||
name = gt_widget_set_name(widget);
|
||||
name = gt_widget_set_name(widget, NULL);
|
||||
|
||||
css = g_string_new(NULL);
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ int gt_find_monitor(GdkMonitor *monitor);
|
|||
#ifdef GTK3
|
||||
void gt_css_add_font(GString *css, gFont *font);
|
||||
void gt_css_add_color(GString *css, gColor bg, gColor fg);
|
||||
const char *gt_widget_set_name(GtkWidget *widget);
|
||||
const char *gt_widget_set_name(GtkWidget *widget, const char *name);
|
||||
void gt_widget_update_css(GtkWidget *widget, gFont *font, gColor bg, gColor fg);
|
||||
void gt_define_style_sheet(GtkStyleProvider **provider, GString *css);
|
||||
#endif
|
||||
|
|
|
@ -125,7 +125,7 @@ static void GTK_CreateControl(CWIDGET *ob, void *parent, GtkWidget *widget)
|
|||
|
||||
ctrl->widget = ctrl->border;
|
||||
InitControl(ctrl, ob);
|
||||
ctrl->realize(false);
|
||||
ctrl->realize();
|
||||
ctrl->_has_input_method = TRUE;
|
||||
|
||||
if (recreate)
|
||||
|
|
|
@ -136,7 +136,7 @@ static void GTK_CreateControl(CWIDGET *ob, void *parent, GtkWidget *widget)
|
|||
|
||||
ctrl->widget = ctrl->border;
|
||||
InitControl(ctrl, ob);
|
||||
ctrl->realize(false);
|
||||
ctrl->realize();
|
||||
ctrl->_has_input_method = TRUE;
|
||||
|
||||
if (recreate)
|
||||
|
|
Loading…
Reference in a new issue