File: XcwcpMultiLineEdit.cpp

package info (click to toggle)
unixcw 2.2-11
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,132 kB
  • ctags: 706
  • sloc: ansic: 6,737; cpp: 1,935; makefile: 341; sh: 214; awk: 209
file content (110 lines) | stat: -rw-r--r-- 3,122 bytes parent folder | download
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
/*
 * UnixCW - Unix CW (Morse code) training program
 * Copyright (C) 2001, 2002  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.
 *
 *
 * XcwcpMultiLineEdit.cpp - Subclass of QMultiLineEdit for catching events. 
 *
 */

/* Include files. */
#include "XcwcpMultiLineEdit.h"
#include "XcwcpApplication.h"

#include <qwidget.h>
#include <qtextedit.h>
#include <qevent.h>
#include <qpopupmenu.h>

/*
 * Constructor.  Call the superclass constructor, and if the parent widget
 * is an instance of XcwcpApplication, save it for sending on key events.
 */
XcwcpMultiLineEdit::XcwcpMultiLineEdit (QWidget *parent, const char *name)
	: QMultiLineEdit (parent, name)
{
	parent_xcwcp_reference = dynamic_cast<XcwcpApplication*> (parent);
}


/*
 * Catch key events and pass them to our parent XcwcpApplication.  Both press
 * and release events are merged into one *_event() call.
 */
void
XcwcpMultiLineEdit::keyPressEvent (QKeyEvent *event)
{
	if (parent_xcwcp_reference != NULL)
		parent_xcwcp_reference->key_event (event);
}
void
XcwcpMultiLineEdit::keyReleaseEvent (QKeyEvent *event)
{
	if (parent_xcwcp_reference != NULL)
		parent_xcwcp_reference->key_event (event);
}


/*
 * Do the same for mouse button events.  We need to catch both press and
 * double-click, since for keying we don't use or care about double-
 * clicks, just any form of button press, any time.
 */
void
XcwcpMultiLineEdit::contentsMousePressEvent (QMouseEvent *event)
{
	if (parent_xcwcp_reference != NULL)
		parent_xcwcp_reference->mouse_event (event);
}
void
XcwcpMultiLineEdit::contentsMouseDoubleClickEvent (QMouseEvent *event)
{
	if (parent_xcwcp_reference != NULL)
		parent_xcwcp_reference->mouse_event (event);
}
void
XcwcpMultiLineEdit::contentsMouseReleaseEvent (QMouseEvent *event)
{
	if (parent_xcwcp_reference != NULL)
		parent_xcwcp_reference->mouse_event (event);
}


/*
 * backspace()
 *
 * Public backspace call entry point.  This allows an external class to
 * call backspace().  I'm not really sure why backspace() is protected in
 * QMultiLineEdit in the first case, but anyway, this defeats it.
 */
void
XcwcpMultiLineEdit::backspace ()
{
	QMultiLineEdit::backspace ();
}

/*
 * Catch the popup menu and delete it, so we can use the right mouse button
 * for dah's.
 */
QPopupMenu *
XcwcpMultiLineEdit::createPopupMenu (const QPoint &pos)
{
	QPopupMenu *menu = QMultiLineEdit::createPopupMenu (pos);
	delete menu;
	return 0;
}