blob: cd7c50aa66db3610f989890b9cab22c0b03450fe [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// -=- PixelFormatList.h
20
21// Definition of the PixelFormatList class, responsible for
22// controlling the list of supported pixel formats.
23
24#include <list>
25
26#include <rfb/Exception.h>
27#include <rfb/PixelFormat.h>
28
29#include <rfb_win32/registry.h>
30
31// Definition indexes of the default pixel formats
32#define PF_BGR233 0
33#define PF_RGB555 1
34#define PF_BGR555 2
35#define PF_RGB565 3
36#define PF_BGR565 4
37#define PF_RGB888 5
38#define PF_BGR888 6
39
40using namespace rfb;
41using namespace std;
42
43// PixelFormatListElement class, it is
44// an item of the PixelFormatList list.
45
46class PixelFormatListElement {
47public:
48 PixelFormatListElement() {
49 format_name[0] = 0;
50 }
51 char format_name[256];
52 PixelFormat PF;
53 void setName(const char *name) {
54 format_name[0] = '\0';
55 strcpy(format_name, name);
56 format_name[strlen(name)] = '\0';
57 }
58 void setPF(PixelFormat *_PF) {
59 memcpy(&PF, _PF, sizeof(PixelFormat));
60 }
61};
62
63class PixelFormatList {
64public:
65 PixelFormatList();
66
67 PixelFormatListElement* operator[](int index);
68 void add(char *format_name, PixelFormat PF);
69 void insert(int index, char *format_name, PixelFormat PF);
70 void remove(int index);
71
72 void readUserDefinedPF(HKEY root, const char *keypath);
73 void writeUserDefinedPF(HKEY root, const char *keypath);
74
75 int count() { return PFList.size(); }
76 int getDefaultPFCount() { return PF_DEFAULT_COUNT; }
77 int getUserPFCount() { return max(0, count() - PF_DEFAULT_COUNT); }
78 int getIndexByPFName(const char *format_name);
79 bool isDefaultPF(int index);
80
81protected:
82 list <PixelFormatListElement>::iterator getIterator(int index);
83 list <PixelFormatListElement> PFList;
84 int PF_DEFAULT_COUNT;
85};