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