summaryrefslogtreecommitdiffstats
path: root/qtjava/javalib/examples/cursor/CursorView.java
blob: 2b6d971ca435004582b12bdc9326a9f42a6a1557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/***************************************************************************
* $Id$
**
* Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
* This file is part of an example program for Qt.  This example
* program may be used, distributed and modified without limitation.
**
****************************************************************************/

import org.kde.qt.*;

//
// The CursorView contains many labels with different cursors.
//

class CursorView extends TQWidget		// cursor view
{

// cb_bits and cm_bits were generated by X bitmap program.

static final int cb_width  = 32;
static final int cb_height = 32;

static char cb_bits[] = {		// cursor bitmap
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00,
   0x00, 0x06, 0x30, 0x00, 0x80, 0x01, 0xc0, 0x00, 0x40, 0x00, 0x00, 0x01,
   0x20, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x04, 0x08, 0x3e, 0x3e, 0x08,
   0x08, 0x03, 0xe0, 0x08, 0xc4, 0x00, 0x00, 0x11, 0x04, 0x1e, 0x78, 0x10,
   0x02, 0x0c, 0x30, 0x20, 0x02, 0x40, 0x00, 0x20, 0x02, 0x40, 0x00, 0x20,
   0x02, 0x40, 0x00, 0x20, 0x02, 0x20, 0x04, 0x20, 0x02, 0x20, 0x04, 0x20,
   0x02, 0x10, 0x08, 0x20, 0x02, 0x08, 0x08, 0x20, 0x02, 0xf0, 0x07, 0x20,
   0x04, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x10, 0x08, 0x00, 0xc0, 0x08,
   0x08, 0x3c, 0x30, 0x08, 0x10, 0xe6, 0x19, 0x04, 0x20, 0x00, 0x0f, 0x02,
   0x40, 0x00, 0x00, 0x01, 0x80, 0x01, 0xc0, 0x00, 0x00, 0x06, 0x30, 0x00,
   0x00, 0xf8, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00};

static final int cm_width  = 32;
static final int cm_height = 32;

static char cm_bits[] = {		// cursor bitmap mask
   0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xfe, 0x3f, 0x00,
   0x80, 0x07, 0xf0, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0x60, 0x00, 0x00, 0x03,
   0x30, 0x00, 0x00, 0x06, 0x18, 0x00, 0x00, 0x0c, 0x0c, 0x3e, 0x3e, 0x18,
   0x0e, 0x03, 0xe0, 0x18, 0xc6, 0x00, 0x00, 0x31, 0x07, 0x1e, 0x78, 0x30,
   0x03, 0x0c, 0x30, 0x60, 0x03, 0x40, 0x00, 0x60, 0x03, 0x40, 0x00, 0x60,
   0x03, 0x40, 0x00, 0x60, 0x03, 0x20, 0x04, 0x60, 0x03, 0x20, 0x04, 0x60,
   0x03, 0x10, 0x08, 0x60, 0x03, 0x08, 0x08, 0x60, 0x03, 0xf0, 0x07, 0x60,
   0x06, 0x00, 0x00, 0x30, 0x06, 0x00, 0x00, 0x30, 0x0c, 0x00, 0xc0, 0x18,
   0x0c, 0x3c, 0x30, 0x18, 0x18, 0xe6, 0x19, 0x0c, 0x30, 0x00, 0x0f, 0x06,
   0x60, 0x00, 0x00, 0x03, 0xc0, 0x01, 0xc0, 0x01, 0x80, 0x07, 0xf0, 0x00,
   0x00, 0xfe, 0x3f, 0x00, 0x00, 0xf8, 0x0f, 0x00};


    static int[] shapeList = {
	ArrowCursor,
	UpArrowCursor,
	CrossCursor,
	WaitCursor,
	IbeamCursor,
	SizeVerCursor,
	SizeHorCursor,
	SizeBDiagCursor,
	SizeFDiagCursor,
	SizeAllCursor,
	BlankCursor,
	SplitVCursor,
	SplitHCursor,
	PointingHandCursor,
	ForbiddenCursor,
	WhatsThisCursor
    };
    
	static String[] nameList = {
	"arrowCursor" ,
	"upArrowCursor" ,
	"crossCursor" ,
	"waitCursor" ,
	"ibeamCursor" ,
	"sizeVerCursor" ,
	"sizeHorCursor" ,
	"sizeBDiagCursor" ,
	"sizeFDiagCursor" ,
	"sizeAllCursor" ,
	"blankCursor" ,
	"splitVCursor" ,
	"splitHCursor" ,
	"pointingHandCursor" ,
	"forbiddenCursor" ,
	"whatsThisCursor"
    };

//
// Constructs a cursor view.
//

public CursorView()			// construct view
{
    setCaption( "CursorView" );			// set window caption

    TQGridLayout grid = new TQGridLayout( this, 5, 4, 20 );
    TQLabel label;

    int i=0;
    for ( int y=0; y<4; y++ ) {			// create the small labels
	for ( int x=0; x<4; x++ ) {
	    label = new TQLabel( this );
	    label.setCursor( new TQCursor( shapeList[i] ) );
	    label.setText( nameList[i] );
	    label.setAlignment( AlignCenter );
	    label.setFrameStyle( TQFrame.Box | TQFrame.Raised );
	    grid.addWidget( label, x, y );
	    i++;
	}
    }

    TQBitmap cb = new TQBitmap( cb_width, cb_height, cb_bits, true );
    TQBitmap cm = new TQBitmap( cm_width, cm_height, cm_bits, true );
    TQCursor custom = new TQCursor( cb, cm );			// create bitmap cursor

    label = new TQLabel( this );			// create the big label
    label.setCursor( custom );
    label.setText( "Custom bitmap cursor" );
    label.setAlignment( AlignCenter );
    label.setFrameStyle( TQFrame.Box | TQFrame.Sunken );
    grid.addMultiCellWidget( label, 4, 4, 0, 3 );

}


//
// Create and display a CursorView.
//

public static void main( String[] args )
{
    TQApplication a = new TQApplication( args );		// application object
    CursorView   v = new  CursorView();				// cursor view
    a.setMainWidget( v );
    v.setCaption("Qt Example - Cursors");
    v.show();
    a.exec();
    return;
}

static {
	qtjava.initialize();
}

}