karbon

vcursor.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2006 The Karbon Developers
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "vcursor.h"
21#include <tqbitmap.h>
22
23static const char* const cminus[] = {
24"16 16 6 1",
25" c Gray0",
26". c #939393",
27"X c Gray63",
28"o c #aeaeae",
29"O c None",
30"+ c Gray100",
31"OOOOo XXoOOOO",
32"OOo ++++ XoOOO",
33"OO ++++++++ XoOO",
34"Oo ++++++++ XXoO",
35"O ++++++++++ XoO",
36"O ++ ++ XoO",
37"O ++ ++ XoO",
38"O ++++++++++ XoO",
39"Oo ++++++++ .oOO",
40"OO ++++++++ .oOO",
41"OOo ++++ .oOO",
42"OOOOo O XoO",
43"OOOOOOOOOOO Xo",
44"OOOOOOOOOOOO X",
45"OOOOOOOOOOOOO ",
46"OOOOOOOOOOOOOO "
47};
48
49static const char* const cplus[] = {
50"16 16 6 1",
51" c Gray0",
52". c #939393",
53"X c Gray63",
54"o c #aeaeae",
55"O c None",
56"+ c Gray100",
57"OOOo XXoOOOOO",
58"Oo ++++ XoOOOO",
59"O ++++++++ XoOOO",
60"o +++ +++ XXoOO",
61" ++++ ++++ XoOO",
62" ++ ++ XoOO",
63" ++ ++ XoOO",
64" ++++ ++++ XoOO",
65"o +++ +++ .oOOO",
66"O ++++++++ .oOOO",
67"Oo ++++ .oOOO",
68"OOOo O XoOO",
69"OOOOOOOOOO XoO",
70"OOOOOOOOOOO XO",
71"OOOOOOOOOOOO O",
72"OOOOOOOOOOOOO O"
73};
74
76{
77 switch( type )
78 {
79 case CrossHair:
80 return crossHair();
81 break;
82 case ZoomPlus:
83 return TQCursor( TQPixmap( ( const char**) cplus ), -1, -1 );
84 break;
85 case ZoomMinus:
86 return TQCursor( TQPixmap( ( const char**) cminus ), -1, -1 );
87 break;
88 case NeedleArrow:
89 return needleArrow();
90 break;
91 default: return TQCursor( TQt::arrowCursor );
92 }
93}
94
95TQCursor VCursor::createCursor( const char * bitmap[], const char * mask[], int hotX, int hotY )
96{
97 // the cursor bitmap and mask
98 TQBitmap b, m;
99
100 b = TQPixmap( (const char**) bitmap );
101 m = TQPixmap( (const char**) mask );
102
103 return TQCursor( b, m, hotX, hotY );
104}
105
107{
108 static unsigned char cross_bits[] = {
109 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
110 0x80, 0x00, 0xff, 0x7f, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
111 0x80, 0x00, 0x80, 0x00, 0x80, 0x00};
112
113 TQBitmap b = TQBitmap( 15, 15, cross_bits, true );
114 TQBitmap m = b.createHeuristicMask( false );
115
116 return TQCursor( b, m, 7, 7 );
117}
118
120{
121 static unsigned char needle_bits[] = {
122 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x60, 0x00, 0xc0, 0x00, 0xc0, 0x01,
123 0x80, 0x03, 0x80, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3e, 0x00, 0x7e,
124 0x00, 0x7c, 0x00, 0x1c, 0x00, 0x18, 0x00, 0x00};
125
126 TQBitmap b = TQBitmap( 16, 16, needle_bits, true );
127 TQBitmap m = b.createHeuristicMask( false );
128
129 return TQCursor( b, m, 2, 0 );
130}
131
133{
134 static unsigned char needle_move_bits[] = {
135 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x60, 0x00, 0xc0, 0x00, 0xc0, 0x01,
136 0x80, 0x03, 0x80, 0x07, 0x10, 0x0f, 0x38, 0x1f, 0x54, 0x3e, 0xfe, 0x7e,
137 0x54, 0x7c, 0x38, 0x1c, 0x10, 0x18, 0x00, 0x00};
138
139 TQBitmap b = TQBitmap( 16, 16, needle_move_bits, true );
140 TQBitmap m = b.createHeuristicMask( false );
141
142 return TQCursor( b, m, 2, 0 );
143}
144
145TQCursor VCursor::horzMove()
146{
147/*
148 #define horzMove_width 15
149 #define horzMove_height 15
150 static unsigned char horzMove_bits[] = {
151 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x90, 0x04,
152 0x98, 0x0c, 0xfc, 0x1f, 0x98, 0x0c, 0x90, 0x04, 0x80, 0x00, 0x80, 0x00,
153 0x80, 0x00, 0x80, 0x00, 0x00, 0x00};
154*/
155 #define horzMove_width 15
156 #define horzMove_height 15
157 static unsigned char horzMove_bits[] = {
158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08,
159 0x0c, 0x18, 0xfe, 0x3f, 0x0c, 0x18, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00,
160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
161
162 TQBitmap b = TQBitmap( 15, 15, horzMove_bits, true );
163 TQBitmap m = b.createHeuristicMask( false );
164
165 return TQCursor( b, m, 7, 7 );
166}
static TQCursor needleMoveArrow()
needle arrow with four way arrow
Definition vcursor.cpp:132
static TQCursor crossHair()
crosshair cursor
Definition vcursor.cpp:106
CursorType
Predefined cursor types.
Definition vcursor.h:37
@ ZoomMinus
zoom out cursor
Definition vcursor.h:40
@ NeedleArrow
needle arrow
Definition vcursor.h:41
@ ZoomPlus
zoom in cursor
Definition vcursor.h:39
@ CrossHair
unthemed crosshair cursor
Definition vcursor.h:38
static TQCursor needleArrow()
needle arraow cursor
Definition vcursor.cpp:119
static TQCursor createCursor(CursorType type)
Creates a predefined cursor of the specified type.
Definition vcursor.cpp:75