karbon

vcursor.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "vcursor.h"
00021 #include <qbitmap.h>
00022 
00023 static const char* const cminus[] = {
00024 "16 16 6 1",
00025 "  c Gray0",
00026 ". c #939393",
00027 "X c Gray63",
00028 "o c #aeaeae",
00029 "O c None",
00030 "+ c Gray100",
00031 "OOOOo    XXoOOOO",
00032 "OOo  ++++  XoOOO",
00033 "OO ++++++++ XoOO",
00034 "Oo ++++++++ XXoO",
00035 "O ++++++++++ XoO",
00036 "O ++      ++ XoO",
00037 "O ++      ++ XoO",
00038 "O ++++++++++ XoO",
00039 "Oo ++++++++ .oOO",
00040 "OO ++++++++ .oOO",
00041 "OOo  ++++   .oOO",
00042 "OOOOo    O   XoO",
00043 "OOOOOOOOOOO   Xo",
00044 "OOOOOOOOOOOO   X",
00045 "OOOOOOOOOOOOO   ",
00046 "OOOOOOOOOOOOOO  "
00047 };
00048 
00049 static const char* const cplus[] = {
00050 "16 16 6 1",
00051 "  c Gray0",
00052 ". c #939393",
00053 "X c Gray63",
00054 "o c #aeaeae",
00055 "O c None",
00056 "+ c Gray100",
00057 "OOOo    XXoOOOOO",
00058 "Oo  ++++  XoOOOO",
00059 "O ++++++++ XoOOO",
00060 "o +++  +++ XXoOO",
00061 " ++++  ++++ XoOO",
00062 " ++      ++ XoOO",
00063 " ++      ++ XoOO",
00064 " ++++  ++++ XoOO",
00065 "o +++  +++ .oOOO",
00066 "O ++++++++ .oOOO",
00067 "Oo  ++++   .oOOO",
00068 "OOOo    O   XoOO",
00069 "OOOOOOOOOO   XoO",
00070 "OOOOOOOOOOO   XO",
00071 "OOOOOOOOOOOO   O",
00072 "OOOOOOOOOOOOO  O"
00073 };
00074 
00075 QCursor VCursor::createCursor( CursorType type )
00076 {
00077     switch( type )
00078     {
00079         case CrossHair:
00080             return crossHair();
00081         break;
00082         case ZoomPlus:
00083             return QCursor( QPixmap( ( const char**) cplus ), -1, -1 );
00084         break;
00085         case ZoomMinus:
00086             return QCursor( QPixmap( ( const char**) cminus ), -1, -1 );
00087         break;
00088         case NeedleArrow:
00089             return needleArrow();
00090         break;
00091         default: return QCursor( Qt::arrowCursor );
00092     }
00093 }
00094 
00095 QCursor VCursor::createCursor( const char * bitmap[], const char * mask[], int hotX, int hotY )
00096 {
00097     // the cursor bitmap and mask
00098     QBitmap b, m;
00099 
00100     b = QPixmap( (const char**) bitmap );
00101     m = QPixmap( (const char**) mask );
00102     
00103     return QCursor( b, m, hotX, hotY );
00104 }
00105 
00106 QCursor VCursor::crossHair()
00107 {
00108     static unsigned char cross_bits[] = {
00109         0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
00110         0x80, 0x00, 0xff, 0x7f, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
00111         0x80, 0x00, 0x80, 0x00, 0x80, 0x00};
00112 
00113     QBitmap b = QBitmap( 15, 15, cross_bits, true );
00114     QBitmap m = b.createHeuristicMask( false );
00115 
00116     return QCursor( b, m, 7, 7 );
00117 }
00118 
00119 QCursor VCursor::needleArrow()
00120 {
00121     static unsigned char needle_bits[] = {
00122         0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x60, 0x00, 0xc0, 0x00, 0xc0, 0x01,
00123         0x80, 0x03, 0x80, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3e, 0x00, 0x7e,
00124         0x00, 0x7c, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x00};
00125 
00126     QBitmap b = QBitmap( 16, 16, needle_bits, true );
00127     QBitmap m = b.createHeuristicMask( false );
00128 
00129     return QCursor( b, m, 2, 0 );
00130 }
00131 
00132 QCursor VCursor::needleMoveArrow()
00133 {
00134     static unsigned char needle_move_bits[] = {
00135         0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x60, 0x00, 0xc0, 0x00, 0xc0, 0x01,
00136         0x80, 0x03, 0x80, 0x07, 0x10, 0x0f, 0x38, 0x1f, 0x54, 0x3e, 0xfe, 0x7e,
00137         0x54, 0x7c, 0x38, 0x1c, 0x10, 0x18, 0x00, 0x00};
00138 
00139     QBitmap b = QBitmap( 16, 16, needle_move_bits, true );
00140     QBitmap m = b.createHeuristicMask( false );
00141 
00142     return QCursor( b, m, 2, 0 );
00143 }
00144 
00145 QCursor VCursor::horzMove()
00146 {
00147 /*
00148     #define horzMove_width 15
00149     #define horzMove_height 15
00150     static unsigned char horzMove_bits[] = {
00151         0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x90, 0x04,
00152         0x98, 0x0c, 0xfc, 0x1f, 0x98, 0x0c, 0x90, 0x04, 0x80, 0x00, 0x80, 0x00,
00153         0x80, 0x00, 0x80, 0x00, 0x00, 0x00};
00154 */
00155     #define horzMove_width 15
00156     #define horzMove_height 15
00157     static unsigned char horzMove_bits[] = {
00158         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08,
00159         0x0c, 0x18, 0xfe, 0x3f, 0x0c, 0x18, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00,
00160         0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00161 
00162     QBitmap b = QBitmap( 15, 15, horzMove_bits, true );
00163     QBitmap m = b.createHeuristicMask( false );
00164 
00165     return QCursor( b, m, 7, 7 );
00166 }
KDE Home | KDE Accessibility Home | Description of Access Keys