• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KStyles

keramik.cpp

Go to the documentation of this file.
00001 /* Keramik Style
00002    Copyright (c) 2002       Malte Starostik <malte@kde.org>
00003              (c) 2002-2005  Maksim Orlovich <maksim@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 
00022 #include "kstyle.h"
00023 #include <QtGui/qdrawutil.h>
00024 #include <QtGui/QPainter>
00025 #include <QtGui/QStyleOption>
00026 #include "colorutil.h"
00027 #include "pixmaploader.h"
00028 #include "gradients.h"
00029 #include "keramikimage.h"
00030 #include <QtGui/QPolygon>
00031 
00032 #define loader Keramik::PixmapLoader::the()
00033 
00034 static const int keramik_up_arrow[] =
00035     {
00036         0, -4, 0, -4,
00037         -1, -3, 1, -3,
00038         -2, -2, 2, -2,
00039         -3, -1, 3, -1,
00040         -4, 0, 4, 0,
00041         -2, 1, 2, 1,
00042         -2, 2, 2, 2,
00043         -2, 3, 2, 3,
00044         -2, 4, 2, 4
00045     };
00046 
00047 static const int keramik_down_arrow[] =
00048     {
00049         0, 4, 0, 4,
00050         -1, 3, 1, 3,
00051         -2, 2, 2, 2,
00052         -3, 1, 3, 1,
00053         -4, 0, 4, 0,
00054         -2, -1, 2, -1,
00055         -2, -2, 2, -2,
00056         -2, -3, 2, -3,
00057         -2, -4, 2, -4
00058     };
00059 
00060 
00061     static const int keramik_right_arrow[] =
00062     {
00063         4, 0, 4, 0,
00064         3, -1, 3, 1,
00065         2, -2, 2, 2,
00066         1, -3, 1, 3,
00067         0, -4, 0, 4,
00068         -1, -2, -1, 2,
00069         -2, -2, -2, 2,
00070         -3, -2, -3, 2,
00071         -4, -2, -4, 2
00072     };
00073 
00074     static const int keramik_left_arrow[] =
00075     {
00076         -4, 0, -4, 0,
00077         -3, -1, -3, 1,
00078         -2, -2, -2, 2,
00079         -1, -3, -1, 3,
00080         0, -4, 0, 4,
00081         1, -2, 1, 2,
00082         2, -2, 2, 2,
00083         3, -2, 3, 2,
00084         4, -2, 4, 2
00085     };
00086 
00087 
00088 
00089 #define POLY_LEN(x) sizeof(x)/(sizeof(int)*2)
00090 
00091 
00092 
00093 class KeramikStyle: public KStyle
00094 {
00095 public:
00096     KeramikStyle()
00097     {
00098         //Just for the heck of it, make the focus rect's RHS nearly flush
00099         setWidgetLayoutProp(WT_PushButton, PushButton::FocusMargin, 3);
00100         setWidgetLayoutProp(WT_PushButton, PushButton::FocusMargin + Right, 2);
00101         setWidgetLayoutProp(WT_PushButton, PushButton::FocusMargin + Top, 2);
00102         setWidgetLayoutProp(WT_PushButton, PushButton::FocusMargin + Bot, 2);
00103 
00104         setWidgetLayoutProp(WT_MenuBar, MenuBar::ItemSpacing,   10);
00105 
00106         setWidgetLayoutProp(WT_MenuBarItem, MenuBarItem::Margin + Left,  2);
00107         setWidgetLayoutProp(WT_MenuBarItem, MenuBarItem::Margin + Right, 2);
00108 
00109         setWidgetLayoutProp(WT_ScrollBar, ScrollBar::MinimumSliderHeight,
00110                         loader.size( keramik_scrollbar_vbar + KeramikSlider1 ).height() +
00111                         loader.size( keramik_scrollbar_vbar + KeramikSlider3 ).height());
00112 
00113 
00114         setWidgetLayoutProp(WT_ScrollBar, ScrollBar::ArrowColor,
00115                             ColorMode(ColorMode::BWAutoContrastMode, QPalette::Button));
00116 
00117         setWidgetLayoutProp(WT_ScrollBar, ScrollBar::ActiveArrowColor,
00118                             ColorMode(ColorMode::BWAutoContrastMode, QPalette::ButtonText));
00119 
00120         //### HACK,for now.
00121         //setWidgetLayoutProp(WT_DockWidgetTitle, DockWidgetTitle::Margin, 8);
00122 
00123         //setWidgetLayoutProp(WT_ProgressBar, ProgressBar::SideText, 1);
00124 
00125         setWidgetLayoutProp(WT_ScrollBar, ScrollBar::SingleButtonHeight,
00126                                 loader.size(keramik_scrollbar_vbar_arrow1).height());
00127 
00128         setWidgetLayoutProp(WT_Slider, Slider::HandleLength, 12);
00129         setWidgetLayoutProp(WT_Slider, Slider::HandleThickness, loader.size(keramik_slider).height());
00130     }
00131 
00132     void drawKStylePrimitive(WidgetType widgetType, int primitive,
00133                  const QStyleOption* opt,
00134                  const QRect &r, const QPalette &pal, State flags,
00135                  QPainter* p,
00136                  const QWidget* widget,
00137                  KStyle::Option* kOpt) const
00138     {
00139         bool disabled = !(flags & State_Enabled);
00140         switch (widgetType)
00141         {
00142             case WT_PushButton:
00143             {
00144                 switch (primitive)
00145                 {
00146                     case PushButton::Panel:
00147                     {
00148                         const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(opt);
00149                         if (bOpt &&  //### helper function in KStyle?
00150                                               (bOpt->features & QStyleOptionButton::DefaultButton))
00151                             return; //The default indicator does the job for us.
00152 
00153                         bool sunken   = (flags & State_On) || (flags & State_Sunken);
00154                         bool disabled = !(flags & State_Enabled);
00155 
00156                         int  name;
00157 
00158                         if (sunken)
00159                             name = keramik_pushbutton_pressed;
00160                         else
00161                             name =  keramik_pushbutton;
00162 
00163                         if (flags & State_MouseOver && name == keramik_pushbutton )
00164                             name = keramik_pushbutton_hov;
00165 
00166                         Keramik::RectTilePainter( name, false ).draw(p, r, pal.color(QPalette::Button), pal.background().color(), disabled);
00167                         //, pmode() );
00168 
00169                         return;
00170                     }
00171 
00172                     case PushButton::DefaultButtonFrame:
00173                     {
00174                         bool sunken = (flags & State_On) || (flags & State_Sunken);
00175 
00176                         int id;
00177                         if ( sunken ) id  = keramik_pushbutton_default_pressed;
00178                         else id = keramik_pushbutton_default;
00179 
00180                         if (flags & State_MouseOver && id == keramik_pushbutton_default )
00181                             id = keramik_pushbutton_default_hov;
00182 
00183 
00184                         Keramik::RectTilePainter( id, false ).draw(p, r, pal.color(QPalette::Button), pal.background().color(), !(flags & State_Enabled));
00185                         //,  pmode() );
00186                         break; // TODO!! this break seems strange, have a look at it later (giessl)
00187 
00188                         return;
00189                     }
00190                 }
00191             }
00192             break;
00193 
00194             case WT_ProgressBar:
00195             {
00196                 switch (primitive)
00197                 {
00198                     case ProgressBar::BusyIndicator:
00199                         Keramik::RowPainter(keramik_progressbar).draw(p, r,
00200                                          pal.color(QPalette::Highlight), pal.background().color());
00201                         return;
00202                     case ProgressBar::Indicator:
00203                         Keramik::ProgressBarPainter(keramik_progressbar, opt->direction == Qt::RightToLeft).draw(p, r,
00204                             pal.color(QPalette::Highlight), pal.background().color());
00205                         return;
00206                 }
00207             }
00208             break;
00209 
00210 
00211             case WT_MenuBarItem:
00212             {
00213                 switch (primitive)
00214                 {
00215                     case MenuBarItem::Panel:
00216                     {
00217                         const QStyleOptionMenuItem* miOpt = ::qstyleoption_cast<const QStyleOptionMenuItem*>(opt);
00218                         bool active  = flags & State_Selected;
00219                         bool focused = flags & State_HasFocus;
00220 
00221                         if ( active && focused )
00222                             qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(),
00223                                             pal, true, 1, &pal.brush(QPalette::Midlight));
00224                         else
00225                             Keramik::GradientPainter::renderGradient( p, miOpt->menuRect, pal.color(QPalette::Button), true, true);
00226                         return;
00227                     }
00228                 }
00229             }
00230             break;
00231 
00232             case WT_Menu:
00233             {
00234                 switch (primitive)
00235                 {
00236                     case Generic::Frame:
00237                     {
00238                         qDrawShadePanel(p, r, pal);
00239                         return;
00240                     }
00241 
00242                     case Menu::Background:
00243                     {
00244                         p->fillRect( r, pal.background().color().light( 105 ) );
00245                         return;
00246                     }
00247 
00248                     case Menu::TearOff:
00249                     {
00250                 //### hmm,may be KStyle should do a default for this.
00251                 //### FIXME
00252                         return;
00253                     }
00254 
00255                     case Menu::Scroller:
00256                     {
00257                 //TODO:scrollr
00258 
00259                         return;
00260                     }
00261                 }
00262             }
00263             break;
00264 
00265             case WT_MenuBar:
00266             {
00267                 switch (primitive)
00268                 {
00269                     case MenuBar::EmptyArea:
00270                     {
00271                         Keramik::GradientPainter::renderGradient( p, r, pal.color(QPalette::Button), true, true);
00272                         return;
00273                     }
00274                 }
00275             }
00276             break;
00277 
00278             case WT_Splitter:
00279             {
00280                 switch (primitive)
00281                 {
00282                     case Splitter::HandleHor:
00283                     case Splitter::HandleVert:
00284                     {
00285                         int x,y,w,h;
00286                         r.getRect(&x, &y, &w, &h);
00287                         int x2 = x+w-1;
00288                         int y2 = y+h-1;
00289 
00290                     //### should probably use color() directly to avoid creating a brush
00291                         p->setPen(pal.dark().color());
00292                         p->drawRect( r );
00293                         p->setPen(pal.background().color());
00294                         p->drawPoint(x, y);
00295                         p->drawPoint(x2, y);
00296                         p->drawPoint(x, y2);
00297                         p->drawPoint(x2, y2);
00298                         p->setPen(pal.color(QPalette::Light));
00299                         p->drawLine(x+1, y+1, x+1, y2-1);
00300                         p->drawLine(x+1, y+1, x2-1, y+1);
00301                         p->setPen(pal.midlight().color());
00302                         p->drawLine(x+2, y+2, x+2, y2-2);
00303                         p->drawLine(x+2, y+2, x2-2, y+2);
00304                         p->setPen(pal.mid().color());
00305                         p->drawLine(x2-1, y+1, x2-1, y2-1);
00306                         p->drawLine(x+1, y2-1, x2-1, y2-1);
00307                         p->fillRect(x+3, y+3, w-5, h-5, pal.brush(QPalette::Background));
00308 
00309                         return;
00310                     }
00311                 }
00312             }
00313             break;
00314 
00315             case WT_MenuItem:
00316             {
00317                 switch (primitive)
00318                 {
00319                     case MenuItem::Separator:
00320                     {
00321                         QRect lr = centerRect(r, r.width(), 2); //Center...
00322                         p->setPen( pal.mid().color() );
00323                         p->drawLine(lr.x()+5, lr.y(), lr.right()-4, lr.y());
00324                         p->setPen( pal.color(QPalette::Light) );
00325                         p->drawLine(lr.x()+5, lr.y() + 1, lr.right()-4, lr.y() + 1);
00326                         return;
00327                     }
00328 
00329                     case MenuItem::ItemIndicator:
00330                     {
00331                         if (flags & State_Enabled)
00332                             Keramik::RowPainter( keramik_menuitem ).draw(p, r, pal.color(QPalette::Highlight), pal.background().color());
00333                         else
00334                             drawKStylePrimitive(WT_Generic, Generic::FocusIndicator, opt, r, pal, flags, p, widget, kOpt);
00335                         return;
00336                     }
00337                 }
00338             }
00339             break;
00340 
00341             case WT_CheckBox:
00342             {
00343                 switch(primitive)
00344                 {
00345                     case CheckBox::CheckOn:
00346                     {
00347                         Keramik::CenteredPainter(keramik_checkbox_on).draw(p, r, pal.color(QPalette::Button),
00348                         pal.background().color(), disabled);//, pmode() );
00349                         return;
00350                     }
00351                     case CheckBox::CheckOff:
00352                     {
00353                         Keramik::CenteredPainter(keramik_checkbox_off).draw(p, r, pal.color(QPalette::Button),
00354                         pal.background().color(), disabled);//, pmode() );
00355                         return;
00356                     }
00357                     case CheckBox::CheckTriState:
00358                     {
00359                         Keramik::CenteredPainter(keramik_checkbox_tri).draw(p, r, pal.color(QPalette::Button),
00360                         pal.background().color(), disabled);//, pmode() );
00361                         return;
00362                     }
00363                 }
00364             }
00365             break;
00366 
00367             case WT_RadioButton:
00368             {
00369                 switch(primitive)
00370                 {
00371                     case RadioButton::RadioOn:
00372                     {
00373                         Keramik::CenteredPainter(keramik_radiobutton_on).draw(p, r, pal.color(QPalette::Button),
00374                         pal.background().color(), disabled);//, pmode() );
00375                         return;
00376                     }
00377                     case RadioButton::RadioOff:
00378                     {
00379                         Keramik::CenteredPainter(keramik_radiobutton_off).draw(p, r, pal.color(QPalette::Button),
00380                         pal.background().color(), disabled);//, pmode() );
00381                         return;
00382                     }
00383                 }
00384             }
00385             break;
00386 
00387             case WT_ScrollBar:
00388             {
00389                 bool down = (flags & State_Sunken);
00390                 switch (primitive)
00391                 {
00392                     case ScrollBar::SliderHor:
00393                     case ScrollBar::SliderVert:
00394                     {
00395                         bool horizontal = (flags & State_Horizontal);
00396 
00397                         bool active     = (flags & State_Sunken);
00398                         int name = KeramikSlider1;
00399                         unsigned int count = 3;
00400 
00401                         int w = r.width();
00402                         int h = r.height();
00403 
00404                         if ( horizontal )
00405                         {
00406                             if ( w > ( loader.size( keramik_scrollbar_hbar+KeramikSlider1 ).width() +
00407                                                       loader.size( keramik_scrollbar_hbar+KeramikSlider4 ).width() +
00408                                                       loader.size( keramik_scrollbar_hbar+KeramikSlider3 ).width() + 2 ) )
00409                                 count = 5;
00410                         }
00411                         else if ( h > ( loader.size( keramik_scrollbar_vbar+KeramikSlider1 ).height() +
00412                                                     loader.size( keramik_scrollbar_vbar+KeramikSlider4 ).height() +
00413                                                     loader.size( keramik_scrollbar_vbar+KeramikSlider3 ).height() + 2 ) )
00414                             count = 5;
00415 
00416                         QColor col = pal.color(QPalette::Highlight);
00417 
00418                         //### what to do with the customScrollMode stuff?
00419                         //I suppose KStyle can take care of it, somehow?
00420                         //if (customScrollMode || !highlightScrollBar)
00421                         //  col = pal.button();
00422 
00423                         if (!active)
00424                             Keramik::ScrollBarPainter( name, count, horizontal ).draw( p, r, col, pal.background().color(), false);
00425                         else
00426                             Keramik::ScrollBarPainter( name, count, horizontal ).draw( p, r,                                                Keramik::ColorUtil::lighten(col ,110),
00427                         pal.background().color(), false );
00428 
00429                         return;
00430                     }
00431                     case ScrollBar::GrooveAreaHorLeft:
00432                     case ScrollBar::GrooveAreaHorRight:
00433                     {
00434                         Keramik::ScrollBarPainter(KeramikGroove1, 2, true).draw(
00435                                 p, r, pal.color(QPalette::Button), pal.background().color(), disabled);
00436                         return;
00437                     }
00438                     case ScrollBar::GrooveAreaVertTop:
00439                     case ScrollBar::GrooveAreaVertBottom:
00440                     {
00441                         Keramik::ScrollBarPainter(KeramikGroove1, 2, false).draw(
00442                                 p, r, pal.color(QPalette::Button), pal.background().color(), disabled);
00443                         return;
00444                     }
00445 
00446                     case ScrollBar::DoubleButtonHor:
00447                     {
00448                         const DoubleButtonOption* bOpt = extractOption<const DoubleButtonOption*>(kOpt);
00449 
00450                         //Draw the entire, unselected bevel.
00451                         Keramik::CenteredPainter painter(keramik_scrollbar_hbar_arrow2);
00452                         painter.draw(p, r, pal.color(QPalette::Button), pal.background().color(), !(flags & State_Enabled));
00453 
00454                         p->setPen(pal.buttonText().color());
00455                         p->drawLine(r.x()+r.width()/2 - 1, r.y() + r.height()/2 - 3,
00456                                     r.x()+r.width()/2 - 1, r.y() + r.height()/2 + 3);
00457 
00458                         //Check whether we need to draw any of the buttons
00459                         if (bOpt->activeButton != DoubleButtonOption::None)
00460                         {
00461                             if (bOpt->activeButton == DoubleButtonOption::Right)
00462                             {
00463                                 p->setClipRect(r.x() + r.width()/2, r.y(), r.width()/2, r.height());
00464                                 painter.draw(p, r, pal.buttonText().color(), pal.background().color(),
00465                                                 !(flags & State_Enabled));
00466                             }
00467                             else
00468                             { //Left
00469                                 p->setClipRect(r.x(), r.y(), r.width()/2, r.height());
00470                                 painter.draw(p, r, pal.buttonText().color(), pal.background().color(),
00471                                         !(flags & State_Enabled));
00472                             }
00473 
00474                             p->setClipping(false);
00475                         }
00476 
00477                         return;
00478                     }
00479 
00480                     case ScrollBar::DoubleButtonVert:
00481                     {
00482                         const DoubleButtonOption* bOpt = extractOption<const DoubleButtonOption*>(kOpt);
00483 
00484                         //Draw the entire, unselected bevel.
00485                         Keramik::CenteredPainter painter(keramik_scrollbar_vbar_arrow2);
00486                         painter.draw(p, r, pal.color(QPalette::Button), pal.background().color(), !(flags & State_Enabled));
00487 
00488                         p->setPen(pal.buttonText().color());
00489                         p->drawLine(r.x()+r.width()/2 - 4, r.y()+r.height()/2,
00490                                     r.x()+r.width()/2 + 2, r.y()+r.height()/2);
00491 
00492 
00493                         //Check whether any of the buttons is down
00494                         if (bOpt->activeButton != DoubleButtonOption::None)
00495                         {
00496                             if (bOpt->activeButton == DoubleButtonOption::Bottom)
00497                             {   //down
00498                                 p->setClipRect(r.x(), r.y() + r.height()/2, r.width(), r.height()/2);
00499                                 painter.draw(p, r, pal.buttonText().color(), pal.background().color(),
00500                                             !(flags & State_Enabled));
00501                             }
00502                             else
00503                             {   //up.
00504                                 p->setClipRect(r.x(), r.y(), r.width(), r.height()/2);
00505                                 painter.draw(p, r, pal.buttonText().color(), pal.background().color(),
00506                                             !(flags & State_Enabled));
00507                             }
00508 
00509                             p->setClipping(false);
00510                         }
00511 
00512                         return;
00513                     }
00514 
00515                     case ScrollBar::SingleButtonHor:
00516                     {
00517                         Keramik::CenteredPainter painter(keramik_scrollbar_hbar_arrow1 );
00518                         painter.draw( p, r, down? pal.buttonText().color() : pal.color(QPalette::Button),
00519                                                 pal.background().color(), disabled);
00520                         return;
00521                     }
00522 
00523                     case ScrollBar::SingleButtonVert:
00524                     {
00525                         Keramik::CenteredPainter painter(keramik_scrollbar_vbar_arrow1 );
00526                         painter.draw( p, r, down? pal.buttonText().color() : pal.color(QPalette::Button),
00527                                                 pal.background().color(), disabled);
00528                         return;
00529                     }
00530                 }
00531 
00532                 if (primitive >= Generic::ArrowUp && primitive <= Generic::ArrowLeft)
00533                 {
00534                     KStyle::ColorOption* colorOpt   = extractOption<KStyle::ColorOption*>(kOpt);
00535                     QColor               arrowColor = colorOpt->color.color(pal);
00536 
00537                     QPolygon poly;
00538                     switch (primitive)
00539                     {
00540                         case Generic::ArrowUp:
00541                             poly.setPoints(POLY_LEN(keramik_up_arrow), keramik_up_arrow);
00542                             break;
00543 
00544                         case Generic::ArrowDown:
00545                             poly.setPoints(POLY_LEN(keramik_down_arrow), keramik_down_arrow);
00546                             break;
00547 
00548                         case Generic::ArrowLeft:
00549                             poly.setPoints(POLY_LEN(keramik_left_arrow), keramik_left_arrow);
00550                             break;
00551 
00552                         default:
00553                             poly.setPoints(POLY_LEN(keramik_right_arrow), keramik_right_arrow);
00554                     }
00555 
00556 
00557                     if ( flags & State_Enabled )
00558                     {
00559                         //CHECKME: Why is the -1 needed?
00560                         poly.translate(r.x() + r.width()/2 - 1, r.y() + r.height()/2);
00561 
00562                         p->setPen(arrowColor);
00563                         p->drawPolygon(poly);
00564                     }
00565                     else
00566                     {
00567                         //Disabled ones ignore color parameter
00568                         poly.translate(r.x() + r.width()/2, r.y() + r.height()/2 + 1);
00569                         p->setPen(pal.color(QPalette::Light));
00570                         p->drawPolygon(poly);
00571 
00572                         poly.translate(-1,-1);
00573                         p->setPen(pal.mid().color());
00574                         p->drawPolygon(poly);
00575                     }
00576 
00577                     return;
00578                 }
00579 
00580             }
00581 
00582             case WT_TabBar:
00583             {
00584                 const QStyleOptionTab* tabOpt = qstyleoption_cast<const QStyleOptionTab*>(opt);
00585                 switch (primitive)
00586                 {
00587                     case TabBar::NorthTab:
00588                     case TabBar::SouthTab:
00589                     {
00590                         QStyleOptionTab::TabPosition pos = tabOpt->position;
00591                         //Adjust for RTL
00592                         if (tabOpt->direction == Qt::RightToLeft)
00593                         {
00594                             if (pos == QStyleOptionTab::End)
00595                                 pos = QStyleOptionTab::Beginning;
00596                             else if (pos == QStyleOptionTab::Beginning)
00597                                 pos = QStyleOptionTab::End;
00598                         }
00599 
00600                         if ( flags & State_Selected )
00601                         {
00602                             QRect tabRect = r;
00603                             //If not the right-most tab, readjust the painting to be one pixel wider
00604                             //to avoid a doubled line
00605                             if (pos != QStyleOptionTab::End)
00606                                     tabRect.setWidth( tabRect.width() + 1);
00607 
00608                             Keramik::ActiveTabPainter(primitive == TabBar::SouthTab).draw(p, tabRect,
00609                                     pal.color(QPalette::Button).light(110), pal.background().color(),
00610                                     disabled);
00611                         }
00612                         else
00613                         {
00614                             int x, y, w, h;
00615                             r.getRect(&x, &y, &w, &h);
00616                             if (primitive == TabBar::SouthTab)
00617                             {
00618                                 Keramik::InactiveTabPainter(pos, true).draw(
00619                                     p, x, y, w, h - 3, pal.color(QPalette::Button), pal.background().color(),
00620                                     disabled);
00621                                 p->setPen  (pal.dark().color());
00622                                 p->drawLine(x, y, x + w, y);
00623                             }
00624                             else
00625                             {
00626                                 Keramik::InactiveTabPainter(pos, false).draw(
00627                                     p, x, y + 3, w, h - 3, pal.color(QPalette::Button), pal.background().color(), disabled);
00628                                 p->setPen  (pal.color(QPalette::Light));
00629                                 p->drawLine(x, y + h - 1, x + w, y + h - 1);
00630                             }
00631                         }
00632                     }
00633                     return;
00634                 //### TODO: Handle east, west tabs
00635                 };
00636             } //WT_Tab
00637             break;
00638 
00639             case WT_Slider:
00640             {
00641                 switch (primitive)
00642                 {
00643                     case Slider::GrooveVert:
00644                         Keramik::RectTilePainter(keramik_slider_vgroove, true, false).draw(
00645                             p, r, pal.color(QPalette::Button), pal.background().color(), disabled);
00646                         return;
00647                     case Slider::GrooveHor:
00648                         Keramik::RectTilePainter(keramik_slider_hgroove, false).draw(
00649                             p, r, pal.color(QPalette::Button), pal.background().color(), disabled);
00650                         return;
00651                     case Slider::HandleVert:
00652                     case Slider::HandleHor:
00653                     {
00654                                                 QRect lr = r;
00655                         if (primitive == Slider::HandleHor)
00656                             lr.setY(lr.y() + 2);
00657                         else
00658                             lr.setX(lr.x() + 2);
00659 
00660                         QColor hl = pal.color(QPalette::Highlight);
00661                         if (!disabled && flags & State_Active)
00662                             hl = Keramik::ColorUtil::lighten(pal.color(QPalette::Highlight) ,110);
00663 
00664                         int primCode = (primitive == Slider::HandleVert) ?
00665                                             keramik_vslider : keramik_slider;
00666 
00667                         Keramik::ScaledPainter(primCode).draw(
00668                             p, lr, disabled ? pal.color(QPalette::Button) : hl, Qt::black,  disabled, Keramik::TilePainter::PaintFullBlend);
00669                         return;
00670                     }
00671                 }
00672             } //WT_Slider
00673 
00674             default:
00675             break;
00676         }
00677 
00678         //Handle default fallbacks
00679 
00680         KStyle::drawKStylePrimitive(widgetType, primitive, opt,
00681                         r, pal, flags, p, widget, kOpt);
00682     }
00683 
00684 };
00685 
00686 K_EXPORT_STYLE("Keramik", KeramikStyle)
00687 
00688 // kate: indent-width 4; replace-tabs off; tab-width 4; space-indent off;

KStyles

Skip menu "KStyles"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal