1 /* 2 * Copyright (c) 2008 prissi 3 * 4 * This file is part of the Simutrans project under the artistic licence. 5 */ 6 7 /* 8 * This class defines all toolbar dialogues, floating bar of tools, i.e. the part the user will see 9 */ 10 11 #ifndef TOOL_SELECTOR_H 12 #define TOOL_SELECTOR_H 13 14 #include "gui_frame.h" 15 #include "../tpl/vector_tpl.h" 16 #include "simwin.h" 17 #include "../dataobj/environment.h" 18 19 class tool_t; 20 21 22 class tool_selector_t : public gui_frame_t 23 { 24 private: 25 struct tool_data_t { tooltool_data_t26 tool_data_t(tool_t* t=NULL) : tool(t), selected(false) {} 27 tool_t* tool; ///< pointer to associated tool 28 bool selected; ///< store whether tool was active during last call to tool_selector_t::draw 29 }; 30 /// tool definitions 31 vector_tpl<tool_data_t> tools; 32 33 // get current toolbar number for saving 34 uint32 toolbar_id; 35 36 /** 37 * window width in toolboxes 38 * @author Hj. Malthaner 39 */ 40 uint16 tool_icon_width; 41 uint16 tool_icon_height; 42 43 uint16 tool_icon_disp_start; 44 uint16 tool_icon_disp_end; 45 46 bool has_prev_next; 47 48 /** 49 * Window title 50 * @author Hj. Malthaner 51 */ 52 const char *title; 53 54 /** 55 * Name of the help file 56 * @author Hj. Malthaner 57 */ 58 const char *help_file; 59 60 // needs dirty redraw (only when changed) 61 bool dirty; 62 63 bool allow_break; 64 65 public: 66 tool_selector_t(const char *title, const char *help_file, uint32 toolbar_id, bool allow_break=true ); 67 68 /** 69 * Add a new tool with values and tooltip text. 70 * @author Hj. Malthaner 71 */ 72 void add_tool_selector(tool_t *tool_in); 73 74 // purges toolbar 75 void reset_tools(); 76 77 /** 78 * Set the window associated helptext 79 * @return the filename for the helptext, or NULL 80 * @author Hj. Malthaner 81 */ get_help_filename()82 const char *get_help_filename() const OVERRIDE {return help_file;} 83 get_titlecolor()84 FLAGGED_PIXVAL get_titlecolor() const OVERRIDE { return env_t::default_window_title_color; } 85 86 bool is_hit(int x, int y) OVERRIDE; 87 88 /** 89 * Does this window need a next button in the title bar? 90 * @return true if such a button is needed 91 * @author Volker Meyer 92 */ has_next()93 bool has_next() const OVERRIDE {return has_prev_next;} 94 95 bool infowin_event(event_t const*) OVERRIDE; 96 97 /** 98 * Draw new component. The values to be passed refer to the window 99 * i.e. It's the screen coordinates of the window where the 100 * component is displayed. 101 * @author Hj. Malthaner 102 */ 103 void draw(scr_coord pos, scr_size size) OVERRIDE; 104 105 // since no information are needed to be saved to restore this, returning magic is enough get_rdwr_id()106 uint32 get_rdwr_id() OVERRIDE { return magic_toolbar+toolbar_id; } 107 108 109 bool empty(player_t *player) const; 110 }; 111 112 #endif 113