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
|
/*
* UnixCW - Unix CW (Morse code) training program
* Copyright (C) 2001 Simon Baldwin (simonb@caldera.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
* XcwcpApplication.h - Class header for Qt-based CW tutor program.
*
*/
#ifndef XCWCP_H
#define XCWCP_H
#include <qmainwindow.h>
class QKeyEvent;
class QComboBox;
class QSpinBox;
class QToolButton;
class QCheckBox;
class QTimer;
class XcwcpMultiLineEdit;
class XcwcpApplication: public QMainWindow
{
Q_OBJECT
public:
XcwcpApplication (); /* Class constructor */
~XcwcpApplication (); /* Class destructor */
void key_event (QKeyEvent*); /* Handle key press/release */
void mouse_event (QMouseEvent*); /* Handle mouse press/release */
protected:
void closeEvent (QCloseEvent*);
/* Close app callback */
private slots:
/* Qt widget library callback methods. */
void about (); /* About dialog */
void startstop (); /* Start/stop sending toggle */
void start (); /* Start sending */
void stop (); /* Stop sending */
void new_xcwcp (); /* Open a new window */
void clear (); /* Clear the display window */
void sync_speed (); /* Force adaptive speed */
void speed_change (); /* Handle speed change */
void frequency_change (); /* Handle tone change */
void gap_change (); /* Handle gap change */
void mode_change (); /* Handle mode change */
void curtis_mode_b_change ();/* Handle Curtis mode change */
void adaptive_receive_change ();
/* Handle speed mode change */
void timer_event (); /* Receive poll timeout call */
private:
/* Class variable to enable sharing of the cwlib across instances. */
static XcwcpApplication
*cwlib_user_object_reference;
/* 'this' of CW user instance */
/* GUI elements used throughout the class. */
QComboBox *mode_combo; /* Mode selector */
QSpinBox *speed_spin, *frequency_spin, *gap_spin;
/* Speed/tone/gap settings */
XcwcpMultiLineEdit
*display; /* Sent char display */
QToolButton *startstop_button; /* Toolbar start/stop button */
QCheckBox *reverse_paddles; /* Reverse paddles option */
QCheckBox *curtis_mode_b; /* Curtis mode B option */
QCheckBox *adaptive_receive; /* Adaptive speed option */
/* Receive poll timer. */
QTimer *poll_timer; /* Receive poll timer. */
/* Circular buffer of cw characters awaiting send. */
unsigned char cq_queue[ 256 ]; /* Buffer */
int cq_head; /* Buffer head index */
int cq_tail; /* Buffer tail index */
enum{CQ_IDLE,CQ_ACTIVE}
cq_dequeue_state; /* State of dequeuing chars */
/* Monitor the state of CW library use - either active, or idle. */
enum state {STATE_IDLE,STATE_ACTIVE}
cwlib_use_state; /* Active or idle */
/* Saved receive speed, to reinstate adaptive tracked speed on start. */
int saved_receive_speed;
/* Circular buffer manipulation functions. */
void queue_character (unsigned char);
/* Queue a character */
void dequeue_character (); /* Dequeue a character */
void unqueue_character (); /* Delete a queued character */
/* Polling for completed receive characters. */
void poll_receive (); /* Look for receive character */
/*
* Callback functions for cwlib. For each, there is a static version
* for the whole class, and an instance version for each object.
* The class version calls the relevant instance version, based on
* which instance is the current registered cwlib user.
*/
static void cwlib_callback_event_static ();
void cwlib_callback_event ();
static void cwlib_keying_event_static (int);
void cwlib_keying_event (int);
};
#endif
|