// @topic W010303 FLTK FLUID -- maze navigation // @brief class CMazeWindow implementation -- generated by FLUID // generated by Fast Light User Interface Designer (fluid) version 1.0302 #include "MazeWindow.h" CMazeWindow::CMazeWindow( Room* entry_room ) { { m_double_window = new Fl_Double_Window(493, 400, "Maze Navigation App"); //Fl_Double_Window( 483, 410 ); //m_double_window->user_data((void*)(this)); { canvas = new Drawing2D(25, 25, 445, 321); //Drawing2D(170, 30, 300, 190, entry_room); canvas->box(FL_DOWN_BOX); canvas->color(FL_BACKGROUND_COLOR); canvas->selection_color(FL_BACKGROUND_COLOR); canvas->labeltype(FL_NORMAL_LABEL); canvas->labelfont(0); canvas->labelsize(14); canvas->labelcolor(FL_FOREGROUND_COLOR); canvas->callback((Fl_Callback*)animation_begin, (void*)(canvas)); canvas->align(Fl_Align(FL_ALIGN_CENTER)); canvas->when(FL_WHEN_RELEASE); } // Drawing2D* canvas { button_right = new Fl_Button(125, 360, 80, 25, "- - >"); //Fl_Button( 30, 15, 100, 25, "->" ); button_right->callback((Fl_Callback*)cb_btn_right, (void*)(canvas)); } // Fl_Button* button_right { button_left = new Fl_Button(30, 360, 80, 25, "< - -"); //Fl_Button( 40, 60, 75, 25, "<-" ); button_left->callback((Fl_Callback*)cb_btn_left, (void*)(canvas)); } // Fl_Button* button_left m_double_window->end(); m_double_window->resizable( *m_double_window ); } // Fl_Double_Window* m_double_window } void CMazeWindow::cb_btn_right( Fl_Widget* btn, void* userdata ) { Drawing2D* pcanvas = static_cast< Drawing2D* >( userdata ); pcanvas->turn_head_right(); Fl::redraw(); } void CMazeWindow::cb_btn_left( Fl_Widget* btn, void* userdata ) { Drawing2D* pcanvas = static_cast< Drawing2D* >( userdata ); pcanvas->turn_head_left(); Fl::redraw(); } /** timer animation */ void CMazeWindow::animation_begin( Fl_Widget* widg, void* userdata ) { Drawing2D* pcanvas = static_cast< Drawing2D* >( userdata ); if ( pcanvas->animate_door_entry() ) { Fl::add_timeout( TICK_TIMEOUT, animation_continue, userdata ); } } void CMazeWindow::animation_continue( void* userdata ) { Drawing2D* pcanvas = static_cast< Drawing2D* >( userdata ); if ( pcanvas->animate_door_entry() ) { Fl::redraw(); Fl::add_timeout( TICK_TIMEOUT, animation_continue, userdata ); } else { Fl::redraw(); } } void CMazeWindow::show( Room* entry_room ) { canvas->initialize_room( entry_room ); m_double_window->show(); }