summaryrefslogtreecommitdiff
path: root/Dalos/Dalos.cc
blob: c9d876369cc9171cc488a4c78c404298f5ce8303 (plain)
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
#include <SDL.h>
#include <Main.h>

#include <engine.h>
#include <glbase.h>
#include <glshape.h>

mogltk::widgets::Root * Root;
mogltk::widgets::Frame * Frame;
mogltk::widgets::Menu * MainMenu;

CODE_BEGINS

class frame : public mogltk::widget {
  public:
      frame(mogltk::shape * sh, mogltk::widget * father) :
        widget(father, 2, 2, father->GetW() - 4, father->GetH() - 4, 0, "MyFrame", sh) { }
      protected:
    virtual void draw() {
    }
    virtual bool process_event(int mx, int my, mogltk::event_t event) {
        return false;
    }
};

class timer : public mogltk::widget {
  public:
      timer() :
        widget(Root, 0, 0, 0, 0, 0, "Timer", 0), tick(0)
        { set_timed_event(100); }
  protected:
    virtual bool process_event(int, int, mogltk::event_t event) {
        if (event == mogltk::E_TIMER) {
            set_timed_event(100);
            tick = (tick + 1) % 4;
            switch (tick) {
            case 0:
                MainMenu->SetCaption(0, "/");
                break;
            case 1:
                MainMenu->SetCaption(0, "-");
                break;
            case 2:
                MainMenu->SetCaption(0, "\\");
                break;
            case 3:
                MainMenu->SetCaption(0, "I");
                break;
            }
            return true;
        }
        return false;
    }
  private:
    int tick;
};

class quit : public mogltk::widgets::action {
  public:
    virtual void do_action(mogltk::widget * w) {
        mogltk::engine::quit();
    }
} action_quit;

class about : public mogltk::widgets::action {
  public:
    virtual void do_action(mogltk::widget * w) {
        new mogltk::widgets::MsgBox(w->Shaper(), w->Father(), "About...",
            "Dalos version 0.1 - OpenGL version\n"
            "Copyright (C) 2004 Nicolas \"Pixel\" Noble\n"
            "\n"
            "Thanks and greetings fly to (no particular order)\n"
            "GreatSkaori, Orphis, Ti Dragon, Yaz0r, S-O-R,\n"
            "Meradrin, SkeuD, Moogle, InVerse, LavosSpawn\n"
            "\n"
            "And to all I forgot!\n"
        );
    }
} about_dialog;

virtual int startup() throw (GeneralException) {
    mogltk::widgets::ContextMenu * c;
    mogltk::base * gl = new mogltk::glbase();
    mogltk::shape * sh = new mogltk::glshape();

    mogltk::engine::setcursorvisible(true);
    mogltk::engine::setappactive(true);

    Root = new mogltk::widgets::Root(sh);
    MainMenu = new mogltk::widgets::Menu(sh, Root);
    Frame = new mogltk::widgets::Frame(sh, Root, 0, MainMenu->GetH(), Root->GetW() - 1, Root->GetH() - MainMenu->GetH() - 1);
    new frame(sh, Frame);

    MainMenu->addnode("/", 0);

    c = MainMenu->createsub("File");
    c->addnode("Load", 0);
    c->addnode("Save", 0);
    c->addline();
    c->addnode("Quit", &action_quit);

    c = MainMenu->createsub("Execution");
    c->addnode("Run", 0);

    c = MainMenu->createsub("Help");
    c->addnode("About", &about_dialog);

    new timer();

    Root->mainloop();

    return 0;
}

CODE_ENDS