pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3842 - in trunk/pingus: . src/gui


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3842 - in trunk/pingus: . src/gui
Date: Wed, 16 Jul 2008 21:04:41 +0200

Author: grumbel
Date: 2008-07-16 21:04:40 +0200 (Wed, 16 Jul 2008)
New Revision: 3842

Removed:
   trunk/pingus/src/gui/checkbox.cpp
   trunk/pingus/src/gui/checkbox.hpp
   trunk/pingus/src/gui/checkbox_listener.hpp
   trunk/pingus/src/gui/combobox.cpp
   trunk/pingus/src/gui/combobox.hpp
Modified:
   trunk/pingus/SConstruct
Log:
Unused code removed

Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2008-07-16 19:02:18 UTC (rev 3841)
+++ trunk/pingus/SConstruct     2008-07-16 19:04:40 UTC (rev 3842)
@@ -118,8 +118,6 @@
 'src/graphic_context_state.cpp', 
 'src/groundtype.cpp',
 'src/gui/component.cpp',
-'src/gui/checkbox.cpp',
-'src/gui/combobox.cpp', 
 'src/display/display.cpp', 
 'src/display/framebuffer_surface.cpp', 
 'src/display/sdl_framebuffer_surface_impl.cpp', 

Deleted: trunk/pingus/src/gui/checkbox.cpp
===================================================================
--- trunk/pingus/src/gui/checkbox.cpp   2008-07-16 19:02:18 UTC (rev 3841)
+++ trunk/pingus/src/gui/checkbox.cpp   2008-07-16 19:04:40 UTC (rev 3842)
@@ -1,65 +0,0 @@
-//  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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "checkbox.hpp"
-#include "../fonts.hpp"
-#include "../math/vector2i.hpp"
-#include "../resource.hpp"
-#include "../display/drawing_context.hpp"
-#include "../gui/checkbox_listener.hpp"
-
-
-namespace GUI {
-       
-Checkbox::Checkbox(Vector2i p, std::string label_, CheckboxListener* l) :
-  checkmark("core/misc/checkbox_clicked"),
-  is_checked(false),
-  pos(p),
-  width(20),
-  height(20),
-  listener(l),
-  label(label_)
-{
-}
-       
-void 
-Checkbox::draw(DrawingContext& gc)
-{
-  gc.draw_rect(Rect(pos.x, pos.y, pos.x + width, pos.y + height), 
-               Color(0,0,0));
-  if (is_checked)
-    gc.draw(checkmark, pos);
-       
-  gc.print_right(Fonts::pingus_small, pos, label);
-}
-
-bool
-Checkbox::is_at(int x, int y)
-{
-  return (x > pos.x && x < pos.x + width &&
-          y > pos.y && y < pos.y + height);
-}
-
-void 
-Checkbox::on_primary_button_click(int x, int y)
-{
-  is_checked = !is_checked;
-  listener->checkbox_changed(is_checked, this);
-}
-
-}      // GUI namespace
-
-/* EOF */

Deleted: trunk/pingus/src/gui/checkbox.hpp
===================================================================
--- trunk/pingus/src/gui/checkbox.hpp   2008-07-16 19:02:18 UTC (rev 3841)
+++ trunk/pingus/src/gui/checkbox.hpp   2008-07-16 19:04:40 UTC (rev 3842)
@@ -1,61 +0,0 @@
-//  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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_GUI_CHECKBOX_HPP
-#define HEADER_PINGUS_GUI_CHECKBOX_HPP
-
-#include "../gui/component.hpp"
-#include "../math/vector2i.hpp"
-#include "../sprite.hpp"
-
-       class DrawingContext;
-               
-namespace GUI {
-       
-       class CheckboxListener;         
-
-class Checkbox : public GUI::Component
-{
-private:
-       Sprite box;
-       Sprite checkmark;
-
-       bool is_checked;
-       Vector2i pos;
-
-       int width;
-       int height;
-       
-       CheckboxListener* listener;
-       std::string label;
-
-public:
-       Checkbox(Vector2i 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
-
-#endif
-
-/* EOF */

Deleted: trunk/pingus/src/gui/checkbox_listener.hpp
===================================================================
--- trunk/pingus/src/gui/checkbox_listener.hpp  2008-07-16 19:02:18 UTC (rev 
3841)
+++ trunk/pingus/src/gui/checkbox_listener.hpp  2008-07-16 19:04:40 UTC (rev 
3842)
@@ -1,35 +0,0 @@
-//  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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_GUI_CHECKBOX_LISTENER_HPP
-#define HEADER_PINGUS_GUI_CHECKBOX_LISTENER_HPP
-
-
-namespace GUI {
-       
-       class Checkbox;
-
-class CheckboxListener {
-public:
-       virtual void checkbox_changed(bool new_value, Checkbox* box) = 0;
-       virtual ~CheckboxListener() { }
-};     // CheckboxListener class
-
-}      // GUI namespace
-
-#endif
-
-/* EOF */

Deleted: trunk/pingus/src/gui/combobox.cpp
===================================================================
--- trunk/pingus/src/gui/combobox.cpp   2008-07-16 19:02:18 UTC (rev 3841)
+++ trunk/pingus/src/gui/combobox.cpp   2008-07-16 19:04:40 UTC (rev 3842)
@@ -1,174 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2007 Jason Green <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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include <vector>
-#include <string>
-#include "combobox.hpp"
-#include "combobox_listener.hpp"
-#include "../fonts.hpp"
-
-namespace GUI {
-
-// Constructor
-Combobox::Combobox (Vector2i p, ComboboxListener* listener_, std::string l) :
-  current_item(0),
-  drop_down(false),
-  hover(false),
-  pos(p),
-  enabled(false),
-  label(l),
-  listener(listener_)
-{
-  // Default to 20 characters wide.
-  width = Fonts::pingus_small.get_width('O') * 20;
-  height = Fonts::pingus_small.get_height();
-}
-
-// Destructor
-Combobox::~Combobox ()
-{
-  clear();
-}
-
-// Add an item to the combobox
-void
-Combobox::add(ComboItem* item)
-{
-  item_list.push_back(item);
-}
-
-// Remove an item from the combobox.  Delete it if necessary
-void
-Combobox::remove(ComboItem* item)
-{
-  for (std::vector<ComboItem*>::iterator i = item_list.begin();
-       i != item_list.end(); i++)
-    {
-      if ((*i) == item)
-        {
-          item_list.erase(i);
-          if (item->delete_it())
-            delete item;
-        }
-    }
-}
-
-// Remove all items from this combobox
-void
-Combobox::clear()
-{
-  for (std::vector<ComboItem*>::iterator i = item_list.begin();
-       i != item_list.end(); i++)
-    {
-      if ((*i)->delete_it())
-        delete (*i);
-    }
-  item_list.clear();
-  current_item = 0;
-  drop_down = false;
-}
-
-// Returns whether or not the combobox is at this location
-bool
-Combobox::is_at(int x, int y)
-{
-  if (enabled)
-    return (x > pos.x && x < pos.x + get_width() &&
-            y > pos.y && y < pos.y + get_height());
-  else
-    return false;
-}
-
-// Returns the width of the box
-int
-Combobox::get_width()
-{
-  return width;
-}
-
-// Returns the height of the box
-int
-Combobox::get_height()
-{
-  if (drop_down)
-    return height * (item_list.size() + 1);
-  else
-    return height;
-}
-
-// action taken when the primary mouse button is clicked
-void
-Combobox::on_primary_button_click(int x, int y)
-{
-  if (drop_down)
-    {
-      // Determine which item was selected, if any, and set the current item 
to it.
-      drop_down = false;
-      if (y > pos.y + height)
-        {
-          current_item = item_list[(y - pos.y - height) / height];
-          listener->combobox_changed(this);
-        }
-    }
-  else
-    {
-      drop_down = true;
-    }
-}
-
-// Draws the Combobox on the screen at it's location
-void
-Combobox::draw(DrawingContext &gc)
-{
-  if (!enabled)
-    return;
-       
-  // Draw the label
-  gc.print_right(Fonts::pingus_small, pos, label);
-
-  // Draw the rectangle
-  gc.draw_fillrect(Rect(pos.x, pos.y, pos.x + get_width(), pos.y + 
get_height()),
-                   Color(255,255,255));
-
-  // Next, draw the rectangle border
-  gc.draw_rect(Rect(pos.x, pos.y, pos.x + get_width(), pos.y + get_height()),
-               Color(0,0,0));
-
-  if (drop_down && item_list.size() > 0)
-    {
-      // Draw the highlighted box
-      int y_offset = (((mouse_pos.y - pos.y - height)/height)+1) * height;
-      gc.draw_fillrect(Rect(pos.x, pos.y + y_offset, pos.x + get_width(), 
pos.y + y_offset + height),
-                       Color(128,128,128));
-               
-      // Draw all of the items
-      for (unsigned i = 0; i < item_list.size(); i++)
-        {
-          gc.print_left(Fonts::pingus_small, Vector2i(pos.x + 5, pos.y + ((i + 
1) * height)), 
-                        item_list[i]->get_displayed_string());
-        }
-    }
-
-  if (current_item)
-    {
-      // Print the currently selected item
-      gc.print_left(Fonts::pingus_small, Vector2i(pos.x + 3, pos.y), 
current_item->get_displayed_string());
-    }
-}
-
-} // namespace GUI 
-
-/* EOF */

Deleted: trunk/pingus/src/gui/combobox.hpp
===================================================================
--- trunk/pingus/src/gui/combobox.hpp   2008-07-16 19:02:18 UTC (rev 3841)
+++ trunk/pingus/src/gui/combobox.hpp   2008-07-16 19:04:40 UTC (rev 3842)
@@ -1,180 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2007 Jason Green <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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_GUI_COMBOBOX_HPP
-#define HEADER_PINGUS_GUI_COMBOBOX_HPP
-
-#include <vector>
-#include <string>
-#include "component.hpp"
-#include "../math/vector2i.hpp"
-
-namespace GUI {
-      
-class ComboboxListener;
-
-/** A ComboItems holds a specific item in a Combobox (string, id, etc.) */
-class ComboItem
-{
-protected:
-  /* The item's hidden ID field */
-  std::string id;
-
-  /** string that displays when printed on the Combobox */
-  std::string str;
-
-  /** Should this item be deleted when the Combobox dies? */
-  bool delete_item;
-
-public:
-  /** Constructors */
-  ComboItem () { delete_item = true; }
-  ComboItem (std::string id_, std::string displayed_string, bool d = true) 
-    : id(id_), str(displayed_string), delete_item(d) 
-  { 
-  }
-
-  virtual ~ComboItem () { }
-
-  /** Returns this item's ID */
-  std::string get_id() { return id; }
-
-  /** Returns this item's string */
-  std::string get_displayed_string() { return str; }
-
-  /** Returns the value of del_item */
-  bool delete_it() { return delete_item; }
-
-  /** Set this item's ID */
-  void set_id(std::string s) { id = s; }
-
-  /** Set this item's string */
-  void set_displayed_string(std::string s) { str = s; }
-
-private:
-  ComboItem (const ComboItem&);
-  ComboItem& operator= (const ComboItem&);
-};     // ComboItem class
-
-
-
-/** The Combobox class gives you a drop-down list of items to choose from. */
-class Combobox : public Component
-{
-protected:
-  /** List of items in this Combobox */
-  std::vector<ComboItem*> item_list;
-
-  /** The currently selected item in the list */
-  ComboItem* current_item;
-
-  /** Whether or not the list is showing right now */
-  bool drop_down;
-
-  /** Is the mouse hovering over this object? */
-  bool hover;
-
-  /** Where the mouse is located */
-  Vector2i mouse_pos;
-
-  /** Width of the Combobox */
-  int width;
-
-  /** Height of EACH ITEM in the Combobox.  So, when drop_down is false, this
-      should be the height of the entire widget/component.  When drop_down is 
-      true, the entire widget's height should be this height times the number 
of
-      items */
-  int height;
-
-  /** Location of the Combobox */
-  Vector2i pos;
-
-  /** Whether or not this combobox is enabled */
-  bool enabled;
-       
-  /** Label that prints to the left of the drop-down */
-  std::string label;
-       
-  /** The "owner" of this combobox */
-  ComboboxListener* listener;
-
-public:
-  /** Constructor */
-  Combobox (Vector2i p, ComboboxListener* listener, std::string label = 
std::string());
-       
-  /** Destructor */
-  virtual ~Combobox ();
-
-  /** Add an item to the list. 
-      @param del_item Set to true if you want this Combobox to delete the 
-      ComboItem when it's destroyed */
-  virtual void add(ComboItem* item);
-
-  /** Remove an item from the list */
-  virtual void remove(ComboItem* item);
-
-  /** Clears all items from combobox */
-  virtual void clear();
-
-  /** Return a pointer to the selected item.  Returns 0 if nothing is selected 
*/
-  ComboItem* get_selected_item() { return current_item; }
-
-  /** Sets the selected item to the given ComboItem.  Returns false if that 
item
-      doesn't exist */
-  bool set_selected_item(ComboItem*);
-
-  /** Draw this Combobox and all of it's items if selected */
-  virtual void draw (DrawingContext& gc);
-
-  /** Tells the gui_manager if the mouse is on top of the Combobox */
-  virtual bool is_at (int x, int y);
-
-  /** Returns the height of the Combobox at this given moment.  Will be tall 
if 
-      drop_down = true, and short if drop_down = false */
-  virtual int get_height();
-
-  /** Returns the width of the Combobox */
-  virtual int get_width();
-
-  /** Gets emmited when a button is pressed and released over the
-      same component */
-  virtual void on_primary_button_click (int x, int y);
-       
-  virtual void on_pointer_enter() { hover = true; }
-  virtual void on_pointer_leave() { hover = false; }
-  virtual void on_pointer_move(int x, int y) { mouse_pos = Vector2i(x, y); }
-       
-  /** Sets whether or not this combobox is clickable */
-  virtual void set_enabled(bool e) { enabled = e; }
-       
-  /** Returns whether or not the combobox is enabled */
-  virtual bool is_enabled() { return enabled; }
-       
-  /** Sets the label */
-  virtual void set_label(std::string l) { label = l; }
-
-private:
-  Combobox();
-  Combobox (const Combobox&);
-  Combobox& operator= (const Combobox&);
-
-};
-
-} // namespace GUI 
-
-#endif
-
-/* EOF */





reply via email to

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