pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r2595 - in trunk/src: editor gui


From: jave27
Subject: [Pingus-CVS] r2595 - in trunk/src: editor gui
Date: Mon, 16 Jan 2006 06:01:46 +0100

Author: jave27
Date: 2006-01-16 06:01:38 +0100 (Mon, 16 Jan 2006)
New Revision: 2595

Added:
   trunk/src/gui/checkbox.cxx
   trunk/src/gui/checkbox.hxx
   trunk/src/gui/checkbox_listener.hxx
Modified:
   trunk/src/editor/editor_panel.cxx
Log:
Actually added the checkbox files this time, plus added one to the 
editor panel.



Modified: trunk/src/editor/editor_panel.cxx
===================================================================
--- trunk/src/editor/editor_panel.cxx   2006-01-16 04:46:29 UTC (rev 2594)
+++ trunk/src/editor/editor_panel.cxx   2006-01-16 05:01:38 UTC (rev 2595)
@@ -65,7 +65,11 @@
        add((PanelButton*)(new PanelButtonSave(this)));
        add((PanelButton*)(new PanelButtonGroundpiece(this)));
 
-       // Create Combobox
+       // Create Checkboxes
+       snap_to_checkbox = new GUI::Checkbox(Vector(400, 0), "Snap To Grid: ", 
this);
+       get_screen()->get_gui_manager()->add(snap_to_checkbox);
+       
+       // Create Comboboxes
        combobox_1 = new GUI::Combobox(Vector(500,  0));
        combobox_2 = new GUI::Combobox(Vector(500, 30));
        get_screen()->get_gui_manager()->add(combobox_1);

Added: trunk/src/gui/checkbox.cxx
===================================================================
--- trunk/src/gui/checkbox.cxx  2006-01-16 04:46:29 UTC (rev 2594)
+++ trunk/src/gui/checkbox.cxx  2006-01-16 05:01:38 UTC (rev 2595)
@@ -0,0 +1,69 @@
+//  $Id: checkbox.cxx,v 1.00 2006/1/15 23:41:12 Jave27 Exp $
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2006 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 <ClanLib/Display/sprite.h>
+#include "checkbox.hxx"
+#include "../fonts.hxx"
+#include "../vector.hxx"
+#include "../resource.hxx"
+#include "../display/drawing_context.hxx"
+#include "../gui/checkbox_listener.hxx"
+
+namespace Pingus {
+
+namespace GUI {
+       
+Checkbox::Checkbox(Vector p, std::string label_, CheckboxListener* l) :
+       box(Resource::load_sprite("core/start/ok")),
+       checkmark(Resource::load_sprite("core/start/ok_clicked")),
+       is_checked(false),
+       pos(p),
+       listener(l),
+       label(label_)
+{
+}
+       
+void 
+Checkbox::draw(DrawingContext& gc)
+{
+       gc.draw(box, pos);
+       if (is_checked)
+               gc.draw(checkmark, pos);
+       
+       gc.print_right(Fonts::pingus_small, (int)pos.x, (int)pos.y, label);
+}
+
+bool
+Checkbox::is_at(int x, int y)
+{
+       return (x > pos.x && x < pos.x + box.get_width() &&
+               y > pos.y && y < pos.y + box.get_height());
+}
+
+void 
+Checkbox::on_primary_button_click(int x, int y)
+{
+       is_checked = !is_checked;
+       listener->checkbox_changed(is_checked, this);
+}
+
+}      // GUI namespace
+}      // Pingus namespace
+
+/* EOF */

Added: trunk/src/gui/checkbox.hxx
===================================================================
--- trunk/src/gui/checkbox.hxx  2006-01-16 04:46:29 UTC (rev 2594)
+++ trunk/src/gui/checkbox.hxx  2006-01-16 05:01:38 UTC (rev 2595)
@@ -0,0 +1,63 @@
+//  $Id: checkbox.hxx,v 1.00 2006/1/15 23:41:12 Jave27 Exp $
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2006 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_PINGUS_GUI_CHECKBOX_HXX
+#define HEADER_PINGUS_GUI_CHECKBOX_HXX
+
+#include "../gui/component.hxx"
+#include "../vector.hxx"
+
+namespace Pingus {
+
+       class DrawingContext;
+               
+namespace GUI {
+       
+       class CheckboxListener;         
+
+class Checkbox : public GUI::Component
+{
+private:
+       CL_Sprite box;
+       CL_Sprite checkmark;
+
+       bool    is_checked;
+       Vector pos;
+       
+       CheckboxListener* listener;
+       std::string label;
+
+public:
+       Checkbox(Vector p, std::string label_, CheckboxListener* l);
+
+       void draw(DrawingContext& gc);
+       bool is_at(int x, int y);
+       void on_primary_button_click(int x, int y);
+       void set_checkmark(bool check) { is_checked = check; }
+       
+private:
+       Checkbox();
+};     // Checkbox class
+
+}      // GUI namespace
+}      // Pingus namespace
+
+#endif
+
+/* EOF */

Added: trunk/src/gui/checkbox_listener.hxx
===================================================================
--- trunk/src/gui/checkbox_listener.hxx 2006-01-16 04:46:29 UTC (rev 2594)
+++ trunk/src/gui/checkbox_listener.hxx 2006-01-16 05:01:38 UTC (rev 2595)
@@ -0,0 +1,40 @@
+//  $Id: checkbox_listener.hxx,v 1.00 2006/1/15 23:41:12 Jave27 Exp $
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2006 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_PINGUS_GUI_CHECKBOX_LISTENER_HXX
+#define HEADER_PINGUS_GUI_CHECKBOX_LISTENER_HXX
+
+namespace Pingus {
+
+namespace GUI {
+       
+       class Checkbox;
+
+class CheckboxListener {
+public:
+       virtual void checkbox_changed(bool new_value, Checkbox* box) = 0;
+       virtual ~CheckboxListener() { }
+};     // CheckboxListener class
+
+}      // GUI namespace
+}      // Pingus namespace
+
+#endif
+
+/* EOF */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]