diff options
Diffstat (limited to 'src/gui/styles')
28 files changed, 3079 insertions, 3625 deletions
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index b2c53f3..f947ac1 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -68,6 +68,7 @@ #include <QtGui/QStatusBar> #include <QtGui/QMenuBar> #include <QtGui/QToolBar> +#include <QtGui/QToolButton> #include <QtGui/QX11Info> #include <X11/Xlib.h> @@ -166,6 +167,7 @@ Ptr_gtk_file_filter_set_name QGtk::gtk_file_filter_set_name = 0; Ptr_gtk_file_filter_add_pattern QGtk::gtk_file_filter_add_pattern = 0; Ptr_gtk_file_chooser_add_filter QGtk::gtk_file_chooser_add_filter = 0; Ptr_gtk_file_chooser_set_filter QGtk::gtk_file_chooser_set_filter = 0; +Ptr_gtk_file_chooser_get_filter QGtk::gtk_file_chooser_get_filter = 0; Ptr_gtk_file_chooser_dialog_new QGtk::gtk_file_chooser_dialog_new = 0; Ptr_gtk_file_chooser_set_current_folder QGtk::gtk_file_chooser_set_current_folder = 0; Ptr_gtk_file_chooser_get_filename QGtk::gtk_file_chooser_get_filename = 0; @@ -207,118 +209,119 @@ static QString classPath(GtkWidget *widget) static void resolveGtk() { - const QString GTK_PATH(QLS("gtk-x11-2.0")); - QGtk::gtk_init = (Ptr_gtk_init)QLibrary::resolve(GTK_PATH, 0, "gtk_init"); - QGtk::gtk_window_new = (Ptr_gtk_window_new)QLibrary::resolve(GTK_PATH, 0, "gtk_window_new"); - QGtk::gtk_style_attach = (Ptr_gtk_style_attach)QLibrary::resolve(GTK_PATH, 0, "gtk_style_attach"); - QGtk::gtk_widget_destroy = (Ptr_gtk_widget_destroy)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_destroy"); - QGtk::gtk_widget_realize = (Ptr_gtk_widget_realize)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_realize"); - - QGtk::gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_set_current_folder"); - QGtk::gtk_file_filter_new = (Ptr_gtk_file_filter_new)QLibrary::resolve(GTK_PATH, 0, "gtk_file_filter_new"); - QGtk::gtk_file_filter_set_name = (Ptr_gtk_file_filter_set_name)QLibrary::resolve(GTK_PATH, 0, "gtk_file_filter_set_name"); - QGtk::gtk_file_filter_add_pattern = (Ptr_gtk_file_filter_add_pattern)QLibrary::resolve(GTK_PATH, 0, "gtk_file_filter_add_pattern"); - QGtk::gtk_file_chooser_add_filter = (Ptr_gtk_file_chooser_add_filter)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_add_filter"); - QGtk::gtk_file_chooser_set_filter = (Ptr_gtk_file_chooser_set_filter)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_set_filter"); - QGtk::gtk_file_chooser_dialog_new = (Ptr_gtk_file_chooser_dialog_new)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_dialog_new"); - QGtk::gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_set_current_folder"); - QGtk::gtk_file_chooser_get_filename = (Ptr_gtk_file_chooser_get_filename)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_get_filename"); - QGtk::gtk_file_chooser_get_filenames = (Ptr_gtk_file_chooser_get_filenames)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_get_filenames"); - QGtk::gtk_file_chooser_set_current_name = (Ptr_gtk_file_chooser_set_current_name)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_set_current_name"); - QGtk::gtk_dialog_run = (Ptr_gtk_dialog_run)QLibrary::resolve(GTK_PATH, 0, "gtk_dialog_run"); - QGtk::gtk_file_chooser_set_filename = (Ptr_gtk_file_chooser_set_filename)QLibrary::resolve(GTK_PATH, 0, "gtk_file_chooser_set_filename"); - - QGtk::gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)QLibrary::resolve(GTK_PATH, 0, "gdk_pixbuf_get_pixels"); - QGtk::gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)QLibrary::resolve(GTK_PATH, 0, "gdk_pixbuf_get_width"); - QGtk::gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)QLibrary::resolve(GTK_PATH, 0, "gdk_pixbuf_get_height"); - QGtk::gdk_pixmap_new = (Ptr_gdk_pixmap_new)QLibrary::resolve(GTK_PATH, 0, "gdk_pixmap_new"); - QGtk::gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)QLibrary::resolve(GTK_PATH, 0, "gdk_pixbuf_new"); - QGtk::gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)QLibrary::resolve(GTK_PATH, 0, "gdk_pixbuf_get_from_drawable"); - QGtk::gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)QLibrary::resolve(GTK_PATH, 0, "gdk_draw_rectangle"); - QGtk::gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)QLibrary::resolve(GTK_PATH, 0, "gdk_pixbuf_unref"); - QGtk::gdk_drawable_unref = (Ptr_gdk_drawable_unref)QLibrary::resolve(GTK_PATH, 0, "gdk_drawable_unref"); - QGtk::gdk_drawable_get_depth = (Ptr_gdk_drawable_get_depth)QLibrary::resolve(GTK_PATH, 0, "gdk_drawable_get_depth"); - QGtk::gdk_color_free = (Ptr_gdk_color_free)QLibrary::resolve(GTK_PATH, 0, "gdk_color_free"); - QGtk::gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)QLibrary::resolve(GTK_PATH, 0, "gdk_x11_window_set_user_time"); - QGtk::gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)QLibrary::resolve(GTK_PATH, 0, "gdk_x11_drawable_get_xid"); - QGtk::gdk_x11_drawable_get_xdisplay = (Ptr_gdk_x11_drawable_get_xdisplay)QLibrary::resolve(GTK_PATH, 0, "gdk_x11_drawable_get_xdisplay"); - - QGtk::gtk_widget_set_default_direction = (Ptr_gtk_widget_set_default_direction)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_set_default_direction"); - QGtk::gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_modify_fg"); - QGtk::gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_modify_bg"); - QGtk::gtk_arrow_new = (Ptr_gtk_arrow_new)QLibrary::resolve(GTK_PATH, 0, "gtk_arrow_new"); - QGtk::gtk_menu_item_new = (Ptr_gtk_menu_item_new)QLibrary::resolve(GTK_PATH, 0, "gtk_menu_item_new"); - QGtk::gtk_check_menu_item_new = (Ptr_gtk_check_menu_item_new)QLibrary::resolve(GTK_PATH, 0, "gtk_check_menu_item_new"); - QGtk::gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)QLibrary::resolve(GTK_PATH, 0, "gtk_menu_bar_new"); - QGtk::gtk_menu_new = (Ptr_gtk_menu_new)QLibrary::resolve(GTK_PATH, 0, "gtk_menu_new"); - QGtk::gtk_toolbar_new = (Ptr_gtk_toolbar_new)QLibrary::resolve(GTK_PATH, 0, "gtk_toolbar_new"); - QGtk::gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)QLibrary::resolve(GTK_PATH, 0, "gtk_separator_tool_item_new"); - QGtk::gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)QLibrary::resolve(GTK_PATH, 0, "gtk_toolbar_insert"); - QGtk::gtk_button_new = (Ptr_gtk_button_new)QLibrary::resolve(GTK_PATH, 0, "gtk_button_new"); - QGtk::gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)QLibrary::resolve(GTK_PATH, 0, "gtk_hbutton_box_new"); - QGtk::gtk_check_button_new = (Ptr_gtk_check_button_new)QLibrary::resolve(GTK_PATH, 0, "gtk_check_button_new"); - QGtk::gtk_radio_button_new = (Ptr_gtk_radio_button_new)QLibrary::resolve(GTK_PATH, 0, "gtk_radio_button_new"); - QGtk::gtk_notebook_new = (Ptr_gtk_notebook_new)QLibrary::resolve(GTK_PATH, 0, "gtk_notebook_new"); - QGtk::gtk_progress_bar_new = (Ptr_gtk_progress_bar_new)QLibrary::resolve(GTK_PATH, 0, "gtk_progress_bar_new"); - QGtk::gtk_spin_button_new = (Ptr_gtk_spin_button_new)QLibrary::resolve(GTK_PATH, 0, "gtk_spin_button_new"); - QGtk::gtk_hscale_new = (Ptr_gtk_hscale_new)QLibrary::resolve(GTK_PATH, 0, "gtk_hscale_new"); - QGtk::gtk_vscale_new = (Ptr_gtk_vscale_new)QLibrary::resolve(GTK_PATH, 0, "gtk_vscale_new"); - QGtk::gtk_hscrollbar_new = (Ptr_gtk_hscrollbar_new)QLibrary::resolve(GTK_PATH, 0, "gtk_hscrollbar_new"); - QGtk::gtk_vscrollbar_new = (Ptr_gtk_vscrollbar_new)QLibrary::resolve(GTK_PATH, 0, "gtk_vscrollbar_new"); - QGtk::gtk_scrolled_window_new = (Ptr_gtk_scrolled_window_new)QLibrary::resolve(GTK_PATH, 0, "gtk_scrolled_window_new"); - QGtk::gtk_menu_shell_append = (Ptr_gtk_menu_shell_append)QLibrary::resolve(GTK_PATH, 0, "gtk_menu_shell_append"); - QGtk::gtk_entry_new = (Ptr_gtk_entry_new)QLibrary::resolve(GTK_PATH, 0, "gtk_entry_new"); - QGtk::gtk_tree_view_new = (Ptr_gtk_tree_view_new)QLibrary::resolve(GTK_PATH, 0, "gtk_tree_view_new"); - QGtk::gtk_combo_box_new = (Ptr_gtk_combo_box_new)QLibrary::resolve(GTK_PATH, 0, "gtk_combo_box_new"); - QGtk::gtk_progress_set_adjustment = (Ptr_gtk_progress_set_adjustment)QLibrary::resolve(GTK_PATH, 0, "gtk_progress_set_adjustment"); - QGtk::gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)QLibrary::resolve(GTK_PATH, 0, "gtk_range_set_adjustment"); - QGtk::gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)QLibrary::resolve(GTK_PATH, 0, "gtk_range_set_inverted"); - QGtk::gtk_container_add = (Ptr_gtk_container_add)QLibrary::resolve(GTK_PATH, 0, "gtk_container_add"); - QGtk::gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)QLibrary::resolve(GTK_PATH, 0, "gtk_icon_factory_lookup_default"); - QGtk::gtk_widget_style_get = (Ptr_gtk_widget_style_get)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_style_get"); - QGtk::gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)QLibrary::resolve(GTK_PATH, 0, "gtk_icon_set_render_icon"); - QGtk::gtk_fixed_new = (Ptr_gtk_fixed_new)QLibrary::resolve(GTK_PATH, 0, "gtk_fixed_new"); - QGtk::gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)QLibrary::resolve(GTK_PATH, 0, "gtk_tree_view_column_new"); - QGtk::gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )QLibrary::resolve(GTK_PATH, 0, "gtk_tree_view_append_column"); - QGtk::gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )QLibrary::resolve(GTK_PATH, 0, "gtk_tree_view_get_column"); - QGtk::gtk_paint_check = (Ptr_gtk_paint_check)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_check"); - QGtk::gtk_paint_box = (Ptr_gtk_paint_box)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_box"); - QGtk::gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_flat_box"); - QGtk::gtk_paint_check = (Ptr_gtk_paint_check)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_check"); - QGtk::gtk_paint_box = (Ptr_gtk_paint_box)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_box"); - QGtk::gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_resize_grip"); - QGtk::gtk_paint_focus = (Ptr_gtk_paint_focus)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_focus"); - QGtk::gtk_paint_shadow = (Ptr_gtk_paint_shadow)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_shadow"); - QGtk::gtk_paint_slider = (Ptr_gtk_paint_slider)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_slider"); - QGtk::gtk_paint_expander = (Ptr_gtk_paint_expander)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_expander"); - QGtk::gtk_paint_handle = (Ptr_gtk_paint_handle)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_handle"); - QGtk::gtk_paint_option = (Ptr_gtk_paint_option)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_option"); - QGtk::gtk_paint_arrow = (Ptr_gtk_paint_arrow)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_arrow"); - QGtk::gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_box_gap"); - QGtk::gtk_paint_extension = (Ptr_gtk_paint_extension)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_extension"); - QGtk::gtk_paint_hline = (Ptr_gtk_paint_hline)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_hline"); - QGtk::gtk_paint_vline = (Ptr_gtk_paint_vline)QLibrary::resolve(GTK_PATH, 0, "gtk_paint_vline"); - QGtk::gtk_adjustment_new = (Ptr_gtk_adjustment_new)QLibrary::resolve(GTK_PATH, 0, "gtk_adjustment_new"); - QGtk::gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)QLibrary::resolve(GTK_PATH, 0, "gtk_menu_item_set_submenu"); - QGtk::gtk_settings_get_default = (Ptr_gtk_settings_get_default)QLibrary::resolve(GTK_PATH, 0, "gtk_settings_get_default"); - QGtk::gtk_separator_menu_item_new = (Ptr_gtk_separator_menu_item_new)QLibrary::resolve(GTK_PATH, 0, "gtk_separator_menu_item_new"); - QGtk::gtk_frame_new = (Ptr_gtk_frame_new)QLibrary::resolve(GTK_PATH, 0, "gtk_frame_new"); - QGtk::gtk_expander_new = (Ptr_gtk_expander_new)QLibrary::resolve(GTK_PATH, 0, "gtk_expander_new"); - QGtk::gtk_statusbar_new = (Ptr_gtk_statusbar_new)QLibrary::resolve(GTK_PATH, 0, "gtk_statusbar_new"); - QGtk::gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)QLibrary::resolve(GTK_PATH, 0, "gtk_combo_box_entry_new"); - QGtk::gtk_container_forall = (Ptr_gtk_container_forall)QLibrary::resolve(GTK_PATH, 0, "gtk_container_forall"); - QGtk::gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_size_allocate"); - QGtk::gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_set_direction"); - QGtk::gtk_widget_path =(Ptr_gtk_widget_path)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_path"); - QGtk::gtk_container_get_type =(Ptr_gtk_container_get_type)QLibrary::resolve(GTK_PATH, 0, "gtk_container_get_type"); - QGtk::gtk_window_get_type =(Ptr_gtk_window_get_type)QLibrary::resolve(GTK_PATH, 0, "gtk_window_get_type"); - QGtk::gtk_widget_get_type =(Ptr_gtk_widget_get_type)QLibrary::resolve(GTK_PATH, 0, "gtk_widget_get_type"); - QGtk::gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)QLibrary::resolve(GTK_PATH, 0, "gtk_rc_get_style_by_paths"); - QGtk::gtk_check_version =(Ptr_gtk_check_version)QLibrary::resolve(GTK_PATH, 0, "gtk_check_version"); - QGtk::pango_font_description_get_size = (Ptr_pango_font_description_get_size)QLibrary::resolve(GTK_PATH, 0, "pango_font_description_get_size"); - QGtk::pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)QLibrary::resolve(GTK_PATH, 0, "pango_font_description_get_weight"); - QGtk::pango_font_description_get_family = (Ptr_pango_font_description_get_family)QLibrary::resolve(GTK_PATH, 0, "pango_font_description_get_family"); - QGtk::pango_font_description_get_style = (Ptr_pango_font_description_get_style)QLibrary::resolve(GTK_PATH, 0, "pango_font_description_get_style"); + QLibrary libgtk(QLS("gtk-x11-2.0")); + QGtk::gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init"); + QGtk::gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new"); + QGtk::gtk_style_attach = (Ptr_gtk_style_attach)libgtk.resolve("gtk_style_attach"); + QGtk::gtk_widget_destroy = (Ptr_gtk_widget_destroy)libgtk.resolve("gtk_widget_destroy"); + QGtk::gtk_widget_realize = (Ptr_gtk_widget_realize)libgtk.resolve("gtk_widget_realize"); + + QGtk::gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder"); + QGtk::gtk_file_filter_new = (Ptr_gtk_file_filter_new)libgtk.resolve("gtk_file_filter_new"); + QGtk::gtk_file_filter_set_name = (Ptr_gtk_file_filter_set_name)libgtk.resolve("gtk_file_filter_set_name"); + QGtk::gtk_file_filter_add_pattern = (Ptr_gtk_file_filter_add_pattern)libgtk.resolve("gtk_file_filter_add_pattern"); + QGtk::gtk_file_chooser_add_filter = (Ptr_gtk_file_chooser_add_filter)libgtk.resolve("gtk_file_chooser_add_filter"); + QGtk::gtk_file_chooser_set_filter = (Ptr_gtk_file_chooser_set_filter)libgtk.resolve("gtk_file_chooser_set_filter"); + QGtk::gtk_file_chooser_get_filter = (Ptr_gtk_file_chooser_get_filter)libgtk.resolve("gtk_file_chooser_get_filter"); + QGtk::gtk_file_chooser_dialog_new = (Ptr_gtk_file_chooser_dialog_new)libgtk.resolve("gtk_file_chooser_dialog_new"); + QGtk::gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder"); + QGtk::gtk_file_chooser_get_filename = (Ptr_gtk_file_chooser_get_filename)libgtk.resolve("gtk_file_chooser_get_filename"); + QGtk::gtk_file_chooser_get_filenames = (Ptr_gtk_file_chooser_get_filenames)libgtk.resolve("gtk_file_chooser_get_filenames"); + QGtk::gtk_file_chooser_set_current_name = (Ptr_gtk_file_chooser_set_current_name)libgtk.resolve("gtk_file_chooser_set_current_name"); + QGtk::gtk_dialog_run = (Ptr_gtk_dialog_run)libgtk.resolve("gtk_dialog_run"); + QGtk::gtk_file_chooser_set_filename = (Ptr_gtk_file_chooser_set_filename)libgtk.resolve("gtk_file_chooser_set_filename"); + + QGtk::gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)libgtk.resolve("gdk_pixbuf_get_pixels"); + QGtk::gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)libgtk.resolve("gdk_pixbuf_get_width"); + QGtk::gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)libgtk.resolve("gdk_pixbuf_get_height"); + QGtk::gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new"); + QGtk::gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new"); + QGtk::gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable"); + QGtk::gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle"); + QGtk::gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref"); + QGtk::gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref"); + QGtk::gdk_drawable_get_depth = (Ptr_gdk_drawable_get_depth)libgtk.resolve("gdk_drawable_get_depth"); + QGtk::gdk_color_free = (Ptr_gdk_color_free)libgtk.resolve("gdk_color_free"); + QGtk::gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)libgtk.resolve("gdk_x11_window_set_user_time"); + QGtk::gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)libgtk.resolve("gdk_x11_drawable_get_xid"); + QGtk::gdk_x11_drawable_get_xdisplay = (Ptr_gdk_x11_drawable_get_xdisplay)libgtk.resolve("gdk_x11_drawable_get_xdisplay"); + + QGtk::gtk_widget_set_default_direction = (Ptr_gtk_widget_set_default_direction)libgtk.resolve("gtk_widget_set_default_direction"); + QGtk::gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_fg"); + QGtk::gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_bg"); + QGtk::gtk_arrow_new = (Ptr_gtk_arrow_new)libgtk.resolve("gtk_arrow_new"); + QGtk::gtk_menu_item_new = (Ptr_gtk_menu_item_new)libgtk.resolve("gtk_menu_item_new"); + QGtk::gtk_check_menu_item_new = (Ptr_gtk_check_menu_item_new)libgtk.resolve("gtk_check_menu_item_new"); + QGtk::gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)libgtk.resolve("gtk_menu_bar_new"); + QGtk::gtk_menu_new = (Ptr_gtk_menu_new)libgtk.resolve("gtk_menu_new"); + QGtk::gtk_toolbar_new = (Ptr_gtk_toolbar_new)libgtk.resolve("gtk_toolbar_new"); + QGtk::gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new"); + QGtk::gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert"); + QGtk::gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new"); + QGtk::gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new"); + QGtk::gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new"); + QGtk::gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new"); + QGtk::gtk_notebook_new = (Ptr_gtk_notebook_new)libgtk.resolve("gtk_notebook_new"); + QGtk::gtk_progress_bar_new = (Ptr_gtk_progress_bar_new)libgtk.resolve("gtk_progress_bar_new"); + QGtk::gtk_spin_button_new = (Ptr_gtk_spin_button_new)libgtk.resolve("gtk_spin_button_new"); + QGtk::gtk_hscale_new = (Ptr_gtk_hscale_new)libgtk.resolve("gtk_hscale_new"); + QGtk::gtk_vscale_new = (Ptr_gtk_vscale_new)libgtk.resolve("gtk_vscale_new"); + QGtk::gtk_hscrollbar_new = (Ptr_gtk_hscrollbar_new)libgtk.resolve("gtk_hscrollbar_new"); + QGtk::gtk_vscrollbar_new = (Ptr_gtk_vscrollbar_new)libgtk.resolve("gtk_vscrollbar_new"); + QGtk::gtk_scrolled_window_new = (Ptr_gtk_scrolled_window_new)libgtk.resolve("gtk_scrolled_window_new"); + QGtk::gtk_menu_shell_append = (Ptr_gtk_menu_shell_append)libgtk.resolve("gtk_menu_shell_append"); + QGtk::gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new"); + QGtk::gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new"); + QGtk::gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new"); + QGtk::gtk_progress_set_adjustment = (Ptr_gtk_progress_set_adjustment)libgtk.resolve("gtk_progress_set_adjustment"); + QGtk::gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment"); + QGtk::gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted"); + QGtk::gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add"); + QGtk::gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)libgtk.resolve("gtk_icon_factory_lookup_default"); + QGtk::gtk_widget_style_get = (Ptr_gtk_widget_style_get)libgtk.resolve("gtk_widget_style_get"); + QGtk::gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)libgtk.resolve("gtk_icon_set_render_icon"); + QGtk::gtk_fixed_new = (Ptr_gtk_fixed_new)libgtk.resolve("gtk_fixed_new"); + QGtk::gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)libgtk.resolve("gtk_tree_view_column_new"); + QGtk::gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )libgtk.resolve("gtk_tree_view_append_column"); + QGtk::gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )libgtk.resolve("gtk_tree_view_get_column"); + QGtk::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check"); + QGtk::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box"); + QGtk::gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box"); + QGtk::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check"); + QGtk::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box"); + QGtk::gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip"); + QGtk::gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus"); + QGtk::gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow"); + QGtk::gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider"); + QGtk::gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander"); + QGtk::gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle"); + QGtk::gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option"); + QGtk::gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow"); + QGtk::gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap"); + QGtk::gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension"); + QGtk::gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline"); + QGtk::gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline"); + QGtk::gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new"); + QGtk::gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu"); + QGtk::gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default"); + QGtk::gtk_separator_menu_item_new = (Ptr_gtk_separator_menu_item_new)libgtk.resolve("gtk_separator_menu_item_new"); + QGtk::gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new"); + QGtk::gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new"); + QGtk::gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new"); + QGtk::gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new"); + QGtk::gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall"); + QGtk::gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate"); + QGtk::gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)libgtk.resolve("gtk_widget_set_direction"); + QGtk::gtk_widget_path =(Ptr_gtk_widget_path)libgtk.resolve("gtk_widget_path"); + QGtk::gtk_container_get_type =(Ptr_gtk_container_get_type)libgtk.resolve("gtk_container_get_type"); + QGtk::gtk_window_get_type =(Ptr_gtk_window_get_type)libgtk.resolve("gtk_window_get_type"); + QGtk::gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type"); + QGtk::gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths"); + QGtk::gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version"); + QGtk::pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size"); + QGtk::pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight"); + QGtk::pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family"); + QGtk::pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style"); } void QGtk::cleanup_gtk_widgets() @@ -374,8 +377,8 @@ static QString getThemeName() while(!in.atEnd()) { QString line = in.readLine(); if (line.contains(QLS("gtk-theme-name"))) { - line = line.right(line.length() - line.indexOf(QLS("=")) - 1); - line.remove(QLS("\"")); + line = line.right(line.length() - line.indexOf(QLatin1Char('=')) - 1); + line.remove(QLatin1Char('\"')); line = line.trimmed(); themeName = line; break; @@ -633,6 +636,20 @@ GtkStyle* QGtk::gtkStyle(const QString &path) return 0; } +static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *pspec, gpointer user_data) +{ + GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS; + g_object_get(gtkToolBar, "toolbar-style", &toolbar_style, NULL); + QWidgetList widgets = QApplication::allWidgets(); + for (int i = 0; i < widgets.size(); ++i) { + QWidget *widget = widgets.at(i); + if (qobject_cast<QToolButton*>(widget)) { + QEvent event(QEvent::StyleChange); + QApplication::sendEvent(widget, &event); + } + } +} + void QGtk::initGtkWidgets() { // From gtkmain.c @@ -679,6 +696,7 @@ void QGtk::initGtkWidgets() add_widget(QGtk::gtk_spin_button_new((GtkAdjustment*) (QGtk::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3)); GtkWidget *toolbar = QGtk::gtk_toolbar_new(); + g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar); QGtk::gtk_toolbar_insert((GtkToolbar*)toolbar, QGtk::gtk_separator_tool_item_new(), -1); add_widget(toolbar); init_gtk_treeview(); @@ -695,7 +713,7 @@ void QGtk::initGtkWidgets() QHashIterator<QString, GtkWidget*> it(oldMap); while (it.hasNext()) { it.next(); - if (!it.key().contains(QLS("."))) { + if (!it.key().contains(QLatin1Char('.'))) { add_all_sub_widgets(it.value()); } } @@ -720,7 +738,8 @@ extern QStringList qt_make_filter_list(const QString &filter); static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent, const QString &dir, const QString &filter, QString *selectedFilter, - QFileDialog::Options options, bool isSaveDialog = false) + QFileDialog::Options options, bool isSaveDialog = false, + QMap<GtkFileFilter *, QString> *filterMap = 0) { g_object_set(gtkFileChooser, "do-overwrite-confirmation", gboolean(!(options & QFileDialog::DontConfirmOverwrite)), NULL); g_object_set(gtkFileChooser, "local_only", gboolean(true), NULL); @@ -752,6 +771,8 @@ static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent, QGtk::gtk_file_filter_add_pattern (gtkFilter, qPrintable(caseInsensitive)); } + if (filterMap) + filterMap->insert(gtkFilter, rawfilter); QGtk::gtk_file_chooser_add_filter((GtkFileChooser*)gtkFileChooser, gtkFilter); if (selectedFilter && (rawfilter == *selectedFilter)) QGtk::gtk_file_chooser_set_filter((GtkFileChooser*)gtkFileChooser, gtkFilter); @@ -788,7 +809,7 @@ static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent, QString QGtk::openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options) { - + QMap<GtkFileFilter *, QString> filterMap; GtkWidget *gtkFileChooser = QGtk::gtk_file_chooser_dialog_new (qPrintable(caption), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, @@ -796,7 +817,7 @@ QString QGtk::openFilename(QWidget *parent, const QString &caption, const QStrin GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options); + setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap); QWidget modal_widget; modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true); @@ -808,6 +829,10 @@ QString QGtk::openFilename(QWidget *parent, const QString &caption, const QStrin char *gtk_filename = QGtk::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser); filename = QString::fromUtf8(gtk_filename); g_free (gtk_filename); + if (selectedFilter) { + GtkFileFilter *gtkFilter = QGtk::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser); + *selectedFilter = filterMap.value(gtkFilter); + } } QApplicationPrivate::leaveModal(&modal_widget); @@ -818,6 +843,7 @@ QString QGtk::openFilename(QWidget *parent, const QString &caption, const QStrin QString QGtk::openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options) { + QMap<GtkFileFilter *, QString> filterMap; GtkWidget *gtkFileChooser = QGtk::gtk_file_chooser_dialog_new (qPrintable(caption), NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, @@ -847,6 +873,7 @@ QStringList QGtk::openFilenames(QWidget *parent, const QString &caption, const Q QString *selectedFilter, QFileDialog::Options options) { QStringList filenames; + QMap<GtkFileFilter *, QString> filterMap; GtkWidget *gtkFileChooser = QGtk::gtk_file_chooser_dialog_new (qPrintable(caption), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, @@ -854,7 +881,7 @@ QStringList QGtk::openFilenames(QWidget *parent, const QString &caption, const Q GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options); + setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap); g_object_set(gtkFileChooser, "select-multiple", gboolean(true), NULL); QWidget modal_widget; @@ -867,6 +894,10 @@ QStringList QGtk::openFilenames(QWidget *parent, const QString &caption, const Q for (GSList *iterator = gtk_file_names ; iterator; iterator = iterator->next) filenames << QString::fromUtf8((const char*)iterator->data); g_slist_free(gtk_file_names); + if (selectedFilter) { + GtkFileFilter *gtkFilter = QGtk::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser); + *selectedFilter = filterMap.value(gtkFilter); + } } QApplicationPrivate::leaveModal(&modal_widget); @@ -877,13 +908,14 @@ QStringList QGtk::openFilenames(QWidget *parent, const QString &caption, const Q QString QGtk::saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options) { + QMap<GtkFileFilter *, QString> filterMap; GtkWidget *gtkFileChooser = QGtk::gtk_file_chooser_dialog_new (qPrintable(caption), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); - setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, true); + setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, true, &filterMap); QWidget modal_widget; modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true); @@ -895,6 +927,10 @@ QString QGtk::saveFilename(QWidget *parent, const QString &caption, const QStrin char *gtk_filename = QGtk::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser); filename = QString::fromUtf8(gtk_filename); g_free (gtk_filename); + if (selectedFilter) { + GtkFileFilter *gtkFilter = QGtk::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser); + *selectedFilter = filterMap.value(gtkFilter); + } } QApplicationPrivate::leaveModal(&modal_widget); diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h index b0195d2..18c6dc5 100644 --- a/src/gui/styles/gtksymbols_p.h +++ b/src/gui/styles/gtksymbols_p.h @@ -162,6 +162,7 @@ typedef void (*Ptr_gtk_file_filter_set_name)(GtkFileFilter *, const gchar *); typedef void (*Ptr_gtk_file_filter_add_pattern)(GtkFileFilter *filter, const gchar *pattern); typedef void (*Ptr_gtk_file_chooser_add_filter)(GtkFileChooser *chooser, GtkFileFilter *filter); typedef void (*Ptr_gtk_file_chooser_set_filter)(GtkFileChooser *chooser, GtkFileFilter *filter); +typedef GtkFileFilter* (*Ptr_gtk_file_chooser_get_filter)(GtkFileChooser *chooser); typedef gchar* (*Ptr_gtk_file_chooser_get_filename)(GtkFileChooser *chooser); typedef GSList* (*Ptr_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser); typedef GtkWidget* (*Ptr_gtk_file_chooser_dialog_new)(const gchar *title, @@ -302,6 +303,7 @@ public: static Ptr_gtk_file_filter_add_pattern gtk_file_filter_add_pattern; static Ptr_gtk_file_chooser_add_filter gtk_file_chooser_add_filter; static Ptr_gtk_file_chooser_set_filter gtk_file_chooser_set_filter; + static Ptr_gtk_file_chooser_get_filter gtk_file_chooser_get_filter; static Ptr_gtk_file_chooser_dialog_new gtk_file_chooser_dialog_new; static Ptr_gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder; static Ptr_gtk_file_chooser_get_filename gtk_file_chooser_get_filename; diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index bb6baad..8f88781 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -44,6 +44,7 @@ #if !defined(QT_NO_STYLE_CLEANLOOKS) || defined(QT_PLUGIN) +#include <private/qstylehelper_p.h> #include "qwindowsstyle_p.h" #include <qcombobox.h> #include <qpushbutton.h> @@ -72,7 +73,7 @@ QT_BEGIN_NAMESPACE -static const bool UsePixmapCache = true; +using namespace QStyleHelper; enum Direction { TopDown, @@ -553,26 +554,6 @@ static void qt_cleanlooks_draw_buttongradient(QPainter *painter, const QRect &re delete gradient; } -static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) -{ - QString tmp; - const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); - tmp.sprintf("%s-%d-%d-%lld-%dx%d-%d", key.toLatin1().constData(), uint(option->state), - complexOption ? uint(complexOption->activeSubControls) : uint(0), - option->palette.cacheKey(), size.width(), size.height(), option->direction); -#ifndef QT_NO_SPINBOX - if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { - tmp.append(QLatin1Char('-')); - tmp.append(QString::number(spinBox->buttonSymbols)); - tmp.append(QLatin1Char('-')); - tmp.append(QString::number(spinBox->stepEnabled)); - tmp.append(QLatin1Char('-')); - tmp.append(QLatin1Char(spinBox->frame ? '1' : '0')); - } -#endif // QT_NO_SPINBOX - return tmp; -} - static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken) { QColor dark; @@ -782,7 +763,7 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, QStyleOptionButton button; button.QStyleOption::operator=(*option); button.state &= ~State_MouseOver; - drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); } return; case PE_IndicatorHeaderArrow: @@ -802,7 +783,7 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, } break; case PE_IndicatorButtonDropDown: - drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); break; case PE_IndicatorToolBarSeparator: { @@ -887,9 +868,9 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (widget && widget->inherits("QDockWidgetTitleButton")) { if (option->state & State_MouseOver) - drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); } else { - drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); } } painter->restore(); @@ -902,7 +883,7 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, dockWidgetHandle.state &= ~State_Horizontal; else dockWidgetHandle.state |= State_Horizontal; - drawControl(CE_Splitter, &dockWidgetHandle, painter, widget); + proxy()->drawControl(CE_Splitter, &dockWidgetHandle, painter, widget); } break; case PE_FrameWindow: @@ -928,7 +909,7 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, #endif // QT_NO_LINEEDIT #ifdef QT3_SUPPORT if (widget && widget->inherits("Q3ToolBar")) { - drawPrimitive(PE_Q3Separator, option, painter, widget); + proxy()->drawPrimitive(PE_Q3Separator, option, painter, widget); break; } #endif @@ -1257,7 +1238,7 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, QColor alphaCornerColor = mergedColors(borderColor, option->palette.background().color()); QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); - int borderThickness = pixelMetric(PM_TabBarBaseOverlap, twf, widget); + int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget); bool reverse = (twf->direction == Qt::RightToLeft); QRect tabBarRect; @@ -1370,9 +1351,9 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem, if (d->tabBarcloseButtonIcon.isNull()) d->tabBarcloseButtonIcon = standardIcon(SP_DialogCloseButton, option, widget); if ((option->state & State_Enabled) && (option->state & State_MouseOver)) - drawPrimitive(PE_PanelButtonCommand, option, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On); - drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); + proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); } break; @@ -1649,7 +1630,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o QString titleText = painter->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width()); - drawItemText(painter, + proxy()->drawItemText(painter, titleRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, dwOpt->state & State_Enabled, titleText, @@ -1664,9 +1645,9 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o // Draws the header in tables. if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { QPixmap cache; - QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size()); - pixmapName += QLatin1String("-") + QString::number(int(header->position)); - pixmapName += QLatin1String("-") + QString::number(int(header->orientation)); + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size()); + pixmapName += QString::number(- int(header->position)); + pixmapName += QString::number(- int(header->orientation)); QRect r = option->rect; QColor gradientStopColor; QColor gradientStartColor = option->palette.button().color(); @@ -1683,7 +1664,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o } painter->fillRect(r, gradient); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(r.size()); cache.fill(Qt::transparent); QRect pixmapRect(0, 0, r.width(), r.height()); @@ -1702,8 +1683,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o cachePainter.drawLine(pixmapRect.topRight() + QPoint(-1, 3), pixmapRect.bottomRight() + QPoint(-1, -3)); cachePainter.setPen(QPen(option->palette.light().color())); cachePainter.drawLine(pixmapRect.topRight() + QPoint(0, 3), pixmapRect.bottomRight() + QPoint(0, -3)); } cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(r.topLeft(), cache); } @@ -1758,18 +1738,16 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o // same rendering code for both orientations. if (vertical) { rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - QTransform m; - m.translate(rect.height()-1, -1.0); + QTransform m = QTransform::fromTranslate(rect.height()-1, -1.0); m.rotate(90.0); painter->setTransform(m, true); } int maxWidth = rect.width() - 4; int minWidth = 4; - qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar - double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth); - int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth; - int width = indeterminate ? maxWidth : progressBarWidth; + qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar + int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); + int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth); bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; if (inverted) @@ -1864,7 +1842,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; - drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole); + proxy()->drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole); } } @@ -1891,7 +1869,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o int w = 0; if (!menuItem->text.isEmpty()) { painter->setFont(menuItem->font); - drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, + proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, menuItem->palette, menuItem->state & State_Enabled, menuItem->text, QPalette::Text); w = menuItem->fontMetrics.width(menuItem->text) + 5; @@ -1995,7 +1973,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o mode = QIcon::Active; QPixmap pixmap; - int smallIconSize = pixelMetric(PM_SmallIconSize, option, widget); + int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); QSize iconSize(smallIconSize, smallIconSize); #ifndef QT_NO_COMBOBOX if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget)) @@ -2021,7 +1999,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o } opt.state |= State_Sunken; opt.rect = vCheckRect; - drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); } painter->drawPixmap(pmr.topLeft(), pixmap); } @@ -2054,7 +2032,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o if (t >= 0) { QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); - if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) { + if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { p->setPen(menuitem->palette.light().color()); p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1)); p->setPen(discol); @@ -2063,12 +2041,18 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o s = s.left(t); } QFont font = menuitem->font; + // font may not have any "hard" flags set. We override + // the point size so that when it is resolved against the device, this font will win. + // This is mainly to handle cases where someone sets the font on the window + // and then the combo inherits it and passes it onward. At that point the resolve mask + // is very, very weak. This makes it stonger. + font.setPointSizeF(menuItem->font.pointSizeF()); if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) font.setBold(true); p->setFont(font); - if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) { + if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { p->setPen(menuitem->palette.light().color()); p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t)); p->setPen(discol); @@ -2091,7 +2075,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o if (selected) newMI.palette.setColor(QPalette::ButtonText, newMI.palette.highlightedText().color()); - drawPrimitive(arrow, &newMI, painter, widget); + proxy()->drawPrimitive(arrow, &newMI, painter, widget); } } painter->restore(); @@ -2152,7 +2136,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o if (button->features & QStyleOptionButton::HasMenu) ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0); - drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled), + proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled), button->text, QPalette::ButtonText); } break; @@ -2207,7 +2191,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o || (rtlHorTabs && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)); - int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget); + int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget); bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft) || (rtlHorTabs && tabBarAlignment == Qt::AlignRight); @@ -2220,7 +2204,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o QColor midlight = tab->palette.midlight().color(); QColor background = tab->palette.background().color(); - int borderThinkness = pixelMetric(PM_TabBarBaseOverlap, tab, widget); + int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); if (selected) borderThinkness /= 2; QRect r2(option->rect); @@ -2456,8 +2440,8 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp case CC_SpinBox: if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { QPixmap cache; - QString pixmapName = uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size()); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size()); + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(spinBox->rect.size()); cache.fill(Qt::transparent); QRect pixmapRect(0, 0, spinBox->rect.width(), spinBox->rect.height()); @@ -2473,10 +2457,10 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp QRect rect = pixmapRect; QStyleOptionSpinBox spinBoxCopy = *spinBox; spinBoxCopy.rect = pixmapRect; - QRect upRect = subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget); - QRect downRect = subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget); + QRect upRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget); + QRect downRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget); - int fw = spinBoxCopy.frame ? pixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0; + int fw = spinBoxCopy.frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0; cachePainter.fillRect(rect.adjusted(1, qMax(fw - 1, 0), -1, -fw), option->palette.base()); @@ -2674,8 +2658,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp cachePainter.fillRect(downRect.adjusted(1, 0, 0, 0), disabledColor); } cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(spinBox->rect.topLeft(), cache); } @@ -2699,7 +2682,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (widget && widget->inherits("Q3DockWindowTitleBar")) { QStyleOptionDockWidgetV2 dockwidget; dockwidget.QStyleOption::operator=(*option); - drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget); + proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget); } else #endif // QT3_SUPPORT { @@ -2742,7 +2725,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1); } // draw title - QRect textRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); + QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); QFont font = painter->font(); font.setBold(true); painter->setFont(font); @@ -2757,7 +2740,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // min button if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) && !(titleBar->titleBarState& Qt::WindowMinimized)) { - QRect minButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); + QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); if (minButtonRect.isValid()) { bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken); @@ -2778,7 +2761,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // max button if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && !(titleBar->titleBarState & Qt::WindowMaximized)) { - QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); + QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); if (maxButtonRect.isValid()) { bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); @@ -2800,7 +2783,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // close button if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { - QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); + QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); if (closeButtonRect.isValid()) { bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); @@ -2834,7 +2817,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp (titleBar->titleBarState & Qt::WindowMinimized)) || ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && (titleBar->titleBarState & Qt::WindowMaximized)))) { - QRect normalButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); + QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); if (normalButtonRect.isValid()) { bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver); @@ -2874,7 +2857,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // context help button if (titleBar->subControls & SC_TitleBarContextHelpButton && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) { - QRect contextHelpButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); + QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); if (contextHelpButtonRect.isValid()) { bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken); @@ -2893,7 +2876,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // shade button if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) { - QRect shadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); + QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); if (shadeButtonRect.isValid()) { bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken); @@ -2906,7 +2889,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // unshade button if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) { - QRect unshadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); + QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); if (unshadeButtonRect.isValid()) { bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken); @@ -2918,7 +2901,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp } if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { - QRect iconRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); + QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); if (iconRect.isValid()) { if (!titleBar->icon.isNull()) { titleBar->icon.paint(painter, iconRect); @@ -2928,7 +2911,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp QPixmap pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16); tool.rect = iconRect; painter->save(); - drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); + proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); painter->restore(); } } @@ -2948,10 +2931,10 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp painter->fillRect(option->rect, option->palette.background()); QRect rect = scrollBar->rect; - QRect scrollBarSubLine = subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); - QRect scrollBarAddLine = subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); - QRect scrollBarSlider = subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); - QRect grooveRect = subControlRect(control, scrollBar, SC_ScrollBarGroove, widget); + QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); + QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); + QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); + QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget); // paint groove if (scrollBar->subControls & SC_ScrollBarGroove) { @@ -3086,7 +3069,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // The SubLine (up/left) buttons if (scrollBar->subControls & SC_ScrollBarSubLine) { - //int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, option, widget); + //int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); QRect pixmapRect = scrollBarSubLine; if (isEnabled ) { QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1); @@ -3132,12 +3115,12 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp arrow = PE_IndicatorArrowUp; QStyleOption arrowOpt = *option; arrowOpt.rect = scrollBarSubLine.adjusted(3, 3, -2, -2); - drawPrimitive(arrow, &arrowOpt, painter, widget); + proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget); // The AddLine (down/right) button if (scrollBar->subControls & SC_ScrollBarAddLine) { - QString addLinePixmapName = uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16)); + QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16)); QRect pixmapRect = scrollBarAddLine; if (isEnabled) { QRect fillRect = pixmapRect.adjusted(1, 1, -1, -1); @@ -3183,7 +3166,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp QStyleOption arrowOpt = *option; arrowOpt.rect = scrollBarAddLine.adjusted(3, 3, -2, -2); - drawPrimitive(arrow, &arrowOpt, painter, widget); + proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget); } } } @@ -3198,7 +3181,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp bool isEnabled = (comboBox->state & State_Enabled); bool focus = isEnabled && (comboBox->state & State_HasFocus); QPixmap cache; - QString pixmapName = uniqueName(QLatin1String("combobox"), option, comboBox->rect.size()); + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("combobox"), option, comboBox->rect.size()); if (sunken) pixmapName += QLatin1String("-sunken"); if (comboBox->editable) @@ -3206,7 +3189,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (isEnabled) pixmapName += QLatin1String("-enabled"); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(comboBox->rect.size()); cache.fill(Qt::transparent); QPainter cachePainter(&cache); @@ -3215,9 +3198,9 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp comboBoxCopy.rect = pixmapRect; QRect rect = pixmapRect; - QRect downArrowRect = subControlRect(CC_ComboBox, &comboBoxCopy, + QRect downArrowRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxArrow, widget); - QRect editRect = subControlRect(CC_ComboBox, &comboBoxCopy, + QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget); // Draw a push button if (comboBox->editable) { @@ -3231,7 +3214,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp buttonOption.state &= ~State_MouseOver; } - drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget); //remove shadow from left side of edit field when pressed: if (comboBox->direction != Qt::RightToLeft) @@ -3273,7 +3256,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp buttonOption.state |= State_Sunken; buttonOption.state &= ~State_MouseOver; } - drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget); cachePainter.setPen(buttonShadow.darker(102)); int borderSize = 4; @@ -3326,15 +3309,15 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp } } // Draw the focus rect - if ((focus && (option->state & State_KeyboardFocusChange)) && !comboBox->editable) { + if (focus && !comboBox->editable + && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) { QStyleOptionFocusRect focus; - focus.rect = subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget) + focus.rect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget) .adjusted(0, 2, option->direction == Qt::RightToLeft ? 1 : -1, -2); - drawPrimitive(PE_FrameFocusRect, &focus, &cachePainter, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &focus, &cachePainter, widget); } cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(comboBox->rect.topLeft(), cache); } @@ -3345,8 +3328,8 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp case CC_GroupBox: painter->save(); if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { - QRect textRect = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); - QRect checkBoxRect = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget); + QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); + QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget); bool flat = groupBox->features & QStyleOptionFrameV2::Flat; if(!flat) { @@ -3356,7 +3339,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp frame.features = groupBox->features; frame.lineWidth = groupBox->lineWidth; frame.midLineWidth = groupBox->midLineWidth; - frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); + frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); painter->save(); QRegion region(groupBox->rect); @@ -3365,7 +3348,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp if (!groupBox->text.isEmpty() || groupBox->subControls & SC_GroupBoxCheckBox) painter->setClipRegion(region); frame.palette.setBrush(QPalette::Dark, option->palette.mid().color().lighter(110)); - drawPrimitive(PE_FrameGroupBox, &frame, painter); + proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter); painter->restore(); } } @@ -3393,7 +3376,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp QStyleOptionButton box; box.QStyleOption::operator=(*groupBox); box.rect = checkBoxRect; - drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); } } painter->restore(); @@ -3402,9 +3385,9 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp #ifndef QT_NO_SLIDER case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { - QRect groove = subControlRect(CC_Slider, option, SC_SliderGroove, widget); - QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget); - QRect ticks = subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); + QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); + QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); + QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); bool horizontal = slider->orientation == Qt::Horizontal; bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; @@ -3421,11 +3404,11 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp highlightAlpha.setAlpha(80); if ((option->subControls & SC_SliderGroove) && groove.isValid()) { - QString groovePixmapName = uniqueName(QLatin1String("slider_groove"), option, groove.size()); + QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_groove"), option, groove.size()); QRect pixmapRect(0, 0, groove.width(), groove.height()); // draw background groove - if (!UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) { + if (!QPixmapCache::find(groovePixmapName, cache)) { cache = QPixmap(pixmapRect.size()); cache.fill(Qt::transparent); QPainter groovePainter(&cache); @@ -3452,15 +3435,14 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp groovePainter.setBrush(gradient); groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2)); groovePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(groovePixmapName, cache); + QPixmapCache::insert(groovePixmapName, cache); } painter->drawPixmap(groove.topLeft(), cache); // draw blue groove highlight QRect clipRect; groovePixmapName += QLatin1String("_blue"); - if (!UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) { + if (!QPixmapCache::find(groovePixmapName, cache)) { cache = QPixmap(pixmapRect.size()); cache.fill(Qt::transparent); QPainter groovePainter(&cache); @@ -3479,8 +3461,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp groovePainter.setBrush(gradient); groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2)); groovePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(groovePixmapName, cache); + QPixmapCache::insert(groovePixmapName, cache); } if (horizontal) { if (slider->upsideDown) @@ -3501,8 +3482,8 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp // draw handle if ((option->subControls & SC_SliderHandle) ) { - QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size()); - if (!UsePixmapCache || !QPixmapCache::find(handlePixmapName, cache)) { + QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); + if (!QPixmapCache::find(handlePixmapName, cache)) { cache = QPixmap(handle.size()); cache.fill(Qt::transparent); QRect pixmapRect(0, 0, handle.width(), handle.height()); @@ -3583,8 +3564,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp } } handlePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(handlePixmapName, cache); + QPixmapCache::insert(handlePixmapName, cache); } painter->drawPixmap(handle.topLeft(), cache); @@ -3593,13 +3573,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*slider); fropt.rect = slider->rect; - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); } } if (option->subControls & SC_SliderTickmarks) { painter->setPen(darkOutline); - int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget); - int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget); + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); + int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); int interval = slider->tickInterval; if (interval <= 0) { interval = slider->singleStep; @@ -3613,7 +3593,7 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp interval = 1; int v = slider->minimum; - int len = pixelMetric(PM_SliderLength, slider, widget); + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); while (v <= slider->maximum + 1) { if (v == slider->maximum + 1 && interval == 1) break; @@ -3656,6 +3636,12 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp } break; #endif // QT_NO_SLIDER +#ifndef QT_NO_DIAL + case CC_Dial: + if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) + QStyleHelper::drawDial(dial, painter); + break; +#endif // QT_NO_DIAL default: QWindowsStyle::drawComplexControl(control, option, painter, widget); break; @@ -3781,6 +3767,20 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption * } break; case CT_GroupBox: + // Since we use a bold font we have to recalculate base width + if (const QGroupBox *gb = qobject_cast<const QGroupBox*>(widget)) { + QFont font = gb->font(); + font.setBold(true); + QFontMetrics metrics(font); + int baseWidth = metrics.width(gb->title()) + metrics.width(QLatin1Char(' ')); + if (gb->isCheckable()) { + baseWidth += proxy()->pixelMetric(QStyle::PM_IndicatorWidth, option, widget); + baseWidth += proxy()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, option, widget); + } + newSize.setWidth(qMax(baseWidth, newSize.width())); + } + newSize += QSize(0, 1); + break; case CT_RadioButton: case CT_CheckBox: newSize += QSize(0, 1); @@ -3857,7 +3857,7 @@ void QCleanlooksStyle::polish(QApplication *app) dataDirs = QLatin1String("/usr/local/share/:/usr/share/"); dataDirs.prepend(QDir::homePath() + QLatin1String("/:")); - d->iconDirs = dataDirs.split(QLatin1String(":")); + d->iconDirs = dataDirs.split(QLatin1Char(':')); #endif } @@ -3959,7 +3959,7 @@ QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptio #ifndef QT_NO_SLIDER case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { - int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget); + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); switch (subControl) { case SC_SliderHandle: { if (slider->orientation == Qt::Horizontal) { @@ -4014,7 +4014,7 @@ QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptio if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { QSize bs; int center = spinbox->rect.height() / 2; - int fw = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; + int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; int y = fw; bs.setHeight(qMax(8, spinbox->rect.height()/2 - y)); bs.setWidth(15); @@ -4055,7 +4055,7 @@ QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptio if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { int topMargin = 0; int topHeight = 0; - int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); + int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); bool flat = groupBox->features & QStyleOptionFrameV2::Flat; if (!groupBox->text.isEmpty()) { topHeight = groupBox->fontMetrics.height(); @@ -4086,8 +4086,8 @@ QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptio QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(2, 2); if (subControl == SC_GroupBoxCheckBox) { - int indicatorWidth = pixelMetric(PM_IndicatorWidth, option, widget); - int indicatorHeight = pixelMetric(PM_IndicatorHeight, option, widget); + int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); + int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); rect.setWidth(indicatorWidth); rect.setHeight(indicatorHeight); rect.moveTop((fontMetrics.height() - indicatorHeight) / 2 + 2); @@ -4108,7 +4108,7 @@ QRect QCleanlooksStyle::subControlRect(ComplexControl control, const QStyleOptio rect = visualRect(option->direction, option->rect, rect); break; case SC_ComboBoxEditField: { - int frameWidth = pixelMetric(PM_DefaultFrameWidth); + int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth); rect = visualRect(option->direction, option->rect, rect); rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth, option->rect.width() - 19 - 2 * frameWidth, @@ -4423,7 +4423,7 @@ QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon, { #ifdef Q_WS_X11 Q_D(const QCleanlooksStyle); - if (!qApp->desktopSettingsAware()) + if (!QApplication::desktopSettingsAware()) return QWindowsStyle::standardIconImplementation(standardIcon, option, widget); QIcon icon; QPixmap pixmap; @@ -4431,8 +4431,8 @@ QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon, d->lookupIconTheme(); switch (standardIcon) { case SP_DirIcon: { - icon = QIcon(standardPixmap(standardIcon, option, widget)); - icon.addPixmap(standardPixmap(SP_DirClosedIcon, option, widget), + icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget)); + icon.addPixmap(proxy()->standardPixmap(SP_DirClosedIcon, option, widget), QIcon::Normal, QIcon::Off); pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory.png")); if (!pixmap.isNull()) @@ -4450,10 +4450,10 @@ QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon, break; case SP_DirLinkIcon: { - icon = QIcon(standardPixmap(standardIcon, option, widget)); + icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget)); QPixmap link = d->findIcon(12, QLatin1String("emblem-symbolic-link.png")); if (!link.isNull()) { - icon.addPixmap(standardPixmap(SP_DirLinkIcon, option, widget)); + icon.addPixmap(proxy()->standardPixmap(SP_DirLinkIcon, option, widget)); pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory.png")); if (!pixmap.isNull()) { QPainter painter(&pixmap); @@ -4550,10 +4550,10 @@ QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon, } case SP_FileLinkIcon: { - icon = QIcon(standardPixmap(standardIcon, option, widget)); + icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget)); QPixmap link = d->findIcon(12, QLatin1String("emblem-symbolic-link.png")); if (!link.isNull()) { - icon.addPixmap(standardPixmap(SP_FileLinkIcon,option, widget)); + icon.addPixmap(proxy()->standardPixmap(SP_FileLinkIcon,option, widget)); pixmap = d->findIcon(16, QLatin1String("unknown.png")); if (pixmap.isNull()) pixmap = d->findIcon(16, QLatin1String("stock_new.png")); @@ -4575,7 +4575,7 @@ QIcon QCleanlooksStyle::standardIconImplementation(StandardPixmap standardIcon, return standardIconImplementation(SP_ArrowRight, option, widget); return standardIconImplementation(SP_ArrowLeft, option, widget); default: - icon = QIcon(standardPixmap(standardIcon, option, widget)); + icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget)); } if (!icon.isNull()) return icon; @@ -4592,7 +4592,7 @@ QPixmap QCleanlooksStyle::standardPixmap(StandardPixmap standardPixmap, const QS #ifdef Q_WS_X11 Q_D(const QCleanlooksStyle); QPixmap pixmap; - if (!qApp->desktopSettingsAware()) + if (!QApplication::desktopSettingsAware()) return QWindowsStyle::standardPixmap(standardPixmap, opt, widget); d->lookupIconTheme(); #ifndef QT_NO_IMAGEFORMAT_XPM diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 279cb40..ba28e75 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -66,6 +66,7 @@ #include <private/qapplication_p.h> #include <private/qcommonstylepixmaps_p.h> #include <private/qmath_p.h> +#include <private/qstylehelper_p.h> #include <qdebug.h> #include <qtextformat.h> #include <qwizard.h> @@ -83,6 +84,8 @@ #ifdef Q_WS_X11 # include <private/qt_x11_p.h> +#elif defined(Q_WS_MAC) +# include <private/qt_cocoa_helpers_mac_p.h> #endif QT_BEGIN_NAMESPACE @@ -154,7 +157,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q &opt->palette.brush(QPalette::Button)); break; case PE_IndicatorViewItemCheck: - drawPrimitive(PE_IndicatorCheckBox, opt, p, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, opt, p, widget); break; case PE_IndicatorCheckBox: if (opt->state & State_NoChange) { @@ -504,7 +507,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q QIcon::Active, QIcon::Off); } - int size = pixelMetric(QStyle::PM_SmallIconSize); + int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize); QIcon::Mode mode = opt->state & State_Enabled ? (opt->state & State_Raised ? QIcon::Active : QIcon::Normal) : QIcon::Disabled; @@ -515,7 +518,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q QIcon::State state = opt->state & State_Sunken ? QIcon::On : QIcon::Off; QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(size, mode, state); - drawItemPixmap(p, opt->rect, Qt::AlignCenter, pixmap); + proxy()->drawItemPixmap(p, opt->rect, Qt::AlignCenter, pixmap); break; } #endif // QT_NO_TABBAR @@ -524,7 +527,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q qDrawWinPanel(p, opt->rect, opt->palette, false, 0); break; case PE_FrameLineEdit: - drawPrimitive(PE_Frame, opt, p, widget); + proxy()->drawPrimitive(PE_Frame, opt, p, widget); break; #ifndef QT_NO_GROUPBOX case PE_FrameGroupBox: @@ -549,7 +552,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { int lw = frame->lineWidth; if (lw <= 0) - lw = pixelMetric(PM_DockWidgetFrameWidth); + lw = proxy()->pixelMetric(PM_DockWidgetFrameWidth); qDrawShadePanel(p, frame->rect, frame->palette, false, lw); } @@ -581,7 +584,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q p->restore(); break; case PE_Q3DockWindowSeparator: - drawPrimitive(PE_IndicatorToolBarSeparator, opt, p, widget); + proxy()->drawPrimitive(PE_IndicatorToolBarSeparator, opt, p, widget); break; case PE_IndicatorToolBarSeparator: { @@ -601,7 +604,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q case PE_IndicatorSpinPlus: case PE_IndicatorSpinMinus: { QRect r = opt->rect; - int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); + int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); QRect br = r.adjusted(fw, fw, -fw, -fw); int offset = (opt->state & State_Sunken) ? 1 : 0; @@ -618,7 +621,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q case PE_IndicatorSpinUp: case PE_IndicatorSpinDown: { QRect r = opt->rect; - int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); + int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); // QRect br = r.adjusted(fw, fw, -fw, -fw); int x = r.x(), y = r.y(), w = r.width(), h = r.height(); int sw = w-4; @@ -643,8 +646,8 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q int bsx = 0; int bsy = 0; if (opt->state & State_Sunken) { - bsx = pixelMetric(PM_ButtonShiftHorizontal); - bsy = pixelMetric(PM_ButtonShiftVertical); + bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); + bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); } p->save(); p->translate(sx + bsx, sy + bsy); @@ -693,7 +696,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q panel->palette.brush(QPalette::Base)); if (panel->lineWidth > 0) - drawPrimitive(PE_FrameLineEdit, panel, p, widget); + proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget); } break; #endif // QT_NO_LINEEDIT @@ -765,10 +768,12 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) cg = QPalette::Inactive; - if ((vopt->state & QStyle::State_Selected) && styleHint(QStyle::SH_ItemView_ShowDecorationSelected, opt, widget)) + if ((vopt->state & QStyle::State_Selected) && proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, opt, widget)) p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight)); else if (vopt->features & QStyleOptionViewItemV2::Alternate) p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); + else if (!(vopt->state & QStyle::State_Enabled)) + p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Base)); } break; case PE_PanelItemViewItem: @@ -837,6 +842,11 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut #ifdef Q_WS_X11 // These functions are used to parse the X11 freedesktop icon spec +static int kdeVersion() +{ + static int kdeVersion = qgetenv("KDE_SESSION_VERSION").toInt(); + return kdeVersion; +} void QCommonStylePrivate::lookupIconTheme() const { @@ -850,13 +860,12 @@ void QCommonStylePrivate::lookupIconTheme() const dataDirs.prepend(QDir::homePath() + QLatin1String("/:")); QStringList kdeDirs = QString::fromLocal8Bit(getenv("KDEDIRS")).split(QLatin1Char(':'), QString::SkipEmptyParts); foreach (const QString &dirName, kdeDirs) - dataDirs.append(QLatin1String(":") + dirName + QLatin1String("/share")); + dataDirs.append(QLatin1Char(':') + dirName + QLatin1String("/share")); iconDirs = dataDirs.split(QLatin1Char(':')); QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde")); QDir dir(fileInfo.canonicalFilePath()); - int kdeVersion = qgetenv("KDE_SESSION_VERSION").toInt(); - QString kdeDefault = kdeVersion >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg"); + QString kdeDefault = kdeVersion() >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg"); QString defaultTheme = fileInfo.exists() ? dir.dirName() : kdeDefault; QSettings settings(QApplicationPrivate::kdeHome() + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); @@ -892,7 +901,7 @@ QIconTheme QCommonStylePrivate::parseIndexFile(const QString &themeName) const parents = line.split(QLatin1Char(',')); } - if (line.startsWith(QLatin1String("["))) { + if (line.startsWith(QLatin1Char('['))) { line = line.trimmed(); line.chop(1); QString dirName = line.right(line.length() - 1); @@ -994,6 +1003,29 @@ QIcon QCommonStylePrivate::createIcon(const QString &name) const icon.addPixmap(findIcon(32, name)); return icon; } +/*!internal + +Checks if you are running KDE and looks up the toolbar +from the KDE configuration file + +*/ +int QCommonStylePrivate::lookupToolButtonStyle() const +{ + int result = Qt::ToolButtonIconOnly; + if (kdeVersion() >= 4) { + QSettings settings(QApplicationPrivate::kdeHome() + + QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat); + settings.beginGroup(QLatin1String("Toolbar style")); + QString toolbarStyle = settings.value(QLatin1String("ToolButtonStyle"), QLatin1String("TextBesideIcon")).toString(); + if (toolbarStyle == QLatin1String("TextBesideIcon")) + result = Qt::ToolButtonTextBesideIcon; + else if (toolbarStyle == QLatin1String("TextOnly")) + result = Qt::ToolButtonTextOnly; + else if (toolbarStyle == QLatin1String("TextUnderIcon")) + result = Qt::ToolButtonTextUnderIcon; + } + return result; +} #endif //Q_WS_X11 @@ -1152,8 +1184,14 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt } } -/* Set sizehint to false to layout the elements inside opt->rect. Set sizehint to true to ignore - opt->rect and return rectangles in infinite space */ +/*! \internal + compute the position for the different component of an item (pixmap, text, checkbox) + + Set sizehint to false to layout the elements inside opt->rect. Set sizehint to true to ignore + opt->rect and return rectangles in infinite space + + Code duplicated in QItemDelegate::doLayout +*/ void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItemV4 *opt, QRect *checkRect, QRect *pixmapRect, QRect *textRect, bool sizehint) const { @@ -1174,8 +1212,10 @@ void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItemV4 *opt, QRe int y = opt->rect.top(); int w, h; - if (textRect->height() == 0 && !hasPixmap) + if (textRect->height() == 0 && (!hasPixmap || !sizehint)) { + //if there is no text, we still want to have a decent height for the item sizeHint and the editor size textRect->setHeight(opt->fontMetrics.height()); + } QSize pm(0, 0); if (hasPixmap) { @@ -1290,24 +1330,24 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, case CE_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { - drawControl(CE_PushButtonBevel, btn, p, widget); + proxy()->drawControl(CE_PushButtonBevel, btn, p, widget); QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); - drawControl(CE_PushButtonLabel, &subopt, p, widget); + proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget); if (btn->state & State_HasFocus) { QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*btn); fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } } break; case CE_PushButtonBevel: if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { QRect br = btn->rect; - int dbi = pixelMetric(PM_ButtonDefaultIndicator, btn, widget); + int dbi = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); if (btn->features & QStyleOptionButton::DefaultButton) - drawPrimitive(PE_FrameDefaultButton, opt, p, widget); + proxy()->drawPrimitive(PE_FrameDefaultButton, opt, p, widget); if (btn->features & QStyleOptionButton::AutoDefaultButton) br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi); if (!(btn->features & (QStyleOptionButton::Flat | QStyleOptionButton::CommandLinkButton)) @@ -1315,14 +1355,14 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, || (btn->features & QStyleOptionButton::CommandLinkButton && btn->state & State_MouseOver)) { QStyleOptionButton tmpBtn = *btn; tmpBtn.rect = br; - drawPrimitive(PE_PanelButtonCommand, &tmpBtn, p, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &tmpBtn, p, widget); } if (btn->features & QStyleOptionButton::HasMenu) { - int mbi = pixelMetric(PM_MenuButtonIndicator, btn, widget); + int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget); QRect ir = btn->rect; QStyleOptionButton newBtn = *btn; newBtn.rect = QRect(ir.right() - mbi + 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); } } break; @@ -1330,7 +1370,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) { QRect textRect = button->rect; uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; - if (!styleHint(SH_UnderlineShortcut, button, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, button, widget)) tf |= Qt::TextHideMnemonic; if (!button->icon.isNull()) { @@ -1365,24 +1405,24 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing); if (button->state & (State_On | State_Sunken)) - iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, widget), - pixelMetric(PM_ButtonShiftVertical, opt, widget)); + iconRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget)); p->drawPixmap(iconRect, pixmap); } else { tf |= Qt::AlignHCenter; } if (button->state & (State_On | State_Sunken)) - textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, widget), - pixelMetric(PM_ButtonShiftVertical, opt, widget)); + textRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget)); if (button->features & QStyleOptionButton::HasMenu) { - int indicatorSize = pixelMetric(PM_MenuButtonIndicator, button, widget); + int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget); if (button->direction == Qt::LeftToRight) textRect = textRect.adjusted(0, 0, -indicatorSize, 0); else textRect = textRect.adjusted(indicatorSize, 0, 0, 0); } - drawItemText(p, textRect, tf, button->palette, (button->state & State_Enabled), + proxy()->drawItemText(p, textRect, tf, button->palette, (button->state & State_Enabled), button->text, QPalette::ButtonText); } break; @@ -1393,17 +1433,17 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator : SE_CheckBoxIndicator, btn, widget); - drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, + proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, &subopt, p, widget); subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents : SE_CheckBoxContents, btn, widget); - drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); + proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); if (btn->state & State_HasFocus) { QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*btn); fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect : SE_CheckBoxFocusRect, btn, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } } break; @@ -1412,20 +1452,20 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter); - if (!styleHint(SH_UnderlineShortcut, btn, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, btn, widget)) alignment |= Qt::TextHideMnemonic; QPixmap pix; QRect textRect = btn->rect; if (!btn->icon.isNull()) { pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled); - drawItemPixmap(p, btn->rect, alignment, pix); + proxy()->drawItemPixmap(p, btn->rect, alignment, pix); if (btn->direction == Qt::RightToLeft) textRect.setRight(textRect.right() - btn->iconSize.width() - 4); else textRect.setLeft(textRect.left() + btn->iconSize.width() + 4); } if (!btn->text.isEmpty()){ - drawItemText(p, textRect, alignment | Qt::TextShowMnemonic, + proxy()->drawItemText(p, textRect, alignment | Qt::TextShowMnemonic, btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText); } } @@ -1435,7 +1475,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->fillRect(opt->rect, opt->palette.background()); QStyleOption arrowOpt = *opt; arrowOpt.state |= State_Enabled; - drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp), + proxy()->drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp), &arrowOpt, p, widget); break; } case CE_MenuTearoff: @@ -1457,13 +1497,13 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!styleHint(SH_UnderlineShortcut, mbi, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; - QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); + QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); if (!pix.isNull()) - drawItemPixmap(p,mbi->rect, alignment, pix); + proxy()->drawItemPixmap(p,mbi->rect, alignment, pix); else - drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, + proxy()->drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, QPalette::ButtonText); } break; @@ -1478,12 +1518,12 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { QStyleOptionProgressBarV2 subopt = *pb; subopt.rect = subElementRect(SE_ProgressBarGroove, pb, widget); - drawControl(CE_ProgressBarGroove, &subopt, p, widget); + proxy()->drawControl(CE_ProgressBarGroove, &subopt, p, widget); subopt.rect = subElementRect(SE_ProgressBarContents, pb, widget); - drawControl(CE_ProgressBarContents, &subopt, p, widget); + proxy()->drawControl(CE_ProgressBarContents, &subopt, p, widget); if (pb->textVisible) { subopt.rect = subElementRect(SE_ProgressBarLabel, pb, widget); - drawControl(CE_ProgressBarLabel, &subopt, p, widget); + proxy()->drawControl(CE_ProgressBarLabel, &subopt, p, widget); } } break; @@ -1509,10 +1549,10 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, ? QColor(255,255,255,160) : QColor(0,0,0,160); QPalette shadowPalette = pb->palette; shadowPalette.setColor(textRole, shadowColor); - drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette, + proxy()->drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette, pb->state & State_Enabled, pb->text, textRole); } - drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette, + proxy()->drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette, pb->state & State_Enabled, pb->text, textRole); } } @@ -1559,7 +1599,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->setPen(QPen(pal2.highlight().color(), 4)); p->drawLine(x, rect.y(), x, rect.height()); } else { - const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, pb, widget); + const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget); if (!unit_width) return; @@ -1601,7 +1641,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, for (int i = 0; i < nu; ++i) { pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight); pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); - drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); + proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); x += reverse ? -unit_width : unit_width; } @@ -1612,7 +1652,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, int offset = reverse ? x0 + x + unit_width-pixels_left : x0 + x; pbBits.rect.setRect(offset, myY, pixels_left, myHeight); pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); - drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); + proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); } } } @@ -1623,7 +1663,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, QRect rect = header->rect; if (!header->icon.isNull()) { QPixmap pixmap - = header->icon.pixmap(pixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); + = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); int pixw = pixmap.width(); QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size(), rect); @@ -1640,7 +1680,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, fnt.setBold(true); p->setFont(fnt); } - drawItemText(p, rect, header->textAlignment, header->palette, + proxy()->drawItemText(p, rect, header->textAlignment, header->palette, (header->state & State_Enabled), header->text, QPalette::ButtonText); } break; @@ -1652,18 +1692,19 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, int shiftX = 0; int shiftY = 0; if (toolbutton->state & (State_Sunken | State_On)) { - shiftX = pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget); - shiftY = pixelMetric(PM_ButtonShiftVertical, toolbutton, widget); + shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget); + shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton, widget); } // Arrow type always overrules and is always shown bool hasArrow = toolbutton->features & QStyleOptionToolButton::Arrow; if (((!hasArrow && toolbutton->icon.isNull()) && !toolbutton->text.isEmpty()) || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) { int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; - if (!styleHint(SH_UnderlineShortcut, opt, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) alignment |= Qt::TextHideMnemonic; rect.translate(shiftX, shiftY); - drawItemText(p, rect, alignment, toolbutton->palette, + p->setFont(toolbutton->font); + proxy()->drawItemText(p, rect, alignment, toolbutton->palette, opt->state & State_Enabled, toolbutton->text, QPalette::ButtonText); } else { @@ -1688,7 +1729,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, QRect pr = rect, tr = rect; int alignment = Qt::TextShowMnemonic; - if (!styleHint(SH_UnderlineShortcut, opt, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) alignment |= Qt::TextHideMnemonic; if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { @@ -1696,7 +1737,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, tr.adjust(0, pr.height() - 1, 0, -3); pr.translate(shiftX, shiftY); if (!hasArrow) { - drawItemPixmap(p, pr, Qt::AlignCenter, pm); + proxy()->drawItemPixmap(p, pr, Qt::AlignCenter, pm); } else { drawArrow(this, toolbutton, pr, p, widget); } @@ -1706,14 +1747,14 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, tr.adjust(pr.width(), 0, 0, 0); pr.translate(shiftX, shiftY); if (!hasArrow) { - drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignCenter, pm); + proxy()->drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignCenter, pm); } else { drawArrow(this, toolbutton, pr, p, widget); } alignment |= Qt::AlignLeft | Qt::AlignVCenter; } tr.translate(shiftX, shiftY); - drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette, + proxy()->drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette, toolbutton->state & State_Enabled, toolbutton->text, QPalette::ButtonText); } else { @@ -1721,7 +1762,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (hasArrow) { drawArrow(this, toolbutton, rect, p, widget); } else { - drawItemPixmap(p, rect, Qt::AlignCenter, pm); + proxy()->drawItemPixmap(p, rect, Qt::AlignCenter, pm); } } } @@ -1731,8 +1772,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, #ifndef QT_NO_TOOLBOX case CE_ToolBoxTab: if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) { - drawControl(CE_ToolBoxTabShape, tb, p, widget); - drawControl(CE_ToolBoxTabLabel, tb, p, widget); + proxy()->drawControl(CE_ToolBoxTabShape, tb, p, widget); + proxy()->drawControl(CE_ToolBoxTabLabel, tb, p, widget); } break; case CE_ToolBoxTabShape: @@ -1778,8 +1819,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, #ifndef QT_NO_TABBAR case CE_TabBarTab: if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { - drawControl(CE_TabBarTabShape, tab, p, widget); - drawControl(CE_TabBarTabLabel, tab, p, widget); + proxy()->drawControl(CE_TabBarTabShape, tab, p, widget); + proxy()->drawControl(CE_TabBarTabLabel, tab, p, widget); } break; case CE_TabBarTabShape: @@ -1789,7 +1830,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, QRect rect(tab->rect); bool selected = tab->state & State_Selected; bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; - int tabOverlap = onlyOne ? 0 : pixelMetric(PM_TabBarTabOverlap, opt, widget); + int tabOverlap = onlyOne ? 0 : proxy()->pixelMetric(PM_TabBarTabOverlap, opt, widget); if (!selected) { switch (tab->shape) { @@ -1893,7 +1934,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) { bool enabled = tb->state & State_Enabled; bool selected = tb->state & State_Selected; - QPixmap pm = tb->icon.pixmap(pixelMetric(QStyle::PM_SmallIconSize, tb, widget), + QPixmap pm = tb->icon.pixmap(proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget), enabled ? QIcon::Normal : QIcon::Disabled); QRect cr = subElementRect(QStyle::SE_ToolBoxTabContents, tb, widget); @@ -1909,7 +1950,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, tr = QRect(ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height()); } - if (selected && styleHint(QStyle::SH_ToolBox_SelectedPageTitleBold, tb, widget)) { + if (selected && proxy()->styleHint(QStyle::SH_ToolBox_SelectedPageTitleBold, tb, widget)) { QFont f(p->font()); f.setBold(true); p->setFont(f); @@ -1921,16 +1962,16 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->drawPixmap(ir.left(), (tb->rect.height() - ih) / 2, pm); int alignment = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic; - if (!styleHint(QStyle::SH_UnderlineShortcut, tb, widget)) + if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, tb, widget)) alignment |= Qt::TextHideMnemonic; - drawItemText(p, tr, alignment, tb->palette, enabled, txt, QPalette::ButtonText); + proxy()->drawItemText(p, tr, alignment, tb->palette, enabled, txt, QPalette::ButtonText); if (!txt.isEmpty() && opt->state & State_HasFocus) { QStyleOptionFocusRect opt; opt.rect = tr; opt.palette = tb->palette; opt.state = QStyle::State_None; - drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, widget); + proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, widget); } } break; @@ -1945,7 +1986,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, || tabV2.shape == QTabBar::TriangularWest; int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; - if (!styleHint(SH_UnderlineShortcut, opt, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) alignment |= Qt::TextHideMnemonic; if (verticalTabs) { @@ -1961,8 +2002,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, newRot = -90; } tr.setRect(0, 0, tr.height(), tr.width()); - QTransform m; - m.translate(newX, newY); + QTransform m = QTransform::fromTranslate(newX, newY); m.rotate(newRot); p->setTransform(m, true); } @@ -1971,7 +2011,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (!tabV2.icon.isNull()) { QSize iconSize = tabV2.iconSize; if (!iconSize.isValid()) { - int iconExtent = pixelMetric(PM_SmallIconSize); + int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); iconSize = QSize(iconExtent, iconExtent); } QSize tabIconSize = tabV2.icon.actualSize(iconSize, @@ -1979,7 +2019,9 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, : QIcon::Disabled); QPixmap tabIcon = tabV2.icon.pixmap(iconSize, (tabV2.state & State_Enabled) ? QIcon::Normal - : QIcon::Disabled); + : QIcon::Disabled, + (tabV2.state & State_Selected) ? QIcon::On + : QIcon::Off); int offset = 4; int left = opt->rect.left(); @@ -1994,7 +2036,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon); } - drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); + proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); if (verticalTabs) p->restore(); @@ -2105,7 +2147,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->save(); QRect r = opt->rect; QStyleHintReturnMask mask; - if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) + if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) p->setClipRegion(mask.region); p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap); p->setPen(opt->palette.color(QPalette::Active, QPalette::WindowText)); @@ -2143,7 +2185,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } const int indent = p->fontMetrics().descent(); - drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1), + proxy()->drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, dwOpt->state & State_Enabled, dwOpt->title, QPalette::WindowText); @@ -2158,14 +2200,14 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { QRegion clipRegion = p->clipRegion(); p->setClipRect(opt->rect); - drawControl(CE_HeaderSection, header, p, widget); + proxy()->drawControl(CE_HeaderSection, header, p, widget); QStyleOptionHeader subopt = *header; subopt.rect = subElementRect(SE_HeaderLabel, header, widget); if (subopt.rect.isValid()) - drawControl(CE_HeaderLabel, &subopt, p, widget); + proxy()->drawControl(CE_HeaderLabel, &subopt, p, widget); if (header->sortIndicator != QStyleOptionHeader::None) { subopt.rect = subElementRect(SE_HeaderArrow, opt, widget); - drawPrimitive(PE_IndicatorHeaderArrow, &subopt, p, widget); + proxy()->drawPrimitive(PE_IndicatorHeaderArrow, &subopt, p, widget); } p->setClipRegion(clipRegion); } @@ -2184,7 +2226,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, #ifndef QT_NO_COMBOBOX case CE_ComboBoxLabel: if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { - QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); + QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); p->save(); p->setClipRect(editRect); if (!cb->currentIcon.isNull()) { @@ -2198,7 +2240,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, iconRect.size(), editRect); if (cb->editable) p->fillRect(iconRect, opt->palette.brush(QPalette::Base)); - drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap); + proxy()->drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap); if (cb->direction == Qt::RightToLeft) editRect.translate(-4 - cb->iconSize.width(), 0); @@ -2206,7 +2248,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, editRect.translate(cb->iconSize.width() + 4, 0); } if (!cb->currentText.isEmpty() && !cb->editable) { - drawItemText(p, editRect.adjusted(1, 0, -1, 0), + proxy()->drawItemText(p, editRect.adjusted(1, 0, -1, 0), visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter), cb->palette, cb->state & State_Enabled, cb->currentText); } @@ -2222,7 +2264,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, frame.QStyleOption::operator=(*toolBar); frame.lineWidth = toolBar->lineWidth; frame.midLineWidth = toolBar->midLineWidth; - drawPrimitive(PE_PanelToolBar, opt, p, widget); + proxy()->drawPrimitive(PE_PanelToolBar, opt, p, widget); if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) break; @@ -2264,10 +2306,10 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, QRect textRect = subElementRect(SE_ItemViewItemText, vopt, widget); // draw the background - drawPrimitive(PE_PanelItemViewItem, opt, p, widget); + proxy()->drawPrimitive(PE_PanelItemViewItem, opt, p, widget); // draw the check mark - if (checkRect.isValid()) { + if (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) { QStyleOptionViewItemV4 option(*vopt); option.rect = checkRect; option.state = option.state & ~QStyle::State_HasFocus; @@ -2283,7 +2325,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, option.state |= QStyle::State_On; break; } - drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, p, widget); + proxy()->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, p, widget); } // draw the icon @@ -2326,7 +2368,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, ? QPalette::Normal : QPalette::Disabled; o.backgroundColor = vopt->palette.color(cg, (vopt->state & QStyle::State_Selected) ? QPalette::Highlight : QPalette::Window); - drawPrimitive(QStyle::PE_FrameFocusRect, &o, p, widget); + proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, p, widget); } p->restore(); @@ -2365,7 +2407,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (widget) { widget->style()->drawPrimitive(QStyle::PE_Frame, opt, p, widget); } else { - drawPrimitive(QStyle::PE_Frame, opt, p, widget); + proxy()->drawPrimitive(QStyle::PE_Frame, opt, p, widget); } break; case QFrame::Panel: @@ -2423,9 +2465,9 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, case SE_PushButtonContents: if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { int dx1, dx2; - dx1 = pixelMetric(PM_DefaultFrameWidth, btn, widget); + dx1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); if (btn->features & QStyleOptionButton::AutoDefaultButton) - dx1 += pixelMetric(PM_ButtonDefaultIndicator, btn, widget); + dx1 += proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); dx2 = dx1 * 2; r.setRect(opt->rect.x() + dx1, opt->rect.y() + dx1, opt->rect.width() - dx2, opt->rect.height() - dx2); @@ -2436,11 +2478,11 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { int dbw1 = 0, dbw2 = 0; if (btn->features & QStyleOptionButton::AutoDefaultButton){ - dbw1 = pixelMetric(PM_ButtonDefaultIndicator, btn, widget); + dbw1 = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); dbw2 = dbw1 * 2; } - int dfw1 = pixelMetric(PM_DefaultFrameWidth, btn, widget) + 1, + int dfw1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) + 1, dfw2 = dfw1 * 2; r.setRect(btn->rect.x() + dfw1 + dbw1, btn->rect.y() + dfw1 + dbw1, @@ -2450,9 +2492,9 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, break; case SE_CheckBoxIndicator: { - int h = pixelMetric(PM_IndicatorHeight, opt, widget); + int h = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2), - pixelMetric(PM_IndicatorWidth, opt, widget), h); + proxy()->pixelMetric(PM_IndicatorWidth, opt, widget), h); r = visualRect(opt->direction, opt->rect, r); } break; @@ -2462,7 +2504,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, // Deal with the logical first, then convert it back to screen coords. QRect ir = visualRect(opt->direction, opt->rect, subElementRect(SE_CheckBoxIndicator, opt, widget)); - int spacing = pixelMetric(PM_CheckBoxLabelSpacing, opt, widget); + int spacing = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget); r.setRect(ir.right() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing, opt->rect.height()); r = visualRect(opt->direction, opt->rect, r); @@ -2502,9 +2544,9 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, case SE_RadioButtonIndicator: { - int h = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); + int h = proxy()->pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2), - pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), h); + proxy()->pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), h); r = visualRect(opt->direction, opt->rect, r); } break; @@ -2513,7 +2555,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, { QRect ir = visualRect(opt->direction, opt->rect, subElementRect(SE_RadioButtonIndicator, opt, widget)); - int spacing = pixelMetric(PM_RadioButtonLabelSpacing, opt, widget); + int spacing = proxy()->pixelMetric(PM_RadioButtonLabelSpacing, opt, widget); r.setRect(ir.left() + ir.width() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing, opt->rect.height()); r = visualRect(opt->direction, opt->rect, r); @@ -2550,8 +2592,8 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, #ifndef QT_NO_SLIDER case SE_SliderFocusRect: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { - int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget); - int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); + int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); + int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); if (slider->orientation == Qt::Horizontal) r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2); else @@ -2622,7 +2664,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, break; #endif // QT_NO_TOOLBOX case SE_HeaderLabel: { - int margin = pixelMetric(QStyle::PM_HeaderMargin, opt, widget); + int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget); r.setRect(opt->rect.x() + margin, opt->rect.y() + margin, opt->rect.width() - margin * 2, opt->rect.height() - margin * 2); @@ -2642,7 +2684,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, int w = opt->rect.width(); int x = opt->rect.x(); int y = opt->rect.y(); - int margin = pixelMetric(QStyle::PM_HeaderMargin, opt, widget); + int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget); if (opt->state & State_Horizontal) { int horiz_size = h / 2; @@ -2678,7 +2720,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r.setWidth(qMin(r.width(), twf->rect.width() - twf->leftCornerWidgetSize.width() - twf->rightCornerWidgetSize.width())); - switch (styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { + switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { default: case Qt::AlignLeft: r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), 0)); @@ -2700,7 +2742,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r.setWidth(qMin(r.width(), twf->rect.width() - twf->leftCornerWidgetSize.width() - twf->rightCornerWidgetSize.width())); - switch (styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { + switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { default: case Qt::AlignLeft: r.moveTopLeft(QPoint(twf->leftCornerWidgetSize.width(), @@ -2725,7 +2767,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r.setHeight(qMin(r.height(), twf->rect.height() - twf->leftCornerWidgetSize.height() - twf->rightCornerWidgetSize.height())); - switch (styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { + switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { default: case Qt::AlignLeft: r.moveTopLeft(QPoint(twf->rect.width() - twf->tabBarSize.width(), @@ -2747,7 +2789,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r.setHeight(qMin(r.height(), twf->rect.height() - twf->leftCornerWidgetSize.height() - twf->rightCornerWidgetSize.height())); - switch (styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { + switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { default: case Qt::AlignLeft: r.moveTopLeft(QPoint(0, twf->leftCornerWidgetSize.height())); @@ -2769,7 +2811,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { QStyleOptionTab tabopt; tabopt.shape = twf->shape; - int overlap = pixelMetric(PM_TabBarBaseOverlap, &tabopt, widget); + int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &tabopt, widget); if (twf->lineWidth == 0) overlap = 0; switch (twf->shape) { @@ -2849,9 +2891,11 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, tr.setRect(0, 0, tr.height(), tr.width()); int verticalShift = pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); int horizontalShift = pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); + int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2; + int vpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabVSpace, opt, widget) / 2; if (tabV2.shape == QTabBar::RoundedSouth || tabV2.shape == QTabBar::TriangularSouth) verticalShift = -verticalShift; - tr.adjust(0, 0, horizontalShift, verticalShift); + tr.adjust(hpadding, vpadding, horizontalShift - hpadding, verticalShift - vpadding); bool selected = tabV2.state & State_Selected; if (selected) { tr.setBottom(tr.bottom() - verticalShift); @@ -2868,7 +2912,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, if (!tabV2.icon.isNull()) { QSize iconSize = tabV2.iconSize; if (!iconSize.isValid()) { - int iconExtent = pixelMetric(PM_SmallIconSize); + int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); iconSize = QSize(iconExtent, iconExtent); } QSize tabIconSize = tabV2.icon.actualSize(iconSize, @@ -2900,8 +2944,8 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, case SE_TabBarTabRightButton: if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) { bool selected = tab->state & State_Selected; - int verticalShift = pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); - int horizontalShift = pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); + int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); + int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); bool verticalTabs = tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::RoundedWest @@ -2916,6 +2960,9 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, horizontalShift *= -1; verticalShift *= -1; } + if (tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularWest) + horizontalShift = -horizontalShift; + tr.adjust(0, 0, horizontalShift, verticalShift); if (selected) { @@ -2990,7 +3037,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, break; case SE_FrameContents: if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) { - int fw = pixelMetric(PM_DefaultFrameWidth, f, widget); + int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, f, widget); r = opt->rect.adjusted(fw, fw, -fw, -fw); r = visualRect(opt->direction, opt->rect, r); } @@ -3057,9 +3104,9 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, case SE_DockWidgetFloatButton: case SE_DockWidgetTitleBarText: case SE_DockWidgetIcon: { - int iconSize = pixelMetric(PM_SmallIconSize, opt, widget); - int buttonMargin = pixelMetric(PM_DockWidgetTitleBarButtonMargin, opt, widget); - int margin = pixelMetric(QStyle::PM_DockWidgetTitleMargin, opt, widget); + int iconSize = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); + int buttonMargin = proxy()->pixelMetric(PM_DockWidgetTitleBarButtonMargin, opt, widget); + int margin = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, opt, widget); QRect rect = opt->rect; const QStyleOptionDockWidget *dwOpt @@ -3124,7 +3171,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, if (dw->isFloating()) icon = dw->windowIcon(); if (!icon.isNull() - && icon.cacheKey() != qApp->windowIcon().cacheKey()) { + && icon.cacheKey() != QApplication::windowIcon().cacheKey()) { QSize sz = icon.actualSize(QSize(r.height(), r.height())); if (verticalTitleBar) sz.transpose(); @@ -3182,6 +3229,25 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, } break; #endif //QT_NO_ITEMVIEWS +#ifndef QT_NO_TOOLBAR + case SE_ToolBarHandle: + if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) { + if (tbopt->features & QStyleOptionToolBar::Movable) { + ///we need to access the widget here because the style option doesn't + //have all the information we need (ie. the layout's margin) + const QToolBar *tb = qobject_cast<const QToolBar*>(widget); + const int margin = tb && tb->layout() ? tb->layout()->margin() : 2; + const int handleExtent = pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb); + if (tbopt->state & QStyle::State_Horizontal) { + r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin); + r = QStyle::visualRect(tbopt->direction, tbopt->rect, r); + } else { + r = QRect(margin, margin, tbopt->rect.width() - 2*margin, handleExtent); + } + } + } + break; +#endif //QT_NO_TOOLBAR default: break; } @@ -3189,47 +3255,6 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, } #ifndef QT_NO_DIAL -static qreal angle(const QPointF &p1, const QPointF &p2) -{ - static const qreal rad_factor = 180 / Q_PI; - qreal _angle = 0; - - if (p1.x() == p2.x()) { - if (p1.y() < p2.y()) - _angle = 270; - else - _angle = 90; - } else { - qreal x1, x2, y1, y2; - - if (p1.x() <= p2.x()) { - x1 = p1.x(); y1 = p1.y(); - x2 = p2.x(); y2 = p2.y(); - } else { - x2 = p1.x(); y2 = p1.y(); - x1 = p2.x(); y1 = p2.y(); - } - - qreal m = -(y2 - y1) / (x2 - x1); - _angle = atan(m) * rad_factor; - - if (p1.x() < p2.x()) - _angle = 180 - _angle; - else - _angle = -_angle; - } - return _angle; -} - -static int calcBigLineSize(int radius) -{ - int bigLineSize = radius / 6; - if (bigLineSize < 4) - bigLineSize = 4; - if (bigLineSize > radius / 2) - bigLineSize = radius / 2; - return bigLineSize; -} static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a) { @@ -3250,7 +3275,7 @@ static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a) int xc = width / 2; int yc = height / 2; - int len = r - calcBigLineSize(r) - 5; + int len = r - QStyleHelper::calcBigLineSize(r) - 5; if (len < 5) len = 5; int back = len / 2; @@ -3265,45 +3290,6 @@ static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a) return arrow; } -static QPolygonF calcLines(const QStyleOptionSlider *dial, const QWidget *) -{ - QPolygonF poly; - int width = dial->rect.width(); - int height = dial->rect.height(); - qreal r = qMin(width, height) / 2; - int bigLineSize = calcBigLineSize(int(r)); - - qreal xc = width / 2; - qreal yc = height / 2; - int ns = dial->tickInterval; - int notches = (dial->maximum + ns - 1 - dial->minimum) / ns; - if (notches <= 0) - return poly; - if (dial->maximum < dial->minimum - || dial->maximum - dial->minimum > 1000) { - int maximum = dial->minimum + 1000; - notches = (maximum + ns - 1 - dial->minimum) / ns; - } - - poly.resize(2 + 2 * notches); - int smallLineSize = bigLineSize / 2; - for (int i = 0; i <= notches; ++i) { - qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches - : (Q_PI * 8 - i * 10 * Q_PI / notches) / 6; - qreal s = qSin(angle); - qreal c = qCos(angle); - if (i == 0 || (((ns * i) % (dial->pageStep ? dial->pageStep : 1)) == 0)) { - poly[2 * i] = QPointF(xc + (r - bigLineSize) * c, - yc - (r - bigLineSize) * s); - poly[2 * i + 1] = QPointF(xc + r * c, yc - r * s); - } else { - poly[2 * i] = QPointF(xc + (r - 1 - smallLineSize) * c, - yc - (r - 1 - smallLineSize) * s); - poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s); - } - } - return poly; -} #endif // QT_NO_DIAL /*! @@ -3317,11 +3303,11 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { if (slider->subControls == SC_SliderTickmarks) { - int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget); + int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); int ticks = slider->tickPosition; - int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); - int len = pixelMetric(PM_SliderLength, slider, widget); - int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget); + int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); + int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); int interval = slider->tickInterval; if (interval <= 0) { interval = slider->singleStep; @@ -3379,71 +3365,71 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl if (scrollbar->subControls & SC_ScrollBarSubLine) { newScrollbar.state = saveFlags; - newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget); + newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget); if (newScrollbar.rect.isValid()) { if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine)) newScrollbar.state &= ~(State_Sunken | State_MouseOver); - drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget); + proxy()->drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget); } } if (scrollbar->subControls & SC_ScrollBarAddLine) { newScrollbar.rect = scrollbar->rect; newScrollbar.state = saveFlags; - newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget); + newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget); if (newScrollbar.rect.isValid()) { if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine)) newScrollbar.state &= ~(State_Sunken | State_MouseOver); - drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget); + proxy()->drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget); } } if (scrollbar->subControls & SC_ScrollBarSubPage) { newScrollbar.rect = scrollbar->rect; newScrollbar.state = saveFlags; - newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget); + newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget); if (newScrollbar.rect.isValid()) { if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage)) newScrollbar.state &= ~(State_Sunken | State_MouseOver); - drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget); + proxy()->drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget); } } if (scrollbar->subControls & SC_ScrollBarAddPage) { newScrollbar.rect = scrollbar->rect; newScrollbar.state = saveFlags; - newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget); + newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget); if (newScrollbar.rect.isValid()) { if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage)) newScrollbar.state &= ~(State_Sunken | State_MouseOver); - drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget); + proxy()->drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget); } } if (scrollbar->subControls & SC_ScrollBarFirst) { newScrollbar.rect = scrollbar->rect; newScrollbar.state = saveFlags; - newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget); + newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget); if (newScrollbar.rect.isValid()) { if (!(scrollbar->activeSubControls & SC_ScrollBarFirst)) newScrollbar.state &= ~(State_Sunken | State_MouseOver); - drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget); + proxy()->drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget); } } if (scrollbar->subControls & SC_ScrollBarLast) { newScrollbar.rect = scrollbar->rect; newScrollbar.state = saveFlags; - newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget); + newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget); if (newScrollbar.rect.isValid()) { if (!(scrollbar->activeSubControls & SC_ScrollBarLast)) newScrollbar.state &= ~(State_Sunken | State_MouseOver); - drawControl(CE_ScrollBarLast, &newScrollbar, p, widget); + proxy()->drawControl(CE_ScrollBarLast, &newScrollbar, p, widget); } } if (scrollbar->subControls & SC_ScrollBarSlider) { newScrollbar.rect = scrollbar->rect; newScrollbar.state = saveFlags; - newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget); + newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget); if (newScrollbar.rect.isValid()) { if (!(scrollbar->activeSubControls & SC_ScrollBarSlider)) newScrollbar.state &= ~(State_Sunken | State_MouseOver); - drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget); + proxy()->drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget); if (scrollbar->state & State_HasFocus) { QStyleOptionFocusRect fropt; @@ -3451,7 +3437,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl fropt.rect.setRect(newScrollbar.rect.x() + 2, newScrollbar.rect.y() + 2, newScrollbar.rect.width() - 5, newScrollbar.rect.height() - 5); - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } } } @@ -3473,7 +3459,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl PrimitiveElement pe; if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { - QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); + QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); qDrawWinPanel(p, r, sb->palette, true); } @@ -3497,10 +3483,10 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus : PE_IndicatorSpinUp); - copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); - drawPrimitive(PE_PanelButtonBevel, ©, p, widget); + copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); + proxy()->drawPrimitive(PE_PanelButtonBevel, ©, p, widget); copy.rect.adjust(3, 0, -4, 0); - drawPrimitive(pe, ©, p, widget); + proxy()->drawPrimitive(pe, ©, p, widget); } if (sb->subControls & SC_SpinBoxDown) { @@ -3523,10 +3509,10 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus : PE_IndicatorSpinDown); - copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); - drawPrimitive(PE_PanelButtonBevel, ©, p, widget); + copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); + proxy()->drawPrimitive(PE_PanelButtonBevel, ©, p, widget); copy.rect.adjust(3, 0, -4, 0); - drawPrimitive(pe, ©, p, widget); + proxy()->drawPrimitive(pe, ©, p, widget); } } break; @@ -3536,8 +3522,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { QRect button, menuarea; - button = subControlRect(cc, toolbutton, SC_ToolButton, widget); - menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); + button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget); + menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); State bflags = toolbutton->state & ~State_Sunken; @@ -3559,7 +3545,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl if (bflags & (State_Sunken | State_On | State_Raised)) { tool.rect = button; tool.state = bflags; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); } } @@ -3568,28 +3554,28 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl fr.QStyleOption::operator=(*toolbutton); fr.rect.adjust(3, 3, -3, -3); if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) - fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator, + fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, toolbutton, widget), 0); - drawPrimitive(PE_FrameFocusRect, &fr, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget); } QStyleOptionToolButton label = *toolbutton; label.state = bflags; - int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); + int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); label.rect = button.adjusted(fw, fw, -fw, -fw); - drawControl(CE_ToolButtonLabel, &label, p, widget); + proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); if (toolbutton->subControls & SC_ToolButtonMenu) { tool.rect = menuarea; tool.state = mflags; if (mflags & (State_Sunken | State_On | State_Raised)) - drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); - drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); + proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { - int mbi = pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); + int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); QRect ir = toolbutton->rect; QStyleOptionToolButton newBtn = *toolbutton; newBtn.rect = QRect(ir.right() + 5 - mbi, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); } } break; @@ -3613,7 +3599,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl p->fillRect(opt->rect, fillBrush); - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget); p->setPen(tb->palette.highlightedText().color()); p->drawText(ir.x() + 2, ir.y(), ir.width() - 2, ir.height(), @@ -3626,7 +3612,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl QStyleOption tool(0); tool.palette = tb->palette; if (tb->subControls & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) { - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarCloseButton, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarCloseButton, widget); down = tb->activeSubControls & SC_TitleBarCloseButton && (opt->state & State_Sunken); if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool #ifndef QT_NO_DOCKWIDGET @@ -3638,50 +3624,50 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl pm = standardIcon(SP_TitleBarCloseButton, &tool, widget).pixmap(10, 10); tool.rect = ir; tool.state = down ? State_Sunken : State_Raised; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); p->save(); if (down) - p->translate(pixelMetric(PM_ButtonShiftHorizontal, tb, widget), - pixelMetric(PM_ButtonShiftVertical, tb, widget)); - drawItemPixmap(p, ir, Qt::AlignCenter, pm); + p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); + proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); p->restore(); } if (tb->subControls & SC_TitleBarMaxButton && tb->titleBarFlags & Qt::WindowMaximizeButtonHint && !(tb->titleBarState & Qt::WindowMaximized)) { - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton, widget); down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken); pm = standardIcon(SP_TitleBarMaxButton, &tool, widget).pixmap(10, 10); tool.rect = ir; tool.state = down ? State_Sunken : State_Raised; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); p->save(); if (down) - p->translate(pixelMetric(PM_ButtonShiftHorizontal, tb, widget), - pixelMetric(PM_ButtonShiftVertical, tb, widget)); - drawItemPixmap(p, ir, Qt::AlignCenter, pm); + p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); + proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); p->restore(); } if (tb->subControls & SC_TitleBarMinButton && tb->titleBarFlags & Qt::WindowMinimizeButtonHint && !(tb->titleBarState & Qt::WindowMinimized)) { - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton, widget); down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken); pm = standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(10, 10); tool.rect = ir; tool.state = down ? State_Sunken : State_Raised; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); p->save(); if (down) - p->translate(pixelMetric(PM_ButtonShiftHorizontal, tb, widget), - pixelMetric(PM_ButtonShiftVertical, tb, widget)); - drawItemPixmap(p, ir, Qt::AlignCenter, pm); + p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); + proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); p->restore(); } @@ -3692,81 +3678,81 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl && (tb->titleBarState & Qt::WindowMaximized))); if (drawNormalButton) { - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton, widget); down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken); pm = standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(10, 10); tool.rect = ir; tool.state = down ? State_Sunken : State_Raised; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); p->save(); if (down) - p->translate(pixelMetric(PM_ButtonShiftHorizontal, tb, widget), - pixelMetric(PM_ButtonShiftVertical, tb, widget)); - drawItemPixmap(p, ir, Qt::AlignCenter, pm); + p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); + proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); p->restore(); } if (tb->subControls & SC_TitleBarShadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint && !(tb->titleBarState & Qt::WindowMinimized)) { - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton, widget); down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken)); pm = standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(10, 10); tool.rect = ir; tool.state = down ? State_Sunken : State_Raised; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); p->save(); if (down) - p->translate(pixelMetric(PM_ButtonShiftHorizontal, tb, widget), - pixelMetric(PM_ButtonShiftVertical, tb, widget)); - drawItemPixmap(p, ir, Qt::AlignCenter, pm); + p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); + proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); p->restore(); } if (tb->subControls & SC_TitleBarUnshadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint && tb->titleBarState & Qt::WindowMinimized) { - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton, widget); down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken); pm = standardIcon(SP_TitleBarUnshadeButton, &tool, widget).pixmap(10, 10); tool.rect = ir; tool.state = down ? State_Sunken : State_Raised; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); p->save(); if (down) - p->translate(pixelMetric(PM_ButtonShiftHorizontal, tb, widget), - pixelMetric(PM_ButtonShiftVertical, tb, widget)); - drawItemPixmap(p, ir, Qt::AlignCenter, pm); + p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); + proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); p->restore(); } if (tb->subControls & SC_TitleBarContextHelpButton && tb->titleBarFlags & Qt::WindowContextHelpButtonHint) { - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton, widget); down = tb->activeSubControls & SC_TitleBarContextHelpButton && (opt->state & State_Sunken); pm = standardIcon(SP_TitleBarContextHelpButton, &tool, widget).pixmap(10, 10); tool.rect = ir; tool.state = down ? State_Sunken : State_Raised; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); p->save(); if (down) - p->translate(pixelMetric(PM_ButtonShiftHorizontal, tb, widget), - pixelMetric(PM_ButtonShiftVertical, tb, widget)); - drawItemPixmap(p, ir, Qt::AlignCenter, pm); + p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); + proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); p->restore(); } if (tb->subControls & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) { - ir = subControlRect(CC_TitleBar, tb, SC_TitleBarSysMenu, widget); + ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarSysMenu, widget); if (!tb->icon.isNull()) { tb->icon.paint(p, ir); } else { - int iconSize = pixelMetric(PM_SmallIconSize, tb, widget); + int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget); pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(iconSize, iconSize); tool.rect = ir; p->save(); - drawItemPixmap(p, ir, Qt::AlignCenter, pm); + proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); p->restore(); } } @@ -3794,11 +3780,11 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl // draw notches if (dial->subControls & QStyle::SC_DialTickmarks) { p->setPen(pal.foreground().color()); - p->drawLines(calcLines(dial, widget)); // ### calcLines could be cached... + p->drawLines(QStyleHelper::calcLines(dial)); } if (dial->state & State_Enabled) { - p->setBrush(pal.brush(QPalette::ColorRole(styleHint(SH_Dial_BackgroundRole, + p->setBrush(pal.brush(QPalette::ColorRole(proxy()->styleHint(SH_Dial_BackgroundRole, dial, widget)))); p->setPen(Qt::NoPen); p->drawEllipse(br); @@ -3816,7 +3802,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl p->setBrush(pal.button()); p->drawPolygon(arrow); - a = angle(QPointF(width / 2, height / 2), arrow[0]); + a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]); p->setBrush(Qt::NoBrush); if (a <= 0 || a > 200) { @@ -3859,7 +3845,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl br.setHeight(br.height() + r / 3); } fropt.rect = br.adjusted(-2, -2, 2, 2); - drawPrimitive(QStyle::PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &fropt, p, widget); } p->restore(); } @@ -3869,15 +3855,15 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl case CC_GroupBox: if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) { // Draw frame - QRect textRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, widget); - QRect checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget); + QRect textRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, widget); + QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget); if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { QStyleOptionFrameV2 frame; frame.QStyleOption::operator=(*groupBox); frame.features = groupBox->features; frame.lineWidth = groupBox->lineWidth; frame.midLineWidth = groupBox->midLineWidth; - frame.rect = subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, widget); + frame.rect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, widget); p->save(); QRegion region(groupBox->rect); if (!groupBox->text.isEmpty()) { @@ -3892,7 +3878,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl region -= finalRect; } p->setClipRegion(region); - drawPrimitive(PE_FrameGroupBox, &frame, p, widget); + proxy()->drawPrimitive(PE_FrameGroupBox, &frame, p, widget); p->restore(); } @@ -3902,10 +3888,10 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl if (textColor.isValid()) p->setPen(textColor); int alignment = int(groupBox->textAlignment); - if (!styleHint(QStyle::SH_UnderlineShortcut, opt, widget)) + if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, opt, widget)) alignment |= Qt::TextHideMnemonic; - drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment, + proxy()->drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment, groupBox->palette, groupBox->state & State_Enabled, groupBox->text, textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); @@ -3913,7 +3899,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*groupBox); fropt.rect = textRect; - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } } @@ -3922,7 +3908,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl QStyleOptionButton box; box.QStyleOption::operator=(*groupBox); box.rect = checkBoxRect; - drawPrimitive(PE_IndicatorCheckBox, &box, p, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, p, widget); } } break; @@ -3939,52 +3925,52 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) { btnOpt.state |= State_Sunken; btnOpt.state &= ~State_Raised; - bsx = pixelMetric(PM_ButtonShiftHorizontal); - bsy = pixelMetric(PM_ButtonShiftVertical); + bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); + bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); } else { btnOpt.state |= State_Raised; btnOpt.state &= ~State_Sunken; bsx = 0; bsy = 0; } - btnOpt.rect = subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget); - drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); + btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); QPixmap pm = standardIcon(SP_TitleBarCloseButton).pixmap(16, 16); - drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); + proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); } if (opt->subControls & QStyle::SC_MdiNormalButton) { if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) { btnOpt.state |= State_Sunken; btnOpt.state &= ~State_Raised; - bsx = pixelMetric(PM_ButtonShiftHorizontal); - bsy = pixelMetric(PM_ButtonShiftVertical); + bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); + bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); } else { btnOpt.state |= State_Raised; btnOpt.state &= ~State_Sunken; bsx = 0; bsy = 0; } - btnOpt.rect = subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget); - drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); + btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); QPixmap pm = standardIcon(SP_TitleBarNormalButton).pixmap(16, 16); - drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); + proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); } if (opt->subControls & QStyle::SC_MdiMinButton) { if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) { btnOpt.state |= State_Sunken; btnOpt.state &= ~State_Raised; - bsx = pixelMetric(PM_ButtonShiftHorizontal); - bsy = pixelMetric(PM_ButtonShiftVertical); + bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); + bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); } else { btnOpt.state |= State_Raised; btnOpt.state &= ~State_Sunken; bsx = 0; bsy = 0; } - btnOpt.rect = subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget); - drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); + btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); QPixmap pm = standardIcon(SP_TitleBarMinButton).pixmap(16, 16); - drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); + proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); } } break; @@ -4006,11 +3992,11 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const #ifndef QT_NO_SLIDER case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { - QRect r = subControlRect(cc, slider, SC_SliderHandle, widget); + QRect r = proxy()->subControlRect(cc, slider, SC_SliderHandle, widget); if (r.isValid() && r.contains(pt)) { sc = SC_SliderHandle; } else { - r = subControlRect(cc, slider, SC_SliderGroove ,widget); + r = proxy()->subControlRect(cc, slider, SC_SliderGroove ,widget); if (r.isValid() && r.contains(pt)) sc = SC_SliderGroove; } @@ -4023,7 +4009,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const QRect r; uint ctrl = SC_ScrollBarAddLine; while (ctrl <= SC_ScrollBarGroove) { - r = subControlRect(cc, scrollbar, QStyle::SubControl(ctrl), widget); + r = proxy()->subControlRect(cc, scrollbar, QStyle::SubControl(ctrl), widget); if (r.isValid() && r.contains(pt)) { sc = QStyle::SubControl(ctrl); break; @@ -4039,7 +4025,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const QRect r; uint ctrl = SC_ToolButton; while (ctrl <= SC_ToolButtonMenu) { - r = subControlRect(cc, toolbutton, QStyle::SubControl(ctrl), widget); + r = proxy()->subControlRect(cc, toolbutton, QStyle::SubControl(ctrl), widget); if (r.isValid() && r.contains(pt)) { sc = QStyle::SubControl(ctrl); break; @@ -4063,7 +4049,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const QRect r; uint ctrl = SC_SpinBoxUp; while (ctrl <= SC_SpinBoxEditField) { - r = subControlRect(cc, spinbox, QStyle::SubControl(ctrl), widget); + r = proxy()->subControlRect(cc, spinbox, QStyle::SubControl(ctrl), widget); if (r.isValid() && r.contains(pt)) { sc = QStyle::SubControl(ctrl); break; @@ -4079,7 +4065,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const uint ctrl = SC_TitleBarSysMenu; while (ctrl <= SC_TitleBarLabel) { - r = subControlRect(cc, tb, QStyle::SubControl(ctrl), widget); + r = proxy()->subControlRect(cc, tb, QStyle::SubControl(ctrl), widget); if (r.isValid() && r.contains(pt)) { sc = QStyle::SubControl(ctrl); break; @@ -4094,7 +4080,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const QRect r; uint ctrl = SC_ComboBoxArrow; // Start here and go down. while (ctrl > 0) { - r = subControlRect(cc, cb, QStyle::SubControl(ctrl), widget); + r = proxy()->subControlRect(cc, cb, QStyle::SubControl(ctrl), widget); if (r.isValid() && r.contains(pt)) { sc = QStyle::SubControl(ctrl); break; @@ -4110,7 +4096,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const QRect r; uint ctrl = SC_GroupBoxCheckBox; while (ctrl <= SC_GroupBoxFrame) { - r = subControlRect(cc, groupBox, QStyle::SubControl(ctrl), widget); + r = proxy()->subControlRect(cc, groupBox, QStyle::SubControl(ctrl), widget); if (r.isValid() && r.contains(pt)) { sc = QStyle::SubControl(ctrl); break; @@ -4125,7 +4111,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const QRect r; uint ctrl = SC_MdiMinButton; while (ctrl <= SC_MdiCloseButton) { - r = subControlRect(CC_MdiControls, opt, QStyle::SubControl(ctrl), widget); + r = proxy()->subControlRect(CC_MdiControls, opt, QStyle::SubControl(ctrl), widget); if (r.isValid() && r.contains(pt) && (opt->subControls & ctrl)) { sc = QStyle::SubControl(ctrl); return sc; @@ -4151,13 +4137,13 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex #ifndef QT_NO_SLIDER case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { - int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget); - int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); + int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); + int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); switch (sc) { case SC_SliderHandle: { int sliderPos = 0; - int len = pixelMetric(PM_SliderLength, slider, widget); + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); bool horizontal = slider->orientation == Qt::Horizontal; sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition, @@ -4188,7 +4174,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex case CC_ScrollBar: if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { const QRect scrollBarRect = scrollbar->rect; - int sbextent = pixelMetric(PM_ScrollBarExtent, scrollbar, widget); + int sbextent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar, widget); int maxlen = ((scrollbar->orientation == Qt::Horizontal) ? scrollBarRect.width() : scrollBarRect.height()) - (sbextent * 2); int sliderlen; @@ -4198,7 +4184,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex uint range = scrollbar->maximum - scrollbar->minimum; sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep); - int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget); + int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget); if (sliderlen < slidermin || range > INT_MAX / 2) sliderlen = slidermin; if (sliderlen > maxlen) @@ -4271,7 +4257,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { QSize bs; - int fw = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; + int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; bs.setHeight(qMax(8, spinbox->rect.height()/2 - fw)); // 1.6 -approximate golden mean bs.setWidth(qMax(16, qMin(bs.height() * 8 / 5, spinbox->rect.width() / 4))); @@ -4312,7 +4298,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex #ifndef QT_NO_TOOLBUTTON case CC_ToolButton: if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { - int mbi = pixelMetric(PM_MenuButtonIndicator, tb, widget); + int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, tb, widget); ret = tb->rect; switch (sc) { case SC_ToolButton: @@ -4452,7 +4438,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex case SC_GroupBoxContents: { int topMargin = 0; int topHeight = 0; - int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); + int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); if (groupBox->text.size() || (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)) { topHeight = groupBox->fontMetrics.height(); if (verticalAlignment & Qt::AlignVCenter) @@ -4472,7 +4458,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex int frameWidth = 0; if (!(widget && widget->inherits("Q3GroupBox")) && ((groupBox->features & QStyleOptionFrameV2::Flat) == 0)) { - frameWidth = pixelMetric(PM_DefaultFrameWidth, groupBox, widget); + frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, groupBox, widget); } ret = frameRect.adjusted(frameWidth, frameWidth + topHeight - topMargin, -frameWidth, -frameWidth); @@ -4488,8 +4474,8 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex ret = groupBox->rect.adjusted(marg, 0, -marg, 0); ret.setHeight(h); - int indicatorWidth = pixelMetric(PM_IndicatorWidth, opt, widget); - int indicatorSpace = pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1; + int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget); + int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1; bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox; int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0; @@ -4503,7 +4489,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex int left = 0; // Adjust for check box if (sc == SC_GroupBoxCheckBox) { - int indicatorHeight = pixelMetric(PM_IndicatorHeight, opt, widget); + int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth); int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2; totalRect.setRect(left, top, indicatorWidth, indicatorHeight); @@ -4589,17 +4575,17 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = 0; break; case PM_DialogButtonsSeparator: - ret = 5; + ret = int(QStyleHelper::dpiScaled(5.)); break; case PM_DialogButtonsButtonWidth: - ret = 70; + ret = int(QStyleHelper::dpiScaled(70.)); break; case PM_DialogButtonsButtonHeight: - ret = 30; + ret = int(QStyleHelper::dpiScaled(30.)); break; case PM_CheckListControllerSize: case PM_CheckListButtonSize: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_TitleBarHeight: { if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { @@ -4607,26 +4593,26 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = qMax(widget ? widget->fontMetrics().lineSpacing() : opt->fontMetrics.lineSpacing(), 16); #ifndef QT_NO_DOCKWIDGET } else if (qobject_cast<const QDockWidget*>(widget)) { - ret = qMax(widget->fontMetrics().lineSpacing(), 13); + ret = qMax(widget->fontMetrics().lineSpacing(), int(QStyleHelper::dpiScaled(13))); #endif } else { ret = qMax(widget ? widget->fontMetrics().lineSpacing() : opt->fontMetrics.lineSpacing(), 18); } } else { - ret = 18; + ret = int(QStyleHelper::dpiScaled(18.)); } break; } case PM_ScrollBarSliderMin: - ret = 9; + ret = int(QStyleHelper::dpiScaled(9.)); break; case PM_ButtonMargin: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_DockWidgetTitleBarButtonMargin: - ret = 2; + ret = int(QStyleHelper::dpiScaled(2.)); break; case PM_ButtonDefaultIndicator: @@ -4634,7 +4620,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_MenuButtonIndicator: - ret = 12; + ret = int(QStyleHelper::dpiScaled(12.)); break; case PM_ButtonShiftHorizontal: @@ -4649,15 +4635,15 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_MenuPanelWidth: case PM_TabBarBaseOverlap: case PM_TabBarBaseHeight: - ret = pixelMetric(PM_DefaultFrameWidth, opt, widget); + ret = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); break; case PM_MdiSubWindowFrameWidth: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_MdiSubWindowMinimizedWidth: - ret = 196; + ret = int(QStyleHelper::dpiScaled(196.)); break; #ifndef QT_NO_SCROLLBAR @@ -4668,7 +4654,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid : QApplication::globalStrut().width(); ret = qMax(16, s); } else { - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); } break; #endif @@ -4678,14 +4664,14 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid #ifndef QT_NO_SLIDER case PM_SliderThickness: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_SliderTickmarkOffset: if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width(); - int thickness = pixelMetric(PM_SliderControlThickness, sl, widget); + int thickness = proxy()->pixelMetric(PM_SliderControlThickness, sl, widget); int ticks = sl->tickPosition; if (ticks == QSlider::TicksBothSides) @@ -4702,9 +4688,9 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_SliderSpaceAvailable: if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { if (sl->orientation == Qt::Horizontal) - ret = sl->rect.width() - pixelMetric(PM_SliderLength, sl, widget); + ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, sl, widget); else - ret = sl->rect.height() - pixelMetric(PM_SliderLength, sl, widget); + ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, sl, widget); } else { ret = 0; } @@ -4712,11 +4698,11 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid #endif // QT_NO_SLIDER #ifndef QT_NO_DOCKWIDGET case PM_DockWidgetSeparatorExtent: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_DockWidgetHandleExtent: - ret = 8; + ret = int(QStyleHelper::dpiScaled(8.)); break; case PM_DockWidgetTitleMargin: ret = 0; @@ -4745,19 +4731,19 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_ToolBarItemSpacing: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_ToolBarHandleExtent: - ret = 8; + ret = int(QStyleHelper::dpiScaled(8.)); break; case PM_ToolBarSeparatorExtent: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_ToolBarExtensionExtent: - ret = 12; + ret = int(QStyleHelper::dpiScaled(12.)); break; #endif // QT_NO_TOOLBAR @@ -4767,7 +4753,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_TabBarTabHSpace: - ret = 24; + ret = int(QStyleHelper::dpiScaled(24.)); break; case PM_TabBarTabShiftHorizontal: @@ -4796,27 +4782,27 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_IndicatorWidth: - ret = 13; + ret = int(QStyleHelper::dpiScaled(13.)); break; case PM_IndicatorHeight: - ret = 13; + ret = int(QStyleHelper::dpiScaled(13.)); break; case PM_ExclusiveIndicatorWidth: - ret = 12; + ret = int(QStyleHelper::dpiScaled(12.)); break; case PM_ExclusiveIndicatorHeight: - ret = 12; + ret = int(QStyleHelper::dpiScaled(12.)); break; case PM_MenuTearoffHeight: - ret = 10; + ret = int(QStyleHelper::dpiScaled(10.)); break; case PM_MenuScrollerHeight: - ret = 10; + ret = int(QStyleHelper::dpiScaled(10.)); break; case PM_MenuDesktopFrameWidth: @@ -4826,16 +4812,16 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_HeaderMargin: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_HeaderMarkSize: - ret = 32; + ret = int(QStyleHelper::dpiScaled(32.)); break; case PM_HeaderGripMargin: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_TabBarScrollButtonWidth: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_LayoutLeftMargin: case PM_LayoutTopMargin: @@ -4848,40 +4834,40 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid } else if (widget) { isWindow = widget->isWindow(); } - ret = pixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin); + ret = proxy()->pixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin); } break; case PM_LayoutHorizontalSpacing: case PM_LayoutVerticalSpacing: - ret = pixelMetric(PM_DefaultLayoutSpacing); + ret = proxy()->pixelMetric(PM_DefaultLayoutSpacing); break; case PM_DefaultTopLevelMargin: - ret = 11; + ret = int(QStyleHelper::dpiScaled(11.)); break; case PM_DefaultChildMargin: - ret = 9; + ret = int(QStyleHelper::dpiScaled(9.)); break; case PM_DefaultLayoutSpacing: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_TabBarIconSize: case PM_ToolBarIconSize: case PM_ListViewIconSize: - ret = pixelMetric(PM_SmallIconSize, opt, widget); + ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); break; case PM_ButtonIconSize: case PM_SmallIconSize: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_IconViewIconSize: - ret = pixelMetric(PM_LargeIconSize, opt, widget); + ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); break; case PM_LargeIconSize: - ret = 32; + ret = int(QStyleHelper::dpiScaled(32.)); break; case PM_ToolTipLabelFrameWidth: @@ -4889,13 +4875,20 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_CheckBoxLabelSpacing: case PM_RadioButtonLabelSpacing: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_SizeGripSize: - ret = 13; + ret = int(QStyleHelper::dpiScaled(13.)); break; case PM_MessageBoxIconSize: - ret = 32; +#ifdef Q_WS_MAC + if (QApplication::desktopSettingsAware()) { + ret = 64; // No DPI scaling, it's handled elsewhere. + } else +#endif + { + ret = int(QStyleHelper::dpiScaled(32.)); + } break; case PM_TextCursorWidth: ret = 1; @@ -4905,13 +4898,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_TabCloseIndicatorWidth: case PM_TabCloseIndicatorHeight: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_ScrollView_ScrollBarSpacing: - ret = 2 * pixelMetric(PM_DefaultFrameWidth, opt, widget); + ret = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); break; case PM_SubMenuOverlap: - ret = -pixelMetric(QStyle::PM_MenuPanelWidth, opt, widget); + ret = -proxy()->pixelMetric(QStyle::PM_MenuPanelWidth, opt, widget); break; default: ret = 0; @@ -4934,12 +4927,12 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { int w = csz.width(), h = csz.height(), - bm = pixelMetric(PM_ButtonMargin, btn, widget), - fw = pixelMetric(PM_DefaultFrameWidth, btn, widget) * 2; + bm = proxy()->pixelMetric(PM_ButtonMargin, btn, widget), + fw = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) * 2; w += bm + fw; h += bm + fw; if (btn->features & QStyleOptionButton::AutoDefaultButton){ - int dbw = pixelMetric(PM_ButtonDefaultIndicator, btn, widget) * 2; + int dbw = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget) * 2; w += dbw; h += dbw; } @@ -4951,15 +4944,15 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { bool isRadio = (ct == CT_RadioButton); - int w = pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth + int w = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth : PM_IndicatorWidth, btn, widget); - int h = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight + int h = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight : PM_IndicatorHeight, btn, widget); int margins = 0; // we add 4 pixels for label margins if (btn->icon.isNull() || !btn->text.isEmpty()) - margins = 4 + pixelMetric(isRadio ? PM_RadioButtonLabelSpacing + margins = 4 + proxy()->pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, opt, widget); sz += QSize(w + margins, 4); sz.setHeight(qMax(sz.height(), h)); @@ -4977,7 +4970,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } else { h = mi->fontMetrics.height() + 8; if (!mi->icon.isNull()) { - int iconExtent = pixelMetric(PM_SmallIconSize); + int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4); } } @@ -5002,10 +4995,10 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, #ifndef QT_NO_COMBOBOX case CT_ComboBox: if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { - int fw = cmb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0; - const int textMargins = 2*(pixelMetric(PM_FocusFrameHMargin) + 1); + int fw = cmb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0; + const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1); // QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins... - int other = qMax(23, 2*textMargins + pixelMetric(QStyle::PM_ScrollBarExtent, opt, widget)); + int other = qMax(23, 2*textMargins + proxy()->pixelMetric(QStyle::PM_ScrollBarExtent, opt, widget)); sz = QSize(sz.width() + fw + other, sz.height() + fw); } break; @@ -5013,8 +5006,8 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, case CT_HeaderSection: if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { bool nullIcon = hdr->icon.isNull(); - int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, widget); - int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, widget); + int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, hdr, widget); + int iconSize = nullIcon ? 0 : proxy()->pixelMetric(QStyle::PM_SmallIconSize, hdr, widget); QSize txt = hdr->fontMetrics.size(0, hdr->text); sz.setHeight(margin + qMax(iconSize, txt.height()) + margin); sz.setWidth((nullIcon ? 0 : margin) + iconSize @@ -5212,8 +5205,8 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget if (widget) { if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) { mask->region = widget->rect(); - int vmargin = pixelMetric(QStyle::PM_FocusFrameVMargin), - hmargin = pixelMetric(QStyle::PM_FocusFrameHMargin); + int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin), + hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin); mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin)); } } @@ -5226,7 +5219,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = true; if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) { mask->region = opt->rect; - int margin = pixelMetric(PM_DefaultFrameWidth) * 2; + int margin = proxy()->pixelMetric(PM_DefaultFrameWidth) * 2; mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin); } } @@ -5344,6 +5337,16 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_DockWidget_ButtonsHaveFrame: ret = true; break; + case SH_ToolButtonStyle: + ret = Qt::ToolButtonIconOnly; +#ifdef Q_WS_X11 + { + Q_D(const QCommonStyle); + static int buttonStyle = d->lookupToolButtonStyle(); + return buttonStyle; + } +#endif + break; default: ret = 0; break; @@ -5364,7 +5367,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti #ifdef Q_WS_X11 Q_D(const QCommonStyle); QPixmap pixmap; - if (qApp->desktopSettingsAware()) { + if (QApplication::desktopSettingsAware()) { d->lookupIconTheme(); switch (sp) { case SP_DirHomeIcon: @@ -5669,12 +5672,12 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti case SP_CommandLink: case SP_ArrowForward: if (QApplication::layoutDirection() == Qt::RightToLeft) - return standardPixmap(SP_ArrowLeft, option, widget); - return standardPixmap(SP_ArrowRight, option, widget); + return proxy()->standardPixmap(SP_ArrowLeft, option, widget); + return proxy()->standardPixmap(SP_ArrowRight, option, widget); case SP_ArrowBack: if (QApplication::layoutDirection() == Qt::RightToLeft) - return standardPixmap(SP_ArrowRight, option, widget); - return standardPixmap(SP_ArrowLeft, option, widget); + return proxy()->standardPixmap(SP_ArrowRight, option, widget); + return proxy()->standardPixmap(SP_ArrowLeft, option, widget); case SP_ArrowLeft: return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/left-16.png")); case SP_ArrowRight: @@ -5684,7 +5687,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti case SP_ArrowDown: return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/down-16.png")); case SP_FileDialogToParent: - return standardPixmap(SP_ArrowUp, option, widget); + return proxy()->standardPixmap(SP_ArrowUp, option, widget); case SP_FileDialogNewFolder: return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-16.png")); case SP_FileDialogDetailedView: @@ -5696,7 +5699,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti case SP_FileDialogListView: return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-16.png")); case SP_FileDialogBack: - return standardPixmap(SP_ArrowBack, option, widget); + return proxy()->standardPixmap(SP_ArrowBack, option, widget); case SP_DriveHDIcon: return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/harddrive-16.png")); case SP_TrashIcon: @@ -5783,9 +5786,9 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons const QWidget *widget) const { QIcon icon; + if (QApplication::desktopSettingsAware()) { #ifdef Q_WS_X11 - Q_D(const QCommonStyle); - if (qApp->desktopSettingsAware()) { + Q_D(const QCommonStyle); d->lookupIconTheme(); QPixmap pixmap; switch (standardIcon) { @@ -5804,6 +5807,7 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons case SP_MessageBoxWarning: { icon = d->createIcon(QLatin1String("dialog-warning.png")); + icon = d->createIcon(QLatin1String("dialog-warning.png")); if (icon.isNull()) icon = d->createIcon(QLatin1String("messagebox_warning.png")); break; @@ -5997,7 +6001,7 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons } case SP_FileLinkIcon: { - icon = QIcon(standardPixmap(standardIcon, option, widget)); + icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget)); QPixmap pixmap = d->findIcon(32, QLatin1String("link_overlay.png")); if (!pixmap.isNull()) { QPixmap fileIcon = d->findIcon(32, QLatin1String("text-x-generic.png")); @@ -6012,7 +6016,7 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons } break; case SP_DirLinkIcon: { - icon = QIcon(standardPixmap(standardIcon, option, widget)); + icon = QIcon(proxy()->standardPixmap(standardIcon, option, widget)); QPixmap pixmap = d->findIcon(32, QLatin1String("link_overlay.png")); if (!pixmap.isNull()) { QPixmap fileIcon = d->findIcon(32, QLatin1String("folder.png")); @@ -6029,8 +6033,101 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons } if (!icon.isNull()) return icon; +#elif defined(Q_WS_MAC) + OSType iconType = 0; + switch (standardIcon) { + case QStyle::SP_MessageBoxQuestion: + case QStyle::SP_MessageBoxInformation: + case QStyle::SP_MessageBoxWarning: + case QStyle::SP_MessageBoxCritical: + iconType = kGenericApplicationIcon; + break; + case SP_DesktopIcon: + iconType = kDesktopIcon; + break; + case SP_TrashIcon: + iconType = kTrashIcon; + break; + case SP_ComputerIcon: + iconType = kComputerIcon; + break; + case SP_DriveFDIcon: + iconType = kGenericFloppyIcon; + break; + case SP_DriveHDIcon: + iconType = kGenericHardDiskIcon; + break; + case SP_DriveCDIcon: + case SP_DriveDVDIcon: + iconType = kGenericCDROMIcon; + break; + case SP_DriveNetIcon: + iconType = kGenericNetworkIcon; + break; + case SP_DirOpenIcon: + iconType = kOpenFolderIcon; + break; + case SP_DirClosedIcon: + case SP_DirLinkIcon: + iconType = kGenericFolderIcon; + break; + case SP_FileLinkIcon: + case SP_FileIcon: + iconType = kGenericDocumentIcon; + break; + case SP_DirIcon: { + // A rather special case + QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, option, widget); + QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, option, widget); + closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On); + closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On); + closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On); + closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On); + return closeIcon; + } + case SP_TitleBarNormalButton: + case SP_TitleBarCloseButton: { + QIcon titleBarIcon; + if (standardIcon == SP_TitleBarCloseButton) { + titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-16.png")); + titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); + } else { + titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-16.png")); + titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); + } + return titleBarIcon; + } + default: + break; + } + if (iconType != 0) { + QIcon retIcon; + IconRef icon; + IconRef overlayIcon = 0; + if (iconType != kGenericApplicationIcon) { + GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); + } else { + FSRef fsRef; + ProcessSerialNumber psn = { 0, kCurrentProcess }; + GetProcessBundleLocation(&psn, &fsRef); + GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); + if (standardIcon == SP_MessageBoxCritical) { + overlayIcon = icon; + GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); + } + } + if (icon) { + qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon); + ReleaseIconRef(icon); + } + if (overlayIcon) + ReleaseIconRef(overlayIcon); + return retIcon; } -#endif//Q_WS_X11 + +#endif //Q_WS_X11 || Q_WS_MAC + } + switch (standardIcon) { #ifndef QT_NO_IMAGEFORMAT_PNG @@ -6230,7 +6327,7 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons break; #endif // QT_NO_IMAGEFORMAT_PNG default: - icon.addPixmap(standardPixmap(standardIcon, option, widget)); + icon.addPixmap(proxy()->standardPixmap(standardIcon, option, widget)); break; } return icon; diff --git a/src/gui/styles/qcommonstyle_p.h b/src/gui/styles/qcommonstyle_p.h index 27ebc05..f2af5b2 100644 --- a/src/gui/styles/qcommonstyle_p.h +++ b/src/gui/styles/qcommonstyle_p.h @@ -126,6 +126,7 @@ public: //icon detection on X11 #ifdef Q_WS_X11 void lookupIconTheme() const; + int lookupToolButtonStyle() const; QIcon createIcon(const QString &) const; QPixmap findIcon(int size, const QString &) const; QPixmap findIconHelper(int size, const QString &, const QString &, QStringList &visited) const; diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index e2dcfba..660b4c3 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -70,6 +70,7 @@ #include <qpixmapcache.h> #undef signals // Collides with GTK stymbols #include "qgtkpainter_p.h" +#include "qstylehelper_p.h" #include <private/qcleanlooksstyle_p.h> @@ -150,7 +151,6 @@ bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e) if (e->type() == QEvent::ApplicationPaletteChange) { // Only do this the first time since this will also // generate applicationPaletteChange events - extern QHash<QByteArray, QPalette> *qt_app_palettes_hash(); //qapplication.cpp if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) { QGtk::applyCustomPaletteHash(); } @@ -176,7 +176,6 @@ public: static const int groupBoxBottomMargin = 2; // space below the groupbox static const int groupBoxTitleMargin = 6; // space between contents and title static const int groupBoxTopMargin = 2; -static bool UsePixmapCache = true; // Get size of the arrow controls in a GtkSpinButton static int spinboxArrowSize() @@ -210,17 +209,6 @@ static GdkColor fromQColor(const QColor &color) return retval; } -// Note this is different from uniqueName as used in QGtkPainter -static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) -{ - QString tmp; - const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); - tmp.sprintf("%s-%d-%d-%d-%lld-%dx%d", key.toLatin1().constData(), uint(option->state), - option->direction, complexOption ? uint(complexOption->activeSubControls) : uint(0), - option->palette.cacheKey(), size.width(), size.height()); - return tmp; -} - /*! \class QGtkStyle \brief The QGtkStyle class provides a widget style rendered by GTK+ @@ -611,6 +599,26 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg break; + case SH_ToolButtonStyle: + { + if (QGtk::isKDE4Session()) + return QCleanlooksStyle::styleHint(hint, option, widget, returnData); + GtkWidget *gtkToolbar = QGtk::gtkWidget(QLS("GtkToolbar")); + GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS; + g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL); + switch (toolbar_style) { + case GTK_TOOLBAR_TEXT: + return Qt::ToolButtonTextOnly; + case GTK_TOOLBAR_BOTH: + return Qt::ToolButtonTextUnderIcon; + case GTK_TOOLBAR_BOTH_HORIZ: + return Qt::ToolButtonTextBesideIcon; + case GTK_TOOLBAR_ICONS: + default: + return Qt::ToolButtonIconOnly; + } + } + break; case SH_SpinControls_DisableOnBounds: return int(true); @@ -675,14 +683,14 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, if (widget && widget->inherits("QComboBoxPrivateContainer")){ QStyleOption copy = *option; copy.state |= State_Raised; - drawPrimitive(PE_PanelMenu, ©, painter, widget); + proxy()->drawPrimitive(PE_PanelMenu, ©, painter, widget); break; } // Drawing the entire itemview frame is very expensive, especially on the native X11 engine // Instead we cheat a bit and draw a border image without the center part, hence only scaling // thin rectangular images const int pmSize = 64; - const int border = pixelMetric(PM_DefaultFrameWidth, option, widget); + const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); const QString pmKey = QString(QLS("windowframe %0")).arg(option->state); QPixmap pixmap; @@ -889,8 +897,8 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, int border = (size > 9) ? (size/4) : 0; //Allow small arrows to have exact dimensions int bsx = 0, bsy = 0; if (option->state & State_Sunken) { - bsx = pixelMetric(PM_ButtonShiftHorizontal); - bsy = pixelMetric(PM_ButtonShiftVertical); + bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); + bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); } QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy); GtkShadowType shadow = option->state & State_Sunken ? GTK_SHADOW_IN : GTK_SHADOW_OUT; @@ -970,7 +978,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) { GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry")); if (panel->lineWidth > 0) - drawPrimitive(PE_FrameLineEdit, option, painter, widget); + proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget); uint resolve_mask = option->palette.resolve(); QRect textRect = option->rect.adjusted(gtkEntry->style->xthickness, gtkEntry->style->ythickness, -gtkEntry->style->xthickness, -gtkEntry->style->ythickness); @@ -1241,8 +1249,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom painter->save(); if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { - QRect textRect = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); - QRect checkBoxRect = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget); + QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); + QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget); // Draw title if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { @@ -1257,7 +1265,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (!groupBox->text.isEmpty()) { int alignment = int(groupBox->textAlignment); - if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget)) + if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget)) alignment |= Qt::TextHideMnemonic; QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored int labelState = GTK_STATE_INSENSITIVE; @@ -1282,7 +1290,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QStyleOptionButton box; box.QStyleOption::operator=(*groupBox); box.rect = checkBoxRect; - drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); } } @@ -1305,7 +1313,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom bool focus = isEnabled && (comboBox->state & State_HasFocus); QColor buttonShadow = option->palette.dark().color(); GtkStateType state = gtkPainter.gtkState(option); - int appears_as_list = !styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget); + int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget); QPixmap cache; QString pixmapName; QStyleOptionComboBox comboBoxCopy = *comboBox; @@ -1313,9 +1321,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom bool reverse = (option->direction == Qt::RightToLeft); QRect rect = option->rect; - QRect arrowButtonRect = subControlRect(CC_ComboBox, &comboBoxCopy, + QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxArrow, widget); - QRect editRect = subControlRect(CC_ComboBox, &comboBoxCopy, + QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget); GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ? @@ -1423,7 +1431,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QGtk::gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL); int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0; int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0; - if ((focus && (option->state & State_KeyboardFocusChange))) + if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) gtkCachedPainter.paintFocus(gtkToggleButton, "button", option->rect.adjusted(xt, yt, -xt, -yt), option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL, @@ -1494,8 +1502,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { QRect button, menuarea; - button = subControlRect(control, toolbutton, SC_ToolButton, widget); - menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget); + button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget); + menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget); State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver); if (bflags & State_AutoRaise) @@ -1524,7 +1532,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (bflags & (State_Sunken | State_On | State_Raised | State_MouseOver)) { tool.rect = button; tool.state = bflags; - drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); } } @@ -1535,9 +1543,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (toolbutton->state & State_HasFocus) { QStyleOptionFocusRect fr; fr.QStyleOption::operator=(*toolbutton); - fr.rect = subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget); + fr.rect = proxy()->subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget); fr.rect.adjust(1, 1, -1, -1); - drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget); } QStyleOptionToolButton label = *toolbutton; @@ -1553,21 +1561,21 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom } label.rect = button.adjusted(style->xthickness, style->ythickness, -style->xthickness - popupArrowSize, -style->ythickness); - drawControl(CE_ToolButtonLabel, &label, painter, widget); + proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget); if (toolbutton->subControls & SC_ToolButtonMenu) { tool.rect = menuarea; tool.state = mflags; if ((mflags & State_Enabled && (mflags & (State_Sunken | State_Raised | State_MouseOver))) || !(mflags & State_AutoRaise)) - drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget); + proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget); - drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); } else if (drawMenuArrow) { QRect ir = toolbutton->rect; QStyleOptionToolButton newBtn = *toolbutton; newBtn.rect = QRect(ir.right() - popupArrowSize - style->xthickness - 3, ir.height()/2 - 1, popupArrowSize, popupArrowSize); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); } } break; @@ -1584,10 +1592,10 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom painter->fillRect(option->rect, option->palette.background()); QRect rect = scrollBar->rect; - QRect scrollBarSubLine = subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); - QRect scrollBarAddLine = subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); - QRect scrollBarSlider = subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); - QRect grooveRect = subControlRect(control, scrollBar, SC_ScrollBarGroove, widget); + QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); + QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); + QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); + QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget); bool horizontal = scrollBar->orientation == Qt::Horizontal; GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar; style = scrollbarWidget->style; @@ -1731,7 +1739,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom bool reverse = (spinBox->direction == Qt::RightToLeft); //### Move this to subControlRect - QRect upRect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); + QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); upRect.setTop(option->rect.top()); if (reverse) @@ -1739,8 +1747,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom else upRect.setRight(option->rect.right()); - QRect editRect = subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget); - QRect downRect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); + QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget); + QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); downRect.setBottom(option->rect.bottom()); if (reverse) @@ -1772,8 +1780,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QString key; + if (option->state & State_HasFocus) { - key = QLS("f"); + key += QLatin1Char('f'); GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS); } @@ -1871,9 +1880,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom GtkWidget *hScaleWidget = QGtk::gtkWidget(QLS("GtkHScale")); GtkWidget *vScaleWidget = QGtk::gtkWidget(QLS("GtkVScale")); - QRect groove = subControlRect(CC_Slider, option, SC_SliderGroove, widget); - QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget); - QRect ticks = subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); + QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); + QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); + QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); bool horizontal = slider->orientation == Qt::Horizontal; bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; @@ -1928,8 +1937,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (option->subControls & SC_SliderTickmarks) { painter->setPen(darkOutline); - int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget); - int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget); + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); + int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); int interval = slider->tickInterval; if (interval <= 0) { @@ -1946,7 +1955,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom interval = 1; int v = slider->minimum; - int len = pixelMetric(PM_SliderLength, slider, widget); + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); while (v <= slider->maximum + 1) { if (v == slider->maximum + 1 && interval == 1) break; @@ -2007,7 +2016,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom fropt.rect.setLeft(handle.left() - 3); fropt.rect.setRight(handle.right() + 3); } - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); } gtkPainter.paintSlider( scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style, @@ -2066,8 +2075,8 @@ void QGtkStyle::drawControl(ControlElement element, } if (vertical) rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - const int progressIndicatorPos = static_cast<int>((bar->progress - qint64(bar->minimum)) / - qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * rect.width()); + const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() / + qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); if (vertical) @@ -2097,9 +2106,9 @@ void QGtkStyle::drawControl(ControlElement element, if (option->state & State_Sunken) buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget), - pixelMetric(PM_ButtonShiftVertical, option, widget)); + proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); - if (styleHint(SH_UnderlineShortcut, button, widget)) + if (proxy()->styleHint(SH_UnderlineShortcut, button, widget)) tf |= Qt::TextShowMnemonic; else tf |= Qt::TextHideMnemonic; @@ -2160,7 +2169,7 @@ void QGtkStyle::drawControl(ControlElement element, GdkColor gdkText = gtkButton->style->fg[labelState]; QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); pal.setBrush(QPalette::ButtonText, textColor); - drawItemText(painter, ir, tf, pal, (button->state & State_Enabled), + proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled), button->text, QPalette::ButtonText); } break; @@ -2181,7 +2190,7 @@ void QGtkStyle::drawControl(ControlElement element, QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator : SE_CheckBoxIndicator, btn, widget); - drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, + proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, &subopt, painter, widget); subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents : SE_CheckBoxContents, btn, widget); @@ -2195,14 +2204,14 @@ void QGtkStyle::drawControl(ControlElement element, QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8); pal.setBrush(QPalette::WindowText, textColor); subopt.palette = pal; - drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); + proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); if (btn->state & State_HasFocus) { QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*btn); fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect : SE_CheckBoxFocusRect, btn, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); } } break; @@ -2211,8 +2220,8 @@ void QGtkStyle::drawControl(ControlElement element, case CE_ComboBoxLabel: if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { - QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); - bool appearsAsList = !styleHint(QStyle::SH_ComboBox_Popup, cb, widget); + QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); + bool appearsAsList = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, cb, widget); painter->save(); painter->setClipRect(editRect); @@ -2230,7 +2239,7 @@ void QGtkStyle::drawControl(ControlElement element, if (cb->editable) painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); - drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); + proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); if (cb->direction == Qt::RightToLeft) editRect.translate(-4 - cb->iconSize.width(), 0); @@ -2252,7 +2261,7 @@ void QGtkStyle::drawControl(ControlElement element, pal.setBrush(QPalette::ButtonText, textColor); - drawItemText(painter, editRect.adjusted(1, 0, -1, 0), + proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0), visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter), pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText); } @@ -2298,7 +2307,7 @@ void QGtkStyle::drawControl(ControlElement element, QString titleText = painter->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width()); - drawItemText(painter, + proxy()->drawItemText(painter, titleRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, dwOpt->state & State_Enabled, titleText, @@ -2419,10 +2428,10 @@ void QGtkStyle::drawControl(ControlElement element, QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText; uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!QCleanlooksStyle::styleHint(SH_UnderlineShortcut, mbi, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; - drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole); + proxy()->drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole); } } painter->restore(); @@ -2594,7 +2603,7 @@ void QGtkStyle::drawControl(ControlElement element, mode = QIcon::Active; QPixmap pixmap; - int smallIconSize = pixelMetric(PM_SmallIconSize, option, widget); + int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); QSize iconSize(smallIconSize, smallIconSize); #ifndef QT_NO_COMBOBOX @@ -2622,7 +2631,7 @@ void QGtkStyle::drawControl(ControlElement element, } opt.state |= State_Sunken; opt.rect = vCheckRect; - drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); } painter->drawPixmap(pmr.topLeft(), pixmap); } @@ -2662,7 +2671,7 @@ void QGtkStyle::drawControl(ControlElement element, int t = s.indexOf(QLatin1Char('\t')); int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) text_flags |= Qt::TextHideMnemonic; // Draw shortcut right aligned @@ -2695,7 +2704,7 @@ void QGtkStyle::drawControl(ControlElement element, // Arrow if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow QPoint buttonShift(pixelMetric(PM_ButtonShiftHorizontal, option, widget), - pixelMetric(PM_ButtonShiftVertical, option, widget)); + proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); QFontMetrics fm(menuitem->font); int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness; @@ -2723,7 +2732,7 @@ void QGtkStyle::drawControl(ControlElement element, case CE_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) { GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton")); - drawControl(CE_PushButtonBevel, btn, painter, widget); + proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget); QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); gint interiorFocus = true; @@ -2733,14 +2742,14 @@ void QGtkStyle::drawControl(ControlElement element, if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus) // The normal button focus rect does not work well for flat buttons in Clearlooks - drawPrimitive(PE_FrameFocusRect, option, painter, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget); else if (btn->state & State_HasFocus) gtkPainter.paintFocus(gtkButton, "button", option->rect.adjusted(xt, yt, -xt, -yt), btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL, gtkButton->style); - drawControl(CE_PushButtonLabel, &subopt, painter, widget); + proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget); } break; @@ -2847,8 +2856,7 @@ void QGtkStyle::drawControl(ControlElement element, if (vertical) { rect.translate(xt, -yt * 2); rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // Flip width and height - QTransform m; - m.translate(rect.height(), 0); + QTransform m = QTransform::fromTranslate(rect.height(), 0); m.rotate(90.0); painter->setTransform(m); } @@ -2958,8 +2966,8 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple font.setBold(true); QFontMetrics fontMetrics(font); QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(4, 4); - int indicatorWidth = pixelMetric(PM_IndicatorWidth, option, widget); - int indicatorHeight = pixelMetric(PM_IndicatorHeight, option, widget); + int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); + int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); if (subControl == SC_GroupBoxCheckBox) { rect.setWidth(indicatorWidth); @@ -3040,7 +3048,7 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple QGtk::gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())}; QGtk::gtk_widget_size_allocate(gtkCombo, &geometry); - int appears_as_list = !styleHint(QStyle::SH_ComboBox_Popup, option, widget); + int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget); QString arrowPath = comboBoxPath + QLS(".GtkToggleButton"); if (!box->editable && !appears_as_list) @@ -3204,7 +3212,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, case CT_ComboBox: if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { GtkWidget *gtkCombo = QGtk::gtkWidget(QLS("GtkComboBox")); - QRect arrowButtonRect = subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget); + QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget); newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness); if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget()))) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 48db239..2f93034 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -50,11 +50,13 @@ #define QMAC_QAQUASTYLE_SIZE_CONSTRAIN //#define DEBUG_SIZE_CONSTRAINT +#include <private/qapplication_p.h> #include <private/qcombobox_p.h> #include <private/qmacstylepixmaps_mac_p.h> #include <private/qpaintengine_mac_p.h> #include <private/qpainter_p.h> #include <private/qprintengine_mac_p.h> +#include <private/qstylehelper_p.h> #include <qapplication.h> #include <qbitmap.h> #include <qcheckbox.h> @@ -102,7 +104,6 @@ QT_BEGIN_NAMESPACE extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp -extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp // The following constants are used for adjusting the size // of push buttons so that they are drawn inside their bounds. @@ -130,6 +131,20 @@ static const QColor titlebarSeparatorLineInactive(131, 131, 131); static const QColor mainWindowGradientBegin(240, 240, 240); static const QColor mainWindowGradientEnd(200, 200, 200); +#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5) +enum { + kThemePushButtonTextured = 31, + kThemePushButtonTexturedSmall = 32, + kThemePushButtonTexturedMini = 33 +}; + +/* Search fields */ +enum { + kHIThemeFrameTextFieldRound = 1000, + kHIThemeFrameTextFieldRoundSmall = 1001, + kHIThemeFrameTextFieldRoundMini = 1002 +}; +#endif // Resolve these at run-time, since the functions was moved in Leopard. typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); @@ -491,8 +506,6 @@ public: void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi, QPainter *p, const QStyleOption *opt) const; - void drawPantherTab(const QStyleOptionTab *tab, QPainter *p, const QWidget *w = 0) const; - QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const; HIRect pushButtonContentBounds(const QStyleOptionButton *btn, @@ -545,7 +558,6 @@ QT_END_INCLUDE_NAMESPACE External functions *****************************************************************************/ extern CGContextRef qt_mac_cg_context(const QPaintDevice *); //qpaintdevice_mac.cpp -extern QPixmap qt_mac_convert_iconref(const IconRef, int, int); //qpixmap_mac.cpp extern QRegion qt_mac_convert_mac_region(HIShapeRef); //qregion_mac.cpp void qt_mac_dispose_rgn(RgnHandle r); //qregion_mac.cpp extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp @@ -566,11 +578,7 @@ QPixmap *qt_mac_backgroundPattern = 0; // stores the standard widget background. *****************************************************************************/ static inline int qt_mac_hitheme_tab_version() { -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) - return 1; -#endif - return 0; + return 1; } static inline HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &rect = QRect()) @@ -836,7 +844,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg } break; case QStyle::CT_HeaderSection: - if (sz == QAquaSizeLarge && isTreeView(widg)) + if (isTreeView(widg)) ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight)); break; case QStyle::CT_MenuBar: @@ -1036,7 +1044,7 @@ QSize QMacStylePrivate::pushButtonSizeFromContents(const QStyleOptionButton *btn : btn->fontMetrics.boundingRect(QRect(), Qt::AlignCenter, btn->text); csz.setWidth(iconSize.width() + textRect.width() + ((btn->features & QStyleOptionButton::HasMenu) - ? q->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, 0) : 0)); + ? q->proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, 0) : 0)); csz.setHeight(qMax(iconSize.height(), textRect.height())); return csz; } @@ -1456,8 +1464,7 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti } // Tiger broke reverse scroll bars so put them back and "fake it" - if (isScrollbar && (tdi->attributes & kThemeTrackRightToLeft) - && QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { + if (isScrollbar && (tdi->attributes & kThemeTrackRightToLeft)) { tdi->attributes &= ~kThemeTrackRightToLeft; tdi->value = tdi->max - slider->sliderPosition; } @@ -1540,166 +1547,6 @@ void QMacStylePrivate::startAnimationTimer() timerID = startTimer(animateSpeed(AquaListViewItemOpen)); } -enum { TabNormalLeft, TabNormalMid, TabNormalRight, TabSelectedActiveLeft, - TabSelectedActiveMid, TabSelectedActiveRight, TabSelectedInactiveLeft, - TabSelectedInactiveMid, TabSelectedInactiveRight, TabSelectedActiveGraphiteLeft, - TabSelectedActiveGraphiteMid, TabSelectedActiveGraphiteRight, - TabPressedLeft, TabPressedMid, TabPressedRight }; - -static const char * const * const PantherTabXpms[] = { - qt_mac_tabnrm_left, - qt_mac_tabnrm_mid, - qt_mac_tabnrm_right, - qt_mac_tabselected_active_left, - qt_mac_tabselected_active_mid, - qt_mac_tabselected_active_right, - qt_mac_tabselected_inactive_left, - qt_mac_tabselected_inactive_mid, - qt_mac_tabselected_inactive_right, - qt_mac_tab_selected_active_graph_left, - qt_mac_tab_selected_active_graph_mid, - qt_mac_tab_selected_active_graph_right, - qt_mac_tab_press_left, - qt_mac_tab_press_mid, - qt_mac_tab_press_right}; - -void QMacStylePrivate::drawPantherTab(const QStyleOptionTab *tabOpt, QPainter *p, - const QWidget *) const -{ - QString tabKey = QLatin1String("$qt_mac_style_tab_"); - int pantherTabStart; - int pantherTabMid; - int pantherTabEnd; - - ThemeTabDirection ttd = getTabDirection(tabOpt->shape); - - if (tabOpt->state & QStyle::State_Selected) { - if (!(tabOpt->state & QStyle::State_Active)) { - pantherTabStart = TabSelectedInactiveLeft; - } else { - // Draw into a pixmap to determine which version we use, Aqua or Graphite. - QPixmap tabPix(20, 20); - QPainter pixPainter(&tabPix); - HIThemeTabDrawInfo tdi; - tdi.version = 0; - tdi.style = kThemeTabFront; - tdi.direction = kThemeTabNorth; - tdi.size = kHIThemeTabSizeNormal; - tdi.adornment = kHIThemeTabAdornmentNone; - HIRect inRect = CGRectMake(0.0f, 0.0f, 20.0f, 20.0f); - HIThemeDrawTab(&inRect, &tdi, QMacCGContext(&pixPainter), kHIThemeOrientationNormal, 0); - pixPainter.end(); - const QRgb GraphiteColor = 0xffa7b0ba; - QRgb pmColor = tabPix.toImage().pixel(10, 10); - if (qAbs(qRed(pmColor) - qRed(GraphiteColor)) < 3 && - qAbs(qGreen(pmColor) - qGreen(GraphiteColor)) < 3 - && qAbs(qBlue(pmColor) - qBlue(GraphiteColor)) < 3) - pantherTabStart = TabSelectedActiveGraphiteLeft; - else - pantherTabStart = TabSelectedActiveLeft; - } - } else if (tabOpt->state & QStyle::State_Sunken) { - pantherTabStart = TabPressedLeft; - } else { - pantherTabStart = TabNormalLeft; - } - - - bool doLine; - bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast; - - QStyleOptionTab::TabPosition tp = tabOpt->position; - if (ttd == kThemeTabWest - || ((ttd == kThemeTabNorth || ttd == kThemeTabSouth) - && tabOpt->direction == Qt::RightToLeft)) { - if (tp == QStyleOptionTab::Beginning) - tp = QStyleOptionTab::End; - else if (tp == QStyleOptionTab::End) - tp = QStyleOptionTab::Beginning; - } - - switch (tp) { - default: // Stupid GCC, being overly pedantic - case QStyleOptionTab::Beginning: - doLine = false; - pantherTabMid = pantherTabEnd = pantherTabStart + 1; - break; - case QStyleOptionTab::Middle: - doLine = true; - pantherTabMid = pantherTabEnd = ++pantherTabStart; - break; - case QStyleOptionTab::End: - doLine = true; - pantherTabMid = ++pantherTabStart; - pantherTabEnd = pantherTabMid + 1; - break; - case QStyleOptionTab::OnlyOneTab: - doLine = false; - pantherTabMid = pantherTabStart + 1; - pantherTabEnd = pantherTabMid + 1; - break; - } - - QPixmap pmStart; - if (!QPixmapCache::find(tabKey + QString::number(pantherTabStart), pmStart)) { - pmStart = QPixmap(PantherTabXpms[pantherTabStart]); - QPixmapCache::insert(tabKey + QString::number(pantherTabStart), pmStart); - } - - QPixmap pmMid; - if (!QPixmapCache::find(tabKey + QString::number(pantherTabMid), pmMid)) { - pmMid = QPixmap(PantherTabXpms[pantherTabMid]); - QPixmapCache::insert(tabKey + QString::number(pantherTabMid), pmMid); - } - - QPixmap pmEnd; - if (!QPixmapCache::find(tabKey + QString::number(pantherTabEnd), pmEnd)) { - pmEnd = QPixmap(PantherTabXpms[pantherTabEnd]); - QPixmapCache::insert(tabKey + QString::number(pantherTabEnd), pmEnd); - } - QRect tr = tabOpt->rect; - if (verticalTabs) { - p->save(); - int newX, newY, newRot; - if (tabOpt->shape == QTabBar::RoundedEast || tabOpt->shape == QTabBar::TriangularEast) { - newX = tr.width(); - newY = tr.y(); - newRot = 90; - } else { - newX = 0; - newY = tr.y() + tr.height(); - newRot = -90; - } - tr.setRect(0, 0, tr.height(), tr.width()); - QMatrix m; - if (ttd == kThemeTabEast) { - // It's lame but Apple inverts these on the East side. - m.scale(-1, 1); - m.translate(-tabOpt->rect.width(), 0); - } - m.translate(newX, newY); - m.rotate(newRot); - p->setMatrix(m, true); - } - - int x = tr.x(); - int y = tr.y(); - int endX = x + tr.width() - pmEnd.width(); - - p->drawPixmap(x, y, pmStart.width(), tr.height(), pmStart); - if (doLine) { - QPen oldPen = p->pen(); - p->setPen(QColor(0, 0, 0, 0x35)); - p->drawLine(x, y + (verticalTabs ? 0 : 1), x, tr.height() - 2); - } - - for (x = x + pmStart.width(); x < endX; x += pmMid.width()) - p->drawPixmap(x, y, pmMid.width(), tr.height(), pmMid); - p->drawPixmap(endX, y, pmEnd.width(), tr.height(), pmEnd); - if (verticalTabs) - p->restore(); -} - bool QMacStylePrivate::addWidget(QWidget *w) { //already knew of it @@ -2012,22 +1859,10 @@ QMacStyle::~QMacStyle() QPixmap QMacStylePrivate::generateBackgroundPattern() const { QPixmap px(4, 4); -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { - QMacCGContext cg(&px); - HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal); - const CGRect cgRect = CGRectMake(0, 0, px.width(), px.height()); - CGContextFillRect(cg, cgRect); - } else -#endif - { -#ifndef QT_MAC_NO_QUICKDRAW - QMacSavedPortInfo port(&px); - SetThemeBackground(kThemeBrushDialogBackgroundActive, px.depth(), true); - const Rect qdRect = { 0, 0, px.width(), px.height() }; - EraseRect(&qdRect); -#endif - } + QMacCGContext cg(&px); + HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal); + const CGRect cgRect = CGRectMake(0, 0, px.width(), px.height()); + CGContextFillRect(cg, cgRect); return px; } @@ -2035,25 +1870,23 @@ QPixmap QMacStylePrivate::generateBackgroundPattern() const Fills the given \a rect with the pattern stored in \a brush. As an optimization, HIThemeSetFill us used directly if we are filling with the standard background. */ -void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint &offset, const QBrush &brush) +void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush) { -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) QPoint dummy; const QPaintDevice *target = painter->device(); const QPaintDevice *redirected = QPainter::redirected(target, &dummy); const bool usePainter = redirected && redirected != target; - const QRegion translated = rgn.translated(offset); - if (!usePainter && QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4 && qt_mac_backgroundPattern + if (!usePainter && qt_mac_backgroundPattern && qt_mac_backgroundPattern->cacheKey() == brush.texture().cacheKey()) { - painter->setClipRegion(translated); + painter->setClipRegion(rgn); CGContextRef cg = qt_mac_cg_context(target); CGContextSaveGState(cg); HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationInverted); - const QVector<QRect> &rects = translated.rects(); + const QVector<QRect> &rects = rgn.rects(); for (int i = 0; i < rects.size(); ++i) { const QRect rect(rects.at(i)); // Anchor the pattern to the top so it stays put when the window is resized. @@ -2063,11 +1896,9 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QPoint } CGContextRestoreGState(cg); - } else -#endif - { - const QRect rect(translated.boundingRect()); - painter->setClipRegion(translated); + } else { + const QRect rect(rgn.boundingRect()); + painter->setClipRegion(rgn); painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); } } @@ -2135,18 +1966,6 @@ void QMacStyle::polish(QWidget* w) } } - // Adjust the lineedit of the editable combo box - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_3) { - if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(w)) { - if (qobject_cast<QComboBox *>(lineEdit->parentWidget()) - && !lineEdit->testAttribute(Qt::WA_SetFont)) { - QFont font = lineEdit->font(); - font.setPointSize(font.pointSize() - 1); - lineEdit->setFont(font); - } - } - } - if (QTabBar *tb = qobject_cast<QTabBar*>(w)) { if (tb->documentMode()) { w->setAttribute(Qt::WA_Hover); @@ -2207,7 +2026,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW ret = closeButtonSize; break; case PM_ToolBarIconSize: - ret = pixelMetric(PM_LargeIconSize); + ret = proxy()->pixelMetric(PM_LargeIconSize); break; case PM_FocusFrameVMargin: case PM_FocusFrameHMargin: @@ -2381,12 +2200,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW GetThemeMetric(kThemeMetricScrollBarWidth, &ret); break; case QAquaSizeMini: -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3) && 0 - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_3) { - GetThemeMetric(kThemeMetricMiniScrollBarWidth, &ret); - break; - } -#endif case QAquaSizeSmall: GetThemeMetric(kThemeMetricSmallScrollBarWidth, &ret); break; @@ -2489,9 +2302,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW case PM_ToolBarItemSpacing: ret = 4; break; - case PM_MessageBoxIconSize: - ret = 64; - break; case PM_SplitterWidth: ret = qMax(7, QApplication::globalStrut().width()); break; @@ -2567,6 +2377,9 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW case PM_MenuHMargin: ret = 0; break; + case PM_ToolBarFrameWidth: + ret = 0; + break; default: ret = QWindowsStyle::pixelMetric(metric, opt, widget); break; @@ -2728,7 +2541,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w QPixmap pix(pixmapSize); pix.fill(QColor(fillR, fillG, fillB)); QPainter pix_paint(&pix); - drawControl(CE_FocusFrame, opt, &pix_paint, w); + proxy()->drawControl(CE_FocusFrame, opt, &pix_paint, w); pix_paint.end(); img = pix.toImage(); } @@ -3043,7 +2856,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai twf.rect = twf.rect.adjusted(0, -10, 0, 0); break; } - drawPrimitive(PE_FrameTabWidget, &twf, p, w); + proxy()->drawPrimitive(PE_FrameTabWidget, &twf, p, w); p->restore(); } break; @@ -3141,7 +2954,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { // In HITheme, up is down, down is up and hamburgers eat people. if (header->sortIndicator != QStyleOptionHeader::None) - drawPrimitive( + proxy()->drawPrimitive( (header->sortIndicator == QStyleOptionHeader::SortDown) ? PE_IndicatorArrowUp : PE_IndicatorArrowDown, header, p, w); } @@ -3275,7 +3088,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai fdi.isFocused = (frame->state & State_HasFocus); int lw = frame->lineWidth; if (lw <= 0) - lw = pixelMetric(PM_DefaultFrameWidth, frame, w); + lw = proxy()->pixelMetric(PM_DefaultFrameWidth, frame, w); { //clear to base color p->save(); p->setPen(QPen(baseColor, lw)); @@ -3300,27 +3113,14 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { HIRect hirect = qt_hirectForQRect(twf->rect); -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { - HIThemeTabPaneDrawInfo tpdi; - tpdi.version = qt_mac_hitheme_tab_version(); - tpdi.state = tds; - tpdi.direction = getTabDirection(twf->shape); - tpdi.size = kHIThemeTabSizeNormal; - if (tpdi.version == 1) { - tpdi.kind = kHIThemeTabKindNormal; - tpdi.adornment = kHIThemeTabPaneAdornmentNormal; - } - HIThemeDrawTabPane(&hirect, &tpdi, cg, kHIThemeOrientationNormal); - } else -#endif - { - HIThemeGroupBoxDrawInfo gdi; - gdi.version = qt_mac_hitheme_version; - gdi.state = tds; - gdi.kind = kHIThemeGroupBoxKindSecondary; - HIThemeDrawGroupBox(&hirect, &gdi, cg, kHIThemeOrientationNormal); - } + HIThemeTabPaneDrawInfo tpdi; + tpdi.version = qt_mac_hitheme_tab_version(); + tpdi.state = tds; + tpdi.direction = getTabDirection(twf->shape); + tpdi.size = kHIThemeTabSizeNormal; + tpdi.kind = kHIThemeTabKindNormal; + tpdi.adornment = kHIThemeTabPaneAdornmentNormal; + HIThemeDrawTabPane(&hirect, &tpdi, cg, kHIThemeOrientationNormal); } break; case PE_PanelScrollAreaCorner: { @@ -3344,7 +3144,6 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai QWindowsStyle::drawPrimitive(pe, opt, p, w); break; } - // Use the Leopard style only if the status bar is the status bar for a // QMainWindow with a unifed toolbar. if (w == 0 || w->parent() == 0 || qobject_cast<QMainWindow *>(w->parent()) == 0 || @@ -3488,16 +3287,16 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QIcon::Mode mode = QIcon::Disabled; if (opt->state & State_Enabled) mode = QIcon::Normal; - QPixmap pixmap = header->icon.pixmap(pixelMetric(PM_SmallIconSize), mode); + QPixmap pixmap = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), mode); QRect pixr = header->rect; pixr.setY(header->rect.center().y() - (pixmap.height() - 1) / 2); - drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap); + proxy()->drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap); textr.translate(pixmap.width() + 2, 0); } - drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette, - header->state & State_Enabled, header->text, QPalette::ButtonText); + proxy()->drawItemText(p, textr, header->textAlignment | Qt::AlignVCenter, header->palette, + header->state & State_Enabled, header->text, QPalette::ButtonText); } break; case CE_ToolButtonLabel: @@ -3508,58 +3307,89 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QRect cr = tb->rect; int shiftX = 0; int shiftY = 0; - if (tb->state & (State_Sunken | State_On)) { - shiftX = pixelMetric(PM_ButtonShiftHorizontal, tb, w); - shiftY = pixelMetric(PM_ButtonShiftVertical, tb, w); + bool needText = false; + int alignment = 0; + bool down = tb->state & (State_Sunken | State_On); + if (down) { + shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, w); + shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, tb, w); } // The down state is special for QToolButtons in a toolbar on the Mac // The text is a bit bolder and gets a drop shadow and the icons are also darkened. // This doesn't really fit into any particular case in QIcon, so we // do the majority of the work ourselves. - if (tb->state & State_Sunken - && !(tb->features & QStyleOptionToolButton::Arrow)) { + if (!(tb->features & QStyleOptionToolButton::Arrow)) { Qt::ToolButtonStyle tbstyle = tb->toolButtonStyle; if (tb->icon.isNull() && !tb->text.isEmpty()) tbstyle = Qt::ToolButtonTextOnly; switch (tbstyle) { - case Qt::ToolButtonTextOnly: - drawItemText(p, cr, Qt::AlignCenter, tb->palette, - tb->state & State_Enabled, tb->text); - break; + case Qt::ToolButtonTextOnly: { + needText = true; + alignment = Qt::AlignCenter; + break; } case Qt::ToolButtonIconOnly: case Qt::ToolButtonTextBesideIcon: case Qt::ToolButtonTextUnderIcon: { QRect pr = cr; QIcon::Mode iconMode = (tb->state & State_Enabled) ? QIcon::Normal - : QIcon::Disabled; + : QIcon::Disabled; QIcon::State iconState = (tb->state & State_On) ? QIcon::On - : QIcon::Off; + : QIcon::Off; QPixmap pixmap = tb->icon.pixmap(tb->rect.size().boundedTo(tb->iconSize), iconMode, iconState); // Draw the text if it's needed. if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) { - int alignment = 0; + needText = true; if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { - pr.setHeight(pixmap.size().height() + 6); - cr.adjust(0, pr.bottom(), 0, -3); + pr.setHeight(pixmap.size().height()); + cr.adjust(0, pr.bottom() + 1, 0, 1); alignment |= Qt::AlignCenter; } else { pr.setWidth(pixmap.width() + 8); cr.adjust(pr.right(), 0, 0, 0); alignment |= Qt::AlignLeft | Qt::AlignVCenter; } - cr.translate(shiftX, shiftY); - drawItemText(p, cr, alignment, tb->palette, - tb->state & State_Enabled, tb->text); - cr.adjust(0, 3, 0, -3); // the drop shadow - drawItemText(p, cr, alignment, tb->palette, - tb->state & State_Enabled, tb->text); } - pr.translate(shiftX, shiftY); - pixmap = darkenPixmap(pixmap); - drawItemPixmap(p, pr, Qt::AlignCenter, pixmap); + if (opt->state & State_Sunken) { + pr.translate(shiftX, shiftY); + pixmap = darkenPixmap(pixmap); + } + proxy()->drawItemPixmap(p, pr, Qt::AlignCenter, pixmap); break; } + default: + Q_ASSERT(false); + break; + } + + if (needText) { + QPalette pal = tb->palette; + QPalette::ColorRole role = QPalette::NoRole; + if (down) + cr.translate(shiftX, shiftY); + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 + && (tbstyle == Qt::ToolButtonTextOnly + || (tbstyle != Qt::ToolButtonTextOnly && !down))) { + QPen pen = p->pen(); + QColor light = down ? Qt::black : Qt::white; + light.setAlphaF(0.375f); + p->setPen(light); + p->drawText(cr.adjusted(0, 1, 0, 1), alignment, tb->text); + p->setPen(pen); + if (down && tbstyle == Qt::ToolButtonTextOnly) { + pal = QApplication::palette("QMenu"); + pal.setCurrentColorGroup(tb->palette.currentColorGroup()); + role = QPalette::HighlightedText; + } + } + drawItemText(p, cr, alignment, pal, + tb->state & State_Enabled, tb->text, role); + if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 && + (tb->state & State_Sunken)) { + // Draw a "drop shadow" in earlier versions. + drawItemText(p, cr.adjusted(0, 1, 0, 1), alignment, + tb->palette, tb->state & State_Enabled, tb->text); + } } } else { QWindowsStyle::drawControl(ce, &myTb, p, w); @@ -3609,7 +3439,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0); if (btn->features & QStyleOptionButton::HasMenu) { - int mbi = pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w); + int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w); QRect ir = btn->rect; HIRect arrowRect = CGRectMake(ir.right() - mbi - PushButtonRightOffset, ir.height() / 2 - 4, mbi, ir.height() / 2); @@ -3696,7 +3526,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (hasIcon) { int contentW = textRect.width(); if (hasMenu) - contentW += pixelMetric(PM_MenuButtonIndicator) + 4; + contentW += proxy()->pixelMetric(PM_MenuButtonIndicator) + 4; QIcon::Mode mode = btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; if (mode == QIcon::Normal && btn->state & State_HasFocus) mode = QIcon::Active; @@ -3710,7 +3540,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmap.height()) / 2; QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmap.width(), pixmap.height()); QRect visualIconDestRect = visualRect(btn->direction, freeContentRect, iconDestRect); - drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap); + proxy()->drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap); int newOffset = iconDestRect.x() + iconDestRect.width() + PushButtonContentPadding - textRect.x(); textRect.adjust(newOffset, 0, newOffset, 0); @@ -3718,8 +3548,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // Draw the text: if (hasText) { textRect = visualRect(btn->direction, freeContentRect, textRect); - drawItemText(p, textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, btn->palette, - (btn->state & State_Enabled), btn->text, QPalette::ButtonText); + proxy()->drawItemText(p, textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, btn->palette, + (btn->state & State_Enabled), btn->text, QPalette::ButtonText); } } } @@ -3744,104 +3574,104 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter return; } } - -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_3) { - HIThemeTabDrawInfo tdi; - tdi.version = 1; - tdi.style = kThemeTabNonFront; - tdi.direction = getTabDirection(tabOpt->shape); - switch (d->aquaSizeConstrain(opt, w)) { - default: - case QAquaSizeUnknown: - case QAquaSizeLarge: - tdi.size = kHIThemeTabSizeNormal; - break; - case QAquaSizeSmall: - tdi.size = kHIThemeTabSizeSmall; + HIThemeTabDrawInfo tdi; + tdi.version = 1; + tdi.style = kThemeTabNonFront; + tdi.direction = getTabDirection(tabOpt->shape); + switch (d->aquaSizeConstrain(opt, w)) { + default: + case QAquaSizeUnknown: + case QAquaSizeLarge: + tdi.size = kHIThemeTabSizeNormal; + break; + case QAquaSizeSmall: + tdi.size = kHIThemeTabSizeSmall; + break; + case QAquaSizeMini: + tdi.size = kHIThemeTabSizeMini; + break; + } + bool verticalTabs = tdi.direction == kThemeTabWest || tdi.direction == kThemeTabEast; + QRect tabRect = tabOpt->rect; + + bool selected = tabOpt->state & State_Selected; + if (selected) { + if (!(tabOpt->state & State_Active)) + tdi.style = kThemeTabFrontUnavailable; + else if (!(tabOpt->state & State_Enabled)) + tdi.style = kThemeTabFrontInactive; + else + tdi.style = kThemeTabFront; + } else if (!(tabOpt->state & State_Active)) { + tdi.style = kThemeTabNonFrontUnavailable; + } else if (!(tabOpt->state & State_Enabled)) { + tdi.style = kThemeTabNonFrontInactive; + } else if (tabOpt->state & State_Sunken) { + tdi.style = kThemeTabFrontInactive; // (should be kThemeTabNonFrontPressed) + } + if (tabOpt->state & State_HasFocus) + tdi.adornment = kHIThemeTabAdornmentFocus; + else + tdi.adornment = kHIThemeTabAdornmentNone; + tdi.kind = kHIThemeTabKindNormal; + if (!verticalTabs) + tabRect.setY(tabRect.y() - 1); + else + tabRect.setX(tabRect.x() - 1); + QStyleOptionTab::TabPosition tp = tabOpt->position; + QStyleOptionTab::SelectedPosition sp = tabOpt->selectedPosition; + if (tabOpt->direction == Qt::RightToLeft && !verticalTabs) { + if (sp == QStyleOptionTab::NextIsSelected) + sp = QStyleOptionTab::PreviousIsSelected; + else if (sp == QStyleOptionTab::PreviousIsSelected) + sp = QStyleOptionTab::NextIsSelected; + switch (tp) { + case QStyleOptionTab::Beginning: + tp = QStyleOptionTab::End; break; - case QAquaSizeMini: - tdi.size = kHIThemeTabSizeMini; + case QStyleOptionTab::End: + tp = QStyleOptionTab::Beginning; break; - } - bool verticalTabs = tdi.direction == kThemeTabWest || tdi.direction == kThemeTabEast; - QRect tabRect = tabOpt->rect; - - if ((!verticalTabs && tabRect.height() > 21 || verticalTabs && tabRect.width() > 21)) { - d->drawPantherTab(tabOpt, p, w); + default: break; } + } + switch (tp) { + case QStyleOptionTab::Beginning: + tdi.position = kHIThemeTabPositionFirst; + if (sp != QStyleOptionTab::NextIsSelected) + tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator; + break; + case QStyleOptionTab::Middle: + tdi.position = kHIThemeTabPositionMiddle; + if (selected) + tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator; + if (sp != QStyleOptionTab::NextIsSelected) // Also when we're selected. + tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator; + break; + case QStyleOptionTab::End: + tdi.position = kHIThemeTabPositionLast; + if (selected) + tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator; + break; + case QStyleOptionTab::OnlyOneTab: + tdi.position = kHIThemeTabPositionOnly; + break; + } - bool selected = tabOpt->state & State_Selected; - if (selected) { - if (!(tabOpt->state & State_Active)) - tdi.style = kThemeTabFrontUnavailable; - else if (!(tabOpt->state & State_Enabled)) - tdi.style = kThemeTabFrontInactive; - else - tdi.style = kThemeTabFront; - } else if (!(tabOpt->state & State_Active)) { - tdi.style = kThemeTabNonFrontUnavailable; - } else if (!(tabOpt->state & State_Enabled)) { - tdi.style = kThemeTabNonFrontInactive; - } else if (tabOpt->state & State_Sunken) { - tdi.style = kThemeTabFrontInactive; // (should be kThemeTabNonFrontPressed) - } - if (tabOpt->state & State_HasFocus) - tdi.adornment = kHIThemeTabAdornmentFocus; - else - tdi.adornment = kHIThemeTabAdornmentNone; - tdi.kind = kHIThemeTabKindNormal; - if (!verticalTabs) - tabRect.setY(tabRect.y() - 1); - else - tabRect.setX(tabRect.x() - 1); - QStyleOptionTab::TabPosition tp = tabOpt->position; - QStyleOptionTab::SelectedPosition sp = tabOpt->selectedPosition; - if (tabOpt->direction == Qt::RightToLeft && !verticalTabs) { - if (sp == QStyleOptionTab::NextIsSelected) - sp = QStyleOptionTab::PreviousIsSelected; - else if (sp == QStyleOptionTab::PreviousIsSelected) - sp = QStyleOptionTab::NextIsSelected; - switch (tp) { - case QStyleOptionTab::Beginning: - tp = QStyleOptionTab::End; - break; - case QStyleOptionTab::End: - tp = QStyleOptionTab::Beginning; - break; - default: - break; - } - } - switch (tp) { - case QStyleOptionTab::Beginning: - tdi.position = kHIThemeTabPositionFirst; - if (sp != QStyleOptionTab::NextIsSelected) - tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator; - break; - case QStyleOptionTab::Middle: - tdi.position = kHIThemeTabPositionMiddle; - if (selected) - tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator; - if (sp != QStyleOptionTab::NextIsSelected) // Also when we're selected. - tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator; - break; - case QStyleOptionTab::End: - tdi.position = kHIThemeTabPositionLast; - if (selected) - tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator; - break; - case QStyleOptionTab::OnlyOneTab: - tdi.position = kHIThemeTabPositionOnly; - break; + // HITheme doesn't stretch its tabs. Therefore we have to cheat and do the job ourselves. + if ((!verticalTabs && tabRect.height() > 21 || verticalTabs && tabRect.width() > 21)) { + HIRect hirect = CGRectMake(0, 0, 23, 23); + QPixmap pm(23, 23); + pm.fill(Qt::transparent); + { + QMacCGContext pmcg(&pm); + HIThemeDrawTab(&hirect, &tdi, pmcg, kHIThemeOrientationNormal, 0); } + QStyleHelper::drawBorderPixmap(pm, p, tabRect, 7, 7, 7, 7); + } else { HIRect hirect = qt_hirectForQRect(tabRect); HIThemeDrawTab(&hirect, &tdi, cg, kHIThemeOrientationNormal, 0); - } else -#endif - { - d->drawPantherTab(tabOpt, p, w); } } break; @@ -3876,7 +3706,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QRect nr = subElementRect(SE_TabBarTabText, opt, w); nr.moveTop(+1); int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic; - drawItemText(p, nr, alignment, np, tab->state & State_Enabled, tab->text, QPalette::WindowText); + proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, + tab->text, QPalette::WindowText); p->restore(); } @@ -3999,8 +3830,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } break; case CE_FocusFrame: { - int xOff = pixelMetric(PM_FocusFrameHMargin, opt, w) + 1; - int yOff = pixelMetric(PM_FocusFrameVMargin, opt, w) + 1; + int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w) + 1; + int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w) + 1; HIRect hirect = CGRectMake(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff, opt->rect.height() - 2 * yOff); HIThemeDrawFocusRect(&hirect, true, QMacCGContext(p), kHIThemeOrientationNormal); @@ -4123,7 +3954,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QIcon::Mode mode = (mi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; // Always be normal or disabled to follow the Mac style. - int smallIconSize = pixelMetric(PM_SmallIconSize); + int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize); QSize iconSize(smallIconSize, smallIconSize); if (const QComboBox *comboBox = qobject_cast<const QComboBox *>(w)) { iconSize = comboBox->iconSize(); @@ -4158,8 +3989,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter const int xm = macItemFrame + maxpmw + macItemHMargin; QFont myFont = mi->font; - if (mi->state & QStyle::State_Mini) - myFont.setPointSize(mi->font.pointSize()); + // myFont may not have any "hard" flags set. We override + // the point size so that when it is resolved against the device, this font will win. + // This is mainly to handle cases where someone sets the font on the window + // and then the combo inherits it and passes it onward. At that point the resolve mask + // is very, very weak. This makes it stonger. + myFont.setPointSizeF(mi->font.pointSizeF()); p->setFont(myFont); p->drawText(xpos, yPos, contentRect.width() - xm - tabwidth + 1, contentRect.height(), text_flags ^ Qt::AlignRight, s); @@ -4233,7 +4068,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter drawItemPixmap(p, mi->rect, Qt::AlignCenter | Qt::TextHideMnemonic | Qt::TextDontClip | Qt::TextSingleLine, - mi->icon.pixmap(pixelMetric(PM_SmallIconSize), + mi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (mi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled)); } else { drawItemText(p, mi->rect, @@ -4293,7 +4128,19 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter tdi.enableState = kThemeTrackDisabled; else tdi.enableState = kThemeTrackActive; - HIThemeDrawTrack(&tdi, 0, cg, kHIThemeOrientationNormal); + HIThemeOrientation drawOrientation = kHIThemeOrientationNormal; + if (reverse) { + if (vertical) { + drawOrientation = kHIThemeOrientationInverted; + } else { + CGContextSaveGState(cg); + CGContextTranslateCTM(cg, pb->rect.width(), 0); + CGContextScaleCTM(cg, -1, 1); + } + } + HIThemeDrawTrack(&tdi, 0, cg, drawOrientation); + if (reverse && !vertical) + CGContextRestoreGState(cg); } break; case CE_ProgressBarLabel: @@ -4381,9 +4228,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter case CE_ToolBar: { // For unified tool bars, draw nothing. if (w) { - if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(w->window())) + if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(w->window())) { if (mainWindow->unifiedTitleAndToolBarOnMac()) break; + } } // draw background gradient @@ -4752,10 +4600,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex // similar when I have an upside down scroll bar // because on Tiger I only "fake" the reverse stuff. bool reverseHorizontal = (slider->direction == Qt::RightToLeft - && slider->orientation == Qt::Horizontal - && (!slider->upsideDown - || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4 - && slider->upsideDown))); + && slider->orientation == Qt::Horizontal); if ((reverseHorizontal && slider->activeSubControls == SC_ScrollBarAddLine) || (!reverseHorizontal @@ -4857,7 +4702,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex treeOpt.state |= State_Children; if (item.state & State_Open) treeOpt.state |= State_Open; - drawPrimitive(PE_IndicatorBranch, &treeOpt, p, widget); + proxy()->drawPrimitive(PE_IndicatorBranch, &treeOpt, p, widget); } y += item.totalHeight; } @@ -4871,7 +4716,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex SInt32 frame_size; GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size); - QRect lineeditRect = subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget); + QRect lineeditRect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget); lineeditRect.adjust(-frame_size, -frame_size, +frame_size, +frame_size); HIThemeFrameDrawInfo fdi; @@ -4915,9 +4760,9 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex bdi.value = kThemeButtonOff; bdi.adornment = kThemeAdornmentNone; - QRect updown = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); + QRect updown = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); - updown |= subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); + updown |= proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); HIRect newRect = qt_hirectForQRect(updown); QRect off_rct; HIRect outRect; @@ -5030,7 +4875,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex &titleRegion2); ptrHIShapeGetBounds(titleRegion2, &tmpRect); if (tmpRect.size.width != 1) { - int iconExtent = pixelMetric(PM_SmallIconSize); + int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); iw = titlebar->icon.actualSize(QSize(iconExtent, iconExtent)).width(); } } @@ -5048,7 +4893,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex else x += br.width() / 2 - p->fontMetrics().width(titlebar->text) / 2; if (iw) - p->drawPixmap(x - iw, y, titlebar->icon.pixmap(pixelMetric(PM_SmallIconSize), QIcon::Normal)); + p->drawPixmap(x - iw, y, + titlebar->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), QIcon::Normal)); drawItemText(p, br, Qt::AlignCenter, opt->palette, tds == kThemeStateActive, titlebar->text, QPalette::Text); p->restore(); @@ -5085,7 +4931,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex tti.truncationPosition = kHIThemeTextTruncationNone; tti.truncationMaxLines = 1 + groupBox->text.count(QLatin1Char('\n')); QCFString groupText = qt_mac_removeMnemonics(groupBox->text); - QRect r = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); + QRect r = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); HIRect bounds = qt_hirectForQRect(r); HIThemeDrawTextBox(groupText, &bounds, &tti, cg, kHIThemeOrientationNormal); p->restore(); @@ -5098,29 +4944,35 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) { if (tb->subControls & SC_ToolButtonMenu) { QStyleOption arrowOpt(0); - arrowOpt.rect = subControlRect(cc, tb, SC_ToolButtonMenu, widget); + arrowOpt.rect = proxy()->subControlRect(cc, tb, SC_ToolButtonMenu, widget); arrowOpt.rect.setY(arrowOpt.rect.y() + arrowOpt.rect.height() / 2); arrowOpt.rect.setHeight(arrowOpt.rect.height() / 2); arrowOpt.state = tb->state; arrowOpt.palette = tb->palette; - drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); } else if ((tb->features & QStyleOptionToolButton::HasMenu) && (tb->toolButtonStyle != Qt::ToolButtonTextOnly && !tb->icon.isNull())) { drawToolbarButtonArrow(tb->rect, tds, cg); } if (tb->state & State_On) { - QPen oldPen = p->pen(); - p->setPen(QColor(0, 0, 0, 0x3a)); - p->fillRect(tb->rect.adjusted(1, 1, -1, -1), QColor(0, 0, 0, 0x12)); - p->drawLine(tb->rect.left() + 1, tb->rect.top(), - tb->rect.right() - 1, tb->rect.top()); - p->drawLine(tb->rect.left() + 1, tb->rect.bottom(), - tb->rect.right() - 1, tb->rect.bottom()); - p->drawLine(tb->rect.topLeft(), tb->rect.bottomLeft()); - p->drawLine(tb->rect.topRight(), tb->rect.bottomRight()); - p->setPen(oldPen); + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { + static QPixmap pm(QLatin1String(":/trolltech/mac/style/images/leopard-unified-toolbar-on.png")); + p->setRenderHint(QPainter::SmoothPixmapTransform); + QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2); + } else { + QPen oldPen = p->pen(); + p->setPen(QColor(0, 0, 0, 0x3a)); + p->fillRect(tb->rect.adjusted(1, 1, -1, -1), QColor(0, 0, 0, 0x12)); + p->drawLine(tb->rect.left() + 1, tb->rect.top(), + tb->rect.right() - 1, tb->rect.top()); + p->drawLine(tb->rect.left() + 1, tb->rect.bottom(), + tb->rect.right() - 1, tb->rect.bottom()); + p->drawLine(tb->rect.topLeft(), tb->rect.bottomLeft()); + p->drawLine(tb->rect.topRight(), tb->rect.bottomRight()); + p->setPen(oldPen); + } } - drawControl(CE_ToolButtonLabel, opt, p, widget); + proxy()->drawControl(CE_ToolButtonLabel, opt, p, widget); } else { ThemeButtonKind bkind = kThemeBevelButton; switch (d->aquaSizeConstrain(opt, widget)) { @@ -5129,20 +4981,14 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex bkind = kThemeBevelButton; break; case QAquaSizeMini: -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3) && 0 - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_3) { - bkind = kThemeMiniBevelButton; - break; - } -#endif case QAquaSizeSmall: bkind = kThemeSmallBevelButton; break; } QRect button, menuarea; - button = subControlRect(cc, tb, SC_ToolButton, widget); - menuarea = subControlRect(cc, tb, SC_ToolButtonMenu, widget); + button = proxy()->subControlRect(cc, tb, SC_ToolButton, widget); + menuarea = proxy()->subControlRect(cc, tb, SC_ToolButtonMenu, widget); State bflags = tb->state, mflags = tb->state; if (tb->subControls & SC_ToolButton) @@ -5205,14 +5051,18 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } else if (tb->features & QStyleOptionToolButton::HasMenu) { drawToolbarButtonArrow(tb->rect, tds, cg); } - QRect buttonRect = subControlRect(CC_ToolButton, tb, SC_ToolButton, widget); - int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); + QRect buttonRect = proxy()->subControlRect(CC_ToolButton, tb, SC_ToolButton, widget); + int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); QStyleOptionToolButton label = *tb; label.rect = buttonRect.adjusted(fw, fw, -fw, -fw); - drawControl(CE_ToolButtonLabel, &label, p, widget); + proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); } } break; + case CC_Dial: + if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt)) + QStyleHelper::drawDial(dial, p); + break; default: QWindowsStyle::drawComplexControl(cc, opt, p, widget); break; @@ -5379,11 +5229,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op cpc = sc == SC_ScrollBarSubLine ? kControlUpButtonPart : kControlDownButtonPart; if (slider->direction == Qt::RightToLeft - && slider->orientation == Qt::Horizontal - && (!slider->upsideDown - || (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4 - && slider->upsideDown)) - ) { + && slider->orientation == Qt::Horizontal) { if (cpc == kControlDownButtonPart) cpc = kControlUpButtonPart; else if (cpc == kControlUpButtonPart) @@ -5436,7 +5282,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op else if (sc == SC_TitleBarLabel) wrc = kWindowTitleTextRgn; else if (sc == SC_TitleBarSysMenu) - ret.setRect(-1024, -1024, 10, pixelMetric(PM_TitleBarHeight, + ret.setRect(-1024, -1024, 10, proxy()->pixelMetric(PM_TitleBarHeight, titlebar, widget)); if (wrc != kWindowGlobalPortRgn) { QCFType<HIShapeRef> region; @@ -5533,7 +5379,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op QRect labelRect = alignedRect(groupBox->direction, groupBox->textAlignment, QSize(tw, h), ret); - int indicatorWidth = pixelMetric(PM_IndicatorWidth, opt, widget); + int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget); bool rtl = groupBox->direction == Qt::RightToLeft; if (sc == SC_GroupBoxLabel) { if (checkable) { @@ -5555,7 +5401,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op if (sc == SC_GroupBoxCheckBox) { int left = rtl ? labelRect.right() - indicatorWidth : labelRect.left(); ret.setRect(left, ret.top(), - indicatorWidth, pixelMetric(PM_IndicatorHeight, opt, widget)); + indicatorWidth, proxy()->pixelMetric(PM_IndicatorHeight, opt, widget)); } break; } @@ -5593,7 +5439,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op QAquaWidgetSize aquaSize = d->aquaSizeConstrain(spin, widget); int spinner_w; int spinBoxSep; - int fw = pixelMetric(PM_SpinBoxFrameWidth, spin, widget); + int fw = proxy()->pixelMetric(PM_SpinBoxFrameWidth, spin, widget); switch (aquaSize) { default: case QAquaSizeUnknown: @@ -5701,11 +5547,6 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, break; case QStyle::CT_TabBarTab: if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) { - bool newStyleTabs = -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) - QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4 ? true : -#endif - false; const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget); const bool differentFont = (widget && widget->testAttribute(Qt::WA_SetFont)) || !QApplication::desktopSettingsAware(); @@ -5713,86 +5554,61 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, bool vertTabs = ttd == kThemeTabWest || ttd == kThemeTabEast; if (vertTabs) sz.transpose(); - if (newStyleTabs) { - int defaultTabHeight; - int defaultExtraSpace = pixelMetric(PM_TabBarTabHSpace, tab, widget); // Remove spurious gcc warning (AFAIK) - QFontMetrics fm = opt->fontMetrics; - switch (AquaSize) { - case QAquaSizeUnknown: - case QAquaSizeLarge: - if (tab->documentMode) - defaultTabHeight = 23; - else - defaultTabHeight = 21; - break; - case QAquaSizeSmall: - defaultTabHeight = 18; - break; - case QAquaSizeMini: - defaultTabHeight = 16; - break; - } - - bool setWidth = false; - if (differentFont || !tab->icon.isNull()) { - sz.rheight() = qMax(defaultTabHeight, sz.height()); - } else { - QSize textSize = fm.size(Qt::TextShowMnemonic, tab->text); - sz.rheight() = qMax(defaultTabHeight, textSize.height()); - sz.rwidth() = textSize.width() + defaultExtraSpace; - setWidth = true; - } + int defaultTabHeight; + int defaultExtraSpace = proxy()->pixelMetric(PM_TabBarTabHSpace, tab, widget); // Remove spurious gcc warning (AFAIK) + QFontMetrics fm = opt->fontMetrics; + switch (AquaSize) { + case QAquaSizeUnknown: + case QAquaSizeLarge: + if (tab->documentMode) + defaultTabHeight = 23; + else + defaultTabHeight = 21; + break; + case QAquaSizeSmall: + defaultTabHeight = 18; + break; + case QAquaSizeMini: + defaultTabHeight = 16; + break; + } + bool setWidth = false; + if (differentFont || !tab->icon.isNull()) { + sz.rheight() = qMax(defaultTabHeight, sz.height()); + } else { + QSize textSize = fm.size(Qt::TextShowMnemonic, tab->text); + sz.rheight() = qMax(defaultTabHeight, textSize.height()); + sz.rwidth() = textSize.width() + defaultExtraSpace; + setWidth = true; + } - if (vertTabs) - sz.transpose(); + if (vertTabs) + sz.transpose(); - int maxWidgetHeight = qMax(tab->leftButtonSize.height(), tab->rightButtonSize.height()); - int maxWidgetWidth = qMax(tab->leftButtonSize.width(), tab->rightButtonSize.width()); + int maxWidgetHeight = qMax(tab->leftButtonSize.height(), tab->rightButtonSize.height()); + int maxWidgetWidth = qMax(tab->leftButtonSize.width(), tab->rightButtonSize.width()); - int widgetWidth = 0; - int widgetHeight = 0; - int padding = 0; - if (tab->leftButtonSize.isValid()) { - padding += 8; - widgetWidth += tab->leftButtonSize.width(); - widgetHeight += tab->leftButtonSize.height(); - } - if (tab->rightButtonSize.isValid()) { - padding += 8; - widgetWidth += tab->rightButtonSize.width(); - widgetHeight += tab->rightButtonSize.height(); - } + int widgetWidth = 0; + int widgetHeight = 0; + int padding = 0; + if (tab->leftButtonSize.isValid()) { + padding += 8; + widgetWidth += tab->leftButtonSize.width(); + widgetHeight += tab->leftButtonSize.height(); + } + if (tab->rightButtonSize.isValid()) { + padding += 8; + widgetWidth += tab->rightButtonSize.width(); + widgetHeight += tab->rightButtonSize.height(); + } - if (vertTabs) { - sz.setHeight(sz.height() + widgetHeight + padding); - sz.setWidth(qMax(sz.width(), maxWidgetWidth)); - } else { - if (setWidth) - sz.setWidth(sz.width() + widgetWidth + padding); - sz.setHeight(qMax(sz.height(), maxWidgetHeight)); - } + if (vertTabs) { + sz.setHeight(sz.height() + widgetHeight + padding); + sz.setWidth(qMax(sz.width(), maxWidgetWidth)); } else { - SInt32 tabh = sz.height(); - SInt32 overlap = 0; - switch (AquaSize) { - default: - case QAquaSizeUnknown: - case QAquaSizeLarge: - GetThemeMetric(kThemeLargeTabHeight, &tabh); - GetThemeMetric(kThemeMetricTabFrameOverlap, &overlap); - break; - case QAquaSizeMini: - GetThemeMetric(kThemeMetricMiniTabHeight, &tabh); - GetThemeMetric(kThemeMetricMiniTabFrameOverlap, &overlap); - break; - case QAquaSizeSmall: - GetThemeMetric(kThemeSmallTabHeight, &tabh); - GetThemeMetric(kThemeMetricSmallTabFrameOverlap, &overlap); - break; - } - tabh += overlap; - if (sz.height() < tabh) - sz.rheight() = tabh; + if (setWidth) + sz.setWidth(sz.width() + widgetWidth + padding); + sz.setHeight(qMax(sz.height(), maxWidgetHeight)); } } break; @@ -5822,7 +5638,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, h = qMax(h, iconSize.height() + 4); maxpmw = qMax(maxpmw, iconSize.width()); } else { - int iconExtent = pixelMetric(PM_SmallIconSize); + int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4); } } @@ -5851,6 +5667,14 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } break; case CT_ToolButton: + if (widget && qobject_cast<const QToolBar *>(widget->parentWidget())) { + sz.rwidth() += 4; + if (sz.height() <= 32) { + // Workaround strange HIToolBar bug when getting constraints. + sz.rheight() += 1; + } + return sz; + } sz.rwidth() += 10; sz.rheight() += 10; return sz; @@ -5861,7 +5685,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, QStyleHintReturnMask menuMask; QStyleOption myOption = *opt; myOption.rect.setSize(sz); - if (styleHint(SH_Menu_Mask, &myOption, widget, &menuMask)) { + if (proxy()->styleHint(SH_Menu_Mask, &myOption, widget, &menuMask)) { sz = menuMask.region.boundingRect().size(); } break; } @@ -6030,78 +5854,12 @@ bool QMacStyle::event(QEvent *e) return false; } -void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon, QStyle::StandardPixmap standardIcon = QStyle::SP_CustomBase) -{ - int size = 16; - while (size <= 128) { - - const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size); - QPixmap mainIcon; - if (standardIcon >= QStyle::SP_CustomBase) { - mainIcon = qt_mac_convert_iconref(icon, size, size); - } else if (QPixmapCache::find(cacheKey, mainIcon) == false) { - mainIcon = qt_mac_convert_iconref(icon, size, size); - QPixmapCache::insert(cacheKey, mainIcon); - } - - if (overlayIcon) { - int littleSize = size / 2; - QPixmap overlayPix = qt_mac_convert_iconref(overlayIcon, littleSize, littleSize); - QPainter painter(&mainIcon); - painter.drawPixmap(size - littleSize, size - littleSize, overlayPix); - } - - retIcon->addPixmap(mainIcon); - size += size; // 16 -> 32 -> 64 -> 128 - } -} - QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt, const QWidget *widget) const { - OSType iconType = 0; switch (standardIcon) { - case QStyle::SP_MessageBoxQuestion: - case QStyle::SP_MessageBoxInformation: - case QStyle::SP_MessageBoxWarning: - case QStyle::SP_MessageBoxCritical: - iconType = kGenericApplicationIcon; - break; - case SP_DesktopIcon: - iconType = kDesktopIcon; - break; - case SP_TrashIcon: - iconType = kTrashIcon; - break; -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) - case SP_ComputerIcon: - iconType = kComputerIcon; - break; -#endif - case SP_DriveFDIcon: - iconType = kGenericFloppyIcon; - break; - case SP_DriveHDIcon: - iconType = kGenericHardDiskIcon; - break; - case SP_DriveCDIcon: - case SP_DriveDVDIcon: - iconType = kGenericCDROMIcon; - break; - case SP_DriveNetIcon: - iconType = kGenericNetworkIcon; - break; - case SP_DirOpenIcon: - iconType = kOpenFolderIcon; - break; - case SP_DirClosedIcon: - case SP_DirLinkIcon: - iconType = kGenericFolderIcon; - break; - case SP_FileLinkIcon: - case SP_FileIcon: - iconType = kGenericDocumentIcon; - break; + default: + return QWindowsStyle::standardIconImplementation(standardIcon, opt, widget); case SP_ToolBarHorizontalExtensionButton: case SP_ToolBarVerticalExtensionButton: { QPixmap pixmap(qt_mac_toolbar_ext); @@ -6115,58 +5873,8 @@ QIcon QMacStyle::standardIconImplementation(StandardPixmap standardIcon, const Q return pix2; } return pixmap; - } - break; - case SP_DirIcon: { - // A rather special case - QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, opt, widget); - QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, opt, widget); - closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On); - closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On); - closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On); - closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On); - return closeIcon; - } - case SP_TitleBarNormalButton: - case SP_TitleBarCloseButton: { - QIcon titleBarIcon; - if (standardIcon == SP_TitleBarCloseButton) { - titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-16.png")); - titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); - } else { - titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-16.png")); - titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); - } - return titleBarIcon; } - default: - break; - } - if (iconType != 0) { - QIcon retIcon; - IconRef icon; - IconRef overlayIcon = 0; - if (iconType != kGenericApplicationIcon) { - GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); - } else { - FSRef fsRef; - ProcessSerialNumber psn = { 0, kCurrentProcess }; - GetProcessBundleLocation(&psn, &fsRef); - GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); - if (standardIcon == SP_MessageBoxCritical) { - overlayIcon = icon; - GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); - } - } - if (icon) { - qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon); - ReleaseIconRef(icon); - } - if (overlayIcon) - ReleaseIconRef(overlayIcon); - return retIcon; } - return QWindowsStyle::standardIconImplementation(standardIcon, opt, widget); } int QMacStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, diff --git a/src/gui/styles/qmacstylepixmaps_mac_p.h b/src/gui/styles/qmacstylepixmaps_mac_p.h index 0382acc..eacd6bd 100644 --- a/src/gui/styles/qmacstylepixmaps_mac_p.h +++ b/src/gui/styles/qmacstylepixmaps_mac_p.h @@ -50,1406 +50,6 @@ // We mean it. // -static const char *const qt_mac_tabnrm_left[]={ -"6 22 71 2", -"#a c #5f5f5f", -"## c #6d6d6d", -".c c #737373", -".d c #757575", -".b c #7c7c7c", -".n c #7d7d7d", -".r c #828282", -".f c #838383", -"#. c #878787", -".7 c #8c8c8c", -".v c #8e8e8e", -".4 c #939393", -".1 c #969696", -".j c #979797", -".a c #9a9a9a", -".6 c #9b9b9b", -".A c #a0a0a0", -".Z c #a6a6a6", -".C c #aaaaaa", -".3 c #aeaeae", -".E c #afafaf", -".J c #b3b3b3", -".8 c #b7b7b7", -".o c #b8b8b8", -".g c #b9b9b9", -".P c #bcbcbc", -".R c #bfbfbf", -".T c #c2c2c2", -".s c #c4c4c4", -"#e c #c6c6c6", -".V c #c7c7c7", -".w c #c9c9c9", -".B c #cacaca", -"#d c #cbcbcb", -".z c #cecece", -".F c #cfcfcf", -".5 c #d1d1d1", -"#c c #d3d3d3", -".K c #d4d4d4", -".G c #d5d5d5", -".Q c #d6d6d6", -".S c #d8d8d8", -".U c #dadada", -".2 c #dbdbdb", -".L c #dcdcdc", -".H c #dedede", -".I c #dfdfdf", -".M c #e0e0e0", -".X c #e1e1e1", -".D c #e2e2e2", -"#b c #e3e3e3", -".O c #e4e4e4", -".N c #e6e6e6", -".9 c #e7e7e7", -".e c #e8e8e8", -".# c #e9e9e9", -".t c #ebebeb", -"Qt c #ececec", -".p c #ededed", -".x c #eeeeee", -".y c #efefef", -".u c #f1f1f1", -".k c #f2f2f2", -".q c #f3f3f3", -".W c #f6f6f6", -".l c #f7f7f7", -".m c #f8f8f8", -".Y c #f9f9f9", -".h c #fcfcfc", -".i c #fdfdfd", -".0 c #ffffff", -"Qt.#.a.b.c.d", -".e.f.gQt.h.i", -".j.a.k.l.m.m", -".n.o.p.k.q.q", -".r.s.t.u.u.u", -".v.w.t.x.y.y", -".a.z.#.p.x.x", -".A.B.#.t.x.p", -".C.B.D.t.x.x", -".E.F.G.H.I.I", -".J.K.L.M.N.O", -".P.Q.D.#.e.#", -".R.S.O.p.x.p", -".T.U.#.u.u.k", -".V.I.t.q.W.W", -".P.X.k.W.Y.Y", -".Z.M.u.Y.0.0", -".1.2.l.0.0.0", -".3.4.m.0.0.0", -".5.6.7.8.9.0", -".X.5.3#.###a", -".O#b.L#c#d#e"}; - -static const char *const qt_mac_tabnrm_mid[]={ -"6 22 18 1", -"n c #585858", -". c #777777", -"p c #c2c2c2", -"o c #c3c3c3", -"g c #dedede", -"h c #e5e5e5", -"i c #e8e8e8", -"f c #ededed", -"e c #eeeeee", -"d c #efefef", -"c c #f1f1f1", -"b c #f3f3f3", -"j c #f6f6f6", -"a c #f8f8f8", -"k c #f9f9f9", -"# c #fdfdfd", -"l c #fefefe", -"m c #ffffff", -"......", -"######", -"aaaaaa", -"bbbbbb", -"cccccc", -"dddddd", -"eeeeee", -"ffffff", -"eeeeee", -"gggggg", -"hhhhhh", -"iiiiii", -"eeeeee", -"cccccc", -"jjjjjj", -"kkkkkk", -"llllll", -"mmmmmm", -"mmmmmm", -"mmmmmm", -"nnnnnn", -"oppooo"}; - -static const char *const qt_mac_tabnrm_right[]={ -"6 22 70 2", -".9 c #5f5f5f", -"#. c #6d6d6d", -".# c #747474", -"Qt c #757575", -".a c #7c7c7c", -".p c #7d7d7d", -".t c #828282", -".h c #838383", -"## c #888888", -".6 c #8c8c8c", -".x c #8e8e8e", -".3 c #929292", -".2 c #969696", -".l c #979797", -".b c #9a9a9a", -".7 c #9b9b9b", -".A c #a0a0a0", -".0 c #a6a6a6", -".C c #aaaaaa", -"#a c #aeaeae", -".H c #afafaf", -".N c #b3b3b3", -".5 c #b7b7b7", -".o c #b8b8b8", -".g c #b9b9b9", -".Q c #bcbcbc", -".S c #bfbfbf", -".U c #c2c2c2", -".s c #c4c4c4", -"#b c #c6c6c6", -".W c #c7c7c7", -".w c #c9c9c9", -".z c #cacaca", -".y c #cecece", -".G c #cfcfcf", -".8 c #d1d1d1", -"#c c #d3d3d3", -".M c #d4d4d4", -".F c #d5d5d5", -".P c #d6d6d6", -".R c #d8d8d8", -".T c #dadada", -".1 c #dbdbdb", -".L c #dcdcdc", -".E c #dedede", -".D c #dfdfdf", -".K c #e0e0e0", -".Y c #e1e1e1", -".B c #e2e2e2", -".I c #e4e4e4", -"#d c #e5e5e5", -".J c #e6e6e6", -".4 c #e7e7e7", -".O c #e8e8e8", -".c c #e9e9e9", -".r c #ebebeb", -".d c #ececec", -".n c #ededed", -".v c #eeeeee", -".u c #efefef", -".q c #f1f1f1", -".k c #f2f2f2", -".m c #f3f3f3", -".V c #f6f6f6", -".j c #f7f7f7", -".i c #f8f8f8", -".X c #f9f9f9", -".f c #fcfcfc", -".e c #fdfdfd", -".Z c #ffffff", -"Qt.#.a.b.c.d", -".e.f.d.g.h.c", -".i.i.j.k.b.l", -".m.m.k.n.o.p", -".q.q.q.r.s.t", -".u.u.v.r.w.x", -".v.v.n.c.y.b", -".n.v.r.c.z.A", -".v.v.r.B.z.C", -".D.D.E.F.G.H", -".I.J.K.L.M.N", -".c.O.c.B.P.Q", -".n.v.n.I.R.S", -".k.q.q.c.T.U", -".V.V.m.r.D.W", -".X.X.V.k.Y.Q", -".Z.Z.X.q.K.0", -".Z.Z.Z.j.1.2", -".Z.Z.Z.i.3.H", -".Z.4.5.6.7.8", -".9#.###a.8.B", -"#b.z#c.L.I#d"}; - -static const char *const qt_mac_tabselected_active_left[]={ -"6 22 130 2", -".d c #000069", -".C c #0042b4", -".I c #0157bb", -".w c #0c28a0", -".l c #101094", -".O c #1163c4", -".c c #1a1a6e", -".U c #1e6ec9", -".r c #214eb7", -".x c #256cc9", -".0 c #2877ce", -".6 c #347fd1", -".D c #3981d2", -"#a c #3a81d2", -"#g c #418ad7", -".J c #4288d4", -".q c #45459b", -".V c #458cd5", -".g c #46469f", -".P c #4a8dd7", -".1 c #4a90db", -"#m c #4b91db", -"#s c #4e91dc", -"#y c #4f8dcd", -".7 c #5195df", -".b c #525280", -"#E c #5984b2", -"#b c #5b9be1", -"#R c #5c7e9f", -".2 c #5d9de6", -"#5 c #5f5f5f", -"#Y c #627c8d", -"#h c #65a4e7", -".3 c #65a6e8", -".8 c #67a6eb", -"#n c #69a6e8", -"#c c #6cabed", -"#4 c #6d6d6d", -".4 c #6dacee", -".5 c #6eabee", -"#K c #6f87a1", -"#L c #70aff1", -".9 c #70aff2", -"#t c #71aced", -"#z c #72afee", -"#F c #72afef", -".f c #757592", -"#i c #75b3f4", -"#d c #75b4f3", -"#Z c #77a6b3", -"#. c #77b1f4", -"## c #7ab4f4", -".W c #7cb0e7", -"#o c #7cb8f9", -"#f c #80bdf9", -"#e c #81bbf9", -"#j c #81bbfc", -"#u c #86c1ff", -"#3 c #878787", -"#k c #89c2fd", -"#A c #89c3ff", -".Q c #8bb9e8", -"#l c #8bc4ff", -"#p c #8bc6ff", -"#G c #8dc7ff", -".K c #8ebae8", -"#S c #8ecbff", -"#q c #91c8ff", -"#M c #92ccff", -"#v c #93ccff", -".k c #9494b0", -"#r c #94caff", -".E c #96bde8", -".X c #96c3ee", -"#w c #96cfff", -"#B c #97cfff", -".Y c #99c4ee", -"#x c #99d0ff", -".a c #9a9aa4", -"#X c #9b9b9b", -".s c #9bbee8", -".R c #9bc4ee", -".T c #9cc5ee", -".Z c #9dc7ef", -"#C c #9dd3ff", -".y c #9ec3e8", -".L c #9ec3ed", -".M c #9ec5ed", -"#H c #9ed6ff", -".S c #9fc5ee", -"#D c #a1d7ff", -".N c #a3c8ed", -"#N c #a3daff", -".F c #a5c8ed", -".G c #a7c9ed", -"#J c #a7ddff", -"#I c #a7deff", -".H c #a8caee", -"#T c #a8e0ff", -"#0 c #a8e2e6", -".z c #a9caed", -"#O c #abe3ff", -".A c #adcbed", -"#P c #ade3ff", -"#Q c #aeaeae", -".m c #afbbe7", -".B c #afccee", -"#U c #b0e9ff", -".t c #b3d1ed", -"#V c #b5ebff", -".u c #bad4ee", -".v c #bbd4ef", -".h c #bfc2e8", -"#1 c #bffdff", -"a# c #c6c6c6", -"a. c #cbcbcb", -".n c #cbddf2", -".o c #cce0f3", -".p c #cfe1f4", -"#W c #d1d1d1", -"#9 c #d3d3d3", -"#8 c #dcdcdc", -"#2 c #e1e1e1", -"#7 c #e3e3e3", -"#6 c #e4e4e4", -".i c #e6e9f6", -".e c #e8e8e8", -".# c #e9e9e9", -".j c #e9edf8", -"Qt c #ececec", -"Qt.#.a.b.c.d", -".e.f.g.h.i.j", -".k.l.m.n.o.p", -".q.r.s.t.u.v", -".w.x.y.z.A.B", -".C.D.E.F.G.H", -".I.J.K.L.M.N", -".O.P.Q.R.S.T", -".U.V.W.X.Y.Z", -".0.1.2.3.4.5", -".6.7.8.9#.##", -"#a#b#c#d#e#f", -"#g#h#i#j#k#l", -"#m#n#o#p#q#r", -"#s#t#u#v#w#x", -"#y#z#A#B#C#D", -"#E#F#G#H#I#J", -"#K#L#M#N#O#P", -"#Q#R#S#T#U#V", -"#W#X#Y#Z#0#1", -"#2#W#Q#3#4#5", -"#6#7#8#9a.a#"}; - -static const char *const qt_mac_tabselected_active_mid[]={ -"6 22 23 1", -". c #00006d", -"s c #585858", -"h c #70adef", -"i c #7bb5f5", -"j c #83bcf9", -"k c #8bc3ff", -"l c #93c9ff", -"m c #9ad1ff", -"f c #9ec5ef", -"g c #9ec7f0", -"n c #a0d6ff", -"e c #a2c7ed", -"d c #a8caee", -"o c #a8deff", -"p c #ade2ff", -"c c #afceee", -"q c #b6ecff", -"b c #bbd5f0", -"r c #c1feff", -"u c #c2c2c2", -"t c #c3c3c3", -"a c #cfe1f3", -"# c #e9edf8", -"......", -"######", -"aaaaaa", -"bbbbbb", -"cccccc", -"dddddd", -"eeeeee", -"ffffff", -"gggggg", -"hhhhhh", -"iiiiii", -"jjjjjj", -"kkkkkk", -"llllll", -"mmmmmm", -"nnnnnn", -"oooooo", -"pppppp", -"qqqqqq", -"rrrrrr", -"ssssss", -"ttttuu"}; - -static const char *const qt_mac_tabselected_active_right[]={ -"6 22 128 2", -"Qt c #000069", -".G c #0042b4", -".M c #0157bb", -".A c #0c28a0", -".n c #101094", -".S c #1163c4", -".# c #1b1b6e", -".Y c #1e6ec9", -".t c #214eb7", -".z c #256cc9", -".4 c #2877ce", -"#. c #347fd1", -".F c #3981d2", -"#e c #3a81d2", -"#k c #418ad7", -".L c #4288d4", -".u c #45459b", -".X c #458cd5", -".h c #46469f", -".R c #4a8dd7", -".3 c #4a90db", -"#q c #4b91db", -"#w c #4e91dc", -"#C c #4f8dcd", -".9 c #5195df", -".a c #525280", -"#I c #5984b2", -"#T c #5b7d9f", -"#d c #5b9be1", -".2 c #5d9de6", -"#1 c #5f5f5f", -"#Y c #627c8d", -"#j c #65a4e7", -".1 c #65a6e8", -".8 c #67a6eb", -"#p c #69a6e8", -"#c c #6cabed", -"#2 c #6d6d6d", -".0 c #6dacee", -".Z c #6eabee", -"#O c #6f87a1", -"#N c #70aff1", -".7 c #70aff2", -"#v c #71aced", -"#B c #72afee", -"#H c #72afef", -".i c #757592", -"#i c #75b3f4", -"#b c #75b4f3", -"#X c #77a6b3", -".6 c #77b1f4", -".5 c #7ab4f4", -".W c #7cb0e7", -"#o c #7cb8f9", -"## c #80bdf9", -"#a c #81bbf9", -"#h c #81bbfc", -"#u c #86c1ff", -"#3 c #888888", -"#g c #89c2fd", -"#A c #89c3ff", -".Q c #8bb9e8", -"#f c #8bc4ff", -"#n c #8bc6ff", -"#G c #8dc7ff", -".K c #8ebae8", -"#S c #8ecbff", -"#m c #91c8ff", -"#M c #92ccff", -"#t c #93ccff", -".o c #9494b0", -"#l c #94caff", -".E c #96bde8", -".V c #96c3ee", -"#s c #96cfff", -"#z c #97cfff", -".U c #99c4ee", -"#r c #99d0ff", -".b c #9a9aa4", -"#Z c #9b9b9b", -".s c #9bbee8", -".P c #9bc4ee", -".N c #9cc5ee", -".T c #9dc7ef", -"#y c #9dd3ff", -".y c #9ec3e8", -".J c #9ec3ed", -".I c #9ec5ed", -"#F c #9ed6ff", -".O c #9fc5ee", -"#x c #a1d7ff", -".H c #a3c8ed", -"#L c #a3daff", -".D c #a5c8ed", -".C c #a7c9ed", -"#D c #a7ddff", -"#E c #a7deff", -".B c #a8caee", -"#R c #a8e0ff", -"#W c #a8e2e6", -".x c #a9caed", -"#K c #abe3ff", -".w c #adcbed", -"#J c #ade3ff", -"#U c #aeaeae", -".m c #afbbe7", -".v c #afccee", -"#Q c #b0e9ff", -".r c #b3d1ed", -"#P c #b5ebff", -".q c #bad4ee", -".p c #bbd4ef", -".g c #bfc2e8", -"#V c #bffdff", -"#5 c #c6c6c6", -"#6 c #cacaca", -".l c #cbddf2", -".k c #cce0f3", -".j c #cfe1f4", -"#0 c #d1d1d1", -"#7 c #d3d3d3", -"#8 c #dcdcdc", -"#4 c #e2e2e2", -"#9 c #e4e4e4", -".f c #e6e9f6", -".c c #e9e9e9", -".e c #e9edf8", -".d c #ececec", -"Qt.#.a.b.c.d", -".e.f.g.h.i.c", -".j.k.l.m.n.o", -".p.q.r.s.t.u", -".v.w.x.y.z.A", -".B.C.D.E.F.G", -".H.I.J.K.L.M", -".N.O.P.Q.R.S", -".T.U.V.W.X.Y", -".Z.0.1.2.3.4", -".5.6.7.8.9#.", -"###a#b#c#d#e", -"#f#g#h#i#j#k", -"#l#m#n#o#p#q", -"#r#s#t#u#v#w", -"#x#y#z#A#B#C", -"#D#E#F#G#H#I", -"#J#K#L#M#N#O", -"#P#Q#R#S#T#U", -"#V#W#X#Y#Z#0", -"#1#2#3#U#0#4", -"#5#6#7#8#9#9"}; - -static const char *const qt_mac_tabselected_inactive_left[]={ -"6 22 64 1", -"9 c #656565", -"8 c #737373", -"c c #767676", -"b c #808080", -"n c #818181", -"q c #828282", -"e c #888888", -"7 c #8b8b8b", -"u c #8d8d8d", -"3 c #939393", -"k c #979797", -"0 c #989898", -"j c #9b9b9b", -"A c #9d9d9d", -"a c #9e9e9e", -"4 c #9f9f9f", -"Y c #a3a3a3", -"C c #a6a6a6", -"E c #aaaaaa", -"J c #aeaeae", -"6 c #b0b0b0", -"2 c #b1b1b1", -"o c #b2b2b2", -"f c #b3b3b3", -"O c #b6b6b6", -"Q c #b9b9b9", -"S c #bbbbbb", -"r c #bdbdbd", -"U c #c0c0c0", -"v c #c2c2c2", -"B c #c3c3c3", -"y c #c6c6c6", -"F c #c7c7c7", -"K c #cccccc", -"G c #cdcdcd", -"R c #cfcfcf", -"T c #d1d1d1", -"1 c #d2d2d2", -"L c #d3d3d3", -"H c #d5d5d5", -"I c #d6d6d6", -"W c #d7d7d7", -"D c #d8d8d8", -"N c #dadada", -"M c #dcdcdc", -"5 c #dddddd", -"P c #dedede", -"z c #dfdfdf", -"s c #e0e0e0", -"g c #e1e1e1", -"p c #e2e2e2", -"w c #e3e3e3", -"x c #e4e4e4", -"t c #e6e6e6", -"l c #e7e7e7", -"d c #e8e8e8", -"# c #e9e9e9", -"V c #eaeaea", -"m c #ebebeb", -". c #ececec", -"X c #ededed", -"h c #f0f0f0", -"i c #f1f1f1", -"Z c #f2f2f2", -".#abcc", -"defghi", -"jklm..", -"nopldd", -"qrsttt", -"uvswxx", -"kyzpww", -"ABzswp", -"CBDsww", -"EFGHII", -"JKLIMN", -"OGDzPz", -"QRNpwp", -"STzttl", -"UIsdVV", -"OWlVXX", -"YItXZZ", -"01mZZZ", -"23.ZZZ", -"T4uo5Z", -"gT6789", -"xwMLKF"}; - -static const char *const qt_mac_tabselected_inactive_mid[]={ -"6 22 17 1", -"m c #5f5f5f", -". c #787878", -"o c #c3c3c3", -"n c #c4c4c4", -"g c #d5d5d5", -"h c #dbdbdb", -"i c #dedede", -"f c #e2e2e2", -"e c #e3e3e3", -"d c #e4e4e4", -"c c #e6e6e6", -"b c #e8e8e8", -"j c #eaeaea", -"a c #ececec", -"k c #ededed", -"# c #f1f1f1", -"l c #f2f2f2", -"......", -"######", -"aaaaaa", -"bbbbbb", -"cccccc", -"dddddd", -"eeeeee", -"ffffff", -"eeeeee", -"gggggg", -"hhhhhh", -"iiiiii", -"eeeeee", -"cccccc", -"jjjjjj", -"kkkkkk", -"llllll", -"llllll", -"llllll", -"llllll", -"mmmmmm", -"nnnnno"}; - -static const char *const qt_mac_tabselected_inactive_right[]={ -"6 22 65 2", -".6 c #656565", -".7 c #737373", -"Qt c #767676", -".# c #808080", -".p c #818181", -".t c #828282", -".h c #888888", -".8 c #8c8c8c", -".x c #8d8d8d", -".2 c #929292", -".k c #979797", -".1 c #989898", -".l c #9b9b9b", -".B c #9d9d9d", -".a c #9e9e9e", -".5 c #9f9f9f", -".Z c #a3a3a3", -".D c #a6a6a6", -".I c #aaaaaa", -".N c #aeaeae", -".9 c #b0b0b0", -".3 c #b1b1b1", -".o c #b2b2b2", -".g c #b3b3b3", -".P c #b6b6b6", -".R c #b9b9b9", -".T c #bbbbbb", -".s c #bdbdbd", -".V c #c0c0c0", -".w c #c2c2c2", -".A c #c3c3c3", -".z c #c6c6c6", -".H c #c7c7c7", -"#. c #cbcbcb", -".M c #cccccc", -".G c #cdcdcd", -".Q c #cfcfcf", -".S c #d1d1d1", -".0 c #d2d2d2", -".L c #d3d3d3", -".F c #d5d5d5", -".E c #d6d6d6", -".X c #d7d7d7", -".C c #d8d8d8", -".J c #dadada", -".K c #dcdcdc", -".4 c #dddddd", -".O c #dedede", -".y c #dfdfdf", -".r c #e0e0e0", -".f c #e1e1e1", -".n c #e2e2e2", -".v c #e3e3e3", -".u c #e4e4e4", -".q c #e6e6e6", -".j c #e7e7e7", -".m c #e8e8e8", -".b c #e9e9e9", -".U c #eaeaea", -".i c #ebebeb", -".c c #ececec", -".W c #ededed", -".e c #f0f0f0", -".d c #f1f1f1", -".Y c #f2f2f2", -"QtQt.#.a.b.c", -".d.e.f.g.h.b", -".c.c.i.j.k.l", -".m.m.j.n.o.p", -".q.q.q.r.s.t", -".u.u.v.r.w.x", -".v.v.n.y.z.k", -".n.v.r.y.A.B", -".v.v.r.C.A.D", -".E.E.F.G.H.I", -".J.K.E.L.M.N", -".y.O.y.C.G.P", -".n.v.n.J.Q.R", -".j.q.q.y.S.T", -".U.U.m.r.E.V", -".W.W.U.j.X.P", -".Y.Y.W.q.E.Z", -".Y.Y.Y.i.0.1", -".Y.Y.Y.c.2.3", -".Y.4.o.x.5.S", -".6.7.8.9.S.n", -".H#..L.K.u.u"}; - -static const char * const qt_mac_tab_selected_active_graph_left[]={ -"6 22 126 2", -".d c #15283d", -".c c #283348", -".w c #374459", -".l c #435364", -".B c #465568", -".q c #4d5367", -".b c #525763", -".H c #536271", -".N c #5d6a79", -"#1 c #5f5f5f", -".T c #647181", -"#N c #656e77", -".r c #677282", -"#B c #687380", -"#U c #697077", -".Z c #6c7885", -".5 c #6c7988", -"#0 c #6d6d6d", -"#H c #6f767f", -".x c #727e8a", -"## c #757f8d", -".f c #76767d", -"#v c #76838f", -"#e c #778292", -"#k c #7b8694", -".U c #7b8794", -".C c #7b8795", -".O c #7c8893", -".I c #7d8896", -".g c #7e8895", -".0 c #7e8b99", -"#q c #818c98", -".6 c #85909e", -"#Z c #878787", -"#a c #8a96a3", -"#f c #8d99a7", -".1 c #8e99a6", -"#V c #929ca5", -"#l c #939daa", -".k c #949499", -".7 c #96a0ad", -".2 c #98a3af", -"#r c #99a5b0", -".a c #9a9a9b", -"#I c #9aa4b1", -"#T c #9b9b9b", -".3 c #9ba6b1", -"#b c #9ba6b3", -".8 c #9ca7b4", -".4 c #9da6b1", -"#w c #9da7b5", -"#C c #9ea9b5", -".V c #a0a9b4", -"#g c #a0abb8", -"#. c #a3acb8", -".9 c #a4adba", -"#c c #a6afbc", -"#m c #a8b1bd", -"#d c #a9b3bf", -".J c #abb3bc", -".P c #adb4bb", -"#h c #adb8c3", -"#M c #aeaeae", -"#j c #aeb8c4", -".W c #b0b8c2", -"#i c #b0bac6", -".D c #b3bac3", -"#x c #b3bcc8", -"#n c #b3bdc9", -".Q c #b4bac2", -"#D c #b5bfc9", -".y c #b6bdc5", -"#o c #b6becb", -"#s c #b7c2ce", -".K c #b8bdc6", -".X c #b8bfc8", -"#p c #b8c1ce", -".S c #b9bec7", -".R c #b9bfc8", -".Y c #b9c1c7", -".M c #b9c1c8", -"#J c #bac5cf", -".L c #bbbfc8", -"#O c #bbc7d4", -".s c #bcc3ca", -"#t c #bcc5d1", -"#u c #bcc6d2", -".E c #bdc3ca", -"#y c #bdc7d2", -".G c #bec3cb", -".F c #bec5cb", -".z c #c2c7ce", -"#E c #c2cad6", -".A c #c3c9d0", -"#z c #c3ccd7", -"#A c #c3ced7", -".m c #c5c9d0", -"#7 c #c6c6c6", -"#K c #c7d2dd", -".t c #c8ced3", -"#F c #c8d3de", -"#G c #c9d3df", -"#6 c #cbcbcb", -".u c #cbd1d6", -".v c #ccd2d7", -".h c #ced2d6", -"#W c #ced8e4", -"#L c #d0dae3", -"#S c #d1d1d1", -"#P c #d1dbe6", -"#5 c #d3d3d3", -".n c #d5dadc", -"#Q c #d5deea", -".o c #d7dbdf", -"#R c #d7e1ec", -".p c #dadde0", -"#4 c #dcdcdc", -".i c #e0e2e6", -"#Y c #e1e1e1", -"#3 c #e3e3e3", -"#2 c #e4e4e4", -".j c #e6e8ea", -".e c #e8e8e8", -".# c #e9e9e9", -"#X c #e9f4ff", -"Qt c #ececec", -"Qt.#.a.b.c.d", -".e.f.g.h.i.j", -".k.l.m.n.o.p", -".q.r.s.t.u.v", -".w.x.y.z.A.A", -".B.C.D.E.F.G", -".H.I.J.K.L.M", -".N.O.P.Q.R.S", -".T.U.V.W.X.Y", -".Z.0.1.2.3.4", -".5.6.7.8.9#.", -"###a#b#c#d#d", -"#e#f#g#h#i#j", -"#k#l#m#n#o#p", -"#q#r#h#s#t#u", -"#v#w#x#y#z#A", -"#B#C#D#E#F#G", -"#H#I#J#K#L#L", -"#M#N#O#P#Q#R", -"#S#T#U#V#W#X", -"#Y#S#M#Z#0#1", -"#2#3#4#5#6#7"}; - -static const char * const qt_mac_tab_selected_active_graph_mid[]={ -"6 22 41 1", -". c #15273d", -"# c #16283e", -"a c #17293e", -"b c #192a3f", -"c c #1a2b40", -"K c #585858", -"p c #9ea8b4", -"q c #a4adb9", -"r c #aab4bf", -"s c #afb9c6", -"o c #b6bcc6", -"n c #b8bec6", -"t c #b8c2ce", -"m c #bbc2c8", -"u c #bbc5d0", -"l c #bec4cb", -"v c #bfcad4", -"L c #c2c2c2", -"k c #c2c9ce", -"M c #c3c3c3", -"w c #c7d1dd", -"i c #cad0d5", -"j c #cbd0d5", -"x c #ccd5e1", -"y c #cdd6e2", -"z c #ced6e2", -"A c #d5dfeb", -"B c #d6e0ec", -"C c #d7e1ed", -"e c #d8dbe0", -"f c #d8dce0", -"g c #d9dce0", -"D c #d9e2ee", -"h c #dadce0", -"E c #dae2ef", -"d c #e7e9eb", -"J c #e9f2ff", -"I c #eaf3ff", -"H c #ebf5ff", -"G c #ecf6ff", -"F c #edf6ff", -"..#abc", -"dddddd", -"eeefgh", -"iiiiij", -"kkkkkk", -"llllll", -"mmmmmm", -"nnnnnn", -"oooooo", -"pppppp", -"qqqqqq", -"rrrrrr", -"ssssss", -"tttttt", -"uuuuuu", -"vvvvvv", -"wwwwww", -"xxxxyz", -"AABCDE", -"FFGHIJ", -"KKKKKK", -"LLLLMM"}; - -static const char * const qt_mac_tab_selected_active_graph_right[]={ -"6 22 124 2", -"Qt c #15283d", -".# c #293448", -".z c #374459", -".n c #435364", -".F c #465568", -".u c #4d5367", -".a c #525763", -".L c #536271", -".R c #5d6a79", -"#X c #5f5f5f", -"#P c #646d77", -".X c #647181", -".t c #677282", -"#F c #687380", -"#U c #697077", -".3 c #6c7885", -".9 c #6c7988", -"#Y c #6d6d6d", -"#K c #6f767f", -".y c #727e8a", -"#c c #757f8d", -".i c #76767d", -"#z c #76838f", -"#i c #778292", -"#o c #7b8694", -".W c #7b8794", -".E c #7b8795", -".Q c #7c8893", -".K c #7d8896", -".h c #7e8895", -".2 c #7e8b99", -"#t c #818c98", -".8 c #85909e", -"#Z c #888888", -"#b c #8a96a3", -"#h c #8d99a7", -".1 c #8e99a6", -"#T c #929ca5", -"#n c #939daa", -".o c #949499", -".7 c #96a0ad", -".0 c #98a3af", -"#s c #99a5b0", -".b c #9a9a9b", -"#J c #9aa4b1", -"#V c #9b9b9b", -".Z c #9ba6b1", -"#a c #9ba6b3", -".6 c #9ca7b4", -".Y c #9da6b1", -"#y c #9da7b5", -"#E c #9ea9b5", -".V c #a0a9b4", -"#g c #a0abb8", -".4 c #a3acb8", -".5 c #a4adba", -"## c #a6afbc", -"#m c #a8b1bd", -"#. c #a9b3bf", -".J c #abb3bc", -".P c #adb4bb", -"#f c #adb8c3", -"#Q c #aeaeae", -"#d c #aeb8c4", -".U c #b0b8c2", -"#e c #b0bac6", -".D c #b3bac3", -"#x c #b3bcc8", -"#l c #b3bdc9", -".O c #b4bac2", -"#D c #b5bfc9", -".x c #b6bdc5", -"#k c #b6becb", -"#r c #b7c2ce", -".I c #b8bdc6", -".T c #b8bfc8", -"#j c #b8c1ce", -".M c #b9bec7", -".N c #b9bfc8", -".S c #b9c1c7", -".G c #b9c1c8", -"#I c #bac5cf", -".H c #bbbfc8", -"#O c #bbc7d4", -".s c #bcc3ca", -"#q c #bcc5d1", -"#p c #bcc6d2", -".C c #bdc3ca", -"#w c #bdc7d2", -".A c #bec3cb", -".B c #bec5cb", -".w c #c2c7ce", -"#C c #c2cad6", -".v c #c3c9d0", -"#v c #c3ccd7", -"#u c #c3ced7", -".m c #c5c9d0", -"#1 c #c6c6c6", -"#H c #c7d2dd", -".r c #c8ced3", -"#B c #c8d3de", -"#A c #c9d3df", -"#2 c #cacaca", -".q c #cbd1d6", -".p c #ccd2d7", -".g c #ced2d6", -"#S c #ced8e4", -"#G c #d0dae3", -"#W c #d1d1d1", -"#N c #d1dbe6", -"#3 c #d3d3d3", -".l c #d5dadc", -"#M c #d5deea", -".k c #d7dbdf", -"#L c #d7e1ec", -".j c #dadde0", -"#4 c #dcdcdc", -".f c #e0e2e6", -"#0 c #e2e2e2", -"#5 c #e4e4e4", -".e c #e6e8ea", -".c c #e9e9e9", -"#R c #e9f4ff", -".d c #ececec", -"Qt.#.a.b.c.d", -".e.f.g.h.i.c", -".j.k.l.m.n.o", -".p.q.r.s.t.u", -".v.v.w.x.y.z", -".A.B.C.D.E.F", -".G.H.I.J.K.L", -".M.N.O.P.Q.R", -".S.T.U.V.W.X", -".Y.Z.0.1.2.3", -".4.5.6.7.8.9", -"#.#.###a#b#c", -"#d#e#f#g#h#i", -"#j#k#l#m#n#o", -"#p#q#r#f#s#t", -"#u#v#w#x#y#z", -"#A#B#C#D#E#F", -"#G#G#H#I#J#K", -"#L#M#N#O#P#Q", -"#R#S#T#U#V#W", -"#X#Y#Z#Q#W#0", -"#1#2#3#4#5#5"}; - -static const char * const qt_mac_tab_press_left[]={ -"6 22 65 2", -".8 c #5c5c5c", -".c c #696969", -".d c #6a6a6a", -".b c #767676", -".f c #7e7e7e", -".t c #808080", -".4 c #828282", -".7 c #838383", -".2 c #888888", -".k c #8b8b8b", -".0 c #8c8c8c", -".z c #909090", -".j c #919191", -".a c #959595", -".Y c #989898", -".B c #999999", -".D c #9e9e9e", -".I c #a1a1a1", -".n c #a6a6a6", -".g c #a7a7a7", -".6 c #a8a8a8", -".O c #aaaaaa", -".1 c #ababab", -".R c #acacac", -".T c #afafaf", -".q c #b1b1b1", -".V c #b3b3b3", -".u c #b5b5b5", -".A c #b6b6b6", -".x c #bababa", -".E c #bbbbbb", -"#. c #bebebe", -".J c #bfbfbf", -".F c #c0c0c0", -".P c #c1c1c1", -".S c #c3c3c3", -".U c #c5c5c5", -".K c #c6c6c6", -".G c #c8c8c8", -".H c #c9c9c9", -".L c #cacaca", -".X c #cbcbcb", -".C c #cccccc", -".3 c #cdcdcd", -".N c #cecece", -".M c #cfcfcf", -".5 c #d0d0d0", -".Q c #d1d1d1", -".y c #d2d2d2", -".r c #d4d4d4", -".h c #d5d5d5", -".o c #d6d6d6", -".v c #d7d7d7", -".w c #d8d8d8", -".s c #d9d9d9", -".l c #dadada", -".p c #dbdbdb", -".9 c #dcdcdc", -".W c #dedede", -".m c #dfdfdf", -".e c #e0e0e0", -".# c #e1e1e1", -".i c #e3e3e3", -"Qt c #e4e4e4", -".Z c #e6e6e6", -"Qt.#.a.b.c.d", -".e.f.g.h.iQt", -".j.k.l.m.e.e", -".b.n.o.l.p.p", -".b.q.r.s.s.s", -".t.u.r.v.w.w", -".k.x.y.o.v.v", -".z.A.y.r.v.o", -".B.A.C.r.v.v", -".D.E.F.G.H.H", -".I.J.K.L.M.N", -".O.P.C.y.Q.y", -".R.S.N.o.v.o", -".T.U.y.s.s.l", -".V.H.r.p.W.W", -".O.X.l.W.#.#", -".Y.L.s.#.Z.Z", -".0.K.m.Z.Z.Z", -".1.2.e.Z.Z.Z", -".3.Y.4.n.5.Z", -".s.H.6.7.d.8", -".9.l.r.L.S#."}; - -static const char * const qt_mac_tab_press_mid[]={ -"7 22 19 1", -"o c #555555", -". c #6b6b6b", -"p c #bbbbbb", -"q c #bcbcbc", -"g c #c8c8c8", -"h c #cecece", -"i c #d1d1d1", -"f c #d6d6d6", -"e c #d7d7d7", -"d c #d8d8d8", -"c c #d9d9d9", -"j c #dadada", -"b c #dbdbdb", -"k c #dedede", -"a c #e0e0e0", -"l c #e1e1e1", -"# c #e4e4e4", -"m c #e5e5e5", -"n c #e6e6e6", -".......", -"#######", -"aaaaaaa", -"bbbbbbb", -"ccccccc", -"ddddddd", -"eeeeeee", -"fffffff", -"eeeeeee", -"ggggggg", -"hhhhhhh", -"iiiiiii", -"eeeeeee", -"jjjjjjj", -"kkkkkkk", -"lllllll", -"mmmmmmm", -"nnnnnnn", -"nnnnnnn", -"nnnnnnn", -"ooooooo", -"ppppqqq"}; - -static const char * const qt_mac_tab_press_right[]={ -"6 22 64 1", -"5 c #5c5c5c", -". c #6a6a6a", -"# c #767676", -"g c #7e7e7e", -"v c #808080", -"3 c #828282", -"6 c #848484", -"0 c #888888", -"k c #8b8b8b", -"Z c #8c8c8c", -"z c #909090", -"l c #919191", -"a c #959595", -"Y c #989898", -"B c #999999", -"G c #9e9e9e", -"M c #a1a1a1", -"o c #a6a6a6", -"f c #a7a7a7", -"7 c #a8a8a8", -"P c #aaaaaa", -"1 c #ababab", -"R c #acacac", -"T c #afafaf", -"r c #b1b1b1", -"V c #b3b3b3", -"u c #b5b5b5", -"y c #b6b6b6", -"x c #bababa", -"F c #bbbbbb", -"8 c #bebebe", -"L c #bfbfbf", -"E c #c0c0c0", -"O c #c1c1c1", -"9 c #c2c2c2", -"Q c #c3c3c3", -"S c #c5c5c5", -"K c #c6c6c6", -"D c #c8c8c8", -"C c #c9c9c9", -"J c #cacaca", -"W c #cbcbcb", -"A c #cccccc", -"4 c #cdcdcd", -"H c #cecece", -"I c #cfcfcf", -"2 c #d0d0d0", -"N c #d1d1d1", -"w c #d2d2d2", -"q c #d4d4d4", -"e c #d5d5d5", -"n c #d6d6d6", -"t c #d7d7d7", -"s c #d8d8d8", -"p c #d9d9d9", -"j c #dadada", -"m c #dbdbdb", -"U c #dedede", -"i c #dfdfdf", -"h c #e0e0e0", -"b c #e1e1e1", -"d c #e3e3e3", -"c c #e4e4e4", -"X c #e6e6e6", -"..#abc", -"cdefgb", -"hhijkl", -"mmjno#", -"pppqr#", -"sstquv", -"ttnwxk", -"ntqwyz", -"ttqAyB", -"CCDEFG", -"HIJKLM", -"wNwAOP", -"ntnHQR", -"jppwST", -"UUmqCV", -"bbUjWP", -"XXbpJY", -"XXXiKZ", -"XXXh01", -"X2o3Y4", -"5.67Cj", -"89Jqmm"}; - static const char * const qt_mac_toolbar_ext[]={ "14 9 4 1", "# c #858585", diff --git a/src/gui/styles/qmotifstyle.cpp b/src/gui/styles/qmotifstyle.cpp index aa2007f..328b1c9 100644 --- a/src/gui/styles/qmotifstyle.cpp +++ b/src/gui/styles/qmotifstyle.cpp @@ -386,7 +386,7 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP case PE_FrameTabWidget: case PE_FrameWindow: - qDrawShadePanel(p, opt->rect, opt->palette, QStyle::State_None, pixelMetric(PM_DefaultFrameWidth)); + qDrawShadePanel(p, opt->rect, opt->palette, QStyle::State_None, proxy()->pixelMetric(PM_DefaultFrameWidth)); break; case PE_FrameFocusRect: if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) { @@ -475,7 +475,7 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP fill = opt->palette.brush(QPalette::Button); if ((opt->state & State_Enabled || opt->state & State_On) || !(opt->state & State_AutoRaise)) qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken | State_On)), - pixelMetric(PM_DefaultFrameWidth), &fill); + proxy()->pixelMetric(PM_DefaultFrameWidth), &fill); break; } case PE_IndicatorCheckBox: { @@ -490,9 +490,9 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP opt->rect.x(), opt->rect.y() + opt->rect.height() - 1); } else { qDrawShadePanel(p, opt->rect, opt->palette, !showUp, - pixelMetric(PM_DefaultFrameWidth), &fill); + proxy()->pixelMetric(PM_DefaultFrameWidth), &fill); } - if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) + if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); break; } @@ -545,7 +545,7 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP a.setPoints(INTARRLEN(bottom_pts), bottom_pts); a.translate(opt->rect.x(), opt->rect.y()); p->drawPolyline(a); - if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) + if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); p->setPen(oldPen); p->setBrush(oldBrush); @@ -736,13 +736,13 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP #undef CLEFT #undef CTOP #undef CBOT - if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) + if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); break; } case PE_IndicatorDockWidgetResizeHandle: { const int motifOffset = 10; - int sw = pixelMetric(PM_SplitterWidth); + int sw = proxy()->pixelMetric(PM_SplitterWidth); if (opt->state & State_Horizontal) { int yPos = opt->rect.y() + opt->rect.height() / 2; int kPos = opt->rect.right() - motifOffset - sw; @@ -769,7 +769,7 @@ void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QP const int markH = 6; int posX = opt->rect.x() + (opt->rect.width() - markW) / 2 - 1; int posY = opt->rect.y() + (opt->rect.height() - markH) / 2; - int dfw = pixelMetric(PM_DefaultFrameWidth); + int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth); if (dfw < 2) { // Could do with some optimizing/caching... @@ -843,7 +843,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q handleOpt.state &= ~State_Horizontal; else handleOpt.state |= State_Horizontal; - drawPrimitive(PE_IndicatorDockWidgetResizeHandle, &handleOpt, p, widget); + proxy()->drawPrimitive(PE_IndicatorDockWidgetResizeHandle, &handleOpt, p, widget); break; } case CE_ScrollBarSubLine: @@ -855,9 +855,9 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight) : PE_IndicatorArrowUp; QStyleOption arrowOpt = *opt; arrowOpt.state |= State_Enabled; - drawPrimitive(pe, &arrowOpt, p, widget); - if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) { - int fw = pixelMetric(PM_DefaultFrameWidth); + proxy()->drawPrimitive(pe, &arrowOpt, p, widget); + if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) { + int fw = proxy()->pixelMetric(PM_DefaultFrameWidth); p->fillRect(opt->rect.adjusted(fw, fw, -fw, -fw), QBrush(p->background().color(), Qt::Dense5Pattern)); } }break; @@ -873,9 +873,9 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q bevelOpt.state &= ~(State_Sunken | State_On); p->save(); p->setBrushOrigin(bevelOpt.rect.topLeft()); - drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget); + proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget); p->restore(); - if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) + if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern)); break; } @@ -886,31 +886,31 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator : SE_CheckBoxIndicator, btn, widget); - drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, + proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, &subopt, p, widget); subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents : SE_CheckBoxContents, btn, widget); - drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); + proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) { QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*btn); fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect : SE_CheckBoxFocusRect, btn, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } } break; case CE_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { - drawControl(CE_PushButtonBevel, btn, p, widget); + proxy()->drawControl(CE_PushButtonBevel, btn, p, widget); QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); - drawControl(CE_PushButtonLabel, &subopt, p, widget); + proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget); if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) { QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*btn); fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } } break; @@ -919,7 +919,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q int diw, x1, y1, x2, y2; p->setPen(opt->palette.foreground().color()); p->setBrush(QBrush(opt->palette.button().color(), Qt::NoBrush)); - diw = pixelMetric(PM_ButtonDefaultIndicator); + diw = proxy()->pixelMetric(PM_ButtonDefaultIndicator); opt->rect.getCoords(&x1, &y1, &x2, &y2); if (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)) { x1 += diw; @@ -948,14 +948,14 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q QStyleOptionButton newOpt = *btn; newOpt.rect = QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1); p->setBrushOrigin(p->brushOrigin()); - drawPrimitive(PE_PanelButtonCommand, &newOpt, p, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &newOpt, p, widget); } if (btn->features & QStyleOptionButton::HasMenu) { - int mbi = pixelMetric(PM_MenuButtonIndicator, btn, widget); + int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget); QRect ir = btn->rect; QStyleOptionButton newBtn = *btn; newBtn.rect = QRect(ir.right() - mbi - 3, ir.y() + 4, mbi, ir.height() - 8); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); } break; } @@ -963,7 +963,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q #ifndef QT_NO_TABBAR case CE_TabBarTabShape: if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { - const int default_frame = pixelMetric(PM_DefaultFrameWidth, tab, widget); + const int default_frame = proxy()->pixelMetric(PM_DefaultFrameWidth, tab, widget); const int frame_offset = (default_frame > 1) ? 1 : 0; if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast || @@ -1081,7 +1081,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q } p->setTransform(m, true); } - const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, opt, widget); + const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, widget); int u = rect.width() / unit_width; int p_v = pb->progress - pb->minimum; int t_s = qMax(0, pb->maximum - pb->minimum); @@ -1150,7 +1150,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q QFont oldFont = p->font(); p->setFont(menuitem->font); p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button)); - drawItemText(p, menuitem->rect.adjusted(10, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, + proxy()->drawItemText(p, menuitem->rect.adjusted(10, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, menuitem->palette, menuitem->state & State_Enabled, menuitem->text, QPalette::Text); textWidth = menuitem->fontMetrics.width(menuitem->text) + 10; @@ -1220,10 +1220,10 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q } if (menuitem->checkType & QStyleOptionMenuItem::Exclusive) { newMenuItem.rect.setRect(xvis + 2, y + motifItemFrame + mh / 4, 11, 11); - drawPrimitive(PE_IndicatorRadioButton, &newMenuItem, p, widget); + proxy()->drawPrimitive(PE_IndicatorRadioButton, &newMenuItem, p, widget); } else { newMenuItem.rect.setRect(xvis + 5, y + motifItemFrame + mh / 4, 9, 9); - drawPrimitive(PE_IndicatorCheckBox, &newMenuItem, p, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, &newMenuItem, p, widget); } } @@ -1258,14 +1258,14 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q int xv = vr.x(); QRect tr(xv, y+m, menuitem->tabWidth, h-2*m); p->drawText(tr, text_flags, s.mid(t+1)); - if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) + if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern)); s = s.left(t); } QRect tr(xvis, y+m, w - xm - menuitem->tabWidth + 1, h-2*m); p->drawText(tr, text_flags, s.left(t)); p->setFont(oldFont); - if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) + if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern)); } if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) { // draw sub menu arrow @@ -1279,7 +1279,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q arrowOpt.state = (State_Sunken | ((opt->state & State_Enabled) ? State_Enabled : State_None)); else arrowOpt.state = ((opt->state & State_Enabled) ? State_Enabled : State_None); - drawPrimitive(arrow, &arrowOpt, p, widget); + proxy()->drawPrimitive(arrow, &arrowOpt, p, widget); } break; } @@ -1296,7 +1296,7 @@ void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, Q p->save(); p->setBrushOrigin(opt->rect.topLeft()); qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken|State_On)), - pixelMetric(PM_DefaultFrameWidth), + proxy()->pixelMetric(PM_DefaultFrameWidth), &opt->palette.brush((opt->state & State_Sunken) ? QPalette::Mid : QPalette::Button)); p->restore(); break; @@ -1431,8 +1431,8 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { QRect button, menuarea; - button = subControlRect(cc, toolbutton, SC_ToolButton, widget); - menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); + button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget); + menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); State bflags = toolbutton->state & ~State_Sunken; if (bflags & State_AutoRaise) { @@ -1453,7 +1453,7 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple if (bflags & (State_Sunken | State_On | State_Raised)) { tool.rect = button; tool.state = bflags; - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); } } @@ -1461,26 +1461,26 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple QStyleOptionFocusRect fr; fr.QStyleOption::operator=(*toolbutton); fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3); - drawPrimitive(PE_FrameFocusRect, &fr, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget); } QStyleOptionToolButton label = *toolbutton; label.state = bflags; - int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); + int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); label.rect = button.adjusted(fw, fw, -fw, -fw); - drawControl(CE_ToolButtonLabel, &label, p, widget); + proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); if (toolbutton->subControls & SC_ToolButtonMenu) { tool.rect = menuarea; tool.state = mflags; if (mflags & (State_Sunken | State_On | State_Raised)) - drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); - drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); + proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { - int mbi = pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); + int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); QRect ir = toolbutton->rect; QStyleOptionToolButton newBtn = *toolbutton; newBtn.rect = QRect(ir.right() + 5 - mbi, ir.height() - mbi + 4, mbi - 6, mbi - 6); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); } } break; @@ -1491,18 +1491,18 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple PrimitiveElement pe; if (spinbox->frame && (spinbox->subControls & SC_SpinBoxFrame)) { - QRect r = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxFrame, widget); - qDrawShadePanel(p, r, opt->palette, false, pixelMetric(PM_SpinBoxFrameWidth)); + QRect r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxFrame, widget); + qDrawShadePanel(p, r, opt->palette, false, proxy()->pixelMetric(PM_SpinBoxFrameWidth)); - int fw = pixelMetric(QStyle::PM_DefaultFrameWidth); - r = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw); + int fw = proxy()->pixelMetric(QStyle::PM_DefaultFrameWidth); + r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw); QStyleOptionFrame lineOpt; lineOpt.QStyleOption::operator=(*opt); lineOpt.rect = r; lineOpt.lineWidth = fw; lineOpt.midLineWidth = 0; lineOpt.state |= QStyle::State_Sunken; - drawPrimitive(QStyle::PE_FrameLineEdit, &lineOpt, p, widget); + proxy()->drawPrimitive(QStyle::PE_FrameLineEdit, &lineOpt, p, widget); } if (spinbox->subControls & SC_SpinBoxUp) { @@ -1525,8 +1525,8 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus : PE_IndicatorSpinUp); - copy.rect = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget); - drawPrimitive(pe, ©, p, widget); + copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget); + proxy()->drawPrimitive(pe, ©, p, widget); } if (spinbox->subControls & SC_SpinBoxDown) { @@ -1549,8 +1549,8 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus : PE_IndicatorSpinDown); - copy.rect = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget); - drawPrimitive(pe, ©, p, widget); + copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget); + proxy()->drawPrimitive(pe, ©, p, widget); } } break; @@ -1558,16 +1558,16 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple #ifndef QT_NO_SLIDER case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { - QRect groove = subControlRect(CC_Slider, opt, SC_SliderGroove, widget), - handle = subControlRect(CC_Slider, opt, SC_SliderHandle, widget); + QRect groove = proxy()->subControlRect(CC_Slider, opt, SC_SliderGroove, widget), + handle = proxy()->subControlRect(CC_Slider, opt, SC_SliderHandle, widget); if ((opt->subControls & SC_SliderGroove) && groove.isValid()) { - qDrawShadePanel(p, groove, opt->palette, true, pixelMetric(PM_DefaultFrameWidth), + qDrawShadePanel(p, groove, opt->palette, true, proxy()->pixelMetric(PM_DefaultFrameWidth), &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window)); if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) { QStyleOption focusOpt = *opt; focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget); - drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget); } } @@ -1577,7 +1577,7 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple bevelOpt.rect = handle; p->save(); p->setBrushOrigin(bevelOpt.rect.topLeft()); - drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget); + proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget); p->restore(); if (slider->orientation == Qt::Horizontal) { @@ -1589,14 +1589,14 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple qDrawShadeLine(p, handle.x(), mid, handle.x() + handle.width() - 2, mid, opt->palette, true, 1); } - if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) + if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) p->fillRect(handle, QBrush(p->background().color(), Qt::Dense5Pattern)); } if (slider->subControls & SC_SliderTickmarks) { QStyleOptionSlider tmpSlider = *slider; tmpSlider.subControls = SC_SliderTickmarks; - int frameWidth = pixelMetric(PM_DefaultFrameWidth); + int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth); tmpSlider.rect.translate(frameWidth - 1, 0); QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget); } @@ -1607,13 +1607,13 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { if (opt->subControls & SC_ComboBoxArrow) { int awh, ax, ay, sh, sy, dh, ew; - int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; + int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; if (cb->frame) { QStyleOptionButton btn; btn.QStyleOption::operator=(*cb); btn.state |= QStyle::State_Raised; - drawPrimitive(PE_PanelButtonCommand, &btn, p, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &btn, p, widget); } else { p->fillRect(opt->rect, opt->palette.brush(QPalette::Button)); } @@ -1627,7 +1627,7 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple QStyleOption arrowOpt = *opt; arrowOpt.rect = ar; arrowOpt.state |= State_Enabled; - drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); // draws the shaded line under the arrow @@ -1643,13 +1643,13 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple focus.QStyleOption::operator=(*opt); focus.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget); focus.backgroundColor = opt->palette.button().color(); - drawPrimitive(PE_FrameFocusRect, &focus, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget); } } if (opt->subControls & SC_ComboBoxEditField) { if (cb->editable) { - QRect er = subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, widget); + QRect er = proxy()->subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, widget); er.adjust(-1, -1, 1, 1); qDrawShadePanel(p, er, opt->palette, true, 1, &opt->palette.brush(QPalette::Base)); @@ -1663,7 +1663,7 @@ void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComple case CC_ScrollBar: { if (opt->subControls & SC_ScrollBarGroove) qDrawShadePanel(p, opt->rect, opt->palette, true, - pixelMetric(PM_DefaultFrameWidth, opt, widget), + proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget), &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window)); if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { @@ -1798,7 +1798,7 @@ int QMotifStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, break; case PM_ToolBarFrameWidth: - ret = pixelMetric(PM_DefaultFrameWidth); + ret = proxy()->pixelMetric(PM_DefaultFrameWidth); break; case PM_ToolBarItemMargin: @@ -1819,7 +1819,7 @@ int QMotifStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, break; case PM_SliderThickness: - ret = 16 + 4 * pixelMetric(PM_DefaultFrameWidth); + ret = 16 + 4 * proxy()->pixelMetric(PM_DefaultFrameWidth); break; #ifndef QT_NO_SLIDER case PM_SliderControlThickness: @@ -1849,9 +1849,9 @@ int QMotifStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, case PM_SliderSpaceAvailable: if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { if (sl->orientation == Qt::Horizontal) - ret = sl->rect.width() - pixelMetric(PM_SliderLength, opt, widget) - 2 * pixelMetric(PM_DefaultFrameWidth, opt, widget); + ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); else - ret = sl->rect.height() - pixelMetric(PM_SliderLength, opt, widget) - 2 * pixelMetric(PM_DefaultFrameWidth, opt, widget); + ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); } break; #endif // QT_NO_SLIDER @@ -1901,7 +1901,7 @@ QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, #ifndef QT_NO_SPINBOX case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { - int fw = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; + int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; QSize bs; bs.setHeight(opt->rect.height()/2 - fw); bs.setWidth(qMin(bs.height() * 8 / 5, opt->rect.width() / 4)); // 1.6 -approximate golden mean @@ -1944,11 +1944,11 @@ QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { if (sc == SC_SliderHandle) { - int tickOffset = pixelMetric(PM_SliderTickmarkOffset, opt, widget); - int thickness = pixelMetric(PM_SliderControlThickness, opt, widget); + int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, opt, widget); + int thickness = proxy()->pixelMetric(PM_SliderControlThickness, opt, widget); bool horizontal = slider->orientation == Qt::Horizontal; - int len = pixelMetric(PM_SliderLength, opt, widget); - int motifBorder = pixelMetric(PM_DefaultFrameWidth); + int len = proxy()->pixelMetric(PM_SliderLength, opt, widget); + int motifBorder = proxy()->pixelMetric(PM_DefaultFrameWidth); int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition, horizontal ? slider->rect.width() - len - 2 * motifBorder : slider->rect.height() - len - 2 * motifBorder, @@ -1967,7 +1967,7 @@ QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, #ifndef QT_NO_SCROLLBAR case CC_ScrollBar: if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { - int dfw = pixelMetric(PM_DefaultFrameWidth); + int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth); QRect rect = visualRect(scrollbar->direction, scrollbar->rect, QCommonStyle::subControlRect(cc, scrollbar, sc, widget)); if (sc == SC_ScrollBarSlider) { @@ -1991,7 +1991,7 @@ QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, switch (sc) { case SC_ComboBoxArrow: { int ew, awh, sh, dh, ax, ay, sy; - int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; + int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; QRect cr = opt->rect; cr.adjust(fw, fw, -fw, -fw); get_combo_parameters(cr, ew, awh, ax, ay, sh, dh, sy); @@ -1999,7 +1999,7 @@ QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, } case SC_ComboBoxEditField: { - int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; + int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0; QRect rect = opt->rect; rect.adjust(fw, fw, -fw, -fw); int ew = get_combo_extra_width(rect.height(), rect.width()); @@ -2029,10 +2029,6 @@ QMotifStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, QSize sz(contentsSize); switch(ct) { - case CT_Splitter: - sz = QSize(10, 10); - break; - case CT_RadioButton: case CT_CheckBox: sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget); @@ -2119,7 +2115,7 @@ QMotifStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidge case SE_ComboBoxFocusRect: { int awh, ax, ay, sh, sy, dh, ew; - int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget); + int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); QRect tr = opt->rect; tr.adjust(fw, fw, -fw, -fw); diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 4eb85d8..80c9881 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -43,7 +43,6 @@ #if !defined(QT_NO_STYLE_PLASTIQUE) || defined(QT_PLUGIN) -static bool UsePixmapCache = true; static const bool AnimateBusyProgressBar = true; static const bool AnimateProgressBar = false; // #define QPlastique_MaskButtons @@ -51,6 +50,7 @@ static const int ProgressBarFps = 25; static const int blueFrameWidth = 2; // with of line edit focus frame #include "qwindowsstyle_p.h" +#include <private/qstylehelper_p.h> #include <qapplication.h> #include <qbitmap.h> #include <qabstractitemview.h> @@ -490,7 +490,7 @@ static void qBrushSetAlphaF(QBrush *brush, qreal alpha) QPixmap texture = brush->texture(); QPixmap pixmap; QString name = QString::fromLatin1("qbrushtexture-alpha-%1-%2").arg(alpha).arg(texture.cacheKey()); - if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) { + if (!QPixmapCache::find(name, pixmap)) { QImage image = texture.toImage(); QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); int pixels = image.width() * image.height(); @@ -551,7 +551,7 @@ static QBrush qBrushLight(QBrush brush, int light) QPixmap texture = brush.texture(); QPixmap pixmap; QString name = QString::fromLatin1("qbrushtexture-light-%1-%2").arg(light).arg(texture.cacheKey()); - if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) { + if (!QPixmapCache::find(name, pixmap)) { QImage image = texture.toImage(); QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); int pixels = image.width() * image.height(); @@ -610,7 +610,7 @@ static QBrush qBrushDark(QBrush brush, int dark) QPixmap texture = brush.texture(); QPixmap pixmap; QString name = QString::fromLatin1("qbrushtexture-dark-%1-%2").arg(dark).arg(brush.texture().cacheKey()); - if (UsePixmapCache && !QPixmapCache::find(name, pixmap)) { + if (!QPixmapCache::find(name, pixmap)) { QImage image = texture.toImage(); QRgb *rgb = reinterpret_cast<QRgb *>(image.bits()); int pixels = image.width() * image.height(); @@ -730,16 +730,6 @@ static QColor mergedColors(const QColor &colorA, const QColor &colorB, int facto return tmp; } -static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) -{ - QString tmp; - const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); - tmp.sprintf("%s-%d-%d-%d-%lld-%dx%d", key.toLatin1().constData(), uint(option->state), - option->direction, complexOption ? uint(complexOption->activeSubControls) : uint(0), - option->palette.cacheKey(), size.width(), size.height()); - return tmp; -} - static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, const QColor &gradientStop) { @@ -749,8 +739,7 @@ static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, con QPainter *p = painter; QRect r = rect; - bool doPixmapCache = UsePixmapCache - && painter->deviceTransform().isIdentity() + bool doPixmapCache = painter->deviceTransform().isIdentity() && painter->worldMatrix().isIdentity(); if (doPixmapCache && QPixmapCache::find(gradientName, cache)) { painter->drawPixmap(rect, cache); @@ -1005,8 +994,6 @@ QPlastiqueStylePrivate::QPlastiqueStylePrivate() : , progressBarAnimateTimer(0) #endif { - if (!qgetenv("QT_STYLE_NO_PIXMAPCACHE").isNull()) - UsePixmapCache = false; } /*! @@ -1132,7 +1119,7 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption switch (element) { case PE_IndicatorButtonDropDown: - drawPrimitive(PE_PanelButtonTool, option, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, option, painter, widget); break; case PE_FrameDefaultButton: { if (!(option->state & QStyle::State_Enabled)) @@ -1178,7 +1165,7 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption break; } - int borderThickness = pixelMetric(PM_TabBarBaseOverlap, twf, widget); + int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget); bool reverse = (twf->direction == Qt::RightToLeft); painter->save(); @@ -1357,7 +1344,7 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption painter->setPen(oldPen); } else { frameV2.state &= ~(State_Sunken | State_HasFocus); - drawPrimitive(PE_Frame, &frameV2, painter, widget); + proxy()->drawPrimitive(PE_Frame, &frameV2, painter, widget); } } break; @@ -1515,8 +1502,8 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption rect.adjust(2, 0, -2, 0); } #endif - QString pixmapName = uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(rect.size()); cache.fill(Qt::transparent); QPainter cachePainter(&cache); @@ -1546,8 +1533,7 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption handle); } cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(rect.topLeft(), cache); break; @@ -1857,13 +1843,13 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption QStyleOptionButton button; button.QStyleOption::operator=(*option); button.state &= ~State_MouseOver; - drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); break; } case PE_FrameWindow: { painter->save(); bool active = (option->state & State_Active); - int titleBarStop = option->rect.top() + pixelMetric(PM_TitleBarHeight, option, widget); + int titleBarStop = option->rect.top() + proxy()->pixelMetric(PM_TitleBarHeight, option, widget); QPalette palette = option->palette; if (!active) @@ -2073,7 +2059,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op && !leftCornerWidget; bool reverseShadow = false; - int borderThickness = pixelMetric(PM_TabBarBaseOverlap, tab, widget); + int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); int marginLeft = 0; if ((atBeginning && !selected) || (selected && leftCornerWidget && ((tab->position == QStyleOptionTab::Beginning) || onlyTab))) { marginLeft = 1; @@ -2585,8 +2571,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op painter->setTransform(m, true); } - double vc6_workaround = ((bar->progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * rect.width()); - int progressIndicatorPos = int(vc6_workaround); + int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum) * rect.width(); bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) || ((bar->direction == Qt::LeftToRight) && inverted))) || (vertical && ((!inverted && !bottomToTop) || (inverted && bottomToTop))); @@ -2646,8 +2631,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // same rendering code for both orientations. if (vertical) { rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - QTransform m; - m.translate(rect.height()-1, 0); + QTransform m = QTransform::fromTranslate(rect.height()-1, 0); m.rotate(90.0); painter->setTransform(m, true); } @@ -2782,10 +2766,10 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // contents painter->setPen(QPen()); - QString progressBarName = uniqueName(QLatin1String("progressBarContents"), + QString progressBarName = QStyleHelper::uniqueName(QLatin1String("progressBarContents"), option, rect.size()); QPixmap cache; - if ((!UsePixmapCache || !QPixmapCache::find(progressBarName, cache)) && rect.height() > 7) { + if (!QPixmapCache::find(progressBarName, cache) && rect.height() > 7) { QSize size = rect.size(); cache = QPixmap(QSize(size.width() - 6 + 30, size.height() - 6)); cache.fill(Qt::white); @@ -2818,8 +2802,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op leftEdge += 10; } - if (UsePixmapCache) - QPixmapCache::insert(progressBarName, cache); + QPixmapCache::insert(progressBarName, cache); } painter->setClipRect(progressBar.adjusted(1, 0, -1, -1)); @@ -2843,11 +2826,11 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // Draws the header in tables. if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { QPixmap cache; - QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size()); - pixmapName += QLatin1String("-") + QString::number(int(header->position)); - pixmapName += QLatin1String("-") + QString::number(int(header->orientation)); + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size()); + pixmapName += QString::number(- int(header->position)); + pixmapName += QString::number(- int(header->orientation)); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, option->rect.width(), option->rect.height()); @@ -2891,8 +2874,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op cachePainter.drawLines(lines, 2); cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); @@ -2915,7 +2897,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op int w = 0; if (!menuItem->text.isEmpty()) { painter->setFont(menuItem->font); - drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, + proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, menuItem->palette, menuItem->state & State_Enabled, menuItem->text, QPalette::Text); w = menuItem->fontMetrics.width(menuItem->text) + 5; @@ -2958,7 +2940,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op if (checked) button.state |= State_On; button.palette = menuItem->palette; - drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget); + proxy()->drawPrimitive(PE_IndicatorRadioButton, &button, painter, widget); } else { if (menuItem->icon.isNull()) { QStyleOptionButton button; @@ -2967,7 +2949,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op if (checked) button.state |= State_On; button.palette = menuItem->palette; - drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); } else if (checked) { int iconSize = qMax(menuItem->maxIconWidth, 20); QRect sunkenRect(option->rect.left() + 1, @@ -3079,7 +3061,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op newMI.palette.highlightedText().color()); else newMI.palette.setColor(QPalette::ButtonText, textBrush.color()); - drawPrimitive(arrow, &newMI, painter, widget); + proxy()->drawPrimitive(arrow, &newMI, painter, widget); } painter->restore(); @@ -3091,8 +3073,8 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // Draws a menu bar item; File, Edit, Help etc.. if ((option->state & State_Selected)) { QPixmap cache; - QString pixmapName = uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, option->rect.width(), option->rect.height()); @@ -3142,8 +3124,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op lines[1] = QLine(rect.right() - 1, rect.top() + 1, rect.right() - 1, rect.bottom() - 2); cachePainter.drawLines(lines, 2); cachePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(pixmapName, cache); + QPixmapCache::insert(pixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); } else { @@ -3455,9 +3436,9 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op bool reverse = scrollBar->direction == Qt::RightToLeft; bool sunken = scrollBar->state & State_Sunken; - QString addLinePixmapName = uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size()); + QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, option->rect.size()); QPixmap cache; - if (!UsePixmapCache || !QPixmapCache::find(addLinePixmapName, cache)) { + if (!QPixmapCache::find(addLinePixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, cache.width(), cache.height()); @@ -3516,8 +3497,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op addLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow); } addLinePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(addLinePixmapName, cache); + QPixmapCache::insert(addLinePixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); } @@ -3528,14 +3508,14 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op bool sunken = scrollBar->state & State_Sunken; bool horizontal = scrollBar->orientation == Qt::Horizontal; - QString groovePixmapName = uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size()); + QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_groove"), option, option->rect.size()); if (sunken) groovePixmapName += QLatin1String("-sunken"); if (element == CE_ScrollBarAddPage) groovePixmapName += QLatin1String("-addpage"); QPixmap cache; - if (!UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) { + if (!QPixmapCache::find(groovePixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(option->palette.background().color()); QPainter groovePainter(&cache); @@ -3561,8 +3541,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op } groovePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(groovePixmapName, cache); + QPixmapCache::insert(groovePixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); } @@ -3579,7 +3558,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // The SubLine (up/left) buttons QRect button1; QRect button2; - int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, option, widget); + int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); if (horizontal) { button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height()); button2.setRect(scrollBarSubLine.right() - (scrollBarExtent - 1), scrollBarSubLine.top(), scrollBarExtent, scrollBarSubLine.height()); @@ -3588,9 +3567,9 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op button2.setRect(scrollBarSubLine.left(), scrollBarSubLine.bottom() - (scrollBarExtent - 1), scrollBarSubLine.width(), scrollBarExtent); } - QString subLinePixmapName = uniqueName(QLatin1String("scrollbar_subline"), option, button1.size()); + QString subLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_subline"), option, button1.size()); QPixmap cache; - if (!UsePixmapCache || !QPixmapCache::find(subLinePixmapName, cache)) { + if (!QPixmapCache::find(subLinePixmapName, cache)) { cache = QPixmap(button1.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, cache.width(), cache.height()); @@ -3650,8 +3629,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op subLinePainter.drawImage(QPoint(pixmapRect.center().x() - 3, pixmapRect.center().y() - 2), arrow); } subLinePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(subLinePixmapName, cache); + QPixmapCache::insert(subLinePixmapName, cache); } painter->drawPixmap(button1.topLeft(), cache); painter->drawPixmap(button2.topLeft(), cache); @@ -3664,12 +3642,12 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op // The slider if (option->rect.isValid()) { - QString sliderPixmapName = uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size()); + QString sliderPixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_slider"), option, option->rect.size()); if (horizontal) sliderPixmapName += QLatin1String("-horizontal"); QPixmap cache; - if (!UsePixmapCache || !QPixmapCache::find(sliderPixmapName, cache)) { + if (!QPixmapCache::find(sliderPixmapName, cache)) { cache = QPixmap(option->rect.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, cache.width(), cache.height()); @@ -3720,7 +3698,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op pixmapRect.right() - 1, pixmapRect.bottom() - 1); sliderPainter.drawLines(lines, 2); - int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); + int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); if ((horizontal && scrollBar->rect.width() > sliderMinLength) || (!horizontal && scrollBar->rect.height() > sliderMinLength)) { QImage pattern(horizontal ? qt_scrollbar_slider_pattern_horizontal @@ -3740,8 +3718,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op } sliderPainter.end(); // insert the slider into the cache - if (UsePixmapCache) - QPixmapCache::insert(sliderPixmapName, cache); + QPixmapCache::insert(sliderPixmapName, cache); } painter->drawPixmap(option->rect.topLeft(), cache); } @@ -3760,7 +3737,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QWindowsStyle::drawControl(element, option, painter, widget); } else if (!comboBox->currentIcon.isNull()) { { - QRect editRect = subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); + QRect editRect = proxy()->subControlRect(CC_ComboBox, comboBox, SC_ComboBoxEditField, widget); if (comboBox->direction == Qt::RightToLeft) editRect.adjust(0, 2, -2, -2); else @@ -3777,7 +3754,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op Qt::AlignLeft | Qt::AlignVCenter, iconRect.size(), editRect); painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); - drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); + proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); } painter->restore(); } @@ -3820,9 +3797,9 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt #ifndef QT_NO_SLIDER case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { - QRect grooveRegion = subControlRect(CC_Slider, option, SC_SliderGroove, widget); - QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget); - QRect ticks = subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); + QRect grooveRegion = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); + QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); + QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); bool horizontal = slider->orientation == Qt::Horizontal; bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; @@ -3885,13 +3862,13 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } if ((option->subControls & SC_SliderHandle) && handle.isValid()) { - QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size()); + QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); if (ticksAbove && !ticksBelow) handlePixmapName += QLatin1String("-flipped"); if ((option->activeSubControls & SC_SliderHandle) && (option->state & State_Sunken)) handlePixmapName += QLatin1String("-sunken"); - if (!UsePixmapCache || !QPixmapCache::find(handlePixmapName, cache)) { + if (!QPixmapCache::find(handlePixmapName, cache)) { cache = QPixmap(handle.size()); cache.fill(Qt::white); QRect pixmapRect(0, 0, handle.width(), handle.height()); @@ -3974,8 +3951,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } handlePainter.drawImage(pixmapRect, image); handlePainter.end(); - if (UsePixmapCache) - QPixmapCache::insert(handlePixmapName, cache); + QPixmapCache::insert(handlePixmapName, cache); } painter->drawPixmap(handle.topLeft(), cache); @@ -3984,15 +3960,15 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*slider); fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); } } if (option->subControls & SC_SliderTickmarks) { QPen oldPen = painter->pen(); painter->setPen(borderColor); - int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget); - int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget); + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); + int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); int interval = slider->tickInterval; if (interval <= 0) { interval = slider->singleStep; @@ -4006,7 +3982,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt interval = 1; int v = slider->minimum; - int len = pixelMetric(PM_SliderLength, slider, widget); + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); QVarLengthArray<QLine, 32> lines; while (v <= slider->maximum + 1) { if (v == slider->maximum + 1 && interval == 1) @@ -4061,8 +4037,8 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool reverse = (spinBox->direction == Qt::RightToLeft); // Rects - QRect upRect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); - QRect downRect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); + QRect upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); + QRect downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); QRect buttonRect = upRect | downRect; // Brushes @@ -4083,7 +4059,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } else { d->drawPartialFrame(painter, option, - subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget), + proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget), widget); } // Paint buttons @@ -4423,7 +4399,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt Q_D(const QPlastiqueStyle); d->drawPartialFrame(painter, option, - subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget), + proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget), widget); QBrush border = qMapBrushToRect(option->palette.shadow(), buttonRect); @@ -4547,7 +4523,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt if (!sunken) { buttonOption.state &= ~State_Sunken; } - drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); + proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, painter, widget); // Draw the menu button separator line QBrush border = qMapBrushToRect(option->palette.shadow(), rect); @@ -4580,11 +4556,12 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } // Draw the focus rect - if (((option->state & State_HasFocus) && (option->state & State_KeyboardFocusChange)) && !comboBox->editable) { + if ((option->state & State_HasFocus) && !comboBox->editable + && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) { QStyleOptionFocusRect focus; - focus.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget) + focus.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget) .adjusted(-2, 0, 2, 0); - drawPrimitive(PE_FrameFocusRect, &focus, painter, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &focus, painter, widget); } painter->setPen(oldPen); @@ -4614,7 +4591,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt QStyleOptionDockWidgetV2 dockwidget; dockwidget.QStyleOption::operator=(*option); dockwidget.title = titleBar->text; - drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget); + proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget); } else #endif // QT3_SUPPORT @@ -4687,7 +4664,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt } } // draw title - QRect textRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); + QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); QFont font = painter->font(); font.setBold(true); @@ -4714,7 +4691,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken); - QRect minButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); + QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); qt_plastique_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken); int xoffset = minButtonRect.width() / 3; @@ -4758,7 +4735,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken); - QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); + QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); qt_plastique_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken); int xoffset = maxButtonRect.width() / 3; @@ -4783,7 +4760,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken); - QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); + QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); qt_plastique_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken); int xoffset = closeButtonRect.width() / 3; @@ -4829,7 +4806,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken); - QRect normalButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); + QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); qt_plastique_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken); int xoffset = int(normalButtonRect.width() / 3.5); int yoffset = int(normalButtonRect.height() / 3.5); @@ -4875,7 +4852,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken); - QRect contextHelpButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); + QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); qt_plastique_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken); @@ -4902,7 +4879,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken); - QRect shadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); + QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); qt_plastique_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken); int xoffset = shadeButtonRect.width() / 3; @@ -4926,7 +4903,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken); - QRect unshadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); + QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); qt_plastique_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken); int xoffset = unshadeButtonRect.width() / 3; @@ -4951,7 +4928,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt bool hover = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarSysMenu) && (titleBar->state & State_Sunken); - QRect iconRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); + QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); if (hover) qt_plastique_draw_mdibutton(painter, titleBar, iconRect, hover, sunken); @@ -4963,13 +4940,19 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt QPixmap pm = standardPixmap(SP_TitleBarMenuButton, &tool, widget); tool.rect = iconRect; painter->save(); - drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); + proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); painter->restore(); } } painter->restore(); } break; +#ifndef QT_NO_DIAL + case CC_Dial: + if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) + QStyleHelper::drawDial(dial, painter); + break; +#endif // QT_NO_DIAL default: QWindowsStyle::drawComplexControl(control, option, painter, widget); break; @@ -4992,7 +4975,7 @@ QSize QPlastiqueStyle::sizeFromContents(ContentsType type, const QStyleOption *o #ifndef QT_NO_SLIDER case CT_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { - int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget); + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); if (slider->tickPosition & QSlider::TicksBelow) { if (slider->orientation == Qt::Horizontal) newSize.rheight() += tickSize; @@ -5011,8 +4994,8 @@ QSize QPlastiqueStyle::sizeFromContents(ContentsType type, const QStyleOption *o #ifndef QT_NO_SCROLLBAR case CT_ScrollBar: if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { - int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, option, widget); - int scrollBarSliderMinimum = pixelMetric(PM_ScrollBarSliderMin, option, widget); + int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); + int scrollBarSliderMinimum = proxy()->pixelMetric(PM_ScrollBarSliderMin, option, widget); if (scrollBar->orientation == Qt::Horizontal) { newSize = QSize(scrollBarExtent * 3 + scrollBarSliderMinimum, scrollBarExtent); } else { @@ -5093,7 +5076,7 @@ QRect QPlastiqueStyle::subControlRect(ComplexControl control, const QStyleOption #ifndef QT_NO_SLIDER case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { - int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget); + int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); switch (subControl) { case SC_SliderHandle: @@ -5146,10 +5129,10 @@ QRect QPlastiqueStyle::subControlRect(ComplexControl control, const QStyleOption #ifndef QT_NO_SCROLLBAR case CC_ScrollBar: if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { - int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, scrollBar, widget); + int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollBar, widget); int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ? scrollBar->rect.width() : scrollBar->rect.height()) - (scrollBarExtent * 3); - int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); + int sliderMinLength = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollBar, widget); int sliderLength; // calculate slider length @@ -5271,7 +5254,7 @@ QRect QPlastiqueStyle::subControlRect(ComplexControl control, const QStyleOption break; case SC_ComboBoxEditField: { if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { - int frameWidth = pixelMetric(PM_DefaultFrameWidth); + int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth); rect = visualRect(option->direction, option->rect, rect); if (box->editable) { @@ -5453,6 +5436,11 @@ int QPlastiqueStyle::styleHint(StyleHint hint, const QStyleOption *option, const case SH_Menu_SubMenuPopupDelay: ret = 96; // from Plastik break; +#ifndef Q_OS_WIN + case SH_Menu_AllowActiveAndDisabled: + ret = false; + break; +#endif default: ret = QWindowsStyle::styleHint(hint, option, widget, returnData); break; @@ -5471,31 +5459,31 @@ QStyle::SubControl QPlastiqueStyle::hitTestComplexControl(ComplexControl control #ifndef QT_NO_SCROLLBAR case CC_ScrollBar: if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) { - QRect slider = subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); + QRect slider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); if (slider.contains(pos)) { ret = SC_ScrollBarSlider; break; } - QRect scrollBarAddLine = subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); + QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); if (scrollBarAddLine.contains(pos)) { ret = SC_ScrollBarAddLine; break; } - QRect scrollBarSubPage = subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget); + QRect scrollBarSubPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubPage, widget); if (scrollBarSubPage.contains(pos)) { ret = SC_ScrollBarSubPage; break; } - QRect scrollBarAddPage = subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget); + QRect scrollBarAddPage = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddPage, widget); if (scrollBarAddPage.contains(pos)) { ret = SC_ScrollBarAddPage; break; } - QRect scrollBarSubLine = subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); + QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); if (scrollBarSubLine.contains(pos)) { ret = SC_ScrollBarSubLine; break; diff --git a/src/gui/styles/qproxystyle.cpp b/src/gui/styles/qproxystyle.cpp new file mode 100644 index 0000000..7177bed --- /dev/null +++ b/src/gui/styles/qproxystyle.cpp @@ -0,0 +1,420 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qstyle.h> +#include <private/qstyle_p.h> +#include <private/qproxystyle_p.h> +#include <private/qapplication_p.h> +#include "qproxystyle.h" +#include "qstylefactory.h" + +#if !defined(QT_NO_STYLE_PROXY) || defined(QT_PLUGIN) + +QT_BEGIN_NAMESPACE + +/*! + \class QProxyStyle + + \brief The QProxyStyle class is a convenience class that simplifies + dynamically overriding QStyle elements. + + \since 4.6 + + A QProxyStyle wraps a QStyle (usually the default system style) for the + purpose of dynamically overriding painting or other specific style behavior. + + The following example shows how to override the shortcut underline + behavior on any platform: + + \snippet doc/src/snippets/code/src_gui_qproxystyle.cpp 1 + + Warning: The \l {QCommonStyle} {common styles} provided by Qt will + respect this hint, because they call QStyle::proxy(), but there is + no guarantee that QStyle::proxy() will be called for user defined + or system controlled styles. It would not work on a Mac, for + example, where menus are handled by the operating system. + + \sa QStyle +*/ + +void QProxyStylePrivate::ensureBaseStyle() const +{ + Q_Q(const QProxyStyle); + + if (baseStyle) + return; + + if (!baseStyle && !QApplicationPrivate::styleOverride.isEmpty()) { + baseStyle = QStyleFactory::create(QApplicationPrivate::styleOverride); + if (baseStyle) { + // If baseStyle is an instance of the same proxyStyle + // we destroy it and fall back to the desktop style + if (qstrcmp(baseStyle->metaObject()->className(), + q->metaObject()->className()) == 0) { + delete baseStyle; + baseStyle = 0; + } + } + } + + if (!baseStyle) // Use application desktop style + baseStyle = QStyleFactory::create(QApplicationPrivate::desktopStyleKey()); + + if (!baseStyle) // Fallback to windows style + baseStyle = QStyleFactory::create(QLatin1String("windows")); + + baseStyle->setProxy(const_cast<QProxyStyle*>(q)); + baseStyle->setParent(const_cast<QProxyStyle*>(q)); // Take ownership +} + +/*! + Constructs a QProxyStyle object for overriding behavior in \a style + or in the current application \l{QStyle}{style} if \a style is 0 + (default). Normally \a style is 0, because you want to override + behavior in the system style. + + Ownership of \a style is transferred to QProxyStyle. +*/ +QProxyStyle::QProxyStyle(QStyle *style) : + QCommonStyle(*new QProxyStylePrivate()) +{ + Q_D(QProxyStyle); + if (style) { + style->setProxy(this); + style->setParent(this); // Take ownership + d->baseStyle = style; + } +} + +/*! + Destroys the QProxyStyle object. +*/ +QProxyStyle::~QProxyStyle() +{ +} + +/*! + Returns the proxy base style object. If no base style + is set on the proxy style, QProxyStyle will create + an instance of the application style instead. + + \sa setBaseStyle(), QStyle +*/ +QStyle *QProxyStyle::baseStyle() const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle; +} + +/*! + Sets the base style that should be proxied. + + Ownership of \a style is transferred to QProxyStyle. + + If style is zero, a desktop-dependant style will be + assigned automatically. +*/ +void QProxyStyle::setBaseStyle(QStyle *style) +{ + Q_D (QProxyStyle); + + if (d->baseStyle && d->baseStyle->parent() == this) + d->baseStyle->deleteLater(); + + d->baseStyle = style; + + if (d->baseStyle) { + d->baseStyle->setProxy(this); + d->baseStyle->setParent(this); + } +} + +/*! \reimp + */ +void QProxyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->drawPrimitive(element, option, painter, widget); +} + +/*! + \reimp + */ +void QProxyStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->drawControl(element, option, painter, widget); +} + +/*! \reimp + */ +void QProxyStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->drawComplexControl(control, option, painter, widget); +} + +/*! \reimp + */ +void QProxyStyle::drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, + const QString &text, QPalette::ColorRole textRole) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->drawItemText(painter, rect, flags, pal, enabled, text, textRole); +} + +/*! \reimp + */ +void QProxyStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->drawItemPixmap(painter, rect, alignment, pixmap); +} + +/*! \reimp + */ +QSize QProxyStyle::sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->sizeFromContents(type, option, size, widget); +} + +/*! \reimp + */ +QRect QProxyStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->subElementRect(element, option, widget); +} + +/*! \reimp + */ +QRect QProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *option, SubControl sc, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->subControlRect(cc, option, sc, widget); +} + +/*! \reimp + */ +QRect QProxyStyle::itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->itemTextRect(fm, r, flags, enabled, text); +} + +/*! \reimp + */ +QRect QProxyStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->itemPixmapRect(r, flags, pixmap); +} + +/*! \reimp + */ +QStyle::SubControl QProxyStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->hitTestComplexControl(control, option, pos, widget); +} + +/*! \reimp + */ +int QProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->styleHint(hint, option, widget, returnData); +} + +/*! \reimp + */ +int QProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->pixelMetric(metric, option, widget); +} + +/*! \reimp + */ +QPixmap QProxyStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->standardPixmap(standardPixmap, opt, widget); +} + +/*! \reimp + */ +QPixmap QProxyStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->generatedIconPixmap(iconMode, pixmap, opt); +} + +/*! \reimp + */ +QPalette QProxyStyle::standardPalette() const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->standardPalette(); +} + +/*! \reimp + */ +void QProxyStyle::polish(QWidget *widget) +{ + Q_D (QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->polish(widget); +} + +/*! \reimp + */ +void QProxyStyle::polish(QPalette &pal) +{ + Q_D (QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->polish(pal); +} + +/*! \reimp + */ +void QProxyStyle::polish(QApplication *app) +{ + Q_D (QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->polish(app); +} + +/*! \reimp + */ +void QProxyStyle::unpolish(QWidget *widget) +{ + Q_D (QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->unpolish(widget); +} + +/*! \reimp + */ +void QProxyStyle::unpolish(QApplication *app) +{ + Q_D (QProxyStyle); + d->ensureBaseStyle(); + d->baseStyle->unpolish(app); +} + +/*! \reimp + */ +bool QProxyStyle::event(QEvent *e) +{ + Q_D (QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->event(e); +} + +/*! + Returns an icon for the given \a standardIcon. + + Reimplement this slot to provide your own icons in a QStyle + subclass. The \a option argument can be used to pass extra + information required to find the appropriate icon. The \a widget + argument is optional and can also be used to help find the icon. + + \note Because of binary compatibility constraints, standardIcon() + introduced in Qt 4.1 is not virtual. Therefore it must dynamically + detect and call \e this slot. This default implementation simply + calls standardIcon() with the given parameters. + + \sa standardIcon() + */ +QIcon QProxyStyle::standardIconImplementation(StandardPixmap standardIcon, + const QStyleOption *option, + const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->standardIcon(standardIcon, option, widget); +} + +/*! + This slot is called by layoutSpacing() to determine the spacing that + should be used between \a control1 and \a control2 in a layout. \a + orientation specifies whether the controls are laid out side by side + or stacked vertically. The \a option parameter can be used to pass + extra information about the parent widget. The \a widget parameter + is optional and can also be used if \a option is 0. + + The default implementation returns -1. + + \sa layoutSpacing(), combinedLayoutSpacing() + */ +int QProxyStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, + QSizePolicy::ControlType control2, + Qt::Orientation orientation, + const QStyleOption *option, + const QWidget *widget) const +{ + Q_D (const QProxyStyle); + d->ensureBaseStyle(); + return d->baseStyle->layoutSpacing(control1, control2, orientation, option, widget); +} + +QT_END_NAMESPACE + +#endif // QT_NO_STYLE_PROXY diff --git a/src/gui/styles/qproxystyle.h b/src/gui/styles/qproxystyle.h new file mode 100644 index 0000000..c9edaff --- /dev/null +++ b/src/gui/styles/qproxystyle.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPROXYSTYLE_H +#define QPROXYSTYLE_H + +#include <QtGui/QCommonStyle> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +#if !defined(QT_NO_STYLE_PROXY) + +class QProxyStylePrivate; +class Q_GUI_EXPORT QProxyStyle : public QCommonStyle +{ + Q_OBJECT + +public: + QProxyStyle(QStyle *baseStyle = 0); + ~QProxyStyle(); + + QStyle *baseStyle() const; + void setBaseStyle(QStyle *style); + + void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const; + void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const; + void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const; + void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, + const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const; + virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const; + + QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const; + + QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const; + QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const; + QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const; + QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const; + + SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const; + int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const; + int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const; + + QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const; + QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const; + QPalette standardPalette() const; + + void polish(QWidget *widget); + void polish(QPalette &pal); + void polish(QApplication *app); + + void unpolish(QWidget *widget); + void unpolish(QApplication *app); + +protected: + bool event(QEvent *e); + +protected Q_SLOTS: + QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const; + int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, + Qt::Orientation orientation, const QStyleOption *option = 0, const QWidget *widget = 0) const; +private: + Q_DISABLE_COPY(QProxyStyle) + Q_DECLARE_PRIVATE(QProxyStyle) +}; + +#endif // QT_NO_STYLE_PROXY + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPROXYSTYLE_H diff --git a/src/gui/styles/qproxystyle_p.h b/src/gui/styles/qproxystyle_p.h new file mode 100644 index 0000000..3d5f78d --- /dev/null +++ b/src/gui/styles/qproxystyle_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPROXYSTYLE_P_H +#define QPROXYSTYLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#include "qcommonstyle.h" +#include "qcommonstyle_p.h" +#include "qproxystyle.h" + +#ifndef QT_NO_STYLE_PROXY + +QT_BEGIN_NAMESPACE + +class QProxyStylePrivate : public QCommonStylePrivate +{ + Q_DECLARE_PUBLIC(QProxyStyle) +public: + void ensureBaseStyle() const; +private: + QProxyStylePrivate() : + QCommonStylePrivate(), baseStyle(0) {} + mutable QPointer <QStyle> baseStyle; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_STYLE_PROXY + +#endif //QPROXYSTYLE_P_H diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index d7be344..598fe6b 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -168,12 +168,21 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C \section1 Creating a Custom Style - If you want to design a custom look and feel for your application, - the first step is to pick one of the styles provided with Qt to - build your custom style from. The choice will depend on which - existing style resembles your style the most. The most general - class that you can use as base is QCommonStyle (and not QStyle). - This is because Qt requires its styles to be \l{QCommonStyle}s. + You can create a custom look and feel for your application by + creating a custom style. There are two approaches to creating a + custom style. In the static approach, you either choose an + existing QStyle class, subclass it, and reimplement virtual + functions to provide the custom behavior, or you create an entire + QStyle class from scratch. In the dynamic approach, you modify the + behavior of your system style at runtime. The static approach is + described below. The dynamic approach is described in QProxyStyle. + + The first step in the static approach is to pick one of the styles + provided by Qt from which you will build your custom style. Your + choice of QStyle class will depend on which style resembles your + desired style the most. The most general class that you can use as + a base is QCommonStyle (not QStyle). This is because Qt requires + its styles to be \l{QCommonStyle}s. Depending on which parts of the base style you want to change, you must reimplement the functions that are used to draw those @@ -222,7 +231,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C \section1 Using a Custom Style There are several ways of using a custom style in a Qt - application. The simplest way is call the + application. The simplest way is to pass the custom style to the QApplication::setStyle() static function before creating the QApplication object: @@ -232,8 +241,8 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C it before the constructor, you ensure that the user's preference, set using the \c -style command-line option, is respected. - You may want to make your style available for use in other - applications, some of which may not be yours and are not available for + You may want to make your custom style available for use in other + applications, which may not be yours and hence not available for you to recompile. The Qt Plugin system makes it possible to create styles as plugins. Styles created as plugins are loaded as shared objects at runtime by Qt itself. Please refer to the \link @@ -325,9 +334,10 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C QStyle::QStyle() : QObject(*new QStylePrivate) { + Q_D(QStyle); + d->proxyStyle = this; } - /*! \internal @@ -336,6 +346,8 @@ QStyle::QStyle() QStyle::QStyle(QStylePrivate &dd) : QObject(dd) { + Q_D(QStyle); + d->proxyStyle = this; } /*! @@ -514,8 +526,9 @@ void QStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, c } if (!enabled) { if (styleHint(SH_DitherDisabledText)) { - painter->drawText(rect, alignment, text); - painter->fillRect(painter->boundingRect(rect, alignment, text), QBrush(painter->background().color(), Qt::Dense5Pattern)); + QRect br; + painter->drawText(rect, alignment, text, &br); + painter->fillRect(br, QBrush(painter->background().color(), Qt::Dense5Pattern)); return; } else if (styleHint(SH_EtchDisabledText)) { QPen pen = painter->pen(); @@ -551,7 +564,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, /*! \enum QStyle::PrimitiveElement - This enum describes that various primitive elements. A + This enum describes the various primitive elements. A primitive element is a common GUI element, such as a checkbox indicator or button bevel. @@ -1048,6 +1061,8 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SE_TabBarTabRightButton Area for a widget on the right side of a tab in a tab bar. \value SE_TabBarTabText Area for the text on a tab in a tab bar. + \value SE_ToolBarHandle Area for the handle of a tool bar. + \sa subElementRect() */ @@ -1093,7 +1108,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value CC_ScrollBar A scroll bar, like QScrollBar. \value CC_Slider A slider, like QSlider. \value CC_ToolButton A tool button, like QToolButton. - \value CC_TitleBar A Title bar, like those used in QWorkspace. + \value CC_TitleBar A Title bar, like those used in QMdiSubWindow. \value CC_Q3ListView Used for drawing the Q3ListView class. \value CC_GroupBox A group box, like QGroupBox. \value CC_Dial A dial, like QDial. @@ -1177,6 +1192,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SC_All Special value that matches all sub-controls. \omitvalue SC_Q3ListViewBranch + \omitvalue SC_CustomBase \sa ComplexControl */ @@ -1330,7 +1346,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PM_LayoutVerticalSpacing Default \l{QLayout::spacing}{vertical spacing} for a QLayout. \value PM_MaximumDragDistance The maximum allowed distance between - the mouse and a slider when dragging. Exceeding the specified + the mouse and a scrollbar when dragging. Exceeding the specified distance will cause the slider to jump back to the original position; a value of -1 disables this behavior. @@ -1850,6 +1866,8 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SH_DockWidget_ButtonsHaveFrame Determines if dockwidget buttons should have frames. Default is true. + \value SH_ToolButtonStyle Determines the default system style for tool buttons that uses Qt::ToolButtonFollowStyle. + \omitvalue SH_UnderlineAccelerator \sa styleHint() @@ -1876,7 +1894,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, can follow some existing GUI style or guideline. \value SP_TitleBarMinButton Minimize button on title bars (e.g., - in QWorkspace). + in QMdiSubWindow). \value SP_TitleBarMenuButton Menu button on a title bar. \value SP_TitleBarMaxButton Maximize button on title bars. \value SP_TitleBarCloseButton Close button on title bars. @@ -1948,22 +1966,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SP_CustomBase Base value for custom standard pixmaps; custom values must be greater than this value. - \sa standardPixmap() standardIcon() -*/ - -/*### - \enum QStyle::IconMode - - This enum represents the effects performed on a pixmap to achieve a - GUI style's perferred way of representing the image in different - states. - - \value IM_Disabled A disabled pixmap (drawn on disabled widgets) - \value IM_Active An active pixmap (drawn on active tool buttons and menu items) - \value IM_CustomBase Base value for custom PixmapTypes; custom - values must be greater than this value - - \sa generatedIconPixmap() + \sa standardIcon() */ /*! @@ -2246,7 +2249,7 @@ QPalette QStyle::standardPalette() const slot in your subclass instead. The standardIcon() function will dynamically detect the slot and call it. - \sa standardIconImplementation(), standardPixmap() + \sa standardIconImplementation() */ QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const @@ -2271,8 +2274,7 @@ QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *opti subclass; because of binary compatibility constraints, the standardIcon() function (introduced in Qt 4.1) is not virtual. Instead, standardIcon() will dynamically detect and call - \e this slot. The default implementation simply calls the - standardPixmap() function with the given parameters. + \e this slot. The \a standardIcon is a standard pixmap which can follow some existing GUI style or guideline. The \a option argument can be @@ -2437,9 +2439,36 @@ QDebug operator<<(QDebug debug, QStyle::State state) qSort(states); debug << states.join(QLatin1String(" | ")); - debug << ")"; + debug << ')'; return debug; } #endif +/*! + \since 4.6 + + \fn const QStyle *QStyle::proxy() const + + This function returns the current proxy for this style. + By default most styles will return themselves. However + when a proxy style is in use, it will allow the style to + call back into its proxy. +*/ +const QStyle * QStyle::proxy() const +{ + Q_D(const QStyle); + return d->proxyStyle; +} + +/* \internal + + This function sets the base style that style calls will be + redirected to. Note that ownership is not transferred. +*/ +void QStyle::setProxy(QStyle *style) +{ + Q_D(QStyle); + d->proxyStyle = style; +} + QT_END_NAMESPACE diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h index 133ad37..f22bf55 100644 --- a/src/gui/styles/qstyle.h +++ b/src/gui/styles/qstyle.h @@ -373,6 +373,8 @@ public: SE_ShapedFrameContents, + SE_ToolBarHandle, + // do not add any values below/greater than this SE_CustomBase = 0xf0000000 }; @@ -453,6 +455,7 @@ public: SC_MdiNormalButton = 0x00000002, SC_MdiCloseButton = 0x00000004, + SC_CustomBase = 0xf0000000, SC_All = 0xffffffff }; Q_DECLARE_FLAGS(SubControls, SubControl) @@ -727,7 +730,7 @@ public: SH_ItemView_DrawDelegateFrame, SH_TabBar_CloseButtonPosition, SH_DockWidget_ButtonsHaveFrame, - + SH_ToolButtonStyle, // Add new style hint values here #ifdef QT3_SUPPORT @@ -845,6 +848,8 @@ public: QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, QStyleOption *option = 0, QWidget *widget = 0) const; + const QStyle * proxy() const; + protected Q_SLOTS: QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0, const QWidget *widget = 0) const; @@ -859,6 +864,9 @@ private: friend class QWidget; friend class QWidgetPrivate; friend class QApplication; + friend class QProxyStyle; + friend class QProxyStylePrivate; + void setProxy(QStyle *style); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State) diff --git a/src/gui/styles/qstyle_p.h b/src/gui/styles/qstyle_p.h index 814166b..2d6ef22 100644 --- a/src/gui/styles/qstyle_p.h +++ b/src/gui/styles/qstyle_p.h @@ -43,6 +43,8 @@ #define QSTYLE_P_H #include "private/qobject_p.h" +#include "private/qstylehelper_p.h" +#include <QtGui/qstyle.h> QT_BEGIN_NAMESPACE @@ -51,22 +53,24 @@ QT_BEGIN_NAMESPACE // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of qstyle_*.cpp. This header file may change from version to version +// without notice, or even be removed. // // We mean it. // // Private class +class QStyle; + class QStylePrivate: public QObjectPrivate { - Q_DECLARE_PUBLIC(QStyle) + Q_DECLARE_PUBLIC(QStyle); public: inline QStylePrivate() - : layoutSpacingIndex(-1) - { } + : layoutSpacingIndex(-1), proxyStyle(0) {} mutable int layoutSpacingIndex; + QStyle *proxyStyle; }; @@ -75,9 +79,9 @@ public: QPixmap internalPixmapCache; \ QImage imageCache; \ QPainter *p = painter; \ - QString unique = uniqueName((a), option, option->rect.size()); \ + QString unique = QStyleHelper::uniqueName((a), option, option->rect.size()); \ int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \ - bool doPixmapCache = UsePixmapCache && txType <= QTransform::TxTranslate; \ + bool doPixmapCache = txType <= QTransform::TxTranslate; \ if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) { \ painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \ } else { \ @@ -89,6 +93,7 @@ public: } + #define END_STYLE_PIXMAPCACHE \ if (doPixmapCache) { \ p->end(); \ diff --git a/src/gui/styles/qstylefactory.cpp b/src/gui/styles/qstylefactory.cpp index 1db7f8e..36f405c 100644 --- a/src/gui/styles/qstylefactory.cpp +++ b/src/gui/styles/qstylefactory.cpp @@ -170,7 +170,7 @@ QStyle *QStyleFactory::create(const QString& key) else #endif #ifndef QT_NO_STYLE_MAC - if (style.left(9) == QLatin1String("macintosh")) { + if (style.startsWith(QLatin1String("macintosh"))) { ret = new QMacStyle; # ifdef Q_WS_MAC if (style == QLatin1String("macintosh")) diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp new file mode 100644 index 0000000..4877ec4 --- /dev/null +++ b/src/gui/styles/qstylehelper.cpp @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qstylehelper_p.h" + +#include <qstyleoption.h> +#include <qpainter.h> +#include <qpixmapcache.h> +#include <private/qmath_p.h> +#include <private/qstyle_p.h> +#include <qmath.h> + +#if defined(Q_WS_WIN) +#include "qt_windows.h" +#elif defined(Q_WS_MAC) +#include <private/qt_cocoa_helpers_mac_p.h> +#endif + +QT_BEGIN_NAMESPACE + +namespace QStyleHelper { + +QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) +{ + const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); + QString tmp = QString::fromLatin1("%1-%2-%3-%4-%5-%6x%7").arg(key).arg(uint(option->state)).arg(option->direction) + .arg(complexOption ? uint(complexOption->activeSubControls) : uint(0)) + .arg(option->palette.cacheKey()).arg(size.width()).arg(size.height()); +#ifndef QT_NO_SPINBOX + if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { + tmp.append(QLatin1Char('-')); + tmp.append(QString::number(spinBox->buttonSymbols)); + tmp.append(QLatin1Char('-')); + tmp.append(QString::number(spinBox->stepEnabled)); + tmp.append(QLatin1Char('-')); + tmp.append(QLatin1Char(spinBox->frame ? '1' : '0')); + } +#endif // QT_NO_SPINBOX + return tmp; +} + +qreal dpiScaled(qreal value) +{ + static qreal scale = -1; + if (scale < 0) { + scale = 1.0; +#if defined(Q_WS_WIN) + { + HDC hdcScreen = GetDC(0); + int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX); + ReleaseDC(0, hdcScreen); + scale = dpi/96.0; + } +#elif defined(Q_WS_MAC) + scale = qt_mac_get_scalefactor(); +#endif + } + return value * scale; +} + + +#ifndef QT_NO_DIAL + +int calcBigLineSize(int radius) +{ + int bigLineSize = radius / 6; + if (bigLineSize < 4) + bigLineSize = 4; + if (bigLineSize > radius / 2) + bigLineSize = radius / 2; + return bigLineSize; +} + +static QPointF calcRadialPos(const QStyleOptionSlider *dial, qreal offset) +{ + const int width = dial->rect.width(); + const int height = dial->rect.height(); + const int r = qMin(width, height) / 2; + const int currentSliderPosition = dial->upsideDown ? dial->sliderPosition : (dial->maximum - dial->sliderPosition); + qreal a = 0; + if (dial->maximum == dial->minimum) + a = Q_PI / 2; + else if (dial->dialWrapping) + a = Q_PI * 3 / 2 - (currentSliderPosition - dial->minimum) * 2 * Q_PI + / (dial->maximum - dial->minimum); + else + a = (Q_PI * 8 - (currentSliderPosition - dial->minimum) * 10 * Q_PI + / (dial->maximum - dial->minimum)) / 6; + qreal xc = width / 2.0; + qreal yc = height / 2.0; + qreal len = r - QStyleHelper::calcBigLineSize(r) - 3; + qreal back = offset * len; + QPointF pos(QPointF(xc + back * qCos(a), yc - back * qSin(a))); + return pos; +} + +qreal angle(const QPointF &p1, const QPointF &p2) +{ + static const qreal rad_factor = 180 / Q_PI; + qreal _angle = 0; + + if (p1.x() == p2.x()) { + if (p1.y() < p2.y()) + _angle = 270; + else + _angle = 90; + } else { + qreal x1, x2, y1, y2; + + if (p1.x() <= p2.x()) { + x1 = p1.x(); y1 = p1.y(); + x2 = p2.x(); y2 = p2.y(); + } else { + x2 = p1.x(); y2 = p1.y(); + x1 = p2.x(); y1 = p2.y(); + } + + qreal m = -(y2 - y1) / (x2 - x1); + _angle = atan(m) * rad_factor; + + if (p1.x() < p2.x()) + _angle = 180 - _angle; + else + _angle = -_angle; + } + return _angle; +} + +QPolygonF calcLines(const QStyleOptionSlider *dial) +{ + QPolygonF poly; + int width = dial->rect.width(); + int height = dial->rect.height(); + qreal r = qMin(width, height) / 2; + int bigLineSize = calcBigLineSize(int(r)); + + qreal xc = width / 2 + 0.5; + qreal yc = height / 2 + 0.5; + int ns = dial->tickInterval; + int notches = (dial->maximum + ns - 1 - dial->minimum) / ns; + if (notches <= 0) + return poly; + if (dial->maximum < dial->minimum || dial->maximum - dial->minimum > 1000) { + int maximum = dial->minimum + 1000; + notches = (maximum + ns - 1 - dial->minimum) / ns; + } + + poly.resize(2 + 2 * notches); + int smallLineSize = bigLineSize / 2; + for (int i = 0; i <= notches; ++i) { + qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches + : (Q_PI * 8 - i * 10 * Q_PI / notches) / 6; + qreal s = qSin(angle); + qreal c = qCos(angle); + if (i == 0 || (((ns * i) % (dial->pageStep ? dial->pageStep : 1)) == 0)) { + poly[2 * i] = QPointF(xc + (r - bigLineSize) * c, + yc - (r - bigLineSize) * s); + poly[2 * i + 1] = QPointF(xc + r * c, yc - r * s); + } else { + poly[2 * i] = QPointF(xc + (r - 1 - smallLineSize) * c, + yc - (r - 1 - smallLineSize) * s); + poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s); + } + } + return poly; +} + +// This will draw a nice and shiny QDial for us. We don't want +// all the shinyness in QWindowsStyle, hence we place it here + +void drawDial(const QStyleOptionSlider *option, QPainter *painter) +{ + QPalette pal = option->palette; + QColor buttonColor = pal.button().color(); + const int width = option->rect.width(); + const int height = option->rect.height(); + const bool enabled = option->state & QStyle::State_Enabled; + qreal r = qMin(width, height) / 2; + r -= r/50; + const qreal penSize = r/20.0; + + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + + // Draw notches + if (option->subControls & QStyle::SC_DialTickmarks) { + painter->setPen(option->palette.dark().color().darker(120)); + painter->drawLines(QStyleHelper::calcLines(option)); + } + + // Cache dial background + BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("qdial")); + p->setRenderHint(QPainter::Antialiasing); + + const qreal d_ = r / 6; + const qreal dx = option->rect.x() + d_ + (width - 2 * r) / 2 + 1; + const qreal dy = option->rect.y() + d_ + (height - 2 * r) / 2 + 1; + + QRectF br = QRectF(dx + 0.5, dy + 0.5, + int(r * 2 - 2 * d_ - 2), + int(r * 2 - 2 * d_ - 2)); + buttonColor.setHsv(buttonColor .hue(), + qMin(140, buttonColor .saturation()), + qMax(180, buttonColor.value())); + QColor shadowColor(0, 0, 0, 20); + + if (enabled) { + // Drop shadow + qreal shadowSize = qMax(1.0, penSize/2.0); + QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize, + 2*shadowSize, 2*shadowSize); + QRadialGradient shadowGradient(shadowRect.center().x(), + shadowRect.center().y(), shadowRect.width()/2.0, + shadowRect.center().x(), shadowRect.center().y()); + shadowGradient.setColorAt(0.91, QColor(0, 0, 0, 40)); + shadowGradient.setColorAt(1.0, Qt::transparent); + p->setBrush(shadowGradient); + p->setPen(Qt::NoPen); + p->translate(shadowSize, shadowSize); + p->drawEllipse(shadowRect); + p->translate(-shadowSize, -shadowSize); + + // Main gradient + QRadialGradient gradient(br.center().x() - br.width()/3, dy, + br.width()*1.3, br.center().x(), + br.center().y() - br.height()/2); + gradient.setColorAt(0, buttonColor.lighter(110)); + gradient.setColorAt(0.5, buttonColor); + gradient.setColorAt(0.501, buttonColor.darker(102)); + gradient.setColorAt(1, buttonColor.darker(115)); + p->setBrush(gradient); + } else { + p->setBrush(Qt::NoBrush); + } + + p->setPen(QPen(buttonColor.darker(280))); + p->drawEllipse(br); + p->setBrush(Qt::NoBrush); + p->setPen(buttonColor.lighter(110)); + p->drawEllipse(br.adjusted(1, 1, -1, -1)); + + if (option->state & QStyle::State_HasFocus) { + QColor highlight = pal.highlight().color(); + highlight.setHsv(highlight.hue(), + qMin(160, highlight.saturation()), + qMax(230, highlight.value())); + highlight.setAlpha(127); + p->setPen(QPen(highlight, 2.0)); + p->setBrush(Qt::NoBrush); + p->drawEllipse(br.adjusted(-1, -1, 1, 1)); + } + + END_STYLE_PIXMAPCACHE + + QPointF dp = calcRadialPos(option, 0.70); + buttonColor = buttonColor.lighter(104); + buttonColor.setAlphaF(0.8); + const qreal ds = r/7.0; + QRectF dialRect(dp.x() - ds, dp.y() - ds, 2*ds, 2*ds); + QRadialGradient dialGradient(dialRect.center().x() + dialRect.width()/2, + dialRect.center().y() + dialRect.width(), + dialRect.width()*2, + dialRect.center().x(), dialRect.center().y()); + dialGradient.setColorAt(1, buttonColor.darker(140)); + dialGradient.setColorAt(0.4, buttonColor.darker(120)); + dialGradient.setColorAt(0, buttonColor.darker(110)); + if (penSize > 3.0) { + painter->setPen(QPen(QColor(0, 0, 0, 25), penSize)); + painter->drawLine(calcRadialPos(option, 0.90), calcRadialPos(option, 0.96)); + } + + painter->setBrush(dialGradient); + painter->setPen(QColor(255, 255, 255, 150)); + painter->drawEllipse(dialRect.adjusted(-1, -1, 1, 1)); + painter->setPen(QColor(0, 0, 0, 80)); + painter->drawEllipse(dialRect); + painter->restore(); +} +#endif //QT_NO_DIAL + +void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, + int left, int top, int right, + int bottom) +{ + QSize size = pixmap.size(); + //painter->setRenderHint(QPainter::SmoothPixmapTransform); + + //top + if (top > 0) { + painter->drawPixmap(QRect(rect.left() + left, rect.top(), rect.width() -right - left, top), pixmap, + QRect(left, 0, size.width() -right - left, top)); + + //top-left + if(left > 0) + painter->drawPixmap(QRect(rect.left(), rect.top(), left, top), pixmap, + QRect(0, 0, left, top)); + + //top-right + if (right > 0) + painter->drawPixmap(QRect(rect.left() + rect.width() - right, rect.top(), right, top), pixmap, + QRect(size.width() - right, 0, right, top)); + } + + //left + if (left > 0) + painter->drawPixmap(QRect(rect.left(), rect.top()+top, left, rect.height() - top - bottom), pixmap, + QRect(0, top, left, size.height() - bottom - top)); + + //center + painter->drawPixmap(QRect(rect.left() + left, rect.top()+top, rect.width() -right - left, + rect.height() - bottom - top), pixmap, + QRect(left, top, size.width() -right -left, + size.height() - bottom - top)); + //right + if (right > 0) + painter->drawPixmap(QRect(rect.left() +rect.width() - right, rect.top()+top, right, rect.height() - top - bottom), pixmap, + QRect(size.width() - right, top, right, size.height() - bottom - top)); + + //bottom + if (bottom > 0) { + painter->drawPixmap(QRect(rect.left() +left, rect.top() + rect.height() - bottom, + rect.width() - right - left, bottom), pixmap, + QRect(left, size.height() - bottom, + size.width() - right - left, bottom)); + //bottom-left + if (left > 0) + painter->drawPixmap(QRect(rect.left(), rect.top() + rect.height() - bottom, left, bottom), pixmap, + QRect(0, size.height() - bottom, left, bottom)); + + //bottom-right + if (right > 0) + painter->drawPixmap(QRect(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), pixmap, + QRect(size.width() - right, size.height() - bottom, right, bottom)); + + } +} +} +QT_END_NAMESPACE diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h new file mode 100644 index 0000000..cac88e2 --- /dev/null +++ b/src/gui/styles/qstylehelper_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/qglobal.h> +#include <QtCore/qpoint.h> +#include <QtGui/qpolygon.h> + +#ifndef QSTYLEHELPER_P_H +#define QSTYLEHELPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QPainter; +class QPixmap; +class QStyleOptionSlider; +class QStyleOption; + +namespace QStyleHelper +{ + QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size); + qreal dpiScaled(qreal value); +#ifndef QT_NO_DIAL + qreal angle(const QPointF &p1, const QPointF &p2); + QPolygonF calcLines(const QStyleOptionSlider *dial); + int calcBigLineSize(int radius); + void drawDial(const QStyleOptionSlider *dial, QPainter *painter); +#endif //QT_NO_DIAL + void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect, + int left = 0, int top = 0, int right = 0, + int bottom = 0); +} + +QT_END_NAMESPACE + +#endif // QSTYLEHELPER_P_H diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index c151997..0ff7995 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -48,6 +48,7 @@ #ifndef QT_NO_DEBUG #include <qdebug.h> #endif +#include <QtCore/qmath.h> QT_BEGIN_NAMESPACE @@ -656,7 +657,7 @@ QStyleOptionFrameV2 &QStyleOptionFrameV2::operator=(const QStyleOptionFrame &oth /*! \enum QStyleOptionFrameV2::FrameFeature - This enum describles the different types of features a frame can have. + This enum describes the different types of features a frame can have. \value None Indicates a normal frame. \value Flat Indicates a flat frame. @@ -898,7 +899,7 @@ QStyleOptionViewItemV2 &QStyleOptionViewItemV2::operator=(const QStyleOptionView /*! \enum QStyleOptionViewItemV2::ViewItemFeature - This enum describles the different types of features an item can have. + This enum describes the different types of features an item can have. \value None Indicates a normal item. \value WrapText Indicates an item with wrapped text. @@ -3541,7 +3542,8 @@ QStyleOptionQ3DockWindow::QStyleOptionQ3DockWindow(int version) */ QStyleOptionDockWidget::QStyleOptionDockWidget() - : QStyleOption(Version, SO_DockWidget), movable(false) + : QStyleOption(Version, SO_DockWidget), closable(false), + movable(false), floatable(false) { } @@ -4256,8 +4258,7 @@ QStyleOptionRubberBand::QStyleOptionRubberBand(int version) parameters for drawing a title bar. QStyleOptionTitleBar contains all the information that QStyle - functions need to draw the title bars of QWorkspace's MDI - children. + functions need to draw the title bar of a QMdiSubWindow. For performance reasons, the access to the member variables is direct (i.e., using the \c . or \c -> operator). This low-level feel @@ -4267,7 +4268,7 @@ QStyleOptionRubberBand::QStyleOptionRubberBand(int version) For an example demonstrating how style options can be used, see the \l {widgets/styles}{Styles} example. - \sa QStyleOption, QStyleOptionComplex, QWorkspace + \sa QStyleOption, QStyleOptionComplex, QMdiSubWindow */ /*! @@ -4981,8 +4982,7 @@ QStyleOptionSizeGrip::QStyleOptionSizeGrip(int version) */ /*! - Constructs a QStyleOptionGraphicsItem. The levelOfDetail parameter is - initialized to 1. + Constructs a QStyleOptionGraphicsItem. */ QStyleOptionGraphicsItem::QStyleOptionGraphicsItem() : QStyleOption(Version, Type), levelOfDetail(1) @@ -4998,6 +4998,29 @@ QStyleOptionGraphicsItem::QStyleOptionGraphicsItem(int version) } /*! + \since 4.6 + + Returns the level of detail from the \a worldTransform. + + Its value represents the maximum value of the height and + width of a unity rectangle, mapped using the \a worldTransform + of the painter used to draw the item. By default, if no + transformations are applied, its value is 1. If zoomed out 1:2, the level + of detail will be 0.5, and if zoomed in 2:1, its value is 2. +*/ +qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &worldTransform) +{ + if (worldTransform.type() <= QTransform::TxTranslate) + return 1; // Translation only? The LOD is 1. + + // Two unit vectors. + QLineF v1(0, 0, 1, 0); + QLineF v2(0, 0, 0, 1); + // LOD is the transformed area of a 1x1 rectangle. + return qSqrt(worldTransform.map(v1).length() * worldTransform.map(v2).length()); +} + +/*! \fn QStyleOptionGraphicsItem::QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) Constructs a copy of \a other. @@ -5010,38 +5033,41 @@ QStyleOptionGraphicsItem::QStyleOptionGraphicsItem(int version) Make use of this rectangle to speed up item drawing when only parts of the item are exposed. If the whole item is exposed, this rectangle will be the same as QGraphicsItem::boundingRect(). + + This member is only initialized for items that have the + QGraphicsItem::ItemUsesExtendedStyleOption flag set. */ /*! \variable QStyleOptionGraphicsItem::matrix \brief the complete transformation matrix for the item + \obsolete + + The QMatrix provided through this member does include information about + any perspective transformations applied to the view or item. To get the + correct transformation matrix, use QPainter::transform() on the painter + passed into the QGraphicsItem::paint() implementation. - This matrix is the sum of the item's scene matrix and the matrix of the - painter used for drawing the item. It is provided for convenience, + This matrix is the combination of the item's scene matrix and the matrix + of the painter used for drawing the item. It is provided for convenience, allowing anvanced level-of-detail metrics that can be used to speed up item drawing. - To find the dimentions of an item in screen coordinates (i.e., pixels), + To find the dimensions of an item in screen coordinates (i.e., pixels), you can use the mapping functions of QMatrix, such as QMatrix::map(). - \sa QStyleOptionGraphicsItem::levelOfDetail + This member is only initialized for items that have the + QGraphicsItem::ItemUsesExtendedStyleOption flag set. + + \sa QStyleOptionGraphicsItem::levelOfDetailFromTransform() */ /*! \variable QStyleOptionGraphicsItem::levelOfDetail - \brief a simple metric for determining an item's level of detail - - This simple metric provides an easy way to determine the level of detail - for an item. Its value represents the maximum value of the height and - width of a unity rectangle, mapped using the complete transformation - matrix of the painter used to draw the item. By default, if no - transformations are applied, its value is 1. If zoomed out 1:2, the level - of detail will be 0.5, and if zoomed in 2:1, its value is 2. - - For more advanced level-of-detail metrics, use - QStyleOptionGraphicsItem::matrix directly. + \obsolete - \sa QStyleOptionGraphicsItem::matrix + Use QStyleOptionGraphicsItem::levelOfDetailFromTransform() + together with QPainter::worldTransform() instead. */ /*! @@ -5342,10 +5368,10 @@ QDebug operator<<(QDebug debug, const QStyleOption &option) { debug << "QStyleOption("; debug << QStyleOption::OptionType(option.type); - debug << "," << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight"); - debug << "," << option.state; - debug << "," << option.rect; - debug << ")"; + debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight"); + debug << ',' << option.state; + debug << ',' << option.rect; + debug << ')'; return debug; } #endif diff --git a/src/gui/styles/qstyleoption.h b/src/gui/styles/qstyleoption.h index bf416fd..710c696 100644 --- a/src/gui/styles/qstyleoption.h +++ b/src/gui/styles/qstyleoption.h @@ -856,6 +856,7 @@ public: QStyleOptionGraphicsItem(); QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; } + static qreal levelOfDetailFromTransform(const QTransform &worldTransform); protected: QStyleOptionGraphicsItem(int version); }; diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index f725e68..2efa4a7 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -81,6 +81,7 @@ #include <private/qwidget_p.h> #include <QAbstractSpinBox> #include <QLabel> +#include "qdrawutil.h" #include <limits.h> @@ -312,15 +313,10 @@ struct QStyleSheetBorderImageData : public QSharedData for (int i = 0; i < 4; i++) cuts[i] = -1; } - QPixmap topEdge, bottomEdge, leftEdge, rightEdge, middle; - QRect topEdgeRect, bottomEdgeRect, leftEdgeRect, rightEdgeRect, middleRect; - QRect topLeftCorner, topRightCorner, bottomRightCorner, bottomLeftCorner; int cuts[4]; QPixmap pixmap; QImage image; QCss::TileMode horizStretch, vertStretch; - - void cutBorderImage(); }; struct QStyleSheetBackgroundData : public QSharedData @@ -871,7 +867,7 @@ static QStyle::StandardPixmap subControlIcon(int pe) QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget *widget) : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { - QPalette palette = qApp->palette(); // ###: ideally widget's palette + QPalette palette = QApplication::palette(); // ###: ideally widget's palette ValueExtractor v(declarations, palette); features = v.extractStyleFeatures(); @@ -1122,176 +1118,27 @@ void QRenderRule::fixupBorder(int nativeWidth) for (int i = 0; i < 4; i++) // assume, cut = border bi->cuts[i] = int(border()->borders[i]); } - bi->cutBorderImage(); -} - -void QStyleSheetBorderImageData::cutBorderImage() -{ - const int w = pixmap.width(); - const int h = pixmap.height(); - const int &l = cuts[LeftEdge], &r = cuts[RightEdge], - &t = cuts[TopEdge], &b = cuts[BottomEdge]; - - topEdgeRect = QRect(l, 0, w - r - l, t); - bottomEdgeRect = QRect(l, h - b, w - l - r, b); - if (horizStretch != TileMode_Stretch) { - if (topEdgeRect.isValid()) - topEdge = pixmap.copy(topEdgeRect).scaledToHeight(t); - if (bottomEdgeRect.isValid()) - bottomEdge = pixmap.copy(bottomEdgeRect).scaledToHeight(b); - } - - leftEdgeRect = QRect(0, t, l, h - b - t); - rightEdgeRect = QRect(w - r, t, r, h - t- b); - if (vertStretch != TileMode_Stretch) { - if (leftEdgeRect.isValid()) - leftEdge = pixmap.copy(leftEdgeRect).scaledToWidth(l); - if (rightEdgeRect.isValid()) - rightEdge = pixmap.copy(rightEdgeRect).scaledToWidth(r); - } - - middleRect = QRect(l, t, w - r -l, h - t - b); - if (middleRect.isValid() - && !(horizStretch == TileMode_Stretch && vertStretch == TileMode_Stretch)) { - middle = pixmap.copy(middleRect); - } } -static void qDrawCenterTiledPixmap(QPainter *p, const QRectF& r, const QPixmap& pix) -{ - p->drawTiledPixmap(r, pix, QPoint(pix.width() - int(r.width())%pix.width(), - pix.height() - int(r.height())%pix.height())); -} - -// Note: Round is not supported void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect) { - setClip(p, rect); - const QRectF br(rect); - const int *borders = border()->borders; - const int &l = borders[LeftEdge], &r = borders[RightEdge], - &t = borders[TopEdge], &b = borders[BottomEdge]; - QRectF pr = br.adjusted(l, t, -r, -b); + static const Qt::TileRule tileMode2TileRule[] = { + Qt::Stretch, Qt::Round, Qt::Stretch, Qt::Repeat, Qt::Stretch }; + + const QStyleSheetBorderImageData *borderImageData = border()->borderImage(); + const int *targetBorders = border()->borders; + const int *sourceBorders = borderImageData->cuts; + QMargins sourceMargins(sourceBorders[TopEdge], sourceBorders[LeftEdge], + sourceBorders[BottomEdge], sourceBorders[RightEdge]); + QMargins targetMargins(targetBorders[TopEdge], targetBorders[LeftEdge], + targetBorders[BottomEdge], targetBorders[RightEdge]); bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform; p->setRenderHint(QPainter::SmoothPixmapTransform); - - const QStyleSheetBorderImageData *bi = border()->borderImage(); - const QPixmap& pix = bi->pixmap; - const int *c = bi->cuts; - QRectF tlc(0, 0, c[LeftEdge], c[TopEdge]); - if (tlc.isValid()) - p->drawPixmap(QRectF(br.topLeft(), QSizeF(l, t)), pix, tlc); - QRectF trc(pix.width() - c[RightEdge], 0, c[RightEdge], c[TopEdge]); - if (trc.isValid()) - p->drawPixmap(QRectF(br.left() + br.width() - r, br.y(), r, t), pix, trc); - QRectF blc(0, pix.height() - c[BottomEdge], c[LeftEdge], c[BottomEdge]); - if (blc.isValid()) - p->drawPixmap(QRectF(br.x(), br.y() + br.height() - b, l, b), pix, blc); - QRectF brc(pix.width() - c[RightEdge], pix.height() - c[BottomEdge], - c[RightEdge], c[BottomEdge]); - if (brc.isValid()) - p->drawPixmap(QRectF(br.x() + br.width() - r, br.y() + br.height() - b, r, b), - pix, brc); - - QRectF topEdgeRect(br.x() + l, br.y(), pr.width(), t); - QRectF bottomEdgeRect(br.x() + l, br.y() + br.height() - b, pr.width(), b); - - switch (bi->horizStretch) { - case TileMode_Stretch: - if (bi->topEdgeRect.isValid()) - p->drawPixmap(topEdgeRect, pix, bi->topEdgeRect); - if (bi->bottomEdgeRect.isValid()) - p->drawPixmap(bottomEdgeRect, pix, bi->bottomEdgeRect); - if (bi->middleRect.isValid()) { - if (bi->vertStretch == TileMode_Stretch) - p->drawPixmap(pr, pix, bi->middleRect); - else if (bi->vertStretch == TileMode_Repeat) { - QPixmap scaled = bi->middle.scaled(int(pr.width()), bi->middle.height()); - qDrawCenterTiledPixmap(p, pr, scaled); - } - } - break; - case TileMode_Repeat: - if (!bi->topEdge.isNull() && !topEdgeRect.isEmpty()) { - QPixmap scaled = bi->topEdge.scaled(bi->topEdge.width(), t); - qDrawCenterTiledPixmap(p, topEdgeRect, scaled); - } - if (!bi->bottomEdge.isNull() && !bottomEdgeRect.isEmpty()) { - QPixmap scaled = bi->bottomEdge.scaled(bi->bottomEdge.width(), b); - qDrawCenterTiledPixmap(p, bottomEdgeRect, scaled); - } - if (bi->middleRect.isValid()) { - if (bi->vertStretch == TileMode_Repeat) { - qDrawCenterTiledPixmap(p, pr, bi->middle); - } else if (bi->vertStretch == TileMode_Stretch) { - QPixmap scaled = bi->middle.scaled(bi->middle.width(), int(pr.height())); - qDrawCenterTiledPixmap(p, pr, scaled); - } - } - break; - case TileMode_Round: - if (!bi->topEdge.isNull()) { - int rwh = (int)pr.width()/ceil(pr.width()/bi->topEdge.width()); - QPixmap scaled = bi->topEdge.scaled(rwh, bi->topEdge.height()); - int blank = int(pr.width()) % rwh; - p->drawTiledPixmap(QRectF(br.x() + l + blank/2, br.y(), pr.width() - blank, t), - scaled); - } - if (!bi->bottomEdge.isNull()) { - int rwh = (int) pr.width()/ceil(pr.width()/bi->bottomEdge.width()); - QPixmap scaled = bi->bottomEdge.scaled(rwh, bi->bottomEdge.height()); - int blank = int(pr.width()) % rwh; - p->drawTiledPixmap(QRectF(br.x() + l+ blank/2, br.y()+br.height()-b, - pr.width() - blank, b), scaled); - } - break; - default: - break; - } - - QRectF leftEdgeRect(br.x(), br.y() + t, l, pr.height()); - QRectF rightEdgeRect(br.x() + br.width()- r, br.y() + t, r, pr.height()); - - switch (bi->vertStretch) { - case TileMode_Stretch: - if (bi->leftEdgeRect.isValid()) - p->drawPixmap(leftEdgeRect, pix, bi->leftEdgeRect); - if (bi->rightEdgeRect.isValid()) - p->drawPixmap(rightEdgeRect, pix, bi->rightEdgeRect); - break; - case TileMode_Repeat: - if (!bi->leftEdge.isNull() && !leftEdgeRect.isEmpty()) { - QPixmap scaled = bi->leftEdge.scaled(l, bi->leftEdge.height()); - qDrawCenterTiledPixmap(p, leftEdgeRect, scaled); - } - if (!bi->rightEdge.isNull() && !rightEdgeRect.isEmpty()) { - QPixmap scaled = bi->rightEdge.scaled(r, bi->rightEdge.height()); - qDrawCenterTiledPixmap(p, rightEdgeRect, scaled); - } - break; - case TileMode_Round: - if (!bi->leftEdge.isNull()) { - int rwh = (int) pr.height()/ceil(pr.height()/bi->leftEdge.height()); - QPixmap scaled = bi->leftEdge.scaled(bi->leftEdge.width(), rwh); - int blank = int(pr.height()) % rwh; - p->drawTiledPixmap(QRectF(br.x(), br.y() + t + blank/2, l, pr.height() - blank), - scaled); - } - if (!bi->rightEdge.isNull()) { - int rwh = (int) pr.height()/ceil(pr.height()/bi->rightEdge.height()); - QPixmap scaled = bi->rightEdge.scaled(bi->rightEdge.width(), rwh); - int blank = int(pr.height()) % rwh; - p->drawTiledPixmap(QRectF(br.x() + br.width() - r, br.y()+t+blank/2, r, - pr.height() - blank), scaled); - } - break; - default: - break; - } - + qDrawBorderPixmap(p, rect, targetMargins, borderImageData->pixmap, + QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins, + QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch])); p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform); - unsetClip(p); } QRect QRenderRule::originRect(const QRect &rect, Origin origin) const @@ -1525,7 +1372,7 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q /* For embedded widgets (ComboBox, SpinBox and ScrollArea) we want the embedded widget * to be transparent when we have a transparent background or border image */ if ((hasBackground() && background()->isTransparent()) - || (hasBorder() && border()->hasBorderImage() && border()->borderImage()->middleRect.isValid())) + || (hasBorder() && border()->hasBorderImage() && !border()->borderImage()->pixmap.isNull())) p->setBrush(cg, w->backgroundRole(), Qt::NoBrush); } @@ -1708,7 +1555,7 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const if (widCacheIt == styleSheetCache->constEnd()) { parser.init(wid->styleSheet()); if (!parser.parse(&ss)) { - parser.init(QLatin1String("* {") + wid->styleSheet() + QLatin1String("}")); + parser.init(QLatin1String("* {") + wid->styleSheet() + QLatin1Char('}')); if (!parser.parse(&ss)) qWarning("Could not parse stylesheet of widget %p", wid); } @@ -2737,7 +2584,7 @@ static void updateWidgets(const QList<const QWidget *>& widgets) continue; widget->style()->polish(widget); QEvent event(QEvent::StyleChange); - qApp->sendEvent(widget, &event); + QApplication::sendEvent(widget, &event); widget->update(); widget->updateGeometry(); } @@ -2783,9 +2630,9 @@ QStyle *QStyleSheetStyle::baseStyle() const { if (base) return base; - if (QStyleSheetStyle *me = qobject_cast<QStyleSheetStyle *>(qApp->style())) + if (QStyleSheetStyle *me = qobject_cast<QStyleSheetStyle *>(QApplication::style())) return me->base; - return qApp->style(); + return QApplication::style(); } void QStyleSheetStyle::widgetDestroyed(QObject *o) @@ -2855,14 +2702,10 @@ void QStyleSheetStyle::polish(QWidget *w) QRenderRule rule = renderRule(sa, PseudoElement_None, PseudoClass_Enabled); if ((rule.hasBorder() && rule.border()->hasBorderImage()) || (rule.hasBackground() && !rule.background()->pixmap.isNull())) { - QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)), - sa, SLOT(update())); - QObject::disconnect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)), - sa, SLOT(update())); QObject::connect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)), - sa, SLOT(update())); + sa, SLOT(update()), Qt::UniqueConnection); QObject::connect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)), - sa, SLOT(update())); + sa, SLOT(update()), Qt::UniqueConnection); } } #endif @@ -2876,12 +2719,6 @@ void QStyleSheetStyle::polish(QWidget *w) QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Any); if (rule.hasDrawable() || rule.hasBox()) { if (w->metaObject() == &QWidget::staticMetaObject -#ifndef QT_NO_MENUBAR - || qobject_cast<QMenuBar *>(w) -#endif -#ifndef QT_NO_MENU - || qobject_cast<QMenu *>(w) -#endif #ifndef QT_NO_ITEMVIEWS || qobject_cast<QHeaderView *>(w) #endif @@ -3013,7 +2850,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC rule.drawBackgroundImage(p, cmbOpt.rect); rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button); bool customDropDown = (opt->subControls & QStyle::SC_ComboBoxArrow) - && hasStyleRule(w, PseudoElement_ComboBoxDropDown); + && (hasStyleRule(w, PseudoElement_ComboBoxDropDown) || hasStyleRule(w, PseudoElement_ComboBoxArrow)); if (customDropDown) cmbOpt.subControls &= ~QStyle::SC_ComboBoxArrow; if (rule.baseStyleCanDraw()) { @@ -3059,11 +2896,11 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) { rule.drawBackgroundImage(p, spinOpt.rect); customUp = (opt->subControls & QStyle::SC_SpinBoxUp) - && hasStyleRule(w, PseudoElement_SpinBoxUpButton); + && (hasStyleRule(w, PseudoElement_SpinBoxUpButton) || hasStyleRule(w, PseudoElement_UpArrow)); if (customUp) spinOpt.subControls &= ~QStyle::SC_SpinBoxUp; customDown = (opt->subControls & QStyle::SC_SpinBoxDown) - && hasStyleRule(w, PseudoElement_SpinBoxDownButton); + && (hasStyleRule(w, PseudoElement_SpinBoxDownButton) || hasStyleRule(w, PseudoElement_DownArrow)); if (customDown) spinOpt.subControls &= ~QStyle::SC_SpinBoxDown; if (rule.baseStyleCanDraw()) { @@ -3189,6 +3026,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC if (const QStyleOptionToolButton *tool = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { QStyleOptionToolButton toolOpt(*tool); rule.configurePalette(&toolOpt.palette, QPalette::ButtonText, QPalette::Button); + toolOpt.font = rule.font.resolve(toolOpt.font); toolOpt.rect = rule.borderRect(opt->rect); bool customArrow = (tool->features & (QStyleOptionToolButton::HasMenu | QStyleOptionToolButton::MenuButtonPopup)); bool customDropDown = tool->features & QStyleOptionToolButton::MenuButtonPopup; @@ -3735,7 +3573,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q mi.rect = positionRect(w, subRule, subRule2, PseudoElement_MenuRightArrow, opt->rect, mi.direction); drawPrimitive(arrow, &mi, p, w); } - } else if (hasStyleRule(w, PseudoElement_MenuCheckMark)) { + } else if (hasStyleRule(w, PseudoElement_MenuCheckMark) || hasStyleRule(w, PseudoElement_MenuRightArrow)) { QWindowsStyle::drawControl(ce, &mi, p, w); } else { if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) { @@ -4164,9 +4002,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base); frmOpt.rect = rule.borderRect(frmOpt.rect); baseStyle()->drawControl(ce, &frmOpt, p, w); - } else { - rule.drawBorder(p, rule.borderRect(opt->rect)); } + // else, borders are already drawn in PE_Widget } return; @@ -4220,12 +4057,6 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op QRect rect = opt->rect; switch (pe) { - case PE_PanelStatusBar: - if (rule.hasDrawable()) { - rule.drawRule(p, opt->rect); - return; - } - break; case PE_FrameStatusBar: { QRenderRule subRule = renderRule(w->parentWidget(), opt, PseudoElement_Item); @@ -4337,7 +4168,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op return; case PE_Widget: - if (!rule.hasBackground()) { + if (!rule.hasDrawable()) { QWidget *container = containerWidget(w); if (autoFillDisabledWidgets->contains(container) && (container == w || !renderRule(container, opt).hasBackground())) { @@ -4347,26 +4178,24 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } break; } - #ifndef QT_NO_SCROLLAREA if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) { const QAbstractScrollAreaPrivate *sap = sa->d_func(); rule.drawBackground(p, opt->rect, sap->contentsOffset()); - } else -#endif - { - rule.drawBackground(p, opt->rect); + if (rule.hasBorder()) + rule.drawBorder(p, rule.borderRect(opt->rect)); + break; } - - return; - - case PE_FrameMenu: +#endif + //fall tghought + case PE_PanelMenu: case PE_PanelMenuBar: - if (!rule.hasNativeBorder()) { - rule.drawBorder(p, rule.borderRect(opt->rect)); + case PE_PanelStatusBar: + if(rule.hasDrawable()) { + rule.drawRule(p, opt->rect); return; } - break; + break; case PE_IndicatorToolBarSeparator: case PE_IndicatorToolBarHandle: { @@ -4510,6 +4339,16 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op pseudoElement = PseudoElement_ScrollAreaCorner; break; + case PE_IndicatorSpinDown: + case PE_IndicatorSpinMinus: + pseudoElement = PseudoElement_SpinBoxDownArrow; + break; + + case PE_IndicatorSpinUp: + case PE_IndicatorSpinPlus: + pseudoElement = PseudoElement_SpinBoxUpArrow; + break; + default: break; } @@ -4973,13 +4812,10 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) { return QSize(sz.width(), subRule.size().height()); } else if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder())) { - int width = csz.width(), height = qMax(csz.height(), mi->fontMetrics.height()); - if (!mi->icon.isNull()) { - int iconExtent = pixelMetric(PM_SmallIconSize); - height = qMax(height, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height()); - } - width += mi->tabWidth; - return subRule.boxSize(csz.expandedTo(subRule.minimumContentsSize())); + int width = csz.width(); + if (mi->text.contains(QLatin1Char('\t'))) + width += 12; //as in QCommonStyle + return subRule.boxSize(subRule.adjustSize(QSize(width, csz.height()))); } } break; @@ -5890,13 +5726,11 @@ void QStyleSheetStyle::clearWidgetFont(QWidget* w) const w->setProperty("_q_styleSheetWidgetFont", QVariant(QVariant::Invalid)); } -// Returns the palette that should be used when the particular widget is focused. -// This needs to be called by some widgets that do drawing themselves instead -// of through the style. -// ### This should be removed ideally by Qt 4.5, and at least by Qt 5, and fixed -// for good by letting the style draw everything. +// Polish palette that should be used for a particular widget, with particular states +// (eg. :focus, :hover, ...) +// this is called by widgets that paint themself in their paint event // Returns true if there is a new palette in pal. -bool QStyleSheetStyle::focusPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal) +bool QStyleSheetStyle::styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal) { if (!w || !opt || !pal) return false; diff --git a/src/gui/styles/qstylesheetstyle_p.h b/src/gui/styles/qstylesheetstyle_p.h index ad92e57..9b7b79d 100644 --- a/src/gui/styles/qstylesheetstyle_p.h +++ b/src/gui/styles/qstylesheetstyle_p.h @@ -131,7 +131,7 @@ public: void saveWidgetFont(QWidget* w, const QFont& font) const; void clearWidgetFont(QWidget* w) const; - bool focusPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal); + bool styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal); protected Q_SLOTS: QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0, diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index 8d1086c..c70b4c8 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -72,12 +72,12 @@ #include "qdebug.h" #include "qtabwidget.h" -#ifdef Q_OS_WINCE +#ifdef Q_WS_WINCE #include "qt_windows.h" #include "qguifunctions_wince.h" extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp extern bool qt_wince_is_smartphone(); //defined in qguifunctions_wince.cpp -#endif // Q_OS_WINCE +#endif // Q_WS_WINCE QT_BEGIN_NAMESPACE @@ -685,13 +685,13 @@ QWindowsMobileStyle::QWindowsMobileStyle() : QWindowsStyle(*new QWindowsMobileSt QWindowsMobileStylePrivate::QWindowsMobileStylePrivate() :QWindowsStylePrivate() { -#ifdef Q_OS_WINCE +#ifdef Q_WS_WINCE doubleControls = qt_wince_is_high_dpi(); smartphone = qt_wince_is_smartphone(); #else doubleControls = false; smartphone = false; -#endif //Q_OS_WINCE +#endif //Q_WS_WINCE #ifndef QT_NO_IMAGEFORMAT_XPM diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 313db30..4c66bbb 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -42,6 +42,7 @@ #include "qwindowsstyle.h" #include "qwindowsstyle_p.h" #include <private/qpixmapdata_p.h> +#include <private/qstylehelper_p.h> #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN) @@ -67,6 +68,9 @@ #include "qpixmapcache.h" #include "qwizard.h" #include "qlistview.h" +#include <private/qmath_p.h> +#include <qmath.h> + #ifdef Q_WS_X11 #include "qfileinfo.h" @@ -122,8 +126,6 @@ static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark static const int windowsRightBorder = 15; // right border on windows static const int windowsCheckMarkWidth = 12; // checkmarks width on windows -static bool use2000style = true; - enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight }; /* @@ -265,9 +267,6 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) */ QWindowsStyle::QWindowsStyle() : QCommonStyle(*new QWindowsStylePrivate) { -#if defined(Q_OS_WIN32) - use2000style = QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95; -#endif } /*! @@ -277,9 +276,6 @@ QWindowsStyle::QWindowsStyle() : QCommonStyle(*new QWindowsStylePrivate) */ QWindowsStyle::QWindowsStyle(QWindowsStylePrivate &dd) : QCommonStyle(dd) { -#if defined(Q_OS_WIN32) - use2000style = QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95; -#endif } @@ -301,7 +297,7 @@ void QWindowsStyle::polish(QApplication *app) QCommonStyle::polish(app); QWindowsStylePrivate *d = const_cast<QWindowsStylePrivate*>(d_func()); // We only need the overhead when shortcuts are sometimes hidden - if (!styleHint(SH_UnderlineShortcut, 0) && app) + if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app) app->installEventFilter(this); d->activeCaptionColor = app->palette().highlight().color(); @@ -402,7 +398,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW #ifndef QT_NO_SLIDER case PM_SliderLength: - ret = 11; + ret = int(QStyleHelper::dpiScaled(11.)); break; // Returns the number of pixels to use for the business part of the @@ -424,7 +420,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW int thick = 6; // Magic constant to get 5 + 16 + 5 if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks) - thick += pixelMetric(PM_SliderLength, sl, widget) / 4; + thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4; space -= thick; if (space > 0) @@ -450,25 +446,25 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW break; case PM_SmallIconSize: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_LargeIconSize: - ret = 32; + ret = int(QStyleHelper::dpiScaled(32.)); break; case PM_IconViewIconSize: - ret = pixelMetric(PM_LargeIconSize, opt, widget); + ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); break; case PM_ToolBarIconSize: - ret = 24; + ret = int(QStyleHelper::dpiScaled(24.)); break; case PM_DockWidgetTitleMargin: - ret = 2; + ret = int(QStyleHelper::dpiScaled(2.)); break; case PM_DockWidgetTitleBarButtonMargin: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; #if defined(Q_WS_WIN) case PM_DockWidgetFrameWidth: @@ -550,7 +546,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW ret = 0; break; case PM_ToolBarHandleExtent: - ret = 10; + ret = int(QStyleHelper::dpiScaled(10.)); break; default: ret = QCommonStyle::pixelMetric(pm, opt, widget); @@ -1065,6 +1061,8 @@ QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyl } } break; + default: + break; } if (!desktopIcon.isNull()) { return desktopIcon; @@ -1133,12 +1131,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid #endif break; case SH_ItemView_ChangeHighlightOnFocus: -#if defined(Q_WS_WIN) - if (QSysInfo::WindowsVersion != QSysInfo::WV_95 && QSysInfo::WindowsVersion != QSysInfo::WV_NT) - ret = 1; - else -#endif - ret = 0; + ret = 1; break; case SH_ToolBox_SelectedPageTitleBold: ret = 0; @@ -1146,36 +1139,34 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid #if defined(Q_WS_WIN) case SH_UnderlineShortcut: + { ret = 1; - if (QSysInfo::WindowsVersion != QSysInfo::WV_95 - && QSysInfo::WindowsVersion != QSysInfo::WV_98 - && QSysInfo::WindowsVersion != QSysInfo::WV_NT) { - BOOL cues; - SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0); - ret = int(cues); - // Do nothing if we always paint underlines - Q_D(const QWindowsStyle); - if (!ret && widget && d) { + BOOL cues = false; + SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &cues, 0); + ret = int(cues); + // Do nothing if we always paint underlines + Q_D(const QWindowsStyle); + if (!ret && widget && d) { #ifndef QT_NO_MENUBAR - const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget); - if (!menuBar && qobject_cast<const QMenu *>(widget)) { - QWidget *w = QApplication::activeWindow(); - if (w && w != widget) - menuBar = qFindChild<QMenuBar *>(w); - } - // If we paint a menu bar draw underlines if is in the keyboardState - if (menuBar) { - if (menuBar->d_func()->keyboardState || d->altDown()) - ret = 1; - // Otherwise draw underlines if the toplevel widget has seen an alt-press - } else -#endif // QT_NO_MENUBAR - if (d->hasSeenAlt(widget)) { + const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget); + if (!menuBar && qobject_cast<const QMenu *>(widget)) { + QWidget *w = QApplication::activeWindow(); + if (w && w != widget) + menuBar = qFindChild<QMenuBar *>(w); + } + // If we paint a menu bar draw underlines if is in the keyboardState + if (menuBar) { + if (menuBar->d_func()->keyboardState || d->altDown()) ret = 1; - } + // Otherwise draw underlines if the toplevel widget has seen an alt-press + } else +#endif // QT_NO_MENUBAR + if (d->hasSeenAlt(widget)) { + ret = 1; } } break; + } #endif #ifndef QT_NO_RUBBERBAND case SH_RubberBand_Mask: @@ -1313,7 +1304,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, if ((!(opt->state & State_Sunken )) && (!(opt->state & State_Enabled) || !(opt->state & State_MouseOver && opt->state & State_AutoRaise)) - && (opt->state & State_On) && use2000style) { + && (opt->state & State_On)) { fill = QBrush(opt->palette.light().color(), Qt::Dense4Pattern); stippled = true; } else { @@ -1386,11 +1377,8 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QRect r = opt->rect; int size = qMin(r.height(), r.width()); QPixmap pixmap; - QString pixmapName; - pixmapName.sprintf("%s-%s-%d-%d-%d-%lld", - "$qt_ia", metaObject()->className(), - uint(opt->state), pe, - size, opt->palette.cacheKey()); + QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size)) + + QLatin1Char('-') + QString::number(pe); if (!QPixmapCache::find(pixmapName, pixmap)) { int border = size/5; int sqsize = 2*(size/2); @@ -1420,8 +1408,8 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, int bsy = 0; if (opt->state & State_Sunken) { - bsx = pixelMetric(PM_ButtonShiftHorizontal, opt, w); - bsy = pixelMetric(PM_ButtonShiftVertical, opt, w); + bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, w); + bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, w); } QRect bounds = a.boundingRect(); @@ -1510,7 +1498,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, case PE_FrameFocusRect: if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) { //### check for d->alt_down - if (!(fropt->state & State_KeyboardFocusChange) && !styleHint(SH_UnderlineShortcut, opt)) + if (!(fropt->state & State_KeyboardFocusChange) && !proxy()->styleHint(SH_UnderlineShortcut, opt)) return; QRect r = opt->rect; p->save(); @@ -1577,8 +1565,8 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, //center when rect is larger than indicator size int xOffset = 0; int yOffset = 0; - int indicatorWidth = pixelMetric(PM_ExclusiveIndicatorWidth); - int indicatorHeight = pixelMetric(PM_ExclusiveIndicatorWidth); + int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth); + int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth); if (ir.width() > indicatorWidth) xOffset += (ir.width() - indicatorWidth)/2; if (ir.height() > indicatorHeight) @@ -1627,9 +1615,9 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, popupPal.setColor(QPalette::Light, frame->palette.background().color()); popupPal.setColor(QPalette::Midlight, frame->palette.light().color()); } - if (use2000style && pe == PE_Frame && (frame->state & State_Raised)) + if (pe == PE_Frame && (frame->state & State_Raised)) qDrawWinButton(p, frame->rect, popupPal, frame->state & State_Sunken); - else if (use2000style && pe == PE_Frame && (frame->state & State_Sunken)) + else if (pe == PE_Frame && (frame->state & State_Sunken)) { popupPal.setColor(QPalette::Midlight, frame->palette.background().color()); qDrawWinPanel(p, frame->rect, popupPal, frame->state & State_Sunken); @@ -1735,7 +1723,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, break; } case PE_FrameDockWidget: if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) { - drawPrimitive(QStyle::PE_FrameWindow, opt, p, w); + proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w); } break; #endif // QT_NO_DOCKWIDGET @@ -1754,7 +1742,7 @@ case PE_FrameDockWidget: } int space = 2; - int chunksize = pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space; + int chunksize = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, w) - space; if (!vertical) { if (opt->rect.width() <= chunksize) space = 0; @@ -1780,13 +1768,12 @@ case PE_FrameDockWidget: break; #endif // QT_NO_PROGRESSBAR - case PE_FrameTabWidget: - if (use2000style) { - QRect rect = opt->rect; - QPalette pal = opt->palette; - qDrawWinButton(p, opt->rect, opt->palette, false, 0); - break; - } + case PE_FrameTabWidget: { + QRect rect = opt->rect; + QPalette pal = opt->palette; + qDrawWinButton(p, opt->rect, opt->palette, false, 0); + break; + } default: QCommonStyle::drawPrimitive(pe, opt, p, w); } @@ -1813,7 +1800,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->save(); QRect r = opt->rect; QStyleHintReturnMask mask; - if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) + if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) p->setClipRegion(mask.region); p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap); p->restore(); @@ -1882,9 +1869,9 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai mode = QIcon::Active; QPixmap pixmap; if (checked) - pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On); + pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On); else - pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode); + pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, opt, widget), mode); int pixw = pixmap.width(); int pixh = pixmap.height(); if (act && !dis && !checked) @@ -1903,7 +1890,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai newMi.state |= State_On; newMi.rect = visualRect(opt->direction, menuitem->rect, QRect(menuitem->rect.x() + windowsItemFrame, menuitem->rect.y() + windowsItemFrame, checkcol - 2 * windowsItemFrame, menuitem->rect.height() - 2*windowsItemFrame)); - drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget); + proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget); } p->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color()); @@ -1922,13 +1909,13 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->save(); int t = s.indexOf(QLatin1Char('\t')); int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) text_flags |= Qt::TextHideMnemonic; text_flags |= Qt::AlignLeft; if (t >= 0) { QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); - if (dis && !act && styleHint(SH_EtchDisabledText, opt, widget)) { + if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) { p->setPen(menuitem->palette.light().color()); p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1)); p->setPen(discol); @@ -1940,7 +1927,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) font.setBold(true); p->setFont(font); - if (dis && !act && styleHint(SH_EtchDisabledText, opt, widget)) { + if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, opt, widget)) { p->setPen(menuitem->palette.light().color()); p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t)); p->setPen(discol); @@ -1960,7 +1947,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai if (act) newMI.palette.setColor(QPalette::ButtonText, newMI.palette.highlightedText().color()); - drawPrimitive(arrow, &newMI, p, widget); + proxy()->drawPrimitive(arrow, &newMI, p, widget); } } @@ -1982,8 +1969,8 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai qDrawShadeRect(p, mbi->rect.x(), mbi->rect.y(), mbi->rect.width(), mbi->rect.height(), mbi->palette, active && down, 1, 0, &b); if (active && down) { - newMbi.rect.translate(pixelMetric(PM_ButtonShiftHorizontal, mbi, widget), - pixelMetric(PM_ButtonShiftVertical, mbi, widget)); + newMbi.rect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, mbi, widget), + proxy()->pixelMetric(PM_ButtonShiftVertical, mbi, widget)); p->setBrushOrigin(p->brushOrigin() - QPoint(1, 1)); } } @@ -2017,7 +2004,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai || (rtlHorTabs && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)); - int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget); + int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget); bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft) || (rtlHorTabs && tabBarAlignment == Qt::AlignRight); @@ -2031,7 +2018,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai QColor dark = tab->palette.dark().color(); QColor shadow = tab->palette.shadow().color(); QColor background = tab->palette.background().color(); - int borderThinkness = pixelMetric(PM_TabBarBaseOverlap, tab, widget); + int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); if (selected) borderThinkness /= 2; QRect r2(opt->rect); @@ -2062,10 +2049,6 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->setPen(light); p->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); p->drawPoint(x1 + 1, y1 + 1); - if (!use2000style) { - p->setPen(midlight); - p->drawLine(x1 + 1, y1 + 2, x1 + 1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); - } } // Top { @@ -2073,10 +2056,6 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai int end = x2 - (nextSelected ? 0 : 2); p->setPen(light); p->drawLine(beg, y1, end, y1); - if (!use2000style) { - p->setPen(midlight); - p->drawLine(beg, y1 + 1, end, y1 + 1); - } } // Right if (lastTab || selected || onlyOne || !nextSelected) { @@ -2106,10 +2085,6 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->setPen(light); p->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); p->drawPoint(x1 + 1, y2 - 1); - if (!use2000style) { - p->setPen(midlight); - p->drawLine(x1 + 1, y2 - 2, x1 + 1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness)); - } } // Bottom { @@ -2148,10 +2123,6 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->setPen(light); p->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1); p->drawPoint(x1 + 1, y1 + 1); - if (!use2000style) { - p->setPen(midlight); - p->drawLine(x1 + 2, y1 + 1, x2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1 + 1); - } } // Left { @@ -2159,10 +2130,6 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai int end = y2 - (nextSelected ? 0 : 2); p->setPen(light); p->drawLine(x1, beg, x1, end); - if (!use2000style) { - p->setPen(midlight); - p->drawLine(x1 + 1, beg, x1 + 1, end); - } } // Bottom if (lastTab || selected || onlyOne || !nextSelected) { @@ -2194,11 +2161,6 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->setPen(light); p->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1); p->drawPoint(x2 - 1, y1 + 1); - if (!use2000style) { - p->setPen(midlight); - p->drawLine(x2 - 3, y1 + 1, x1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness), y1 + 1); - p->drawPoint(x2 - 1, y1); - } } // Right { @@ -2235,7 +2197,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai #ifndef QT_NO_SCROLLBAR case CE_ScrollBarSubLine: case CE_ScrollBarAddLine: { - if (use2000style && (opt->state & State_Sunken)) { + if ((opt->state & State_Sunken)) { p->setPen(opt->palette.dark().color()); p->setBrush(opt->palette.brush(QPalette::Button)); p->drawRect(opt->rect.adjusted(0, 0, -1, -1)); @@ -2263,7 +2225,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai } QStyleOption arrowOpt = *opt; arrowOpt.rect = opt->rect.adjusted(4, 4, -4, -4); - drawPrimitive(arrow, &arrowOpt, p, widget); + proxy()->drawPrimitive(arrow, &arrowOpt, p, widget); break; } case CE_ScrollBarAddPage: case CE_ScrollBarSubPage: { @@ -2449,7 +2411,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai int w = rect.width(); if (pb->minimum == 0 && pb->maximum == 0) { Q_D(const QWindowsStyle); - const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, pb, widget); + const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget); QStyleOptionProgressBarV2 pbBits = *pb; Q_ASSERT(unit_width >0); @@ -2473,7 +2435,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai for (int i = 0; i < chunksToDraw ; ++i) { pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight); pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); - drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); + proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); x += reverse ? -unit_width : unit_width; } //Draw wrap-around chunks @@ -2484,7 +2446,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai for (int i = 0; i < chunksToDraw ; ++i) { pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight); pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); - drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); + proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); x += reverse ? -unit_width : unit_width; } } @@ -2572,7 +2534,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai r.top() + titleRect.left() - rect.left(), titleRect.height(), titleRect.width()); } - drawItemText(p, titleRect, + proxy()->drawItemText(p, titleRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette, dwOpt->state & State_Enabled, dwOpt->title, floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText); @@ -2602,7 +2564,7 @@ QRect QWindowsStyle::subElementRect(SubElement sr, const QStyleOption *opt, cons const QStyleOptionDockWidgetV2 *v2 = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(opt); bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; - int m = pixelMetric(PM_DockWidgetTitleMargin, opt, w); + int m = proxy()->pixelMetric(PM_DockWidgetTitleMargin, opt, w); if (verticalTitleBar) { r.adjust(0, 0, 0, -m); } else { @@ -2636,11 +2598,11 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp #ifndef QT_NO_SLIDER case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { - int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); - int len = pixelMetric(PM_SliderLength, slider, widget); + int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); int ticks = slider->tickPosition; - QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget); - QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget); + QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget); + QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget); if ((slider->subControls & SC_SliderGroove) && groove.isValid()) { int mid = thickness / 2; @@ -2711,7 +2673,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*slider); fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) { @@ -3023,8 +2985,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp if ((cmb->subControls & SC_ComboBoxFrame)) { if (cmb->frame) { QPalette shadePal = opt->palette; - if (use2000style) - shadePal.setColor(QPalette::Midlight, shadePal.button().color()); + shadePal.setColor(QPalette::Midlight, shadePal.button().color()); qDrawWinPanel(p, opt->rect, shadePal, true, &editBrush); } else { @@ -3034,7 +2995,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp if (cmb->subControls & SC_ComboBoxArrow) { State flags = State_None; - QRect ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget); + QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget); bool sunkenArrow = cmb->activeSubControls == SC_ComboBoxArrow && cmb->state & State_Sunken; if (sunkenArrow) { @@ -3060,11 +3021,11 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp arrowOpt.rect = ar.adjusted(1, 1, -1, -1); arrowOpt.palette = cmb->palette; arrowOpt.state = flags; - drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget); } if (cmb->subControls & SC_ComboBoxEditField) { - QRect re = subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget); + QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget); if (cmb->state & State_HasFocus && !cmb->editable) p->fillRect(re.x(), re.y(), re.width(), re.height(), cmb->palette.brush(QPalette::Highlight)); @@ -3084,7 +3045,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget); focus.state |= State_FocusAtBorder; focus.backgroundColor = cmb->palette.highlight().color(); - drawPrimitive(PE_FrameFocusRect, &focus, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget); } } } @@ -3098,10 +3059,9 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp bool enabled = opt->state & State_Enabled; if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { QBrush editBrush = sb->palette.brush(QPalette::Base); - QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); + QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); QPalette shadePal = sb->palette; - if (use2000style) - shadePal.setColor(QPalette::Midlight, shadePal.button().color()); + shadePal.setColor(QPalette::Midlight, shadePal.button().color()); qDrawWinPanel(p, r, shadePal, true, &editBrush); } @@ -3129,7 +3089,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus : PE_IndicatorSpinUp); - copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); + copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On), ©.palette.brush(QPalette::Button)); copy.rect.adjust(4, 1, -5, -1); @@ -3137,9 +3097,9 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp QStyleOptionSpinBox lightCopy = copy; lightCopy.rect.adjust(1, 1, 1, 1); lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light()); - drawPrimitive(pe, &lightCopy, p, widget); + proxy()->drawPrimitive(pe, &lightCopy, p, widget); } - drawPrimitive(pe, ©, p, widget); + proxy()->drawPrimitive(pe, ©, p, widget); } if (sb->subControls & SC_SpinBoxDown) { @@ -3162,7 +3122,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus : PE_IndicatorSpinDown); - copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); + copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); qDrawWinButton(p, copy.rect, shadePal, copy.state & (State_Sunken | State_On), ©.palette.brush(QPalette::Button)); copy.rect.adjust(4, 0, -5, -1); @@ -3170,13 +3130,14 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp QStyleOptionSpinBox lightCopy = copy; lightCopy.rect.adjust(1, 1, 1, 1); lightCopy.palette.setBrush(QPalette::ButtonText, copy.palette.light()); - drawPrimitive(pe, &lightCopy, p, widget); + proxy()->drawPrimitive(pe, &lightCopy, p, widget); } - drawPrimitive(pe, ©, p, widget); + proxy()->drawPrimitive(pe, ©, p, widget); } } break; #endif // QT_NO_SPINBOX + default: QCommonStyle::drawComplexControl(cc, opt, p, widget); } @@ -3195,12 +3156,15 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, h = sz.height(); int defwidth = 0; if (btn->features & QStyleOptionButton::AutoDefaultButton) - defwidth = 2 * pixelMetric(PM_ButtonDefaultIndicator, btn, widget); + defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); + int minwidth = int(QStyleHelper::dpiScaled(75.)); + int minheight = int(QStyleHelper::dpiScaled(23.)); + #ifndef QT_QWS_SMALL_PUSHBUTTON - if (w < 75 + defwidth && !btn->text.isEmpty()) - w = 75 + defwidth; - if (h < 23 + defwidth) - h = 23 + defwidth; + if (w < minwidth + defwidth && !btn->text.isEmpty()) + w = minwidth + defwidth; + if (h < minheight + defwidth) + h = minheight + defwidth; #endif sz = QSize(w, h); } @@ -3220,13 +3184,13 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } if (mi->menuItemType != QStyleOptionMenuItem::Separator && !mi->icon.isNull()) { - int iconExtent = pixelMetric(PM_SmallIconSize, opt, widget); + int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); sz.setHeight(qMax(sz.height(), mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 2 * windowsItemFrame)); } int maxpmw = mi->maxIconWidth; - int tabSpacing = use2000style ? 20 :windowsTabSpacing; + int tabSpacing = 20; if (mi->text.contains(QLatin1Char('\t'))) w += tabSpacing; else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu) @@ -3380,7 +3344,7 @@ QIcon QWindowsStyle::standardIconImplementation(StandardPixmap standardIcon, con && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based && pSHGetStockIconInfo) { - icon.addPixmap(standardPixmap(SP_VistaShield, option, widget)); //fetches small icon + icon.addPixmap(proxy()->standardPixmap(SP_VistaShield, option, widget)); //fetches small icon QSHSTOCKICONINFO iconInfo; //append large icon memset(&iconInfo, 0, sizeof(iconInfo)); iconInfo.cbSize = sizeof(iconInfo); diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index d0f4b6b..6f3017a 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -41,6 +41,7 @@ #include "qwindowsvistastyle.h" #include "qwindowsvistastyle_p.h" +#include <private/qstylehelper_p.h> #if !defined(QT_NO_STYLE_WINDOWSVISTA) || defined(QT_PLUGIN) @@ -195,17 +196,15 @@ void Animation::paint(QPainter *painter, const QStyleOption *option) Q_UNUSED(painter); } -/* -* ! \internal -* -* Helperfunction to paint the current transition state -* between two animation frames. -* -* The result is a blended image consisting of -* ((alpha)*_primaryImage) + ((1-alpha)*_secondaryImage) -* -*/ +/*! \internal + + Helperfunction to paint the current transition state between two + animation frames. + The result is a blended image consisting of ((alpha)*_primaryImage) + + ((1-alpha)*_secondaryImage) + +*/ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { if (_secondaryImage.isNull() || _primaryImage.isNull()) return; @@ -247,14 +246,11 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { painter->drawImage(rect, _tempImage); } -/* -* ! \internal -* -* Paints a transition state. The result will be a mix between the -* initial and final state of the transition, depending on the -* time difference between _startTime and current time. +/*! \internal + Paints a transition state. The result will be a mix between the + initial and final state of the transition, depending on the time + difference between _startTime and current time. */ - void Transition::paint(QPainter *painter, const QStyleOption *option) { float alpha = 1.0; @@ -277,15 +273,11 @@ void Transition::paint(QPainter *painter, const QStyleOption *option) drawBlendedImage(painter, option->rect, alpha); } -/* -* ! \internal -* -* Paints a pulse. The result will be a mix between the -* primary and secondary pulse images depending on the -* time difference between _startTime and current time. +/*! \internal + Paints a pulse. The result will be a mix between the primary and + secondary pulse images depending on the time difference between + _startTime and current time. */ - - void Pulse::paint(QPainter *painter, const QStyleOption *option) { float alpha = 1.0; @@ -307,31 +299,37 @@ void Pulse::paint(QPainter *painter, const QStyleOption *option) /*! - \reimp - * - * Animations are used for some state transitions on specific widgets. - * - * Only one running animation can exist for a widget at any specific time. - * Animations can be added through QWindowsVistaStylePrivate::startAnimation(Animation *) - * and any existing animation on a widget can be retrieved with - * QWindowsVistaStylePrivate::widgetAnimation(Widget *). - * - * Once an animation has been started, QWindowsVistaStylePrivate::timerEvent(QTimerEvent *) - * will continuously call update() on the widget until it is stopped, meaning that drawPrimitive - * will be called many times until the transition has completed. During this time, the result - * will be retrieved by the Animation::paint(...) function and not by the style itself. - * - * To determine if a transition should occur, the style needs to know the previous state of the - * widget as well as the current one. This is solved by updating dynamic properties on the widget - * every time the function is called. - * - * Transitions interrupting existing transitions should always be smooth, so whenever a hover-transition - * is started on a pulsating button, it uses the current frame of the pulse-animation as the - * starting image for the hover transition. - * + \internal + + Animations are used for some state transitions on specific widgets. + + Only one running animation can exist for a widget at any specific + time. Animations can be added through + QWindowsVistaStylePrivate::startAnimation(Animation *) and any + existing animation on a widget can be retrieved with + QWindowsVistaStylePrivate::widgetAnimation(Widget *). + + Once an animation has been started, + QWindowsVistaStylePrivate::timerEvent(QTimerEvent *) will + continuously call update() on the widget until it is stopped, + meaning that drawPrimitive will be called many times until the + transition has completed. During this time, the result will be + retrieved by the Animation::paint(...) function and not by the style + itself. + + To determine if a transition should occur, the style needs to know + the previous state of the widget as well as the current one. This is + solved by updating dynamic properties on the widget every time the + function is called. + + Transitions interrupting existing transitions should always be + smooth, so whenever a hover-transition is started on a pulsating + button, it uses the current frame of the pulse-animation as the + starting image for the hover transition. + */ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const + QPainter *painter, const QWidget *widget) const { QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func()); @@ -366,7 +364,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt w->setProperty("_q_stylestate", (int)option->state); w->setProperty("_q_stylerect", w->rect()); - bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) || + bool doTransition = oldState && + ((state & State_Sunken) != (oldState & State_Sunken) || (state & State_On) != (oldState & State_On) || (state & State_MouseOver) != (oldState & State_MouseOver)); @@ -403,7 +402,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt // pulsating default button into the intended target state. if (!anim) - drawPrimitive(element, &opt, &startPainter, 0); // Note that the widget pointer is intentionally 0 + proxy()->drawPrimitive(element, &opt, &startPainter, 0); // Note that the widget pointer is intentionally 0 else // this ensures that we do not recurse in the animation logic above anim->paint(&startPainter, &opt); @@ -417,7 +416,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt endImage.fill(0); QStyleOption opt2 = opt; opt2.state = option->state; - drawPrimitive(element, &opt2, &endPainter, 0); // Note that the widget pointer is intentionally 0 + proxy()->drawPrimitive(element, &opt2, &endPainter, 0); // Note that the widget pointer is intentionally 0 // this ensures that we do not recurse in the animation logic above t->setEndImage(endImage); @@ -487,7 +486,12 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_IndicatorBranch: { XPThemeData theme(d->treeViewHelper(), painter, QLatin1String("TREEVIEW")); - static const int decoration_size = 16; + static int decoration_size = 0; + if (theme.isValid() && !decoration_size) { + SIZE size; + pGetThemePartSize(theme.handle(), 0, TVP_HOTGLYPH, GLPS_OPENED, 0, TS_TRUE, &size); + decoration_size = qMax(size.cx, size.cy); + } int mid_h = option->rect.x() + option->rect.width() / 2; int mid_v = option->rect.y() + option->rect.height() / 2; int bef_h = mid_h; @@ -535,17 +539,6 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt } break; - case PE_IndicatorToolBarHandle: - { - XPThemeData theme; - if (option->state & State_Horizontal) - theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2)); - else - theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2)); - d->drawBackground(theme); - } - break; - case PE_FrameMenu: { int stateId = option->state & State_Active ? MB_ACTIVE : MB_INACTIVE; @@ -645,7 +638,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt } } if (panel->lineWidth > 0) - drawPrimitive(PE_FrameLineEdit, panel, painter, widget); + proxy()->drawPrimitive(PE_FrameLineEdit, panel, painter, widget); return; } break; @@ -694,6 +687,24 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt } break; + case PE_IndicatorToolBarHandle: + { + XPThemeData theme; + QRect rect; + if (option->state & State_Horizontal) { + theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2)); + rect = option->rect.adjusted(0, 1, 0, -2); + rect.setWidth(4); + } else { + theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2)); + rect = option->rect.adjusted(1, 0, -1, 0); + rect.setHeight(4); + } + theme.rect = rect; + d->drawBackground(theme); + } + break; + case PE_IndicatorToolBarSeparator: { QPen pen = painter->pen(); @@ -725,7 +736,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt if (const QListView *listview = qobject_cast<const QListView *>(widget)) { if (listview->viewMode() == QListView::IconMode) newStyle = true; - } else if (const QTreeView* treeview = qobject_cast<const QTreeView *>(widget)) { + } else if (qobject_cast<const QTreeView *>(widget)) { newStyle = true; } if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) { @@ -864,11 +875,9 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt /*! - - \reimp + \internal see drawPrimitive for comments on the animation support - */ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const @@ -934,7 +943,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QPainter startPainter(&startImage); if (!anim) { - drawControl(element, &opt, &startPainter, 0 /* Intentional */); + proxy()->drawControl(element, &opt, &startPainter, 0 /* Intentional */); } else { anim->paint(&startPainter, &opt); d->stopAnimation(widget); @@ -945,7 +954,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption endImage.fill(0); QPainter endPainter(&endImage); - drawControl(element, option, &endPainter, 0 /* Intentional */); + proxy()->drawControl(element, option, &endPainter, 0 /* Intentional */); t->setEndImage(endImage); int duration = 0; HTHEME theme = pOpenThemeData(0, L"Button"); @@ -1047,9 +1056,10 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QRect ir = subElementRect(SE_PushButtonContents, option, 0); QStyleOptionButton newBtn = *btn; newBtn.rect = QStyle::visualRect(option->direction, option->rect, - QRect(ir.right() - mbiw - 2, (option->rect.height()/2) - (mbih/2), + QRect(ir.right() - mbiw - 2, + option->rect.top() + (option->rect.height()/2) - (mbih/2), mbiw + 1, mbih + 1)); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); } return; } @@ -1084,7 +1094,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption XPThemeData theme(widget, painter, QLatin1String("PROGRESS"), vertical ? PP_FILLVERT : PP_FILL); theme.rect = option->rect; - bool reverse = bar->direction == Qt::LeftToRight && inverted || bar->direction == Qt::RightToLeft && !inverted; + bool reverse = bar->direction == (Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted); QTime current = QTime::currentTime(); if (isIndeterminate) { @@ -1197,10 +1207,10 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption break; QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText; - QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal); + QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal); uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!styleHint(SH_UnderlineShortcut, mbi, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; //The rect adjustment is a workaround for the menu not really filling its background. @@ -1229,7 +1239,15 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption case CE_MenuItem: if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { // windows always has a check column, regardless whether we have an icon or not - int checkcol = qMax(menuitem->maxIconWidth, 28); + int checkcol = 28; + { + SIZE size; + MARGINS margins; + XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT); + pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size); + pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins); + checkcol = qMax(menuitem->maxIconWidth, int(6 + size.cx + margins.cxLeftWidth + margins.cxRightWidth)); + } QColor darkLine = option->palette.background().color().darker(108); QColor lightLine = option->palette.background().color().lighter(107); QRect rect = option->rect; @@ -1254,7 +1272,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption int yoff = y-2 + h / 2; QPoint p1 = QPoint(x + checkcol, yoff); QPoint p2 = QPoint(x + w + 6 , yoff); - int stateId = stateId = MBI_HOT; + stateId = MBI_HOT; QRect subRect(p1.x(), p1.y(), p2.x() - p1.x(), 6); subRect = QStyle::visualRect(option->direction, option->rect, subRect ); XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPSEPARATOR, stateId, subRect); @@ -1266,7 +1284,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption menuitem->rect.y(), checkcol - 6, menuitem->rect.height())); if (act) { - int stateId = stateId = MBI_HOT; + stateId = MBI_HOT; XPThemeData theme2(widget, painter, QLatin1String("MENU"), MENU_POPUPITEM, stateId, option->rect); d->drawBackground(theme2); } @@ -1274,8 +1292,23 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (checked) { XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, menuitem->icon.isNull() ? MBI_HOT : MBI_PUSHED, vCheckRect); + SIZE size; + MARGINS margins; + pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size); + pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, + TMT_CONTENTMARGINS, NULL, &margins); + QRect checkRect(0, 0, size.cx + margins.cxLeftWidth + margins.cxRightWidth , + size.cy + margins.cyBottomHeight + margins.cyTopHeight); + checkRect.moveCenter(vCheckRect.center()); + theme.rect = checkRect; + d->drawBackground(theme); + if (menuitem->icon.isNull()) { + checkRect = QRect(0, 0, size.cx, size.cy); + checkRect.moveCenter(theme.rect.center()); + theme.rect = checkRect; + theme.partId = MENU_POPUPCHECK; bool bullet = menuitem->checkType & QStyleOptionMenuItem::Exclusive; if (dis) @@ -1292,9 +1325,9 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption mode = QIcon::Active; QPixmap pixmap; if (checked) - pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On); + pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On); else - pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode); + pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode); int pixw = pixmap.width(); int pixh = pixmap.height(); QRect pmr(0, 0, pixw, pixh); @@ -1320,7 +1353,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption painter->save(); int t = s.indexOf(QLatin1Char('\t')); int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) text_flags |= Qt::TextHideMnemonic; text_flags |= Qt::AlignLeft; if (t >= 0) { @@ -1346,7 +1379,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QStyleOptionMenuItem newMI = *menuitem; newMI.rect = vSubMenuRect; newMI.state = dis ? State_None : State_Enabled; - drawPrimitive(arrow, &newMI, painter, widget); + proxy()->drawPrimitive(arrow, &newMI, painter, widget); } } break; @@ -1371,7 +1404,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption break; case CE_MenuBarEmptyArea: { - int stateId = MBI_NORMAL; + stateId = MBI_NORMAL; if (!(state & State_Enabled)) stateId = MBI_DISABLED; XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_BARBACKGROUND, stateId, option->rect); @@ -1416,8 +1449,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption painter->drawRect(rect.adjusted(0, 1, -1, -3)); int buttonMargin = 4; - int mw = pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget); - int fw = pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget); + int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget); + int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget); const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget); bool isFloating = dw != 0 && dw->isFloating(); @@ -1436,7 +1469,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (isFloating) { titleRect.adjust(0, -fw, 0, 0); - if (widget != 0 && widget->windowIcon().cacheKey() != qApp->windowIcon().cacheKey()) + if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) titleRect.adjust(titleRect.height() + mw, 0, 0, 0); } else { titleRect.adjust(mw, 0, 0, 0); @@ -1468,7 +1501,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (const QListView *listview = qobject_cast<const QListView *>(widget)) { if (listview->viewMode() == QListView::IconMode) newStyle = true; - } else if (const QTreeView* treeview = qobject_cast<const QTreeView *>(widget)) { + } else if (qobject_cast<const QTreeView *>(widget)) { newStyle = true; } if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option))) { @@ -1504,7 +1537,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } /*! - \reimp + \internal see drawPrimitive for comments on the animation support @@ -1556,7 +1589,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle if (qstyleoption_cast<const QStyleOptionSlider *>(option)) { QRect oldSliderPos = w->property("_q_stylesliderpos").toRect(); - QRect currentPos = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); + QRect currentPos = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); w->setProperty("_q_stylesliderpos", currentPos); if (oldSliderPos != currentPos) { doTransition = false; @@ -1587,7 +1620,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle QStyleOptionComboBox startCombo = *combo; startCombo.state = (QStyle::State)oldState; startCombo.activeSubControls = (QStyle::SubControl)oldActiveControls; - drawComplexControl(control, &startCombo, &startPainter, 0 /* Intentional */); + proxy()->drawComplexControl(control, &startCombo, &startPainter, 0 /* Intentional */); t->setStartImage(startImage); } else if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option)) { //This is a workaround for the direct3d engine as it currently has some issues with grabWindow @@ -1596,7 +1629,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle QStyleOptionSlider startSlider = *slider; startSlider.state = (QStyle::State)oldState; startSlider.activeSubControls = (QStyle::SubControl)oldActiveControls; - drawComplexControl(control, &startSlider, &startPainter, 0 /* Intentional */); + proxy()->drawComplexControl(control, &startSlider, &startPainter, 0 /* Intentional */); t->setStartImage(startImage); } else { QPoint offset(0, 0); @@ -1614,7 +1647,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->startAnimation(t); endImage.fill(0); QPainter endPainter(&endImage); - drawComplexControl(control, option, &endPainter, 0 /* Intentional */); + proxy()->drawComplexControl(control, option, &endPainter, 0 /* Intentional */); t->setEndImage(endImage); t->setStartTime(QTime::currentTime()); @@ -1653,9 +1686,9 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->drawBackground(theme); } if (sub & SC_ComboBoxArrow) { - QRect subRect = subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget); + QRect subRect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget); XPThemeData theme(widget, painter, QLatin1String("COMBOBOX")); - theme.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget); + theme.rect = subRect; partId = option->direction == Qt::RightToLeft ? CP_DROPDOWNBUTTONLEFT : CP_DROPDOWNBUTTONRIGHT; if (!(cmb->state & State_Enabled)) @@ -1679,7 +1712,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle btn.rect = option->rect.adjusted(-1, -1, 1, 1); if (sub & SC_ComboBoxArrow) btn.features = QStyleOptionButton::HasMenu; - drawControl(QStyle::CE_PushButton, &btn, painter, widget); + proxy()->drawControl(QStyle::CE_PushButton, &btn, painter, widget); } } } @@ -1696,7 +1729,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle bool isHorz = flags & State_Horizontal; bool isRTL = option->direction == Qt::RightToLeft; if (sub & SC_ScrollBarAddLine) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget); partId = SBP_ARROWBTN; if (!(flags & State_Enabled)) stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED); @@ -1713,7 +1746,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->drawBackground(theme); } if (sub & SC_ScrollBarSubLine) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget); partId = SBP_ARROWBTN; if (!(flags & State_Enabled)) stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED); @@ -1730,9 +1763,9 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->drawBackground(theme); } if (maxedOut) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); - theme.rect = theme.rect.united(subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget)); - theme.rect = theme.rect.united(subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget)); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); + theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget)); + theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget)); partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; stateId = SCRBS_DISABLED; theme.partId = partId; @@ -1740,7 +1773,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->drawBackground(theme); } else { if (sub & SC_ScrollBarSubPage) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget); partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT; if (!(flags & State_Enabled)) stateId = SCRBS_DISABLED; @@ -1755,7 +1788,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->drawBackground(theme); } if (sub & SC_ScrollBarAddPage) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget); partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; if (!(flags & State_Enabled)) stateId = SCRBS_DISABLED; @@ -1770,7 +1803,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->drawBackground(theme); } if (sub & SC_ScrollBarSlider) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); if (!(flags & State_Enabled)) stateId = SCRBS_DISABLED; else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken)) @@ -1783,7 +1816,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle stateId = SCRBS_NORMAL; // Draw handle - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT; theme.stateId = stateId; d->drawBackground(theme); @@ -1851,7 +1884,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->drawBackground(ftheme); } if (sub & SC_SpinBoxUp) { - theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget).adjusted(0, 0, 0, 1); + theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget).adjusted(0, 0, 0, 1); partId = SPNP_UP; if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled)) stateId = UPS_DISABLED; @@ -1866,7 +1899,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle d->drawBackground(theme); } if (sub & SC_SpinBoxDown) { - theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); + theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); partId = SPNP_DOWN; if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled)) stateId = DNS_DISABLED; @@ -1890,7 +1923,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle } /*! - \reimp + \internal */ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const @@ -1925,9 +1958,18 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption return sz; case CT_MenuItem: sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget); - sz.rwidth() += 28; + int minimumHeight; + { + SIZE size; + MARGINS margins; + XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT); + pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size); + pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins); + minimumHeight = qMax<qint32>(size.cy + margins.cyBottomHeight+ margins.cyTopHeight, sz.height()); + sz.rwidth() += size.cx + margins.cxLeftWidth + margins.cxRightWidth; + } + if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { - int minimumHeight = qMax<qint32>(22, sz.height()); if (menuitem->menuItemType != QStyleOptionMenuItem::Separator) sz.setHeight(minimumHeight); } @@ -1947,7 +1989,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption { //Spinbox adds frame twice sz = QWindowsStyle::sizeFromContents(type, option, size, widget); - int border = pixelMetric(PM_SpinBoxFrameWidth, option, widget); + int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget); sz -= QSize(2*border, 2*border); } return sz; @@ -1958,7 +2000,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption } /*! - \reimp + \internal */ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const { @@ -1973,7 +2015,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption MARGINS borderSize; HTHEME theme = pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button"); if (theme) { - int stateId; + int stateId = PBS_NORMAL; if (!(option->state & State_Enabled)) stateId = PBS_DISABLED; else if (option->state & State_Sunken) @@ -1982,10 +2024,8 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption stateId = PBS_HOT; else if (btn->features & QStyleOptionButton::DefaultButton) stateId = PBS_DEFAULTED; - else - stateId = PBS_NORMAL; - int border = pixelMetric(PM_DefaultFrameWidth, btn, widget); + int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); rect = option->rect.adjusted(border, border, -border, -border); int result = pGetThemeMargins(theme, @@ -2012,7 +2052,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption int w = option->rect.width(); int x = option->rect.x(); int y = option->rect.y(); - int margin = pixelMetric(QStyle::PM_HeaderMargin, option, widget); + int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget); XPThemeData theme(widget, 0, QLatin1String("HEADER"), HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect); @@ -2038,7 +2078,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption case SE_HeaderLabel: { - int margin = pixelMetric(QStyle::PM_HeaderMargin, option, widget); + int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget); QRect r = option->rect; r.setRect(option->rect.x() + margin, option->rect.y() + margin, option->rect.width() - margin * 2, option->rect.height() - margin * 2); @@ -2056,7 +2096,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption rect = QCommonStyle::subElementRect(SE_ProgressBarGroove, option, widget); break; case SE_ItemViewItemDecoration: - if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) + if (qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) rect.adjust(-2, 0, 2, 0); break; case SE_ItemViewItemFocusRect: @@ -2129,7 +2169,7 @@ static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBa } -/*! \reimp */ +/*! \internal */ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const { @@ -2163,7 +2203,7 @@ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, co /*! - \reimp + \internal */ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const @@ -2190,7 +2230,7 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt rect = cb->rect; break; case SC_ComboBoxArrow: - rect.setRect(cb->editable ? xpos : 0, y , wi - xpos, he); + rect.setRect(xpos, y , wi - xpos, he); break; case SC_ComboBoxEditField: rect.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin); @@ -2214,7 +2254,7 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt const int width = tb->rect.width(); int buttonWidth = GetSystemMetrics(SM_CXSIZE) - 4; - const int frameWidth = pixelMetric(PM_MdiSubWindowFrameWidth, option, widget); + const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget); const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0; const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0; const bool maximizeHint = (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) != 0; @@ -2251,7 +2291,7 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt { const int controlTop = 6; const int controlHeight = height - controlTop - 3; - int iconExtent = pixelMetric(PM_SmallIconSize); + int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent)); if (tb->icon.isNull()) iconSize = QSize(controlHeight, controlHeight); @@ -2262,6 +2302,8 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt rect = visualRect(option->direction, option->rect, rect); } break; + default: + break; } } break; @@ -2272,7 +2314,7 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt } /*! - \reimp + \internal */ bool QWindowsVistaStyle::event(QEvent *e) { @@ -2295,7 +2337,7 @@ bool QWindowsVistaStyle::event(QEvent *e) } /*! - \reimp + \internal */ QStyle::SubControl QWindowsVistaStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget) const @@ -2307,7 +2349,7 @@ QStyle::SubControl QWindowsVistaStyle::hitTestComplexControl(ComplexControl cont } /*! - \reimp + \internal */ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { @@ -2317,9 +2359,9 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti switch (metric) { case PM_DockWidgetTitleBarButtonMargin: - return 5; + return int(QStyleHelper::dpiScaled(5.)); case PM_ScrollBarSliderMin: - return 18; + return int(QStyleHelper::dpiScaled(18.)); case PM_MenuHMargin: case PM_MenuVMargin: return 0; @@ -2332,7 +2374,7 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti } /*! - \reimp + \internal */ QPalette QWindowsVistaStyle::standardPalette() const { @@ -2340,7 +2382,7 @@ QPalette QWindowsVistaStyle::standardPalette() const } /*! - \reimp + \internal */ void QWindowsVistaStyle::polish(QApplication *app) { @@ -2348,7 +2390,7 @@ void QWindowsVistaStyle::polish(QApplication *app) } /*! - \reimp + \internal */ void QWindowsVistaStyle::polish(QWidget *widget) { @@ -2402,7 +2444,7 @@ void QWindowsVistaStyle::polish(QWidget *widget) } /*! - \reimp + \internal */ void QWindowsVistaStyle::unpolish(QWidget *widget) { @@ -2435,7 +2477,7 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) { tree->viewport()->setAttribute(Qt::WA_Hover, false); } else if (qobject_cast<QCommandLinkButton*>(widget)) { - QFont font = qApp->font("QCommandLinkButton"); + QFont font = QApplication::font("QCommandLinkButton"); QFont widgetFont = widget->font(); widgetFont.setFamily(font.family()); //Only family set by polish widget->setFont(widgetFont); @@ -2444,7 +2486,7 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) /*! - \reimp + \internal */ void QWindowsVistaStyle::unpolish(QApplication *app) { @@ -2452,7 +2494,7 @@ void QWindowsVistaStyle::unpolish(QApplication *app) } /*! - \reimp + \internal */ void QWindowsVistaStyle::polish(QPalette &pal) { @@ -2461,7 +2503,7 @@ void QWindowsVistaStyle::polish(QPalette &pal) } /*! - \reimp + \internal */ QPixmap QWindowsVistaStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) const @@ -2530,9 +2572,7 @@ void QWindowsVistaStylePrivate::startAnimation(Animation *t) bool QWindowsVistaStylePrivate::transitionsEnabled() const { BOOL animEnabled = false; - if (QT_WA_INLINE(SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0), - SystemParametersInfoA(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0) - )) + if (SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0)) { if (animEnabled) return true; diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 1b8ceae..ad87354 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -46,6 +46,7 @@ #include <private/qobject_p.h> #include <private/qpaintengine_raster_p.h> #include <private/qapplication_p.h> +#include <private/qstylehelper_p.h> #include <qlibrary.h> #include <qpainter.h> #include <qpaintengine.h> @@ -133,6 +134,7 @@ static const int windowsRightBorder = 12; // right border on windows // External function calls extern Q_GUI_EXPORT HDC qt_win_display_dc(); +extern QRegion qt_region_from_HRGN(HRGN rgn); @@ -160,8 +162,7 @@ HTHEME XPThemeData::handle() htheme = QWindowsXPStylePrivate::handleMap->operator[](name); if (!htheme) { - htheme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), - (TCHAR*)name.utf16()); + htheme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), (wchar_t*)name.utf16()); if (htheme) { if (!QWindowsXPStylePrivate::handleMap) QWindowsXPStylePrivate::handleMap = new QMap<QString, HTHEME>; @@ -260,7 +261,7 @@ void QWindowsXPStylePrivate::cleanup(bool force) use_xp = false; cleanupHandleMap(); if (limboWidget) { - if (qApp->closingDown()) + if (QApplication::closingDown()) delete limboWidget; else limboWidget->deleteLater(); @@ -445,6 +446,7 @@ bool QWindowsXPStylePrivate::isTransparent(XPThemeData &themeData) themeData.stateId); } + /*! \internal Returns a QRegion of the region of the part */ @@ -456,12 +458,18 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData) themeData.stateId, &rect, &hRgn))) return QRegion(); - QRegion rgn = QRegion(0,0,1,1); - const bool success = CombineRgn(rgn.handle(), hRgn, 0, RGN_COPY) != ERROR; - DeleteObject(hRgn); + HRGN dest = CreateRectRgn(0, 0, 0, 0); + const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR; + + QRegion region; + if (success) - return rgn; - return QRegion(); + region = qt_region_from_HRGN(dest); + + DeleteObject(hRgn); + DeleteObject(dest); + + return region; } /*! \internal @@ -1025,7 +1033,7 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa Most of the functions are documented in the base classes QWindowsStyle, QCommonStyle, and QStyle, but the QWindowsXPStyle overloads of drawComplexControl(), drawControl(), - drawControlMask(), drawPrimitive(), subControlRect(), and + drawControlMask(), drawPrimitive(), proxy()->subControlRect(), and sizeFromContents(), are documented here. \img qwindowsxpstyle.png @@ -1192,8 +1200,8 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option, QStyleOptionTab otherOption; otherOption.shape = (twfOption->shape == QTabBar::RoundedNorth ? QTabBar::RoundedEast : QTabBar::RoundedSouth); - int overlap = pixelMetric(PM_TabBarBaseOverlap, &otherOption, widget); - int borderThickness = pixelMetric(PM_DefaultFrameWidth, option, widget); + int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &otherOption, widget); + int borderThickness = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); rect.adjust(-overlap + borderThickness, 0, -overlap + borderThickness, 0); } break;} @@ -1217,7 +1225,7 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option, else stateId = PBS_NORMAL; - int border = pixelMetric(PM_DefaultFrameWidth, btn, widget); + int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); rect = option->rect.adjusted(border, border, -border, -border); int result = pGetThemeMargins(theme, @@ -1533,7 +1541,7 @@ case PE_Frame: } if (panel->lineWidth > 0) - drawPrimitive(PE_FrameLineEdit, panel, p, widget); + proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget); return; } break; @@ -1547,11 +1555,11 @@ case PE_Frame: if (widget) { bool useGradient = true; const int maxlength = 256; - WCHAR themeFileName[maxlength]; - WCHAR themeColor[maxlength]; + wchar_t themeFileName[maxlength]; + wchar_t themeColor[maxlength]; // Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it if (pGetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) { - WCHAR* offset; + wchar_t *offset = 0; if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) { offset++; if (!lstrcmp(offset, L"Luna.msstyles") && !lstrcmp(offset, L"Metallic")) { @@ -1618,7 +1626,7 @@ case PE_Frame: else stateId = FS_INACTIVE; - int fwidth = pixelMetric(PM_DockWidgetFrameWidth, frm, widget); + int fwidth = proxy()->pixelMetric(PM_DockWidgetFrameWidth, frm, widget); XPThemeData theme(widget, p, name, 0, stateId); if (!theme.isValid()) @@ -1792,7 +1800,12 @@ case PE_Frame: return; case PE_IndicatorToolBarSeparator: - + if (option->rect.height() < 3) { + // XP style requires a few pixels for the separator + // to be visible. + QWindowsStyle::drawPrimitive(pe, option, p, widget); + return; + } name = QLatin1String("TOOLBAR"); partId = TP_SEPARATOR; @@ -1821,7 +1834,7 @@ case PE_Frame: QStyleOptionButton button; button.QStyleOption::operator=(*option); button.state &= ~State_MouseOver; - drawPrimitive(PE_IndicatorCheckBox, &button, p, widget); + proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, p, widget); return; } @@ -1914,8 +1927,8 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op { name = QLatin1String("BUTTON"); partId = BP_PUSHBUTTON; - bool justFlat = (btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken)) - || (btn->features & QStyleOptionButton::CommandLinkButton + bool justFlat = ((btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken))) + || ((btn->features & QStyleOptionButton::CommandLinkButton) && !(flags & State_MouseOver) && !(btn->features & QStyleOptionButton::DefaultButton)); if (!(flags & State_Enabled) && !(btn->features & QStyleOptionButton::Flat)) @@ -1949,7 +1962,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QRect ir = btn->rect; QStyleOptionButton newBtn = *btn; newBtn.rect = QRect(ir.right() - mbiw - 1, 1 + (ir.height()/2) - (mbih/2), mbiw, mbih); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); } return; } @@ -1972,10 +1985,10 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op bool lastTab = tab->position == QStyleOptionTab::End; bool firstTab = tab->position == QStyleOptionTab::Beginning; bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; - bool leftAligned = styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignLeft; - bool centerAligned = styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignCenter; - int borderThickness = pixelMetric(PM_DefaultFrameWidth, option, widget); - int tabOverlap = pixelMetric(PM_TabBarTabOverlap, option, widget); + bool leftAligned = proxy()->styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignLeft; + bool centerAligned = proxy()->styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignCenter; + int borderThickness = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); + int tabOverlap = proxy()->pixelMetric(PM_TabBarTabOverlap, option, widget); if (isDisabled) stateId = TIS_DISABLED; @@ -2120,8 +2133,8 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op if (act && !dis) mode = QIcon::Active; QPixmap pixmap = checked ? - menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On) : - menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), mode); + menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On) : + menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode); int pixw = pixmap.width(); int pixh = pixmap.height(); QRect iconRect(0, 0, pixw, pixh); @@ -2147,7 +2160,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op checkcol - 2 * windowsItemFrame, menuitem->rect.height() - 2*windowsItemFrame); newMi.rect = visualRect(option->direction, option->rect, checkMarkRect); - drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget); + proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget); } QColor textColor = dis ? menuitem->palette.text().color() : @@ -2164,12 +2177,12 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op p->save(); int t = s.indexOf(QLatin1Char('\t')); int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine | Qt::AlignLeft; - if (!styleHint(SH_UnderlineShortcut, menuitem, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget)) text_flags |= Qt::TextHideMnemonic; // draw tab text ---------------- if (t >= 0) { QRect vShortcutRect = visualRect(option->direction, option->rect, QRect(textRect.topRight(), menuitem->rect.bottomRight())); - if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) { + if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { p->setPen(menuitem->palette.light().color()); p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1)); p->setPen(textColor); @@ -2181,7 +2194,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) font.setBold(true); p->setFont(font); - if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) { + if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { p->setPen(menuitem->palette.light().color()); p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t)); p->setPen(textColor); @@ -2202,7 +2215,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op newMI.state = dis ? State_None : State_Enabled; if (act) newMI.palette.setColor(QPalette::ButtonText, newMI.palette.highlightedText().color()); - drawPrimitive(arrow, &newMI, p, widget); + proxy()->drawPrimitive(arrow, &newMI, p, widget); } } return; @@ -2219,10 +2232,10 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QBrush fill = mbi->palette.brush(act ? QPalette::Highlight : QPalette::Button); QPalette::ColorRole textRole = dis ? QPalette::Text: act ? QPalette::HighlightedText : QPalette::ButtonText; - QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal); + QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal); uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!styleHint(SH_UnderlineShortcut, mbi, widget)) + if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; p->fillRect(rect, fill); @@ -2237,8 +2250,8 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) { int buttonMargin = 4; - int mw = pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget); - int fw = pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget); + int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget); + int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget); bool isFloating = widget && widget->isWindow(); bool isActive = dwOpt->state & State_Active; @@ -2259,18 +2272,18 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op QRect titleRect = r; if (dwOpt->closable) { - QSize sz = standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10)); + QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10)); titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0); } if (dwOpt->floatable) { - QSize sz = standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10)); + QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10)); titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0); } if (isFloating) { titleRect.adjust(0, -fw, 0, 0); - if (widget != 0 && widget->windowIcon().cacheKey() != qApp->windowIcon().cacheKey()) + if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey()) titleRect.adjust(titleRect.height() + mw, 0, 0, 0); } else { titleRect.adjust(mw, 0, 0, 0); @@ -2317,7 +2330,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op // Figure out maximal button space on title bar QIcon ico = widget->windowIcon(); - bool hasIcon = (ico.cacheKey() != qApp->windowIcon().cacheKey()); + bool hasIcon = (ico.cacheKey() != QApplication::windowIcon().cacheKey()); if (hasIcon) { QPixmap pxIco = ico.pixmap(titleHeight); if (!verticalTitleBar && QApplication::layoutDirection() == Qt::RightToLeft) @@ -2450,7 +2463,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo d->drawBackground(ftheme); } if (sub & SC_SpinBoxUp) { - theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); + theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget); partId = SPNP_UP; if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled)) stateId = UPS_DISABLED; @@ -2465,7 +2478,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo d->drawBackground(theme); } if (sub & SC_SpinBoxDown) { - theme.rect = subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); + theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget); partId = SPNP_DOWN; if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled)) stateId = DNS_DISABLED; @@ -2502,7 +2515,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo p->fillRect(option->rect, editBrush); } if (!cmb->editable) { - QRect re = subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget); + QRect re = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget); if (option->state & State_HasFocus) { p->fillRect(re, option->palette.highlight()); p->setPen(option->palette.highlightedText().color()); @@ -2517,7 +2530,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo if (sub & SC_ComboBoxArrow) { XPThemeData theme(widget, p, QLatin1String("COMBOBOX")); - theme.rect = subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget); + theme.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget); partId = CP_DROPDOWNBUTTON; if (!(flags & State_Enabled)) stateId = CBXS_DISABLED; @@ -2545,7 +2558,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo bool isHorz = flags & State_Horizontal; bool isRTL = option->direction == Qt::RightToLeft; if (sub & SC_ScrollBarAddLine) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget); partId = SBP_ARROWBTN; if (!(flags & State_Enabled)) stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED); @@ -2560,7 +2573,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo d->drawBackground(theme); } if (sub & SC_ScrollBarSubLine) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget); partId = SBP_ARROWBTN; if (!(flags & State_Enabled)) stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED); @@ -2575,9 +2588,9 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo d->drawBackground(theme); } if (maxedOut) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); - theme.rect = theme.rect.united(subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget)); - theme.rect = theme.rect.united(subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget)); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); + theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget)); + theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget)); partId = scrollbar->orientation == Qt::Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; stateId = SCRBS_DISABLED; theme.partId = partId; @@ -2585,7 +2598,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo d->drawBackground(theme); } else { if (sub & SC_ScrollBarSubPage) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget); partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT; if (!(flags & State_Enabled)) stateId = SCRBS_DISABLED; @@ -2600,7 +2613,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo d->drawBackground(theme); } if (sub & SC_ScrollBarAddPage) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget); partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT; if (!(flags & State_Enabled)) stateId = SCRBS_DISABLED; @@ -2615,7 +2628,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo d->drawBackground(theme); } if (sub & SC_ScrollBarSlider) { - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); if (!(flags & State_Enabled)) stateId = SCRBS_DISABLED; else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken)) @@ -2626,7 +2639,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo stateId = SCRBS_NORMAL; // Draw handle - theme.rect = subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); + theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget); theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT; theme.stateId = stateId; d->drawBackground(theme); @@ -2682,7 +2695,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo QRect slrect = slider->rect; QRegion tickreg = slrect; if (sub & SC_SliderGroove) { - theme.rect = subControlRect(CC_Slider, option, SC_SliderGroove, widget); + theme.rect = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); if (slider->orientation == Qt::Horizontal) { partId = TKP_TRACK; stateId = TRS_NORMAL; @@ -2698,11 +2711,11 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo tickreg -= theme.rect; } if (sub & SC_SliderTickmarks) { - int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget); + int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); int ticks = slider->tickPosition; - int thickness = pixelMetric(PM_SliderControlThickness, slider, widget); - int len = pixelMetric(PM_SliderLength, slider, widget); - int available = pixelMetric(PM_SliderSpaceAvailable, slider, widget); + int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); + int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); + int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); int interval = slider->tickInterval; if (interval <= 0) { interval = slider->singleStep; @@ -2758,7 +2771,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } } if (sub & SC_SliderHandle) { - theme.rect = subControlRect(CC_Slider, option, SC_SliderHandle, widget); + theme.rect = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); if (slider->orientation == Qt::Horizontal) { if (slider->tickPosition == QSlider::TicksAbove) partId = TKP_THUMBTOP; @@ -2804,7 +2817,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo QStyleOptionFocusRect fropt; fropt.QStyleOption::operator=(*slider); fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget); - drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); } } break; @@ -2814,8 +2827,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { QRect button, menuarea; - button = subControlRect(cc, toolbutton, SC_ToolButton, widget); - menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); + button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget); + menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); State bflags = toolbutton->state & ~State_Sunken; State mflags = bflags; @@ -2863,9 +2876,9 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo tool.state = bflags; if (widget && !qobject_cast<QToolBar*>(widget->parentWidget()) && !(bflags & State_AutoRaise)) - drawPrimitive(PE_PanelButtonBevel, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget); else - drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); } } } @@ -2875,26 +2888,26 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo fr.QStyleOption::operator=(*toolbutton); fr.rect.adjust(3, 3, -3, -3); if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) - fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator, + fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, toolbutton, widget), 0); - drawPrimitive(PE_FrameFocusRect, &fr, p, widget); + proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget); } QStyleOptionToolButton label = *toolbutton; label.state = bflags; int fw = 2; label.rect = button.adjusted(fw, fw, -fw, -fw); - drawControl(CE_ToolButtonLabel, &label, p, widget); + proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); if (toolbutton->subControls & SC_ToolButtonMenu) { tool.rect = menuarea; tool.state = mflags; - drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); + proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { - int mbi = pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); + int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); QRect ir = toolbutton->rect; QStyleOptionToolButton newBtn = *toolbutton; newBtn.rect = QRect(ir.right() + 4 - mbi, ir.height() - mbi + 4, mbi - 5, mbi - 5); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); } } break; @@ -2926,7 +2939,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo theme.stateId = stateId; d->drawBackground(theme); - QRect ir = subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget); + QRect ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget); int result = TST_NONE; pGetThemeEnumValue(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result); @@ -2945,7 +2958,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text); } if (sub & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) { - theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarSysMenu, widget); + theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarSysMenu, widget); partId = WP_SYSBUTTON; if ((widget && !widget->isEnabled()) || !isActive) stateId = SBS_DISABLED; @@ -2963,8 +2976,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo SIZE sz; pGetThemePartSize(theme.handle(), qt_win_display_dc(), theme.partId, theme.stateId, 0, TS_TRUE, &sz); if (sz.cx == 0 || sz.cy == 0) { - int iconSize = pixelMetric(PM_SmallIconSize, tb, widget); - QPixmap pm = standardIcon(SP_TitleBarMenuButton, tb, widget).pixmap(iconSize, iconSize); + int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget); + QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, tb, widget).pixmap(iconSize, iconSize); p->save(); drawItemPixmap(p, theme.rect, Qt::AlignCenter, pm); p->restore(); @@ -2976,7 +2989,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo if (sub & SC_TitleBarMinButton && tb->titleBarFlags & Qt::WindowMinimizeButtonHint && !(tb->titleBarState & Qt::WindowMinimized)) { - theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarMinButton, widget); + theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarMinButton, widget); partId = WP_MINBUTTON; if (widget && !widget->isEnabled()) stateId = MINBS_DISABLED; @@ -2994,7 +3007,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } if (sub & SC_TitleBarMaxButton && tb->titleBarFlags & Qt::WindowMaximizeButtonHint && !(tb->titleBarState & Qt::WindowMaximized)) { - theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarMaxButton, widget); + theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarMaxButton, widget); partId = WP_MAXBUTTON; if (widget && !widget->isEnabled()) stateId = MAXBS_DISABLED; @@ -3012,7 +3025,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } if (sub & SC_TitleBarContextHelpButton && tb->titleBarFlags & Qt::WindowContextHelpButtonHint) { - theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarContextHelpButton, widget); + theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarContextHelpButton, widget); partId = WP_HELPBUTTON; if (widget && !widget->isEnabled()) stateId = MINBS_DISABLED; @@ -3034,7 +3047,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo || ((tb->titleBarFlags & Qt::WindowMaximizeButtonHint) && (tb->titleBarState & Qt::WindowMaximized))); if (drawNormalButton) { - theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarNormalButton, widget); + theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarNormalButton, widget); partId = WP_RESTOREBUTTON; if (widget && !widget->isEnabled()) stateId = RBS_DISABLED; @@ -3052,7 +3065,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } if (sub & SC_TitleBarShadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint && !(tb->titleBarState & Qt::WindowMinimized)) { - theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarShadeButton, widget); + theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarShadeButton, widget); partId = WP_MINBUTTON; if (widget && !widget->isEnabled()) stateId = MINBS_DISABLED; @@ -3070,7 +3083,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } if (sub & SC_TitleBarUnshadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint && tb->titleBarState & Qt::WindowMinimized) { - theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarUnshadeButton, widget); + theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarUnshadeButton, widget); partId = WP_RESTOREBUTTON; if (widget && !widget->isEnabled()) stateId = RBS_DISABLED; @@ -3087,7 +3100,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo d->drawBackground(theme); } if (sub & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) { - theme.rect = subControlRect(CC_TitleBar, option, SC_TitleBarCloseButton, widget); + theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarCloseButton, widget); //partId = titlebar->testWFlags(Qt::WA_WState_Tool) ? WP_SMALLCLOSEBUTTON : WP_CLOSEBUTTON; partId = WP_CLOSEBUTTON; if (widget && !widget->isEnabled()) @@ -3115,7 +3128,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo XPThemeData theme(widget, p, QLatin1String("WINDOW"), WP_MDICLOSEBUTTON, CBS_NORMAL); if (option->subControls & SC_MdiCloseButton) { - buttonRect = subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget); + buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget); if (theme.isValid()) { theme.partId = WP_MDICLOSEBUTTON; theme.rect = buttonRect; @@ -3131,7 +3144,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } } if (option->subControls & SC_MdiNormalButton) { - buttonRect = subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget); + buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget); if (theme.isValid()) { theme.partId = WP_MDIRESTOREBUTTON; theme.rect = buttonRect; @@ -3147,7 +3160,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } } if (option->subControls & QStyle::SC_MdiMinButton) { - buttonRect = subControlRect(CC_MdiControls, option, SC_MdiMinButton, widget); + buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiMinButton, widget); if (theme.isValid()) { theme.partId = WP_MDIMINBUTTON; theme.rect = buttonRect; @@ -3165,6 +3178,12 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } break; #endif //QT_NO_WORKSPACE +#ifndef QT_NO_DIAL + case CC_Dial: + if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) + QStyleHelper::drawDial(dial, p); + break; +#endif // QT_NO_DIAL default: QWindowsStyle::drawComplexControl(cc, option, p, widget); break; @@ -3224,7 +3243,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con break; case PM_SplitterWidth: - res = qMax(5, QApplication::globalStrut().width()); + res = qMax(int(QStyleHelper::dpiScaled(5.)), QApplication::globalStrut().width()); break; case PM_IndicatorWidth: @@ -3234,7 +3253,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con if (theme.isValid()) { SIZE size; pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); - res = (pm == PM_IndicatorWidth ? size.cx+2 : res = size.cy+2); + res = (pm == PM_IndicatorWidth) ? size.cx : size.cy; } } break; @@ -3246,7 +3265,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con if (theme.isValid()) { SIZE size; pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); - res = (pm == PM_ExclusiveIndicatorWidth ? size.cx+2 : res = size.cy+2); + res = (pm == PM_ExclusiveIndicatorWidth) ? size.cx : size.cy; } } break; @@ -3318,7 +3337,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con #ifndef QT_NO_TOOLBAR case PM_ToolBarHandleExtent: - res = 8; + res = int(QStyleHelper::dpiScaled(8.)); break; #endif // QT_NO_TOOLBAR @@ -3333,10 +3352,10 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con } break; case PM_DockWidgetSeparatorExtent: - res = 4; + res = int(QStyleHelper::dpiScaled(4.)); break; case PM_DockWidgetTitleMargin: - res = 4; + res = int(QStyleHelper::dpiScaled(4.)); break; case PM_ButtonShiftHorizontal: @@ -3347,6 +3366,10 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con res = 0; break; + case PM_ButtonDefaultIndicator: + res = 0; + break; + default: res = QWindowsStyle::pixelMetric(pm, option, widget); } @@ -3428,7 +3451,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl int buttonWidth = GetSystemMetrics(SM_CXSIZE) - 4; const int delta = buttonWidth + 2; int controlTop = option->rect.bottom() - buttonHeight - 2; - const int frameWidth = pixelMetric(PM_MdiSubWindowFrameWidth, option, widget); + const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget); const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0; const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0; const bool maximizeHint = (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) != 0; @@ -3513,7 +3536,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl { const int controlTop = 6; const int controlHeight = height - controlTop - 3; - const int iconExtent = pixelMetric(PM_SmallIconSize); + const int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent)); if (tb->icon.isNull()) iconSize = QSize(controlHeight, controlHeight); @@ -3522,6 +3545,8 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl rect = QRect(frameWidth + hPad, controlTop + vPad, iconSize.width(), iconSize.height()); } break; + default: + break; } } break; @@ -3548,6 +3573,9 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl case SC_ComboBoxListBoxPopup: rect = cmb->rect; break; + + default: + break; } } break; @@ -3635,7 +3663,7 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt { //Spinbox adds frame twice sz = QWindowsStyle::sizeFromContents(ct, option, contentsSize, widget); - int border = pixelMetric(PM_SpinBoxFrameWidth, option, widget); + int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget); sz -= QSize(2*border, 2*border); } break; @@ -3789,6 +3817,8 @@ QPixmap QWindowsXPStyle::standardPixmap(StandardPixmap standardPixmap, const QSt } } break; + default: + break; } return QWindowsStyle::standardPixmap(standardPixmap, option, widget); } @@ -3910,6 +3940,8 @@ QIcon QWindowsXPStyle::standardIconImplementation(StandardPixmap standardIcon, } break; + default: + break; } return QWindowsStyle::standardIconImplementation(standardIcon, option, widget); diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index 376f834..d255f80 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -7,13 +7,19 @@ HEADERS += \ styles/qstyleplugin.h \ styles/qcommonstylepixmaps_p.h \ styles/qcommonstyle.h \ + styles/qstylehelper_p.h \ + styles/qproxystyle.h \ + styles/qproxystyle_p.h \ styles/qstylesheetstyle_p.h + SOURCES += \ styles/qstyle.cpp \ styles/qstylefactory.cpp \ styles/qstyleoption.cpp \ styles/qstyleplugin.cpp \ + styles/qstylehelper.cpp \ styles/qcommonstyle.cpp \ + styles/qproxystyle.cpp \ styles/qstylesheetstyle.cpp \ styles/qstylesheetstyle_default.cpp |