From b23b8edce7cbd48165084dbd852875afeb800735 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 5 Oct 2010 18:12:45 +0000 Subject: Update qtcurve to latest upstream version git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kde-style-qtcurve@1182805 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- common/common.h | 1726 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 1409 insertions(+), 317 deletions(-) (limited to 'common/common.h') diff --git a/common/common.h b/common/common.h index 21f6bae..c64872b 100644 --- a/common/common.h +++ b/common/common.h @@ -2,7 +2,7 @@ #define __COMMON_H__ /* - QtCurve (C) Craig Drummond, 2003 - 2007 Craig.Drummond@lycos.co.uk + QtCurve (C) Craig Drummond, 2003 - 2010 craig.p.drummond@gmail.com ---- @@ -25,17 +25,29 @@ between Qt and Gtk, but not polute the namespace with exported functions... */ #include +#include #include #include "config.h" -/* - The following #define disables the rounding when scrollbar type==none. -#define QTC_SIMPLE_SCROLLBARS -*/ +#if defined _WIN32 && defined QT_VERSION && (QT_VERSION >= 0x040000) +#include +#include +#include + +static int isnan(double x) +{ + return _isnan(x); +} + +static int lstat(const char* fileName, struct stat* s) +{ + return stat(fileName, s); +} +#endif /* - The following #define disables the custom focus rectangle -#define QTC_PLAIN_FOCUS_ONLY + The following #define disables the rounding when scrollbar type==none. +#define SIMPLE_SCROLLBARS */ /* @@ -43,64 +55,62 @@ the scrollbar buttons when at min/max. This removes the thick looking line between the slider and the buttons. */ -#define QTC_INCREASE_SB_SLIDER - -/* - Enable this to do focus highlighting for scrollviews... NOTE: Gtk2 currently does not do this. -#define QTC_HIGHLIGHT_SCROLVIEWS -*/ - -/* - Control shading used for glass variants. - 0 => As used in 0.51.1 + - 1 => As used in 0.51 - 2 => As used in <0.51 -*/ -#define QTC_GLASS_SHADING 0 +#define INCREASE_SB_SLIDER typedef enum { SHADING_SIMPLE=0, SHADING_HSL=1, - SHADING_HSV=2 + SHADING_HSV=2, + SHADING_HCY=3 } EShading; -#if (!defined QTC_CONFIG_DIALOG) && (!defined QTC_KWIN) -static EShading shading=SHADING_HSL; -#endif - #ifdef __cplusplus #include -#ifdef QTC_CONFIG_DIALOG +#ifdef CONFIG_DIALOG #include #endif +#include +#include +#if !defined CONFIG_DIALOG && defined QT_VERSION && (QT_VERSION >= 0x040000) +#include +#endif #else #include #endif #ifdef __cplusplus +#include typedef QColor color; + +#if defined QT_VERSION && (QT_VERSION >= 0x040000) +#include +typedef QSet Strings; +#else +typedef QStringList Strings; +#endif + #else typedef gboolean bool; typedef GdkColor color; +typedef gchar ** Strings; #define true TRUE #define false FALSE #endif -#define QTC_GROUP "Settings" -/*#define QTC_DESCR_GROUP "Description"*/ +#define SETTINGS_GROUP "Settings" +#define KWIN_GROUP "KWin" +/*#define DESCR_GROUP "Description"*/ /* qtc_.themerc support */ #define KDE_PREFIX(V) ((4==(V)) ? KDE4PREFIX : KDE3PREFIX) -#define QTC_THEME_DIR "/share/apps/kstyle/themes/" -#define QTC_THEME_PREFIX "qtc_" -#define QTC_THEME_SUFFIX ".themerc" - +#define THEME_DIR "/share/apps/kstyle/themes/" +#define THEME_DIR4 "/share/kde4/apps/kstyle/themes/" +#define THEME_PREFIX "qtc_" +#define THEME_SUFFIX ".themerc" +#define BORDER_SIZE_FILE "windowBorderSizes" -#define QTC_CHECK_SIZE 13 -#define QTC_RADIO_SIZE 13 -#define QTC_MIN_BTN_SIZE 8 -#define QTC_LV_SIZE 7 +#define LV_SIZE 7 #define LARGE_ARR_WIDTH 7 #define LARGE_ARR_HEIGHT 4 @@ -110,6 +120,13 @@ typedef GdkColor color; #define NUM_STD_SHADES 6 #define NUM_EXTRA_SHADES 3 +enum +{ + ALPHA_ETCH_LIGHT = 0, + ALPHA_ETCH_DARK, + NUM_STD_ALPHAS +}; + #define TOTAL_SHADES NUM_STD_SHADES+NUM_EXTRA_SHADES #define ORIGINAL_SHADE TOTAL_SHADES @@ -118,7 +135,7 @@ typedef GdkColor color; #define SHADE_2_HIGHLIGHT NUM_STD_SHADES+2 /* 3d effect - i.e. buttons, etc */ -#define QTC_SHADES \ +#define SHADES \ static const double shades[2][11][NUM_STD_SHADES]=\ { \ { /* HSV & HSL */ \ @@ -149,88 +166,70 @@ typedef GdkColor color; } \ } ; -#define QTC_SIMPLE_SHADING (!shading) - -#define QT_STD_BORDER 5 -#define QT_DISABLED_BORDER QT_STD_BORDER /*3*/ -#define QT_BORDER(E) (/*(E) ?*/ QT_STD_BORDER/* : QT_DISABLED_BORDER*/) - -#define QT_FRAME_DARK_SHADOW 2 -#define QT_FOCUS 3 - -#define QTC_SHADE(c, s) \ +#define SIMPLE_SHADING (!shading) +#define DEFAULT_CONTRAST 7 + +#define THIN_SBAR_MOD ((opts.sliderWidthDEFAULT_SLIDER_WIDTH ? (opts.sliderWidth-9)/2 : 4)+(EFFECT_NONE==opts.buttonEffect ? 1 : 0)) +#define SLIDER_SIZE (opts.sliderWidth10 || c<0 || s>=NUM_STD_SHADES || s<0 \ ? 1.0 \ - : opts.darkerBorders && (QT_STD_BORDER==i || QT_DISABLED_BORDER==i) \ - ? shades[SHADING_SIMPLE==shading ? 1 : 0][c][s] - 0.1 \ - : shades[SHADING_SIMPLE==shading ? 1 : 0][c][s] ) + : opts.darkerBorders && (STD_BORDER==i || DISABLED_BORDER==i) \ + ? shades[SHADING_SIMPLE==opts.shading ? 1 : 0][c][s] - 0.1 \ + : shades[SHADING_SIMPLE==opts.shading ? 1 : 0][c][s] ) #define TAB_APPEARANCE(A) (A) /* (APPEARANCE_GLASS==(A) ? APPEARANCE_GRADIENT : (A)) */ -#define QTC_COLOR_SEL_TAB_FACTOR 1.2 - -#define QTC_ROUNDED (ROUND_NONE!=opts.round) - -#define QTC_ETCHED_DARK 0.95 -#define SHADE_BEVEL_GRAD_LIGHT (QTC_SIMPLE_SHADING ? 1.05 : 1.07) -#define SHADE_BEVEL_GRAD_DARK (QTC_SIMPLE_SHADING ? 0.93 : 0.91) -#define SHADE_BEVEL_GRAD_SEL_LIGHT (QTC_SIMPLE_SHADING ? 1.05 : 1.07) -#define SHADE_BEVEL_GRAD_SEL_DARK (QTC_SIMPLE_SHADING ? 0.95 : 0.93) - -#define SHADE_BEVEL_MENU_ITEM_LIGHT (QTC_SIMPLE_SHADING ? 1.07 : 1.09) -#define SHADE_BEVEL_MENU_ITEM_DARK (QTC_SIMPLE_SHADING ? 0.85 : 0.83) - -#define SHADE_SLIDER_LIGHT 1.1 -#define SHADE_SLIDER_DARK 0.8 - -#define SHADE_SBAR_LIGHT 1.02 -#define SHADE_SBAR_DARK 0.95 - -#define SHADE_MENU_LIGHT 1.02 -#define SHADE_MENU_DARK 0.96 - -#define SHADE_TAB_SEL_LIGHT 1.1 -#define SHADE_TAB_SEL_DARK 1.0 -#define SHADE_BOTTOM_TAB_SEL_LIGHT 1.0 -#define SHADE_BOTTOM_TAB_SEL_DARK 0.96 - -#define SPLIT_GRADIENT_FACTOR 0.415 - -#if !defined QTC_GLASS_SHADING || QTC_GLASS_SHADING==0 - - #define SHADE_GLASS_TOP_A(A, W) (APPEARANCE_DULL_GLASS==A \ - ? (WIDGET_DEF_BUTTON==W ? 0.99 : 0.98) \ - : (WIDGET_DEF_BUTTON==W ? 1.08 : 1.55)) - #define SHADE_GLASS_TOP_B(A, W) (APPEARANCE_DULL_GLASS==A \ - ? (WIDGET_DEF_BUTTON==W ? 0.94 : 0.92) \ - : 0.92) - #define SHADE_GLASS_BOT_A(A) (APPEARANCE_DULL_GLASS==A ? 1.02 : 0.99) - #define SHADE_GLASS_BOT_B(A) (APPEARANCE_DULL_GLASS==A ? 1.10 : 1.16) - -#elif QTC_GLASS_SHADING==1 - - #define SHADE_GLASS_TOP_A(A, W) (APPEARANCE_DULL_GLASS==A \ - ? (WIDGET_DEF_BUTTON==W ? 1.0 : 1.0) \ - : (WIDGET_DEF_BUTTON==W ? 1.08 : 1.7)) - #define SHADE_GLASS_TOP_B(A, W) (APPEARANCE_DULL_GLASS==A ? 0.96 : 0.96) - #define SHADE_GLASS_BOT_A(A) 0.99 - #define SHADE_GLASS_BOT_B(A) (APPEARANCE_DULL_GLASS==A ? 1.08 : 1.16) - -#else +#define INVERT_SHADE(A) (1.0+(1.0-(A))) - #define SHADE_GLASS_TOP_A(A, W) (APPEARANCE_DULL_GLASS==A \ - ? (WIDGET_DEF_BUTTON==W ? 1.05 : 1.05) \ - : (WIDGET_DEF_BUTTON==W ? 1.08 : 1.7)) - #define SHADE_GLASS_TOP_B(A, W) 0.96 - #define SHADE_GLASS_BOT_A(A) 0.99 - #define SHADE_GLASS_BOT_B(A) (APPEARANCE_DULL_GLASS==A ? 1.08 : 1.16) +#define ROUNDED (ROUND_NONE!=opts.round) -#endif +#define TOOLBAR_SEP_GAP (opts.fadeLines ? 5 : 6) +#define FADE_SIZE 0.4 +#define ETCHED_DARK 0.95 -#define IS_GLASS(A) (APPEARANCE_DULL_GLASS==A || APPEARANCE_SHINY_GLASS==A) -#define IS_FLAT(A) (APPEARANCE_FLAT==A || APPEARANCE_RAISED==A) -#define SHADE_SELECTION_TOP 1.15 -#define SHADE_SELECTION_BOT 0.9 +#define IS_GLASS(A) (APPEARANCE_DULL_GLASS==(A) || APPEARANCE_SHINY_GLASS==(A)) +#define IS_CUSTOM(A) ((A)>=APPEARANCE_CUSTOM1 && (A)<(APPEARANCE_CUSTOM1+NUM_CUSTOM_GRAD)) +#define IS_FLAT(A) (APPEARANCE_FLAT==(A) || APPEARANCE_RAISED==(A) || APPEARANCE_FADE==(A)) +#define IS_FLAT_BGND(A) (APPEARANCE_FLAT==(A) || APPEARANCE_RAISED==(A)) #ifdef __cplusplus #define MENUBAR_DARK_LIMIT 160 @@ -240,71 +239,338 @@ typedef GdkColor color; #define TOO_DARK(A) ((A).redborder) && WIDGET_MENU_ITEM!=(WIDGET) && !IS_TROUGH(WIDGET) && \ + (WIDGET_DEF_BUTTON!=(WIDGET) || IND_COLORED!=opts.defBtnIndicator)) + +#define DRAW_3D_FULL_BORDER(SUNKEN, APP) \ + (!(SUNKEN) && GB_3D_FULL==getGradient((APP), &opts)->border) + +#define DRAW_3D_BORDER(SUNKEN, APP) \ + (!(SUNKEN) && GB_3D==getGradient((APP), &opts)->border) + +#define DRAW_SHINE(SUNKEN, APP) \ + (!(SUNKEN) && GB_SHINE==getGradient((APP), &opts)->border) + +#define LIGHT_BORDER(APP) (APPEARANCE_DULL_GLASS==(APP) ? 1 : 0) #define PROGRESS_ANIMATION 100 -#define MIN_SLIDER_SIZE(A) (LINE_DOTS==A ? 24 : 20) - -#define QTC_NORM_TAB_APP (APPEARANCE_BEVELLED==opts.tabAppearance || APPEARANCE_SPLIT_GRADIENT==opts.appearance \ - ? APPEARANCE_GRADIENT : opts.tabAppearance) -#define QTC_SEL_TAB_APP (APPEARANCE_INVERTED==opts.tabAppearance ? APPEARANCE_FLAT : (QTC_NORM_TAB_APP)) -#define QTC_SLIDER_MO_SHADE (SHADE_SELECTED==opts.shadeSliders ? 1 : (SHADE_BLEND_SELECTED==opts.shadeSliders ? 0 : ORIGINAL_SHADE)) -#define QTC_SLIDER_MO_BORDER (SHADE_SELECTED==opts.shadeSliders || SHADE_BLEND_SELECTED==opts.shadeSliders ? 2 : 1) -#define QTC_SLIDER_MO_LEN (SLIDER_TRIANGULAR==opts.sliderStyle ? 2 : (SHADE_SELECTED==opts.shadeSliders || SHADE_BLEND_SELECTED==opts.shadeSliders ? 4 : 3)) -#define QTC_SB_SLIDER_MO_LEN(A) ((A)<22 && ROUND_FULL!=opts.round \ +#define MIN_SLIDER_SIZE(A) (LINE_DOTS==(A) ? 24 : 20) + +#define CR_SMALL_SIZE 13 +#define CR_LARGE_SIZE 15 + +#define TAB_APP(A) (APPEARANCE_BEVELLED==(A) || APPEARANCE_SPLIT_GRADIENT==(A) ? APPEARANCE_GRADIENT : (A)) +#define NORM_TAB_APP TAB_APP(opts.tabAppearance) +#define SEL_TAB_APP TAB_APP(opts.activeTabAppearance) + +#define SLIDER_MO_SHADE (SHADE_SELECTED==opts.shadeSliders ? 1 : (SHADE_BLEND_SELECTED==opts.shadeSliders ? 0 : ORIGINAL_SHADE)) +#define SLIDER_MO_PLASTIK_BORDER (SHADE_SELECTED==opts.shadeSliders || SHADE_BLEND_SELECTED==opts.shadeSliders ? 2 : 1) +#define SLIDER_MO_LEN (SLIDER_TRIANGULAR==opts.sliderStyle ? 2 : (SHADE_SELECTED==opts.shadeSliders || SHADE_BLEND_SELECTED==opts.shadeSliders ? 4 : 3)) +#define SB_SLIDER_MO_LEN(A) ((A)<22 && !FULLLY_ROUNDED \ ? 2 \ : ((A)<32 || (SHADE_SELECTED!=opts.shadeSliders && SHADE_BLEND_SELECTED!=opts.shadeSliders) \ ? 4 \ : 6)) -#define QTC_CR_MO_FILL (SHADE_BLEND_SELECTED==opts.shadeCheckRadio || SHADE_SELECTED==opts.shadeCheckRadio ? 1 : 2) -#define QTC_MO_DEF_BTN 2 -#define QTC_MO_PLASTIK_DARK(W) (WIDGET_DEF_BUTTON==W && IND_COLORED==opts.defBtnIndicator ? 3 : 2) /*? 2 : 1) */ -#define QTC_MO_PLASTIK_LIGHT(W) (WIDGET_DEF_BUTTON==W && IND_COLORED==opts.defBtnIndicator ? 4 : 1) /*? 2 : 0) */ +#define CR_MO_FILL 1 +#define MO_DEF_BTN 2 +#define MO_PLASTIK_DARK(W) (WIDGET_DEF_BUTTON==(W) && IND_COLORED==opts.defBtnIndicator ? 3 : 2) /*? 2 : 1) */ +#define MO_PLASTIK_LIGHT(W) (WIDGET_DEF_BUTTON==(W) && IND_COLORED==opts.defBtnIndicator ? 4 : 1) /*? 2 : 0) */ + +#define MO_STD_DARK(W) (MO_GLOW==opts.coloredMouseOver \ + ? 1 \ + : MO_PLASTIK_DARK(W)) +#define MO_STD_LIGHT(W, S) (MO_GLOW==opts.coloredMouseOver \ + ? 1 \ + : MO_PLASTIK_LIGHT(W)) + +#define FULLLY_ROUNDED (opts.round>=ROUND_FULL) +#define DO_EFFECT (EFFECT_NONE!=opts.buttonEffect) +#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000)) +#define SLIDER_GLOW (DO_EFFECT && MO_GLOW==opts.coloredMouseOver /*&& SLIDER_TRIANGULAR!=opts.sliderStyle*/ ? 2 : 0) +#endif -#define QTC_MO_STD_DARK(W) QTC_MO_PLASTIK_DARK(W) /*(WIDGET_DEF_BUTTON==W && IND_COLORED==opts.defBtnIndicator ? 4 : 1) */ -#define QTC_MO_STD_LIGHT(W, S) QTC_MO_PLASTIK_LIGHT(W) /*(WIDGET_DEF_BUTTON==W && IND_COLORED==opts.defBtnIndicator ? 2 : (S ? 1 : 0))*/ +#define ENTRY_MO (opts.unifyCombo && opts.unifySpin) + +#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000)) +#define FOCUS_ALPHA 0.08 +#define FOCUS_GLOW_LINE_ALPHA 0.5 +#define BORDER_BLEND_ALPHA 0.7 +#define ETCH_TOP_ALPHA 0.055 +#define ETCH_BOTTOM_ALPHA 0.1 +// #if defined QT_VERSION && (QT_VERSION >= 0x040000) +// #define ETCH_RADIO_TOP_ALPHA 0.055 +// #define ETCH_RADIO_BOTTOM_ALPHA 0.80 +// #else +#define ETCH_RADIO_TOP_ALPHA 0.09 +#define ETCH_RADIO_BOTTOM_ALPHA 1.0 +// #endif + +#define RINGS_INNER_ALPHA(T) qtcRingAlpha[IMG_PLAIN_RINGS==(T) ? 1 : 0] //(IMG_PLAIN_RINGS==opts.bgndImage.type ? 0.25 : 0.125) +#define RINGS_OUTER_ALPHA qtcRingAlpha[2] //0.5 +#define RINGS_WIDTH(T) (IMG_SQUARE_RINGS==T ? 260 : 450) +#define RINGS_HEIGHT(T) (IMG_SQUARE_RINGS==T ? 220 : 360) + +#define RINGS_SQUARE_LARGE_ALPHA (RINGS_OUTER_ALPHA*0.675) +#define RINGS_SQUARE_SMALL_ALPHA (RINGS_OUTER_ALPHA*0.50) +#define RINGS_SQUARE_LINE_WIDTH 20.0 +#define RINGS_SQUARE_RADIUS 18.0 +#define RINGS_SQUARE_LARGE_SIZE 120.0 +#define RINGS_SQUARE_SMALL_SIZE 100.0 + +#if !defined __cplusplus +#define MENU_AND_TOOLTIP_RADIUS (opts.round>=ROUND_FULL ? 5.0 : 3.5) +#else +#define MENU_AND_TOOLTIP_RADIUS (opts.round>=ROUND_FULL ? 5.0 : 2.5) +#endif -#define QTC_DO_EFFECT (ROUND_FULL==opts.round && EFFECT_NONE!=opts.buttonEffect) +#define CUSTOM_BGND (!(IS_FLAT_BGND(opts.bgndAppearance)) || IMG_NONE!=opts.bgndImage.type || 100!=opts.bgndOpacity || 100!=opts.dlgOpacity) + +#define GLOW_PROG_ALPHA 0.55 + +#endif + +#if defined __cplusplus && defined QT_VERSION && (QT_VERSION >= 0x040000) -#ifdef __cplusplus #include typedef enum { - QtC_Round = QStyle::PM_CustomBase + QtC_Round = QStyle::PM_CustomBase, + QtC_TitleBarButtonAppearance, + QtC_TitleAlignment, + QtC_TitleBarButtons, + QtC_TitleBarIcon, + QtC_TitleBarIconColor, + QtC_TitleBarEffect, + QtC_BlendMenuAndTitleBar, + QtC_ShadeMenubarOnlyWhenActive, + QtC_ToggleButtons, + QtC_MenubarColor, + QtC_WindowBorder, + QtC_CustomBgnd, + QtC_TitleBarApp } QtCMetrics; + +#define QtC_StateKWin ((QStyle::StateFlag)0x10000000) +// PE_FrameWindow +#define QtC_StateKWinNotFull ((QStyle::StateFlag)0x20000000) +// CC_TitleBar +#define QtC_StateKWinFillBgnd ((QStyle::StateFlag)0x20000000) +#define QtC_StateKWinNoBorder ((QStyle::StateFlag)0x40000000) +#define QtC_StateKWinCompositing ((QStyle::StateFlag)0x80000000) +#define QtC_StateKWinTabDrag ((QStyle::StateFlag)0x00000001) + +#define QtC_PE_DrawBackground ((QStyle::PrimitiveElement)(QStyle::PE_CustomBase+10000)) + +#define CLOSE_COLOR QColor(191, 82, 82) +#define DARK_WINDOW_TEXT(A) ((A).red()<230 || (A).green()<230 || (A).blue()<230) +#define HOVER_BUTTON_ALPHA(A) (DARK_WINDOW_TEXT(A) ? 0.25 : 0.65) +#define WINDOW_TEXT_SHADOW_ALPHA(A) (EFFECT_SHADOW==(A) ? 0.10 : 0.60) +#define WINDOW_SHADOW_COLOR(A) (EFFECT_SHADOW==(A) ? Qt::black : Qt::white) +#endif + +#if defined CONFIG_DIALOG || (defined QT_VERSION && (QT_VERSION >= 0x040000)) +#define QTCURVE_PREVIEW_CONFIG "QTCURVE_PREVIEW_CONFIG" +#define QTCURVE_PREVIEW_CONFIG_FULL "QTCURVE_PREVIEW_CONFIG_FULL" + +typedef enum +{ + DWT_BUTTONS_AS_PER_TITLEBAR = 0x0001, + DWT_COLOR_AS_PER_TITLEBAR = 0x0002, + DWT_FONT_AS_PER_TITLEBAR = 0x0004, + DWT_TEXT_ALIGN_AS_PER_TITLEBAR = 0x0008, + DWT_EFFECT_AS_PER_TITLEBAR = 0x0010, + DWT_ROUND_TOP_ONLY = 0x0020, + DWT_ICON_COLOR_AS_PER_TITLEBAR = 0x0040 +} EDwtSettingsFlags; + +typedef enum +{ + TITLEBAR_BUTTON_ROUND = 0x0001, + TITLEBAR_BUTTON_HOVER_FRAME = 0x0002, + TITLEBAR_BUTTON_HOVER_SYMBOL = 0x0004, + TITLEBAR_BUTTON_NO_FRAME = 0x0008, + TITLEBAR_BUTTON_COLOR = 0x0010, + TITLEBAR_BUTTON_COLOR_INACTIVE = 0x0020, + TITLEBAR_BUTTON_COLOR_MOUSE_OVER = 0x0040, + TITLEBAR_BUTTON_STD_COLOR = 0x0080, + TITLEBAR_BUTTON_COLOR_SYMBOL = 0x0100, + TITLEBAR_BUTTON_HOVER_SYMBOL_FULL = 0x0200, + TITLEBAR_BUTTON_SUNKEN_BACKGROUND = 0x0400, + TITLEBAR_BUTTOM_ARROW_MIN_MAX = 0x0800, + TITLEBAR_BUTTOM_HIDE_ON_INACTIVE_WINDOW = 0x1000, + TITLEBAR_BUTTON_ICON_COLOR = 0x2000 +} ETitleBarButtonFlags; + +typedef enum +{ + TITLEBAR_ICON_NONE, + TITLEBAR_ICON_MENU_BUTTON, + TITLEBAR_ICON_NEXT_TO_TITLE +} ETitleBarIcon; + +typedef enum +{ + TITLEBAR_CLOSE, + TITLEBAR_MIN, + TITLEBAR_MAX, + TITLEBAR_HELP, + TITLEBAR_MENU, + TITLEBAR_SHADE, + TITLEBAR_ALL_DESKTOPS, + TITLEBAR_KEEP_ABOVE, + TITLEBAR_KEEP_BELOW, + NUM_TITLEBAR_BUTTONS +} ETitleBarButtons; + +#define TBAR_VERSION_HACK 65535 +#define TBAR_BORDER_VERSION_HACK (TBAR_VERSION_HACK+1000) + +typedef std::map TBCols; #endif +typedef enum +{ + WINDOW_BORDER_COLOR_TITLEBAR_ONLY = 0x01, // colorTitlebarOnly + WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR = 0x02, // titlebarMenuColor + WINDOW_BORDER_ADD_LIGHT_BORDER = 0x04, // titlebarBorder + WINDOW_BORDER_BLEND_TITLEBAR = 0x08, // titlebarBlend + WINDOW_BORDER_SEPARATOR = 0x10 +} EWindowBorder; + +typedef enum +{ + IMG_NONE, + IMG_BORDERED_RINGS, + IMG_PLAIN_RINGS, + IMG_SQUARE_RINGS, + IMG_FILE +} EImageType; + +typedef struct +{ + EImageType type; + bool loaded; +#if defined __cplusplus + QString file; + QPixmap pix; +#else // __cplusplus + const char *file; + GdkPixbuf *pix; +#endif // __cplusplus + int width, height; +} QtCImage; + +typedef enum +{ + SQUARE_NONE = 0x0000, + SQUARE_ENTRY = 0x0001, + SQUARE_PROGRESS = 0x0002, + SQUARE_SCROLLVIEW = 0x0004, + SQUARE_LISTVIEW_SELECTION = 0x0008, + SQUARE_FRAME = 0x0010, + SQUARE_TAB_FRAME = 0x0020, + SQUARE_SLIDER = 0x0040, + SQUARE_SB_SLIDER = 0x0080, + SQUARE_WINDOWS = 0x0100, + SQUARE_TOOLTIPS = 0x0200, + SQUARE_POPUP_MENUS = 0x0400 +} ESquare; + +typedef enum +{ + WM_DRAG_NONE = 0, + WM_DRAG_MENUBAR = 1, + WM_DRAG_MENU_AND_TOOLBAR = 2, + WM_DRAG_ALL = 3 +} EWmDrag; + typedef enum { EFFECT_NONE, @@ -314,14 +580,22 @@ typedef enum typedef enum { + PIX_CHECK, +#ifdef __cplusplus +#if defined QT_VERSION && (QT_VERSION < 0x040000) + PIX_RADIO_ON, PIX_RADIO_BORDER, + PIX_RADIO_INNER, PIX_RADIO_LIGHT, - PIX_RADIO_ON, - PIX_CHECK, PIX_SLIDER, PIX_SLIDER_LIGHT, PIX_SLIDER_V, - PIX_SLIDER_LIGHT_V + PIX_SLIDER_LIGHT_V, +#endif + PIX_DOT +#else + PIX_BLANK +#endif } EPixmap; typedef enum @@ -330,46 +604,109 @@ typedef enum WIDGET_TAB_BOT, WIDGET_STD_BUTTON, WIDGET_DEF_BUTTON, + WIDGET_TOOLBAR_BUTTON, WIDGET_LISTVIEW_HEADER, WIDGET_SLIDER, WIDGET_SLIDER_TROUGH, + WIDGET_FILLED_SLIDER_TROUGH, WIDGET_SB_SLIDER, WIDGET_SB_BUTTON, + WIDGET_SB_BGND, WIDGET_TROUGH, WIDGET_CHECKBOX, - WIDGET_TOGGLE_BUTTON, + WIDGET_RADIO_BUTTON, + WIDGET_COMBO, + WIDGET_COMBO_BUTTON, WIDGET_MENU_ITEM, WIDGET_PROGRESSBAR, + WIDGET_PBAR_TROUGH, #ifndef __cplusplus + WIDGET_ENTRY_PROGRESSBAR, + WIDGET_TOGGLE_BUTTON, WIDGET_SPIN_UP, WIDGET_SPIN_DOWN, + WIDGET_UNCOLOURED_MO_BUTTON, +#else + WIDGET_CHECKBUTTON, // Qt4 only + WIDGET_MDI_WINDOW, // Qt4 only + WIDGET_MDI_WINDOW_TITLE, // Qt4 only + WIDGET_MDI_WINDOW_BUTTON, // Qt4 only + WIDGET_DOCK_WIDGET_TITLE, + WIDGET_DIAL, #endif WIDGET_SPIN, -#ifdef __cplusplus - WIDGET_CHECKBUTTON, // Qt4 only - WIDGET_MDI_WINDOW, // Qt4 only - WIDGET_MDI_WINDOW_TITLE, // Qt4 only WIDGET_ENTRY, + WIDGET_SCROLLVIEW, + WIDGET_SELECTION, WIDGET_FRAME, WIDGET_NO_ETCH_BTN, -#endif + WIDGET_MENU_BUTTON, // Qt4 only + WIDGET_FOCUS, + WIDGET_TAB_FRAME, WIDGET_OTHER } EWidget; typedef enum { - APPEARANCE_FLAT, + APP_ALLOW_BASIC, + APP_ALLOW_FADE, + APP_ALLOW_STRIPED, + APP_ALLOW_NONE +} EAppAllow; + +typedef enum +{ + APPEARANCE_CUSTOM1, + APPEARANCE_CUSTOM2, + APPEARANCE_CUSTOM3, + APPEARANCE_CUSTOM4, + APPEARANCE_CUSTOM5, + APPEARANCE_CUSTOM6, + APPEARANCE_CUSTOM7, + APPEARANCE_CUSTOM8, + APPEARANCE_CUSTOM9, + APPEARANCE_CUSTOM10, + APPEARANCE_CUSTOM11, + APPEARANCE_CUSTOM12, + APPEARANCE_CUSTOM13, + APPEARANCE_CUSTOM14, + APPEARANCE_CUSTOM15, + APPEARANCE_CUSTOM16, + APPEARANCE_CUSTOM17, + APPEARANCE_CUSTOM18, + APPEARANCE_CUSTOM19, + APPEARANCE_CUSTOM20, + APPEARANCE_CUSTOM21, + APPEARANCE_CUSTOM22, + + NUM_CUSTOM_GRAD, + + APPEARANCE_FLAT = NUM_CUSTOM_GRAD, APPEARANCE_RAISED, APPEARANCE_DULL_GLASS, APPEARANCE_SHINY_GLASS, + APPEARANCE_AGUA, + APPEARANCE_SOFT_GRADIENT, APPEARANCE_GRADIENT, + APPEARANCE_HARSH_GRADIENT, APPEARANCE_INVERTED, + APPEARANCE_DARK_INVERTED, APPEARANCE_SPLIT_GRADIENT, - APPEARANCE_BEVELLED + APPEARANCE_BEVELLED, + APPEARANCE_FADE, /* Only for poupmenu items! */ + APPEARANCE_STRIPED = APPEARANCE_FADE, /* Only for windows and menus */ + APPEARANCE_NONE = APPEARANCE_FADE, /* Only for titlebars */ + APPEARANCE_LV_BEVELLED, /* To be used only with getGradient */ + APPEARANCE_AGUA_MOD, + APPEARANCE_LV_AGUA, + NUM_STD_APP = (APPEARANCE_LV_AGUA-NUM_CUSTOM_GRAD)+1 } EAppearance; -#define IS_SLIDER(W) (WIDGET_SLIDER==W || WIDGET_SB_SLIDER==W) -#define IS_TOGGLE_BUTTON(W) (WIDGET_TOGGLE_BUTTON==W || WIDGET_CHECKBOX==W) +#define IS_SLIDER(W) (WIDGET_SLIDER==(W) || WIDGET_SB_SLIDER==(W)) +#define IS_TROUGH(W) (WIDGET_SLIDER_TROUGH==(W) || WIDGET_PBAR_TROUGH==(W) || WIDGET_TROUGH==(W) || WIDGET_FILLED_SLIDER_TROUGH==(W)) +#ifndef __cplusplus +#define IS_TOGGLE_BUTTON(W) (WIDGET_TOGGLE_BUTTON==(W) || WIDGET_CHECKBOX==(W)) +#endif typedef enum { @@ -379,49 +716,54 @@ typedef enum CORNER_BL = 0x8 } ECornerBits; -#define ROUNDED_NONE 0x0 -#define ROUNDED_TOP (CORNER_TL|CORNER_TR) -#define ROUNDED_BOTTOM (CORNER_BL|CORNER_BR) -#define ROUNDED_LEFT (CORNER_TL|CORNER_BL) -#define ROUNDED_RIGHT (CORNER_TR|CORNER_BR) -#define ROUNDED_TOPRIGHT CORNER_TR -#define ROUNDED_BOTTOMRIGHT CORNER_BR -#define ROUNDED_TOPLEFT CORNER_TL -#define ROUNDED_BOTTOMLEFT CORNER_BL -#define ROUNDED_ALL (CORNER_TL|CORNER_TR|CORNER_BR|CORNER_BL) +#define ROUNDED_NONE 0x0 +#define ROUNDED_TOP (CORNER_TL|CORNER_TR) +#define ROUNDED_BOTTOM (CORNER_BL|CORNER_BR) +#define ROUNDED_LEFT (CORNER_TL|CORNER_BL) +#define ROUNDED_RIGHT (CORNER_TR|CORNER_BR) +#define ROUNDED_TOPRIGHT CORNER_TR +#define ROUNDED_BOTTOMRIGHT CORNER_BR +#define ROUNDED_TOPLEFT CORNER_TL +#define ROUNDED_BOTTOMLEFT CORNER_BL +#define ROUNDED_ALL (CORNER_TL|CORNER_TR|CORNER_BR|CORNER_BL) typedef enum { IND_CORNER, IND_FONT_COLOR, IND_COLORED, + IND_TINT, + IND_GLOW, + IND_DARKEN, + IND_SELECTED, IND_NONE } EDefBtnIndicator; typedef enum { + LINE_NONE, LINE_SUNKEN, LINE_FLAT, LINE_DOTS, - LINE_DASHES + LINE_1DOT, + LINE_DASHES, } ELine; -#define LINE_NONE LINE_DASHES - typedef enum { TB_NONE, TB_LIGHT, TB_DARK, TB_LIGHT_ALL, - TB_DARK_ALL, + TB_DARK_ALL } ETBarBorder; typedef enum { BORDER_FLAT, BORDER_RAISED, - BORDER_SUNKEN + BORDER_SUNKEN, + BORDER_LIGHT } EBorder; /* @@ -433,16 +775,26 @@ typedef enum { SHADE_NONE, SHADE_CUSTOM, - SHADE_BLEND_SELECTED, /* In the case of check/radios this is SHADE_SELECTED */ - SHADE_SELECTED, - SHADE_DARKEN = SHADE_SELECTED , /* For menubar only! */ + SHADE_SELECTED, + SHADE_BLEND_SELECTED, + SHADE_DARKEN, + SHADE_WINDOW_BORDER } EShade; +typedef enum +{ + ECOLOR_BASE, + ECOLOR_BACKGROUND, + ECOLOR_DARK, +} EColor; + typedef enum { ROUND_NONE, ROUND_SLIGHT, - ROUND_FULL + ROUND_FULL, + ROUND_EXTRA, + ROUND_MAX } ERound; typedef enum @@ -454,68 +806,439 @@ typedef enum SCROLLBAR_NONE } EScrollbar; +typedef enum +{ + FRAME_NONE, + FRAME_PLAIN, + FRAME_LINE, + FRAME_SHADED, + FRAME_FADED +} EFrame; + +typedef enum +{ + GB_LBL_BOLD = 0x01, + GB_LBL_CENTRED = 0x02, + GB_LBL_INSIDE = 0x04, + GB_LBL_OUTSIDE = 0x08 +} EGBLabel; + +#define NO_FRAME(A) (FRAME_NONE==(A) || FRAME_LINE==(A)) + typedef enum { MO_NONE, MO_COLORED, - MO_PLASTIK + MO_COLORED_THICK, + MO_PLASTIK, + MO_GLOW } EMouseOver; typedef enum { STRIPE_NONE, STRIPE_PLAIN, - STRIPE_DIAGONAL + STRIPE_DIAGONAL, + STRIPE_FADE } EStripe; typedef enum { SLIDER_PLAIN, SLIDER_ROUND, + SLIDER_PLAIN_ROTATED, + SLIDER_ROUND_ROTATED, SLIDER_TRIANGULAR, + SLIDER_CIRCULAR } ESliderStyle; -#define DEF_IND_STR "fontcolor" -#define DEF_LINE_STR "dots" -#define DEF_TB_BORDER "none" -#define DEF_APPEARANCE_STR "bevelled" -#define DEF_MENU_APPEARANCE_STR "gradient" -#define DEF_TOOLBAR_APPEARANCE_STR "gradient" -#define DEF_SLIDER_SHADE_STR "selected" -#define DEF_TBS_STR "dots" -#define DEF_COLOR_STR "background" -#define DEF_TOOLBAR_SHADE_STR "none" +#define ROTATED_SLIDER (SLIDER_PLAIN_ROTATED==opts.sliderStyle || SLIDER_ROUND_ROTATED==opts.sliderStyle) -#ifdef QTC_COMMON_FUNCTIONS -static double getWidgetShade(EWidget w, bool light, bool sunken, EAppearance app) +typedef enum { - switch(w) + FOCUS_STANDARD, + FOCUS_RECTANGLE, + FOCUS_FULL, + FOCUS_FILLED, + FOCUS_LINE, + FOCUS_GLOW +} EFocus; + +typedef enum +{ + TAB_MO_TOP, + TAB_MO_BOTTOM, + TAB_MO_GLOW +} ETabMo; + +typedef enum +{ + GT_HORIZ, + GT_VERT +} EGradType; + +typedef enum +{ + GLOW_NONE, + GLOW_START, + GLOW_MIDDLE, + GLOW_END +} EGlow; + +#define FULL_FOCUS (FOCUS_FULL==opts.focus || FOCUS_FILLED==opts.focus) + +enum +{ + HIDE_NONE = 0x00, + HIDE_KEYBOARD = 0x01, + HIDE_KWIN = 0x02 +}; + +#if defined __cplusplus +typedef enum +{ + ALIGN_LEFT, + ALIGN_CENTER, + ALIGN_FULL_CENTER, + ALIGN_RIGHT +} EAlign; +#endif + +#ifdef __cplusplus +inline +#else +static +#endif +bool equal(double d1, double d2) +{ + return (fabs(d1 - d2) < 0.0001); +} + +#ifdef __cplusplus +struct GradientStop +#else +typedef struct +#endif +{ +#ifdef __cplusplus + GradientStop(double p=0.0, double v=0.0, double a=1.0) : pos(p), val(v), alpha(a) { } + + bool operator==(const GradientStop &o) const { - case WIDGET_TROUGH: - return light ? SHADE_SBAR_LIGHT : SHADE_SBAR_DARK; - case WIDGET_SLIDER_TROUGH: - return light ? SHADE_SLIDER_LIGHT : SHADE_SLIDER_DARK; - case WIDGET_MENU_ITEM: - if(APPEARANCE_DULL_GLASS!=app && APPEARANCE_SHINY_GLASS!=app) - return light ? SHADE_BEVEL_MENU_ITEM_LIGHT : SHADE_BEVEL_MENU_ITEM_DARK; - default: - return light - ? sunken - ? SHADE_BEVEL_GRAD_SEL_LIGHT - : SHADE_BEVEL_GRAD_LIGHT - : sunken - ? SHADE_BEVEL_GRAD_SEL_DARK - : SHADE_BEVEL_GRAD_DARK; + return equal(pos, o.pos) && equal(val, o.val) && equal(alpha, o.alpha); + } + + bool operator<(const GradientStop &o) const + { + return pos +{ + GradientStopCont fix() const + { + GradientStopCont c(*this); + if(size()) + { + GradientStopCont::const_iterator first(c.begin()); + GradientStopCont::reverse_iterator last(c.rbegin()); + + if((*first).pos>0.001) + c.insert(GradientStop(0.0, 1.0)); + if((*last).pos<0.999) + c.insert(GradientStop(1.0, 1.0)); + } + return c; + } +}; +struct Gradient +#else +typedef struct +#endif +{ +#ifdef __cplusplus + Gradient() : border(GB_3D) { } + +#ifdef CONFIG_DIALOG + bool operator==(const Gradient &o) const + { + return border==o.border && stops==o.stops; + } +#endif +#endif + EGradientBorder border; +#ifdef __cplusplus + GradientStopCont stops; +#else + int numStops; + GradientStop *stops; +#endif } +#ifndef __cplusplus +Gradient +#endif +; + +#define USE_CUSTOM_SHADES(A) ((A).customShades[0]>0.00001) +#define USE_CUSTOM_ALPHAS(A) ((A).customAlphas[0]>0.00001) + +#ifdef __cplusplus +typedef std::map GradientCont; +struct Options +#else +typedef struct +#endif +{ + + int version, + contrast, + passwordChar, + highlightFactor, + lighterPopupMenuBgnd, + menuDelay, + sliderWidth, + tabBgnd, + colorSelTab, + expanderHighlight, + crHighlight, + splitterHighlight, + crSize, + gbFactor, + gbLabel; + ERound round; + bool embolden, + highlightTab, + roundAllTabs, + animatedProgress, +#ifdef QTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT + fixParentlessDialogs, +#endif + customMenuTextColor, + menubarMouseOver, + useHighlightForMenu, + shadeMenubarOnlyWhenActive, + thinnerMenuItems, + thinnerBtns, + lvButton, + drawStatusBarFrames, + fillSlider, + roundMbTopOnly, + gtkScrollViews, + stdSidebarButtons, + toolbarTabs, +#ifdef __cplusplus + gtkComboMenus, +/* +#else + setDialogButtonOrder, +*/ +#endif + mapKdeIcons, +#if defined CONFIG_DIALOG || (defined QT_VERSION && (QT_VERSION >= 0x040000)) || !defined __cplusplus + gtkButtonOrder, + fadeLines, +#endif + reorderGtkButtons, + borderMenuitems, + colorMenubarMouseOver, + darkerBorders, + vArrows, + xCheck, + crButton, + smallRadio, + fillProgress, + comboSplitter, + highlightScrollViews, + sunkenScrollViews, + etchEntry, + colorSliderMouseOver, + thinSbarGroove, + flatSbarButtons, + borderSbarGroove, + borderProgress, + popupBorder, + unifySpinBtns, + unifyCombo, + unifySpin, + borderTab, + borderInactiveTab, + doubleGtkComboArrow, + menuIcons, +#if defined CONFIG_DIALOG || (defined QT_VERSION && (QT_VERSION >= 0x040000)) + stdBtnSizes, +#endif +#if defined QT_VERSION && (QT_VERSION >= 0x040000) + xbar, +#endif + forceAlternateLvCols, + invertBotTab, + boldProgress, + coloredTbarMo, + borderSelection, + stripedSbar, + shadePopupMenu; + EFrame groupBox; + EGlow glowProgress; + ELvLines lvLines; + EGradType bgndGrad, + menuBgndGrad; + int menubarHiding, + statusbarHiding, + square, + windowDrag, + windowBorder, + bgndOpacity, + menuBgndOpacity, + dlgOpacity; +#if defined QT_VERSION && (QT_VERSION >= 0x040000) + int dwtSettings; +#endif +#if defined CONFIG_DIALOG || (defined QT_VERSION && (QT_VERSION >= 0x040000)) + int titlebarButtons; + TBCols titlebarButtonColors; + ETitleBarIcon titlebarIcon; +#endif + EStripe stripedProgress; + ESliderStyle sliderStyle; + EMouseOver coloredMouseOver; + ETBarBorder toolbarBorders; + EDefBtnIndicator defBtnIndicator; + ELine sliderThumbs, + handles, + toolbarSeparators, + splitters; + ETabMo tabMouseOver; +/* NOTE: If add an appearance setting, increase the number of custmo gradients to match! */ + EAppearance appearance, + bgndAppearance, + menuBgndAppearance, + menubarAppearance, + menuitemAppearance, + toolbarAppearance, + lvAppearance, + tabAppearance, + activeTabAppearance, + sliderAppearance, + titlebarAppearance, + inactiveTitlebarAppearance, +#ifdef __cplusplus + titlebarButtonAppearance, + dwtAppearance, +#endif + selectionAppearance, + menuStripeAppearance, + progressAppearance, + progressGrooveAppearance, + grooveAppearance, + sunkenAppearance, + sbarBgndAppearance, + sliderFill, + tooltipAppearance; + EShade shadeSliders, + shadeMenubars, + menuStripe, + shadeCheckRadio, + comboBtn, + sortedLv, + crColor, + progressColor; + EColor progressGrooveColor; + EEffect buttonEffect; + EScrollbar scrollbarType; + EFocus focus; + color customMenubarsColor, + customSlidersColor, + customMenuNormTextColor, + customMenuSelTextColor, + customMenuStripeColor, + customCheckRadioColor, + customComboBtnColor, + customSortedLvColor, + customCrBgndColor, + customProgressColor; + EShading shading; +#if defined __cplusplus + EAlign titlebarAlignment; + EEffect titlebarEffect; + bool centerTabText; +#endif + double customShades[NUM_STD_SHADES], + customAlphas[NUM_STD_ALPHAS]; +#ifdef __cplusplus + GradientCont customGradient; +#else + Gradient *customGradient[NUM_CUSTOM_GRAD]; +#endif + QtCImage bgndImage, + menuBgndImage; +#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000)) + /* NOTE: If add any more settings here, need to alter copyOpts/freeOpts/defaultSettings in config_file.c */ + Strings noBgndGradientApps, + noBgndOpacityApps, + noMenuBgndOpacityApps, + noBgndImageApps; +#endif +#ifdef QTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT + Strings noDlgFixApps; +#endif + Strings noMenuStripeApps; +#if defined QT_VERSION && (QT_VERSION >= 0x040000) + Strings menubarApps, + statusbarApps, + useQtFileDialogApps, + windowDragWhiteList, + windowDragBlackList; +#endif + +#ifndef __cplusplus +} Options; +#else +}; +#endif + +#ifdef COMMON_FUNCTIONS + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) ((b) < (a) ? (a) : (b)) +#endif /* Taken from rgb->hsl routines taken from KColor Copyright 2007 Matthew Woehlke @@ -551,8 +1274,8 @@ static inline double h2c(double h, double m1, double m2) static inline void rgbToHsl(double r, double g, double b, double *h, double *s, double *l) { - double min=QTC_MIN(QTC_MIN(r, g), b), - max=QTC_MAX(QTC_MAX(r, g), b); + double min=MIN(MIN(r, g), b), + max=MAX(MAX(r, g), b); *l = 0.5 * (max + min); *s = 0.0; @@ -600,29 +1323,30 @@ static inline void hslToRgb(double h, double s, double l, double *r, double *g, static void rgbToHsv(double r, double g, double b, double *h, double *s, double *v) { - double min=QTC_MIN(QTC_MIN(r, g), b), - max=QTC_MAX(QTC_MAX(r, g), b), + double min=MIN(MIN(r, g), b), + max=MAX(MAX(r, g), b), delta=max - min; *v=max; if(max != 0) *s=delta / max; else - { - /* r=g=b=0 s=0, v is undefined */ *s=0; - *h=-1; - return; - } - if(r == max) - *h=(g - b) / delta; /* between yellow & magenta */ - else if(g == max) - *h=2 + (b - r) / delta; /* between cyan & yellow */ + + if (*s==0.0) + *h = 0.0; else - *h=4 + (r - g) / delta; /* between magenta & cyan */ - *h *= 60; /* degrees */ - if(*h < 0) - *h += 360; + { + if(r == max) + *h=(g - b) / delta; /* between yellow & magenta */ + else if(g == max) + *h=2 + (b - r) / delta; /* between cyan & yellow */ + else if(b == max) + *h=4 + (r - g) / delta; /* between magenta & cyan */ + *h *= 60; /* degrees */ + if(*h < 0) + *h += 360; + } } static void hsvToRgb(double *r, double *g, double *b, double h, double s, double v) @@ -692,10 +1416,26 @@ inline int limit(double c) } #endif +#if defined QT_VERSION && (QT_VERSION >= 0x040000) && !defined QTC_QT_ONLY +#include +#define tint(COLA, COLB, FACTOR) KColorUtils::tint((COLA), (COLB), (FACTOR)) +#define midColor(COLA, COLB) KColorUtils::mix((COLA), (COLB), 0.5) +#else +#include "colorutils.c" +#ifdef __cplusplus +#define tint(COLA, COLB, FACTOR) ColorUtils_tint(&(COLA), &(COLB), (FACTOR)) +#define midColor(COLA, COLB) ColorUtils_mix(&(COLA), &(COLB), 0.5) +#define midColorF(COLA, COLB, FACTOR) ColorUtils_mix(&(COLA), &(COLB), FACTOR-0.5) +#else +#define tint(COLA, COLB, FACTOR) ColorUtils_tint((COLA), (COLB), (FACTOR)) +#define midColor(COLA, COLB) ColorUtils_mix((COLA), (COLB), 0.5) +#endif +#endif + #ifdef __cplusplus -static void shade(const color &ca, color *cb, double k) +static void shade(const Options *opts, const color &ca, color *cb, double k) #else -static void shade(const color *ca, color *cb, double k) +static void shade(const Options *opts, const color *ca, color *cb, double k) #endif { if(equal(k, 1.0)) @@ -709,7 +1449,7 @@ static void shade(const color *ca, color *cb, double k) #endif } else - switch(shading) + switch(opts->shading) { case SHADING_SIMPLE: { @@ -782,11 +1522,39 @@ static void shade(const color *ca, color *cb, double k) cb->red=limit(r*65535.0); cb->green=limit(g*65535.0); cb->blue=limit(b*65535.0); + #endif + break; + } + case SHADING_HCY: + { + #define HCY_FACTOR 0.15 + #if defined QT_VERSION && (QT_VERSION >= 0x040000) && !defined QTC_QT_ONLY + if(k>1.0) + *cb=KColorUtils::lighten(ca, (k*(1+HCY_FACTOR))-1.0, 1.0); + else + *cb=KColorUtils::darken(ca, 1.0-(k*(1-HCY_FACTOR)), 1.0); + #elif defined __cplusplus + if(k>1.0) + *cb=ColorUtils_lighten(&ca, (k*(1+HCY_FACTOR))-1.0, 1.0); + else + *cb=ColorUtils_darken(&ca, 1.0-(k*(1-HCY_FACTOR)), 1.0); + #else + if(k>1.0) + *cb=ColorUtils_lighten(ca, (k*(1+HCY_FACTOR))-1.0, 1.0); + else + *cb=ColorUtils_darken(ca, 1.0-(k*(1-HCY_FACTOR)), 1.0); #endif } } +#if defined __cplusplus && defined QT_VERSION && (QT_VERSION >= 0x040000) + cb->setAlpha(ca.alpha()); +#endif +#ifndef __cplusplus + cb->pixel = ca->pixel; +#endif } +#if (!defined CONFIG_DIALOG) static unsigned char checkBounds(int num) { return num < 0 ? 0 : @@ -835,121 +1603,445 @@ static void adjustPix(unsigned char *data, int numChannels, int w, int h, int st offset+=stride; } } -#endif /* QTC_COMMON_NO_FUNCTIONS */ +#endif + +static void setupGradient(Gradient *grad, EGradientBorder border, int numStops, ...) +{ + va_list ap; + int i; + grad->border=border; +#ifndef __cplusplus + grad->numStops=numStops; + grad->stops=malloc(sizeof(GradientStop) * numStops); +#endif + va_start(ap, numStops); + for(i=0; istops.insert(GradientStop(pos, val)); #else -typedef struct + grad->stops[i].pos=pos; + grad->stops[i].val=val; + grad->stops[i].alpha=1.0; #endif + } + va_end(ap); +} + +static const Gradient * getGradient(EAppearance app, const Options *opts) { - int contrast, - passwordChar; - double highlightFactor; - ERound round; - bool embolden, - lighterPopupMenuBgnd, - highlightTab, - colorSelTab, - animatedProgress, - fixParentlessDialogs, - customMenuTextColor, - menubarMouseOver, - shadeMenubarOnlyWhenActive, - thinnerMenuItems, -#ifndef QTC_PLAIN_FOCUS_ONLY - stdFocus, -#endif - lvLines, - drawStatusBarFrames, - fillSlider, - roundMbTopOnly, - gradientPbGroove, + if(IS_CUSTOM(app)) + { #ifdef __cplusplus - stdSidebarButtons, - gtkScrollViews, - gtkComboMenus, -/* + GradientCont::const_iterator grad(opts->customGradient.find(app)); + + if(grad!=opts->customGradient.end()) + return &((*grad).second); #else - setDialogButtonOrder, -*/ -#endif -#if !defined __cplusplus || defined QTC_CONFIG_DIALOG - mapKdeIcons, -#endif -#if defined QTC_CONFIG_DIALOG || (defined QT_VERSION && (QT_VERSION >= 0x040000)) || !defined __cplusplus - gtkButtonOrder, + Gradient *grad=opts->customGradient[app-APPEARANCE_CUSTOM1]; + + if(grad) + return grad; #endif - borderMenuitems, - colorMenubarMouseOver, - darkerBorders, - vArrows, - xCheck, - framelessGroupBoxes, - inactiveHighlight; - EStripe stripedProgress; - ESliderStyle sliderStyle; - EMouseOver coloredMouseOver; - ETBarBorder toolbarBorders; - EDefBtnIndicator defBtnIndicator; - ELine sliderThumbs, - handles, - toolbarSeparators, - splitters; - EAppearance appearance, - menubarAppearance, - menuitemAppearance, - toolbarAppearance, - lvAppearance, - tabAppearance, - sliderAppearance, - progressAppearance; - EShade shadeSliders, - shadeMenubars, - shadeCheckRadio; - EEffect buttonEffect; - EScrollbar scrollbarType; - color customMenubarsColor, - customSlidersColor, - customMenuNormTextColor, - customMenuSelTextColor, - customCheckRadioColor; - #ifdef QTC_CONFIG_DIALOG - EShading shading; - #endif -#ifndef __cplusplus -} Options; -#else -}; + app=APPEARANCE_RAISED; + } + + { + static Gradient stdGradients[NUM_STD_APP]; + static bool init=false; + + if(!init) + { + setupGradient(&stdGradients[APPEARANCE_FLAT-APPEARANCE_FLAT], GB_3D,2,0.0,1.0,1.0,1.0); + setupGradient(&stdGradients[APPEARANCE_RAISED-APPEARANCE_FLAT], GB_3D_FULL,2,0.0,1.0,1.0,1.0); + setupGradient(&stdGradients[APPEARANCE_DULL_GLASS-APPEARANCE_FLAT], GB_LIGHT,4,0.0,1.05,0.499,0.984,0.5,0.928,1.0,1.0); + setupGradient(&stdGradients[APPEARANCE_SHINY_GLASS-APPEARANCE_FLAT], GB_LIGHT,4,0.0,1.2,0.499,0.984,0.5,0.9,1.0,1.06); + setupGradient(&stdGradients[APPEARANCE_AGUA-APPEARANCE_FLAT], GB_SHINE, 2,0.0,0.6,1.0,1.1); + setupGradient(&stdGradients[APPEARANCE_SOFT_GRADIENT-APPEARANCE_FLAT], GB_3D,2,0.0,1.04,1.0,0.98); + setupGradient(&stdGradients[APPEARANCE_GRADIENT-APPEARANCE_FLAT], GB_3D,2,0.0,1.1,1.0,0.94); + setupGradient(&stdGradients[APPEARANCE_HARSH_GRADIENT-APPEARANCE_FLAT], GB_3D,2,0.0,1.3,1.0,0.925); + setupGradient(&stdGradients[APPEARANCE_INVERTED-APPEARANCE_FLAT], GB_3D,2,0.0,0.93,1.0,1.04); + setupGradient(&stdGradients[APPEARANCE_DARK_INVERTED-APPEARANCE_FLAT], GB_NONE,3,0.0,0.8,0.7,0.95,1.0,1.0); + setupGradient(&stdGradients[APPEARANCE_SPLIT_GRADIENT-APPEARANCE_FLAT], GB_3D,4,0.0,1.06,0.499,1.004,0.5,0.986,1.0,0.92); + setupGradient(&stdGradients[APPEARANCE_BEVELLED-APPEARANCE_FLAT], GB_3D,4,0.0,1.05,0.1,1.02,0.9,0.985,1.0,0.94); + setupGradient(&stdGradients[APPEARANCE_LV_BEVELLED-APPEARANCE_FLAT], GB_3D,3,0.0,1.00,0.85,1.0,1.0,0.90); + setupGradient(&stdGradients[APPEARANCE_AGUA_MOD-APPEARANCE_FLAT], GB_NONE,3,0.0,1.5,0.49,0.85,1.0,1.3); + setupGradient(&stdGradients[APPEARANCE_LV_AGUA-APPEARANCE_FLAT], GB_NONE,4,0.0,0.98,0.35,0.95,0.4,0.93,1.0,1.15); + init=true; + } + + return &stdGradients[app-APPEARANCE_FLAT]; + } + + return 0L; /* Will never happen! */ +} + #endif -#if defined QTC_COMMON_FUNCTIONS && !defined QTC_CONFIG_DIALOG +#if defined COMMON_FUNCTIONS && !defined CONFIG_DIALOG + +#ifdef __cplusplus +static EAppearance widgetApp(EWidget w, const Options *opts, bool active=true) +#else static EAppearance widgetApp(EWidget w, const Options *opts) +#endif { switch(w) { + case WIDGET_SB_BGND: + return opts->sbarBgndAppearance; case WIDGET_LISTVIEW_HEADER: return opts->lvAppearance; case WIDGET_SB_BUTTON: case WIDGET_SLIDER: case WIDGET_SB_SLIDER: return opts->sliderAppearance; + case WIDGET_FILLED_SLIDER_TROUGH: + return opts->sliderFill; case WIDGET_TAB_TOP: case WIDGET_TAB_BOT: return opts->tabAppearance; case WIDGET_MENU_ITEM: return opts->menuitemAppearance; case WIDGET_PROGRESSBAR: +#ifndef __cplusplus + case WIDGET_ENTRY_PROGRESSBAR: +#endif return opts->progressAppearance; + case WIDGET_PBAR_TROUGH: + return opts->progressGrooveAppearance; + case WIDGET_SELECTION: + return opts->selectionAppearance; +#ifdef __cplusplus + case WIDGET_DOCK_WIDGET_TITLE: + return opts->dwtAppearance; + case WIDGET_MDI_WINDOW: + case WIDGET_MDI_WINDOW_TITLE: + return active ? opts->titlebarAppearance : opts->inactiveTitlebarAppearance; + case WIDGET_MDI_WINDOW_BUTTON: + return opts->titlebarButtonAppearance; + case WIDGET_DIAL: + return IS_FLAT(opts->appearance) ? APPEARANCE_RAISED : APPEARANCE_SOFT_GRADIENT; +#endif + case WIDGET_TROUGH: case WIDGET_SLIDER_TROUGH: - return APPEARANCE_FLAT==opts->appearance || APPEARANCE_RAISED==opts->appearance - ? APPEARANCE_FLAT : APPEARANCE_GRADIENT; + return opts->grooveAppearance; +#ifndef __cplusplus + case WIDGET_SPIN_UP: + case WIDGET_SPIN_DOWN: +#endif + case WIDGET_SPIN: + return MODIFY_AGUA(opts->appearance); default: break; } return opts->appearance; }; + +#define MIN_ROUND_FULL_SIZE 8 +#ifdef __cplusplus +#define MIN_ROUND_EXTRA_SIZE(W) (WIDGET_SPIN==(W) ? 7 : 14) +#else +#define MIN_ROUND_EXTRA_SIZE(W) (WIDGET_SPIN_UP==(W) || WIDGET_SPIN_DOWN==(W) || WIDGET_SPIN==(W) ? 7 : 14) +#endif +#define MIN_ROUND_MAX_HEIGHT 12 +#define MIN_ROUND_MAX_WIDTH 24 + +#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000)) + +#if defined __cplusplus +#define EXTRA_INNER_RADIUS 3.5 +#define EXTRA_OUTER_RADIUS 4.5 +#define EXTRA_ETCH_RADIUS 5.5 +#define FULL_INNER_RADIUS 1.5 +#define FULL_OUTER_RADIUS 2.5 +#define FULL_ETCH_RADIUS 3.5 + +#if defined QT_VERSION && (QT_VERSION < 0x040600) +#define SLIGHT_INNER_RADIUS 0.5 +#define SLIGHT_OUTER_RADIUS 1.5 +#define SLIGHT_ETCH_RADIUS 2.5 +#else +#define SLIGHT_INNER_RADIUS 0.75 +#define SLIGHT_OUTER_RADIUS 1.75 +#define SLIGHT_ETCH_RADIUS 2.75 #endif +#else +#define EXTRA_INNER_RADIUS 4 +#define EXTRA_OUTER_RADIUS 5 +#define EXTRA_ETCH_RADIUS 6 +#define FULL_INNER_RADIUS 2 +#define FULL_OUTER_RADIUS 3 +#define FULL_ETCH_RADIUS 4 +#define SLIGHT_INNER_RADIUS 1 +#define SLIGHT_OUTER_RADIUS 2 +#define SLIGHT_ETCH_RADIUS 3 #endif + +#define MAX_RADIUS_INTERNAL 9.0 +#define MAX_RADIUS_EXTERNAL (MAX_RADIUS_INTERNAL+2.0) + +typedef enum +{ + RADIUS_SELECTION, + RADIUS_INTERNAL, + RADIUS_EXTERNAL, + RADIUS_ETCH +} ERadius; + +#ifdef __cplusplus +#define IS_MAX_ROUND_WIDGET(A) \ + (WIDGET_STD_BUTTON==A || WIDGET_DEF_BUTTON==A /*|| WIDGET_MENU_BUTTON==A*/) +#define IS_EXTRA_ROUND_WIDGET(A) \ + (A!=WIDGET_MENU_ITEM && A!=WIDGET_TAB_FRAME && A!=WIDGET_PBAR_TROUGH && A!=WIDGET_PROGRESSBAR && \ + A!=WIDGET_MDI_WINDOW && A!=WIDGET_MDI_WINDOW_TITLE) +#else +#define IS_MAX_ROUND_WIDGET(A) \ + (WIDGET_STD_BUTTON==A || WIDGET_DEF_BUTTON==A || WIDGET_TOGGLE_BUTTON==A /*|| WIDGET_MENU_BUTTON==A*/) +#define IS_EXTRA_ROUND_WIDGET(A) \ + (A!=WIDGET_MENU_ITEM && A!=WIDGET_TAB_FRAME && A!=WIDGET_PBAR_TROUGH && A!=WIDGET_PROGRESSBAR) +#endif + +#define CAN_EXTRA_ROUND(MOD) \ + (IS_EXTRA_ROUND_WIDGET(widget) && \ + (IS_SLIDER(widget) || WIDGET_TROUGH==widget || \ + ( ( (w>(MIN_ROUND_EXTRA_SIZE(widget)+MOD)) || (WIDGET_NO_ETCH_BTN==widget || WIDGET_MENU_BUTTON==widget) ) &&\ + (h>(MIN_ROUND_EXTRA_SIZE(widget)+MOD))))) +#define CAN_FULL_ROUND(MOD) (w>(MIN_ROUND_FULL_SIZE+MOD) && h>(MIN_ROUND_FULL_SIZE+MOD)) + +// **NOTE** MUST KEEP IN SYNC WITH getRadius/RADIUS_ETCH !!! +ERound getWidgetRound(const Options *opts, int w, int h, EWidget widget) +{ + ERound r=opts->round; + + if( ((WIDGET_PBAR_TROUGH==widget || WIDGET_PROGRESSBAR==widget) && (opts->square&SQUARE_PROGRESS)) || + (WIDGET_ENTRY==widget && (opts->square&SQUARE_ENTRY)) ) + return ROUND_NONE; + + if((WIDGET_CHECKBOX==widget || WIDGET_FOCUS==widget) && ROUND_NONE!=r) + r=ROUND_SLIGHT; + +#if defined __cplusplus && (defined QT_VERSION && (QT_VERSION >= 0x040000)) + if((WIDGET_MDI_WINDOW_BUTTON==widget && (opts->titlebarButtons&TITLEBAR_BUTTON_ROUND)) || + WIDGET_RADIO_BUTTON==widget || WIDGET_DIAL==widget) + return ROUND_MAX; +#endif +#ifndef __cplusplus + if(WIDGET_RADIO_BUTTON==widget) + return ROUND_MAX; +#endif + +#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000)) + if(WIDGET_SLIDER==widget && + (SLIDER_ROUND==opts->sliderStyle || SLIDER_ROUND_ROTATED==opts->sliderStyle || SLIDER_CIRCULAR==opts->sliderStyle)) + return ROUND_MAX; +#endif + + switch(r) + { + case ROUND_MAX: + if(IS_SLIDER(widget) || WIDGET_TROUGH==widget || + (w>(MIN_ROUND_MAX_WIDTH+2) && h>(MIN_ROUND_MAX_HEIGHT+2) && IS_MAX_ROUND_WIDGET(widget))) + return ROUND_MAX; + case ROUND_EXTRA: + if(CAN_EXTRA_ROUND(2)) + return ROUND_EXTRA; + case ROUND_FULL: + if(CAN_FULL_ROUND(2)) + return ROUND_FULL; + case ROUND_SLIGHT: + return ROUND_SLIGHT; + case ROUND_NONE: + return ROUND_NONE; + } + + return ROUND_NONE; +} + +static double getRadius(const Options *opts, int w, int h, EWidget widget, ERadius rad) +{ + ERound r=opts->round; + + if((WIDGET_CHECKBOX==widget || WIDGET_FOCUS==widget) && ROUND_NONE!=r) + r=ROUND_SLIGHT; + + if( ((WIDGET_PBAR_TROUGH==widget || WIDGET_PROGRESSBAR==widget) && (opts->square&SQUARE_PROGRESS)) || + (WIDGET_ENTRY==widget && (opts->square&SQUARE_ENTRY)) ) + return 0.0; + +#if defined __cplusplus && (defined QT_VERSION && (QT_VERSION >= 0x040000)) + if((WIDGET_MDI_WINDOW_BUTTON==widget && (opts->titlebarButtons&TITLEBAR_BUTTON_ROUND)) || + WIDGET_RADIO_BUTTON==widget || WIDGET_DIAL==widget) + return (w>h ? h : w)/2.0; +#endif +#ifndef __cplusplus + if(WIDGET_RADIO_BUTTON==widget) + return (w>h ? h : w)/2.0; +#endif + +#if !defined __cplusplus || (defined QT_VERSION && (QT_VERSION >= 0x040000)) + if(WIDGET_SLIDER==widget && + (SLIDER_ROUND==opts->sliderStyle || SLIDER_ROUND_ROTATED==opts->sliderStyle || SLIDER_CIRCULAR==opts->sliderStyle)) + return (w>h ? h : w)/2.0; +#endif + + if(RADIUS_EXTERNAL==rad && !opts->fillProgress && (WIDGET_PROGRESSBAR==widget +#ifndef __cplusplus + || WIDGET_ENTRY_PROGRESSBAR==widget +#endif + )) + rad=RADIUS_INTERNAL; + + switch(rad) + { + case RADIUS_SELECTION: + switch(r) + { + case ROUND_MAX: + case ROUND_EXTRA: + if(/* (WIDGET_RUBBER_BAND==widget && w>14 && h>14) || */(w>48 && h>48)) + return 6.0; + case ROUND_FULL: +// if( /*(WIDGET_RUBBER_BAND==widget && w>11 && h>11) || */(w>48 && h>48)) +// return 3.0; + if(w>MIN_ROUND_FULL_SIZE && h>MIN_ROUND_FULL_SIZE) + return 3.0; + case ROUND_SLIGHT: + return 2.0; + case ROUND_NONE: + return 0; + } + case RADIUS_INTERNAL: + switch(r) + { + case ROUND_MAX: + if(IS_SLIDER(widget) || WIDGET_TROUGH==widget) + { + double r=((w>h ? h : w)-(WIDGET_SLIDER==widget ? 1 : 0))/2.0; + return r>MAX_RADIUS_INTERNAL ? MAX_RADIUS_INTERNAL : r; + } + if(w>(MIN_ROUND_MAX_WIDTH-2) && h>(MIN_ROUND_MAX_HEIGHT-2) && IS_MAX_ROUND_WIDGET(widget)) + { + double r=((w>h ? h : w)-2.0)/2.0; + return r>9.5 ? 9.5 : r; + } + case ROUND_EXTRA: + if(CAN_EXTRA_ROUND(-2)) + return EXTRA_INNER_RADIUS; + case ROUND_FULL: + if(CAN_FULL_ROUND(-2)) + return FULL_INNER_RADIUS; + case ROUND_SLIGHT: + return SLIGHT_INNER_RADIUS; + case ROUND_NONE: + return 0; + } + case RADIUS_EXTERNAL: + switch(r) + { + case ROUND_MAX: + if(IS_SLIDER(widget) || WIDGET_TROUGH==widget) + { + double r=((w>h ? h : w)-(WIDGET_SLIDER==widget ? 1 : 0))/2.0; + return r>MAX_RADIUS_EXTERNAL ? MAX_RADIUS_EXTERNAL : r; + } + if(w>MIN_ROUND_MAX_WIDTH && h>MIN_ROUND_MAX_HEIGHT && IS_MAX_ROUND_WIDGET(widget)) + { + double r=((w>h ? h : w)-2.0)/2.0; + return r>10.5 ? 10.5 : r; + } + case ROUND_EXTRA: + if(CAN_EXTRA_ROUND(0)) + return EXTRA_OUTER_RADIUS; + case ROUND_FULL: + if(CAN_FULL_ROUND(0)) + return FULL_OUTER_RADIUS; + case ROUND_SLIGHT: + return SLIGHT_OUTER_RADIUS; + case ROUND_NONE: + return 0; + } + case RADIUS_ETCH: + // **NOTE** MUST KEEP IN SYNC WITH getWidgetRound !!! + switch(r) + { + case ROUND_MAX: + if(IS_SLIDER(widget) || WIDGET_TROUGH==widget) + { + double r=((w>h ? h : w)-(WIDGET_SLIDER==widget ? 1 : 0))/2.0; + return r>MAX_RADIUS_EXTERNAL ? MAX_RADIUS_EXTERNAL : r; + } + if(w>(MIN_ROUND_MAX_WIDTH+2) && h>(MIN_ROUND_MAX_HEIGHT+2) && IS_MAX_ROUND_WIDGET(widget)) + { + double r=((w>h ? h : w)-2.0)/2.0; + return r>11.5 ? 11.5 : r; + } + case ROUND_EXTRA: + if(CAN_FULL_ROUND(2)) + return EXTRA_ETCH_RADIUS; + case ROUND_FULL: + if(w>(MIN_ROUND_FULL_SIZE+2) && h>(MIN_ROUND_FULL_SIZE+2)) + return FULL_ETCH_RADIUS; + case ROUND_SLIGHT: + return SLIGHT_ETCH_RADIUS; + case ROUND_NONE: + return 0; + } + } + + return 0; +} + +static double qtcRingAlpha[3]={0.125, 0.125, 0.5}; + +static void calcRingAlphas(const color *bgnd) +{ +#ifdef __cplusplus + double r=bgnd->red()/255.0, + g=bgnd->green()/255.0, + b=bgnd->blue()/255.0, +#else + double r=bgnd->red/65535.0, + g=bgnd->green/65535.0, + b=bgnd->blue/65535.0, +#endif + h=0, + s=0, + v=0; + rgbToHsv(r, g, b, &h, &s, &v); + qtcRingAlpha[0]=v*0.26; + qtcRingAlpha[1]=v*0.14; + qtcRingAlpha[2]=v*0.55; +} + +#define BGND_SHINE_SIZE 300 +#define BGND_SHINE_STEPS 8 + +static double shineAlpha(const color *bgnd) +{ +#ifdef __cplusplus + double r=bgnd->red()/255.0, + g=bgnd->green()/255.0, + b=bgnd->blue()/255.0, +#else + double r=bgnd->red/65535.0, + g=bgnd->green/65535.0, + b=bgnd->blue/65535.0, +#endif + h=0, + s=0, + v=0; + rgbToHsv(r, g, b, &h, &s, &v); + return v*0.8; +} + +#endif + +#endif + +#endif // __COMMON_H__ -- cgit v1.2.1