summaryrefslogtreecommitdiffstats
path: root/vmchooser/inc/SWindow.h
blob: 777b04b73cf03340215478dee88676246da93ba2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

#ifndef SWindow_h
#define SWindow_h

#include <fltk/Window.h>
#include <fltk/ReturnButton.h>
#include <fltk/Browser.h>
//#include <fltk/TextDisplay.h>
#include <fltk/ItemGroup.h>
#include <fltk/Item.h>
#include <fltk/SharedImage.h>
#include <fltk/Image.h>
#include <fltk/xpmImage.h>


#include "DataEntry.h"
#include "functions.h"
#include <map>
#include <unistd.h>
#include <iostream>

class SWindow : public fltk::Window {

private:
  // ReturnButton to start the session
  fltk::ReturnButton go;

  // Browser to select sessions
  fltk::Browser sel;

  // TextDisplay to display info about current session
//  fltk::TextDisplay info;
  // TextBuffer buf is used for info
//  fltk::TextBuffer buf;
  
  // currently selected Browser-Item
  fltk::Item* curr;

  // Two groups - Linux and VMWare
  fltk::ItemGroup* entgroup;
  fltk::ItemGroup* lin_entgroup;

  // Arrays with data from .xml and .desktop files
  DataEntry** ent;
  DataEntry** lin_ent;
  
  
  

  /**
   * ctor with some reasonable default values
   */
  SWindow(char* p = "Choose your session!") :
    fltk::Window(fltk::USEDEFAULT,fltk::USEDEFAULT,500,550,p, true),
    go(10,520, 490, 20, "Ausführen"),
    sel(10,10, 480, 500) //,
//    info(10, 510, 480, 110),
//    buf()
  {
    border(false);
    go.callback(cb_return,this);
    sel.callback(cb_select, this);
    
    
    // Array for width of Select-Columns 
    // (one Column for a lock-symbol)
    int widths[] = { 450, 20 };
    sel.column_widths(widths);
//    info.callback(cb_info, this);
    resizable(sel);
    end();
    
//    info.wrap_mode(true, 0);
    //sel.style(fltk::Browser::default_style);
    sel.indented(1);
  };

public:
  static SWindow* getInstance() {
    static SWindow instance;
    return &instance;
  }
  
  
  int pathsize;
  char* pname; /* Holds the current absolute path */

  ~SWindow() { };

  static void cb_return(fltk::Widget*, void* w) {
    ((SWindow*)w)->cb_return();
  };
  static void cb_select(fltk::Widget*, void* w) {
    ((SWindow*)w)->cb_select();
  };
  static void cb_info(fltk::Widget*, void* w) {
    ((SWindow*)w)->cb_info();
  };

  void cb_return();
  void cb_select();
  void cb_info();

  void set_entries(DataEntry** ent, char* slxgroup);
  void set_lin_entries(DataEntry** ent, char* slxgroup);
  
  char** get_symbol(DataEntry* dat);

  void free_entries();
  void unfold_entries();

};


#endif