src/video/qtopia/SDL_QWin.cc
author Sam Lantinga <slouken@libsdl.org>
Sun, 28 May 2006 13:29:03 +0000
branchSDL-1.3
changeset 1663 11775724e3fe
parent 1662 782fd950bd46
child 1664 cd3db072ba8a
permissions -rw-r--r--
fine tuning indent output
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #include "SDL_QWin.h"
    25 #include <qapplication.h>
    26 #include <qdirectpainter_qws.h>
    27 
    28 screenRotationT screenRotation = SDL_QT_NO_ROTATION;
    29 
    30 SDL_QWin::SDL_QWin (const QSize & size):
    31 QWidget (0, "SDL_main"),
    32 my_painter (0),
    33 my_image (0),
    34 my_inhibit_resize (false),
    35 my_mouse_pos (-1, -1),
    36 my_flags (0),
    37 my_has_fullscreen (false),
    38 my_locked (0)
    39 {
    40     setBackgroundMode (NoBackground);
    41 }
    42 
    43 SDL_QWin::~SDL_QWin ()
    44 {
    45     // Nothing to do yet.
    46     if (my_image) {
    47         delete my_image;
    48     }
    49 }
    50 
    51 void
    52 SDL_QWin::setImage (QImage * image)
    53 {
    54     if (my_image) {
    55         delete my_image;
    56     }
    57     my_image = image;
    58     //  setFixedSize(image->size());
    59 }
    60 
    61 void
    62 SDL_QWin::resizeEvent (QResizeEvent * e)
    63 {
    64     if (size () != qApp->desktop ()->size ()) {
    65         // Widget is not the correct size, so do the fullscreen magic
    66         my_has_fullscreen = false;
    67         enableFullscreen ();
    68     }
    69     if (my_inhibit_resize) {
    70         my_inhibit_resize = false;
    71     } else {
    72         SDL_PrivateResize (e->size ().width (), e->size ().height ());
    73     }
    74 }
    75 
    76 void
    77 SDL_QWin::focusInEvent (QFocusEvent *)
    78 {
    79     // Always do it here, no matter the size.
    80     enableFullscreen ();
    81     SDL_PrivateAppActive (true, SDL_APPINPUTFOCUS);
    82 }
    83 
    84 void
    85 SDL_QWin::focusOutEvent (QFocusEvent *)
    86 {
    87     my_has_fullscreen = false;
    88     SDL_PrivateAppActive (false, SDL_APPINPUTFOCUS);
    89 }
    90 
    91 void
    92 SDL_QWin::closeEvent (QCloseEvent * e)
    93 {
    94     SDL_PrivateQuit ();
    95     e->ignore ();
    96 }
    97 
    98 void
    99 SDL_QWin::setMousePos (const QPoint & pos)
   100 {
   101     if (my_image->width () == height ()) {
   102         if (screenRotation == SDL_QT_ROTATION_90)
   103             my_mouse_pos = QPoint (height () - pos.y (), pos.x ());
   104         else if (screenRotation == SDL_QT_ROTATION_270)
   105             my_mouse_pos = QPoint (pos.y (), width () - pos.x ());
   106     } else {
   107         my_mouse_pos = pos;
   108     }
   109 }
   110 
   111 void
   112 SDL_QWin::mouseMoveEvent (QMouseEvent * e)
   113 {
   114     Qt::ButtonState button = e->button ();
   115     int sdlstate = 0;
   116     if ((button & Qt::LeftButton)) {
   117         sdlstate |= SDL_BUTTON_LMASK;
   118     }
   119     if ((button & Qt::RightButton)) {
   120         sdlstate |= SDL_BUTTON_RMASK;
   121     }
   122     if ((button & Qt::MidButton)) {
   123         sdlstate |= SDL_BUTTON_MMASK;
   124     }
   125     setMousePos (e->pos ());
   126     SDL_PrivateMouseMotion (sdlstate, 0, my_mouse_pos.x (),
   127                             my_mouse_pos.y ());
   128 }
   129 
   130 void
   131 SDL_QWin::mousePressEvent (QMouseEvent * e)
   132 {
   133     mouseMoveEvent (e);
   134     Qt::ButtonState button = e->button ();
   135     SDL_PrivateMouseButton (SDL_PRESSED,
   136                             (button & Qt::LeftButton) ? 1 :
   137                             ((button & Qt::RightButton) ? 2 : 3),
   138                             my_mouse_pos.x (), my_mouse_pos.y ());
   139 }
   140 
   141 void
   142 SDL_QWin::mouseReleaseEvent (QMouseEvent * e)
   143 {
   144     setMousePos (e->pos ());
   145     Qt::ButtonState button = e->button ();
   146     SDL_PrivateMouseButton (SDL_RELEASED,
   147                             (button & Qt::LeftButton) ? 1 :
   148                             ((button & Qt::RightButton) ? 2 : 3),
   149                             my_mouse_pos.x (), my_mouse_pos.y ());
   150     my_mouse_pos = QPoint (-1, -1);
   151 }
   152 
   153 static inline void
   154 gs_fastRotateBlit_3 (unsigned short *fb,
   155                      unsigned short *bits, const QRect & rect)
   156 {
   157     // FIXME: this only works correctly for 240x320 displays
   158     int startx, starty;
   159     int width, height;
   160 
   161     startx = rect.left () >> 1;
   162     starty = rect.top () >> 1;
   163     width = ((rect.right () - rect.left ()) >> 1) + 2;
   164     height = ((rect.bottom () - rect.top ()) >> 1) + 2;
   165 
   166     if ((startx + width) > 120) {
   167         width = 120 - startx;   // avoid horizontal overflow
   168     }
   169     if ((starty + height) > 160) {
   170         height = 160 - starty;  // avoid vertical overflow
   171     }
   172 
   173     ulong *sp1, *sp2, *dp1, *dp2;
   174     ulong stop, sbot, dtop, dbot;
   175 
   176     sp1 = (ulong *) bits + startx + starty * 240;
   177     sp2 = sp1 + 120;
   178     dp1 = (ulong *) fb + (159 - starty) + startx * 320;
   179     dp2 = dp1 + 160;
   180     int rowadd = (-320 * width) - 1;
   181     int rowadd2 = 240 - width;
   182     // transfer in cells of 2x2 pixels in words
   183     for (int y = 0; y < height; y++) {
   184         for (int x = 0; x < width; x++) {
   185             // read source pixels
   186             stop = *sp1;
   187             sbot = *sp2;
   188             // rotate pixels
   189             dtop = (sbot & 0xffff) + ((stop & 0xffff) << 16);
   190             dbot = ((sbot & 0xffff0000) >> 16) + (stop & 0xffff0000);
   191             // write to framebuffer
   192             *dp1 = dtop;
   193             *dp2 = dbot;
   194             // update source ptrs
   195             sp1++;
   196             sp2++;
   197             // update dest ptrs - 2 pix at a time
   198             dp1 += 320;
   199             dp2 += 320;
   200         }
   201         // adjust src ptrs - skip a row as we work in pairs
   202         sp1 += rowadd2;
   203         sp2 += rowadd2;
   204         // adjust dest ptrs for rotation
   205         dp1 += rowadd;
   206         dp2 += rowadd;
   207     }
   208 }
   209 
   210 static inline void
   211 gs_fastRotateBlit_1 (unsigned short *fb,
   212                      unsigned short *bits, const QRect & rect)
   213 {
   214     // FIXME: this only works correctly for 240x320 displays
   215     int startx, starty;
   216     int width, height;
   217 
   218     startx = rect.left () >> 1;
   219     starty = rect.top () >> 1;
   220     width = ((rect.right () - rect.left ()) >> 1) + 2;
   221     height = ((rect.bottom () - rect.top ()) >> 1) + 2;
   222 
   223     if ((startx + width) > 120) {
   224         width = 120 - startx;   // avoid horizontal overflow
   225     }
   226     if ((starty + height) > 160) {
   227         height = 160 - starty;  // avoid vertical overflow
   228     }
   229 
   230     ulong *sp1, *sp2, *dp1, *dp2;
   231     ulong stop, sbot, dtop, dbot;
   232     fb += 320 * 239;            // Move "fb" to top left corner
   233     sp1 = (ulong *) bits + startx + starty * 240;
   234     sp2 = sp1 + 120;
   235     dp1 = (ulong *) fb - startx * 320 - starty;
   236     dp2 = dp1 - 160;
   237     int rowadd = (320 * width) + 1;
   238     int rowadd2 = 240 - width;
   239     // transfer in cells of 2x2 pixels in words
   240     for (int y = 0; y < height; y++) {
   241         for (int x = 0; x < width; x++) {
   242             // read
   243             stop = *sp1;
   244             sbot = *sp2;
   245             // rotate
   246             dtop = (stop & 0xffff) + ((sbot & 0xffff) << 16);
   247             dbot = ((stop & 0xffff0000) >> 16) + (sbot & 0xffff0000);
   248             // write
   249             *dp1 = dtop;
   250             *dp2 = dbot;
   251             // update source ptrs
   252             sp1++;
   253             sp2++;
   254             // update dest ptrs - 2 pix at a time
   255             dp1 -= 320;
   256             dp2 -= 320;
   257         }
   258         // adjust src ptrs - skip a row as we work in pairs
   259         sp1 += rowadd2;
   260         sp2 += rowadd2;
   261         // adjust dest ptrs for rotation
   262         dp1 += rowadd;
   263         dp2 += rowadd;
   264     }
   265 }
   266 
   267 // desktop, SL-A300 etc
   268 bool
   269 SDL_QWin::repaintRotation0 (const QRect & rect)
   270 {
   271     if (my_image->width () == width ()) {
   272         uchar *fb = (uchar *) my_painter->frameBuffer ();
   273         uchar *buf = (uchar *) my_image->bits ();
   274         if (rect == my_image->rect ()) {
   275             SDL_memcpy (fb, buf, width () * height () * 2);
   276         } else {
   277             int h = rect.height ();
   278             int wd = rect.width () << 1;
   279             int fblineadd = my_painter->lineStep ();
   280             int buflineadd = my_image->bytesPerLine ();
   281             fb += (rect.left () << 1) + rect.top () * my_painter->lineStep ();
   282             buf +=
   283                 (rect.left () << 1) + rect.top () * my_image->bytesPerLine ();
   284             while (h--) {
   285                 SDL_memcpy (fb, buf, wd);
   286                 fb += fblineadd;
   287                 buf += buflineadd;
   288             }
   289         }
   290     } else {
   291         return false;           // FIXME: Landscape
   292     }
   293 #ifdef __i386__
   294     my_painter->fillRect (rect, QBrush (Qt::NoBrush));
   295 #endif
   296     return true;
   297 }
   298 
   299 
   300 // Sharp Zaurus SL-5500 etc 
   301 bool
   302 SDL_QWin::repaintRotation3 (const QRect & rect)
   303 {
   304     if (my_image->width () == width ()) {
   305         ushort *fb = (ushort *) my_painter->frameBuffer ();
   306         ushort *buf = (ushort *) my_image->bits ();
   307         gs_fastRotateBlit_3 (fb, buf, rect);
   308     } else {
   309         // landscape mode
   310         if (screenRotation == SDL_QT_ROTATION_90) {
   311             uchar *fb = (uchar *) my_painter->frameBuffer ();
   312             uchar *buf = (uchar *) my_image->bits ();
   313             if (rect == my_image->rect ()) {
   314                 SDL_memcpy (fb, buf, width () * height () * 2);
   315             } else {
   316                 int h = rect.height ();
   317                 int wd = rect.width () << 1;
   318                 int fblineadd = my_painter->lineStep ();
   319                 int buflineadd = my_image->bytesPerLine ();
   320                 fb +=
   321                     (rect.left () << 1) +
   322                     rect.top () * my_painter->lineStep ();
   323                 buf +=
   324                     (rect.left () << 1) +
   325                     rect.top () * my_image->bytesPerLine ();
   326                 while (h--) {
   327                     SDL_memcpy (fb, buf, wd);
   328                     fb += fblineadd;
   329                     buf += buflineadd;
   330                 }
   331             }
   332         } else if (screenRotation == SDL_QT_ROTATION_270) {
   333             int h = rect.height ();
   334             int wd = rect.width ();
   335             int fblineadd = my_painter->lineStep () - (rect.width () << 1);
   336             int buflineadd = my_image->bytesPerLine () - (rect.width () << 1);
   337             int w;
   338 
   339             uchar *fb = (uchar *) my_painter->frameBuffer ();
   340             uchar *buf = (uchar *) my_image->bits ();
   341 
   342             fb +=
   343                 ((my_painter->width () -
   344                   (rect.top () +
   345                    rect.height ())) * my_painter->lineStep ()) +
   346                 ((my_painter->height () -
   347                   ((rect.left () + rect.width ()))) << 1);
   348 
   349             buf +=
   350                 my_image->bytesPerLine () * (rect.top () +
   351                                              rect.height ()) -
   352                 (((my_image->width () -
   353                    (rect.left () + rect.width ())) << 1) + 2);
   354 
   355             while (h--) {
   356                 w = wd;
   357                 while (w--)
   358                     *((unsigned short *) fb)++ = *((unsigned short *) buf)--;
   359                 fb += fblineadd;
   360                 buf -= buflineadd;
   361             }
   362         }
   363     }
   364     return true;
   365 }
   366 
   367 // ipaq 3800...
   368 bool
   369 SDL_QWin::repaintRotation1 (const QRect & rect)
   370 {
   371     if (my_image->width () == width ()) {
   372         ushort *fb = (ushort *) my_painter->frameBuffer ();
   373         ushort *buf = (ushort *) my_image->bits ();
   374         gs_fastRotateBlit_1 (fb, buf, rect);
   375     } else {
   376         return false;           // FIXME: landscape mode
   377     }
   378     return true;
   379 }
   380 
   381 void
   382 SDL_QWin::repaintRect (const QRect & rect)
   383 {
   384     if (!my_painter || !rect.width () || !rect.height ()) {
   385         return;
   386     }
   387 
   388     if (QPixmap::defaultDepth () == 16) {
   389         switch (my_painter->transformOrientation ()) {
   390         case 3:
   391             if (repaintRotation3 (rect)) {
   392                 return;
   393             }
   394             break;
   395         case 1:
   396             if (repaintRotation1 (rect)) {
   397                 return;
   398             }
   399             break;
   400         case 0:
   401             if (repaintRotation0 (rect)) {
   402                 return;
   403             }
   404             break;
   405         }
   406     }
   407     my_painter->drawImage (rect.topLeft (), *my_image, rect);
   408 }
   409 
   410 // This paints the current buffer to the screen, when desired. 
   411 void
   412 SDL_QWin::paintEvent (QPaintEvent * ev)
   413 {
   414     if (my_image) {
   415         lockScreen (true);
   416         repaintRect (ev->rect ());
   417         unlockScreen ();
   418     }
   419 }
   420 
   421 /* Function to translate a keyboard transition and queue the key event
   422  * This should probably be a table although this method isn't exactly
   423  * slow.
   424  */
   425 void
   426 SDL_QWin::QueueKey (QKeyEvent * e, int pressed)
   427 {
   428     SDL_keysym keysym;
   429     int scancode = e->key ();
   430     /* Set the keysym information */
   431     if (scancode >= 'A' && scancode <= 'Z') {
   432         // Qt sends uppercase, SDL wants lowercase
   433         keysym.sym = static_cast < SDLKey > (scancode + 32);
   434     } else if (scancode >= 0x1000) {
   435         // Special keys
   436         switch (scancode) {
   437         case Qt::Key_Escape:
   438             scancode = SDLK_ESCAPE;
   439             break;
   440         case Qt::Key_Tab:
   441             scancode = SDLK_TAB;
   442             break;
   443         case Qt::Key_Backspace:
   444             scancode = SDLK_BACKSPACE;
   445             break;
   446         case Qt::Key_Return:
   447             scancode = SDLK_RETURN;
   448             break;
   449         case Qt::Key_Enter:
   450             scancode = SDLK_KP_ENTER;
   451             break;
   452         case Qt::Key_Insert:
   453             scancode = SDLK_INSERT;
   454             break;
   455         case Qt::Key_Delete:
   456             scancode = SDLK_DELETE;
   457             break;
   458         case Qt::Key_Pause:
   459             scancode = SDLK_PAUSE;
   460             break;
   461         case Qt::Key_Print:
   462             scancode = SDLK_PRINT;
   463             break;
   464         case Qt::Key_SysReq:
   465             scancode = SDLK_SYSREQ;
   466             break;
   467         case Qt::Key_Home:
   468             scancode = SDLK_HOME;
   469             break;
   470         case Qt::Key_End:
   471             scancode = SDLK_END;
   472             break;
   473             // We want the control keys to rotate with the screen
   474         case Qt::Key_Left:
   475             if (screenRotation == SDL_QT_ROTATION_90)
   476                 scancode = SDLK_UP;
   477             else if (screenRotation == SDL_QT_ROTATION_270)
   478                 scancode = SDLK_DOWN;
   479             else
   480                 scancode = SDLK_LEFT;
   481             break;
   482         case Qt::Key_Up:
   483             if (screenRotation == SDL_QT_ROTATION_90)
   484                 scancode = SDLK_RIGHT;
   485             else if (screenRotation == SDL_QT_ROTATION_270)
   486                 scancode = SDLK_LEFT;
   487             else
   488                 scancode = SDLK_UP;
   489             break;
   490         case Qt::Key_Right:
   491             if (screenRotation == SDL_QT_ROTATION_90)
   492                 scancode = SDLK_DOWN;
   493             else if (screenRotation == SDL_QT_ROTATION_270)
   494                 scancode = SDLK_UP;
   495             else
   496                 scancode = SDLK_RIGHT;
   497             break;
   498         case Qt::Key_Down:
   499             if (screenRotation == SDL_QT_ROTATION_90)
   500                 scancode = SDLK_LEFT;
   501             else if (screenRotation == SDL_QT_ROTATION_270)
   502                 scancode = SDLK_RIGHT;
   503             else
   504                 scancode = SDLK_DOWN;
   505             break;
   506         case Qt::Key_Prior:
   507             scancode = SDLK_PAGEUP;
   508             break;
   509         case Qt::Key_Next:
   510             scancode = SDLK_PAGEDOWN;
   511             break;
   512         case Qt::Key_Shift:
   513             scancode = SDLK_LSHIFT;
   514             break;
   515         case Qt::Key_Control:
   516             scancode = SDLK_LCTRL;
   517             break;
   518         case Qt::Key_Meta:
   519             scancode = SDLK_LMETA;
   520             break;
   521         case Qt::Key_Alt:
   522             scancode = SDLK_LALT;
   523             break;
   524         case Qt::Key_CapsLock:
   525             scancode = SDLK_CAPSLOCK;
   526             break;
   527         case Qt::Key_NumLock:
   528             scancode = SDLK_NUMLOCK;
   529             break;
   530         case Qt::Key_ScrollLock:
   531             scancode = SDLK_SCROLLOCK;
   532             break;
   533         case Qt::Key_F1:
   534             scancode = SDLK_F1;
   535             break;
   536         case Qt::Key_F2:
   537             scancode = SDLK_F2;
   538             break;
   539         case Qt::Key_F3:
   540             scancode = SDLK_F3;
   541             break;
   542         case Qt::Key_F4:
   543             scancode = SDLK_F4;
   544             break;
   545         case Qt::Key_F5:
   546             scancode = SDLK_F5;
   547             break;
   548         case Qt::Key_F6:
   549             scancode = SDLK_F6;
   550             break;
   551         case Qt::Key_F7:
   552             scancode = SDLK_F7;
   553             break;
   554         case Qt::Key_F8:
   555             scancode = SDLK_F8;
   556             break;
   557         case Qt::Key_F9:
   558             scancode = SDLK_F9;
   559             break;
   560         case Qt::Key_F10:
   561             scancode = SDLK_F10;
   562             break;
   563         case Qt::Key_F11:
   564             scancode = SDLK_F11;
   565             break;
   566         case Qt::Key_F12:
   567             scancode = SDLK_F12;
   568             break;
   569         case Qt::Key_F13:
   570             scancode = SDLK_F13;
   571             break;
   572         case Qt::Key_F14:
   573             scancode = SDLK_F14;
   574             break;
   575         case Qt::Key_F15:
   576             scancode = SDLK_F15;
   577             break;
   578         case Qt::Key_Super_L:
   579             scancode = SDLK_LSUPER;
   580             break;
   581         case Qt::Key_Super_R:
   582             scancode = SDLK_RSUPER;
   583             break;
   584         case Qt::Key_Menu:
   585             scancode = SDLK_MENU;
   586             break;
   587         case Qt::Key_Help:
   588             scancode = SDLK_HELP;
   589             break;
   590 
   591         case Qt::Key_F33:
   592             // FIXME: This is a hack to enable the OK key on
   593             // Zaurii devices. SDLK_RETURN is a suitable key to use
   594             // since it often is used as such.
   595             //     david@hedbor.org
   596             scancode = SDLK_RETURN;
   597             break;
   598         default:
   599             scancode = SDLK_UNKNOWN;
   600             break;
   601         }
   602         keysym.sym = static_cast < SDLKey > (scancode);
   603     } else {
   604         keysym.sym = static_cast < SDLKey > (scancode);
   605     }
   606     keysym.scancode = scancode;
   607     keysym.mod = KMOD_NONE;
   608     ButtonState st = e->state ();
   609     if ((st & ShiftButton)) {
   610         keysym.mod = static_cast < SDLMod > (keysym.mod | KMOD_LSHIFT);
   611     }
   612     if ((st & ControlButton)) {
   613         keysym.mod = static_cast < SDLMod > (keysym.mod | KMOD_LCTRL);
   614     }
   615     if ((st & AltButton)) {
   616         keysym.mod = static_cast < SDLMod > (keysym.mod | KMOD_LALT);
   617     }
   618     if (SDL_TranslateUNICODE) {
   619         QChar qchar = e->text ()[0];
   620         keysym.unicode = qchar.unicode ();
   621     } else {
   622         keysym.unicode = 0;
   623     }
   624 
   625     /* NUMLOCK and CAPSLOCK are implemented as double-presses in reality */
   626     //    if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) {
   627     //            pressed = 1;
   628     //    }
   629 
   630     /* Queue the key event */
   631     if (pressed) {
   632         SDL_PrivateKeyboard (SDL_PRESSED, &keysym);
   633     } else {
   634         SDL_PrivateKeyboard (SDL_RELEASED, &keysym);
   635     }
   636 }
   637 
   638 void
   639 SDL_QWin::setFullscreen (bool fs_on)
   640 {
   641     my_has_fullscreen = false;
   642     enableFullscreen ();
   643 }
   644 
   645 void
   646 SDL_QWin::enableFullscreen ()
   647 {
   648     // Make sure size is correct
   649     if (!my_has_fullscreen) {
   650         setFixedSize (qApp->desktop ()->size ());
   651         // This call is needed because showFullScreen won't work
   652         // correctly if the widget already considers itself to be fullscreen.
   653         showNormal ();
   654         // This is needed because showNormal() forcefully changes the window
   655         // style to WSTyle_TopLevel.
   656         setWFlags (WStyle_Customize | WStyle_NoBorder);
   657         // Enable fullscreen.
   658         showFullScreen ();
   659         my_has_fullscreen = true;
   660     }
   661 }
   662 
   663 bool
   664 SDL_QWin::lockScreen (bool force)
   665 {
   666     if (!my_painter) {
   667         if (force || (isVisible () && isActiveWindow ())) {
   668             my_painter = new QDirectPainter (this);
   669         } else {
   670             return false;
   671         }
   672     }
   673     my_locked++;                // Increate lock refcount
   674     return true;
   675 }
   676 
   677 void
   678 SDL_QWin::unlockScreen ()
   679 {
   680     if (my_locked > 0) {
   681         my_locked--;            // decrease lock refcount;
   682     }
   683     if (!my_locked && my_painter) {
   684         my_painter->end ();
   685         delete my_painter;
   686         my_painter = 0;
   687     }
   688 }
   689 
   690 /* vi: set ts=4 sw=4 expandtab: */