[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Windstille-devel] rev 349 - trunk/src
From: |
Ingo Ruhnke |
Subject: |
[Windstille-devel] rev 349 - trunk/src |
Date: |
Sat, 22 May 2004 20:10:43 +0200 |
Author: grumbel
Date: 2004-05-22 20:10:43 +0200 (Sat, 22 May 2004)
New Revision: 349
Added:
trunk/src/menubar.cxx
trunk/src/menubar.hxx
Modified:
trunk/src/SConstruct
trunk/src/editor.py
trunk/src/flexlay.i
trunk/src/menu.cxx
trunk/src/menu.hxx
Log:
- some more menu tweak
- added menubar framework
Modified: trunk/src/SConstruct
===================================================================
--- trunk/src/SConstruct 2004-05-22 16:42:27 UTC (rev 348)
+++ trunk/src/SConstruct 2004-05-22 18:10:43 UTC (rev 349)
@@ -93,6 +93,7 @@
'paint_command.cxx',
'panel.cxx',
'menu.cxx',
+ 'menubar.cxx',
'popup_menu.cxx',
'lispreader.cxx',
'tile.cxx',
Modified: trunk/src/editor.py
===================================================================
--- trunk/src/editor.py 2004-05-22 16:42:27 UTC (rev 348)
+++ trunk/src/editor.py 2004-05-22 18:10:43 UTC (rev 349)
@@ -135,6 +135,12 @@
mymenu.add_item("blub")
mymenu.add_item("bla")
+def show_menu():
+ mymenu.run()
+
+_button = CL_Button(CL_Rect(100, 100, 200, 125), "Hello World",
gui.get_component())
+connect(_button.sig_clicked(), show_menu)
+
minimap_panel = Panel(CL_Rect(CL_Point(0, 600-56), CL_Size(800-134, 56)),
gui.get_component())
minimap = Minimap(editor_map, CL_Rect(CL_Point(3, 3), CL_Size(794-134, 50)),
minimap_panel)
Modified: trunk/src/flexlay.i
===================================================================
--- trunk/src/flexlay.i 2004-05-22 16:42:27 UTC (rev 348)
+++ trunk/src/flexlay.i 2004-05-22 18:10:43 UTC (rev 349)
@@ -38,6 +38,7 @@
#include "panel.hxx"
#include "directory_view.hxx"
#include "menu.hxx"
+#include "menubar.hxx"
%}
%include "std_string.i"
@@ -75,6 +76,7 @@
%include "minimap.hxx"
%include "directory_view.hxx"
%include "menu.hxx"
+%include "menubar.hxx"
/* EOF */
Modified: trunk/src/menu.cxx
===================================================================
--- trunk/src/menu.cxx 2004-05-22 16:42:27 UTC (rev 348)
+++ trunk/src/menu.cxx 2004-05-22 18:10:43 UTC (rev 349)
@@ -45,7 +45,7 @@
}
int get_width() { return 10; }
- int get_height() { return 4; }
+ int get_height() { return 2; }
};
class TextMenuItem : public MenuItem
@@ -103,6 +103,8 @@
impl->slots.push_back(sig_paint().connect(impl.get(), &MenuImpl::draw));
impl->slots.push_back(sig_mouse_move().connect(impl.get(),
&MenuImpl::on_mouse_move));
impl->slots.push_back(sig_mouse_down().connect(impl.get(),
&MenuImpl::on_mouse_down));
+
+ show(false);
}
MenuItemHandle
@@ -178,6 +180,9 @@
MenuImpl::on_mouse_down(const CL_InputEvent& event)
{
std::cout << "Click on item: " << current_item << std::endl;
+
+ parent->release_mouse();
+ parent->show(false);
}
void
@@ -197,4 +202,12 @@
current_item = -1;
}
+void
+Menu::run()
+{
+ show(true);
+ capture_mouse();
+ raise();
+}
+
/* EOF */
Modified: trunk/src/menu.hxx
===================================================================
--- trunk/src/menu.hxx 2004-05-22 16:42:27 UTC (rev 348)
+++ trunk/src/menu.hxx 2004-05-22 18:10:43 UTC (rev 349)
@@ -38,7 +38,8 @@
MenuItemHandle add_item(const std::string& name);
MenuItemHandle add_submenu(const std::string& name, const Menu& submenu);
MenuItemHandle add_seperator();
-
+
+ void run();
private:
SharedPtr<MenuImpl> impl;
};
Added: trunk/src/menubar.cxx
===================================================================
--- trunk/src/menubar.cxx 2004-05-22 16:42:27 UTC (rev 348)
+++ trunk/src/menubar.cxx 2004-05-22 18:10:43 UTC (rev 349)
@@ -0,0 +1,53 @@
+// $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 "menu.hxx"
+#include "menubar.hxx"
+
+class MenubarItem
+{
+public:
+ MenubarItem(const std::string& name_, const Menu& menu_)
+ : name(name_), menu(menu_){}
+
+ std::string name;
+ Menu menu;
+};
+
+class MenubarImpl
+{
+public:
+ typedef std::vector<MenubarItem> Items;
+ Items items;
+};
+
+Menubar::Menubar(const CL_Point& pos, CL_Component* parent)
+ : CL_Component(CL_Rect(pos, CL_Size(1, 1)), parent),
+ impl(new MenubarImpl())
+{
+
+}
+
+void
+Menubar::add_submenu(const std::string& name, const Menu& menu)
+{
+ impl->items.push_back(MenubarItem(name, menu));
+}
+
+/* EOF */
Added: trunk/src/menubar.hxx
===================================================================
--- trunk/src/menubar.hxx 2004-05-22 16:42:27 UTC (rev 348)
+++ trunk/src/menubar.hxx 2004-05-22 18:10:43 UTC (rev 349)
@@ -0,0 +1,43 @@
+// $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_MENUBAR_HXX
+#define HEADER_MENUBAR_HXX
+
+#include <ClanLib/GUI/component.h>
+#include <ClanLib/Core/Math/rect.h>
+#include "shared_ptr.hxx"
+
+class Menu;
+class MenubarImpl;
+
+/** */
+class Menubar : public CL_Component
+{
+public:
+ Menubar(const CL_Point& pos, CL_Component* parent);
+
+ void add_submenu(const std::string& name, const Menu& menu);
+private:
+ SharedPtr<MenubarImpl> impl;
+};
+
+#endif
+
+/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Windstille-devel] rev 349 - trunk/src,
Ingo Ruhnke <=