diff options
Diffstat (limited to 'src/gui/styles')
25 files changed, 2327 insertions, 1332 deletions
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index be9b10a..f553d27 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -207,118 +207,118 @@ 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_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 +374,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; @@ -695,7 +695,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()); } } diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index bb6baad..902ffdd 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); } @@ -1864,7 +1844,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 +1871,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 +1975,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 +2001,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 +2034,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); @@ -2068,7 +2048,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o 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 +2071,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 +2132,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 +2187,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 +2200,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 +2436,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 +2453,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 +2654,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 +2678,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 +2721,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 +2736,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 +2757,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 +2779,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 +2813,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 +2853,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 +2872,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 +2885,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 +2897,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 +2907,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 +2927,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 +3065,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 +3111,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 +3162,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 +3177,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 +3185,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 +3194,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 +3210,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 +3252,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 +3305,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 +3324,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 +3335,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 +3344,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 +3372,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 +3381,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 +3400,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 +3431,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 +3457,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 +3478,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 +3560,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 +3569,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 +3589,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 +3632,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 +3763,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 +3853,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 +3955,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 +4010,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 +4051,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 +4082,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 +4104,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 +4419,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 +4427,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 +4446,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 +4546,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 +4571,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 +4588,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..682e00b 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> @@ -154,7 +155,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 +505,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 +516,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 +525,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 +550,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 +582,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 +602,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 +619,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 +644,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 +694,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,7 +766,7 @@ 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)); @@ -850,7 +851,7 @@ 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")); @@ -892,7 +893,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); @@ -1290,24 +1291,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 +1316,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 +1331,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 +1366,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 +1394,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 +1413,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 +1436,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 +1458,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 +1479,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 +1510,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 +1560,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 +1602,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 +1613,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 +1624,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 +1641,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 +1653,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 +1690,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 +1698,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 +1708,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 +1723,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 +1733,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 +1780,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 +1791,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 +1895,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 +1911,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 +1923,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 +1947,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) { @@ -1971,7 +1973,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 +1981,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 +1998,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 +2109,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 +2147,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 +2162,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 +2188,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 +2202,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 +2210,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 +2226,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 +2268,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 +2287,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 +2330,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 +2369,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 +2427,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 +2440,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 +2454,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 +2466,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 +2506,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 +2517,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 +2554,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 +2626,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 +2646,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 +2682,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 +2704,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 +2729,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 +2751,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 +2773,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 +2853,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 +2874,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 +2906,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 @@ -2990,7 +2996,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 +3063,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 +3130,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 +3188,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_ToolBarExtensionExtent, 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 +3214,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 +3234,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 +3249,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 +3262,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 +3324,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 +3396,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 +3418,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 +3442,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 +3468,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 +3481,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 +3504,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 +3513,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 +3558,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 +3571,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 +3583,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 +3637,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 +3739,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 +3761,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 +3804,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 +3814,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 +3837,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 +3847,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 +3858,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 +3867,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 +3884,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 +3951,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 +3968,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 +3984,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 +4008,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 +4024,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 +4039,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 +4055,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 +4070,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 +4096,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 +4133,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 +4143,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 +4216,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 +4257,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 +4397,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 +4417,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 +4433,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 +4448,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); @@ -4649,7 +4594,7 @@ 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: @@ -4685,7 +4630,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid 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 +4647,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; } @@ -4848,12 +4793,12 @@ 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: @@ -4869,7 +4814,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid 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: @@ -4877,7 +4822,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = 16; break; case PM_IconViewIconSize: - ret = pixelMetric(PM_LargeIconSize, opt, widget); + ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); break; case PM_LargeIconSize: @@ -4908,10 +4853,10 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = 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 +4879,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 +4896,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 +4922,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 +4947,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 +4958,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 +5157,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 +5171,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); } } @@ -5364,7 +5309,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 +5614,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 +5629,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 +5641,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: @@ -5785,7 +5730,7 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons QIcon icon; #ifdef Q_WS_X11 Q_D(const QCommonStyle); - if (qApp->desktopSettingsAware()) { + if (QApplication::desktopSettingsAware()) { d->lookupIconTheme(); QPixmap pixmap; switch (standardIcon) { @@ -5997,7 +5942,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 +5957,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")); @@ -6230,7 +6175,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/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 218f651..a4a468d 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -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() @@ -675,14 +674,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; @@ -890,8 +889,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; @@ -971,7 +970,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); @@ -1242,8 +1241,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()) { @@ -1258,7 +1257,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; @@ -1283,7 +1282,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); } } @@ -1306,7 +1305,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; @@ -1314,9 +1313,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 ) ? @@ -1424,7 +1423,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, @@ -1495,8 +1494,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) @@ -1525,7 +1524,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); } } @@ -1536,9 +1535,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; @@ -1554,21 +1553,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; @@ -1585,10 +1584,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; @@ -1732,7 +1731,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) @@ -1740,8 +1739,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) @@ -1773,8 +1772,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); } @@ -1872,9 +1872,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; @@ -1929,8 +1929,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) { @@ -1947,7 +1947,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; @@ -2008,7 +2008,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, @@ -2098,9 +2098,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; @@ -2161,7 +2161,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; @@ -2182,7 +2182,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); @@ -2196,14 +2196,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; @@ -2212,8 +2212,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); @@ -2231,7 +2231,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); @@ -2253,7 +2253,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); } @@ -2299,7 +2299,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, @@ -2420,10 +2420,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(); @@ -2595,7 +2595,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 @@ -2623,7 +2623,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); } @@ -2663,7 +2663,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 @@ -2696,7 +2696,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; @@ -2724,7 +2724,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; @@ -2734,14 +2734,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; @@ -2959,8 +2959,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); @@ -3041,7 +3041,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) @@ -3205,7 +3205,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..262fbcb 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -55,6 +55,7 @@ #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> @@ -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 *); @@ -836,7 +851,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 +1051,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; } @@ -2207,7 +2222,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: @@ -2567,6 +2582,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 +2746,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 +3061,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 +3159,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 +3293,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)); @@ -3488,16 +3506,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,59 +3526,87 @@ 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; } } + + 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 +3655,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 +3742,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 +3756,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 +3764,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); } } } @@ -3876,7 +3922,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 +4046,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 +4170,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(); @@ -4233,7 +4280,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 +4340,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 +4440,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 @@ -4857,7 +4917,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 +4931,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 +4975,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 +5090,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 +5108,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 +5146,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 +5159,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)) { @@ -5141,8 +5208,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } 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 +5272,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; @@ -5436,7 +5507,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 +5604,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 +5626,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 +5664,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: @@ -5715,7 +5786,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz.transpose(); if (newStyleTabs) { int defaultTabHeight; - int defaultExtraSpace = pixelMetric(PM_TabBarTabHSpace, tab, widget); // Remove spurious gcc warning (AFAIK) + int defaultExtraSpace = proxy()->pixelMetric(PM_TabBarTabHSpace, tab, widget); // Remove spurious gcc warning (AFAIK) QFontMetrics fm = opt->fontMetrics; switch (AquaSize) { case QAquaSizeUnknown: @@ -5822,7 +5893,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 +5922,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 +5940,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; } 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..3935dc1 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(); @@ -749,8 +749,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 +1004,6 @@ QPlastiqueStylePrivate::QPlastiqueStylePrivate() : , progressBarAnimateTimer(0) #endif { - if (!qgetenv("QT_STYLE_NO_PIXMAPCACHE").isNull()) - UsePixmapCache = false; } /*! @@ -1132,7 +1129,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 +1175,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 +1354,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; @@ -1516,7 +1513,7 @@ void QPlastiqueStyle::drawPrimitive(PrimitiveElement element, const QStyleOption } #endif QString pixmapName = uniqueName(QLatin1String("toolbarhandle"), option, rect.size()); - if (!UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) { + if (!QPixmapCache::find(pixmapName, cache)) { cache = QPixmap(rect.size()); cache.fill(Qt::transparent); QPainter cachePainter(&cache); @@ -1546,8 +1543,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 +1853,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 +2069,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; @@ -2785,7 +2781,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QString progressBarName = 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 +2814,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)); @@ -2844,10 +2839,10 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op 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)); + 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 +2886,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 +2909,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 +2952,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 +2961,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 +3073,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(); @@ -3092,7 +3086,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op if ((option->state & State_Selected)) { QPixmap cache; QString pixmapName = uniqueName(QLatin1String("menubaritem"), option, option->rect.size()); - 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()); @@ -3142,8 +3136,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 { @@ -3457,7 +3450,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QString addLinePixmapName = 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 +3509,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); } @@ -3535,7 +3527,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op 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 +3553,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 +3570,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()); @@ -3590,7 +3581,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QString subLinePixmapName = 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 +3641,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); @@ -3669,7 +3659,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op 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 +3710,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 +3730,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 +3749,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 +3766,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 +3809,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; @@ -3891,7 +3880,7 @@ void QPlastiqueStyle::drawComplexControl(ComplexControl control, const QStyleOpt 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 +3963,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 +3972,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 +3994,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 +4049,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 +4071,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 +4411,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 +4535,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 +4568,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 +4603,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 +4676,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 +4703,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 +4747,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 +4772,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 +4818,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 +4864,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 +4891,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 +4915,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 +4940,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 +4952,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 +4987,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 +5006,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 +5088,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 +5141,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 +5266,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 +5448,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 +5471,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..94269b0 --- /dev/null +++ b/src/gui/styles/qproxystyle.cpp @@ -0,0 +1,420 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $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 + the overriding of QStyle elements. + + \since 4.6 + + A QProxyStyle wraps a QStyle (usually the default system style) for the + purpose of overriding the painting or other specific behavior of the + wrapped style. + + Below is an example that overrides the shortcut underline + behavior on all platforms: + + \snippet doc/src/snippets/code/src_gui_qproxystyle.cpp 1 + + Warning: Although Qt's internal styles should respect this hint, + there is no guarantee that it will work for all styles. It would + not work on a Mac, for example, because menus are handled by the + operating system on the Mac. + + \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..76b0768 --- /dev/null +++ b/src/gui/styles/qproxystyle.h @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $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..e7630d9 --- /dev/null +++ b/src/gui/styles/qproxystyle_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $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..797886c 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; } /*! @@ -1048,6 +1060,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() */ @@ -1177,6 +1191,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 +1345,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. @@ -2437,9 +2452,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..d79c39c 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) @@ -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..854874f 100644 --- a/src/gui/styles/qstyle_p.h +++ b/src/gui/styles/qstyle_p.h @@ -43,6 +43,7 @@ #define QSTYLE_P_H #include "private/qobject_p.h" +#include <QtGui/qstyle.h> QT_BEGIN_NAMESPACE @@ -51,22 +52,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; }; @@ -77,7 +80,7 @@ public: QPainter *p = painter; \ QString unique = 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 +92,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..20de892 --- /dev/null +++ b/src/gui/styles/qstylehelper.cpp @@ -0,0 +1,352 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $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> + +QT_BEGIN_NAMESPACE + +namespace QStyleHelper { + +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; +} + +#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..ef6e66c --- /dev/null +++ b/src/gui/styles/qstylehelper_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 qt-sales@nokia.com. +** $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); +#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..704f8ba 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 @@ -4998,6 +4999,34 @@ 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. + + For more advanced level-of-detail metrics, use + QStyleOptionGraphicsItem::matrix directly. + + \sa QStyleOptionGraphicsItem::matrix +*/ +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. @@ -5029,19 +5058,10 @@ QStyleOptionGraphicsItem::QStyleOptionGraphicsItem(int version) /*! \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 +5362,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..01d8aad 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,36 +4168,34 @@ 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())) { + && (container == w || !renderRule(container, opt).hasDrawable())) { //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now. // (this may happen if we have rules like :focus) p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole())); } 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..39743b0 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -67,6 +67,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" @@ -301,7 +304,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(); @@ -424,7 +427,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) @@ -458,7 +461,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW break; case PM_IconViewIconSize: - ret = pixelMetric(PM_LargeIconSize, opt, widget); + ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); break; case PM_ToolBarIconSize: @@ -1420,8 +1423,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 +1513,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 +1580,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) @@ -1735,7 +1738,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 +1757,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; @@ -1813,7 +1816,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 +1885,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 +1906,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 +1925,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 +1943,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 +1963,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 +1985,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 +2020,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 +2034,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); @@ -2263,7 +2266,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 +2452,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 +2476,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 +2487,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 +2575,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 +2605,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 +2639,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 +2714,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)) { @@ -3034,7 +3037,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 +3063,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 +3087,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,7 +3101,7 @@ 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()); @@ -3129,7 +3132,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 +3140,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 +3165,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 +3173,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,7 +3199,7 @@ 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); #ifndef QT_QWS_SMALL_PUSHBUTTON if (w < 75 + defwidth && !btn->text.isEmpty()) w = 75 + defwidth; @@ -3220,7 +3224,7 @@ 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)); @@ -3380,7 +3384,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..283c37a 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -403,7 +403,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 +417,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); @@ -645,7 +645,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; @@ -934,7 +934,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 +945,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"); @@ -1049,7 +1049,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption newBtn.rect = QStyle::visualRect(option->direction, option->rect, QRect(ir.right() - mbiw - 2, (option->rect.height()/2) - (mbih/2), mbiw + 1, mbih + 1)); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); } return; } @@ -1197,10 +1197,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. @@ -1292,9 +1292,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 +1320,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 +1346,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; @@ -1416,8 +1416,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 +1436,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); @@ -1556,7 +1556,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 +1587,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 +1596,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 +1614,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 +1653,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 = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget); partId = option->direction == Qt::RightToLeft ? CP_DROPDOWNBUTTONLEFT : CP_DROPDOWNBUTTONRIGHT; if (!(cmb->state & State_Enabled)) @@ -1679,7 +1679,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 +1696,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 +1713,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 +1730,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 +1740,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 +1755,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 +1770,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 +1783,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 +1851,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 +1866,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; @@ -1947,7 +1947,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; @@ -1985,7 +1985,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption 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 +2012,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 +2038,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); @@ -2214,7 +2214,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 +2251,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); @@ -2435,7 +2435,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); diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 2abf3bc..09e5b93 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> @@ -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(); @@ -1025,7 +1026,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 +1193,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;} @@ -1216,7 +1217,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, @@ -1532,7 +1533,7 @@ case PE_Frame: } if (panel->lineWidth > 0) - drawPrimitive(PE_FrameLineEdit, panel, p, widget); + proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget); return; } break; @@ -1617,7 +1618,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()) @@ -1791,7 +1792,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; @@ -1820,7 +1826,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; } @@ -1948,7 +1954,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; } @@ -1971,10 +1977,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; @@ -2119,8 +2125,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); @@ -2146,7 +2152,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() : @@ -2163,12 +2169,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); @@ -2180,7 +2186,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); @@ -2201,7 +2207,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; @@ -2218,10 +2224,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); @@ -2236,8 +2242,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; @@ -2258,18 +2264,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); @@ -2316,7 +2322,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) @@ -2449,7 +2455,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; @@ -2464,7 +2470,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; @@ -2501,7 +2507,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()); @@ -2516,7 +2522,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; @@ -2544,7 +2550,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); @@ -2559,7 +2565,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); @@ -2574,9 +2580,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; @@ -2584,7 +2590,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; @@ -2599,7 +2605,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; @@ -2614,7 +2620,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)) @@ -2625,7 +2631,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); @@ -2681,7 +2687,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; @@ -2697,11 +2703,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; @@ -2757,7 +2763,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; @@ -2803,7 +2809,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; @@ -2813,8 +2819,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; @@ -2862,9 +2868,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); } } } @@ -2874,26 +2880,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; @@ -2925,7 +2931,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); @@ -2944,7 +2950,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; @@ -2962,8 +2968,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(); @@ -2975,7 +2981,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; @@ -2993,7 +2999,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; @@ -3011,7 +3017,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; @@ -3033,7 +3039,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; @@ -3051,7 +3057,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; @@ -3069,7 +3075,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; @@ -3086,7 +3092,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()) @@ -3114,7 +3120,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; @@ -3130,7 +3136,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; @@ -3146,7 +3152,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; @@ -3164,6 +3170,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; @@ -3427,7 +3439,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; @@ -3512,7 +3524,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); @@ -3633,7 +3645,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; 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 |