1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
12 #include "lib/scritchui/gtk2/gtk2.h"
13 #include "lib/scritchui/gtk2/gtk2Intern.h"
14 #include "lib/scritchui/scritchuiTypes.h"
16 sjme_errorCode
sjme_scritchui_gtk2_viewGetView(
17 sjme_attrInNotNull sjme_scritchui inState
,
18 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
19 sjme_attrOutNotNull sjme_scritchui_rect
* outViewRect
)
23 GtkAdjustment
* hAdjust
;
24 GtkAdjustment
* vAdjust
;
27 if (inState
== NULL
|| inComponent
== NULL
|| outViewRect
== NULL
)
28 return SJME_ERROR_NULL_ARGUMENTS
;
30 /* Get wrapped widget. */
31 topWidget
= inComponent
->common
.handle
[SJME_SUI_GTK2_H_WIDGET
];
33 /* Depends on the type. */
34 switch (inComponent
->common
.type
)
36 case SJME_SCRITCHUI_TYPE_SCROLL_PANEL
:
37 /* Get the allocation of the window. */
38 memset(&alloc
, 0, sizeof(alloc
));
39 binChild
= gtk_bin_get_child(GTK_BIN(topWidget
));
40 gtk_widget_get_allocation(binChild
, &alloc
);
43 hAdjust
= gtk_scrolled_window_get_hadjustment(
44 GTK_SCROLLED_WINDOW(topWidget
));
45 vAdjust
= gtk_scrolled_window_get_vadjustment(
46 GTK_SCROLLED_WINDOW(topWidget
));
50 outViewRect
->s
.x
= gtk_adjustment_get_value(
53 outViewRect
->d
.width
= gtk_adjustment_get_page_size(
55 if (alloc
.width
> outViewRect
->d
.width
)
56 outViewRect
->d
.width
= alloc
.width
;
61 outViewRect
->s
.y
= gtk_adjustment_get_value(
64 /* Get the higher of the two widths/heights. */
65 outViewRect
->d
.height
= gtk_adjustment_get_page_size(
67 if (alloc
.height
> outViewRect
->d
.height
)
68 outViewRect
->d
.height
= alloc
.height
;
73 return sjme_error_notImplemented(0);
77 return inState
->implIntern
->checkError(inState
, SJME_ERROR_NONE
);
80 sjme_errorCode
sjme_scritchui_gtk2_viewSetArea(
81 sjme_attrInNotNull sjme_scritchui inState
,
82 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
83 sjme_attrInNotNull
const sjme_scritchui_dim
* inViewArea
,
84 sjme_attrInNotNull
const sjme_scritchui_dim
* inViewPage
)
87 GtkAdjustment
* hAdjust
;
88 GtkAdjustment
* vAdjust
;
90 if (inState
== NULL
|| inComponent
== NULL
|| inViewArea
== NULL
)
91 return SJME_ERROR_NULL_ARGUMENTS
;
93 /* Get wrapped widget. */
94 topWidget
= inComponent
->common
.handle
[SJME_SUI_GTK2_H_WIDGET
];
96 /* Depends on the type. */
97 switch (inComponent
->common
.type
)
99 case SJME_SCRITCHUI_TYPE_SCROLL_PANEL
:
100 /* Change adjustment. */
101 hAdjust
= gtk_scrolled_window_get_hadjustment(
102 GTK_SCROLLED_WINDOW(topWidget
));
103 vAdjust
= gtk_scrolled_window_get_vadjustment(
104 GTK_SCROLLED_WINDOW(topWidget
));
106 gtk_adjustment_set_upper(hAdjust
,
108 gtk_adjustment_set_upper(vAdjust
,
113 return sjme_error_notImplemented(0);
117 return inState
->implIntern
->checkError(inState
, SJME_ERROR_NONE
);
120 sjme_errorCode
sjme_scritchui_gtk2_viewSetView(
121 sjme_attrInNotNull sjme_scritchui inState
,
122 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
123 sjme_attrInNotNull
const sjme_scritchui_point
* inViewPos
)
126 return sjme_error_notImplemented(0);
129 sjme_errorCode
sjme_scritchui_gtk2_viewSetViewListener(
130 sjme_attrInNotNull sjme_scritchui inState
,
131 sjme_attrInNotNull sjme_scritchui_uiComponent inComponent
,
132 SJME_SCRITCHUI_SET_LISTENER_ARGS(view
))
135 return sjme_error_notImplemented(0);