Created
February 19, 2012 11:54
-
-
Save diosmosis/1863423 to your computer and use it in GitHub Desktop.
iris examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a small GUI using mythos, the library iris will | |
// be a rewrite of | |
using namespace mythos; | |
namespace myapp | |
{ | |
nyx::window mainframe; | |
std::string mloc_str(\"(MAX,MAX)\"); | |
iris::event_handler extra; | |
// event handler that destroys the main window | |
// when pressed | |
void quit_prog() | |
{ | |
nyx::destroy_window(mainframe); | |
} | |
// event handler that sets and displays the mouse's | |
// current location every time it moves | |
struct set_mloc_str | |
{ | |
void operator()(nyx::point const& pt) const | |
{ | |
std::stringstream ss; | |
ss << '(' << pt.x << ',' << pt.y << ')'; | |
mloc_str = ss.str(); | |
iris::paint(mainframe); | |
} | |
}; | |
int main(int argc, char ** argv) | |
{ | |
using namespace nyx; | |
using namespace gaia; | |
// create the main window | |
mainframe = nyx::create_toplevel_window( | |
\"My window\", 200, 200, 200, 200); | |
// create two buttons | |
window do_dlog = | |
button(show_dialog)[ hcenter[\"Show Dialog\"] ]; | |
window quit = button(quit_prog)[ hcenter[\"Quit\"] ]; | |
// create the layout of the main window | |
layout(mainframe) = | |
rows[ \"Hello World\" ] | |
[ \"Mouse coords:\" | text(mloc_str) ] | |
[ do_dlog | right[quit] ] | |
; | |
// handle some other events | |
extra = iris::on::mouse_move[set_mloc_str()]; | |
mainframe.connect(extra); | |
return EXIT_SUCCESS; | |
} | |
} | |
MYTHOS_KHAOS_IMPLEMENT_MAIN(myapp::main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment