diff options
author | Yaniv Kamay <ykamay@redhat.com> | 2009-12-28 01:15:08 +0200 |
---|---|---|
committer | Yaniv Kamay <ykamay@redhat.com> | 2009-12-28 12:38:58 +0200 |
commit | 68fb44012982897ea883b336c56d0e8c12ddce0d (patch) | |
tree | 209556db04762b5f5f7581af4f51970f04e8d836 /client/gui/resource_provider.cpp | |
parent | 659be313a43fc741ed9decd95178efbeedf2c4fd (diff) | |
download | spice-68fb44012982897ea883b336c56d0e8c12ddce0d.tar.gz spice-68fb44012982897ea883b336c56d0e8c12ddce0d.tar.xz spice-68fb44012982897ea883b336c56d0e8c12ddce0d.zip |
client: add GUI infrastructure + functional login dialog
Diffstat (limited to 'client/gui/resource_provider.cpp')
-rw-r--r-- | client/gui/resource_provider.cpp | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/client/gui/resource_provider.cpp b/client/gui/resource_provider.cpp new file mode 100644 index 00000000..47f86a43 --- /dev/null +++ b/client/gui/resource_provider.cpp @@ -0,0 +1,128 @@ +#include "common.h" + +#include "resource_provider.h" +#include "debug.h" +#include "utils.h" + +#include "CEGUIExceptions.h" + +#include "taharez_look.scheme.c" +#include "taharez_look.imageset.c" +#include "taharez_look.tga.c" +#include "commonwealth-10.font.c" +#include "commonv2c.ttf.c" +#include "taharez_look.looknfeel.c" +#include "dejavu_sans-10.font.c" +#include "dejavu_sans.ttf.c" + +//(echo "const unsigned char <struct name>[] = +//{"; od -txC -v <in file name> | sed -e "s/^[0-9]*//" -e s"/ \([0-9a-f][0-9a-f]\)/0x\1,/g" -e"\$d" +//| sed -e"\$s/,$/};/") > <out file name>.c + +void CEGUIResourceProvider::loadRawDataContainer(const CEGUI::String &filename, + CEGUI::RawDataContainer &output, + const CEGUI::String &resourceGroup) +{ + DBG(0, "%s", filename.c_str()); + if (strcmp(filename.c_str(), "TaharezLook.scheme") == 0) { + DBG(0, "size %d", sizeof(taharez_look_schem)); + output.setData((CEGUI::uint8*)taharez_look_schem); + output.setSize(sizeof(taharez_look_schem)); + return; + } + + if (strcmp(filename.c_str(), "TaharezLook.imageset") == 0) { + DBG(0, "size %d", sizeof(taharez_look_imageset)); + output.setData((CEGUI::uint8*)taharez_look_imageset); + output.setSize(sizeof(taharez_look_imageset)); + return; + } + + if (strcmp(filename.c_str(), "TaharezLook.tga") == 0) { + DBG(0, "size %d", sizeof(taharez_look_tga)); + output.setData((CEGUI::uint8*)taharez_look_tga); + output.setSize(sizeof(taharez_look_tga)); + return; + } + + if (strcmp(filename.c_str(), "Commonwealth-10.font") == 0) { + DBG(0, "size %d", sizeof(commonwealth_10_font)); + output.setData((CEGUI::uint8*)commonwealth_10_font); + output.setSize(sizeof(commonwealth_10_font)); + return; + } + + if (strcmp(filename.c_str(), "Commonv2c.ttf") == 0) { + DBG(0, "size %d", sizeof(commonv2c_ttf)); + output.setData((CEGUI::uint8*)commonv2c_ttf); + output.setSize(sizeof(commonv2c_ttf)); + return; + } + + if (strcmp(filename.c_str(), "TaharezLook.looknfeel") == 0) { + DBG(0, "size %d", sizeof(taharez_look_looknfeel)); + output.setData((CEGUI::uint8*)taharez_look_looknfeel); + output.setSize(sizeof(taharez_look_looknfeel)); + return; + } + + if (strcmp(filename.c_str(), "DejaVuSans-10.font") == 0) { + DBG(0, "size %d", sizeof(dejavu_sans_10_font)); + output.setData((CEGUI::uint8*)dejavu_sans_10_font); + output.setSize(sizeof(dejavu_sans_10_font)); + return; + } + + if (strcmp(filename.c_str(), "DejaVuSans.ttf") == 0) { + DBG(0, "size %d", sizeof(dejavu_sans_ttf)); + output.setData((CEGUI::uint8*)dejavu_sans_ttf); + output.setSize(sizeof(dejavu_sans_ttf)); + return; + } + + throw CEGUI::GenericException("failed"); +} + +void CEGUIResourceProvider::unloadRawDataContainer(CEGUI::RawDataContainer& data) +{ + data.setData(NULL); + data.setSize(0); +} + +struct ResString{ + int id; + const char* str; +} res_strings[] = { + {STR_MESG_MISSING_HOST_NAME, "Missing host name"}, + {STR_MESG_INVALID_PORT, "Invalid port"}, + {STR_MESG_INVALID_SPORT, "Invalid sport"}, + {STR_MESG_MISSING_PORT, "Missing port"}, + {STR_MESG_CONNECTING, "Connecting to"}, + {STR_BUTTON_OK, "OK"}, + {STR_BUTTON_CANCEL, "Cancel"}, + {STR_BUTTON_CONNECT, "Connect"}, + {STR_BUTTON_QUIT, "Quit"}, + {STR_BUTTON_CLOSE, "Close"}, + {STR_BUTTON_DISCONNECT, "Disconnect"}, + {STR_BUTTON_OPTIONS, "Options"}, + {STR_BUTTON_BACK, "Back"}, + {STR_LABEL_HOST, "Host"}, + {STR_LABEL_PORT, "Port"}, + {STR_LABEL_SPORT, "Secore port"}, + {STR_LABEL_PASSWORD, "Password"}, + {0, NULL}, +}; + +const char* res_get_string(int id) +{ + ResString *string; + + for (string = res_strings; string->str; string++) { + if (string->id == id) { + return string->str; + } + } + + return NULL; +} + |