t_mouse.cpp

Go to the documentation of this file.
00001 
00002 #include <basis/chaos.h>
00003 #include <opsystem/application_shell.h>
00004 #include <loggers/console_logger.h>
00005 #include <data_struct/static_memory_gremlin.h>
00006 #include <wp_passive/label.h>
00007 #include <wp_passive/manager.h>
00008 #include <wp_active/mouse.h>
00009 #include <wp_passive/wp_implementation.h>
00010 
00011 #include <stdio.h>
00012 
00013 class my_mouse : public mouse
00014 {
00015 public:
00016   my_mouse(manager &to_connect)
00017     : mouse(*(nub *)&to_connect), my_mang(to_connect)
00018   {
00019   }
00020 
00021   IMPLEMENT_CLASS_NAME("my_mouse");
00022 
00023   virtual void button_event(const c_point &where, int button_number,
00024       button_positions state)
00025   {
00026     FUNCDEF("button_event");
00027 LOG("button event in my mouse: ");
00028 LOG(isprintf("button number=%d, button state=%d, mouse posn=%s",
00029 button_number, state, my_mang.device_to_universe(where).text_form().s()));
00030   }
00031 
00032 private:
00033   manager &my_mang;
00034 };
00035 
00036 class test_mouse : public application_shell
00037 {
00038 public:
00039   test_mouse() : application_shell(class_name()) {}
00040   IMPLEMENT_CLASS_NAME("test_mouse");
00041   virtual int execute();
00042 };
00043 
00044 int test_mouse::execute()
00045 {
00046   FUNCDEF("execute");
00047   manager root("A Tester for the Mouse");
00048   my_mouse fred(root);
00049   color green(root.lookup("green"));
00050   color gray(root.lookup("gray"));
00051   label bob(root, c_point(0, 0), "bite me", green, gray);
00052   bob.draw();
00053   while (true) {
00054 printf((istring("orig posn: ") + fred.position().text_form() + "\n").s());
00055     c_point posn = root.device_to_universe
00056       (fred.position() - root.view_to_device(root.dimensions()).vertex_1());
00057 printf((istring("move posn: ") + posn.text_form() + "\n").s());
00058     bob.set_origin(posn);
00059     root.poll_and_return(400);
00060   }
00061   root.poll();
00062   return 0;
00063 }
00064 
00065 HOOPLE_MAIN(test_mouse, )
00066 

Generated on Fri Nov 28 04:29:34 2008 for HOOPLE Libraries by  doxygen 1.5.1