netpanzer-cvs
[Top][All Lists]
Advanced

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

[netPanzer-CVS] netpanzer/src/Lib/View Button.cpp CheckBox.cpp ...


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer/src/Lib/View Button.cpp CheckBox.cpp ...
Date: Tue, 16 Sep 2003 12:00:17 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/09/16 12:00:17

Modified files:
        src/Lib/View   : Button.cpp CheckBox.cpp CheckBox.hpp Choice.cpp 
                         Choice.hpp Component.hpp Icon.hpp 
                         MouseEvent.hpp View.hpp 
Removed files:
        src/Lib/View   : Dialog.cpp Dialog.hpp FileDialog.cpp 
                         FileDialog.hpp Window.cpp Window.hpp 

Log message:
        removed some unused files

Patches:
Index: netpanzer/src/Lib/View/Button.cpp
diff -u netpanzer/src/Lib/View/Button.cpp:1.3 
netpanzer/src/Lib/View/Button.cpp:1.4
--- netpanzer/src/Lib/View/Button.cpp:1.3       Fri Sep  5 22:01:18 2003
+++ netpanzer/src/Lib/View/Button.cpp   Tue Sep 16 12:00:16 2003
@@ -15,9 +15,8 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-
-
 #include <config.h>
+
 #include "Button.hpp"
 #include "ViewGlobals.hpp"
 #include "MouseEvent.hpp"
Index: netpanzer/src/Lib/View/CheckBox.cpp
diff -u netpanzer/src/Lib/View/CheckBox.cpp:1.3 
netpanzer/src/Lib/View/CheckBox.cpp:1.4
--- netpanzer/src/Lib/View/CheckBox.cpp:1.3     Fri Sep  5 22:01:18 2003
+++ netpanzer/src/Lib/View/CheckBox.cpp Tue Sep 16 12:00:17 2003
@@ -15,22 +15,11 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-
-
 #include <config.h>
+
 #include "CheckBox.hpp"
 #include "MouseEvent.hpp"
-
-
-// reset
-//---------------------------------------------------------------------------
-void CheckBox::reset()
-{
-       label = "";
-       state = false;
-       size  = 14;
-
-} // end CheckBox::reset
+#include "StateChangedCallback.hpp"
 
 // draw
 //---------------------------------------------------------------------------
@@ -110,6 +99,8 @@
                        (me.getModifiers() & InputEvent::BUTTON1_MASK))
        {
                state = !state;
+               if(callback)
+                       callback->stateChanged(this);
        }
 
 } // end CheckBox::actionPerformed
Index: netpanzer/src/Lib/View/CheckBox.hpp
diff -u netpanzer/src/Lib/View/CheckBox.hpp:1.1 
netpanzer/src/Lib/View/CheckBox.hpp:1.2
--- netpanzer/src/Lib/View/CheckBox.hpp:1.1     Sun Dec  1 12:51:46 2002
+++ netpanzer/src/Lib/View/CheckBox.hpp Tue Sep 16 12:00:17 2003
@@ -19,15 +19,10 @@
 #ifndef __CheckBox_hpp__
 #define __CheckBox_hpp__
 
-
-#if _MSC_VER > 1000
-       #pragma once
-#endif
-
-
 #include "Component.hpp"
 #include "MouseEvent.hpp"
 
+class StateChangedCallback;
 
 //--------------------------------------------------------------------------
 class CheckBox : public Component
@@ -35,45 +30,42 @@
 protected:
        String label;
        bool   state;
+       StateChangedCallback* callback;
 
        virtual void drawCheckBox(const Surface &dest);
        virtual void drawCheck(const Surface &dest);
        virtual void drawLabel(const Surface &dest);
 
 public:
-       CheckBox() : Component()
+       CheckBox(StateChangedCallback* newcallback = 0) 
+               : Component(), state(false), callback(newcallback)
        {
-               reset();
+               size = 14;
        }
 
-       CheckBox(const String &label) : Component()
+       CheckBox(const String &newlabel, bool newstate = false) 
+               : Component(), label(newlabel), state(newstate), callback(0)
        {
-               reset();
-
-               CheckBox::label = label;
+               size = 14;
        }
 
-       CheckBox(const String &label, bool state) : Component()
-       {
-               reset();
+       virtual ~CheckBox()
+       { }
 
-               CheckBox::label = label;
-               CheckBox::state = state;
-       }
-
-       virtual ~CheckBox() {}
-
-       void reset();
-
-       String getLabel() { return label; }
-       bool   getState() { return state; }
-
-       void setLabel(String label) { CheckBox::label = label; }
-       void setState(bool state) { CheckBox::state = state; }
+       String getLabel() const
+       { return label; }
+       bool   getState() const
+       { return state; }
+       
+       void setLabel(String label)
+       { CheckBox::label = label; }
+       void setState(bool state)
+       { CheckBox::state = state; }
+       void setStateChangedCallback(StateChangedCallback* newcallback)
+       { callback = newcallback; }
 
        virtual void draw(const Surface &dest);
        virtual void actionPerformed(const mMouseEvent &me);
-
 }; // end CheckBox
 
 #endif // end __CheckBox_hpp__
Index: netpanzer/src/Lib/View/Choice.cpp
diff -u netpanzer/src/Lib/View/Choice.cpp:1.4 
netpanzer/src/Lib/View/Choice.cpp:1.5
--- netpanzer/src/Lib/View/Choice.cpp:1.4       Tue Sep  9 13:16:13 2003
+++ netpanzer/src/Lib/View/Choice.cpp   Tue Sep 16 12:00:17 2003
@@ -20,6 +20,7 @@
 #include <algorithm>
 #include "Choice.hpp"
 #include "View.hpp"
+#include "StateChangedCallback.hpp"
 
 //---------------------------------------------------------------------------
 void Choice::reset()
@@ -29,6 +30,7 @@
        size.x    = 10;
        size.y    = ChoiceItemHeight;
        isOpen    = 0;
+       mouseover = 0;
        adjustedY = 0;
 }
 
@@ -107,7 +109,12 @@
        {
                if (strcmp((const char *) item, (const char *) choiceList[i]) 
== 0)
                {
+                       if(index == i)
+                               return;
+
                        index = i;
+                       if(callback)
+                               callback->stateChanged(this);
                        
                        return;
                }
@@ -117,7 +124,14 @@
 //---------------------------------------------------------------------------
 void Choice::select(int index)
 {
+       assert(index >= 0 && index < choiceList.getCount());
+
+       if(index == Choice::index)
+               return;
+       
        Choice::index = index;
+       if(callback)
+               callback->stateChanged(this);
 }
 
 //---------------------------------------------------------------------------
@@ -172,7 +186,7 @@
                        // Find the selected item.
                        if (r.contains(iXY(me.getX(), me.getY())))
                        {
-                               index = i;
+                               mouseover = i;
                                break;
                        }
 
@@ -193,6 +207,14 @@
                min.y += adjustedY;
                adjustedY = 0;
 
+               // set new element
+               if(mouseover == index)
+                       return;
+                                                                       
+               index = mouseover;
+               if(callback)
+                       callback->stateChanged(this);                           
+
                // Since an item was selected, find which item was selected.
                assert(min + size < parentDimensions);
        }
@@ -208,6 +230,15 @@
                // Move the choice back to its original location.
                min.y += adjustedY;
                adjustedY = 0;
+
+               // set new element
+               if(mouseover == index)
+                       return;
+                                                                       
+               index = mouseover;
+               if(callback)
+                       callback->stateChanged(this);                           
+               
                assert(min + size < parentDimensions);
        }
 
@@ -241,11 +272,9 @@
        s.drawRect(iRect(1, 1, s.getPixX() - 1, s.getPixY() - 1), Color::white);
        s.fillRect(iRect(1, 1, s.getPixX() - 2, s.getPixY() - 2), 
Color::terreVerte);
 
-       if (!isOpen)
-       {
+       if (!isOpen)    {
                s.bltStringShadowedCenter(choiceList[index], Color::white, 
Color::black);
-       } else
-       {
+       } else {
                r = iRect(min.x, min.y, min.x + size.x, min.y + 
ChoiceItemHeight);
                
                int count = choiceList.getCount();
@@ -254,7 +283,7 @@
                {
                        s.setTo(dest, r);
 
-                       if (i == index)
+                       if (i == mouseover)
                        {
                                // Higlight the selected item.
                                s.fill(Color::white);
Index: netpanzer/src/Lib/View/Choice.hpp
diff -u netpanzer/src/Lib/View/Choice.hpp:1.1 
netpanzer/src/Lib/View/Choice.hpp:1.2
--- netpanzer/src/Lib/View/Choice.hpp:1.1       Sun Dec  1 12:51:46 2002
+++ netpanzer/src/Lib/View/Choice.hpp   Tue Sep 16 12:00:17 2003
@@ -15,20 +15,14 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-
 #ifndef __Choice_hpp__
 #define __Choice_hpp__
 
-
-#if _MSC_VER > 1000
-       #pragma once
-#endif
-
-
 #include "Component.hpp"
 #include "cGrowList.hpp"
 #include "MouseEvent.hpp"
 
+class StateChangedCallback;
 
 //--------------------------------------------------------------------------
 class Choice : public Component
@@ -37,25 +31,29 @@
        cGrowList <String> choiceList;
        int                index;
        int                minWidth;
-       int                isOpen;
+       bool               isOpen;
+       int                                mouseover;
        int                adjustedY;  // The y translation value to keep the 
choice on the screen.
+       StateChangedCallback* callback;
 
        enum { ChoiceItemHeight = 14 };
 
 public:
-       Choice()
+       Choice(StateChangedCallback* newcallback = 0)
+               : callback(newcallback)
        {
                reset();
        }
        virtual ~Choice() {}
 
-       void   reset();
        void   add(const String &item);
        void   addItem(const String &item);
        void   addItemDefault(const String &item);
        void   copyItems(const Choice &choice);
-       int    getItemCount() const { return choiceList.getCount(); }
-       int    getSelectedIndex() const { return index; }
+       int    getItemCount() const
+       { return choiceList.getCount(); }
+       int    getSelectedIndex() const
+       { return index; }
        void   insert(String item, int index);
        String paramString() { return String(); }
        void   remove(String item);
@@ -64,10 +62,15 @@
        void   select(const String &item);
        void   select(int index);
        void   setMinWidth(int minWidth);
-       
+
+       void setStateChangedCallback(StateChangedCallback* newcallback)
+       { callback = newcallback; }
+
        virtual void draw(const Surface &dest);
        virtual void actionPerformed(const mMouseEvent &me);
 
+private:
+       void reset();
 }; // end Choice
 
 #endif // end __Choice_hpp__
Index: netpanzer/src/Lib/View/Component.hpp
diff -u netpanzer/src/Lib/View/Component.hpp:1.2 
netpanzer/src/Lib/View/Component.hpp:1.3
--- netpanzer/src/Lib/View/Component.hpp:1.2    Mon Sep  1 16:24:19 2003
+++ netpanzer/src/Lib/View/Component.hpp        Tue Sep 16 12:00:17 2003
@@ -15,31 +15,22 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-
 #ifndef __Component_hpp__
 #define __Component_hpp__
 
-
-#if _MSC_VER > 1000
-       #pragma once
-#endif
-
-
 #include "Cursor.hpp"
 #include "Color.hpp"
 #include "Surface.hpp"
 #include "iXY.hpp"
 #include "iRect.hpp"
 #include "String.hpp"
+#include "NoCopy.hpp"
 
 class mMouseEvent;
 
-
 //--------------------------------------------------------------------------
-class Component
+class Component : public NoCopy
 {
-       //virtual copy() {}
-
 protected:
        BYTE    background;
        BYTE    foreground;
@@ -80,13 +71,6 @@
        {
                reset();
        }
-       Component(const Component &)
-       {
-               
-       }
-
-       //const Component &operator=(const Component &)
-
        virtual ~Component() {}
 
        // Accessor functions.
@@ -109,8 +93,6 @@
        inline        bool     isEnabled() const { return enabled; }
        //const bool &isValid() {}
        inline        bool     isVisible() const { return visible; }
-
-       void processEvent() {}
 
        void setBackground(BYTE color) {}
        void setBounds(const iRect &r)
Index: netpanzer/src/Lib/View/Icon.hpp
diff -u netpanzer/src/Lib/View/Icon.hpp:1.1 netpanzer/src/Lib/View/Icon.hpp:1.2
--- netpanzer/src/Lib/View/Icon.hpp:1.1 Sun Dec  1 12:51:46 2002
+++ netpanzer/src/Lib/View/Icon.hpp     Tue Sep 16 12:00:17 2003
@@ -15,19 +15,11 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-
 #ifndef __Icon_hpp__
 #define __Icon_hpp__
 
-
-#if _MSC_VER > 1000
-       #pragma once
-#endif
-
-
 #include "String.hpp"
 #include "Surface.hpp"
-
 
 //--------------------------------------------------------------------------
 class Icon : public Surface
Index: netpanzer/src/Lib/View/MouseEvent.hpp
diff -u netpanzer/src/Lib/View/MouseEvent.hpp:1.2 
netpanzer/src/Lib/View/MouseEvent.hpp:1.3
--- netpanzer/src/Lib/View/MouseEvent.hpp:1.2   Mon Sep  1 16:24:20 2003
+++ netpanzer/src/Lib/View/MouseEvent.hpp       Tue Sep 16 12:00:17 2003
@@ -15,21 +15,12 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-
 #ifndef __mMouseEvent_hpp__
 #define __mMouseEvent_hpp__
 
-
-#if _MSC_VER > 1000
-       #pragma once
-#endif
-
-
-
 #include "Component.hpp"
 #include "iXY.hpp"
 #include "InputEvent.hpp"
-
 
 class mMouseEvent : public InputEvent
 {
Index: netpanzer/src/Lib/View/View.hpp
diff -u netpanzer/src/Lib/View/View.hpp:1.2 netpanzer/src/Lib/View/View.hpp:1.3
--- netpanzer/src/Lib/View/View.hpp:1.2 Mon Sep  1 16:24:20 2003
+++ netpanzer/src/Lib/View/View.hpp     Tue Sep 16 12:00:17 2003
@@ -20,13 +20,6 @@
 #ifndef __View_hpp__
 #define __View_hpp__
 
-
-#if _MSC_VER > 1000
-       #pragma once
-#endif
-
-
-
 #include "cMouse.hpp"
 #include "cGrowList.hpp"
 #include "cButton.hpp"




reply via email to

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