[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 357 - trunk/src
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 357 - trunk/src |
Date: |
Fri, 28 May 2004 23:54:21 +0200 |
Author: grumbel
Date: 2004-05-28 23:54:21 +0200 (Fri, 28 May 2004)
New Revision: 357
Added:
trunk/src/paned.cxx
trunk/src/paned.hxx
Modified:
trunk/src/editor.py
trunk/src/flexlay.i
trunk/src/menu.cxx
trunk/src/menu.hxx
Log:
- added click signal to menu stuff
Modified: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-28 17:52:41 UTC (rev 356)
+++ trunk/src/editor.py 2004-05-28 21:54:21 UTC (rev 357)
@@ -74,7 +74,6 @@
copy_icon = Icon(CL_Point(34*3.1+2, 2),
make_sprite("../data/images/icons24/stock_copy.png"), "Some tooltip",
gui.get_component());
paste_icon = Icon(CL_Point(34*4.1+2, 2),
make_sprite("../data/images/icons24/stock_paste.png"), "Some tooltip",
gui.get_component());
-
def foo():
print "Button pressed"
@@ -84,6 +83,14 @@
willow = Panel(CL_Rect(CL_Point(0, 23), CL_Size(800, 33)), gui.get_component())
+def Icon_set_callback(self, func):
+ connect(self.sig_clicked(), func)
+Icon.set_callback = Icon_set_callback
+del Icon_set_callback
+
+def do_something():
+ print "do_something"
+
load_icon = Icon(CL_Point(32*0+2, 2),
make_sprite("../data/images/icons24/stock_open.png"), "Some tooltip", willow);
save_icon = Icon(CL_Point(32*1+2, 2),
make_sprite("../data/images/icons24/stock_save.png"), "Some tooltip", willow);
save_as_icon = Icon(CL_Point(32*2+2, 2),
make_sprite("../data/images/icons24/stock_save_as.png"), "Some tooltip",
willow);
@@ -91,7 +98,12 @@
copy_icon = Icon(CL_Point(32*3.1+2, 2),
make_sprite("../data/images/icons24/stock_copy.png"), "Some tooltip", willow);
paste_icon = Icon(CL_Point(32*4.1+2, 2),
make_sprite("../data/images/icons24/stock_paste.png"), "Some tooltip", willow);
+undo_icon = Icon(CL_Point(32*5.1+2, 2),
make_sprite("../data/images/icons24/stock_undo.png"), "Some tooltip", willow);
+redo_icon = Icon(CL_Point(32*6.1+2, 2),
make_sprite("../data/images/icons24/stock_redo.png"), "Some tooltip", willow);
+undo_icon.set_callback(do_something)
+redo_icon.set_callback(do_something)
+
toolbar = Panel(CL_Rect(CL_Point(0, 23+33), CL_Size(33, 256)),
gui.get_component())
select = Icon(CL_Point(2, 32*0+2),
make_sprite("../data/images/tools/stock-tool-rect-select-22.png"), "Some
tooltip", toolbar);
@@ -101,14 +113,13 @@
supertux = SuperTuxGUI(tileset, gui)
-class MMenu(CL_Menu):
- def __init__(self):
- CL_Menu.__init__(self, gui.get_component())
+def block():
+ def CL_Menu_add_item(self, name, func):
+ item = self.create_item(name)
+ connect(item.sig_clicked(), func)
+ CL_Menu.add_item = CL_Menu_add_item
+block()
- def add_item(self, name, func):
- item = self.create_item(name)
- connect(item.sig_clicked(), func)
-
level = None
def menu_file_open():
print "File/Open"
@@ -123,7 +134,7 @@
def menu_file_save_as():
print "File/Save As"
-menu = MMenu()
+menu = CL_Menu(gui.get_component())
a = menu.add_item("File/Open...", menu_file_open)
a = menu.add_item("File/Save...", menu_file_save)
a = menu.add_item("File/Save As...", menu_file_save_as)
@@ -131,17 +142,27 @@
mysprite = make_sprite("../data/images/icons16/stock_paste-16.png")
+def Menu_add_item(self, sprite, text, func):
+ i = self.__add_item(mysprite, text)
+ if func != None:
+ connect(self.sig_clicked(i), func)
+Menu.__add_item = Menu.add_item
+Menu.add_item = Menu_add_item
+del Menu_add_item
+
mymenu = Menu(CL_Point(100, 100), gui.get_component())
-mymenu.add_item(mysprite, "Foobar aeuaeu")
-mymenu.add_item(mysprite, "blub")
-mymenu.add_item(mysprite, "bla")
+mymenu.add_item(mysprite, "Foobar aeuaeu", None)
+mymenu.add_item(mysprite, "blub", do_something)
+mymenu.add_item(mysprite, "bla", None)
mymenu.add_seperator()
-mymenu.add_item(mysprite, "Foobar")
-mymenu.add_item(mysprite, "blubaoeuau aueau aeu")
-mymenu.add_item(mysprite, "bla")
+mymenu.add_item(mysprite, "Foobar", None)
+mymenu.add_item(mysprite, "blubaoeuau aueau aeu", None)
+mymenu.add_item(mysprite, "bla", None)
def show_menu():
mymenu.run()
+
+copy_icon.set_callback(show_menu)
# _button = CL_Button(CL_Rect(100, 100, 200, 125), "Hello World",
gui.get_component())
# connect(_button.sig_clicked(), show_menu)
Modified: trunk/src/flexlay.i
===================================================================
--- trunk/src/flexlay.i 2004-05-28 17:52:41 UTC (rev 356)
+++ trunk/src/flexlay.i 2004-05-28 21:54:21 UTC (rev 357)
@@ -81,5 +81,6 @@
%include "menu.hxx"
%include "menubar.hxx"
%include "scrollbar.hxx"
+
/* EOF */
Modified: trunk/src/menu.cxx
===================================================================
--- trunk/src/menu.cxx 2004-05-28 17:52:41 UTC (rev 356)
+++ trunk/src/menu.cxx 2004-05-28 21:54:21 UTC (rev 357)
@@ -54,12 +54,19 @@
{
protected:
MenuImpl* parent;
+ CL_Signal_v0 on_clicked;
+
public:
MenuItem(MenuImpl* parent_)
: parent(parent_) {}
+
+ virtual ~MenuItem() {}
+
virtual void draw(int x, int y, bool active) =0;
virtual int get_width() =0;
virtual int get_height() =0;
+
+ CL_Signal_v0& sig_clicked() { return on_clicked; }
};
class SeperatorMenuItem : public MenuItem
@@ -87,6 +94,7 @@
private:
CL_Sprite sprite;
std::string text;
+
public:
TextMenuItem(const CL_Sprite& sprite_, const std::string& text_, MenuImpl*
parent_)
: MenuItem(parent_),
@@ -133,7 +141,7 @@
{
impl->items.push_back(new SeperatorMenuItem(impl.get()));
impl->recalc_size();
- return impl->items.size();
+ return impl->items.size()-1;
}
MenuItemHandle
@@ -141,7 +149,7 @@
{
impl->items.push_back(new TextMenuItem(sprite, name, impl.get()));
impl->recalc_size();
- return impl->items.size();
+ return impl->items.size()-1;
}
MenuItemHandle
@@ -200,8 +208,7 @@
void
MenuImpl::on_mouse_down(const CL_InputEvent& event)
{
- std::cout << "Click on item: " << current_item << std::endl;
-
+ items[current_item]->sig_clicked()();
parent->release_mouse();
parent->show(false);
}
@@ -223,6 +230,12 @@
current_item = -1;
}
+CL_Signal_v0&
+Menu::sig_clicked(MenuItemHandle item)
+{
+ return impl->items[item]->sig_clicked();
+}
+
void
Menu::run()
{
Modified: trunk/src/menu.hxx
===================================================================
--- trunk/src/menu.hxx 2004-05-28 17:52:41 UTC (rev 356)
+++ trunk/src/menu.hxx 2004-05-28 21:54:21 UTC (rev 357)
@@ -40,6 +40,8 @@
MenuItemHandle add_submenu(const std::string& name, const Menu& submenu);
MenuItemHandle add_seperator();
+ CL_Signal_v0& sig_clicked(MenuItemHandle item);
+
void run();
private:
SharedPtr<MenuImpl> impl;
Added: trunk/src/paned.cxx
===================================================================
--- trunk/src/paned.cxx 2004-05-28 17:52:41 UTC (rev 356)
+++ trunk/src/paned.cxx 2004-05-28 21:54:21 UTC (rev 357)
@@ -0,0 +1,48 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "paned.hxx"
+
+class PanedImpl
+{
+public:
+ CL_Component* first;
+ CL_Component* second;
+};
+
+Paned::Paned(CL_Component* parent)
+ : impl(new PanedImpl())
+{
+ impl->first = 0;
+ impl->second = 0;
+}
+
+void
+Paned::set_first(CL_Component* first)
+{
+ impl->first = first;
+}
+
+void
+Paned::set_second(CL_Component* second)
+{
+ impl->second = second;
+}
+
+/* EOF */
Added: trunk/src/paned.hxx
===================================================================
--- trunk/src/paned.hxx 2004-05-28 17:52:41 UTC (rev 356)
+++ trunk/src/paned.hxx 2004-05-28 21:54:21 UTC (rev 357)
@@ -0,0 +1,37 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_PANED_HXX
+#define HEADER_PANED_HXX
+
+/** */
+class Paned : public CL_Component
+{
+public:
+ Paned(CL_Component* parent);
+
+ void set_first(CL_Component* );
+ void set_second(CL_Component* );
+private:
+ SharedPtr<PanedImpl> impl;
+};
+
+#endif
+
+/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 357 - trunk/src,
Ingo Ruhnke <=