Talk:New Theme Engine
From SkyOS
Contents |
[edit]
Alex Forster
This theme engine is very interesting. What inspired you to get this object-oriented? Can you post the code to the example with all the images being used?
[edit]
Robert
Which code do you mean? To make a theme like WindUI you just need the Settings File and the images. No need to write any code.
[edit]
Alex Forster
Oh, that clears some things up. Is any of it accessible from an API to theme on a per-widget basis? Or could there be a manifest-esque file that a developer could put in the same place as their .app and theme only their program?
[edit]
Robert
Theoretically every app can use its own theme by setting the THEME environment variable in a static constructor. Regarding the interface:
enum ThemeWindowType
{
THEME_WINDOW_TYPE_BUTTON,
THEME_WINDOW_TYPE_TITLEWINDOW,
};
enum ThemeProperty
{
THEME_PROPERTY_TITLE_HEIGHT,
THEME_PROPERTY_BUTTON_HEIGHT,
THEME_PROPERTY_SCROLLBAR_WIDTH,
THEME_PROPERTY_SCROLLBAR_HEIGHT,
THEME_PROPERTY_SCROLLBAR_BUTTON_WIDTH,
THEME_PROPERTY_SCROLLBAR_BUTTON_HEIGHT,
THEME_PROPERTY_SCROLLBAR_INDICATOR_MIN_SIZE,
THEME_PROPERTY_POPUP_OPEN_ON_MOVE,
THEME_PROPERTY_MENU_BAR_HEIGHT,
THEME_PROPERTY_STATUS_BAR_HEIGHT,
THEME_PROPERTY_LISTVIEW_HEADER_HEIGHT,
THEME_PROPERTY_PROGRESSBAR_HEIGHT,
THEME_PROPERTY_DESKTOP_ICON_TEXT_COLOR,
THEME_PROPERTY_DESKTOP_ICON_BACK_COLOR,
THEME_PROPERTY_DESKTOP_ICON_TEXT_COLOR_SELECTED,
THEME_PROPERTY_DESKTOP_ICON_BACK_COLOR_SELECTED,
THEME_PROPERTY_FRAME_COLOR,
THEME_PROPERTY_TREE_IMAGE_EXPANDED,
THEME_PROPERTY_TREE_IMAGE_COLLAPSED,
THEME_PROPERTY_TAB_HEIGHT,
THEME_PROPERTY_TAB_VIEW_BORDER,
THEME_PROPERTY_PROGRESS_BRUSH,
THEME_PROPERTY_PROGRESS_BORDER,
THEME_PROPERTY_GROUP_VIEW_BORDER,
THEME_PROPERTY_CLIENT_BACKGROUND_COLOR,
THEME_PROPERTY_DONT_DRAW_FRAME_BORDER_WITH_BACKGROUND,
THEME_PROPERTY_STATUS_BAR_ACTS_AS_FRAME,
THEME_PROPERTY_TAB_VIEW_HEADER_SIZE,
THEME_PROPERTY_APPLICATION_WINDOW_MIN_SIZE_WIDTH,
THEME_PROPERTY_APPLICATION_WINDOW_MIN_SIZE_HEIGHT,
THEME_PROPERTY_APPLICATION_WINDOW_DEFAULT_COLOR,
THEME_PROPERTY_APPLICATION_WINDOW_DEFAULT_BACKGROUND_COLOR
};
enum ThemeImage
{
THEME_IMAGE_MENU_CHILD_ARROW = 0,
THEME_IMAGE_RADIO_BUTTON_OFF,
THEME_IMAGE_RADIO_BUTTON_ON,
};
class Theme : public Object
{
public:
Theme();
virtual ~Theme();
virtual void DrawTitle(TitleWindow *pWindow)=0;
virtual void DrawButtonBackground(Button *pWindow)=0;
virtual void DrawFrameBackground(Window *pWindow, const Rect& rRect)=0;
virtual void DrawControlBackground(Painter *m_pPainter, const Rect& rRect)=0;
virtual void DrawEditWindow(Window *pWindow, const Rect& rRect)=0;
virtual void DrawInnerFrame(ApplicationWindow *pWindow, int iTopGap = 0, int iBottomGap = 0)=0;
virtual void DrawOuterFrame(ApplicationWindow *pWindow)=0;
virtual int GetProperty(ThemeProperty nProperty)=0;
virtual int GetFrameWidth(FrameWidthPosition nPos)=0;
virtual int GetInnerWindowMargin(InnerWindowMargin nPos)=0;
virtual void ApplyWindowShape(ApplicationWindow *pWindow)=0;
virtual void TitleWindowFlagsChanged(TitleWindow *pWindow)=0;
virtual TitleWindowAction TitleWindowMouseEvent(TitleWindow *pWindow, const InputEvent& nInputEvent)=0;
virtual Point TitleGetPreferredSize(TitleWindow *pWindow)=0;
virtual void WindowCreated(Window *pWindow, ThemeWindowType nThemeWindowType)=0;
virtual void DrawScrollBar(ScrollBar *pWindow, const Rect& rDirty)=0;
virtual void DrawScrollBarIndicator(ScrollBar *pWindow, const Rect& rDirty)=0;
virtual Image* GetImage(int iID)=0;
virtual void DrawStatusBar(Window *pWindow, const Rect& rDirty)=0;
virtual void DrawCheckBox(CheckBox *pWindow, const Rect& rDirty)=0;
virtual Point CheckBoxGetPreferredSize(CheckBox *pWindow)=0;
virtual void DrawListView(Window *pWindow, const Rect& rDirty)=0;
virtual void DrawListViewHeader(ListViewHeader *pListViewHeader, const Rect& rRect, int iColumnIndex, ListViewColumn *pColumn)=0;
virtual void DrawProgressBar(ProgressBar *pWindow, const Rect& rDirty)=0;
virtual void DrawSplitterGrip(SplitterSeperator *pSplitter)=0;
virtual void DrawTab(TabView *pWindow, TabViewEntry *pEntry, bool bFirst, bool bLast)=0;
virtual void DrawTabView(TabView *pWindow)=0;
virtual bool GetAlign(const String& cKey, const String& cSuffix, int& iAlign, int iDefaultAlign)=0;
virtual bool Get(const String& cKey, const String& cSuffix, Image** ppImage, int iIndex)=0;
virtual bool Get(const String& cKey, const String& cSuffix, Font** pFont, SystemFont nDefaultFont = DEFAULT_FONT_NORMAL, int iDefaultSize = 8)=0;
virtual bool Get(const String& cKey, const String& cSuffix, Variant& pVariant, int iIndex = 0)=0;
virtual bool Get(const String& cKey, const String& cSuffix, String& cString, int iIndex = 0)=0;
virtual bool Get(const String& cKey, const String& cSuffix, int& iValue, int iIndex = 0)=0;
virtual bool Get(const String& cKey, const String& cSuffix, long long& llValue, int iIndex = 0)=0;
virtual bool Get(const String& cKey, const String& cSuffix, bool& bBool, int iIndex = 0)=0;
virtual bool Get(const String& cKey, const String& cSuffix, Color& nColor, int iIndex = 0)=0 ;
virtual void Get(const String& szKey, const String& szSuffix, BrushAssembly& pBrush, int iIndex = 0)=0;
private:
};
