- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

uwidget.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/widgets/uwidget.hpp 00008 begin : Sun May 13 2001 00009 $Id: uwidget.hpp,v 1.31 2005/10/17 16:39:22 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UWIDGET_HPP 00029 #define UWIDGET_HPP 00030 00031 #include "../uobject.hpp" 00032 00033 #include <map> 00034 00035 // headers in util 00036 #include "../util/ugeom.hpp" 00037 #include "../util/uinsets.hpp" 00038 //#include "../util/uhashmap.hpp" 00039 #include "../util/ustring.hpp" 00040 #include "../util/ucolor.hpp" 00041 #include "../util/upalette.hpp" 00042 00043 #include "../ui/ustyle.hpp" 00044 00045 // headers in events 00046 #include "../events/uevent.hpp" 00047 00048 // headers in layouts 00049 #include "../layouts/ulayoutmanager.hpp" 00050 00051 // headers in signals 00052 #include "../signals/ufo_signals.hpp" 00053 00054 //#include "../ukeystroke.hpp" 00055 00061 #define UFO_UI_CLASS(name) \ 00062 public: \ 00063 virtual std::string getUIClassID() const { \ 00064 return #name; \ 00065 } 00066 00067 #define UFO_STYLE_TYPE(name) \ 00068 public: \ 00069 virtual UStyle::ComponentElement getStyleType() const { \ 00070 return name; \ 00071 } 00072 00073 namespace ufo { 00074 00075 typedef std::map<std::string, UObject*> UPropertiesMap; 00076 00077 00078 // forward declartions 00079 class UColor; 00080 class UFont; 00081 class UBorder; 00082 class UUIManager; 00083 class UWidgetUI; 00084 class URootPane; 00085 00086 class UPopupMenu; 00087 00088 class UDrawable; 00089 00090 class UInputMap; 00091 class UKeyStroke; 00092 00093 class UWidgetUI; 00094 00095 class UContext; 00096 class UUIManager; 00097 class UGraphics; 00098 00099 class UEvent; 00100 class UActionEvent; 00101 class UFocusEvent; 00102 class UKeyEvent; 00103 class UMouseEvent; 00104 class UMouseWheelEvent; 00105 class UPropertyChangeEvent; 00106 class UShortcutEvent; 00107 class UWidgetEvent; 00108 00109 class UStyle; 00110 class UStyleHints; 00111 class UStyleManager; 00112 class UStyleOption; 00113 class UWidgetModel; 00114 00129 class UFO_EXPORT UWidget : public UObject { 00130 UFO_DECLARE_DYNAMIC_CLASS(UWidget) 00131 UFO_UI_CLASS(UWidgetUI) 00132 UFO_STYLE_TYPE(UStyle::CE_Widget) 00133 private: 00134 friend class UWidgetUI; 00135 00136 public: // Public types 00137 // keyboard input conditions 00138 enum InputCondition { 00139 WhenFocused = 1, 00140 WhenAncestorFocused = 2 00141 }; 00142 enum EventState { 00143 NoEvents = 0x0000, 00144 MouseEvents = 0x0001, 00145 MouseMotionEvents = 0x0002, 00146 MouseWheelEvents = 0x0004, 00147 KeyEvents = 0x0008, 00148 WidgetEvents = 0x0010, 00149 FocusEvents = 0x0020 00150 }; 00151 public: 00152 UWidget(); 00153 UWidget(ULayoutManager * layout); 00154 virtual ~UWidget(); 00155 00160 virtual bool isVisible() const; 00169 virtual void setVisible(bool v); 00170 00176 void setClipping(bool b); 00178 bool hasClipping() const; 00179 00181 bool isEnabled() const; 00190 void setEnabled(bool b); 00194 bool isOpaque() const; 00200 virtual void setOpaque(bool o); 00201 00209 virtual bool isActive() const; 00210 00221 virtual bool isInValidHierarchy() const; 00224 bool isValid() const; 00229 virtual void validate(); 00230 virtual void validateSelf(); 00231 00237 virtual void invalidateSelf(); 00240 void invalidate(); 00241 00244 void invalidateTree(); 00245 00249 00250 00252 int getX() const; 00254 int getY() const; 00256 int getWidth() const; 00258 int getHeight() const; 00260 void setLocation(int x, int y); 00262 void setLocation(const UPoint & p); 00264 virtual UPoint getLocation() const; 00265 00267 void setSize(int w, int h); 00269 void setSize(const UDimension & d); 00271 virtual UDimension getSize() const; 00273 UDimension getInnerSize() const; 00274 00278 virtual void setBounds(int x, int y, int w, int h); 00280 void setBounds(const URectangle & b); 00282 virtual URectangle getBounds() const; 00288 URectangle getInnerBounds() const; 00293 URectangle getRootBounds() const; 00298 URectangle getClipBounds() const; 00299 00300 00301 00305 bool contains(int x, int y) const; 00307 bool contains(const UPoint & p) const; 00311 bool containsRootPoint(int x, int y) const; 00313 bool containsRootPoint(const UPoint & p) const; 00314 00320 UPoint pointToRootPoint(int x, int y) const; 00322 UPoint pointToRootPoint(const UPoint & p) const; 00323 00329 UPoint rootPointToPoint(int x, int y) const; 00331 UPoint rootPointToPoint(const UPoint & p) const; 00332 00336 UPoint getRootLocation() const; 00337 00338 00339 // 00340 // painting and UI methods 00341 // 00342 00343 00353 virtual void paint(UGraphics * g); 00354 00358 void repaint(); 00359 00360 00362 virtual UStyleManager * getStyleManager() const; 00363 00365 UStyle * getStyle() const; 00371 void setStyle(UStyle * style); 00373 const UStyleHints * getStyleHints() const; 00375 void setStyleHints(UStyleHints * hints); 00376 00380 void setCssType(const std::string & type); 00382 std::string getCssType() const; 00387 void setCssClass(const std::string & cssClass); 00389 std::string getCssClass() const; 00390 00394 UContext * getContext() const; 00395 00403 void setContext(UContext * context); 00404 00406 UUIManager * getUIManager() const; 00407 00409 UGraphics * getGraphics() const; 00410 00411 00412 // 00413 // several attribute methods 00414 // 00415 00416 // 00417 // style hints 00418 // 00419 float getOpacity() const; 00425 virtual void setOpacity(float f); 00426 00428 void setPalette(const UPalette & palette); 00430 const UPalette & getPalette() const; 00431 00437 void setBackgroundColor(const UColor & col); 00439 const UColor & getBackgroundColor() const; 00440 00446 void setForegroundColor(const UColor & col); 00448 const UColor & getForegroundColor() const; 00449 00453 bool hasBackground() const; 00457 void setBackground(UDrawable * tex); 00459 UDrawable * getBackground() const; 00460 00462 void setFont(const UFont & font); 00464 const UFont & getFont() const; 00466 void setBorder(BorderType borderType); 00468 BorderType getBorder() const; 00469 00470 00476 void setMargin(const UInsets & margin); 00482 void setMargin(int top, int left, int bottom, int right); 00483 00488 const UInsets & getMargin() const; 00489 00493 virtual UInsets getInsets() const; 00494 00495 00497 void setMinimumSize(const UDimension & minimumSize); 00499 UDimension getMinimumSize() const; 00500 00509 void setPreferredSize(const UDimension & preferredSize); 00510 00512 void setMaximumSize(const UDimension & maximumSize); 00514 UDimension getMaximumSize() const; 00515 00520 void setHorizontalAlignment(Alignment alignX); 00522 Alignment getHorizontalAlignment() const; 00527 void setVerticalAlignment(Alignment alignY); 00529 Alignment getVerticalAlignment() const; 00530 00536 void setDirection(Direction dir); 00538 Direction getDirection() const; 00543 void setOrientation(Orientation orientation); 00545 Orientation getOrientation() const; 00546 00547 // 00548 // generic methods 00549 // 00550 00554 virtual bool isFocused() const; 00556 virtual bool isChildFocused() const; 00558 virtual bool isAncestorFocused() const; 00562 virtual UWidget * requestFocus(); 00564 virtual bool releaseFocus(); 00565 00566 virtual bool isFocusable() const; 00568 virtual void setFocusable(bool focusable); 00569 00572 static UWidget * getFocusedWidget(); 00573 00575 bool hasMouseFocus() const; 00576 00579 static UWidget * getMouseFocusWidget(); 00580 00584 00591 void dispatchEvent(UEvent * e); 00592 00593 00594 00595 00599 00604 void setPopupMenu(UPopupMenu * popupMenu); 00607 virtual UPopupMenu * getPopupMenu() const; 00608 00609 00615 virtual bool remove(UWidget * w); 00621 virtual bool remove(unsigned int n); 00631 virtual UWidget * removeAndReturn(unsigned int n); 00635 virtual unsigned int removeAll(); 00642 void add(UWidget * w, int index = -1); 00655 void add(UWidget * w, UObject * constraints, int index = -1); 00669 void add(UWidget * w, const UObject * constraints, int index = -1); 00670 00671 00682 virtual URootPane * getRootPane(bool topmost = false) const; 00683 00687 UWidget * getParent() const; 00688 00689 00693 00696 int getIndexOf(const UWidget * w) const; 00704 void setIndexOf(UWidget * w, int index); 00708 UWidget * getWidget(unsigned int n) const; 00715 UWidget * getWidgetAt(int x, int y) const; 00717 virtual UWidget * getWidgetAt(const UPoint & p) const; 00724 UWidget * getVisibleWidgetAt(int x, int y) const; 00726 virtual UWidget * getVisibleWidgetAt(const UPoint & p) const; 00727 00729 unsigned int getWidgetCount() const; 00730 00732 const std::vector<UWidget*> & getWidgets() const; 00734 std::vector<UWidget*> & getWidgets(); 00735 00736 00740 00742 ULayoutManager * getLayout() const; 00747 void setLayout(ULayoutManager * layout); 00748 00758 virtual UDimension getPreferredSize() const; 00772 virtual UDimension getPreferredSize(const UDimension & maxSize) const; 00773 00777 00784 void put(const std::string & key, UObject * value); 00788 //void put(const std::string & key, int value); 00792 void put(const std::string & key, const std::string & value); 00798 UObject * get(const std::string & key) const; 00804 std::string getString(const std::string & key) const; 00805 00818 UInputMap * getInputMap(InputCondition conditionA = WhenFocused); 00821 void setInputMap(UInputMap * newInputMapA, 00822 InputCondition conditionA = WhenFocused); 00823 00828 void setEventState(UEvent::Type type, bool b); 00831 bool isEventEnabled(UEvent::Type type) const; 00832 00837 const UWidgetModel * getModel() const; 00838 00851 void grabShortcut(const UKeyStroke & stroke); 00855 void releaseShortcut(const UKeyStroke & stroke); 00859 void releaseAllShortcuts(); 00860 00861 protected: // Overrides UObject 00862 virtual std::ostream & paramString(std::ostream & os) const; 00863 00864 protected: // Protected methods 00876 virtual void addImpl(UWidget * w, UObject * constraints, int index); 00880 virtual bool removeImpl(int index); 00881 00885 virtual void addedToHierarchy(); 00887 virtual void removedFromHierarchy(); 00888 00892 void doLayout(); 00893 00898 virtual void paintWidget(UGraphics * g); 00900 virtual void paintBorder(UGraphics * g); 00902 virtual void paintChildren(UGraphics * g); 00903 00904 00907 virtual void processEvent(UEvent * e); 00908 00911 virtual void processMouseEvent(UMouseEvent * e); 00914 virtual void processMouseWheelEvent(UMouseWheelEvent * e); 00917 virtual void processKeyEvent(UKeyEvent * e); 00918 virtual void processShortcutEvent(UShortcutEvent * e); 00921 virtual void processFocusEvent(UFocusEvent * e); 00924 virtual void processWidgetEvent(UWidgetEvent * e); 00925 00926 virtual void processStyleHintChange(uint32_t styleHint); 00927 virtual void processStateChangeEvent(uint32_t state); 00928 00929 00932 bool firePropertyChangeEvent(const std::string & prop, 00933 UObject * oldValue, UObject * newValue); 00934 00937 bool fireMouseEvent(UMouseEvent * e); 00938 00941 bool fireKeyEvent(UKeyEvent * e); 00942 00945 bool fireFocusEvent(UFocusEvent * e); 00948 bool fireWidgetEvent(UWidgetEvent * e); 00949 00950 bool notifyKeyBindingAction(const UKeyStroke & ks, UKeyEvent * e, 00951 InputCondition condition); 00955 virtual bool processKeyBindings(UKeyEvent * e); 00956 00960 void resetFocus(); 00961 00962 virtual UDimension getContentsSize(const UDimension & maxSize) const; 00963 void detachStyleHints(); 00964 00965 public: // Protected methods 00966 bool testState(uint32_t state) const; 00967 void setState(uint32_t state, bool b = true); 00968 void setStates(uint32_t states); 00969 uint32_t getStates() const; 00970 00971 private: 00975 void setChildrenVisible(bool b); 00979 void setChildrenEnabled(bool b); 00980 00981 protected: // Protected static attributes 00983 static UWidget * sm_inputFocusWidget; 00985 static UWidget * sm_mouseFocusWidget; 00987 static UWidget * sm_dragWidget; 00988 00989 protected: // Protected attributes 00991 UContext * m_context; 00992 00993 UWidgetModel * m_model; 00994 00995 private: // Private attributes 00996 // 00997 // flags 00998 // 00999 01001 uint32_t m_isVisible: 1; 01003 uint32_t m_hasClipping: 1; 01005 uint32_t m_isEnabled: 1; 01007 //uint16_t m_isOpaque: 1; 01009 uint32_t m_isFocusable: 1; 01013 uint32_t m_isInValidHierarchy: 1; 01015 uint32_t m_hasInvalidLayout : 1; 01017 uint32_t m_styleHintsDetached : 1; 01018 01019 // 01020 // flags for caching 01021 // 01025 uint32_t m_eventState; 01026 01027 // 01028 // general variables 01029 // 01030 01032 UWidget * m_parent; 01033 01035 std::vector<UWidget*> m_children; 01036 01038 ULayoutManager * m_layout; 01039 01041 UPopupMenu * m_popupMenu; 01042 01043 // 01044 // style hints 01045 // 01046 std::string m_cssType; 01047 std::string m_cssClass; 01048 mutable UStyle * m_style; 01049 mutable UStyleHints * m_styleHints; 01050 01051 // 01052 // size hints 01053 // 01054 01056 URectangle m_bounds; 01057 mutable URectangle m_clipBounds; 01059 mutable UPoint m_cachedRootLocation; 01060 mutable UDimension m_cachedPreferredSize; 01061 01063 //const UColor * m_bgColor; 01065 //const UColor * m_fgColor; 01066 01068 UPropertiesMap m_properties; 01069 01070 UInputMap * m_inputMap; 01071 UInputMap * m_ancestorInputMap; 01072 01073 public: // Public Signals 01074 // Mouse event signals 01076 USignal1<UMouseEvent*> & sigMouseEntered(); 01078 USignal1<UMouseEvent*> & sigMouseExited(); 01079 01083 USignal1<UMouseEvent*> & sigMouseMoved(); 01088 USignal1<UMouseEvent*> & sigMouseDragged(); 01089 01093 USignal1<UMouseEvent*> & sigMousePressed(); 01097 USignal1<UMouseEvent*> & sigMouseReleased(); 01101 USignal1<UMouseEvent*> & sigMouseClicked(); 01102 01106 USignal1<UMouseWheelEvent*> & sigMouseWheel(); 01107 01108 01109 // Key event signals 01113 USignal1<UKeyEvent*> & sigKeyPressed(); 01117 USignal1<UKeyEvent*> & sigKeyReleased(); 01121 USignal1<UKeyEvent*> & sigKeyTyped(); 01122 01123 // Widget event signals 01126 USignal1<UWidgetEvent*> & sigWidgetMoved(); 01129 USignal1<UWidgetEvent*> & sigWidgetResized(); 01132 USignal1<UWidgetEvent*> & sigWidgetShown(); 01135 USignal1<UWidgetEvent*> & sigWidgetHidden(); 01136 01146 USignal1<UWidgetEvent*> & sigWidgetAdded(); 01149 USignal1<UWidgetEvent*> & sigWidgetRemoved(); 01150 01151 // Focus event signals 01153 USignal1<UFocusEvent*> & sigFocusGained(); 01155 USignal1<UFocusEvent*> & sigFocusLost(); 01156 01157 private: // Private Signals 01158 // mouse signals 01159 USignal1<UMouseEvent*> m_sigMouseEntered; 01160 USignal1<UMouseEvent*> m_sigMouseExited; 01161 01162 USignal1<UMouseEvent*> m_sigMouseMoved; 01163 USignal1<UMouseEvent*> m_sigMouseDragged; 01164 01165 USignal1<UMouseEvent*> m_sigMousePressed; 01166 USignal1<UMouseEvent*> m_sigMouseReleased; 01167 USignal1<UMouseEvent*> m_sigMouseClicked; 01168 01169 USignal1<UMouseWheelEvent*> m_sigMouseWheel; 01170 01171 // key signals 01172 USignal1<UKeyEvent*> m_sigKeyPressed; 01173 USignal1<UKeyEvent*> m_sigKeyReleased; 01174 USignal1<UKeyEvent*> m_sigKeyTyped; 01175 01176 // widget signals 01177 USignal1<UWidgetEvent*> m_sigWidgetMoved; 01178 USignal1<UWidgetEvent*> m_sigWidgetResized; 01179 USignal1<UWidgetEvent*> m_sigWidgetShown; 01180 USignal1<UWidgetEvent*> m_sigWidgetHidden; 01181 01182 USignal1<UWidgetEvent*> m_sigWidgetAdded; 01183 USignal1<UWidgetEvent*> m_sigWidgetRemoved; 01184 01185 // focus signals 01186 USignal1<UFocusEvent*> m_sigFocusGained; 01187 USignal1<UFocusEvent*> m_sigFocusLost; 01188 }; 01189 01190 01191 // 01192 // inline implementation 01193 // 01194 01195 // Mouse Motion event signals 01196 inline USignal1<UMouseEvent*> & 01197 UWidget::sigMouseEntered() { 01198 setEventState(UEvent::MouseEntered, true); 01199 return m_sigMouseEntered; 01200 } 01201 inline USignal1<UMouseEvent*> & 01202 UWidget::sigMouseExited() { 01203 setEventState(UEvent::MouseExited, true); 01204 return m_sigMouseExited; 01205 } 01206 inline USignal1<UMouseEvent*> & 01207 UWidget::sigMouseMoved() { 01208 setEventState(UEvent::MouseMoved, true); 01209 return m_sigMouseMoved; 01210 } 01211 inline USignal1<UMouseEvent*> & 01212 UWidget::sigMouseDragged() { 01213 setEventState(UEvent::MouseDragged, true); 01214 return m_sigMouseDragged; 01215 } 01216 01217 // Mouse event signals 01218 inline USignal1<UMouseEvent*> & 01219 UWidget::sigMousePressed() { 01220 setEventState(UEvent::MousePressed, true); 01221 return m_sigMousePressed; 01222 } 01223 inline USignal1<UMouseEvent*> & 01224 UWidget::sigMouseReleased() { 01225 setEventState(UEvent::MouseReleased, true); 01226 return m_sigMouseReleased; 01227 } 01228 inline USignal1<UMouseEvent*> & 01229 UWidget::sigMouseClicked() { 01230 setEventState(UEvent::MouseClicked, true); 01231 return m_sigMouseClicked; 01232 } 01233 01234 inline USignal1<UMouseWheelEvent*> & 01235 UWidget::sigMouseWheel() { 01236 setEventState(UEvent::MouseWheel, true); 01237 return m_sigMouseWheel; 01238 } 01239 01240 // Key event signals 01241 inline USignal1<UKeyEvent*> & 01242 UWidget::sigKeyPressed() { 01243 setEventState(UEvent::KeyPressed, true); 01244 return m_sigKeyPressed; 01245 } 01246 inline USignal1<UKeyEvent*> & 01247 UWidget::sigKeyReleased() { 01248 setEventState(UEvent::KeyReleased, true); 01249 return m_sigKeyReleased; 01250 } 01251 inline USignal1<UKeyEvent*> & 01252 UWidget::sigKeyTyped() { 01253 setEventState(UEvent::KeyTyped, true); 01254 return m_sigKeyTyped; 01255 } 01256 01257 // Widget event signals 01258 inline USignal1<UWidgetEvent*> & 01259 UWidget::sigWidgetMoved() { 01260 setEventState(UEvent::WidgetMoved, true); 01261 return m_sigWidgetMoved; 01262 } 01263 inline USignal1<UWidgetEvent*> & 01264 UWidget::sigWidgetResized() { 01265 setEventState(UEvent::WidgetResized, true); 01266 return m_sigWidgetResized; 01267 } 01268 inline USignal1<UWidgetEvent*> & 01269 UWidget::sigWidgetShown() { 01270 setEventState(UEvent::WidgetShown, true); 01271 return m_sigWidgetShown; 01272 } 01273 inline USignal1<UWidgetEvent*> & 01274 UWidget::sigWidgetHidden() { 01275 setEventState(UEvent::WidgetHidden, true); 01276 return m_sigWidgetHidden; 01277 } 01278 inline USignal1<UWidgetEvent*> & 01279 UWidget::sigWidgetAdded() { 01280 return m_sigWidgetAdded; 01281 } 01282 inline USignal1<UWidgetEvent*> & 01283 UWidget::sigWidgetRemoved() { 01284 return m_sigWidgetRemoved; 01285 } 01286 01287 // Focus event signals 01288 inline USignal1<UFocusEvent*> & 01289 UWidget::sigFocusGained() { 01290 setEventState(UEvent::FocusGained, true); 01291 return m_sigFocusGained; 01292 } 01293 inline USignal1<UFocusEvent*> & 01294 UWidget::sigFocusLost() { 01295 setEventState(UEvent::FocusLost, true); 01296 return m_sigFocusLost; 01297 } 01298 01299 01300 01301 // 01302 // inline position 01303 // 01304 01305 inline int 01306 UWidget::getX() const { 01307 return m_bounds.x; 01308 } 01309 inline int 01310 UWidget::getY() const { 01311 return m_bounds.y; 01312 } 01313 inline int 01314 UWidget::getWidth() const { 01315 return m_bounds.w; 01316 } 01317 inline int 01318 UWidget::getHeight() const { 01319 return m_bounds.h; 01320 } 01321 01322 inline void 01323 UWidget::setLocation(int x, int y) { 01324 setBounds(x, y, m_bounds.w, m_bounds.h); 01325 } 01326 inline void 01327 UWidget::setLocation(const UPoint & p) { 01328 setLocation(p.x, p.y); 01329 } 01330 inline UPoint 01331 UWidget::getLocation() const { 01332 return UPoint(m_bounds.x, m_bounds.y); 01333 } 01334 01335 inline void 01336 UWidget::setSize(int w, int h) { 01337 setBounds(m_bounds.x, m_bounds.y, w, h); 01338 } 01339 inline void 01340 UWidget::setSize(const UDimension & d) { 01341 setSize(d.w, d.h); 01342 } 01343 inline UDimension 01344 UWidget::getSize() const { 01345 return UDimension(m_bounds.w, m_bounds.h); 01346 } 01347 inline UDimension 01348 UWidget::getInnerSize() const { 01349 UDimension ret(getSize()); 01350 return ret - getInsets(); 01351 } 01352 01353 inline void 01354 UWidget::setBounds(const URectangle & b) { 01355 setBounds(b.x, b.y, b.w, b.h); 01356 } 01357 inline URectangle 01358 UWidget::getInnerBounds() const { 01359 URectangle ret(0, 0, getWidth(), getHeight()); 01360 return ret - getInsets(); 01361 } 01362 inline URectangle 01363 UWidget::getRootBounds() const { 01364 return URectangle(getRootLocation(), getSize()); 01365 } 01366 01367 01368 inline bool 01369 UWidget::contains(int x, int y) const { 01370 return (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()); 01371 } 01372 01373 inline bool 01374 UWidget::contains(const UPoint & p) const { 01375 return (p.x >= 0 && p.x < getWidth() && p.y >= 0 && p.y < getHeight()); 01376 } 01377 01378 inline UPoint 01379 UWidget::pointToRootPoint(const UPoint & p) const { 01380 return (p + getRootLocation()); 01381 } 01382 01383 inline UPoint 01384 UWidget::pointToRootPoint(int x, int y) const { 01385 return pointToRootPoint(UPoint(x, y)); 01386 } 01387 01388 inline UPoint 01389 UWidget::rootPointToPoint(const UPoint & p) const { 01390 return (p - getRootLocation()); 01391 } 01392 01393 inline UPoint 01394 UWidget::rootPointToPoint(int x, int y) const { 01395 return rootPointToPoint(UPoint(x, y)); 01396 } 01397 01398 inline bool 01399 UWidget::containsRootPoint(int x, int y) const { 01400 return contains(rootPointToPoint(x, y)); 01401 } 01402 01403 inline bool 01404 UWidget::containsRootPoint(const UPoint & p) const { 01405 return contains(rootPointToPoint(p)); 01406 } 01407 01408 01409 inline void 01410 UWidget::add(UWidget * w, int index) { 01411 addImpl(w, NULL, index); 01412 } 01413 inline void 01414 UWidget::add(UWidget * w, UObject * constraints, int index) { 01415 addImpl(w, constraints, index); 01416 } 01417 01418 } // namespace ufo 01419 01420 #endif // UWIDGET_HPP

The libUFO Project - written by Johannes Schmidt