home *** CD-ROM | disk | FTP | other *** search
- #include <theatrix.h>
-
- const int fg = 0;
- const int bg = 15;
-
- class MouseDemo : public SceneryDirector {
- void display();
- void hide();
- void on_quit(int,int,int);
- void on_click(int x,int y,int b);
- void on_move(int x,int y,int b);
- void on_centerclick(int, int);
- DECLARE_CUELIST
- DECLARE_MOUSECURSORS
- public:
- MouseDemo()
- { }
- };
-
- CUELIST(MouseDemo)
- MOUSECLICK(RIGHTMOUSEBUTTON,on_quit)
- MOUSECLICK(LEFTMOUSEBUTTON,on_click)
- MOUSEMOVE(on_move)
- KEYSTROKE(ESC, on_quit)
- ENDCUELIST
-
- CURSORLIST(MouseDemo)
- MOUSE_CURSOR( 0, 0,105, 79,UPPERLEFTARROWCURSOR, 0)
- MOUSE_CURSOR(106, 0,211, 79,UPARROWCURSOR, 0)
- MOUSE_CURSOR(212, 0,319, 79,UPPERRIGHTARROWCURSOR, 0)
- MOUSE_CURSOR( 0, 80,105,159,LEFTARROWCURSOR, 0)
- MOUSE_CURSOR(106, 80,211,159,CENTERCURSOR, on_centerclick)
- MOUSE_CURSOR(212, 80,319,159,RIGHTARROWCURSOR, 0)
- MOUSE_CURSOR( 0,160,105,239,LOWERLEFTARROWCURSOR, 0)
- MOUSE_CURSOR(106,160,211,239,DOWNARROWCURSOR, 0)
- MOUSE_CURSOR(212,160,319,239,LOWERRIGHTARROWCURSOR, 0)
- ENDCURSORLIST
-
- void MouseDemo::display()
- {
- fg_setcolor(bg);
- fg_fillpage();
- fg_setcolor(fg);
- mouse_visible();
- }
-
- void MouseDemo::hide()
- {
- mouse_invisible();
- }
- void MouseDemo::on_quit(int,int,int)
- {
- stop_director();
- }
- void MouseDemo::on_click(int x,int y,int)
- {
- fg_move(x,y); // position graphics cursor
- mouse_invisible();
- fg_circle(5); // draw a circle
- mouse_visible();
- }
- void MouseDemo::on_move(int x,int y,int b)
- {
- fg_move(x,y);
- mouse_invisible();
- fg_circle((b & LEFTMOUSEBUTTON) ? 5 : 1);
- mouse_visible();
- }
- void MouseDemo::on_centerclick(int x, int y)
- {
- mouse_invisible();
- fg_box(x, x+10, y, y+10);
- mouse_visible();
- }
-
- class MouseApp : public Theatrix {
- public:
- MouseApp() : Theatrix("mouse demo")
- { demo=new MouseDemo; }
- ~MouseApp()
- { delete demo; }
- private:
- MouseDemo* demo;
- };
-
- int main()
- {
- MouseApp app;
- app.go();
- return 0;
- }
-