* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
*/
/*
#include "gtkmain.h"
#include "gtkmarshalers.h"
+#include "gtksizerequest.h"
#include "gtkwin32embedwidget.h"
#include "gtkintl.h"
#include "gtkprivate.h"
+#include "gtkwindowprivate.h"
+#include "gtkwidgetprivate.h"
+#include "gtkcontainerprivate.h"
-#include "gtkalias.h"
static void gtk_win32_embed_widget_realize (GtkWidget *widget);
static void gtk_win32_embed_widget_unrealize (GtkWidget *widget);
window = GTK_WINDOW (embed_widget);
- window->type = GTK_WINDOW_TOPLEVEL;
-
- GTK_WIDGET_SET_FLAGS (embed_widget, GTK_TOPLEVEL);
+ _gtk_widget_set_is_toplevel (GTK_WIDGET (embed_widget), TRUE);
gtk_container_set_resize_mode (GTK_CONTAINER (embed_widget), GTK_RESIZE_QUEUE);
}
GtkWidget*
-_gtk_win32_embed_widget_new (GdkNativeWindow parent_id)
+_gtk_win32_embed_widget_new (HWND parent)
{
GtkWin32EmbedWidget *embed_widget;
embed_widget = g_object_new (GTK_TYPE_WIN32_EMBED_WIDGET, NULL);
embed_widget->parent_window =
- gdk_window_lookup_for_display (gdk_display_get_default (),
- parent_id);
+ gdk_win32_window_lookup_for_display (gdk_display_get_default (),
+ parent);
if (!embed_widget->parent_window)
embed_widget->parent_window =
- gdk_window_foreign_new_for_display (gdk_display_get_default (),
- parent_id);
+ gdk_win32_window_foreign_new_for_display (gdk_display_get_default (),
+ parent);
return GTK_WIDGET (embed_widget);
}
_gtk_win32_embed_widget_dialog_procedure (GtkWin32EmbedWidget *embed_widget,
HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (embed_widget);
if (message == WM_SIZE)
{
- widget->allocation.width = LOWORD(lparam);
- widget->allocation.height = HIWORD(lparam);
-
+ allocation.width = LOWORD(lparam);
+ allocation.height = HIWORD(lparam);
+ gtk_widget_set_allocation (widget, &allocation);
+
gtk_widget_queue_resize (widget);
}
if (embed_widget->parent_window != NULL)
{
- gdk_window_set_user_data (embed_widget->parent_window, NULL);
+ gtk_widget_unregister_window (widget, embed_widget->parent_window);
g_object_unref (embed_widget->parent_window);
embed_widget->parent_window = NULL;
}
-
- if (GTK_WIDGET_CLASS (gtk_win32_embed_widget_parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (gtk_win32_embed_widget_parent_class)->unrealize) (widget);
+
+ GTK_WIDGET_CLASS (gtk_win32_embed_widget_parent_class)->unrealize (widget);
}
static LRESULT CALLBACK
GtkWin32EmbedWidget *embed_widget;
gpointer user_data;
- window = gdk_window_lookup ((GdkNativeWindow)hwnd);
+ window = gdk_win32_window_lookup_for_display (gdk_display_get_default (), hwnd);
if (window == NULL) {
g_warning ("No such window!");
return 0;
{
GtkWindow *window = GTK_WINDOW (widget);
GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget);
+ GtkAllocation allocation;
+ GdkWindow *gdk_window;
GdkWindowAttr attributes;
gint attributes_mask;
LONG_PTR styles;
+ gtk_widget_get_allocation (widget, &allocation);
+
/* ensure widget tree is properly size allocated */
- if (widget->allocation.x == -1 &&
- widget->allocation.y == -1 &&
- widget->allocation.width == 1 &&
- widget->allocation.height == 1)
+ if (allocation.x == -1 && allocation.y == -1 &&
+ allocation.width == 1 && allocation.height == 1)
{
GtkRequisition requisition;
GtkAllocation allocation = { 0, 0, 200, 200 };
- gtk_widget_size_request (widget, &requisition);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
if (requisition.width || requisition.height)
{
/* non-empty window */
_gtk_container_queue_resize (GTK_CONTAINER (widget));
- g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
+ g_return_if_fail (!gtk_widget_get_realized (widget));
}
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_set_realized (widget, TRUE);
+
+ gtk_widget_get_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.title = window->title;
- attributes.wmclass_name = window->wmclass_name;
- attributes.wmclass_class = window->wmclass_class;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.title = gtk_window_get_title (window);
+ _gtk_window_get_wmclass (window, &attributes.wmclass_name, &attributes.wmclass_class);
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
/* this isn't right - we should match our parent's visual/colormap.
* though that will require handling "foreign" colormaps */
attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK |
GDK_KEY_PRESS_MASK |
GDK_STRUCTURE_MASK |
GDK_FOCUS_CHANGE_MASK);
- attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes_mask |= (window->title ? GDK_WA_TITLE : 0);
- attributes_mask |= (window->wmclass_name ? GDK_WA_WMCLASS : 0);
-
- widget->window = gdk_window_new (embed_widget->parent_window,
- &attributes, attributes_mask);
+ attributes_mask = GDK_WA_VISUAL;
+ attributes_mask |= (gtk_window_get_title (window) ? GDK_WA_TITLE : 0);
+ attributes_mask |= (attributes.wmclass_name ? GDK_WA_WMCLASS : 0);
- gdk_window_set_user_data (widget->window, window);
+ gdk_window = gdk_window_new (embed_widget->parent_window,
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, gdk_window);
+ gtk_widget_register_window (widget, gdk_window);
embed_widget->old_window_procedure = (gpointer)
- SetWindowLongPtrW(GDK_WINDOW_HWND (widget->window),
+ SetWindowLongPtrW(GDK_WINDOW_HWND (gdk_window),
GWLP_WNDPROC,
(LONG_PTR)gtk_win32_embed_widget_window_process);
/* Enable tab to focus the widget */
- styles = GetWindowLongPtr(GDK_WINDOW_HWND (widget->window), GWL_STYLE);
- SetWindowLongPtrW(GDK_WINDOW_HWND (widget->window), GWL_STYLE, styles | WS_TABSTOP);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ styles = GetWindowLongPtr(GDK_WINDOW_HWND (gdk_window), GWL_STYLE);
+ SetWindowLongPtrW(GDK_WINDOW_HWND (gdk_window), GWL_STYLE, styles | WS_TABSTOP);
+
+ gtk_style_context_set_background (gtk_widget_get_style_context (widget),
+ gdk_window);
}
static void
gtk_win32_embed_widget_show (GtkWidget *widget)
{
- GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
+ gtk_widget_set_visible (widget, TRUE);
gtk_widget_realize (widget);
gtk_container_check_resize (GTK_CONTAINER (widget));
static void
gtk_win32_embed_widget_hide (GtkWidget *widget)
{
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
+ gtk_widget_set_visible (widget, FALSE);
gtk_widget_unmap (widget);
}
static void
gtk_win32_embed_widget_map (GtkWidget *widget)
{
- GtkBin *bin = GTK_BIN (widget);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- if (bin->child &&
- GTK_WIDGET_VISIBLE (bin->child) &&
- !GTK_WIDGET_MAPPED (bin->child))
- gtk_widget_map (bin->child);
+ GtkBin *bin = GTK_BIN (widget);
+ GtkWidget *child;
+
+ gtk_widget_set_mapped (widget, TRUE);
+
+ child = gtk_bin_get_child (bin);
+ if (child &&
+ gtk_widget_get_visible (child) &&
+ !gtk_widget_get_mapped (child))
+ gtk_widget_map (child);
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
}
static void
gtk_win32_embed_widget_unmap (GtkWidget *widget)
{
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
- gdk_window_hide (widget->window);
+ gtk_widget_set_mapped (widget, FALSE);
+ gdk_window_hide (gtk_widget_get_window (widget));
}
static void
gtk_win32_embed_widget_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- GtkBin *bin = GTK_BIN (widget);
+ GtkBin *bin = GTK_BIN (widget);
+ GtkWidget *child;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
+ if (gtk_widget_get_realized (widget))
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
-
- if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
{
GtkAllocation child_allocation;
- child_allocation.x = child_allocation.y = GTK_CONTAINER (widget)->border_width;
+ child_allocation.x = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ child_allocation.y = child_allocation.x;
child_allocation.width =
MAX (1, (gint)allocation->width - child_allocation.x * 2);
child_allocation.height =
MAX (1, (gint)allocation->height - child_allocation.y * 2);
- gtk_widget_size_allocate (bin->child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
}
}
GtkWin32EmbedWidget *embed_widget = GTK_WIN32_EMBED_WIDGET (widget);
GtkWindow *window = GTK_WINDOW (widget);
GtkContainer *container = GTK_CONTAINER (widget);
- GtkWidget *old_focus_child = container->focus_child;
+ GtkWidget *old_focus_child = gtk_container_get_focus_child (container);
GtkWidget *parent;
+ GtkWidget *child;
/* We override GtkWindow's behavior, since we don't want wrapping here.
*/
if (gtk_widget_child_focus (old_focus_child, direction))
return TRUE;
- if (window->focus_widget)
+ if (gtk_window_get_focus (window))
{
/* Wrapped off the end, clear the focus setting for the toplevel */
- parent = window->focus_widget->parent;
+ parent = gtk_widget_get_parent (gtk_window_get_focus (window));
while (parent)
{
gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
- parent = GTK_WIDGET (parent)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (parent));
}
gtk_window_set_focus (GTK_WINDOW (container), NULL);
else
{
/* Try to focus the first widget in the window */
- if (bin->child && gtk_widget_child_focus (bin->child, direction))
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_child_focus (child, direction))
return TRUE;
}
- if (!GTK_CONTAINER (window)->focus_child)
+ if (!gtk_container_get_focus_child (GTK_CONTAINER (window)))
{
int backwards = FALSE;
{
GTK_WINDOW_CLASS (gtk_win32_embed_widget_parent_class)->set_focus (window, focus);
- gdk_window_focus (GTK_WIDGET(window)->window, 0);
+ gdk_window_focus (gtk_widget_get_window (GTK_WIDGET(window)), 0);
}
-
-#define __GTK_WIN32_EMBED_WIDGET_C__
-#include "gtkaliasdef.c"