00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #pragma once
00029 #ifndef COMPONENT_H
00030 #define COMPONENT_H
00031
00032 #include ".\Pointers.h"
00033 #include ".\util\Rectangle.h"
00034 #include ".\util\Dimension.h"
00035 #include ".\util\Point.h"
00036 #include ".\util\Insets.h"
00037 #include ".\util\Color.h"
00038
00039 namespace ui
00040 {
00046 class Component
00047 {
00048 public:
00052 Component();
00053
00059 Component(const Component& rhs);
00060
00068 Component& operator=(const Component& rhs);
00069
00075 virtual ~Component();
00076
00081 void swap(Component& rhs) throw();
00082
00089 virtual void setEnabled(bool enable);
00090
00094 bool isEnabled() const;
00095
00103 void setVisible(bool visible);
00104
00116 bool isVisible() const;
00117
00123 virtual void invalidate();
00124
00128 virtual void validate();
00129
00137 bool isValid() const;
00138
00145 void setParent(Component* parent);
00146
00154 Component* getParent() const;
00155
00164 void paint(Graphics& g);
00165
00166 protected:
00173 virtual void paintComponent(Graphics& g);
00174
00180 virtual void paintChildren(Graphics& g);
00181
00188 void paintBorder(Graphics& g);
00189
00198 virtual void paintSelectionComponent(Graphics &g);
00199
00206 virtual void validateTree() {};
00207
00208 public:
00218 const util::Paint* getForeground() const;
00219
00225 void setForeground(util::Paint* c);
00226
00236 const util::Paint* getBackground() const;
00237
00243 void setBackground(util::Paint* c);
00244
00252 void setTheme(theme::ThemeComponent *theme);
00253
00258 void resetTheme();
00259
00267 void setThemeName(const std::string &name);
00268
00272 const std::string & getThemeName() const;
00273
00277 const theme::ThemeComponent* getTheme() const;
00278
00287 void setLocation(int x, int y);
00288
00296 void setLocation(const util::Point& p);
00297
00310 const util::Point getLocation() const;
00311
00320 const util::Point getLocationOnScreen() const;
00321
00333 void setBounds(int x, int y, int width, int height);
00334
00340 void setBounds(const util::Rectangle& rhs);
00341
00350 const util::Rectangle& getBounds() const;
00351
00365 virtual const util::Dimension& getPreferredSize() const;
00366
00374 void setPreferredSize(const util::Dimension& d);
00375
00384 void setSize(int width, int height);
00385
00392 void setSize(const util::Dimension& rhs);
00393
00404 void setDepth(int type);
00405
00411 int getDepth() const;
00412
00418 enum ComponentDepth
00419 {
00423 NORMAL = 8,
00427 NORMAL_MODAL = 4,
00428
00432 POPUP = 2,
00433
00437 POPUP_MODAL = 1
00438 };
00439
00445 virtual bool isContainer() const;
00446
00453 virtual bool isRootContainer() const;
00454
00464 const ComponentList& getChildren() const;
00465
00473 void setBorderPainted(bool enable);
00474
00480 bool isBorderPainted() const;
00481
00487 bool hasBorder() const;
00488
00496 void setBorder(border::Border* b);
00497
00501 border::Border * getBorder() const;
00502
00513 void setInsets(const util::Insets& i);
00514
00520 const util::Insets& getInsets() const;
00521
00529 void setFont(Font* font);
00530
00536 Font* getFont() const;
00537
00541 enum CONSTANTS
00542 {
00546 LEFT,
00550 RIGHT,
00554 CENTER
00555 };
00556
00563 void processMouseEvent(const event::MouseEvent& e);
00564
00570 bool hasMouseListener() const;
00571
00577 void addMouseListener(event::MouseListener* l);
00578
00584 void removeMouseListener(event::MouseListener* l);
00585
00589 void removeMouseListeners();
00590
00596 bool hasFocus() const;
00597
00603 void setFocus(bool enable);
00604
00610 void processFocusEvent(const event::FocusEvent& e);
00611
00617 void addFocusListener(event::FocusListener* l);
00618
00624 void removeFocusListener(event::FocusListener* l);
00625
00629 void removeFocusListeners();
00630
00636 const event::FocusListenerList getFocusListeners() const;
00637
00643 bool hasFocusListener() const;
00644
00652 virtual bool canHoldPermanentFocus() const;
00653
00659 void addKeyListener(event::KeyListener* l);
00660
00666 void removeKeyListener(event::KeyListener* l);
00667
00671 void removeKeyListeners();
00672
00678 const event::KeyListenerList getKeyListeners() const;
00679
00685 bool hasKeyListener() const;
00686
00692 void processKeyEvent(const event::KeyEvent& e);
00693
00699 void processPropertyEvent(const event::PropertyEvent& e);
00700
00706 void addPropertyListener(event::PropertyListener* l);
00707
00713 void removePropertyListener(event::PropertyListener* l);
00714
00718 void removePropertyListeners();
00719
00725 const event::PropertyListenerList getPropertyListeners() const;
00726
00732 bool hasPropertyListener() const;
00733
00740 virtual void updateComponent(float deltaTime);
00741
00746 void addInterpolator(util::Interpolator* i);
00747
00753 void removeInterpolator(util::Interpolator* i);
00754
00758 void removeInterpolators();
00759
00767 void setTransparency(float f);
00768
00775 float getTransparency() const;
00776
00783 void setRotation(float r);
00784
00790 float getRotation() const;
00791
00792 private:
00793 bool visible, valid, borderPainted, focus,enabled;
00794
00799 float transparency;
00800
00804 event::MouseListenerList mouseListeners;
00805
00809 event::FocusListenerList focusListeners;
00810
00814 event::KeyListenerList keyListeners;
00815
00819 util::InterpolatorList interpolators;
00820
00824 event::PropertyListenerList propertyListeners;
00825
00830 Component* parent;
00831
00835 util::Paint *background;
00836
00840 util::Paint *foreground;
00841
00845 util::Rectangle rec;
00846
00850 border::Border* border;
00851
00855 util::Insets insets;
00856
00860 std::size_t font;
00861
00865 theme::ThemeComponent *theme;
00866
00870 std::string name;
00871
00872 float rotation;
00873
00874
00875
00876
00877
00878 protected:
00882 float depth;
00883
00889 ComponentList componentList;
00890
00899 mutable util::Dimension preferredSize;
00900 };
00901 }
00902 #endif