📄 widget.h
字号:
*/ virtual void setDisabledColor(const Color& color); /** * Gets the disabled color. * * @return the disabled Color. */ virtual const Color& getDisabledColor() const; /** * Called when a Widget recieves a MouseInput. * * WARNING: This function is used internally to handle all mouse * messages. Don't call or overload it unless you know what * you are doing. * * @param mouseInput the MouseInput message. */ virtual void _mouseInputMessage(const MouseInput& mouseInput); /** * Called when a Widget recieves a KeyInput. * * WARNING: This function is used internally to handle all key * messages. Don't call or overload it unless you know what * you are doing. * * @param keyInput the KeyInput message. */ virtual bool _keyInputMessage(const KeyInput& keyInput); /** * Called when a Widget's hot key is pressed */ virtual void hotKeyPress() {} /** * Called when a Widget's hot key is released */ virtual void hotKeyRelease() {} /** * Called when the mouse enters the Widget area. * * WARNING: This function is used internally to handle mouse in * messages. Don't call or overload this function unless * you know what you are doing. */ virtual void _mouseInMessage(); /** * Called when the mouse leaves the Widget area. * * WARNING: This function is used internally be to handle mouse * out messages. Don't call or overload this function * unless you know what you are doing. */ virtual void _mouseOutMessage(); /** * Requests focus for the Widget. A Widget will only recieve focus * if it is focusable. */ virtual void requestFocus(); /** * Requests a move to the top in the parent Widget. */ virtual void requestMoveToTop(); /** * Requests a move to the bottom in the parent Widget. */ virtual void requestMoveToBottom(); /** * Sets the FocusHandler to be used. * * WARNING: This function is used internally and should not * be called or overloaded unless you know what you * are doing. * * @param focusHandler the FocusHandler to use. */ virtual void _setFocusHandler(FocusHandler* focusHandler); /** * Gets the FocusHandler used. * * WARNING: This function is used internally and should not * be called or overloaded unless you know what you * are doing. * * @return the FocusHandler used. */ virtual FocusHandler* _getFocusHandler(); /** * Adds an ActionListener to the Widget. When an action is triggered * by the Widget, the action function in all the Widget's * ActionListeners will be called. * * @param actionListener the ActionListener to add. */ virtual void addActionListener(ActionListener* actionListener); /** * Removes an added ActionListener from the Widget. * * @param actionListener the ActionListener to remove. */ virtual void removeActionListener(ActionListener* actionListener); /** * Adds a MouseListener to the Widget. When a mouse message is * recieved, it will be sent to the Widget's MouseListeners. * * @param mouseListener the MouseListener to add. */ virtual void addMouseListener(MouseListener* mouseListener); /** * Removes an added MouseListener from the Widget. * * @param mouseListener the MouseListener to remove. */ virtual void removeMouseListener(MouseListener* mouseListener); /** * Adds a KeyListener to the Widget. When a key message is recieved, * it will be sent to the Widget's KeyListeners. * * @param keyListener the KeyListener to add. */ virtual void addKeyListener(KeyListener* keyListener); /** * Removes an added KeyListener from the Widget. * * @param keyListener the KeyListener to remove. */ virtual void removeKeyListener(KeyListener* keyListener); /** * Sets the event identifier of the Widget. The event identifier is * used to be able to identify which Widget generated an action when * an action has occured. * * NOTE: An event identifier should not be used to identify a certain * Widget but rather a certain event in your application. Several * Widgets can have the same event identifer. * * @param eventId the event identifier. */ virtual void setEventId(const std::string& eventId); /** * Gets the event identifier. * * @return the event identifier. */ virtual const std::string& getEventId() const; /** * Gets the absolute position on the screen for the Widget. * * @param x absolute x coordinate will be stored in this parameter. * @param y absolute y coordinate will be stored in this parameter. */ virtual void getAbsolutePosition(int& x, int& y) const; /** * Sets the parent of the Widget. A parent must be a BasicContainer. * * WARNING: This function is used internally and should not * be called or overloaded unless you know what you * are doing. * * @param parent the parent BasicContainer.. */ virtual void _setParent(BasicContainer* parent); /** * Gets the font used. If no font has been set, the global font will * be returned instead. If no global font has been set, the default * font will be returend. * ugly default. * * @return the used Font. */ Font *getFont() const; /** * Sets the global font to be used by default for all Widgets. * * @param font the global Font. */ static void setGlobalFont(Font* font); /** * Sets the font. If font is NULL, the global font will be used. * * @param font the Font. */ virtual void setFont(Font* font); /** * Called when the font has changed. If the change is global, * this function will only be called if the Widget don't have a * font already set. */ virtual void fontChanged() { } /** * Get the hot key */ virtual int getHotKey() const { return mHotKey; } /** * Set the hot key */ virtual void setHotKey(const int key); virtual void setHotKey(const char *key); /** * Checks whether a Widget exists or not, that is if it still exists * an instance of the object. * * @param widget the Widget to check. */ static bool widgetExists(const Widget* widget); /** * Check if tab in is enabled. Tab in means that you can set focus * to this Widget by pressing the tab button. If tab in is disabled * then the FocusHandler will skip this widget and focus the next * in its focus order. * * @return true if tab in is enabled. */ virtual bool isTabInEnabled() const; /** * Sets tab in enabled. Tab in means that you can set focus * to this Widget by pressing the tab button. If tab in is disabled * then the FocusHandler will skip this widget and focus the next * in its focus order. * * @param enabled true if tab in should be enabled. */ virtual void setTabInEnabled(bool enabled); /** * Checks if tab out is enabled. Tab out means that you can lose * focus to this Widget by pressing the tab button. If tab out is * disabled then the FocusHandler ignores tabbing and focus will * stay with this Widget. * * @return true if tab out is enabled. */ virtual bool isTabOutEnabled() const; /** * Sets tab out enabled. Tab out means that you can lose * focus to this Widget by pressing the tab button. If tab out is * disabled then the FocusHandler ignores tabbing and focus will * stay with this Widget. * * @param enabled true if tab out should be enabled. */ virtual void setTabOutEnabled(bool enabled); /** * Checks if the Widget is dragged. Dragged means that the mouse * button has been pressed down over the Widget and the mouse has * been moved. * * @return true if the widget is dragged. */ virtual bool isDragged() const; /** * Requests modal focus. When a widget has modal focus, only that * Widget and it's children may recieve input. If some other Widget * already has modal focus, an exception will be thrown. * * @throws Exception if another Widget already has modal focus. */ virtual void requestModalFocus(); /** * Releases modal focus. Modal focus will only be released if the * Widget has the modal focus. */ virtual void releaseModalFocus(); /** * Checks if the Widget or it's parent has modal focus. */ virtual bool hasModalFocus() const; protected: /** * Generates an action to the Widget's ActionListeners. */ void generateAction(); typedef std::list<MouseListener*> MouseListenerList; MouseListenerList mMouseListeners; typedef MouseListenerList::iterator MouseListenerIterator; typedef std::list<KeyListener*> KeyListenerList; KeyListenerList mKeyListeners; typedef KeyListenerList::iterator KeyListenerIterator; typedef std::list<ActionListener*> ActionListenerList; ActionListenerList mActionListeners; typedef ActionListenerList::iterator ActionListenerIterator; Color mForegroundColor; Color mBackgroundColor; Color mBaseColor; Color mDisabledColor; FocusHandler* mFocusHandler; BasicContainer* mParent; Rectangle mDimension; unsigned int mBorderSize; std::string mEventId; int mClickTimeStamp; int mClickCount; int mClickButton; bool mHasMouse; bool mFocusable; bool mVisible; bool mTabIn; bool mTabOut; bool mEnabled; Font* mCurrentFont; int mHotKey; static DefaultFont mDefaultFont; static Font* mGlobalFont; static std::list<Widget*> mWidgets; }; }#endif // end GCN_WIDGET_HPP/* * yakslem - "I have a really great idea! Why not have an * interesting and funny quote or story at the * end of every source file." * finalman - "Yeah - good idea! .... do you know any funny * quotes?" * yakslem - "Well.. I guess not. I just thought it would be * fun to tell funny quotes." * finalman - "That's not a very funny quote. But i believe * pointless quotes are funny in their own pointless * way." * yakslem - "...eh...ok..." */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -