author | zecke <zecke> | 2005-02-14 16:06:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-14 16:06:11 (UTC) |
commit | 277adb0af903b8bc2760c20891b664b763b667d9 (patch) (unidiff) | |
tree | 9d6b33b8ed71f9f280981630ad45f3f8ba33eafb | |
parent | 866b55b819809a7bc448ea8b9cf2597051518007 (diff) | |
download | opie-277adb0af903b8bc2760c20891b664b763b667d9.zip opie-277adb0af903b8bc2760c20891b664b763b667d9.tar.gz opie-277adb0af903b8bc2760c20891b664b763b667d9.tar.bz2 |
Remove stupid #ifdef
-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,320 +1,312 @@ | |||
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(); |
@@ -774,517 +766,513 @@ void QMyMainWindow::timerEvent(QTimerEvent* e) | |||
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 | } |
@@ -1363,363 +1351,359 @@ void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, | |||
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 | */ |