author | zecke <zecke> | 2005-02-14 17:53:31 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-14 17:53:31 (UTC) |
commit | 41881e3dcd695dc8ecdc5ef22cefd6f842858992 (patch) (unidiff) | |
tree | bd533c7e75700bbafb69ab8a7cd53eb031969080 | |
parent | 0e6780c400fbae2ccd8895e40480adb4273906ae (diff) | |
download | opie-41881e3dcd695dc8ecdc5ef22cefd6f842858992.zip opie-41881e3dcd695dc8ecdc5ef22cefd6f842858992.tar.gz opie-41881e3dcd695dc8ecdc5ef22cefd6f842858992.tar.bz2 |
Remove the special Ok/Cancel handling and go with what QDialog provides
This also fixes crashes when the user clicked ok in the Dialog
-rw-r--r-- | noncore/net/opierdesktop/qtwin.cpp | 21 | ||||
-rw-r--r-- | noncore/net/opierdesktop/qtwin.h | 6 |
2 files changed, 5 insertions, 22 deletions
diff --git a/noncore/net/opierdesktop/qtwin.cpp b/noncore/net/opierdesktop/qtwin.cpp index 181d275..54a5a03 100644 --- a/noncore/net/opierdesktop/qtwin.cpp +++ b/noncore/net/opierdesktop/qtwin.cpp | |||
@@ -1,1711 +1,1696 @@ | |||
1 | /* | 1 | /* |
2 | rdesktop: A Remote Desktop Protocol client. | 2 | rdesktop: A Remote Desktop Protocol client. |
3 | User interface services - X Window System | 3 | User interface services - X Window System |
4 | Copyright (C) Matthew Chapman 1999-2002 | 4 | Copyright (C) Matthew Chapman 1999-2002 |
5 | qt.cpp by Jay Sorg | 5 | qt.cpp by Jay Sorg |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "rdesktop.h" | 22 | #include "rdesktop.h" |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qwidget.h> | 25 | #include <qwidget.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qimage.h> | 27 | #include <qimage.h> |
28 | #include <qsocketnotifier.h> | 28 | #include <qsocketnotifier.h> |
29 | #include <qscrollview.h> | 29 | #include <qscrollview.h> |
30 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qcheckbox.h> | 36 | #include <qcheckbox.h> |
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include "qtwin.h" | 38 | #include "qtwin.h" |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | 40 | ||
41 | uint32 flags; | 41 | uint32 flags; |
42 | char server[64] = ""; | 42 | char server[64] = ""; |
43 | char domain[16] = ""; | 43 | char domain[16] = ""; |
44 | char password[16] = ""; | 44 | char password[16] = ""; |
45 | char shell[128] = ""; | 45 | char shell[128] = ""; |
46 | char directory[32] = ""; | 46 | char directory[32] = ""; |
47 | 47 | ||
48 | extern int g_width; | 48 | extern int g_width; |
49 | extern int g_height; | 49 | extern int g_height; |
50 | extern int server_bpp; | 50 | extern int server_bpp; |
51 | extern BOOL fullscreen; | 51 | extern BOOL fullscreen; |
52 | extern char username[]; | 52 | extern char username[]; |
53 | int global_sock; | 53 | int global_sock; |
54 | 54 | ||
55 | QSocketNotifier* SocketNotifier; | 55 | QSocketNotifier* SocketNotifier; |
56 | QPEApplication* App; | 56 | QPEApplication* App; |
57 | QMyMainWindow* MW; | 57 | QMyMainWindow* MW; |
58 | QMyScrollView* SV; | 58 | QMyScrollView* SV; |
59 | struct QColorMap | 59 | struct QColorMap |
60 | { | 60 | { |
61 | uint32 RGBColors[256]; | 61 | uint32 RGBColors[256]; |
62 | int NumColors; | 62 | int NumColors; |
63 | }; | 63 | }; |
64 | QColorMap* CM; | 64 | QColorMap* CM; |
65 | uint8* BS; | 65 | uint8* BS; |
66 | int clipx; | 66 | int clipx; |
67 | int clipy; | 67 | int clipy; |
68 | int clipcx; | 68 | int clipcx; |
69 | int clipcy; | 69 | int clipcy; |
70 | 70 | ||
71 | struct bitmap | 71 | struct bitmap |
72 | { | 72 | { |
73 | int w; | 73 | int w; |
74 | int h; | 74 | int h; |
75 | uint8* data; | 75 | uint8* data; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | BOOL owncolmap = False; | 78 | BOOL owncolmap = False; |
79 | 79 | ||
80 | //***************************************************************************** | 80 | //***************************************************************************** |
81 | void CleanString(QString* Item) | 81 | void CleanString(QString* Item) |
82 | { | 82 | { |
83 | int i; | 83 | int i; |
84 | 84 | ||
85 | i = Item->length() - 1; | 85 | i = Item->length() - 1; |
86 | while (i >= 0) | 86 | while (i >= 0) |
87 | { | 87 | { |
88 | if (Item->at(i) == 10 || Item->at(i) == 13) | 88 | if (Item->at(i) == 10 || Item->at(i) == 13) |
89 | Item->remove(i, 1); | 89 | Item->remove(i, 1); |
90 | i--; | 90 | i--; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | //***************************************************************************** | 94 | //***************************************************************************** |
95 | QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) | 95 | QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) |
96 | { | 96 | { |
97 | setCaption( tr( "Configuration" ) ); | 97 | setCaption( tr( "Configuration" ) ); |
98 | int i, j; | 98 | int i, j; |
99 | char* home; | 99 | char* home; |
100 | char Text[256]; | 100 | char Text[256]; |
101 | QString Line; | 101 | QString Line; |
102 | QString ItemName; | 102 | QString ItemName; |
103 | QString ItemValue; | 103 | QString ItemValue; |
104 | 104 | ||
105 | // resize dialog | 105 | // resize dialog |
106 | resize(230, 270); | 106 | resize(230, 270); |
107 | // main list box | 107 | // main list box |
108 | ListBox = new QListBox(this); | 108 | ListBox = new QListBox(this); |
109 | ListBox->move(10, 10); | 109 | ListBox->move(10, 10); |
110 | ListBox->resize(200, 100); | 110 | ListBox->resize(200, 100); |
111 | connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged())); | 111 | connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged())); |
112 | connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int))); | 112 | connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int))); |
113 | // server | 113 | // server |
114 | Label1 = new QLabel(this); | 114 | Label1 = new QLabel(this); |
115 | Label1->setText("Server Desc"); | 115 | Label1->setText("Server Desc"); |
116 | Label1->move(10, 120); | 116 | Label1->move(10, 120); |
117 | Label1->resize(100, 20); | 117 | Label1->resize(100, 20); |
118 | ServerNameEdit = new QLineEdit(this); | 118 | ServerNameEdit = new QLineEdit(this); |
119 | ServerNameEdit->move(75, 120); | 119 | ServerNameEdit->move(75, 120); |
120 | ServerNameEdit->resize(100, 20); | 120 | ServerNameEdit->resize(100, 20); |
121 | // username | 121 | // username |
122 | Label2 = new QLabel(this); | 122 | Label2 = new QLabel(this); |
123 | Label2->setText("User Name"); | 123 | Label2->setText("User Name"); |
124 | Label2->move(10, 150); | 124 | Label2->move(10, 150); |
125 | Label2->resize(100, 20); | 125 | Label2->resize(100, 20); |
126 | UserNameEdit = new QLineEdit(this); | 126 | UserNameEdit = new QLineEdit(this); |
127 | UserNameEdit->move(75, 150); | 127 | UserNameEdit->move(75, 150); |
128 | UserNameEdit->resize(100, 20); | 128 | UserNameEdit->resize(100, 20); |
129 | // ip | 129 | // ip |
130 | Label3 = new QLabel(this); | 130 | Label3 = new QLabel(this); |
131 | Label3->setText("Server IP"); | 131 | Label3->setText("Server IP"); |
132 | Label3->move(10, 180); | 132 | Label3->move(10, 180); |
133 | Label3->resize(100, 20); | 133 | Label3->resize(100, 20); |
134 | IPEdit = new QLineEdit(this); | 134 | IPEdit = new QLineEdit(this); |
135 | IPEdit->move(75, 180); | 135 | IPEdit->move(75, 180); |
136 | IPEdit->resize(100, 20); | 136 | IPEdit->resize(100, 20); |
137 | // width and height | 137 | // width and height |
138 | WidthHeightBox = new QComboBox(this); | 138 | WidthHeightBox = new QComboBox(this); |
139 | WidthHeightBox->move(10, 210); | 139 | WidthHeightBox->move(10, 210); |
140 | WidthHeightBox->resize(100, 20); | 140 | WidthHeightBox->resize(100, 20); |
141 | WidthHeightBox->insertItem("240x320"); | 141 | WidthHeightBox->insertItem("240x320"); |
142 | WidthHeightBox->insertItem("640x480"); | 142 | WidthHeightBox->insertItem("640x480"); |
143 | WidthHeightBox->insertItem("800x600"); | 143 | WidthHeightBox->insertItem("800x600"); |
144 | connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int))); | 144 | connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int))); |
145 | WidthHeightBox->setCurrentItem(1); | 145 | WidthHeightBox->setCurrentItem(1); |
146 | WidthEdit = new QLineEdit(this); | 146 | WidthEdit = new QLineEdit(this); |
147 | WidthEdit->move(110, 210); | 147 | WidthEdit->move(110, 210); |
148 | WidthEdit->resize(30, 20); | 148 | WidthEdit->resize(30, 20); |
149 | WidthEdit->setText("800"); | 149 | WidthEdit->setText("800"); |
150 | HeightEdit = new QLineEdit(this); | 150 | HeightEdit = new QLineEdit(this); |
151 | HeightEdit->move(140, 210); | 151 | HeightEdit->move(140, 210); |
152 | HeightEdit->resize(30, 20); | 152 | HeightEdit->resize(30, 20); |
153 | HeightEdit->setText("600"); | 153 | HeightEdit->setText("600"); |
154 | // add to list button | 154 | // add to list button |
155 | AddButton = new QPushButton(this); | 155 | AddButton = new QPushButton(this); |
156 | AddButton->move(180, 120); | 156 | AddButton->move(180, 120); |
157 | AddButton->resize(50, 20); | 157 | AddButton->resize(50, 20); |
158 | AddButton->setText("Add"); | 158 | AddButton->setText("Add"); |
159 | connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked())); | 159 | connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked())); |
160 | // change list item button | 160 | // change list item button |
161 | EditButton = new QPushButton(this); | 161 | EditButton = new QPushButton(this); |
162 | EditButton->move(180, 140); | 162 | EditButton->move(180, 140); |
163 | EditButton->resize(50, 20); | 163 | EditButton->resize(50, 20); |
164 | EditButton->setText("Edit"); | 164 | EditButton->setText("Edit"); |
165 | connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked())); | 165 | connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked())); |
166 | // save to file button | 166 | // save to file button |
167 | SaveButton = new QPushButton(this); | 167 | SaveButton = new QPushButton(this); |
168 | SaveButton->move(180, 160); | 168 | SaveButton->move(180, 160); |
169 | SaveButton->resize(50, 20); | 169 | SaveButton->resize(50, 20); |
170 | SaveButton->setText("Save"); | 170 | SaveButton->setText("Save"); |
171 | connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked())); | 171 | connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked())); |
172 | // remove an item button | 172 | // remove an item button |
173 | RemoveButton = new QPushButton(this); | 173 | RemoveButton = new QPushButton(this); |
174 | RemoveButton->move(180, 180); | 174 | RemoveButton->move(180, 180); |
175 | RemoveButton->resize(50, 20); | 175 | RemoveButton->resize(50, 20); |
176 | RemoveButton->setText("Remove"); | 176 | RemoveButton->setText("Remove"); |
177 | connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked())); | 177 | connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked())); |
178 | // full screen check box | 178 | // full screen check box |
179 | FullScreenCheckBox = new QCheckBox(this, "Full Screen"); | 179 | FullScreenCheckBox = new QCheckBox(this, "Full Screen"); |
180 | FullScreenCheckBox->setText("Full Screen"); | 180 | FullScreenCheckBox->setText("Full Screen"); |
181 | FullScreenCheckBox->move(10, 230); | 181 | FullScreenCheckBox->move(10, 230); |
182 | // ok button | 182 | // ok button |
183 | OKButton = new QPushButton(this); | ||
184 | OKButton->setText("OK"); | ||
185 | OKButton->move(100, 240); | ||
186 | OKButton->resize(50, 20); | ||
187 | connect(OKButton, SIGNAL(clicked()), this, SLOT(OKClicked())); | ||
188 | // cancel button | ||
189 | CancelButton = new QPushButton(this); | ||
190 | CancelButton->setText("Cancel"); | ||
191 | CancelButton->move(160, 240); | ||
192 | CancelButton->resize(50, 20); | ||
193 | connect(CancelButton, SIGNAL(clicked()), this, SLOT(CancelClicked())); | ||
194 | 183 | ||
195 | for (i = 0; i < 10; i++) | 184 | for (i = 0; i < 10; i++) |
196 | { | 185 | { |
197 | ConnectionList[i] = new QMyConnectionItem; | 186 | ConnectionList[i] = new QMyConnectionItem; |
198 | ConnectionList[i]->ServerName = ""; | 187 | ConnectionList[i]->ServerName = ""; |
199 | ConnectionList[i]->UserName = ""; | 188 | ConnectionList[i]->UserName = ""; |
200 | ConnectionList[i]->ServerIP = ""; | 189 | ConnectionList[i]->ServerIP = ""; |
201 | ConnectionList[i]->Width = 0; | 190 | ConnectionList[i]->Width = 0; |
202 | ConnectionList[i]->Height = 0; | 191 | ConnectionList[i]->Height = 0; |
203 | ConnectionList[i]->FullScreen = 0; | 192 | ConnectionList[i]->FullScreen = 0; |
204 | } | 193 | } |
205 | home = getenv("HOME"); | 194 | home = getenv("HOME"); |
206 | if (home != NULL) | 195 | if (home != NULL) |
207 | { | 196 | { |
208 | sprintf(Text, "%s/rdesktop.ini", home); | 197 | sprintf(Text, "%s/rdesktop.ini", home); |
209 | QFile* File = new QFile(Text); | 198 | QFile* File = new QFile(Text); |
210 | if (File->open(IO_ReadOnly)) | 199 | if (File->open(IO_ReadOnly)) |
211 | { | 200 | { |
212 | i = -1; | 201 | i = -1; |
213 | while (!File->atEnd()) | 202 | while (!File->atEnd()) |
214 | { | 203 | { |
215 | File->readLine(Line, 255); | 204 | File->readLine(Line, 255); |
216 | j = Line.find("="); | 205 | j = Line.find("="); |
217 | if (j > 0) | 206 | if (j > 0) |
218 | { | 207 | { |
219 | ItemName = Line.mid(0, j); | 208 | ItemName = Line.mid(0, j); |
220 | CleanString(&ItemName); | 209 | CleanString(&ItemName); |
221 | ItemValue = Line.mid(j + 1); | 210 | ItemValue = Line.mid(j + 1); |
222 | CleanString(&ItemValue); | 211 | CleanString(&ItemValue); |
223 | if (ItemName == "Server") | 212 | if (ItemName == "Server") |
224 | { | 213 | { |
225 | i++; | 214 | i++; |
226 | ConnectionList[i]->ServerName = ItemValue; | 215 | ConnectionList[i]->ServerName = ItemValue; |
227 | ListBox->insertItem(ItemValue); | 216 | ListBox->insertItem(ItemValue); |
228 | } | 217 | } |
229 | else if (ItemName == "UserName") | 218 | else if (ItemName == "UserName") |
230 | ConnectionList[i]->UserName = ItemValue; | 219 | ConnectionList[i]->UserName = ItemValue; |
231 | else if (ItemName == "Width") | 220 | else if (ItemName == "Width") |
232 | ConnectionList[i]->Width = ItemValue.toInt(); | 221 | ConnectionList[i]->Width = ItemValue.toInt(); |
233 | else if (ItemName == "Height") | 222 | else if (ItemName == "Height") |
234 | ConnectionList[i]->Height = ItemValue.toInt(); | 223 | ConnectionList[i]->Height = ItemValue.toInt(); |
235 | else if (ItemName == "IP") | 224 | else if (ItemName == "IP") |
236 | ConnectionList[i]->ServerIP = ItemValue; | 225 | ConnectionList[i]->ServerIP = ItemValue; |
237 | else if (ItemName == "FullScreen") | 226 | else if (ItemName == "FullScreen") |
238 | ConnectionList[i]->FullScreen = (ItemValue != "0"); | 227 | ConnectionList[i]->FullScreen = (ItemValue != "0"); |
239 | } | 228 | } |
240 | } | 229 | } |
241 | } | 230 | } |
242 | delete File; | 231 | delete File; |
243 | } | 232 | } |
244 | } | 233 | } |
245 | 234 | ||
246 | //***************************************************************************** | 235 | //***************************************************************************** |
247 | QMyDialog::~QMyDialog() | 236 | QMyDialog::~QMyDialog() |
248 | { | 237 | { |
249 | QMyConnectionItem* Item; | 238 | QMyConnectionItem* Item; |
250 | int i; | 239 | int i; |
251 | 240 | ||
252 | for (i = 0; i < 10; i++) | 241 | for (i = 0; i < 10; i++) |
253 | { | 242 | { |
254 | Item = ConnectionList[i]; | 243 | Item = ConnectionList[i]; |
255 | delete Item; | 244 | delete Item; |
256 | } | 245 | } |
257 | } | 246 | } |
258 | 247 | ||
259 | //***************************************************************************** | 248 | //***************************************************************************** |
260 | void QMyDialog::ComboChanged(int index) | 249 | void QMyDialog::ComboChanged(int index) |
261 | { | 250 | { |
262 | if (index == 0) | 251 | if (index == 0) |
263 | { | 252 | { |
264 | WidthEdit->setText("240"); | 253 | WidthEdit->setText("240"); |
265 | HeightEdit->setText("320"); | 254 | HeightEdit->setText("320"); |
266 | } | 255 | } |
267 | if (index == 1) | 256 | if (index == 1) |
268 | { | 257 | { |
269 | WidthEdit->setText("640"); | 258 | WidthEdit->setText("640"); |
270 | HeightEdit->setText("480"); | 259 | HeightEdit->setText("480"); |
271 | } | 260 | } |
272 | else if (index == 2) | 261 | else if (index == 2) |
273 | { | 262 | { |
274 | WidthEdit->setText("800"); | 263 | WidthEdit->setText("800"); |
275 | HeightEdit->setText("600"); | 264 | HeightEdit->setText("600"); |
276 | } | 265 | } |
277 | } | 266 | } |
278 | 267 | ||
279 | //***************************************************************************** | 268 | //***************************************************************************** |
280 | void QMyDialog::OKClicked() | 269 | void QMyDialog::accept() |
281 | { | 270 | { |
282 | ServerName = ServerNameEdit->text(); | 271 | ServerName = ServerNameEdit->text(); |
283 | UserName = UserNameEdit->text(); | 272 | UserName = UserNameEdit->text(); |
284 | Width = WidthEdit->text().toInt(); | 273 | Width = WidthEdit->text().toInt(); |
285 | Height = HeightEdit->text().toInt(); | 274 | Height = HeightEdit->text().toInt(); |
286 | ServerIP = IPEdit->text(); | 275 | ServerIP = IPEdit->text(); |
287 | FullScreen = FullScreenCheckBox->isChecked(); | 276 | FullScreen = FullScreenCheckBox->isChecked(); |
288 | done(1); | ||
289 | } | ||
290 | 277 | ||
291 | //***************************************************************************** | 278 | QDialog::accept(); |
292 | void QMyDialog::CancelClicked() | ||
293 | { | ||
294 | done(0); | ||
295 | } | 279 | } |
296 | 280 | ||
281 | |||
297 | //***************************************************************************** | 282 | //***************************************************************************** |
298 | void QMyDialog::AddClicked() | 283 | void QMyDialog::AddClicked() |
299 | { | 284 | { |
300 | int i; | 285 | int i; |
301 | QMyConnectionItem* Item; | 286 | QMyConnectionItem* Item; |
302 | 287 | ||
303 | i = ListBox->count(); | 288 | i = ListBox->count(); |
304 | if (i < 10) | 289 | if (i < 10) |
305 | { | 290 | { |
306 | ListBox->insertItem(ServerNameEdit->text()); | 291 | ListBox->insertItem(ServerNameEdit->text()); |
307 | Item = ConnectionList[i]; | 292 | Item = ConnectionList[i]; |
308 | Item->ServerName = ServerNameEdit->text(); | 293 | Item->ServerName = ServerNameEdit->text(); |
309 | Item->UserName = UserNameEdit->text(); | 294 | Item->UserName = UserNameEdit->text(); |
310 | Item->Width = WidthEdit->text().toInt(); | 295 | Item->Width = WidthEdit->text().toInt(); |
311 | Item->Height = HeightEdit->text().toInt(); | 296 | Item->Height = HeightEdit->text().toInt(); |
312 | Item->ServerIP = IPEdit->text(); | 297 | Item->ServerIP = IPEdit->text(); |
313 | Item->FullScreen = FullScreenCheckBox->isChecked(); | 298 | Item->FullScreen = FullScreenCheckBox->isChecked(); |
314 | } | 299 | } |
315 | } | 300 | } |
316 | 301 | ||
317 | //***************************************************************************** | 302 | //***************************************************************************** |
318 | void QMyDialog::EditClicked() | 303 | void QMyDialog::EditClicked() |
319 | { | 304 | { |
320 | int i; | 305 | int i; |
321 | QMyConnectionItem* Item; | 306 | QMyConnectionItem* Item; |
322 | 307 | ||
323 | i = ListBox->currentItem(); | 308 | i = ListBox->currentItem(); |
324 | if (i >= 0) | 309 | if (i >= 0) |
325 | { | 310 | { |
326 | Item = ConnectionList[i]; | 311 | Item = ConnectionList[i]; |
327 | Item->ServerName = ServerNameEdit->text(); | 312 | Item->ServerName = ServerNameEdit->text(); |
328 | Item->UserName = UserNameEdit->text(); | 313 | Item->UserName = UserNameEdit->text(); |
329 | Item->Width = WidthEdit->text().toInt(); | 314 | Item->Width = WidthEdit->text().toInt(); |
330 | Item->Height = HeightEdit->text().toInt(); | 315 | Item->Height = HeightEdit->text().toInt(); |
331 | Item->ServerIP = IPEdit->text(); | 316 | Item->ServerIP = IPEdit->text(); |
332 | Item->FullScreen = FullScreenCheckBox->isChecked(); | 317 | Item->FullScreen = FullScreenCheckBox->isChecked(); |
333 | ListBox->changeItem(ServerNameEdit->text(), i); | 318 | ListBox->changeItem(ServerNameEdit->text(), i); |
334 | } | 319 | } |
335 | } | 320 | } |
336 | 321 | ||
337 | //***************************************************************************** | 322 | //***************************************************************************** |
338 | void WriteString(QFile* File, QString* Line) | 323 | void WriteString(QFile* File, QString* Line) |
339 | { | 324 | { |
340 | File->writeBlock((const char*)(*Line), Line->length()); | 325 | File->writeBlock((const char*)(*Line), Line->length()); |
341 | } | 326 | } |
342 | 327 | ||
343 | //***************************************************************************** | 328 | //***************************************************************************** |
344 | void QMyDialog::SaveClicked() | 329 | void QMyDialog::SaveClicked() |
345 | { | 330 | { |
346 | int i, j; | 331 | int i, j; |
347 | QMyConnectionItem* Item; | 332 | QMyConnectionItem* Item; |
348 | QString Line; | 333 | QString Line; |
349 | char* home; | 334 | char* home; |
350 | char Text[256]; | 335 | char Text[256]; |
351 | QFile* File; | 336 | QFile* File; |
352 | 337 | ||
353 | home = getenv("HOME"); | 338 | home = getenv("HOME"); |
354 | if (home != NULL) | 339 | if (home != NULL) |
355 | { | 340 | { |
356 | sprintf(Text, "%s/rdesktop.ini", home); | 341 | sprintf(Text, "%s/rdesktop.ini", home); |
357 | File = new QFile(Text); | 342 | File = new QFile(Text); |
358 | if (File->open(IO_Truncate | IO_ReadWrite)) | 343 | if (File->open(IO_Truncate | IO_ReadWrite)) |
359 | { | 344 | { |
360 | i = ListBox->count(); | 345 | i = ListBox->count(); |
361 | for (j = 0; j < i; j++) | 346 | for (j = 0; j < i; j++) |
362 | { | 347 | { |
363 | Item = ConnectionList[j]; | 348 | Item = ConnectionList[j]; |
364 | Line = "Server="; | 349 | Line = "Server="; |
365 | Line += Item->ServerName; | 350 | Line += Item->ServerName; |
366 | Line += (char)10; | 351 | Line += (char)10; |
367 | WriteString(File, &Line); | 352 | WriteString(File, &Line); |
368 | Line = "UserName="; | 353 | Line = "UserName="; |
369 | Line += Item->UserName; | 354 | Line += Item->UserName; |
370 | Line += (char)10; | 355 | Line += (char)10; |
371 | WriteString(File, &Line); | 356 | WriteString(File, &Line); |
372 | Line = "Width="; | 357 | Line = "Width="; |
373 | sprintf(Text, "%d", Item->Width); | 358 | sprintf(Text, "%d", Item->Width); |
374 | Line += Text; | 359 | Line += Text; |
375 | Line += (char)10; | 360 | Line += (char)10; |
376 | WriteString(File, &Line); | 361 | WriteString(File, &Line); |
377 | Line = "Height="; | 362 | Line = "Height="; |
378 | sprintf(Text, "%d", Item->Height); | 363 | sprintf(Text, "%d", Item->Height); |
379 | Line += Text; | 364 | Line += Text; |
380 | Line += (char)10; | 365 | Line += (char)10; |
381 | WriteString(File, &Line); | 366 | WriteString(File, &Line); |
382 | Line = "IP="; | 367 | Line = "IP="; |
383 | Line += Item->ServerIP; | 368 | Line += Item->ServerIP; |
384 | Line += (char)10; | 369 | Line += (char)10; |
385 | WriteString(File, &Line); | 370 | WriteString(File, &Line); |
386 | Line = "FullScreen="; | 371 | Line = "FullScreen="; |
387 | if (Item->FullScreen) | 372 | if (Item->FullScreen) |
388 | Line += "1"; | 373 | Line += "1"; |
389 | else | 374 | else |
390 | Line += "0"; | 375 | Line += "0"; |
391 | Line += (char)10; | 376 | Line += (char)10; |
392 | WriteString(File, &Line); | 377 | WriteString(File, &Line); |
393 | } | 378 | } |
394 | } | 379 | } |
395 | File->flush(); | 380 | File->flush(); |
396 | File->close(); | 381 | File->close(); |
397 | delete File; | 382 | delete File; |
398 | } | 383 | } |
399 | } | 384 | } |
400 | 385 | ||
401 | //***************************************************************************** | 386 | //***************************************************************************** |
402 | void QMyDialog::RemoveClicked() | 387 | void QMyDialog::RemoveClicked() |
403 | { | 388 | { |
404 | int i, j, c; | 389 | int i, j, c; |
405 | QMyConnectionItem* Item1; | 390 | QMyConnectionItem* Item1; |
406 | QMyConnectionItem* Item2; | 391 | QMyConnectionItem* Item2; |
407 | 392 | ||
408 | i = ListBox->currentItem(); | 393 | i = ListBox->currentItem(); |
409 | if (i >= 0) | 394 | if (i >= 0) |
410 | { | 395 | { |
411 | c = ListBox->count(); | 396 | c = ListBox->count(); |
412 | for (j = i; j < c - 1; j++) | 397 | for (j = i; j < c - 1; j++) |
413 | { | 398 | { |
414 | Item1 = ConnectionList[i]; | 399 | Item1 = ConnectionList[i]; |
415 | Item2 = ConnectionList[i + 1]; | 400 | Item2 = ConnectionList[i + 1]; |
416 | Item1->ServerName = Item2->ServerName; | 401 | Item1->ServerName = Item2->ServerName; |
417 | Item1->UserName = Item2->UserName; | 402 | Item1->UserName = Item2->UserName; |
418 | Item1->Width = Item2->Width; | 403 | Item1->Width = Item2->Width; |
419 | Item1->Height = Item2->Height; | 404 | Item1->Height = Item2->Height; |
420 | Item1->ServerIP = Item2->ServerIP; | 405 | Item1->ServerIP = Item2->ServerIP; |
421 | Item1->FullScreen = Item2->FullScreen; | 406 | Item1->FullScreen = Item2->FullScreen; |
422 | } | 407 | } |
423 | ListBox->removeItem(i); | 408 | ListBox->removeItem(i); |
424 | } | 409 | } |
425 | } | 410 | } |
426 | 411 | ||
427 | //***************************************************************************** | 412 | //***************************************************************************** |
428 | void QMyDialog::ListBoxChanged() | 413 | void QMyDialog::ListBoxChanged() |
429 | { | 414 | { |
430 | int i; | 415 | int i; |
431 | QMyConnectionItem* Item; | 416 | QMyConnectionItem* Item; |
432 | char Text[100]; | 417 | char Text[100]; |
433 | 418 | ||
434 | i = ListBox->currentItem(); | 419 | i = ListBox->currentItem(); |
435 | if (i >= 0 && i < 10) | 420 | if (i >= 0 && i < 10) |
436 | { | 421 | { |
437 | Item = ConnectionList[i]; | 422 | Item = ConnectionList[i]; |
438 | ServerNameEdit->setText(Item->ServerName); | 423 | ServerNameEdit->setText(Item->ServerName); |
439 | UserNameEdit->setText(Item->UserName); | 424 | UserNameEdit->setText(Item->UserName); |
440 | sprintf(Text, "%d", Item->Width); | 425 | sprintf(Text, "%d", Item->Width); |
441 | WidthEdit->setText(Text); | 426 | WidthEdit->setText(Text); |
442 | sprintf(Text, "%d", Item->Height); | 427 | sprintf(Text, "%d", Item->Height); |
443 | HeightEdit->setText(Text); | 428 | HeightEdit->setText(Text); |
444 | IPEdit->setText(Item->ServerIP); | 429 | IPEdit->setText(Item->ServerIP); |
445 | FullScreenCheckBox->setChecked(Item->FullScreen != 0); | 430 | FullScreenCheckBox->setChecked(Item->FullScreen != 0); |
446 | } | 431 | } |
447 | } | 432 | } |
448 | 433 | ||
449 | //***************************************************************************** | 434 | //***************************************************************************** |
450 | void QMyDialog::ListBoxSelected(int /*index*/) | 435 | void QMyDialog::ListBoxSelected(int /*index*/) |
451 | { | 436 | { |
452 | } | 437 | } |
453 | 438 | ||
454 | //***************************************************************************** | 439 | //***************************************************************************** |
455 | void GetScanCode(QKeyEvent* e, int* ScanCode, int* code) | 440 | void GetScanCode(QKeyEvent* e, int* ScanCode, int* code) |
456 | { | 441 | { |
457 | int key; | 442 | int key; |
458 | int mod; | 443 | int mod; |
459 | int ascii; | 444 | int ascii; |
460 | 445 | ||
461 | key = e->key(); | 446 | key = e->key(); |
462 | mod = e->state(); | 447 | mod = e->state(); |
463 | ascii = e->ascii(); | 448 | ascii = e->ascii(); |
464 | 449 | ||
465 | *ScanCode = 0; | 450 | *ScanCode = 0; |
466 | *code = mod; // 8 shift, 16 control, 32 alt | 451 | *code = mod; // 8 shift, 16 control, 32 alt |
467 | 452 | ||
468 | switch (key) | 453 | switch (key) |
469 | { | 454 | { |
470 | case 4096: // esc | 455 | case 4096: // esc |
471 | case 4097: // tab | 456 | case 4097: // tab |
472 | case 4099: // backspace | 457 | case 4099: // backspace |
473 | case 4100: // enter | 458 | case 4100: // enter |
474 | case 4101: // enter | 459 | case 4101: // enter |
475 | case 4103: // delete | 460 | case 4103: // delete |
476 | ascii = 0; | 461 | ascii = 0; |
477 | } | 462 | } |
478 | 463 | ||
479 | if (ascii == 0) | 464 | if (ascii == 0) |
480 | { | 465 | { |
481 | switch (key) | 466 | switch (key) |
482 | { | 467 | { |
483 | case 4096: *ScanCode = 0x01; break; // esc | 468 | case 4096: *ScanCode = 0x01; break; // esc |
484 | case 4097: *ScanCode = 0x0f; break; // tab | 469 | case 4097: *ScanCode = 0x0f; break; // tab |
485 | case 4099: *ScanCode = 0x0e; break; // backspace | 470 | case 4099: *ScanCode = 0x0e; break; // backspace |
486 | case 4100: *ScanCode = 0x1c; break; // enter | 471 | case 4100: *ScanCode = 0x1c; break; // enter |
487 | case 4101: *ScanCode = 0x1c; break; // enter | 472 | case 4101: *ScanCode = 0x1c; break; // enter |
488 | case 4112: *ScanCode = 0xc7; break; // home | 473 | case 4112: *ScanCode = 0xc7; break; // home |
489 | case 4113: *ScanCode = 0xcf; break; // end | 474 | case 4113: *ScanCode = 0xcf; break; // end |
490 | case 4102: *ScanCode = 0xd2; break; // insert | 475 | case 4102: *ScanCode = 0xd2; break; // insert |
491 | case 4103: *ScanCode = 0xd3; break; // delete | 476 | case 4103: *ScanCode = 0xd3; break; // delete |
492 | case 4118: *ScanCode = 0xc9; break; // page up | 477 | case 4118: *ScanCode = 0xc9; break; // page up |
493 | case 4119: *ScanCode = 0xd1; break; // page down | 478 | case 4119: *ScanCode = 0xd1; break; // page down |
494 | case 4117: *ScanCode = 0xd0; break; // down arrow | 479 | case 4117: *ScanCode = 0xd0; break; // down arrow |
495 | case 4115: *ScanCode = 0xc8; break; // up arrow | 480 | case 4115: *ScanCode = 0xc8; break; // up arrow |
496 | case 4114: *ScanCode = 0xcb; break; // left arrow | 481 | case 4114: *ScanCode = 0xcb; break; // left arrow |
497 | case 4116: *ScanCode = 0xcd; break; // right arrow | 482 | case 4116: *ScanCode = 0xcd; break; // right arrow |
498 | case 4128: *ScanCode = 0x2a; break; // shift | 483 | case 4128: *ScanCode = 0x2a; break; // shift |
499 | case 4131: *ScanCode = 0x38; break; // alt | 484 | case 4131: *ScanCode = 0x38; break; // alt |
500 | case 4129: *ScanCode = 0x1d; break; // ctrl | 485 | case 4129: *ScanCode = 0x1d; break; // ctrl |
501 | } | 486 | } |
502 | if (*ScanCode != 0) | 487 | if (*ScanCode != 0) |
503 | return; | 488 | return; |
504 | } | 489 | } |
505 | 490 | ||
506 | switch (ascii) | 491 | switch (ascii) |
507 | { | 492 | { |
508 | // first row | 493 | // first row |
509 | case 'q': *ScanCode = 0x10; break; | 494 | case 'q': *ScanCode = 0x10; break; |
510 | case 'Q': *ScanCode = 0x10; *code |= 8; break; | 495 | case 'Q': *ScanCode = 0x10; *code |= 8; break; |
511 | case '1': *ScanCode = 0x02; break; | 496 | case '1': *ScanCode = 0x02; break; |
512 | case 'w': *ScanCode = 0x11; break; | 497 | case 'w': *ScanCode = 0x11; break; |
513 | case 'W': *ScanCode = 0x11; *code |= 8; break; | 498 | case 'W': *ScanCode = 0x11; *code |= 8; break; |
514 | case '2': *ScanCode = 0x03; break; | 499 | case '2': *ScanCode = 0x03; break; |
515 | case 'e': *ScanCode = 0x12; break; | 500 | case 'e': *ScanCode = 0x12; break; |
516 | case 'E': *ScanCode = 0x12; *code |= 8; break; | 501 | case 'E': *ScanCode = 0x12; *code |= 8; break; |
517 | case '3': *ScanCode = 0x04; break; | 502 | case '3': *ScanCode = 0x04; break; |
518 | case 'r': *ScanCode = 0x13; break; | 503 | case 'r': *ScanCode = 0x13; break; |
519 | case 'R': *ScanCode = 0x13; *code |= 8; break; | 504 | case 'R': *ScanCode = 0x13; *code |= 8; break; |
520 | case '4': *ScanCode = 0x05; break; | 505 | case '4': *ScanCode = 0x05; break; |
521 | case 't': *ScanCode = 0x14; break; | 506 | case 't': *ScanCode = 0x14; break; |
522 | case 'T': *ScanCode = 0x14; *code |= 8; break; | 507 | case 'T': *ScanCode = 0x14; *code |= 8; break; |
523 | case '5': *ScanCode = 0x06; break; | 508 | case '5': *ScanCode = 0x06; break; |
524 | case 'y': *ScanCode = 0x15; break; | 509 | case 'y': *ScanCode = 0x15; break; |
525 | case 'Y': *ScanCode = 0x15; *code |= 8; break; | 510 | case 'Y': *ScanCode = 0x15; *code |= 8; break; |
526 | case '6': *ScanCode = 0x07; break; | 511 | case '6': *ScanCode = 0x07; break; |
527 | case 'u': *ScanCode = 0x16; break; | 512 | case 'u': *ScanCode = 0x16; break; |
528 | case 'U': *ScanCode = 0x16; *code |= 8; break; | 513 | case 'U': *ScanCode = 0x16; *code |= 8; break; |
529 | case '7': *ScanCode = 0x08; break; | 514 | case '7': *ScanCode = 0x08; break; |
530 | case 'i': *ScanCode = 0x17; break; | 515 | case 'i': *ScanCode = 0x17; break; |
531 | case 'I': *ScanCode = 0x17; *code |= 8; break; | 516 | case 'I': *ScanCode = 0x17; *code |= 8; break; |
532 | case '8': *ScanCode = 0x09; break; | 517 | case '8': *ScanCode = 0x09; break; |
533 | case 'o': *ScanCode = 0x18; break; | 518 | case 'o': *ScanCode = 0x18; break; |
534 | case 'O': *ScanCode = 0x18; *code |= 8; break; | 519 | case 'O': *ScanCode = 0x18; *code |= 8; break; |
535 | case '9': *ScanCode = 0x0a; break; | 520 | case '9': *ScanCode = 0x0a; break; |
536 | case 'p': *ScanCode = 0x19; break; | 521 | case 'p': *ScanCode = 0x19; break; |
537 | case 'P': *ScanCode = 0x19; *code |= 8; break; | 522 | case 'P': *ScanCode = 0x19; *code |= 8; break; |
538 | case '0': *ScanCode = 0x0b; break; | 523 | case '0': *ScanCode = 0x0b; break; |
539 | // second row | 524 | // second row |
540 | case 'a': *ScanCode = 0x1e; break; | 525 | case 'a': *ScanCode = 0x1e; break; |
541 | case 'A': *ScanCode = 0x1e; *code |= 8; break; | 526 | case 'A': *ScanCode = 0x1e; *code |= 8; break; |
542 | case '!': *ScanCode = 0x02; *code |= 8; break; | 527 | case '!': *ScanCode = 0x02; *code |= 8; break; |
543 | case 's': *ScanCode = 0x1f; break; | 528 | case 's': *ScanCode = 0x1f; break; |
544 | case 'S': *ScanCode = 0x1f; *code |= 8; break; | 529 | case 'S': *ScanCode = 0x1f; *code |= 8; break; |
545 | case '@': *ScanCode = 0x03; *code |= 8; break; | 530 | case '@': *ScanCode = 0x03; *code |= 8; break; |
546 | case 'd': *ScanCode = 0x20; break; | 531 | case 'd': *ScanCode = 0x20; break; |
547 | case 'D': *ScanCode = 0x20; *code |= 8; break; | 532 | case 'D': *ScanCode = 0x20; *code |= 8; break; |
548 | case '#': *ScanCode = 0x04; *code |= 8; break; | 533 | case '#': *ScanCode = 0x04; *code |= 8; break; |
549 | case 'f': *ScanCode = 0x21; break; | 534 | case 'f': *ScanCode = 0x21; break; |
550 | case 'F': *ScanCode = 0x21; *code |= 8; break; | 535 | case 'F': *ScanCode = 0x21; *code |= 8; break; |
551 | case '$': *ScanCode = 0x05; *code |= 8; break; | 536 | case '$': *ScanCode = 0x05; *code |= 8; break; |
552 | case 'g': *ScanCode = 0x22; break; | 537 | case 'g': *ScanCode = 0x22; break; |
553 | case 'G': *ScanCode = 0x22; *code |= 8; break; | 538 | case 'G': *ScanCode = 0x22; *code |= 8; break; |
554 | case '%': *ScanCode = 0x06; *code |= 8; break; | 539 | case '%': *ScanCode = 0x06; *code |= 8; break; |
555 | case 'h': *ScanCode = 0x23; break; | 540 | case 'h': *ScanCode = 0x23; break; |
556 | case 'H': *ScanCode = 0x23; *code |= 8; break; | 541 | case 'H': *ScanCode = 0x23; *code |= 8; break; |
557 | case '_': *ScanCode = 0x0c; *code |= 8; break; | 542 | case '_': *ScanCode = 0x0c; *code |= 8; break; |
558 | case 'j': *ScanCode = 0x24; break; | 543 | case 'j': *ScanCode = 0x24; break; |
559 | case 'J': *ScanCode = 0x24; *code |= 8; break; | 544 | case 'J': *ScanCode = 0x24; *code |= 8; break; |
560 | case '&': *ScanCode = 0x08; *code |= 8; break; | 545 | case '&': *ScanCode = 0x08; *code |= 8; break; |
561 | case 'k': *ScanCode = 0x25; break; | 546 | case 'k': *ScanCode = 0x25; break; |
562 | case 'K': *ScanCode = 0x25; *code |= 8; break; | 547 | case 'K': *ScanCode = 0x25; *code |= 8; break; |
563 | case '*': *ScanCode = 0x09; *code |= 8; break; | 548 | case '*': *ScanCode = 0x09; *code |= 8; break; |
564 | case 'l': *ScanCode = 0x26; break; | 549 | case 'l': *ScanCode = 0x26; break; |
565 | case 'L': *ScanCode = 0x26; *code |= 8; break; | 550 | case 'L': *ScanCode = 0x26; *code |= 8; break; |
566 | case '(': *ScanCode = 0x0a; *code |= 8; break; | 551 | case '(': *ScanCode = 0x0a; *code |= 8; break; |
567 | // case 8: *ScanCode = 0x0e; break; // backspace | 552 | // case 8: *ScanCode = 0x0e; break; // backspace |
568 | // third row | 553 | // third row |
569 | case 'z': *ScanCode = 0x2c; break; | 554 | case 'z': *ScanCode = 0x2c; break; |
570 | case 'Z': *ScanCode = 0x2c; *code |= 8; break; | 555 | case 'Z': *ScanCode = 0x2c; *code |= 8; break; |
571 | case 'x': *ScanCode = 0x2d; break; | 556 | case 'x': *ScanCode = 0x2d; break; |
572 | case 'X': *ScanCode = 0x2d; *code |= 8; break; | 557 | case 'X': *ScanCode = 0x2d; *code |= 8; break; |
573 | case 'c': *ScanCode = 0x2e; break; | 558 | case 'c': *ScanCode = 0x2e; break; |
574 | case 'C': *ScanCode = 0x2e; *code |= 8; break; | 559 | case 'C': *ScanCode = 0x2e; *code |= 8; break; |
575 | case 'v': *ScanCode = 0x2f; break; | 560 | case 'v': *ScanCode = 0x2f; break; |
576 | case 'V': *ScanCode = 0x2f; *code |= 8; break; | 561 | case 'V': *ScanCode = 0x2f; *code |= 8; break; |
577 | case 'b': *ScanCode = 0x30; break; | 562 | case 'b': *ScanCode = 0x30; break; |
578 | case 'B': *ScanCode = 0x30; *code |= 8; break; | 563 | case 'B': *ScanCode = 0x30; *code |= 8; break; |
579 | case '-': *ScanCode = 0x0c; break; | 564 | case '-': *ScanCode = 0x0c; break; |
580 | case 'n': *ScanCode = 0x31; break; | 565 | case 'n': *ScanCode = 0x31; break; |
581 | case 'N': *ScanCode = 0x31; *code |= 8; break; | 566 | case 'N': *ScanCode = 0x31; *code |= 8; break; |
582 | case '+': *ScanCode = 0x0d; *code |= 8; break; | 567 | case '+': *ScanCode = 0x0d; *code |= 8; break; |
583 | case 'm': *ScanCode = 0x32; break; | 568 | case 'm': *ScanCode = 0x32; break; |
584 | case 'M': *ScanCode = 0x32; *code |= 8; break; | 569 | case 'M': *ScanCode = 0x32; *code |= 8; break; |
585 | case '=': *ScanCode = 0x0d; break; | 570 | case '=': *ScanCode = 0x0d; break; |
586 | case ',': *ScanCode = 0x33; break; | 571 | case ',': *ScanCode = 0x33; break; |
587 | case ';': *ScanCode = 0x27; break; | 572 | case ';': *ScanCode = 0x27; break; |
588 | case ')': *ScanCode = 0x0b; *code |= 8; break; | 573 | case ')': *ScanCode = 0x0b; *code |= 8; break; |
589 | // fourth row | 574 | // fourth row |
590 | // case 9: *ScanCode = 0x0f; break; // tab | 575 | // case 9: *ScanCode = 0x0f; break; // tab |
591 | case '/': *ScanCode = 0x35; break; | 576 | case '/': *ScanCode = 0x35; break; |
592 | case '?': *ScanCode = 0x35; *code |= 8; break; | 577 | case '?': *ScanCode = 0x35; *code |= 8; break; |
593 | case ' ': *ScanCode = 0x39; break; | 578 | case ' ': *ScanCode = 0x39; break; |
594 | case '\'': *ScanCode = 0x28; break; | 579 | case '\'': *ScanCode = 0x28; break; |
595 | case '"': *ScanCode = 0x28; *code |= 8; break; | 580 | case '"': *ScanCode = 0x28; *code |= 8; break; |
596 | case '~': *ScanCode = 0x29; *code |= 8; break; | 581 | case '~': *ScanCode = 0x29; *code |= 8; break; |
597 | case '.': *ScanCode = 0x34; break; | 582 | case '.': *ScanCode = 0x34; break; |
598 | case ':': *ScanCode = 0x27; *code |= 8; break; | 583 | case ':': *ScanCode = 0x27; *code |= 8; break; |
599 | case '<': *ScanCode = 0x33; *code |= 8; break; | 584 | case '<': *ScanCode = 0x33; *code |= 8; break; |
600 | // case 13: *ScanCode = 0x1c; break; // enter | 585 | // case 13: *ScanCode = 0x1c; break; // enter |
601 | case '>': *ScanCode = 0x34; *code |= 8; break; | 586 | case '>': *ScanCode = 0x34; *code |= 8; break; |
602 | // others | 587 | // others |
603 | // case 27: *ScanCode = 0x01; break; // esc | 588 | // case 27: *ScanCode = 0x01; break; // esc |
604 | case '`': *ScanCode = 0x29; break; | 589 | case '`': *ScanCode = 0x29; break; |
605 | case '^': *ScanCode = 0x07; *code |= 8; break; | 590 | case '^': *ScanCode = 0x07; *code |= 8; break; |
606 | case '[': *ScanCode = 0x1a; break; | 591 | case '[': *ScanCode = 0x1a; break; |
607 | case '{': *ScanCode = 0x1a; *code |= 8; break; | 592 | case '{': *ScanCode = 0x1a; *code |= 8; break; |
608 | case ']': *ScanCode = 0x1b; break; | 593 | case ']': *ScanCode = 0x1b; break; |
609 | case '}': *ScanCode = 0x1b; *code |= 8; break; | 594 | case '}': *ScanCode = 0x1b; *code |= 8; break; |
610 | case '\\': *ScanCode = 0x2b; break; | 595 | case '\\': *ScanCode = 0x2b; break; |
611 | case '|': *ScanCode = 0x2b; *code |= 8; break; | 596 | case '|': *ScanCode = 0x2b; *code |= 8; break; |
612 | // ctrl keys | 597 | // ctrl keys |
613 | case 1: *ScanCode = 0x1e; *code |= 16; break; // a | 598 | case 1: *ScanCode = 0x1e; *code |= 16; break; // a |
614 | case 2: *ScanCode = 0x30; *code |= 16; break; // b | 599 | case 2: *ScanCode = 0x30; *code |= 16; break; // b |
615 | } | 600 | } |
616 | 601 | ||
617 | if (*ScanCode == 0 && key < 3000) | 602 | if (*ScanCode == 0 && key < 3000) |
618 | printf("unknown key %d mod %d ascii %d\n", key, mod, ascii); | 603 | printf("unknown key %d mod %d ascii %d\n", key, mod, ascii); |
619 | 604 | ||
620 | } | 605 | } |
621 | 606 | ||
622 | //***************************************************************************** | 607 | //***************************************************************************** |
623 | QMyScrollView::QMyScrollView() : QScrollView() | 608 | QMyScrollView::QMyScrollView() : QScrollView() |
624 | { | 609 | { |
625 | } | 610 | } |
626 | 611 | ||
627 | //***************************************************************************** | 612 | //***************************************************************************** |
628 | QMyScrollView::~QMyScrollView() | 613 | QMyScrollView::~QMyScrollView() |
629 | { | 614 | { |
630 | } | 615 | } |
631 | 616 | ||
632 | //***************************************************************************** | 617 | //***************************************************************************** |
633 | void QMyScrollView::keyPressEvent(QKeyEvent* e) | 618 | void QMyScrollView::keyPressEvent(QKeyEvent* e) |
634 | { | 619 | { |
635 | int ScanCode, code; | 620 | int ScanCode, code; |
636 | GetScanCode(e, &ScanCode, &code); | 621 | GetScanCode(e, &ScanCode, &code); |
637 | if (ScanCode != 0) | 622 | if (ScanCode != 0) |
638 | { | 623 | { |
639 | if (code & 8) // send shift | 624 | if (code & 8) // send shift |
640 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x2a, 0); | 625 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x2a, 0); |
641 | if (code & 16) // send control | 626 | if (code & 16) // send control |
642 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0); | 627 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0); |
643 | if (code & 32) // send alt | 628 | if (code & 32) // send alt |
644 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x38, 0); | 629 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x38, 0); |
645 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0); | 630 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0); |
646 | e->accept(); | 631 | e->accept(); |
647 | } | 632 | } |
648 | } | 633 | } |
649 | 634 | ||
650 | //***************************************************************************** | 635 | //***************************************************************************** |
651 | void QMyScrollView::keyReleaseEvent(QKeyEvent* e) | 636 | void QMyScrollView::keyReleaseEvent(QKeyEvent* e) |
652 | { | 637 | { |
653 | int ScanCode, code; | 638 | int ScanCode, code; |
654 | GetScanCode(e, &ScanCode, &code); | 639 | GetScanCode(e, &ScanCode, &code); |
655 | if (ScanCode != 0) | 640 | if (ScanCode != 0) |
656 | { | 641 | { |
657 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0); | 642 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0); |
658 | if (code & 8) // send shift | 643 | if (code & 8) // send shift |
659 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); | 644 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); |
660 | if (code & 16) // send control | 645 | if (code & 16) // send control |
661 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); | 646 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); |
662 | if (code & 32) // send alt | 647 | if (code & 32) // send alt |
663 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); | 648 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); |
664 | e->accept(); | 649 | e->accept(); |
665 | } | 650 | } |
666 | } | 651 | } |
667 | 652 | ||
668 | //***************************************************************************** | 653 | //***************************************************************************** |
669 | void QMyScrollView::showEvent(QShowEvent* e) | 654 | void QMyScrollView::showEvent(QShowEvent* e) |
670 | { | 655 | { |
671 | QScrollView::showEvent(e); | 656 | QScrollView::showEvent(e); |
672 | } | 657 | } |
673 | 658 | ||
674 | //***************************************************************************** | 659 | //***************************************************************************** |
675 | void QMyScrollView::show() | 660 | void QMyScrollView::show() |
676 | { | 661 | { |
677 | QScrollView::show(); | 662 | QScrollView::show(); |
678 | } | 663 | } |
679 | 664 | ||
680 | //***************************************************************************** | 665 | //***************************************************************************** |
681 | void QMyScrollView::polish() | 666 | void QMyScrollView::polish() |
682 | { | 667 | { |
683 | QScrollView::polish(); | 668 | QScrollView::polish(); |
684 | } | 669 | } |
685 | 670 | ||
686 | //***************************************************************************** | 671 | //***************************************************************************** |
687 | void QMyScrollView::timerEvent(QTimerEvent* e) | 672 | void QMyScrollView::timerEvent(QTimerEvent* e) |
688 | { | 673 | { |
689 | QScrollView::timerEvent(e); | 674 | QScrollView::timerEvent(e); |
690 | killTimer(timer_id); | 675 | killTimer(timer_id); |
691 | QMyDialog* d; | 676 | QMyDialog* d; |
692 | QWidget* Desktop; | 677 | QWidget* Desktop; |
693 | int dw; | 678 | int dw; |
694 | int dh; | 679 | int dh; |
695 | 680 | ||
696 | d = new QMyDialog(this); | 681 | d = new QMyDialog(this); |
697 | if (d->exec() == 1) // ok clicked | 682 | if (d->exec() == 1) // ok clicked |
698 | { | 683 | { |
699 | flags = RDP_LOGON_NORMAL; | 684 | flags = RDP_LOGON_NORMAL; |
700 | g_width = d->Width; | 685 | g_width = d->Width; |
701 | g_height = d->Height; | 686 | g_height = d->Height; |
702 | fullscreen = d->FullScreen; | 687 | fullscreen = d->FullScreen; |
703 | sprintf(server, "%s", (const char*)d->ServerIP); | 688 | sprintf(server, "%s", (const char*)d->ServerIP); |
704 | sprintf(username, "%s", (const char*)d->UserName); | 689 | sprintf(username, "%s", (const char*)d->UserName); |
705 | if (!rdp_connect(server, flags, domain, password, shell, directory)) | 690 | if (!rdp_connect(server, flags, domain, password, shell, directory)) |
706 | { | 691 | { |
707 | delete d; | 692 | delete d; |
708 | SV->close(); | 693 | SV->close(); |
709 | return; | 694 | return; |
710 | } | 695 | } |
711 | BS = (uint8*)xmalloc(g_width * g_height); | 696 | BS = (uint8*)xmalloc(g_width * g_height); |
712 | memset(BS, 0, g_width * g_height); | 697 | memset(BS, 0, g_width * g_height); |
713 | clipx = 0; | 698 | clipx = 0; |
714 | clipy = 0; | 699 | clipy = 0; |
715 | clipcx = g_width; | 700 | clipcx = g_width; |
716 | clipcy = g_height; | 701 | clipcy = g_height; |
717 | CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); | 702 | CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); |
718 | memset(CM, 0, sizeof(struct QColorMap)); | 703 | memset(CM, 0, sizeof(struct QColorMap)); |
719 | CM->NumColors = 256; | 704 | CM->NumColors = 256; |
720 | MW = new QMyMainWindow(); | 705 | MW = new QMyMainWindow(); |
721 | MW->resize(g_width, g_height); | 706 | MW->resize(g_width, g_height); |
722 | MW->show(); | 707 | MW->show(); |
723 | SV->addChild(MW); | 708 | SV->addChild(MW); |
724 | MW->setMouseTracking(true); | 709 | MW->setMouseTracking(true); |
725 | SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); | 710 | SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); |
726 | MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); | 711 | MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); |
727 | if (fullscreen) | 712 | if (fullscreen) |
728 | { | 713 | { |
729 | Desktop = App->desktop(); | 714 | Desktop = App->desktop(); |
730 | dw = Desktop->width(); | 715 | dw = Desktop->width(); |
731 | dh = Desktop->height(); | 716 | dh = Desktop->height(); |
732 | if (dw == g_width && dh == g_height) | 717 | if (dw == g_width && dh == g_height) |
733 | MW->resize(g_width - 4, g_height - 4); | 718 | MW->resize(g_width - 4, g_height - 4); |
734 | SV->showFullScreen(); | 719 | SV->showFullScreen(); |
735 | } | 720 | } |
736 | delete d; | 721 | delete d; |
737 | } | 722 | } |
738 | else // cancel clicked | 723 | else // cancel clicked |
739 | { | 724 | { |
740 | delete d; | 725 | delete d; |
741 | SV->close(); | 726 | SV->close(); |
742 | } | 727 | } |
743 | } | 728 | } |
744 | 729 | ||
745 | //***************************************************************************** | 730 | //***************************************************************************** |
746 | QMyMainWindow::QMyMainWindow() : QWidget(SV->viewport()) | 731 | QMyMainWindow::QMyMainWindow() : QWidget(SV->viewport()) |
747 | { | 732 | { |
748 | PopupMenu = new QPopupMenu(this); | 733 | PopupMenu = new QPopupMenu(this); |
749 | PopupMenu->insertItem("Right click", 1, 0); | 734 | PopupMenu->insertItem("Right click", 1, 0); |
750 | PopupMenu->insertItem("Toggle fullscreen", 2, 1); | 735 | PopupMenu->insertItem("Toggle fullscreen", 2, 1); |
751 | PopupMenu->insertItem("Reset keyboard", 3, 2); | 736 | PopupMenu->insertItem("Reset keyboard", 3, 2); |
752 | PopupMenu->insertItem("Double click", 4, 3); | 737 | PopupMenu->insertItem("Double click", 4, 3); |
753 | connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); | 738 | connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); |
754 | } | 739 | } |
755 | 740 | ||
756 | //***************************************************************************** | 741 | //***************************************************************************** |
757 | QMyMainWindow::~QMyMainWindow() | 742 | QMyMainWindow::~QMyMainWindow() |
758 | { | 743 | { |
759 | delete PopupMenu; | 744 | delete PopupMenu; |
760 | } | 745 | } |
761 | 746 | ||
762 | //***************************************************************************** | 747 | //***************************************************************************** |
763 | void QMyMainWindow::timerEvent(QTimerEvent* e) | 748 | void QMyMainWindow::timerEvent(QTimerEvent* e) |
764 | { | 749 | { |
765 | QWidget::timerEvent(e); | 750 | QWidget::timerEvent(e); |
766 | if (e->timerId() == timer_id) | 751 | if (e->timerId() == timer_id) |
767 | { | 752 | { |
768 | // send mouse up | 753 | // send mouse up |
769 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); | 754 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
770 | // if in fullscreen, take it out or the menu won't work | 755 | // if in fullscreen, take it out or the menu won't work |
771 | if (fullscreen) | 756 | if (fullscreen) |
772 | { | 757 | { |
773 | fullscreen = 0; | 758 | fullscreen = 0; |
774 | SV->showNormal(); | 759 | SV->showNormal(); |
775 | SV->showMaximized(); | 760 | SV->showMaximized(); |
776 | } | 761 | } |
777 | else | 762 | else |
778 | PopupMenu->popup(mapToGlobal(QPoint(mx, my))); | 763 | PopupMenu->popup(mapToGlobal(QPoint(mx, my))); |
779 | } | 764 | } |
780 | killTimer(timer_id); | 765 | killTimer(timer_id); |
781 | } | 766 | } |
782 | 767 | ||
783 | //***************************************************************************** | 768 | //***************************************************************************** |
784 | void QMyMainWindow::MemuClicked(int MenuID) | 769 | void QMyMainWindow::MemuClicked(int MenuID) |
785 | { | 770 | { |
786 | QWidget* Desktop; | 771 | QWidget* Desktop; |
787 | int dw; | 772 | int dw; |
788 | int dh; | 773 | int dh; |
789 | 774 | ||
790 | if (MenuID == 1) // right click | 775 | if (MenuID == 1) // right click |
791 | { | 776 | { |
792 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, mx, my); | 777 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, mx, my); |
793 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, mx, my); | 778 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, mx, my); |
794 | } | 779 | } |
795 | else if (MenuID == 2) // toggle full screen | 780 | else if (MenuID == 2) // toggle full screen |
796 | { | 781 | { |
797 | fullscreen = ~fullscreen; | 782 | fullscreen = ~fullscreen; |
798 | if (fullscreen) | 783 | if (fullscreen) |
799 | { | 784 | { |
800 | Desktop = App->desktop(); | 785 | Desktop = App->desktop(); |
801 | dw = Desktop->width(); | 786 | dw = Desktop->width(); |
802 | dh = Desktop->height(); | 787 | dh = Desktop->height(); |
803 | if (dw == g_width && dh == g_height) | 788 | if (dw == g_width && dh == g_height) |
804 | MW->resize(g_width - 4, g_height - 4); | 789 | MW->resize(g_width - 4, g_height - 4); |
805 | SV->showFullScreen(); | 790 | SV->showFullScreen(); |
806 | } | 791 | } |
807 | else | 792 | else |
808 | { | 793 | { |
809 | SV->showNormal(); | 794 | SV->showNormal(); |
810 | SV->showMaximized(); | 795 | SV->showMaximized(); |
811 | MW->resize(g_width, g_height); | 796 | MW->resize(g_width, g_height); |
812 | } | 797 | } |
813 | } | 798 | } |
814 | else if (MenuID == 3) // reset keyboard | 799 | else if (MenuID == 3) // reset keyboard |
815 | { | 800 | { |
816 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); // shift | 801 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); // shift |
817 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); // control | 802 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); // control |
818 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); // alt | 803 | rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); // alt |
819 | } | 804 | } |
820 | else if (MenuID == 4) // double click | 805 | else if (MenuID == 4) // double click |
821 | { | 806 | { |
822 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); | 807 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); |
823 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); | 808 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
824 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); | 809 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); |
825 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); | 810 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); |
826 | } | 811 | } |
827 | } | 812 | } |
828 | 813 | ||
829 | //***************************************************************************** | 814 | //***************************************************************************** |
830 | void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) | 815 | void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) |
831 | { | 816 | { |
832 | int x; | 817 | int x; |
833 | int y; | 818 | int y; |
834 | 819 | ||
835 | x = e->x(); | 820 | x = e->x(); |
836 | y = e->y(); | 821 | y = e->y(); |
837 | 822 | ||
838 | if (timer_id) | 823 | if (timer_id) |
839 | { | 824 | { |
840 | x = x - mx; | 825 | x = x - mx; |
841 | y = y - my; | 826 | y = y - my; |
842 | if (x < -10 || x > 10 || y < -10 || y > 10) | 827 | if (x < -10 || x > 10 || y < -10 || y > 10) |
843 | { | 828 | { |
844 | killTimer(timer_id); | 829 | killTimer(timer_id); |
845 | timer_id = 0; | 830 | timer_id = 0; |
846 | } | 831 | } |
847 | } | 832 | } |
848 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y()); | 833 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y()); |
849 | } | 834 | } |
850 | 835 | ||
851 | //***************************************************************************** | 836 | //***************************************************************************** |
852 | void QMyMainWindow::mousePressEvent(QMouseEvent* e) | 837 | void QMyMainWindow::mousePressEvent(QMouseEvent* e) |
853 | { | 838 | { |
854 | timer_id = startTimer(1000); | 839 | timer_id = startTimer(1000); |
855 | mx = e->x(); | 840 | mx = e->x(); |
856 | my = e->y(); | 841 | my = e->y(); |
857 | if (e->button() == LeftButton) | 842 | if (e->button() == LeftButton) |
858 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, e->x(), e->y()); | 843 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, e->x(), e->y()); |
859 | else if (e->button() == RightButton) | 844 | else if (e->button() == RightButton) |
860 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, e->x(), e->y()); | 845 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, e->x(), e->y()); |
861 | else if (e->button() == MidButton) | 846 | else if (e->button() == MidButton) |
862 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y()); | 847 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y()); |
863 | } | 848 | } |
864 | 849 | ||
865 | //***************************************************************************** | 850 | //***************************************************************************** |
866 | void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) | 851 | void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) |
867 | { | 852 | { |
868 | killTimer(timer_id); | 853 | killTimer(timer_id); |
869 | timer_id = 0; | 854 | timer_id = 0; |
870 | if (e->button() == LeftButton) | 855 | if (e->button() == LeftButton) |
871 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y()); | 856 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y()); |
872 | else if (e->button() == RightButton) | 857 | else if (e->button() == RightButton) |
873 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y()); | 858 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y()); |
874 | else if (e->button() == MidButton) | 859 | else if (e->button() == MidButton) |
875 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y()); | 860 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y()); |
876 | } | 861 | } |
877 | 862 | ||
878 | //***************************************************************************** | 863 | //***************************************************************************** |
879 | void QMyMainWindow::wheelEvent(QWheelEvent* e) | 864 | void QMyMainWindow::wheelEvent(QWheelEvent* e) |
880 | { | 865 | { |
881 | if (e->delta() > 0) | 866 | if (e->delta() > 0) |
882 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y()); | 867 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y()); |
883 | else if (e->delta() < 0) | 868 | else if (e->delta() < 0) |
884 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y()); | 869 | rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y()); |
885 | } | 870 | } |
886 | 871 | ||
887 | #define NOT(x) (255-(x)) | 872 | #define NOT(x) (255-(x)) |
888 | 873 | ||
889 | //***************************************************************************** | 874 | //***************************************************************************** |
890 | uint8 rop(int rop, uint8 src, uint8 dst) | 875 | uint8 rop(int rop, uint8 src, uint8 dst) |
891 | { | 876 | { |
892 | switch (rop) | 877 | switch (rop) |
893 | { | 878 | { |
894 | case 0x0: return 0; | 879 | case 0x0: return 0; |
895 | case 0x1: return NOT (src | dst); | 880 | case 0x1: return NOT (src | dst); |
896 | case 0x2: return NOT (src) & dst; | 881 | case 0x2: return NOT (src) & dst; |
897 | case 0x3: return NOT (src); | 882 | case 0x3: return NOT (src); |
898 | case 0x4: return src & NOT (dst); | 883 | case 0x4: return src & NOT (dst); |
899 | case 0x5: return NOT (dst); | 884 | case 0x5: return NOT (dst); |
900 | case 0x6: return src ^ dst; | 885 | case 0x6: return src ^ dst; |
901 | case 0x7: return NOT (src & dst); | 886 | case 0x7: return NOT (src & dst); |
902 | case 0x8: return src & dst; | 887 | case 0x8: return src & dst; |
903 | case 0x9: return NOT (src) ^ dst; | 888 | case 0x9: return NOT (src) ^ dst; |
904 | case 0xa: return dst; | 889 | case 0xa: return dst; |
905 | case 0xb: return NOT (src) | dst; | 890 | case 0xb: return NOT (src) | dst; |
906 | case 0xc: return src; | 891 | case 0xc: return src; |
907 | case 0xd: return src | NOT (dst); | 892 | case 0xd: return src | NOT (dst); |
908 | case 0xe: return src | dst; | 893 | case 0xe: return src | dst; |
909 | case 0xf: return NOT (0); | 894 | case 0xf: return NOT (0); |
910 | } | 895 | } |
911 | return dst; | 896 | return dst; |
912 | } | 897 | } |
913 | 898 | ||
914 | //***************************************************************************** | 899 | //***************************************************************************** |
915 | uint8 get_pixel(int x, int y) | 900 | uint8 get_pixel(int x, int y) |
916 | { | 901 | { |
917 | if (x >= 0 && x < g_width && y >= 0 && y < g_height) | 902 | if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
918 | return BS[y * g_width + x]; | 903 | return BS[y * g_width + x]; |
919 | else | 904 | else |
920 | return 0; | 905 | return 0; |
921 | } | 906 | } |
922 | 907 | ||
923 | //***************************************************************************** | 908 | //***************************************************************************** |
924 | void set_pixel(int x, int y, uint8 pixel, int op = 0xc) | 909 | void set_pixel(int x, int y, uint8 pixel, int op = 0xc) |
925 | { | 910 | { |
926 | if (x >= clipx && x < (clipx + clipcx) && y >= clipy && y < (clipy + clipcy)) | 911 | if (x >= clipx && x < (clipx + clipcx) && y >= clipy && y < (clipy + clipcy)) |
927 | if (x >= 0 && x < g_width && y >= 0 && y < g_height) | 912 | if (x >= 0 && x < g_width && y >= 0 && y < g_height) |
928 | if (op == 0xc) | 913 | if (op == 0xc) |
929 | BS[y * g_width + x] = pixel; | 914 | BS[y * g_width + x] = pixel; |
930 | else | 915 | else |
931 | BS[y * g_width + x] = rop(op, pixel, BS[y * g_width + x]); | 916 | BS[y * g_width + x] = rop(op, pixel, BS[y * g_width + x]); |
932 | } | 917 | } |
933 | 918 | ||
934 | //****************************************************************************** | 919 | //****************************************************************************** |
935 | // adjust coordinates for cliping rect | 920 | // adjust coordinates for cliping rect |
936 | bool WarpCoords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy) | 921 | bool WarpCoords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy) |
937 | { | 922 | { |
938 | int dx, dy; | 923 | int dx, dy; |
939 | QRect InRect(*x, *y, *cx, *cy); | 924 | QRect InRect(*x, *y, *cx, *cy); |
940 | QRect OutRect; | 925 | QRect OutRect; |
941 | QRect CRect(clipx, clipy, clipcx, clipcy); | 926 | QRect CRect(clipx, clipy, clipcx, clipcy); |
942 | OutRect = InRect.intersect(CRect); | 927 | OutRect = InRect.intersect(CRect); |
943 | if (OutRect.isEmpty()) | 928 | if (OutRect.isEmpty()) |
944 | return false; | 929 | return false; |
945 | dx = OutRect.x() - InRect.x(); | 930 | dx = OutRect.x() - InRect.x(); |
946 | dy = OutRect.y() - InRect.y(); | 931 | dy = OutRect.y() - InRect.y(); |
947 | *x = OutRect.x(); | 932 | *x = OutRect.x(); |
948 | *y = OutRect.y(); | 933 | *y = OutRect.y(); |
949 | *cx = OutRect.width(); | 934 | *cx = OutRect.width(); |
950 | *cy = OutRect.height(); | 935 | *cy = OutRect.height(); |
951 | if (srcx != NULL) | 936 | if (srcx != NULL) |
952 | *srcx = *srcx + dx; | 937 | *srcx = *srcx + dx; |
953 | if (srcy != NULL) | 938 | if (srcy != NULL) |
954 | *srcy = *srcy + dy; | 939 | *srcy = *srcy + dy; |
955 | return true; | 940 | return true; |
956 | } | 941 | } |
957 | 942 | ||
958 | //***************************************************************************** | 943 | //***************************************************************************** |
959 | void QMyMainWindow::paintEvent(QPaintEvent* pe) | 944 | void QMyMainWindow::paintEvent(QPaintEvent* pe) |
960 | { | 945 | { |
961 | QImage* Image; | 946 | QImage* Image; |
962 | QPainter* Painter; | 947 | QPainter* Painter; |
963 | QRect Rect; | 948 | QRect Rect; |
964 | int i, j, w, h, l, t; | 949 | int i, j, w, h, l, t; |
965 | uint8* data; | 950 | uint8* data; |
966 | 951 | ||
967 | if (!testWFlags(WRepaintNoErase)) | 952 | if (!testWFlags(WRepaintNoErase)) |
968 | setWFlags(WRepaintNoErase); | 953 | setWFlags(WRepaintNoErase); |
969 | if (CM != NULL) | 954 | if (CM != NULL) |
970 | { | 955 | { |
971 | Rect = pe->rect(); | 956 | Rect = pe->rect(); |
972 | l = Rect.left(); | 957 | l = Rect.left(); |
973 | t = Rect.top(); | 958 | t = Rect.top(); |
974 | w = Rect.width(); | 959 | w = Rect.width(); |
975 | h = Rect.height(); | 960 | h = Rect.height(); |
976 | if (w > 0 && h > 0 && CM->NumColors > 0) | 961 | if (w > 0 && h > 0 && CM->NumColors > 0) |
977 | { | 962 | { |
978 | data = (uint8*)xmalloc(w * h); | 963 | data = (uint8*)xmalloc(w * h); |
979 | for (i = 0; i < h; i++) | 964 | for (i = 0; i < h; i++) |
980 | for (j = 0; j < w; j++) | 965 | for (j = 0; j < w; j++) |
981 | data[i * w + j] = get_pixel(l + j, t + i); | 966 | data[i * w + j] = get_pixel(l + j, t + i); |
982 | Image = new QImage(data, w, h, 8,(QRgb*)CM->RGBColors, CM->NumColors, QImage::IgnoreEndian); | 967 | Image = new QImage(data, w, h, 8,(QRgb*)CM->RGBColors, CM->NumColors, QImage::IgnoreEndian); |
983 | Painter = new QPainter(this); | 968 | Painter = new QPainter(this); |
984 | Painter->drawImage(l, t, *Image, 0, 0, w, h); | 969 | Painter->drawImage(l, t, *Image, 0, 0, w, h); |
985 | xfree(data); | 970 | xfree(data); |
986 | delete Painter; | 971 | delete Painter; |
987 | delete Image; | 972 | delete Image; |
988 | } | 973 | } |
989 | } | 974 | } |
990 | } | 975 | } |
991 | 976 | ||
992 | //***************************************************************************** | 977 | //***************************************************************************** |
993 | void QMyMainWindow::closeEvent(QCloseEvent* e) | 978 | void QMyMainWindow::closeEvent(QCloseEvent* e) |
994 | { | 979 | { |
995 | e->accept(); | 980 | e->accept(); |
996 | } | 981 | } |
997 | 982 | ||
998 | //***************************************************************************** | 983 | //***************************************************************************** |
999 | void QMyMainWindow::dataReceived() | 984 | void QMyMainWindow::dataReceived() |
1000 | { | 985 | { |
1001 | if (rdp_main_loop()) | 986 | if (rdp_main_loop()) |
1002 | return; | 987 | return; |
1003 | else | 988 | else |
1004 | SV->close(); | 989 | SV->close(); |
1005 | } | 990 | } |
1006 | 991 | ||
1007 | //***************************************************************************** | 992 | //***************************************************************************** |
1008 | void redraw(int x, int y, int cx, int cy) | 993 | void redraw(int x, int y, int cx, int cy) |
1009 | { | 994 | { |
1010 | if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL)) | 995 | if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL)) |
1011 | { | 996 | { |
1012 | MW->update(x, y, cx, cy); | 997 | MW->update(x, y, cx, cy); |
1013 | } | 998 | } |
1014 | } | 999 | } |
1015 | 1000 | ||
1016 | /* | 1001 | /* |
1017 | BOOL ui_init(void) | 1002 | BOOL ui_init(void) |
1018 | { | 1003 | { |
1019 | QWidget* d; | 1004 | QWidget* d; |
1020 | 1005 | ||
1021 | CM = NULL; | 1006 | CM = NULL; |
1022 | BS = NULL; | 1007 | BS = NULL; |
1023 | App = new QPEApplication(g_argc, g_argv); | 1008 | App = new QPEApplication(g_argc, g_argv); |
1024 | if (fullscreen) | 1009 | if (fullscreen) |
1025 | { | 1010 | { |
1026 | d = QApplication::desktop(); | 1011 | d = QApplication::desktop(); |
1027 | width = d->width(); // returns screen width | 1012 | width = d->width(); // returns screen width |
1028 | height = d->height(); // returns screen height | 1013 | height = d->height(); // returns screen height |
1029 | } | 1014 | } |
1030 | return True; | 1015 | return True; |
1031 | } | 1016 | } |
1032 | */ | 1017 | */ |
1033 | 1018 | ||
1034 | /* | 1019 | /* |
1035 | void ui_deinit(void) | 1020 | void ui_deinit(void) |
1036 | { | 1021 | { |
1037 | delete App; | 1022 | delete App; |
1038 | } | 1023 | } |
1039 | */ | 1024 | */ |
1040 | 1025 | ||
1041 | /* | 1026 | /* |
1042 | BOOL ui_create_window(void) | 1027 | BOOL ui_create_window(void) |
1043 | { | 1028 | { |
1044 | MW = new QMyMainWindow(); | 1029 | MW = new QMyMainWindow(); |
1045 | MW->resize(width, height); | 1030 | MW->resize(width, height); |
1046 | SV = new QMyScrollView(); | 1031 | SV = new QMyScrollView(); |
1047 | SV->resize(width + 4, height + 4); | 1032 | SV->resize(width + 4, height + 4); |
1048 | App->setMainWidget(SV); | 1033 | App->setMainWidget(SV); |
1049 | SV->addChild(MW); | 1034 | SV->addChild(MW); |
1050 | MW->setMouseTracking(true); | 1035 | MW->setMouseTracking(true); |
1051 | SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); | 1036 | SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); |
1052 | MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); | 1037 | MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); |
1053 | if (fullscreen) | 1038 | if (fullscreen) |
1054 | SV->showFullScreen(); | 1039 | SV->showFullScreen(); |
1055 | else | 1040 | else |
1056 | SV->showMaximized(); | 1041 | SV->showMaximized(); |
1057 | BS = (uint8*)xmalloc(width * height); | 1042 | BS = (uint8*)xmalloc(width * height); |
1058 | memset(BS, 0, width * height); | 1043 | memset(BS, 0, width * height); |
1059 | clipx = 0; | 1044 | clipx = 0; |
1060 | clipy = 0; | 1045 | clipy = 0; |
1061 | clipcx = width; | 1046 | clipcx = width; |
1062 | clipcy = height; | 1047 | clipcy = height; |
1063 | CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); | 1048 | CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); |
1064 | memset(CM, 0, sizeof(struct QColorMap)); | 1049 | memset(CM, 0, sizeof(struct QColorMap)); |
1065 | SV->timer_id = SV->startTimer(1000); | 1050 | SV->timer_id = SV->startTimer(1000); |
1066 | return True; | 1051 | return True; |
1067 | } | 1052 | } |
1068 | */ | 1053 | */ |
1069 | 1054 | ||
1070 | /* | 1055 | /* |
1071 | void ui_destroy_window(void) | 1056 | void ui_destroy_window(void) |
1072 | { | 1057 | { |
1073 | delete MW; | 1058 | delete MW; |
1074 | delete SV; | 1059 | delete SV; |
1075 | xfree(BS); | 1060 | xfree(BS); |
1076 | xfree(CM); | 1061 | xfree(CM); |
1077 | } | 1062 | } |
1078 | */ | 1063 | */ |
1079 | 1064 | ||
1080 | //***************************************************************************** | 1065 | //***************************************************************************** |
1081 | /* Returns 0 after user quit, 1 otherwise */ | 1066 | /* Returns 0 after user quit, 1 otherwise */ |
1082 | int ui_select(int rdp_socket) | 1067 | int ui_select(int rdp_socket) |
1083 | { | 1068 | { |
1084 | global_sock = rdp_socket; | 1069 | global_sock = rdp_socket; |
1085 | return 1; | 1070 | return 1; |
1086 | } | 1071 | } |
1087 | 1072 | ||
1088 | //***************************************************************************** | 1073 | //***************************************************************************** |
1089 | void ui_move_pointer(int /*x*/, int /*y*/) | 1074 | void ui_move_pointer(int /*x*/, int /*y*/) |
1090 | { | 1075 | { |
1091 | } | 1076 | } |
1092 | 1077 | ||
1093 | //***************************************************************************** | 1078 | //***************************************************************************** |
1094 | HBITMAP ui_create_bitmap(int width, int height, uint8 * data) | 1079 | HBITMAP ui_create_bitmap(int width, int height, uint8 * data) |
1095 | { | 1080 | { |
1096 | struct bitmap* the_bitmap; | 1081 | struct bitmap* the_bitmap; |
1097 | uint8* bitmap_data; | 1082 | uint8* bitmap_data; |
1098 | int i, j; | 1083 | int i, j; |
1099 | 1084 | ||
1100 | // printf("width %d height %d times %d\n", width, height, width * height); | 1085 | // printf("width %d height %d times %d\n", width, height, width * height); |
1101 | bitmap_data = (uint8*)xmalloc(width * height); | 1086 | bitmap_data = (uint8*)xmalloc(width * height); |
1102 | the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap)); | 1087 | the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap)); |
1103 | the_bitmap->w = width; | 1088 | the_bitmap->w = width; |
1104 | the_bitmap->h = height; | 1089 | the_bitmap->h = height; |
1105 | the_bitmap->data = bitmap_data; | 1090 | the_bitmap->data = bitmap_data; |
1106 | for (i = 0; i < height; i++) | 1091 | for (i = 0; i < height; i++) |
1107 | for (j = 0; j < width; j++) | 1092 | for (j = 0; j < width; j++) |
1108 | bitmap_data[i * width + j] = data[i * width + j]; | 1093 | bitmap_data[i * width + j] = data[i * width + j]; |
1109 | return the_bitmap; | 1094 | return the_bitmap; |
1110 | } | 1095 | } |
1111 | 1096 | ||
1112 | //***************************************************************************** | 1097 | //***************************************************************************** |
1113 | void ui_paint_bitmap(int x, int y, int cx, int cy, int width, | 1098 | void ui_paint_bitmap(int x, int y, int cx, int cy, int width, |
1114 | int height, uint8 * data) | 1099 | int height, uint8 * data) |
1115 | { | 1100 | { |
1116 | int i, j; | 1101 | int i, j; |
1117 | 1102 | ||
1118 | for (i = 0; i < cy; i++) | 1103 | for (i = 0; i < cy; i++) |
1119 | for (j = 0; j < cx; j++) | 1104 | for (j = 0; j < cx; j++) |
1120 | if (i < height) | 1105 | if (i < height) |
1121 | if (j < width) | 1106 | if (j < width) |
1122 | set_pixel(x + j, y + i, data[i * width + j]); | 1107 | set_pixel(x + j, y + i, data[i * width + j]); |
1123 | redraw(x, y, cx, cy); | 1108 | redraw(x, y, cx, cy); |
1124 | } | 1109 | } |
1125 | 1110 | ||
1126 | //***************************************************************************** | 1111 | //***************************************************************************** |
1127 | void ui_destroy_bitmap(HBITMAP bmp) | 1112 | void ui_destroy_bitmap(HBITMAP bmp) |
1128 | { | 1113 | { |
1129 | struct bitmap* the_bitmap; | 1114 | struct bitmap* the_bitmap; |
1130 | 1115 | ||
1131 | the_bitmap = (struct bitmap*)bmp; | 1116 | the_bitmap = (struct bitmap*)bmp; |
1132 | if (the_bitmap != NULL) | 1117 | if (the_bitmap != NULL) |
1133 | { | 1118 | { |
1134 | if (the_bitmap->data != NULL) | 1119 | if (the_bitmap->data != NULL) |
1135 | xfree(the_bitmap->data); | 1120 | xfree(the_bitmap->data); |
1136 | xfree(the_bitmap); | 1121 | xfree(the_bitmap); |
1137 | } | 1122 | } |
1138 | } | 1123 | } |
1139 | 1124 | ||
1140 | //***************************************************************************** | 1125 | //***************************************************************************** |
1141 | bool is_pixel_on(uint8* data, int x, int y, int width, int bpp) | 1126 | bool is_pixel_on(uint8* data, int x, int y, int width, int bpp) |
1142 | { | 1127 | { |
1143 | int start, shift; | 1128 | int start, shift; |
1144 | 1129 | ||
1145 | if (bpp == 1) | 1130 | if (bpp == 1) |
1146 | { | 1131 | { |
1147 | width = (width + 7) / 8; | 1132 | width = (width + 7) / 8; |
1148 | start = (y * width) + x / 8; | 1133 | start = (y * width) + x / 8; |
1149 | shift = x % 8; | 1134 | shift = x % 8; |
1150 | return (data[start] & (0x80 >> shift)) != 0; | 1135 | return (data[start] & (0x80 >> shift)) != 0; |
1151 | } | 1136 | } |
1152 | else if (bpp == 8) | 1137 | else if (bpp == 8) |
1153 | return data[y * width + x] != 0; | 1138 | return data[y * width + x] != 0; |
1154 | else | 1139 | else |
1155 | return false; | 1140 | return false; |
1156 | } | 1141 | } |
1157 | 1142 | ||
1158 | //***************************************************************************** | 1143 | //***************************************************************************** |
1159 | void set_pixel_on(uint8* data, int x, int y, int width, int bpp, uint8 pixel) | 1144 | void set_pixel_on(uint8* data, int x, int y, int width, int bpp, uint8 pixel) |
1160 | { | 1145 | { |
1161 | if (bpp == 8) | 1146 | if (bpp == 8) |
1162 | data[y * width + x] = pixel; | 1147 | data[y * width + x] = pixel; |
1163 | } | 1148 | } |
1164 | 1149 | ||
1165 | //***************************************************************************** | 1150 | //***************************************************************************** |
1166 | HGLYPH ui_create_glyph(int width, int height, uint8 * data) | 1151 | HGLYPH ui_create_glyph(int width, int height, uint8 * data) |
1167 | { | 1152 | { |
1168 | int i, j; | 1153 | int i, j; |
1169 | uint8* glyph_data; | 1154 | uint8* glyph_data; |
1170 | struct bitmap* the_glyph; | 1155 | struct bitmap* the_glyph; |
1171 | 1156 | ||
1172 | glyph_data = (uint8*)xmalloc(width * height); | 1157 | glyph_data = (uint8*)xmalloc(width * height); |
1173 | the_glyph = (struct bitmap*)xmalloc(sizeof(struct bitmap)); | 1158 | the_glyph = (struct bitmap*)xmalloc(sizeof(struct bitmap)); |
1174 | the_glyph->w = width; | 1159 | the_glyph->w = width; |
1175 | the_glyph->h = height; | 1160 | the_glyph->h = height; |
1176 | the_glyph->data = glyph_data; | 1161 | the_glyph->data = glyph_data; |
1177 | memset(glyph_data, 0, width * height); | 1162 | memset(glyph_data, 0, width * height); |
1178 | for (i = 0; i < height; i++) | 1163 | for (i = 0; i < height; i++) |
1179 | for (j = 0; j < width; j++) | 1164 | for (j = 0; j < width; j++) |
1180 | if (is_pixel_on(data, j, i, width, 1)) | 1165 | if (is_pixel_on(data, j, i, width, 1)) |
1181 | set_pixel_on(glyph_data, j, i, width, 8, 255); | 1166 | set_pixel_on(glyph_data, j, i, width, 8, 255); |
1182 | return the_glyph; | 1167 | return the_glyph; |
1183 | } | 1168 | } |
1184 | 1169 | ||
1185 | //***************************************************************************** | 1170 | //***************************************************************************** |
1186 | void ui_destroy_glyph(HGLYPH glyph) | 1171 | void ui_destroy_glyph(HGLYPH glyph) |
1187 | { | 1172 | { |
1188 | struct bitmap* the_glyph; | 1173 | struct bitmap* the_glyph; |
1189 | 1174 | ||
1190 | the_glyph = (struct bitmap*)glyph; | 1175 | the_glyph = (struct bitmap*)glyph; |
1191 | if (the_glyph != NULL) | 1176 | if (the_glyph != NULL) |
1192 | { | 1177 | { |
1193 | if (the_glyph->data != NULL) | 1178 | if (the_glyph->data != NULL) |
1194 | xfree(the_glyph->data); | 1179 | xfree(the_glyph->data); |
1195 | xfree(the_glyph); | 1180 | xfree(the_glyph); |
1196 | } | 1181 | } |
1197 | } | 1182 | } |
1198 | 1183 | ||
1199 | //***************************************************************************** | 1184 | //***************************************************************************** |
1200 | HCURSOR ui_create_cursor(unsigned int /*x*/, unsigned int /*y*/, | 1185 | HCURSOR ui_create_cursor(unsigned int /*x*/, unsigned int /*y*/, |
1201 | int /*width*/, int /*height*/, uint8 * /*andmask*/, | 1186 | int /*width*/, int /*height*/, uint8 * /*andmask*/, |
1202 | uint8 * /*xormask*/) | 1187 | uint8 * /*xormask*/) |
1203 | { | 1188 | { |
1204 | return (void*)1; | 1189 | return (void*)1; |
1205 | } | 1190 | } |
1206 | 1191 | ||
1207 | //***************************************************************************** | 1192 | //***************************************************************************** |
1208 | void ui_set_cursor(HCURSOR /*cursor*/) | 1193 | void ui_set_cursor(HCURSOR /*cursor*/) |
1209 | { | 1194 | { |
1210 | } | 1195 | } |
1211 | 1196 | ||
1212 | //***************************************************************************** | 1197 | //***************************************************************************** |
1213 | void ui_destroy_cursor(HCURSOR /*cursor*/) | 1198 | void ui_destroy_cursor(HCURSOR /*cursor*/) |
1214 | { | 1199 | { |
1215 | } | 1200 | } |
1216 | 1201 | ||
1217 | //***************************************************************************** | 1202 | //***************************************************************************** |
1218 | HCOLOURMAP ui_create_colourmap(COLOURMAP * colours) | 1203 | HCOLOURMAP ui_create_colourmap(COLOURMAP * colours) |
1219 | { | 1204 | { |
1220 | int i; | 1205 | int i; |
1221 | int x; | 1206 | int x; |
1222 | uint8 r, g, b; | 1207 | uint8 r, g, b; |
1223 | i = 0; | 1208 | i = 0; |
1224 | while (i < colours->ncolours && i < 256) | 1209 | while (i < colours->ncolours && i < 256) |
1225 | { | 1210 | { |
1226 | r = colours->colours[i].red; | 1211 | r = colours->colours[i].red; |
1227 | g = colours->colours[i].green; | 1212 | g = colours->colours[i].green; |
1228 | b = colours->colours[i].blue; | 1213 | b = colours->colours[i].blue; |
1229 | x = (r << 16) | (g << 8) | b; | 1214 | x = (r << 16) | (g << 8) | b; |
1230 | CM->RGBColors[i] = x; | 1215 | CM->RGBColors[i] = x; |
1231 | i++; | 1216 | i++; |
1232 | } | 1217 | } |
1233 | CM->NumColors = colours->ncolours; | 1218 | CM->NumColors = colours->ncolours; |
1234 | return CM; | 1219 | return CM; |
1235 | } | 1220 | } |
1236 | 1221 | ||
1237 | //***************************************************************************** | 1222 | //***************************************************************************** |
1238 | void ui_destroy_colourmap(HCOLOURMAP /*map*/) | 1223 | void ui_destroy_colourmap(HCOLOURMAP /*map*/) |
1239 | { | 1224 | { |
1240 | } | 1225 | } |
1241 | 1226 | ||
1242 | //***************************************************************************** | 1227 | //***************************************************************************** |
1243 | void ui_set_colourmap(HCOLOURMAP /*map*/) | 1228 | void ui_set_colourmap(HCOLOURMAP /*map*/) |
1244 | { | 1229 | { |
1245 | } | 1230 | } |
1246 | 1231 | ||
1247 | //***************************************************************************** | 1232 | //***************************************************************************** |
1248 | void ui_begin_update(void) | 1233 | void ui_begin_update(void) |
1249 | { | 1234 | { |
1250 | } | 1235 | } |
1251 | 1236 | ||
1252 | //***************************************************************************** | 1237 | //***************************************************************************** |
1253 | void ui_end_update(void) | 1238 | void ui_end_update(void) |
1254 | { | 1239 | { |
1255 | } | 1240 | } |
1256 | 1241 | ||
1257 | //***************************************************************************** | 1242 | //***************************************************************************** |
1258 | void ui_set_clip(int x, int y, int cx, int cy) | 1243 | void ui_set_clip(int x, int y, int cx, int cy) |
1259 | { | 1244 | { |
1260 | clipx = x; | 1245 | clipx = x; |
1261 | clipy = y; | 1246 | clipy = y; |
1262 | clipcx = cx; | 1247 | clipcx = cx; |
1263 | clipcy = cy; | 1248 | clipcy = cy; |
1264 | } | 1249 | } |
1265 | 1250 | ||
1266 | //***************************************************************************** | 1251 | //***************************************************************************** |
1267 | void ui_reset_clip(void) | 1252 | void ui_reset_clip(void) |
1268 | { | 1253 | { |
1269 | clipx = 0; | 1254 | clipx = 0; |
1270 | clipy = 0; | 1255 | clipy = 0; |
1271 | clipcx = g_width; | 1256 | clipcx = g_width; |
1272 | clipcy = g_height; | 1257 | clipcy = g_height; |
1273 | } | 1258 | } |
1274 | 1259 | ||
1275 | //***************************************************************************** | 1260 | //***************************************************************************** |
1276 | void ui_bell(void) | 1261 | void ui_bell(void) |
1277 | { | 1262 | { |
1278 | App->beep(); | 1263 | App->beep(); |
1279 | } | 1264 | } |
1280 | 1265 | ||
1281 | //***************************************************************************** | 1266 | //***************************************************************************** |
1282 | void ui_destblt(uint8 opcode, int x, int y, int cx, int cy) | 1267 | void ui_destblt(uint8 opcode, int x, int y, int cx, int cy) |
1283 | { | 1268 | { |
1284 | int i, j; | 1269 | int i, j; |
1285 | 1270 | ||
1286 | for (i = 0; i < cy; i++) | 1271 | for (i = 0; i < cy; i++) |
1287 | for (j = 0; j < cx; j++) | 1272 | for (j = 0; j < cx; j++) |
1288 | set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode); | 1273 | set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode); |
1289 | redraw(x, y, cx, cy); | 1274 | redraw(x, y, cx, cy); |
1290 | } | 1275 | } |
1291 | 1276 | ||
1292 | //***************************************************************************** | 1277 | //***************************************************************************** |
1293 | // does not repaint | 1278 | // does not repaint |
1294 | void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc) | 1279 | void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc) |
1295 | { | 1280 | { |
1296 | int i, j; | 1281 | int i, j; |
1297 | 1282 | ||
1298 | for (i = 0; i < cy; i++) | 1283 | for (i = 0; i < cy; i++) |
1299 | for (j = 0; j < cx; j++) | 1284 | for (j = 0; j < cx; j++) |
1300 | set_pixel(x + j, y + i, colour, opcode); | 1285 | set_pixel(x + j, y + i, colour, opcode); |
1301 | } | 1286 | } |
1302 | 1287 | ||
1303 | //***************************************************************************** | 1288 | //***************************************************************************** |
1304 | void ui_rect(int x, int y, int cx, int cy, int colour) | 1289 | void ui_rect(int x, int y, int cx, int cy, int colour) |
1305 | { | 1290 | { |
1306 | fill_rect(x, y, cx, cy, colour); | 1291 | fill_rect(x, y, cx, cy, colour); |
1307 | redraw(x, y, cx, cy); | 1292 | redraw(x, y, cx, cy); |
1308 | } | 1293 | } |
1309 | 1294 | ||
1310 | //***************************************************************************** | 1295 | //***************************************************************************** |
1311 | void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, | 1296 | void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, |
1312 | BRUSH * brush, int bgcolour, int fgcolour) | 1297 | BRUSH * brush, int bgcolour, int fgcolour) |
1313 | { | 1298 | { |
1314 | int i, j; | 1299 | int i, j; |
1315 | uint8 ipattern[8]; | 1300 | uint8 ipattern[8]; |
1316 | 1301 | ||
1317 | switch (brush->style) | 1302 | switch (brush->style) |
1318 | { | 1303 | { |
1319 | case 0: | 1304 | case 0: |
1320 | fill_rect(x, y, cx, cy, fgcolour, opcode); | 1305 | fill_rect(x, y, cx, cy, fgcolour, opcode); |
1321 | break; | 1306 | break; |
1322 | case 3: | 1307 | case 3: |
1323 | for (i = 0; i < 8; i++) | 1308 | for (i = 0; i < 8; i++) |
1324 | ipattern[i] = ~brush->pattern[7 - i]; | 1309 | ipattern[i] = ~brush->pattern[7 - i]; |
1325 | for (i = 0; i < cy; i++) | 1310 | for (i = 0; i < cy; i++) |
1326 | for (j = 0; j < cx; j++) | 1311 | for (j = 0; j < cx; j++) |
1327 | if (is_pixel_on(ipattern, (x + j + brush->xorigin) % 8, | 1312 | if (is_pixel_on(ipattern, (x + j + brush->xorigin) % 8, |
1328 | (y + i + brush->yorigin) % 8, 8, 1)) | 1313 | (y + i + brush->yorigin) % 8, 8, 1)) |
1329 | set_pixel(x + j, y + i, fgcolour, opcode); | 1314 | set_pixel(x + j, y + i, fgcolour, opcode); |
1330 | else | 1315 | else |
1331 | set_pixel(x + j, y + i, bgcolour, opcode); | 1316 | set_pixel(x + j, y + i, bgcolour, opcode); |
1332 | break; | 1317 | break; |
1333 | } | 1318 | } |
1334 | redraw(x, y, cx, cy); | 1319 | redraw(x, y, cx, cy); |
1335 | } | 1320 | } |
1336 | 1321 | ||
1337 | //***************************************************************************** | 1322 | //***************************************************************************** |
1338 | void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, | 1323 | void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, |
1339 | int srcx, int srcy) | 1324 | int srcx, int srcy) |
1340 | { | 1325 | { |
1341 | int i, j; | 1326 | int i, j; |
1342 | uint8* temp; | 1327 | uint8* temp; |
1343 | 1328 | ||
1344 | temp = (uint8*)xmalloc(cx * cy); | 1329 | temp = (uint8*)xmalloc(cx * cy); |
1345 | for (i = 0; i < cy; i++) | 1330 | for (i = 0; i < cy; i++) |
1346 | for (j = 0; j < cx; j++) | 1331 | for (j = 0; j < cx; j++) |
1347 | temp[i * cx + j] = get_pixel(srcx + j, srcy + i); | 1332 | temp[i * cx + j] = get_pixel(srcx + j, srcy + i); |
1348 | for (i = 0; i < cy; i++) | 1333 | for (i = 0; i < cy; i++) |
1349 | for (j = 0; j < cx; j++) | 1334 | for (j = 0; j < cx; j++) |
1350 | set_pixel(x + j, y + i, temp[i * cx + j], opcode); | 1335 | set_pixel(x + j, y + i, temp[i * cx + j], opcode); |
1351 | xfree(temp); | 1336 | xfree(temp); |
1352 | redraw(x, y, cx, cy); | 1337 | redraw(x, y, cx, cy); |
1353 | } | 1338 | } |
1354 | 1339 | ||
1355 | //***************************************************************************** | 1340 | //***************************************************************************** |
1356 | void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, | 1341 | void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, |
1357 | HBITMAP src, int srcx, int srcy) | 1342 | HBITMAP src, int srcx, int srcy) |
1358 | { | 1343 | { |
1359 | int i, j; | 1344 | int i, j; |
1360 | struct bitmap* the_bitmap; | 1345 | struct bitmap* the_bitmap; |
1361 | 1346 | ||
1362 | the_bitmap = (struct bitmap*)src; | 1347 | the_bitmap = (struct bitmap*)src; |
1363 | if (the_bitmap == NULL) | 1348 | if (the_bitmap == NULL) |
1364 | return; | 1349 | return; |
1365 | for (i = 0; i < cy; i++) | 1350 | for (i = 0; i < cy; i++) |
1366 | for (j = 0; j < cx; j++) | 1351 | for (j = 0; j < cx; j++) |
1367 | if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) | 1352 | if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
1368 | set_pixel(x + j, y + i, the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)], opcode); | 1353 | set_pixel(x + j, y + i, the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)], opcode); |
1369 | redraw(x, y, cx, cy); | 1354 | redraw(x, y, cx, cy); |
1370 | } | 1355 | } |
1371 | 1356 | ||
1372 | //***************************************************************************** | 1357 | //***************************************************************************** |
1373 | // not used | 1358 | // not used |
1374 | void ui_triblt(uint8 /*opcode*/, int /*x*/, int /*y*/, int /*cx*/, int /*cy*/, | 1359 | void ui_triblt(uint8 /*opcode*/, int /*x*/, int /*y*/, int /*cx*/, int /*cy*/, |
1375 | HBITMAP /*src*/, int /*srcx*/, int /*srcy*/, BRUSH * /*brush*/, | 1360 | HBITMAP /*src*/, int /*srcx*/, int /*srcy*/, BRUSH * /*brush*/, |
1376 | int /*bgcolour*/, int /*fgcolour*/) | 1361 | int /*bgcolour*/, int /*fgcolour*/) |
1377 | { | 1362 | { |
1378 | } | 1363 | } |
1379 | 1364 | ||
1380 | //***************************************************************************** | 1365 | //***************************************************************************** |
1381 | // Bresenham's line drawing algorithm | 1366 | // Bresenham's line drawing algorithm |
1382 | void ui_line(uint8 opcode, int startx, int starty, int endx, | 1367 | void ui_line(uint8 opcode, int startx, int starty, int endx, |
1383 | int endy, PEN * pen) | 1368 | int endy, PEN * pen) |
1384 | { | 1369 | { |
1385 | int dx, dy, incx, incy, dpr, dpru, p, left, top, right, bottom; | 1370 | int dx, dy, incx, incy, dpr, dpru, p, left, top, right, bottom; |
1386 | 1371 | ||
1387 | if (startx > endx) | 1372 | if (startx > endx) |
1388 | { | 1373 | { |
1389 | dx = startx - endx; | 1374 | dx = startx - endx; |
1390 | incx = -1; | 1375 | incx = -1; |
1391 | left = endx; | 1376 | left = endx; |
1392 | right = startx; | 1377 | right = startx; |
1393 | } | 1378 | } |
1394 | else | 1379 | else |
1395 | { | 1380 | { |
1396 | dx = endx - startx; | 1381 | dx = endx - startx; |
1397 | incx = 1; | 1382 | incx = 1; |
1398 | left = startx; | 1383 | left = startx; |
1399 | right = endx; | 1384 | right = endx; |
1400 | } | 1385 | } |
1401 | if (starty > endy) | 1386 | if (starty > endy) |
1402 | { | 1387 | { |
1403 | dy = starty - endy; | 1388 | dy = starty - endy; |
1404 | incy = -1; | 1389 | incy = -1; |
1405 | top = endy; | 1390 | top = endy; |
1406 | bottom = starty; | 1391 | bottom = starty; |
1407 | } | 1392 | } |
1408 | else | 1393 | else |
1409 | { | 1394 | { |
1410 | dy = endy - starty; | 1395 | dy = endy - starty; |
1411 | incy = 1; | 1396 | incy = 1; |
1412 | top = starty; | 1397 | top = starty; |
1413 | bottom = endy; | 1398 | bottom = endy; |
1414 | } | 1399 | } |
1415 | if (dx >= dy) | 1400 | if (dx >= dy) |
1416 | { | 1401 | { |
1417 | dpr = dy << 1; | 1402 | dpr = dy << 1; |
1418 | dpru = dpr - (dx << 1); | 1403 | dpru = dpr - (dx << 1); |
1419 | p = dpr - dx; | 1404 | p = dpr - dx; |
1420 | for (; dx >= 0; dx--) | 1405 | for (; dx >= 0; dx--) |
1421 | { | 1406 | { |
1422 | set_pixel(startx, starty, pen->colour, opcode); | 1407 | set_pixel(startx, starty, pen->colour, opcode); |
1423 | if (p > 0) | 1408 | if (p > 0) |
1424 | { | 1409 | { |
1425 | startx += incx; | 1410 | startx += incx; |
1426 | starty += incy; | 1411 | starty += incy; |
1427 | p += dpru; | 1412 | p += dpru; |
1428 | } | 1413 | } |
1429 | else | 1414 | else |
1430 | { | 1415 | { |
1431 | startx += incx; | 1416 | startx += incx; |
1432 | p += dpr; | 1417 | p += dpr; |
1433 | } | 1418 | } |
1434 | } | 1419 | } |
1435 | } | 1420 | } |
1436 | else | 1421 | else |
1437 | { | 1422 | { |
1438 | dpr = dx << 1; | 1423 | dpr = dx << 1; |
1439 | dpru = dpr - (dy << 1); | 1424 | dpru = dpr - (dy << 1); |
1440 | p = dpr - dy; | 1425 | p = dpr - dy; |
1441 | for (; dy >= 0; dy--) | 1426 | for (; dy >= 0; dy--) |
1442 | { | 1427 | { |
1443 | set_pixel(startx, starty, pen->colour, opcode); | 1428 | set_pixel(startx, starty, pen->colour, opcode); |
1444 | if (p > 0) | 1429 | if (p > 0) |
1445 | { | 1430 | { |
1446 | startx += incx; | 1431 | startx += incx; |
1447 | starty += incy; | 1432 | starty += incy; |
1448 | p += dpru; | 1433 | p += dpru; |
1449 | } | 1434 | } |
1450 | else | 1435 | else |
1451 | { | 1436 | { |
1452 | starty += incy; | 1437 | starty += incy; |
1453 | p += dpr; | 1438 | p += dpr; |
1454 | } | 1439 | } |
1455 | } | 1440 | } |
1456 | } | 1441 | } |
1457 | redraw(left, top, (right - left) + 1, (bottom - top) + 1); | 1442 | redraw(left, top, (right - left) + 1, (bottom - top) + 1); |
1458 | } | 1443 | } |
1459 | 1444 | ||
1460 | //***************************************************************************** | 1445 | //***************************************************************************** |
1461 | void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) | 1446 | void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) |
1462 | { | 1447 | { |
1463 | struct bitmap* the_glyph; | 1448 | struct bitmap* the_glyph; |
1464 | int i, j; | 1449 | int i, j; |
1465 | 1450 | ||
1466 | the_glyph = (struct bitmap*)glyph; | 1451 | the_glyph = (struct bitmap*)glyph; |
1467 | if (the_glyph == NULL) | 1452 | if (the_glyph == NULL) |
1468 | return; | 1453 | return; |
1469 | for (i = 0; i < the_glyph->h; i++) | 1454 | for (i = 0; i < the_glyph->h; i++) |
1470 | for (j = 0; j < the_glyph->w; j++) | 1455 | for (j = 0; j < the_glyph->w; j++) |
1471 | if (is_pixel_on(the_glyph->data, j, i, the_glyph->w, 8)) | 1456 | if (is_pixel_on(the_glyph->data, j, i, the_glyph->w, 8)) |
1472 | set_pixel(x + j, y + i, fgcolour); | 1457 | set_pixel(x + j, y + i, fgcolour); |
1473 | } | 1458 | } |
1474 | 1459 | ||
1475 | #define DO_GLYPH(ttext,idx) \ | 1460 | #define DO_GLYPH(ttext,idx) \ |
1476 | {\ | 1461 | {\ |
1477 | glyph = cache_get_font (font, ttext[idx]);\ | 1462 | glyph = cache_get_font (font, ttext[idx]);\ |
1478 | if (!(flags & TEXT2_IMPLICIT_X))\ | 1463 | if (!(flags & TEXT2_IMPLICIT_X))\ |
1479 | {\ | 1464 | {\ |
1480 | xyoffset = ttext[++idx];\ | 1465 | xyoffset = ttext[++idx];\ |
1481 | if ((xyoffset & 0x80))\ | 1466 | if ((xyoffset & 0x80))\ |
1482 | {\ | 1467 | {\ |
1483 | if (flags & TEXT2_VERTICAL) \ | 1468 | if (flags & TEXT2_VERTICAL) \ |
1484 | y += ttext[idx+1] | (ttext[idx+2] << 8);\ | 1469 | y += ttext[idx+1] | (ttext[idx+2] << 8);\ |
1485 | else\ | 1470 | else\ |
1486 | x += ttext[idx+1] | (ttext[idx+2] << 8);\ | 1471 | x += ttext[idx+1] | (ttext[idx+2] << 8);\ |
1487 | idx += 2;\ | 1472 | idx += 2;\ |
1488 | }\ | 1473 | }\ |
1489 | else\ | 1474 | else\ |
1490 | {\ | 1475 | {\ |
1491 | if (flags & TEXT2_VERTICAL) \ | 1476 | if (flags & TEXT2_VERTICAL) \ |
1492 | y += xyoffset;\ | 1477 | y += xyoffset;\ |
1493 | else\ | 1478 | else\ |
1494 | x += xyoffset;\ | 1479 | x += xyoffset;\ |
1495 | }\ | 1480 | }\ |
1496 | }\ | 1481 | }\ |
1497 | if (glyph != NULL)\ | 1482 | if (glyph != NULL)\ |
1498 | {\ | 1483 | {\ |
1499 | draw_glyph (x + glyph->offset, y + glyph->baseline, glyph->pixmap, fgcolour);\ | 1484 | draw_glyph (x + glyph->offset, y + glyph->baseline, glyph->pixmap, fgcolour);\ |
1500 | if (flags & TEXT2_IMPLICIT_X)\ | 1485 | if (flags & TEXT2_IMPLICIT_X)\ |
1501 | x += glyph->width;\ | 1486 | x += glyph->width;\ |
1502 | }\ | 1487 | }\ |
1503 | } | 1488 | } |
1504 | 1489 | ||
1505 | //***************************************************************************** | 1490 | //***************************************************************************** |
1506 | void ui_draw_text(uint8 font, uint8 flags, int mixmode, | 1491 | void ui_draw_text(uint8 font, uint8 flags, int mixmode, |
1507 | int x, int y, int clipx, int clipy, | 1492 | int x, int y, int clipx, int clipy, |
1508 | int clipcx, int clipcy, int boxx, | 1493 | int clipcx, int clipcy, int boxx, |
1509 | int boxy, int boxcx, int boxcy, int bgcolour, | 1494 | int boxy, int boxcx, int boxcy, int bgcolour, |
1510 | int fgcolour, uint8 * text, uint8 length) | 1495 | int fgcolour, uint8 * text, uint8 length) |
1511 | { | 1496 | { |
1512 | FONTGLYPH *glyph; | 1497 | FONTGLYPH *glyph; |
1513 | int i, j, xyoffset; | 1498 | int i, j, xyoffset; |
1514 | DATABLOB *entry; | 1499 | DATABLOB *entry; |
1515 | 1500 | ||
1516 | if (boxcx > 1) | 1501 | if (boxcx > 1) |
1517 | fill_rect(boxx, boxy, boxcx, boxcy, bgcolour); | 1502 | fill_rect(boxx, boxy, boxcx, boxcy, bgcolour); |
1518 | else if (mixmode == MIX_OPAQUE) | 1503 | else if (mixmode == MIX_OPAQUE) |
1519 | fill_rect(clipx, clipy, clipcx, clipcy, bgcolour); | 1504 | fill_rect(clipx, clipy, clipcx, clipcy, bgcolour); |
1520 | 1505 | ||
1521 | /* Paint text, character by character */ | 1506 | /* Paint text, character by character */ |
1522 | for (i = 0; i < length;) | 1507 | for (i = 0; i < length;) |
1523 | { | 1508 | { |
1524 | switch (text[i]) | 1509 | switch (text[i]) |
1525 | { | 1510 | { |
1526 | case 0xff: | 1511 | case 0xff: |
1527 | if (i + 2 < length) | 1512 | if (i + 2 < length) |
1528 | cache_put_text(text[i + 1], text, text[i + 2]); | 1513 | cache_put_text(text[i + 1], text, text[i + 2]); |
1529 | else | 1514 | else |
1530 | { | 1515 | { |
1531 | error("this shouldn't be happening\n"); | 1516 | error("this shouldn't be happening\n"); |
1532 | exit(1); | 1517 | exit(1); |
1533 | } | 1518 | } |
1534 | /* this will move pointer from start to first character after FF command */ | 1519 | /* this will move pointer from start to first character after FF command */ |
1535 | length -= i + 3; | 1520 | length -= i + 3; |
1536 | text = &(text[i + 3]); | 1521 | text = &(text[i + 3]); |
1537 | i = 0; | 1522 | i = 0; |
1538 | break; | 1523 | break; |
1539 | 1524 | ||
1540 | case 0xfe: | 1525 | case 0xfe: |
1541 | entry = cache_get_text(text[i + 1]); | 1526 | entry = cache_get_text(text[i + 1]); |
1542 | if (entry != NULL) | 1527 | if (entry != NULL) |
1543 | { | 1528 | { |
1544 | if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X))) | 1529 | if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X))) |
1545 | { | 1530 | { |
1546 | if (flags & TEXT2_VERTICAL) | 1531 | if (flags & TEXT2_VERTICAL) |
1547 | y += text[i + 2]; | 1532 | y += text[i + 2]; |
1548 | else | 1533 | else |
1549 | x += text[i + 2]; | 1534 | x += text[i + 2]; |
1550 | } | 1535 | } |
1551 | for (j = 0; j < entry->size; j++) | 1536 | for (j = 0; j < entry->size; j++) |
1552 | DO_GLYPH(((uint8 *) (entry->data)), j); | 1537 | DO_GLYPH(((uint8 *) (entry->data)), j); |
1553 | } | 1538 | } |
1554 | if (i + 2 < length) | 1539 | if (i + 2 < length) |
1555 | i += 3; | 1540 | i += 3; |
1556 | else | 1541 | else |
1557 | i += 2; | 1542 | i += 2; |
1558 | length -= i; | 1543 | length -= i; |
1559 | /* this will move pointer from start to first character after FE command */ | 1544 | /* this will move pointer from start to first character after FE command */ |
1560 | text = &(text[i]); | 1545 | text = &(text[i]); |
1561 | i = 0; | 1546 | i = 0; |
1562 | break; | 1547 | break; |
1563 | 1548 | ||
1564 | default: | 1549 | default: |
1565 | DO_GLYPH(text, i); | 1550 | DO_GLYPH(text, i); |
1566 | i++; | 1551 | i++; |
1567 | break; | 1552 | break; |
1568 | } | 1553 | } |
1569 | } | 1554 | } |
1570 | if (boxcx > 1) | 1555 | if (boxcx > 1) |
1571 | redraw(boxx, boxy, boxcx, boxcy); | 1556 | redraw(boxx, boxy, boxcx, boxcy); |
1572 | else | 1557 | else |
1573 | redraw(clipx, clipy, clipcx, clipcy); | 1558 | redraw(clipx, clipy, clipcx, clipcy); |
1574 | } | 1559 | } |
1575 | 1560 | ||
1576 | //***************************************************************************** | 1561 | //***************************************************************************** |
1577 | void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) | 1562 | void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) |
1578 | { | 1563 | { |
1579 | uint8* data; | 1564 | uint8* data; |
1580 | int i, j; | 1565 | int i, j; |
1581 | 1566 | ||
1582 | data = (uint8*)xmalloc(cx * cy); | 1567 | data = (uint8*)xmalloc(cx * cy); |
1583 | for (i = 0; i < cy; i++) | 1568 | for (i = 0; i < cy; i++) |
1584 | for (j = 0; j < cx; j++) | 1569 | for (j = 0; j < cx; j++) |
1585 | data[i * cx + j] = get_pixel(x + j, y + i); | 1570 | data[i * cx + j] = get_pixel(x + j, y + i); |
1586 | cache_put_desktop(offset, cx, cy, cx, 1, data); | 1571 | cache_put_desktop(offset, cx, cy, cx, 1, data); |
1587 | xfree(data); | 1572 | xfree(data); |
1588 | } | 1573 | } |
1589 | 1574 | ||
1590 | //***************************************************************************** | 1575 | //***************************************************************************** |
1591 | void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) | 1576 | void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) |
1592 | { | 1577 | { |
1593 | uint8* data; | 1578 | uint8* data; |
1594 | int i, j; | 1579 | int i, j; |
1595 | 1580 | ||
1596 | data = cache_get_desktop(offset, cx, cy, 1); | 1581 | data = cache_get_desktop(offset, cx, cy, 1); |
1597 | for (i = 0; i < cy; i++) | 1582 | for (i = 0; i < cy; i++) |
1598 | for (j = 0; j < cx; j++) | 1583 | for (j = 0; j < cx; j++) |
1599 | set_pixel(x + j, y + i, data[i * cx + j]); | 1584 | set_pixel(x + j, y + i, data[i * cx + j]); |
1600 | redraw(x, y, cx, cy); | 1585 | redraw(x, y, cx, cy); |
1601 | } | 1586 | } |
1602 | 1587 | ||
1603 | //***************************************************************************** | 1588 | //***************************************************************************** |
1604 | int main(int argc, char** argv) | 1589 | int main(int argc, char** argv) |
1605 | { | 1590 | { |
1606 | CM = NULL; | 1591 | CM = NULL; |
1607 | BS = NULL; | 1592 | BS = NULL; |
1608 | App = new QPEApplication(argc, argv); | 1593 | App = new QPEApplication(argc, argv); |
1609 | SV = new QMyScrollView(); | 1594 | SV = new QMyScrollView(); |
1610 | App->setMainWidget(SV); | 1595 | App->setMainWidget(SV); |
1611 | SV->showMaximized(); | 1596 | SV->showMaximized(); |
1612 | SV->setCaption( QMyScrollView::tr("Remote Desktop Client (RDP)") ); | 1597 | SV->setCaption( QMyScrollView::tr("Remote Desktop Client (RDP)") ); |
1613 | SV->timer_id = SV->startTimer(1000); | 1598 | SV->timer_id = SV->startTimer(1000); |
1614 | App->exec(); | 1599 | App->exec(); |
1615 | delete SV; | 1600 | delete SV; |
1616 | delete App; | 1601 | delete App; |
1617 | if (CM != NULL) | 1602 | if (CM != NULL) |
1618 | xfree(CM); | 1603 | xfree(CM); |
1619 | if (BS !=NULL) | 1604 | if (BS !=NULL) |
1620 | xfree(BS); | 1605 | xfree(BS); |
1621 | return 0; | 1606 | return 0; |
1622 | } | 1607 | } |
1623 | 1608 | ||
1624 | /* | 1609 | /* |
1625 | MW = new QMyMainWindow(); | 1610 | MW = new QMyMainWindow(); |
1626 | MW->resize(width, height); | 1611 | MW->resize(width, height); |
1627 | SV->resize(width + 4, height + 4); | 1612 | SV->resize(width + 4, height + 4); |
1628 | App->setMainWidget(SV); | 1613 | App->setMainWidget(SV); |
1629 | SV->addChild(MW); | 1614 | SV->addChild(MW); |
1630 | MW->setMouseTracking(true); | 1615 | MW->setMouseTracking(true); |
1631 | SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); | 1616 | SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); |
1632 | MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); | 1617 | MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); |
1633 | if (fullscreen) | 1618 | if (fullscreen) |
1634 | SV->showFullScreen(); | 1619 | SV->showFullScreen(); |
1635 | else | 1620 | else |
1636 | SV->showMaximized(); | 1621 | SV->showMaximized(); |
1637 | BS = (uint8*)xmalloc(width * height); | 1622 | BS = (uint8*)xmalloc(width * height); |
1638 | memset(BS, 0, width * height); | 1623 | memset(BS, 0, width * height); |
1639 | clipx = 0; | 1624 | clipx = 0; |
1640 | clipy = 0; | 1625 | clipy = 0; |
1641 | clipcx = width; | 1626 | clipcx = width; |
1642 | clipcy = height; | 1627 | clipcy = height; |
1643 | CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); | 1628 | CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); |
1644 | memset(CM, 0, sizeof(struct QColorMap)); | 1629 | memset(CM, 0, sizeof(struct QColorMap)); |
1645 | SV->timer_id = SV->startTimer(1000); | 1630 | SV->timer_id = SV->startTimer(1000); |
1646 | return True; | 1631 | return True; |
1647 | 1632 | ||
1648 | 1633 | ||
1649 | 1634 | ||
1650 | 1635 | ||
1651 | 1636 | ||
1652 | int main(int argc, char ** argv) | 1637 | int main(int argc, char ** argv) |
1653 | { | 1638 | { |
1654 | uint32 flags; | 1639 | uint32 flags; |
1655 | int i, total_params; | 1640 | int i, total_params; |
1656 | char server[64] = "192.168.0.164"; | 1641 | char server[64] = "192.168.0.164"; |
1657 | char domain[16] = ""; | 1642 | char domain[16] = ""; |
1658 | char password[16] = ""; | 1643 | char password[16] = ""; |
1659 | char shell[128] = ""; | 1644 | char shell[128] = ""; |
1660 | char directory[32] = ""; | 1645 | char directory[32] = ""; |
1661 | char* p; | 1646 | char* p; |
1662 | QString param, s1, s2, s3; | 1647 | QString param, s1, s2, s3; |
1663 | 1648 | ||
1664 | flags = RDP_LOGON_NORMAL; | 1649 | flags = RDP_LOGON_NORMAL; |
1665 | 1650 | ||
1666 | g_argc = argc; | 1651 | g_argc = argc; |
1667 | g_argv = argv; | 1652 | g_argv = argv; |
1668 | 1653 | ||
1669 | if (!ui_init()) | 1654 | if (!ui_init()) |
1670 | return 1; | 1655 | return 1; |
1671 | 1656 | ||
1672 | total_params = App->argc(); | 1657 | total_params = App->argc(); |
1673 | 1658 | ||
1674 | for (i = 1; (i + 1) < total_params; i = i + 2) | 1659 | for (i = 1; (i + 1) < total_params; i = i + 2) |
1675 | { | 1660 | { |
1676 | s1 = App->argv()[i]; | 1661 | s1 = App->argv()[i]; |
1677 | s2 = App->argv()[i + 1]; | 1662 | s2 = App->argv()[i + 1]; |
1678 | if (s1 == "-g") | 1663 | if (s1 == "-g") |
1679 | { | 1664 | { |
1680 | width = strtol((const char*)s2, &p, 10); | 1665 | width = strtol((const char*)s2, &p, 10); |
1681 | if (*p == 'x') | 1666 | if (*p == 'x') |
1682 | height = strtol(p + 1, NULL, 10); | 1667 | height = strtol(p + 1, NULL, 10); |
1683 | } | 1668 | } |
1684 | else if (s1 = "-u") | 1669 | else if (s1 = "-u") |
1685 | strcpy(username, (const char*)s2); | 1670 | strcpy(username, (const char*)s2); |
1686 | } | 1671 | } |
1687 | if (i < total_params) | 1672 | if (i < total_params) |
1688 | strcpy(server, App->argv()[i]); | 1673 | strcpy(server, App->argv()[i]); |
1689 | 1674 | ||
1690 | // printf("server %s width %d height %d\n", server, width, height); | 1675 | // printf("server %s width %d height %d\n", server, width, height); |
1691 | 1676 | ||
1692 | if (width == 0 || height == 0) | 1677 | if (width == 0 || height == 0) |
1693 | { | 1678 | { |
1694 | ui_deinit(); | 1679 | ui_deinit(); |
1695 | return 1; | 1680 | return 1; |
1696 | } | 1681 | } |
1697 | 1682 | ||
1698 | if (!rdp_connect(server, flags, domain, password, shell, directory)) | 1683 | if (!rdp_connect(server, flags, domain, password, shell, directory)) |
1699 | { | 1684 | { |
1700 | ui_deinit(); | 1685 | ui_deinit(); |
1701 | return 1; | 1686 | return 1; |
1702 | } | 1687 | } |
1703 | if (ui_create_window()) | 1688 | if (ui_create_window()) |
1704 | { | 1689 | { |
1705 | ui_main_loop(); | 1690 | ui_main_loop(); |
1706 | ui_destroy_window(); | 1691 | ui_destroy_window(); |
1707 | } | 1692 | } |
1708 | rdp_disconnect(); | 1693 | rdp_disconnect(); |
1709 | ui_deinit(); | 1694 | ui_deinit(); |
1710 | } | 1695 | } |
1711 | */ | 1696 | */ |
diff --git a/noncore/net/opierdesktop/qtwin.h b/noncore/net/opierdesktop/qtwin.h index 38ad190..7a2110b 100644 --- a/noncore/net/opierdesktop/qtwin.h +++ b/noncore/net/opierdesktop/qtwin.h | |||
@@ -1,105 +1,103 @@ | |||
1 | 1 | ||
2 | #include <qwidget.h> | 2 | #include <qwidget.h> |
3 | #include <qscrollview.h> | 3 | #include <qscrollview.h> |
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | #include <qlistbox.h> | 5 | #include <qlistbox.h> |
6 | #include <qlineedit.h> | 6 | #include <qlineedit.h> |
7 | #include <qcombobox.h> | 7 | #include <qcombobox.h> |
8 | #include <qlabel.h> | 8 | #include <qlabel.h> |
9 | #include <qcheckbox.h> | 9 | #include <qcheckbox.h> |
10 | #include <qpopupmenu.h> | 10 | #include <qpopupmenu.h> |
11 | 11 | ||
12 | class QMyConnectionItem | 12 | class QMyConnectionItem |
13 | { | 13 | { |
14 | public: | 14 | public: |
15 | QString ServerName; | 15 | QString ServerName; |
16 | QString UserName; | 16 | QString UserName; |
17 | QString ServerIP; | 17 | QString ServerIP; |
18 | int Width; | 18 | int Width; |
19 | int Height; | 19 | int Height; |
20 | int FullScreen; | 20 | int FullScreen; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | class QMyDialog: public QDialog | 23 | class QMyDialog: public QDialog |
24 | { | 24 | { |
25 | Q_OBJECT | 25 | Q_OBJECT |
26 | public: | 26 | public: |
27 | QMyDialog(QWidget*); | 27 | QMyDialog(QWidget*); |
28 | ~QMyDialog(); | 28 | ~QMyDialog(); |
29 | public: | 29 | public: |
30 | QListBox* ListBox; | 30 | QListBox* ListBox; |
31 | QPushButton* OKButton; | ||
32 | QPushButton* CancelButton; | ||
33 | QLabel* Label1; | 31 | QLabel* Label1; |
34 | QLineEdit* ServerNameEdit; | 32 | QLineEdit* ServerNameEdit; |
35 | QLabel* Label2; | 33 | QLabel* Label2; |
36 | QLineEdit* UserNameEdit; | 34 | QLineEdit* UserNameEdit; |
37 | QLabel* Label3; | 35 | QLabel* Label3; |
38 | QLineEdit* IPEdit; | 36 | QLineEdit* IPEdit; |
39 | QLineEdit* WidthEdit; | 37 | QLineEdit* WidthEdit; |
40 | QLineEdit* HeightEdit; | 38 | QLineEdit* HeightEdit; |
41 | QComboBox* WidthHeightBox; | 39 | QComboBox* WidthHeightBox; |
42 | QPushButton* AddButton; | 40 | QPushButton* AddButton; |
43 | QPushButton* EditButton; | 41 | QPushButton* EditButton; |
44 | QPushButton* SaveButton; | 42 | QPushButton* SaveButton; |
45 | QPushButton* RemoveButton; | 43 | QPushButton* RemoveButton; |
46 | QCheckBox* FullScreenCheckBox; | 44 | QCheckBox* FullScreenCheckBox; |
47 | public slots: | 45 | public slots: |
48 | void ComboChanged(int); | 46 | void ComboChanged(int); |
49 | void OKClicked(); | ||
50 | void CancelClicked(); | ||
51 | void AddClicked(); | 47 | void AddClicked(); |
52 | void EditClicked(); | 48 | void EditClicked(); |
53 | void SaveClicked(); | 49 | void SaveClicked(); |
54 | void RemoveClicked(); | 50 | void RemoveClicked(); |
55 | void ListBoxChanged(); | 51 | void ListBoxChanged(); |
56 | void ListBoxSelected(int); | 52 | void ListBoxSelected(int); |
57 | public: | 53 | public: |
58 | QString ServerName; | 54 | QString ServerName; |
59 | QString UserName; | 55 | QString UserName; |
60 | QString ServerIP; | 56 | QString ServerIP; |
61 | int Width; | 57 | int Width; |
62 | int Height; | 58 | int Height; |
63 | int FullScreen; | 59 | int FullScreen; |
64 | QMyConnectionItem* ConnectionList[10]; | 60 | QMyConnectionItem* ConnectionList[10]; |
61 | protected slots: | ||
62 | void accept(); | ||
65 | }; | 63 | }; |
66 | 64 | ||
67 | class QMyScrollView: public QScrollView | 65 | class QMyScrollView: public QScrollView |
68 | { | 66 | { |
69 | Q_OBJECT | 67 | Q_OBJECT |
70 | public: | 68 | public: |
71 | QMyScrollView(); | 69 | QMyScrollView(); |
72 | ~QMyScrollView(); | 70 | ~QMyScrollView(); |
73 | void keyPressEvent(QKeyEvent*); | 71 | void keyPressEvent(QKeyEvent*); |
74 | void keyReleaseEvent(QKeyEvent*); | 72 | void keyReleaseEvent(QKeyEvent*); |
75 | void showEvent(QShowEvent*); | 73 | void showEvent(QShowEvent*); |
76 | void show(); | 74 | void show(); |
77 | void polish(); | 75 | void polish(); |
78 | void timerEvent(QTimerEvent*); | 76 | void timerEvent(QTimerEvent*); |
79 | public: | 77 | public: |
80 | int timer_id; | 78 | int timer_id; |
81 | }; | 79 | }; |
82 | 80 | ||
83 | class QMyMainWindow: public QWidget | 81 | class QMyMainWindow: public QWidget |
84 | { | 82 | { |
85 | Q_OBJECT | 83 | Q_OBJECT |
86 | public: | 84 | public: |
87 | QMyMainWindow(); | 85 | QMyMainWindow(); |
88 | ~QMyMainWindow(); | 86 | ~QMyMainWindow(); |
89 | void paintEvent(QPaintEvent*); | 87 | void paintEvent(QPaintEvent*); |
90 | void mouseMoveEvent(QMouseEvent*); | 88 | void mouseMoveEvent(QMouseEvent*); |
91 | void mousePressEvent(QMouseEvent*); | 89 | void mousePressEvent(QMouseEvent*); |
92 | void mouseReleaseEvent(QMouseEvent*); | 90 | void mouseReleaseEvent(QMouseEvent*); |
93 | void wheelEvent(QWheelEvent*); | 91 | void wheelEvent(QWheelEvent*); |
94 | void closeEvent(QCloseEvent*); | 92 | void closeEvent(QCloseEvent*); |
95 | void timerEvent(QTimerEvent*); | 93 | void timerEvent(QTimerEvent*); |
96 | public slots: | 94 | public slots: |
97 | void dataReceived(); | 95 | void dataReceived(); |
98 | void MemuClicked(int); | 96 | void MemuClicked(int); |
99 | public: | 97 | public: |
100 | QPopupMenu* PopupMenu; | 98 | QPopupMenu* PopupMenu; |
101 | int timer_id; | 99 | int timer_id; |
102 | int mx; | 100 | int mx; |
103 | int my; | 101 | int my; |
104 | }; | 102 | }; |
105 | 103 | ||