~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/editor/object_selector_window.hxx

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Goulais
  • Date: 2004-08-09 10:26:00 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040809102600-lg2q9lfars0q1p42
Tags: 0.6.0-8
Applied patch from Andreas Jochens (Closes: #263992)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  $Id: object_selector_window.hxx,v 1.2 2002/12/03 00:51:19 grumbel Exp $
 
2
// 
 
3
//  Pingus - A free Lemmings clone
 
4
//  Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
 
5
//
 
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.
 
10
//
 
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.
 
15
// 
 
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.
 
19
 
 
20
#ifndef HEADER_PINGUS_EDITOR_OBJECT_SELECTOR_WINDOW_HXX
 
21
#define HEADER_PINGUS_EDITOR_OBJECT_SELECTOR_WINDOW_HXX
 
22
 
 
23
#include <string>
 
24
#include <vector>
 
25
#include <ClanLib/GUI/window.h>
 
26
#include <ClanLib/GUI/button.h>
 
27
 
 
28
/** A Little window that lets you select an object type to insert */
 
29
class ObjectSelectorWindow : public CL_Window
 
30
{
 
31
private:
 
32
  typedef void (ObjectSelectorWindow::*Callback)();
 
33
 
 
34
  class ButtonPair {
 
35
  private:
 
36
    ObjectSelectorWindow* parent;
 
37
    Callback callback;
 
38
    CL_Button button;
 
39
    CL_Slot button_click_slot;
 
40
 
 
41
  public:
 
42
    ButtonPair (ObjectSelectorWindow* p, const std::string& name, Callback c, int y_pos)
 
43
      : parent (p), 
 
44
        callback(c),
 
45
        button (CL_Rect(10, y_pos, 190, y_pos + 20), name, parent->get_client_area())
 
46
    {
 
47
      button_click_slot = button.sig_clicked().connect(this, &ButtonPair::on_click);
 
48
    }
 
49
 
 
50
    void on_click() 
 
51
    {
 
52
      // Call the callback, yeah, func_ptr synaxt is cool...
 
53
      ((*parent).*callback)();
 
54
    }
 
55
  };
 
56
 
 
57
  /** Position for the next inserted button */
 
58
  int y_pos;
 
59
 
 
60
  /** container for buttons and callbacks */
 
61
  std::vector<ButtonPair*> buttons;
 
62
 
 
63
public:
 
64
  ObjectSelectorWindow(CL_Component*);
 
65
  ~ObjectSelectorWindow();
 
66
 
 
67
  void on_close_press();
 
68
  
 
69
  void on_groundpiece_ground_press();
 
70
  void on_groundpiece_solid_press();
 
71
  void on_groundpiece_transparent_press();
 
72
  void on_groundpiece_remove_press();
 
73
  void on_hotspot_press();
 
74
  void on_entrance_press();
 
75
  void on_exit_press();
 
76
  void on_liquid_press();
 
77
  void on_weather_press();
 
78
  void on_trap_press();
 
79
  void on_worldobject_press();
 
80
  void on_background_press();
 
81
  void on_prefab_press();
 
82
  void on_from_file_press();
 
83
 
 
84
private:
 
85
  void add_button (const std::string& name, Callback callback);
 
86
  
 
87
  ObjectSelectorWindow (const ObjectSelectorWindow&);
 
88
  ObjectSelectorWindow& operator= (const ObjectSelectorWindow&);
 
89
};
 
90
 
 
91
#endif
 
92
 
 
93
/* EOF */