summaryrefslogtreecommitdiffstats
path: root/examples/cursor
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/cursor
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/cursor')
-rw-r--r--examples/cursor/README2
-rw-r--r--examples/cursor/cursor.cpp148
-rw-r--r--examples/cursor/cursor.doc17
-rw-r--r--examples/cursor/cursor.pro10
4 files changed, 177 insertions, 0 deletions
diff --git a/examples/cursor/README b/examples/cursor/README
new file mode 100644
index 00000000..c2040e5f
--- /dev/null
+++ b/examples/cursor/README
@@ -0,0 +1,2 @@
+The cursor sample program displays the predefined cursors and
+creates a custom bitmap cursor.
diff --git a/examples/cursor/cursor.cpp b/examples/cursor/cursor.cpp
new file mode 100644
index 00000000..4252dc34
--- /dev/null
+++ b/examples/cursor/cursor.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
+**
+** This file is part of an example program for TQt. This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include <qlabel.h>
+#include <qbitmap.h>
+#include <qapplication.h>
+#include <qlayout.h>
+#include <qcursor.h>
+
+// cb_bits and cm_bits were generated by X bitmap program.
+
+#define cb_width 32
+#define cb_height 32
+
+static unsigned 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};
+
+#define cm_width 32
+#define cm_height 32
+
+static unsigned 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};
+
+
+//
+// The CursorView contains many labels with different cursors.
+//
+
+class CursorView : public TQWidget // cursor view
+{
+public:
+ CursorView();
+};
+
+//
+// Constructs a cursor view.
+//
+
+CursorView::CursorView() // construct view
+{
+ struct List {
+ CursorShape shape;
+ const char* name; // cursor name
+ };
+ static List list[] = {
+ { ArrowCursor, "arrowCursor" },
+ { UpArrowCursor, "upArrowCursor" },
+ { CrossCursor, "crossCursor" },
+ { WaitCursor, "waitCursor" },
+ { IbeamCursor, "ibeamCursor" },
+ { SizeVerCursor, "sizeVerCursor" },
+ { SizeHorCursor, "sizeHorCursor" },
+ { SizeBDiagCursor, "sizeBDiagCursor" },
+ { SizeFDiagCursor, "sizeFDiagCursor" },
+ { SizeAllCursor, "sizeAllCursor" },
+ { BlankCursor, "blankCursor" },
+ { SplitVCursor, "splitVCursor" },
+ { SplitHCursor, "splitHCursor" },
+ { PointingHandCursor, "pointingHandCursor" },
+ { ForbiddenCursor, "forbiddenCursor" },
+ { WhatsThisCursor, "whatsThisCursor" },
+ { BusyCursor, "busyCursor" }
+ };
+
+ 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( TQCursor( list[i].shape ) );
+ label->setText( list[i].name );
+ label->setAlignment( AlignCenter );
+ label->setMargin( 10 );
+ label->setFrameStyle( TQFrame::Box | TQFrame::Raised );
+ grid->addWidget( label, x, y );
+ i++;
+ }
+ }
+
+
+ label = new TQLabel( this );
+ label->setCursor( TQCursor( list[i].shape ) );
+ label->setText( list[i].name );
+ label->setAlignment( AlignCenter );
+ label->setMargin( 10 );
+ label->setFrameStyle( TQFrame::Box | TQFrame::Raised );
+ grid->addWidget( label, 4, 0 );
+
+
+
+ TQBitmap cb( cb_width, cb_height, cb_bits, TRUE );
+ TQBitmap cm( cm_width, cm_height, cm_bits, TRUE );
+ TQCursor custom( 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->setMargin( 10 );
+ label->setFrameStyle( TQFrame::Box | TQFrame::Sunken );
+ grid->addMultiCellWidget( label, 4, 4, 1, 3 );
+
+}
+
+
+//
+// Create and display a CursorView.
+//
+
+int main( int argc, char **argv )
+{
+ TQApplication a( argc, argv ); // application object
+ CursorView v; // cursor view
+ a.setMainWidget( &v );
+ v.setCaption("TQt Example - Cursors");
+ v.show();
+ return a.exec();
+}
diff --git a/examples/cursor/cursor.doc b/examples/cursor/cursor.doc
new file mode 100644
index 00000000..4bee6d87
--- /dev/null
+++ b/examples/cursor/cursor.doc
@@ -0,0 +1,17 @@
+/*
+*/
+/*! \page cursor-example.html
+
+ \ingroup examples
+ \title Cursors
+
+ This example shows how to set a mouse cursor for a widget.
+
+ <hr>
+
+ Implementation:
+
+ \include cursor/cursor.cpp
+
+*/
+
diff --git a/examples/cursor/cursor.pro b/examples/cursor/cursor.pro
new file mode 100644
index 00000000..23f65935
--- /dev/null
+++ b/examples/cursor/cursor.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+TARGET = cursor
+
+CONFIG += qt warn_on release
+DEPENDPATH = ../../include
+
+REQUIRES = small-config
+
+HEADERS =
+SOURCES = cursor.cpp