25 |
#else |
#else |
26 |
#include <qapplication.h> |
#include <qapplication.h> |
27 |
#endif |
#endif |
28 |
|
#include <qcursor.h> |
29 |
#include <qmainwindow.h> |
#include <qmainwindow.h> |
30 |
#include <qwidget.h> |
#include <qwidget.h> |
31 |
#include <qpainter.h> |
#include <qpainter.h> |
120 |
#define SETPIXEL16(d, x, y, w, v) *(((uint16*)d) + ((y) * (w) + (x))) = v |
#define SETPIXEL16(d, x, y, w, v) *(((uint16*)d) + ((y) * (w) + (x))) = v |
121 |
#define SETPIXEL32(d, x, y, w, v) *(((uint32*)d) + ((y) * (w) + (x))) = v |
#define SETPIXEL32(d, x, y, w, v) *(((uint32*)d) + ((y) * (w) + (x))) = v |
122 |
|
|
123 |
//***************************************************************************** |
/******************************************************************************/ |
124 |
void CleanString(QString * Item) |
void CleanString(QString * Item) |
125 |
{ |
{ |
126 |
int i; |
int i; |
134 |
} |
} |
135 |
} |
} |
136 |
|
|
137 |
//***************************************************************************** |
/******************************************************************************/ |
138 |
QMyDialog::QMyDialog(QWidget * parent) : QDialog(parent, "Settings", true) |
QMyDialog::QMyDialog(QWidget * parent) : QDialog(parent, "Settings", true) |
139 |
{ |
{ |
140 |
int i, j; |
int i, j; |
248 |
if (home != NULL) |
if (home != NULL) |
249 |
{ |
{ |
250 |
sprintf(Text, "%s/rdesktop.ini", home); |
sprintf(Text, "%s/rdesktop.ini", home); |
251 |
QFile* File = new QFile(Text); |
QFile * File = new QFile(Text); |
252 |
if (File->open(IO_ReadOnly)) |
if (File->open(IO_ReadOnly)) |
253 |
{ |
{ |
254 |
i = -1; |
i = -1; |
285 |
} |
} |
286 |
} |
} |
287 |
|
|
288 |
//***************************************************************************** |
/******************************************************************************/ |
289 |
QMyDialog::~QMyDialog() |
QMyDialog::~QMyDialog() |
290 |
{ |
{ |
291 |
QMyConnectionItem* Item; |
QMyConnectionItem * Item; |
292 |
int i; |
int i; |
293 |
|
|
294 |
for (i = 0; i < 10; i++) |
for (i = 0; i < 10; i++) |
298 |
} |
} |
299 |
} |
} |
300 |
|
|
301 |
//***************************************************************************** |
/******************************************************************************/ |
302 |
void QMyDialog::ComboChanged(int index) |
void QMyDialog::ComboChanged(int index) |
303 |
{ |
{ |
304 |
if (index == 0) |
if (index == 0) |
318 |
} |
} |
319 |
} |
} |
320 |
|
|
321 |
//***************************************************************************** |
/******************************************************************************/ |
322 |
void QMyDialog::OKClicked() |
void QMyDialog::OKClicked() |
323 |
{ |
{ |
324 |
ServerName = ServerNameEdit->text(); |
ServerName = ServerNameEdit->text(); |
330 |
done(1); |
done(1); |
331 |
} |
} |
332 |
|
|
333 |
//***************************************************************************** |
/******************************************************************************/ |
334 |
void QMyDialog::CancelClicked() |
void QMyDialog::CancelClicked() |
335 |
{ |
{ |
336 |
done(0); |
done(0); |
337 |
} |
} |
338 |
|
|
339 |
//***************************************************************************** |
/******************************************************************************/ |
340 |
void QMyDialog::AddClicked() |
void QMyDialog::AddClicked() |
341 |
{ |
{ |
342 |
int i; |
int i; |
356 |
} |
} |
357 |
} |
} |
358 |
|
|
359 |
//***************************************************************************** |
/******************************************************************************/ |
360 |
void QMyDialog::EditClicked() |
void QMyDialog::EditClicked() |
361 |
{ |
{ |
362 |
int i; |
int i; |
376 |
} |
} |
377 |
} |
} |
378 |
|
|
379 |
//***************************************************************************** |
/******************************************************************************/ |
380 |
void WriteString(QFile* File, QString* Line) |
void WriteString(QFile* File, QString* Line) |
381 |
{ |
{ |
382 |
File->writeBlock((const char*)(*Line), Line->length()); |
File->writeBlock((const char*)(*Line), Line->length()); |
383 |
} |
} |
384 |
|
|
385 |
//***************************************************************************** |
/******************************************************************************/ |
386 |
void QMyDialog::SaveClicked() |
void QMyDialog::SaveClicked() |
387 |
{ |
{ |
388 |
int i, j; |
int i, j; |
440 |
} |
} |
441 |
} |
} |
442 |
|
|
443 |
//***************************************************************************** |
/******************************************************************************/ |
444 |
void QMyDialog::RemoveClicked() |
void QMyDialog::RemoveClicked() |
445 |
{ |
{ |
446 |
int i, j, c; |
int i, j, c; |
466 |
} |
} |
467 |
} |
} |
468 |
|
|
469 |
//***************************************************************************** |
/******************************************************************************/ |
470 |
void QMyDialog::ListBoxChanged() |
void QMyDialog::ListBoxChanged() |
471 |
{ |
{ |
472 |
int i; |
int i; |
488 |
} |
} |
489 |
} |
} |
490 |
|
|
491 |
//***************************************************************************** |
/******************************************************************************/ |
492 |
void QMyDialog::ListBoxSelected(int /*index*/) |
void QMyDialog::ListBoxSelected(int /*index*/) |
493 |
{ |
{ |
494 |
} |
} |
495 |
|
|
496 |
//***************************************************************************** |
/******************************************************************************/ |
497 |
void GetScanCode(QKeyEvent * e, int * ScanCode, int * code) |
void GetScanCode(QKeyEvent * e, int * ScanCode, int * code) |
498 |
{ |
{ |
499 |
int key; |
int key; |
661 |
|
|
662 |
} |
} |
663 |
|
|
664 |
//***************************************************************************** |
/******************************************************************************/ |
665 |
QMyScrollView::QMyScrollView() : QScrollView() |
QMyScrollView::QMyScrollView() : QScrollView() |
666 |
{ |
{ |
667 |
} |
} |
668 |
|
|
669 |
//***************************************************************************** |
/******************************************************************************/ |
670 |
QMyScrollView::~QMyScrollView() |
QMyScrollView::~QMyScrollView() |
671 |
{ |
{ |
672 |
} |
} |
673 |
|
|
674 |
//***************************************************************************** |
/******************************************************************************/ |
675 |
void QMyScrollView::keyPressEvent(QKeyEvent* e) |
void QMyScrollView::keyPressEvent(QKeyEvent* e) |
676 |
{ |
{ |
677 |
int ScanCode, code; |
int ScanCode, code; |
689 |
} |
} |
690 |
} |
} |
691 |
|
|
692 |
//***************************************************************************** |
/******************************************************************************/ |
693 |
void QMyScrollView::keyReleaseEvent(QKeyEvent* e) |
void QMyScrollView::keyReleaseEvent(QKeyEvent* e) |
694 |
{ |
{ |
695 |
int ScanCode, code; |
int ScanCode, code; |
707 |
} |
} |
708 |
} |
} |
709 |
|
|
710 |
//***************************************************************************** |
/******************************************************************************/ |
711 |
void QMyScrollView::showEvent(QShowEvent* e) |
void QMyScrollView::showEvent(QShowEvent* e) |
712 |
{ |
{ |
713 |
QScrollView::showEvent(e); |
QScrollView::showEvent(e); |
714 |
} |
} |
715 |
|
|
716 |
//***************************************************************************** |
/******************************************************************************/ |
717 |
void QMyScrollView::show() |
void QMyScrollView::show() |
718 |
{ |
{ |
719 |
QScrollView::show(); |
QScrollView::show(); |
720 |
} |
} |
721 |
|
|
722 |
//***************************************************************************** |
/******************************************************************************/ |
723 |
void QMyScrollView::polish() |
void QMyScrollView::polish() |
724 |
{ |
{ |
725 |
QScrollView::polish(); |
QScrollView::polish(); |
726 |
} |
} |
727 |
|
|
728 |
//***************************************************************************** |
/******************************************************************************/ |
729 |
void QMyScrollView::timerEvent(QTimerEvent * e) |
void QMyScrollView::timerEvent(QTimerEvent * e) |
730 |
{ |
{ |
731 |
QScrollView::timerEvent(e); |
QScrollView::timerEvent(e); |
787 |
} |
} |
788 |
} |
} |
789 |
|
|
790 |
//***************************************************************************** |
/******************************************************************************/ |
791 |
QMyMainWindow::QMyMainWindow() : QWidget(g_SV->viewport()) |
QMyMainWindow::QMyMainWindow() : QWidget(g_SV->viewport()) |
792 |
{ |
{ |
793 |
PopupMenu = new QPopupMenu(this); |
PopupMenu = new QPopupMenu(this); |
798 |
connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); |
connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); |
799 |
} |
} |
800 |
|
|
801 |
//***************************************************************************** |
/******************************************************************************/ |
802 |
QMyMainWindow::~QMyMainWindow() |
QMyMainWindow::~QMyMainWindow() |
803 |
{ |
{ |
804 |
delete PopupMenu; |
delete PopupMenu; |
805 |
} |
} |
806 |
|
|
807 |
//***************************************************************************** |
/******************************************************************************/ |
808 |
void QMyMainWindow::timerEvent(QTimerEvent * e) |
void QMyMainWindow::timerEvent(QTimerEvent * e) |
809 |
{ |
{ |
810 |
QWidget::timerEvent(e); |
QWidget::timerEvent(e); |
825 |
killTimer(timer_id); |
killTimer(timer_id); |
826 |
} |
} |
827 |
|
|
828 |
//***************************************************************************** |
/******************************************************************************/ |
829 |
void QMyMainWindow::MemuClicked(int MenuID) |
void QMyMainWindow::MemuClicked(int MenuID) |
830 |
{ |
{ |
831 |
QWidget * Desktop; |
QWidget * Desktop; |
871 |
} |
} |
872 |
} |
} |
873 |
|
|
874 |
//***************************************************************************** |
/******************************************************************************/ |
875 |
void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) |
void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) |
876 |
{ |
{ |
877 |
int x; |
int x; |
893 |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y()); |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y()); |
894 |
} |
} |
895 |
|
|
896 |
//***************************************************************************** |
/******************************************************************************/ |
897 |
void QMyMainWindow::mousePressEvent(QMouseEvent* e) |
void QMyMainWindow::mousePressEvent(QMouseEvent* e) |
898 |
{ |
{ |
899 |
timer_id = startTimer(1000); |
timer_id = startTimer(1000); |
907 |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y()); |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y()); |
908 |
} |
} |
909 |
|
|
910 |
//***************************************************************************** |
/******************************************************************************/ |
911 |
void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) |
void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) |
912 |
{ |
{ |
913 |
killTimer(timer_id); |
killTimer(timer_id); |
920 |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y()); |
rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y()); |
921 |
} |
} |
922 |
|
|
923 |
//***************************************************************************** |
/******************************************************************************/ |
924 |
void QMyMainWindow::wheelEvent(QWheelEvent* e) |
void QMyMainWindow::wheelEvent(QWheelEvent* e) |
925 |
{ |
{ |
926 |
if (e->delta() > 0) |
if (e->delta() > 0) |
931 |
|
|
932 |
#define NOT(x) (~x) |
#define NOT(x) (~x) |
933 |
|
|
934 |
//***************************************************************************** |
/******************************************************************************/ |
935 |
int rop(int rop, int src, int dst) |
int rop(int rop, int src, int dst) |
936 |
{ |
{ |
937 |
switch (rop) |
switch (rop) |
965 |
return g_BS[y * g_width + x]; |
return g_BS[y * g_width + x]; |
966 |
else if (g_server_bpp == 16) |
else if (g_server_bpp == 16) |
967 |
return *(((uint16*)g_BS) + (y * g_width + x)); |
return *(((uint16*)g_BS) + (y * g_width + x)); |
968 |
|
else if (g_server_bpp == 24) |
969 |
|
return *(((uint32*)g_BS) + (y * g_width + x)); |
970 |
else |
else |
971 |
return 0; |
return 0; |
972 |
} |
} |
974 |
return 0; |
return 0; |
975 |
} |
} |
976 |
|
|
977 |
//***************************************************************************** |
/******************************************************************************/ |
978 |
void set_pixel(int x, int y, int pixel, int op = 0xc) |
void set_pixel(int x, int y, int pixel, int op = 0xc) |
979 |
{ |
{ |
980 |
uint32 p; |
uint32 p; |
994 |
{ |
{ |
995 |
SETPIXEL16(g_BS, x, y, g_width, pixel); |
SETPIXEL16(g_BS, x, y, g_width, pixel); |
996 |
} |
} |
997 |
|
else if (g_server_bpp == 24) |
998 |
|
{ |
999 |
|
SETPIXEL32(g_BS, x, y, g_width, pixel); |
1000 |
|
} |
1001 |
} |
} |
1002 |
else |
else |
1003 |
{ |
{ |
1013 |
p = rop(op, pixel, p); |
p = rop(op, pixel, p); |
1014 |
SETPIXEL16(g_BS, x, y, g_width, p); |
SETPIXEL16(g_BS, x, y, g_width, p); |
1015 |
} |
} |
1016 |
|
else if (g_server_bpp == 24) |
1017 |
|
{ |
1018 |
|
p = GETPIXEL32(g_BS, x, y, g_width); |
1019 |
|
p = rop(op, pixel, p); |
1020 |
|
SETPIXEL32(g_BS, x, y, g_width, p); |
1021 |
|
} |
1022 |
} |
} |
1023 |
} |
} |
1024 |
} |
} |
1025 |
} |
} |
1026 |
|
|
1027 |
//****************************************************************************** |
/******************************************************************************/ |
1028 |
// adjust coordinates for cliping rect |
// adjust coordinates for cliping rect |
1029 |
bool WarpCoords(int * x, int * y, int * cx, int * cy, int * srcx, int * srcy) |
bool WarpCoords(int * x, int * y, int * cx, int * cy, int * srcx, int * srcy) |
1030 |
{ |
{ |
1048 |
return true; |
return true; |
1049 |
} |
} |
1050 |
|
|
1051 |
//***************************************************************************** |
/******************************************************************************/ |
1052 |
uint32 color16to32(uint32 colour) |
uint32 color16to32(uint32 colour) |
1053 |
{ |
{ |
1054 |
uint32 r, g, b; |
uint32 r, g, b; |
1058 |
return ((r << 16) | (g << 8) | b); |
return ((r << 16) | (g << 8) | b); |
1059 |
} |
} |
1060 |
|
|
1061 |
//***************************************************************************** |
/******************************************************************************/ |
1062 |
|
uint32 color24to32(uint32 colour) |
1063 |
|
{ |
1064 |
|
uint32 r, g, b; |
1065 |
|
r = (colour >> 0) & 0xff; |
1066 |
|
g = (colour >> 8) & 0xff; |
1067 |
|
b = (colour >> 16) & 0xff; |
1068 |
|
return ((r << 16) | (g << 8) | b); |
1069 |
|
} |
1070 |
|
|
1071 |
|
/******************************************************************************/ |
1072 |
void QMyMainWindow::paintEvent(QPaintEvent * pe) |
void QMyMainWindow::paintEvent(QPaintEvent * pe) |
1073 |
{ |
{ |
1074 |
QImage * Image; |
QImage * Image; |
1075 |
QPainter * Painter; |
QPainter * Painter; |
1076 |
QRect Rect; |
QRect Rect; |
1077 |
int i, j, w, h, l, t; |
int i, j, w, h, l, t; |
1078 |
|
int pixel; |
1079 |
uint8 * data; |
uint8 * data; |
1080 |
|
|
1081 |
Image = 0; |
Image = 0; |
1107 |
data = (uint8*)xmalloc(w * h * 4); |
data = (uint8*)xmalloc(w * h * 4); |
1108 |
for (i = 0; i < h; i++) |
for (i = 0; i < h; i++) |
1109 |
for (j = 0; j < w; j++) |
for (j = 0; j < w; j++) |
1110 |
*(((uint32*)data) + (i * w + j)) = color16to32(get_pixel(l + j, t + i)); |
{ |
1111 |
|
pixel = GETPIXEL16(g_BS, l + j, t + i, g_width); |
1112 |
|
pixel = color16to32(pixel); |
1113 |
|
SETPIXEL32(data, j, i, w, pixel); |
1114 |
|
} |
1115 |
|
Image = new QImage(data, w, h, 32, NULL, |
1116 |
|
0, QImage::IgnoreEndian); |
1117 |
|
} |
1118 |
|
else if (g_server_bpp == 24) |
1119 |
|
{ |
1120 |
|
w = (w + 3) & ~3; |
1121 |
|
data = (uint8*)xmalloc(w * h * 4); |
1122 |
|
for (i = 0; i < h; i++) |
1123 |
|
for (j = 0; j < w; j++) |
1124 |
|
{ |
1125 |
|
pixel = GETPIXEL32(g_BS, l + j, t + i, g_width); |
1126 |
|
pixel = color24to32(pixel); |
1127 |
|
SETPIXEL32(data, j, i, w, pixel); |
1128 |
|
} |
1129 |
Image = new QImage(data, w, h, 32, NULL, |
Image = new QImage(data, w, h, 32, NULL, |
1130 |
0, QImage::IgnoreEndian); |
0, QImage::IgnoreEndian); |
1131 |
} |
} |
1141 |
} |
} |
1142 |
} |
} |
1143 |
|
|
1144 |
//***************************************************************************** |
/******************************************************************************/ |
1145 |
void QMyMainWindow::closeEvent(QCloseEvent * e) |
void QMyMainWindow::closeEvent(QCloseEvent * e) |
1146 |
{ |
{ |
1147 |
e->accept(); |
e->accept(); |
1148 |
} |
} |
1149 |
|
|
1150 |
//***************************************************************************** |
/******************************************************************************/ |
1151 |
void QMyMainWindow::dataReceived() |
void QMyMainWindow::dataReceived() |
1152 |
{ |
{ |
1153 |
if (!rdp_loop(&g_deactivated, &g_ext_disc_reason)) |
if (!rdp_loop(&g_deactivated, &g_ext_disc_reason)) |
1171 |
#endif |
#endif |
1172 |
} |
} |
1173 |
|
|
1174 |
//***************************************************************************** |
/******************************************************************************/ |
1175 |
void QMyMainWindow::soundSend() |
void QMyMainWindow::soundSend() |
1176 |
{ |
{ |
1177 |
g_SoundNotifier->setEnabled(false); |
g_SoundNotifier->setEnabled(false); |
1182 |
#endif |
#endif |
1183 |
} |
} |
1184 |
|
|
1185 |
//***************************************************************************** |
/******************************************************************************/ |
1186 |
void redraw(int x, int y, int cx, int cy) |
void redraw(int x, int y, int cx, int cy) |
1187 |
{ |
{ |
1188 |
if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL)) |
if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL)) |
1191 |
} |
} |
1192 |
} |
} |
1193 |
|
|
1194 |
//***************************************************************************** |
/******************************************************************************/ |
1195 |
/* Returns 0 after user quit, 1 otherwise */ |
/* Returns 0 after user quit, 1 otherwise */ |
1196 |
int ui_select(int rdp_socket) |
int ui_select(int rdp_socket) |
1197 |
{ |
{ |
1200 |
return 1; |
return 1; |
1201 |
} |
} |
1202 |
|
|
1203 |
//***************************************************************************** |
/******************************************************************************/ |
1204 |
void ui_move_pointer(int /*x*/, int /*y*/) |
void ui_move_pointer(int /*x*/, int /*y*/) |
1205 |
{ |
{ |
1206 |
} |
} |
1207 |
|
|
1208 |
/*****************************************************************************/ |
/******************************************************************************/ |
1209 |
void ui_set_null_cursor(void) |
void ui_set_null_cursor(void) |
1210 |
{ |
{ |
1211 |
} |
} |
1212 |
|
|
1213 |
//***************************************************************************** |
/******************************************************************************/ |
1214 |
HBITMAP ui_create_bitmap(int width, int height, uint8 * data) |
HBITMAP ui_create_bitmap(int width, int height, uint8 * data) |
1215 |
{ |
{ |
1216 |
struct bitmap * the_bitmap; |
struct bitmap * the_bitmap; |
1217 |
uint8 * bitmap_data; |
uint8 * bitmap_data; |
1218 |
int i, j; |
int i, j; |
1219 |
|
int r, g, b, pixel; |
1220 |
|
|
1221 |
bitmap_data = (uint8*)xmalloc(width * height * BPP); |
bitmap_data = (uint8*)xmalloc(width * height * 4); |
1222 |
the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap)); |
the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap)); |
1223 |
the_bitmap->w = width; |
the_bitmap->w = width; |
1224 |
the_bitmap->h = height; |
the_bitmap->h = height; |
1233 |
{ |
{ |
1234 |
for (i = 0; i < height; i++) |
for (i = 0; i < height; i++) |
1235 |
for (j = 0; j < width; j++) |
for (j = 0; j < width; j++) |
1236 |
*(((uint16*)bitmap_data) + (i * width + j)) = *(((uint16*)data) + (i * width + j)); |
*(((uint16*)bitmap_data) + (i * width + j)) = |
1237 |
|
*(((uint16*)data) + (i * width + j)); |
1238 |
|
} |
1239 |
|
else if (g_server_bpp == 24) |
1240 |
|
{ |
1241 |
|
for (i = 0; i < height; i++) |
1242 |
|
for (j = 0; j < width; j++) |
1243 |
|
{ |
1244 |
|
r = data[(i * width + j) * 3 + 0]; |
1245 |
|
g = data[(i * width + j) * 3 + 1]; |
1246 |
|
b = data[(i * width + j) * 3 + 2]; |
1247 |
|
pixel = (r << 16) | (g << 8) | b; |
1248 |
|
SETPIXEL32(bitmap_data, j, i, width, pixel); |
1249 |
|
} |
1250 |
} |
} |
1251 |
return the_bitmap; |
return the_bitmap; |
1252 |
} |
} |
1253 |
|
|
1254 |
//***************************************************************************** |
/******************************************************************************/ |
1255 |
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, |
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, |
1256 |
int height, uint8 * data) |
int height, uint8 * data) |
1257 |
{ |
{ |
1258 |
int i, j; |
int i, j; |
1259 |
|
int r, g, b, pixel; |
1260 |
|
|
1261 |
if (g_server_bpp == 8) |
if (g_server_bpp == 8) |
1262 |
{ |
{ |
1274 |
if (j < width) |
if (j < width) |
1275 |
set_pixel(x + j, y + i, *(((uint16*)data) + (i * width + j))); |
set_pixel(x + j, y + i, *(((uint16*)data) + (i * width + j))); |
1276 |
} |
} |
1277 |
|
else if (g_server_bpp == 24) |
1278 |
|
{ |
1279 |
|
for (i = 0; i < cy; i++) |
1280 |
|
for (j = 0; j < cx; j++) |
1281 |
|
if (i < height) |
1282 |
|
if (j < width) |
1283 |
|
{ |
1284 |
|
r = data[(i * width + j) * 3 + 0]; |
1285 |
|
g = data[(i * width + j) * 3 + 1]; |
1286 |
|
b = data[(i * width + j) * 3 + 2]; |
1287 |
|
pixel = (r << 16) | (g << 8) | b; |
1288 |
|
set_pixel(x + j, y + i, pixel); |
1289 |
|
} |
1290 |
|
} |
1291 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1292 |
} |
} |
1293 |
|
|
1294 |
//***************************************************************************** |
/******************************************************************************/ |
1295 |
void ui_destroy_bitmap(HBITMAP bmp) |
void ui_destroy_bitmap(HBITMAP bmp) |
1296 |
{ |
{ |
1297 |
struct bitmap* the_bitmap; |
struct bitmap* the_bitmap; |
1305 |
} |
} |
1306 |
} |
} |
1307 |
|
|
1308 |
//***************************************************************************** |
/******************************************************************************/ |
1309 |
bool is_pixel_on(uint8* data, int x, int y, int width, int bpp) |
bool is_pixel_on(uint8 * data, int x, int y, int width, int bpp) |
1310 |
{ |
{ |
1311 |
int start, shift; |
int start, shift; |
1312 |
|
|
1323 |
return false; |
return false; |
1324 |
} |
} |
1325 |
|
|
1326 |
//***************************************************************************** |
/******************************************************************************/ |
1327 |
void set_pixel_on(uint8* data, int x, int y, int width, int bpp, uint8 pixel) |
void set_pixel_on(uint8 * data, int x, int y, int width, int bpp, uint8 pixel) |
1328 |
{ |
{ |
1329 |
if (bpp == 8) |
if (bpp == 8) |
1330 |
data[y * width + x] = pixel; |
data[y * width + x] = pixel; |
1331 |
} |
} |
1332 |
|
|
1333 |
//***************************************************************************** |
/******************************************************************************/ |
1334 |
HGLYPH ui_create_glyph(int width, int height, uint8 * data) |
HGLYPH ui_create_glyph(int width, int height, uint8 * data) |
1335 |
{ |
{ |
1336 |
int i, j; |
int i, j; |
1350 |
return the_glyph; |
return the_glyph; |
1351 |
} |
} |
1352 |
|
|
1353 |
//***************************************************************************** |
/******************************************************************************/ |
1354 |
void ui_destroy_glyph(HGLYPH glyph) |
void ui_destroy_glyph(HGLYPH glyph) |
1355 |
{ |
{ |
1356 |
struct bitmap* the_glyph; |
struct bitmap* the_glyph; |
1364 |
} |
} |
1365 |
} |
} |
1366 |
|
|
1367 |
//***************************************************************************** |
/******************************************************************************/ |
1368 |
HCURSOR ui_create_cursor(uint32 x, uint32 y, |
HCURSOR ui_create_cursor(uint32 x, uint32 y, |
1369 |
int width, int height, |
int width, int height, |
1370 |
uint8 * andmask, uint8 * xormask) |
uint8 * andmask, uint8 * xormask) |
1372 |
return (void*)1; |
return (void*)1; |
1373 |
} |
} |
1374 |
|
|
1375 |
//***************************************************************************** |
/******************************************************************************/ |
1376 |
void ui_set_cursor(HCURSOR /*cursor*/) |
void ui_set_cursor(HCURSOR /*cursor*/) |
1377 |
{ |
{ |
1378 |
} |
} |
1393 |
void ui_resize_window(void) |
void ui_resize_window(void) |
1394 |
{ |
{ |
1395 |
} |
} |
1396 |
//***************************************************************************** |
|
1397 |
|
/******************************************************************************/ |
1398 |
void ui_destroy_cursor(HCURSOR /*cursor*/) |
void ui_destroy_cursor(HCURSOR /*cursor*/) |
1399 |
{ |
{ |
1400 |
} |
} |
1401 |
|
|
1402 |
//***************************************************************************** |
/******************************************************************************/ |
1403 |
HCOLOURMAP ui_create_colourmap(COLOURMAP * colours) |
HCOLOURMAP ui_create_colourmap(COLOURMAP * colours) |
1404 |
{ |
{ |
1405 |
int i; |
int i; |
1419 |
return g_CM; |
return g_CM; |
1420 |
} |
} |
1421 |
|
|
1422 |
//***************************************************************************** |
/******************************************************************************/ |
1423 |
void ui_set_colourmap(HCOLOURMAP map) |
void ui_set_colourmap(HCOLOURMAP map) |
1424 |
{ |
{ |
1425 |
} |
} |
1426 |
|
|
1427 |
//***************************************************************************** |
/******************************************************************************/ |
1428 |
void ui_destroy_colourmap(HCOLOURMAP map) |
void ui_destroy_colourmap(HCOLOURMAP map) |
1429 |
{ |
{ |
1430 |
} |
} |
1431 |
|
|
1432 |
//***************************************************************************** |
/******************************************************************************/ |
1433 |
void ui_begin_update(void) |
void ui_begin_update(void) |
1434 |
{ |
{ |
1435 |
} |
} |
1436 |
|
|
1437 |
//***************************************************************************** |
/******************************************************************************/ |
1438 |
void ui_end_update(void) |
void ui_end_update(void) |
1439 |
{ |
{ |
1440 |
} |
} |
1441 |
|
|
1442 |
//***************************************************************************** |
/******************************************************************************/ |
1443 |
void ui_set_clip(int x, int y, int cx, int cy) |
void ui_set_clip(int x, int y, int cx, int cy) |
1444 |
{ |
{ |
1445 |
g_clipx = x; |
g_clipx = x; |
1448 |
g_clipcy = cy; |
g_clipcy = cy; |
1449 |
} |
} |
1450 |
|
|
1451 |
//***************************************************************************** |
/******************************************************************************/ |
1452 |
void ui_reset_clip(void) |
void ui_reset_clip(void) |
1453 |
{ |
{ |
1454 |
g_clipx = 0; |
g_clipx = 0; |
1457 |
g_clipcy = g_height; |
g_clipcy = g_height; |
1458 |
} |
} |
1459 |
|
|
1460 |
//***************************************************************************** |
/******************************************************************************/ |
1461 |
void ui_bell(void) |
void ui_bell(void) |
1462 |
{ |
{ |
1463 |
g_App->beep(); |
g_App->beep(); |
1464 |
} |
} |
1465 |
|
|
1466 |
//***************************************************************************** |
/******************************************************************************/ |
1467 |
void ui_destblt(uint8 opcode, int x, int y, int cx, int cy) |
void ui_destblt(uint8 opcode, int x, int y, int cx, int cy) |
1468 |
{ |
{ |
1469 |
int i, j; |
int i, j; |
1474 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1475 |
} |
} |
1476 |
|
|
1477 |
//***************************************************************************** |
/******************************************************************************/ |
1478 |
// does not repaint |
// does not repaint |
1479 |
void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc) |
void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc) |
1480 |
{ |
{ |
1489 |
set_pixel(x + j, y + i, colour, opcode); |
set_pixel(x + j, y + i, colour, opcode); |
1490 |
} |
} |
1491 |
|
|
1492 |
//***************************************************************************** |
/******************************************************************************/ |
1493 |
void ui_rect(int x, int y, int cx, int cy, int colour) |
void ui_rect(int x, int y, int cx, int cy, int colour) |
1494 |
{ |
{ |
1495 |
fill_rect(x, y, cx, cy, colour); |
fill_rect(x, y, cx, cy, colour); |
1496 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1497 |
} |
} |
1498 |
|
|
1499 |
//***************************************************************************** |
/******************************************************************************/ |
1500 |
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, |
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, |
1501 |
BRUSH * brush, int bgcolour, int fgcolour) |
BRUSH * brush, int bgcolour, int fgcolour) |
1502 |
{ |
{ |
1523 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1524 |
} |
} |
1525 |
|
|
1526 |
//***************************************************************************** |
/******************************************************************************/ |
1527 |
void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, |
void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, |
1528 |
int srcx, int srcy) |
int srcx, int srcy) |
1529 |
{ |
{ |
1530 |
int i, j; |
int i, j; |
1531 |
uint8* temp; |
uint8 * temp; |
1532 |
|
|
1533 |
temp = (uint8*)xmalloc(cx * cy * BPP); |
temp = (uint8*)xmalloc(cx * cy * (BPP + 1)); |
1534 |
if (g_server_bpp == 8) |
if (g_server_bpp == 8) |
1535 |
{ |
{ |
1536 |
for (i = 0; i < cy; i++) |
for (i = 0; i < cy; i++) |
1549 |
for (j = 0; j < cx; j++) |
for (j = 0; j < cx; j++) |
1550 |
set_pixel(x + j, y + i, *(((uint16*)temp) + (i * cx + j)), opcode); |
set_pixel(x + j, y + i, *(((uint16*)temp) + (i * cx + j)), opcode); |
1551 |
} |
} |
1552 |
|
else if (g_server_bpp == 24) |
1553 |
|
{ |
1554 |
|
for (i = 0; i < cy; i++) |
1555 |
|
for (j = 0; j < cx; j++) |
1556 |
|
*(((uint32*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i); |
1557 |
|
for (i = 0; i < cy; i++) |
1558 |
|
for (j = 0; j < cx; j++) |
1559 |
|
set_pixel(x + j, y + i, *(((uint32*)temp) + (i * cx + j)), opcode); |
1560 |
|
} |
1561 |
xfree(temp); |
xfree(temp); |
1562 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1563 |
} |
} |
1564 |
|
|
1565 |
//***************************************************************************** |
/******************************************************************************/ |
1566 |
void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, |
void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, |
1567 |
HBITMAP src, int srcx, int srcy) |
HBITMAP src, int srcx, int srcy) |
1568 |
{ |
{ |
1569 |
int i, j; |
int i, j; |
1570 |
struct bitmap* the_bitmap; |
struct bitmap * the_bitmap; |
1571 |
|
|
1572 |
the_bitmap = (struct bitmap*)src; |
the_bitmap = (struct bitmap*)src; |
1573 |
if (the_bitmap == NULL) |
if (the_bitmap == NULL) |
1590 |
*(((uint16*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))), |
*(((uint16*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))), |
1591 |
opcode); |
opcode); |
1592 |
} |
} |
1593 |
|
else if (g_server_bpp == 24) |
1594 |
|
{ |
1595 |
|
for (i = 0; i < cy; i++) |
1596 |
|
for (j = 0; j < cx; j++) |
1597 |
|
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) |
1598 |
|
set_pixel(x + j, y + i, |
1599 |
|
*(((uint32*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))), |
1600 |
|
opcode); |
1601 |
|
} |
1602 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1603 |
} |
} |
1604 |
|
|
1605 |
//***************************************************************************** |
/******************************************************************************/ |
1606 |
// not used |
// not used |
1607 |
void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, |
void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, |
1608 |
HBITMAP src, int srcx, int srcy, BRUSH * brush, |
HBITMAP src, int srcx, int srcy, BRUSH * brush, |
1610 |
{ |
{ |
1611 |
} |
} |
1612 |
|
|
1613 |
//***************************************************************************** |
/******************************************************************************/ |
1614 |
// Bresenham's line drawing algorithm |
/* Bresenham's line drawing algorithm */ |
1615 |
void ui_line(uint8 opcode, int startx, int starty, int endx, |
void ui_line(uint8 opcode, int startx, int starty, int endx, |
1616 |
int endy, PEN * pen) |
int endy, PEN * pen) |
1617 |
{ |
{ |
1690 |
redraw(left, top, (right - left) + 1, (bottom - top) + 1); |
redraw(left, top, (right - left) + 1, (bottom - top) + 1); |
1691 |
} |
} |
1692 |
|
|
1693 |
//***************************************************************************** |
/******************************************************************************/ |
1694 |
void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) |
void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) |
1695 |
{ |
{ |
1696 |
struct bitmap *the_glyph; |
struct bitmap *the_glyph; |
1735 |
}\ |
}\ |
1736 |
} |
} |
1737 |
|
|
1738 |
//***************************************************************************** |
/******************************************************************************/ |
1739 |
void ui_draw_text(uint8 font, uint8 flags, int mixmode, |
void ui_draw_text(uint8 font, uint8 flags, int mixmode, |
1740 |
int x, int y, int clipx, int clipy, |
int x, int y, int clipx, int clipy, |
1741 |
int clipcx, int clipcy, int boxx, |
int clipcx, int clipcy, int boxx, |
1806 |
redraw(clipx, clipy, clipcx, clipcy); |
redraw(clipx, clipy, clipcx, clipcy); |
1807 |
} |
} |
1808 |
|
|
1809 |
//***************************************************************************** |
/******************************************************************************/ |
1810 |
void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) |
void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) |
1811 |
{ |
{ |
1812 |
uint8* data; |
uint8 * data; |
1813 |
int i, j; |
int i, j; |
1814 |
|
int Bpp; |
1815 |
|
|
1816 |
data = (uint8*)xmalloc(cx * cy * BPP); |
Bpp = 4; |
1817 |
|
switch (g_server_bpp) |
1818 |
|
{ |
1819 |
|
case 8: Bpp = 1; break; |
1820 |
|
case 15: Bpp = 2; break; |
1821 |
|
case 16: Bpp = 2; break; |
1822 |
|
} |
1823 |
|
data = (uint8*)xmalloc(cx * cy * Bpp); |
1824 |
if (g_server_bpp == 8) |
if (g_server_bpp == 8) |
1825 |
{ |
{ |
1826 |
for (i = 0; i < cy; i++) |
for (i = 0; i < cy; i++) |
1833 |
for (j = 0; j < cx; j++) |
for (j = 0; j < cx; j++) |
1834 |
*(((uint16*)data) + (i * cx + j)) = get_pixel(x + j, y + i); |
*(((uint16*)data) + (i * cx + j)) = get_pixel(x + j, y + i); |
1835 |
} |
} |
1836 |
offset *= BPP; |
else if (g_server_bpp == 24) |
1837 |
cache_put_desktop(offset, cx, cy, cx * BPP, BPP, data); |
{ |
1838 |
|
for (i = 0; i < cy; i++) |
1839 |
|
for (j = 0; j < cx; j++) |
1840 |
|
*(((uint32*)data) + (i * cx + j)) = get_pixel(x + j, y + i); |
1841 |
|
} |
1842 |
|
offset *= Bpp; |
1843 |
|
cache_put_desktop(offset, cx, cy, cx * Bpp, Bpp, data); |
1844 |
xfree(data); |
xfree(data); |
1845 |
} |
} |
1846 |
|
|
1847 |
//***************************************************************************** |
/******************************************************************************/ |
1848 |
void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) |
void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) |
1849 |
{ |
{ |
1850 |
uint8* data; |
uint8* data; |
1851 |
int i, j; |
int i, j; |
1852 |
|
int Bpp; |
1853 |
|
|
1854 |
offset *= BPP; |
Bpp = 4; |
1855 |
data = cache_get_desktop(offset, cx, cy, BPP); |
switch (g_server_bpp) |
1856 |
|
{ |
1857 |
|
case 8: Bpp = 1; break; |
1858 |
|
case 15: Bpp = 2; break; |
1859 |
|
case 16: Bpp = 2; break; |
1860 |
|
} |
1861 |
|
offset *= Bpp; |
1862 |
|
data = cache_get_desktop(offset, cx, cy, Bpp); |
1863 |
if (g_server_bpp == 8) |
if (g_server_bpp == 8) |
1864 |
{ |
{ |
1865 |
for (i = 0; i < cy; i++) |
for (i = 0; i < cy; i++) |
1872 |
for (j = 0; j < cx; j++) |
for (j = 0; j < cx; j++) |
1873 |
set_pixel(x + j, y + i, *(((uint16*)data) + (i * cx + j))); |
set_pixel(x + j, y + i, *(((uint16*)data) + (i * cx + j))); |
1874 |
} |
} |
1875 |
|
else if (g_server_bpp == 24) |
1876 |
|
{ |
1877 |
|
for (i = 0; i < cy; i++) |
1878 |
|
for (j = 0; j < cx; j++) |
1879 |
|
set_pixel(x + j, y + i, *(((uint32*)data) + (i * cx + j))); |
1880 |
|
} |
1881 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1882 |
} |
} |
1883 |
|
|
2152 |
return 1; |
return 1; |
2153 |
} |
} |
2154 |
|
|
2155 |
//***************************************************************************** |
/******************************************************************************/ |
2156 |
int param_connect(void) |
int param_connect(void) |
2157 |
{ |
{ |
2158 |
QWidget * Desktop; |
QWidget * Desktop; |
2192 |
g_MW->resize(g_width - 4, g_height - 4); |
g_MW->resize(g_width - 4, g_height - 4); |
2193 |
g_SV->showFullScreen(); |
g_SV->showFullScreen(); |
2194 |
} |
} |
2195 |
g_MW->setCursor(BlankCursor); |
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
2196 |
g_App->exec(); |
g_App->exec(); |
2197 |
} |
} |
2198 |
return 0; |
return 0; |
2199 |
} |
} |
2200 |
|
|
2201 |
//***************************************************************************** |
/******************************************************************************/ |
2202 |
int main(int argc, char ** argv) |
int main(int argc, char ** argv) |
2203 |
{ |
{ |
2204 |
#ifdef SHARP |
#ifdef SHARP |
2218 |
else |
else |
2219 |
{ |
{ |
2220 |
g_SV->timer_id = g_SV->startTimer(1000); /* one sec delay, then dialog */ |
g_SV->timer_id = g_SV->startTimer(1000); /* one sec delay, then dialog */ |
2221 |
g_MW->setCursor(BlankCursor); |
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
2222 |
g_App->exec(); |
g_App->exec(); |
2223 |
} |
} |
2224 |
delete g_SV; |
delete g_SV; |