From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- popup/src/skin.h | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 popup/src/skin.h (limited to 'popup/src/skin.h') diff --git a/popup/src/skin.h b/popup/src/skin.h new file mode 100644 index 0000000..fb9890f --- /dev/null +++ b/popup/src/skin.h @@ -0,0 +1,203 @@ +/* +Popup Plus plugin for Miranda IM + +Copyright © 2002 Luca Santarelli, + © 2004-2007 Victor Pavlychko + © 2010 MPK + © 2010 Merlin_de + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +=============================================================================== + +File name : $HeadURL: http://svn.miranda.im/mainrepo/popup/trunk/src/skin.h $ +Revision : $Revision: 1620 $ +Last change on : $Date: 2010-06-23 21:31:05 +0300 (Ср, 23 июн 2010) $ +Last change by : $Author: Merlin_de $ + +=============================================================================== +*/ + +#ifndef __skin_h__ +#define __skin_h__ + +#include +#include + +class MyBitmap; +class PopupWnd2; + +class PopupSkin +{ +public: + enum + { + ST_TYPEMASK = 0x07, + ST_NOTHING = 0x00, + ST_ICON = 0x01, + ST_TEXT = 0x02, + ST_TITLE = 0x03, + ST_BITMAP = 0x04, + ST_MYBITMAP = 0x05, + ST_AVATAR = 0x06, + ST_CLOCK = 0x07, + + ST_STRETCH = 0x08, + ST_MONO = 0x10, + ST_BLEND = 0x20, + ST_BADPOS = 0x40 + }; + + enum + { + DF_STATIC = 0x01, + DF_ANIMATE = 0x02, + DF_ALL = 0xff + }; + + enum + { + // left, separator, digits, am/pm, right + CLOCK_LEFT = 0, + CLOCK_SEPARATOR = 1, + CLOCK_DIGITS = 2, + CLOCK_AM = 12, + CLOCK_PM = 13, + CLOCK_RIGHT = 14, + CLOCK_ITEMS = 1+1+10+2+1 + }; + + struct SKINELEMENT + { + int type; + union + { + HICON hic; + HBITMAP hbm; + MyBitmap *myBmp; + struct + { + COLORREF textColor; + HFONT hfn; +// int textw; + }; + }; + unsigned long flags; + unsigned long flag_mask; + Formula fx, fy, fw, fh; + int clocksize[CLOCK_ITEMS]; + int clockstart[CLOCK_ITEMS]; + int proportional; + SKINELEMENT *next; + }; + + struct RenderInfo + { + bool hasAvatar; + int titlew, textw; + int realtextw, texth; + int actw; + RECT textRect; + }; + +private: + LPTSTR m_name; + int m_bottom_gap, m_right_gap; + int m_legacy_region_opacity, m_shadow_region_opacity; + int m_popup_version; + bool m_internalClock; + Formula m_fw, m_fh; + SKINELEMENT *m_elements; + char *m_flag_names[32]; + mutable unsigned long m_flags; + + void loadOptions(std::istream &f); + SKINELEMENT *loadObject(std::istream &f); + void loadSkin(std::istream &f); + void loadSkin(LPCTSTR fn); + void loadSkin(LPCTSTR lpName, LPCTSTR lpType); + + void freeSkin(SKINELEMENT *head); + + SIZE measureAction(HDC hdc, POPUPACTION *act) const; + SIZE measureActionBar(HDC hdc, PopupWnd2 *wnd) const; + void drawAction(MyBitmap *bmp, POPUPACTION *act, int x, int y, bool hover) const; + void drawActionBar(MyBitmap *bmp, PopupWnd2 *wnd, int x, int y) const; + +public: + PopupSkin(LPCTSTR aName = 0); + ~PopupSkin(); + + void measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options) const; + void display(MyBitmap *bmp, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options, DWORD drawFlags=DF_ALL) const; + bool onMouseMove(PopupWnd2 *wnd, int x, int y) const; + bool onMouseLeave(PopupWnd2 *wnd) const; + + bool load(LPCTSTR dir); // load skin from current directory + + SKINELEMENT *getSubSkin() { return m_elements; } + int getBottomGap() const { return m_bottom_gap; } + int getRightGap() const { return m_right_gap; } + int useInternalClock() const { return m_internalClock; } + int getLegacyRegionOpacity() const { return m_legacy_region_opacity; } + int getShadowRegionOpacity() const { return m_shadow_region_opacity; } + bool isCompatible() const { return (DWORD) m_popup_version <= (DWORD) pluginInfo.version; } + + const LPTSTR getName() const { return m_name; } + + const char *getFlagName(int id) const { return m_flag_names[id-1]; } + bool getFlag(int id) const { return (m_flags & (1 << (id-1))) != 0; } + void setFlag(int id, bool val) const + { + if (val) + m_flags |= 1 << (id-1); + else + m_flags &= ~(1 << (id-1)); + } + + void saveOpts() const; + void loadOpts() const; +}; + +class Skins +{ +public: + struct SKINLIST + { + PopupSkin *skin; + LPTSTR dir; + LPTSTR name; + SKINLIST *next; + }; + +private: + SKINLIST *m_skins; + +public: + Skins(); + ~Skins(); + + bool load(LPCTSTR dir); + const PopupSkin *getSkin(LPCTSTR name); + + const SKINLIST *getSkinList() const { return m_skins; } + + void loadActiveSkin(); + void freeAllButActive(); +}; + +extern Skins skins; + +#endif -- cgit v1.2.3