1 // $Id: worldview_component.hxx,v 1.21 2003/07/28 22:46:48 grumbel Exp $
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_WORLDVIEW_COMPONENT_HXX
21 #define HEADER_WORLDVIEW_COMPONENT_HXX
23 #include "input_context.hxx"
24 #include "zoom_graphic_context.hxx"
25 #include "gui_component.hxx"
29 class WorldViewInsertTool
;
30 class WorldViewSelectTool
;
31 class WorldViewZoomTool
;
32 class WorldViewColliderTool
;
34 /** GUI Component that manages the view and the editing of the
35 world, this is the main component of Construo */
36 class WorldViewComponent
: public GUIComponent
39 enum Mode
{ INSERT_MODE
, SELECT_MODE
, ZOOM_MODE
, COLLIDER_MODE
};
44 ZoomGraphicContext gc
;
46 /** If set to true, display a grid and align dots to it */
49 /** True if the third button is currently pressed and we are in
59 /** If the user clicks in this component, the tool decides what to
61 WorldViewTool
* current_tool
;
62 WorldViewSelectTool
* select_tool
;
63 WorldViewInsertTool
* insert_tool
;
64 WorldViewZoomTool
* zoom_tool
;
65 WorldViewColliderTool
* collider_tool
;
67 static WorldViewComponent
* instance_
;
69 /** Draw the background grid to which new dots align */
72 /** Draw ground, aka the all overspanning collider at the bottem */
75 void set_mode (Mode m
);
76 Mode
get_mode () { return mode
; }
78 WorldViewComponent ();
79 ~WorldViewComponent ();
81 static inline WorldViewComponent
* instance() { return instance_
; }
83 WorldViewInsertTool
* get_insert_tool() { return insert_tool
; }
85 ZoomGraphicContext
* get_gc () { return &gc
; }
86 void draw (GraphicContext
* parent_gc
);
88 bool uses_grid() const { return use_grid
; }
90 void on_primary_button_press (int x
, int y
);
91 void on_primary_button_release (int x
, int y
);
93 void on_secondary_button_press (int x
, int y
);
94 void on_secondary_button_release (int x
, int y
);
96 void on_tertiary_button_press (int x
, int y
);
97 void on_tertiary_button_release (int x
, int y
);
99 void on_mouse_move (int x
, int y
, int of_x
, int of_y
);
101 void on_scale_press(int x
, int y
);
102 void on_grid_press(int x
, int y
);
103 void on_duplicate_press (int x
, int y
);
104 void on_delete_press (int x
, int y
);
105 void on_fix_press (int x
, int y
);
106 void on_join_press (int x
, int y
);
108 void on_button_press (int button_id
, int x
, int y
);
110 void wheel_up (int x
, int y
);
111 void wheel_down (int x
, int y
);
114 void scroll_right ();
120 /** Called once the world has changed, aka a new world got loaded */
121 void on_world_change();
124 bool is_at (int x
, int y
) { return true; }