pingus-cvs
[Top][All Lists]
Advanced

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

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


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

Author: grumbel
Date: 2008-07-16 21:08:16 +0200 (Wed, 16 Jul 2008)
New Revision: 3843

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

Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2008-07-16 19:04:40 UTC (rev 3842)
+++ trunk/pingus/SConstruct     2008-07-16 19:08:16 UTC (rev 3843)
@@ -126,7 +126,6 @@
 'src/display/rect_merger.cpp',
 'src/gui/group_component.cpp', 
 'src/gui/gui_manager.cpp', 
-'src/gui/input_box.cpp', 
 'src/gui/surface_button.cpp',
 'src/screen/gui_screen.cpp', 
 'src/screen/screen.cpp', 

Deleted: trunk/pingus/src/gui/input_box.cpp
===================================================================
--- trunk/pingus/src/gui/input_box.cpp  2008-07-16 19:04:40 UTC (rev 3842)
+++ trunk/pingus/src/gui/input_box.cpp  2008-07-16 19:08:16 UTC (rev 3843)
@@ -1,103 +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 <algorithm>
-#include "input_box.hpp"
-#include "../display/drawing_context.hpp"
-#include "../math/vector2i.hpp"
-#include "../fonts.hpp"
-
-namespace GUI {
-      
-InputBox::InputBox(int width_, Vector2i p, const std::string& default_value,
-                   bool locked, const std::string& label_) 
-  :    str(default_value),
-       pos(p),
-       width(width_),
-       height(Fonts::pingus_small.get_height()),
-       is_locked(locked),
-       label(label_)
-{
-}
-
-void
-InputBox::draw(DrawingContext &gc)
-{
-  // Draw the rectangle and border
-  gc.draw_fillrect(Rect(pos.x, pos.y, pos.x + width, pos.y + height), 
-                   Color(0,0,0));
-  gc.draw_rect(Rect(pos.x, pos.y, pos.x + width, pos.y + height), 
Color(255,255,255)); 
-
-  // If there is text, draw it:
-  if (str != std::string())
-    gc.print_left(Fonts::pingus_small, Vector2i(pos.x + 10, pos.y), 
shrink_string(str));
-
-  if (label != std::string())
-    gc.print_right(Fonts::pingus_small, pos, label);
-     
-  if (has_focus())
-    gc.draw_line(Vector2i(pos.x + 
Fonts::pingus_small.get_size(shrink_string(str)).width + 12,
-                          pos.y), 
-                 Vector2i(pos.x + 
Fonts::pingus_small.get_size(shrink_string(str)).width + 12, 
-                          pos.y + height),
-                 Color(0,255,255));
-}
-
-bool
-InputBox::is_at(int x, int y)
-{
-  return (x > pos.x && x < pos.x + width &&
-          y > pos.y && y < pos.y + height);
-}
-
-std::string
-InputBox::shrink_string(const std::string& s) const
-{
-  std::string ret_string;
-  int w = (int)width / Fonts::pingus_small.get_width('W');
-       
-  if ((int)s.length() > w - 1)
-    ret_string = s.substr(std::max(0, (int)s.length()-w), w - 1);
-  else
-    ret_string = s;
-       
-  return ret_string;
-}
-
-void
-InputBox::on_key_pressed(const unsigned short c)
-{
-  if (!is_locked)
-    {
-      // Verify input and escape out bad characters
-      if (c == 0x08)   // backspace
-        {
-          str = str.substr(0, str.length()-1);
-        }
-      else if ((c > 0x2c && c < 0x3a)    // - . / 0-9
-               || (c > 0x40 && c < 0x5b)        // capital letters
-               || (c > 0x60 && c < 0x7b)        // lowercase letters
-               || (c == 0x7e || c == 0x5f)      // ~ and _
-               ||  c == 0x20)                   // space
-        {
-          str += (unsigned char)c;
-        }
-    }
-}
-
-} // namespace GUI
-
-/* EOF */

Deleted: trunk/pingus/src/gui/input_box.hpp
===================================================================
--- trunk/pingus/src/gui/input_box.hpp  2008-07-16 19:04:40 UTC (rev 3842)
+++ trunk/pingus/src/gui/input_box.hpp  2008-07-16 19:08:16 UTC (rev 3843)
@@ -1,66 +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_INPUTBOX_HPP
-#define HEADER_PINGUS_GUI_INPUTBOX_HPP
-
-#include "component.hpp"
-#include "../math/vector2i.hpp"
-#include <string>
-
-class DrawingContext;
-
-namespace GUI {
-
-/** This class allows keyboard input to be displayed in a box */
-class InputBox : public GUI::Component {
-protected:
-  std::string str;
-  Vector2i pos;
-  int width;
-  int height;
-  bool  is_locked;
-
-  /** Shrink the string to fit in the box */
-  std::string shrink_string(const std::string& s) const;
-  
-  /** Optional label to display */
-  std::string label;  
-
-public:
-  InputBox(int width_, Vector2i p, const std::string& 
-           default_value = std::string(), bool locked = false,
-           const std::string& label_ = std::string());
-
-  void set_string(const std::string& s) { str = s; }
-  std::string get_string() { return str; }
-       
-  void on_key_pressed(const unsigned short c);
-       
-  /// GUI Component functions:
-  ///
-  void update(float delta) { }
-       
-  bool is_at(int x, int y);
-       
-  void draw(DrawingContext &gc);
-};     // InputBox class
-
-} // namespace GUI
-
-#endif
-
-/* EOF */





reply via email to

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