~ubuntu-branches/ubuntu/trusty/gtk2-engines-oxygen/trusty-proposed

« back to all changes in this revision

Viewing changes to src/oxygenstylewrapper.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-07-20 15:38:45 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20120720153845-57jzms7fq759z9lg
Tags: 1.3.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "oxygenmetrics.h"
41
41
#include "oxygenstyle.h"
42
42
#include "oxygenwindowmanager.h"
 
43
#include "oxygencolorutils.h"
43
44
 
44
45
#include <iostream>
45
46
namespace Oxygen
116
117
        #endif
117
118
 
118
119
        const Gtk::Detail d( detail );
 
120
 
 
121
        // Render tab background
 
122
        if(Style::instance().settings().applicationName().isOpenOffice() && GTK_IS_NOTEBOOK(widget))
 
123
        {
 
124
            Style::instance().renderWindowBackground(window,widget,NULL,x,y,w,h);
 
125
            return;
 
126
        }
 
127
 
119
128
        if( d.isBase() || d.isEventBox() || (d.isNull() && Gtk::g_object_is_a( G_OBJECT( widget ), "ShellWindow" ) ) )
120
129
        {
121
130
 
129
138
                return;
130
139
            }
131
140
 
132
 
            // for openoffice we fill the background with flat color unless it is a toolbar
133
 
            if( Style::instance().settings().applicationName().isOpenOffice( widget ) )
134
 
            {
135
 
                if( !GTK_IS_TOOLBAR( widget ) )
136
 
                { Style::instance().fill( window, clipRect, x, y, w, h, Palette::Window ); }
137
 
 
138
 
                return;
139
 
            }
140
 
 
141
141
            // do nothing for mozilla, acrobat, gnome applets, and other hint-specific windows
142
142
            if(
143
143
                Style::instance().settings().applicationName().useFlatBackground( widget ) ||
178
178
            // render background gradient
179
179
            StyleOptions options;
180
180
            options._customColors.insert( Palette::Window, Gtk::gdk_get_color( style->bg[state] ) );
181
 
            const bool success( Style::instance().renderWindowBackground( window, clipRect, x, y, w, h, options ) );
 
181
            const bool success( Style::instance().renderWindowBackground( window, widget, clipRect, x, y, w, h, options ) );
182
182
 
183
183
            // if widget has flat parent, store in flatWidget engine so that children gets the right background nonetheless
184
184
            if( success && Style::instance().animations().flatWidgetEngine().flatParent( widget ) )
248
248
        } else if( d.isTrough() ) {
249
249
 
250
250
            if( GTK_IS_PROGRESS_BAR( widget ) )
251
 
            { return; }
 
251
            {
 
252
                if( Style::instance().settings().applicationName().isOpenOffice() )
 
253
                {
 
254
                    StyleOptions options;
 
255
                    if( Gtk::gtk_widget_is_vertical( widget ) ) options |= Vertical;
 
256
                    Style::instance().renderProgressBarHole( window, clipRect, x,y,w,h, options );
 
257
                }
 
258
                return;
 
259
            }
252
260
 
253
261
        } else if( d.isTooltip() && Style::instance().settings().tooltipDrawStyledFrames() ) {
254
262
 
478
486
            const bool isChromeAddressBar( widget &&
479
487
                    GTK_IS_HBOX(widget) &&
480
488
                    Style::instance().settings().applicationName().isGoogleChrome() );
 
489
            if(Style::instance().settings().applicationName().isOpenOffice())
 
490
            {
 
491
                x+=2;
 
492
                w-=4;
 
493
                y+=1;
 
494
                h-=2;
 
495
            }
481
496
 
482
497
            StyleOptions options( widget, state, shadow );
483
498
            if(
549
564
                y -= yOffset;
550
565
                h += 2*yOffset;
551
566
 
552
 
                // for openoffice only draw solid window background
553
 
                // the rest of the spinbutton is painted on top, in draw_box and draw_shadow
 
567
                // for libreoffice do nothing
554
568
                if( Style::instance().settings().applicationName().isOpenOffice( widget ) )
555
 
                {
556
 
 
557
 
                    Style::instance().fill( window, clipRect, x, y, w, h, Palette::Window );
558
 
                    return;
559
 
                }
 
569
                { return; }
560
570
 
561
571
                if(
562
572
                    Style::instance().animations().hoverEngine().contains( widget ) &&
657
667
    {
658
668
 
659
669
        #if OXYGEN_DEBUG
660
 
        std::cerr << "Oxygen::processTabCloseButton" << std::endl;
 
670
        std::cerr << "Oxygen::processTabCloseButton("<<widget<<","<<state <<")"<< std::endl;
661
671
        #endif
662
672
 
 
673
        if(!widget)
 
674
            return 0L;
 
675
 
663
676
        switch (state)
664
677
        {
665
678
            case GTK_STATE_NORMAL:
720
733
        Style::instance().sanitizeSize( window, w, h );
721
734
        const Gtk::Detail d( detail );
722
735
 
723
 
        // OpenOffice doesn't call draw_box, so we have to draw it here to make steppers look not like slabs.
 
736
        // Don't draw anything for OpenOffice or steppers will look like slabs.
724
737
        if( d.isStepper() && Style::instance().settings().applicationName().isOpenOffice( widget ))
725
 
        {
726
 
            Style::instance().fill( window, clipRect, x, y, w-2, h-1, Palette::Window );
727
 
            return;
728
 
        }
 
738
        { return; }
 
739
        // Don't render window bg here because it's redundant and leads to problems with bg gradient behind buttons
 
740
        if( GTK_IS_WINDOW(widget) && Style::instance().settings().applicationName().isOpenOffice( widget ))
 
741
        { return; }
729
742
 
730
743
        GtkWidget* parent(0L);
731
744
        if( d.isInfoBar() )
890
903
                )
891
904
            {
892
905
 
 
906
                {
 
907
                    // Set minimum combobox button height if it's smaller
 
908
                    GtkAllocation alloc;
 
909
                    gtk_widget_get_allocation(widget,&alloc);
 
910
                    gtk_widget_get_size_request(widget,&alloc.width,NULL);
 
911
                    if(alloc.height<22)
 
912
                        gtk_widget_set_size_request(widget,alloc.width,22);
 
913
                }
893
914
                // combobox buttons
894
915
                const bool reversed( Gtk::gtk_widget_layout_is_reversed( widget ) );
895
916
 
1030
1051
            // flat buttons
1031
1052
            bool useWidgetState( true );
1032
1053
            AnimationData data;
1033
 
            if( widget && Gtk::gtk_button_is_flat( widget ) )
 
1054
            // Such small buttons should rather be flat for OpenOffice (the only ones present there seem
 
1055
            // to be the navigation buttons under vertical scrollbar in main window)
 
1056
            bool ooFlat(Style::instance().settings().applicationName().isOpenOffice() && w<20 && h<20 && w==h);
 
1057
            // LibO formula entry expand expand button is very small, would look better if rendered flat
 
1058
            bool ooFormulaExpand(Style::instance().settings().applicationName().isOpenOffice() && w==16);
 
1059
 
 
1060
            if( (widget && Gtk::gtk_button_is_flat( widget )) || ooFlat || ooFormulaExpand )
1034
1061
            {
1035
1062
 
1036
1063
                // set button as flat and disable focus
1037
1064
                options |= Flat;
1038
1065
                options &= ~Focus;
1039
1066
 
1040
 
                // register to Hover engine and check state
1041
 
                Style::instance().animations().hoverEngine().registerWidget( widget );
1042
 
                if( (options&Hover) )  Style::instance().animations().hoverEngine().setHovered( widget, true );
1043
 
                else if( Style::instance().animations().hoverEngine().hovered( widget ) ) options |= Hover;
1044
 
 
1045
 
                // register to ToolBarState engine
1046
 
                ToolBarStateEngine& engine( Style::instance().animations().toolBarStateEngine() );
1047
 
                GtkWidget* parent( 0L );
1048
 
 
1049
 
                bool toolPalette(false);
1050
 
                #if GTK_CHECK_VERSION(2,20,0)
1051
 
                toolPalette=Gtk::gtk_widget_find_parent( widget, GTK_TYPE_TOOL_PALETTE );
1052
 
                #endif
1053
 
 
1054
 
                if( !toolPalette && (parent = engine.findParent( widget ) ) )
 
1067
                if(!Style::instance().settings().applicationName().isOpenOffice())
1055
1068
                {
1056
 
 
1057
 
                    // register child
1058
 
                    engine.registerChild( parent, widget, options&Hover );
1059
 
                    useWidgetState = false;
1060
 
 
1061
 
                    if( engine.animatedRectangleIsValid( parent ) && !(options&Sunken) ) {
1062
 
 
1063
 
                        return;
1064
 
 
1065
 
                    } if( engine.widget( parent, AnimationCurrent ) == widget ) {
1066
 
 
1067
 
                        data = engine.animationData( parent, AnimationCurrent );
1068
 
 
1069
 
                        if( engine.isLocked( parent ) ) options |= Hover;
1070
 
 
1071
 
                    } else if( (options & Sunken ) && engine.widget( parent, AnimationPrevious ) == widget ) {
1072
 
 
1073
 
                        data = engine.animationData( parent, AnimationPrevious );
 
1069
                    // register to Hover engine and check state
 
1070
                    Style::instance().animations().hoverEngine().registerWidget( widget );
 
1071
                    if( (options&Hover) )  Style::instance().animations().hoverEngine().setHovered( widget, true );
 
1072
                    else if( Style::instance().animations().hoverEngine().hovered( widget ) ) options |= Hover;
 
1073
 
 
1074
                    // register to ToolBarState engine
 
1075
                    ToolBarStateEngine& engine( Style::instance().animations().toolBarStateEngine() );
 
1076
                    GtkWidget* parent( 0L );
 
1077
 
 
1078
                    bool toolPalette(false);
 
1079
                    #if GTK_CHECK_VERSION(2,20,0)
 
1080
                    toolPalette=Gtk::gtk_widget_find_parent( widget, GTK_TYPE_TOOL_PALETTE );
 
1081
                    #endif
 
1082
 
 
1083
                    if( !toolPalette && (parent = engine.findParent( widget ) ) )
 
1084
                    {
 
1085
 
 
1086
                        // register child
 
1087
                        engine.registerChild( parent, widget, options&Hover );
 
1088
                        useWidgetState = false;
 
1089
 
 
1090
                        if( engine.animatedRectangleIsValid( parent ) && !(options&Sunken) ) {
 
1091
 
 
1092
                            return;
 
1093
 
 
1094
                        } if( engine.widget( parent, AnimationCurrent ) == widget ) {
 
1095
 
 
1096
                            data = engine.animationData( parent, AnimationCurrent );
 
1097
 
 
1098
                            if( engine.isLocked( parent ) ) options |= Hover;
 
1099
 
 
1100
                        } else if( (options & Sunken ) && engine.widget( parent, AnimationPrevious ) == widget ) {
 
1101
 
 
1102
                            data = engine.animationData( parent, AnimationPrevious );
 
1103
 
 
1104
                        }
1074
1105
 
1075
1106
                    }
1076
 
 
 
1107
                }
 
1108
                else if(ooFlat)
 
1109
                {
 
1110
                    // Fill with bottom color because the buttons are most likely at the bottom
 
1111
                    Cairo::Context context(window);
 
1112
                    cairo_set_source(context,ColorUtils::backgroundBottomColor( Style::instance().settings().palette().color( Palette::Window )));
 
1113
                    cairo_rectangle(context,x,y,w,h);
 
1114
                    cairo_fill(context);
1077
1115
                }
1078
1116
 
1079
1117
            }
1082
1120
            if( useWidgetState )
1083
1121
            { data = Style::instance().animations().widgetStateEngine().get( widget, options ); }
1084
1122
 
 
1123
            if(Style::instance().settings().applicationName().isOpenOffice())
 
1124
                Style::instance().renderWindowBackground(window,clipRect,x,y,w,h);
1085
1125
            // render
1086
1126
            Style::instance().renderButtonSlab( window, clipRect, x, y, w, h, options, data );
1087
1127
 
1381
1421
 
1382
1422
                if(Style::instance().settings().applicationName().isOpenOffice( widget ) )
1383
1423
                {
1384
 
 
1385
 
                    // OpenOffice doesn't call draw_box to draw background
1386
 
                    Cairo::Context context(window,clipRect);
1387
 
                    cairo_set_source(context,Gtk::gdk_get_color(style->bg[GTK_STATE_NORMAL]));
1388
 
                    cairo_paint(context);
1389
 
 
1390
1424
                    // adjust scrollbar hole since it has wrong geometry in OOo
1391
 
                    y-=1; h+=1;
 
1425
                    y-=1;
1392
1426
                }
1393
1427
 
1394
1428
 
1399
1433
 
1400
1434
                if(Style::instance().settings().applicationName().isOpenOffice( widget ) )
1401
1435
                {
1402
 
                    // OpenOffice doesn't call draw_box to draw background
1403
 
                    Cairo::Context context(window,clipRect);
1404
 
                    cairo_set_source(context,Gtk::gdk_get_color(style->bg[GTK_STATE_NORMAL]));
1405
 
                    cairo_paint(context);
1406
 
 
1407
1436
                    // adjust scrollbar hole since it has wrong geometry in OOo
1408
1437
                    x-=2; w+=1;
1409
1438
                }
1420
1449
 
1421
1450
            if( Style::instance().settings().applicationName().isOpenOffice( widget ) )
1422
1451
            {
1423
 
 
1424
 
                // adjust rect
1425
 
                y+=1;
1426
 
                h-=2;
1427
 
                x-=1;
1428
 
                w+=1;
1429
 
 
1430
 
                // also first draw solid window background
1431
 
                Style::instance().fill( window, clipRect, x, y, w, h, Palette::Window );
1432
 
 
 
1452
                // Do nothing for openoffice
 
1453
                return;
1433
1454
            } else {
1434
1455
 
1435
1456
                options |= NoFill;
1491
1512
            }
1492
1513
 
1493
1514
 
 
1515
        } else if( d.isSpinButtonUp() || d.isSpinButtonDown() )
 
1516
        {
 
1517
 
 
1518
            if( Style::instance().settings().applicationName().isOpenOffice( widget ) )
 
1519
            {
 
1520
                if(state==GTK_STATE_ACTIVE)
 
1521
                    state=GTK_STATE_NORMAL;
 
1522
                ColorUtils::Rgba background( Gtk::gdk_get_color( style->base[state] ) );
 
1523
                Cairo::Context context( window, clipRect );
 
1524
                StyleOptions options( NoFill );
 
1525
                options|=Blend;
 
1526
                TileSet::Tiles tiles( TileSet::Ring );
 
1527
                tiles &= ~TileSet::Left;
 
1528
                {
 
1529
                    int W(w-4), Y(y),H(h);
 
1530
                    if(d.isSpinButtonUp())
 
1531
                    {
 
1532
                        tiles &= ~TileSet::Bottom;
 
1533
                        Y+=1;
 
1534
                    }
 
1535
                    else
 
1536
                    {
 
1537
                        tiles &= ~TileSet::Top;
 
1538
                        H-=2;
 
1539
                    }
 
1540
 
 
1541
                    cairo_rounded_rectangle( context, x, Y, W, H, 2, CornersRight );
 
1542
                    cairo_set_source( context, background );
 
1543
                    cairo_fill( context );
 
1544
                }
 
1545
 
 
1546
                const AnimationData data( Style::instance().animations().widgetStateEngine().get( widget, options, AnimationHover|AnimationFocus, AnimationFocus ) );
 
1547
                if(d.isSpinButtonUp())
 
1548
                    Style::instance().renderHole( window, clipRect, x-7, y, w+5, h+6, options, data, tiles );
 
1549
                else
 
1550
                    Style::instance().renderHole( window, clipRect, x-6, y-7, w+4, h+7, options, data, tiles );
 
1551
                return;
 
1552
            }
 
1553
 
 
1554
 
1494
1555
        } else if( d.isSpinButtonArrow() ) {
1495
1556
 
1496
1557
            return;
1524
1585
                    clipRect->y += delta_y; clipRect->height -= 2*delta_y;
1525
1586
                }
1526
1587
 
 
1588
                if(Style::instance().settings().applicationName().isOpenOffice())
 
1589
                {
 
1590
                    ++x;
 
1591
                    w-=2;
 
1592
                }
1527
1593
                // need to adjust rect and clip to handle unexpected x/y thickness values
1528
1594
                Style::instance().renderProgressBarHandle( window, clipRect, x, y, w, h, options );
1529
1595
 
1531
1597
 
1532
1598
                // most likely it's progressbar in the list
1533
1599
                // FIXME: is it always the case ? Should we check on TREE_VIEW, CELL_VIEW, like done with scrollbar hole ?
1534
 
                Style::instance().renderProgressBarHandle( window, clipRect, x-1, y, w+2, h, options );
 
1600
                Style::instance().renderProgressBarHandle( window, clipRect, x-1, y, w+1, h, options );
1535
1601
 
1536
1602
            }
1537
1603
 
1662
1728
 
1663
1729
                    Style::instance().animations().widgetSizeEngine().setAlpha(parent, true);
1664
1730
                }
1665
 
 
 
1731
#if !ENABLE_INNER_SHADOWS_HACK
1666
1732
                // also sets inner list mask
1667
1733
                if( GtkWidget* child = gtk_bin_get_child( GTK_BIN( widget ) ) )
1668
1734
                {
1681
1747
                    gdk_pixmap_unref( mask );
1682
1748
 
1683
1749
                }
1684
 
 
 
1750
#endif
1685
1751
            }
1686
1752
 
1687
1753
            // menu background and float frame
1878
1944
 
1879
1945
                }
1880
1946
 
 
1947
                // Do nothing for OpenOffice
 
1948
                if(d.isEntry() && Style::instance().settings().applicationName().isOpenOffice())
 
1949
                    return;
1881
1950
                // OpenOffice or Chromium address bar
1882
 
                if( Style::instance().settings().applicationName().isOpenOffice( widget )||
1883
 
                    (widget && GTK_IS_HBOX(widget) && Style::instance().settings().applicationName().isGoogleChrome()) )
 
1951
                if( (widget && GTK_IS_HBOX(widget) && Style::instance().settings().applicationName().isGoogleChrome()) ||
 
1952
                        Style::instance().settings().applicationName().isOpenOffice() )
1884
1953
                {
1885
1954
 
1886
1955
                    if( d.isEntry() )
2010
2079
 
2011
2080
            // it's likely progressbar hole
2012
2081
            // FIXME: is it enough to check for TreeView? is shadow_in the only possible case?
2013
 
            Style::instance().renderProgressBarHole( window, clipRect, x-2, y, w+4, h, StyleOptions() );
 
2082
            Style::instance().renderProgressBarHole( window, clipRect, x-2, y, w+3, h, StyleOptions() );
2014
2083
 
 
2084
        } else if(Style::instance().settings().applicationName().isOpenOffice() && x==0 && y==0)
 
2085
        {
 
2086
            StyleOptions options(Blend);
 
2087
            if( Gtk::gdk_default_screen_is_composited() ) options |= Alpha;
 
2088
            Style::instance().drawFloatFrame( window, clipRect, x,y,w,h,options);
 
2089
            return;
2015
2090
        } else if( shadow == GTK_SHADOW_IN && !Gtk::gtk_parent_statusbar( widget ) ) {
2016
2091
 
2017
2092
            if( GTK_IS_FRAME( widget ) )
2164
2239
 
2165
2240
            Style::instance().renderCheckBox( window, clipRect, x, y, w, h, shadow, options, data );
2166
2241
 
2167
 
        } else if( d.isCheck() && GTK_IS_CHECK_MENU_ITEM( widget ) ) {
 
2242
        } else if( d.isCheck() && ( GTK_IS_CHECK_MENU_ITEM( widget ) || /* for LibreOffice */GTK_IS_MENU_ITEM( widget ) ) ) {
 
2243
 
 
2244
            // Fix cliprect for LibreOffice
 
2245
            if( clipRect && GTK_IS_MENU_ITEM(widget))
 
2246
            { ++clipRect->width; }
2168
2247
 
2169
2248
            StyleOptions options( widget, state, shadow );
2170
2249
            options |= (Blend|Flat|NoFill);
2250
2329
                    options &= ~(Hover|Focus);
2251
2330
                    x-=1;
2252
2331
                    y-=1;
 
2332
                    if(Style::instance().settings().applicationName().isOpenOffice())
 
2333
                    {
 
2334
                        // Override the sizes passed by LibreOffice and draw how we want it to look
 
2335
                        // Mostly works OK, but in scrollable menus results in glitches. But scrollable menus have
 
2336
                        // their own glitches, so this seems to be not much of a problem.
 
2337
                        clipRect=0;
 
2338
                        x-=(CheckBox_Size-w)/2;
 
2339
                        y-=(CheckBox_Size-h)/2-1;
 
2340
                        w=CheckBox_Size;
 
2341
                        h=CheckBox_Size;
 
2342
                    }
2253
2343
                }
2254
2344
 
2255
2345
            }
2521
2611
 
2522
2612
            }
2523
2613
 
 
2614
            if( arrow == GTK_ARROW_DOWN && Style::instance().settings().applicationName().isOpenOffice( widget ) )
 
2615
            {
 
2616
 
 
2617
                y-= 1;
 
2618
 
 
2619
            }
 
2620
 
2524
2621
            // disable contrast
2525
2622
            options &= ~Contrast;
2526
2623
 
2572
2669
            if( Gtk::gtk_widget_layout_is_reversed( widget ) )
2573
2670
            { x+=2; }
2574
2671
 
2575
 
        } else if(
2576
 
            Gtk::gtk_parent_button( widget ) &&
2577
 
            !Gtk::gtk_parent_tree_view( widget ) &&
2578
 
            !Gtk::gtk_parent_combo( widget ) )
2579
 
        {
2580
 
 
2581
 
            useWidgetStateEngine = false;
2582
 
            options &= ~( Focus|Hover );
2583
 
            if( d.isArrow() && GTK_IS_ARROW( widget ) )
 
2672
        } else if( ( parent = Gtk::gtk_parent_button( widget ) ) ) {
 
2673
 
 
2674
 
 
2675
            if(!Gtk::gtk_parent_tree_view( widget ) &&
 
2676
                !Gtk::gtk_parent_combo( widget ) )
2584
2677
            {
2585
2678
 
2586
 
                //if( arrow == GTK_ARROW_DOWN || arrow == GTK_ARROW_UP )
2587
 
                { x += 1; }
2588
 
 
2589
 
                role = Palette::WindowText;
 
2679
                useWidgetStateEngine = false;
 
2680
                options &= ~( Focus|Hover );
 
2681
 
 
2682
                if( d.isArrow() && GTK_IS_ARROW( widget ) )
 
2683
                {
 
2684
 
 
2685
                    x += 1;
 
2686
                    role = Palette::WindowText;
 
2687
                }
 
2688
 
 
2689
            } else if( Gtk::gtk_button_is_header( parent ) && Style::instance().settings().viewInvertSortIndicator() ) {
 
2690
 
 
2691
                arrow = (arrow == GTK_ARROW_UP) ? GTK_ARROW_DOWN:GTK_ARROW_UP;
 
2692
 
2590
2693
            }
2591
2694
 
2592
2695
        } else if( GTK_IS_CALENDAR( widget ) ) {
2944
3047
 
2945
3048
                }
2946
3049
 
2947
 
                gap.setHeight( 8 );
 
3050
                if(Style::instance().settings().applicationName().isOpenOffice())
 
3051
                    gap.setHeight( 0 );
 
3052
                else
 
3053
                    gap.setHeight( 8 );
2948
3054
                Style::instance().renderTabBarFrame( window, clipRect, x-1, y-1, w+2, h+2, gap, options );
2949
3055
 
2950
3056
            }
3062
3168
        #endif
3063
3169
 
3064
3170
        Gtk::Detail d( detail );
 
3171
 
 
3172
        // Will be used for LibreOffice
 
3173
        bool prelight(g_object_get_data(G_OBJECT(window),"libreoffice-tab-is-prelit"));
 
3174
 
3065
3175
        if( d.isTab() )
3066
3176
        {
3067
 
 
3068
3177
            StyleOptions options( widget, state, shadow );
 
3178
            if(prelight)
 
3179
                options|=Hover;
3069
3180
            TabOptions tabOptions( widget, state, position, x, y, w, h );
3070
3181
 
3071
3182
            const bool isCurrentTab( tabOptions & CurrentTab );
3127
3238
            }
3128
3239
 
3129
3240
            if( isOpenOffice )
3130
 
            {
3131
 
                // draw background since OOo won't draw it as it should
3132
 
                // in addition, it passes wrong rectangle to the theme
3133
 
                Style::instance().fill(
3134
 
                    window, clipRect, x-1, y, w+2, h+1,
3135
 
                    Style::instance().settings().palette().color( Palette::Window ) );
3136
 
            }
 
3241
            { x+=1; }
3137
3242
 
3138
3243
            // render
3139
3244
            if( isXul ) tabOptions |= Xul;
3141
3246
            Style::instance().renderTab( window, clipRect, x, y, w, h, position, options, tabOptions, data );
3142
3247
 
3143
3248
            // render tabbar base if current tab
3144
 
            if( drawTabBarBase )
 
3249
            if( !isOpenOffice && drawTabBarBase )
3145
3250
            {
3146
3251
 
3147
3252
                const GtkAllocation allocation( Gtk::gtk_widget_get_allocation( widget ) );
3177
3282
                Style::instance().renderTabBarBase( window, clipRect, xBase-1, yBase-1, wBase+2, hBase+2, position, gap, options, tabOptions );
3178
3283
 
3179
3284
            }
 
3285
            else if(isOpenOffice && !clipRect )
 
3286
            {
 
3287
                options&=~Hover;
 
3288
                Cairo::Context context(window);
 
3289
                const ColorUtils::Rgba base( Style::instance().settings().palette().color( Palette::Window ) );
 
3290
 
 
3291
                if(position==GTK_POS_BOTTOM)
 
3292
                {
 
3293
                    if(isCurrentTab)
 
3294
                    {
 
3295
                        cairo_rectangle(context,x,y,w,h);
 
3296
                        cairo_rectangle_negative(context, x+4, y, w-8, h);
 
3297
                        cairo_clip(context);
 
3298
                        ++y;
 
3299
                    }
 
3300
                    Style::instance().helper().slab( base, 0 ).render( context, x-8, y+h-4, w+17, 15, TileSet::Top );
 
3301
                }
 
3302
                else if(position==GTK_POS_TOP)
 
3303
                {
 
3304
                    if(isCurrentTab)
 
3305
                    {
 
3306
                        cairo_rectangle(context,x-1,y,w+2,h);
 
3307
                        cairo_rectangle_negative(context, x+3, y, w-6, h);
 
3308
                        cairo_clip(context);
 
3309
                        y+=4;
 
3310
                    }
 
3311
                    Style::instance().helper().slab( base, 0 ).render( context, x-8, y-15, w+17, 16, TileSet::Bottom );
 
3312
                }
 
3313
            }
3180
3314
 
3181
3315
            if( GTK_IS_NOTEBOOK( widget ) )
3182
3316
            { Gtk::gtk_notebook_update_close_buttons(GTK_NOTEBOOK(widget)); }
3323
3457
 
3324
3458
        } else if( d.isHandleBox() ) {
3325
3459
 
3326
 
            if( Style::instance().settings().applicationName().isOpenOffice( widget ) )
 
3460
            if( !Gtk::gtk_widget_is_applet( widget ) )
3327
3461
            {
3328
 
 
3329
 
                Style::instance().fill( window, clipRect, x, y, w, h, Gtk::gdk_get_color( style->bg[state] ) );
3330
 
 
3331
 
            } else if( !Gtk::gtk_widget_is_applet( widget ) ) {
3332
 
 
3333
3462
                Style::instance().renderWindowBackground( window, widget, clipRect, x, y, w, h );
3334
 
 
3335
3463
            }
3336
3464
 
3337
3465
            StyleOptions options( widget, state, shadow );
3379
3507
    }
3380
3508
 
3381
3509
    //___________________________________________________________
 
3510
    static GdkPixbuf* render_stated_pixbuf( GdkPixbuf* source, GtkStateType state, bool useEffect )
 
3511
    {
 
3512
 
 
3513
        #if OXYGEN_DEBUG
 
3514
        std::cerr
 
3515
            << "Oxygen::render_stated_pixbuf -"
 
3516
            << " state: " << Gtk::TypeNames::state( state )
 
3517
            << " useEffect: " << useEffect
 
3518
            << std::endl;
 
3519
        #endif
 
3520
 
 
3521
        // first make a copy
 
3522
        GdkPixbuf* stated( source );
 
3523
        if( state == GTK_STATE_INSENSITIVE )
 
3524
        {
 
3525
 
 
3526
            stated = Gtk::gdk_pixbuf_set_alpha( source, 0.3 );
 
3527
            gdk_pixbuf_saturate_and_pixelate( stated, stated, 0.1, false );
 
3528
 
 
3529
        } else if( useEffect && state == GTK_STATE_PRELIGHT ) {
 
3530
 
 
3531
            stated = gdk_pixbuf_copy( source );
 
3532
            if(!Gtk::gdk_pixbuf_to_gamma( stated, 0.7 ) )
 
3533
            {
 
3534
                // FIXME: correct the value to match KDE
 
3535
                /*
 
3536
                in fact KDE allows one to set many different effects on icon
 
3537
                not sure we want to copy this code all over the place, especially since nobody changes the default settings,
 
3538
                as far as I know */
 
3539
                gdk_pixbuf_saturate_and_pixelate( source, stated, 1.2, false );
 
3540
            }
 
3541
 
 
3542
        }
 
3543
 
 
3544
        return stated;
 
3545
    }
 
3546
 
 
3547
    //___________________________________________________________
3382
3548
    static GdkPixbuf* render_icon(
3383
3549
        GtkStyle* style,
3384
3550
        const GtkIconSource* source,
3448
3614
 
3449
3615
        }
3450
3616
 
3451
 
        /* If the state was wildcarded, then generate a state. */
3452
 
        GdkPixbuf *stated( scaled );
3453
 
 
3454
 
        // non-flat pushbuttons don't have any icon effect
3455
 
        const bool useEffect( Style::instance().settings().useIconEffect() && Gtk::gtk_button_is_flat( Gtk::gtk_parent_button( widget ) ) );
3456
 
 
3457
 
        if( gtk_icon_source_get_state_wildcarded( source ) )
3458
 
        {
3459
 
 
3460
 
            if( state == GTK_STATE_INSENSITIVE )
3461
 
            {
3462
 
 
3463
 
                stated = Gtk::gdk_pixbuf_set_alpha( scaled, 0.3 );
3464
 
                gdk_pixbuf_saturate_and_pixelate( stated, stated, 0.1, false );
3465
 
                g_object_unref (scaled);
3466
 
 
3467
 
            } else if( useEffect && state == GTK_STATE_PRELIGHT ) {
3468
 
 
3469
 
                stated = gdk_pixbuf_copy( scaled );
3470
 
                if(!Gtk::gdk_pixbuf_to_gamma( stated, 0.7 ) )
3471
 
                {
3472
 
                    // FIXME: correct the value to match KDE
3473
 
                    /*
3474
 
                    in fact KDE allows one to set many different effects on icon
3475
 
                    not sure we want to copy this code all over the place, especially since nobody changes the default settings,
3476
 
                    as far as I know */
3477
 
                    gdk_pixbuf_saturate_and_pixelate( scaled, stated, 1.2, false );
3478
 
                }
3479
 
                g_object_unref( scaled );
3480
 
 
3481
 
            }
 
3617
        if( !gtk_icon_source_get_state_wildcarded( source ) ) return scaled;
 
3618
        else {
 
3619
 
 
3620
            // non-flat pushbuttons don't have any icon effect
 
3621
            const bool useEffect( Style::instance().settings().useIconEffect() && Gtk::gtk_button_is_flat( Gtk::gtk_parent_button( widget ) ) );
 
3622
 
 
3623
            /* If the state was wildcarded, then generate a state. */
 
3624
            GdkPixbuf *stated( render_stated_pixbuf( scaled, state, useEffect ) );
 
3625
 
 
3626
            // clean-up
 
3627
            if( stated != scaled )
 
3628
            { g_object_unref( scaled ); }
 
3629
 
 
3630
            // return
 
3631
            return stated;
 
3632
 
3482
3633
        }
3483
3634
 
3484
 
        return stated;
3485
3635
    }
3486
3636
 
3487
3637
    //___________________________________________________________________________________________________________