Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
scuri committed Oct 26, 2012
1 parent a7c6813 commit ae59392
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
52 changes: 25 additions & 27 deletions src/gtk/iupgtk_canvas.c
Expand Up @@ -47,18 +47,11 @@ static void gtkCanvasUpdateChildLayout(Ihandle *ih)
sb_horiz_height = iupdrvGetScrollbarSize();

if (sb_vert && gtk_widget_get_visible(sb_vert))
{
gtk_fixed_move(sb_win, sb_vert, width-sb_vert_width-border, border);
gtk_widget_set_size_request(sb_vert, sb_vert_width, height-sb_horiz_height-2*border);
}
iupgtkSetPosSize(sb_win, sb_vert, width-sb_vert_width-border, border, sb_vert_width, height-sb_horiz_height-2*border);
if (sb_horiz && gtk_widget_get_visible(sb_horiz))
{
gtk_fixed_move(sb_win, sb_horiz, border, height-sb_horiz_height-border);
gtk_widget_set_size_request(sb_horiz, width-sb_vert_width-2*border, sb_horiz_height);
}
iupgtkSetPosSize(sb_win, sb_horiz, border, height-sb_horiz_height-border, width-sb_vert_width-2*border, sb_horiz_height);

gtk_fixed_move(sb_win, ih->handle, border, border);
gtk_widget_set_size_request(ih->handle, width-sb_vert_width-2*border, height-sb_horiz_height-2*border);
iupgtkSetPosSize(sb_win, ih->handle, border, border, width-sb_vert_width-2*border, height-sb_horiz_height-2*border);
}

static int gtkCanvasScroll2Iup(GtkScrollType scroll, int vert)
Expand Down Expand Up @@ -619,7 +612,7 @@ static char* gtkCanvasGetDrawableAttrib(Ihandle* ih)

static int gtkCanvasMapMethod(Ihandle* ih)
{
GtkContainer* sb_win;
GtkWidget* sb_win;
#if !GTK_CHECK_VERSION(3, 0, 0)
void* visual;
#endif
Expand Down Expand Up @@ -650,12 +643,12 @@ static int gtkCanvasMapMethod(Ihandle* ih)
gtk_widget_set_has_window(ih->handle, TRUE);
#endif

sb_win = (GtkContainer*)gtk_fixed_new();
sb_win = gtk_fixed_new();
if (!sb_win)
return IUP_ERROR;

gtk_container_add(sb_win, ih->handle);
gtk_widget_show((GtkWidget*)sb_win);
gtk_fixed_put(GTK_FIXED(sb_win), ih->handle, 0, 0);
gtk_widget_show(sb_win);

iupAttribSetStr(ih, "_IUP_EXTRAPARENT", (char*)sb_win);

Expand Down Expand Up @@ -697,14 +690,28 @@ static int gtkCanvasMapMethod(Ihandle* ih)
iupgtkSetCanFocus(ih->handle, 1);
}

if (iupAttribGetBoolean(ih, "BORDER"))
{
iupAttribSetInt(ih, "BORDERWIDTH", 1);
#if GTK_CHECK_VERSION(3, 0, 0)
g_signal_connect(G_OBJECT(sb_win), "draw", G_CALLBACK(gtkCanvasBorderDraw), NULL);
#else
g_signal_connect(G_OBJECT(sb_win), "expose-event", G_CALLBACK(gtkCanvasBorderExposeEvent), NULL);
#endif
}

gtk_widget_realize(sb_win);

if (ih->data->sb & IUP_SB_HORIZ)
{
#if GTK_CHECK_VERSION(3, 0, 0)
GtkWidget* sb_horiz = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
#else
GtkWidget* sb_horiz = gtk_hscrollbar_new(NULL);
#endif
gtk_container_add(sb_win, sb_horiz);
gtk_fixed_put(GTK_FIXED(sb_win), sb_horiz, 0, 0);
gtk_widget_show(sb_horiz);
gtk_widget_realize(sb_horiz);

g_signal_connect(G_OBJECT(sb_horiz), "change-value",G_CALLBACK(gtkCanvasHChangeValue), ih);
iupAttribSetStr(ih, "_IUPGTK_SBHORIZ", (char*)sb_horiz);
Expand All @@ -717,23 +724,14 @@ static int gtkCanvasMapMethod(Ihandle* ih)
#else
GtkWidget* sb_vert = gtk_vscrollbar_new(NULL);
#endif
gtk_container_add(sb_win, sb_vert);
gtk_fixed_put(GTK_FIXED(sb_win), sb_vert, 0, 0);
gtk_widget_show(sb_vert);
gtk_widget_realize(sb_vert);

g_signal_connect(G_OBJECT(sb_vert), "change-value",G_CALLBACK(gtkCanvasVChangeValue), ih);
iupAttribSetStr(ih, "_IUPGTK_SBVERT", (char*)sb_vert);
}

if (iupAttribGetBoolean(ih, "BORDER"))
{
iupAttribSetInt(ih, "BORDERWIDTH", 1);
#if GTK_CHECK_VERSION(3, 0, 0)
g_signal_connect(G_OBJECT(sb_win), "draw", G_CALLBACK(gtkCanvasBorderDraw), NULL);
#else
g_signal_connect(G_OBJECT(sb_win), "expose-event", G_CALLBACK(gtkCanvasBorderExposeEvent), NULL);
#endif
}

gtk_widget_realize((GtkWidget*)sb_win);
gtk_widget_realize(ih->handle);

/* configure for DRAG&DROP */
Expand Down
9 changes: 7 additions & 2 deletions src/gtk/iupgtk_common.c
Expand Up @@ -82,14 +82,19 @@ void iupgtkBaseAddToParent(Ihandle* ih)
gtk_fixed_put(fixed, widget, 0, 0);
}

void iupgtkSetPosSize(GtkFixed* fixed, GtkWidget* widget, int x, int y, int width, int height)
{
gtk_fixed_move(fixed, widget, x, y);
gtk_widget_set_size_request(widget, width, height);
}

void iupdrvBaseLayoutUpdateMethod(Ihandle *ih)
{
GtkFixed* fixed = gtkGetFixedParent(ih);
GtkWidget* widget = (GtkWidget*)iupAttribGet(ih, "_IUP_EXTRAPARENT");
if (!widget) widget = ih->handle;

gtk_fixed_move(fixed, widget, ih->x, ih->y);
gtk_widget_set_size_request(widget, ih->currentwidth, ih->currentheight);
iupgtkSetPosSize(fixed, widget, ih->x, ih->y, ih->currentwidth, ih->currentheight);
}

void iupdrvBaseUnMapMethod(Ihandle* ih)
Expand Down
2 changes: 1 addition & 1 deletion src/gtk/iupgtk_drv.h
Expand Up @@ -38,7 +38,7 @@ gboolean iupgtkButtonEvent(GtkWidget *widget, GdkEventButton *evt, Ihandle *ih);
void iupgtkBaseSetBgColor(InativeHandle* handle, unsigned char r, unsigned char g, unsigned char b);
void iupgtkBaseSetFgColor(InativeHandle* handle, unsigned char r, unsigned char g, unsigned char b);
const char* iupgtkGetWidgetClassName(GtkWidget* widget);

void iupgtkSetPosSize(GtkFixed* fixed, GtkWidget* widget, int x, int y, int width, int height);
GdkWindow* iupgtkGetWindow(GtkWidget *widget);
void iupgtkWindowGetPointer(GdkWindow *window, int *x, int *y, GdkModifierType *mask);

Expand Down

0 comments on commit ae59392

Please sign in to comment.