diff options
Diffstat (limited to 'src/guichan/widgets')
-rw-r--r-- | src/guichan/widgets/button.hpp | 220 | ||||
-rw-r--r-- | src/guichan/widgets/checkbox.hpp | 173 | ||||
-rw-r--r-- | src/guichan/widgets/container.hpp | 162 | ||||
-rw-r--r-- | src/guichan/widgets/dropdown.hpp | 325 | ||||
-rw-r--r-- | src/guichan/widgets/icon.hpp | 118 | ||||
-rw-r--r-- | src/guichan/widgets/imagebutton.hpp | 123 | ||||
-rw-r--r-- | src/guichan/widgets/label.hpp | 133 | ||||
-rw-r--r-- | src/guichan/widgets/listbox.hpp | 253 | ||||
-rw-r--r-- | src/guichan/widgets/radiobutton.hpp | 211 | ||||
-rw-r--r-- | src/guichan/widgets/scrollarea.hpp | 590 | ||||
-rw-r--r-- | src/guichan/widgets/slider.hpp | 300 | ||||
-rw-r--r-- | src/guichan/widgets/tab.hpp | 157 | ||||
-rw-r--r-- | src/guichan/widgets/tabbedarea.hpp | 280 | ||||
-rw-r--r-- | src/guichan/widgets/textbox.hpp | 289 | ||||
-rw-r--r-- | src/guichan/widgets/textfield.hpp | 177 | ||||
-rw-r--r-- | src/guichan/widgets/window.hpp | 261 |
16 files changed, 0 insertions, 3772 deletions
diff --git a/src/guichan/widgets/button.hpp b/src/guichan/widgets/button.hpp deleted file mode 100644 index 05b961b1e..000000000 --- a/src/guichan/widgets/button.hpp +++ /dev/null @@ -1,220 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_BUTTON_HPP -#define GCN_BUTTON_HPP - -#include <string> - -#include "guichan/focuslistener.hpp" -#include "guichan/graphics.hpp" -#include "guichan/keylistener.hpp" -#include "guichan/mouseevent.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -#ifdef __GNUC__ -#define _UNUSED_ __attribute__ ((unused)) -#else -#define _UNUSED_ -#endif - -namespace gcn -{ - /** - * An implementation of a regular clickable button. A button is capable of - * displaying a caption. - * - * If a button is clicked an action event will be sent to all action listener's - * of the button. - * - * @see ImageButton - */ - class GCN_CORE_DECLSPEC Button : public Widget, - public MouseListener, - public KeyListener, - public FocusListener - { - public: - /** - * Constructor. - */ - Button(); - - /** - * Constructor. The button will be automatically resized - * to fit the caption. - * - * @param caption The caption of the button. - */ - Button(const std::string& caption); - - /** - * Sets the caption of the button. It's advisable to call - * adjustSize after setting of the caption to adjust the - * button's size to fit the caption. - * - * @param caption The caption of the button. - * @see getCaption, adjustSize - */ - void setCaption(const std::string& caption); - - /** - * Gets the caption of the button. - * - * @return The caption of the button. - */ - const std::string& getCaption() const; - - /** - * Sets the alignment of the caption. The alignment is relative - * to the center of the button. - * - * @param alignment The alignment of the caption. - * @see getAlignment, Graphics - */ - void setAlignment(Graphics::Alignment alignment); - - /** - * Gets the alignment of the caption. - * - * @return The alignment of the caption. - * @see setAlignment, Graphics - */ - Graphics::Alignment getAlignment() const; - - /** - * Sets the spacing between the border of the button and its caption. - * - * @param spacing The default value for spacing is 4 and can be changed - * using this method. - * @see getSpacing - */ - void setSpacing(unsigned int spacing); - - /** - * Gets the spacing between the border of the button and its caption. - * - * @return spacing. - * @see setSpacing - */ - unsigned int getSpacing() const; - - /** - * Adjusts the button's size to fit the caption. - */ - void adjustSize(); - - - //Inherited from Widget - - virtual void draw(Graphics* graphics); - - - // Inherited from FocusListener - - virtual void focusLost(const Event& event); - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent); - - virtual void mouseReleased(MouseEvent& mouseEvent); - - virtual void mouseEntered(MouseEvent& mouseEvent); - - virtual void mouseExited(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - virtual void keyReleased(KeyEvent& keyEvent); - - protected: - /** - * Checks if the button is pressed. Convenient method to use - * when overloading the draw method of the button. - * - * @return True if the button is pressed, false otherwise. - */ - bool isPressed() const; - - /** - * Holds the caption of the button. - */ - std::string mCaption; - - /** - * True if the mouse is ontop of the button, false otherwise. - */ - bool mHasMouse; - - /** - * True if a key has been pressed, false otherwise. - */ - bool mKeyPressed; - - /** - * True if a mouse has been pressed, false otherwise. - */ - bool mMousePressed; - - /** - * Holds the alignment of the caption. - */ - Graphics::Alignment mAlignment; - - /** - * Holds the spacing between the border and the caption. - */ - unsigned int mSpacing; - }; -} - -#endif // end GCN_BUTTON_HPP diff --git a/src/guichan/widgets/checkbox.hpp b/src/guichan/widgets/checkbox.hpp deleted file mode 100644 index ad43e2896..000000000 --- a/src/guichan/widgets/checkbox.hpp +++ /dev/null @@ -1,173 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_CHECKBOX_HPP -#define GCN_CHECKBOX_HPP - -#include <string> - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a check box where a user can select or deselect - * the check box and where the status of the check box is displayed to the user. - * A check box is capable of displaying a caption. - * - * If a check box's state changes an action event will be sent to all action - * listeners of the check box. - */ - class GCN_CORE_DECLSPEC CheckBox : - public Widget, - public MouseListener, - public KeyListener - { - public: - - /** - * Contructor. - */ - CheckBox(); - - /** - * Constructor. The check box will be automatically resized - * to fit the caption. - * - * @param caption The caption of the check box. - * @param marked True if the check box is selected, false otherwise. - */ - CheckBox(const std::string &caption, bool selected = false); - - /** - * Destructor. - */ - virtual ~CheckBox() { } - - /** - * Checks if the check box is selected. - * - * @return True if the check box is selected, false otherwise. - * @see setSelected - */ - bool isSelected() const; - - /** - * Sets the check box to be selected or not. - * - * @param selected True if the check box should be set as selected. - * @see isSelected - */ - void setSelected(bool selected); - - /** - * Gets the caption of the check box. - * - * @return The caption of the check box. - * @see setCaption - */ - const std::string &getCaption() const; - - /** - * Sets the caption of the check box. It's advisable to call - * adjustSize after setting of the caption to adjust the - * check box's size to fit the caption. - * - * @param caption The caption of the check box. - * @see getCaption, adjustSize - */ - void setCaption(const std::string& caption); - - /** - * Adjusts the check box's size to fit the caption. - */ - void adjustSize(); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - - // Inherited from MouseListener - - virtual void mouseClicked(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - - protected: - /** - * Draws the box of the check box. - * - * @param graphics A Graphics object to draw with. - */ - virtual void drawBox(Graphics *graphics); - - /** - * Toggles the check box between being selected and - * not being selected. - */ - virtual void toggleSelected(); - - /** - * True if the check box is selected, false otherwise. - */ - bool mSelected; - - /** - * Holds the caption of the check box. - */ - std::string mCaption; - }; -} - -#endif // end GCN_CHECKBOX_HPP diff --git a/src/guichan/widgets/container.hpp b/src/guichan/widgets/container.hpp deleted file mode 100644 index 4946b1f74..000000000 --- a/src/guichan/widgets/container.hpp +++ /dev/null @@ -1,162 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_CONTAINER_HPP -#define GCN_CONTAINER_HPP - -#include <list> - -#include "guichan/basiccontainer.hpp" -#include "guichan/graphics.hpp" -#include "guichan/platform.hpp" - -namespace gcn -{ - /** - * An implementation of a container able to contain other widgets. A widget's - * position in the container is relative to the container itself and not the screen. - * A container is the most common widget to use as the Gui's top widget as makes the Gui - * able to contain more than one widget. - * - * @see Gui::setTop - */ - class GCN_CORE_DECLSPEC Container: public BasicContainer - { - public: - - /** - * Constructor. A container is opauqe as default, if you want a - * none opaque container call setQpaque(false). - * - * @see setOpaque, isOpaque - */ - Container(); - - /** - * Destructor. - */ - virtual ~Container(); - - /** - * Sets the container to be opaque or not. If the container - * is opaque its background will be drawn, if it's not opaque - * its background will not be drawn, and thus making the container - * completely transparent. - * - * NOTE: This is not the same as to set visibility. A non visible - * container will not itself nor will it draw its content. - * - * @param opaque True if the container should be opaque, false otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque); - - /** - * Checks if the container is opaque or not. - * - * @return True if the container is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque() const; - - /** - * Adds a widget to the container. - * - * @param widget The widget to add. - * @see remove, clear - */ - virtual void add(Widget* widget); - - /** - * Adds a widget to the container and also specifies the widget's - * position in the container. The position is relative to the container - * and not relative to the screen. - * - * @param widget The widget to add. - * @param x The x coordinate for the widget. - * @param y The y coordinate for the widget. - * @see remove, clear - */ - virtual void add(Widget* widget, int x, int y); - - /** - * Removes a widget from the Container. - * - * @param widget The widget to remove. - * @throws Exception when the widget has not been added to the - * container. - * @see add, clear - */ - virtual void remove(Widget* widget); - - /** - * Clears the container of all widgets. - * - * @see add, remove - */ - virtual void clear(); - - /** - * Finds a widget given an id. - * - * @param id The id to find a widget by. - * @return A widget with a corrosponding id, NULL if no widget - * is found. - * @see Widget::setId - */ - virtual Widget* findWidgetById(const std::string &id); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - protected: - /** - * True if the container is opaque, false otherwise. - */ - bool mOpaque; - }; -} - -#endif // end GCN_CONTAINER_HPP diff --git a/src/guichan/widgets/dropdown.hpp b/src/guichan/widgets/dropdown.hpp deleted file mode 100644 index 5853783e5..000000000 --- a/src/guichan/widgets/dropdown.hpp +++ /dev/null @@ -1,325 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_DROPDOWN_HPP -#define GCN_DROPDOWN_HPP - -#include "guichan/actionlistener.hpp" -#include "guichan/basiccontainer.hpp" -#include "guichan/deathlistener.hpp" -#include "guichan/focushandler.hpp" -#include "guichan/focuslistener.hpp" -#include "guichan/keylistener.hpp" -#include "guichan/listmodel.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/selectionlistener.hpp" -#include "guichan/widgets/listbox.hpp" -#include "guichan/widgets/scrollarea.hpp" - -#ifdef __GNUC__ -#define _UNUSED_ __attribute__ ((unused)) -#else -#define _UNUSED_ -#endif - -namespace gcn -{ - /** - * An implementation of a drop downable list from which an item can be - * selected. The drop down consists of an internal ScrollArea and an - * internal ListBox. The drop down also uses an internal FocusHandler to - * handle the focus of the internal ScollArea and the internal ListBox. The - * scroll area and the list box can be passed to the drop down if a custom - * scroll area and or a custom list box is preferable. - * - * To be able display a list the drop down uses a user provided list model. - * A list model can be any class that implements the ListModel interface. - * - * If an item is selected in the drop down a select event will be sent to - * all selection listeners of the drop down. If an item is selected by - * using a mouse click or by using the enter or space key an action event - * will be sent to all action listeners of the drop down. - */ - class GCN_CORE_DECLSPEC DropDown : - public ActionListener, - public BasicContainer, - public KeyListener, - public MouseListener, - public FocusListener, - public SelectionListener - { - public: - /** - * Contructor. - * - * @param listModel the ListModel to use. - * @param scrollArea the ScrollArea to use. - * @param listBox the listBox to use. - * @see ListModel, ScrollArea, ListBox. - */ - DropDown(ListModel *listModel = NULL, - ScrollArea *scrollArea = NULL, - ListBox *listBox = NULL); - - /** - * Destructor. - */ - virtual ~DropDown(); - - /** - * Gets the selected item as an index in the list model. - * - * @return the selected item as an index in the list model. - * @see setSelected - */ - int getSelected() const; - - /** - * Sets the selected item. The selected item is represented by - * an index from the list model. - * - * @param selected the selected item as an index from the list model. - * @see getSelected - */ - void setSelected(int selected); - - /** - * Sets the list model to use when displaying the list. - * - * @param listModel the list model to use. - * @see getListModel - */ - void setListModel(ListModel *listModel); - - /** - * Gets the list model used. - * - * @return the ListModel used. - * @see setListModel - */ - ListModel *getListModel(); - - /** - * Adjusts the height of the drop down to fit the height of the - * drop down's parent's height. It's used to not make the drop down - * draw itself outside of it's parent if folded down. - */ - void adjustHeight(); - - /** - * Adds a selection listener to the drop down. When the selection - * changes an event will be sent to all selection listeners of the - * drop down. - * - * If you delete your selection listener, be sure to also remove it - * using removeSelectionListener(). - * - * @param listener the selection listener to add. - * @since 0.8.0 - */ - void addSelectionListener(SelectionListener* listener); - - /** - * Removes a selection listener from the drop down. - * - * @param selectionListener the selection listener to remove. - * @since 0.8.0 - */ - void removeSelectionListener(SelectionListener* selectionListener); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - void setBaseColor(const Color& color); - - void setBackgroundColor(const Color& color); - - void setForegroundColor(const Color& color); - - void setFont(Font *font); - - void setSelectionColor(const Color& color); - - - // Inherited from BasicContainer - - virtual Rectangle getChildrenArea(); - - - // Inherited from FocusListener - - virtual void focusLost(const Event& event); - - - // Inherited from ActionListener - - virtual void action(const ActionEvent& actionEvent); - - - // Inherited from DeathListener - - virtual void death(const Event& event); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent); - - virtual void mouseReleased(MouseEvent& mouseEvent); - - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent); - - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - - // Inherited from SelectionListener - - virtual void valueChanged(const SelectionEvent& event); - - protected: - /** - * Draws the button of the drop down. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawButton(Graphics *graphics); - - /** - * Sets the drop down to be dropped down. - */ - virtual void dropDown(); - - /** - * Sets the drop down to be folded up. - */ - virtual void foldUp(); - - /** - * Distributes a value changed event to all selection listeners - * of the drop down. - * - * @since 0.8.0 - */ - void distributeValueChangedEvent(); - - /** - * True if the drop down is dropped down, false otherwise. - */ - bool mDroppedDown; - - /** - * True if the drop down has been pushed with the mouse, false - * otherwise. - */ - bool mPushed; - - /** - * Holds what the height is if the drop down is folded up. Used when - * checking if the list of the drop down was clicked or if the upper - * part of the drop down was clicked on a mouse click. - */ - int mFoldedUpHeight; - - /** - * The scroll area used. - */ - ScrollArea* mScrollArea; - - /** - * The list box used. - */ - ListBox* mListBox; - - /** - * The internal focus handler used to keep track of focus for the - * internal list box. - */ - FocusHandler mInternalFocusHandler; - - /** - * True if an internal scroll area is used, false if a scroll area - * has been passed to the drop down which the drop down should not - * deleted in it's destructor. - */ - bool mInternalScrollArea; - - /** - * True if an internal list box is used, false if a list box - * has been passed to the drop down which the drop down should not - * deleted in it's destructor. - */ - bool mInternalListBox; - - /** - * True if the drop down is dragged. - */ - bool mIsDragged; - - /** - * Typedef. - */ - typedef std::list<SelectionListener*> SelectionListenerList; - - /** - * The selection listener's of the drop down. - */ - SelectionListenerList mSelectionListeners; - - /** - * Typedef. - */ - typedef SelectionListenerList::iterator SelectionListenerIterator; - }; -} - -#endif // end GCN_DROPDOWN_HPP diff --git a/src/guichan/widgets/icon.hpp b/src/guichan/widgets/icon.hpp deleted file mode 100644 index f0f9ff566..000000000 --- a/src/guichan/widgets/icon.hpp +++ /dev/null @@ -1,118 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_ICON_HPP -#define GCN_ICON_HPP - -#include "guichan/image.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * Implements an icon capable of displaying an image. - */ - class GCN_CORE_DECLSPEC Icon: public Widget - { - public: - /** - * Default constructor. - */ - Icon(); - - /** - * Constructor. - * - * @param filename The filename of the image to display. - */ - Icon(const std::string& filename); - - /** - * Constructor. - * - * @param image The image to display. - */ - Icon(const Image* image); - - /** - * Descructor. - */ - virtual ~Icon(); - - /** - * Sets the image to display. Existing image is freed automatically - * if it was loaded internally. - * - * @param image The image to display. - */ - void setImage(const Image* image); - - /** - * Gets the current image. - * - * @return The current image. - */ - const Image* getImage() const; - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - protected: - /** - * The image to display. - */ - const Image* mImage; - - /** - * True if the image has been loaded internally, false otherwise. - * An image not loaded internally should not be deleted in the - * destructor. - */ - bool mInternalImage; - }; -} - -#endif // end GCN_ICON_HPP diff --git a/src/guichan/widgets/imagebutton.hpp b/src/guichan/widgets/imagebutton.hpp deleted file mode 100644 index 1ab285ce9..000000000 --- a/src/guichan/widgets/imagebutton.hpp +++ /dev/null @@ -1,123 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_IMAGEBUTTON_HPP
-#define GCN_IMAGEBUTTON_HPP
-
-#include "guichan/platform.hpp"
-#include "guichan/widgets/button.hpp"
-
-namespace gcn
-{
- class Image;
-
- /**
- * An implementation of a regular clickable button. Unlike a normal button an image
- * button is capable of displaying an image instead of a simple text caption.
- * Whenever an image button is clicked an action event will be sent to the action
- * listener's of the image button.
- *
- * @see Button
- */
- class GCN_CORE_DECLSPEC ImageButton : public gcn::Button
- {
- public:
- /**
- * Default constructor.
- */
- ImageButton();
-
- /**
- * Constructor.
- *
- * @param filename The filename of the image to display.
- */
- ImageButton(const std::string& filename);
-
- /**
- * Constructor.
- *
- * @param image The image to display.
- */
- ImageButton(const Image* image);
-
- /**
- * Destructor.
- */
- virtual ~ImageButton();
-
- /**
- * Sets the image to display. Existing Image is freed automatically,
- * if it was loaded internally.
- *
- * @param image The image to display.
- */
- void setImage(const Image* image);
-
- /**
- * Gets current image.
- *
- * @return The current image.
- */
- const Image* getImage() const;
-
-
- // Inherited from Widget
-
- void draw(gcn::Graphics* graphics);
-
- protected:
- /**
- * The image to display.
- */
- const Image* mImage;
-
- /**
- * True if the image has been loaded internally, false otherwise.
- * An image not loaded internally should not be deleted in the
- * destructor.
- */
- bool mInternalImage;
- };
-}
-#endif
diff --git a/src/guichan/widgets/label.hpp b/src/guichan/widgets/label.hpp deleted file mode 100644 index 4d6ea0006..000000000 --- a/src/guichan/widgets/label.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_LABEL_HPP -#define GCN_LABEL_HPP - -#include <string> - -#include "guichan/graphics.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * Implementation of a label capable of displaying a caption. - */ - class GCN_CORE_DECLSPEC Label: public Widget - { - public: - /** - * Constructor. - */ - Label(); - - /** - * Constructor. The label will be automatically resized - * to fit the caption. - * - * @param caption The caption of the label. - */ - Label(const std::string& caption); - - /** - * Gets the caption of the label. - * - * @return The caption of the label. - * @see setCaption - */ - const std::string &getCaption() const; - - /** - * Sets the caption of the label. It's advisable to call - * adjustSize after setting of the caption to adjust the - * label's size to fit the caption. - * - * @param caption The caption of the label. - * @see getCaption, adjustSize - */ - void setCaption(const std::string& caption); - - /** - * Sets the alignment of the caption. The alignment is relative - * to the center of the label. - * - * @param alignemnt The alignment of the caption of the label. - * @see getAlignment, Graphics - */ - void setAlignment(Graphics::Alignment alignment); - - /** - * Gets the alignment of the caption. The alignment is relative to - * the center of the label. - * - * @return The alignment of caption of the label. - * @see setAlignmentm Graphics - */ - Graphics::Alignment getAlignment() const; - - /** - * Adjusts the label's size to fit the caption. - */ - void adjustSize(); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - protected: - /** - * Holds the caption of the label. - */ - std::string mCaption; - - /** - * Holds the alignment of the caption. - */ - Graphics::Alignment mAlignment; - }; -} - -#endif // end GCN_LABEL_HPP diff --git a/src/guichan/widgets/listbox.hpp b/src/guichan/widgets/listbox.hpp deleted file mode 100644 index b99f84aaa..000000000 --- a/src/guichan/widgets/listbox.hpp +++ /dev/null @@ -1,253 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_LISTBOX_HPP -#define GCN_LISTBOX_HPP - -#include <list> - -#include "guichan/keylistener.hpp" -#include "guichan/listmodel.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - class SelectionListener; - - /** - * An implementation of a list box where an item can be selected. - * - * To be able display a list the list box uses a user provided list model. - * A list model can be any class that implements the ListModel interface. - * - * If an item is selected in the list box a select event will be sent to - * all selection listeners of the list box. If an item is selected by using - * a mouse click or by using the enter or space key an action event will be - * sent to all action listeners of the list box. - */ - class GCN_CORE_DECLSPEC ListBox : - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Constructor. - */ - ListBox(); - - /** - * Constructor. - * - * @param listModel the list model to use. - */ - ListBox(ListModel *listModel); - - /** - * Destructor. - */ - virtual ~ListBox() { } - - /** - * Gets the selected item as an index in the list model. - * - * @return the selected item as an index in the list model. - * @see setSelected - */ - int getSelected() const; - - /** - * Sets the selected item. The selected item is represented by - * an index from the list model. - * - * @param selected the selected item as an index from the list model. - * @see getSelected - */ - void setSelected(int selected); - - /** - * Sets the list model to use. - * - * @param listModel the list model to use. - * @see getListModel - */ - void setListModel(ListModel *listModel); - - /** - * Gets the list model used. - * - * @return the list model used. - * @see setListModel - */ - ListModel *getListModel(); - - /** - * Adjusts the size of the list box to fit it's list model. - */ - void adjustSize(); - - /** - * Checks whether the list box wraps when selecting items with a - * keyboard. - * - * Wrapping means that the selection of items will be wrapped. That is, - * if the first item is selected and up is pressed, the last item will - * get selected. If the last item is selected and down is pressed, the - * first item will get selected. - * - * @return true if wrapping is enabled, fasle otherwise. - * @see setWrappingEnabled - */ - bool isWrappingEnabled() const; - - /** - * Sets the list box to wrap or not when selecting items with a - * keyboard. - * - * Wrapping means that the selection of items will be wrapped. That is, - * if the first item is selected and up is pressed, the last item will - * get selected. If the last item is selected and down is pressed, the - * first item will get selected. - * - * @see isWrappingEnabled - */ - void setWrappingEnabled(bool wrappingEnabled); - - /** - * Adds a selection listener to the list box. When the selection - * changes an event will be sent to all selection listeners of the - * list box. - * - * If you delete your selection listener, be sure to also remove it - * using removeSelectionListener(). - * - * @param selectionListener The selection listener to add. - * @since 0.8.0 - */ - void addSelectionListener(SelectionListener* selectionListener); - - /** - * Removes a selection listener from the list box. - * - * @param selectionListener The selection listener to remove. - * @since 0.8.0 - */ - void removeSelectionListener(SelectionListener* selectionListener); - - /** - * Gets the height of a row. Should be overridden if another row - * height than the font height is preferred. - * - * @return The height of a row. - * @since 0.8.0 - */ - virtual unsigned int getRowHeight() const; - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - virtual void logic(); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent); - - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent); - - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - - protected: - /** - * Distributes a value changed event to all selection listeners - * of the list box. - * - * @since 0.8.0 - */ - void distributeValueChangedEvent(); - - /** - * The selected item as an index in the list model. - */ - int mSelected; - - /** - * The list model to use. - */ - ListModel *mListModel; - - /** - * True if wrapping is enabled, false otherwise. - */ - bool mWrappingEnabled; - - /** - * Typdef. - */ - typedef std::list<SelectionListener*> SelectionListenerList; - - /** - * The selection listeners of the list box. - */ - SelectionListenerList mSelectionListeners; - - /** - * Typedef. - */ - typedef SelectionListenerList::iterator SelectionListenerIterator; - }; -} - -#endif // end GCN_LISTBOX_HPP diff --git a/src/guichan/widgets/radiobutton.hpp b/src/guichan/widgets/radiobutton.hpp deleted file mode 100644 index 0fb5b4123..000000000 --- a/src/guichan/widgets/radiobutton.hpp +++ /dev/null @@ -1,211 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_RADIOBUTTON_HPP -#define GCN_RADIOBUTTON_HPP - -#include <map> -#include <string> - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a radio button where a user can select or deselect - * the radio button and where the status of the radio button is displayed to the user. - * A radio button can belong to a group and when a radio button belongs to a - * group only one radio button can be selected in the group. A radio button is - * capable of displaying a caption. - * - * If a radio button's state changes an action event will be sent to all action - * listeners of the check box. - */ - class GCN_CORE_DECLSPEC RadioButton : - public Widget, - public MouseListener, - public KeyListener - { - public: - - /** - * Constructor. - */ - RadioButton(); - - /** - * Constructor. The radio button will be automatically resized - * to fit the caption. - * - * @param caption The caption of the radio button. - * @param group The group the radio button should belong to. - * @param selected True if the radio button should be selected. - */ - RadioButton(const std::string &caption, - const std::string &group, - bool selected = false); - - /** - * Destructor. - */ - virtual ~RadioButton(); - - /** - * Checks if the radio button is selected. - * - * @return True if the radio button is selecte, false otherwise. - * @see setSelected - */ - bool isSelected() const; - - /** - * Sets the radio button to selected or not. - * - * @param selected True if the radio button should be selected, - * false otherwise. - * @see isSelected - */ - void setSelected(bool selected); - - /** - * Gets the caption of the radio button. - * - * @return The caption of the radio button. - * @see setCaption - */ - const std::string &getCaption() const; - - /** - * Sets the caption of the radio button. It's advisable to call - * adjustSize after setting of the caption to adjust the - * radio button's size to fit the caption. - * - * @param caption The caption of the radio button. - * @see getCaption, adjustSize - */ - void setCaption(const std::string caption); - - /** - * Sets the group the radio button should belong to. Note that - * a radio button group is unique per application, not per Gui object - * as the group is stored in a static map. - * - * @param group The name of the group. - * @see getGroup - */ - void setGroup(const std::string &group); - - /** - * Gets the group the radio button belongs to. - * - * @return The group the radio button belongs to. - * @see setGroup - */ - const std::string &getGroup() const; - - /** - * Adjusts the radio button's size to fit the caption. - */ - void adjustSize(); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - - // Inherited from MouseListener - - virtual void mouseClicked(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - protected: - /** - * Draws the box. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawBox(Graphics *graphics); - - /** - * True if the radio button is selected, false otherwise. - */ - bool mSelected; - - /** - * Holds the caption of the radio button. - */ - std::string mCaption; - - /** - * Holds the group of the radio button. - */ - std::string mGroup; - - /** - * Typdef. - */ - typedef std::multimap<std::string, RadioButton *> GroupMap; - - /** - * Typdef. - */ - typedef GroupMap::iterator GroupIterator; - - /** - * Holds all available radio button groups. - */ - static GroupMap mGroupMap; - }; -} - -#endif // end GCN_RADIOBUTTON_HPP diff --git a/src/guichan/widgets/scrollarea.hpp b/src/guichan/widgets/scrollarea.hpp deleted file mode 100644 index 0b2ccad92..000000000 --- a/src/guichan/widgets/scrollarea.hpp +++ /dev/null @@ -1,590 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_SCROLLAREA_HPP -#define GCN_SCROLLAREA_HPP - -#include <string> - -#include "guichan/basiccontainer.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" - -namespace gcn -{ - /** - * Implementation if a scrollable area used to view widgets larger than the scroll area. - * A scroll area can be customized to always show scroll bars or to show them only when - * necessary. - */ - class GCN_CORE_DECLSPEC ScrollArea: - public BasicContainer, - public MouseListener - { - public: - - /** - * Scrollpolicies for the horizontal and vertical scrollbar. - * The policies are: - * - * SHOW_ALWAYS - Always show the scrollbars no matter what. - * SHOW_NEVER - Never show the scrollbars no matter waht. - * SHOW_AUTO - Show the scrollbars only when needed. That is if the - * content grows larger then the ScrollArea. - */ - enum ScrollPolicy - { - SHOW_ALWAYS = 0, - SHOW_NEVER, - SHOW_AUTO - }; - - /** - * Constructor. - */ - ScrollArea(); - - /** - * Constructor. - * - * @param content The content of the scroll area. - */ - ScrollArea(Widget *content); - - /** - * Constructor. - * - * @param content The content of the scroll area. - * @param hPolicy The policy for the horizontal scrollbar. See enum with - * policies. - * @param vPolicy The policy for the vertical scrollbar. See enum with - * policies. - */ - ScrollArea(Widget *content, - ScrollPolicy hPolicy, - ScrollPolicy vPolicy); - - /** - * Destructor. - */ - virtual ~ScrollArea(); - - /** - * Sets the content. - * - * @param widget The content of the scroll area. - */ - void setContent(Widget* widget); - - /** - * Gets the content. - * - * @return The content of the scroll area. - */ - Widget* getContent(); - - /** - * Sets the horizontal scrollbar policy. See enum with policies. - * - * @param hPolicy The policy for the horizontal scrollbar. - * @see getHorizontalScrollPolicy - */ - void setHorizontalScrollPolicy(ScrollPolicy hPolicy); - - /** - * Gets the horizontal scrollbar policy. See enum with policies. - * - * @return The policy for the horizontal scrollbar policy. - * @see setHorizontalScrollPolicy, setScrollPolicy - */ - ScrollPolicy getHorizontalScrollPolicy() const; - - /** - * Sets the vertical scrollbar policy. See enum with policies. - * - * @param vPolicy The policy for the vertical scrollbar. - * @see getVerticalScrollPolicy - */ - void setVerticalScrollPolicy(ScrollPolicy vPolicy); - - /** - * Gets the vertical scrollbar policy. See enum with policies. - * - * @return The policy for the vertical scrollbar. - * @see setVerticalScrollPolicy, setScrollPolicy - */ - ScrollPolicy getVerticalScrollPolicy() const; - - /** - * Sets the horizontal and vertical scrollbar policy. - * - * @param hPolicy The policy for the horizontal scrollbar. - * @param vPolicy The policy for the vertical scrollbar. - * @see getVerticalScrollPolicy, getHorizontalScrollPolicy - */ - void setScrollPolicy(ScrollPolicy hPolicy, ScrollPolicy vPolicy); - - /** - * Sets the amount to scroll vertically. - * - * @param vScroll The amount to scroll. - * @see getVerticalScrollAmount - */ - void setVerticalScrollAmount(int vScroll); - - /** - * Gets the amount that is scrolled vertically. - * - * @return The scroll amount on vertical scroll. - * @see setVerticalScrollAmount, setScrollAmount - */ - int getVerticalScrollAmount() const; - - /** - * Sets the amount to scroll horizontally. - * - * @param hScroll The amount to scroll. - * @see getHorizontalScrollAmount - */ - void setHorizontalScrollAmount(int hScroll); - - /** - * Gets the amount that is scrolled horizontally. - * - * @return The scroll amount on horizontal scroll. - * @see setHorizontalScrollAmount, setScrollAmount - */ - int getHorizontalScrollAmount() const; - - /** - * Sets the amount to scroll horizontally and vertically. - * - * @param hScroll The amount to scroll on horizontal scroll. - * @param vScroll The amount to scroll on vertical scroll. - * @see getHorizontalScrollAmount, getVerticalScrollAmount - */ - void setScrollAmount(int hScroll, int vScroll); - - /** - * Gets the maximum amount of horizontal scroll. - * - * @return The horizontal max scroll. - */ - int getHorizontalMaxScroll(); - - /** - * Gets the maximum amount of vertical scroll. - * - * @return The vertical max scroll. - */ - int getVerticalMaxScroll(); - - /** - * Sets the width of the scroll bars. - * - * @param width The width of the scroll bars. - * @see getScrollbarWidth - */ - void setScrollbarWidth(int width); - - /** - * Gets the width of the scroll bars. - * - * @return the width of the ScrollBar. - * @see setScrollbarWidth - */ - int getScrollbarWidth() const; - - /** - * Sets the amount to scroll in pixels when the left scroll button is - * pushed. - * - * @param amount The amount to scroll in pixels. - * @see getLeftButtonScrollAmount - */ - void setLeftButtonScrollAmount(int amount); - - /** - * Sets the amount to scroll in pixels when the right scroll button is - * pushed. - * - * @param amount The amount to scroll in pixels. - * @see getRightButtonScrollAmount - */ - void setRightButtonScrollAmount(int amount); - - /** - * Sets the amount to scroll in pixels when the up scroll button is - * pushed. - * - * @param amount The amount to scroll in pixels. - * @see getUpButtonScrollAmount - */ - void setUpButtonScrollAmount(int amount); - - /** - * Sets the amount to scroll in pixels when the down scroll button is - * pushed. - * - * @param amount The amount to scroll in pixels. - * @see getDownButtonScrollAmount - */ - void setDownButtonScrollAmount(int amount); - - /** - * Gets the amount to scroll in pixels when the left scroll button is - * pushed. - * - * @return The amount to scroll in pixels. - * @see setLeftButtonScrollAmount - */ - int getLeftButtonScrollAmount() const; - - /** - * Gets the amount to scroll in pixels when the right scroll button is - * pushed. - * - * @return The amount to scroll in pixels. - * @see setRightButtonScrollAmount - */ - int getRightButtonScrollAmount() const; - - /** - * Gets the amount to scroll in pixels when the up scroll button is - * pushed. - * - * @return The amount to scroll in pixels. - * @see setUpButtonScrollAmount - */ - int getUpButtonScrollAmount() const; - - /** - * Gets the amount to scroll in pixels when the down scroll button is - * pushed. - * - * @return The amount to scroll in pixels. - * @see setDownButtonScrollAmount - */ - int getDownButtonScrollAmount() const; - - /** - * Sets the scroll area to be opaque, that is sets the scoll area - * to display its background. - * - * @param opaque True if the scoll area should be opaque, false otherwise. - */ - void setOpaque(bool opaque); - - /** - * Checks if the scroll area is opaque, that is if the scroll area - * displays its background. - * - * @return True if the scroll area is opaque, false otherwise. - */ - bool isOpaque() const; - - - // Inherited from BasicContainer - - virtual void showWidgetPart(Widget* widget, Rectangle area); - - virtual Rectangle getChildrenArea(); - - virtual Widget *getWidgetAt(int x, int y); - - - // Inherited from Widget - - virtual void draw(Graphics *graphics); - - virtual void logic(); - - void setWidth(int width); - - void setHeight(int height); - - void setDimension(const Rectangle& dimension); - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent); - - virtual void mouseReleased(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent); - - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent); - - protected: - /** - * Draws the background of the scroll area, that is - * the area behind the content. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawBackground(Graphics *graphics); - - /** - * Draws the up button. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawUpButton(Graphics *graphics); - - /** - * Draws the down button. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawDownButton(Graphics *graphics); - - /** - * Draws the left button. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawLeftButton(Graphics *graphics); - - /** - * Draws the right button. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawRightButton(Graphics *graphics); - - /** - * Draws the vertical scroll bar. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawVBar(Graphics* graphics); - - /** - * Draws the horizontal scroll bar. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawHBar(Graphics* graphics); - - /** - * Draws the vertical marker. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawVMarker(Graphics* graphics); - - /** - * Draws the horizontal marker. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawHMarker(Graphics* graphics); - - /** - * Checks the policies for the scroll bars. - */ - virtual void checkPolicies(); - - /** - * Gets the up button dimension. - * - * @return the dimension of the up button. - */ - Rectangle getUpButtonDimension(); - - /** - * Gets the down button dimension. - * - * @return the dimension of the down button. - */ - Rectangle getDownButtonDimension(); - - /** - * Gets the left button dimension. - * - * @return the dimension of the left button. - */ - Rectangle getLeftButtonDimension(); - - /** - * Gets the right button dimension. - * - * @return the dimension of the right button. - */ - Rectangle getRightButtonDimension(); - - /** - * Gets the vertical scrollbar dimension. - * - * @return the dimension of the vertical scrollbar. - */ - Rectangle getVerticalBarDimension(); - - /** - * Gets the horizontal scrollbar dimension. - * - * @return the dimension of the horizontal scrollbar. - */ - Rectangle getHorizontalBarDimension(); - - /** - * Gets the vertical marker dimension. - * - * @return the dimension of the vertical marker. - */ - Rectangle getVerticalMarkerDimension(); - - /** - * Gets the horizontal marker dimension. - * - * @return the dimension of the horizontal marker. - */ - Rectangle getHorizontalMarkerDimension(); - - /** - * Holds the vertical scroll amount. - */ - int mVScroll; - - /** - * Holds the horizontal scroll amount. - */ - int mHScroll; - - /** - * Holds the width of the scroll bars. - */ - int mScrollbarWidth; - - /** - * Holds the horizontal scroll bar policy. - */ - ScrollPolicy mHPolicy; - - /** - * Holds the vertical scroll bar policy. - */ - ScrollPolicy mVPolicy; - - /** - * True if the vertical scroll bar is visible, false otherwise. - */ - bool mVBarVisible; - - /** - * True if the horizontal scroll bar is visible, false otherwise. - */ - bool mHBarVisible; - - /** - * True if the up button is pressed, false otherwise. - */ - bool mUpButtonPressed; - - /** - * True if the down button is pressed, false otherwise. - */ - bool mDownButtonPressed; - - /** - * True if the left button is pressed, false otherwise. - */ - bool mLeftButtonPressed; - - /** - * True if the right button is pressed, false otherwise. - */ - bool mRightButtonPressed; - - /** - * Holds the up button scroll amount. - */ - int mUpButtonScrollAmount; - - /** - * Holds the down button scroll amount. - */ - int mDownButtonScrollAmount; - - /** - * Holds the left button scroll amount. - */ - int mLeftButtonScrollAmount; - - /** - * Holds the right button scroll amount. - */ - int mRightButtonScrollAmount; - - /** - * True if the vertical marked is dragged. - */ - bool mIsVerticalMarkerDragged; - - /** - * True if the horizontal marked is dragged. - */ - bool mIsHorizontalMarkerDragged; - - /** - * Holds the horizontal markers drag offset. - */ - int mHorizontalMarkerDragOffset; - - /** - * Holds the vertical markers drag offset. - */ - int mVerticalMarkerDragOffset; - - /** - * True if the scroll area should be opaque (that is - * display its background), false otherwise. - */ - bool mOpaque; - }; -} - -#endif // end GCN_SCROLLAREA_HPP diff --git a/src/guichan/widgets/slider.hpp b/src/guichan/widgets/slider.hpp deleted file mode 100644 index eddf02c50..000000000 --- a/src/guichan/widgets/slider.hpp +++ /dev/null @@ -1,300 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_SLIDER_HPP -#define GCN_SLIDER_HPP - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a slider where a user can select different values by - * sliding between a start value and an end value of a scale. - * - * If the selected value is changed an action event will be sent to all - * action listeners of the slider. - */ - class GCN_CORE_DECLSPEC Slider : - public Widget, - public MouseListener, - public KeyListener - { - public: - - /** - * Draw orientations for the slider. A slider can be drawn vertically or - * horizontally. - */ - enum Orientation - { - HORIZONTAL = 0, - VERTICAL - }; - - /** - * Constructor. The default start value of the slider scale is zero. - * - * @param scaleEnd The end value of the slider scale. - */ - Slider(double scaleEnd = 1.0); - - /** - * Constructor. - * - * @param scaleStart The start value of the slider scale. - * @param scaleEnd The end value of the slider scale. - */ - Slider(double scaleStart, double scaleEnd); - - /** - * Destructor. - */ - virtual ~Slider() { } - - /** - * Sets the scale of the slider. - * - * @param scaleStart The start value of the scale. - * @param scaleEnd tThe end of value the scale. - * @see getScaleStart, getScaleEnd - */ - void setScale(double scaleStart, double scaleEnd); - - /** - * Gets the start value of the scale. - * - * @return The start value of the scale. - * @see setScaleStart, setScale - */ - double getScaleStart() const; - - /** - * Sets the start value of the scale. - * - * @param scaleStart The start value of the scale. - * @see getScaleStart - */ - void setScaleStart(double scaleStart); - - /** - * Gets the end value of the scale. - * - * @return The end value of the scale. - * @see setScaleEnd, setScale - */ - double getScaleEnd() const; - - /** - * Sets the end value of the scale. - * - * @param scaleEnd The end value of the scale. - * @see getScaleEnd - */ - void setScaleEnd(double scaleEnd); - - /** - * Gets the current selected value. - * - * @return The current selected value. - * @see setValue - */ - double getValue() const; - - /** - * Sets the current selected value. - * - * @param value The current selected value. - * @see getValue - */ - void setValue(double value); - - /** - * Sets the length of the marker. - * - * @param length The length for the marker. - * @see getMarkerLength - */ - void setMarkerLength(int length); - - /** - * Gets the length of the marker. - * - * @return The length of the marker. - * @see setMarkerLength - */ - int getMarkerLength() const; - - /** - * Sets the orientation of the slider. A slider can be drawn vertically - * or horizontally. - * - * @param orientation The orientation of the slider. - * @see getOrientation - */ - void setOrientation(Orientation orientation); - - /** - * Gets the orientation of the slider. A slider can be drawn vertically - * or horizontally. - * - * @return The orientation of the slider. - * @see setOrientation - */ - Orientation getOrientation() const; - - /** - * Sets the step length. The step length is used when the keys LEFT - * and RIGHT are pressed to step in the scale. - * - * @param length The step length. - * @see getStepLength - */ - void setStepLength(double length); - - /** - * Gets the step length. The step length is used when the keys LEFT - * and RIGHT are pressed to step in the scale. - * - * @return the step length. - * @see setStepLength - */ - double getStepLength() const; - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - - // Inherited from MouseListener. - - virtual void mousePressed(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent); - - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - protected: - /** - * Draws the marker. - * - * @param graphics A graphics object to draw with. - */ - virtual void drawMarker(gcn::Graphics* graphics); - - /** - * Converts a marker position to a value in the scale. - * - * @param position The position to convert. - * @return A scale value corresponding to the position. - * @see valueToMarkerPosition - */ - virtual double markerPositionToValue(int position) const; - - /** - * Converts a value to a marker position. - * - * @param value The value to convert. - * @return A marker position corresponding to the value. - * @see markerPositionToValue - */ - virtual int valueToMarkerPosition(double value) const; - - /** - * Gets the marker position of the current selected value. - * - * @return The marker position of the current selected value. - */ - virtual int getMarkerPosition() const; - - /** - * True if the slider is dragged, false otherwise. - */ - bool mDragged; - - /** - * Holds the current selected value. - */ - double mValue; - - /** - * Holds the step length. The step length is used when the keys LEFT - * and RIGHT are pressed to step in the scale. - */ - double mStepLength; - - /** - * Holds the length of the marker. - */ - int mMarkerLength; - - /** - * Holds the start value of the scale. - */ - double mScaleStart; - - /** - * Holds the end value of the scale. - */ - double mScaleEnd; - - /** - * Holds the orientation of the slider. A slider can be drawn - * vertically or horizontally. - */ - Orientation mOrientation; - }; -} - -#endif // end GCN_SLIDER_HPP diff --git a/src/guichan/widgets/tab.hpp b/src/guichan/widgets/tab.hpp deleted file mode 100644 index d123bac15..000000000 --- a/src/guichan/widgets/tab.hpp +++ /dev/null @@ -1,157 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_TAB_HPP -#define GCN_TAB_HPP - -#include <map> -#include <string> - -#include "guichan/basiccontainer.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" - -#ifdef __GNUC__ -#define _UNUSED_ __attribute__ ((unused)) -#else -#define _UNUSED_ -#endif - -namespace gcn -{ - class Label; - class TabbedArea; - - /** - * An implementation of a simple tab to be used in a tabbed area. - * - * @see TabbedArea - * @since 0.8.0 - */ - class GCN_CORE_DECLSPEC Tab: - public BasicContainer, - public MouseListener - { - public: - - /** - * Constructor. - */ - Tab(); - - /** - * Destructor. - */ - virtual ~Tab(); - - /** - * Adjusts the size of the tab to fit the caption. If this tab was - * added to a TabbedArea, it will also adjust the tab positions. - */ - void adjustSize(); - - /** - * Sets the tabbed area the tab should be a part of. - * - * @param tabbedArea The tabbed area the tab should be a part of. - * @see getTabbedArea - */ - void setTabbedArea(TabbedArea* tabbedArea); - - /** - * Gets the tabbed are the tab is a part of. - * - * @return The tabbed are the tab is a part of. - * @see setTabbedArea - */ - TabbedArea* getTabbedArea(); - - /** - * Sets the caption of the tab. It's advisable to call - * adjustSize after setting the caption to make the tab - * fit the caption. - * - * @param caption The caption of the tab. - * @see getCaption, adjustSize - */ - void setCaption(const std::string& caption); - - /** - * Gets the caption of the tab. - * - * @return The caption of the tab. - * @see setCaption - */ - const std::string& getCaption() const; - - - // Inherited from Widget - - virtual void draw(Graphics *graphics); - - - // Inherited from MouseListener - - virtual void mouseEntered(MouseEvent& mouseEvent); - - virtual void mouseExited(MouseEvent& mouseEvent); - - protected: - /** - * Holds the label of the tab. - */ - Label* mLabel; - - /** - * True if the tab has the mouse, false otherwise. - */ - bool mHasMouse; - - /** - * Holds the tabbed area the tab is a part of. - */ - TabbedArea* mTabbedArea; - }; -} - -#endif // end GCN_TABBEDAREA_HPP diff --git a/src/guichan/widgets/tabbedarea.hpp b/src/guichan/widgets/tabbedarea.hpp deleted file mode 100644 index 843bbde81..000000000 --- a/src/guichan/widgets/tabbedarea.hpp +++ /dev/null @@ -1,280 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_TABBEDAREA_HPP -#define GCN_TABBEDAREA_HPP - -#include <map> -#include <string> -#include <vector> - -#include "guichan/actionlistener.hpp" -#include "guichan/basiccontainer.hpp" -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" - -namespace gcn -{ - class Container; - class Tab; - - /** - * An implementation of a tabbed area where a user can display a widget by - * selecting a tab. - * - * @since 0.8.0 - */ - class GCN_CORE_DECLSPEC TabbedArea: - public ActionListener, - public BasicContainer, - public KeyListener, - public MouseListener - { - friend class Tab; - - public: - /** - * Constructor. - */ - TabbedArea(); - - /** - * Destructor. - */ - virtual ~TabbedArea(); - - /** - * Sets the tabbed area to be opaque or not. If the tabbed area is - * opaque its background will be drawn, if it's not opaque its - * background will not be drawn. By default, a tabbed area is not - * opaque. - * - * The tabbed area's background is normally only visible behind the - * tabs, since the container holding the tab contents is opaque by - * default. - * - * @param opaque True if the tabbed area should be opaque, false - * otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque); - - /** - * Checks if the tabbed area is opaque or not. - * - * @return true if the tabbed area is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque() const; - - /** - * Adds a tab to the tabbed area. The newly created tab will be - * automatically deleted by the tabbed area when it is removed. - * - * @param caption The caption of the tab to add. - * @param widget The widget to view when the tab is selected. - * @see removeTab, removeTabWithIndex - */ - virtual void addTab(const std::string& caption, Widget* widget); - - /** - * Adds a tab to the tabbed area. The tab will not be deleted by the - * tabbed area when it is removed. - * - * @param tab The tab widget for the tab. - * @param widget The widget to view when the tab is selected. - * @see removeTab, removeTabWithIndex - */ - virtual void addTab(Tab* tab, Widget* widget); - - /** - * Removes a tab from the tabbed area. - * - * @param index The index of the tab to remove. - * @see addTab - */ - virtual void removeTabWithIndex(unsigned int index); - - /** - * Removes a tab from the tabbed area. - * - * @param index The tab to remove. - * @see addTab - */ - virtual void removeTab(Tab* tab); - - /** - * Checks if a tab given an index is selected or not. - * - * @param index The index of the tab to check. - * @return True if the tab is selected, false otherwise. - * @see setSelectedTab - */ - virtual bool isTabSelected(unsigned int index) const; - - /** - * Checks if a tab is selected or not. - * - * @param index The tab to check. - * @return True if the tab is selected, false otherwise. - * @see setSelectedTab - */ - virtual bool isTabSelected(Tab* tab); - - /** - * Sets a tab given an index to be selected. - * - * @param index The index of the tab to be selected. - * @see isTabSelected, getSelectedTab - */ - virtual void setSelectedTab(unsigned int index); - - /** - * Sets a tab to be selected or not. - * - * @param index The tab to be selected. - * @see isTabSelected, getSelectedTab - */ - virtual void setSelectedTab(Tab* tab); - - /** - * Gets the index of the selected tab. - * - * @return The undex of the selected tab. - * If no tab is selected -1 will be returned. - * @see isTabSelected, setSelectedTab - */ - virtual int getSelectedTabIndex() const; - - /** - * Gets the selected tab. - * - * @return The selected tab. - * @see isTabSelected, setSelectedTab - */ - Tab* getSelectedTab(); - - - // Inherited from Widget - - virtual void draw(Graphics *graphics); - - virtual void logic(); - - void setWidth(int width); - - void setHeight(int height); - - void setSize(int width, int height); - - void setDimension(const Rectangle& dimension); - - - // Inherited from ActionListener - - void action(const ActionEvent& actionEvent); - - - // Inherited from DeathListener - - virtual void death(const Event& event); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent); - - - protected: - /** - * Adjusts the size of the tab container and the widget container. - */ - void adjustSize(); - - /** - * Adjusts the positions of the tabs. - */ - void adjustTabPositions(); - - /** - * Holds the selected tab. - */ - Tab* mSelectedTab; - - /** - * Holds the container for the tabs. - */ - Container* mTabContainer; - - /** - * Holds the container for the widgets. - */ - Container* mWidgetContainer; - - /** - * Holds a vector of tabs to delete in the destructor. - * A tab that is to be deleted is a tab that has been - * internally created by the tabbed area. - */ - std::vector<Tab*> mTabsToDelete; - - /** - * A map between a tab and a widget to display when the - * tab is selected. - */ - std::vector<std::pair<Tab*, Widget*> > mTabs; - - /** - * True if the tabbed area is opaque, false otherwise. - */ - bool mOpaque; - }; -} - -#endif // end GCN_TABBEDAREA_HPP diff --git a/src/guichan/widgets/textbox.hpp b/src/guichan/widgets/textbox.hpp deleted file mode 100644 index b00dcef20..000000000 --- a/src/guichan/widgets/textbox.hpp +++ /dev/null @@ -1,289 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_TEXTBOX_HPP -#define GCN_TEXTBOX_HPP - -#include <ctime> -#include <string> -#include <vector> - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a text box where a user can enter text that contains of many lines. - */ - class GCN_CORE_DECLSPEC TextBox: - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Constructor. - */ - TextBox(); - - /** - * Constructor. - * - * @param text The default text of the text box. - */ - TextBox(const std::string& text); - - /** - * Sets the text of the text box. - * - * @param text The text of the text box. - * @see getText - */ - void setText(const std::string& text); - - /** - * Gets the text of the text box. - * - * @return The text of the text box. - * @see setText - */ - std::string getText() const; - - /** - * Gets a certain row from the text. - * - * @param row The number of the row to get from the text. - * @return A row from the text of the text box. - * @see setTextRow - */ - const std::string& getTextRow(int row) const; - - /** - * Sets the text of a certain row of the text. - * - * @param row The number of the row to set in the text. - * @param text The text to set in the given row number. - * @see getTextRow - */ - void setTextRow(int row, const std::string& text); - - /** - * Gets the number of rows in the text. - * - * @return The number of rows in the text. - */ - unsigned int getNumberOfRows() const; - - /** - * Gets the caret position in the text. - * - * @return The caret position in the text. - * @see setCaretPosition - */ - unsigned int getCaretPosition() const; - - /** - * Sets the position of the caret in the text. - * - * @param position the positon of the caret. - * @see getCaretPosition - */ - void setCaretPosition(unsigned int position); - - /** - * Gets the row number where the caret is currently located. - * - * @return The row number where the caret is currently located. - * @see setCaretRow - */ - unsigned int getCaretRow() const; - - /** - * Sets the row where the caret should be currently located. - * - * @param The row where the caret should be currently located. - * @see getCaretRow - */ - void setCaretRow(int row); - - /** - * Gets the column where the caret is currently located. - * - * @return The column where the caret is currently located. - * @see setCaretColumn - */ - unsigned int getCaretColumn() const; - - /** - * Sets the column where the caret should be currently located. - * - * @param The column where the caret should be currently located. - * @see getCaretColumn - */ - void setCaretColumn(int column); - - /** - * Sets the row and the column where the caret should be curretly - * located. - * - * @param row The row where the caret should be currently located. - * @param column The column where the caret should be currently located. - * @see getCaretRow, getCaretColumn - */ - void setCaretRowColumn(int row, int column); - - /** - * Scrolls the text to the caret if the text box is in a scroll area. - * - * @see ScrollArea - */ - virtual void scrollToCaret(); - - /** - * Checks if the text box is editable. - * - * @return True it the text box is editable, false otherwise. - * @see setEditable - */ - bool isEditable() const; - - /** - * Sets the text box to be editable or not. - * - * @param editable True if the text box should be editable, false otherwise. - */ - void setEditable(bool editable); - - /** - * Adds a row of text to the end of the text. - * - * @param row The row to add. - */ - virtual void addRow(const std::string row); - - /** - * Checks if the text box is opaque. An opaque text box will draw - * it's background and it's text. A non opaque text box only draw it's - * text making it transparent. - * - * @return True if the text box is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque(); - - /** - * Sets the text box to be opaque or not. An opaque text box will draw - * it's background and it's text. A non opaque text box only draw it's - * text making it transparent. - * - * @param opaque True if the text box should be opaque, false otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - virtual void fontChanged(); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - protected: - /** - * Draws the caret. Overloaded this method if you want to - * change the style of the caret. - * - * @param graphics a Graphics object to draw with. - * @param x the x position. - * @param y the y position. - */ - virtual void drawCaret(Graphics* graphics, int x, int y); - - /** - * Adjusts the text box's size to fit the text. - */ - virtual void adjustSize(); - - /** - * Holds all the rows of the text. - */ - std::vector<std::string> mTextRows; - - /** - * Holds the current column of the caret. - */ - int mCaretColumn; - - /** - * Holds the current row of the caret. - */ - int mCaretRow; - - /** - * True if the text box is editable, false otherwise. - */ - bool mEditable; - - /** - * True if the text box is editable, false otherwise. - */ - bool mOpaque; - }; -} - -#endif // end GCN_TEXTBOX_HPP diff --git a/src/guichan/widgets/textfield.hpp b/src/guichan/widgets/textfield.hpp deleted file mode 100644 index 486660a8a..000000000 --- a/src/guichan/widgets/textfield.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_TEXTFIELD_HPP -#define GCN_TEXTFIELD_HPP - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/widget.hpp" - -#include <string> - -namespace gcn -{ - /** - * An implementation of a text field where a user can enter a line of text. - */ - class GCN_CORE_DECLSPEC TextField: - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Constructor. - */ - TextField(); - - /** - * Constructor. The text field will be automatically resized - * to fit the text. - * - * @param text The default text of the text field. - */ - TextField(const std::string& text); - - /** - * Sets the text of the text field. - * - * @param text The text of the text field. - * @see getText - */ - void setText(const std::string& text); - - /** - * Gets the text of the text field. - * - * @return The text of the text field. - * @see setText - */ - const std::string& getText() const; - - /** - * Adjusts the size of the text field to fit the text. - */ - void adjustSize(); - - /** - * Adjusts the height of the text field to fit caption. - */ - void adjustHeight(); - - /** - * Sets the caret position. As there is only one line of text - * in a text field the position is the caret's x coordinate. - * - * @param position The caret position. - * @see getCaretPosition - */ - void setCaretPosition(unsigned int position); - - /** - * Gets the caret position. As there is only one line of text - * in a text field the position is the caret's x coordinate. - * - * @return The caret position. - * @see setCaretPosition - */ - unsigned int getCaretPosition() const; - - - // Inherited from Widget - - virtual void fontChanged(); - - virtual void draw(Graphics* graphics); - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); - - protected: - /** - * Draws the caret. Overloaded this method if you want to - * change the style of the caret. - * - * @param graphics the Graphics object to draw with. - * @param x the caret's x-position. - */ - virtual void drawCaret(Graphics* graphics, int x); - - /** - * Scrolls the text horizontally so that the caret shows if needed. - * The method is used any time a user types in the text field so the - * caret always will be shown. - */ - void fixScroll(); - - /** - * Holds the text of the text box. - */ - std::string mText; - - /** - * Holds the caret position. - */ - unsigned int mCaretPosition; - - /** - * Holds the amount scrolled in x. If a user types more characters than - * the text field can display, due to the text field being to small, the - * text needs to scroll in order to show the last type character. - */ - int mXScroll; - }; -} - -#endif // end GCN_TEXTFIELD_HPP diff --git a/src/guichan/widgets/window.hpp b/src/guichan/widgets/window.hpp deleted file mode 100644 index 63685c7fb..000000000 --- a/src/guichan/widgets/window.hpp +++ /dev/null @@ -1,261 +0,0 @@ -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_WINDOW_HPP -#define GCN_WINDOW_HPP - -#include <string> - -#include "guichan/mouselistener.hpp" -#include "guichan/platform.hpp" -#include "guichan/widgets/container.hpp" - -#ifdef __GNUC__ -#define _UNUSED_ __attribute__ ((unused)) -#else -#define _UNUSED_ -#endif - -namespace gcn -{ - /** - * An implementation of a movable window that can contain other widgets. - */ - class GCN_CORE_DECLSPEC Window : public Container, - public MouseListener - { - public: - /** - * Constructor. - */ - Window(); - - /** - * Constructor. The window will be automatically resized in height - * to fit the caption. - * - * @param caption the caption of the window. - */ - Window(const std::string& caption); - - /** - * Destructor. - */ - virtual ~Window(); - - /** - * Sets the caption of the window. - * - * @param caption The caption of the window. - * @see getCaption - */ - void setCaption(const std::string& caption); - - /** - * Gets the caption of the window. - * - * @return the caption of the window. - * @see setCaption - */ - const std::string& getCaption() const; - - /** - * Sets the alignment of the caption. - * - * @param alignment The alignment of the caption. - * @see getAlignment, Graphics - */ - void setAlignment(Graphics::Alignment alignment); - - /** - * Gets the alignment of the caption. - * - * @return The alignment of caption. - * @see setAlignment, Graphics - */ - Graphics::Alignment getAlignment() const; - - /** - * Sets the padding of the window. The padding is the distance between the - * window border and the content. - * - * @param padding The padding of the window. - * @see getPadding - */ - void setPadding(unsigned int padding); - - /** - * Gets the padding of the window. The padding is the distance between the - * window border and the content. - * - * @return The padding of the window. - * @see setPadding - */ - unsigned int getPadding() const; - - /** - * Sets the title bar height. - * - * @param height The title height value. - * @see getTitleBarHeight - */ - void setTitleBarHeight(unsigned int height); - - /** - * Gets the title bar height. - * - * @return The title bar height. - * @see setTitleBarHeight - */ - unsigned int getTitleBarHeight(); - - /** - * Sets the window to be moveble or not. - * - * @param movable True if the window should be movable, false otherwise. - * @see isMovable - */ - void setMovable(bool movable); - - /** - * Checks if the window is movable. - * - * @return True if the window is movable, false otherwise. - * @see setMovable - */ - bool isMovable() const; - - /** - * Sets the window to be opaque or not. An opaque window will draw it's background - * and it's content. A non opaque window will only draw it's content. - * - * @param opaque True if the window should be opaque, false otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque); - - /** - * Checks if the window is opaque. - * - * @return True if the window is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque(); - - /** - * Resizes the window to fit the content. - */ - virtual void resizeToContent(); - - - // Inherited from BasicContainer - - virtual Rectangle getChildrenArea(); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent); - - virtual void mouseDragged(MouseEvent& mouseEvent); - - virtual void mouseReleased(MouseEvent& mouseEvent); - - protected: - /** - * Holds the caption of the window. - */ - std::string mCaption; - - /** - * Holds the alignment of the caption. - */ - Graphics::Alignment mAlignment; - - /** - * Holds the padding of the window. - */ - unsigned int mPadding; - - /** - * Holds the title bar height of the window. - */ - unsigned int mTitleBarHeight; - - /** - * True if the window is movable, false otherwise. - */ - bool mMovable; - - /** - * True if the window is opaque, false otherwise. - */ - bool mOpaque; - - /** - * Holds a drag offset as an x coordinate where the drag of the window - * started if the window is being dragged. It's used to move the window - * correctly when dragged. - */ - int mDragOffsetX; - - /** - * Holds a drag offset as an y coordinate where the drag of the window - * started if the window is being dragged. It's used to move the window - * correctly when dragged. - */ - int mDragOffsetY; - - /** - * True if the window is being moved, false otherwise. - */ - bool mMoved; - }; -} - -#endif // end GCN_WINDOW_HPP |