├── .gitignore ├── DuiLib ├── StdAfx.h ├── Core │ ├── UIBase.h │ ├── UIBase.cpp │ ├── UIControl.h │ ├── UIDefine.h │ ├── UIRender.h │ ├── UIContainer.h │ ├── UIControl.cpp │ ├── UIMarkup.cpp │ ├── UIRender.cpp │ ├── UIContainer.cpp │ ├── UIDlgBuilder.cpp │ ├── UIDlgBuilder.h │ └── UIMarkup.h ├── Control │ ├── UIList.h │ ├── UICombo.cpp │ ├── UIFlash.cpp │ ├── UIFlash.h │ ├── UIList.cpp │ ├── UIActiveX.cpp │ ├── UICheckBox.h │ ├── UIComboBox.h │ ├── UIDateTime.h │ ├── UIRichEdit.h │ ├── UIDateTime.cpp │ ├── UIRichEdit.cpp │ ├── UITreeView.cpp │ ├── UIWebBrowser.cpp │ ├── UIWebBrowser.h │ ├── UICheckBox.cpp │ ├── UIText.h │ ├── UIProgress.h │ ├── UISlider.h │ ├── UIOption.h │ ├── UIButton.h │ ├── UIActiveX.h │ ├── UIEdit.h │ ├── UILabel.h │ ├── UIComboBox.cpp │ ├── UIProgress.cpp │ ├── UICombo.h │ ├── UIScrollBar.h │ ├── UITreeView.h │ ├── UIText.cpp │ ├── UISlider.cpp │ └── UIOption.cpp ├── Utils │ ├── Utils.cpp │ ├── WinImplBase.h │ ├── WinImplBase.cpp │ ├── FlashEventHandler.h │ ├── WebBrowserEventHandler.h │ ├── UIDelegate.cpp │ ├── UIDelegate.h │ ├── downloadmgr.h │ └── Utils.h ├── StdAfx.cpp ├── Layout │ ├── UIChildLayout.h │ ├── UITileLayout.h │ ├── UITabLayout.h │ ├── UIVerticalLayout.h │ ├── UIHorizontalLayout.h │ ├── UIChildLayout.cpp │ ├── UITabLayout.cpp │ ├── UITileLayout.cpp │ └── UIHorizontalLayout.cpp ├── CMakeLists.txt ├── UIlib.cpp └── UIlib.h ├── DuiDesigner ├── HookAPI.h ├── MainFrm.h ├── stdafx.h ├── ChildFrm.h ├── ClassView.h ├── FileView.h ├── HookAPI.cpp ├── MainFrm.cpp ├── ReadMe.txt ├── ViewTree.h ├── stdafx.cpp ├── targetver.h ├── ChildFrm.cpp ├── ClassView.cpp ├── DuiDesigner.h ├── DuiDesigner.rc ├── FileView.cpp ├── ToolBoxWnd.cpp ├── UserImages.bmp ├── ViewTree.cpp ├── res │ ├── banner.bmp │ ├── sort.bmp │ ├── uimenu.bmp │ ├── Toolbar.bmp │ ├── explorer.bmp │ ├── fileview.bmp │ ├── formedit.bmp │ ├── res_view.ico │ ├── resource.bmp │ ├── sort_hc.bmp │ ├── Toolbar256.bmp │ ├── Toolbar_hc.bmp │ ├── UIDesigner.ico │ ├── UIDesigner.rc2 │ ├── class_view.ico │ ├── classview.bmp │ ├── explorer_hc.bmp │ ├── file_view.ico │ ├── fileview_hc.bmp │ ├── formedit_hc.bmp │ ├── menuimages.bmp │ ├── movehandle.bmp │ ├── properties.bmp │ ├── res_view_hc.ico │ ├── resource24.bmp │ ├── ToolBox │ │ ├── Combo.ico │ │ ├── Edit.ico │ │ ├── Label.ico │ │ ├── Text.ico │ │ ├── Active.ico │ │ ├── Button.ico │ │ ├── Control.ico │ │ ├── Option.ico │ │ ├── Pointer.ico │ │ ├── Progress.ico │ │ ├── Slider.ico │ │ ├── Container.ico │ │ ├── ScrollBar.ico │ │ ├── TabLayout.ico │ │ ├── TileLayout.ico │ │ ├── VerticalLayout.ico │ │ └── HorizontalLayout.ico │ ├── UIDesignerDoc.ico │ ├── class_view_hc.ico │ ├── classview_hc.bmp │ ├── file_view_hc.ico │ ├── menuimages_hc.bmp │ ├── properties_hc.bmp │ ├── properties_wnd.ico │ ├── toolbox_wnd_hc.ico │ └── properties_wnd_hc.ico ├── DuiDesigner.cpp ├── DuiDesigner.reg ├── ImageDialog.cpp ├── ImagePreview.cpp ├── PropertiesWnd.h ├── ToolBoxCtrl.cpp ├── UIDesignerDoc.h ├── UIDesignerView.h ├── UIProperties.cpp ├── DialogCheckUpdate.h ├── DialogProjectNew.h ├── DialogSaveAsName.h ├── DuiDesigner.vcproj ├── LayoutManager.cpp ├── UIDesignerDoc.cpp ├── UIDesignerView.cpp ├── UIImagePreview.cpp ├── DialogCheckUpdate.cpp ├── DialogCustomFonts.cpp ├── DialogProjectNew.cpp ├── DialogSaveAsName.cpp ├── DialogSkinFileNew.cpp ├── DialogTemplateOpen.h ├── DialogUIAttribEdit.h ├── DialogTemplateOpen.cpp ├── DialogUIAttribEdit.cpp ├── PropertyTabLayoutUI.cpp ├── DialogDefaultAttribList.cpp ├── third_party │ └── tinyxml │ │ ├── tinystr.cpp │ │ └── tinyxmlerror.cpp ├── UIImagePreview.h ├── GlobalVariable.h ├── ToolBoxWnd.h ├── DialogCustomFonts.h ├── ImagePreview.h ├── DialogSkinFileNew.h ├── CMakeLists.txt ├── DialogDefaultAttribList.h ├── GlobalVariable.cpp ├── PropertyTabLayoutUI.h ├── ResourceView.h ├── ImageDialog.h ├── UICommandHistory.h ├── UIUtil.h ├── UIUtil.cpp ├── ToolBoxCtrl.h ├── MultiUITracker.h ├── PropertiesWnd.cpp ├── LayoutManager.h └── ResourceView.cpp └── DuiDesigner.sln /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | bin/ 3 | DuiDesigner/ 4 | DuiLib/ 5 | Lib/ 6 | -------------------------------------------------------------------------------- /DuiLib/StdAfx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/StdAfx.h -------------------------------------------------------------------------------- /DuiDesigner/HookAPI.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/HookAPI.h -------------------------------------------------------------------------------- /DuiDesigner/MainFrm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/MainFrm.h -------------------------------------------------------------------------------- /DuiDesigner/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/stdafx.h -------------------------------------------------------------------------------- /DuiLib/Core/UIBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIBase.h -------------------------------------------------------------------------------- /DuiDesigner/ChildFrm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ChildFrm.h -------------------------------------------------------------------------------- /DuiDesigner/ClassView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ClassView.h -------------------------------------------------------------------------------- /DuiDesigner/FileView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/FileView.h -------------------------------------------------------------------------------- /DuiDesigner/HookAPI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/HookAPI.cpp -------------------------------------------------------------------------------- /DuiDesigner/MainFrm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/MainFrm.cpp -------------------------------------------------------------------------------- /DuiDesigner/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ReadMe.txt -------------------------------------------------------------------------------- /DuiDesigner/ViewTree.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ViewTree.h -------------------------------------------------------------------------------- /DuiDesigner/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/stdafx.cpp -------------------------------------------------------------------------------- /DuiDesigner/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/targetver.h -------------------------------------------------------------------------------- /DuiLib/Control/UIList.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIList.h -------------------------------------------------------------------------------- /DuiLib/Core/UIBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIBase.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIControl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIControl.h -------------------------------------------------------------------------------- /DuiLib/Core/UIDefine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIDefine.h -------------------------------------------------------------------------------- /DuiLib/Core/UIRender.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIRender.h -------------------------------------------------------------------------------- /DuiLib/Utils/Utils.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Utils/Utils.cpp -------------------------------------------------------------------------------- /DuiDesigner/ChildFrm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ChildFrm.cpp -------------------------------------------------------------------------------- /DuiDesigner/ClassView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ClassView.cpp -------------------------------------------------------------------------------- /DuiDesigner/DuiDesigner.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DuiDesigner.h -------------------------------------------------------------------------------- /DuiDesigner/DuiDesigner.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DuiDesigner.rc -------------------------------------------------------------------------------- /DuiDesigner/FileView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/FileView.cpp -------------------------------------------------------------------------------- /DuiDesigner/ToolBoxWnd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ToolBoxWnd.cpp -------------------------------------------------------------------------------- /DuiDesigner/UserImages.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/UserImages.bmp -------------------------------------------------------------------------------- /DuiDesigner/ViewTree.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ViewTree.cpp -------------------------------------------------------------------------------- /DuiDesigner/res/banner.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/banner.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/sort.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/sort.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/uimenu.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/uimenu.bmp -------------------------------------------------------------------------------- /DuiLib/Control/UICombo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UICombo.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIFlash.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIFlash.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIFlash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIFlash.h -------------------------------------------------------------------------------- /DuiLib/Control/UIList.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIList.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIContainer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIContainer.h -------------------------------------------------------------------------------- /DuiLib/Core/UIControl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIControl.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIMarkup.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIMarkup.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIRender.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIRender.cpp -------------------------------------------------------------------------------- /DuiLib/Utils/WinImplBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Utils/WinImplBase.h -------------------------------------------------------------------------------- /DuiDesigner/DuiDesigner.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DuiDesigner.cpp -------------------------------------------------------------------------------- /DuiDesigner/DuiDesigner.reg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DuiDesigner.reg -------------------------------------------------------------------------------- /DuiDesigner/ImageDialog.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ImageDialog.cpp -------------------------------------------------------------------------------- /DuiDesigner/ImagePreview.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ImagePreview.cpp -------------------------------------------------------------------------------- /DuiDesigner/PropertiesWnd.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/PropertiesWnd.h -------------------------------------------------------------------------------- /DuiDesigner/ToolBoxCtrl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/ToolBoxCtrl.cpp -------------------------------------------------------------------------------- /DuiDesigner/UIDesignerDoc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/UIDesignerDoc.h -------------------------------------------------------------------------------- /DuiDesigner/UIDesignerView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/UIDesignerView.h -------------------------------------------------------------------------------- /DuiDesigner/UIProperties.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/UIProperties.cpp -------------------------------------------------------------------------------- /DuiDesigner/res/Toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/Toolbar.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/explorer.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/explorer.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/fileview.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/fileview.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/formedit.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/formedit.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/res_view.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/res_view.ico -------------------------------------------------------------------------------- /DuiDesigner/res/resource.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/resource.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/sort_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/sort_hc.bmp -------------------------------------------------------------------------------- /DuiLib/Control/UIActiveX.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIActiveX.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UICheckBox.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UICheckBox.h -------------------------------------------------------------------------------- /DuiLib/Control/UIComboBox.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIComboBox.h -------------------------------------------------------------------------------- /DuiLib/Control/UIDateTime.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIDateTime.h -------------------------------------------------------------------------------- /DuiLib/Control/UIRichEdit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIRichEdit.h -------------------------------------------------------------------------------- /DuiLib/Core/UIContainer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIContainer.cpp -------------------------------------------------------------------------------- /DuiLib/Core/UIDlgBuilder.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Core/UIDlgBuilder.cpp -------------------------------------------------------------------------------- /DuiLib/Utils/WinImplBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Utils/WinImplBase.cpp -------------------------------------------------------------------------------- /DuiDesigner/DialogCheckUpdate.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogCheckUpdate.h -------------------------------------------------------------------------------- /DuiDesigner/DialogProjectNew.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogProjectNew.h -------------------------------------------------------------------------------- /DuiDesigner/DialogSaveAsName.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogSaveAsName.h -------------------------------------------------------------------------------- /DuiDesigner/DuiDesigner.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DuiDesigner.vcproj -------------------------------------------------------------------------------- /DuiDesigner/LayoutManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/LayoutManager.cpp -------------------------------------------------------------------------------- /DuiDesigner/UIDesignerDoc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/UIDesignerDoc.cpp -------------------------------------------------------------------------------- /DuiDesigner/UIDesignerView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/UIDesignerView.cpp -------------------------------------------------------------------------------- /DuiDesigner/UIImagePreview.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/UIImagePreview.cpp -------------------------------------------------------------------------------- /DuiDesigner/res/Toolbar256.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/Toolbar256.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/Toolbar_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/Toolbar_hc.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/UIDesigner.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/UIDesigner.ico -------------------------------------------------------------------------------- /DuiDesigner/res/UIDesigner.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/UIDesigner.rc2 -------------------------------------------------------------------------------- /DuiDesigner/res/class_view.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/class_view.ico -------------------------------------------------------------------------------- /DuiDesigner/res/classview.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/classview.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/explorer_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/explorer_hc.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/file_view.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/file_view.ico -------------------------------------------------------------------------------- /DuiDesigner/res/fileview_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/fileview_hc.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/formedit_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/formedit_hc.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/menuimages.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/menuimages.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/movehandle.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/movehandle.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/properties.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/properties.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/res_view_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/res_view_hc.ico -------------------------------------------------------------------------------- /DuiDesigner/res/resource24.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/resource24.bmp -------------------------------------------------------------------------------- /DuiLib/Control/UIDateTime.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIDateTime.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIRichEdit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIRichEdit.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UITreeView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UITreeView.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIWebBrowser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIWebBrowser.cpp -------------------------------------------------------------------------------- /DuiLib/Control/UIWebBrowser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Control/UIWebBrowser.h -------------------------------------------------------------------------------- /DuiDesigner/DialogCheckUpdate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogCheckUpdate.cpp -------------------------------------------------------------------------------- /DuiDesigner/DialogCustomFonts.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogCustomFonts.cpp -------------------------------------------------------------------------------- /DuiDesigner/DialogProjectNew.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogProjectNew.cpp -------------------------------------------------------------------------------- /DuiDesigner/DialogSaveAsName.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogSaveAsName.cpp -------------------------------------------------------------------------------- /DuiDesigner/DialogSkinFileNew.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogSkinFileNew.cpp -------------------------------------------------------------------------------- /DuiDesigner/DialogTemplateOpen.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogTemplateOpen.h -------------------------------------------------------------------------------- /DuiDesigner/DialogUIAttribEdit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogUIAttribEdit.h -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Combo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Combo.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Edit.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Edit.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Label.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Label.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Text.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Text.ico -------------------------------------------------------------------------------- /DuiDesigner/res/UIDesignerDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/UIDesignerDoc.ico -------------------------------------------------------------------------------- /DuiDesigner/res/class_view_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/class_view_hc.ico -------------------------------------------------------------------------------- /DuiDesigner/res/classview_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/classview_hc.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/file_view_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/file_view_hc.ico -------------------------------------------------------------------------------- /DuiDesigner/res/menuimages_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/menuimages_hc.bmp -------------------------------------------------------------------------------- /DuiDesigner/res/properties_hc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/properties_hc.bmp -------------------------------------------------------------------------------- /DuiLib/Utils/FlashEventHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Utils/FlashEventHandler.h -------------------------------------------------------------------------------- /DuiDesigner/DialogTemplateOpen.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogTemplateOpen.cpp -------------------------------------------------------------------------------- /DuiDesigner/DialogUIAttribEdit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogUIAttribEdit.cpp -------------------------------------------------------------------------------- /DuiDesigner/PropertyTabLayoutUI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/PropertyTabLayoutUI.cpp -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Active.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Active.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Button.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Button.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Control.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Control.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Option.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Option.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Pointer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Pointer.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Progress.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Progress.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Slider.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Slider.ico -------------------------------------------------------------------------------- /DuiDesigner/res/properties_wnd.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/properties_wnd.ico -------------------------------------------------------------------------------- /DuiDesigner/res/toolbox_wnd_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/toolbox_wnd_hc.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/Container.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/Container.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/ScrollBar.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/ScrollBar.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/TabLayout.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/TabLayout.ico -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/TileLayout.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/TileLayout.ico -------------------------------------------------------------------------------- /DuiDesigner/res/properties_wnd_hc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/properties_wnd_hc.ico -------------------------------------------------------------------------------- /DuiLib/Utils/WebBrowserEventHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiLib/Utils/WebBrowserEventHandler.h -------------------------------------------------------------------------------- /DuiDesigner/DialogDefaultAttribList.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/DialogDefaultAttribList.cpp -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/VerticalLayout.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/VerticalLayout.ico -------------------------------------------------------------------------------- /DuiDesigner/third_party/tinyxml/tinystr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/third_party/tinyxml/tinystr.cpp -------------------------------------------------------------------------------- /DuiDesigner/res/ToolBox/HorizontalLayout.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quanzhuo/DuiDesigner/HEAD/DuiDesigner/res/ToolBox/HorizontalLayout.ico -------------------------------------------------------------------------------- /DuiLib/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // UIlib.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "StdAfx.h" 6 | 7 | 8 | #pragma comment( lib, "winmm.lib" ) 9 | #pragma comment( lib, "comctl32.lib" ) 10 | -------------------------------------------------------------------------------- /DuiLib/Control/UICheckBox.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UICheckBox.h" 3 | 4 | namespace DuiLib 5 | { 6 | LPCTSTR CCheckBoxUI::GetClass() const 7 | { 8 | return _T("CheckBoxUI"); 9 | } 10 | 11 | void CCheckBoxUI::SetCheck(bool bCheck) 12 | { 13 | Selected(bCheck); 14 | } 15 | 16 | bool CCheckBoxUI::GetCheck() const 17 | { 18 | return IsSelected(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DuiDesigner/UIImagePreview.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | // CUIImagePreview 5 | 6 | class CUIImagePreview : public CStatic 7 | { 8 | DECLARE_DYNAMIC(CUIImagePreview) 9 | 10 | public: 11 | CUIImagePreview(); 12 | virtual ~CUIImagePreview(); 13 | 14 | private: 15 | CImage m_imgPreview; 16 | 17 | public: 18 | void SetPreviewImage(LPCTSTR pstrImage); 19 | 20 | protected: 21 | DECLARE_MESSAGE_MAP() 22 | public: 23 | afx_msg void OnPaint(); 24 | }; -------------------------------------------------------------------------------- /DuiDesigner/GlobalVariable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CGlobalVariable 4 | { 5 | public: 6 | CGlobalVariable(void); 7 | ~CGlobalVariable(void); 8 | 9 | public: 10 | static CString& GetCurPath(); 11 | static CString& GetTemplatesDir(); 12 | static CString& GetStylesDir(); 13 | 14 | public: 15 | static bool m_bIsProjectExist; 16 | static CString m_strProjectName; 17 | static CString m_strProjectPath; 18 | 19 | private: 20 | static CString m_strCurPath; 21 | static CString m_strTemplatesDir; 22 | static CString m_strStylesDir; 23 | }; 24 | -------------------------------------------------------------------------------- /DuiLib/Layout/UIChildLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICHILDLAYOUT_H__ 2 | #define __UICHILDLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CChildLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CChildLayoutUI(); 12 | 13 | void Init(); 14 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 15 | void SetChildLayoutXML(CDuiString pXML); 16 | DuiLib::CDuiString GetChildLayoutXML(); 17 | virtual LPVOID GetInterface(LPCTSTR pstrName); 18 | virtual LPCTSTR GetClass() const; 19 | 20 | private: 21 | DuiLib::CDuiString m_pstrXMLFile; 22 | }; 23 | } // namespace DuiLib 24 | #endif // __UICHILDLAYOUT_H__ 25 | -------------------------------------------------------------------------------- /DuiLib/Layout/UITileLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITILELAYOUT_H__ 2 | #define __UITILELAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTileLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CTileLayoutUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | 16 | void SetPos(RECT rc); 17 | 18 | SIZE GetItemSize() const; 19 | void SetItemSize(SIZE szItem); 20 | int GetColumns() const; 21 | void SetColumns(int nCols); 22 | 23 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 24 | 25 | protected: 26 | SIZE m_szItem; 27 | int m_nColumns; 28 | }; 29 | } 30 | #endif // __UITILELAYOUT_H__ 31 | -------------------------------------------------------------------------------- /DuiDesigner/ToolBoxWnd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ToolBoxCtrl.h" 3 | 4 | // CToolBoxWnd 5 | 6 | class CToolBoxWnd : public CDockablePane 7 | { 8 | DECLARE_DYNAMIC(CToolBoxWnd) 9 | 10 | public: 11 | CToolBoxWnd(); 12 | virtual ~CToolBoxWnd(); 13 | 14 | protected: 15 | CToolBoxCtrl m_ctlToolList; 16 | 17 | public: 18 | CToolElement* GetCurSel() const { return m_ctlToolList.GetCurSel(); } 19 | void SetCurSel(int nClass,BOOL bRedraw=TRUE) { m_ctlToolList.SetCurSel(nClass,bRedraw); } 20 | 21 | protected: 22 | void AdjustLayout(); 23 | void InitToolList(); 24 | 25 | protected: 26 | DECLARE_MESSAGE_MAP() 27 | public: 28 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 29 | afx_msg void OnSize(UINT nType, int cx, int cy); 30 | }; 31 | 32 | 33 | -------------------------------------------------------------------------------- /DuiLib/Control/UIText.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITEXT_H__ 2 | #define __UITEXT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTextUI : public CLabelUI 9 | { 10 | public: 11 | CTextUI(); 12 | ~CTextUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | UINT GetControlFlags() const; 16 | LPVOID GetInterface(LPCTSTR pstrName); 17 | 18 | CDuiString* GetLinkContent(int iIndex); 19 | 20 | void DoEvent(TEventUI& event); 21 | SIZE EstimateSize(SIZE szAvailable); 22 | 23 | void PaintText(HDC hDC); 24 | 25 | protected: 26 | enum { MAX_LINK = 8 }; 27 | int m_nLinks; 28 | RECT m_rcLinks[MAX_LINK]; 29 | CDuiString m_sLinks[MAX_LINK]; 30 | int m_nHoverLink; 31 | }; 32 | 33 | } // namespace DuiLib 34 | 35 | #endif //__UITEXT_H__ -------------------------------------------------------------------------------- /DuiLib/Layout/UITabLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITABLAYOUT_H__ 2 | #define __UITABLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTabLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CTabLayoutUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | 16 | bool Add(CControlUI* pControl); 17 | bool AddAt(CControlUI* pControl, int iIndex); 18 | bool Remove(CControlUI* pControl); 19 | void RemoveAll(); 20 | int GetCurSel() const; 21 | bool SelectItem(int iIndex); 22 | bool SelectItem(CControlUI* pControl); 23 | 24 | void SetPos(RECT rc); 25 | 26 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 27 | 28 | protected: 29 | int m_iCurSel; 30 | }; 31 | } 32 | #endif // __UITABLAYOUT_H__ 33 | -------------------------------------------------------------------------------- /DuiDesigner/DialogCustomFonts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | 4 | 5 | // CDialogCustomFonts dialog 6 | 7 | class CDialogCustomFonts : public CDialog 8 | { 9 | DECLARE_DYNAMIC(CDialogCustomFonts) 10 | 11 | public: 12 | CDialogCustomFonts(CWnd* pParent = NULL); // standard constructor 13 | virtual ~CDialogCustomFonts(); 14 | 15 | // Dialog Data 16 | enum { IDD = IDD_DIALOG_CUSTOM_FONTS }; 17 | 18 | private: 19 | CPaintManagerUI* m_pManager; 20 | 21 | protected: 22 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 23 | 24 | DECLARE_MESSAGE_MAP() 25 | public: 26 | virtual BOOL OnInitDialog(); 27 | CListCtrl m_lstCustomFonts; 28 | afx_msg void OnBnClickedButtonFontAdd(); 29 | afx_msg void OnBnClickedButtonFontDelete(); 30 | afx_msg void OnBnClickedButtonFontModify(); 31 | }; 32 | -------------------------------------------------------------------------------- /DuiDesigner/ImagePreview.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../DuiLib/Core/UIRender.h" 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // CImagePreview 6 | 7 | class CImagePreview : public CStatic 8 | { 9 | DECLARE_DYNAMIC(CImagePreview) 10 | 11 | public: 12 | CImagePreview(); 13 | virtual ~CImagePreview(); 14 | 15 | public: 16 | void SetImageProperty(LPCTSTR pstrImage,CRect& rcDest,CRect& rcSource,CRect& rcCorner,COLORREF clrMask,int nFade,BOOL bHole); 17 | LPCTSTR GetImageProperty() const { return m_strProperty; } 18 | void SetManager(CPaintManagerUI* pManager); 19 | 20 | private: 21 | CString m_strImage; 22 | CString m_strProperty; 23 | CRect m_rcImage; 24 | CPaintManagerUI* m_pManager; 25 | 26 | protected: 27 | DECLARE_MESSAGE_MAP() 28 | public: 29 | afx_msg void OnPaint(); 30 | }; 31 | 32 | 33 | -------------------------------------------------------------------------------- /DuiDesigner/DialogSkinFileNew.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | #include "UIImagePreview.h" 4 | 5 | // CDialogSkinFileNew dialog 6 | 7 | class CDialogSkinFileNew : public CDialog 8 | { 9 | DECLARE_DYNAMIC(CDialogSkinFileNew) 10 | 11 | public: 12 | CDialogSkinFileNew(CWnd* pParent = NULL); // standard constructor 13 | virtual ~CDialogSkinFileNew(); 14 | 15 | // Dialog Data 16 | enum { IDD = IDD_SKINFILE_NEW }; 17 | 18 | protected: 19 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 20 | 21 | public: 22 | CString& GetStyleFilePath(); 23 | 24 | private: 25 | void FindStyleFiles(CString& strDir); 26 | 27 | DECLARE_MESSAGE_MAP() 28 | public: 29 | CString m_strUITitle; 30 | 31 | private: 32 | CListBox m_lstStyles; 33 | CUIImagePreview m_StylePreview; 34 | CString m_strStyleFile; 35 | 36 | public: 37 | virtual BOOL OnInitDialog(); 38 | afx_msg void OnLbnSelchangeListStyle(); 39 | afx_msg void OnBnClickedOk(); 40 | }; 41 | -------------------------------------------------------------------------------- /DuiLib/Layout/UIVerticalLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIVERTICALLAYOUT_H__ 2 | #define __UIVERTICALLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CVerticalLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CVerticalLayoutUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | UINT GetControlFlags() const; 16 | 17 | void SetSepHeight(int iHeight); 18 | int GetSepHeight() const; 19 | void SetSepImmMode(bool bImmediately); 20 | bool IsSepImmMode() const; 21 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 22 | void DoEvent(TEventUI& event); 23 | 24 | void SetPos(RECT rc); 25 | void DoPostPaint(HDC hDC, const RECT& rcPaint); 26 | 27 | RECT GetThumbRect(bool bUseNew = false) const; 28 | 29 | protected: 30 | int m_iSepHeight; 31 | UINT m_uButtonState; 32 | POINT ptLastMouse; 33 | RECT m_rcNewPos; 34 | bool m_bImmMode; 35 | }; 36 | } 37 | #endif // __UIVERTICALLAYOUT_H__ 38 | -------------------------------------------------------------------------------- /DuiLib/Layout/UIHorizontalLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIHORIZONTALLAYOUT_H__ 2 | #define __UIHORIZONTALLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CHorizontalLayoutUI : public CContainerUI 9 | { 10 | public: 11 | CHorizontalLayoutUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | UINT GetControlFlags() const; 16 | 17 | void SetSepWidth(int iWidth); 18 | int GetSepWidth() const; 19 | void SetSepImmMode(bool bImmediately); 20 | bool IsSepImmMode() const; 21 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 22 | void DoEvent(TEventUI& event); 23 | 24 | void SetPos(RECT rc); 25 | void DoPostPaint(HDC hDC, const RECT& rcPaint); 26 | 27 | RECT GetThumbRect(bool bUseNew = false) const; 28 | 29 | protected: 30 | int m_iSepWidth; 31 | UINT m_uButtonState; 32 | POINT ptLastMouse; 33 | RECT m_rcNewPos; 34 | bool m_bImmMode; 35 | }; 36 | } 37 | #endif // __UIHORIZONTALLAYOUT_H__ 38 | -------------------------------------------------------------------------------- /DuiLib/Control/UIProgress.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIPROGRESS_H__ 2 | #define __UIPROGRESS_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CProgressUI : public CLabelUI 9 | { 10 | public: 11 | CProgressUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | 16 | bool IsHorizontal(); 17 | void SetHorizontal(bool bHorizontal = true); 18 | bool IsStretchForeImage(); 19 | void SetStretchForeImage(bool bStretchForeImage = true); 20 | int GetMinValue() const; 21 | void SetMinValue(int nMin); 22 | int GetMaxValue() const; 23 | void SetMaxValue(int nMax); 24 | int GetValue() const; 25 | void SetValue(int nValue); 26 | LPCTSTR GetForeImage() const; 27 | void SetForeImage(LPCTSTR pStrImage); 28 | 29 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 30 | void PaintStatusImage(HDC hDC); 31 | 32 | protected: 33 | bool m_bHorizontal; 34 | bool m_bStretchForeImage; 35 | int m_nMax; 36 | int m_nMin; 37 | int m_nValue; 38 | 39 | CDuiString m_sForeImage; 40 | CDuiString m_sForeImageModify; 41 | }; 42 | 43 | } // namespace DuiLib 44 | 45 | #endif // __UIPROGRESS_H__ 46 | -------------------------------------------------------------------------------- /DuiDesigner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #Cmake file for DuiDesigner 2 | #Author: Qi Gao(monkgau@gmail.com) 3 | #Date: 2012/9/17 4 | 5 | 6 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC) 7 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/tinyxml TINYXML_SRC) 8 | 9 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/tinyxml/) 10 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 11 | 12 | 13 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) 14 | add_executable(DuiDesigner WIN32 ${SRC} ${TINYXML_SRC} DuiDesigner.rc) 15 | 16 | 17 | 18 | set_target_properties(DuiDesigner PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") 19 | 20 | #used for mfc project 21 | add_definitions(-D_AFXDLL) 22 | set_target_properties(DuiDesigner PROPERTIES COMPILE_DEFINITIONS _BIND_TO_CURRENT_CRT_VERSION,_BIND_TO_CURRENT_MFC_VERSION 23 | LINK_FLAGS "/ENTRY:\"wWinMainCRTStartup\"") 24 | target_link_libraries(DuiDesigner duilib) 25 | 26 | 27 | add_custom_command(TARGET DuiDesigner POST_BUILD 28 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 29 | ${PROJECT_BINARY_DIR}/bin/DuiDesigner.exe ${PROJECT_SOURCE_DIR}/bin/DuiDesigner.exe) 30 | 31 | -------------------------------------------------------------------------------- /DuiLib/Core/UIDlgBuilder.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIDLGBUILDER_H__ 2 | #define __UIDLGBUILDER_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | 8 | class IDialogBuilderCallback 9 | { 10 | public: 11 | virtual CControlUI* CreateControl(LPCTSTR pstrClass) = 0; 12 | }; 13 | 14 | 15 | class UILIB_API CDialogBuilder 16 | { 17 | public: 18 | CDialogBuilder(); 19 | CControlUI* Create(STRINGorID xml, LPCTSTR type = NULL, IDialogBuilderCallback* pCallback = NULL, 20 | CPaintManagerUI* pManager = NULL, CControlUI* pParent = NULL); 21 | CControlUI* Create(IDialogBuilderCallback* pCallback = NULL, CPaintManagerUI* pManager = NULL, 22 | CControlUI* pParent = NULL); 23 | 24 | CMarkup* GetMarkup(); 25 | 26 | void GetLastErrorMessage(LPTSTR pstrMessage, SIZE_T cchMax) const; 27 | void GetLastErrorLocation(LPTSTR pstrSource, SIZE_T cchMax) const; 28 | private: 29 | CControlUI* _Parse(CMarkupNode* parent, CControlUI* pParent = NULL, CPaintManagerUI* pManager = NULL); 30 | 31 | CMarkup m_xml; 32 | IDialogBuilderCallback* m_pCallback; 33 | LPCTSTR m_pstrtype; 34 | }; 35 | 36 | } // namespace DuiLib 37 | 38 | #endif // __UIDLGBUILDER_H__ 39 | -------------------------------------------------------------------------------- /DuiLib/Control/UISlider.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISLIDER_H__ 2 | #define __UISLIDER_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CSliderUI : public CProgressUI 9 | { 10 | public: 11 | CSliderUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | UINT GetControlFlags() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | 17 | void SetEnabled(bool bEnable = true); 18 | 19 | int GetChangeStep(); 20 | void SetChangeStep(int step); 21 | void SetThumbSize(SIZE szXY); 22 | RECT GetThumbRect() const; 23 | LPCTSTR GetThumbImage() const; 24 | void SetThumbImage(LPCTSTR pStrImage); 25 | LPCTSTR GetThumbHotImage() const; 26 | void SetThumbHotImage(LPCTSTR pStrImage); 27 | LPCTSTR GetThumbPushedImage() const; 28 | void SetThumbPushedImage(LPCTSTR pStrImage); 29 | 30 | void DoEvent(TEventUI& event); 31 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 32 | void PaintStatusImage(HDC hDC); 33 | 34 | protected: 35 | SIZE m_szThumb; 36 | UINT m_uButtonState; 37 | int m_nStep; 38 | 39 | CDuiString m_sThumbImage; 40 | CDuiString m_sThumbHotImage; 41 | CDuiString m_sThumbPushedImage; 42 | 43 | CDuiString m_sImageModify; 44 | }; 45 | } 46 | 47 | #endif // __UISLIDER_H__ -------------------------------------------------------------------------------- /DuiLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # cmake file for duilib 2 | #Author Qi Gao(monkgau@gmail.com) 3 | #Created: 2012/09/16 4 | 5 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} Root_src) 6 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Control Control_src) 7 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Core Core_src) 8 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Layout Layout_src) 9 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Utils Utils_src) 10 | 11 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 12 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Control) 13 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core) 14 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Layout) 15 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Utils) 16 | 17 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 18 | add_library(duilib SHARED ${Control_src} ${Core_src} ${Layout_src} ${Utils_src} ${Root_src}) 19 | 20 | add_definitions(-DUILIB_EXPORTS) 21 | target_link_libraries(duilib riched20 comctl32) 22 | set_target_properties(duilib PROPERTIES OUTPUT_NAME "duilib") 23 | add_custom_command(TARGET duilib POST_BUILD 24 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 25 | ${PROJECT_BINARY_DIR}/lib/duilib.dll ${PROJECT_SOURCE_DIR}/bin/duilib.dll) 26 | -------------------------------------------------------------------------------- /DuiDesigner/DialogDefaultAttribList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | #include "UIProperties.h" 4 | 5 | ////////////////////////////////////////////////////////////////////////// 6 | // CDialogDefaultAttribList dialog 7 | 8 | class CDialogDefaultAttribList : public CDialog 9 | { 10 | DECLARE_DYNAMIC(CDialogDefaultAttribList) 11 | 12 | public: 13 | CDialogDefaultAttribList(CWnd* pParent = NULL); // standard constructor 14 | virtual ~CDialogDefaultAttribList(); 15 | 16 | // Dialog Data 17 | enum { IDD = IDD_DIALOG_DEFAULT_ATTRIB_LIST }; 18 | 19 | private: 20 | CUIProperties m_wndUIProperties; 21 | CPaintManagerUI* m_pManager; 22 | 23 | protected: 24 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 25 | 26 | DECLARE_MESSAGE_MAP() 27 | protected: 28 | virtual BOOL OnInitDialog(); 29 | BOOL GetDefaultAttrib(CControlUI* pControl, CString& strValue); 30 | 31 | private: 32 | CStatic m_wndUIPropLocation; 33 | CMFCMenuButton m_btnAdd; 34 | CMenu m_menuUI; 35 | CListBox m_lstDefaultAttrib; 36 | public: 37 | afx_msg void OnBnClickedButtonAttribAdd(); 38 | afx_msg void OnBnClickedButtonAttribDelete(); 39 | afx_msg void OnBnClickedButtonAttribModify(); 40 | afx_msg void OnLbnSelchangeListDefaultAttrib(); 41 | afx_msg void OnDestroy(); 42 | afx_msg void OnBnClickedButtonSaveAsStyle(); 43 | }; 44 | -------------------------------------------------------------------------------- /DuiDesigner/GlobalVariable.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "GlobalVariable.h" 3 | 4 | bool CGlobalVariable::m_bIsProjectExist = false; 5 | CString CGlobalVariable::m_strProjectName; 6 | CString CGlobalVariable::m_strProjectPath; 7 | CString CGlobalVariable::m_strCurPath; 8 | CString CGlobalVariable::m_strTemplatesDir; 9 | CString CGlobalVariable::m_strStylesDir; 10 | 11 | CGlobalVariable::CGlobalVariable(void) 12 | { 13 | } 14 | 15 | CGlobalVariable::~CGlobalVariable(void) 16 | { 17 | } 18 | 19 | CString& CGlobalVariable::GetCurPath() 20 | { 21 | if(m_strCurPath.IsEmpty()) 22 | { 23 | TCHAR szFileName[MAX_PATH] = {0}; 24 | ::GetModuleFileName(NULL, szFileName, MAX_PATH); 25 | m_strCurPath = szFileName; 26 | int nPos = m_strCurPath.ReverseFind('\\'); 27 | if(nPos != -1) 28 | m_strCurPath = m_strCurPath.Left(nPos + 1); 29 | } 30 | 31 | return m_strCurPath; 32 | } 33 | 34 | CString& CGlobalVariable::GetTemplatesDir() 35 | { 36 | if(m_strTemplatesDir.IsEmpty()) 37 | { 38 | m_strTemplatesDir = GetCurPath() + DIR_TEMPLATES; 39 | CreateDirectory(m_strTemplatesDir, NULL); 40 | } 41 | 42 | return m_strTemplatesDir; 43 | } 44 | 45 | CString& CGlobalVariable::GetStylesDir() 46 | { 47 | if(m_strStylesDir.IsEmpty()) 48 | { 49 | m_strStylesDir = GetCurPath() + DIR_STYLES; 50 | CreateDirectory(m_strStylesDir, NULL); 51 | } 52 | 53 | return m_strStylesDir; 54 | } -------------------------------------------------------------------------------- /DuiLib/Layout/UIChildLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIChildLayout.h" 3 | 4 | namespace DuiLib 5 | { 6 | CChildLayoutUI::CChildLayoutUI() 7 | { 8 | 9 | } 10 | 11 | void CChildLayoutUI::Init() 12 | { 13 | if (!m_pstrXMLFile.IsEmpty()) 14 | { 15 | CDialogBuilder builder; 16 | CContainerUI* pChildWindow = static_cast(builder.Create(m_pstrXMLFile.GetData(), (UINT)0, NULL, m_pManager)); 17 | if (pChildWindow) 18 | { 19 | this->Add(pChildWindow); 20 | } 21 | else 22 | { 23 | this->RemoveAll(); 24 | } 25 | } 26 | } 27 | 28 | void CChildLayoutUI::SetAttribute( LPCTSTR pstrName, LPCTSTR pstrValue ) 29 | { 30 | if( _tcscmp(pstrName, _T("xmlfile")) == 0 ) 31 | SetChildLayoutXML(pstrValue); 32 | else 33 | CContainerUI::SetAttribute(pstrName,pstrValue); 34 | } 35 | 36 | void CChildLayoutUI::SetChildLayoutXML( DuiLib::CDuiString pXML ) 37 | { 38 | m_pstrXMLFile=pXML; 39 | } 40 | 41 | DuiLib::CDuiString CChildLayoutUI::GetChildLayoutXML() 42 | { 43 | return m_pstrXMLFile; 44 | } 45 | 46 | LPVOID CChildLayoutUI::GetInterface( LPCTSTR pstrName ) 47 | { 48 | if( _tcscmp(pstrName, DUI_CTR_CHILDLAYOUT) == 0 ) return static_cast(this); 49 | return CControlUI::GetInterface(pstrName); 50 | } 51 | 52 | LPCTSTR CChildLayoutUI::GetClass() const 53 | { 54 | return _T("ChildLayoutUI"); 55 | } 56 | } // namespace DuiLib 57 | -------------------------------------------------------------------------------- /DuiDesigner/PropertyTabLayoutUI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | //CSingleCheckListBox 6 | 7 | class CSingleCheckListBox : public CCheckListBox 8 | { 9 | DECLARE_DYNAMIC(CSingleCheckListBox) 10 | 11 | public: 12 | static int m_nLastChecked; 13 | 14 | protected: 15 | //{{AFX_MSG(CSingleCheckListBox) 16 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point); 17 | afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); 18 | afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); 19 | //}}AFX_MSG 20 | DECLARE_MESSAGE_MAP() 21 | }; 22 | 23 | ////////////////////////////////////////////////////////////////////////// 24 | // CPropertyTabLayoutUI Dialog 25 | 26 | class CPropertyTabLayoutUI : public CDialog 27 | { 28 | DECLARE_DYNAMIC(CPropertyTabLayoutUI) 29 | 30 | public: 31 | CPropertyTabLayoutUI(CControlUI* const pControl,CWnd* pParent = NULL); // standard constructor 32 | virtual ~CPropertyTabLayoutUI(); 33 | 34 | // Dialog Data 35 | enum { IDD = IDD_PROPERTY_TABLAYOUTUI }; 36 | 37 | private: 38 | CSingleCheckListBox m_lstTab; 39 | CMFCMenuButton m_btnAdd; 40 | CMenu m_menuUI; 41 | 42 | CTabLayoutUI* m_pTablayoutUI; 43 | 44 | protected: 45 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 46 | 47 | DECLARE_MESSAGE_MAP() 48 | public: 49 | virtual BOOL OnInitDialog(); 50 | afx_msg void OnBnClickedButtonTabLayoutUIAdd(); 51 | afx_msg void OnBnClickedOk(); 52 | }; 53 | -------------------------------------------------------------------------------- /DuiLib/Control/UIOption.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIOPTION_H__ 2 | #define __UIOPTION_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API COptionUI : public CButtonUI 9 | { 10 | public: 11 | COptionUI(); 12 | ~COptionUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | 17 | void SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit = true); 18 | 19 | bool Activate(); 20 | void SetEnabled(bool bEnable = true); 21 | 22 | LPCTSTR GetSelectedImage(); 23 | void SetSelectedImage(LPCTSTR pStrImage); 24 | 25 | LPCTSTR GetSelectedHotImage(); 26 | void SetSelectedHotImage(LPCTSTR pStrImage); 27 | 28 | void SetSelectedTextColor(DWORD dwTextColor); 29 | DWORD GetSelectedTextColor(); 30 | 31 | void SetSelectedBkColor(DWORD dwBkColor); 32 | DWORD GetSelectBkColor(); 33 | 34 | LPCTSTR GetForeImage(); 35 | void SetForeImage(LPCTSTR pStrImage); 36 | 37 | LPCTSTR GetGroup() const; 38 | void SetGroup(LPCTSTR pStrGroupName = NULL); 39 | bool IsSelected() const; 40 | virtual void Selected(bool bSelected); 41 | 42 | SIZE EstimateSize(SIZE szAvailable); 43 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 44 | 45 | void PaintStatusImage(HDC hDC); 46 | void PaintText(HDC hDC); 47 | 48 | protected: 49 | bool m_bSelected; 50 | CDuiString m_sGroupName; 51 | 52 | DWORD m_dwSelectedBkColor; 53 | DWORD m_dwSelectedTextColor; 54 | 55 | CDuiString m_sSelectedImage; 56 | CDuiString m_sSelectedHotImage; 57 | CDuiString m_sForeImage; 58 | }; 59 | 60 | } // namespace DuiLib 61 | 62 | #endif // __UIOPTION_H__ -------------------------------------------------------------------------------- /DuiDesigner.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiDesigner", "DuiDesigner\DuiDesigner.vcxproj", "{8CC28A8B-CD88-44A7-8994-066CCD8938CB}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiLib", "DuiLib\DuiLib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | UnicodeDebug|Win32 = UnicodeDebug|Win32 13 | UnicodeRelease|Win32 = UnicodeRelease|Win32 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {8CC28A8B-CD88-44A7-8994-066CCD8938CB}.UnicodeDebug|Win32.ActiveCfg = UnicodeDebug|Win32 17 | {8CC28A8B-CD88-44A7-8994-066CCD8938CB}.UnicodeDebug|Win32.Build.0 = UnicodeDebug|Win32 18 | {8CC28A8B-CD88-44A7-8994-066CCD8938CB}.UnicodeRelease|Win32.ActiveCfg = UnicodeRelease|Win32 19 | {8CC28A8B-CD88-44A7-8994-066CCD8938CB}.UnicodeRelease|Win32.Build.0 = UnicodeRelease|Win32 20 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|Win32.ActiveCfg = UnicodeDebug|Win32 21 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|Win32.Build.0 = UnicodeDebug|Win32 22 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|Win32.ActiveCfg = UnicodeRelease|Win32 23 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|Win32.Build.0 = UnicodeRelease|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /DuiDesigner/ResourceView.h: -------------------------------------------------------------------------------- 1 | // This is a part of the Microsoft Foundation Classes C++ library. 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // This source code is only intended as a supplement to the 5 | // Microsoft Foundation Classes Reference and related 6 | // electronic documentation provided with the library. 7 | // See these sources for detailed information regarding the 8 | // Microsoft Foundation Classes product. 9 | 10 | #pragma once 11 | 12 | class CResourceViewBar : public CDockablePane 13 | { 14 | // Construction 15 | public: 16 | CResourceViewBar(); 17 | 18 | // Attributes 19 | protected: 20 | CViewTree m_wndResourceView; 21 | CImageList m_ResourceViewImages; 22 | 23 | public: 24 | void OnChangeVisualStyle(); 25 | 26 | void InsertImageTree(CString strTitle, CString strPath); 27 | void RemoveImageTree(CString strTree); 28 | void RenameImageTree(LPCTSTR pstrTree, LPCTSTR pstrNewName); 29 | void InsertImage(CString strImage, CString strTree); 30 | const CStringArray* GetImageTree(CString strTree) const; 31 | void CopyImageToSkinDir(LPCTSTR pstrSkinDir, LPCTSTR pstrTree); 32 | 33 | protected: 34 | void InitResourceView(); 35 | 36 | private: 37 | CMapStringToPtr m_mapTree; 38 | CMapStringToPtr m_mapImageArray; 39 | 40 | // Implementation 41 | public: 42 | virtual ~CResourceViewBar(); 43 | 44 | protected: 45 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 46 | afx_msg void OnSize(UINT nType, int cx, int cy); 47 | afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); 48 | afx_msg void OnEditCut(); 49 | afx_msg void OnEditCopy(); 50 | afx_msg void OnEditPaste(); 51 | afx_msg void OnEditClear(); 52 | afx_msg void OnPaint(); 53 | afx_msg void OnSetFocus(CWnd* pOldWnd); 54 | 55 | DECLARE_MESSAGE_MAP() 56 | }; 57 | 58 | -------------------------------------------------------------------------------- /DuiLib/Control/UIButton.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIBUTTON_H__ 2 | #define __UIBUTTON_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CButtonUI : public CLabelUI 9 | { 10 | public: 11 | CButtonUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | UINT GetControlFlags() const; 16 | 17 | bool Activate(); 18 | void SetEnabled(bool bEnable = true); 19 | void DoEvent(TEventUI& event); 20 | 21 | LPCTSTR GetNormalImage(); 22 | void SetNormalImage(LPCTSTR pStrImage); 23 | LPCTSTR GetHotImage(); 24 | void SetHotImage(LPCTSTR pStrImage); 25 | LPCTSTR GetPushedImage(); 26 | void SetPushedImage(LPCTSTR pStrImage); 27 | LPCTSTR GetFocusedImage(); 28 | void SetFocusedImage(LPCTSTR pStrImage); 29 | LPCTSTR GetDisabledImage(); 30 | void SetDisabledImage(LPCTSTR pStrImage); 31 | LPCTSTR GetForeImage(); 32 | void SetForeImage(LPCTSTR pStrImage); 33 | LPCTSTR GetHotForeImage(); 34 | void SetHotForeImage(LPCTSTR pStrImage); 35 | 36 | void SetHotBkColor(DWORD dwColor); 37 | DWORD GetHotBkColor() const; 38 | void SetHotTextColor(DWORD dwColor); 39 | DWORD GetHotTextColor() const; 40 | void SetPushedTextColor(DWORD dwColor); 41 | DWORD GetPushedTextColor() const; 42 | void SetFocusedTextColor(DWORD dwColor); 43 | DWORD GetFocusedTextColor() const; 44 | SIZE EstimateSize(SIZE szAvailable); 45 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 46 | 47 | void PaintText(HDC hDC); 48 | void PaintStatusImage(HDC hDC); 49 | 50 | protected: 51 | UINT m_uButtonState; 52 | 53 | DWORD m_dwHotBkColor; 54 | DWORD m_dwHotTextColor; 55 | DWORD m_dwPushedTextColor; 56 | DWORD m_dwFocusedTextColor; 57 | 58 | CDuiString m_sNormalImage; 59 | CDuiString m_sHotImage; 60 | CDuiString m_sHotForeImage; 61 | CDuiString m_sPushedImage; 62 | CDuiString m_sPushedForeImage; 63 | CDuiString m_sFocusedImage; 64 | CDuiString m_sDisabledImage; 65 | }; 66 | 67 | } // namespace DuiLib 68 | 69 | #endif // __UIBUTTON_H__ -------------------------------------------------------------------------------- /DuiDesigner/third_party/tinyxml/tinyxmlerror.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any 7 | damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any 10 | purpose, including commercial applications, and to alter it and 11 | redistribute it freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must 14 | not claim that you wrote the original software. If you use this 15 | software in a product, an acknowledgment in the product documentation 16 | would be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and 19 | must not be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | */ 24 | 25 | #include "tinyxml.h" 26 | 27 | // The goal of the seperate error file is to make the first 28 | // step towards localization. tinyxml (currently) only supports 29 | // english error messages, but the could now be translated. 30 | // 31 | // It also cleans up the code a bit. 32 | // 33 | 34 | const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = 35 | { 36 | "No error", 37 | "Error", 38 | "Failed to open file", 39 | "Memory allocation failed.", 40 | "Error parsing Element.", 41 | "Failed to read Element name", 42 | "Error reading Element value.", 43 | "Error reading Attributes.", 44 | "Error: empty tag.", 45 | "Error reading end tag.", 46 | "Error parsing Unknown.", 47 | "Error parsing Comment.", 48 | "Error parsing Declaration.", 49 | "Error document empty.", 50 | "Error null (0) or unexpected EOF found in input stream.", 51 | "Error parsing CDATA.", 52 | "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", 53 | }; 54 | -------------------------------------------------------------------------------- /DuiLib/Control/UIActiveX.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIACTIVEX_H__ 2 | #define __UIACTIVEX_H__ 3 | 4 | #pragma once 5 | 6 | struct IOleObject; 7 | 8 | 9 | namespace DuiLib { 10 | ///////////////////////////////////////////////////////////////////////////////////// 11 | // 12 | 13 | class CActiveXCtrl; 14 | 15 | template< class T > 16 | class CSafeRelease 17 | { 18 | public: 19 | CSafeRelease(T* p) : m_p(p) { }; 20 | ~CSafeRelease() { if( m_p != NULL ) m_p->Release(); }; 21 | T* Detach() { T* t = m_p; m_p = NULL; return t; }; 22 | T* m_p; 23 | }; 24 | 25 | ///////////////////////////////////////////////////////////////////////////////////// 26 | // 27 | 28 | class UILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI 29 | { 30 | friend class CActiveXCtrl; 31 | public: 32 | CActiveXUI(); 33 | virtual ~CActiveXUI(); 34 | 35 | LPCTSTR GetClass() const; 36 | LPVOID GetInterface(LPCTSTR pstrName); 37 | 38 | HWND GetHostWindow() const; 39 | 40 | bool IsDelayCreate() const; 41 | void SetDelayCreate(bool bDelayCreate = true); 42 | 43 | bool CreateControl(const CLSID clsid); 44 | bool CreateControl(LPCTSTR pstrCLSID); 45 | HRESULT GetControl(const IID iid, LPVOID* ppRet); 46 | CLSID GetClisd() const; 47 | CDuiString GetModuleName() const; 48 | void SetModuleName(LPCTSTR pstrText); 49 | 50 | void SetVisible(bool bVisible = true); 51 | void SetInternVisible(bool bVisible = true); 52 | void SetPos(RECT rc); 53 | void DoPaint(HDC hDC, const RECT& rcPaint); 54 | 55 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 56 | 57 | LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled); 58 | 59 | protected: 60 | virtual void ReleaseControl(); 61 | virtual bool DoCreateControl(); 62 | 63 | protected: 64 | CLSID m_clsid; 65 | CDuiString m_sModuleName; 66 | bool m_bCreated; 67 | bool m_bDelayCreate; 68 | IOleObject* m_pUnk; 69 | CActiveXCtrl* m_pControl; 70 | HWND m_hwndHost; 71 | }; 72 | 73 | } // namespace DuiLib 74 | 75 | #endif // __UIACTIVEX_H__ 76 | -------------------------------------------------------------------------------- /DuiLib/Control/UIEdit.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIEDIT_H__ 2 | #define __UIEDIT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class CEditWnd; 9 | 10 | class UILIB_API CEditUI : public CLabelUI 11 | { 12 | friend class CEditWnd; 13 | public: 14 | CEditUI(); 15 | 16 | LPCTSTR GetClass() const; 17 | LPVOID GetInterface(LPCTSTR pstrName); 18 | UINT GetControlFlags() const; 19 | 20 | void SetEnabled(bool bEnable = true); 21 | void SetText(LPCTSTR pstrText); 22 | void SetMaxChar(UINT uMax); 23 | UINT GetMaxChar(); 24 | void SetReadOnly(bool bReadOnly); 25 | bool IsReadOnly() const; 26 | void SetPasswordMode(bool bPasswordMode); 27 | bool IsPasswordMode() const; 28 | void SetPasswordChar(TCHAR cPasswordChar); 29 | TCHAR GetPasswordChar() const; 30 | void SetNumberOnly(bool bNumberOnly); 31 | bool IsNumberOnly() const; 32 | int GetWindowStyls() const; 33 | 34 | LPCTSTR GetNormalImage(); 35 | void SetNormalImage(LPCTSTR pStrImage); 36 | LPCTSTR GetHotImage(); 37 | void SetHotImage(LPCTSTR pStrImage); 38 | LPCTSTR GetFocusedImage(); 39 | void SetFocusedImage(LPCTSTR pStrImage); 40 | LPCTSTR GetDisabledImage(); 41 | void SetDisabledImage(LPCTSTR pStrImage); 42 | void SetNativeEditBkColor(DWORD dwBkColor); 43 | DWORD GetNativeEditBkColor() const; 44 | 45 | void SetSel(long nStartChar, long nEndChar); 46 | void SetSelAll(); 47 | void SetReplaceSel(LPCTSTR lpszReplace); 48 | 49 | void SetPos(RECT rc); 50 | void SetVisible(bool bVisible = true); 51 | void SetInternVisible(bool bVisible = true); 52 | SIZE EstimateSize(SIZE szAvailable); 53 | void DoEvent(TEventUI& event); 54 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 55 | 56 | void PaintStatusImage(HDC hDC); 57 | void PaintText(HDC hDC); 58 | 59 | protected: 60 | CEditWnd* m_pWindow; 61 | 62 | UINT m_uMaxChar; 63 | bool m_bReadOnly; 64 | bool m_bPasswordMode; 65 | TCHAR m_cPasswordChar; 66 | UINT m_uButtonState; 67 | CDuiString m_sNormalImage; 68 | CDuiString m_sHotImage; 69 | CDuiString m_sFocusedImage; 70 | CDuiString m_sDisabledImage; 71 | DWORD m_dwEditbkColor; 72 | int m_iWindowStyls; 73 | }; 74 | } 75 | #endif // __UIEDIT_H__ -------------------------------------------------------------------------------- /DuiDesigner/ImageDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxwin.h" 3 | #include "afxcmn.h" 4 | #include "ImagePreview.h" 5 | 6 | ////////////////////////////////////////////////////////////////////////// 7 | //CMyColorButton 8 | 9 | class CMyColorButton : public CMFCColorButton 10 | { 11 | DECLARE_DYNAMIC(CMyColorButton) 12 | 13 | protected: 14 | virtual void OnDraw(CDC* pDC, const CRect& rect, UINT uiState); 15 | }; 16 | 17 | ////////////////////////////////////////////////////////////////////////// 18 | // CImageDialog dialog 19 | 20 | class CImageDialog : public CDialog 21 | { 22 | DECLARE_DYNAMIC(CImageDialog) 23 | 24 | public: 25 | CImageDialog(const CString& strImageProperty, CWnd* pParent = NULL); 26 | virtual ~CImageDialog(); 27 | 28 | // Dialog Data 29 | enum { IDD = IDD_DIALOG_IMAGE }; 30 | 31 | public: 32 | CString GetImage() const; 33 | 34 | private: 35 | CString m_strImageProperty; 36 | CString m_strImagePathName; 37 | CRect m_rcDest; 38 | CRect m_rcSource; 39 | CRect m_rcCorner; 40 | CPaintManagerUI* m_pManager; 41 | 42 | static const CString m_strNullImage; 43 | CStringArray m_strImageArray; 44 | 45 | protected: 46 | RECT StringToRect(CString& str); 47 | void SetImageProperty(LPCTSTR pstrPathName); 48 | 49 | protected: 50 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 51 | 52 | DECLARE_MESSAGE_MAP() 53 | 54 | protected: 55 | virtual BOOL OnInitDialog(); 56 | CListBox m_lstImages; 57 | CString m_strDest; 58 | CString m_strSource; 59 | CString m_strCorner; 60 | CMyColorButton m_btnMask; 61 | CSliderCtrl m_ctlFade; 62 | int m_nFade; 63 | BOOL m_bHole; 64 | CImagePreview m_ImagePreview; 65 | afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); 66 | afx_msg void OnBnClickedButtonImageImport(); 67 | afx_msg void OnBnClickedButtonImageClear(); 68 | virtual BOOL PreTranslateMessage(MSG* pMsg); 69 | afx_msg void OnEnKillfocusEditImageFade(); 70 | afx_msg void OnLbnDblclkListImageResource(); 71 | afx_msg void OnDestroy(); 72 | afx_msg void OnEnKillfocusEditImageDest(); 73 | afx_msg void OnEnKillfocusEditImageSource(); 74 | afx_msg void OnEnKillfocusEditImageCorner(); 75 | afx_msg void OnBnClickedButtonImageMask(); 76 | afx_msg void OnBnClickedRadioImageHoleFalse(); 77 | afx_msg void OnBnClickedRadioImageHoleTrue(); 78 | afx_msg void OnBnClickedOk(); 79 | }; 80 | -------------------------------------------------------------------------------- /DuiLib/Utils/UIDelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | 3 | namespace DuiLib { 4 | 5 | CDelegateBase::CDelegateBase(void* pObject, void* pFn) 6 | { 7 | m_pObject = pObject; 8 | m_pFn = pFn; 9 | } 10 | 11 | CDelegateBase::CDelegateBase(const CDelegateBase& rhs) 12 | { 13 | m_pObject = rhs.m_pObject; 14 | m_pFn = rhs.m_pFn; 15 | } 16 | 17 | CDelegateBase::~CDelegateBase() 18 | { 19 | 20 | } 21 | 22 | bool CDelegateBase::Equals(const CDelegateBase& rhs) const 23 | { 24 | return m_pObject == rhs.m_pObject && m_pFn == rhs.m_pFn; 25 | } 26 | 27 | bool CDelegateBase::operator() (void* param) 28 | { 29 | return Invoke(param); 30 | } 31 | 32 | void* CDelegateBase::GetFn() 33 | { 34 | return m_pFn; 35 | } 36 | 37 | void* CDelegateBase::GetObject() 38 | { 39 | return m_pObject; 40 | } 41 | 42 | CEventSource::~CEventSource() 43 | { 44 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 45 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 46 | if( pObject) delete pObject; 47 | } 48 | } 49 | 50 | CEventSource::operator bool() 51 | { 52 | return m_aDelegates.GetSize() > 0; 53 | } 54 | 55 | void CEventSource::operator+= (const CDelegateBase& d) 56 | { 57 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 58 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 59 | if( pObject && pObject->Equals(d) ) return; 60 | } 61 | 62 | m_aDelegates.Add(d.Copy()); 63 | } 64 | 65 | void CEventSource::operator+= (FnType pFn) 66 | { 67 | (*this) += MakeDelegate(pFn); 68 | } 69 | 70 | void CEventSource::operator-= (const CDelegateBase& d) 71 | { 72 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 73 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 74 | if( pObject && pObject->Equals(d) ) { 75 | delete pObject; 76 | m_aDelegates.Remove(i); 77 | return; 78 | } 79 | } 80 | } 81 | void CEventSource::operator-= (FnType pFn) 82 | { 83 | (*this) -= MakeDelegate(pFn); 84 | } 85 | 86 | bool CEventSource::operator() (void* param) 87 | { 88 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 89 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 90 | if( pObject && !(*pObject)(param) ) return false; 91 | } 92 | return true; 93 | } 94 | 95 | } // namespace DuiLib 96 | -------------------------------------------------------------------------------- /DuiLib/Utils/UIDelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIDELEGATE_H__ 2 | #define __UIDELEGATE_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | 8 | class UILIB_API CDelegateBase 9 | { 10 | public: 11 | CDelegateBase(void* pObject, void* pFn); 12 | CDelegateBase(const CDelegateBase& rhs); 13 | virtual ~CDelegateBase(); 14 | bool Equals(const CDelegateBase& rhs) const; 15 | bool operator() (void* param); 16 | virtual CDelegateBase* Copy() const = 0; // add const for gcc 17 | 18 | protected: 19 | void* GetFn(); 20 | void* GetObject(); 21 | virtual bool Invoke(void* param) = 0; 22 | 23 | private: 24 | void* m_pObject; 25 | void* m_pFn; 26 | }; 27 | 28 | class CDelegateStatic: public CDelegateBase 29 | { 30 | typedef bool (*Fn)(void*); 31 | public: 32 | CDelegateStatic(Fn pFn) : CDelegateBase(NULL, pFn) { } 33 | CDelegateStatic(const CDelegateStatic& rhs) : CDelegateBase(rhs) { } 34 | virtual CDelegateBase* Copy() const { return new CDelegateStatic(*this); } 35 | 36 | protected: 37 | virtual bool Invoke(void* param) 38 | { 39 | Fn pFn = (Fn)GetFn(); 40 | return (*pFn)(param); 41 | } 42 | }; 43 | 44 | template 45 | class CDelegate : public CDelegateBase 46 | { 47 | typedef bool (T::* Fn)(void*); 48 | public: 49 | CDelegate(O* pObj, Fn pFn) : CDelegateBase(pObj, &pFn), m_pFn(pFn) { } 50 | CDelegate(const CDelegate& rhs) : CDelegateBase(rhs) { m_pFn = rhs.m_pFn; } 51 | virtual CDelegateBase* Copy() const { return new CDelegate(*this); } 52 | 53 | protected: 54 | virtual bool Invoke(void* param) 55 | { 56 | O* pObject = (O*) GetObject(); 57 | return (pObject->*m_pFn)(param); 58 | } 59 | 60 | private: 61 | Fn m_pFn; 62 | }; 63 | 64 | template 65 | CDelegate MakeDelegate(O* pObject, bool (T::* pFn)(void*)) 66 | { 67 | return CDelegate(pObject, pFn); 68 | } 69 | 70 | inline CDelegateStatic MakeDelegate(bool (*pFn)(void*)) 71 | { 72 | return CDelegateStatic(pFn); 73 | } 74 | 75 | class UILIB_API CEventSource 76 | { 77 | typedef bool (*FnType)(void*); 78 | public: 79 | ~CEventSource(); 80 | operator bool(); 81 | void operator+= (const CDelegateBase& d); // add const for gcc 82 | void operator+= (FnType pFn); 83 | void operator-= (const CDelegateBase& d); 84 | void operator-= (FnType pFn); 85 | bool operator() (void* param); 86 | 87 | protected: 88 | CStdPtrArray m_aDelegates; 89 | }; 90 | 91 | } // namespace DuiLib 92 | 93 | #endif // __UIDELEGATE_H__ -------------------------------------------------------------------------------- /DuiLib/UIlib.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010-2011, duilib develop team(www.duilib.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or 5 | // without modification, are permitted provided that the 6 | // following conditions are met. 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // 11 | // Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following 13 | // disclaimer in the documentation and/or other materials 14 | // provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 17 | // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 18 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // 31 | // DirectUI - UI Library 32 | // 33 | // Written by Bjarke Viksoe (bjarke@viksoe.dk) 34 | // Copyright (c) 2006-2007 Bjarke Viksoe. 35 | // 36 | // This code may be used in compiled form in any way you desire. These 37 | // source files may be redistributed by any means PROVIDING it is 38 | // not sold for profit without the authors written consent, and 39 | // providing that this notice and the authors name is included. 40 | // 41 | // This file is provided "as is" with no expressed or implied warranty. 42 | // The author accepts no liability if it causes any damage to you or your 43 | // computer whatsoever. It's free, so don't hassle me about it. 44 | // 45 | // Beware of bugs. 46 | // 47 | // 48 | 49 | 50 | #include "stdafx.h" 51 | #include "UIlib.h" 52 | 53 | 54 | BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID /*lpReserved*/) 55 | { 56 | switch( dwReason ) { 57 | case DLL_PROCESS_ATTACH: 58 | case DLL_THREAD_ATTACH: 59 | case DLL_THREAD_DETACH: 60 | case DLL_PROCESS_DETACH: 61 | ::DisableThreadLibraryCalls((HMODULE)hModule); 62 | break; 63 | } 64 | return TRUE; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /DuiDesigner/UICommandHistory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "UIDesignerView.h" 3 | #include "tinyxml.h" 4 | #include "..\DuiLib\UIlib.h" 5 | using DuiLib::CContainerUI; 6 | 7 | enum CommandType 8 | { 9 | cmdUndo, 10 | cmdRedo, 11 | }; 12 | enum ActionType 13 | { 14 | actionAdd, 15 | actionDelete, 16 | actionModify, 17 | }; 18 | 19 | ////////////////////////////////////////////////////////////////////////// 20 | //CUICommandElement 21 | 22 | class CUICommandNode; 23 | class CUICommandHistory; 24 | 25 | class CUICommandElement 26 | { 27 | friend CUICommandNode; 28 | friend CUICommandHistory; 29 | 30 | public: 31 | CUICommandElement(); 32 | CUICommandElement(CArray& arrSelected, BOOL bModify); 33 | CUICommandElement(const CUICommandElement& copy); 34 | 35 | ~CUICommandElement(); 36 | 37 | protected: 38 | TiXmlElement* m_pElementXml; 39 | }; 40 | 41 | ////////////////////////////////////////////////////////////////////////// 42 | //CUICommandNode 43 | 44 | class CUICommandHistory; 45 | 46 | class CUICommandNode 47 | { 48 | friend CUICommandHistory; 49 | 50 | public: 51 | CUICommandNode(ActionType type); 52 | CUICommandNode(CUICommandElement* pBefore, CUICommandElement* pAfter, ActionType type); 53 | 54 | ~CUICommandNode(); 55 | 56 | public: 57 | void Begin(CArray& arrSelected); 58 | void Begin(CControlUI* pControl, LPCTSTR pstrName, LPCTSTR pstrValue); 59 | void End(); 60 | void End(CControlUI* pControl, LPCTSTR pstrName, LPCTSTR pstrValue); 61 | 62 | protected: 63 | BOOL RemoveSameProperties(TiXmlNode* pBeforeElem, TiXmlNode* pAfterElem); 64 | inline void RemoveSameProperty(TiXmlNode* pBeforeElem, TiXmlNode* pAfterElem); 65 | 66 | protected: 67 | ActionType m_ActionType; 68 | CUICommandElement* m_pBefore; 69 | CUICommandElement* m_pAfter; 70 | CArray* m_pAllSelected; 71 | CControlUI* m_pControl; 72 | }; 73 | 74 | ////////////////////////////////////////////////////////////////////////// 75 | //CUICommandHistory 76 | 77 | typedef void (CALLBACK* UIACTIONPROC)(TiXmlNode*); 78 | 79 | class CUICommandHistory 80 | { 81 | public: 82 | CUICommandHistory(void); 83 | ~CUICommandHistory(void); 84 | 85 | public: 86 | void Begin(CArray& arrSelected, ActionType type); 87 | void Begin(CControlUI* pControl, LPCTSTR pstrName, LPCTSTR pstrValue); 88 | void End(); 89 | void End(CControlUI* pControl, LPCTSTR pstrName, LPCTSTR pstrValue); 90 | 91 | void Undo(); 92 | void Redo(); 93 | BOOL CanUndo(); 94 | BOOL CanRedo(); 95 | 96 | protected: 97 | BOOL AddUICommand(CUICommandNode* pNode); 98 | void UICommandAction(CommandType type); 99 | 100 | void ActionAdd(CUICommandElement* pAfter); 101 | void ActionModify(CUICommandElement* pAfter); 102 | void ActionDelete(CUICommandElement* pBefore); 103 | void SetUIAction(TiXmlNode* pElement, UIACTIONPROC Proc); 104 | 105 | private: 106 | static void CALLBACK UIAdd(TiXmlNode* pNode); 107 | static void CALLBACK UIModify(TiXmlNode* pNode); 108 | static void CALLBACK UIDelete(TiXmlNode* pNode); 109 | 110 | private: 111 | CUICommandNode* m_pNode; 112 | int m_nCommandIndex; 113 | CList m_lstCommandNodes; 114 | }; -------------------------------------------------------------------------------- /DuiLib/Core/UIMarkup.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIMARKUP_H__ 2 | #define __UIMARKUP_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | 8 | enum 9 | { 10 | XMLFILE_ENCODING_UTF8 = 0, 11 | XMLFILE_ENCODING_UNICODE = 1, 12 | XMLFILE_ENCODING_ASNI = 2, 13 | }; 14 | 15 | class CMarkup; 16 | class CMarkupNode; 17 | 18 | 19 | class UILIB_API CMarkup 20 | { 21 | friend class CMarkupNode; 22 | public: 23 | CMarkup(LPCTSTR pstrXML = NULL); 24 | ~CMarkup(); 25 | 26 | bool Load(LPCTSTR pstrXML); 27 | bool LoadFromMem(BYTE* pByte, DWORD dwSize, int encoding = XMLFILE_ENCODING_UTF8); 28 | bool LoadFromFile(LPCTSTR pstrFilename, int encoding = XMLFILE_ENCODING_UTF8); 29 | void Release(); 30 | bool IsValid() const; 31 | 32 | void SetPreserveWhitespace(bool bPreserve = true); 33 | void GetLastErrorMessage(LPTSTR pstrMessage, SIZE_T cchMax) const; 34 | void GetLastErrorLocation(LPTSTR pstrSource, SIZE_T cchMax) const; 35 | 36 | CMarkupNode GetRoot(); 37 | 38 | private: 39 | typedef struct tagXMLELEMENT 40 | { 41 | ULONG iStart; 42 | ULONG iChild; 43 | ULONG iNext; 44 | ULONG iParent; 45 | ULONG iData; 46 | } XMLELEMENT; 47 | 48 | LPTSTR m_pstrXML; 49 | XMLELEMENT* m_pElements; 50 | ULONG m_nElements; 51 | ULONG m_nReservedElements; 52 | TCHAR m_szErrorMsg[100]; 53 | TCHAR m_szErrorXML[50]; 54 | bool m_bPreserveWhitespace; 55 | 56 | private: 57 | bool _Parse(); 58 | bool _Parse(LPTSTR& pstrText, ULONG iParent); 59 | XMLELEMENT* _ReserveElement(); 60 | inline void _SkipWhitespace(LPTSTR& pstr) const; 61 | inline void _SkipWhitespace(LPCTSTR& pstr) const; 62 | inline void _SkipIdentifier(LPTSTR& pstr) const; 63 | inline void _SkipIdentifier(LPCTSTR& pstr) const; 64 | bool _ParseData(LPTSTR& pstrText, LPTSTR& pstrData, char cEnd); 65 | void _ParseMetaChar(LPTSTR& pstrText, LPTSTR& pstrDest); 66 | bool _ParseAttributes(LPTSTR& pstrText); 67 | bool _Failed(LPCTSTR pstrError, LPCTSTR pstrLocation = NULL); 68 | }; 69 | 70 | 71 | class UILIB_API CMarkupNode 72 | { 73 | friend class CMarkup; 74 | private: 75 | CMarkupNode(); 76 | CMarkupNode(CMarkup* pOwner, int iPos); 77 | 78 | public: 79 | bool IsValid() const; 80 | 81 | CMarkupNode GetParent(); 82 | CMarkupNode GetSibling(); 83 | CMarkupNode GetChild(); 84 | CMarkupNode GetChild(LPCTSTR pstrName); 85 | 86 | bool HasSiblings() const; 87 | bool HasChildren() const; 88 | LPCTSTR GetName() const; 89 | LPCTSTR GetValue() const; 90 | 91 | bool HasAttributes(); 92 | bool HasAttribute(LPCTSTR pstrName); 93 | int GetAttributeCount(); 94 | LPCTSTR GetAttributeName(int iIndex); 95 | LPCTSTR GetAttributeValue(int iIndex); 96 | LPCTSTR GetAttributeValue(LPCTSTR pstrName); 97 | bool GetAttributeValue(int iIndex, LPTSTR pstrValue, SIZE_T cchMax); 98 | bool GetAttributeValue(LPCTSTR pstrName, LPTSTR pstrValue, SIZE_T cchMax); 99 | 100 | private: 101 | void _MapAttributes(); 102 | 103 | enum { MAX_XML_ATTRIBUTES = 64 }; 104 | 105 | typedef struct 106 | { 107 | ULONG iName; 108 | ULONG iValue; 109 | } XMLATTRIBUTE; 110 | 111 | int m_iPos; 112 | int m_nAttributes; 113 | XMLATTRIBUTE m_aAttributes[MAX_XML_ATTRIBUTES]; 114 | CMarkup* m_pOwner; 115 | }; 116 | 117 | } // namespace DuiLib 118 | 119 | #endif // __UIMARKUP_H__ 120 | -------------------------------------------------------------------------------- /DuiLib/Control/UILabel.h: -------------------------------------------------------------------------------- 1 | #ifndef __UILABEL_H__ 2 | #define __UILABEL_H__ 3 | 4 | #pragma once 5 | 6 | #include 7 | #pragma comment( lib, "GdiPlus.lib" ) 8 | using namespace Gdiplus; 9 | class UILIB_API Gdiplus::RectF; 10 | struct UILIB_API Gdiplus::GdiplusStartupInput; 11 | 12 | namespace DuiLib 13 | { 14 | class UILIB_API CLabelUI : public CControlUI 15 | { 16 | public: 17 | CLabelUI(); 18 | ~CLabelUI(); 19 | 20 | LPCTSTR GetClass() const; 21 | LPVOID GetInterface(LPCTSTR pstrName); 22 | 23 | void SetTextStyle(UINT uStyle); 24 | UINT GetTextStyle() const; 25 | void SetTextColor(DWORD dwTextColor); 26 | DWORD GetTextColor() const; 27 | void SetDisabledTextColor(DWORD dwTextColor); 28 | DWORD GetDisabledTextColor() const; 29 | void SetFont(int index); 30 | int GetFont() const; 31 | RECT GetTextPadding() const; 32 | void SetTextPadding(RECT rc); 33 | bool IsShowHtml(); 34 | void SetShowHtml(bool bShowHtml = true); 35 | 36 | SIZE EstimateSize(SIZE szAvailable); 37 | void DoEvent(TEventUI& event); 38 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 39 | 40 | void PaintText(HDC hDC); 41 | 42 | void SetEnabledEffect(bool _EnabledEffect); 43 | bool GetEnabledEffect(); 44 | void SetText(LPCTSTR pstrText); 45 | CDuiString GetText() const; 46 | void SetTransShadow(int _TransShadow); 47 | int GetTransShadow(); 48 | void SetTransShadow1(int _TransShadow); 49 | int GetTransShadow1(); 50 | void SetTransText(int _TransText); 51 | int GetTransText(); 52 | void SetTransText1(int _TransText); 53 | int GetTransText1(); 54 | void SetTransStroke(int _TransStroke); 55 | int GetTransStroke(); 56 | void SetGradientLength(int _GradientLength); 57 | int GetGradientLength(); 58 | void SetTextRenderingHintAntiAlias(int _TextRenderingHintAntiAlias); 59 | int GetTextRenderingHintAntiAlias(); 60 | void SetShadowOffset(int _offset,int _angle); 61 | RectF GetShadowOffset(); 62 | void SetTextColor1(DWORD _TextColor1); 63 | DWORD GetTextColor1(); 64 | void SetTextShadowColorA(DWORD _TextShadowColorA); 65 | DWORD GetTextShadowColorA(); 66 | void SetTextShadowColorB(DWORD _TextShadowColorB); 67 | DWORD GetTextShadowColorB(); 68 | void SetStrokeColor(DWORD _StrokeColor); 69 | DWORD GetStrokeColor(); 70 | void SetGradientAngle(int _SetGradientAngle); 71 | int GetGradientAngle(); 72 | void SetEnabledStroke(bool _EnabledStroke); 73 | bool GetEnabledStroke(); 74 | void SetEnabledShadow(bool _EnabledShadowe); 75 | bool GetEnabledShadow(); 76 | 77 | protected: 78 | DWORD m_dwTextColor; 79 | DWORD m_dwDisabledTextColor; 80 | int m_iFont; 81 | UINT m_uTextStyle; 82 | RECT m_rcTextPadding; 83 | bool m_bShowHtml; 84 | 85 | int m_hAlign; 86 | int m_vAlign; 87 | int m_TransShadow; 88 | int m_TransShadow1; 89 | int m_TransText; 90 | int m_TransText1; 91 | int m_TransStroke; 92 | int m_GradientLength; 93 | int m_GradientAngle; 94 | bool m_EnableEffect; 95 | bool m_EnabledStroke; 96 | bool m_EnabledShadow; 97 | DWORD m_dwTextColor1; 98 | DWORD m_dwTextShadowColorA; 99 | DWORD m_dwTextShadowColorB; 100 | DWORD m_dwStrokeColor; 101 | RectF m_ShadowOffset; 102 | CDuiString m_TextValue; 103 | ULONG_PTR m_gdiplusToken; 104 | GdiplusStartupInput m_gdiplusStartupInput; 105 | TextRenderingHint m_TextRenderingHintAntiAlias; 106 | }; 107 | } 108 | 109 | #endif // __UILABEL_H__ -------------------------------------------------------------------------------- /DuiLib/Control/UIComboBox.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIComboBox.h" 3 | 4 | namespace DuiLib 5 | { 6 | CComboBoxUI::CComboBoxUI() 7 | { 8 | m_nArrowWidth = 0; 9 | } 10 | 11 | LPCTSTR CComboBoxUI::GetClass() const 12 | { 13 | return _T("ComboBoxUI"); 14 | } 15 | 16 | void CComboBoxUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 17 | { 18 | if (_tcscmp(pstrName, _T("arrowimage")) == 0) 19 | m_sArrowImage = pstrValue; 20 | else 21 | CComboUI::SetAttribute(pstrName, pstrValue); 22 | } 23 | 24 | void CComboBoxUI::PaintStatusImage(HDC hDC) 25 | { 26 | if (m_sArrowImage.IsEmpty()) 27 | CComboUI::PaintStatusImage(hDC); 28 | else 29 | { 30 | // get index 31 | if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED; 32 | else m_uButtonState &= ~ UISTATE_FOCUSED; 33 | if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED; 34 | else m_uButtonState &= ~ UISTATE_DISABLED; 35 | 36 | int nIndex = 0; 37 | if ((m_uButtonState & UISTATE_DISABLED) != 0) 38 | nIndex = 4; 39 | else if ((m_uButtonState & UISTATE_PUSHED) != 0) 40 | nIndex = 2; 41 | else if ((m_uButtonState & UISTATE_HOT) != 0) 42 | nIndex = 1; 43 | else if ((m_uButtonState & UISTATE_FOCUSED) != 0) 44 | nIndex = 3; 45 | 46 | // make modify string 47 | CDuiString sModify = m_sArrowImage; 48 | 49 | int nPos1 = sModify.Find(_T("source")); 50 | int nPos2 = sModify.Find(_T("'"), nPos1 + 7); 51 | if (nPos2 == -1) return; //first 52 | int nPos3 = sModify.Find(_T("'"), nPos2 + 1); 53 | if (nPos3 == -1) return; //second 54 | 55 | CDuiRect rcBmpPart; 56 | LPTSTR lpszValue = NULL; 57 | rcBmpPart.left = _tcstol(sModify.GetData() + nPos2 + 1, &lpszValue, 10); ASSERT(lpszValue); 58 | rcBmpPart.top = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); 59 | rcBmpPart.right = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); 60 | rcBmpPart.bottom = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); 61 | 62 | m_nArrowWidth = rcBmpPart.GetWidth() / 5; 63 | rcBmpPart.left += nIndex * m_nArrowWidth; 64 | rcBmpPart.right = rcBmpPart.left + m_nArrowWidth; 65 | 66 | CDuiRect rcDest(0, 0, m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top); 67 | rcDest.Deflate(GetBorderSize(), GetBorderSize()); 68 | rcDest.left = rcDest.right - m_nArrowWidth; 69 | 70 | CDuiString sSource = sModify.Mid(nPos1, nPos3 + 1 - nPos1); 71 | CDuiString sReplace; 72 | sReplace.SmallFormat(_T("source='%d,%d,%d,%d' dest='%d,%d,%d,%d'"), 73 | rcBmpPart.left, rcBmpPart.top, rcBmpPart.right, rcBmpPart.bottom, 74 | rcDest.left, rcDest.top, rcDest.right, rcDest.bottom); 75 | 76 | sModify.Replace(sSource, sReplace); 77 | 78 | // draw image 79 | if (!DrawImage(hDC, m_sArrowImage, sModify)) 80 | m_sNormalImage.Empty(); 81 | } 82 | } 83 | 84 | void CComboBoxUI::PaintText(HDC hDC) 85 | { 86 | RECT rcText = m_rcItem; 87 | rcText.left += m_rcTextPadding.left; 88 | rcText.right -= m_rcTextPadding.right; 89 | rcText.top += m_rcTextPadding.top; 90 | rcText.bottom -= m_rcTextPadding.bottom; 91 | 92 | rcText.right -= m_nArrowWidth; // add this line than CComboUI::PaintText(HDC hDC) 93 | 94 | if( m_iCurSel >= 0 ) { 95 | CControlUI* pControl = static_cast(m_items[m_iCurSel]); 96 | IListItemUI* pElement = static_cast(pControl->GetInterface(_T("ListItem"))); 97 | if( pElement != NULL ) { 98 | pElement->DrawItemText(hDC, rcText); 99 | } 100 | else { 101 | RECT rcOldPos = pControl->GetPos(); 102 | pControl->SetPos(rcText); 103 | pControl->DoPaint(hDC, rcText); 104 | pControl->SetPos(rcOldPos); 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /DuiLib/Control/UIProgress.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIProgress.h" 3 | 4 | namespace DuiLib 5 | { 6 | CProgressUI::CProgressUI() : m_bHorizontal(true), m_nMin(0), m_nMax(100), m_nValue(0), m_bStretchForeImage(true) 7 | { 8 | m_uTextStyle = DT_SINGLELINE | DT_CENTER; 9 | SetFixedHeight(12); 10 | } 11 | 12 | LPCTSTR CProgressUI::GetClass() const 13 | { 14 | return _T("ProgressUI"); 15 | } 16 | 17 | LPVOID CProgressUI::GetInterface(LPCTSTR pstrName) 18 | { 19 | if( _tcscmp(pstrName, DUI_CTR_PROGRESS) == 0 ) return static_cast(this); 20 | return CLabelUI::GetInterface(pstrName); 21 | } 22 | 23 | bool CProgressUI::IsHorizontal() 24 | { 25 | return m_bHorizontal; 26 | } 27 | 28 | void CProgressUI::SetHorizontal(bool bHorizontal) 29 | { 30 | if( m_bHorizontal == bHorizontal ) return; 31 | 32 | m_bHorizontal = bHorizontal; 33 | Invalidate(); 34 | } 35 | 36 | int CProgressUI::GetMinValue() const 37 | { 38 | return m_nMin; 39 | } 40 | 41 | void CProgressUI::SetMinValue(int nMin) 42 | { 43 | m_nMin = nMin; 44 | Invalidate(); 45 | } 46 | 47 | int CProgressUI::GetMaxValue() const 48 | { 49 | return m_nMax; 50 | } 51 | 52 | void CProgressUI::SetMaxValue(int nMax) 53 | { 54 | m_nMax = nMax; 55 | Invalidate(); 56 | } 57 | 58 | int CProgressUI::GetValue() const 59 | { 60 | return m_nValue; 61 | } 62 | 63 | void CProgressUI::SetValue(int nValue) 64 | { 65 | m_nValue = nValue; 66 | Invalidate(); 67 | } 68 | 69 | LPCTSTR CProgressUI::GetForeImage() const 70 | { 71 | return m_sForeImage; 72 | } 73 | 74 | void CProgressUI::SetForeImage(LPCTSTR pStrImage) 75 | { 76 | if( m_sForeImage == pStrImage ) return; 77 | 78 | m_sForeImage = pStrImage; 79 | Invalidate(); 80 | } 81 | 82 | void CProgressUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 83 | { 84 | if( _tcscmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue); 85 | else if( _tcscmp(pstrName, _T("hor")) == 0 ) SetHorizontal(_tcscmp(pstrValue, _T("true")) == 0); 86 | else if( _tcscmp(pstrName, _T("min")) == 0 ) SetMinValue(_ttoi(pstrValue)); 87 | else if( _tcscmp(pstrName, _T("max")) == 0 ) SetMaxValue(_ttoi(pstrValue)); 88 | else if( _tcscmp(pstrName, _T("value")) == 0 ) SetValue(_ttoi(pstrValue)); 89 | else if( _tcscmp(pstrName, _T("isstretchfore"))==0) SetStretchForeImage(_tcscmp(pstrValue, _T("true")) == 0? true : false); 90 | else CLabelUI::SetAttribute(pstrName, pstrValue); 91 | } 92 | 93 | void CProgressUI::PaintStatusImage(HDC hDC) 94 | { 95 | if( m_nMax <= m_nMin ) m_nMax = m_nMin + 1; 96 | if( m_nValue > m_nMax ) m_nValue = m_nMax; 97 | if( m_nValue < m_nMin ) m_nValue = m_nMin; 98 | 99 | RECT rc = {0}; 100 | if( m_bHorizontal ) { 101 | rc.right = (m_nValue - m_nMin) * (m_rcItem.right - m_rcItem.left) / (m_nMax - m_nMin); 102 | rc.bottom = m_rcItem.bottom - m_rcItem.top; 103 | } 104 | else { 105 | rc.top = (m_rcItem.bottom - m_rcItem.top) * (m_nMax - m_nValue) / (m_nMax - m_nMin); 106 | rc.right = m_rcItem.right - m_rcItem.left; 107 | rc.bottom = m_rcItem.bottom - m_rcItem.top; 108 | } 109 | 110 | if( !m_sForeImage.IsEmpty() ) { 111 | m_sForeImageModify.Empty(); 112 | if (m_bStretchForeImage) 113 | m_sForeImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rc.left, rc.top, rc.right, rc.bottom); 114 | else 115 | m_sForeImageModify.SmallFormat(_T("dest='%d,%d,%d,%d' source='%d,%d,%d,%d'") 116 | , rc.left, rc.top, rc.right, rc.bottom 117 | , rc.left, rc.top, rc.right, rc.bottom); 118 | 119 | if( !DrawImage(hDC, (LPCTSTR)m_sForeImage, (LPCTSTR)m_sForeImageModify) ) m_sForeImage.Empty(); 120 | else return; 121 | } 122 | } 123 | 124 | bool CProgressUI::IsStretchForeImage() 125 | { 126 | return m_bStretchForeImage; 127 | } 128 | 129 | void CProgressUI::SetStretchForeImage( bool bStretchForeImage /*= true*/ ) 130 | { 131 | if (m_bStretchForeImage==bStretchForeImage) return; 132 | m_bStretchForeImage=bStretchForeImage; 133 | Invalidate(); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /DuiDesigner/UIUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // DirectUI - UI Library 4 | // 5 | // Written by Bjarke Viksoe (bjarke@viksoe.dk) 6 | // Copyright (c) 2006-2007 Bjarke Viksoe. 7 | // 8 | // This code may be used in compiled form in any way you desire. These 9 | // source files may be redistributed by any means PROVIDING it is 10 | // not sold for profit without the authors written consent, and 11 | // providing that this notice and the authors name is included. 12 | // 13 | // This file is provided "as is" with no expressed or implied warranty. 14 | // The author accepts no liability if it causes any damage to you or your 15 | // computer whatsoever. It's free, so don't hassle me about it. 16 | // 17 | //// 18 | // Acknowledgements : 19 | // Bjarke Viksoe (http://www.viksoe.dk/code/windowless1.htm) 20 | // 21 | // 22 | // 23 | // Beware of bugs. 24 | // 25 | // 26 | // 27 | //////////////////////////////////////////////////////// 28 | #ifndef __UIUTIL_H__ 29 | #define __UIUTIL_H__ 30 | 31 | #ifdef _MSC_VER 32 | #pragma once 33 | #endif 34 | 35 | namespace StringConvertor { 36 | 37 | #pragma warning(disable: 4996) 38 | 39 | LPSTR WideToAnsi(LPCWSTR str, int len = -1); 40 | LPSTR WideToUtf8(LPCWSTR str, int len = -1); 41 | LPWSTR WideStrDup(LPCWSTR str, int len = -1); 42 | 43 | LPWSTR AnsiToWide(LPCSTR str, int len = -1); 44 | __declspec(deprecated) LPSTR AnsiToUtf8(LPCSTR str, int len = -1); 45 | __declspec(deprecated) LPSTR AnsiStrDup(LPCSTR str, int len = -1); 46 | 47 | LPWSTR Utf8ToWide(LPCSTR str, int len = -1); 48 | __declspec(deprecated) LPSTR Utf8ToAnsi(LPCSTR str, int len = -1); 49 | static __inline LPSTR Utf8StrDup(LPCSTR str, int len = -1) { return AnsiStrDup(str, len); } 50 | 51 | //StringAlloc takes the number of characters, not bytes! 52 | __declspec(deprecated) LPWSTR StringAllocW(size_t len); 53 | __declspec(deprecated) LPSTR StringAllocA(size_t len); 54 | void StringFree(LPWSTR str); 55 | void StringFree(LPSTR str); 56 | 57 | #define StringFreeW StringFree 58 | #define StringFreeA StringFree 59 | 60 | #ifdef UNICODE 61 | static __declspec(deprecated) __inline LPTSTR WideToTchar(LPCWSTR str, int len = -1) { return WideStrDup(str, len); } 62 | static __declspec(deprecated) __inline LPTSTR AnsiToTchar(LPCSTR str, int len = -1) { return AnsiToWide(str, len); } 63 | static __declspec(deprecated) __inline LPTSTR Utf8ToTchar(LPCSTR str, int len = -1) { return Utf8ToWide(str, len); } 64 | static __declspec(deprecated) __inline LPWSTR TcharToWide(LPCTSTR str, int len = -1) { return WideStrDup(str, len); } 65 | static __declspec(deprecated) __inline LPSTR TcharToAnsi(LPCTSTR str, int len = -1) { return WideToAnsi(str, len); } 66 | static __declspec(deprecated) __inline LPSTR TcharToUtf8(LPCTSTR str, int len = -1) { return WideToUtf8(str, len); } 67 | static __declspec(deprecated) __inline LPTSTR TcharStrDup(LPCTSTR str, int len = -1) { return WideStrDup(str, len); } 68 | static __declspec(deprecated) __inline LPTSTR StringAlloc(size_t len) { return StringAllocW(len); } 69 | #else 70 | static __declspec(deprecated) __inline LPTSTR WideToTchar(LPCWSTR str, int len = -1) { return WideToAnsi(str, len); } 71 | static __declspec(deprecated) __inline LPTSTR AnsiToTchar(LPCSTR str, int len = -1) { return AnsiStrDup(str, len); } 72 | static __declspec(deprecated) __inline LPTSTR Utf8ToTchar(LPCSTR str, int len = -1) { return Utf8ToAnsi(str, len); } 73 | static __declspec(deprecated) __inline LPWSTR TcharToWide(LPCTSTR str, int len = -1) { return AnsiToWide(str, len); } 74 | static __declspec(deprecated) __inline LPSTR TcharToAnsi(LPCTSTR str, int len = -1) { return AnsiStrDup(str, len); } 75 | static __declspec(deprecated) __inline LPSTR TcharToUtf8(LPCTSTR str, int len = -1) { return AnsiToUtf8(str, len); } 76 | static __declspec(deprecated) __inline LPTSTR TcharStrDup(LPCTSTR str, int len = -1) { return AnsiStrDup(str, len); } 77 | static __declspec(deprecated) __inline LPTSTR StringAlloc(size_t len) { return StringAllocA(len); } 78 | #endif 79 | 80 | #pragma warning(default: 4996) 81 | 82 | } // namespace StringConvertor 83 | 84 | #endif //__UIUTIL_H__ 85 | -------------------------------------------------------------------------------- /DuiLib/Control/UICombo.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICOMBO_H__ 2 | #define __UICOMBO_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | ///////////////////////////////////////////////////////////////////////////////////// 8 | // 9 | 10 | class CComboWnd; 11 | 12 | class UILIB_API CComboUI : public CContainerUI, public IListOwnerUI 13 | { 14 | friend class CComboWnd; 15 | public: 16 | CComboUI(); 17 | 18 | LPCTSTR GetClass() const; 19 | LPVOID GetInterface(LPCTSTR pstrName); 20 | 21 | void DoInit(); 22 | UINT GetControlFlags() const; 23 | 24 | CDuiString GetText() const; 25 | void SetEnabled(bool bEnable = true); 26 | 27 | CDuiString GetDropBoxAttributeList(); 28 | void SetDropBoxAttributeList(LPCTSTR pstrList); 29 | SIZE GetDropBoxSize() const; 30 | void SetDropBoxSize(SIZE szDropBox); 31 | 32 | int GetCurSel() const; 33 | bool SelectItem(int iIndex, bool bTakeFocus = false); 34 | 35 | bool SetItemIndex(CControlUI* pControl, int iIndex); 36 | bool Add(CControlUI* pControl); 37 | bool AddAt(CControlUI* pControl, int iIndex); 38 | bool Remove(CControlUI* pControl); 39 | bool RemoveAt(int iIndex); 40 | void RemoveAll(); 41 | 42 | bool Activate(); 43 | 44 | RECT GetTextPadding() const; 45 | void SetTextPadding(RECT rc); 46 | LPCTSTR GetNormalImage() const; 47 | void SetNormalImage(LPCTSTR pStrImage); 48 | LPCTSTR GetHotImage() const; 49 | void SetHotImage(LPCTSTR pStrImage); 50 | LPCTSTR GetPushedImage() const; 51 | void SetPushedImage(LPCTSTR pStrImage); 52 | LPCTSTR GetFocusedImage() const; 53 | void SetFocusedImage(LPCTSTR pStrImage); 54 | LPCTSTR GetDisabledImage() const; 55 | void SetDisabledImage(LPCTSTR pStrImage); 56 | 57 | TListInfoUI* GetListInfo(); 58 | void SetItemFont(int index); 59 | void SetItemTextStyle(UINT uStyle); 60 | RECT GetItemTextPadding() const; 61 | void SetItemTextPadding(RECT rc); 62 | DWORD GetItemTextColor() const; 63 | void SetItemTextColor(DWORD dwTextColor); 64 | DWORD GetItemBkColor() const; 65 | void SetItemBkColor(DWORD dwBkColor); 66 | LPCTSTR GetItemBkImage() const; 67 | void SetItemBkImage(LPCTSTR pStrImage); 68 | bool IsAlternateBk() const; 69 | void SetAlternateBk(bool bAlternateBk); 70 | DWORD GetSelectedItemTextColor() const; 71 | void SetSelectedItemTextColor(DWORD dwTextColor); 72 | DWORD GetSelectedItemBkColor() const; 73 | void SetSelectedItemBkColor(DWORD dwBkColor); 74 | LPCTSTR GetSelectedItemImage() const; 75 | void SetSelectedItemImage(LPCTSTR pStrImage); 76 | DWORD GetHotItemTextColor() const; 77 | void SetHotItemTextColor(DWORD dwTextColor); 78 | DWORD GetHotItemBkColor() const; 79 | void SetHotItemBkColor(DWORD dwBkColor); 80 | LPCTSTR GetHotItemImage() const; 81 | void SetHotItemImage(LPCTSTR pStrImage); 82 | DWORD GetDisabledItemTextColor() const; 83 | void SetDisabledItemTextColor(DWORD dwTextColor); 84 | DWORD GetDisabledItemBkColor() const; 85 | void SetDisabledItemBkColor(DWORD dwBkColor); 86 | LPCTSTR GetDisabledItemImage() const; 87 | void SetDisabledItemImage(LPCTSTR pStrImage); 88 | DWORD GetItemLineColor() const; 89 | void SetItemLineColor(DWORD dwLineColor); 90 | bool IsItemShowHtml(); 91 | void SetItemShowHtml(bool bShowHtml = true); 92 | 93 | SIZE EstimateSize(SIZE szAvailable); 94 | void SetPos(RECT rc); 95 | void DoEvent(TEventUI& event); 96 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 97 | 98 | void DoPaint(HDC hDC, const RECT& rcPaint); 99 | void PaintText(HDC hDC); 100 | void PaintStatusImage(HDC hDC); 101 | 102 | protected: 103 | CComboWnd* m_pWindow; 104 | 105 | int m_iCurSel; 106 | RECT m_rcTextPadding; 107 | CDuiString m_sDropBoxAttributes; 108 | SIZE m_szDropBox; 109 | UINT m_uButtonState; 110 | 111 | CDuiString m_sNormalImage; 112 | CDuiString m_sHotImage; 113 | CDuiString m_sPushedImage; 114 | CDuiString m_sFocusedImage; 115 | CDuiString m_sDisabledImage; 116 | 117 | TListInfoUI m_ListInfo; 118 | }; 119 | 120 | } // namespace DuiLib 121 | 122 | #endif // __UICOMBO_H__ 123 | -------------------------------------------------------------------------------- /DuiLib/UIlib.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010-2011, duilib develop team(www.duilib.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or 5 | // without modification, are permitted provided that the 6 | // following conditions are met. 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // 11 | // Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following 13 | // disclaimer in the documentation and/or other materials 14 | // provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 17 | // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 18 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #if defined(UILIB_EXPORTS) 31 | #if defined(_MSC_VER) 32 | #define UILIB_API __declspec(dllexport) 33 | #else 34 | #define UILIB_API 35 | #endif 36 | #else 37 | #if defined(_MSC_VER) 38 | #define UILIB_API __declspec(dllimport) 39 | #else 40 | #define UILIB_API 41 | #endif 42 | #endif 43 | 44 | #define UILIB_COMDAT __declspec(selectany) 45 | 46 | #if defined _M_IX86 47 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 48 | #elif defined _M_IA64 49 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") 50 | #elif defined _M_X64 51 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 52 | #else 53 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 54 | #endif 55 | 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | 66 | #include "Utils/Utils.h" 67 | #include "Utils/UIDelegate.h" 68 | #include "Core/UIDefine.h" 69 | #include "Core/UIManager.h" 70 | #include "Core/UIBase.h" 71 | #include "Core/UIControl.h" 72 | #include "Core/UIContainer.h" 73 | #include "Core/UIMarkup.h" 74 | #include "Core/UIDlgBuilder.h" 75 | #include "Core/UIRender.h" 76 | #include "Utils/WinImplBase.h" 77 | 78 | #include "Layout/UIVerticalLayout.h" 79 | #include "Layout/UIHorizontalLayout.h" 80 | #include "Layout/UITileLayout.h" 81 | #include "Layout/UITabLayout.h" 82 | #include "Layout/UIChildLayout.h" 83 | 84 | #include "Control/UIList.h" 85 | #include "Control/UICombo.h" 86 | #include "Control/UIScrollBar.h" 87 | #include "Control/UITreeView.h" 88 | 89 | #include "Control/UILabel.h" 90 | #include "Control/UIText.h" 91 | #include "Control/UIEdit.h" 92 | 93 | #include "Control/UIButton.h" 94 | #include "Control/UIOption.h" 95 | #include "Control/UICheckBox.h" 96 | 97 | #include "Control/UIProgress.h" 98 | #include "Control/UISlider.h" 99 | 100 | #include "Control/UIComboBox.h" 101 | #include "Control/UIRichEdit.h" 102 | #include "Control/UIDateTime.h" 103 | 104 | #include "Control/UIActiveX.h" 105 | #include "Control/UIWebBrowser.h" 106 | //#include "Control/UIFlash.h" 107 | 108 | -------------------------------------------------------------------------------- /DuiLib/Control/UIScrollBar.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISCROLLBAR_H__ 2 | #define __UISCROLLBAR_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CScrollBarUI : public CControlUI 9 | { 10 | public: 11 | CScrollBarUI(); 12 | 13 | LPCTSTR GetClass() const; 14 | LPVOID GetInterface(LPCTSTR pstrName); 15 | 16 | CContainerUI* GetOwner() const; 17 | void SetOwner(CContainerUI* pOwner); 18 | 19 | void SetVisible(bool bVisible = true); 20 | void SetEnabled(bool bEnable = true); 21 | void SetFocus(); 22 | 23 | bool IsHorizontal(); 24 | void SetHorizontal(bool bHorizontal = true); 25 | int GetScrollRange() const; 26 | void SetScrollRange(int nRange); 27 | int GetScrollPos() const; 28 | void SetScrollPos(int nPos); 29 | int GetLineSize() const; 30 | void SetLineSize(int nSize); 31 | 32 | bool GetShowButton1(); 33 | void SetShowButton1(bool bShow); 34 | LPCTSTR GetButton1NormalImage(); 35 | void SetButton1NormalImage(LPCTSTR pStrImage); 36 | LPCTSTR GetButton1HotImage(); 37 | void SetButton1HotImage(LPCTSTR pStrImage); 38 | LPCTSTR GetButton1PushedImage(); 39 | void SetButton1PushedImage(LPCTSTR pStrImage); 40 | LPCTSTR GetButton1DisabledImage(); 41 | void SetButton1DisabledImage(LPCTSTR pStrImage); 42 | 43 | bool GetShowButton2(); 44 | void SetShowButton2(bool bShow); 45 | LPCTSTR GetButton2NormalImage(); 46 | void SetButton2NormalImage(LPCTSTR pStrImage); 47 | LPCTSTR GetButton2HotImage(); 48 | void SetButton2HotImage(LPCTSTR pStrImage); 49 | LPCTSTR GetButton2PushedImage(); 50 | void SetButton2PushedImage(LPCTSTR pStrImage); 51 | LPCTSTR GetButton2DisabledImage(); 52 | void SetButton2DisabledImage(LPCTSTR pStrImage); 53 | 54 | LPCTSTR GetThumbNormalImage(); 55 | void SetThumbNormalImage(LPCTSTR pStrImage); 56 | LPCTSTR GetThumbHotImage(); 57 | void SetThumbHotImage(LPCTSTR pStrImage); 58 | LPCTSTR GetThumbPushedImage(); 59 | void SetThumbPushedImage(LPCTSTR pStrImage); 60 | LPCTSTR GetThumbDisabledImage(); 61 | void SetThumbDisabledImage(LPCTSTR pStrImage); 62 | 63 | LPCTSTR GetRailNormalImage(); 64 | void SetRailNormalImage(LPCTSTR pStrImage); 65 | LPCTSTR GetRailHotImage(); 66 | void SetRailHotImage(LPCTSTR pStrImage); 67 | LPCTSTR GetRailPushedImage(); 68 | void SetRailPushedImage(LPCTSTR pStrImage); 69 | LPCTSTR GetRailDisabledImage(); 70 | void SetRailDisabledImage(LPCTSTR pStrImage); 71 | 72 | LPCTSTR GetBkNormalImage(); 73 | void SetBkNormalImage(LPCTSTR pStrImage); 74 | LPCTSTR GetBkHotImage(); 75 | void SetBkHotImage(LPCTSTR pStrImage); 76 | LPCTSTR GetBkPushedImage(); 77 | void SetBkPushedImage(LPCTSTR pStrImage); 78 | LPCTSTR GetBkDisabledImage(); 79 | void SetBkDisabledImage(LPCTSTR pStrImage); 80 | 81 | void SetPos(RECT rc); 82 | void DoEvent(TEventUI& event); 83 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 84 | 85 | void DoPaint(HDC hDC, const RECT& rcPaint); 86 | 87 | void PaintBk(HDC hDC); 88 | void PaintButton1(HDC hDC); 89 | void PaintButton2(HDC hDC); 90 | void PaintThumb(HDC hDC); 91 | void PaintRail(HDC hDC); 92 | 93 | protected: 94 | 95 | enum 96 | { 97 | DEFAULT_SCROLLBAR_SIZE = 16, 98 | DEFAULT_TIMERID = 10, 99 | }; 100 | 101 | bool m_bHorizontal; 102 | int m_nRange; 103 | int m_nScrollPos; 104 | int m_nLineSize; 105 | CContainerUI* m_pOwner; 106 | POINT ptLastMouse; 107 | int m_nLastScrollPos; 108 | int m_nLastScrollOffset; 109 | int m_nScrollRepeatDelay; 110 | 111 | CDuiString m_sBkNormalImage; 112 | CDuiString m_sBkHotImage; 113 | CDuiString m_sBkPushedImage; 114 | CDuiString m_sBkDisabledImage; 115 | 116 | bool m_bShowButton1; 117 | RECT m_rcButton1; 118 | UINT m_uButton1State; 119 | CDuiString m_sButton1NormalImage; 120 | CDuiString m_sButton1HotImage; 121 | CDuiString m_sButton1PushedImage; 122 | CDuiString m_sButton1DisabledImage; 123 | 124 | bool m_bShowButton2; 125 | RECT m_rcButton2; 126 | UINT m_uButton2State; 127 | CDuiString m_sButton2NormalImage; 128 | CDuiString m_sButton2HotImage; 129 | CDuiString m_sButton2PushedImage; 130 | CDuiString m_sButton2DisabledImage; 131 | 132 | RECT m_rcThumb; 133 | UINT m_uThumbState; 134 | CDuiString m_sThumbNormalImage; 135 | CDuiString m_sThumbHotImage; 136 | CDuiString m_sThumbPushedImage; 137 | CDuiString m_sThumbDisabledImage; 138 | 139 | CDuiString m_sRailNormalImage; 140 | CDuiString m_sRailHotImage; 141 | CDuiString m_sRailPushedImage; 142 | CDuiString m_sRailDisabledImage; 143 | 144 | CDuiString m_sImageModify; 145 | }; 146 | } 147 | 148 | #endif // __UISCROLLBAR_H__ -------------------------------------------------------------------------------- /DuiDesigner/UIUtil.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIUtil.h" 3 | 4 | namespace StringConvertor { 5 | 6 | #pragma warning(disable: 4996) 7 | 8 | #if defined(USE_OP_LIBC) 9 | #define __malloc(size) ((void*)(op_malloc(size))) 10 | #define __free(ptr) ((void)(op_free(ptr))) 11 | #elif defined(USE_LIBC) 12 | #define __malloc(size) ((void*)(malloc(size))) 13 | #define __free(ptr) ((void)(free(ptr))) 14 | #else 15 | #define __malloc(size) ((void*)(LocalAlloc(LPTR, (size)))) 16 | #define __free(ptr) ((void)(LocalFree(ptr))) 17 | #endif 18 | 19 | enum FROM 20 | { 21 | ansi, 22 | wide 23 | }; 24 | 25 | template struct Conversion; 26 | template <> struct Conversion 27 | { 28 | typedef LPWSTR FromT; 29 | typedef LPCWSTR CFromT; 30 | typedef LPSTR ToT; 31 | enum { TO = ansi }; 32 | static __inline int Convert(UINT cp, CFromT strW, int lenW, ToT strA, int lenA) { return WideCharToMultiByte(cp, 0, strW, lenW, strA, lenA, NULL, NULL); } 33 | static __inline FromT Alloc(size_t len) { return StringAllocW(len); } 34 | static __inline size_t StrLen(CFromT strW) { return wcslen(strW); } 35 | static __inline size_t BufferSize(size_t len) { return len * sizeof(wchar_t); } 36 | }; 37 | 38 | template <> struct Conversion 39 | { 40 | typedef LPSTR FromT; 41 | typedef LPCSTR CFromT; 42 | typedef LPWSTR ToT; 43 | enum { TO = wide }; 44 | static __inline int Convert(UINT cp, CFromT strA, int lenA, ToT strW, int lenW) { return MultiByteToWideChar(cp, 0, strA, lenA, strW, lenW); } 45 | static __inline FromT Alloc(size_t len) { return StringAllocA(len); } 46 | static __inline size_t StrLen(CFromT strA) { return strlen(strA); } 47 | static __inline size_t BufferSize(size_t len) { return len; } 48 | }; 49 | 50 | template struct Decode 51 | { 52 | typedef typename Conversion::CFromT CFromT; 53 | typedef typename Conversion::ToT ToT; 54 | enum { OPPOSITE = Conversion::TO }; 55 | ToT out; 56 | __inline Decode(CFromT in, int in_len = -1): out(NULL) 57 | { 58 | if (!in) return; 59 | int out_len = Conversion::Convert(to, in, in_len, NULL, 0); 60 | if (out_len) 61 | { 62 | ++out_len; //this might be over-allocation 63 | out = Conversion< (FROM)OPPOSITE >::Alloc(out_len); 64 | if (out) 65 | { 66 | Conversion::Convert(to, in, in_len, out, out_len); 67 | } 68 | } 69 | } 70 | __inline operator ToT () const { return out; } 71 | }; 72 | 73 | template struct Recode 74 | { 75 | LPSTR out; 76 | __inline Recode(LPCSTR in, int len = -1): out(NULL) 77 | { 78 | LPWSTR mid = Decode(in, len); 79 | if (!mid) return; 80 | out = Decode(mid); 81 | StringFreeW(mid); 82 | } 83 | __inline operator LPSTR () const { return out; } 84 | }; 85 | 86 | template struct Duplicate 87 | { 88 | typedef typename Conversion::FromT FromT; 89 | typedef typename Conversion::CFromT CFromT; 90 | FromT out; 91 | __inline Duplicate(CFromT in, int in_len = -1): out(NULL) 92 | { 93 | if (!in) return; 94 | size_t len = ((in_len < 0) ? Conversion::StrLen(in) : (size_t)in_len) + 1; 95 | out = Conversion::Alloc(len); 96 | if (!out) return; 97 | CopyMemory(out, in, Conversion::BufferSize(len)); 98 | out[len - 1] = 0; 99 | } 100 | __inline operator FromT () const { return out; } 101 | }; 102 | 103 | LPSTR WideToAnsi(LPCWSTR str, int len) { return Decode(str, len); } 104 | LPSTR WideToUtf8(LPCWSTR str, int len) { return Decode(str, len); } 105 | LPWSTR AnsiToWide(LPCSTR str, int len) { return Decode(str, len); } 106 | LPWSTR Utf8ToWide(LPCSTR str, int len) { return Decode(str, len); } 107 | LPSTR AnsiToUtf8(LPCSTR str, int len) { return Recode(str, len); } 108 | LPSTR Utf8ToAnsi(LPCSTR str, int len) { return Recode(str, len); } 109 | LPWSTR WideStrDup(LPCWSTR str, int len) { return Duplicate(str, len); } 110 | LPSTR AnsiStrDup(LPCSTR str, int len) { return Duplicate(str, len); } 111 | 112 | //memory routines 113 | LPWSTR StringAllocW(size_t len) { return (LPWSTR)__malloc(len * sizeof(wchar_t)); } 114 | LPSTR StringAllocA(size_t len) { return (LPSTR)__malloc(len); } 115 | void StringFreeW(LPWSTR strW) { __free(strW); } 116 | void StringFreeA(LPSTR strA) { __free(strA); } 117 | 118 | } // namespace StringConvertor -------------------------------------------------------------------------------- /DuiLib/Layout/UITabLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UITabLayout.h" 3 | 4 | namespace DuiLib 5 | { 6 | CTabLayoutUI::CTabLayoutUI() : m_iCurSel(-1) 7 | { 8 | } 9 | 10 | LPCTSTR CTabLayoutUI::GetClass() const 11 | { 12 | return _T("TabLayoutUI"); 13 | } 14 | 15 | LPVOID CTabLayoutUI::GetInterface(LPCTSTR pstrName) 16 | { 17 | if( _tcscmp(pstrName, DUI_CTR_TABLAYOUT) == 0 ) return static_cast(this); 18 | return CContainerUI::GetInterface(pstrName); 19 | } 20 | 21 | bool CTabLayoutUI::Add(CControlUI* pControl) 22 | { 23 | bool ret = CContainerUI::Add(pControl); 24 | if( !ret ) return ret; 25 | 26 | if(m_iCurSel == -1 && pControl->IsVisible()) 27 | { 28 | m_iCurSel = GetItemIndex(pControl); 29 | } 30 | else 31 | { 32 | pControl->SetVisible(false); 33 | } 34 | 35 | return ret; 36 | } 37 | 38 | bool CTabLayoutUI::AddAt(CControlUI* pControl, int iIndex) 39 | { 40 | bool ret = CContainerUI::AddAt(pControl, iIndex); 41 | if( !ret ) return ret; 42 | 43 | if(m_iCurSel == -1 && pControl->IsVisible()) 44 | { 45 | m_iCurSel = GetItemIndex(pControl); 46 | } 47 | else if( m_iCurSel != -1 && iIndex <= m_iCurSel ) 48 | { 49 | m_iCurSel += 1; 50 | } 51 | else 52 | { 53 | pControl->SetVisible(false); 54 | } 55 | 56 | return ret; 57 | } 58 | 59 | bool CTabLayoutUI::Remove(CControlUI* pControl) 60 | { 61 | if( pControl == NULL) return false; 62 | 63 | int index = GetItemIndex(pControl); 64 | bool ret = CContainerUI::Remove(pControl); 65 | if( !ret ) return false; 66 | 67 | if( m_iCurSel == index) 68 | { 69 | if( GetCount() > 0 ) 70 | { 71 | m_iCurSel=0; 72 | GetItemAt(m_iCurSel)->SetVisible(true); 73 | } 74 | else 75 | m_iCurSel=-1; 76 | NeedParentUpdate(); 77 | } 78 | else if( m_iCurSel > index ) 79 | { 80 | m_iCurSel -= 1; 81 | } 82 | 83 | return ret; 84 | } 85 | 86 | void CTabLayoutUI::RemoveAll() 87 | { 88 | m_iCurSel = -1; 89 | CContainerUI::RemoveAll(); 90 | NeedParentUpdate(); 91 | } 92 | 93 | int CTabLayoutUI::GetCurSel() const 94 | { 95 | return m_iCurSel; 96 | } 97 | 98 | bool CTabLayoutUI::SelectItem(int iIndex) 99 | { 100 | if( iIndex < 0 || iIndex >= m_items.GetSize() ) return false; 101 | if( iIndex == m_iCurSel ) return true; 102 | 103 | int iOldSel = m_iCurSel; 104 | m_iCurSel = iIndex; 105 | for( int it = 0; it < m_items.GetSize(); it++ ) 106 | { 107 | if( it == iIndex ) { 108 | GetItemAt(it)->SetVisible(true); 109 | GetItemAt(it)->SetFocus(); 110 | SetPos(m_rcItem); 111 | } 112 | else GetItemAt(it)->SetVisible(false); 113 | } 114 | NeedParentUpdate(); 115 | 116 | if( m_pManager != NULL ) { 117 | m_pManager->SetNextTabControl(); 118 | m_pManager->SendNotify(this, DUI_MSGTYPE_TABSELECT, m_iCurSel, iOldSel); 119 | } 120 | return true; 121 | } 122 | 123 | bool CTabLayoutUI::SelectItem( CControlUI* pControl ) 124 | { 125 | int iIndex=GetItemIndex(pControl); 126 | if (iIndex==-1) 127 | return false; 128 | else 129 | return SelectItem(iIndex); 130 | } 131 | 132 | void CTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 133 | { 134 | if( _tcscmp(pstrName, _T("selectedid")) == 0 ) SelectItem(_ttoi(pstrValue)); 135 | return CContainerUI::SetAttribute(pstrName, pstrValue); 136 | } 137 | 138 | void CTabLayoutUI::SetPos(RECT rc) 139 | { 140 | CControlUI::SetPos(rc); 141 | rc = m_rcItem; 142 | 143 | // Adjust for inset 144 | rc.left += m_rcInset.left; 145 | rc.top += m_rcInset.top; 146 | rc.right -= m_rcInset.right; 147 | rc.bottom -= m_rcInset.bottom; 148 | 149 | for( int it = 0; it < m_items.GetSize(); it++ ) { 150 | CControlUI* pControl = static_cast(m_items[it]); 151 | if( !pControl->IsVisible() ) continue; 152 | if( pControl->IsFloat() ) { 153 | SetFloatPos(it); 154 | continue; 155 | } 156 | 157 | if( it != m_iCurSel ) continue; 158 | 159 | RECT rcPadding = pControl->GetPadding(); 160 | rc.left += rcPadding.left; 161 | rc.top += rcPadding.top; 162 | rc.right -= rcPadding.right; 163 | rc.bottom -= rcPadding.bottom; 164 | 165 | SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top }; 166 | 167 | SIZE sz = pControl->EstimateSize(szAvailable); 168 | if( sz.cx == 0 ) { 169 | sz.cx = MAX(0, szAvailable.cx); 170 | } 171 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth(); 172 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth(); 173 | 174 | if(sz.cy == 0) { 175 | sz.cy = MAX(0, szAvailable.cy); 176 | } 177 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight(); 178 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight(); 179 | 180 | RECT rcCtrl = { rc.left, rc.top, rc.left + sz.cx, rc.top + sz.cy}; 181 | pControl->SetPos(rcCtrl); 182 | } 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /DuiLib/Control/UITreeView.h: -------------------------------------------------------------------------------- 1 | #ifndef UITreeView_h__ 2 | #define UITreeView_h__ 3 | 4 | #include 5 | using namespace std; 6 | 7 | #pragma once 8 | 9 | namespace DuiLib 10 | { 11 | class CTreeViewUI; 12 | class CCheckBoxUI; 13 | class CLabelUI; 14 | class COptionUI; 15 | 16 | class UILIB_API CTreeNodeUI : public CListContainerElementUI 17 | { 18 | public: 19 | CTreeNodeUI(CTreeNodeUI* _ParentNode = NULL); 20 | ~CTreeNodeUI(void); 21 | 22 | public: 23 | LPCTSTR GetClass() const; 24 | LPVOID GetInterface(LPCTSTR pstrName); 25 | void DoEvent(TEventUI& event); 26 | void Invalidate(); 27 | bool Select(bool bSelect = true); 28 | 29 | bool Add(CControlUI* _pTreeNodeUI); 30 | bool AddAt(CControlUI* pControl, int iIndex); 31 | bool Remove(CControlUI* pControl); 32 | 33 | void SetVisibleTag(bool _IsVisible); 34 | bool GetVisibleTag(); 35 | void SetItemText(LPCTSTR pstrValue); 36 | CDuiString GetItemText(); 37 | void CheckBoxSelected(bool _Selected); 38 | bool IsCheckBoxSelected() const; 39 | bool IsHasChild() const; 40 | long GetTreeLevel() const; 41 | bool AddChildNode(CTreeNodeUI* _pTreeNodeUI); 42 | bool RemoveAt(CTreeNodeUI* _pTreeNodeUI); 43 | void SetParentNode(CTreeNodeUI* _pParentTreeNode); 44 | CTreeNodeUI* GetParentNode(); 45 | long GetCountChild(); 46 | void SetTreeView(CTreeViewUI* _CTreeViewUI); 47 | CTreeViewUI* GetTreeView(); 48 | CTreeNodeUI* GetChildNode(int _nIndex); 49 | void SetVisibleFolderBtn(bool _IsVisibled); 50 | bool GetVisibleFolderBtn(); 51 | void SetVisibleCheckBtn(bool _IsVisibled); 52 | bool GetVisibleCheckBtn(); 53 | void SetItemTextColor(DWORD _dwItemTextColor); 54 | DWORD GetItemTextColor() const; 55 | void SetItemHotTextColor(DWORD _dwItemHotTextColor); 56 | DWORD GetItemHotTextColor() const; 57 | void SetSelItemTextColor(DWORD _dwSelItemTextColor); 58 | DWORD GetSelItemTextColor() const; 59 | void SetSelItemHotTextColor(DWORD _dwSelHotItemTextColor); 60 | DWORD GetSelItemHotTextColor() const; 61 | 62 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 63 | 64 | CStdPtrArray GetTreeNodes(); 65 | 66 | int GetTreeIndex(); 67 | int GetNodeIndex(); 68 | 69 | private: 70 | CTreeNodeUI* GetLastNode(); 71 | CTreeNodeUI* CalLocation(CTreeNodeUI* _pTreeNodeUI); 72 | public: 73 | CHorizontalLayoutUI* GetTreeNodeHoriznotal() const {return pHoriz;}; 74 | CCheckBoxUI* GetFolderButton() const {return pFolderButton;}; 75 | CLabelUI* GetDottedLine() const {return pDottedLine;}; 76 | CCheckBoxUI* GetCheckBox() const {return pCheckBox;}; 77 | COptionUI* GetItemButton() const {return pItemButton;}; 78 | 79 | private: 80 | long m_iTreeLavel; 81 | bool m_bIsVisable; 82 | bool m_bIsCheckBox; 83 | DWORD m_dwItemTextColor; 84 | DWORD m_dwItemHotTextColor; 85 | DWORD m_dwSelItemTextColor; 86 | DWORD m_dwSelItemHotTextColor; 87 | 88 | CTreeViewUI* pTreeView; 89 | CHorizontalLayoutUI* pHoriz; 90 | CCheckBoxUI* pFolderButton; 91 | CLabelUI* pDottedLine; 92 | CCheckBoxUI* pCheckBox; 93 | COptionUI* pItemButton; 94 | 95 | CTreeNodeUI* pParentTreeNode; 96 | 97 | CStdPtrArray mTreeNodes; 98 | }; 99 | 100 | class UILIB_API CTreeViewUI : public CListUI,public INotifyUI 101 | { 102 | public: 103 | CTreeViewUI(void); 104 | ~CTreeViewUI(void); 105 | 106 | public: 107 | virtual LPCTSTR GetClass() const; 108 | virtual LPVOID GetInterface(LPCTSTR pstrName); 109 | virtual bool Add(CTreeNodeUI* pControl ); 110 | virtual long AddAt(CTreeNodeUI* pControl, int iIndex ); 111 | virtual bool AddAt(CTreeNodeUI* pControl,CTreeNodeUI* _IndexNode); 112 | virtual bool Remove(CTreeNodeUI* pControl); 113 | virtual bool RemoveAt(int iIndex); 114 | virtual void RemoveAll(); 115 | virtual bool OnCheckBoxChanged(void* param); 116 | virtual bool OnFolderChanged(void* param); 117 | virtual bool OnDBClickItem(void* param); 118 | virtual bool SetItemCheckBox(bool _Selected,CTreeNodeUI* _TreeNode = NULL); 119 | virtual void SetItemExpand(bool _Expanded,CTreeNodeUI* _TreeNode = NULL); 120 | virtual void Notify(TNotifyUI& msg); 121 | virtual void SetVisibleFolderBtn(bool _IsVisibled); 122 | virtual bool GetVisibleFolderBtn(); 123 | virtual void SetVisibleCheckBtn(bool _IsVisibled); 124 | virtual bool GetVisibleCheckBtn(); 125 | virtual void SetItemMinWidth(UINT _ItemMinWidth); 126 | virtual UINT GetItemMinWidth(); 127 | virtual void SetItemTextColor(DWORD _dwItemTextColor); 128 | virtual void SetItemHotTextColor(DWORD _dwItemHotTextColor); 129 | virtual void SetSelItemTextColor(DWORD _dwSelItemTextColor); 130 | virtual void SetSelItemHotTextColor(DWORD _dwSelHotItemTextColor); 131 | 132 | virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 133 | private: 134 | UINT m_uItemMinWidth; 135 | bool m_bVisibleFolderBtn; 136 | bool m_bVisibleCheckBtn; 137 | }; 138 | } 139 | 140 | 141 | #endif // UITreeView_h__ 142 | -------------------------------------------------------------------------------- /DuiLib/Control/UIText.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIText.h" 3 | 4 | namespace DuiLib 5 | { 6 | CTextUI::CTextUI() : m_nLinks(0), m_nHoverLink(-1) 7 | { 8 | m_uTextStyle = DT_WORDBREAK; 9 | m_rcTextPadding.left = 2; 10 | m_rcTextPadding.right = 2; 11 | ::ZeroMemory(m_rcLinks, sizeof(m_rcLinks)); 12 | } 13 | 14 | CTextUI::~CTextUI() 15 | { 16 | } 17 | 18 | LPCTSTR CTextUI::GetClass() const 19 | { 20 | return _T("TextUI"); 21 | } 22 | 23 | LPVOID CTextUI::GetInterface(LPCTSTR pstrName) 24 | { 25 | if( _tcscmp(pstrName, DUI_CTR_TEXT) == 0 ) return static_cast(this); 26 | return CLabelUI::GetInterface(pstrName); 27 | } 28 | 29 | UINT CTextUI::GetControlFlags() const 30 | { 31 | if( IsEnabled() && m_nLinks > 0 ) return UIFLAG_SETCURSOR; 32 | else return 0; 33 | } 34 | 35 | CDuiString* CTextUI::GetLinkContent(int iIndex) 36 | { 37 | if( iIndex >= 0 && iIndex < m_nLinks ) return &m_sLinks[iIndex]; 38 | return NULL; 39 | } 40 | 41 | void CTextUI::DoEvent(TEventUI& event) 42 | { 43 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { 44 | if( m_pParent != NULL ) m_pParent->DoEvent(event); 45 | else CLabelUI::DoEvent(event); 46 | return; 47 | } 48 | 49 | if( event.Type == UIEVENT_SETCURSOR ) { 50 | for( int i = 0; i < m_nLinks; i++ ) { 51 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { 52 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); 53 | return; 54 | } 55 | } 56 | } 57 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK && IsEnabled() ) { 58 | for( int i = 0; i < m_nLinks; i++ ) { 59 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { 60 | Invalidate(); 61 | return; 62 | } 63 | } 64 | } 65 | if( event.Type == UIEVENT_BUTTONUP && IsEnabled() ) { 66 | for( int i = 0; i < m_nLinks; i++ ) { 67 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { 68 | m_pManager->SendNotify(this, DUI_MSGTYPE_LINK, i); 69 | return; 70 | } 71 | } 72 | } 73 | if( event.Type == UIEVENT_CONTEXTMENU ) 74 | { 75 | return; 76 | } 77 | // When you move over a link 78 | if( m_nLinks > 0 && event.Type == UIEVENT_MOUSEMOVE && IsEnabled() ) { 79 | int nHoverLink = -1; 80 | for( int i = 0; i < m_nLinks; i++ ) { 81 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { 82 | nHoverLink = i; 83 | break; 84 | } 85 | } 86 | 87 | if(m_nHoverLink != nHoverLink) { 88 | m_nHoverLink = nHoverLink; 89 | Invalidate(); 90 | return; 91 | } 92 | } 93 | if( event.Type == UIEVENT_MOUSELEAVE ) { 94 | if( m_nLinks > 0 && IsEnabled() ) { 95 | if(m_nHoverLink != -1) { 96 | m_nHoverLink = -1; 97 | Invalidate(); 98 | return; 99 | } 100 | } 101 | } 102 | 103 | CLabelUI::DoEvent(event); 104 | } 105 | 106 | SIZE CTextUI::EstimateSize(SIZE szAvailable) 107 | { 108 | RECT rcText = { 0, 0, MAX(szAvailable.cx, m_cxyFixed.cx), 9999 }; 109 | rcText.left += m_rcTextPadding.left; 110 | rcText.right -= m_rcTextPadding.right; 111 | if( m_bShowHtml ) { 112 | int nLinks = 0; 113 | CRenderEngine::DrawHtmlText(m_pManager->GetPaintDC(), m_pManager, rcText, m_sText, m_dwTextColor, NULL, NULL, nLinks, DT_CALCRECT | m_uTextStyle); 114 | } 115 | else { 116 | CRenderEngine::DrawText(m_pManager->GetPaintDC(), m_pManager, rcText, m_sText, m_dwTextColor, m_iFont, DT_CALCRECT | m_uTextStyle); 117 | } 118 | SIZE cXY = {rcText.right - rcText.left + m_rcTextPadding.left + m_rcTextPadding.right, 119 | rcText.bottom - rcText.top + m_rcTextPadding.top + m_rcTextPadding.bottom}; 120 | 121 | if( m_cxyFixed.cy != 0 ) cXY.cy = m_cxyFixed.cy; 122 | return cXY; 123 | } 124 | 125 | void CTextUI::PaintText(HDC hDC) 126 | { 127 | if( m_sText.IsEmpty() ) { 128 | m_nLinks = 0; 129 | return; 130 | } 131 | 132 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor(); 133 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor(); 134 | 135 | if( m_sText.IsEmpty() ) return; 136 | 137 | m_nLinks = lengthof(m_rcLinks); 138 | RECT rc = m_rcItem; 139 | rc.left += m_rcTextPadding.left; 140 | rc.right -= m_rcTextPadding.right; 141 | rc.top += m_rcTextPadding.top; 142 | rc.bottom -= m_rcTextPadding.bottom; 143 | if( IsEnabled() ) { 144 | if( m_bShowHtml ) 145 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, m_dwTextColor, \ 146 | m_rcLinks, m_sLinks, m_nLinks, m_uTextStyle); 147 | else 148 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, m_dwTextColor, \ 149 | m_iFont, m_uTextStyle); 150 | } 151 | else { 152 | if( m_bShowHtml ) 153 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, m_dwDisabledTextColor, \ 154 | m_rcLinks, m_sLinks, m_nLinks, m_uTextStyle); 155 | else 156 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, m_dwDisabledTextColor, \ 157 | m_iFont, m_uTextStyle); 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /DuiDesigner/ToolBoxCtrl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | ////////////////////////////////////////////////////////////////////////// 4 | // CToolElement 5 | 6 | class CToolElement : public CObject 7 | { 8 | DECLARE_DYNAMIC(CToolElement) 9 | 10 | friend class CToolBoxCtrl; 11 | 12 | public: 13 | CToolElement(const CString& strTabName); 14 | CToolElement(const CString& strName,int nClass,UINT nIDIcon); 15 | virtual ~CToolElement(); 16 | 17 | public: 18 | BOOL AddSubTool(CToolElement* pTool); 19 | BOOL IsToolTab() const { return m_bTab; } 20 | void Expand(BOOL bExpand = TRUE); 21 | BOOL IsExpanded() const { return m_bExpanded; } 22 | BOOL IsEnabled() const { return m_bEnabled; } 23 | BOOL IsVisible() const { return m_bIsVisible; } 24 | void SetClass(int nClass) { m_nClass=nClass; } 25 | CToolElement* GetTool(int nClass) const; 26 | int GetClass() const { return m_nClass; } 27 | virtual BOOL IsSelected() const; 28 | virtual BOOL IsHovered() const; 29 | BOOL IsParentExpanded() const; 30 | int GetExpandedSubTools(BOOL bIncludeHidden = TRUE) const; 31 | BOOL RemoveSubTool(CToolElement*& pTool, BOOL bDelete = TRUE); 32 | CToolElement* HitTest(CPoint point); 33 | 34 | void Redraw(); 35 | virtual void OnDrawExpandBox(CDC* pDC, CRect rectExpand); 36 | virtual void OnDrawIcon(CDC* pDC, CRect rect); 37 | virtual void OnDrawName(CDC* pDC, CRect rect); 38 | 39 | protected: 40 | void Init(); 41 | BOOL IsSubTool(CToolElement* pTool) const; 42 | void SetOwnerList(CToolBoxCtrl* pWndList); 43 | void Reposition(int& y); 44 | 45 | protected: 46 | CString m_strName;//Tool Name 47 | int m_nClass;//Tool Class 48 | BOOL m_bTab;//Is ToolTab? 49 | HICON m_hIcon;//Tool Icon 50 | CRect m_Rect;//Tool rectangle (in the ToolBox.list coordinates) 51 | BOOL m_bEnabled; // Is Tool enabled? 52 | BOOL m_bIsVisible; // Is property visible 53 | BOOL m_bExpanded; // Is ToolTab expanded (for ToolTab only) 54 | BOOL m_bNameIsTruncated; 55 | 56 | CToolBoxCtrl* m_pWndList; // Pointer to the ToolBoxList window 57 | CToolElement* m_pParent; // Parent Tool (NULL for ToolTab) 58 | CList m_lstSubTools; // Sub-tools list 59 | }; 60 | 61 | //////////////////////////////////////////////////////////// 62 | // CToolBoxCtrl 63 | 64 | class CToolBoxCtrl : public CWnd 65 | { 66 | DECLARE_DYNAMIC(CToolBoxCtrl) 67 | 68 | friend class CToolElement; 69 | 70 | public: 71 | CToolBoxCtrl(); 72 | virtual ~CToolBoxCtrl(); 73 | 74 | public: 75 | virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); 76 | 77 | public: 78 | int AddToolTab(CToolElement* pToolTab, BOOL bRedraw = TRUE, BOOL bAdjustLayout = TRUE); 79 | BOOL DeleteToolTab(CToolElement*& pTool, BOOL bRedraw = TRUE, BOOL bAdjustLayout = TRUE); 80 | void RemoveAll(); 81 | int GetToolTabCount() const { return (int) m_lstToolTabs.GetCount(); } 82 | 83 | void SetCurSel(CToolElement* pTool, BOOL bRedraw = TRUE); 84 | void SetCurSel(int nClass,BOOL bRedraw=TRUE); 85 | CToolElement* GetCurSel() const { return m_pSel; } 86 | void ExpandAll(BOOL bExpand = TRUE); 87 | 88 | virtual void AdjustLayout(); 89 | CToolElement* HitTest(CPoint pt) const; 90 | 91 | public: 92 | virtual int OnDrawTool(CDC* pDC, CToolElement* pTool) const; 93 | void SetCustomColors(COLORREF clrBackground, COLORREF clrSelected, COLORREF clrHover, COLORREF m_clrSelectedBorder, 94 | COLORREF clrToolTab); 95 | void GetCustomColors(COLORREF& clrBackground, COLORREF& clrSelected, COLORREF& clrHover, COLORREF& m_clrSelectedBorder, 96 | COLORREF& clrToolTab); 97 | 98 | protected: 99 | virtual void OnFillBackground(CDC* pDC, CRect rectClient); 100 | virtual void OnDrawList(CDC* pDC); 101 | HFONT SetCurrFont(CDC* pDC); 102 | void CreateToolTabFont(); 103 | 104 | void ReposTools(); 105 | void SetScrollSizes(); 106 | int GetTotalItems(BOOL bIncludeHidden = TRUE) const; 107 | 108 | protected: 109 | CToolTipCtrl m_ToolTip; // Tooltip control 110 | CScrollBar m_wndScrollVert; // Vertical scroll bar 111 | 112 | protected: 113 | CList m_lstToolTabs; // List of ToolTab 114 | CToolElement* m_pSel; // Current selection 115 | CToolElement* m_pHover; //Hover over 116 | 117 | CRect m_rectList; // ToolBox area 118 | int m_nTabHeight; //ToolTab height of the single row 119 | int m_nToolHeight; // Tool height of the single row 120 | int m_nVertScrollOffset; // In rows 121 | int m_nVertScrollTotal; 122 | int m_nVertScrollPage; 123 | 124 | HFONT m_hFont; // ToolBox list regular font 125 | CFont m_fontToolTab; // ToolTab font 126 | CBrush m_brBackground; 127 | 128 | COLORREF m_clrBackground; 129 | COLORREF m_clrSelected; 130 | COLORREF m_clrHover; 131 | COLORREF m_clrSelectedBorder; 132 | COLORREF m_clrToolTab; 133 | 134 | protected: 135 | DECLARE_MESSAGE_MAP() 136 | public: 137 | afx_msg void OnPaint(); 138 | afx_msg void OnSize(UINT nType, int cx, int cy); 139 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 140 | afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); 141 | afx_msg void OnMouseMove(UINT nFlags, CPoint point); 142 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point); 143 | afx_msg void OnLButtonUp(UINT nFlags, CPoint point); 144 | afx_msg BOOL OnEraseBkgnd(CDC* pDC); 145 | afx_msg void OnMouseLeave(); 146 | afx_msg void OnDestroy(); 147 | }; 148 | 149 | 150 | -------------------------------------------------------------------------------- /DuiDesigner/MultiUITracker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "resource.h" 3 | #include "..\DuiLib\UIlib.h" 4 | using DuiLib::CControlUI; 5 | using DuiLib::INotifyUI; 6 | 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // CUITracker - Modified according to CRectTracker 9 | 10 | // the struct below is used to determine the qualities of a particular handle 11 | typedef struct tagHandleInfo 12 | { 13 | size_t nOffsetX; // offset within RECT for X coordinate 14 | size_t nOffsetY; // offset within RECT for Y coordinate 15 | int nCenterX; // adjust X by Width()/2 * this number 16 | int nCenterY; // adjust Y by Height()/2 * this number 17 | int nHandleX; // adjust X by handle size * this number 18 | int nHandleY; // adjust Y by handle size * this number 19 | int nInvertX; // handle converts to this when X inverted 20 | int nInvertY; // handle converts to this when Y inverted 21 | }HandleInfo; 22 | 23 | // the struct below gives us information on the layout of a RECT struct and 24 | // the relationship between its members 25 | typedef struct tagRectInfo 26 | { 27 | size_t nOffsetAcross; // offset of opposite point (ie. left->right) 28 | int nSignAcross; // sign relative to that point (ie. add/subtract) 29 | }RectInfo; 30 | 31 | // Style Flags 32 | enum StyleFlags 33 | { 34 | solidLine = 1, dottedLine = 2, hatchedBorder = 4, 35 | resizeInside = 8, resizeOutside = 16, hatchInside = 32, 36 | }; 37 | 38 | // Hit-Test codes 39 | enum TrackerHit 40 | { 41 | hitNothing = -1, 42 | hitTopLeft = 0, hitTopRight = 1, hitBottomRight = 2, hitBottomLeft = 3, 43 | hitTop = 4, hitRight = 5, hitBottom = 6, hitLeft = 7, hitMiddle = 8, 44 | }; 45 | 46 | class CUITracker 47 | { 48 | public: 49 | // Constructors 50 | CUITracker(); 51 | CUITracker(LPCRECT lpSrcRect, UINT nStyle); 52 | 53 | // Operations 54 | void GetTrueRect(LPRECT lpTrueRect) const; 55 | BOOL SetCursor(CPoint point, UINT nHitTest) const; 56 | BOOL Track(CWnd* pWnd, CPoint point, BOOL bAllowInvert = FALSE, 57 | CDC* pDCClipTo = NULL); 58 | BOOL TrackRubberBand(CWnd* pWnd, CPoint point, BOOL bAllowInvert = TRUE); 59 | int HitTest(CPoint point) const; 60 | int NormalizeHit(int nHandle) const; 61 | RECT GetRect() const { return m_rect; } 62 | 63 | void SetHandleSize(int nHandleSize) { m_nHandleSize=nHandleSize; } 64 | void SetStyle(UINT style) { m_nStyle=style; } 65 | 66 | // Overridables 67 | virtual void Draw(CDC* pDC) const; 68 | virtual void DrawTrackerRect(LPCRECT lpRect, CDC* pDC); 69 | virtual void AdjustRect(int nHandle, LPRECT lpRect); 70 | virtual void OnChangedRect(const CRect& rectOld); 71 | virtual UINT GetHandleMask() const; 72 | virtual int GetHandleSize(LPCRECT lpRect = NULL) const; 73 | virtual void SetControlType(int nType); 74 | 75 | // Implementation 76 | public: 77 | virtual ~CUITracker(); 78 | 79 | protected: 80 | // Attributes 81 | UINT m_nStyle; // current state 82 | CRect m_rect; // current position (always in pixels) 83 | CSize m_sizeMin; // minimum X and Y size during track operation 84 | int m_nHandleSize; // size of resize handles 85 | int m_nMoveHandleSize;//size of move handle 86 | UINT m_nMask; 87 | UINT m_nControlType; 88 | 89 | BOOL m_bAllowInvert; // flag passed to Track or TrackRubberBand 90 | CRect m_rectLast; 91 | CSize m_sizeLast; 92 | BOOL m_bErase; // TRUE if DrawTrackerRect is called for erasing 93 | BOOL m_bFinalErase; // TRUE if DragTrackerRect called for final erase 94 | 95 | static HCURSOR m_hCursors[10]; 96 | static HBRUSH m_hHatchBrush; 97 | COLORREF m_clrDottedLine; 98 | HPEN m_hDottedLinePen; 99 | COLORREF m_clrHandleBorder; 100 | HPEN m_hHandlePen; 101 | COLORREF m_clrHandleBackground; 102 | HBRUSH m_hHandleBrush; 103 | HBITMAP m_hMoveHandleBitmap; 104 | 105 | // implementation helpers 106 | int HitTestHandles(CPoint point) const; 107 | void GetHandleRect(int nHandle, CRect* pHandleRect) const; 108 | void GetMoveHandleRect(CRect* pHandleRect) const; 109 | void GetModifyPointers(int nHandle, int**ppx, int**ppy, int* px, int*py); 110 | BOOL TrackHandle(int nHandle, CWnd* pWnd, CDC* pDCClipTo); 111 | void Init(); 112 | void Construct(); 113 | }; 114 | 115 | //////////////////////////////////////////////////////////// 116 | // CTrackerElement 117 | 118 | class CMultiUITracker; 119 | 120 | class CTrackerElement 121 | { 122 | public: 123 | CTrackerElement(void); 124 | CTrackerElement(CControlUI* pControl,int nType,INotifyUI* pOwner); 125 | virtual ~CTrackerElement(void); 126 | 127 | friend CMultiUITracker; 128 | 129 | public: 130 | const RECT& GetPos() const; 131 | void SetPos(RECT rect,BOOL bMove=FALSE); 132 | CControlUI* GetControl() { return m_pControl; } 133 | 134 | protected: 135 | CControlUI * m_pControl; 136 | int m_nType; 137 | INotifyUI* m_pOwner; 138 | }; 139 | 140 | //////////////////////////////////////////////////////////// 141 | // CMultiUITracker 142 | 143 | class CMultiUITracker : public CUITracker 144 | { 145 | public: 146 | CMultiUITracker(void); 147 | virtual ~CMultiUITracker(void); 148 | 149 | public: 150 | void Draw(CDC* pDC,LPSIZE pOffset=NULL); 151 | 152 | int HitTest(CPoint point); 153 | int HitTestHandles(CPoint point); 154 | BOOL Track(CWnd* pWnd, CPoint point,BOOL bAllowInvert=FALSE,CDC* pDCClipTo=NULL); 155 | BOOL SetCursor(CPoint point, UINT nHitTest); 156 | 157 | BOOL Add(CTrackerElement * pTracker); 158 | BOOL Remove(CTrackerElement * pTracker); 159 | void RemoveAll(); 160 | BOOL SetFocus(CPoint point); 161 | BOOL SetFocus(CControlUI* pControl); 162 | CTrackerElement* FindTracker(CControlUI* pControl) const; 163 | CControlUI* GetFocused() const; 164 | BOOL GetSelected(CArray& arrSelected); 165 | BOOL IsEmpty() const { return m_arrTracker.IsEmpty(); } 166 | int GetSize() const { return m_arrTracker.GetSize(); } 167 | 168 | SIZE GetFormSize() const { return m_szForm; } 169 | void SetFormSize(SIZE size) { m_szForm=size; } 170 | 171 | protected: 172 | BOOL MultiTrackHandle(CWnd* pWnd,CDC* pDCClipTo); 173 | BOOL OneTrackHandle(int nHandle, CWnd* pWnd, BOOL bAllowInvert, CDC* pDCClipTo); 174 | void CopyUIRect(); 175 | void ClearUIRect(); 176 | void UpdateUIRect(); 177 | void ExcludeChildren(CArray& arrSelected); 178 | 179 | private: 180 | CArray m_arrTracker; //Tracking controls array 181 | CArray m_arrCloneRect;//Copies of the tracking rectangle 182 | CTrackerElement* m_pFocused; // Control has focus 183 | 184 | SIZE m_szForm; 185 | HCURSOR m_hNoDropCursor; 186 | }; 187 | -------------------------------------------------------------------------------- /DuiLib/Layout/UITileLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UITileLayout.h" 3 | 4 | namespace DuiLib 5 | { 6 | CTileLayoutUI::CTileLayoutUI() : m_nColumns(1) 7 | { 8 | m_szItem.cx = m_szItem.cy = 0; 9 | } 10 | 11 | LPCTSTR CTileLayoutUI::GetClass() const 12 | { 13 | return _T("TileLayoutUI"); 14 | } 15 | 16 | LPVOID CTileLayoutUI::GetInterface(LPCTSTR pstrName) 17 | { 18 | if( _tcscmp(pstrName, DUI_CTR_TILELAYOUT) == 0 ) return static_cast(this); 19 | return CContainerUI::GetInterface(pstrName); 20 | } 21 | 22 | SIZE CTileLayoutUI::GetItemSize() const 23 | { 24 | return m_szItem; 25 | } 26 | 27 | void CTileLayoutUI::SetItemSize(SIZE szItem) 28 | { 29 | if( m_szItem.cx != szItem.cx || m_szItem.cy != szItem.cy ) { 30 | m_szItem = szItem; 31 | NeedUpdate(); 32 | } 33 | } 34 | 35 | int CTileLayoutUI::GetColumns() const 36 | { 37 | return m_nColumns; 38 | } 39 | 40 | void CTileLayoutUI::SetColumns(int nCols) 41 | { 42 | if( nCols <= 0 ) return; 43 | m_nColumns = nCols; 44 | NeedUpdate(); 45 | } 46 | 47 | void CTileLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 48 | { 49 | if( _tcscmp(pstrName, _T("itemsize")) == 0 ) { 50 | SIZE szItem = { 0 }; 51 | LPTSTR pstr = NULL; 52 | szItem.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 53 | szItem.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 54 | SetItemSize(szItem); 55 | } 56 | else if( _tcscmp(pstrName, _T("columns")) == 0 ) SetColumns(_ttoi(pstrValue)); 57 | else CContainerUI::SetAttribute(pstrName, pstrValue); 58 | } 59 | 60 | void CTileLayoutUI::SetPos(RECT rc) 61 | { 62 | CControlUI::SetPos(rc); 63 | rc = m_rcItem; 64 | 65 | // Adjust for inset 66 | rc.left += m_rcInset.left; 67 | rc.top += m_rcInset.top; 68 | rc.right -= m_rcInset.right; 69 | rc.bottom -= m_rcInset.bottom; 70 | 71 | if( m_items.GetSize() == 0) { 72 | ProcessScrollBar(rc, 0, 0); 73 | return; 74 | } 75 | 76 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) rc.right -= m_pVerticalScrollBar->GetFixedWidth(); 77 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight(); 78 | 79 | // Position the elements 80 | if( m_szItem.cx > 0 ) m_nColumns = (rc.right - rc.left) / m_szItem.cx; 81 | if( m_nColumns == 0 ) m_nColumns = 1; 82 | 83 | int cyNeeded = 0; 84 | int cxWidth = (rc.right - rc.left) / m_nColumns; 85 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) 86 | cxWidth = (rc.right - rc.left + m_pHorizontalScrollBar->GetScrollRange() ) / m_nColumns; ; 87 | 88 | int cyHeight = 0; 89 | int iCount = 0; 90 | POINT ptTile = { rc.left, rc.top }; 91 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) { 92 | ptTile.y -= m_pVerticalScrollBar->GetScrollPos(); 93 | } 94 | int iPosX = rc.left; 95 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) { 96 | iPosX -= m_pHorizontalScrollBar->GetScrollPos(); 97 | ptTile.x = iPosX; 98 | } 99 | for( int it1 = 0; it1 < m_items.GetSize(); it1++ ) { 100 | CControlUI* pControl = static_cast(m_items[it1]); 101 | if( !pControl->IsVisible() ) continue; 102 | if( pControl->IsFloat() ) { 103 | SetFloatPos(it1); 104 | continue; 105 | } 106 | 107 | // Determine size 108 | RECT rcTile = { ptTile.x, ptTile.y, ptTile.x + cxWidth, ptTile.y }; 109 | if( (iCount % m_nColumns) == 0 ) 110 | { 111 | int iIndex = iCount; 112 | for( int it2 = it1; it2 < m_items.GetSize(); it2++ ) { 113 | CControlUI* pLineControl = static_cast(m_items[it2]); 114 | if( !pLineControl->IsVisible() ) continue; 115 | if( pLineControl->IsFloat() ) continue; 116 | 117 | RECT rcPadding = pLineControl->GetPadding(); 118 | SIZE szAvailable = { rcTile.right - rcTile.left - rcPadding.left - rcPadding.right, 9999 }; 119 | if( iIndex == iCount || (iIndex + 1) % m_nColumns == 0 ) { 120 | szAvailable.cx -= m_iChildPadding / 2; 121 | } 122 | else { 123 | szAvailable.cx -= m_iChildPadding; 124 | } 125 | 126 | if( szAvailable.cx < pControl->GetMinWidth() ) szAvailable.cx = pControl->GetMinWidth(); 127 | if( szAvailable.cx > pControl->GetMaxWidth() ) szAvailable.cx = pControl->GetMaxWidth(); 128 | 129 | SIZE szTile = pLineControl->EstimateSize(szAvailable); 130 | if( szTile.cx < pControl->GetMinWidth() ) szTile.cx = pControl->GetMinWidth(); 131 | if( szTile.cx > pControl->GetMaxWidth() ) szTile.cx = pControl->GetMaxWidth(); 132 | if( szTile.cy < pControl->GetMinHeight() ) szTile.cy = pControl->GetMinHeight(); 133 | if( szTile.cy > pControl->GetMaxHeight() ) szTile.cy = pControl->GetMaxHeight(); 134 | 135 | cyHeight = MAX(cyHeight, szTile.cy + rcPadding.top + rcPadding.bottom); 136 | if( (++iIndex % m_nColumns) == 0) break; 137 | } 138 | } 139 | 140 | RECT rcPadding = pControl->GetPadding(); 141 | 142 | rcTile.left += rcPadding.left + m_iChildPadding / 2; 143 | rcTile.right -= rcPadding.right + m_iChildPadding / 2; 144 | if( (iCount % m_nColumns) == 0 ) { 145 | rcTile.left -= m_iChildPadding / 2; 146 | } 147 | 148 | if( ( (iCount + 1) % m_nColumns) == 0 ) { 149 | rcTile.right += m_iChildPadding / 2; 150 | } 151 | 152 | // Set position 153 | rcTile.top = ptTile.y + rcPadding.top; 154 | rcTile.bottom = ptTile.y + cyHeight; 155 | 156 | SIZE szAvailable = { rcTile.right - rcTile.left, rcTile.bottom - rcTile.top }; 157 | SIZE szTile = pControl->EstimateSize(szAvailable); 158 | if( szTile.cx == 0 ) szTile.cx = szAvailable.cx; 159 | if( szTile.cy == 0 ) szTile.cy = szAvailable.cy; 160 | if( szTile.cx < pControl->GetMinWidth() ) szTile.cx = pControl->GetMinWidth(); 161 | if( szTile.cx > pControl->GetMaxWidth() ) szTile.cx = pControl->GetMaxWidth(); 162 | if( szTile.cy < pControl->GetMinHeight() ) szTile.cy = pControl->GetMinHeight(); 163 | if( szTile.cy > pControl->GetMaxHeight() ) szTile.cy = pControl->GetMaxHeight(); 164 | RECT rcPos = {(rcTile.left + rcTile.right - szTile.cx) / 2, (rcTile.top + rcTile.bottom - szTile.cy) / 2, 165 | (rcTile.left + rcTile.right - szTile.cx) / 2 + szTile.cx, (rcTile.top + rcTile.bottom - szTile.cy) / 2 + szTile.cy}; 166 | pControl->SetPos(rcPos); 167 | 168 | if( (++iCount % m_nColumns) == 0 ) { 169 | ptTile.x = iPosX; 170 | ptTile.y += cyHeight + m_iChildPadding; 171 | cyHeight = 0; 172 | } 173 | else { 174 | ptTile.x += cxWidth; 175 | } 176 | cyNeeded = rcTile.bottom - rc.top; 177 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) cyNeeded += m_pVerticalScrollBar->GetScrollPos(); 178 | } 179 | 180 | // Process the scrollbar 181 | ProcessScrollBar(rc, 0, cyNeeded); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /DuiLib/Utils/downloadmgr.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma warning( disable: 4049 ) /* more than 64k source lines */ 3 | 4 | /* this ALWAYS GENERATED file contains the definitions for the interfaces */ 5 | 6 | 7 | /* File created by MIDL compiler version 5.03.0279 */ 8 | /* at Mon Jul 23 17:42:46 2001 9 | */ 10 | /* Compiler settings for downloadmgr.idl: 11 | Oicf (OptLev=i2), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext 12 | error checks: allocation ref bounds_check enum stub_data 13 | VC __declspec() decoration level: 14 | __declspec(uuid()), __declspec(selectany), __declspec(novtable) 15 | DECLSPEC_UUID(), MIDL_INTERFACE() 16 | */ 17 | //@@MIDL_FILE_HEADING( ) 18 | 19 | 20 | /* verify that the version is high enough to compile this file*/ 21 | #ifndef __REQUIRED_RPCNDR_H_VERSION__ 22 | #define __REQUIRED_RPCNDR_H_VERSION__ 440 23 | #endif 24 | 25 | #include "rpc.h" 26 | #include "rpcndr.h" 27 | 28 | #ifndef __RPCNDR_H_VERSION__ 29 | #error this stub requires an updated version of 30 | #endif // __RPCNDR_H_VERSION__ 31 | 32 | #ifndef COM_NO_WINDOWS_H 33 | #include "windows.h" 34 | #include "ole2.h" 35 | #endif /*COM_NO_WINDOWS_H*/ 36 | 37 | #ifndef __downloadmgr_h__ 38 | #define __downloadmgr_h__ 39 | 40 | /* Forward Declarations */ 41 | 42 | #ifndef __IDownloadManager_FWD_DEFINED__ 43 | #define __IDownloadManager_FWD_DEFINED__ 44 | typedef interface IDownloadManager IDownloadManager; 45 | #endif /* __IDownloadManager_FWD_DEFINED__ */ 46 | 47 | 48 | /* header files for imported files */ 49 | #include "unknwn.h" 50 | #include "ocidl.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C"{ 54 | #endif 55 | 56 | void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); 57 | void __RPC_USER MIDL_user_free( void __RPC_FAR * ); 58 | 59 | /* interface __MIDL_itf_downloadmgr_0000 */ 60 | /* [local] */ 61 | 62 | //=--------------------------------------------------------------------------= 63 | // downloadmgr.h 64 | //=--------------------------------------------------------------------------= 65 | // (C) Copyright 2000 Microsoft Corporation. All Rights Reserved. 66 | // 67 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 68 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 69 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 70 | // PARTICULAR PURPOSE. 71 | //=--------------------------------------------------------------------------= 72 | 73 | #pragma comment(lib,"uuid.lib") 74 | 75 | //---------------------------------------------------------------------------= 76 | // Internet Explorer Download Manager Interfaces 77 | 78 | // -------------------------------------------------------------------------------- 79 | // GUIDS 80 | // -------------------------------------------------------------------------------- 81 | // {988934A4-064B-11D3-BB80-00104B35E7F9} 82 | DEFINE_GUID(IID_IDownloadManager, 0x988934a4, 0x064b, 0x11d3, 0xbb, 0x80, 0x0, 0x10, 0x4b, 0x35, 0xe7, 0xf9); 83 | #define SID_SDownloadManager IID_IDownloadManager 84 | 85 | 86 | 87 | extern RPC_IF_HANDLE __MIDL_itf_downloadmgr_0000_v0_0_c_ifspec; 88 | extern RPC_IF_HANDLE __MIDL_itf_downloadmgr_0000_v0_0_s_ifspec; 89 | 90 | #ifndef __IDownloadManager_INTERFACE_DEFINED__ 91 | #define __IDownloadManager_INTERFACE_DEFINED__ 92 | 93 | /* interface IDownloadManager */ 94 | /* [local][unique][uuid][object][helpstring] */ 95 | 96 | 97 | EXTERN_C const IID IID_IDownloadManager; 98 | 99 | #if defined(__cplusplus) && !defined(CINTERFACE) 100 | 101 | MIDL_INTERFACE("988934A4-064B-11D3-BB80-00104B35E7F9") 102 | IDownloadManager : public IUnknown 103 | { 104 | public: 105 | virtual HRESULT STDMETHODCALLTYPE Download( 106 | /* [in] */ IMoniker __RPC_FAR *pmk, 107 | /* [in] */ IBindCtx __RPC_FAR *pbc, 108 | /* [in] */ DWORD dwBindVerb, 109 | /* [in] */ LONG grfBINDF, 110 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo, 111 | /* [in] */ LPCOLESTR pszHeaders, 112 | /* [in] */ LPCOLESTR pszRedir, 113 | /* [in] */ UINT uiCP) = 0; 114 | 115 | }; 116 | 117 | #else /* C style interface */ 118 | 119 | typedef struct IDownloadManagerVtbl 120 | { 121 | BEGIN_INTERFACE 122 | 123 | HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 124 | IDownloadManager __RPC_FAR * This, 125 | /* [in] */ REFIID riid, 126 | /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 127 | 128 | ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 129 | IDownloadManager __RPC_FAR * This); 130 | 131 | ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 132 | IDownloadManager __RPC_FAR * This); 133 | 134 | HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Download )( 135 | IDownloadManager __RPC_FAR * This, 136 | /* [in] */ IMoniker __RPC_FAR *pmk, 137 | /* [in] */ IBindCtx __RPC_FAR *pbc, 138 | /* [in] */ DWORD dwBindVerb, 139 | /* [in] */ LONG grfBINDF, 140 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo, 141 | /* [in] */ LPCOLESTR pszHeaders, 142 | /* [in] */ LPCOLESTR pszRedir, 143 | /* [in] */ UINT uiCP); 144 | 145 | END_INTERFACE 146 | } IDownloadManagerVtbl; 147 | 148 | interface IDownloadManager 149 | { 150 | CONST_VTBL struct IDownloadManagerVtbl __RPC_FAR *lpVtbl; 151 | }; 152 | 153 | 154 | 155 | #ifdef COBJMACROS 156 | 157 | 158 | #define IDownloadManager_QueryInterface(This,riid,ppvObject) \ 159 | (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) 160 | 161 | #define IDownloadManager_AddRef(This) \ 162 | (This)->lpVtbl -> AddRef(This) 163 | 164 | #define IDownloadManager_Release(This) \ 165 | (This)->lpVtbl -> Release(This) 166 | 167 | 168 | #define IDownloadManager_Download(This,pmk,pbc,dwBindVerb,grfBINDF,pBindInfo,pszHeaders,pszRedir,uiCP) \ 169 | (This)->lpVtbl -> Download(This,pmk,pbc,dwBindVerb,grfBINDF,pBindInfo,pszHeaders,pszRedir,uiCP) 170 | 171 | #endif /* COBJMACROS */ 172 | 173 | 174 | #endif /* C style interface */ 175 | 176 | 177 | 178 | HRESULT STDMETHODCALLTYPE IDownloadManager_Download_Proxy( 179 | IDownloadManager __RPC_FAR * This, 180 | /* [in] */ IMoniker __RPC_FAR *pmk, 181 | /* [in] */ IBindCtx __RPC_FAR *pbc, 182 | /* [in] */ DWORD dwBindVerb, 183 | /* [in] */ LONG grfBINDF, 184 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo, 185 | /* [in] */ LPCOLESTR pszHeaders, 186 | /* [in] */ LPCOLESTR pszRedir, 187 | /* [in] */ UINT uiCP); 188 | 189 | 190 | void __RPC_STUB IDownloadManager_Download_Stub( 191 | IRpcStubBuffer *This, 192 | IRpcChannelBuffer *_pRpcChannelBuffer, 193 | PRPC_MESSAGE _pRpcMessage, 194 | DWORD *_pdwStubPhase); 195 | 196 | 197 | 198 | #endif /* __IDownloadManager_INTERFACE_DEFINED__ */ 199 | 200 | 201 | /* Additional Prototypes for ALL interfaces */ 202 | 203 | /* end of Additional Prototypes */ 204 | 205 | #ifdef __cplusplus 206 | } 207 | #endif 208 | 209 | #endif 210 | 211 | 212 | -------------------------------------------------------------------------------- /DuiLib/Utils/Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTILS_H__ 2 | #define __UTILS_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | ///////////////////////////////////////////////////////////////////////////////////// 9 | // 10 | 11 | class STRINGorID 12 | { 13 | public: 14 | STRINGorID(LPCTSTR lpString) : m_lpstr(lpString) 15 | { } 16 | STRINGorID(UINT nID) : m_lpstr(MAKEINTRESOURCE(nID)) 17 | { } 18 | LPCTSTR m_lpstr; 19 | }; 20 | 21 | ///////////////////////////////////////////////////////////////////////////////////// 22 | // 23 | 24 | class UILIB_API CPoint : public tagPOINT 25 | { 26 | public: 27 | CPoint(); 28 | CPoint(const POINT& src); 29 | CPoint(int x, int y); 30 | CPoint(LPARAM lParam); 31 | }; 32 | 33 | 34 | ///////////////////////////////////////////////////////////////////////////////////// 35 | // 36 | 37 | class UILIB_API CSize : public tagSIZE 38 | { 39 | public: 40 | CSize(); 41 | CSize(const SIZE& src); 42 | CSize(const RECT rc); 43 | CSize(int cx, int cy); 44 | }; 45 | 46 | 47 | ///////////////////////////////////////////////////////////////////////////////////// 48 | // 49 | 50 | class UILIB_API CDuiRect : public tagRECT 51 | { 52 | public: 53 | CDuiRect(); 54 | CDuiRect(const RECT& src); 55 | CDuiRect(int iLeft, int iTop, int iRight, int iBottom); 56 | 57 | int GetWidth() const; 58 | int GetHeight() const; 59 | void Empty(); 60 | bool IsNull() const; 61 | void Join(const RECT& rc); 62 | void ResetOffset(); 63 | void Normalize(); 64 | void Offset(int cx, int cy); 65 | void Inflate(int cx, int cy); 66 | void Deflate(int cx, int cy); 67 | void Union(CDuiRect& rc); 68 | }; 69 | 70 | ///////////////////////////////////////////////////////////////////////////////////// 71 | // 72 | 73 | class UILIB_API CStdPtrArray 74 | { 75 | public: 76 | CStdPtrArray(int iPreallocSize = 0); 77 | CStdPtrArray(const CStdPtrArray& src); 78 | ~CStdPtrArray(); 79 | 80 | void Empty(); 81 | void Resize(int iSize); 82 | bool IsEmpty() const; 83 | int Find(LPVOID iIndex) const; 84 | bool Add(LPVOID pData); 85 | bool SetAt(int iIndex, LPVOID pData); 86 | bool InsertAt(int iIndex, LPVOID pData); 87 | bool Remove(int iIndex); 88 | int GetSize() const; 89 | LPVOID* GetData(); 90 | 91 | LPVOID GetAt(int iIndex) const; 92 | LPVOID operator[] (int nIndex) const; 93 | 94 | protected: 95 | LPVOID* m_ppVoid; 96 | int m_nCount; 97 | int m_nAllocated; 98 | }; 99 | 100 | 101 | ///////////////////////////////////////////////////////////////////////////////////// 102 | // 103 | 104 | class UILIB_API CStdValArray 105 | { 106 | public: 107 | CStdValArray(int iElementSize, int iPreallocSize = 0); 108 | ~CStdValArray(); 109 | 110 | void Empty(); 111 | bool IsEmpty() const; 112 | bool Add(LPCVOID pData); 113 | bool Remove(int iIndex); 114 | int GetSize() const; 115 | LPVOID GetData(); 116 | 117 | LPVOID GetAt(int iIndex) const; 118 | LPVOID operator[] (int nIndex) const; 119 | 120 | protected: 121 | LPBYTE m_pVoid; 122 | int m_iElementSize; 123 | int m_nCount; 124 | int m_nAllocated; 125 | }; 126 | 127 | 128 | ///////////////////////////////////////////////////////////////////////////////////// 129 | // 130 | 131 | class UILIB_API CDuiString 132 | { 133 | public: 134 | enum { MAX_LOCAL_STRING_LEN = 63 }; 135 | 136 | CDuiString(); 137 | CDuiString(const TCHAR ch); 138 | CDuiString(const CDuiString& src); 139 | CDuiString(LPCTSTR lpsz, int nLen = -1); 140 | ~CDuiString(); 141 | 142 | void Empty(); 143 | int GetLength() const; 144 | bool IsEmpty() const; 145 | TCHAR GetAt(int nIndex) const; 146 | void Append(LPCTSTR pstr); 147 | void Assign(LPCTSTR pstr, int nLength = -1); 148 | LPCTSTR GetData() const; 149 | 150 | void SetAt(int nIndex, TCHAR ch); 151 | operator LPCTSTR() const; 152 | 153 | TCHAR operator[] (int nIndex) const; 154 | const CDuiString& operator=(const CDuiString& src); 155 | const CDuiString& operator=(const TCHAR ch); 156 | const CDuiString& operator=(LPCTSTR pstr); 157 | #ifdef _UNICODE 158 | const CDuiString& CDuiString::operator=(LPCSTR lpStr); 159 | const CDuiString& CDuiString::operator+=(LPCSTR lpStr); 160 | #else 161 | const CDuiString& CDuiString::operator=(LPCWSTR lpwStr); 162 | const CDuiString& CDuiString::operator+=(LPCWSTR lpwStr); 163 | #endif 164 | CDuiString operator+(const CDuiString& src) const; 165 | CDuiString operator+(LPCTSTR pstr) const; 166 | const CDuiString& operator+=(const CDuiString& src); 167 | const CDuiString& operator+=(LPCTSTR pstr); 168 | const CDuiString& operator+=(const TCHAR ch); 169 | 170 | bool operator == (LPCTSTR str) const; 171 | bool operator != (LPCTSTR str) const; 172 | bool operator <= (LPCTSTR str) const; 173 | bool operator < (LPCTSTR str) const; 174 | bool operator >= (LPCTSTR str) const; 175 | bool operator > (LPCTSTR str) const; 176 | 177 | int Compare(LPCTSTR pstr) const; 178 | int CompareNoCase(LPCTSTR pstr) const; 179 | 180 | void MakeUpper(); 181 | void MakeLower(); 182 | 183 | CDuiString Left(int nLength) const; 184 | CDuiString Mid(int iPos, int nLength = -1) const; 185 | CDuiString Right(int nLength) const; 186 | 187 | int Find(TCHAR ch, int iPos = 0) const; 188 | int Find(LPCTSTR pstr, int iPos = 0) const; 189 | int ReverseFind(TCHAR ch) const; 190 | int Replace(LPCTSTR pstrFrom, LPCTSTR pstrTo); 191 | 192 | int __cdecl Format(LPCTSTR pstrFormat, ...); 193 | int __cdecl SmallFormat(LPCTSTR pstrFormat, ...); 194 | 195 | protected: 196 | LPTSTR m_pstr; 197 | TCHAR m_szBuffer[MAX_LOCAL_STRING_LEN + 1]; 198 | }; 199 | 200 | 201 | ///////////////////////////////////////////////////////////////////////////////////// 202 | // 203 | 204 | struct TITEM 205 | { 206 | CDuiString Key; 207 | LPVOID Data; 208 | struct TITEM* pPrev; 209 | struct TITEM* pNext; 210 | }; 211 | 212 | class UILIB_API CStdStringPtrMap 213 | { 214 | public: 215 | CStdStringPtrMap(int nSize = 83); 216 | ~CStdStringPtrMap(); 217 | 218 | void Resize(int nSize = 83); 219 | LPVOID Find(LPCTSTR key, bool optimize = true) const; 220 | bool Insert(LPCTSTR key, LPVOID pData); 221 | LPVOID Set(LPCTSTR key, LPVOID pData); 222 | bool Remove(LPCTSTR key); 223 | void RemoveAll(); 224 | int GetSize() const; 225 | LPCTSTR GetAt(int iIndex) const; 226 | LPCTSTR operator[] (int nIndex) const; 227 | 228 | protected: 229 | TITEM** m_aT; 230 | int m_nBuckets; 231 | int m_nCount; 232 | }; 233 | 234 | ///////////////////////////////////////////////////////////////////////////////////// 235 | // 236 | 237 | class UILIB_API CWaitCursor 238 | { 239 | public: 240 | CWaitCursor(); 241 | ~CWaitCursor(); 242 | 243 | protected: 244 | HCURSOR m_hOrigCursor; 245 | }; 246 | 247 | ///////////////////////////////////////////////////////////////////////////////////// 248 | // 249 | 250 | class CVariant : public VARIANT 251 | { 252 | public: 253 | CVariant() 254 | { 255 | VariantInit(this); 256 | } 257 | CVariant(int i) 258 | { 259 | VariantInit(this); 260 | this->vt = VT_I4; 261 | this->intVal = i; 262 | } 263 | CVariant(float f) 264 | { 265 | VariantInit(this); 266 | this->vt = VT_R4; 267 | this->fltVal = f; 268 | } 269 | CVariant(LPOLESTR s) 270 | { 271 | VariantInit(this); 272 | this->vt = VT_BSTR; 273 | this->bstrVal = s; 274 | } 275 | CVariant(IDispatch *disp) 276 | { 277 | VariantInit(this); 278 | this->vt = VT_DISPATCH; 279 | this->pdispVal = disp; 280 | } 281 | 282 | ~CVariant() 283 | { 284 | VariantClear(this); 285 | } 286 | }; 287 | 288 | }// namespace DuiLib 289 | 290 | #endif // __UTILS_H__ -------------------------------------------------------------------------------- /DuiDesigner/PropertiesWnd.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "PropertiesWnd.h" 3 | #include "Resource.h" 4 | 5 | #ifdef _DEBUG 6 | #undef THIS_FILE 7 | static char THIS_FILE[]=__FILE__; 8 | #define new DEBUG_NEW 9 | #endif 10 | 11 | ////////////////////////////////////////////////////////////////////////// 12 | // CPropertiesWnd 13 | 14 | CPropertiesWnd::CPropertiesWnd() 15 | { 16 | g_pPropertiesWnd = this; 17 | } 18 | 19 | CPropertiesWnd::~CPropertiesWnd() 20 | { 21 | } 22 | 23 | BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane) 24 | ON_WM_CREATE() 25 | ON_WM_SIZE() 26 | ON_REGISTERED_MESSAGE(WM_UI_PROPERTY_CHANGED, OnUIPropChanged) 27 | END_MESSAGE_MAP() 28 | 29 | ///////////////////////////////////////////////////////////////////////////// 30 | // CPropertiesWnd 消息处理程序 31 | 32 | int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 33 | { 34 | if (CDockablePane::OnCreate(lpCreateStruct) == -1) 35 | return -1; 36 | 37 | CRect rectDummy; 38 | rectDummy.SetRectEmpty(); 39 | 40 | m_wndUIProperties.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, ID_UI_PROP_WND); 41 | 42 | AdjustLayout(); 43 | 44 | return 0; 45 | } 46 | 47 | void CPropertiesWnd::AdjustLayout() 48 | { 49 | if(GetSafeHwnd() == NULL) 50 | return; 51 | 52 | CRect rectClient; 53 | GetClientRect(rectClient); 54 | m_wndUIProperties.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), rectClient.Height(), SWP_NOACTIVATE | SWP_NOZORDER); 55 | 56 | } 57 | 58 | void CPropertiesWnd::OnSize(UINT nType, int cx, int cy) 59 | { 60 | CDockablePane::OnSize(nType, cx, cy); 61 | 62 | AdjustLayout(); 63 | } 64 | 65 | void CPropertiesWnd::SetVSDotNetLook(BOOL bSet) 66 | { 67 | m_wndUIProperties.SetVSDotNetLook(bSet); 68 | } 69 | 70 | void CPropertiesWnd::ShowProperty(CControlUI* pControl) 71 | { 72 | m_wndUIProperties.ShowProperty(pControl); 73 | } 74 | 75 | LRESULT CPropertiesWnd::OnUIPropChanged(WPARAM wp, LPARAM lp) 76 | { 77 | CMFCPropertyGridProperty* pProp = (CMFCPropertyGridProperty *)lp; 78 | SetUIValue(pProp, pProp->GetData()); 79 | 80 | return TRUE; 81 | } 82 | 83 | void CPropertiesWnd::SetPropValue(CControlUI* pControl,int nTag) 84 | { 85 | CControlUI* pCurControl = m_wndUIProperties.GetCurUI(); 86 | if(pCurControl != pControl) 87 | return; 88 | 89 | CMFCPropertyGridProperty* pPropUI=NULL; 90 | CMFCPropertyGridProperty* pValueList=NULL; 91 | switch(nTag) 92 | { 93 | case tagWindowSize: 94 | { 95 | pPropUI = m_wndUIProperties.FindPropByData(classWindow,FALSE); 96 | 97 | RECT rect=pControl->GetPos(); 98 | pValueList=pPropUI->GetSubItem(tagWindowSize-tagWindow); 99 | pValueList->GetSubItem(0)->SetValue((_variant_t)(LONG)(rect.right-rect.left)); 100 | pValueList->GetSubItem(1)->SetValue((_variant_t)(LONG)(rect.bottom-rect.top)); 101 | pValueList->GetSubItem(0)->SetOriginalValue((_variant_t)(LONG)(rect.right-rect.left)); 102 | pValueList->GetSubItem(1)->SetOriginalValue((_variant_t)(LONG)(rect.bottom-rect.top)); 103 | 104 | break; 105 | } 106 | case tagPos: 107 | { 108 | pPropUI = m_wndUIProperties.FindPropByData(classControl,FALSE); 109 | 110 | SIZE szXY=pControl->GetFixedXY(); 111 | int nWidth=pControl->GetFixedWidth(); 112 | int nHeight=pControl->GetFixedHeight(); 113 | pValueList=pPropUI->GetSubItem(tagPos-tagControl); 114 | pValueList->GetSubItem(0)->SetValue((_variant_t)(LONG)szXY.cx); 115 | pValueList->GetSubItem(1)->SetValue((_variant_t)(LONG)szXY.cy); 116 | pValueList->GetSubItem(2)->SetValue((_variant_t)(LONG)(szXY.cx+nWidth)); 117 | pValueList->GetSubItem(3)->SetValue((_variant_t)(LONG)(szXY.cy+nHeight)); 118 | pValueList->GetSubItem(0)->SetOriginalValue((_variant_t)(LONG)szXY.cx); 119 | pValueList->GetSubItem(1)->SetOriginalValue((_variant_t)(LONG)szXY.cy); 120 | pValueList->GetSubItem(2)->SetOriginalValue((_variant_t)(LONG)(szXY.cx+nWidth)); 121 | pValueList->GetSubItem(3)->SetOriginalValue((_variant_t)(LONG)(szXY.cy+nHeight)); 122 | 123 | break; 124 | } 125 | case tagSize: 126 | { 127 | pPropUI = m_wndUIProperties.FindPropByData(classControl,FALSE); 128 | 129 | pValueList=pPropUI->GetSubItem(tagSize-tagControl); 130 | pValueList->GetSubItem(0)->SetValue((_variant_t)(LONG)pControl->GetWidth()); 131 | pValueList->GetSubItem(1)->SetValue((_variant_t)(LONG)pControl->GetHeight()); 132 | pValueList->GetSubItem(0)->SetOriginalValue((_variant_t)(LONG)pControl->GetWidth()); 133 | pValueList->GetSubItem(1)->SetOriginalValue((_variant_t)(LONG)pControl->GetHeight()); 134 | 135 | break; 136 | } 137 | } 138 | } 139 | 140 | void CPropertiesWnd::SetUIValue(CMFCPropertyGridProperty* pProp,int nTag) 141 | { 142 | CControlUI* pControl = m_wndUIProperties.GetCurUI(); 143 | if(pControl == NULL) 144 | return; 145 | 146 | int nUpdate=UPDATE_REDRAW_CONTROL; 147 | CString strName=pProp->GetName(); 148 | strName.MakeLower(); 149 | CString strNewVal; 150 | CString strOldVal; 151 | strNewVal = pProp->FormatProperty(); 152 | strOldVal = m_wndUIProperties.FormatOrigProperty(pProp); 153 | if(nTag!=tagName && nTag!=tagText && strName.Find(_T("image"))==-1) 154 | { 155 | strNewVal.MakeLower(); 156 | strOldVal.MakeLower(); 157 | } 158 | 159 | switch(nTag) 160 | { 161 | case tagName: 162 | { 163 | CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager(); 164 | if(strNewVal.IsEmpty() || pManager->FindControl(strNewVal)) 165 | { 166 | if(!strNewVal.IsEmpty()) 167 | MessageBox(strNewVal + _T("名称已被其他控件使用")); 168 | pProp->SetValue((_variant_t)pControl->GetName()); 169 | return; 170 | } 171 | else 172 | pManager->ReapObjects(pControl); 173 | 174 | g_pClassView->RenameUITreeItem(pControl, strNewVal); 175 | break; 176 | } 177 | case tagPos: 178 | case tagPadding: 179 | SetPropValue(pControl,tagSize); 180 | 181 | nUpdate=UPDATE_POS; 182 | break; 183 | case tagSize: 184 | case tagMinSize: 185 | case tagMaxSize: 186 | case tagMinMax: 187 | SetUIValue(pProp->GetSubItem(0),-1); 188 | SetUIValue(pProp->GetSubItem(1),-1); 189 | SetPropValue(pControl,tagPos); 190 | 191 | nUpdate=UPDATE_POS; 192 | break; 193 | case tagFloat: 194 | case tagColumns: 195 | nUpdate=UPDATE_POS; 196 | break; 197 | case tagVisible: 198 | nUpdate=UPDATE_REDRAW_PARENT; 199 | break; 200 | case tagListHeader: 201 | if (strNewVal.Compare(_T("false"))==0) 202 | { 203 | strNewVal = _T("hidden"); 204 | } 205 | break; 206 | case tagAlpha: 207 | { 208 | int alpha=_ttoi(strNewVal); 209 | if (alpha<0) 210 | { 211 | strNewVal=_T("0"); 212 | pProp->SetValue((_variant_t)(LONG)0); 213 | } 214 | else if (alpha<=255) 215 | { 216 | pProp->SetValue((_variant_t)(LONG)alpha); 217 | } 218 | else 219 | { 220 | strNewVal=_T("255"); 221 | pProp->SetValue((_variant_t)(LONG)255); 222 | } 223 | break; 224 | } 225 | } 226 | 227 | CUIDesignerView* pUIView=g_pMainFrame->GetActiveUIView(); 228 | ASSERT(pUIView); 229 | TNotifyUI Msg; 230 | UIAttribute oldAttrib = {strName, strOldVal}; 231 | Msg.pSender=pControl; 232 | Msg.sType=_T("PropertyBeginChanged"); 233 | Msg.wParam=0; 234 | Msg.lParam=(LPARAM)&oldAttrib; 235 | pUIView->Notify(Msg); 236 | 237 | pControl->SetAttribute(strName,strNewVal); 238 | pProp->SetOriginalValue(pProp->GetValue()); 239 | 240 | UIAttribute newAttrib = {strName, strNewVal}; 241 | Msg.sType = _T("PropertyEndChanged"); 242 | Msg.lParam = (LPARAM)&newAttrib; 243 | pUIView->Notify(Msg); 244 | 245 | if(nTag==tagWindowSize) 246 | { 247 | Msg.sType=_T("formsize"); 248 | Msg.lParam = NULL; 249 | pUIView->Notify(Msg); 250 | } 251 | else if(nTag == tagName) 252 | { 253 | CPaintManagerUI* pManager = pUIView->GetPaintManager(); 254 | pManager->InitControls(pControl); 255 | } 256 | 257 | CControlUI* pParent=pControl->GetParent(); 258 | if(pParent==NULL) 259 | pParent=pControl; 260 | switch(nUpdate) 261 | { 262 | case UPDATE_POS: 263 | pParent->SetPos(pParent->GetPos()); 264 | 265 | break; 266 | case UPDATE_REDRAW_CONTROL: 267 | pControl->NeedUpdate(); 268 | 269 | break; 270 | case UPDATE_REDRAW_PARENT: 271 | pParent->NeedUpdate(); 272 | } 273 | } 274 | -------------------------------------------------------------------------------- /DuiLib/Control/UISlider.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UISlider.h" 3 | 4 | namespace DuiLib 5 | { 6 | CSliderUI::CSliderUI() : m_uButtonState(0), m_nStep(1) 7 | { 8 | m_uTextStyle = DT_SINGLELINE | DT_CENTER; 9 | m_szThumb.cx = m_szThumb.cy = 10; 10 | } 11 | 12 | LPCTSTR CSliderUI::GetClass() const 13 | { 14 | return _T("SliderUI"); 15 | } 16 | 17 | UINT CSliderUI::GetControlFlags() const 18 | { 19 | if( IsEnabled() ) return UIFLAG_SETCURSOR; 20 | else return 0; 21 | } 22 | 23 | LPVOID CSliderUI::GetInterface(LPCTSTR pstrName) 24 | { 25 | if( _tcscmp(pstrName, DUI_CTR_SLIDER) == 0 ) return static_cast(this); 26 | return CProgressUI::GetInterface(pstrName); 27 | } 28 | 29 | void CSliderUI::SetEnabled(bool bEnable) 30 | { 31 | CControlUI::SetEnabled(bEnable); 32 | if( !IsEnabled() ) { 33 | m_uButtonState = 0; 34 | } 35 | } 36 | 37 | int CSliderUI::GetChangeStep() 38 | { 39 | return m_nStep; 40 | } 41 | 42 | void CSliderUI::SetChangeStep(int step) 43 | { 44 | m_nStep = step; 45 | } 46 | 47 | void CSliderUI::SetThumbSize(SIZE szXY) 48 | { 49 | m_szThumb = szXY; 50 | } 51 | 52 | RECT CSliderUI::GetThumbRect() const 53 | { 54 | if( m_bHorizontal ) { 55 | int left = m_rcItem.left + (m_rcItem.right - m_rcItem.left - m_szThumb.cx) * (m_nValue - m_nMin) / (m_nMax - m_nMin); 56 | int top = (m_rcItem.bottom + m_rcItem.top - m_szThumb.cy) / 2; 57 | return CDuiRect(left, top, left + m_szThumb.cx, top + m_szThumb.cy); 58 | } 59 | else { 60 | int left = (m_rcItem.right + m_rcItem.left - m_szThumb.cx) / 2; 61 | int top = m_rcItem.bottom - m_szThumb.cy - (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy) * (m_nValue - m_nMin) / (m_nMax - m_nMin); 62 | return CDuiRect(left, top, left + m_szThumb.cx, top + m_szThumb.cy); 63 | } 64 | } 65 | 66 | LPCTSTR CSliderUI::GetThumbImage() const 67 | { 68 | return m_sThumbImage; 69 | } 70 | 71 | void CSliderUI::SetThumbImage(LPCTSTR pStrImage) 72 | { 73 | m_sThumbImage = pStrImage; 74 | Invalidate(); 75 | } 76 | 77 | LPCTSTR CSliderUI::GetThumbHotImage() const 78 | { 79 | return m_sThumbHotImage; 80 | } 81 | 82 | void CSliderUI::SetThumbHotImage(LPCTSTR pStrImage) 83 | { 84 | m_sThumbHotImage = pStrImage; 85 | Invalidate(); 86 | } 87 | 88 | LPCTSTR CSliderUI::GetThumbPushedImage() const 89 | { 90 | return m_sThumbPushedImage; 91 | } 92 | 93 | void CSliderUI::SetThumbPushedImage(LPCTSTR pStrImage) 94 | { 95 | m_sThumbPushedImage = pStrImage; 96 | Invalidate(); 97 | } 98 | 99 | void CSliderUI::DoEvent(TEventUI& event) 100 | { 101 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { 102 | if( m_pParent != NULL ) m_pParent->DoEvent(event); 103 | else CProgressUI::DoEvent(event); 104 | return; 105 | } 106 | 107 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) 108 | { 109 | if( IsEnabled() ) { 110 | RECT rcThumb = GetThumbRect(); 111 | if( ::PtInRect(&rcThumb, event.ptMouse) ) { 112 | m_uButtonState |= UISTATE_CAPTURED; 113 | } 114 | } 115 | return; 116 | } 117 | if( event.Type == UIEVENT_BUTTONUP ) 118 | { 119 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { 120 | m_uButtonState &= ~UISTATE_CAPTURED; 121 | } 122 | if( m_bHorizontal ) { 123 | if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; 124 | else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; 125 | else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); 126 | } 127 | else { 128 | if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; 129 | else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; 130 | else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); 131 | } 132 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); 133 | Invalidate(); 134 | return; 135 | } 136 | if( event.Type == UIEVENT_CONTEXTMENU ) 137 | { 138 | return; 139 | } 140 | if( event.Type == UIEVENT_SCROLLWHEEL ) 141 | { 142 | switch( LOWORD(event.wParam) ) { 143 | case SB_LINEUP: 144 | SetValue(GetValue() + GetChangeStep()); 145 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); 146 | return; 147 | case SB_LINEDOWN: 148 | SetValue(GetValue() - GetChangeStep()); 149 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); 150 | return; 151 | } 152 | } 153 | if( event.Type == UIEVENT_MOUSEMOVE ) 154 | { 155 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { 156 | if( m_bHorizontal ) { 157 | if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; 158 | else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; 159 | else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); 160 | } 161 | else { 162 | if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; 163 | else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; 164 | else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); 165 | } 166 | Invalidate(); 167 | } 168 | return; 169 | } 170 | if( event.Type == UIEVENT_SETCURSOR ) 171 | { 172 | RECT rcThumb = GetThumbRect(); 173 | if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) { 174 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); 175 | return; 176 | } 177 | } 178 | if( event.Type == UIEVENT_MOUSEENTER ) 179 | { 180 | if( IsEnabled() ) { 181 | m_uButtonState |= UISTATE_HOT; 182 | Invalidate(); 183 | } 184 | return; 185 | } 186 | if( event.Type == UIEVENT_MOUSELEAVE ) 187 | { 188 | if( IsEnabled() ) { 189 | m_uButtonState &= ~UISTATE_HOT; 190 | Invalidate(); 191 | } 192 | return; 193 | } 194 | CControlUI::DoEvent(event); 195 | } 196 | 197 | 198 | void CSliderUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 199 | { 200 | if( _tcscmp(pstrName, _T("thumbimage")) == 0 ) SetThumbImage(pstrValue); 201 | else if( _tcscmp(pstrName, _T("thumbhotimage")) == 0 ) SetThumbHotImage(pstrValue); 202 | else if( _tcscmp(pstrName, _T("thumbpushedimage")) == 0 ) SetThumbPushedImage(pstrValue); 203 | else if( _tcscmp(pstrName, _T("thumbsize")) == 0 ) { 204 | SIZE szXY = {0}; 205 | LPTSTR pstr = NULL; 206 | szXY.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 207 | szXY.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 208 | SetThumbSize(szXY); 209 | } 210 | else if( _tcscmp(pstrName, _T("step")) == 0 ) { 211 | SetChangeStep(_ttoi(pstrValue)); 212 | } 213 | else CProgressUI::SetAttribute(pstrName, pstrValue); 214 | } 215 | 216 | void CSliderUI::PaintStatusImage(HDC hDC) 217 | { 218 | CProgressUI::PaintStatusImage(hDC); 219 | 220 | RECT rcThumb = GetThumbRect(); 221 | rcThumb.left -= m_rcItem.left; 222 | rcThumb.top -= m_rcItem.top; 223 | rcThumb.right -= m_rcItem.left; 224 | rcThumb.bottom -= m_rcItem.top; 225 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { 226 | if( !m_sThumbPushedImage.IsEmpty() ) { 227 | m_sImageModify.Empty(); 228 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom); 229 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbPushedImage, (LPCTSTR)m_sImageModify) ) m_sThumbPushedImage.Empty(); 230 | else return; 231 | } 232 | } 233 | else if( (m_uButtonState & UISTATE_HOT) != 0 ) { 234 | if( !m_sThumbHotImage.IsEmpty() ) { 235 | m_sImageModify.Empty(); 236 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom); 237 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbHotImage, (LPCTSTR)m_sImageModify) ) m_sThumbHotImage.Empty(); 238 | else return; 239 | } 240 | } 241 | 242 | if( !m_sThumbImage.IsEmpty() ) { 243 | m_sImageModify.Empty(); 244 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom); 245 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbImage, (LPCTSTR)m_sImageModify) ) m_sThumbImage.Empty(); 246 | else return; 247 | } 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /DuiDesigner/LayoutManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "..\DuiLib\UIlib.h" 3 | using DuiLib::CContainerUI; 4 | using DuiLib::CPaintManagerUI; 5 | using DuiLib::CWindowWnd; 6 | using DuiLib::TNotifyUI; 7 | using DuiLib::IDialogBuilderCallback; 8 | 9 | #define EXPORT_UI_SCRIPT 10 | 11 | #if defined(EXPORT_UI_SCRIPT) 12 | #include "tinyxml.h" 13 | #endif 14 | 15 | ////////////////////////////////////////////////////////////////////////// 16 | //CFormUI 17 | 18 | class CWindowUI : public CContainerUI 19 | { 20 | public: 21 | CWindowUI(); 22 | virtual ~CWindowUI(); 23 | 24 | public: 25 | LPCTSTR GetClass() const; 26 | LPVOID GetInterface(LPCTSTR pstrName); 27 | 28 | SIZE GetInitSize(); 29 | void SetInitSize(int cx, int cy); 30 | RECT& GetSizeBox(); 31 | void SetSizeBox(RECT& rcSizeBox); 32 | RECT& GetCaptionRect(); 33 | void SetCaptionRect(RECT& rcCaption); 34 | SIZE GetRoundCorner() const; 35 | void SetRoundCorner(int cx, int cy); 36 | SIZE GetMinInfo() const; 37 | SIZE GetMaxInfo() const; 38 | void SetMinInfo(int cx, int cy); 39 | void SetMaxInfo(int cx, int cy); 40 | bool IsShowUpdateRect() const; 41 | void SetShowUpdateRect(bool show); 42 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 43 | 44 | void SetPos(RECT rc); 45 | 46 | public: 47 | void SetAlpha(int nOpacity); 48 | int GetAlpha() const; 49 | 50 | void SetBackgroundTransparent(bool bTrans); 51 | bool GetBackgroundTransparent() const; 52 | 53 | void SetDefaultFontColor(DWORD dwColor); 54 | DWORD GetDefaultFontColor() const; 55 | 56 | void SetDefaultSelectedFontColor(DWORD dwColor); 57 | DWORD GetDefaultSelectedFontColor() const; 58 | 59 | void SetDefaultDisabledFontColor(DWORD dwColor); 60 | DWORD GetDefaultDisabledFontColor() const; 61 | 62 | void SetDefaultLinkFontColor(DWORD dwColor); 63 | DWORD GetDefaultLinkFontColor() const; 64 | 65 | void SetDefaultLinkHoverFontColor(DWORD dwColor); 66 | DWORD GetDefaultLinkHoverFontColor() const; 67 | 68 | private: 69 | int m_nOpacity; 70 | bool m_bAlphaBackground; 71 | DWORD m_dwDefaultFontColor; 72 | DWORD m_dwDefaultDisabledFontColor; 73 | DWORD m_dwDefaultLinkFontColor; 74 | DWORD m_dwDefaultLinkHoverFontColor; 75 | DWORD m_dwDefaultSelectedFontColor; 76 | }; 77 | 78 | ////////////////////////////////////////////////////////////////////////// 79 | //CFormTestWnd 80 | 81 | class CFormTestWnd : public CWindowWnd, public INotifyUI 82 | { 83 | public: 84 | CFormTestWnd(); 85 | ~CFormTestWnd(); 86 | LPCTSTR GetWindowClassName() const; 87 | UINT GetClassStyle() const; 88 | void OnFinalMessage(HWND /*hWnd*/); 89 | 90 | public: 91 | void SetManager(CPaintManagerUI* pPaintManager); 92 | CPaintManagerUI* GetManager() const; 93 | void SetRoot(CControlUI* pControl); 94 | void Init(); 95 | 96 | void Notify(TNotifyUI& msg); 97 | LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 98 | LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 99 | LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 100 | LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 101 | LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 102 | LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 103 | LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 104 | LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 105 | LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); 106 | 107 | private: 108 | CPaintManagerUI* m_pManager; 109 | CControlUI* m_pRoot; 110 | }; 111 | 112 | ////////////////////////////////////////////////////////////////////////// 113 | //CLayoutManager 114 | 115 | class CLayoutManager : public IDialogBuilderCallback 116 | { 117 | public: 118 | CLayoutManager(void); 119 | virtual ~CLayoutManager(void); 120 | 121 | public: 122 | void Init(HWND hWnd,LPCTSTR pstrLoad); 123 | 124 | void Draw(CDC* pDC); 125 | void DrawAuxBorder(CDC* pDC,CControlUI* pControl); 126 | void DrawGrid(CDC* pDC,CRect& rect); 127 | 128 | static CControlUI* NewUI(int nClass,CRect& rect,CControlUI* pParent, CLayoutManager* pLayout); 129 | static BOOL DeleteUI(CControlUI* pControl); 130 | static void ReleaseExtendedAttrib(CControlUI* pControl, CPaintManagerUI* pManager); 131 | CPaintManagerUI* GetManager(); 132 | inline CWindowUI* GetForm() const; 133 | CControlUI* FindControl(CPoint point) const; 134 | 135 | void TestForm(LPCTSTR pstrFile); 136 | BOOL IsEmptyForm() const; 137 | void AlignLeft(CControlUI* pFocused,CArray& arrSelected); 138 | void AlignRight(CControlUI* pFocused,CArray& arrSelected); 139 | void AlignTop(CControlUI* pFocused,CArray& arrSelected); 140 | void AlignBottom(CControlUI* pFocused,CArray& arrSelected); 141 | void AlignCenterVertically(CControlUI* pFocused,CArray& arrSelected); 142 | void AlignCenterHorizontally(CControlUI* pFocused,CArray& arrSelected); 143 | void AlignHorizontal(CControlUI* pFocused,CArray& arrSelected); 144 | void AlignVertical(CControlUI* pFocused,CArray& arrSelected); 145 | void AlignSameWidth(CControlUI* pFocused,CArray& arrSelected); 146 | void AlignSameHeight(CControlUI* pFocused,CArray& arrSelected); 147 | void AlignSameSize(CControlUI* pFocused,CArray& arrSelected); 148 | void ShowGrid(bool bShow); 149 | bool IsShowGrid() const; 150 | void ShowAuxBorder(bool bShow); 151 | bool IsShowAuxBorder() const; 152 | void MicoMoveUp(CArray& arrSelected,int nMoved); 153 | void MicoMoveDown(CArray& arrSelected,int nMoved); 154 | void MicoMoveLeft(CArray& arrSelected,int nMoved); 155 | void MicoMoveRight(CArray& arrSelected,int nMoved); 156 | 157 | bool SaveSkinFile(LPCTSTR pstrPathName); 158 | static void SaveProperties(CControlUI* pControl, TiXmlElement* pParentNode 159 | , BOOL bSaveChildren = TRUE); 160 | 161 | void SetDefaultUIName(CControlUI* pControl); 162 | 163 | LPCTSTR GetSkinDir() const { return m_strSkinDir; } 164 | 165 | static CControlUI* CloneControls(CControlUI* pControl); 166 | static CControlUI* CloneControl(CControlUI* pControl); 167 | 168 | CControlUI* CreateControl(LPCTSTR pstrClass); 169 | protected: 170 | static void SaveControlProperty(CControlUI* pControl, TiXmlElement* pNode); 171 | static void SaveLabelProperty(CControlUI* pControl, TiXmlElement* pNode); 172 | static void SaveButtonProperty(CControlUI* pControl, TiXmlElement* pNode); 173 | static void SaveOptionProperty(CControlUI* pControl, TiXmlElement* pNode); 174 | static void SaveProgressProperty(CControlUI* pControl, TiXmlElement* pNode); 175 | static void SaveSliderProperty(CControlUI* pControl, TiXmlElement* pNode); 176 | static void SaveEditProperty(CControlUI* pControl, TiXmlElement* pNode); 177 | static void SaveScrollBarProperty(CControlUI* pControl, TiXmlElement* pNode); 178 | static void SaveListProperty(CControlUI* pControl, TiXmlElement* pNode); 179 | static void SaveComboProperty(CControlUI* pControl, TiXmlElement* pNode); 180 | static void SaveListHeaderProperty(CControlUI* pControl, TiXmlElement* pNode); 181 | static void SaveListHeaderItemProperty(CControlUI* pControl, TiXmlElement* pNode); 182 | static void SaveListElementProperty(CControlUI* pControl, TiXmlElement* pNode); 183 | static void SaveContainerProperty(CControlUI* pControl, TiXmlElement* pNode); 184 | static void SaveHorizontalLayoutProperty(CControlUI* pControl, TiXmlElement* pNode); 185 | static void SaveTileLayoutProperty(CControlUI* pControl, TiXmlElement* pNode); 186 | static void SaveActiveXProperty(CControlUI* pControl, TiXmlElement* pNode); 187 | static void SaveListContainerElementProperty(CControlUI* pControl, TiXmlElement* pNode); 188 | static void SaveItemProperty(CControlUI* pControl, TiXmlElement* pNode); 189 | static void SaveTabLayoutProperty(CControlUI* pControl, TiXmlElement* pNode); 190 | static void SaveChildWindowProperty(CControlUI* pControl, TiXmlElement* pNode); 191 | static void SaveWebBrowserProperty(CControlUI* pControl, TiXmlElement* pNode); 192 | 193 | static CString ConvertImageFileName(LPCTSTR pstrImageAttrib); 194 | 195 | protected: 196 | class CDelayRepos 197 | { 198 | public: 199 | CDelayRepos(); 200 | ~CDelayRepos(); 201 | 202 | public: 203 | BOOL AddParent(CControlUI* pControl); 204 | void Repos(); 205 | 206 | private: 207 | CArray m_arrDelay; 208 | }; 209 | 210 | private: 211 | CPaintManagerUI m_Manager; 212 | CWindowUI* m_pFormUI; 213 | static CString m_strSkinDir; 214 | 215 | bool m_bShowGrid; 216 | bool m_bShowAuxBorder; 217 | }; -------------------------------------------------------------------------------- /DuiLib/Control/UIOption.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIOption.h" 3 | 4 | namespace DuiLib 5 | { 6 | COptionUI::COptionUI() : m_bSelected(false), m_dwSelectedTextColor(0) 7 | { 8 | } 9 | 10 | COptionUI::~COptionUI() 11 | { 12 | if( !m_sGroupName.IsEmpty() && m_pManager ) m_pManager->RemoveOptionGroup(m_sGroupName, this); 13 | } 14 | 15 | LPCTSTR COptionUI::GetClass() const 16 | { 17 | return _T("OptionUI"); 18 | } 19 | 20 | LPVOID COptionUI::GetInterface(LPCTSTR pstrName) 21 | { 22 | if( _tcscmp(pstrName, DUI_CTR_OPTION) == 0 ) return static_cast(this); 23 | return CButtonUI::GetInterface(pstrName); 24 | } 25 | 26 | void COptionUI::SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit) 27 | { 28 | CControlUI::SetManager(pManager, pParent, bInit); 29 | if( bInit && !m_sGroupName.IsEmpty() ) { 30 | if (m_pManager) m_pManager->AddOptionGroup(m_sGroupName, this); 31 | } 32 | } 33 | 34 | LPCTSTR COptionUI::GetGroup() const 35 | { 36 | return m_sGroupName; 37 | } 38 | 39 | void COptionUI::SetGroup(LPCTSTR pStrGroupName) 40 | { 41 | if( pStrGroupName == NULL ) { 42 | if( m_sGroupName.IsEmpty() ) return; 43 | m_sGroupName.Empty(); 44 | } 45 | else { 46 | if( m_sGroupName == pStrGroupName ) return; 47 | if (!m_sGroupName.IsEmpty() && m_pManager) m_pManager->RemoveOptionGroup(m_sGroupName, this); 48 | m_sGroupName = pStrGroupName; 49 | } 50 | 51 | if( !m_sGroupName.IsEmpty() ) { 52 | if (m_pManager) m_pManager->AddOptionGroup(m_sGroupName, this); 53 | } 54 | else { 55 | if (m_pManager) m_pManager->RemoveOptionGroup(m_sGroupName, this); 56 | } 57 | 58 | Selected(m_bSelected); 59 | } 60 | 61 | bool COptionUI::IsSelected() const 62 | { 63 | return m_bSelected; 64 | } 65 | 66 | void COptionUI::Selected(bool bSelected) 67 | { 68 | if( m_bSelected == bSelected ) return; 69 | m_bSelected = bSelected; 70 | if( m_bSelected ) m_uButtonState |= UISTATE_SELECTED; 71 | else m_uButtonState &= ~UISTATE_SELECTED; 72 | 73 | if( m_pManager != NULL ) { 74 | if( !m_sGroupName.IsEmpty() ) { 75 | if( m_bSelected ) { 76 | CStdPtrArray* aOptionGroup = m_pManager->GetOptionGroup(m_sGroupName); 77 | for( int i = 0; i < aOptionGroup->GetSize(); i++ ) { 78 | COptionUI* pControl = static_cast(aOptionGroup->GetAt(i)); 79 | if( pControl != this ) { 80 | pControl->Selected(false); 81 | } 82 | } 83 | m_pManager->SendNotify(this, DUI_MSGTYPE_SELECTCHANGED); 84 | } 85 | } 86 | else { 87 | m_pManager->SendNotify(this, DUI_MSGTYPE_SELECTCHANGED); 88 | } 89 | } 90 | 91 | Invalidate(); 92 | } 93 | 94 | bool COptionUI::Activate() 95 | { 96 | if( !CButtonUI::Activate() ) return false; 97 | if( !m_sGroupName.IsEmpty() ) Selected(true); 98 | else Selected(!m_bSelected); 99 | 100 | return true; 101 | } 102 | 103 | void COptionUI::SetEnabled(bool bEnable) 104 | { 105 | CControlUI::SetEnabled(bEnable); 106 | if( !IsEnabled() ) { 107 | if( m_bSelected ) m_uButtonState = UISTATE_SELECTED; 108 | else m_uButtonState = 0; 109 | } 110 | } 111 | 112 | LPCTSTR COptionUI::GetSelectedImage() 113 | { 114 | return m_sSelectedImage; 115 | } 116 | 117 | void COptionUI::SetSelectedImage(LPCTSTR pStrImage) 118 | { 119 | m_sSelectedImage = pStrImage; 120 | Invalidate(); 121 | } 122 | 123 | //************************************ 124 | // Method: GetSelectedHotImage 125 | // FullName: COptionUI::GetSelectedHotImage 126 | // Access: public 127 | // Returns: LPCTSTR 128 | // Qualifier: 129 | // Node: 130 | //************************************ 131 | LPCTSTR COptionUI::GetSelectedHotImage() 132 | { 133 | return m_sSelectedHotImage; 134 | } 135 | //************************************ 136 | // Method: SetSelectedHotImage 137 | // FullName: COptionUI::SetSelectedHotImage 138 | // Access: public 139 | // Returns: void 140 | // Qualifier: 141 | // Parameter: LPCTSTR pStrImage 142 | // Node: 143 | //************************************ 144 | void COptionUI::SetSelectedHotImage( LPCTSTR pStrImage ) 145 | { 146 | m_sSelectedHotImage = pStrImage; 147 | Invalidate(); 148 | } 149 | 150 | void COptionUI::SetSelectedTextColor(DWORD dwTextColor) 151 | { 152 | m_dwSelectedTextColor = dwTextColor; 153 | } 154 | 155 | DWORD COptionUI::GetSelectedTextColor() 156 | { 157 | if (m_dwSelectedTextColor == 0) m_dwSelectedTextColor = m_pManager->GetDefaultFontColor(); 158 | return m_dwSelectedTextColor; 159 | } 160 | 161 | //************************************ 162 | // Method: SetSelectedBkColor 163 | // FullName: COptionUI::SetSelectedBkColor 164 | // Access: public 165 | // Returns: void 166 | // Qualifier: 167 | // Parameter: DWORD dwBkColor 168 | // Note: 169 | //************************************ 170 | void COptionUI::SetSelectedBkColor( DWORD dwBkColor ) 171 | { 172 | m_dwSelectedBkColor = dwBkColor; 173 | } 174 | 175 | //************************************ 176 | // Method: GetSelectBkColor 177 | // FullName: COptionUI::GetSelectBkColor 178 | // Access: public 179 | // Returns: DWORD 180 | // Qualifier: 181 | // Note: 182 | //************************************ 183 | DWORD COptionUI::GetSelectBkColor() 184 | { 185 | return m_dwSelectedBkColor; 186 | } 187 | 188 | LPCTSTR COptionUI::GetForeImage() 189 | { 190 | return m_sForeImage; 191 | } 192 | 193 | void COptionUI::SetForeImage(LPCTSTR pStrImage) 194 | { 195 | m_sForeImage = pStrImage; 196 | Invalidate(); 197 | } 198 | 199 | SIZE COptionUI::EstimateSize(SIZE szAvailable) 200 | { 201 | if( m_cxyFixed.cy == 0 ) return CSize(m_cxyFixed.cx, m_pManager->GetFontInfo(GetFont())->tm.tmHeight + 8); 202 | return CControlUI::EstimateSize(szAvailable); 203 | } 204 | 205 | void COptionUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 206 | { 207 | if( _tcscmp(pstrName, _T("group")) == 0 ) SetGroup(pstrValue); 208 | else if( _tcscmp(pstrName, _T("selected")) == 0 ) Selected(_tcscmp(pstrValue, _T("true")) == 0); 209 | else if( _tcscmp(pstrName, _T("selectedimage")) == 0 ) SetSelectedImage(pstrValue); 210 | else if( _tcscmp(pstrName, _T("selectedhotimage")) == 0 ) SetSelectedHotImage(pstrValue); 211 | else if( _tcscmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue); 212 | else if( _tcscmp(pstrName, _T("selectedbkcolor")) == 0 ) { 213 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); 214 | LPTSTR pstr = NULL; 215 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); 216 | SetSelectedBkColor(clrColor); 217 | } 218 | else if( _tcscmp(pstrName, _T("selectedtextcolor")) == 0 ) { 219 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); 220 | LPTSTR pstr = NULL; 221 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); 222 | SetSelectedTextColor(clrColor); 223 | } 224 | else CButtonUI::SetAttribute(pstrName, pstrValue); 225 | } 226 | 227 | void COptionUI::PaintStatusImage(HDC hDC) 228 | { 229 | m_uButtonState &= ~UISTATE_PUSHED; 230 | 231 | if( (m_uButtonState & UISTATE_HOT) != 0 && IsSelected() && !m_sSelectedHotImage.IsEmpty()) { 232 | if( !DrawImage(hDC, (LPCTSTR)m_sSelectedHotImage) ) 233 | m_sSelectedHotImage.Empty(); 234 | else goto Label_ForeImage; 235 | } 236 | else if( (m_uButtonState & UISTATE_SELECTED) != 0 ) { 237 | if( !m_sSelectedImage.IsEmpty() ) { 238 | if( !DrawImage(hDC, (LPCTSTR)m_sSelectedImage) ) m_sSelectedImage.Empty(); 239 | else goto Label_ForeImage; 240 | } 241 | else if(m_dwSelectedBkColor != 0) { 242 | CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwSelectedBkColor)); 243 | return; 244 | } 245 | } 246 | 247 | CButtonUI::PaintStatusImage(hDC); 248 | 249 | Label_ForeImage: 250 | if( !m_sForeImage.IsEmpty() ) { 251 | if( !DrawImage(hDC, (LPCTSTR)m_sForeImage) ) m_sForeImage.Empty(); 252 | } 253 | } 254 | 255 | void COptionUI::PaintText(HDC hDC) 256 | { 257 | if( (m_uButtonState & UISTATE_SELECTED) != 0 ) 258 | { 259 | DWORD oldTextColor = m_dwTextColor; 260 | if( m_dwSelectedTextColor != 0 ) m_dwTextColor = m_dwSelectedTextColor; 261 | 262 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor(); 263 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor(); 264 | 265 | if( m_sText.IsEmpty() ) return; 266 | int nLinks = 0; 267 | RECT rc = m_rcItem; 268 | rc.left += m_rcTextPadding.left; 269 | rc.right -= m_rcTextPadding.right; 270 | rc.top += m_rcTextPadding.top; 271 | rc.bottom -= m_rcTextPadding.bottom; 272 | 273 | if( m_bShowHtml ) 274 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, IsEnabled()?m_dwTextColor:m_dwDisabledTextColor, \ 275 | NULL, NULL, nLinks, m_uTextStyle); 276 | else 277 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, IsEnabled()?m_dwTextColor:m_dwDisabledTextColor, \ 278 | m_iFont, m_uTextStyle); 279 | 280 | m_dwTextColor = oldTextColor; 281 | } 282 | else 283 | CButtonUI::PaintText(hDC); 284 | } 285 | } -------------------------------------------------------------------------------- /DuiDesigner/ResourceView.cpp: -------------------------------------------------------------------------------- 1 | // This is a part of the Microsoft Foundation Classes C++ library. 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // This source code is only intended as a supplement to the 5 | // Microsoft Foundation Classes Reference and related 6 | // electronic documentation provided with the library. 7 | // See these sources for detailed information regarding the 8 | // Microsoft Foundation Classes product. 9 | 10 | #include "stdafx.h" 11 | #include "DuiDesigner.h" 12 | #include "MainFrm.h" 13 | #include "ResourceView.h" 14 | 15 | #ifdef _DEBUG 16 | #define new DEBUG_NEW 17 | #undef THIS_FILE 18 | static char THIS_FILE[] = __FILE__; 19 | #endif 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | // CResourceViewBar 23 | 24 | CResourceViewBar::CResourceViewBar() 25 | { 26 | g_pResourceView = this; 27 | } 28 | 29 | CResourceViewBar::~CResourceViewBar() 30 | { 31 | m_mapTree.RemoveAll(); 32 | 33 | POSITION pos; 34 | CString strKey; 35 | CStringArray* pstrArray; 36 | for(pos=m_mapImageArray.GetStartPosition(); pos != NULL; ) 37 | { 38 | m_mapImageArray.GetNextAssoc(pos, strKey, (void*&)pstrArray); 39 | delete pstrArray; 40 | } 41 | m_mapImageArray.RemoveAll(); 42 | } 43 | 44 | BEGIN_MESSAGE_MAP(CResourceViewBar, CDockablePane) 45 | ON_WM_CREATE() 46 | ON_WM_SIZE() 47 | ON_WM_CONTEXTMENU() 48 | ON_COMMAND(ID_EDIT_CUT, OnEditCut) 49 | ON_COMMAND(ID_EDIT_COPY, OnEditCopy) 50 | ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) 51 | ON_COMMAND(ID_EDIT_CLEAR, OnEditClear) 52 | ON_WM_PAINT() 53 | ON_WM_SETFOCUS() 54 | END_MESSAGE_MAP() 55 | 56 | ///////////////////////////////////////////////////////////////////////////// 57 | // CResourceViewBar message handlers 58 | 59 | int CResourceViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 60 | { 61 | if (CDockablePane::OnCreate(lpCreateStruct) == -1) 62 | return -1; 63 | 64 | CRect rectDummy; 65 | rectDummy.SetRectEmpty(); 66 | 67 | // Create view: 68 | const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS; 69 | 70 | if (!m_wndResourceView.Create(dwViewStyle, rectDummy, this, 3)) 71 | { 72 | TRACE0("Failed to create workspace view\n"); 73 | return -1; // fail to create 74 | } 75 | 76 | // Load view images: 77 | m_ResourceViewImages.Create(IDB_RESOURCE_VIEW, 16, 0, RGB(255, 0, 255)); 78 | m_wndResourceView.SetImageList(&m_ResourceViewImages, TVSIL_NORMAL); 79 | 80 | // Fill view context(dummy code, don't seek here something magic :-)): 81 | InitResourceView(); 82 | 83 | OnChangeVisualStyle(); 84 | return 0; 85 | } 86 | 87 | void CResourceViewBar::OnSize(UINT nType, int cx, int cy) 88 | { 89 | CDockablePane::OnSize(nType, cx, cy); 90 | 91 | //if (CanAdjustLayout()) 92 | { 93 | m_wndResourceView.SetWindowPos(NULL, 1, 1, cx - 2, cy - 2, SWP_NOACTIVATE | SWP_NOZORDER); 94 | } 95 | } 96 | 97 | void CResourceViewBar::InitResourceView() 98 | { 99 | } 100 | 101 | void CResourceViewBar::OnContextMenu(CWnd* pWnd, CPoint point) 102 | { 103 | CTreeCtrl* pWndTree = (CTreeCtrl*) &m_wndResourceView; 104 | ASSERT_VALID(pWndTree); 105 | 106 | if (pWnd != pWndTree) 107 | { 108 | CDockablePane::OnContextMenu(pWnd, point); 109 | return; 110 | } 111 | 112 | if (point != CPoint(-1, -1)) 113 | { 114 | // Select clicked item: 115 | CPoint ptTree = point; 116 | pWndTree->ScreenToClient(&ptTree); 117 | 118 | UINT flags = 0; 119 | HTREEITEM hTreeItem = pWndTree->HitTest(ptTree, &flags); 120 | if (hTreeItem != NULL) 121 | { 122 | pWndTree->SelectItem(hTreeItem); 123 | } 124 | } 125 | 126 | pWndTree->SetFocus(); 127 | theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_RESOURCE, point.x, point.y, this, TRUE); 128 | } 129 | 130 | void CResourceViewBar::OnEditCut() 131 | { 132 | // TODO: Add your command handler code here 133 | 134 | } 135 | 136 | void CResourceViewBar::OnEditCopy() 137 | { 138 | // TODO: Add your command handler code here 139 | 140 | } 141 | 142 | void CResourceViewBar::OnEditPaste() 143 | { 144 | // TODO: Add your command handler code here 145 | 146 | } 147 | 148 | void CResourceViewBar::OnEditClear() 149 | { 150 | // TODO: Add your command handler code here 151 | 152 | } 153 | 154 | void CResourceViewBar::OnPaint() 155 | { 156 | CPaintDC dc(this); // device context for painting 157 | 158 | CRect rectTree; 159 | m_wndResourceView.GetWindowRect(rectTree); 160 | ScreenToClient(rectTree); 161 | 162 | rectTree.InflateRect(1, 1); 163 | dc.Draw3dRect(rectTree, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DSHADOW)); 164 | } 165 | 166 | void CResourceViewBar::OnSetFocus(CWnd* pOldWnd) 167 | { 168 | CDockablePane::OnSetFocus(pOldWnd); 169 | m_wndResourceView.SetFocus(); 170 | } 171 | 172 | void CResourceViewBar::OnChangeVisualStyle() 173 | { 174 | m_ResourceViewImages.DeleteImageList(); 175 | 176 | UINT uiBmpId = theApp.m_bHiColorIcons ? IDB_RESOURCE_VIEW24 : IDB_RESOURCE_VIEW; 177 | 178 | CBitmap bmp; 179 | if (!bmp.LoadBitmap(uiBmpId)) 180 | { 181 | TRACE(_T("Can't load bitmap: %x\n"), uiBmpId); 182 | ASSERT(FALSE); 183 | return; 184 | } 185 | 186 | BITMAP bmpObj; 187 | bmp.GetBitmap(&bmpObj); 188 | 189 | UINT nFlags = ILC_MASK; 190 | 191 | nFlags |= (theApp.m_bHiColorIcons) ? ILC_COLOR24 : ILC_COLOR4; 192 | 193 | m_ResourceViewImages.Create(16, bmpObj.bmHeight, nFlags, 0, 0); 194 | m_ResourceViewImages.Add(&bmp, RGB(255, 0, 255)); 195 | 196 | m_wndResourceView.SetImageList(&m_ResourceViewImages, TVSIL_NORMAL); 197 | } 198 | 199 | void CResourceViewBar::InsertImageTree(CString strTitle, CString strPath) 200 | { 201 | HTREEITEM hRoot = m_wndResourceView.InsertItem(strTitle, 0, 0, TVI_ROOT); 202 | m_wndResourceView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD); 203 | m_mapTree.SetAt(strTitle, (void*)hRoot); 204 | CStringArray* pstrArray = new CStringArray; 205 | m_mapImageArray.SetAt(strTitle, (void*)pstrArray); 206 | 207 | if(strPath.IsEmpty()) 208 | return; 209 | 210 | int nPos = strPath.ReverseFind('\\'); 211 | if(nPos == -1) 212 | return; 213 | CString strDir = strPath.Left(nPos + 1); 214 | WIN32_FIND_DATA FindFileData = {0}; 215 | CString strFind = strDir + _T("*.*"); 216 | HANDLE hFind = ::FindFirstFile(strFind, &FindFileData); 217 | if(hFind == INVALID_HANDLE_VALUE) 218 | return; 219 | do 220 | { 221 | CString strExt = _tcsrchr(FindFileData.cFileName, _T('.')) + 1; 222 | if(strExt.IsEmpty()) 223 | continue; 224 | int nType = 0; 225 | if(strExt == _T("bmp")) 226 | nType = 1; 227 | else if(strExt == _T("jpg")) 228 | nType = 2; 229 | else if(strExt == _T("png")) 230 | nType = 3; 231 | if(nType > 0) 232 | { 233 | pstrArray->Add(strDir + FindFileData.cFileName); 234 | HTREEITEM hItem = m_wndResourceView.InsertItem(FindFileData.cFileName, nType, nType, hRoot); 235 | } 236 | }while(::FindNextFile(hFind, &FindFileData)); 237 | ::FindClose(hFind); 238 | m_wndResourceView.Expand(hRoot, TVE_EXPAND); 239 | } 240 | 241 | void CResourceViewBar::RemoveImageTree(CString strTree) 242 | { 243 | HTREEITEM hTree; 244 | if(!m_mapTree.Lookup(strTree, (void*&)hTree)) 245 | return; 246 | 247 | m_wndResourceView.DeleteItem(hTree); 248 | m_mapTree.RemoveKey(strTree); 249 | 250 | CStringArray* pstrArray = NULL; 251 | if(!m_mapImageArray.Lookup(strTree, (void*&)pstrArray)) 252 | return; 253 | 254 | m_mapImageArray.RemoveKey(strTree); 255 | delete pstrArray; 256 | } 257 | 258 | void CResourceViewBar::RenameImageTree(LPCTSTR pstrTree, LPCTSTR pstrNewName) 259 | { 260 | HTREEITEM hTree; 261 | if(!m_mapTree.Lookup(pstrTree, (void*&)hTree)) 262 | return; 263 | 264 | m_wndResourceView.SetItemText(hTree, pstrNewName); 265 | m_mapTree.RemoveKey(pstrTree); 266 | m_mapTree.SetAt(pstrNewName, (void*)hTree); 267 | 268 | CStringArray* pstrArray = NULL; 269 | if(!m_mapImageArray.Lookup(pstrTree, (void*&)pstrArray)) 270 | return; 271 | 272 | m_mapImageArray.RemoveKey(pstrTree); 273 | m_mapImageArray.SetAt(pstrNewName, (void*)pstrArray); 274 | } 275 | 276 | void CResourceViewBar::InsertImage(CString strImage, CString strTree) 277 | { 278 | if(strImage.IsEmpty()) 279 | return; 280 | HTREEITEM hTree; 281 | if(!m_mapTree.Lookup(strTree, (void*&)hTree)) 282 | return; 283 | CStringArray* pstrArray = NULL; 284 | if(!m_mapImageArray.Lookup(strTree, (void*&)pstrArray)) 285 | return; 286 | 287 | for(int i=0; iGetSize(); i++) 288 | { 289 | if((*pstrArray)[i] == strImage) 290 | return; 291 | } 292 | 293 | int nPos = strImage.ReverseFind('\\'); 294 | if(nPos == -1) 295 | return; 296 | CString strName = strImage.Right(strImage.GetLength() - nPos - 1); 297 | nPos = strName.ReverseFind('.'); 298 | if(nPos == -1) 299 | return; 300 | CString strExt = strName.Right(strName.GetLength() - nPos - 1); 301 | int nType = 0; 302 | if(strExt == _T("bmp")) 303 | nType = 1; 304 | else if(strExt == _T("jpg")) 305 | nType = 2; 306 | else if(strExt == _T("png")) 307 | nType = 3; 308 | m_wndResourceView.InsertItem(strName, nType, nType, hTree); 309 | pstrArray->Add(strImage); 310 | } 311 | 312 | const CStringArray* CResourceViewBar::GetImageTree(CString strTree) const 313 | { 314 | 315 | CStringArray* pstrArray = NULL; 316 | m_mapImageArray.Lookup(strTree, (void*&)pstrArray); 317 | 318 | return pstrArray; 319 | } 320 | 321 | void CResourceViewBar::CopyImageToSkinDir(LPCTSTR pstrSkinDir, LPCTSTR pstrTree) 322 | { 323 | CStringArray* pstrArray = NULL; 324 | if(!m_mapImageArray.Lookup(pstrTree, (void*&)pstrArray)) 325 | return; 326 | 327 | for(int i=0; iGetSize(); i++) 328 | { 329 | CString strPath = (*pstrArray)[i]; 330 | int nPos = strPath.ReverseFind('\\'); 331 | if(nPos == -1) 332 | continue; 333 | 334 | CString strDir = strPath.Left(nPos + 1); 335 | if(strDir != pstrSkinDir) 336 | { 337 | CString strName = strPath.Right(strPath.GetLength() - nPos - 1); 338 | CopyFile(strPath, pstrSkinDir + strName, TRUE); 339 | } 340 | } 341 | } 342 | -------------------------------------------------------------------------------- /DuiLib/Layout/UIHorizontalLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UIHorizontalLayout.h" 3 | 4 | namespace DuiLib 5 | { 6 | CHorizontalLayoutUI::CHorizontalLayoutUI() : m_iSepWidth(0), m_uButtonState(0), m_bImmMode(false) 7 | { 8 | ptLastMouse.x = ptLastMouse.y = 0; 9 | ::ZeroMemory(&m_rcNewPos, sizeof(m_rcNewPos)); 10 | } 11 | 12 | LPCTSTR CHorizontalLayoutUI::GetClass() const 13 | { 14 | return _T("HorizontalLayoutUI"); 15 | } 16 | 17 | LPVOID CHorizontalLayoutUI::GetInterface(LPCTSTR pstrName) 18 | { 19 | if( _tcscmp(pstrName, DUI_CTR_HORIZONTALLAYOUT) == 0 ) return static_cast(this); 20 | return CContainerUI::GetInterface(pstrName); 21 | } 22 | 23 | UINT CHorizontalLayoutUI::GetControlFlags() const 24 | { 25 | if( IsEnabled() && m_iSepWidth != 0 ) return UIFLAG_SETCURSOR; 26 | else return 0; 27 | } 28 | 29 | void CHorizontalLayoutUI::SetPos(RECT rc) 30 | { 31 | CControlUI::SetPos(rc); 32 | rc = m_rcItem; 33 | 34 | // Adjust for inset 35 | rc.left += m_rcInset.left; 36 | rc.top += m_rcInset.top; 37 | rc.right -= m_rcInset.right; 38 | rc.bottom -= m_rcInset.bottom; 39 | 40 | if( m_items.GetSize() == 0) { 41 | ProcessScrollBar(rc, 0, 0); 42 | return; 43 | } 44 | 45 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) rc.right -= m_pVerticalScrollBar->GetFixedWidth(); 46 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight(); 47 | 48 | // Determine the width of elements that are sizeable 49 | SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top }; 50 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) 51 | szAvailable.cx += m_pHorizontalScrollBar->GetScrollRange(); 52 | 53 | int nAdjustables = 0; 54 | int cxFixed = 0; 55 | int nEstimateNum = 0; 56 | for( int it1 = 0; it1 < m_items.GetSize(); it1++ ) { 57 | CControlUI* pControl = static_cast(m_items[it1]); 58 | if( !pControl->IsVisible() ) continue; 59 | if( pControl->IsFloat() ) continue; 60 | SIZE sz = pControl->EstimateSize(szAvailable); 61 | if( sz.cx == 0 ) { 62 | nAdjustables++; 63 | } 64 | else { 65 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth(); 66 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth(); 67 | } 68 | cxFixed += sz.cx + pControl->GetPadding().left + pControl->GetPadding().right; 69 | nEstimateNum++; 70 | } 71 | cxFixed += (nEstimateNum - 1) * m_iChildPadding; 72 | 73 | int cxExpand = 0; 74 | int cxNeeded = 0; 75 | if( nAdjustables > 0 ) cxExpand = MAX(0, (szAvailable.cx - cxFixed) / nAdjustables); 76 | // Position the elements 77 | SIZE szRemaining = szAvailable; 78 | int iPosX = rc.left; 79 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) { 80 | iPosX -= m_pHorizontalScrollBar->GetScrollPos(); 81 | } 82 | int iAdjustable = 0; 83 | int cxFixedRemaining = cxFixed; 84 | for( int it2 = 0; it2 < m_items.GetSize(); it2++ ) { 85 | CControlUI* pControl = static_cast(m_items[it2]); 86 | if( !pControl->IsVisible() ) continue; 87 | if( pControl->IsFloat() ) { 88 | SetFloatPos(it2); 89 | continue; 90 | } 91 | RECT rcPadding = pControl->GetPadding(); 92 | szRemaining.cx -= rcPadding.left; 93 | SIZE sz = pControl->EstimateSize(szRemaining); 94 | if( sz.cx == 0 ) { 95 | iAdjustable++; 96 | sz.cx = cxExpand; 97 | // Distribute remaining to last element (usually round-off left-overs) 98 | if( iAdjustable == nAdjustables ) { 99 | sz.cx = MAX(0, szRemaining.cx - rcPadding.right - cxFixedRemaining); 100 | } 101 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth(); 102 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth(); 103 | } 104 | else { 105 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth(); 106 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth(); 107 | 108 | cxFixedRemaining -= sz.cx; 109 | } 110 | 111 | sz.cy = pControl->GetFixedHeight(); 112 | if( sz.cy == 0 ) sz.cy = rc.bottom - rc.top - rcPadding.top - rcPadding.bottom; 113 | if( sz.cy < 0 ) sz.cy = 0; 114 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight(); 115 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight(); 116 | 117 | RECT rcCtrl = { iPosX + rcPadding.left, rc.top + rcPadding.top, iPosX + sz.cx + rcPadding.left + rcPadding.right, rc.top + rcPadding.top + sz.cy}; 118 | pControl->SetPos(rcCtrl); 119 | iPosX += sz.cx + m_iChildPadding + rcPadding.left + rcPadding.right; 120 | cxNeeded += sz.cx + rcPadding.left + rcPadding.right; 121 | szRemaining.cx -= sz.cx + m_iChildPadding + rcPadding.right; 122 | } 123 | cxNeeded += (nEstimateNum - 1) * m_iChildPadding; 124 | 125 | // Process the scrollbar 126 | ProcessScrollBar(rc, cxNeeded, 0); 127 | } 128 | 129 | void CHorizontalLayoutUI::DoPostPaint(HDC hDC, const RECT& rcPaint) 130 | { 131 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && !m_bImmMode ) { 132 | RECT rcSeparator = GetThumbRect(true); 133 | CRenderEngine::DrawColor(hDC, rcSeparator, 0xAA000000); 134 | } 135 | } 136 | 137 | void CHorizontalLayoutUI::SetSepWidth(int iWidth) 138 | { 139 | m_iSepWidth = iWidth; 140 | } 141 | 142 | int CHorizontalLayoutUI::GetSepWidth() const 143 | { 144 | return m_iSepWidth; 145 | } 146 | 147 | void CHorizontalLayoutUI::SetSepImmMode(bool bImmediately) 148 | { 149 | if( m_bImmMode == bImmediately ) return; 150 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && !m_bImmMode && m_pManager != NULL ) { 151 | m_pManager->RemovePostPaint(this); 152 | } 153 | 154 | m_bImmMode = bImmediately; 155 | } 156 | 157 | bool CHorizontalLayoutUI::IsSepImmMode() const 158 | { 159 | return m_bImmMode; 160 | } 161 | 162 | void CHorizontalLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 163 | { 164 | if( _tcscmp(pstrName, _T("sepwidth")) == 0 ) SetSepWidth(_ttoi(pstrValue)); 165 | else if( _tcscmp(pstrName, _T("sepimm")) == 0 ) SetSepImmMode(_tcscmp(pstrValue, _T("true")) == 0); 166 | else CContainerUI::SetAttribute(pstrName, pstrValue); 167 | } 168 | 169 | void CHorizontalLayoutUI::DoEvent(TEventUI& event) 170 | { 171 | if( m_iSepWidth != 0 ) { 172 | if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() ) 173 | { 174 | RECT rcSeparator = GetThumbRect(false); 175 | if( ::PtInRect(&rcSeparator, event.ptMouse) ) { 176 | m_uButtonState |= UISTATE_CAPTURED; 177 | ptLastMouse = event.ptMouse; 178 | m_rcNewPos = m_rcItem; 179 | if( !m_bImmMode && m_pManager ) m_pManager->AddPostPaint(this); 180 | return; 181 | } 182 | } 183 | if( event.Type == UIEVENT_BUTTONUP ) 184 | { 185 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { 186 | m_uButtonState &= ~UISTATE_CAPTURED; 187 | m_rcItem = m_rcNewPos; 188 | if( !m_bImmMode && m_pManager ) m_pManager->RemovePostPaint(this); 189 | NeedParentUpdate(); 190 | return; 191 | } 192 | } 193 | if( event.Type == UIEVENT_MOUSEMOVE ) 194 | { 195 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { 196 | LONG cx = event.ptMouse.x - ptLastMouse.x; 197 | ptLastMouse = event.ptMouse; 198 | RECT rc = m_rcNewPos; 199 | if( m_iSepWidth >= 0 ) { 200 | if( cx > 0 && event.ptMouse.x < m_rcNewPos.right - m_iSepWidth ) return; 201 | if( cx < 0 && event.ptMouse.x > m_rcNewPos.right ) return; 202 | rc.right += cx; 203 | if( rc.right - rc.left <= GetMinWidth() ) { 204 | if( m_rcNewPos.right - m_rcNewPos.left <= GetMinWidth() ) return; 205 | rc.right = rc.left + GetMinWidth(); 206 | } 207 | if( rc.right - rc.left >= GetMaxWidth() ) { 208 | if( m_rcNewPos.right - m_rcNewPos.left >= GetMaxWidth() ) return; 209 | rc.right = rc.left + GetMaxWidth(); 210 | } 211 | } 212 | else { 213 | if( cx > 0 && event.ptMouse.x < m_rcNewPos.left ) return; 214 | if( cx < 0 && event.ptMouse.x > m_rcNewPos.left - m_iSepWidth ) return; 215 | rc.left += cx; 216 | if( rc.right - rc.left <= GetMinWidth() ) { 217 | if( m_rcNewPos.right - m_rcNewPos.left <= GetMinWidth() ) return; 218 | rc.left = rc.right - GetMinWidth(); 219 | } 220 | if( rc.right - rc.left >= GetMaxWidth() ) { 221 | if( m_rcNewPos.right - m_rcNewPos.left >= GetMaxWidth() ) return; 222 | rc.left = rc.right - GetMaxWidth(); 223 | } 224 | } 225 | 226 | CDuiRect rcInvalidate = GetThumbRect(true); 227 | m_rcNewPos = rc; 228 | m_cxyFixed.cx = m_rcNewPos.right - m_rcNewPos.left; 229 | 230 | if( m_bImmMode ) { 231 | m_rcItem = m_rcNewPos; 232 | NeedParentUpdate(); 233 | } 234 | else { 235 | rcInvalidate.Join(GetThumbRect(true)); 236 | rcInvalidate.Join(GetThumbRect(false)); 237 | if( m_pManager ) m_pManager->Invalidate(rcInvalidate); 238 | } 239 | return; 240 | } 241 | } 242 | if( event.Type == UIEVENT_SETCURSOR ) 243 | { 244 | RECT rcSeparator = GetThumbRect(false); 245 | if( IsEnabled() && ::PtInRect(&rcSeparator, event.ptMouse) ) { 246 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE))); 247 | return; 248 | } 249 | } 250 | } 251 | CContainerUI::DoEvent(event); 252 | } 253 | 254 | RECT CHorizontalLayoutUI::GetThumbRect(bool bUseNew) const 255 | { 256 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && bUseNew) { 257 | if( m_iSepWidth >= 0 ) return CDuiRect(m_rcNewPos.right - m_iSepWidth, m_rcNewPos.top, m_rcNewPos.right, m_rcNewPos.bottom); 258 | else return CDuiRect(m_rcNewPos.left, m_rcNewPos.top, m_rcNewPos.left - m_iSepWidth, m_rcNewPos.bottom); 259 | } 260 | else { 261 | if( m_iSepWidth >= 0 ) return CDuiRect(m_rcItem.right - m_iSepWidth, m_rcItem.top, m_rcItem.right, m_rcItem.bottom); 262 | else return CDuiRect(m_rcItem.left, m_rcItem.top, m_rcItem.left - m_iSepWidth, m_rcItem.bottom); 263 | } 264 | } 265 | } 266 | --------------------------------------------------------------------------------