blob: 2c036db01d3cd400b42f309c580d6e01298eab1e [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2004 TightVNC Team. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// -=- SessionInfoDialog.h
20
21#include <math.h>
22
23#include <rfb/ConnParams.h>
24
25#include <rfb_win32/Dialog.h>
26
27#define log2(n) log(n) / 0.693147180559945
28
29int max3(int v1, int v2, int v3) {
30 return max(v1, max(v2, v3));
31}
32
33class SessionInfoDialog : public rfb::win32::Dialog {
34public:
35 SessionInfoDialog(ConnParams *_cp, int _currentEncoding)
36 : Dialog(GetModuleHandle(0)), cp(_cp), currentEncoding(_currentEncoding) {}
37 // - Show the dialog and return true if OK was clicked,
38 // false in case of error or Cancel
39 virtual bool showDialog(HWND parent = 0) {
40 return Dialog::showDialog(MAKEINTRESOURCE(IDD_SESSION_INFO), parent);
41 }
42protected:
43 // Dialog methods (protected)
44 virtual void initDialog() {
45 char strValue[255] = "\0";
46 setItemString(IDC_DESKTOP_NAME, cp->name());
47
48 sprintf(strValue, "%ix%i", cp->width, cp->height);
49 setItemString(IDC_DESKTOP_SIZE, strValue);
50
51 int r = cp->pf().redShift, g = cp->pf().greenShift, b = cp->pf().blueShift;
52 int i = 3;
53 char buffer[10];
54 sprintf(strValue, "depth %i(%ibpp), ", cp->pf().depth, cp->pf().bpp);
55 while (i) {
56 if (r == max3(r, g, b)) {
57 strcat(strValue, "r");
58 _itoa(ceil(log2(cp->pf().redMax)), buffer, 10);
59 strcat(strValue, buffer);
60 r = -1;
61 i--;
62 continue;
63 } else if (g == max3(r, g, b)) {
64 strcat(strValue, "g");
65 _itoa(ceil(log2(cp->pf().greenMax)), buffer, 10);
66 strcat(strValue, buffer);
67 g = -1;
68 i--;
69 continue;
70 } else if (b == max3(r, g, b)) {
71 strcat(strValue, "b");
72 _itoa(ceil(log2(cp->pf().blueMax)), buffer, 10);
73 strcat(strValue, buffer);
74 b = -1;
75 i--;
76 continue;
77 } else break;
78 }
79 if (cp->pf().bigEndian) strcat(strValue, ", big-endian");
80 else strcat(strValue, ", little-endian");
81 setItemString(IDC_PIXEL_FORMAT, strValue);
82
83 switch (currentEncoding) {
84 case encodingRaw: strcpy(strValue, "Raw"); break;
85 case encodingCopyRect: strcpy(strValue, "CopyRect"); break;
86 case encodingRRE: strcpy(strValue, "RRE"); break;
87 case encodingCoRRE: strcpy(strValue, "CoRRE"); break;
88 case encodingHextile: strcpy(strValue, "Hextile"); break;
89 case encodingTight: strcpy(strValue, "Tight"); break;
90 case encodingZRLE: strcpy(strValue, "ZRLE"); break;
91 default: strcpy(strValue, "Unknown");
92 }
93 setItemString(IDC_CURRENT_ENCODING, strValue);
94
95 sprintf(strValue, "%i.%i", cp->majorVersion, cp->minorVersion);
96 setItemString(IDC_VERSION, strValue);
97 }
98 ConnParams *cp;
99 int currentEncoding;
100};