mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
tooltips, handle boxes, menus, toolbars
This commit is contained in:
parent
b1b4498b0e
commit
ccdf6b9bc9
@ -1,3 +1,7 @@
|
||||
2003-08-26 Dom Lachowicz <cinamod@hotmail.com>
|
||||
|
||||
* src/*.c: Tooltips should do XP-style theming. Handle Boxes/Panes do XP style REBAR theming (TODO: non-XP version of the above for handleboxes). Toolbars should draw the REBAR part properly. Preparation for using the Toolbar class. Menubars and Toolbars now are etched-in to mimic Windows' behavior. HandleBoxes' shadow types should also be correct now, compared to OfficeXP applications.
|
||||
|
||||
2003-08-26 Raymond Penners <raymond@dotsphinx.com>
|
||||
|
||||
* === Released 0.3.0 ===
|
||||
@ -62,4 +66,4 @@
|
||||
2003-03-18 Raymond Penners <raymond@dotsphinx.com>
|
||||
|
||||
* === Released 0.1.0 ===
|
||||
|
||||
|
||||
|
@ -3,6 +3,9 @@ style "wimp-default"
|
||||
GtkWidget::interior_focus = 1
|
||||
GtkOptionMenu::indicator_size = { 9, 5 }
|
||||
GtkOptionMenu::indicator_spacing = { 7, 5, 2, 2 }
|
||||
GtkMenuBar::shadow-type = etched-in
|
||||
GtkToolBar::shadow-type = etched-in
|
||||
GtkHandleBox::shadow-type = none
|
||||
GtkSpinButton::shadow-type = in
|
||||
|
||||
GtkTreeView::allow-rules = 0
|
||||
|
@ -120,41 +120,16 @@ static gboolean
|
||||
get_system_font(LOGFONT *lf)
|
||||
{
|
||||
gboolean ok;
|
||||
/*
|
||||
if (NULL)//uxtheme_dll)
|
||||
|
||||
NONCLIENTMETRICS ncm;
|
||||
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
||||
ok = SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
|
||||
sizeof(NONCLIENTMETRICS), &ncm, 0);
|
||||
if (ok)
|
||||
{
|
||||
LOGFONTW lfw;
|
||||
ok = get_system_font_xp(&lfw);
|
||||
if (ok)
|
||||
{
|
||||
memcpy(lf, &lfw, sizeof(*lf));
|
||||
WideCharToMultiByte(CP_ACP, 0, lfw.lfFaceName, -1,
|
||||
lf->lfFaceName, sizeof(lf->lfFaceName),
|
||||
NULL, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
NONCLIENTMETRICS ncm;
|
||||
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
||||
ok = SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
|
||||
sizeof(NONCLIENTMETRICS), &ncm, 0);
|
||||
if (ok)
|
||||
{
|
||||
*lf = ncm.lfMessageFont;
|
||||
}
|
||||
/*
|
||||
HGDIOBJ font = GetStockObject(SYSTEM_FONT);
|
||||
if (font)
|
||||
{
|
||||
if (GetObject( font, sizeof( LOGFONT ), lf ))
|
||||
{
|
||||
ok = TRUE;
|
||||
}
|
||||
}
|
||||
*/
|
||||
*lf = ncm.lfMessageFont;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -947,6 +922,18 @@ draw_box (GtkStyle *style,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (detail && !strcmp (detail, "handlebox_bin")) {
|
||||
if (xp_theme_draw (window, XP_THEME_ELEMENT_REBAR, style, x, y, width, height, state_type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (gtk_widget_get_name (widget), "gtk-tooltips")) {
|
||||
if (xp_theme_draw (window, XP_THEME_ELEMENT_TOOLTIP, style, x, y, width, height, state_type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (detail && strcmp (detail, "menuitem") == 0)
|
||||
shadow_type = GTK_SHADOW_NONE;
|
||||
@ -1095,6 +1082,10 @@ draw_tab (GtkStyle *style,
|
||||
x, y, indicator_size.width, arrow_height);
|
||||
}
|
||||
|
||||
/* this is an undefined magic value that, according to the mozilla folks,
|
||||
worked for all the various themes that they tried */
|
||||
#define XP_EDGE_SIZE 2
|
||||
|
||||
static void
|
||||
draw_extension(GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
@ -1112,17 +1103,26 @@ draw_extension(GtkStyle *style,
|
||||
if (detail && !strcmp(detail, "tab"))
|
||||
{
|
||||
GtkNotebook *notebook = GTK_NOTEBOOK(widget);
|
||||
GtkPositionType pos_type = gtk_notebook_get_tab_pos(notebook);
|
||||
|
||||
/* FIXME: pos != TOP to be implemented */
|
||||
if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP
|
||||
&& xp_theme_draw (window,
|
||||
gtk_notebook_get_current_page(notebook)==0
|
||||
? XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE
|
||||
: XP_THEME_ELEMENT_TAB_ITEM,
|
||||
style, x, y, width, height
|
||||
/* FIXME: where does the magic number 2 come from? */
|
||||
+ ( state_type == GTK_STATE_NORMAL
|
||||
? 2 : 0), state_type))
|
||||
if (pos_type == GTK_POS_TOP)
|
||||
height += XP_EDGE_SIZE;
|
||||
|
||||
#if 0
|
||||
/* FIXME: pos != TOP to be implemented */
|
||||
else if (pos_type == GTK_POS_BOTTOM)
|
||||
y -= XP_EDGE_SIZE;
|
||||
else if (pos_type == GTK_POS_RIGHT)
|
||||
width += XP_EDGE_SIZE;
|
||||
else if (pos_type == GTK_POS_LEFT)
|
||||
height -= XP_EDGE_SIZE;
|
||||
#endif
|
||||
|
||||
if (xp_theme_draw (window,
|
||||
gtk_notebook_get_current_page(notebook)==0
|
||||
? XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE
|
||||
: XP_THEME_ELEMENT_TAB_ITEM,
|
||||
style, x, y, width, height, state_type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1143,10 +1143,9 @@ draw_box_gap (GtkStyle *style, GdkWindow *window, GtkStateType state_type,
|
||||
{
|
||||
GtkNotebook *notebook = GTK_NOTEBOOK(widget);
|
||||
|
||||
/* FIXME: pos != TOP to be implemented */
|
||||
if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP
|
||||
&& xp_theme_draw(window, XP_THEME_ELEMENT_TAB_PANE, style, x, y, width, height,
|
||||
state_type))
|
||||
/* FIXME: pos != TOP to be implemented */
|
||||
if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP && xp_theme_draw(window, XP_THEME_ELEMENT_TAB_PANE, style, x, y, width, height,
|
||||
state_type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1171,10 +1170,6 @@ draw_flat_box (GtkStyle *style, GdkWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
/* gtk_style_apply_default_background (style, window,
|
||||
widget && !GTK_WIDGET_NO_WINDOW (widget),
|
||||
state_type, area, x, y, width, height);
|
||||
*/
|
||||
parent_class->draw_flat_box(style, window, state_type, shadow_type,
|
||||
area, widget, detail, x, y, width, height);
|
||||
}
|
||||
@ -1194,12 +1189,6 @@ draw_shadow (GtkStyle *style,
|
||||
{
|
||||
if(detail && ! strcmp(detail, "entry"))
|
||||
{
|
||||
/* Is this necessary?
|
||||
if(GTK_IS_COMBO(widget->parent))
|
||||
width += 10;
|
||||
if(GTK_WIDGET_HAS_FOCUS (widget))
|
||||
state_type = GTK_STATE_PRELIGHT;
|
||||
*/
|
||||
if (xp_theme_draw(window, XP_THEME_ELEMENT_EDIT_TEXT, style,
|
||||
x, y, width, height, state_type))
|
||||
{
|
||||
@ -1210,6 +1199,70 @@ draw_shadow (GtkStyle *style,
|
||||
detail, x, y, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_hline (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
GtkStateType state_type,
|
||||
GdkRectangle *area,
|
||||
GtkWidget *widget,
|
||||
const gchar *detail,
|
||||
gint x1,
|
||||
gint x2,
|
||||
gint y)
|
||||
{
|
||||
/* TODO: GP_LINEHORIZ : LHS_FLAT, LHS_RAISED, LHS_SUNKEN*/
|
||||
parent_class->draw_hline (style, window, state_type, area, widget,
|
||||
detail, x1, x2, y);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_vline (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
GtkStateType state_type,
|
||||
GdkRectangle *area,
|
||||
GtkWidget *widget,
|
||||
const gchar *detail,
|
||||
gint y1,
|
||||
gint y2,
|
||||
gint x)
|
||||
{
|
||||
/* TODO: GP_LINEVERT : LVS_FLAT, LVS_RAISED, LVS_SUNKEN */
|
||||
parent_class->draw_vline (style, window, state_type, area, widget,
|
||||
detail, y1, y2, x);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_handle (GtkStyle *style,
|
||||
GdkWindow *window,
|
||||
GtkStateType state_type,
|
||||
GtkShadowType shadow_type,
|
||||
GdkRectangle *area,
|
||||
GtkWidget *widget,
|
||||
const gchar *detail,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GtkOrientation orientation)
|
||||
{
|
||||
XpThemeElement hndl;
|
||||
|
||||
if (TRUE) {
|
||||
if (orientation == GTK_ORIENTATION_VERTICAL)
|
||||
hndl = XP_THEME_ELEMENT_GRIPPER_V;
|
||||
else
|
||||
hndl = XP_THEME_ELEMENT_GRIPPER_H;
|
||||
|
||||
if (xp_theme_draw(window, hndl, style, x, y, width, height, state_type))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
parent_class->draw_handle (style, window, state_type, shadow_type, area, widget,
|
||||
detail, x, y, width, height, orientation);
|
||||
}
|
||||
|
||||
static void
|
||||
wimp_style_init_from_rc (GtkStyle * style, GtkRcStyle * rc_style)
|
||||
{
|
||||
@ -1242,6 +1295,9 @@ wimp_style_class_init (WimpStyleClass *klass)
|
||||
style_class->draw_extension = draw_extension;
|
||||
style_class->draw_box_gap = draw_box_gap;
|
||||
style_class->draw_shadow = draw_shadow;
|
||||
style_class->draw_hline = draw_hline;
|
||||
style_class->draw_vline = draw_vline;
|
||||
style_class->draw_handle = draw_handle;
|
||||
}
|
||||
|
||||
GType wimp_type_style = 0;
|
||||
|
@ -40,6 +40,9 @@ static LPCWSTR class_descriptors[] =
|
||||
L"TreeView",
|
||||
L"Spin",
|
||||
L"Progress",
|
||||
L"Tooltip",
|
||||
L"Rebar",
|
||||
L"Toolbar"
|
||||
};
|
||||
|
||||
static const short element_part_map[]=
|
||||
@ -74,13 +77,18 @@ static const short element_part_map[]=
|
||||
PP_CHUNKVERT,
|
||||
PP_BAR,
|
||||
PP_BARVERT,
|
||||
TTP_STANDARD,
|
||||
RP_BAND,
|
||||
RP_GRIPPER,
|
||||
RP_GRIPPERVERT,
|
||||
TP_BUTTON
|
||||
};
|
||||
|
||||
static HINSTANCE uxtheme_dll = NULL;
|
||||
static HTHEME open_themes[XP_THEME_CLASS__SIZEOF];
|
||||
|
||||
typedef HRESULT (FAR PASCAL *GetThemeSysFontFunc)
|
||||
(HTHEME hTheme, int iFontID, FAR LOGFONTW *plf);
|
||||
(HTHEME hTheme, int iFontID, FAR LOGFONT *plf);
|
||||
typedef HTHEME (FAR PASCAL *OpenThemeDataFunc)
|
||||
(HWND hwnd, LPCWSTR pszClassList);
|
||||
typedef HRESULT (FAR PASCAL *CloseThemeDataFunc)(HTHEME theme);
|
||||
@ -158,6 +166,20 @@ xp_theme_get_handle_by_element(XpThemeElement element)
|
||||
|
||||
switch(element)
|
||||
{
|
||||
case XP_THEME_ELEMENT_TOOLTIP:
|
||||
klazz = XP_THEME_CLASS_TOOLTIP;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_REBAR:
|
||||
case XP_THEME_ELEMENT_GRIPPER_H:
|
||||
case XP_THEME_ELEMENT_GRIPPER_V:
|
||||
klazz = XP_THEME_CLASS_REBAR;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_TOOLBAR:
|
||||
klazz = XP_THEME_CLASS_TOOLBAR;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_PRESSED_CHECKBOX:
|
||||
case XP_THEME_ELEMENT_CHECKBOX:
|
||||
case XP_THEME_ELEMENT_BUTTON:
|
||||
@ -231,10 +253,24 @@ xp_theme_map_gtk_state(XpThemeElement element, GtkStateType state)
|
||||
|
||||
switch(element)
|
||||
{
|
||||
case XP_THEME_ELEMENT_TAB_PANE:
|
||||
case XP_THEME_ELEMENT_TOOLTIP:
|
||||
ret = TTSS_NORMAL;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_REBAR:
|
||||
case XP_THEME_ELEMENT_GRIPPER_H:
|
||||
case XP_THEME_ELEMENT_GRIPPER_V:
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_TOOLBAR:
|
||||
ret = 1;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_TAB_PANE:
|
||||
ret = 1;
|
||||
break;
|
||||
|
||||
case XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE:
|
||||
case XP_THEME_ELEMENT_TAB_ITEM:
|
||||
switch(state)
|
||||
@ -540,7 +576,7 @@ xp_theme_is_drawable(XpThemeElement element)
|
||||
}
|
||||
|
||||
gboolean
|
||||
xp_theme_get_system_font(LOGFONTW *lf)
|
||||
xp_theme_get_system_font(LOGFONT *lf)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
if (get_theme_sys_font_func != NULL)
|
||||
|
@ -35,6 +35,9 @@ typedef enum
|
||||
XP_THEME_CLASS_TREEVIEW,
|
||||
XP_THEME_CLASS_SPIN,
|
||||
XP_THEME_CLASS_PROGRESS,
|
||||
XP_THEME_CLASS_TOOLTIP,
|
||||
XP_THEME_CLASS_REBAR,
|
||||
XP_THEME_CLASS_TOOLBAR,
|
||||
XP_THEME_CLASS__SIZEOF
|
||||
} XpThemeClass;
|
||||
|
||||
@ -70,6 +73,11 @@ typedef enum
|
||||
XP_THEME_ELEMENT_PROGRESS_BAR_V,
|
||||
XP_THEME_ELEMENT_PROGRESS_TROUGH_H,
|
||||
XP_THEME_ELEMENT_PROGRESS_TROUGH_V,
|
||||
XP_THEME_ELEMENT_TOOLTIP,
|
||||
XP_THEME_ELEMENT_REBAR,
|
||||
XP_THEME_ELEMENT_GRIPPER_H,
|
||||
XP_THEME_ELEMENT_GRIPPER_V,
|
||||
XP_THEME_ELEMENT_TOOLBAR,
|
||||
XP_THEME_ELEMENT__SIZEOF
|
||||
} XpThemeElement;
|
||||
|
||||
@ -77,9 +85,7 @@ void xp_theme_init();
|
||||
void xp_theme_exit();
|
||||
gboolean xp_theme_draw(GdkWindow *win, XpThemeElement element, GtkStyle *style,
|
||||
int x, int y, int width, int height, GtkStateType state_type);
|
||||
gboolean xp_theme_can_draw(XpThemeElement element, GtkStyle *style,
|
||||
int x, int y, int width, int height, GtkStateType state_type);
|
||||
gboolean xp_theme_is_drawable(XpThemeElement element);
|
||||
gboolean xp_theme_get_system_font(LOGFONTW *lf);
|
||||
gboolean xp_theme_get_system_font(LOGFONT *lf);
|
||||
|
||||
#endif /* XP_THEME_H */
|
||||
|
Loading…
Reference in New Issue
Block a user