├── xskin_dll ├── stdafx.cpp ├── dllmain.cpp ├── targetver.h ├── xskin_dll.cpp ├── stdafx.h └── ReadMe.txt ├── xskin_test ├── xskin_test.h ├── res.zip ├── res1.zip ├── skin.zip ├── Resource.h ├── small.ico ├── stdafx.cpp ├── disk │ └── 10.jpg ├── targetver.h ├── xskin_test.rc ├── xskin_test.ico ├── res │ ├── image │ │ ├── 10.jpg │ │ ├── bhzz.png │ │ ├── cxye.png │ │ ├── gas.png │ │ ├── kh.png │ │ ├── khzz.png │ │ ├── water.png │ │ ├── bk_shadow.png │ │ ├── metro_bk.png │ │ ├── scrollbar.png │ │ ├── testimg.bmp │ │ ├── thunder.png │ │ ├── background.bmp │ │ ├── combobox_checked.png │ │ ├── combobox_normal.png │ │ └── combobox_disabled.png │ ├── string │ │ ├── string.xml │ │ ├── string_tw.xml │ │ └── string_zh.xml │ ├── skin │ │ ├── VScrollBar_LineUp.xml │ │ ├── VScrollBar_Track.xml │ │ ├── VScrollBar_LineDown.xml │ │ ├── VScrollBar.xml │ │ └── ComboBox.xml │ └── layout │ │ └── mainwindow.xml ├── skin │ ├── image │ │ ├── box_bk.png │ │ ├── button.png │ │ ├── radio_bk.png │ │ ├── tabitem.png │ │ ├── testimg.bmp │ │ ├── box_check.png │ │ ├── scrollbar.png │ │ └── radio_check.png │ └── skin │ │ ├── UIListView.xml │ │ ├── UIProgressBar.xml │ │ ├── UISlider.xml │ │ ├── HScrollBar_LineUp.xml │ │ ├── VScrollBar_LineUp.xml │ │ ├── VScrollBar_Track.xml │ │ ├── HScrollBar_LineDown.xml │ │ ├── HScrollBar_Track.xml │ │ ├── VScrollBar_LineDown.xml │ │ ├── HScrollBar.xml │ │ ├── VScrollBar.xml │ │ ├── UIButton.xml │ │ ├── UIEditView.xml │ │ ├── UISlider_Handle.xml │ │ ├── UIComboBox.xml │ │ ├── UITabItem.xml │ │ ├── UICheckBox.xml │ │ └── UIRadioButton.xml ├── stdafx.h ├── xskin_test.vcxproj.user ├── dialog.xml ├── xskin_test.cpp ├── listitem.xml ├── App.h └── xskin_test.vcxproj.filters ├── xskin ├── src │ ├── view │ │ ├── UIEditView.cpp │ │ ├── UITabItem.cpp │ │ ├── UICheckBox.cpp │ │ ├── UIHyperlink.cpp │ │ ├── UIPanel.cpp │ │ ├── UITabBar.cpp │ │ ├── UIButton.cpp │ │ ├── UIListItem.cpp │ │ ├── UIProgressBar.cpp │ │ ├── UITextView.cpp │ │ └── UICardLayout.cpp │ ├── event │ │ ├── UIFocusEvent.cpp │ │ ├── UITimerEvent.cpp │ │ ├── UIWheelEvent.cpp │ │ ├── UIKeyEvent.cpp │ │ ├── UIActionEvent.cpp │ │ ├── UIHierarchyEvent.cpp │ │ ├── UIMouseEvent.cpp │ │ └── UIEvent.cpp │ ├── core │ │ ├── UIResponser.cpp │ │ ├── UIObject.cpp │ │ └── UIApplication.cpp │ ├── animation │ │ ├── UIAlphaAnimation.cpp │ │ ├── UIBoundAnimation.cpp │ │ ├── UITranslateAnimation.cpp │ │ └── UIScaleAnimation.cpp │ ├── model │ │ └── UIModel.cpp │ └── gfx │ │ ├── UIPen.cpp │ │ ├── UIBrush.cpp │ │ ├── UIBitmap.cpp │ │ ├── UIRender.cpp │ │ └── UIFont.cpp └── include │ ├── core │ ├── UIAlign.h │ ├── UISizePolicy.h │ ├── UIResponser.h │ ├── RefCounted.h │ ├── UIObject.h │ ├── UISize.h │ ├── UIPoint.h │ ├── UIApplication.h │ ├── UIMeasure.h │ ├── UIString.h │ ├── UIAsset.h │ ├── UIRect.h │ └── AutoPtr.h │ ├── event │ ├── UIFocusEvent.h │ ├── UITimerEvent.h │ ├── UIWheelEvent.h │ ├── UIKeyEvent.h │ ├── UIHierarchyEvent.h │ ├── UIMouseEvent.h │ ├── UIActionEvent.h │ └── UIEvent.h │ ├── view │ ├── UITabItem.h │ ├── UIHyperlink.h │ ├── UICheckBox.h │ ├── UIListItem.h │ ├── UIButton.h │ ├── UITabBar.h │ ├── UIImageButton.h │ ├── UITextView.h │ ├── UICardLayout.h │ ├── UIBoxLayout.h │ ├── UIProgressBar.h │ ├── UIPanel.h │ ├── UIImageView.h │ ├── UIListView.h │ ├── UIRadioButton.h │ ├── UIComboBox.h │ ├── UIGridLayout.h │ ├── UIScrollView.h │ ├── UISlider.h │ ├── UIEditView.h │ ├── UIRootView.h │ ├── UIControl.h │ ├── UIScrollBar.h │ ├── UITreeView.h │ └── UIWindow.h │ ├── animation │ ├── UIAlphaAnimation.h │ ├── UIBoundAnimation.h │ ├── UITranslateAnimation.h │ ├── UIScaleAnimation.h │ └── UIAnimation.h │ ├── gfx │ ├── UIPen.h │ ├── UIBrush.h │ ├── UIDrawable.h │ ├── UIBitmap.h │ ├── UIRender.h │ └── UIFont.h │ ├── model │ └── UIModel.h │ └── XSkin.h ├── README.md ├── libpng ├── libpng.vcxproj.user ├── ReadMe.txt ├── libpng.vcxproj.filters └── pngrio.c ├── libjpeg ├── jversion.h ├── rdgif.c ├── jconfig.h ├── jcinit.c ├── jmemnobs.c ├── jinclude.h └── jcomapi.c ├── zlib ├── inffast.h ├── ReadMe.txt ├── gzclose.c ├── mztools.h ├── iowin32.h ├── ioapi_mem.h ├── compress.c ├── inftrees.h └── uncompr.c ├── tinyxml2 ├── tinyxml2.vcxproj.filters └── tinyxml2.vcxproj └── unzip ├── unzip.vcxproj.filters ├── ZipFile.h └── main.cpp /xskin_dll/stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /xskin_test/xskin_test.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /xskin_test/res.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res.zip -------------------------------------------------------------------------------- /xskin_test/res1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res1.zip -------------------------------------------------------------------------------- /xskin_test/skin.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin.zip -------------------------------------------------------------------------------- /xskin_dll/dllmain.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_dll/dllmain.cpp -------------------------------------------------------------------------------- /xskin_dll/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_dll/targetver.h -------------------------------------------------------------------------------- /xskin_test/Resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/Resource.h -------------------------------------------------------------------------------- /xskin_test/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/small.ico -------------------------------------------------------------------------------- /xskin_test/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/stdafx.cpp -------------------------------------------------------------------------------- /xskin_dll/xskin_dll.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_dll/xskin_dll.cpp -------------------------------------------------------------------------------- /xskin_test/disk/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/disk/10.jpg -------------------------------------------------------------------------------- /xskin_test/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/targetver.h -------------------------------------------------------------------------------- /xskin_test/xskin_test.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/xskin_test.rc -------------------------------------------------------------------------------- /xskin_test/xskin_test.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/xskin_test.ico -------------------------------------------------------------------------------- /xskin/src/view/UIEditView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin/src/view/UIEditView.cpp -------------------------------------------------------------------------------- /xskin_test/res/image/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/10.jpg -------------------------------------------------------------------------------- /xskin_test/res/image/bhzz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/bhzz.png -------------------------------------------------------------------------------- /xskin_test/res/image/cxye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/cxye.png -------------------------------------------------------------------------------- /xskin_test/res/image/gas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/gas.png -------------------------------------------------------------------------------- /xskin_test/res/image/kh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/kh.png -------------------------------------------------------------------------------- /xskin_test/res/image/khzz.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/khzz.png -------------------------------------------------------------------------------- /xskin_test/res/image/water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/water.png -------------------------------------------------------------------------------- /xskin_test/res/image/bk_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/bk_shadow.png -------------------------------------------------------------------------------- /xskin_test/res/image/metro_bk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/metro_bk.png -------------------------------------------------------------------------------- /xskin_test/res/image/scrollbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/scrollbar.png -------------------------------------------------------------------------------- /xskin_test/res/image/testimg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/testimg.bmp -------------------------------------------------------------------------------- /xskin_test/res/image/thunder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/thunder.png -------------------------------------------------------------------------------- /xskin_test/skin/image/box_bk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin/image/box_bk.png -------------------------------------------------------------------------------- /xskin_test/skin/image/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin/image/button.png -------------------------------------------------------------------------------- /xskin_test/skin/image/radio_bk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin/image/radio_bk.png -------------------------------------------------------------------------------- /xskin_test/skin/image/tabitem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin/image/tabitem.png -------------------------------------------------------------------------------- /xskin_test/skin/image/testimg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin/image/testimg.bmp -------------------------------------------------------------------------------- /xskin_test/res/image/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/background.bmp -------------------------------------------------------------------------------- /xskin_test/skin/image/box_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin/image/box_check.png -------------------------------------------------------------------------------- /xskin_test/skin/image/scrollbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin/image/scrollbar.png -------------------------------------------------------------------------------- /xskin_test/skin/image/radio_check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/skin/image/radio_check.png -------------------------------------------------------------------------------- /xskin_test/res/image/combobox_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/combobox_checked.png -------------------------------------------------------------------------------- /xskin_test/res/image/combobox_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/combobox_normal.png -------------------------------------------------------------------------------- /xskin_test/res/image/combobox_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Justysxh/xskin/HEAD/xskin_test/res/image/combobox_disabled.png -------------------------------------------------------------------------------- /xskin/include/core/UIAlign.h: -------------------------------------------------------------------------------- 1 | #ifndef __ALIGN_H_INCLUDED__ 2 | #define __ALIGN_H_INCLUDED__ 3 | 4 | 5 | 6 | #endif //! __ALIGN_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/core/UISizePolicy.h: -------------------------------------------------------------------------------- 1 | #ifndef __SIZE_POLICY_H_INCLUDED__ 2 | #define __SIZE_POLICY_H_INCLUDED__ 3 | 4 | 5 | #endif //! __SIZE_POLICY_H_INCLUDED__ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xskin 2 | 作者: http://my.csdn.net/pcradio 3 | 是基于 c++ 和GDI做的 一个UI库. Direct UI库,部分参考Duilib,有些作者自己的想法实现,模仿java事件监听器机制和android布局文件. 4 | 内部使用其它该源的jpg, png图片解码库 5 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/UIListView.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/UIProgressBar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /libpng/libpng.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /xskin_test/res/string/string.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | A1 4 | A2 5 | A3 6 | -------------------------------------------------------------------------------- /xskin_test/res/string/string_tw.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 繁體 4 | 代碼 5 | 測試 6 | -------------------------------------------------------------------------------- /xskin_test/res/string/string_zh.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 你好 4 | 世界 5 | 代码 6 | -------------------------------------------------------------------------------- /xskin_test/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | -------------------------------------------------------------------------------- /xskin_test/xskin_test.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/UISlider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/res/skin/VScrollBar_LineUp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/res/skin/VScrollBar_Track.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/res/skin/VScrollBar_LineDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/res/skin/VScrollBar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /xskin/src/event/UIFocusEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/event/UIFocusEvent.h" 3 | 4 | UIFocusEvent::UIFocusEvent(UIResponser* pSource, EventType nType) 5 | : UIEvent(pSource, nType, 0) 6 | { 7 | 8 | } 9 | 10 | UIFocusEvent::~UIFocusEvent() 11 | { 12 | 13 | } -------------------------------------------------------------------------------- /xskin_test/skin/skin/HScrollBar_LineUp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/VScrollBar_LineUp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/VScrollBar_Track.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/HScrollBar_LineDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/HScrollBar_Track.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/VScrollBar_LineDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /xskin_dll/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | #include 6 | #include 7 | 8 | #pragma comment(lib, "msimg32.lib") 9 | 10 | #pragma warning (disable:4800) 11 | #pragma warning (disable:4996) 12 | #pragma warning (disable:4251) 13 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/HScrollBar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/VScrollBar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /xskin_test/res/skin/ComboBox.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/UIButton.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/UIEditView.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /xskin/include/event/UIFocusEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIFOCUS_EVENT_H_INCLUDED__ 2 | #define __UIFOCUS_EVENT_H_INCLUDED__ 3 | 4 | #include "UIEvent.h" 5 | 6 | class XSKIN_API UIFocusEvent : public UIEvent 7 | { 8 | public: 9 | UIFocusEvent(UIResponser* pSource, EventType nType); 10 | ~UIFocusEvent(); 11 | }; 12 | #endif //! __UIFOCUS_EVENT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin_test/skin/skin/UISlider_Handle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/UIComboBox.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | -------------------------------------------------------------------------------- /xskin/include/view/UITabItem.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITAB_ITEM_H_INCLUDED__ 2 | #define __UITAB_ITEM_H_INCLUDED__ 3 | 4 | #include "UIListItem.h" 5 | 6 | class UITabItem : public UIListItem 7 | { 8 | DECLARE_XML_NODE(UITabItem) 9 | DECLARE_XML_PROPERTY() 10 | public: 11 | UITabItem(UIView* parent = NULL); 12 | ~UITabItem(); 13 | }; 14 | #endif //! __UITAB_ITEM_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/core/UIResponser.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/core/UIResponser.h" 3 | 4 | UIResponser::UIResponser() 5 | { 6 | 7 | } 8 | 9 | UIResponser::~UIResponser() 10 | { 11 | 12 | } 13 | 14 | BOOL UIResponser::Event(UIEvent* event) 15 | { 16 | return FALSE; 17 | } 18 | 19 | UIResponser* UIResponser::GetNextResponser() const 20 | { 21 | return NULL; 22 | } -------------------------------------------------------------------------------- /xskin_test/dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 16 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/UITabItem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /xskin/src/view/UITabItem.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UITabItem.h" 3 | 4 | IMPLEMENT_XML_NODE(UITabItem) 5 | 6 | BEGIN_XML_PROPERTY(UITabItem) 7 | END_XML_PROPERTY() 8 | 9 | UITabItem::UITabItem(UIView* parent) 10 | : UIListItem(parent) 11 | { 12 | m_alignment.cx = UIAlignment::ALIGN_HCENTER; 13 | m_alignment.cy = UIAlignment::ALIGN_VCENTER; 14 | } 15 | 16 | UITabItem::~UITabItem() 17 | { 18 | 19 | } -------------------------------------------------------------------------------- /xskin/src/event/UITimerEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/event/UITimerEvent.h" 3 | 4 | UITimerEvent::UITimerEvent(UIResponser* pSource, UINT uTimerID, int nFlags /* = 0 */) 5 | : UIEvent(pSource, UIEvent::EVENT_TIMER, nFlags) 6 | { 7 | m_uTimerID = uTimerID; 8 | } 9 | 10 | UITimerEvent::~UITimerEvent() 11 | { 12 | 13 | } 14 | 15 | UINT UITimerEvent::GetTimerID() const 16 | { 17 | return m_uTimerID; 18 | } 19 | -------------------------------------------------------------------------------- /xskin/src/event/UIWheelEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/event/UIWheelEvent.h" 3 | 4 | UIWheelEvent::UIWheelEvent(UIResponser* pSource, EventType nType, const UIPoint& point, int zDelta, int nFlags) 5 | : UIMouseEvent(pSource, nType, point, nFlags) 6 | { 7 | m_nDelta = zDelta; 8 | } 9 | 10 | UIWheelEvent::~UIWheelEvent() 11 | { 12 | 13 | } 14 | 15 | int UIWheelEvent::GetDelta() const 16 | { 17 | return m_nDelta; 18 | } -------------------------------------------------------------------------------- /xskin/include/event/UITimerEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITIMER_EVENT_H_INCLUDED__ 2 | #define __UITIMER_EVENT_H_INCLUDED__ 3 | 4 | #include "UIEvent.h" 5 | 6 | class XSKIN_API UITimerEvent : public UIEvent 7 | { 8 | public: 9 | UITimerEvent(UIResponser* pSource, UINT uTimerID, int nFlags = 0); 10 | ~UITimerEvent(); 11 | 12 | public: 13 | UINT GetTimerID() const; 14 | 15 | private: 16 | UINT m_uTimerID; 17 | }; 18 | #endif //! __UITIMER_EVENT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/core/UIResponser.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIRESPONSER_H_INCLUDED__ 2 | #define __UIRESPONSER_H_INCLUDED__ 3 | 4 | #include "UIObject.h" 5 | #include "../event/UIEvent.h" 6 | 7 | class XSKIN_API UIResponser : public UIObject 8 | { 9 | public: 10 | UIResponser(); 11 | ~UIResponser(); 12 | 13 | public: 14 | virtual BOOL Event(UIEvent* event); 15 | virtual UIResponser* GetNextResponser() const; 16 | }; 17 | #endif //! __UIRESPONSER_H_INCLUDED__ -------------------------------------------------------------------------------- /libjpeg/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-2016, Thomas G. Lane, Guido Vollbeding. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "9b 17-Jan-2016" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 2016, Thomas G. Lane, Guido Vollbeding" 15 | -------------------------------------------------------------------------------- /xskin/include/view/UIHyperlink.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIHYPERLINK_H_INCLUDED__ 2 | #define __UIHYPERLINK_H_INCLUDED__ 3 | 4 | #include "UIButton.h" 5 | 6 | class XSKIN_API UIHyperlink : public UIButton 7 | { 8 | DECLARE_XML_NODE(UIHyperlink) 9 | public: 10 | UIHyperlink(UIView* parent = NULL); 11 | ~UIHyperlink(); 12 | public: 13 | UISize GetPreferredSize() const OVERRIDE; 14 | 15 | protected: 16 | void OnPaint(HDC hdc) OVERRIDE; 17 | }; 18 | #endif //! __UIHYPERLINK_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin_test/xskin_test.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "App.h" 3 | 4 | 5 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) 6 | { 7 | MyApp app; 8 | app.SetResZip(TEXT("skin.zip")); 9 | 10 | MainWindow mainWnd; 11 | mainWnd.Create(); 12 | UIRect rc(0, 0, 1024, 800); 13 | mainWnd.SetBounds(rc); 14 | mainWnd.CenterWindow(); 15 | mainWnd.SetFrameVisible(TRUE); 16 | mainWnd.Show(); 17 | return app.Run(); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /xskin/include/core/RefCounted.h: -------------------------------------------------------------------------------- 1 | #ifndef __REFCOUNTED_H_INCLUDED__ 2 | #define __REFCOUNTED_H_INCLUDED__ 3 | 4 | #include "UIObject.h" 5 | 6 | class XSKIN_API RefCounted 7 | { 8 | public: 9 | RefCounted() { m_nRefCount = 0; } 10 | virtual ~RefCounted() { } 11 | 12 | public: 13 | void AddRef() const { ++m_nRefCount; } 14 | void Release() const { if(--m_nRefCount == 0) delete this; } 15 | 16 | private: 17 | mutable int m_nRefCount; 18 | }; 19 | 20 | #endif //! __REFCOUNTED_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/event/UIWheelEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIMOUSEWHEEL_EVENT_H_INCLUDED__ 2 | #define __UIMOUSEWHEEL_EVENT_H_INCLUDED__ 3 | 4 | #include "UIMouseEvent.h" 5 | 6 | class XSKIN_API UIWheelEvent : public UIMouseEvent 7 | { 8 | public: 9 | UIWheelEvent(UIResponser* pSource, EventType nType, const UIPoint& point, int zDelta, int nFlags); 10 | ~UIWheelEvent(); 11 | 12 | public: 13 | int GetDelta() const; 14 | 15 | private: 16 | int m_nDelta; 17 | }; 18 | #endif //! __UIMOUSEWHEEL_EVENT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin_test/listitem.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 16 | 24 | -------------------------------------------------------------------------------- /xskin/include/event/UIKeyEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIKEY_EVENT_H_INCLUDED__ 2 | #define __UIKEY_EVENT_H_INCLUDED__ 3 | 4 | #include "UIEvent.h" 5 | 6 | class XSKIN_API UIKeyEvent : public UIEvent 7 | { 8 | public: 9 | UIKeyEvent(UIResponser* pSource, EventType nType, int nKeytCode, int nRepeatCount, int nFlags); 10 | ~UIKeyEvent(); 11 | 12 | public: 13 | int GetKeyCode() const; 14 | int GetRepeatCount() const; 15 | 16 | private: 17 | int m_nKeyCode; 18 | int m_nRepeatCount; 19 | }; 20 | 21 | #endif //! __UIKEY_EVENT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/view/UICheckBox.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICHECK_BOX_H_INCLUDED__ 2 | #define __UICHECK_BOX_H_INCLUDED__ 3 | 4 | #include "UIRadioButton.h" 5 | 6 | class XSKIN_API UICheckBox : public UIRadioButton 7 | { 8 | DECLARE_XML_NODE(UICheckBox) 9 | DECLARE_XML_PROPERTY() 10 | public: 11 | UICheckBox(UIView* parent = NULL); 12 | ~UICheckBox(); 13 | 14 | public: 15 | void SetChecked(BOOL b) OVERRIDE; 16 | 17 | protected: 18 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 19 | 20 | }; 21 | #endif //! __UICHECK_BOX_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/core/UIObject.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIOBJECT_H_INCLUDED__ 2 | #define __UIOBJECT_H_INCLUDED__ 3 | 4 | #include "Macros.h" 5 | 6 | class XSKIN_API UIObject 7 | { 8 | public: 9 | UIObject(); 10 | virtual ~UIObject(); 11 | 12 | public: 13 | LPCSTR Name() const; 14 | int HashCode() const; 15 | BOOL operator ==(const UIObject& obj) const; 16 | void Trace(LPCTSTR szFmt, ...); 17 | 18 | private: 19 | UIObject(const UIObject&); 20 | UIObject& operator=(const UIObject&); 21 | }; 22 | 23 | #endif //! __UIOBJECT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/event/UIHierarchyEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIHIERARCHY_EVENT_H_INCLUDED__ 2 | #define __UIHIERARCHY_EVENT_H_INCLUDED__ 3 | 4 | #include "UIEvent.h" 5 | 6 | class XSKIN_API UIView; 7 | class XSKIN_API UIHierarchyEvent : public UIEvent 8 | { 9 | public: 10 | UIHierarchyEvent(UIView* pSource, EventType nType, UIView* pParent, int nFlags = 0); 11 | ~UIHierarchyEvent(); 12 | 13 | public: 14 | UIView* GetChanged(); 15 | UIView* GetChangedParent(); 16 | 17 | private: 18 | UIView* m_pParent; 19 | }; 20 | #endif //! __UIHIERARCHY_EVENT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/view/UIListItem.h: -------------------------------------------------------------------------------- 1 | #ifndef __UILIST_ITEM_H_INCLUDED__ 2 | #define __UILIST_ITEM_H_INCLUDED__ 3 | 4 | #include "UIButton.h" 5 | 6 | class XSKIN_API UIListItem : public UIButton 7 | { 8 | DECLARE_XML_NODE(UIListItem) 9 | DECLARE_XML_PROPERTY() 10 | public: 11 | UIListItem(UIView* parent = NULL); 12 | ~UIListItem(); 13 | 14 | protected: 15 | void OnPaint(HDC hdc) OVERRIDE; 16 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 17 | BOOL OnMouseClicked(UIMouseEvent* event) OVERRIDE; 18 | }; 19 | #endif //! __UILIST_ITEM_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/event/UIKeyEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/event/UIKeyEvent.h" 3 | 4 | UIKeyEvent::UIKeyEvent(UIResponser* pSource, EventType nType, int nKeyCode, int nRepeatCount, int nFlags) 5 | : UIEvent(pSource, nType, nFlags) 6 | { 7 | m_nKeyCode = nKeyCode; 8 | m_nRepeatCount = nRepeatCount; 9 | } 10 | 11 | UIKeyEvent::~UIKeyEvent() 12 | { 13 | 14 | } 15 | 16 | int UIKeyEvent::GetKeyCode() const 17 | { 18 | return m_nKeyCode; 19 | } 20 | 21 | int UIKeyEvent::GetRepeatCount() const 22 | { 23 | return m_nRepeatCount; 24 | } -------------------------------------------------------------------------------- /xskin/src/event/UIActionEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/event/UIActionEvent.h" 3 | 4 | UIActionEvent::UIActionEvent(UIResponser* pSource, const UIString& szID, const UIString& szCommand, int nFlags) 5 | : UIEvent(pSource, EVENT_ACTION, nFlags) 6 | { 7 | m_szID = szID; 8 | m_szCommand = szCommand; 9 | } 10 | 11 | UIActionEvent::~UIActionEvent() 12 | { 13 | 14 | } 15 | 16 | UIString UIActionEvent::GetID() const 17 | { 18 | return m_szID; 19 | } 20 | 21 | UIString UIActionEvent::GetCommand() const 22 | { 23 | return m_szCommand; 24 | } -------------------------------------------------------------------------------- /xskin/include/view/UIButton.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIBUTTON_H_INCLUDED__ 2 | #define __UIBUTTON_H_INCLUDED__ 3 | 4 | #include "UIControl.h" 5 | #include "../core/UIString.h" 6 | 7 | class XSKIN_API UIButton : public UIControl 8 | { 9 | DECLARE_XML_NODE(UIButton) 10 | DECLARE_XML_PROPERTY() 11 | public: 12 | UIButton(UIView* parent = NULL); 13 | ~UIButton(); 14 | 15 | public: 16 | void Activate(BOOL b) OVERRIDE; 17 | 18 | protected: 19 | BOOL OnMouseClicked(UIMouseEvent* event) OVERRIDE; 20 | void OnPaint(HDC hdc) OVERRIDE; 21 | }; 22 | 23 | #endif //! __UIBUTTON_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/event/UIMouseEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIMOUSE_EVENT_H_INCLUDED__ 2 | #define __UIMOUSE_EVENT_H_INCLUDED__ 3 | 4 | #include "UIEvent.h" 5 | #include "../core/UIPoint.h" 6 | 7 | class XSKIN_API UIMouseEvent : public UIEvent 8 | { 9 | public: 10 | UIMouseEvent(UIResponser* pSource, EventType nType, const UIPoint& point, int nFlags); 11 | ~UIMouseEvent(); 12 | 13 | public: 14 | UIPoint GetLocation() const; 15 | BOOL IsCtrlDown() const; 16 | BOOL IsShiftDown() const; 17 | BOOL IsAltDown() const; 18 | 19 | private: 20 | UIPoint m_pos; 21 | }; 22 | #endif //! __UIMOUSE_EVENT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/event/UIHierarchyEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/event/UIHierarchyEvent.h" 3 | #include "../../include/view/UIView.h" 4 | 5 | UIHierarchyEvent::UIHierarchyEvent(UIView* pSource, EventType nType, UIView* pParent, int nFlags) 6 | : UIEvent(pSource, nType, nFlags) 7 | { 8 | m_pParent = pParent; 9 | } 10 | 11 | UIHierarchyEvent::~UIHierarchyEvent() 12 | { 13 | 14 | } 15 | 16 | UIView* UIHierarchyEvent::GetChanged() 17 | { 18 | return static_cast(GetSource()); 19 | } 20 | 21 | UIView* UIHierarchyEvent::GetChangedParent() 22 | { 23 | return m_pParent; 24 | } -------------------------------------------------------------------------------- /xskin_test/skin/skin/UICheckBox.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | -------------------------------------------------------------------------------- /xskin_test/skin/skin/UIRadioButton.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | -------------------------------------------------------------------------------- /xskin/include/view/UITabBar.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITAB_BAR_H_INCLUDED__ 2 | #define __UITAB_BAR_H_INCLUDED__ 3 | 4 | #include "UIBoxLayout.h" 5 | 6 | class XSKIN_API UITabBar : public UIBoxLayout 7 | { 8 | DECLARE_XML_NODE(UITabBar) 9 | public: 10 | UITabBar(UIView* parent = NULL); 11 | ~UITabBar(); 12 | 13 | public: 14 | void SetCheckedView(UIView* v); 15 | UIView* GetCheckedView() const; 16 | void SetCheckedIndex(int nIndex); 17 | int GetCheckedIndex() const; 18 | 19 | protected: 20 | void OnInit() OVERRIDE; 21 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 22 | 23 | protected: 24 | UIView* m_pChecked; 25 | }; 26 | #endif //! __UITAB_BAR_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/animation/UIAlphaAnimation.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIALPHA_ANIMATION_H_INCLUDED__ 2 | #define __UIALPHA_ANIMATION_H_INCLUDED__ 3 | 4 | #include "UIAnimation.h" 5 | 6 | class UIView; 7 | class XSKIN_API UIAlphaAnimation : public UIAnimation 8 | { 9 | public: 10 | UIAlphaAnimation(UIView* pTarget = NULL, int nStart = 0, int nEnd = 0); 11 | ~UIAlphaAnimation(); 12 | 13 | public: 14 | void SetStartValue(int nStart); 15 | void SetEndValue(int nEnd); 16 | void OnAnimationStarted() OVERRIDE; 17 | void OnAnimationStepped() OVERRIDE; 18 | void OnAnimationStopped() OVERRIDE; 19 | 20 | private: 21 | int m_nStart; 22 | int m_nEnd; 23 | }; 24 | #endif //! __UIALPHA_ANIMATION_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/core/UISize.h: -------------------------------------------------------------------------------- 1 | #ifndef __H_INCLUDED__ 2 | #define __H_INCLUDED__ 3 | 4 | #include 5 | 6 | class XSKIN_API UISize : public tagSIZE 7 | { 8 | public: 9 | inline UISize() 10 | { 11 | cx = cy = 0; 12 | } 13 | 14 | inline UISize(const SIZE& src) 15 | { 16 | cx = src.cx; 17 | cy = src.cy; 18 | } 19 | 20 | inline UISize(const RECT rc) 21 | { 22 | cx = rc.right - rc.left; 23 | cy = rc.bottom - rc.top; 24 | } 25 | 26 | inline UISize(int cx, int cy) 27 | { 28 | this->cx = cx; 29 | this->cy = cy; 30 | } 31 | 32 | inline ~UISize() 33 | { 34 | 35 | } 36 | 37 | public: 38 | inline operator LPSIZE() 39 | { 40 | return this; 41 | } 42 | }; 43 | #endif //! __H_INCLUDED__ 44 | -------------------------------------------------------------------------------- /zlib/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 静态库:zlib 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 zlib 库项目。 6 | 7 | 没有为此项目创建源文件。 8 | 9 | 10 | zlib.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | zlib.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | 其他注释: 18 | 19 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | -------------------------------------------------------------------------------- /libpng/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 静态库:libpng 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 libpng 库项目。 6 | 7 | 没有为此项目创建源文件。 8 | 9 | 10 | libpng.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | libpng.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | 其他注释: 18 | 19 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | -------------------------------------------------------------------------------- /xskin/src/event/UIMouseEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/event/UIMouseEvent.h" 3 | 4 | UIMouseEvent::UIMouseEvent(UIResponser* pSource, EventType nType, const UIPoint& pt, int nFlags) 5 | : UIEvent(pSource, nType, nFlags) 6 | { 7 | m_pos = pt; 8 | } 9 | 10 | UIMouseEvent::~UIMouseEvent() 11 | { 12 | 13 | } 14 | 15 | UIPoint UIMouseEvent::GetLocation() const 16 | { 17 | return m_pos; 18 | } 19 | 20 | BOOL UIMouseEvent::IsCtrlDown() const 21 | { 22 | return GetFlags() & CTRL_MASK ? TRUE : FALSE; 23 | } 24 | 25 | BOOL UIMouseEvent::IsShiftDown() const 26 | { 27 | return GetFlags() & SHIFT_MASK ? TRUE : FALSE; 28 | } 29 | 30 | BOOL UIMouseEvent::IsAltDown() const 31 | { 32 | return GetFlags() & ALT_MASK ? TRUE : FALSE; 33 | } -------------------------------------------------------------------------------- /xskin/include/animation/UIBoundAnimation.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIBOUND_ANIMATION_H_INCLUDED__ 2 | #define __UIBOUND_ANIMATION_H_INCLUDED__ 3 | 4 | #include "UIAnimation.h" 5 | #include "../core/UIRect.h" 6 | 7 | class XSKIN_API UIBoundAnimation : public UIAnimation 8 | { 9 | public: 10 | UIBoundAnimation(UIView* pTarget = NULL, const UIRect& rcStart = UIRect(), const UIRect& rcEnd = UIRect()); 11 | ~UIBoundAnimation(); 12 | 13 | public: 14 | void SetStartValue(const UIRect& rcStart); 15 | void SetEndValue(const UIRect& rcEnd); 16 | 17 | void OnAnimationStarted() OVERRIDE; 18 | void OnAnimationStepped() OVERRIDE; 19 | void OnAnimationStopped() OVERRIDE; 20 | 21 | private: 22 | UIRect m_rcStart; 23 | UIRect m_rcEnd; 24 | }; 25 | #endif //! __UIBOUND_ANIMATION_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/view/UIImageButton.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIIMAGE_BUTTON_H_INCLUDED__ 2 | #define __UIIMAGE_BUTTON_H_INCLUDED__ 3 | 4 | #include "UIButton.h" 5 | #include "../gfx/UIDrawable.h" 6 | 7 | class XSKIN_API UIImageButton : public UIButton 8 | { 9 | DECLARE_XML_NODE(UIImageButton) 10 | DECLARE_XML_PROPERTY() 11 | public: 12 | enum { BITMAP_TEXT_SPACING = 8 }; 13 | 14 | UIImageButton(UIView* parent = NULL); 15 | ~UIImageButton(); 16 | 17 | public: 18 | void SetIcon(const UIBitmap* pBitmap, const UIRect& rcPos); 19 | void SetSpacing(int nSpacing); 20 | UISize GetPreferredSize() const OVERRIDE; 21 | 22 | protected: 23 | void OnPaint(HDC hdc) OVERRIDE; 24 | 25 | protected: 26 | UIDrawable m_bkIcon; 27 | int m_nSpacing; 28 | }; 29 | 30 | #endif //! __UIIMAGE_BUTTON_H_INCLUDED___ -------------------------------------------------------------------------------- /xskin/include/view/UITextView.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITEXT_VIEW_H_INCLUDED__ 2 | #define __UITEXT_VIEW_H_INCLUDED__ 3 | 4 | #include "UIControl.h" 5 | 6 | class UIScrollBar; 7 | class XSKIN_API UITextView : public UIControl 8 | { 9 | DECLARE_XML_NODE(UITextView) 10 | DECLARE_XML_PROPERTY() 11 | public: 12 | UITextView(UIView* parent = NULL); 13 | ~UITextView(); 14 | 15 | public: 16 | UISize GetPreferredSize() const OVERRIDE; 17 | 18 | protected: 19 | void OnLayout() OVERRIDE; 20 | void OnPaint(HDC hdc) OVERRIDE; 21 | BOOL OnMouseWheel(UIWheelEvent* event) OVERRIDE; 22 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 23 | 24 | private: 25 | UIScrollBar* m_pVScrollbar; 26 | int m_nScroll; 27 | BOOL m_bMultiline; 28 | }; 29 | #endif //! __UITEXT_VIEW_H_INCLUDED__ -------------------------------------------------------------------------------- /zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /xskin/include/view/UICardLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICARD_LAYOUT_H_INCLUDED__ 2 | #define __UICARD_LAYOUT_H_INCLUDED__ 3 | 4 | #include "UIView.h" 5 | 6 | class XSKIN_API UICardLayout : public UIView 7 | { 8 | DECLARE_XML_NODE(UICardLayout) 9 | DECLARE_XML_PROPERTY() 10 | public: 11 | UICardLayout(UIView* parent = NULL); 12 | ~UICardLayout(); 13 | 14 | public: 15 | void First(); 16 | void Last(); 17 | void Previous(); 18 | void Next(); 19 | void Show(int nIndex); 20 | void Show(const UIString& szViewID); 21 | UISize GetPreferredSize() const OVERRIDE; 22 | 23 | protected: 24 | void ShowExclusive(UIView* v); 25 | void OnInit() OVERRIDE; 26 | void OnLayout() OVERRIDE; 27 | void OnPaint(HDC hdc) OVERRIDE; 28 | 29 | protected: 30 | int m_nShownIndex; 31 | }; 32 | #endif //! __UICARD_LAYOUT_H_INCLUDED__ 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /xskin/include/view/UIBoxLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIBOX_LAYOUT_H_INCLUDED__ 2 | #define __UIBOX_LAYOUT_H_INCLUDED__ 3 | 4 | #include "UIView.h" 5 | 6 | class XSKIN_API UIBoxLayout : public UIView 7 | { 8 | DECLARE_XML_NODE(UIBoxLayout) 9 | DECLARE_XML_PROPERTY() 10 | 11 | public: 12 | UIBoxLayout(UIView* parent = NULL); 13 | ~UIBoxLayout(); 14 | 15 | public: 16 | void SetAlignment(UIAlignment::AlignFlag horz, UIAlignment::AlignFlag vert); 17 | UIAlignment GetAlignment() const; 18 | void SetDirection(Direction dir); 19 | Direction GetDirection() const; 20 | UISize GetPreferredSize() const OVERRIDE; 21 | 22 | protected: 23 | void OnLayout() OVERRIDE; 24 | void OnPaint(HDC hdc) OVERRIDE; 25 | 26 | protected: 27 | UIAlignment m_alignment; 28 | Direction m_direction; 29 | }; 30 | 31 | #endif //! __UIBOX_LAYOUT_H_INCLUDED__ -------------------------------------------------------------------------------- /zlib/mztools.h: -------------------------------------------------------------------------------- 1 | /* 2 | Additional tools for Minizip 3 | Code: Xavier Roche '2004 4 | License: Same as ZLIB (www.gzip.org) 5 | */ 6 | 7 | #ifndef _zip_tools_H 8 | #define _zip_tools_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef _ZLIB_H 15 | #include "zlib.h" 16 | #endif 17 | 18 | #include "unzip.h" 19 | 20 | /* Repair a ZIP file (missing central directory) 21 | file: file to recover 22 | fileOut: output file after recovery 23 | fileOutTmp: temporary file name used for recovery 24 | */ 25 | extern int ZEXPORT unzRepair(const char* file, 26 | const char* fileOut, 27 | const char* fileOutTmp, 28 | uLong* nRecovered, 29 | uLong* bytesRecovered); 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /xskin/include/gfx/UIPen.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIPEN_H_INCLUDED__ 2 | #define __UIPEN_H_INCLUDED__ 3 | 4 | #include 5 | #include "../core/RefCounted.h" 6 | #include "../core/UIObject.h" 7 | #include "../core/UIString.h" 8 | 9 | class XSKIN_API UIPen : public UIObject, public RefCounted 10 | { 11 | public: 12 | static UIPen* GetPen(LPCTSTR szCacheKey); 13 | static UIPen* CreateNew(HPEN hPen, LPCTSTR szCacheKey = NULL); 14 | static UIPen* CreateNew(COLORREF clr, int nWidth, LPCTSTR szCacheKey = NULL); 15 | HPEN GetNativePen() const; 16 | operator HPEN() const; 17 | 18 | protected: 19 | 20 | UIPen(HPEN hPen); 21 | UIPen(COLORREF clr, int nWidth); 22 | ~UIPen(); 23 | void Init(); 24 | 25 | private: 26 | HPEN m_hPen; 27 | UIString m_szKey; 28 | typedef std::map GdiPenCache; 29 | static GdiPenCache cache; 30 | }; 31 | #endif //! __UIPEN_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/gfx/UIBrush.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIBRUSH_H_INCLUDED__ 2 | #define __UIBRUSH_H_INCLUDED__ 3 | 4 | #include 5 | #include "../core/RefCounted.h" 6 | #include "../core/UIObject.h" 7 | #include "../core/UIString.h" 8 | 9 | class XSKIN_API UIBrush : public UIObject, public RefCounted 10 | { 11 | public: 12 | static UIBrush* GetBrush(LPCTSTR szCacheKey); 13 | static UIBrush* CreateNew(HBRUSH hBrush, LPCTSTR szCacheKey = NULL); 14 | static UIBrush* CreateNew(COLORREF clr, LPCTSTR szCacheKey = NULL); 15 | HBRUSH GetNativeBrush() const; 16 | operator HBRUSH() const; 17 | 18 | protected: 19 | 20 | UIBrush(HBRUSH hBrush); 21 | UIBrush(COLORREF clr); 22 | ~UIBrush(); 23 | void Init(); 24 | 25 | private: 26 | HBRUSH m_hBrush; 27 | UIString m_szKey; 28 | typedef std::map GdiBrushCache; 29 | static GdiBrushCache cache; 30 | }; 31 | #endif //! __UIBRUSH_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/animation/UIAlphaAnimation.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UIView.h" 3 | #include "../../include/animation/UIAlphaAnimation.h" 4 | 5 | UIAlphaAnimation::UIAlphaAnimation(UIView* pTarget, int nStart, int nEnd) 6 | : UIAnimation(pTarget) 7 | { 8 | m_nStart = nStart; 9 | m_nEnd = nEnd; 10 | } 11 | 12 | UIAlphaAnimation::~UIAlphaAnimation() 13 | { 14 | 15 | } 16 | 17 | void UIAlphaAnimation::SetStartValue(int nStart) 18 | { 19 | m_nStart = nStart; 20 | } 21 | 22 | void UIAlphaAnimation::SetEndValue(int nEnd) 23 | { 24 | m_nEnd = nEnd; 25 | } 26 | 27 | void UIAlphaAnimation::OnAnimationStarted() 28 | { 29 | 30 | } 31 | 32 | void UIAlphaAnimation::OnAnimationStopped() 33 | { 34 | 35 | } 36 | 37 | void UIAlphaAnimation::OnAnimationStepped() 38 | { 39 | int nAlpha = GetValueBetween(m_nStart, m_nEnd); 40 | m_pTarget->SetOpacity(nAlpha); 41 | __super::OnAnimationStepped(); 42 | } -------------------------------------------------------------------------------- /xskin/include/animation/UITranslateAnimation.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITRANSLATE_ANIMATION_H_INCLUDED__ 2 | #define __UITRANSLATE_ANIMATION_H_INCLUDED__ 3 | 4 | #include "UIAnimation.h" 5 | #include "../../include/core/UIPoint.h" 6 | 7 | class UIView; 8 | class XSKIN_API UITranslateAnimation : public UIAnimation 9 | { 10 | public: 11 | UITranslateAnimation(UIView* pTarget = NULL, 12 | int nFromXDelta = 0, int nToXDelta = 0, int nFromYDelta = 0, int nToYDelta = 0); 13 | ~UITranslateAnimation(); 14 | 15 | public: 16 | void SetStartValue(int nFromXDelta, int nFromYDelta); 17 | void SetEndValue(int nToXDelta, int nToYDelta); 18 | void OnAnimationStarted() OVERRIDE; 19 | void OnAnimationStepped() OVERRIDE; 20 | void OnAnimationStopped() OVERRIDE; 21 | 22 | private: 23 | int m_nFromXDelta; 24 | int m_nFromYDelta; 25 | int m_nToXDelta; 26 | int m_nToYDelta; 27 | UIPoint m_pos; 28 | }; 29 | #endif //! __UITRANSLATE_ANIMATION_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/gfx/UIDrawable.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIDRAWABLE_H_INCLUDED__ 2 | #define __UIDRAWABLE_H_INCLUDED__ 3 | 4 | #include "../core/UIObject.h" 5 | #include "../core/UISize.h" 6 | #include "../core/UIRect.h" 7 | #include "UIBitmap.h" 8 | 9 | class XSKIN_API UIDrawable : public UIObject 10 | { 11 | public: 12 | enum FillMode 13 | { 14 | FILL_NONE = 0, 15 | FILL_SCALE, 16 | FILL_REPEAT_X, 17 | FILL_REPEAT_Y, 18 | FILL_REPEAT_BOTH 19 | }; 20 | 21 | UIDrawable(); 22 | UIDrawable(const UIBitmap* pBitmap, const UIRect& rcPos); 23 | ~UIDrawable(); 24 | 25 | public: 26 | BOOL IsValid() const; 27 | int Width() const; 28 | int Height() const; 29 | void SetBitmap(const UIBitmap* pBitmap); 30 | void SetPos(const UIRect& rcPos); 31 | void Draw(HDC hdc, const UIRect& rcDest, FillMode fm = FILL_SCALE, int nOpacity = 255); 32 | 33 | private: 34 | const UIBitmap* m_pBitmap; 35 | UIRect m_rcPos; 36 | }; 37 | #endif //! __UIBACKGROUND_H_INCLUDED__ -------------------------------------------------------------------------------- /zlib/iowin32.h: -------------------------------------------------------------------------------- 1 | /* iowin32.h -- IO base function header for compress/uncompress .zip 2 | Version 1.1, February 14h, 2010 3 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 4 | 5 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 6 | 7 | Modifications for Zip64 support 8 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 9 | 10 | For more info read MiniZip_info.txt 11 | 12 | */ 13 | 14 | #include 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 22 | void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); 23 | void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); 24 | void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /xskin/include/view/UIProgressBar.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIPROGRESS_BAR_H_INCLUDED__ 2 | #define __UIPROGRESS_BAR_H_INCLUDED__ 3 | 4 | #include "UIControl.h" 5 | 6 | class XSKIN_API UIProgressBar : public UIControl 7 | { 8 | DECLARE_XML_NODE(UIProgressBar) 9 | DECLARE_XML_PROPERTY() 10 | public: 11 | UIProgressBar(UIView* parent = NULL); 12 | ~UIProgressBar(); 13 | 14 | public: 15 | void SetDirection(Direction dir); 16 | Direction GetDirection() const; 17 | void SetTextVisible(BOOL b); 18 | void SetValue(int nValue); 19 | int GetValue() const; 20 | void SetRange(int nMin, int nMax); 21 | UISize GetRange() const; 22 | UISize GetPreferredSize() const OVERRIDE; 23 | 24 | protected: 25 | int Clamp(int x, int a, int b); 26 | void OnPaint(HDC hdc) OVERRIDE; 27 | 28 | protected: 29 | Direction m_direction; 30 | int m_nValue; 31 | BOOL m_bTextVisible; 32 | UISize m_szRange; 33 | UIDrawable m_bkFragment; 34 | }; 35 | 36 | #endif //! __UIPROGRESS_BAR_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/view/UICheckBox.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UICheckBox.h" 3 | #include "../../include/core/UIApplication.h" 4 | #include "../../include/event/UIActionEvent.h" 5 | 6 | IMPLEMENT_XML_NODE(UICheckBox) 7 | 8 | BEGIN_XML_PROPERTY(UICheckBox) 9 | END_XML_PROPERTY() 10 | 11 | UICheckBox::UICheckBox(UIView* parent) 12 | : UIRadioButton(parent) 13 | { 14 | 15 | } 16 | 17 | UICheckBox::~UICheckBox() 18 | { 19 | 20 | } 21 | 22 | void UICheckBox::SetChecked(BOOL b) 23 | { 24 | if(m_bChecked == b) 25 | return; 26 | 27 | m_bChecked = b; 28 | Invalidate(); 29 | 30 | UIActionEvent event(this, GetID(), ACTION_SELECT, m_bChecked); 31 | UIApplication::SendEvent(&event); 32 | } 33 | 34 | BOOL UICheckBox::OnActionPerformed(UIActionEvent* event) 35 | { 36 | if(event->GetCommand() == ACTION_CLICK) 37 | { 38 | SetChecked(m_bChecked ? FALSE : TRUE); 39 | return TRUE; 40 | } 41 | else 42 | { 43 | return __super::OnActionPerformed(event); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /xskin/include/view/UIPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIPANEL_H_INCLUDED__ 2 | #define __UIPANEL_H_INCLUDED__ 3 | 4 | #include "UIWindow.h" 5 | 6 | class UIResponser; 7 | class UIWheelEvent; 8 | class UIKeyEvent; 9 | class XSKIN_API UIPanel : public UIWindow 10 | { 11 | public: 12 | UIPanel(UIResponser* owner = NULL, UIWindow* parent = NULL); 13 | ~UIPanel(); 14 | 15 | public: 16 | // Window without focus can not receive key event and mouse wheel event, 17 | // so we must forward it from owner view. 18 | void ForwardWheelEvent(UIWheelEvent* event); 19 | void ForwardKeyPressedEvent(UIKeyEvent* event); 20 | void ForwardKeyReleasedEvent(UIKeyEvent* event); 21 | 22 | protected: 23 | DWORD GetWndStyle() const OVERRIDE; 24 | DWORD GetWndExStyle() const OVERRIDE; 25 | UIResponser* GetNextResponser() const OVERRIDE; 26 | LRESULT OnWindowMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) OVERRIDE; 27 | 28 | protected: 29 | UIResponser* m_pOwner; 30 | }; 31 | #endif //! __UIPANEL_H_INCLUDED__ -------------------------------------------------------------------------------- /tinyxml2/tinyxml2.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /xskin/include/model/UIModel.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIMODEL_H_INCLUDED__ 2 | #define __UIMODEL_H_INCLUDED__ 3 | 4 | #include 5 | #include "../core/UIObject.h" 6 | 7 | class UIView; 8 | class UIString; 9 | class XSKIN_API UIModel : public UIObject 10 | { 11 | public: 12 | UIModel(); 13 | ~UIModel(); 14 | 15 | public: 16 | virtual UIView* GetView(UIView* pView, int nPos) const = 0; 17 | virtual int GetCount() const = 0; 18 | virtual const void* GetItem(int nPos) const = 0; 19 | virtual BOOL IsEmpty() const = 0; 20 | 21 | }; 22 | 23 | class XSKIN_API UIStringModel : public UIModel 24 | { 25 | public: 26 | UIStringModel(); 27 | ~UIStringModel(); 28 | 29 | public: 30 | void Append(const UIString& str); 31 | UIView* GetView(UIView* pView, int nPos) const OVERRIDE; 32 | int GetCount() const OVERRIDE; 33 | const void* GetItem(int nPos) const OVERRIDE; 34 | BOOL IsEmpty() const OVERRIDE; 35 | 36 | private: 37 | std::vector m_items; 38 | }; 39 | #endif //! __UIADAPTER_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/event/UIEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/event/UIEvent.h" 3 | #include "../../include/core/UIResponser.h" 4 | 5 | UIEvent::UIEvent(UIResponser* pSource, EventType nType, int nFlags) 6 | { 7 | m_pSource = pSource; 8 | m_nTimestamp = ::GetTickCount(); 9 | m_nFlags = nFlags; 10 | m_nType = nType; 11 | } 12 | 13 | UIEvent::~UIEvent() 14 | { 15 | 16 | } 17 | 18 | UIResponser* UIEvent::GetSource() const 19 | { 20 | return m_pSource; 21 | } 22 | 23 | int UIEvent::GetTimestamp() const 24 | { 25 | return m_nTimestamp; 26 | } 27 | 28 | UIEvent::EventType UIEvent::GetType() const 29 | { 30 | return m_nType; 31 | } 32 | 33 | int UIEvent::GetFlags() const 34 | { 35 | return m_nFlags; 36 | } 37 | 38 | int UIEvent::GetKeyStateFlags() 39 | { 40 | int nFlags = 0; 41 | if(::GetKeyState(VK_CONTROL) < 0) 42 | nFlags |= UIEvent::CTRL_MASK; 43 | if(::GetKeyState(VK_SHIFT) < 0) 44 | nFlags |= UIEvent::SHIFT_MASK; 45 | if(::GetKeyState(VK_MENU) < 0) 46 | nFlags |= UIEvent::ALT_MASK; 47 | 48 | return nFlags; 49 | } -------------------------------------------------------------------------------- /xskin/include/view/UIImageView.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIIMAGE_VIEW_H_INCLUDED__ 2 | #define __UIIMAGE_VIEW_H_INCLUDED__ 3 | 4 | #include "UIView.h" 5 | 6 | class UIImageView : public UIView 7 | { 8 | DECLARE_XML_NODE(UIImageView) 9 | DECLARE_XML_PROPERTY() 10 | 11 | 12 | public: 13 | enum ScaleType 14 | { 15 | CENTER = 0, 16 | LEFT, 17 | RIGHT, 18 | TOP, 19 | BOTTOM, 20 | TOP_LEFT, 21 | TOP_RIGHT, 22 | BOTTOM_LEFT, 23 | BOTTOM_RIGHT, 24 | SCALE_FILL, 25 | SCALE_FIT 26 | }; 27 | UIImageView(UIView* parent = NULL); 28 | ~UIImageView(); 29 | 30 | void SetSource(const UIBitmap* pBitmap, const UIRect& rcPos); 31 | void SetSource(const UIString& szFileName, const UIRect& rcPos = UIRect()); 32 | void SetScaleType(ScaleType st); 33 | UISize GetPreferredSize() const OVERRIDE; 34 | 35 | protected: 36 | BOOL OnCustomAttribute(const UIString& szAttrName, const UIString& szAttrValue) OVERRIDE; 37 | void OnPaint(HDC hdc) OVERRIDE; 38 | 39 | private: 40 | UIDrawable m_src; 41 | ScaleType m_scaleType; 42 | }; 43 | #endif //! __UIIMAGE_VIEW_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/animation/UIBoundAnimation.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/animation/UIBoundAnimation.h" 3 | #include "../../include/view/UIView.h" 4 | 5 | UIBoundAnimation::UIBoundAnimation(UIView* pTarget, const UIRect& rcStart, const UIRect& rcEnd) 6 | : UIAnimation(pTarget) 7 | { 8 | m_rcStart = rcStart; 9 | m_rcEnd = rcEnd; 10 | } 11 | 12 | UIBoundAnimation::~UIBoundAnimation() 13 | { 14 | 15 | } 16 | 17 | void UIBoundAnimation::SetStartValue(const UIRect& rcStart) 18 | { 19 | m_rcStart = rcStart; 20 | } 21 | 22 | void UIBoundAnimation::SetEndValue(const UIRect& rcEnd) 23 | { 24 | m_rcEnd = rcEnd; 25 | } 26 | 27 | void UIBoundAnimation::OnAnimationStarted() 28 | { 29 | 30 | } 31 | 32 | void UIBoundAnimation::OnAnimationStopped() 33 | { 34 | 35 | } 36 | 37 | void UIBoundAnimation::OnAnimationStepped() 38 | { 39 | UIRect rcDst = GetValueBetween(m_rcStart, m_rcEnd); 40 | 41 | m_pTarget->Invalidate(); 42 | m_pTarget->SetBounds(rcDst); 43 | m_pTarget->InvalidateLayout(); 44 | m_pTarget->Invalidate(); 45 | 46 | __super::OnAnimationStepped(); 47 | } -------------------------------------------------------------------------------- /xskin/include/animation/UIScaleAnimation.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISCALE_ANIMATION_H_INCLUDED__ 2 | #define __UISCALE_ANIMATION_H_INCLUDED__ 3 | 4 | #include "UIAnimation.h" 5 | 6 | class XSKIN_API UIScaleAnimation : public UIAnimation 7 | { 8 | public: 9 | UIScaleAnimation(UIView* pTarget = NULL, 10 | double fromXScale = 0, double toXScale = 0, 11 | double fromYScale = 0, double toYScale = 0); 12 | ~UIScaleAnimation(); 13 | 14 | enum ScaleAnchor 15 | { 16 | ANCHOR_CENTER = 0, 17 | ANCHOR_TOPLEFT, 18 | ANCHOR_TOPRIGHT, 19 | ANCHOR_BOTTOM_LEFT, 20 | ANCHOR_BOTTOM_RIGHT 21 | }; 22 | 23 | public: 24 | void SetStartValue(double fromXScale, int fromYScale); 25 | void SetEndValue(double toXScale, double toYScale); 26 | void SetScaleAnchor(ScaleAnchor anchor); 27 | void OnAnimationStarted() OVERRIDE; 28 | void OnAnimationStepped() OVERRIDE; 29 | void OnAnimationStopped() OVERRIDE; 30 | 31 | private: 32 | UIRect m_rcBound; 33 | ScaleAnchor m_anchor; 34 | double m_dFromXScale; 35 | double m_dToXScale; 36 | double m_dFromYScale; 37 | double m_dToYScale; 38 | }; 39 | #endif //! __UISCALE_ANIMATION_H_INCLUDED__ -------------------------------------------------------------------------------- /unzip/unzip.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 23 | 24 | 头文件 25 | 26 | 27 | -------------------------------------------------------------------------------- /xskin/include/gfx/UIBitmap.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIBITMAP_H_INCLUDED__ 2 | #define __UIBITMAP_H_INCLUDED__ 3 | 4 | #include 5 | #include "../core/UIObject.h" 6 | #include "../core/UIString.h" 7 | #include "../core/RefCounted.h" 8 | 9 | class XSKIN_API UIBitmap : public UIObject, public RefCounted 10 | { 11 | public: 12 | static UIBitmap* GetBitmap(LPCTSTR szCacheKey); 13 | static UIBitmap* CreateNew(HBITMAP hBitmap, LPCTSTR szCacheKey = NULL); 14 | static UIBitmap* CreateNew(int w, int h, int nBitCount, LPCVOID lpvBits, LPCTSTR szCacheKey = NULL); 15 | 16 | BOOL HasAlpha() const; 17 | int GetWidth() const; 18 | int GetHeight() const; 19 | HBITMAP GetNativeBitmap() const; 20 | operator HBITMAP() const; 21 | 22 | protected: 23 | UIBitmap(HBITMAP hBitmap); 24 | UIBitmap(int w, int h, int nBitCount, LPCVOID lpvBits); 25 | ~UIBitmap(); 26 | void Init(); 27 | 28 | private: 29 | UIString m_szKey; 30 | HBITMAP m_hBitmap; 31 | int m_nWidth; 32 | int m_nHeight; 33 | BOOL m_bAlphaChannel; 34 | 35 | typedef std::map BitmapCache; 36 | static BitmapCache cache; 37 | }; 38 | #endif //! __UIBITMAP_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/core/UIPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIPOINT_H_INCLUDED__ 2 | #define __UIPOINT_H_INCLUDED__ 3 | 4 | #include 5 | 6 | class XSKIN_API UIPoint : public tagPOINT 7 | { 8 | public: 9 | inline UIPoint() 10 | { 11 | x = y = 0; 12 | } 13 | 14 | inline UIPoint(const POINT& src) 15 | { 16 | x = src.x; 17 | y = src.y; 18 | } 19 | 20 | inline UIPoint(int x, int y) 21 | { 22 | this->x = x; 23 | this->y = y; 24 | } 25 | 26 | inline UIPoint(LPARAM lParam) 27 | { 28 | x = LOWORD(lParam); 29 | y = HIWORD(lParam); 30 | } 31 | 32 | inline ~UIPoint() 33 | { 34 | 35 | } 36 | 37 | public: 38 | inline void SetPoint(int x, int y) 39 | { 40 | this->x = x; 41 | this->y = y; 42 | } 43 | 44 | inline void Offset(int xOffset, int yOffset) 45 | { 46 | x += xOffset; 47 | y += yOffset; 48 | } 49 | 50 | inline UIPoint operator+(POINT point) const 51 | { 52 | return UIPoint(x + point.x, y + point.y); 53 | } 54 | 55 | inline UIPoint operator-(POINT point) const 56 | { 57 | return UIPoint(x - point.x, y - point.y); 58 | } 59 | 60 | inline operator LPPOINT() 61 | { 62 | return this; 63 | } 64 | }; 65 | #endif //! __UIPOINT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin_dll/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 动态链接库:xskin_dll 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 xskin_dll DLL。 6 | 7 | 本文件概要介绍组成 xskin_dll 应用程序的每个文件的内容。 8 | 9 | 10 | xskin_dll.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | xskin_dll.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | xskin_dll.cpp 17 | 这是主 DLL 源文件。 18 | 19 | 此 DLL 在创建时不导出任何符号。因此,生成时不会产生 .lib 文件。如果希望此项目成为其他某个项目的项目依赖项,则需要添加代码以从 DLL 导出某些符号,以便产生一个导出库,或者,也可以在项目“属性页”对话框中的“链接器”文件夹中,将“常规”属性页上的“忽略输入库”属性设置为“是”。 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | 其他标准文件: 23 | 24 | StdAfx.h, StdAfx.cpp 25 | 这些文件用于生成名为 xskin_dll.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | 其他注释: 29 | 30 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 31 | 32 | ///////////////////////////////////////////////////////////////////////////// 33 | -------------------------------------------------------------------------------- /xskin/src/core/UIObject.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include "../../Include/core/UIObject.h" 4 | 5 | UIObject::UIObject() 6 | { 7 | 8 | } 9 | 10 | UIObject::~UIObject() 11 | { 12 | 13 | } 14 | 15 | void UIObject::Trace(LPCTSTR szFmt, ...) 16 | { 17 | #if _DEBUG 18 | TCHAR szMsg[128] = { 0 }; 19 | TCHAR szTime[32] = { 0 }; 20 | SYSTEMTIME st; 21 | ::GetLocalTime(&st); 22 | _sntprintf(szTime, sizeof(szTime) / sizeof(TCHAR), TEXT("%04d-%02d-%02d %02d:%02d:%02d.%03d "), 23 | st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); 24 | _tcscpy(szMsg, szTime); 25 | va_list arglist; 26 | va_start(arglist, szFmt); 27 | _vsntprintf(szMsg + _tcslen(szTime), sizeof(szMsg) / sizeof(TCHAR) - _tcslen(szTime), szFmt, arglist); 28 | _tcscat(szMsg, TEXT("\n")); 29 | va_end(arglist); 30 | ::OutputDebugString(szMsg); 31 | #endif 32 | } 33 | 34 | LPCSTR UIObject::Name() const 35 | { 36 | return typeid(*this).name(); 37 | } 38 | 39 | int UIObject::HashCode() const 40 | { 41 | return typeid(*this).hash_code(); 42 | } 43 | 44 | BOOL UIObject::operator==(const UIObject& obj) const 45 | { 46 | return typeid(*this) == typeid(obj) ? TRUE : FALSE; 47 | } -------------------------------------------------------------------------------- /xskin/include/view/UIListView.h: -------------------------------------------------------------------------------- 1 | #ifndef __UILIST_VIEW_H_INCLUDED__ 2 | #define __UILIST_VIEW_H_INCLUDED__ 3 | 4 | #include "UIScrollView.h" 5 | 6 | class UIModel; 7 | class XSKIN_API UIListView : public UIScrollView 8 | { 9 | DECLARE_XML_NODE(UIListView) 10 | DECLARE_XML_PROPERTY() 11 | public: 12 | enum { DEFAULT_ITEM_HEIGHT = 20 }; 13 | 14 | UIListView(UIView* parent = NULL); 15 | ~UIListView(); 16 | 17 | public: 18 | void SetModel(UIModel* model); 19 | UIModel* GetModel() const; 20 | void NotifyDataChanged(); 21 | UIView* GetItem(int nIndex); 22 | void SetCheckedItem(UIView* v); 23 | void SetCheckedIndex(int nIndex); 24 | UIView* GetCheckedItem() const; 25 | int GetCheckedIndex() const; 26 | UISize GetPreferredSize() const OVERRIDE; 27 | BOOL IsFocusFrameVisible() const OVERRIDE; 28 | 29 | protected: 30 | void DeleteItems(); 31 | void Scroll(int x, int y) OVERRIDE; 32 | void OnLayout() OVERRIDE; 33 | void ProcessContent() OVERRIDE; 34 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 35 | 36 | protected: 37 | BOOL m_bReload; 38 | std::vector m_items; 39 | UIModel* m_pModel; 40 | UIView* m_pCheckedItem; 41 | }; 42 | #endif //! __UILIST_VIEW_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/view/UIRadioButton.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIRADIO_BUTTON_H_INCLUDED__ 2 | #define __UIRADIO_BUTTON_H_INCLUDED__ 3 | 4 | #include "UIButton.h" 5 | 6 | class XSKIN_API UIRadioButton : public UIButton 7 | { 8 | DECLARE_XML_NODE(UIRadioButton) 9 | DECLARE_XML_PROPERTY() 10 | public: 11 | enum { BITMAP_TEXT_SPACING = 3 }; 12 | 13 | UIRadioButton(UIView* parent = NULL); 14 | ~UIRadioButton(); 15 | 16 | public: 17 | void SetCheckedBkNormal(const UIBitmap* pBitmap, const UIRect& rcPos); 18 | void SetCheckedBkHot(const UIBitmap* pBitmap, const UIRect& rcPos); 19 | void SetCheckedBkPushed(const UIBitmap* pBitmap, const UIRect& rcPos); 20 | void SetCheckedBkDisabled(const UIBitmap* pBitmap, const UIRect& rcPos); 21 | void SetChecked(BOOL b) OVERRIDE; 22 | void Activate(BOOL b) OVERRIDE; 23 | void SetSpacing(int nSpacing); 24 | UISize GetPreferredSize() const OVERRIDE; 25 | 26 | protected: 27 | BOOL OnActionPerformed(UIActionEvent* event); 28 | void OnPaint(HDC hdc) OVERRIDE; 29 | 30 | protected: 31 | int m_nSpacing; 32 | UIDrawable m_bkCheckedNormal; 33 | UIDrawable m_bkCheckedHot; 34 | UIDrawable m_bkCheckedPushed; 35 | UIDrawable m_bkCheckedDisabled; 36 | }; 37 | #endif //! __UIRADIO_BUTTON_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/core/UIApplication.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIAPPLICATION_H_INCLUDED__ 2 | #define __UIAPPLICATION_H_INCLUDED__ 3 | 4 | #include 5 | #include "UIResponser.h" 6 | #include "UIAsset.h" 7 | #include "UIString.h" 8 | #include "AutoPtr.h" 9 | 10 | class XSKIN_API UIApplication : public UIResponser 11 | { 12 | public: 13 | enum Locale 14 | { 15 | LOCALE_FOLLOW_SYSTEM, 16 | LOCALE_ENGLISH, 17 | LOCALE_SIMPLIFIED_CHINESE, 18 | LOCALE_TRADITIONAL_CHINESE 19 | }; 20 | 21 | public: 22 | UIApplication(); 23 | ~UIApplication(); 24 | static UIApplication* Instance(); 25 | int Run() const; 26 | void Exit(int nRetuenCode = 0) const; 27 | void SetResZip(LPCTSTR szResZipFile); 28 | UIAsset* GetAssetManager() const; 29 | int GetCommandCount() const; 30 | UIString GetCommandString(int nIndex) const; 31 | UIString GetApplicationName() const; 32 | void SetLocale(Locale locale); 33 | Locale GetLocale() const; 34 | HINSTANCE GetHandle() const; 35 | static void SendEvent(UIEvent* event); 36 | 37 | protected: 38 | BOOL Event(UIEvent* event) OVERRIDE; 39 | 40 | protected: 41 | static UIApplication* self; 42 | AutoPtr m_pAsset; 43 | Locale m_locale; 44 | }; 45 | 46 | #endif //! __UIAPPLICATION_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/event/UIActionEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIACTION_EVENT_H_INCLUDED__ 2 | #define __UIACTION_EVENT_H_INCLUDED__ 3 | 4 | #include "UIEvent.h" 5 | #include "../core/UIString.h" 6 | 7 | #define ACTION_CLICK _T("click") // clicking on object, nFlag is unused. 8 | #define ACTION_CHECK _T("check") // checked state changed, nFlag is TRUE if selected otherwise FALSE. 9 | #define ACTION_SELECT _T("select") // selection changed, nFlag is selected index. 10 | #define ACTION_SCROLL _T("scroll") // view content scrolled, high word of nFlag is x-offset, low word is y-offset 11 | #define ACTION_HSCROLL _T("hscroll") // horizontal scrollbar scrolled, nFlag is scroll value. 12 | #define ACTION_VSCROLL _T("vscroll") // vertical scrollbar scrolled, nFlag is scroll value. 13 | #define ACTION_VALUE_CHANGED _T("valuechanged") // value changed, such as text etc, nFlag is unused. 14 | 15 | class XSKIN_API UIActionEvent : public UIEvent 16 | { 17 | public: 18 | UIActionEvent(UIResponser* pSource, const UIString& szID, const UIString& szCommand, int nFlags = 0); 19 | ~UIActionEvent(); 20 | 21 | public: 22 | UIString GetID() const; 23 | UIString GetCommand() const; 24 | 25 | private: 26 | UIString m_szID; 27 | UIString m_szCommand; 28 | }; 29 | #endif //! __UIACTION_EVENT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/gfx/UIRender.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIRENDER_H_INCLUDED__ 2 | #define __UIRENDER_H_INCLUDED__ 3 | 4 | #include "../core/UIObject.h" 5 | #include "../core/UIString.h" 6 | #include "../core/UIPoint.h" 7 | #include "../core/UISize.h" 8 | #include "../core/UIRect.h" 9 | #include "../core/UIMeasure.h" 10 | #include "../gfx/UIBitmap.h" 11 | #include "../gfx/UIPen.h" 12 | #include "../gfx/UIBrush.h" 13 | 14 | class XSKIN_API UIRender : public UIObject 15 | { 16 | public: 17 | UIRender(); 18 | ~UIRender(); 19 | static void MeasureString(HDC hdc, UIRect& rcOut, const UIString& szText, const UIAlignment& align, BOOL bMultiline = FALSE); 20 | static void DrawString(HDC hdc, const UIRect& rc, const UIString& szText, const UIAlignment& align, BOOL bMultiline = FALSE); 21 | static void DrawLine(HDC hdc, const UIPoint& p1, const UIPoint& p2); 22 | static void DrawRect(HDC hdc, const UIRect& rc, const UIBrush& hbr); 23 | static void DrawFocusRect(HDC hdc, const UIRect& rc); 24 | static void FillRect(HDC hdc, const UIRect& rc, const UIBrush& hbr); 25 | static void DrawBitmap(HDC hdc, const UIRect& dst, const UIRect& src, const UIBitmap* pBitmap, int nOpacity = 255); 26 | static void DrawBitmap(HDC hdc, const UIRect& dst, const UIBitmap* pBitmap, int nOpacity = 255); 27 | }; 28 | #endif //! __UIRENDER_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin_test/App.h: -------------------------------------------------------------------------------- 1 | #ifndef __APP_H_INCLUDED__ 2 | #define __APP_H_INCLUDED__ 3 | 4 | #include "include/XSkin.h" 5 | 6 | class ListAdapter : public UIModel 7 | { 8 | public: 9 | ListAdapter(); 10 | ~ListAdapter(); 11 | 12 | public: 13 | void SetData(const std::vector& data); 14 | UIView* GetView(UIView* pView, int nPos) const OVERRIDE; 15 | int GetCount() const OVERRIDE; 16 | const void* GetItem(int nPos) const OVERRIDE; 17 | BOOL IsEmpty() const OVERRIDE; 18 | 19 | protected: 20 | std::vector m_data; 21 | }; 22 | 23 | // app 24 | class MyApp : public UIApplication 25 | { 26 | public: 27 | MyApp(); 28 | ~MyApp(); 29 | 30 | protected: 31 | BOOL Event(UIEvent* event) OVERRIDE; 32 | }; 33 | 34 | // main window. 35 | class MainWindow : public UIWindow 36 | { 37 | public: 38 | MainWindow(UIWindow* parent = NULL); 39 | ~MainWindow(); 40 | 41 | public: 42 | BOOL Event(UIEvent* event) OVERRIDE; 43 | void OnCreate() OVERRIDE; 44 | void OnDestroy() OVERRIDE; 45 | 46 | protected: 47 | UICardLayout* m_pPager; 48 | }; 49 | 50 | class Dialog : public UIWindow 51 | { 52 | public: 53 | Dialog(UIWindow* parent = NULL); 54 | ~Dialog(); 55 | 56 | public: 57 | BOOL Event(UIEvent* event) OVERRIDE; 58 | void OnCreate() OVERRIDE; 59 | void OnDestroy() OVERRIDE; 60 | 61 | private: 62 | UIButton* m_pClose; 63 | }; 64 | #endif //! __APP_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/animation/UITranslateAnimation.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/animation/UITranslateAnimation.h" 3 | #include "../../include/view/UIView.h" 4 | 5 | UITranslateAnimation::UITranslateAnimation(UIView* pTarget, 6 | int nFromXDelta, int nToXDelta, int nFromYDelta, int nToYDelta) 7 | : UIAnimation(pTarget) 8 | { 9 | m_nFromXDelta = nFromXDelta; 10 | m_nFromYDelta = nFromYDelta; 11 | m_nToXDelta = nToXDelta; 12 | m_nToYDelta = nToYDelta; 13 | } 14 | 15 | UITranslateAnimation::~UITranslateAnimation() 16 | { 17 | 18 | } 19 | 20 | void UITranslateAnimation::SetStartValue(int nFromXDelta, int nFromYDelta) 21 | { 22 | m_nFromXDelta = nFromXDelta; 23 | m_nFromYDelta = nFromYDelta; 24 | } 25 | 26 | void UITranslateAnimation::SetEndValue(int nToXDelta, int nToYDelta) 27 | { 28 | m_nToXDelta = nToXDelta; 29 | m_nToYDelta = nToYDelta; 30 | } 31 | 32 | void UITranslateAnimation::OnAnimationStarted() 33 | { 34 | m_pos = m_pTarget->GetPosition(); 35 | } 36 | 37 | void UITranslateAnimation::OnAnimationStepped() 38 | { 39 | __super::OnAnimationStepped(); 40 | 41 | int x = GetValueBetween(m_pos.x + m_nFromXDelta, m_pos.x + m_nToXDelta); 42 | int y = GetValueBetween(m_pos.y + m_nFromYDelta, m_pos.y + m_nToYDelta); 43 | m_pTarget->Invalidate(); 44 | m_pTarget->SetPosition(x, y); 45 | m_pTarget->Invalidate(); 46 | } 47 | 48 | void UITranslateAnimation::OnAnimationStopped() 49 | { 50 | 51 | } -------------------------------------------------------------------------------- /xskin/include/event/UIEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef __EVENT_H_INCLUDED__ 2 | #define __EVENT_H_INCLUDED__ 3 | 4 | #include "../core/UIObject.h" 5 | 6 | class XSKIN_API UIResponser; 7 | class XSKIN_API UIEvent : public UIObject 8 | { 9 | public: 10 | enum EventType 11 | { 12 | EVENT_UNKNOWN = 0, 13 | EVENT_MOUSE_PRESSED, 14 | EVENT_MOUSE_RELEASED, 15 | EVENT_MOUSE_MOVED, 16 | EVENT_MOUSE_DRAGGED, 17 | EVENT_MOUSE_ENTERED, 18 | EVENT_MOUSE_EXITED, 19 | EVENT_MOUSE_CLICKED, 20 | EVENT_MOUSE_DBLCLICKED, 21 | EVENT_MOUSE_WHEEL, 22 | EVENT_KEY_PRESSED, 23 | EVENT_KEY_RELEASED, 24 | EVENT_FOCUS_GAIN, 25 | EVENT_FOCUS_LOST, 26 | EVENT_ACTION, 27 | EVENT_TIMER, 28 | EVENT_HIERARCHY_CHILD_ADDED, 29 | EVENT_HIERARCHY_CHILD_REMOVED, 30 | }; 31 | 32 | enum EventFlags 33 | { 34 | ALT_MASK = 1 << 0, 35 | CTRL_MASK = 1 << 1, 36 | SHIFT_MASK = 1 << 2, 37 | LEFT_BUTTON_MASK = 1 << 3, 38 | RIGHT_BUTTON_MASK = 1 << 4, 39 | MIDDLE_BUTTON_MASK = 1 << 5 40 | }; 41 | 42 | UIEvent(UIResponser* pSource, EventType nType, int nFlags); 43 | ~UIEvent(); 44 | 45 | public: 46 | UIResponser* GetSource() const; 47 | int GetTimestamp() const; 48 | EventType GetType() const; 49 | int GetFlags() const; 50 | static int GetKeyStateFlags(); 51 | 52 | private: 53 | UIResponser* m_pSource; 54 | EventType m_nType; 55 | int m_nTimestamp; 56 | int m_nFlags; 57 | }; 58 | #endif //! __EVENT_H_INCLUDED__ -------------------------------------------------------------------------------- /libjpeg/rdgif.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rdgif.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains routines to read input images in GIF format. 9 | * 10 | ***************************************************************************** 11 | * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * 12 | * the ability to read GIF files has been removed from the IJG distribution. * 13 | * Sorry about that. * 14 | ***************************************************************************** 15 | * 16 | * We are required to state that 17 | * "The Graphics Interchange Format(c) is the Copyright property of 18 | * CompuServe Incorporated. GIF(sm) is a Service Mark property of 19 | * CompuServe Incorporated." 20 | */ 21 | 22 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ 23 | 24 | #ifdef GIF_SUPPORTED 25 | 26 | /* 27 | * The module selection routine for GIF format input. 28 | */ 29 | 30 | GLOBAL(cjpeg_source_ptr) 31 | jinit_read_gif (j_compress_ptr cinfo) 32 | { 33 | fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n"); 34 | exit(EXIT_FAILURE); 35 | return NULL; /* keep compiler happy */ 36 | } 37 | 38 | #endif /* GIF_SUPPORTED */ 39 | -------------------------------------------------------------------------------- /xskin/include/view/UIComboBox.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICOMBO_BOX_H_INCLUDED__ 2 | #define __UICOMBO_BOX_H_INCLUDED__ 3 | 4 | #include "UIControl.h" 5 | 6 | class UIModel; 7 | class UIListView; 8 | class UIPanel; 9 | class XSKIN_API UIComboBox : public UIControl 10 | { 11 | DECLARE_XML_NODE(UIComboBox) 12 | DECLARE_XML_PROPERTY() 13 | public: 14 | UIComboBox(UIView* parent = NULL); 15 | ~UIComboBox(); 16 | 17 | public: 18 | void SetModel(UIModel* model); 19 | UIModel* GetModel() const; 20 | UIView* GetItem(int nIndex) const; 21 | void SetCheckedIndex(int nIndex); 22 | void SetCheckedItem(UIView* v); 23 | UIView* GetCheckedItem() const; 24 | int GetCheckedIndex() const; 25 | void SetDroplistHeight(int nHeight); 26 | void Activate(BOOL b) OVERRIDE; 27 | BOOL IsFocusFrameVisible() const OVERRIDE; 28 | 29 | protected: 30 | void OnInit() OVERRIDE; 31 | void OnPaint(HDC hdc) OVERRIDE; 32 | BOOL OnMouseWheel(UIWheelEvent* event) OVERRIDE; 33 | BOOL OnKeyPressed(UIKeyEvent* event) OVERRIDE; 34 | BOOL OnKeyReleased(UIKeyEvent* event) OVERRIDE; 35 | BOOL OnFocusGain(UIFocusEvent* event) OVERRIDE; 36 | BOOL OnFocusLost(UIFocusEvent* event) OVERRIDE; 37 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 38 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 39 | 40 | protected: 41 | UIListView* m_pListView; 42 | UIPanel* m_pPanel; 43 | int m_nDroplistHeight; 44 | }; 45 | #endif //! __UICOMBO_BOX_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/view/UIGridLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIGRID_LAYOUT_H_INCLUDED__ 2 | #define __UIGRID_LAYOUT_H_INCLUDED__ 3 | 4 | #include "UIView.h" 5 | 6 | class XSKIN_API UIGridLayout : public UIView 7 | { 8 | DECLARE_XML_NODE(UIGridLayout) 9 | DECLARE_XML_PROPERTY() 10 | public: 11 | enum 12 | { 13 | DEFAULT_HORIZONTAL_SPACING = 2, 14 | DEFAULT_VERTICAL_SPACING = 2 15 | }; 16 | 17 | UIGridLayout(UIView* parent = NULL); 18 | UIGridLayout(int nRowCount, int nColumnCount, UIView* parent = NULL); 19 | ~UIGridLayout(); 20 | 21 | public: 22 | void AddView(UIView* v, int nRow, int nColumn,int nRowSpan = 1, int nColumnSpan = 1, const UIAlignment& alignment = UIAlignment()); 23 | void AddView(UIView* v, int nRow, int nColumn, const UIAlignment& align = UIAlignment()); 24 | UIView* GetView(int nRow, int nColumn) const; 25 | void SetHorizontalSpacing(int nSpacing); 26 | void SetVerticalSpacing(int nSpacing); 27 | UISize GetSpacing() const; 28 | void SetRowCount(int nRowCount); 29 | int SetColumnCount(int nColumnCount); 30 | int GetRowCount() const; 31 | int GetColumnCount() const; 32 | UISize GetPreferredSize() const OVERRIDE; 33 | 34 | protected: 35 | UISize CalcRowColumn() const; 36 | void OnLayout() OVERRIDE; 37 | void OnPaint(HDC hdc) OVERRIDE; 38 | 39 | protected: 40 | int m_nRowCount; 41 | int m_nColumnCount; 42 | int m_nHorizontalSpacing; 43 | int m_nVerticalSpacing; 44 | }; 45 | #endif // __UIGRID_LAYOUT_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/view/UIScrollView.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISCROLL_VIEW_H_INCLUDED__ 2 | #define __UISCROLL_VIEW_H_INCLUDED__ 3 | 4 | #include "UIView.h" 5 | 6 | class UIScrollBar; 7 | class XSKIN_API UIScrollView : public UIView 8 | { 9 | DECLARE_XML_NODE(UIScrollView) 10 | DECLARE_XML_PROPERTY() 11 | public: 12 | UIScrollView(UIView* parent = NULL); 13 | ~UIScrollView(); 14 | 15 | public: 16 | void SetContentView(UIView* v); 17 | UIView* GetContentView(); 18 | void RemoveContentView(); 19 | void SetScrollUnit(int nUint); 20 | void ScrollToTop(); 21 | void ScrollToBottom(); 22 | void ScrollToLeft(); 23 | void ScrollToRight(); 24 | UIPoint GetOffset() const; 25 | UISize GetPageSize() const; 26 | UISize GetPreferredSize() const OVERRIDE; 27 | BOOL IsFocusFrameVisible() const OVERRIDE; 28 | 29 | protected: 30 | virtual void ProcessScrollbar(); 31 | virtual void ProcessContent(); 32 | virtual void Scroll(int x, int y); 33 | void OnLayout() OVERRIDE; 34 | void OnInit() OVERRIDE; 35 | void OnPaint(HDC hdc) OVERRIDE; 36 | BOOL OnMouseWheel(UIWheelEvent* event) OVERRIDE; 37 | BOOL OnKeyPressed(UIKeyEvent* event) OVERRIDE; 38 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 39 | 40 | protected: 41 | UIScrollBar* m_pHScrollBar; 42 | UIScrollBar* m_pVScrollBar; 43 | BOOL m_bHScrollVisible; 44 | BOOL m_bVScrollVisible; 45 | UIPoint m_ptOffset; 46 | UISize m_szPage; 47 | }; 48 | #endif //! __UISCROLL_VIEW_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/view/UIHyperlink.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UIHyperlink.h" 3 | #include "../../include/view/UIWindow.h" 4 | #include "../../include/view/UIRootView.h" 5 | #include "../../include/gfx/UIRender.h" 6 | #include "../../include/gfx/UIPen.h" 7 | 8 | IMPLEMENT_XML_NODE(UIHyperlink) 9 | 10 | UIHyperlink::UIHyperlink(UIView* parent) 11 | : UIButton(parent) 12 | { 13 | m_hCursor = UIApplication::Instance()->GetAssetManager()->GetCursor(UIAsset::CURSOR_HAND); 14 | } 15 | 16 | UIHyperlink::~UIHyperlink() 17 | { 18 | 19 | } 20 | 21 | UISize UIHyperlink::GetPreferredSize() const 22 | { 23 | UISize size; 24 | size.cx = m_pFont->GetStringWidth(m_szText) + m_rcPadding.left + m_rcPadding.right; 25 | size.cy = m_pFont->GetHeight() + m_rcPadding.top + m_rcPadding.bottom; 26 | return size; 27 | } 28 | 29 | void UIHyperlink::OnPaint(HDC hdc) 30 | { 31 | UIRect rcText(0, 0, m_rcBounds.Width(), m_rcBounds.Height()); 32 | m_bkgnd.Draw(hdc, rcText, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 33 | 34 | HFONT hOldFont = static_cast(::SelectObject(hdc, *m_pFont)); 35 | COLORREF clrOld = ::SetTextColor(hdc, m_bEnabled ? m_clrText : m_clrTextDisabled); 36 | rcText.left += m_rcPadding.left; 37 | rcText.right -= m_rcPadding.right; 38 | rcText.top += m_rcPadding.top; 39 | rcText.bottom -= m_rcPadding.bottom; 40 | UIRender::DrawString(hdc, rcText, m_szText, m_alignment); 41 | ::SetTextColor(hdc, clrOld); 42 | ::SelectObject(hdc, hOldFont); 43 | } -------------------------------------------------------------------------------- /xskin/src/view/UIPanel.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UIPanel.h" 3 | #include "../../include/core/UIResponser.h" 4 | #include "../../include/view/UIRootView.h" 5 | #include "../../include/event/UIWheelEvent.h" 6 | #include "../../include/event/UIKeyEvent.h" 7 | 8 | UIPanel::UIPanel(UIResponser* owner, UIWindow* parent) 9 | : UIWindow(parent) 10 | { 11 | m_pOwner = owner; 12 | } 13 | 14 | UIPanel::~UIPanel() 15 | { 16 | 17 | } 18 | 19 | void UIPanel::ForwardWheelEvent(UIWheelEvent* event) 20 | { 21 | m_pRootView->ProcessMouseWheel(event->GetLocation(), event->GetDelta(), event->GetFlags()); 22 | } 23 | 24 | void UIPanel::ForwardKeyPressedEvent(UIKeyEvent* event) 25 | { 26 | m_pRootView->ProcessKeyPressed(event->GetKeyCode(), event->GetRepeatCount(), event->GetFlags()); 27 | } 28 | 29 | void UIPanel::ForwardKeyReleasedEvent(UIKeyEvent* event) 30 | { 31 | m_pRootView->ProcessKeyReleased(event->GetKeyCode(), event->GetRepeatCount(), event->GetFlags()); 32 | } 33 | 34 | DWORD UIPanel::GetWndStyle() const 35 | { 36 | return WS_POPUP; 37 | } 38 | 39 | DWORD UIPanel::GetWndExStyle() const 40 | { 41 | return WS_EX_TOOLWINDOW | WS_EX_TOPMOST; 42 | } 43 | 44 | UIResponser* UIPanel::GetNextResponser() const 45 | { 46 | return m_pOwner; 47 | } 48 | 49 | LRESULT UIPanel::OnWindowMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) 50 | { 51 | if(uMsg == WM_MOUSEACTIVATE) 52 | { 53 | return MA_NOACTIVATE; 54 | } 55 | return __super::OnWindowMessage(uMsg, wParam, lParam); 56 | } -------------------------------------------------------------------------------- /xskin/include/view/UISlider.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISLIDER_H_INCLUDED__ 2 | #define __UISLIDER_H_INCLUDED__ 3 | 4 | #include "UIProgressBar.h" 5 | 6 | class XSKIN_API UISlider : public UIProgressBar 7 | { 8 | protected: 9 | class XSKIN_API UISliderButton : public UIControl 10 | { 11 | public: 12 | UISliderButton(UIView* parent = NULL); 13 | ~UISliderButton(); 14 | 15 | protected: 16 | void OnPaint(HDC hdc) OVERRIDE; 17 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 18 | BOOL OnMouseDragged(UIMouseEvent* event) OVERRIDE; 19 | }; 20 | 21 | DECLARE_XML_NODE(UISlider) 22 | DECLARE_XML_PROPERTY() 23 | public: 24 | enum { DEFAULT_STEP_UNIT = 1 }; 25 | 26 | UISlider(UIView* parent = NULL); 27 | ~UISlider(); 28 | 29 | public: 30 | void SetStepUnit(int nUnit); 31 | int GetStepUnit() const; 32 | void StepForward(); 33 | void StepBackward(); 34 | void SetEnabled(BOOL b) OVERRIDE; 35 | UISize GetPreferredSize() const OVERRIDE; 36 | 37 | protected: 38 | void UpdateTrackPos(); 39 | void SetTrackPos(const UIRect& rcTrack); 40 | void OnLayout() OVERRIDE; 41 | void OnPaint(HDC hdc) OVERRIDE; 42 | void OnInit() OVERRIDE; 43 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 44 | BOOL OnMouseDragged(UIMouseEvent* event) OVERRIDE; 45 | BOOL OnKeyPressed(UIKeyEvent* event) OVERRIDE; 46 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 47 | 48 | protected: 49 | int m_nStepUnit; 50 | UIPoint m_ptLast; 51 | UISliderButton* m_pHandle; 52 | }; 53 | #endif //! __UISLIDER_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/model/UIModel.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/model/UIModel.h" 3 | #include "../../include/core/UIString.h" 4 | #include "../../include/view/UIListItem.h" 5 | 6 | UIModel::UIModel() 7 | { 8 | 9 | } 10 | 11 | UIModel::~UIModel() 12 | { 13 | 14 | } 15 | 16 | UIStringModel::UIStringModel() 17 | { 18 | 19 | } 20 | 21 | UIStringModel::~UIStringModel() 22 | { 23 | 24 | } 25 | 26 | void UIStringModel::Append(const UIString& str) 27 | { 28 | m_items.push_back(str); 29 | } 30 | 31 | UIView* UIStringModel::GetView(UIView* pView, int nPos) const 32 | { 33 | UIListItem* pItem; 34 | if(pView) 35 | { 36 | pItem = static_cast(pView); 37 | pItem->SetText(m_items[nPos]); 38 | } 39 | else 40 | { 41 | pItem = new UIListItem; 42 | pItem->SetText(m_items[nPos]); 43 | pItem->SetSizePolicy(UISizePolicy::EXPANDING, UISizePolicy::PREFERRED); 44 | const UIBitmap* pNormalBitmap = UIApplication::Instance()->GetAssetManager()->GetRGBImage(RGB(229, 237, 242)); 45 | const UIBitmap* pCheckedBitmap = UIApplication::Instance()->GetAssetManager()->GetRGBImage(RGB(70, 185, 240)); 46 | pItem->SetBkHot(pNormalBitmap, UIRect(0, 0, 0, 0)); 47 | pItem->SetBkChecked(pCheckedBitmap, UIRect(0, 0, 0, 0)); 48 | } 49 | 50 | return pItem; 51 | } 52 | 53 | int UIStringModel::GetCount() const 54 | { 55 | return m_items.size(); 56 | } 57 | 58 | const void* UIStringModel::GetItem(int nPos) const 59 | { 60 | return m_items[nPos].GetData(); 61 | } 62 | 63 | BOOL UIStringModel::IsEmpty() const 64 | { 65 | return m_items.size() == 0 ? TRUE : FALSE; 66 | } 67 | -------------------------------------------------------------------------------- /xskin/include/core/UIMeasure.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIMEASURE_H_INCLUDED__ 2 | #define __UIMEASURE_H_INCLUDED__ 3 | 4 | enum Direction 5 | { 6 | HORIZONTAL, 7 | VERTICAL 8 | }; 9 | 10 | class XSKIN_API UISizePolicy 11 | { 12 | public: 13 | enum Policy 14 | { 15 | FIXED = 0, 16 | PREFERRED, 17 | EXPANDING, 18 | }; 19 | 20 | inline UISizePolicy() 21 | { 22 | cx = cy = FIXED; 23 | } 24 | 25 | inline UISizePolicy(Policy horizontal, Policy vertical) 26 | { 27 | cx = horizontal; 28 | cy = vertical; 29 | } 30 | 31 | inline UISizePolicy(const UISizePolicy& src) 32 | { 33 | cx = src.cx; 34 | cy = src.cy; 35 | } 36 | 37 | inline ~UISizePolicy() 38 | { 39 | 40 | } 41 | 42 | public: 43 | Policy cx; 44 | Policy cy; 45 | }; 46 | 47 | class XSKIN_API UIAlignment 48 | { 49 | public: 50 | enum AlignFlag 51 | { 52 | ALIGN_LEFT = 0, 53 | ALIGN_HCENTER, 54 | ALIGN_RIGHT, 55 | ALIGN_TOP, 56 | ALIGN_VCENTER, 57 | ALIGN_BOTTOM 58 | }; 59 | 60 | inline UIAlignment() 61 | { 62 | cx = ALIGN_LEFT; 63 | cy = ALIGN_TOP; 64 | } 65 | 66 | inline UIAlignment(AlignFlag horz, AlignFlag vert) 67 | { 68 | cx = horz; 69 | cy = vert; 70 | } 71 | 72 | inline UIAlignment(const UIAlignment& src) 73 | { 74 | cx = src.cx; 75 | cy = src.cy; 76 | } 77 | 78 | inline ~UIAlignment() 79 | { 80 | 81 | } 82 | 83 | public: 84 | inline operator int() 85 | { 86 | return cx | cy; 87 | } 88 | 89 | inline operator int() const 90 | { 91 | return cx | cy; 92 | } 93 | 94 | public: 95 | AlignFlag cx; 96 | AlignFlag cy; 97 | }; 98 | #endif //! __UIMEASURE_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/gfx/UIFont.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIFONT_H_INCLUDED__ 2 | #define __UIFONT_H_INCLUDED__ 3 | 4 | #include 5 | #include "../core/UIObject.h" 6 | #include "../core/RefCounted.h" 7 | #include "../core/UIString.h" 8 | 9 | class XSKIN_API UIFont : public UIObject, public RefCounted 10 | { 11 | public: 12 | enum FontStyle 13 | { 14 | NORMAL = 1 << 0, 15 | BOLD = 1 << 1, 16 | ITALIC = 1 << 2, 17 | UNDERLINED = 1 << 3 18 | }; 19 | 20 | public: 21 | static UIFont* GetFont(LPCTSTR szCacheKey); 22 | static UIFont* CreateNew(HFONT hFont, LPCTSTR szCacheKey = NULL); 23 | static UIFont* CreateNew(const UIString& szFontName, int nFontSize, int nFontStyle, LPCTSTR szCacheKey = NULL); 24 | 25 | int GetHeight() const; 26 | int GetBaseline() const; 27 | int GetAverageCharWidth() const; 28 | int GetStringWidth(const UIString& szText) const; 29 | int GetFontStyle() const; 30 | int GetFontSize() const; 31 | UIString GetFontName() const; 32 | HFONT GetNativeFont() const; 33 | operator HFONT() const; 34 | 35 | protected: 36 | UIFont(HFONT hFont); 37 | UIFont(const UIString& szFontName, int nFontSize, int nFontStyle); 38 | ~UIFont(); 39 | void Init(); 40 | 41 | private: 42 | HFONT m_hFont; 43 | UIString m_szKey; 44 | UIString m_szName; 45 | int m_nStyle; 46 | int m_nSize; 47 | int m_nHeight; 48 | int m_nBaseline; 49 | int m_nAvgCharWidth; 50 | 51 | typedef std::map FontCache; 52 | typedef std::map StringWidthCache; 53 | static FontCache fontCache; 54 | }; 55 | 56 | #endif //! __UIFONT_H_INCLUDED__ -------------------------------------------------------------------------------- /libjpeg/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 9x or NT. */ 2 | /* This file also works for Borland C++ 32-bit (bcc32) on Windows 9x or NT. */ 3 | /* see jconfig.txt for explanations */ 4 | 5 | #define HAVE_PROTOTYPES 6 | #define HAVE_UNSIGNED_CHAR 7 | #define HAVE_UNSIGNED_SHORT 8 | /* #define void char */ 9 | /* #define const */ 10 | #undef CHAR_IS_UNSIGNED 11 | #define HAVE_STDDEF_H 12 | #define HAVE_STDLIB_H 13 | #undef NEED_BSD_STRINGS 14 | #undef NEED_SYS_TYPES_H 15 | #undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ 16 | #undef NEED_SHORT_EXTERNAL_NAMES 17 | #undef INCOMPLETE_TYPES_BROKEN 18 | 19 | /* Define "boolean" as unsigned char, not enum, per Windows custom */ 20 | #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ 21 | typedef unsigned char boolean; 22 | #endif 23 | #ifndef FALSE /* in case these macros already exist */ 24 | #define FALSE 0 /* values of boolean */ 25 | #endif 26 | #ifndef TRUE 27 | #define TRUE 1 28 | #endif 29 | #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ 30 | 31 | 32 | #ifdef JPEG_INTERNALS 33 | 34 | #undef RIGHT_SHIFT_IS_UNSIGNED 35 | 36 | #endif /* JPEG_INTERNALS */ 37 | 38 | #ifdef JPEG_CJPEG_DJPEG 39 | 40 | #define BMP_SUPPORTED /* BMP image file format */ 41 | #define GIF_SUPPORTED /* GIF image file format */ 42 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 43 | #undef RLE_SUPPORTED /* Utah RLE image file format */ 44 | #define TARGA_SUPPORTED /* Targa image file format */ 45 | 46 | #define TWO_FILE_COMMANDLINE /* optional */ 47 | #define USE_SETMODE /* Microsoft has setmode() */ 48 | #undef NEED_SIGNAL_CATCHER 49 | #undef DONT_USE_B_MODE 50 | #undef PROGRESS_REPORT /* optional */ 51 | 52 | #endif /* JPEG_CJPEG_DJPEG */ 53 | -------------------------------------------------------------------------------- /xskin/include/view/UIEditView.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIEDIT_VIEW_H_INCLUDED__ 2 | #define __UIEDIT_VIEW_H_INCLUDED__ 3 | 4 | #include "UIControl.h" 5 | #include "../core/AutoPtr.h" 6 | 7 | #define INPUT_MODE_NUMBER _T("number") 8 | #define INPUT_MODE_UPPERCASE _T("upperCase") 9 | #define INPUT_MODE_LOWERCASE _T("lowerCase") 10 | #define INPUT_MODE_PASSWORD _T("password") 11 | 12 | class UIBrush; 13 | class UIScrollBar; 14 | class XSKIN_API UIEditView : public UIControl 15 | { 16 | DECLARE_XML_NODE(UIEditView) 17 | DECLARE_XML_PROPERTY() 18 | public: 19 | UIEditView(UIView* parent = NULL); 20 | ~UIEditView(); 21 | 22 | public: 23 | void SetTransparent(BOOL b); 24 | BOOL IsTransparent() const; 25 | void SetMaxLength(int nMax); 26 | int GetMaxLength() const; 27 | void SetReadOnly(BOOL b); 28 | BOOL IsReadOnly() const; 29 | void SetMultiLine(BOOL b); 30 | BOOL IsMultiLine() const; 31 | void SetInputMode(const UIString& szInputMode); 32 | UIString GetInputMode() const; 33 | void SetPlaceholder(const UIString& szText); 34 | UIString GetPlaceholder() const; 35 | void Activate(BOOL b) OVERRIDE; 36 | BOOL IsFocusFrameVisible() const OVERRIDE; 37 | UISize GetPreferredSize() const OVERRIDE; 38 | 39 | protected: 40 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 41 | BOOL OnFocusGain(UIFocusEvent* event) OVERRIDE; 42 | BOOL OnFocusLost(UIFocusEvent* event) OVERRIDE; 43 | void OnPaint(HDC hdc) OVERRIDE; 44 | 45 | BOOL RegisterControlClass(); 46 | BOOL CreateControl(); 47 | void DestroyControl(); 48 | void UpdateControl(); 49 | LRESULT OnControlMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); 50 | static LRESULT CALLBACK ControlProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 51 | 52 | protected: 53 | HWND m_hWnd; 54 | BOOL m_bTransparent; 55 | BOOL m_bMultiline; 56 | BOOL m_bReadOnly; 57 | UIString m_szInputMode; 58 | UIString m_szPlaceholder; 59 | int m_nMaxLength; 60 | UIRect m_rcControl; 61 | WNDPROC m_pfnSuperWndProc; 62 | }; 63 | #endif //! __UIEDIT_VIEW_H_INCLUDED__ -------------------------------------------------------------------------------- /unzip/ZipFile.h: -------------------------------------------------------------------------------- 1 | #ifndef __ZIPFILE_H_INCLUDED__ 2 | #define __ZIPFILE_H_INCLUDED__ 3 | 4 | #pragma warning (disable:4244) 5 | #pragma warning (disable:4996) 6 | 7 | #include 8 | #include "../zlib/unzip.h" 9 | 10 | typedef struct ZipEntry 11 | { 12 | BOOL bDir; 13 | char szFileName[256]; 14 | char szComment[2048]; 15 | char szModifiedTime[128]; 16 | unsigned int nCompressedSize; 17 | unsigned int nUnCompressedSize; 18 | unz64_file_pos pos; 19 | } ZIPENTRY; 20 | 21 | typedef struct ZipMsg 22 | { 23 | char szFileName[256]; 24 | size_t nFileProcessedSize; 25 | size_t nFileSize; 26 | int nFileIndex; 27 | int nFileCount; 28 | } ZIPMSG; 29 | 30 | typedef void(*ZIPCALLBACK)(ZIPMSG*); 31 | 32 | class ZipFile 33 | { 34 | public: 35 | ZipFile(); 36 | ~ZipFile(); 37 | 38 | public: 39 | BOOL Open(const char* szFileName); 40 | BOOL Open(const void* buffer, unsigned long nSize); 41 | void Close(); 42 | BOOL FindFile(const char* szFileInZipName, __out ZIPENTRY* pEntry) const; 43 | BOOL ExtractFile(__in ZIPENTRY* pEntry, const char* szDir, ZIPCALLBACK callback = NULL) const; 44 | BOOL ExtractFile(__in ZIPENTRY* pEntry, void* pBuf, size_t nBufSize, ZIPCALLBACK callback = NULL) const; 45 | BOOL ExtractAllFiles(const char* szDir, ZIPCALLBACK callback = NULL) const; 46 | 47 | protected: 48 | BOOL GetCurrentFileInfo(__out ZIPENTRY* pEntry) const; 49 | BOOL FindFirstFile(__out ZIPENTRY* pEntry) const; 50 | BOOL FindNextFile(__out ZIPENTRY* pEntry) const; 51 | BOOL CreateDirectory(const char* szDirPath) const; 52 | BOOL IsFileExists(const char* szFilePath) const; 53 | void ParseFileName(char* szFileName, const char* szFilePath) const; 54 | void ProcessPathToken(char* szNewFilePath, const char* szFilePath) const; 55 | struct tm* GetSystemTime() const; 56 | 57 | private: 58 | unzFile m_unzFile; 59 | }; 60 | 61 | #endif //! __ZIPFILE_H_INCLUDED__ 62 | -------------------------------------------------------------------------------- /xskin/include/XSkin.h: -------------------------------------------------------------------------------- 1 | #ifndef __XSKIN_H_INCLUDED__ 2 | #define __XSKIN_H_INCLUDED__ 3 | 4 | #pragma warning (disable:4800) 5 | #pragma warning (disable:4996) 6 | #pragma warning (disable:4251) 7 | 8 | #include "core/UIObject.h" 9 | #include "core/UIPoint.h" 10 | #include "core/UISize.h" 11 | #include "core/UIRect.h" 12 | #include "core/UIString.h" 13 | #include "core/UIMeasure.h" 14 | #include "core/AutoPtr.h" 15 | #include "core/RefCounted.h" 16 | #include "core/UIAsset.h" 17 | #include "core/UIResponser.h" 18 | #include "core/UIApplication.h" 19 | 20 | #include "gfx/UIBitmap.h" 21 | #include "gfx/UIBrush.h" 22 | #include "gfx/UIPen.h" 23 | #include "gfx/UIFont.h" 24 | #include "gfx/UIDrawable.h" 25 | #include "gfx/UIRender.h" 26 | 27 | #include "event/UIEvent.h" 28 | #include "event/UIMouseEvent.h" 29 | #include "event/UIWheelEvent.h" 30 | #include "event/UIKeyEvent.h" 31 | #include "event/UIFocusEvent.h" 32 | #include "event/UITimerEvent.h" 33 | #include "event/UIActionEvent.h" 34 | 35 | #include "model/UIModel.h" 36 | 37 | #include "animation/UIAnimation.h" 38 | #include "animation//UIAlphaAnimation.h" 39 | #include "animation/UIBoundAnimation.h" 40 | #include "animation/UITranslateAnimation.h" 41 | #include "animation/UIScaleAnimation.h" 42 | 43 | #include "view/UIView.h" 44 | #include "view/UIRootView.h" 45 | #include "view/UIWindow.h" 46 | #include "view/UIPanel.h" 47 | #include "view/UIBoxLayout.h" 48 | #include "view/UICardLayout.h" 49 | #include "view/UIGridLayout.h" 50 | #include "view/UIControl.h" 51 | #include "view/UITabBar.h" 52 | #include "view/UIControl.h" 53 | #include "view/UIButton.h" 54 | #include "view/UIHyperlink.h" 55 | #include "view/UICheckBox.h" 56 | #include "view/UIRadioButton.h" 57 | #include "view/UIImageButton.h" 58 | #include "view/UIImageView.h" 59 | #include "view/UIListItem.h" 60 | #include "view/UIProgressBar.h" 61 | #include "view/UISlider.h" 62 | #include "view/UITextView.h" 63 | #include "view/UIScrollBar.h" 64 | #include "view/UIScrollView.h" 65 | #include "view/UIListView.h" 66 | #include "view/UIComboBox.h" 67 | #include "view/UITreeView.h" 68 | 69 | #endif //! __XSKIN_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/view/UITabBar.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UITabBar.h" 3 | #include "../../include/event/UIMouseEvent.h" 4 | #include "../../include/event/UIActionEvent.h" 5 | #include "../../include/core/UIApplication.h" 6 | 7 | IMPLEMENT_XML_NODE(UITabBar) 8 | 9 | UITabBar::UITabBar(UIView* parent) 10 | : UIBoxLayout(parent) 11 | { 12 | m_pChecked = NULL; 13 | } 14 | 15 | UITabBar::~UITabBar() 16 | { 17 | 18 | } 19 | 20 | void UITabBar::SetCheckedIndex(int nIndex) 21 | { 22 | UIView* v = GetChildView(nIndex); 23 | if(v) 24 | SetCheckedView(v); 25 | } 26 | 27 | void UITabBar::SetCheckedView(UIView* v) 28 | { 29 | if(m_pChecked == v) 30 | return; 31 | 32 | if(v && v->IsEnabled() && !v->IsChecked()) 33 | { 34 | v->SetChecked(TRUE); 35 | m_pChecked = v; 36 | 37 | int nIndex = 0; 38 | for(int x = 0; x < GetChildViewCount(); ++x) 39 | { 40 | UIView* pChild = GetChildView(x); 41 | if(pChild == v) 42 | { 43 | nIndex = x; 44 | continue; 45 | } 46 | else if(pChild->IsChecked()) 47 | { 48 | pChild->SetChecked(FALSE); 49 | } 50 | } 51 | 52 | UIActionEvent event(this, GetID(), ACTION_SELECT, nIndex); 53 | UIApplication::SendEvent(&event); 54 | } 55 | } 56 | 57 | UIView* UITabBar::GetCheckedView() const 58 | { 59 | return m_pChecked; 60 | } 61 | 62 | int UITabBar::GetCheckedIndex() const 63 | { 64 | int nCheckedIndex = 0; 65 | for(int x = 0; x < GetChildViewCount(); ++x) 66 | { 67 | if(GetChildView(x) == m_pChecked) 68 | { 69 | nCheckedIndex = x; 70 | break; 71 | } 72 | } 73 | 74 | return nCheckedIndex; 75 | } 76 | 77 | void UITabBar::OnInit() 78 | { 79 | if(!m_pChecked) 80 | { 81 | if(GetChildViewCount() > 0) 82 | SetCheckedView(GetChildView(0)); 83 | } 84 | __super::OnInit(); 85 | } 86 | 87 | BOOL UITabBar::OnActionPerformed(UIActionEvent* event) 88 | { 89 | if(event->GetSource() != this && event->GetCommand() == ACTION_CLICK) 90 | { 91 | UIView* v = static_cast(event->GetSource()); 92 | SetCheckedView(v); 93 | return FALSE; 94 | } 95 | else 96 | { 97 | return __super::OnActionPerformed(event); 98 | } 99 | } -------------------------------------------------------------------------------- /xskin_test/xskin_test.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 38 | 39 | 源文件 40 | 41 | 42 | 源文件 43 | 44 | 45 | 源文件 46 | 47 | 48 | 49 | 50 | 资源文件 51 | 52 | 53 | 54 | 55 | 资源文件 56 | 57 | 58 | 资源文件 59 | 60 | 61 | -------------------------------------------------------------------------------- /xskin/include/animation/UIAnimation.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIANIMATION_H_INCLUDED__ 2 | #define __UIANIMATION_H_INCLUDED__ 3 | 4 | #include "../core/UIObject.h" 5 | #include "../core/UIRect.h" 6 | 7 | class UIView; 8 | class XSKIN_API UIAnimation : public UIObject 9 | { 10 | public: 11 | enum TweenType 12 | { 13 | LINEAR = 0, // Linear. 14 | EASE_OUT, // Fast in, slow out (default). 15 | EASE_IN, // Slow in, fast out. 16 | EASE_IN_OUT, // Slow in and out, fast in the middle. 17 | FAST_IN_OUT, // Fast in and out, slow in the middle. 18 | EASE_OUT_SNAP, // Fast in, slow out, snap to final value. 19 | BOUNCE_EASE_OUT, // Fast in, bounce out. 20 | ELASTIC_EASE_OUT, // Fast in, shake out. 21 | ZERO, 22 | }; 23 | 24 | enum RepeatMode 25 | { 26 | RESTART = 0, 27 | REVERSE 28 | }; 29 | 30 | UIAnimation(UIView* target = NULL); 31 | ~UIAnimation(); 32 | 33 | public: 34 | void Start(); 35 | void Stop(); 36 | void Reset(); 37 | void SetTarget(UIView* pTarget); 38 | UIView* GetTarget(); 39 | void SetStartTime(DWORD dwStartTimeTick); 40 | DWORD GetStartTime() const; 41 | BOOL IsAnimating() const; 42 | void SetDuration(int nDuration); 43 | int GetDuration() const; 44 | void SetRepeatCount(int nCount); 45 | int GetRepeatCount() const; 46 | void SetRepeatMode(RepeatMode mode); 47 | RepeatMode GetRepeatMode() const; 48 | void SetTweenType(TweenType type); 49 | TweenType GetTweenType() const; 50 | int GetValueBetween(int start, int target); 51 | double GetValueBetween(double start, double target); 52 | UIRect GetValueBetween(const UIRect start, const UIRect& target); 53 | COLORREF GetValueBetween(COLORREF start, COLORREF target); 54 | virtual double GetCurrentValue(); 55 | virtual void OnAnimationStarted(); 56 | virtual void OnAnimationStepped(); 57 | virtual void OnAnimationStopped(); 58 | 59 | protected: 60 | UIView* m_pTarget; 61 | int m_nRepeatCount; 62 | int m_nRepeated; 63 | BOOL m_bAnimating; 64 | BOOL m_bStarted; 65 | BOOL m_bCycleFlip; 66 | UINT m_nDuration; 67 | UINT m_nStartTimeTick; 68 | TweenType m_tweenType; 69 | RepeatMode m_repeatMode; 70 | }; 71 | #endif //! __UIANIMATION_H_INCLUDED__ -------------------------------------------------------------------------------- /zlib/ioapi_mem.h: -------------------------------------------------------------------------------- 1 | /* ioapi_mem.c -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | This version of ioapi is designed to access memory rather than files. 5 | We do use a region of memory to put data in to and take it out of. We do 6 | not have auto-extending buffers and do not inform anyone else that the 7 | data has been written. It is really intended for accessing a zip archive 8 | embedded in an application such that I can write an installer with no 9 | external files. Creation of archives has not been attempted, although 10 | parts of the framework are present. 11 | 12 | Based on Unzip ioapi.c version 0.22, May 19th, 2003 13 | 14 | Copyright (C) 1998-2003 Gilles Vollant 15 | (C) 2003 Justin Fletcher 16 | 17 | This file is under the same license as the Unzip tool it is distributed 18 | with. 19 | */ 20 | 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "zlib.h" 27 | #include "ioapi.h" 28 | 29 | 30 | 31 | voidpf ZCALLBACK fopen_mem_func OF(( 32 | voidpf opaque, 33 | const char* filename, 34 | int mode)); 35 | 36 | uLong ZCALLBACK fread_mem_func OF(( 37 | voidpf opaque, 38 | voidpf stream, 39 | void* buf, 40 | uLong size)); 41 | 42 | uLong ZCALLBACK fwrite_mem_func OF(( 43 | voidpf opaque, 44 | voidpf stream, 45 | const void* buf, 46 | uLong size)); 47 | 48 | long ZCALLBACK ftell_mem_func OF(( 49 | voidpf opaque, 50 | voidpf stream)); 51 | 52 | long ZCALLBACK fseek_mem_func OF(( 53 | voidpf opaque, 54 | voidpf stream, 55 | uLong offset, 56 | int origin)); 57 | 58 | int ZCALLBACK fclose_mem_func OF(( 59 | voidpf opaque, 60 | voidpf stream)); 61 | 62 | int ZCALLBACK ferror_mem_func OF(( 63 | voidpf opaque, 64 | voidpf stream)); 65 | 66 | void fill_memory_filefunc64_32(pzlib_filefunc_def); 67 | 68 | 69 | typedef struct ourmemory_s { 70 | char *base; /* Base of the region of memory we're using */ 71 | uLong size; /* Size of the region of memory we're using */ 72 | uLong limit; /* Furthest we've written */ 73 | uLong cur_offset; /* Current offset in the area */ 74 | } ourmemory_t; -------------------------------------------------------------------------------- /xskin/src/gfx/UIPen.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/gfx/UIPen.h" 3 | 4 | UIPen::GdiPenCache UIPen::cache; 5 | 6 | UIPen::UIPen(HPEN hPen) 7 | { 8 | m_hPen = hPen; 9 | Init(); 10 | } 11 | 12 | UIPen::UIPen(COLORREF clr, int nWidth) 13 | { 14 | m_hPen = ::CreatePen(PS_SOLID, nWidth, clr); 15 | Init(); 16 | } 17 | 18 | UIPen::~UIPen() 19 | { 20 | GdiPenCache::iterator itor = cache.find(m_szKey); 21 | if(itor != cache.end()) 22 | cache.erase(itor); 23 | 24 | if(m_hPen) 25 | ::DeleteObject(m_hPen); 26 | } 27 | 28 | void UIPen::Init() 29 | { 30 | AddRef(); 31 | } 32 | 33 | UIPen* UIPen::GetPen(LPCTSTR szCacheKey) 34 | { 35 | GdiPenCache::const_iterator itor = cache.find(szCacheKey); 36 | if(itor != cache.end()) 37 | { 38 | itor->second->AddRef(); 39 | return itor->second; 40 | } 41 | else 42 | { 43 | return NULL; 44 | } 45 | } 46 | 47 | UIPen* UIPen::CreateNew(HPEN hPen, LPCTSTR szCacheKey) 48 | { 49 | UIPen* pPen = NULL; 50 | if(szCacheKey) 51 | { 52 | GdiPenCache::const_iterator itor = cache.find(szCacheKey); 53 | if(itor != cache.end()) 54 | { 55 | pPen = itor->second; 56 | pPen->AddRef(); 57 | } 58 | else 59 | { 60 | pPen = new UIPen(hPen); 61 | pPen->m_szKey = szCacheKey; 62 | cache.insert(std::make_pair(szCacheKey, pPen)); 63 | } 64 | } 65 | else 66 | { 67 | pPen = new UIPen(hPen); 68 | } 69 | 70 | return pPen; 71 | } 72 | 73 | UIPen* UIPen::CreateNew(COLORREF clr, int nWidth, LPCTSTR szCacheKey) 74 | { 75 | UIPen* pPen = NULL; 76 | if(szCacheKey) 77 | { 78 | GdiPenCache::const_iterator itor = cache.find(szCacheKey); 79 | if(itor != cache.end()) 80 | { 81 | pPen = itor->second; 82 | pPen->AddRef(); 83 | } 84 | else 85 | { 86 | pPen = new UIPen(clr, nWidth); 87 | pPen->m_szKey = szCacheKey; 88 | cache.insert(std::make_pair(szCacheKey, pPen)); 89 | } 90 | } 91 | else 92 | { 93 | pPen = new UIPen(clr, nWidth); 94 | } 95 | 96 | return pPen; 97 | } 98 | 99 | HPEN UIPen::GetNativePen() const 100 | { 101 | return m_hPen; 102 | } 103 | 104 | UIPen::operator HPEN() const 105 | { 106 | return m_hPen; 107 | } -------------------------------------------------------------------------------- /xskin/src/gfx/UIBrush.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/gfx/UIBrush.h" 3 | 4 | UIBrush::GdiBrushCache UIBrush::cache; 5 | 6 | UIBrush::UIBrush(HBRUSH hBrush) 7 | { 8 | m_hBrush = hBrush; 9 | Init(); 10 | } 11 | 12 | UIBrush::UIBrush(COLORREF clr) 13 | { 14 | m_hBrush = ::CreateSolidBrush(clr); 15 | Init(); 16 | } 17 | 18 | UIBrush::~UIBrush() 19 | { 20 | GdiBrushCache::iterator itor = cache.find(m_szKey); 21 | if(itor != cache.end()) 22 | cache.erase(itor); 23 | 24 | if(m_hBrush) 25 | ::DeleteObject(m_hBrush); 26 | } 27 | 28 | void UIBrush::Init() 29 | { 30 | AddRef(); 31 | } 32 | 33 | UIBrush* UIBrush::GetBrush(LPCTSTR szCacheKey) 34 | { 35 | GdiBrushCache::const_iterator itor = cache.find(szCacheKey); 36 | if(itor != cache.end()) 37 | { 38 | itor->second->AddRef(); 39 | return itor->second; 40 | } 41 | else 42 | { 43 | return NULL; 44 | } 45 | } 46 | 47 | UIBrush* UIBrush::CreateNew(HBRUSH hBrush, LPCTSTR szCacheKey) 48 | { 49 | UIBrush* pBrush = NULL; 50 | if(szCacheKey) 51 | { 52 | GdiBrushCache::const_iterator itor = cache.find(szCacheKey); 53 | if(itor != cache.end()) 54 | { 55 | pBrush = itor->second; 56 | pBrush->AddRef(); 57 | } 58 | else 59 | { 60 | pBrush = new UIBrush(hBrush); 61 | pBrush->m_szKey = szCacheKey; 62 | cache.insert(std::make_pair(szCacheKey, pBrush)); 63 | } 64 | } 65 | else 66 | { 67 | pBrush = new UIBrush(hBrush); 68 | } 69 | 70 | return pBrush; 71 | } 72 | 73 | UIBrush* UIBrush::CreateNew(COLORREF clr, LPCTSTR szCacheKey) 74 | { 75 | UIBrush* pBrush = NULL; 76 | if(szCacheKey) 77 | { 78 | GdiBrushCache::const_iterator itor = cache.find(szCacheKey); 79 | if(itor != cache.end()) 80 | { 81 | pBrush = itor->second; 82 | pBrush->AddRef(); 83 | } 84 | else 85 | { 86 | pBrush = new UIBrush(clr); 87 | pBrush->m_szKey = szCacheKey; 88 | cache.insert(std::make_pair(szCacheKey, pBrush)); 89 | } 90 | } 91 | else 92 | { 93 | pBrush = new UIBrush(clr); 94 | } 95 | 96 | return pBrush; 97 | } 98 | 99 | HBRUSH UIBrush::GetNativeBrush() const 100 | { 101 | return m_hBrush; 102 | } 103 | 104 | UIBrush::operator HBRUSH() const 105 | { 106 | return m_hBrush; 107 | } -------------------------------------------------------------------------------- /xskin/src/view/UIButton.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UIButton.h" 3 | #include "../../include/event/UIActionEvent.h" 4 | #include "../../include/gfx/UIFont.h" 5 | #include "../../include/gfx/UIRender.h" 6 | 7 | IMPLEMENT_XML_NODE(UIButton) 8 | 9 | BEGIN_XML_PROPERTY(UIButton) 10 | END_XML_PROPERTY() 11 | 12 | UIButton::UIButton(UIView* parent) 13 | : UIControl(parent) 14 | { 15 | m_alignment.cx = UIAlignment::ALIGN_HCENTER; 16 | m_alignment.cy = UIAlignment::ALIGN_VCENTER; 17 | } 18 | 19 | UIButton::~UIButton() 20 | { 21 | 22 | } 23 | 24 | void UIButton::Activate(BOOL b) 25 | { 26 | if(b) 27 | { 28 | UIActionEvent event(this, GetID(), ACTION_CLICK, 0); 29 | UIApplication::SendEvent(&event); 30 | } 31 | 32 | __super::Activate(b); 33 | } 34 | 35 | BOOL UIButton::OnMouseClicked(UIMouseEvent* event) 36 | { 37 | UIActionEvent action(this, GetID(), ACTION_CLICK, 0); 38 | UIApplication::SendEvent(&action); 39 | 40 | return __super::OnMouseClicked(event); 41 | } 42 | 43 | void UIButton::OnPaint(HDC hdc) 44 | { 45 | UIRect rcPaint(0, 0, m_rcBounds.Width(), m_rcBounds.Height()); 46 | m_bkgnd.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 47 | 48 | int bkState = GetBkState(); 49 | if(bkState == BS_NORMAL) 50 | { 51 | if(m_bChecked) 52 | m_bkChecked.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 53 | else 54 | m_bkNormal.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 55 | } 56 | else if(bkState == BS_HOT) 57 | { 58 | m_bkHot.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 59 | } 60 | else if(bkState == BS_PUSHED) 61 | { 62 | m_bkPushed.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 63 | rcPaint.OffsetRect(1, 1); 64 | } 65 | else if(bkState == BS_DISABLED) 66 | { 67 | m_bkDisabled.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 68 | } 69 | 70 | HFONT hOldFont = static_cast(::SelectObject(hdc, *m_pFont)); 71 | COLORREF clrOld = ::SetTextColor(hdc, m_bEnabled ? m_clrText : m_clrTextDisabled); 72 | rcPaint.left += m_rcPadding.left; 73 | rcPaint.right -= m_rcPadding.right; 74 | rcPaint.top += m_rcPadding.top; 75 | rcPaint.bottom -= m_rcPadding.bottom; 76 | UIRender::DrawString(hdc, rcPaint, m_szText, m_alignment); 77 | ::SetTextColor(hdc, clrOld); 78 | ::SelectObject(hdc, hOldFont); 79 | } -------------------------------------------------------------------------------- /xskin/include/view/UIRootView.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIROOT_VIEW_H_INCLUDED__ 2 | #define __UIROOT_VIEW_H_INCLUDED__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "UIView.h" 8 | 9 | class UIWindow; 10 | class XSKIN_API UIRootView : public UIView 11 | { 12 | friend class XSKIN_API UIWindow; 13 | 14 | DECLARE_XML_NODE(UIRootView) 15 | public: 16 | UIRootView(); 17 | ~UIRootView(); 18 | 19 | public: 20 | UIWindow* GetWindow() const; 21 | void SetWindow(UIWindow* pWnd); 22 | UIView* GetFocusedView() const; 23 | void SetFocusView(UIView* v); 24 | void ShowTooltip(const UIPoint& pt, const UIString& szTooltip); 25 | void HideTooltip(); 26 | UIView* FindNextFocusableView(); 27 | UIView* FindPrevFocusableView(); 28 | UINT SetTimer(UIView* pView, UINT uTimerID, int nInterval); 29 | void KillTimer(UINT_PTR uTimerID); 30 | UIRootView* GetRootView() OVERRIDE; 31 | void ScheduleAnimation(UIView* pView); 32 | 33 | void ProcessMouseDoubleClicked(const UIPoint& pt, int nFlags); 34 | void ProcessMousePressed(const UIPoint& pt, int nFlags); 35 | void ProcessMouseReleased(const UIPoint& pt, int nFlags); 36 | void ProcessMouseMoved(const UIPoint& pt, int nFlags); 37 | void ProcessMouseWheel(const UIPoint& pt, short zDelta, int nFlags); 38 | void ProcessMouseDragged(const UIPoint& pt, int nFlags); 39 | void ProcessKeyPressed(int nKeyCode, int nRepeatCnt, int nFlags); 40 | void ProcessKeyReleased(int nKeyCode, int nRepeatCnt, int nFlags); 41 | void ProcessChar(int nChar, int nRepeatCnt, int nFlags); 42 | void ProcessTimer(UINT uTimerID); 43 | void ProcessCursor(HWND hWnd, UINT nHitTest, UINT message); 44 | 45 | protected: 46 | void InitGlobalTabList(); 47 | UIResponser* GetNextResponser() const OVERRIDE; 48 | void OnLayout() OVERRIDE; 49 | void OnPaint(HDC hdc) OVERRIDE; 50 | void OnInit() OVERRIDE; 51 | BOOL OnTimer(UITimerEvent* event) OVERRIDE; 52 | 53 | private: 54 | typedef std::map ViewTimers; 55 | typedef std::set AnimationViews; 56 | UIView* m_pFocusedView; 57 | UIView* m_pMousePressedView; 58 | UIView* m_pMouseMoveView; 59 | UIView* m_pFirstTabstopView; 60 | UIWindow* m_pWindow; 61 | UINT m_nAnimationTimer; 62 | BOOL m_bAnimationSchedulable; 63 | ViewTimers m_viewTimers; 64 | AnimationViews m_animViews; 65 | }; 66 | 67 | #endif //! __UIROOT_VIEW_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/core/UIString.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISTRING_H_INCLUDED__ 2 | #define __UISTRING_H_INCLUDED__ 3 | 4 | #include 5 | #include "UIObject.h" 6 | 7 | class XSKIN_API UIString 8 | { 9 | public: 10 | enum { INIT_STRING_MAX_LEN = 64 }; 11 | 12 | UIString(); 13 | UIString(const TCHAR ch); 14 | UIString(LPCTSTR lpszString, int nLen = -1); 15 | UIString(const UIString& str); 16 | ~UIString(); 17 | 18 | public: 19 | void Empty(); 20 | int GetLength() const; 21 | BOOL IsEmpty() const; 22 | TCHAR GetAt(int nIndex) const; 23 | void SetAt(int nIndex, TCHAR ch); 24 | UIString& Append(LPCTSTR lpszString); 25 | void Assign(LPCTSTR lpszString, int nLen = -1); 26 | LPTSTR GetData() const; 27 | int Compare(LPCTSTR lpszString) const; 28 | int CompareNoCase(LPCTSTR lpszString) const; 29 | void MakeUpper(); 30 | void MakeLower(); 31 | void Trim(); 32 | void TrimLeft(); 33 | void TrimRight(); 34 | UIString Tokenize(LPCTSTR szTokens, int& nStart) const; 35 | BOOL StartWidth(const LPCTSTR str) const; 36 | BOOL EndWith(const LPCTSTR str) const; 37 | UIString Left(int nLen) const; 38 | UIString Mid(int nPos, int nLen = -1) const; 39 | UIString Right(int nLen) const; 40 | int Find(TCHAR ch, int nPos = 0) const; 41 | int Find(LPCTSTR lpszString, int nPos = 0) const; 42 | int ReverseFind(TCHAR ch) const; 43 | int Replace(LPCTSTR lpszStringFrom, LPCTSTR lpszStringTo); 44 | void Format(LPCTSTR lpszFormat, ...); 45 | 46 | operator LPCTSTR() const; 47 | TCHAR operator[](int nIndex) const; 48 | const UIString& operator=(const UIString& str); 49 | const UIString& operator=(const TCHAR ch); 50 | const UIString& operator=(LPCTSTR lpszString); 51 | const UIString& operator+=(const UIString& str); 52 | const UIString& operator+=(LPCTSTR lpszString); 53 | const UIString& operator+=(const TCHAR ch); 54 | const UIString operator+(const UIString& str) const; 55 | const UIString operator+(LPCTSTR lpszString) const; 56 | const UIString operator+(const TCHAR ch) const; 57 | BOOL operator==(LPCTSTR str) const; 58 | BOOL operator!=(LPCTSTR str) const; 59 | BOOL operator<=(LPCTSTR str) const; 60 | BOOL operator<(LPCTSTR str) const; 61 | BOOL operator>=(LPCTSTR str) const; 62 | BOOL operator>(LPCTSTR str) const; 63 | 64 | private: 65 | LPTSTR m_lpszData; 66 | }; 67 | #endif //! __UISTRING_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/include/view/UIControl.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICONTROL_H_INCLUDED__ 2 | #define __UICONTROL_H_INCLUDED__ 3 | 4 | #include "UIView.h" 5 | 6 | class XSKIN_API UIControl : public UIView 7 | { 8 | DECLARE_XML_NODE(UIControl) 9 | DECLARE_XML_PROPERTY() 10 | public: 11 | enum BackgroundState 12 | { 13 | BS_NORMAL = 0, 14 | BS_HOT, 15 | BS_PUSHED, 16 | BS_DISABLED 17 | }; 18 | UIControl(UIView* parent = NULL); 19 | ~UIControl(); 20 | 21 | public: 22 | void SetText(const UIString& szText); 23 | UIString GetText() const; 24 | void SetFont(const UIFont* pFont); 25 | const UIFont* GetFont() const; 26 | void SetTextColor(COLORREF clr); 27 | COLORREF GetTextColor() const; 28 | void SetDisabledTextColor(COLORREF clr); 29 | COLORREF GetDisabledTextColor() const; 30 | void SetTextAlign(UIAlignment::AlignFlag cx, UIAlignment::AlignFlag cy); 31 | UIAlignment GetTextAlign() const; 32 | void SetBkState(BackgroundState state); 33 | BackgroundState GetBkState() const; 34 | void SetBkNormal(const UIBitmap* pBitmap, const UIRect& rcPos); 35 | void SetBkHot(const UIBitmap* pBitmap, const UIRect& rcPos); 36 | void SetBkPushed(const UIBitmap* pBitmap, const UIRect& rcPos); 37 | void SetBkDisabled(const UIBitmap* pBitmap, const UIRect& rcPos); 38 | void SetBkChecked(const UIBitmap* pBitmap, const UIRect& rcPos); 39 | UIDrawable* GetBkNormal(); 40 | UIDrawable* GetBkHot(); 41 | UIDrawable* GetBkPushed(); 42 | UIDrawable* GetBkDisabled(); 43 | UIDrawable* GetBkChecked(); 44 | void SetEnabled(BOOL b) OVERRIDE; 45 | UISize GetPreferredSize() const OVERRIDE; 46 | 47 | protected: 48 | void OnInit() OVERRIDE; 49 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 50 | BOOL OnMouseReleased(UIMouseEvent* event) OVERRIDE; 51 | BOOL OnMouseEntered(UIMouseEvent* event) OVERRIDE; 52 | BOOL OnMouseExited(UIMouseEvent* event) OVERRIDE; 53 | BOOL OnKeyPressed(UIKeyEvent* event) OVERRIDE; 54 | BOOL OnKeyReleased(UIKeyEvent* event) OVERRIDE; 55 | 56 | protected: 57 | UIString m_szText; 58 | const UIFont* m_pFont; 59 | UIAlignment m_alignment; 60 | COLORREF m_clrText; 61 | COLORREF m_clrTextDisabled; 62 | BackgroundState m_bkState; 63 | UIDrawable m_bkNormal; 64 | UIDrawable m_bkHot; 65 | UIDrawable m_bkPushed; 66 | UIDrawable m_bkDisabled; 67 | UIDrawable m_bkChecked; 68 | }; 69 | 70 | #endif //! __UICONTROL_H_INCLUDED__ -------------------------------------------------------------------------------- /libpng/libpng.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 源文件 32 | 33 | 34 | 源文件 35 | 36 | 37 | 源文件 38 | 39 | 40 | 源文件 41 | 42 | 43 | 源文件 44 | 45 | 46 | 源文件 47 | 48 | 49 | 源文件 50 | 51 | 52 | 源文件 53 | 54 | 55 | 源文件 56 | 57 | 58 | 源文件 59 | 60 | 61 | 源文件 62 | 63 | 64 | 源文件 65 | 66 | 67 | 源文件 68 | 69 | 70 | -------------------------------------------------------------------------------- /xskin/src/view/UIListItem.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UIListItem.h" 3 | #include "../../include/gfx/UIRender.h" 4 | #include "../../include/event/UIMouseEvent.h" 5 | #include "../../include/event/UIActionEvent.h" 6 | 7 | IMPLEMENT_XML_NODE(UIListItem) 8 | 9 | BEGIN_XML_PROPERTY(UIListItem) 10 | END_XML_PROPERTY() 11 | 12 | UIListItem::UIListItem(UIView* parent) 13 | : UIButton(parent) 14 | { 15 | m_alignment.cx = UIAlignment::ALIGN_LEFT; 16 | m_alignment.cy = UIAlignment::ALIGN_VCENTER; 17 | m_szText = _T("TextItem"); 18 | } 19 | 20 | UIListItem::~UIListItem() 21 | { 22 | 23 | } 24 | 25 | void UIListItem::OnPaint(HDC hdc) 26 | { 27 | UIRect rcPaint(0, 0, m_rcBounds.Width(), m_rcBounds.Height()); 28 | m_bkgnd.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 29 | 30 | int bkState = GetBkState(); 31 | if(bkState == BS_NORMAL) 32 | { 33 | if(m_bChecked) 34 | m_bkChecked.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 35 | else 36 | m_bkNormal.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 37 | } 38 | else if(bkState == BS_HOT) 39 | { 40 | if(m_bChecked) 41 | m_bkChecked.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 42 | else 43 | m_bkHot.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 44 | } 45 | else if(bkState == BS_PUSHED) 46 | { 47 | if(m_bChecked) 48 | m_bkChecked.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 49 | else 50 | m_bkPushed.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 51 | } 52 | else if(bkState == BS_DISABLED) 53 | { 54 | m_bkDisabled.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 55 | } 56 | 57 | HFONT hOldFont = static_cast(::SelectObject(hdc, *m_pFont)); 58 | COLORREF clrOld = ::SetTextColor(hdc, m_bEnabled ? m_clrText : m_clrTextDisabled); 59 | rcPaint.left += m_rcPadding.left; 60 | rcPaint.right -= m_rcPadding.right; 61 | rcPaint.top += m_rcPadding.top; 62 | rcPaint.bottom -= m_rcPadding.bottom; 63 | UIRender::DrawString(hdc, rcPaint, m_szText, m_alignment); 64 | ::SetTextColor(hdc, clrOld); 65 | ::SelectObject(hdc, hOldFont); 66 | } 67 | 68 | BOOL UIListItem::OnMousePressed(UIMouseEvent* event) 69 | { 70 | if(event->GetFlags() & UIEvent::LEFT_BUTTON_MASK) 71 | { 72 | UIActionEvent action(this, GetID(), ACTION_CLICK, 0); 73 | UIApplication::SendEvent(&action); 74 | } 75 | 76 | return TRUE; 77 | } 78 | 79 | BOOL UIListItem::OnMouseClicked(UIMouseEvent* event) 80 | { 81 | return TRUE; 82 | } 83 | -------------------------------------------------------------------------------- /xskin/src/core/UIApplication.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | #include "../../include/core/UIApplication.h" 5 | 6 | UIApplication* UIApplication::self = NULL; 7 | 8 | UIApplication::UIApplication() 9 | { 10 | if(self == NULL) 11 | { 12 | self = this; 13 | SetLocale(LOCALE_ENGLISH); 14 | m_pAsset.Reset(new UIAsset); 15 | } 16 | } 17 | 18 | BOOL UIApplication::Event(UIEvent* event) 19 | { 20 | return FALSE; 21 | } 22 | 23 | UIApplication::~UIApplication() 24 | { 25 | 26 | } 27 | 28 | UIApplication* UIApplication::Instance() 29 | { 30 | return self; 31 | } 32 | 33 | int UIApplication::Run() const 34 | { 35 | MSG msg = { 0 }; 36 | while(::GetMessage(&msg, NULL, 0, 0)) 37 | { 38 | ::TranslateMessage(&msg); 39 | ::DispatchMessage(&msg); 40 | } 41 | return msg.wParam; 42 | } 43 | 44 | void UIApplication::Exit(int nRetuenCode) const 45 | { 46 | 47 | ::PostQuitMessage(nRetuenCode); 48 | } 49 | 50 | void UIApplication::SetLocale(Locale locale) 51 | { 52 | if(locale == LOCALE_FOLLOW_SYSTEM) 53 | { 54 | WORD wLangID = PRIMARYLANGID(::GetSystemDefaultLangID()); 55 | switch(wLangID) 56 | { 57 | case LANG_CHINESE_SIMPLIFIED: 58 | m_locale = LOCALE_SIMPLIFIED_CHINESE; 59 | break; 60 | case LANG_CHINESE_TRADITIONAL: 61 | m_locale = LOCALE_TRADITIONAL_CHINESE; 62 | default: 63 | m_locale = LOCALE_ENGLISH; 64 | } 65 | } 66 | else 67 | { 68 | m_locale = locale; 69 | } 70 | } 71 | 72 | UIApplication::Locale UIApplication::GetLocale() const 73 | { 74 | return m_locale; 75 | } 76 | 77 | HINSTANCE UIApplication::GetHandle() const 78 | { 79 | return ::GetModuleHandle(NULL); 80 | } 81 | 82 | void UIApplication::SendEvent(UIEvent* event) 83 | { 84 | UIResponser* p = event->GetSource(); 85 | BOOL bComsumed = FALSE; 86 | for(; p && !bComsumed; p = p->GetNextResponser()) 87 | { 88 | bComsumed = p->Event(event); 89 | } 90 | } 91 | 92 | int UIApplication::GetCommandCount() const 93 | { 94 | return __argc; 95 | } 96 | 97 | UIString UIApplication::GetCommandString(int nIndex) const 98 | { 99 | XASSERT(nIndex < __argc); 100 | return __targv[nIndex]; 101 | } 102 | 103 | UIString UIApplication::GetApplicationName() const 104 | { 105 | return __targv[0]; 106 | } 107 | 108 | UIAsset* UIApplication::GetAssetManager() const 109 | { 110 | return m_pAsset.Get(); 111 | } 112 | 113 | void UIApplication::SetResZip(LPCTSTR szResZipFile) 114 | { 115 | BOOL bRet = m_pAsset->Load(szResZipFile); 116 | XASSERT(bRet); 117 | } -------------------------------------------------------------------------------- /xskin/include/view/UIScrollBar.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISCROLL_BAR_H_INCLUDED__ 2 | #define __UISCROLL_BAR_H_INCLUDED__ 3 | 4 | #include "UIButton.h" 5 | #include "../gfx/UIDrawable.h" 6 | 7 | class XSKIN_API UIScrollBar : public UIView 8 | { 9 | protected: 10 | class XSKIN_API UIScrollButton : public UIControl 11 | { 12 | public: 13 | enum { AUTO_SCROLL_DELAY_MS = 500 }; 14 | 15 | UIScrollButton(UIView* parent = NULL); 16 | ~UIScrollButton(); 17 | BOOL EnsureDelay(); 18 | BOOL IsFocusable() const OVERRIDE; 19 | UISize GetPreferredSize() const OVERRIDE; 20 | 21 | protected: 22 | void OnPaint(HDC hdc) OVERRIDE; 23 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 24 | BOOL OnMouseReleased(UIMouseEvent* event) OVERRIDE; 25 | BOOL OnMouseDragged(UIMouseEvent* event) OVERRIDE; 26 | BOOL OnMouseWheel(UIWheelEvent* event) OVERRIDE; 27 | 28 | private: 29 | UINT_PTR m_nTimerID; 30 | DWORD m_nTickStart; 31 | }; 32 | 33 | DECLARE_XML_NODE(UIScrollBar) 34 | DECLARE_XML_PROPERTY() 35 | public: 36 | UIScrollBar(UIView* parent = NULL); 37 | ~UIScrollBar(); 38 | 39 | public: 40 | void Scroll(int nDistance); 41 | void SetPos(int nPos); 42 | int GetPos() const; 43 | void LineUp(); 44 | void LineDown(); 45 | void PageUp(); 46 | void PageDown(); 47 | void WheelUp(); 48 | void WheelDown(); 49 | void SetViewportSize(int nSize); 50 | int GetViewportSize() const; 51 | void SetLineSize(int nLineSize); 52 | int GetLineSize() const; 53 | void SetRange(int nMin, int nMax); 54 | UISize GetRange() const; 55 | void SetDirection(Direction orient); 56 | Direction GetDirection() const; 57 | UISize GetPreferredSize() const OVERRIDE; 58 | 59 | protected: 60 | void SetTrackPos(const UIRect& rcTrack); 61 | void UpdateTrackPos(); 62 | int Clamp(int x, int a, int b); 63 | void OnLayout() OVERRIDE; 64 | void OnPaint(HDC hdc) OVERRIDE; 65 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 66 | BOOL OnMouseReleased(UIMouseEvent* event) OVERRIDE; 67 | BOOL OnMouseWheel(UIWheelEvent* event) OVERRIDE; 68 | BOOL OnMouseDragged(UIMouseEvent* event) OVERRIDE; 69 | BOOL OnTimer(UITimerEvent* event) OVERRIDE; 70 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 71 | 72 | protected: 73 | Direction m_direction; 74 | UIScrollButton* m_pLineUp; 75 | UIScrollButton* m_pLineDown; 76 | UIScrollButton* m_pTrack; 77 | UIPoint m_ptLast; 78 | int m_nViewportSize; 79 | int m_nLineSize; 80 | int m_nMin; 81 | int m_nMax; 82 | int m_nPos; 83 | int m_nMinTrackSize; 84 | }; 85 | #endif //! __UISCROLL_BAR_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/gfx/UIBitmap.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/gfx/UIBitmap.h" 3 | 4 | UIBitmap::BitmapCache UIBitmap::cache; 5 | 6 | 7 | UIBitmap::UIBitmap(HBITMAP hBitmap) 8 | { 9 | m_hBitmap = hBitmap; 10 | Init(); 11 | } 12 | 13 | UIBitmap::UIBitmap(int w, int h, int nBitCount, LPCVOID lpvBits) 14 | { 15 | m_hBitmap = ::CreateBitmap(w, h, 1, nBitCount, lpvBits); 16 | Init(); 17 | } 18 | 19 | UIBitmap::~UIBitmap() 20 | { 21 | BitmapCache::iterator itor = cache.find(m_szKey); 22 | if(itor != cache.end()) 23 | cache.erase(itor); 24 | 25 | if(m_hBitmap) 26 | ::DeleteObject(m_hBitmap); 27 | } 28 | 29 | UIBitmap* UIBitmap::GetBitmap(LPCTSTR szCacheKey) 30 | { 31 | BitmapCache::const_iterator itor = cache.find(szCacheKey); 32 | if(itor != cache.end()) 33 | { 34 | itor->second->AddRef(); 35 | return itor->second; 36 | } 37 | else 38 | { 39 | return NULL; 40 | } 41 | } 42 | 43 | void UIBitmap::Init() 44 | { 45 | BITMAP bm; 46 | GetObject(m_hBitmap, sizeof(BITMAP), &bm); 47 | m_nWidth = bm.bmWidth; 48 | m_nHeight = bm.bmHeight; 49 | m_bAlphaChannel = (bm.bmBitsPixel == 32) ? TRUE : FALSE; 50 | AddRef(); 51 | } 52 | 53 | UIBitmap* UIBitmap::CreateNew(HBITMAP hBitmap, LPCTSTR szCacheKey) 54 | { 55 | UIBitmap* pBitmap = NULL; 56 | if(szCacheKey) 57 | { 58 | BitmapCache::const_iterator itor = cache.find(szCacheKey); 59 | if(itor != cache.end()) 60 | { 61 | pBitmap = itor->second; 62 | pBitmap->AddRef(); 63 | } 64 | else 65 | { 66 | pBitmap = new UIBitmap(hBitmap); 67 | pBitmap->m_szKey = szCacheKey; 68 | cache.insert(std::make_pair(szCacheKey, pBitmap)); 69 | } 70 | } 71 | else 72 | { 73 | pBitmap = new UIBitmap(hBitmap); 74 | } 75 | return pBitmap; 76 | } 77 | 78 | UIBitmap* UIBitmap::CreateNew(int w, int h, int nBitCount, LPCVOID lpvBits, LPCTSTR szCacheKey) 79 | { 80 | UIBitmap* pBitmap = NULL; 81 | if(szCacheKey) 82 | { 83 | BitmapCache::const_iterator itor = cache.find(szCacheKey); 84 | if(itor != cache.end()) 85 | { 86 | pBitmap = itor->second; 87 | pBitmap->AddRef(); 88 | } 89 | else 90 | { 91 | pBitmap = new UIBitmap(w, h, nBitCount, lpvBits); 92 | cache.insert(std::make_pair(szCacheKey, pBitmap)); 93 | } 94 | } 95 | else 96 | { 97 | pBitmap = new UIBitmap(w, h, nBitCount, lpvBits); 98 | } 99 | return pBitmap; 100 | } 101 | 102 | BOOL UIBitmap::HasAlpha() const 103 | { 104 | return m_bAlphaChannel; 105 | } 106 | 107 | int UIBitmap::GetWidth() const 108 | { 109 | return m_nWidth; 110 | } 111 | 112 | int UIBitmap::GetHeight() const 113 | { 114 | return m_nHeight; 115 | } 116 | 117 | HBITMAP UIBitmap::GetNativeBitmap() const 118 | { 119 | return m_hBitmap; 120 | } 121 | 122 | UIBitmap::operator HBITMAP() const 123 | { 124 | return m_hBitmap; 125 | } -------------------------------------------------------------------------------- /xskin/include/view/UITreeView.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITREE_VIEW_H_INCLUDED__ 2 | #define __UITREE_VIEW_H_INCLUDED__ 3 | 4 | #include "UIListView.h" 5 | #include "UIControl.h" 6 | 7 | class XSKIN_API UITreeItem : public UIControl 8 | { 9 | DECLARE_XML_NODE(UITreeItem) 10 | DECLARE_XML_PROPERTY() 11 | public: 12 | enum 13 | { BITMAP_TEXT_SPACING = 2, 14 | DEFAULT_SUBITEM_INDENT_DISTANCE = 10 15 | }; 16 | UITreeItem(UIView* parent = NULL); 17 | ~UITreeItem(); 18 | 19 | public: 20 | void SetIcon(const UIBitmap* pBitmap, const UIRect& rcPos); 21 | void SetExpandedIcon(const UIBitmap* pBitmap, const UIRect& rcPos); 22 | void SetCollapsedIcon(const UIBitmap* pBitmap, const UIRect& rcPos); 23 | void SetExpanded(BOOL b); 24 | BOOL IsExpaned() const; 25 | BOOL IsExpandable() const; 26 | void SetSubItemLoaded(BOOL b); 27 | BOOL IsSubItemLoaded() const; 28 | int GetDepth() const; 29 | int GetIndent() const; 30 | void AddSubItem(UITreeItem* v); 31 | int GetSubItemCount() const; 32 | UITreeItem* GetSubItem(int nIndex); 33 | void SetParentItem(UITreeItem* v); 34 | UITreeItem* GetParentItem() const; 35 | UISize GetPreferredSize() const OVERRIDE; 36 | 37 | protected: 38 | void OnInit() OVERRIDE; 39 | void OnPaint(HDC hdc) OVERRIDE; 40 | BOOL OnMousePressed(UIMouseEvent* event) OVERRIDE; 41 | BOOL OnMouseClicked(UIMouseEvent* event) OVERRIDE; 42 | 43 | private: 44 | UIDrawable m_foldIcon; 45 | UIDrawable m_unfoldIcon; 46 | UIDrawable m_minusIcon; 47 | UIDrawable m_plusIcon; 48 | UITreeItem* m_pParentItem; 49 | ViewList m_subitems; 50 | BOOL m_bExpanded; 51 | BOOL m_bSubItemsLoaded; 52 | int m_nDepth; 53 | }; 54 | 55 | class XSKIN_API UITabBar; 56 | class XSKIN_API UITreeView : public UIScrollView 57 | { 58 | DECLARE_XML_NODE(UITreeView) 59 | DECLARE_XML_PROPERTY() 60 | public: 61 | UITreeView(UIView* parent = NULL); 62 | ~UITreeView(); 63 | 64 | public: 65 | void AddItem(UITreeItem* v); 66 | void InsertItem(UITreeItem* v, int nIndex); 67 | void RemoveItem(UITreeItem* v); 68 | void RemoveItem(int nIndex); 69 | UITreeItem* GetItem(int nIndex); 70 | void SetCheckedItem(UITreeItem* v); 71 | UITreeItem* GetCheckedItem() const; 72 | void SetCheckedIndex(int nIndex); 73 | int GetCheckedIndex() const; 74 | void ExpandItem(UITreeItem* pItem, BOOL bExpandAll); 75 | void CollapseItem(UITreeItem* pItem, BOOL bCollapseAll); 76 | BOOL IsFocusFrameVisible() const OVERRIDE; 77 | 78 | protected: 79 | void Expand(UITreeItem* pItem, BOOL bExpandAll = FALSE); 80 | void Collapse(UITreeItem* pItem, BOOL bCollapseAll = FALSE); 81 | void LoadSubItems(int nItemIndex); 82 | void ProcessContent() OVERRIDE; 83 | void OnInit() OVERRIDE; 84 | BOOL OnActionPerformed(UIActionEvent* event) OVERRIDE; 85 | 86 | private: 87 | UITabBar* m_pTab; 88 | }; 89 | #endif //! __UITREE_VIEW_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/animation/UIScaleAnimation.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/animation/UIScaleAnimation.h" 3 | #include "../../include/view/UIView.h" 4 | 5 | UIScaleAnimation::UIScaleAnimation(UIView* pTarget, 6 | double fromXScale, double toXScale, double fromYScale, double toYScale) 7 | : UIAnimation(pTarget) 8 | { 9 | m_rcBound.SetRectEmpty(); 10 | m_anchor = ANCHOR_CENTER; 11 | m_dFromXScale = fromXScale; 12 | m_dFromYScale = fromYScale; 13 | m_dToXScale = toXScale; 14 | m_dToYScale = toYScale; 15 | } 16 | 17 | UIScaleAnimation::~UIScaleAnimation() 18 | { 19 | 20 | } 21 | 22 | void UIScaleAnimation::SetStartValue(double fromXScale, int fromYScale) 23 | { 24 | m_dFromXScale = fromXScale; 25 | m_dFromYScale = fromYScale; 26 | } 27 | 28 | void UIScaleAnimation::SetEndValue(double toXScale, double toYScale) 29 | { 30 | m_dToXScale = toXScale; 31 | m_dToYScale = toYScale; 32 | } 33 | 34 | void UIScaleAnimation::SetScaleAnchor(ScaleAnchor anchor) 35 | { 36 | m_anchor = anchor; 37 | } 38 | 39 | void UIScaleAnimation::OnAnimationStarted() 40 | { 41 | m_rcBound = m_pTarget->GetBounds(); 42 | } 43 | 44 | void UIScaleAnimation::OnAnimationStepped() 45 | { 46 | __super::OnAnimationStepped(); 47 | 48 | double xScale = GetValueBetween(m_dFromXScale, m_dToXScale); 49 | double yScale = GetValueBetween(m_dFromYScale, m_dToYScale); 50 | int width = static_cast(m_rcBound.Width() * xScale); 51 | int height = static_cast(m_rcBound.Height() * yScale); 52 | m_pTarget->Invalidate(); 53 | 54 | UIRect rcBound; 55 | if(m_anchor == ScaleAnchor::ANCHOR_CENTER) 56 | { 57 | rcBound.left = m_rcBound.left + (m_rcBound.Width() - width) / 2; 58 | rcBound.right = rcBound.left + width; 59 | rcBound.top = m_rcBound.top + (m_rcBound.Height() - height) / 2; 60 | rcBound.bottom = rcBound.top + height; 61 | } 62 | else if(m_anchor == ScaleAnchor::ANCHOR_TOPLEFT) 63 | { 64 | rcBound.left = m_rcBound.left; 65 | rcBound.right = rcBound.left + width; 66 | rcBound.top = m_rcBound.top; 67 | rcBound.bottom = rcBound.top + height; 68 | } 69 | else if(m_anchor == ScaleAnchor::ANCHOR_TOPRIGHT) 70 | { 71 | rcBound.right = m_rcBound.right; 72 | rcBound.left = rcBound.right - width; 73 | rcBound.top = m_rcBound.top; 74 | rcBound.bottom = rcBound.top + height; 75 | } 76 | else if(m_anchor == ScaleAnchor::ANCHOR_BOTTOM_LEFT) 77 | { 78 | rcBound.left = m_rcBound.left; 79 | rcBound.right = rcBound.left + width; 80 | rcBound.bottom = m_rcBound.bottom; 81 | rcBound.top = rcBound.bottom - height; 82 | } 83 | else if(m_anchor == ScaleAnchor::ANCHOR_BOTTOM_RIGHT) 84 | { 85 | rcBound.right = m_rcBound.right; 86 | rcBound.left = rcBound.right - width; 87 | rcBound.bottom = m_rcBound.bottom; 88 | rcBound.top = rcBound.bottom - height; 89 | } 90 | 91 | m_pTarget->SetBounds(rcBound); 92 | m_pTarget->Invalidate(); 93 | } 94 | 95 | void UIScaleAnimation::OnAnimationStopped() 96 | { 97 | 98 | } -------------------------------------------------------------------------------- /unzip/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ZipFile.h" 5 | 6 | using namespace std; 7 | 8 | 9 | // zip file callback. 10 | void OnZipCallback(ZIPMSG* pMsg) 11 | { 12 | printf("%d/%d, %s --- %ld/%ld\n", 13 | pMsg->nFileIndex, pMsg->nFileCount, pMsg->szFileName, pMsg->nFileProcessedSize, pMsg->nFileSize); 14 | } 15 | 16 | int main(int argc, char *argv[]) 17 | { 18 | char* buf = NULL; 19 | size_t nBufSize = 0; 20 | // test unzip ///////////////////////////////////////////////////////////// 21 | ZipFile zf; 22 | if(zf.Open("/home/finch/Desktop/test_zip_add.zip", ZipFile::UNZIP)) 23 | { 24 | ZIPENTRY zi; 25 | if(zf.FindFile("dir1/dir2/dir3/file.iso", &zi)) 26 | { 27 | // test unzip to buffer. 28 | buf = new char[zi.nUnCompressedSize]; 29 | nBufSize = zi.nUnCompressedSize; 30 | memset(buf, 0, sizeof(zi.nUnCompressedSize)); 31 | if(zf.ExtractFile(&zi, buf, zi.nUnCompressedSize, OnZipCallback)) 32 | { 33 | printf("extract to buffer success.\n\n\n"); 34 | } 35 | else 36 | { 37 | printf("fail to extract to buffer.\n\n\n"); 38 | } 39 | 40 | // test unzip to file. 41 | if(zf.ExtractFile(&zi, "/home/finch/Desktop", OnZipCallback)) 42 | { 43 | printf("extract to file success.\n\n\n"); 44 | } 45 | else 46 | { 47 | printf("fail to extract to file.\n\n\n"); 48 | } 49 | } 50 | else 51 | { 52 | printf("fail to find file.\n\n\n"); 53 | } 54 | 55 | // test unzip all files. 56 | if(zf.ExtractAllFiles("/home/finch/Desktop", OnZipCallback)) 57 | { 58 | printf("extract all files success.\n\n\n"); 59 | } 60 | else 61 | { 62 | printf("fail to extract all files.\n\n\n"); 63 | } 64 | zf.Close(); 65 | } 66 | else 67 | { 68 | printf("fail to open zip file.\n\n\n"); 69 | } 70 | 71 | // test zip ///////////////////////////////////////////////////////////// 72 | ZipFile zf2; 73 | if(zf2.Open("/home/finch/Desktop/test_zip_add.zip", ZipFile::ZIP)) 74 | { 75 | if(zf2.AddFile("dir1/dir2/dir3/file.iso", "VCP600ENU1.iso", OnZipCallback)) 76 | { 77 | printf("zip add file success.\n\n\n"); 78 | } 79 | else 80 | { 81 | printf("fail to add file into zip.\n\n\n"); 82 | } 83 | if(zf2.AddFile("file_buf.iso", buf, nBufSize, OnZipCallback)) 84 | { 85 | printf("zip add file from buffer success.\n\n\n"); 86 | } 87 | else 88 | { 89 | printf("fail to add file from buffer into zip.\n\n\n"); 90 | } 91 | zf2.Close(); 92 | } 93 | else 94 | { 95 | printf("fail to create zip file.\n\n\n"); 96 | } 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /zlib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | const uInt max = (uInt)-1; 32 | uLong left; 33 | 34 | left = *destLen; 35 | *destLen = 0; 36 | 37 | stream.zalloc = (alloc_func)0; 38 | stream.zfree = (free_func)0; 39 | stream.opaque = (voidpf)0; 40 | 41 | err = deflateInit(&stream, level); 42 | if (err != Z_OK) return err; 43 | 44 | stream.next_out = dest; 45 | stream.avail_out = 0; 46 | stream.next_in = (z_const Bytef *)source; 47 | stream.avail_in = 0; 48 | 49 | do { 50 | if (stream.avail_out == 0) { 51 | stream.avail_out = left > (uLong)max ? max : (uInt)left; 52 | left -= stream.avail_out; 53 | } 54 | if (stream.avail_in == 0) { 55 | stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; 56 | sourceLen -= stream.avail_in; 57 | } 58 | err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); 59 | } while (err == Z_OK); 60 | 61 | *destLen = stream.total_out; 62 | deflateEnd(&stream); 63 | return err == Z_STREAM_END ? Z_OK : err; 64 | } 65 | 66 | /* =========================================================================== 67 | */ 68 | int ZEXPORT compress (dest, destLen, source, sourceLen) 69 | Bytef *dest; 70 | uLongf *destLen; 71 | const Bytef *source; 72 | uLong sourceLen; 73 | { 74 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 75 | } 76 | 77 | /* =========================================================================== 78 | If the default memLevel or windowBits for deflateInit() is changed, then 79 | this function needs to be updated. 80 | */ 81 | uLong ZEXPORT compressBound (sourceLen) 82 | uLong sourceLen; 83 | { 84 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 85 | (sourceLen >> 25) + 13; 86 | } 87 | -------------------------------------------------------------------------------- /zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /xskin/include/core/UIAsset.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIASSET_H_INCLUDED__ 2 | #define __UIASSET_H_INCLUDED__ 3 | 4 | #include 5 | #include "UIObject.h" 6 | #include "../core/AutoPtr.h" 7 | #include "../core/UIString.h" 8 | #include "../gfx/UIFont.h" 9 | 10 | namespace tinyxml2 { class XMLDocument; }; 11 | class UIPen; 12 | class UIBrush; 13 | class UIBitmap; 14 | class ZipFile; 15 | class XSKIN_API UIAsset : public UIObject 16 | { 17 | public: 18 | enum CursorType 19 | { 20 | CURSOR_ARROW = 0, 21 | CURSOR_HAND, 22 | CURSOR_CROSS, 23 | CURSOR_IBEAM, 24 | CURSOR_WAIT 25 | }; 26 | UIAsset(); 27 | ~UIAsset(); 28 | 29 | public: 30 | BOOL Load(LPCTSTR szResZipFile); 31 | BOOL GetRaw(const UIString& szRawFileName, LPVOID* lppBuffer, int* pSize); 32 | const tinyxml2::XMLDocument* GetLayout(const UIString& szXmlFileName); 33 | const tinyxml2::XMLDocument* GetSkin(const UIString& szXmlFileName); 34 | const UIBitmap* GetImage(const UIString& szImageFileName); 35 | const UIString GetString(const UIString& szID); 36 | 37 | const UIBitmap* GetRGBImage(COLORREF clr, BOOL bTrans = FALSE, int alpha = 255) const; 38 | const UIFont* GetGuiFont() const; 39 | const UIFont* GetFont(const UIString& szFontName, int nFontSize, int nFontStyle) const; 40 | const UIPen* GetPen(COLORREF clr, int nWidth = 1) const; 41 | const UIBrush* GetBrush(COLORREF clr) const; 42 | HCURSOR GetCursor(CursorType type) const; 43 | 44 | static UIString UTF8ToString(LPCSTR str); 45 | static LPCWSTR ANSIToUCS(LPCSTR ansi); 46 | static LPCSTR ANSIToUTF8(LPCSTR ansi); 47 | static LPCSTR UCSToANSI(LPCWSTR ucs); 48 | static LPCSTR UCSToUTF8(LPCWSTR ucs); 49 | static LPCSTR UTF8ToANSI(LPCSTR utf8); 50 | static LPCWSTR UTF8ToUCS(LPCSTR utf8); 51 | static LPCSTR StringToUTF8(LPCTSTR str); 52 | 53 | protected: 54 | HBITMAP LoadPNG(const void* buffer, int size) const; 55 | HBITMAP LoadBMP(const void* buffer, int size) const; 56 | HBITMAP LoadJPG(const void* buffer, int size) const; 57 | const UIBitmap* LoadImageFromZip(const UIString& szImageFileName); 58 | const UIBitmap* LoadImageFromDisk(const UIString& szImageFileName); 59 | BOOL LoadRawFromZip(const UIString& szRawFileName, LPVOID* lppBuffer, int* pSize); 60 | BOOL LoadRawFromDisk(const UIString& szRawFileName, LPVOID* lppBuffer, int* pSize); 61 | const tinyxml2::XMLDocument* LoadLayoutFromZip(const UIString& szXmlFileName); 62 | const tinyxml2::XMLDocument* LoadLayoutFromDisk(const UIString& szXmlFileName); 63 | const tinyxml2::XMLDocument* LoadSkinFromZip(const UIString& szXmlFileName); 64 | const tinyxml2::XMLDocument* LoadSkinFromDisk(const UIString& szXmlFileName); 65 | void XMLError(const char* szXmlFileName, const tinyxml2::XMLDocument* pDoc) const; 66 | 67 | private: 68 | BOOL m_bLoad; 69 | AutoPtr m_pResZip; 70 | typedef std::map LayoutCache; 71 | typedef std::map SkinCache; 72 | typedef std::map StringCache; 73 | LayoutCache m_cacheLayout; 74 | SkinCache m_cachedSkin; 75 | StringCache m_cacheString; 76 | }; 77 | 78 | #endif //! __UIASSET_H_INCLUDED__ -------------------------------------------------------------------------------- /libjpeg/jcinit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jcinit.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * Modified 2003-2013 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains initialization logic for the JPEG compressor. 10 | * This routine is in charge of selecting the modules to be executed and 11 | * making an initialization call to each one. 12 | * 13 | * Logically, this code belongs in jcmaster.c. It's split out because 14 | * linking this routine implies linking the entire compression library. 15 | * For a transcoding-only application, we want to be able to use jcmaster.c 16 | * without linking in the whole library. 17 | */ 18 | 19 | #define JPEG_INTERNALS 20 | #include "jinclude.h" 21 | #include "jpeglib.h" 22 | 23 | 24 | /* 25 | * Master selection of compression modules. 26 | * This is done once at the start of processing an image. We determine 27 | * which modules will be used and give them appropriate initialization calls. 28 | */ 29 | 30 | GLOBAL(void) 31 | jinit_compress_master (j_compress_ptr cinfo) 32 | { 33 | long samplesperrow; 34 | JDIMENSION jd_samplesperrow; 35 | 36 | /* For now, precision must match compiled-in value... */ 37 | if (cinfo->data_precision != BITS_IN_JSAMPLE) 38 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); 39 | 40 | /* Sanity check on image dimensions */ 41 | if (cinfo->image_height <= 0 || cinfo->image_width <= 0 || 42 | cinfo->input_components <= 0) 43 | ERREXIT(cinfo, JERR_EMPTY_IMAGE); 44 | 45 | /* Width of an input scanline must be representable as JDIMENSION. */ 46 | samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; 47 | jd_samplesperrow = (JDIMENSION) samplesperrow; 48 | if ((long) jd_samplesperrow != samplesperrow) 49 | ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); 50 | 51 | /* Initialize master control (includes parameter checking/processing) */ 52 | jinit_c_master_control(cinfo, FALSE /* full compression */); 53 | 54 | /* Preprocessing */ 55 | if (! cinfo->raw_data_in) { 56 | jinit_color_converter(cinfo); 57 | jinit_downsampler(cinfo); 58 | jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); 59 | } 60 | /* Forward DCT */ 61 | jinit_forward_dct(cinfo); 62 | /* Entropy encoding: either Huffman or arithmetic coding. */ 63 | if (cinfo->arith_code) 64 | jinit_arith_encoder(cinfo); 65 | else { 66 | jinit_huff_encoder(cinfo); 67 | } 68 | 69 | /* Need a full-image coefficient buffer in any multi-pass mode. */ 70 | jinit_c_coef_controller(cinfo, 71 | (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); 72 | jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); 73 | 74 | jinit_marker_writer(cinfo); 75 | 76 | /* We can now tell the memory manager to allocate virtual arrays. */ 77 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); 78 | 79 | /* Write the datastream header (SOI) immediately. 80 | * Frame and scan headers are postponed till later. 81 | * This lets application insert special markers after the SOI. 82 | */ 83 | (*cinfo->marker->write_file_header) (cinfo); 84 | } 85 | -------------------------------------------------------------------------------- /libjpeg/jmemnobs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jmemnobs.c 3 | * 4 | * Copyright (C) 1992-1996, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file provides a really simple implementation of the system- 9 | * dependent portion of the JPEG memory manager. This implementation 10 | * assumes that no backing-store files are needed: all required space 11 | * can be obtained from malloc(). 12 | * This is very portable in the sense that it'll compile on almost anything, 13 | * but you'd better have lots of main memory (or virtual memory) if you want 14 | * to process big images. 15 | * Note that the max_memory_to_use option is ignored by this implementation. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | #include "jmemsys.h" /* import the system-dependent declarations */ 22 | 23 | #ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ 24 | extern void * malloc JPP((size_t size)); 25 | extern void free JPP((void *ptr)); 26 | #endif 27 | 28 | 29 | /* 30 | * Memory allocation and freeing are controlled by the regular library 31 | * routines malloc() and free(). 32 | */ 33 | 34 | GLOBAL(void *) 35 | jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) 36 | { 37 | return (void *) malloc(sizeofobject); 38 | } 39 | 40 | GLOBAL(void) 41 | jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) 42 | { 43 | free(object); 44 | } 45 | 46 | 47 | /* 48 | * "Large" objects are treated the same as "small" ones. 49 | * NB: although we include FAR keywords in the routine declarations, 50 | * this file won't actually work in 80x86 small/medium model; at least, 51 | * you probably won't be able to process useful-size images in only 64KB. 52 | */ 53 | 54 | GLOBAL(void FAR *) 55 | jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) 56 | { 57 | return (void FAR *) malloc(sizeofobject); 58 | } 59 | 60 | GLOBAL(void) 61 | jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) 62 | { 63 | free(object); 64 | } 65 | 66 | 67 | /* 68 | * This routine computes the total memory space available for allocation. 69 | * Here we always say, "we got all you want bud!" 70 | */ 71 | 72 | GLOBAL(long) 73 | jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, 74 | long max_bytes_needed, long already_allocated) 75 | { 76 | return max_bytes_needed; 77 | } 78 | 79 | 80 | /* 81 | * Backing store (temporary file) management. 82 | * Since jpeg_mem_available always promised the moon, 83 | * this should never be called and we can just error out. 84 | */ 85 | 86 | GLOBAL(void) 87 | jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, 88 | long total_bytes_needed) 89 | { 90 | ERREXIT(cinfo, JERR_NO_BACKING_STORE); 91 | } 92 | 93 | 94 | /* 95 | * These routines take care of any system-dependent initialization and 96 | * cleanup required. Here, there isn't any. 97 | */ 98 | 99 | GLOBAL(long) 100 | jpeg_mem_init (j_common_ptr cinfo) 101 | { 102 | return 0; /* just set max_memory_to_use to 0 */ 103 | } 104 | 105 | GLOBAL(void) 106 | jpeg_mem_term (j_common_ptr cinfo) 107 | { 108 | /* no work */ 109 | } 110 | -------------------------------------------------------------------------------- /zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. *sourceLen is 13 | the byte length of the source buffer. Upon entry, *destLen is the total size 14 | of the destination buffer, which must be large enough to hold the entire 15 | uncompressed data. (The size of the uncompressed data must have been saved 16 | previously by the compressor and transmitted to the decompressor by some 17 | mechanism outside the scope of this compression library.) Upon exit, 18 | *destLen is the size of the decompressed data and *sourceLen is the number 19 | of source bytes consumed. Upon return, source + *sourceLen points to the 20 | first unused input byte. 21 | 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough 23 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, or 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is 25 | an incomplete zlib stream. 26 | */ 27 | int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) 28 | Bytef *dest; 29 | uLongf *destLen; 30 | const Bytef *source; 31 | uLong *sourceLen; 32 | { 33 | z_stream stream; 34 | int err; 35 | const uInt max = (uInt)-1; 36 | uLong len, left; 37 | Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ 38 | 39 | len = *sourceLen; 40 | if (*destLen) { 41 | left = *destLen; 42 | *destLen = 0; 43 | } 44 | else { 45 | left = 1; 46 | dest = buf; 47 | } 48 | 49 | stream.next_in = (z_const Bytef *)source; 50 | stream.avail_in = 0; 51 | stream.zalloc = (alloc_func)0; 52 | stream.zfree = (free_func)0; 53 | stream.opaque = (voidpf)0; 54 | 55 | err = inflateInit(&stream); 56 | if (err != Z_OK) return err; 57 | 58 | stream.next_out = dest; 59 | stream.avail_out = 0; 60 | 61 | do { 62 | if (stream.avail_out == 0) { 63 | stream.avail_out = left > (uLong)max ? max : (uInt)left; 64 | left -= stream.avail_out; 65 | } 66 | if (stream.avail_in == 0) { 67 | stream.avail_in = len > (uLong)max ? max : (uInt)len; 68 | len -= stream.avail_in; 69 | } 70 | err = inflate(&stream, Z_NO_FLUSH); 71 | } while (err == Z_OK); 72 | 73 | *sourceLen -= len + stream.avail_in; 74 | if (dest != buf) 75 | *destLen = stream.total_out; 76 | else if (stream.total_out && err == Z_BUF_ERROR) 77 | left = 1; 78 | 79 | inflateEnd(&stream); 80 | return err == Z_STREAM_END ? Z_OK : 81 | err == Z_NEED_DICT ? Z_DATA_ERROR : 82 | err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : 83 | err; 84 | } 85 | 86 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 87 | Bytef *dest; 88 | uLongf *destLen; 89 | const Bytef *source; 90 | uLong sourceLen; 91 | { 92 | return uncompress2(dest, destLen, source, &sourceLen); 93 | } 94 | -------------------------------------------------------------------------------- /xskin/src/gfx/UIRender.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/gfx/UIRender.h" 3 | 4 | UIRender::UIRender() 5 | { 6 | 7 | } 8 | 9 | UIRender::~UIRender() 10 | { 11 | 12 | } 13 | 14 | void UIRender::DrawLine(HDC hdc, const UIPoint& p1, const UIPoint& p2) 15 | { 16 | ::MoveToEx(hdc, p1.x, p1.y, NULL); 17 | ::LineTo(hdc, p2.x, p2.y); 18 | } 19 | 20 | void UIRender::DrawString(HDC hdc, const UIRect& rc, const UIString& szText, const UIAlignment& align, BOOL bMultiline) 21 | { 22 | int nFlags = DT_END_ELLIPSIS; 23 | 24 | if(bMultiline) 25 | nFlags |= (DT_WORDBREAK | DT_EDITCONTROL); 26 | else 27 | nFlags |= DT_SINGLELINE; 28 | 29 | if(align.cx == UIAlignment::ALIGN_LEFT) 30 | nFlags |= DT_LEFT; 31 | else if(align.cx == UIAlignment::ALIGN_HCENTER) 32 | nFlags |= DT_CENTER; 33 | else 34 | nFlags |= DT_RIGHT; 35 | 36 | if(align.cy == UIAlignment::ALIGN_TOP) 37 | nFlags |= DT_TOP; 38 | else if(align.cy == UIAlignment::ALIGN_VCENTER) 39 | nFlags |= DT_VCENTER; 40 | else 41 | nFlags |= DT_BOTTOM; 42 | 43 | int nOldMode = ::SetBkMode(hdc, TRANSPARENT); 44 | UIRect rcTemp = rc; 45 | 46 | DrawText(hdc, szText, -1, rcTemp, nFlags); 47 | ::SetBkMode(hdc, nOldMode); 48 | } 49 | 50 | void UIRender::MeasureString(HDC hdc, UIRect& rcOut, const UIString& szText, const UIAlignment& align, BOOL bMultiline) 51 | { 52 | int nFlags = DT_CALCRECT; 53 | 54 | if(bMultiline) 55 | nFlags |= (DT_WORDBREAK | DT_EDITCONTROL); 56 | else 57 | nFlags |= DT_SINGLELINE; 58 | 59 | if(align.cx == UIAlignment::ALIGN_LEFT) 60 | nFlags |= DT_LEFT; 61 | else if(align.cx == UIAlignment::ALIGN_HCENTER) 62 | nFlags |= DT_CENTER; 63 | else 64 | nFlags |= DT_RIGHT; 65 | 66 | if(align.cy == UIAlignment::ALIGN_TOP) 67 | nFlags |= DT_TOP; 68 | else if(align.cy == UIAlignment::ALIGN_VCENTER) 69 | nFlags |= DT_VCENTER; 70 | else 71 | nFlags |= DT_BOTTOM; 72 | 73 | ::DrawText(hdc, szText, -1, rcOut, nFlags); 74 | } 75 | 76 | void UIRender::DrawRect(HDC hdc, const UIRect& rc, const UIBrush& hbr) 77 | { 78 | ::FrameRect(hdc, rc, hbr); 79 | } 80 | 81 | void UIRender::DrawFocusRect(HDC hdc, const UIRect& rc) 82 | { 83 | ::DrawFocusRect(hdc, rc); 84 | } 85 | 86 | void UIRender::FillRect(HDC hdc, const UIRect& rc, const UIBrush& hbr) 87 | { 88 | ::FillRect(hdc, rc, hbr); 89 | } 90 | 91 | void UIRender::DrawBitmap(HDC hdc, const UIRect& dst, const UIRect& src, const UIBitmap* pBitmap, int nOpacity) 92 | { 93 | HDC hMemDC = ::CreateCompatibleDC(NULL); 94 | ::SelectObject(hMemDC, *pBitmap); 95 | if(pBitmap->HasAlpha()) 96 | { 97 | BLENDFUNCTION bf; 98 | bf.BlendOp = AC_SRC_OVER; 99 | bf.BlendFlags = 0; 100 | bf.AlphaFormat = AC_SRC_ALPHA; 101 | bf.SourceConstantAlpha = nOpacity; 102 | ::AlphaBlend(hdc, dst.left, dst.top, dst.Width(), dst.Height(), hMemDC, src.left, src.top, src.Width(), src.Height(), bf); 103 | } 104 | else 105 | { 106 | ::SetStretchBltMode(hdc, COLORONCOLOR); 107 | ::StretchBlt(hdc, dst.left, dst.top, dst.Width(), dst.Height(), hMemDC, src.left, src.top, src.Width(), src.Height(), SRCCOPY); 108 | } 109 | ::DeleteDC(hMemDC); 110 | } 111 | 112 | void UIRender::DrawBitmap(HDC hdc, const UIRect& dst, const UIBitmap* pBitmap, int nOpacity) 113 | { 114 | UIRect rcBmp(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); 115 | DrawBitmap(hdc, dst, rcBmp, pBitmap, nOpacity); 116 | } -------------------------------------------------------------------------------- /xskin/include/core/UIRect.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIRECT_H_INCLUDED__ 2 | #define __UIRECT_H_INCLUDED__ 3 | 4 | #include 5 | 6 | class XSKIN_API UIRect : public tagRECT 7 | { 8 | public: 9 | inline UIRect() 10 | { 11 | left = top = right = bottom = 0; 12 | } 13 | 14 | inline UIRect(const RECT& src) 15 | { 16 | left = src.left; 17 | top = src.top; 18 | right = src.right; 19 | bottom = src.bottom; 20 | } 21 | 22 | inline UIRect(int l, int t, int r, int b) 23 | { 24 | left = l; 25 | top = t; 26 | right = r; 27 | bottom = b; 28 | } 29 | inline UIRect(POINT point, SIZE size) 30 | { 31 | right = (left = point.x) + size.cx; 32 | bottom = (top = point.y) + size.cy; 33 | } 34 | 35 | inline ~UIRect() 36 | { 37 | 38 | } 39 | 40 | public: 41 | inline int Width() const 42 | { 43 | return right - left; 44 | } 45 | 46 | inline int Height() const 47 | { 48 | return bottom - top; 49 | } 50 | 51 | inline void SetWidth(int cx) 52 | { 53 | right = left + cx; 54 | } 55 | 56 | inline void SetHeight(int cy) 57 | { 58 | bottom = top + cy; 59 | } 60 | 61 | inline void SetSize(SIZE sz) 62 | { 63 | right = left + sz.cx; 64 | bottom = top + sz.cy; 65 | } 66 | 67 | inline SIZE GetSize() const 68 | { 69 | SIZE size; 70 | size.cx = right - left; 71 | size.cy = bottom - left; 72 | 73 | return size; 74 | } 75 | 76 | inline void SetPos(int x, int y) 77 | { 78 | int nWidth = right - left; 79 | int nHeight = bottom - top; 80 | left = x; 81 | top = y; 82 | right = left + nWidth; 83 | bottom = top + nHeight; 84 | } 85 | 86 | inline POINT GetPos() const 87 | { 88 | POINT pt; 89 | pt.x = left; 90 | pt.y = top; 91 | 92 | return pt; 93 | } 94 | 95 | inline void SetRect(int l, int t, int r, int b) 96 | { 97 | left = l; top = t; right = r; bottom = b; 98 | } 99 | 100 | inline void SetRectEmpty() 101 | { 102 | left = top = right = bottom = 0; 103 | } 104 | 105 | inline BOOL IsRectEmpty() const 106 | { 107 | return ::IsRectEmpty(this); 108 | } 109 | 110 | inline BOOL IntersectRect(LPCRECT rc1, LPCRECT rc2) 111 | { 112 | return ::IntersectRect(this, rc1, rc2); 113 | } 114 | 115 | inline BOOL UnionRect(LPCRECT rc1, LPCRECT rc2) 116 | { 117 | return ::UnionRect(this, rc1, rc2); 118 | } 119 | 120 | inline void NormalizeRect() 121 | { 122 | int nTemp; 123 | if(left > right) 124 | { 125 | nTemp = left; 126 | left = right; 127 | right = nTemp; 128 | } 129 | if(top > bottom) 130 | { 131 | nTemp = top; 132 | top = bottom; 133 | bottom = nTemp; 134 | } 135 | } 136 | 137 | inline void OffsetRect(int cx, int cy) 138 | { 139 | ::OffsetRect(this, cx, cy); 140 | } 141 | 142 | inline void InflateRect(int cx, int cy) 143 | { 144 | ::InflateRect(this, cx, cy); 145 | } 146 | 147 | inline void DeflateRect(int cx, int cy) 148 | { 149 | ::InflateRect(this, -cx, -cy); 150 | } 151 | 152 | inline BOOL PtInRect(const POINT& point) const 153 | { 154 | return ::PtInRect(this, point); 155 | } 156 | 157 | inline operator LPRECT() 158 | { 159 | return this; 160 | } 161 | 162 | inline operator LPCRECT() const 163 | { 164 | return this; 165 | } 166 | 167 | inline BOOL operator ==(const UIRect& rhs) const 168 | { 169 | return left == rhs.left && top == rhs.top && 170 | right == rhs.right && bottom == rhs.bottom; 171 | } 172 | }; 173 | #endif //! __UIRECT_H_INCLUDED__ -------------------------------------------------------------------------------- /libjpeg/jinclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jinclude.h 3 | * 4 | * Copyright (C) 1991-1994, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file exists to provide a single place to fix any problems with 9 | * including the wrong system include files. (Common problems are taken 10 | * care of by the standard jconfig symbols, but on really weird systems 11 | * you may have to edit this file.) 12 | * 13 | * NOTE: this file is NOT intended to be included by applications using the 14 | * JPEG library. Most applications need only include jpeglib.h. 15 | */ 16 | 17 | 18 | /* Include auto-config file to find out which system include files we need. */ 19 | 20 | #include "jconfig.h" /* auto configuration options */ 21 | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ 22 | 23 | /* 24 | * We need the NULL macro and size_t typedef. 25 | * On an ANSI-conforming system it is sufficient to include . 26 | * Otherwise, we get them from or ; we may have to 27 | * pull in as well. 28 | * Note that the core JPEG library does not require ; 29 | * only the default error handler and data source/destination modules do. 30 | * But we must pull it in because of the references to FILE in jpeglib.h. 31 | * You can remove those references if you want to compile without . 32 | */ 33 | 34 | #ifdef HAVE_STDDEF_H 35 | #include 36 | #endif 37 | 38 | #ifdef HAVE_STDLIB_H 39 | #include 40 | #endif 41 | 42 | #ifdef NEED_SYS_TYPES_H 43 | #include 44 | #endif 45 | 46 | #include 47 | 48 | /* 49 | * We need memory copying and zeroing functions, plus strncpy(). 50 | * ANSI and System V implementations declare these in . 51 | * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). 52 | * Some systems may declare memset and memcpy in . 53 | * 54 | * NOTE: we assume the size parameters to these functions are of type size_t. 55 | * Change the casts in these macros if not! 56 | */ 57 | 58 | #ifdef NEED_BSD_STRINGS 59 | 60 | #include 61 | #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) 62 | #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) 63 | 64 | #else /* not BSD, assume ANSI/SysV string lib */ 65 | 66 | #include 67 | #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) 68 | #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 69 | 70 | #endif 71 | 72 | /* 73 | * In ANSI C, and indeed any rational implementation, size_t is also the 74 | * type returned by sizeof(). However, it seems there are some irrational 75 | * implementations out there, in which sizeof() returns an int even though 76 | * size_t is defined as long or unsigned long. To ensure consistent results 77 | * we always use this SIZEOF() macro in place of using sizeof() directly. 78 | */ 79 | 80 | #define SIZEOF(object) ((size_t) sizeof(object)) 81 | 82 | /* 83 | * The modules that use fread() and fwrite() always invoke them through 84 | * these macros. On some systems you may need to twiddle the argument casts. 85 | * CAUTION: argument order is different from underlying functions! 86 | */ 87 | 88 | #define JFREAD(file,buf,sizeofbuf) \ 89 | ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 90 | #define JFWRITE(file,buf,sizeofbuf) \ 91 | ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 92 | -------------------------------------------------------------------------------- /libjpeg/jcomapi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jcomapi.c 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains application interface routines that are used for both 9 | * compression and decompression. 10 | */ 11 | 12 | #define JPEG_INTERNALS 13 | #include "jinclude.h" 14 | #include "jpeglib.h" 15 | 16 | 17 | /* 18 | * Abort processing of a JPEG compression or decompression operation, 19 | * but don't destroy the object itself. 20 | * 21 | * For this, we merely clean up all the nonpermanent memory pools. 22 | * Note that temp files (virtual arrays) are not allowed to belong to 23 | * the permanent pool, so we will be able to close all temp files here. 24 | * Closing a data source or destination, if necessary, is the application's 25 | * responsibility. 26 | */ 27 | 28 | GLOBAL(void) 29 | jpeg_abort (j_common_ptr cinfo) 30 | { 31 | int pool; 32 | 33 | /* Do nothing if called on a not-initialized or destroyed JPEG object. */ 34 | if (cinfo->mem == NULL) 35 | return; 36 | 37 | /* Releasing pools in reverse order might help avoid fragmentation 38 | * with some (brain-damaged) malloc libraries. 39 | */ 40 | for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { 41 | (*cinfo->mem->free_pool) (cinfo, pool); 42 | } 43 | 44 | /* Reset overall state for possible reuse of object */ 45 | if (cinfo->is_decompressor) { 46 | cinfo->global_state = DSTATE_START; 47 | /* Try to keep application from accessing now-deleted marker list. 48 | * A bit kludgy to do it here, but this is the most central place. 49 | */ 50 | ((j_decompress_ptr) cinfo)->marker_list = NULL; 51 | } else { 52 | cinfo->global_state = CSTATE_START; 53 | } 54 | } 55 | 56 | 57 | /* 58 | * Destruction of a JPEG object. 59 | * 60 | * Everything gets deallocated except the master jpeg_compress_struct itself 61 | * and the error manager struct. Both of these are supplied by the application 62 | * and must be freed, if necessary, by the application. (Often they are on 63 | * the stack and so don't need to be freed anyway.) 64 | * Closing a data source or destination, if necessary, is the application's 65 | * responsibility. 66 | */ 67 | 68 | GLOBAL(void) 69 | jpeg_destroy (j_common_ptr cinfo) 70 | { 71 | /* We need only tell the memory manager to release everything. */ 72 | /* NB: mem pointer is NULL if memory mgr failed to initialize. */ 73 | if (cinfo->mem != NULL) 74 | (*cinfo->mem->self_destruct) (cinfo); 75 | cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ 76 | cinfo->global_state = 0; /* mark it destroyed */ 77 | } 78 | 79 | 80 | /* 81 | * Convenience routines for allocating quantization and Huffman tables. 82 | * (Would jutils.c be a more reasonable place to put these?) 83 | */ 84 | 85 | GLOBAL(JQUANT_TBL *) 86 | jpeg_alloc_quant_table (j_common_ptr cinfo) 87 | { 88 | JQUANT_TBL *tbl; 89 | 90 | tbl = (JQUANT_TBL *) 91 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); 92 | tbl->sent_table = FALSE; /* make sure this is false in any new table */ 93 | return tbl; 94 | } 95 | 96 | 97 | GLOBAL(JHUFF_TBL *) 98 | jpeg_alloc_huff_table (j_common_ptr cinfo) 99 | { 100 | JHUFF_TBL *tbl; 101 | 102 | tbl = (JHUFF_TBL *) 103 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); 104 | tbl->sent_table = FALSE; /* make sure this is false in any new table */ 105 | return tbl; 106 | } 107 | -------------------------------------------------------------------------------- /xskin/include/core/AutoPtr.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCOPED_PTR_H_INCLUDED__ 2 | #define __SCOPED_PTR_H_INCLUDED__ 3 | 4 | #include 5 | #include 6 | 7 | template 8 | class XSKIN_API AutoPtr 9 | { 10 | public: 11 | explicit AutoPtr(_Ty* p = NULL) : ptr_(p) {} 12 | 13 | ~AutoPtr() 14 | { 15 | enum { type_must_be_complete = sizeof(_Ty) }; 16 | delete ptr_; 17 | } 18 | 19 | void Reset(_Ty* p = NULL) 20 | { 21 | if(p != ptr_) 22 | { 23 | enum { type_must_be_complete = sizeof(_Ty) }; 24 | delete ptr_; 25 | ptr_ = p; 26 | } 27 | } 28 | 29 | _Ty& operator*() const 30 | { 31 | assert(ptr_ != NULL); 32 | return *ptr_; 33 | } 34 | 35 | _Ty* operator->() const 36 | { 37 | assert(ptr_ != NULL); 38 | return ptr_; 39 | } 40 | 41 | _Ty* Get() const { return ptr_; } 42 | 43 | bool operator==(_Ty* p) const { return ptr_ == p; } 44 | 45 | bool operator!=(_Ty* p) const { return ptr_ != p; } 46 | 47 | void Swap(AutoPtr& p2) 48 | { 49 | _Ty* tmp = ptr_; 50 | ptr_ = p2.ptr_; 51 | p2.ptr_ = tmp; 52 | } 53 | 54 | _Ty* Release() 55 | { 56 | _Ty* retVal = ptr_; 57 | ptr_ = NULL; 58 | return retVal; 59 | } 60 | 61 | private: 62 | _Ty* ptr_; 63 | 64 | template bool operator==(AutoPtr const& p2) const; 65 | 66 | template bool operator!=(AutoPtr const& p2) const; 67 | 68 | AutoPtr(const AutoPtr&); 69 | 70 | void operator=(const AutoPtr&); 71 | }; 72 | 73 | template 74 | void Swap(AutoPtr<_Ty>& p1, AutoPtr<_Ty>& p2) 75 | { 76 | p1.Swap(p2); 77 | } 78 | 79 | template 80 | bool operator==(_Ty* p1, const AutoPtr<_Ty>& p2) 81 | { 82 | return p1 == p2.Get(); 83 | } 84 | 85 | template 86 | bool operator!=(_Ty* p1, const AutoPtr<_Ty>& p2) 87 | { 88 | return p1 != p2.Get(); 89 | } 90 | 91 | 92 | template 93 | class XSKIN_API AutoPtrArray 94 | { 95 | public: 96 | typedef _Ty element_type; 97 | 98 | explicit AutoPtrArray(_Ty* p = NULL) : array_(p) { } 99 | 100 | ~AutoPtrArray() 101 | { 102 | enum { type_must_be_complete = sizeof(_Ty) }; 103 | delete[] array_; 104 | } 105 | 106 | void Reset(_Ty* p = NULL) 107 | { 108 | if(p != array_) 109 | { 110 | enum { type_must_be_complete = sizeof(_Ty) }; 111 | delete[] array_; 112 | array_ = p; 113 | } 114 | } 115 | 116 | _Ty& operator[](std::ptrdiff_t i) const 117 | { 118 | assert(i >= 0); 119 | assert(array_ != NULL); 120 | return array_[i]; 121 | } 122 | 123 | _Ty* Get() const 124 | { 125 | return array_; 126 | } 127 | 128 | bool operator==(_Ty* p) const { return array_ == p; } 129 | 130 | bool operator!=(_Ty* p) const { return array_ != p; } 131 | 132 | void Swap(AutoPtrArray& p2) 133 | { 134 | _Ty* tmp = array_; 135 | array_ = p2.array_; 136 | p2.array_ = tmp; 137 | } 138 | 139 | _Ty* Release() 140 | { 141 | _Ty* retVal = array_; 142 | array_ = NULL; 143 | return retVal; 144 | } 145 | 146 | private: 147 | _Ty* array_; 148 | 149 | template bool operator==(AutoPtrArray const& p2) const; 150 | 151 | template bool operator!=(AutoPtrArray const& p2) const; 152 | 153 | AutoPtrArray(const AutoPtrArray&); 154 | void operator=(const AutoPtrArray&); 155 | }; 156 | 157 | template 158 | void Swap(AutoPtrArray<_Ty>& p1, AutoPtrArray<_Ty>& p2) 159 | { 160 | p1.Swap(p2); 161 | } 162 | 163 | template 164 | bool operator==(_Ty* p1, const AutoPtrArray<_Ty>& p2) 165 | { 166 | return p1 == p2.Get(); 167 | } 168 | 169 | template 170 | bool operator!=(_Ty* p1, const AutoPtrArray<_Ty>& p2) 171 | { 172 | return p1 != p2.Get(); 173 | } 174 | 175 | #endif //! __SCOPED_PTR_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/view/UIProgressBar.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UIProgressBar.h" 3 | #include "../../include/gfx/UIRender.h" 4 | #include "../../include/event/UIActionEvent.h" 5 | 6 | IMPLEMENT_XML_NODE(UIProgressBar) 7 | 8 | BEGIN_XML_PROPERTY(UIProgressBar) 9 | SET_DIRECTION(direction, m_direction) 10 | SET_DRAWABLE(bkFragmentImage, m_bkFragment) 11 | SET_INT(value, m_nValue) 12 | SET_INT(min, m_szRange.cx) 13 | SET_INT(max, m_szRange.cy) 14 | SET_BOOL(textVisible, m_bTextVisible) 15 | END_XML_PROPERTY() 16 | 17 | UIProgressBar::UIProgressBar(UIView* parent) 18 | : UIControl(parent) 19 | { 20 | m_direction = HORIZONTAL; 21 | m_bFocusable = FALSE; 22 | m_bTextVisible = FALSE; 23 | m_nValue = 0; 24 | m_szRange.cx = 0; 25 | m_szRange.cy = 100; 26 | m_alignment.cx = UIAlignment::ALIGN_HCENTER; 27 | m_alignment.cy = UIAlignment::ALIGN_VCENTER; 28 | } 29 | 30 | UIProgressBar::~UIProgressBar() 31 | { 32 | 33 | } 34 | 35 | void UIProgressBar::SetDirection(Direction dir) 36 | { 37 | m_direction = dir; 38 | } 39 | 40 | Direction UIProgressBar::GetDirection() const 41 | { 42 | return m_direction; 43 | } 44 | 45 | void UIProgressBar::SetTextVisible(BOOL b) 46 | { 47 | if(m_bTextVisible == b) 48 | return; 49 | 50 | m_bTextVisible = b; 51 | Invalidate(); 52 | } 53 | 54 | void UIProgressBar::SetValue(int nValue) 55 | { 56 | if(nValue == m_nValue) 57 | return; 58 | 59 | Invalidate(); 60 | m_nValue = Clamp(nValue, m_szRange.cx, m_szRange.cy); 61 | Invalidate(); 62 | 63 | UIActionEvent event(this, GetID(), ACTION_VALUE_CHANGED, m_nValue); 64 | UIApplication::SendEvent(&event); 65 | } 66 | 67 | int UIProgressBar::GetValue() const 68 | { 69 | return m_nValue; 70 | } 71 | 72 | void UIProgressBar::SetRange(int nMin, int nMax) 73 | { 74 | m_szRange.cx = nMin; 75 | m_szRange.cy = nMax; 76 | } 77 | 78 | UISize UIProgressBar::GetRange() const 79 | { 80 | return m_szRange; 81 | } 82 | 83 | UISize UIProgressBar::GetPreferredSize() const 84 | { 85 | UIRect bound; 86 | UIRect temp; 87 | if(m_bkgnd.IsValid()) 88 | { 89 | temp.SetRect(0, 0, m_bkgnd.Width(), m_bkgnd.Height()); 90 | bound.UnionRect(bound, temp); 91 | } 92 | if(m_bkFragment.IsValid()) 93 | { 94 | temp.SetRect(0, 0, m_bkFragment.Width(), m_bkFragment.Height()); 95 | bound.UnionRect(bound, temp); 96 | } 97 | 98 | return UISize(bound.Width(), bound.Height()); 99 | } 100 | 101 | int UIProgressBar::Clamp(int x, int a, int b) 102 | { 103 | if(x < a) 104 | x = a; 105 | else if(x > b) 106 | x = b; 107 | 108 | return x; 109 | } 110 | 111 | void UIProgressBar::OnPaint(HDC hdc) 112 | { 113 | UIDrawable::FillMode fm = (m_direction == HORIZONTAL) ? UIDrawable::FILL_REPEAT_X : UIDrawable::FILL_REPEAT_Y; 114 | UIRect rcPaint(0, 0, m_rcBounds.Width(), m_rcBounds.Height()); 115 | m_bkgnd.Draw(hdc, rcPaint, fm, m_nOpacity); 116 | 117 | UIRect rcFragment; 118 | if(m_direction == HORIZONTAL) 119 | { 120 | rcFragment.left = 0; 121 | rcFragment.top = 0; 122 | rcFragment.right = static_cast(static_cast(m_nValue - m_szRange.cx) / (m_szRange.cy - m_szRange.cx) * m_rcBounds.Width()); 123 | rcFragment.bottom = rcPaint.bottom; 124 | } 125 | else 126 | { 127 | rcFragment.left = 0; 128 | rcFragment.right = rcPaint.right; 129 | rcFragment.top = rcPaint.bottom 130 | - static_cast(static_cast(m_nValue - m_szRange.cx) / (m_szRange.cy - m_szRange.cx) * m_rcBounds.Height());; 131 | rcFragment.bottom = rcPaint.bottom; 132 | } 133 | 134 | m_bkFragment.Draw(hdc, rcFragment, fm, m_nOpacity); 135 | 136 | if(m_bTextVisible) 137 | { 138 | m_szText.Format(_T("%d%%"), m_nValue); 139 | HFONT hOldFont = static_cast(::SelectObject(hdc, *m_pFont)); 140 | COLORREF clrOld = ::SetTextColor(hdc, m_clrText); 141 | UIRender::DrawString(hdc, rcPaint, m_szText, m_alignment); 142 | ::SetTextColor(hdc, clrOld); 143 | ::SelectObject(hdc, hOldFont); 144 | } 145 | } -------------------------------------------------------------------------------- /xskin/src/view/UITextView.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UITextView.h" 3 | #include "../../include/view/UIScrollBar.h" 4 | #include "../../include/gfx/UIRender.h" 5 | #include "../../include/event/UIActionEvent.h" 6 | #include "../../include/event/UIWheelEvent.h" 7 | 8 | IMPLEMENT_XML_NODE(UITextView) 9 | 10 | BEGIN_XML_PROPERTY(UITextView) 11 | SET_BOOL(multiline, m_bMultiline) 12 | SET_SKIN(vscroll:skin, m_pVScrollbar) 13 | END_XML_PROPERTY() 14 | 15 | UITextView::UITextView(UIView* parent) 16 | : UIControl(parent) 17 | { 18 | m_nScroll = 0; 19 | m_bMultiline = FALSE; 20 | m_alignment.cx = UIAlignment::ALIGN_LEFT; 21 | m_alignment.cy = UIAlignment::ALIGN_VCENTER; 22 | m_pVScrollbar = new UIScrollBar(this); 23 | m_pVScrollbar->SetSizePolicy(UISizePolicy::PREFERRED, UISizePolicy::EXPANDING); 24 | m_pVScrollbar->SetDirection(Direction::VERTICAL); 25 | m_pVScrollbar->SetRange(0, 10000); 26 | m_pVScrollbar->SetVisible(FALSE); 27 | } 28 | 29 | UITextView::~UITextView() 30 | { 31 | 32 | } 33 | 34 | UISize UITextView::GetPreferredSize() const 35 | { 36 | UISize size; 37 | size.cx = m_pFont->GetStringWidth(m_szText); 38 | size.cy = m_pFont->GetHeight(); 39 | 40 | if(m_bkgnd.IsValid()) 41 | { 42 | size.cx = max(size.cx, m_bkgnd.Width()); 43 | size.cy = max(size.cy, m_bkgnd.Height()); 44 | } 45 | 46 | size.cx += m_rcPadding.left + m_rcPadding.right; 47 | size.cy += m_rcPadding.top + m_rcPadding.bottom; 48 | 49 | return size; 50 | } 51 | 52 | void UITextView::OnLayout() 53 | { 54 | if(!m_bMultiline) 55 | { 56 | m_pVScrollbar->SetVisible(FALSE); 57 | } 58 | else 59 | { 60 | m_pVScrollbar->SetVisible(TRUE); 61 | UISize szPref = m_pVScrollbar->GetPreferredSize(); 62 | UIRect rect; 63 | rect.right = m_rcBounds.Width(); 64 | rect.left = rect.right - szPref.cx; 65 | rect.top = 0; 66 | rect.bottom = m_rcBounds.Height(); 67 | m_pVScrollbar->SetBounds(rect); 68 | } 69 | 70 | __super::OnLayout(); 71 | } 72 | 73 | void UITextView::OnPaint(HDC hdc) 74 | { 75 | UIRect rcPaint(0, 0, m_rcBounds.Width(), m_rcBounds.Height()); 76 | m_bkgnd.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH, m_nOpacity); 77 | 78 | HFONT hOldFont = static_cast(::SelectObject(hdc, *m_pFont)); 79 | COLORREF clrOld = ::SetTextColor(hdc, m_clrText); 80 | rcPaint.left += m_rcPadding.left; 81 | rcPaint.right -= m_rcPadding.right; 82 | rcPaint.top += m_rcPadding.top; 83 | rcPaint.bottom -= m_rcPadding.bottom; 84 | 85 | if(m_bMultiline) 86 | { 87 | UISize szPref = m_pVScrollbar->GetSize(); 88 | rcPaint.right -= szPref.cx; 89 | UIRender::MeasureString(hdc, rcPaint, m_szText, m_alignment, m_bMultiline); 90 | m_pVScrollbar->SetViewportSize(rcPaint.Height()); 91 | if(rcPaint.Height() <= m_rcBounds.Height()) 92 | { 93 | m_pVScrollbar->SetVisible(FALSE); 94 | rcPaint.right += szPref.cx; 95 | } 96 | else 97 | { 98 | m_pVScrollbar->SetVisible(TRUE); 99 | } 100 | } 101 | 102 | rcPaint.OffsetRect(0, -m_nScroll); 103 | 104 | UIRender::DrawString(hdc, rcPaint, m_szText, m_alignment, m_bMultiline); 105 | ::SetTextColor(hdc, clrOld); 106 | ::SelectObject(hdc, hOldFont); 107 | } 108 | 109 | BOOL UITextView::OnMouseWheel(UIWheelEvent* event) 110 | { 111 | if(m_pVScrollbar->IsVisible()) 112 | { 113 | if(event->GetDelta() < 0) 114 | m_pVScrollbar->WheelDown(); 115 | else 116 | m_pVScrollbar->WheelUp(); 117 | } 118 | 119 | return TRUE; 120 | } 121 | 122 | BOOL UITextView::OnActionPerformed(UIActionEvent* event) 123 | { 124 | if(event->GetCommand() == ACTION_VSCROLL) 125 | { 126 | UISize szRange = m_pVScrollbar->GetRange(); 127 | int nPos = event->GetFlags(); 128 | double ratio = static_cast((nPos - szRange.cx)) / (szRange.cy - szRange.cx); 129 | m_nScroll = static_cast((m_pVScrollbar->GetViewportSize() - m_rcBounds.Height()) * ratio); 130 | SetViewportOrg(0, -m_nScroll); 131 | } 132 | 133 | return TRUE; 134 | } -------------------------------------------------------------------------------- /xskin/src/view/UICardLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/view/UICardLayout.h" 3 | 4 | IMPLEMENT_XML_NODE(UICardLayout) 5 | 6 | BEGIN_XML_PROPERTY(UICardLayout) 7 | END_XML_PROPERTY() 8 | 9 | UICardLayout::UICardLayout(UIView* parent) 10 | : UIView(parent) 11 | { 12 | m_nShownIndex = -1; 13 | } 14 | 15 | UICardLayout::~UICardLayout() 16 | { 17 | 18 | } 19 | 20 | void UICardLayout::First() 21 | { 22 | Show(0); 23 | } 24 | 25 | void UICardLayout::Last() 26 | { 27 | Show(GetChildViewCount() - 1); 28 | } 29 | 30 | void UICardLayout::Previous() 31 | { 32 | if(m_nShownIndex > 0) 33 | Show(m_nShownIndex - 1); 34 | } 35 | 36 | void UICardLayout::Next() 37 | { 38 | if(m_nShownIndex < GetChildViewCount() - 1) 39 | Show(m_nShownIndex + 1); 40 | } 41 | 42 | void UICardLayout::Show(int nIndex) 43 | { 44 | if(nIndex >= 0 && nIndex < GetChildViewCount()) 45 | { 46 | UIView* v = GetChildView(nIndex); 47 | if(v) 48 | { 49 | m_nShownIndex = nIndex; 50 | ShowExclusive(v); 51 | } 52 | } 53 | } 54 | 55 | void UICardLayout::Show(const UIString& szViewID) 56 | { 57 | bool b = m_childViews.empty(); 58 | for(int x = 0; x < GetChildViewCount(); ++x) 59 | { 60 | UIView* v = GetChildView(x); 61 | if(v->GetID() == szViewID) 62 | { 63 | Show(x); 64 | break; 65 | } 66 | } 67 | 68 | int x = 1; 69 | } 70 | 71 | void UICardLayout::ShowExclusive(UIView* v) 72 | { 73 | if(v) 74 | { 75 | v->SetVisible(TRUE); 76 | for(int x = 0; x < GetChildViewCount(); ++x) 77 | { 78 | UIView* pChild = GetChildView(x); 79 | if(pChild != v) 80 | pChild->SetVisible(FALSE); 81 | } 82 | } 83 | } 84 | 85 | UISize UICardLayout::GetPreferredSize() const 86 | { 87 | UISize szView = GetSize(); 88 | UIRect bound; 89 | UIRect rcTemp; 90 | for(int x = 0; x < GetChildViewCount(); ++x) 91 | { 92 | UISize size; 93 | UIView* v = GetChildView(x); 94 | UIRect rcMargin = v->GetMargin(); 95 | UISize szFixed = v->GetSize(); 96 | UISizePolicy sp = v->GetSizePolicy(); 97 | 98 | UISize szPref; 99 | if(sp.cx == UISizePolicy::PREFERRED || sp.cy == UISizePolicy::PREFERRED) 100 | szPref = v->GetPreferredSize(); 101 | 102 | if(sp.cx == UISizePolicy::PREFERRED) 103 | size.cx = szPref.cx; 104 | else if(sp.cx == UISizePolicy::EXPANDING) 105 | size.cx = szPref.cx; 106 | else 107 | size.cx = szFixed.cx; 108 | 109 | if(sp.cy == UISizePolicy::PREFERRED) 110 | size.cy = szPref.cy; 111 | else if(sp.cy == UISizePolicy::EXPANDING) 112 | size.cy = szPref.cy; 113 | else 114 | size.cy = szFixed.cy; 115 | 116 | rcTemp.SetRect(0, 0, rcMargin.left + size.cx + rcMargin.right, rcMargin.top + size.cy + rcMargin.bottom); 117 | bound.UnionRect(bound, rcTemp); 118 | } 119 | 120 | return UISize(bound.Width(), bound.Height()); 121 | } 122 | 123 | void UICardLayout::OnInit() 124 | { 125 | if(m_nShownIndex == -1) 126 | Show(0); 127 | 128 | __super::OnInit(); 129 | } 130 | 131 | void UICardLayout::OnLayout() 132 | { 133 | UISize szParent = GetSize(); 134 | UISize size; 135 | for(int x = 0; x < GetChildViewCount(); ++x) 136 | { 137 | UIView* v = GetChildView(x); 138 | UISizePolicy sp = v->GetSizePolicy(); 139 | UISize szPref = v->GetPreferredSize(); 140 | UISize szFixed = v->GetSize(); 141 | UIRect rcMargin = v->GetMargin(); 142 | 143 | if(sp.cx == UISizePolicy::PREFERRED) 144 | size.cx = szPref.cx; 145 | else if(sp.cx == UISizePolicy::EXPANDING) 146 | size.cx = szParent.cx - rcMargin.left - rcMargin.right; 147 | else 148 | size.cx = szFixed.cx; 149 | 150 | if(sp.cy == UISizePolicy::PREFERRED) 151 | size.cy = szPref.cy; 152 | else if(sp.cy == UISizePolicy::EXPANDING) 153 | size.cy = szParent.cy - rcMargin.top - rcMargin.bottom; 154 | else 155 | size.cy = szFixed.cy; 156 | 157 | v->SetBounds(rcMargin.left, rcMargin.top, rcMargin.left + size.cx, rcMargin.top + size.cy); 158 | } 159 | 160 | __super::OnLayout(); 161 | } 162 | 163 | void UICardLayout::OnPaint(HDC hdc) 164 | { 165 | UIRect rcPaint(0, 0, m_rcBounds.Width(), m_rcBounds.Height()); 166 | m_bkgnd.Draw(hdc, rcPaint, UIDrawable::FILL_REPEAT_BOTH); 167 | } -------------------------------------------------------------------------------- /xskin_test/res/layout/mainwindow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 18 | 19 | 36 | 37 | 54 | 55 | 71 | 72 | 88 | 89 | 105 | 106 | 122 | 123 | 139 | 140 | 141 | 142 | 149 | 157 | 158 | 169 | 170 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /tinyxml2/tinyxml2.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {B66613C9-21F0-4ACC-B49F-F418C6D87F93} 15 | Win32Proj 16 | tinyxml2 17 | 18 | 19 | 20 | StaticLibrary 21 | true 22 | v120 23 | Unicode 24 | 25 | 26 | StaticLibrary 27 | false 28 | v120 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | NotUsing 46 | Level3 47 | Disabled 48 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 49 | /D _CRT_SECURE_NO_WARNINGS %(AdditionalOptions) 50 | true 51 | true 52 | 53 | 54 | Windows 55 | true 56 | 57 | 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | NotUsing 65 | MaxSpeed 66 | true 67 | true 68 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 69 | /D _CRT_SECURE_NO_WARNINGS %(AdditionalOptions) 70 | true 71 | 72 | 73 | Windows 74 | true 75 | true 76 | true 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /libpng/pngrio.c: -------------------------------------------------------------------------------- 1 | 2 | /* pngrio.c - functions for data input 3 | * 4 | * Last changed in libpng 1.6.24 [August 4, 2016] 5 | * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson 6 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 | * 9 | * This code is released under the libpng license. 10 | * For conditions of distribution and use, see the disclaimer 11 | * and license in png.h 12 | * 13 | * This file provides a location for all input. Users who need 14 | * special handling are expected to write a function that has the same 15 | * arguments as this and performs a similar function, but that possibly 16 | * has a different input method. Note that you shouldn't change this 17 | * function, but rather write a replacement function and then make 18 | * libpng use it at run time with png_set_read_fn(...). 19 | */ 20 | 21 | #include "pngpriv.h" 22 | 23 | #ifdef PNG_READ_SUPPORTED 24 | 25 | /* Read the data from whatever input you are using. The default routine 26 | * reads from a file pointer. Note that this routine sometimes gets called 27 | * with very small lengths, so you should implement some kind of simple 28 | * buffering if you are using unbuffered reads. This should never be asked 29 | * to read more than 64K on a 16-bit machine. 30 | */ 31 | void /* PRIVATE */ 32 | png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length) 33 | { 34 | png_debug1(4, "reading %d bytes", (int)length); 35 | 36 | if (png_ptr->read_data_fn != NULL) 37 | (*(png_ptr->read_data_fn))(png_ptr, data, length); 38 | 39 | else 40 | png_error(png_ptr, "Call to NULL read function"); 41 | } 42 | 43 | #ifdef PNG_STDIO_SUPPORTED 44 | /* This is the function that does the actual reading of data. If you are 45 | * not reading from a standard C stream, you should create a replacement 46 | * read_data function and use it at run time with png_set_read_fn(), rather 47 | * than changing the library. 48 | */ 49 | void PNGCBAPI 50 | png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 51 | { 52 | png_size_t check; 53 | 54 | if (png_ptr == NULL) 55 | return; 56 | 57 | /* fread() returns 0 on error, so it is OK to store this in a png_size_t 58 | * instead of an int, which is what fread() actually returns. 59 | */ 60 | check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr)); 61 | 62 | if (check != length) 63 | png_error(png_ptr, "Read Error"); 64 | } 65 | #endif 66 | 67 | /* This function allows the application to supply a new input function 68 | * for libpng if standard C streams aren't being used. 69 | * 70 | * This function takes as its arguments: 71 | * 72 | * png_ptr - pointer to a png input data structure 73 | * 74 | * io_ptr - pointer to user supplied structure containing info about 75 | * the input functions. May be NULL. 76 | * 77 | * read_data_fn - pointer to a new input function that takes as its 78 | * arguments a pointer to a png_struct, a pointer to 79 | * a location where input data can be stored, and a 32-bit 80 | * unsigned int that is the number of bytes to be read. 81 | * To exit and output any fatal error messages the new write 82 | * function should call png_error(png_ptr, "Error msg"). 83 | * May be NULL, in which case libpng's default function will 84 | * be used. 85 | */ 86 | void PNGAPI 87 | png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, 88 | png_rw_ptr read_data_fn) 89 | { 90 | if (png_ptr == NULL) 91 | return; 92 | 93 | png_ptr->io_ptr = io_ptr; 94 | 95 | #ifdef PNG_STDIO_SUPPORTED 96 | if (read_data_fn != NULL) 97 | png_ptr->read_data_fn = read_data_fn; 98 | 99 | else 100 | png_ptr->read_data_fn = png_default_read_data; 101 | #else 102 | png_ptr->read_data_fn = read_data_fn; 103 | #endif 104 | 105 | #ifdef PNG_WRITE_SUPPORTED 106 | /* It is an error to write to a read device */ 107 | if (png_ptr->write_data_fn != NULL) 108 | { 109 | png_ptr->write_data_fn = NULL; 110 | png_warning(png_ptr, 111 | "Can't set both read_data_fn and write_data_fn in the" 112 | " same structure"); 113 | } 114 | #endif 115 | 116 | #ifdef PNG_WRITE_FLUSH_SUPPORTED 117 | png_ptr->output_flush_fn = NULL; 118 | #endif 119 | } 120 | #endif /* READ */ 121 | -------------------------------------------------------------------------------- /xskin/include/view/UIWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIWINDOW_H_INCLUDED__ 2 | #define __UIWINDOW_H_INCLUDED__ 3 | 4 | #include 5 | #include 6 | #include "../core/UIResponser.h" 7 | #include "../core/UIString.h" 8 | #include "../core/AutoPtr.h" 9 | #include "../core/UIRect.h" 10 | #include "../core/UIPoint.h" 11 | 12 | class UIView; 13 | class UIRootView; 14 | class UIBitmap; 15 | class UIEvent; 16 | class XSKIN_API UIWindow : public UIResponser 17 | { 18 | public: 19 | enum SizeType 20 | { 21 | MAXIMIZED = 0, 22 | MINIMIZED, 23 | RESTORED 24 | }; 25 | 26 | UIWindow(UIWindow* pParent = NULL); 27 | ~UIWindow(); 28 | 29 | public: 30 | BOOL Create(); 31 | const UIRect& GetBounds() const; 32 | void SetBounds(const UIRect& rc); 33 | void SetBounds(int l, int t, int r, int b); 34 | void SetPos(int x, int y); 35 | void SetPos(const UIPoint& pt); 36 | void CenterWindow(); 37 | void Show(); 38 | void ShowNoActive(); 39 | int ShowModal(); 40 | void Hide(); 41 | void Close(); 42 | void Maximize(); 43 | void Minimize(); 44 | void Restore(); 45 | void ShowFullscreen(BOOL b); 46 | void SetAlwaysOnTop(BOOL b); 47 | void Activate(); 48 | void SetWindowOwner(UIWindow* pOwner); 49 | void Deactivate(); 50 | void SetCapture(BOOL b); 51 | void SetIcon(HICON hIcon); 52 | BOOL IsActive() const; 53 | BOOL IsVisible() const; 54 | BOOL IsMaximized() const; 55 | BOOL IsMinimized() const; 56 | BOOL IsFullscreen() const; 57 | HWND GetNativeWindow() const; 58 | HDC GetPaintDC() const; 59 | void SetContentView(const UIString& szXmlFileName); 60 | void SetContentView(UIView* v); 61 | UIRootView* GetRootView() const; 62 | void ShowTooltip(const UIPoint& pt, const UIString& szTooltip); 63 | void HideTooltip(); 64 | void SetFrameVisible(BOOL b); 65 | BOOL IsFrameVisible() const; 66 | void SetResizeRect(const UIRect& rc); 67 | void SetResizeRect(int l, int t, int r, int b); 68 | UIRect GetResizeRect() const; 69 | 70 | protected: 71 | LPCTSTR GetWndClassName() const; 72 | virtual DWORD GetWndStyle() const; 73 | virtual DWORD GetWndExStyle() const; 74 | virtual LRESULT OnWindowMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); 75 | UIResponser* GetNextResponser() const OVERRIDE; 76 | BOOL Event(UIEvent* event) OVERRIDE; 77 | BOOL RegisterWndClass(); 78 | void DoPaint(); 79 | LRESULT OnReflect(UINT uMsg, WPARAM wParam, LPARAM lParam); 80 | LRESULT OnSetCursor(HWND hWnd, UINT nHitTest, UINT message); 81 | LRESULT OnSize(int nType, int cx, int cy); 82 | LRESULT OnPaint(HDC hdc); 83 | LRESULT OnEraseBkgnd(HDC hdc); 84 | LRESULT OnNcHitTest(const UIPoint& pt); 85 | LRESULT OnMouseMove(const UIPoint& pt, int nFlags); 86 | LRESULT OnMouseWheel(const UIPoint& pt, short zDelta, int nFlags); 87 | LRESULT OnMouseHover(const UIPoint& pt, int nFlags); 88 | LRESULT OnMouseLeave(const UIPoint& pt, int nFlags); 89 | LRESULT OnLButtonDown(const UIPoint& pt, int nFlags); 90 | LRESULT OnLButtonDblClicked(const UIPoint& pt, int nFlags); 91 | LRESULT OnNCLButtonDown(const UIPoint& pt, int nFlags); 92 | LRESULT OnMButtonDown(const UIPoint& pt, int nFlags); 93 | LRESULT OnRButtonDown(const UIPoint& pt, int nFlags); 94 | LRESULT OnLButtonUp(const UIPoint& pt, int nFlags); 95 | LRESULT OnMButtonUp(const UIPoint& pt, int nFlags); 96 | LRESULT OnRButtonUp(const UIPoint& pt, int nFlags); 97 | LRESULT OnKeyDown(int nKeyCode, int nRepeatCnt, int nFlags); 98 | LRESULT OnKeyUp(int nKeyCode, int nRepeatCnt, int nFlags); 99 | LRESULT OnChar(int nChar, int nRepeatCnt, int nFlags); 100 | LRESULT OnTimer(UINT uTimerID); 101 | LRESULT OnKillFocus(HWND hNewWnd); 102 | LRESULT OnSetFocus(HWND hOldWnd); 103 | virtual void OnCreate(); 104 | virtual void OnDestroy(); 105 | static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 106 | 107 | protected: 108 | struct SavedWindowInfo 109 | { 110 | BOOL bMaximized; 111 | LONG nStyle; 112 | LONG nExStyle; 113 | UIRect rcRect; 114 | } m_sif; 115 | 116 | struct SavedWndStyle 117 | { 118 | LONG nStyle; 119 | LONG nExStyle; 120 | } m_sws; 121 | 122 | UIWindow* m_pParent; 123 | HWND m_hWnd; 124 | HWND m_hTooltip; 125 | HDC m_hDC; 126 | UIRect m_rcBound; 127 | UIRect m_rcResize; 128 | BOOL m_bFullscreen; 129 | BOOL m_bTrackingMouse; 130 | BOOL m_bFrameVisible; 131 | const UIBitmap* m_pOffscreen; 132 | const UIBitmap* m_pIcon; 133 | AutoPtr m_pRootView; 134 | TOOLINFO m_toolinfo; 135 | }; 136 | #endif //! __UIWINDOW_H_INCLUDED__ -------------------------------------------------------------------------------- /xskin/src/gfx/UIFont.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "../../include/gfx/UIFont.h" 3 | 4 | UIFont::FontCache UIFont::fontCache; 5 | 6 | UIFont::UIFont(HFONT hFont) 7 | { 8 | m_hFont = hFont; 9 | Init(); 10 | } 11 | 12 | UIFont::UIFont(const UIString& szFontName, int nFontSize, int nFontStyle) 13 | { 14 | m_szName = szFontName; 15 | m_nSize = nFontSize; 16 | HDC hdc = GetDC(NULL); 17 | int nHeight = -MulDiv(nFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); 18 | ReleaseDC(NULL, hdc); 19 | 20 | int nWeight = FW_NORMAL; 21 | BOOL bItalic = FALSE; 22 | BOOL bUnderlined = FALSE; 23 | 24 | if(nFontStyle & BOLD) 25 | nWeight = FW_BOLD; 26 | if(nFontStyle & ITALIC) 27 | bItalic = TRUE; 28 | if(nFontStyle & UNDERLINED) 29 | bUnderlined = TRUE; 30 | 31 | m_hFont = ::CreateFont(nHeight, 0, 0, 0, nWeight, bItalic, bUnderlined, 0, 0, 0, 0, 0, 0, szFontName); 32 | XASSERT(m_hFont); 33 | 34 | Init(); 35 | } 36 | 37 | UIFont::~UIFont() 38 | { 39 | FontCache::iterator itor = fontCache.find(m_szKey); 40 | if(itor != fontCache.end()) 41 | fontCache.erase(itor); 42 | 43 | if(m_hFont) 44 | ::DeleteObject(m_hFont); 45 | } 46 | 47 | UIFont* UIFont::GetFont(LPCTSTR szCacheKey) 48 | { 49 | FontCache::const_iterator itor = fontCache.find(szCacheKey); 50 | if(itor != fontCache.end()) 51 | { 52 | itor->second->AddRef(); 53 | return itor->second; 54 | } 55 | else 56 | { 57 | return NULL; 58 | } 59 | } 60 | 61 | UIFont* UIFont::CreateNew(HFONT hFont, LPCTSTR szCacheKey) 62 | { 63 | UIFont* pFont; 64 | if(szCacheKey) 65 | { 66 | FontCache::const_iterator itor = fontCache.find(szCacheKey); 67 | if(itor != fontCache.end()) 68 | { 69 | pFont = itor->second; 70 | pFont->AddRef(); 71 | } 72 | else 73 | { 74 | pFont = new UIFont(hFont); 75 | pFont->m_szKey = szCacheKey; 76 | fontCache.insert(std::make_pair(szCacheKey, pFont)); 77 | } 78 | } 79 | else 80 | { 81 | pFont = new UIFont(hFont); 82 | } 83 | 84 | return pFont; 85 | } 86 | 87 | UIFont* UIFont::CreateNew(const UIString& szFontName, int nFontSize, int nFontStyle, LPCTSTR szCacheKey) 88 | { 89 | UIFont* pFont; 90 | if(szCacheKey) 91 | { 92 | FontCache::const_iterator itor = fontCache.find(szCacheKey); 93 | if(itor != fontCache.end()) 94 | { 95 | pFont = itor->second; 96 | pFont->AddRef(); 97 | } 98 | else 99 | { 100 | pFont = new UIFont(szFontName, nFontSize, nFontStyle); 101 | pFont->m_szKey = szCacheKey; 102 | fontCache.insert(std::make_pair(szCacheKey, pFont)); 103 | } 104 | } 105 | else 106 | { 107 | pFont = new UIFont(szFontName, nFontSize, nFontStyle); 108 | } 109 | 110 | return pFont; 111 | } 112 | 113 | void UIFont::Init() 114 | { 115 | TEXTMETRIC metrics; 116 | HDC hScreenDC = GetDC(NULL); 117 | HFONT hOldFont = static_cast(SelectObject(hScreenDC, m_hFont)); 118 | int nOldMapMode = SetMapMode(hScreenDC, MM_TEXT); 119 | GetTextMetrics(hScreenDC, &metrics); 120 | SelectObject(hScreenDC, hOldFont); 121 | SetMapMode(hScreenDC, nOldMapMode); 122 | ReleaseDC(NULL, hScreenDC); 123 | 124 | m_nHeight = max(1, static_cast(metrics.tmHeight)); 125 | m_nBaseline = max(1, static_cast(metrics.tmAscent)); 126 | m_nAvgCharWidth = max(1, static_cast(metrics.tmAveCharWidth)); 127 | m_nStyle = UIFont::NORMAL; 128 | if(metrics.tmItalic) 129 | m_nStyle |= UIFont::ITALIC; 130 | if(metrics.tmUnderlined) 131 | m_nStyle |= UIFont::UNDERLINED; 132 | if(metrics.tmWeight >= FW_BOLD) 133 | m_nStyle |= UIFont::BOLD; 134 | 135 | AddRef(); 136 | } 137 | 138 | int UIFont::GetHeight() const 139 | { 140 | return m_nHeight; 141 | } 142 | 143 | int UIFont::GetBaseline() const 144 | { 145 | return m_nBaseline; 146 | } 147 | 148 | int UIFont::GetAverageCharWidth() const 149 | { 150 | return m_nAvgCharWidth; 151 | } 152 | 153 | int UIFont::GetStringWidth(const UIString& szText) const 154 | { 155 | HDC hdc = GetDC(NULL); 156 | HFONT hOldFont = static_cast(SelectObject(hdc, m_hFont)); 157 | int nOldMap = SetMapMode(hdc, MM_TEXT); 158 | SIZE size; 159 | GetTextExtentPoint32(hdc, szText, szText.GetLength(), &size); 160 | SelectObject(hdc, hOldFont); 161 | SetMapMode(hdc, nOldMap); 162 | ReleaseDC(NULL, hdc); 163 | 164 | return size.cx; 165 | } 166 | 167 | int UIFont::GetFontStyle() const 168 | { 169 | return m_nStyle; 170 | } 171 | 172 | int UIFont::GetFontSize() const 173 | { 174 | return m_nSize; 175 | } 176 | 177 | UIString UIFont::GetFontName() const 178 | { 179 | return m_szName; 180 | } 181 | 182 | HFONT UIFont::GetNativeFont() const 183 | { 184 | return m_hFont; 185 | } 186 | 187 | UIFont::operator HFONT() const 188 | { 189 | return m_hFont; 190 | } --------------------------------------------------------------------------------