summaryrefslogtreecommitdiffstats
path: root/src/MainWidget.h
blob: de38b0167601ce9f81291100b55dea415a0c980a (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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/***************************************************************************
 *   Copyright (C) 2007 by Todor Gyumyushev   *
 *   yodor@developer.bg   *
 *                                                                         *
 *   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.                          *
 *        0000                                                                 *
 *   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.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/
#ifndef KVKBDMAINWIDGET_H
#define KVKBDMAINWIDGET_H


#include <tqevent.h>
#include <tqpoint.h>
#include <tqtimer.h>
#include <kaboutdata.h>
#include <ksystemtray.h>
#include <kpopupmenu.h>
#include <tqpainter.h>
#include <tqthread.h>

#include "resizabledragwidget.h"
#include "VButton.h"
#include "numpadvbutton.h"
#include <X11/Xlib.h>

class KbdDock;
class KbdTray;

class MainWidget : public ResizableDragWidget
{
Q_OBJECT
  
public:
	MainWidget(KAboutData *about=0, bool tren=false, TQWidget *parent=0,const char *name="", WFlags f=WStyle_Customize | TQt::WX11BypassWM |WStyle_NormalBorder);
	void mappingNotify(XMappingEvent *e);
	void finishInit();
	bool close ( bool alsoDelete );

public slots:
	void keyPress(unsigned int keycode);

	void toggleCaps();
	void toggleNumlock();

	void toggleShift();

	void queryModState();
	void showDock();
	
	void quitClicked();
	void chooseFont();
	void toggleNumericPad();
	void toggleFontAutoRes();
	void restorePosition();
	void showConfigMenu();
// 	void shutDown();
 	void saveState();

protected:
	void resizeEvent(TQResizeEvent *e);
	void hideEvent ( TQHideEvent *e );


private:
	void updateFont();

	bool nresize;

	bool keyState(int iKey);
	void keyPress(int keycode);
	void setupText(VButton &v);


	VButton *caps;
	VButton *lshft;
	VButton *rshft;

	VButton *lctrl;
	VButton *rctrl;
	
	VButton *lalt;
	VButton *ralt;

	VButton *win;
	VButton *mnu;

	VButton *numl;
	VButton *div;
	VButton *mul;
	VButton *min;
	VButton *plu;
	VButton *ent;

	NumpadVButton *ins;
	NumpadVButton *del;
	
	TQValueList<VButton *> btns;
	TQValueList<VButton *> mod_keys;
	TQValueList<VButton *> other_keys;
	TQValueList<NumpadVButton *> numl_keys;

	void send_key(unsigned int keycode, bool press, bool release);
	 
	Display *display;	
	KbdTray *tray;
	KbdDock *dock;

	bool stand_alone;
	long keysym2ucs(KeySym keysym);

	bool extent_visible;
	VButton *quit;
	VButton *popup_menu;
	VButton *extent;
	double sdxs;
	double sdxb;
	int mnu_dock;
	int mnu_autores;

};


class KbdDock : public DragWidget
{
    Q_OBJECT
  

public:
    KbdDock(MainWidget *m);
    ~KbdDock();

	void paintEvent(TQPaintEvent *);


private:
	TQPixmap icn;
	MainWidget *mainWidget;
	

protected:
	void mouseReleaseEvent(TQMouseEvent *e);

};

class KbdTray : public KSystemTray
{

public:
 	KbdTray( TQWidget* parent = 0, const char* name  = 0 );

protected:	
    void mousePressEvent(TQMouseEvent *);

};

#endif