00001 #ifndef MYTHUI_BUTTON_H_
00002 #define MYTHUI_BUTTON_H_
00003
00004 #include <qstring.h>
00005
00006 #include "mythuitype.h"
00007 #include "mythuistatetype.h"
00008 #include "mythuitext.h"
00009 #include "mythuiimage.h"
00010 #include "mythfontproperties.h"
00011
00012
00013
00014
00015
00016
00017
00018
00019 class MythUIButton : public MythUIType
00020 {
00021 Q_OBJECT
00022 public:
00023 enum StateType { None = 0, Normal, Disabled, Active, Selected,
00024 SelectedInactive };
00025
00026 MythUIButton(MythUIType *parent, const char *name, bool doInit = true);
00027 ~MythUIButton();
00028
00029 void SetBackgroundImage(StateType state, MythImage *image);
00030 void SetCheckImage(MythUIStateType::StateType state, MythImage *image);
00031 void SetTextRect(const QRect &textRect);
00032 void SetFont(StateType state, MythFontProperties &prop);
00033 void SetButtonImage(MythImage *image);
00034 void SetRightArrowImage(MythImage *image);
00035 void SetPaddingMargin(int margin);
00036
00037 void SetText(const QString &msg, int textFlags = -1);
00038 QString GetText() const { return m_Text->GetText(); }
00039
00040 void SelectState(StateType newState);
00041 void SetCheckState(MythUIStateType::StateType state);
00042 void EnableCheck(bool enable);
00043 void EnableRightArrow(bool enable);
00044
00045 void SetupPlacement(void);
00046
00047 public slots:
00048 void Select() { SelectState(Selected); }
00049 void Deselect() { SelectState(Normal); }
00050
00051 signals:
00052 void buttonPressed();
00053
00054 protected:
00055 virtual bool ParseElement(QDomElement &element);
00056 virtual void CopyFrom(MythUIType *base);
00057 virtual void CreateCopy(MythUIType *parent);
00058 virtual bool keyPressEvent(QKeyEvent *);
00059
00060 void Init(void);
00061
00062 MythImage* LoadImage(QDomElement element);
00063
00064 MythUIStateType *m_BackgroundImage;
00065 MythUIText *m_Text;
00066 MythUIStateType *m_CheckImage;
00067 MythUIImage *m_ButtonImage;
00068 MythUIImage *m_ArrowImage;
00069
00070 QMap<int, MythFontProperties> m_FontProps;
00071
00072 StateType m_State;
00073
00074 QRect m_TextRect;
00075 int m_PaddingMargin;
00076 int m_textFlags;
00077 };
00078
00079 #endif