diff options
author | Bastian Wissler | 2008-07-17 17:50:23 +0200 |
---|---|---|
committer | Bastian Wissler | 2008-07-17 17:50:23 +0200 |
commit | a17cc241adc60b41f99c08e1083e5e0595a8d062 (patch) | |
tree | 0757f705db67f104ca14175bf6cd7bf56c65d5a6 | |
parent | vmchooser changes: (diff) | |
download | vmchooser-a17cc241adc60b41f99c08e1083e5e0595a8d062.tar.gz vmchooser-a17cc241adc60b41f99c08e1083e5e0595a8d062.tar.xz vmchooser-a17cc241adc60b41f99c08e1083e5e0595a8d062.zip |
vmchooser:
* dynamic resizing through argument
* bold fonts in program
git-svn-id: http://svn.openslx.org/svn/openslx/openslx-src-tools/trunk/os-plugins/plugins/vmchooser@1930 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r-- | vmchooser/SWindow.cxx | 76 | ||||
-rw-r--r-- | vmchooser/inc/SWindow.h | 27 | ||||
-rw-r--r-- | vmchooser/main.cxx | 30 |
3 files changed, 110 insertions, 23 deletions
diff --git a/vmchooser/SWindow.cxx b/vmchooser/SWindow.cxx index ef1a871..6cfb12d 100644 --- a/vmchooser/SWindow.cxx +++ b/vmchooser/SWindow.cxx @@ -14,6 +14,82 @@ using namespace fltk; using namespace std; + +/******************************************************** + * default constructur for the main window + * ---------------------------------------------------- + * if you want to set the size, call second ctor + ********************************************************/ +// SWindow::SWindow(char* p): +// fltk::Window(fltk::USEDEFAULT,fltk::USEDEFAULT,500,550,p, true), +// go(160, 520, 320, 20, "Ausführen"), +// exit_btn(10, 520, 140, 20, "Abbrechen"), +// sel(10,10, 480, 500) +// { +// border(false); +// go.callback(cb_return,this); +// sel.callback(cb_select, this); +// exit_btn.callback(cb_exit, this); +// +// // Array for width of Select-Columns +// // (one Column for a lock-symbol) +// int widths[] = { 450, 20 }; +// sel.column_widths(widths); +// resizable(sel); +// end(); +// //sel.style(fltk::Browser::default_style); +// sel.indented(1); +// }; + + +/******************************************************** + * second constructur for the main window + * ---------------------------------------------------- + * if you want to use default sizes, call first ctor + ********************************************************/ +SWindow::SWindow(int w, int h, char* p): + fltk::Window(fltk::USEDEFAULT,fltk::USEDEFAULT,w,h,p, true), + go(w/3 + 10, h-30, (2*w)/3 - 10 , 30, "Ausführen"), + exit_btn(10, h-30, w/3 -10, 30, "Abbrechen"), + sel(10,10, w-20, h-40) +{ + border(false); + go.callback(cb_return,this); + sel.callback(cb_select, this); + exit_btn.callback(cb_exit, this); + + // Array for width of Select-Columns + // (one Column for a lock-symbol) + +// int v = w-20; +// int widths[] = { (7*v)/8, v/8 }; +// sel.column_widths(widths); +// resizable(sel); + end(); + + Style* btn_style = new Style(*fltk::ReturnButton::default_style); + Style* sel_style = new Style(*fltk::Browser::default_style); + + + sel.indented(1); + + Font* f1 = font("sans bold"); + //Font* f1bold = f1->bold(); + + btn_style->textsize(16); + btn_style->labelsize(16); + btn_style->labelfont(f1); + btn_style->textfont(f1); + + sel_style->textfont(f1); + sel_style->textsize(16); + + exit_btn.style(btn_style); + go.style(btn_style); + sel.style(sel_style); +}; + + /******************************************************** * Callback for ReturnButton at the bottom of the GUI * ---------------------------------------------------- diff --git a/vmchooser/inc/SWindow.h b/vmchooser/inc/SWindow.h index 4e8ccb2..f4121a7 100644 --- a/vmchooser/inc/SWindow.h +++ b/vmchooser/inc/SWindow.h @@ -5,6 +5,7 @@ #include <fltk/Window.h> #include <fltk/ReturnButton.h> #include <fltk/Browser.h> +#include <fltk/Font.h> //#include <fltk/TextDisplay.h> #include <fltk/ItemGroup.h> #include <fltk/Item.h> @@ -48,30 +49,12 @@ private: /** * ctor with some reasonable default values */ - SWindow(char* p = "Choose your session!") : - fltk::Window(fltk::USEDEFAULT,fltk::USEDEFAULT,500,550,p, true), - go(160, 520, 320, 20, "Ausführen"), - exit_btn(10, 520, 140, 20, "Abbrechen"), - sel(10,10, 480, 500) - { - border(false); - go.callback(cb_return,this); - sel.callback(cb_select, this); - exit_btn.callback(cb_exit, this); - - // Array for width of Select-Columns - // (one Column for a lock-symbol) - int widths[] = { 450, 20 }; - sel.column_widths(widths); - resizable(sel); - end(); - //sel.style(fltk::Browser::default_style); - sel.indented(1); - }; + //SWindow(char* p = "Choose your session!"); + SWindow(int w, int h, char* p = "Choose your session!"); public: - static SWindow* getInstance() { - static SWindow instance; + static SWindow* getInstance(int w, int h) { + static SWindow instance(w,h); return &instance; } diff --git a/vmchooser/main.cxx b/vmchooser/main.cxx index 9f8087f..8fff48b 100644 --- a/vmchooser/main.cxx +++ b/vmchooser/main.cxx @@ -27,6 +27,7 @@ int main(int argc, char** argv) { char* xmlpath = NULL; char* slxgroup = NULL; char* lsesspath = NULL; + int width=0, height=0; opt->setVerbose(); opt->autoUsagePrint(true); @@ -36,6 +37,7 @@ int main(int argc, char** argv) { opt->addUsage("\t{-p |--path=} path to vmware (.xml) files"); opt->addUsage("\t{-l |--lpath=} path to linux session (.desktop) files"); opt->addUsage("\t{-g |--group=} group name"); + opt->addUsage("\t{-s |--size=} [widthxheight]"); opt->addUsage("\t{-h |--help} prints help"); opt->addUsage(""); @@ -43,6 +45,7 @@ int main(int argc, char** argv) { opt->setOption("path", 'p'); opt->setOption("lpath", 'l'); opt->setOption("group",'g'); + opt->setOption("size",'s'); opt->processCommandArgs(argc, argv); @@ -86,6 +89,31 @@ int main(int argc, char** argv) { lsesspath = "/usr/share/xsessions/"; } + /** Size of Window */ + string size; + unsigned int i; + + if(opt->getValue('s')!=NULL) { + size = opt->getValue('s'); + } + if(opt->getValue("size")!= NULL) { + size = opt->getValue("size"); + } + + if (size.empty()) { + width = 500; + height = 550; + } + else { + i = size.find_first_of("x"); + if( i == string::npos) { + cerr << "Please write <width>x<height> as argument for -s|--size." << endl; + return 1; + } + height = atoi(size.substr(i+1).c_str()); + width = atoi(size.substr(0, size.size()-i-1).c_str()); + } + delete opt; /* read xml files */ @@ -99,7 +127,7 @@ int main(int argc, char** argv) { } lsessions = readLinSess(lsesspath); - SWindow& win = *SWindow::getInstance(); + SWindow& win = *SWindow::getInstance(width, height); if(lsessions != NULL) { win.set_lin_entries(lsessions, slxgroup); |