src/gui/styles/qgtkpainter.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
   239     const int maxHeight = 256;
   239     const int maxHeight = 256;
   240     const int border = 16;
   240     const int border = 16;
   241     if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
   241     if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
   242         rect.setHeight(2 * border + 1);
   242         rect.setHeight(2 * border + 1);
   243 
   243 
   244     QString gapExtras = QString(QLS("s %0 w %1 g %2")).arg(gap_side).arg(width).arg(x);
   244     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
   245     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) + gapExtras;
   245                          % HexString<uchar>(gap_side)
       
   246                          % HexString<gint>(width)
       
   247                          % HexString<gint>(x);
   246 
   248 
   247     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   249     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   248         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box_gap (style,
   250         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box_gap (style,
   249                                            pixmap,
   251                                            pixmap,
   250                                            state,
   252                                            state,
   305     const int border = 32;
   307     const int border = 32;
   306     if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
   308     if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
   307         rect.setHeight(2 * border + 1);
   309         rect.setHeight(2 * border + 1);
   308 
   310 
   309     QString pixmapName = uniqueName(QLS(part), state, shadow,
   311     QString pixmapName = uniqueName(QLS(part), state, shadow,
   310                                     rect.size(), gtkWidget) + pmKey;
   312                                     rect.size(), gtkWidget) % pmKey;
   311 
   313 
   312     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   314     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   313         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box (style,
   315         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box (style,
   314                                            pixmap,
   316                                            pixmap,
   315                                            state,
   317                                            state,
   355 {
   357 {
   356     if (!rect.isValid())
   358     if (!rect.isValid())
   357         return;
   359         return;
   358 
   360 
   359     QPixmap cache;
   361     QPixmap cache;
   360     QString hLineExtras = QString(QLS("%0 %1 %2")).arg(x1).arg(x2).arg(y);
       
   361     QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
   362     QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
   362                          + hLineExtras + pmKey;
   363                          % HexString<int>(x1)
       
   364                          % HexString<int>(x2)
       
   365                          % HexString<int>(y)
       
   366                          % pmKey;
   363     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   367     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   364         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_hline (style,
   368         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_hline (style,
   365                                          pixmap,
   369                                          pixmap,
   366                                          state,
   370                                          state,
   367                                          NULL,
   371                                          NULL,
   382 {
   386 {
   383     if (!rect.isValid())
   387     if (!rect.isValid())
   384         return;
   388         return;
   385 
   389 
   386     QPixmap cache;
   390     QPixmap cache;
   387     QString vLineExtras = QString(QLS("%0 %1 %2")).arg(y1).arg(y2).arg(x);
   391     QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
   388     QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(),
   392                         % HexString<int>(y1)
   389                                     gtkWidget) + vLineExtras +pmKey;
   393                         % HexString<int>(y2)
       
   394                         % HexString<int>(x)
       
   395                         % pmKey;
       
   396 
   390     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   397     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   391         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_vline (style,
   398         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_vline (style,
   392                                          pixmap,
   399                                          pixmap,
   393                                          state,
   400                                          state,
   394                                          NULL,
   401                                          NULL,
   410 {
   417 {
   411     if (!rect.isValid())
   418     if (!rect.isValid())
   412         return;
   419         return;
   413 
   420 
   414     QPixmap cache;
   421     QPixmap cache;
   415     QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(),
   422     QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
   416                                     gtkWidget) + QString::number(expander_state) + pmKey;
   423                          % HexString<uchar>(expander_state)
       
   424                          % pmKey;
       
   425 
   417     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   426     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   418         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_expander (style, pixmap,
   427         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_expander (style, pixmap,
   419                                             state, NULL,
   428                                             state, NULL,
   420                                             gtkWidget, part,
   429                                             gtkWidget, part,
   421                                             rect.width()/2,
   430                                             rect.width()/2,
   434 {
   443 {
   435     if (!rect.isValid())
   444     if (!rect.isValid())
   436         return;
   445         return;
   437 
   446 
   438     QPixmap cache;
   447     QPixmap cache;
   439     QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) + pmKey;
   448     QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey;
   440     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   449     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   441         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_focus (style, pixmap, state, NULL,
   450         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_focus (style, pixmap, state, NULL,
   442                                          gtkWidget,
   451                                          gtkWidget,
   443                                          part,
   452                                          part,
   444                                          0, 0,
   453                                          0, 0,
   459 {
   468 {
   460     if (!rect.isValid())
   469     if (!rect.isValid())
   461         return;
   470         return;
   462 
   471 
   463     QPixmap cache;
   472     QPixmap cache;
   464     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) + pmKey;
   473     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
   465     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   474     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   466         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_resize_grip (style, pixmap, state,
   475         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_resize_grip (style, pixmap, state,
   467                                                NULL, gtkWidget,
   476                                                NULL, gtkWidget,
   468                                                part, edge, 0, 0,
   477                                                part, edge, 0, 0,
   469                                                rect.width(),
   478                                                rect.width(),
   484     QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
   493     QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
   485     if (!rect.isValid())
   494     if (!rect.isValid())
   486         return;
   495         return;
   487 
   496 
   488     QPixmap cache;
   497     QPixmap cache;
   489     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) +
   498     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
   490                          QString::number((int)arrow_type) + pmKey;
   499                          % HexString<uchar>(arrow_type)
       
   500                          % pmKey;
   491 
   501 
   492     GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
   502     GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
   493     int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
   503     int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
   494     int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
   504     int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
   495     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   505     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   516     if (!rect.isValid())
   526     if (!rect.isValid())
   517         return;
   527         return;
   518 
   528 
   519     QPixmap cache;
   529     QPixmap cache;
   520     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
   530     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
   521                          + QString::number(orientation);
   531                          % HexString<uchar>(orientation);
       
   532 
   522     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   533     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   523         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_handle (style,
   534         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_handle (style,
   524                                           pixmap,
   535                                           pixmap,
   525                                           state,
   536                                           state,
   526                                           shadow,
   537                                           shadow,
   544 {
   555 {
   545     if (!rect.isValid())
   556     if (!rect.isValid())
   546         return;
   557         return;
   547 
   558 
   548     QPixmap cache;
   559     QPixmap cache;
   549     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) + pmKey;
   560     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
   550     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   561     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   551         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_slider (style,
   562         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_slider (style,
   552                                           pixmap,
   563                                           pixmap,
   553                                           state,
   564                                           state,
   554                                           shadow,
   565                                           shadow,
   575     if (!rect.isValid())
   586     if (!rect.isValid())
   576         return;
   587         return;
   577 
   588 
   578     QRect r = rect;
   589     QRect r = rect;
   579     QPixmap cache;
   590     QPixmap cache;
   580     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) + pmKey;
   591     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
   581     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   592     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   582         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
   593         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
   583                                          gtkWidget, part, 0, 0, rect.width(), rect.height()));
   594                                          gtkWidget, part, 0, 0, rect.width(), rect.height()));
   584         if (m_usePixmapCache)
   595         if (m_usePixmapCache)
   585             QPixmapCache::insert(pixmapName, cache);
   596             QPixmapCache::insert(pixmapName, cache);
   594 {
   605 {
   595     if (!rect.isValid())
   606     if (!rect.isValid())
   596         return;
   607         return;
   597     QRect r = rect;
   608     QRect r = rect;
   598     QPixmap cache;
   609     QPixmap cache;
   599     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) + pmKey;
   610     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
   600     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   611     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   601         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_flat_box (style,
   612         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_flat_box (style,
   602                                             pixmap,
   613                                             pixmap,
   603                                             state,
   614                                             state,
   604                                             shadow,
   615                                             shadow,
   621     if (!rect.isValid())
   632     if (!rect.isValid())
   622         return;
   633         return;
   623 
   634 
   624     QRect r = rect;
   635     QRect r = rect;
   625     QPixmap cache;
   636     QPixmap cache;
   626     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget);
   637     QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
   627     pixmapName += QString::number(gap_pos);
   638                          % HexString<uchar>(gap_pos);
   628 
   639 
   629     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   640     if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
   630         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_extension (style, pixmap, state, shadow,
   641         DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_extension (style, pixmap, state, shadow,
   631                                              NULL, gtkWidget,
   642                                              NULL, gtkWidget,
   632                                              (gchar*)part, 0, 0,
   643                                              (gchar*)part, 0, 0,