├── examples ├── __init__.py ├── animation_lib │ ├── __init__.py │ ├── common │ │ ├── __init__.py │ │ └── xdg.py │ └── animation │ │ └── __init__.py ├── resources │ ├── exe.ico │ ├── image │ │ ├── 123.png │ │ ├── gif.gif │ │ ├── avatar.png │ │ ├── bubble.png │ │ ├── img-1.jpg │ │ ├── img-2.jpg │ │ ├── img-3.jpg │ │ ├── img-4.jpg │ │ ├── img-5.jpg │ │ ├── img-6.jpg │ │ ├── img-7.jpg │ │ ├── img-8.jpg │ │ ├── logo.png │ │ ├── bubble2.png │ │ ├── progressBar.png │ │ └── sliderBar.png │ ├── login │ │ ├── img │ │ │ ├── BJ.png │ │ │ ├── logo.png │ │ │ ├── close1.png │ │ │ ├── close2.png │ │ │ ├── logo1.png │ │ │ ├── Selected.png │ │ │ ├── logo1 (2).png │ │ │ ├── Unselected1.png │ │ │ └── Unselected2.png │ │ └── resource.res │ ├── dianshangzhibo.ico │ ├── baidu │ │ ├── image │ │ │ └── baidu.png │ │ └── resource.res │ ├── qqmusic │ │ └── image │ │ │ ├── zip.png │ │ │ ├── 上一曲.png │ │ │ ├── 下一曲.png │ │ │ ├── 下载.png │ │ │ ├── 声音.png │ │ │ ├── 我喜欢.png │ │ │ ├── 推荐1.png │ │ │ ├── 推荐2.png │ │ │ ├── 更多.png │ │ │ ├── 电台.png │ │ │ ├── 视频.png │ │ │ ├── 音乐.png │ │ │ ├── close.png │ │ │ ├── logo.png │ │ │ ├── skin.png │ │ │ ├── start.png │ │ │ ├── 列表循环.png │ │ │ ├── 单曲循环 .png │ │ │ ├── 听歌辩曲.png │ │ │ ├── 播放列表.png │ │ │ ├── 播放暂停.png │ │ │ ├── 最近播放.png │ │ │ ├── 本地与下载.png │ │ │ ├── 试听列表.png │ │ │ ├── 随机播放.png │ │ │ ├── 顺序播放.png │ │ │ ├── maxIcon.png │ │ │ ├── maxIcon2.png │ │ │ ├── minIcon.png │ │ │ ├── search.png │ │ │ ├── setting.png │ │ │ ├── 上一曲_按下.png │ │ │ ├── 下一曲_按下.png │ │ │ ├── 音乐馆 │ │ │ ├── 111.jpg │ │ │ ├── 2-1.jpg │ │ │ ├── 2-2.jpg │ │ │ ├── 2-3.jpg │ │ │ ├── 2-4.jpg │ │ │ ├── 2-5.jpg │ │ │ ├── 222.jpg │ │ │ ├── 2-1-1.jpg │ │ │ ├── 2-2-1.jpg │ │ │ ├── 2-3-1.jpg │ │ │ ├── 2-4-1.jpg │ │ │ └── 2-5-1.jpg │ │ │ ├── arrow_bottom.png │ │ │ ├── arrow_right.png │ │ │ └── QQ截图20210821220155.png │ ├── WmUi │ │ ├── beaming_face_with_smiling_eyes_3d.png │ │ ├── font │ │ │ └── Font Awesome 6 Pro-Solid-900.ttf │ │ ├── resource.res │ │ ├── 列表框项模板.xml │ │ ├── control │ │ │ ├── 窗口_提示框.xml │ │ │ ├── 窗口_输入框.xml │ │ │ ├── 窗口_信息框.xml │ │ │ └── 布局_分页器.xml │ │ ├── 列表树项模板.xml │ │ ├── 列表视图项模板.xml │ │ └── WmUi_Base.res │ └── svg │ │ ├── test-border.svg │ │ ├── 时间戳.svg │ │ ├── 成功.svg │ │ ├── 警告.svg │ │ ├── 查验.svg │ │ ├── 技术服务.svg │ │ ├── 底层架构.svg │ │ ├── 错误.svg │ │ ├── 图标-保存.svg │ │ ├── 消息.svg │ │ ├── 量子统计.svg │ │ ├── 公益.svg │ │ ├── play.svg │ │ ├── 接口配置.svg │ │ └── 淘公仔文字.svg ├── animation.py ├── baidu.py ├── login.py ├── qqmusic.py ├── event.py ├── window.py ├── trayicon.py ├── menu.py ├── draw.py ├── thread.py └── msg.py ├── xcgui ├── __init__.py └── decorators.py ├── pyxcgui ├── framework.h ├── xcgui │ ├── animation │ │ ├── XCAnimationGroup.hpp │ │ ├── XCAnimationItem.hpp │ │ └── XCAnimation.hpp │ ├── adapter │ │ ├── XCAdapter.hpp │ │ └── XCAdapterMap.hpp │ ├── shape │ │ ├── XCShapeLine.hpp │ │ ├── XCShapeGif.hpp │ │ ├── XCShapePicture.hpp │ │ ├── XCShapeEllipse.hpp │ │ ├── XCShapeRect.hpp │ │ ├── XCShapeText.hpp │ │ └── XCShapeGroupBox.hpp │ ├── window │ │ ├── XCMsgWindow.hpp │ │ ├── XCModelWindow.hpp │ │ └── XCFrameWindow.hpp │ ├── utils │ │ ├── Color.hpp │ │ └── String.hpp │ ├── XCResource.hpp │ ├── element │ │ ├── XCTextLink.hpp │ │ ├── XCLayoutEle.hpp │ │ ├── XCLayoutFrame.hpp │ │ ├── XCMonthCal.hpp │ │ ├── XCMenuBar.hpp │ │ ├── XCProgressBar.hpp │ │ ├── XCSliderBar.hpp │ │ ├── XCToolBar.hpp │ │ ├── XCDateTime.hpp │ │ └── XCScrollBar.hpp │ ├── XCLayoutBox.hpp │ ├── XCObjectUI.hpp │ ├── XCObject.hpp │ ├── XCApp.hpp │ ├── bkmanager │ │ └── XCBkManager.hpp │ ├── ease │ │ └── XCEase.hpp │ └── XCGlobal.hpp ├── binding │ ├── adapter │ │ ├── XAdapter.hpp │ │ ├── XAdapterMap.hpp │ │ └── XAdapterTree.hpp │ ├── animation │ │ ├── XAnimationGroup.hpp │ │ ├── XAnimationItem.hpp │ │ └── XAnimation.hpp │ ├── window │ │ ├── XMsgWindow.hpp │ │ ├── XModelWindow.hpp │ │ └── XFrameWindow.hpp │ ├── XLayoutBox.hpp │ ├── XObject.hpp │ ├── ease │ │ └── XEase.hpp │ ├── shape │ │ ├── XShapeLine.hpp │ │ ├── XShapeEllipse.hpp │ │ ├── XShapeGif.hpp │ │ ├── XShapePicture.hpp │ │ ├── XShapeRect.hpp │ │ ├── XShapeText.hpp │ │ ├── XShape.hpp │ │ ├── XShapeGroupBox.hpp │ │ └── XShapeTable.hpp │ ├── XTrayIcon.hpp │ ├── element │ │ ├── XTextLink.hpp │ │ ├── XLayoutEle.hpp │ │ ├── XLayoutFrame.hpp │ │ ├── XSliderBar.hpp │ │ ├── XProgressBar.hpp │ │ ├── XMonthCal.hpp │ │ ├── XPane.hpp │ │ ├── XDateTime.hpp │ │ ├── XScrollBar.hpp │ │ ├── XToolBar.hpp │ │ ├── XButton.hpp │ │ └── XScrollView.hpp │ ├── XResource.hpp │ ├── menu │ │ └── XMenuBar.hpp │ ├── manager │ │ ├── XUserDataManager.hpp │ │ └── XMainThreadManager.hpp │ ├── bkmanager │ │ ├── XBkManager.hpp │ │ └── XBkObject.hpp │ └── XWidget.hpp └── pch.h ├── stubs.bat ├── LICENSE ├── pyproject.toml └── README.md /examples/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/animation_lib/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/animation_lib/common/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/animation_lib/animation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/resources/exe.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/exe.ico -------------------------------------------------------------------------------- /xcgui/__init__.py: -------------------------------------------------------------------------------- 1 | from xcgui._xcgui import * 2 | from xcgui.decorators import * 3 | 4 | __VERSION__ = '0.1.7' 5 | -------------------------------------------------------------------------------- /examples/resources/image/123.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/123.png -------------------------------------------------------------------------------- /examples/resources/image/gif.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/gif.gif -------------------------------------------------------------------------------- /examples/resources/image/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/avatar.png -------------------------------------------------------------------------------- /examples/resources/image/bubble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/bubble.png -------------------------------------------------------------------------------- /examples/resources/image/img-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/img-1.jpg -------------------------------------------------------------------------------- /examples/resources/image/img-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/img-2.jpg -------------------------------------------------------------------------------- /examples/resources/image/img-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/img-3.jpg -------------------------------------------------------------------------------- /examples/resources/image/img-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/img-4.jpg -------------------------------------------------------------------------------- /examples/resources/image/img-5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/img-5.jpg -------------------------------------------------------------------------------- /examples/resources/image/img-6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/img-6.jpg -------------------------------------------------------------------------------- /examples/resources/image/img-7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/img-7.jpg -------------------------------------------------------------------------------- /examples/resources/image/img-8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/img-8.jpg -------------------------------------------------------------------------------- /examples/resources/image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/logo.png -------------------------------------------------------------------------------- /examples/resources/login/img/BJ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/BJ.png -------------------------------------------------------------------------------- /examples/resources/dianshangzhibo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/dianshangzhibo.ico -------------------------------------------------------------------------------- /examples/resources/image/bubble2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/bubble2.png -------------------------------------------------------------------------------- /examples/resources/login/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/logo.png -------------------------------------------------------------------------------- /examples/resources/baidu/image/baidu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/baidu/image/baidu.png -------------------------------------------------------------------------------- /examples/resources/image/progressBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/progressBar.png -------------------------------------------------------------------------------- /examples/resources/image/sliderBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/image/sliderBar.png -------------------------------------------------------------------------------- /examples/resources/login/img/close1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/close1.png -------------------------------------------------------------------------------- /examples/resources/login/img/close2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/close2.png -------------------------------------------------------------------------------- /examples/resources/login/img/logo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/logo1.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/zip.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/上一曲.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/上一曲.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/下一曲.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/下一曲.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/下载.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/下载.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/声音.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/声音.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/我喜欢.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/我喜欢.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/推荐1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/推荐1.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/推荐2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/推荐2.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/更多.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/更多.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/电台.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/电台.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/视频.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/视频.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐.png -------------------------------------------------------------------------------- /examples/resources/login/img/Selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/Selected.png -------------------------------------------------------------------------------- /examples/resources/login/img/logo1 (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/logo1 (2).png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/close.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/logo.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/skin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/skin.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/start.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/列表循环.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/列表循环.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/单曲循环 .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/单曲循环 .png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/听歌辩曲.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/听歌辩曲.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/播放列表.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/播放列表.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/播放暂停.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/播放暂停.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/最近播放.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/最近播放.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/本地与下载.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/本地与下载.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/试听列表.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/试听列表.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/随机播放.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/随机播放.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/顺序播放.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/顺序播放.png -------------------------------------------------------------------------------- /examples/resources/login/img/Unselected1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/Unselected1.png -------------------------------------------------------------------------------- /examples/resources/login/img/Unselected2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/login/img/Unselected2.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/maxIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/maxIcon.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/maxIcon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/maxIcon2.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/minIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/minIcon.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/search.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/setting.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/上一曲_按下.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/上一曲_按下.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/下一曲_按下.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/下一曲_按下.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/111.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/111.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-1.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-2.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-3.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-4.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-5.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/222.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/222.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-1-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-1-1.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-2-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-2-1.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-3-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-3-1.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-4-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-4-1.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/音乐馆/2-5-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/音乐馆/2-5-1.jpg -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/arrow_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/arrow_bottom.png -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/arrow_right.png -------------------------------------------------------------------------------- /pyxcgui/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 4 | // Windows 头文件 5 | #include 6 | -------------------------------------------------------------------------------- /examples/resources/qqmusic/image/QQ截图20210821220155.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/qqmusic/image/QQ截图20210821220155.png -------------------------------------------------------------------------------- /examples/resources/WmUi/beaming_face_with_smiling_eyes_3d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/WmUi/beaming_face_with_smiling_eyes_3d.png -------------------------------------------------------------------------------- /examples/resources/WmUi/font/Font Awesome 6 Pro-Solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smallevilbeast/pyxcgui/HEAD/examples/resources/WmUi/font/Font Awesome 6 Pro-Solid-900.ttf -------------------------------------------------------------------------------- /stubs.bat: -------------------------------------------------------------------------------- 1 | pybind11-stubgen xcgui._xcgui --enum-class-locations menu_popup_position_:xcgui._xcgui.menu_popup_position_ --enum-class-locations adjustLayout_:xcgui._xcgui.adjustLayout_ --enum-class-locations position_flag_:xcgui._xcgui.position_flag_ -o . 2 | -------------------------------------------------------------------------------- /examples/animation_lib/common/xdg.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def getRootPath(): 5 | return os.path.dirname(os.path.dirname(os.path.dirname(__file__))) 6 | 7 | 8 | def getResource(*args): 9 | return os.path.join(getRootPath(), "resources", *args) 10 | -------------------------------------------------------------------------------- /xcgui/decorators.py: -------------------------------------------------------------------------------- 1 | import functools 2 | from xcgui._xcgui import CallUiThread 3 | 4 | 5 | class RunUiThread: 6 | def __call__(self, func): 7 | self.func = func 8 | 9 | @functools.wraps(func) 10 | def objCall(*args, **kwargs): 11 | CallUiThread(self.func, *args, **kwargs) 12 | 13 | return objCall 14 | -------------------------------------------------------------------------------- /examples/animation.py: -------------------------------------------------------------------------------- 1 | from xcgui import XApp 2 | from animation_lib.animation.main import AnimationWindow 3 | 4 | if __name__ == '__main__': 5 | app = XApp(True) 6 | app.enableDPI(True) 7 | app.setPaintFrequency(10) 8 | # app.showLayoutFrame(True) 9 | # app.showSvgFrame(True) 10 | window = AnimationWindow() 11 | window.show(True) 12 | app.run() 13 | app.exit() 14 | -------------------------------------------------------------------------------- /examples/resources/baidu/resource.res: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/baidu.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | from xcgui import XApp, XWindow, XDesigner 3 | 4 | app = XApp() 5 | app.enableDPI(True) 6 | XDesigner.loadResource("resources\\baidu\\resource.res") 7 | 8 | 9 | class BaiduWindow(XWindow): 10 | def __init__(self): 11 | super(BaiduWindow, self).__init__() 12 | self.loadLayout("resources\\baidu\\main.xml") 13 | 14 | 15 | window = BaiduWindow() 16 | window.showWindow() 17 | app.run() 18 | app.exit() 19 | -------------------------------------------------------------------------------- /examples/login.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | from xcgui import XApp, XWindow, XDesigner 3 | 4 | app = XApp() 5 | app.enableDPI(True) 6 | XDesigner.loadResource("resources\\login\\resource.res") 7 | 8 | 9 | class LoginWindow(XWindow): 10 | def __init__(self): 11 | super(LoginWindow, self).__init__() 12 | self.loadLayout("resources\\login\\main.xml") 13 | 14 | 15 | window = LoginWindow() 16 | window.showWindow() 17 | app.run() 18 | app.exit() 19 | -------------------------------------------------------------------------------- /examples/qqmusic.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | from xcgui import XApp, XWindow, XDesigner 3 | 4 | app = XApp() 5 | app.enableDPI(True) 6 | XDesigner.loadResource("resources\\qqmusic\\resource.res") 7 | 8 | 9 | class QQMuiscWindow(XWindow): 10 | def __init__(self): 11 | super(QQMuiscWindow, self).__init__() 12 | self.loadLayout("resources\\qqmusic\\main.xml") 13 | 14 | 15 | window = QQMuiscWindow() 16 | window.showWindow() 17 | app.run() 18 | app.exit() 19 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/animation/XCAnimationGroup.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "XCAnimation.hpp" 4 | 5 | namespace xcgui { 6 | 7 | 8 | class XCAnimationGroup : public XCAnimation 9 | { 10 | 11 | public: 12 | XCAnimationGroup(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCAnimationGroup() = default; 18 | 19 | XCAnimationGroup(int nLoopCount=0) { 20 | 21 | m_handle = XAnimaGroup_Create(nLoopCount); 22 | } 23 | 24 | void AddItem(HXCGUI hSequence) { 25 | XAnimaGroup_AddItem(m_handle, hSequence); 26 | } 27 | }; 28 | } -------------------------------------------------------------------------------- /pyxcgui/binding/adapter/XAdapter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/adapter/XCAdapter.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareAdapter(py::module& m) { 8 | 9 | py::class_(m, "XAdapter") 10 | PYCASTOBJECT(XCAdapter) 11 | PYOBJECTVALID(XCAdapter, XC_ADAPTER) 12 | .def("enableAutoDestroy", &XCAdapter::EnableAutoDestroy, "enable"_a) 13 | .def("addRef", &XCAdapter::AddRef) 14 | .def("release", &XCAdapter::Release) 15 | .def("getRefCount", &XCAdapter::GetRefCount) 16 | .def("destroy", &XCAdapter::Destroy); 17 | ; 18 | } 19 | } -------------------------------------------------------------------------------- /examples/resources/svg/test-border.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | ]> 6 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/resources/WmUi/resource.res: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /pyxcgui/binding/animation/XAnimationGroup.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/animation/XCAnimationGroup.hpp" 4 | #include "xcgui/animation/XCAnimationSequence.hpp" 5 | 6 | 7 | 8 | namespace xcgui { 9 | 10 | void declareAnimationGroup(py::module& m) { 11 | py::class_(m, "XAnimationGroup") 12 | PYCASTOBJECT(XCAnimationGroup) 13 | PYOBJECTVALID(XCAnimationGroup, XC_ANIMATION_GROUP) 14 | .def(py::init(), "loopCount"_a=0) 15 | 16 | .def("addItem", [](XCAnimationGroup& self, const XCAnimationSequence& sequence) { 17 | self.AddItem(sequence.GetHandle()); 18 | }, "sequence"_a) 19 | ; 20 | } 21 | } -------------------------------------------------------------------------------- /examples/resources/WmUi/列表框项模板.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/event.py: -------------------------------------------------------------------------------- 1 | import xcgui 2 | from xcgui import XApp, XWindow, XEvent, XPoint 3 | 4 | 5 | class EventParamDemo(XWindow): 6 | def __init__(self): 7 | super(EventParamDemo, self).__init__(400, 300, "XCGUI界面库 for python") 8 | 9 | # 注册窗口鼠标按下事件 10 | self.regEvent(xcgui.WM_LBUTTONDOWN, self.onWinButtonDown) 11 | 12 | def onWinButtonDown(self, event: XEvent, _): 13 | flags = event.wParam 14 | 15 | # 指针转python对象 16 | pt = XPoint.cast(event.lParam) 17 | print(f"flags: {flags}, pt.x: {pt.x}, pt.y: {pt.y}") 18 | return False 19 | 20 | 21 | def main(): 22 | app = XApp() 23 | app.enableDPI(True) 24 | window = EventParamDemo() 25 | window.showWindow() 26 | app.run() 27 | app.exit() 28 | 29 | 30 | if __name__ == '__main__': 31 | main() 32 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/adapter/XCAdapter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pch.h" 4 | #include "xcgui/XCObject.hpp" 5 | 6 | namespace xcgui { 7 | 8 | class XCAdapter : public XCObject 9 | { 10 | public: 11 | XCAdapter() = default; 12 | 13 | XCAdapter(HXCGUI handle) 14 | { 15 | m_handle = handle; 16 | } 17 | 18 | // 增加引用计数() 19 | int AddRef() { 20 | return XAd_AddRef(m_handle); 21 | } 22 | 23 | // 释放引用计数() 24 | int Release() { 25 | return XAd_Release(m_handle); 26 | } 27 | 28 | // 取引用计数() 29 | int GetRefCount() { 30 | return XAd_GetRefCount(m_handle); 31 | } 32 | 33 | // 销毁() 34 | void Destroy() { 35 | XAd_Destroy(m_handle); 36 | } 37 | 38 | // 启用自动销毁() 39 | void EnableAutoDestroy(BOOL bEnable) { 40 | XAd_EnableAutoDestroy(m_handle, bEnable); 41 | } 42 | 43 | }; 44 | 45 | } -------------------------------------------------------------------------------- /examples/resources/svg/时间戳.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /pyxcgui/binding/window/XMsgWindow.hpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "xcgui/window/XCMsgWindow.hpp" 3 | 4 | namespace xcgui { 5 | 6 | void declareMsgWindow(py::module& m) { 7 | 8 | py::class_(m, "XMsgWindow") 9 | PYOBJECTVALID(XCMsgWindow, XC_MODALWINDOW) 10 | PYCASTOBJECT(XCMsgWindow) 11 | .def(py::init() 12 | ,"title"_a, "text"_a, "flags"_a= messageBox_flag_ok | messageBox_flag_icon_info, "hwndParent"_a=0, "xcStyle"_a= (int)window_style_modal) 13 | 14 | .def(py::init() 15 | , "exStyle"_a, "style"_a, "className"_a, "title"_a, "text"_a, "flags"_a, "hwndParent"_a, "xcStyle"_a = (int)window_style_modal) 16 | 17 | ; 18 | } 19 | } -------------------------------------------------------------------------------- /examples/resources/svg/成功.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/resources/svg/警告.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/shape/XCShapeLine.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShape.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCShapeLine : public XCShape 8 | { 9 | public: 10 | XCShapeLine() = default; 11 | 12 | XCShapeLine(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCShapeLine(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 18 | this->Create(x, y, cx, cy, hParent); 19 | } 20 | 21 | HXCGUI Create(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 22 | m_handle = XShapeLine_Create(x, y, cx, cy, hParent); 23 | return m_handle; 24 | } 25 | 26 | void SetColor(COLORREF color) { 27 | XShapeLine_SetColor(m_handle, color); 28 | } 29 | 30 | void SetPosition(int x1, int y1, int x2, int y2) { 31 | XShapeLine_SetPosition(m_handle, x1, y1, x2, y2); 32 | } 33 | }; 34 | } -------------------------------------------------------------------------------- /examples/resources/svg/查验.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | -------------------------------------------------------------------------------- /examples/resources/svg/技术服务.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyxcgui/binding/XLayoutBox.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCLayoutBox.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareLayoutBox(py::module& m) { 8 | 9 | py::class_(m, "XLayoutBox") 10 | PYCASTOBJECT(XCLayoutBox) 11 | PYOBJECTVALID(XCLayoutBox, XC_LAYOUT_BOX) 12 | .def("enableHorizon", &XCLayoutBox::EnableHorizon, "enable"_a) 13 | .def("enableAutoWrap", &XCLayoutBox::EnableAutoWrap, "enable"_a) 14 | .def("enableOverflowHide", &XCLayoutBox::EnableOverflowHide, "enable"_a) 15 | .def("setAlignH", &XCLayoutBox::SetAlignH, "align"_a) 16 | .def("setAlignV", &XCLayoutBox::SetAlignV, "align"_a) 17 | .def("setAlignBaseline", &XCLayoutBox::SetAlignBaseline, "align"_a) 18 | .def("setSpace", &XCLayoutBox::SetSpace, "space"_a) 19 | .def("setSpaceRow", &XCLayoutBox::SetSpaceRow, "space"_a); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/resources/svg/底层架构.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/resources/WmUi/control/窗口_提示框.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /examples/resources/WmUi/列表树项模板.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/shape/XCShapeGif.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShape.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCShapeGif : public XCShape 8 | { 9 | public: 10 | XCShapeGif() = default; 11 | 12 | XCShapeGif(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCShapeGif(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 18 | this->Create(x, y, cx, cy, hParent); 19 | } 20 | 21 | HXCGUI Create(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 22 | m_handle = XShapeGif_Create(x, y, cx, cy, hParent); 23 | return m_handle; 24 | } 25 | 26 | //@备注 设置GIF图片. 27 | //@参数 hImage 图片句柄. 28 | //@别名 置图片() 29 | void SetImage(HIMAGE hImage) { 30 | XShapeGif_SetImage(m_handle, hImage); 31 | } 32 | 33 | //@备注 获取图片句柄. 34 | //@返回 返回图片句柄. 35 | //@别名 取图片() 36 | HIMAGE GetImage() { 37 | return XShapeGif_GetImage(m_handle); 38 | } 39 | }; 40 | } -------------------------------------------------------------------------------- /examples/resources/svg/错误.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/shape/XCShapePicture.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShape.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCShapePicture : public XCShape 8 | { 9 | public: 10 | XCShapePicture() = default; 11 | 12 | XCShapePicture(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCShapePicture(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 18 | this->Create(x, y, cx, cy, hParent); 19 | } 20 | 21 | HXCGUI Create(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 22 | m_handle = XShapePic_Create(x, y, cx, cy, hParent); 23 | return m_handle; 24 | } 25 | 26 | //@备注 设置图片. 27 | //@参数 hImage 图片句柄. 28 | //@别名 置图片() 29 | void SetImage(HIMAGE hImage) { 30 | XShapePic_SetImage(m_handle, hImage); 31 | } 32 | 33 | //@备注 获取图片句柄 34 | //@返回 返回图片句柄. 35 | //@别名 取图片() 36 | HIMAGE GetImage() { 37 | return XShapePic_GetImage(m_handle); 38 | } 39 | }; 40 | } -------------------------------------------------------------------------------- /pyxcgui/binding/XObject.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCObject.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareBase(py::module& m) { 8 | 9 | py::class_(m, "XObject") 10 | PYCASTOBJECT(XCObject) 11 | .def("getType", &XCObject::GetType) 12 | .def("getTypeBase", &XCObject::GetTypeBase) 13 | .def("getHandle", [](XCObject& self) -> uintptr_t { 14 | return (uintptr_t)self.GetHandle(); 15 | }) 16 | .def("releaseAnimation", [](XCObject& self, bool end=false) { 17 | self.ReleaseAnimation(end); 18 | }, "end"_a=false) 19 | .def("getTypeEx", &XCObject::GetTypeEx) 20 | .def("setTypeEx", &XCObject::SetTypeEx, "nType"_a) 21 | .def("setProperty", &XCObject::SetProperty, "name"_a, "value"_a) 22 | .def("getProperty", &XCObject::GetProperty, "name"_a) 23 | .def("__eq__", [](const XCObject& self, const XCObject& other) { 24 | return self.GetHandle() == other.GetHandle(); 25 | }); 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /pyxcgui/binding/ease/XEase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/ease/XCEase.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareEase(py::module& m) { 8 | 9 | py::class_(m, "XEase") 10 | .def_static("linear", &XCEase::Linear, "pos"_a) 11 | .def_static("quad", &XCEase::Quad, "pos"_a, "flag"_a) 12 | .def_static("cubic", &XCEase::Cubic, "pos"_a, "flag"_a) 13 | .def_static("quart", &XCEase::Quart, "pos"_a, "flag"_a) 14 | .def_static("quint", &XCEase::Quint, "pos"_a, "flag"_a) 15 | .def_static("sine", &XCEase::Sine, "pos"_a, "flag"_a) 16 | .def_static("expo", &XCEase::Expo, "pos"_a, "flag"_a) 17 | .def_static("circ", &XCEase::Circ, "pos"_a, "flag"_a) 18 | .def_static("elastic", &XCEase::Elastic, "pos"_a, "flag"_a) 19 | .def_static("back", &XCEase::Back, "pos"_a, "flag"_a) 20 | .def_static("bounce", &XCEase::Bounce, "pos"_a, "flag"_a) 21 | .def_static("ex", &XCEase::Ex, "pos"_a, "flag"_a) 22 | ; 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/window/XCMsgWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pch.h" 4 | #include "xcgui/window/XCModelWindow.hpp" 5 | 6 | namespace xcgui { 7 | 8 | class XCMsgWindow : public XCModelWindow 9 | { 10 | public: 11 | XCMsgWindow() = default; 12 | XCMsgWindow(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCMsgWindow(const std::wstring& title, const std::wstring& text, int flags= messageBox_flag_ok | messageBox_flag_icon_info, uintptr_t hWndParent=0, int xcStyle = window_style_modal) { 18 | m_handle = XMsg_Create(title.c_str(), text.c_str(), flags, (HWND)hWndParent, xcStyle); 19 | } 20 | 21 | XCMsgWindow(DWORD dwExStyle, DWORD dwStyle, const std::wstring& className, 22 | const std::wstring& title, const std::wstring& text, int flags, uintptr_t hWndParent, int xcStyle = window_style_modal) 23 | { 24 | m_handle = XMsg_CreateEx(dwExStyle, dwStyle, className.c_str(), 25 | title.c_str(), text.c_str(), flags, (HWND)hWndParent, xcStyle); 26 | } 27 | }; 28 | } -------------------------------------------------------------------------------- /examples/window.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | import xcgui as xc 3 | 4 | 5 | class DemoWindow(xc.XWindow): 6 | def __init__(self): 7 | super(DemoWindow, self).__init__(600, 400, "测试") 8 | btn = xc.XButton(150, 120, 80, 30, "打开", self) 9 | btn.regEvent(xc.XE_BNCLICK, self.onBtnClick) 10 | 11 | def onBtnClick(self, event, _): 12 | dlg = xc.XModelWindow(400, 300, "提示", self.getHWND()) 13 | okBtn = xc.XButton(200, 250, 80, 30, "确定", dlg) 14 | okBtn.regEvent(xc.XE_BNCLICK, lambda e, _: dlg.endModal(xc.messageBox_flag_ok)) 15 | cancelBtn = xc.XButton(290, 250, 80, 30, "取消", dlg) 16 | cancelBtn.regEvent(xc.XE_BNCLICK, lambda e, _: dlg.endModal(xc.messageBox_flag_cancel)) 17 | 18 | flag = dlg.doModal() 19 | if flag == xc.messageBox_flag_ok: 20 | xc.Alert("提示", "你点了确定") 21 | 22 | 23 | if __name__ == '__main__': 24 | app = xc.XApp() 25 | app.enableDPI(True) 26 | window = DemoWindow() 27 | window.show(True) 28 | app.run() 29 | app.exit() 30 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/utils/Color.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include 4 | #include "String.hpp" 5 | 6 | COLORREF hexToRGBColorRef(std::string hex) { 7 | 8 | if (hex.at(0) == '#') { 9 | hex.erase(0, 1); 10 | } 11 | 12 | while (hex.length() != 6) { 13 | hex += "0"; 14 | } 15 | 16 | std::vector colori = SplitWithCharacters(hex, 2); 17 | 18 | BYTE r = stoi(colori[0], nullptr, 16); 19 | BYTE g = stoi(colori[1], nullptr, 16); 20 | BYTE b = stoi(colori[2], nullptr, 16); 21 | 22 | return (RGB(r, g, b)) & 0xFFFFFFFF; 23 | } 24 | 25 | COLORREF hexToRGBAColorRef(std::string hex) { 26 | 27 | if (hex.at(0) == '#') { 28 | hex.erase(0, 1); 29 | } 30 | 31 | while (hex.length() != 8) { 32 | hex += "0"; 33 | } 34 | 35 | std::vector colori = SplitWithCharacters(hex, 2); 36 | 37 | BYTE a = stoi(colori[0], nullptr, 16); 38 | BYTE r = stoi(colori[1], nullptr, 16); 39 | BYTE g = stoi(colori[2], nullptr, 16); 40 | BYTE b = stoi(colori[3], nullptr, 16); 41 | 42 | return (RGBA(r, g, b, a)) & 0xFFFFFFFF; 43 | } -------------------------------------------------------------------------------- /examples/resources/svg/图标-保存.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/resources/svg/消息.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShapeLine.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShapeLine.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareShapeLine(py::module& m) { 8 | py::class_(m, "XShapeLine") 9 | PYCASTOBJECT(XCShapeLine) 10 | PYOBJECTVALID(XCShapeLine, XC_SHAPE_LINE) 11 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 12 | HXCGUI handle = nullptr; 13 | if (parent) { 14 | handle = parent->GetHandle(); 15 | } 16 | XCShapeLine obj(x, y, cx, cy, handle); 17 | return obj; 18 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 19 | 20 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 21 | HXCGUI handle = nullptr; 22 | if (parent) { 23 | handle = parent->GetHandle(); 24 | } 25 | XCShapeLine obj(0,0, cx, cy, handle); 26 | return obj; 27 | }), "width"_a, "height"_a, "parent"_a=nullptr) 28 | 29 | 30 | .def("setColor", &XCShapeLine::SetColor, "color"_a) 31 | .def("setPosition", &XCShapeLine::SetPosition, "x1"_a, "y1"_a, "x2"_a, "y2"_a) 32 | ; 33 | } 34 | } -------------------------------------------------------------------------------- /examples/resources/svg/量子统计.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /pyxcgui/binding/XTrayIcon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCTrayIcon.hpp" 4 | #include "xcgui/window/XCWindow.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareTrayIcon(py::module& m) { 9 | py::class_(m, "XTrayIcon") 10 | .def(py::init<>()) 11 | .def(py::init(), "window"_a, "id"_a) 12 | 13 | // 静态方法 14 | .def_static("reset", &XCTrayIcon::Reset) 15 | .def_static("setCallbackMessage", &XCTrayIcon::SetCallbackMessage, "userMessage"_a) 16 | .def_static("setTips", &XCTrayIcon::SetTips, "tips"_a) 17 | .def_static("setPopupBalloon", [](const std::wstring& title, const std::wstring& text, const XCImage* balloonIcon = nullptr, int flags = 0) { 18 | XCTrayIcon::SetPopupBalloon(title, text, balloonIcon, flags); 19 | }, "title"_a, "text"_a, "balloonIcon"_a = nullptr, "flags"_a = 0) 20 | 21 | // 实例方法 22 | .def("add", &XCTrayIcon::Add) 23 | 24 | .def("remove", &XCTrayIcon::Remove) 25 | 26 | .def("modify", &XCTrayIcon::Modify) 27 | 28 | .def("setIcon", &XCTrayIcon::SetIcon, "hIcon"_a) 29 | 30 | .def("setFocus", &XCTrayIcon::SetFocus) 31 | ; 32 | } 33 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 evilbeast 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/resources/svg/公益.svg: -------------------------------------------------------------------------------- 1 | 2 | 5 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/XCResource.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | 4 | namespace xcgui { 5 | 6 | class XCResource 7 | { 8 | public: 9 | // 启用延迟加载;图片文件,列表项模板文件 10 | static void EnableDelayLoad(bool bEnable) { 11 | XRes_EnableDelayLoad(bEnable); 12 | } 13 | 14 | // 从资源中查找背景 15 | static HBKM GetBkM(const std::wstring& name) { 16 | return XRes_GetBkM(name.c_str()); 17 | } 18 | 19 | // 从资源中查找颜色 20 | static COLORREF GetColor(const std::wstring& name) { 21 | return XRes_GetColor(name.c_str()); 22 | } 23 | 24 | // 从资源中查找字体 25 | static HFONTX GetFont(const std::wstring& name) { 26 | return XRes_GetFont(name.c_str()); 27 | } 28 | 29 | // 获取资源ID整型值 30 | static int GetIDValue(const std::wstring& name) { 31 | return XRes_GetIDValue(name.c_str()); 32 | } 33 | 34 | // 查找资源图片 35 | static HIMAGE GetImage(const std::wstring& name) { 36 | return XRes_GetImage(name.c_str()); 37 | } 38 | 39 | // 从指定的资源文件中查找图片 40 | static HIMAGE GetImageEx(const std::wstring& fileName, const std::wstring& name) { 41 | return XRes_GetImageEx(fileName.c_str(), name.c_str()); 42 | } 43 | 44 | // 设置文件加载回调函数 45 | static void SetLoadFileCallback(funLoadFile pFun) { 46 | XRes_SetLoadFileCallback(pFun); 47 | } 48 | 49 | }; 50 | } -------------------------------------------------------------------------------- /examples/resources/svg/play.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCTextLink.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCButton.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCTextLink : public XCButton 8 | { 9 | public: 10 | XCTextLink(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | XCTextLink() = default; 16 | 17 | XCTextLink(int x, int y, int width, int height, const std::wstring& name, HXCGUI parent = NULL) { 18 | m_handle = XTextLink_Create(x, y, width, height, name.c_str(), parent); 19 | } 20 | 21 | // 启用下划线,鼠标离开状态 22 | void EnableUnderlineLeave(bool bEnable) { 23 | XTextLink_EnableUnderlineLeave(getEleHandle(), bEnable); 24 | } 25 | 26 | // 启用下划线,鼠标停留状态. 27 | void EnableUnderlineStay(bool bEnable) { 28 | XTextLink_EnableUnderlineStay(getEleHandle(), bEnable); 29 | } 30 | 31 | // 设置文本颜色,鼠标停留状态 32 | void SetTextColorStay(COLORREF color) { 33 | XTextLink_SetTextColorStay(getEleHandle(), color); 34 | } 35 | 36 | // 设置下划线颜色,鼠标离开状态 37 | void SetUnderlineColorLeave(COLORREF color) { 38 | XTextLink_SetUnderlineColorLeave(getEleHandle(), color); 39 | } 40 | 41 | // 设置下划线颜色,鼠标停留状态. 42 | void SetUnderlineColorStay(COLORREF color) { 43 | XTextLink_SetUnderlineColorStay(getEleHandle(), color); 44 | } 45 | }; 46 | } -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShapeEllipse.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShapeEllipse.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareShapeEllipse(py::module& m) { 8 | py::class_(m, "XShapeEllipse") 9 | PYCASTOBJECT(XCShapeEllipse) 10 | PYOBJECTVALID(XCShapeEllipse, XC_SHAPE_ELLIPSE) 11 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 12 | HXCGUI handle = nullptr; 13 | if (parent) { 14 | handle = parent->GetHandle(); 15 | } 16 | XCShapeEllipse obj(x, y, cx, cy, handle); 17 | return obj; 18 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 19 | 20 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 21 | HXCGUI handle = nullptr; 22 | if (parent) { 23 | handle = parent->GetHandle(); 24 | } 25 | XCShapeEllipse obj(0,0, cx, cy, handle); 26 | return obj; 27 | }), "width"_a, "height"_a, "parent"_a=nullptr) 28 | 29 | 30 | .def("setBorderColor", &XCShapeEllipse::SetBorderColor, "color"_a) 31 | .def("setFillColor", &XCShapeEllipse::SetFillColor, "color"_a) 32 | .def("enableBorder", &XCShapeEllipse::EnableBorder, "enable"_a) 33 | .def("enableFill", &XCShapeEllipse::EnableFill, "enable"_a) 34 | ; 35 | } 36 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/XCLayoutBox.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "XCObject.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCLayoutBox :virtual public XCObject 8 | { 9 | public: 10 | XCLayoutBox() { 11 | 12 | } 13 | XCLayoutBox(HXCGUI handle) 14 | { 15 | m_handle = handle; 16 | } 17 | // 布局盒子_启用水平 18 | void EnableHorizon(bool bEnable) { 19 | XLayoutBox_EnableHorizon(m_handle, bEnable); 20 | } 21 | 22 | // 布局盒子_启用自动换行 23 | void EnableAutoWrap(bool bEnable) { 24 | XLayoutBox_EnableAutoWrap(m_handle, bEnable); 25 | } 26 | 27 | // 布局盒子_启用溢出隐藏 28 | void EnableOverflowHide(bool bEnable) { 29 | XLayoutBox_EnableOverflowHide(m_handle, bEnable); 30 | } 31 | 32 | // 布局盒子_置水平对齐 33 | void SetAlignH(layout_align_ align) { 34 | XLayoutBox_SetAlignH(m_handle, align); 35 | } 36 | 37 | // 布局盒子_置垂直对齐 38 | void SetAlignV(layout_align_ align) { 39 | XLayoutBox_SetAlignV(m_handle, align); 40 | } 41 | 42 | // 布局盒子_置对齐基线 43 | void SetAlignBaseline(layout_align_axis_ align) { 44 | XLayoutBox_SetAlignBaseline(m_handle, align); 45 | } 46 | 47 | // 布局盒子_置间距 48 | void SetSpace(int space) { 49 | XLayoutBox_SetSpace(m_handle, space); 50 | } 51 | 52 | // 布局盒子_置行距 53 | void SetSpaceRow(int space) { 54 | XLayoutBox_SetSpaceRow(m_handle, space); 55 | } 56 | }; 57 | } -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShapeGif.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShapeGif.hpp" 4 | #include "xcgui/XCImage.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareShapeGif(py::module& m) { 9 | py::class_(m, "XShapeGif") 10 | PYCASTOBJECT(XCShapeGif) 11 | PYOBJECTVALID(XCShapeGif, XC_SHAPE_GIF) 12 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 13 | HXCGUI handle = nullptr; 14 | if (parent) { 15 | handle = parent->GetHandle(); 16 | } 17 | XCShapeGif obj(x, y, cx, cy, handle); 18 | return obj; 19 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 20 | 21 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 22 | HXCGUI handle = nullptr; 23 | if (parent) { 24 | handle = parent->GetHandle(); 25 | } 26 | XCShapeGif obj(0,0, cx, cy, handle); 27 | return obj; 28 | }), "width"_a, "height"_a, "parent"_a=nullptr) 29 | 30 | 31 | .def("setImage", [](XCShapeGif& self, const XCImage& image) { 32 | self.SetImage(image.getImageHandle()); 33 | }, "image"_a) 34 | .def("getImage", [](XCShapeGif& self) -> XCImage* { 35 | auto handle = self.GetImage(); 36 | if (!handle) return nullptr; 37 | return new XCImage(handle); 38 | }, py::return_value_policy::take_ownership) 39 | ; 40 | } 41 | } -------------------------------------------------------------------------------- /examples/trayicon.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | XCGUI 托盘图标示例 5 | 展示面向对象的XTrayIcon类的使用方法 6 | """ 7 | 8 | 9 | import xcgui 10 | from xcgui import XApp, XWindow, XButton, XEdit, XTrayIcon, XImage 11 | 12 | 13 | class DemoWindow(XWindow): 14 | def __init__(self): 15 | super(DemoWindow, self).__init__(400, 300, "XCGUI界面库 for python") 16 | self.enableLayout(True) 17 | self.setAlignV(xcgui.layout_align_center) 18 | self.setAlignH(xcgui.layout_align_center) 19 | self.enableHorizon(False) 20 | self.setSpace(20) 21 | self.btn = XButton(100, 30, "测试", self) 22 | self.btn.regEvent(xcgui.XE_BNCLICK, self.onBtnClick) 23 | self.edit = XEdit(200, 30, self) 24 | 25 | self.setupTrayIcon() 26 | 27 | def onBtnClick(self, event, userdata): 28 | self.edit.setText("你好,世界!") 29 | self.edit.redraw(True) 30 | 31 | def setupTrayIcon(self): 32 | self.tray = XTrayIcon(self, 100); 33 | self.tray.setIcon(xcgui.LoadIcon("resources\\exe.ico")) 34 | self.tray.setTips("XCGUI托盘图标测试") 35 | self.tray.add() 36 | 37 | 38 | def main(): 39 | app = XApp() 40 | app.enableDPI(True) 41 | window = DemoWindow() 42 | window.showWindow() 43 | app.run() 44 | app.exit() 45 | 46 | 47 | if __name__ == '__main__': 48 | main() 49 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/shape/XCShapeEllipse.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShape.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCShapeEllipse : public XCShape 8 | { 9 | public: 10 | XCShapeEllipse() = default; 11 | 12 | XCShapeEllipse(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCShapeEllipse(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 18 | this->Create(x, y, cx, cy, hParent); 19 | } 20 | 21 | HXCGUI Create(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 22 | m_handle = XShapeEllipse_Create(x, y, cx, cy, hParent); 23 | return m_handle; 24 | } 25 | 26 | //@备注 设置边框颜色. 27 | //@参数 color 颜色值, 请使用宏: RGBA() 28 | //@别名 置边框色() 29 | void SetBorderColor(COLORREF color) { 30 | XShapeEllipse_SetBorderColor(m_handle, color); 31 | } 32 | 33 | //@备注 设置填充颜色. 34 | //@参数 color 颜色值, 请使用宏: RGBA() 35 | //@别名 置填充色() 36 | void SetFillColor(COLORREF color) { 37 | XShapeEllipse_SetFillColor(m_handle, color); 38 | } 39 | 40 | //@备注 启用绘制圆边框. 41 | //@参数 bEnable 是否启用. 42 | //@别名 启用边框() 43 | void EnableBorder(bool bEnable) { 44 | XShapeEllipse_EnableBorder(m_handle, bEnable); 45 | } 46 | 47 | //@备注 启用填充圆. 48 | //@参数 bEnable 是否启用. 49 | //@别名 启用填充() 50 | void EnableFill(bool bEnable) { 51 | XShapeEllipse_EnableFill(m_handle, bEnable); 52 | } 53 | }; 54 | } -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShapePicture.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShapePicture.hpp" 4 | #include "xcgui/XCImage.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareShapePicture(py::module& m) { 9 | py::class_(m, "XShapePicture") 10 | PYCASTOBJECT(XCShapePicture) 11 | PYOBJECTVALID(XCShapePicture, XC_SHAPE_PICTURE) 12 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 13 | HXCGUI handle = nullptr; 14 | if (parent) { 15 | handle = parent->GetHandle(); 16 | } 17 | XCShapePicture obj(x, y, cx, cy, handle); 18 | return obj; 19 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 20 | 21 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 22 | HXCGUI handle = nullptr; 23 | if (parent) { 24 | handle = parent->GetHandle(); 25 | } 26 | XCShapePicture obj(0,0, cx, cy, handle); 27 | return obj; 28 | }), "width"_a, "height"_a, "parent"_a=nullptr) 29 | 30 | 31 | .def("setImage", [](XCShapePicture& self, const XCImage& image) { 32 | self.SetImage(image.getImageHandle()); 33 | }, "image"_a) 34 | .def("getImage", [](XCShapePicture& self) -> XCImage* { 35 | auto handle = self.GetImage(); 36 | if (!handle) return nullptr; 37 | return new XCImage(handle); 38 | }, py::return_value_policy::take_ownership) 39 | ; 40 | } 41 | } -------------------------------------------------------------------------------- /examples/menu.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | import xcgui 3 | from xcgui import XApp, XWindow, XEvent, XMenu, XButton, XImage, XSvg 4 | 5 | 6 | class MenuDemo(XWindow): 7 | def __init__(self): 8 | super(MenuDemo, self).__init__(400, 300, "XCGUI界面库 for python") 9 | self.enableLayout(True) 10 | self.setAlignV(xcgui.layout_align_center) 11 | self.setAlignH(xcgui.layout_align_center) 12 | self.btn = XButton(80, 30, "弹出菜单", self) 13 | self.btn.regEvent(xcgui.XE_BNCLICK, self.onBtnClick) 14 | 15 | self.menu = XMenu() 16 | self.menu.setAutoDestroy(False) 17 | self.createMenu() 18 | 19 | def createMenu(self): 20 | self.menu.addItem(101, "复制") 21 | self.menu.addItem(102, "粘贴") 22 | self.menu.addItem(0, "", 0, xcgui.menu_item_flag_separator) 23 | self.menu.addItem(103, "最近文件") 24 | self.menu.addItemIcon(1031, "东京热.mp4", 103, XImage.loadFile('resources\\dianshangzhibo.ico'), 0) 25 | 26 | def onBtnClick(self, event: XEvent, userdata) -> bool: 27 | pt = self.btn.pointClientToScreen(xcgui.position_flag_leftBottom) 28 | self.menu.popup(self.getHWND(), pt.x, pt.y, self.btn) 29 | 30 | 31 | def main(): 32 | app = XApp() 33 | app.enableDPI(True) 34 | window = MenuDemo() 35 | window.showWindow() 36 | app.run() 37 | app.exit() 38 | 39 | 40 | if __name__ == '__main__': 41 | main() 42 | -------------------------------------------------------------------------------- /pyxcgui/binding/adapter/XAdapterMap.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/adapter/XCAdapterMap.hpp" 4 | #include "xcgui/XCImage.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareAdapterMap(py::module& m) { 9 | 10 | py::class_(m, "XAdapterMap") 11 | PYCASTOBJECT(XCAdapterMap) 12 | PYOBJECTVALID(XCAdapterMap, XC_ADAPTER_MAP) 13 | .def(py::init<>()) 14 | 15 | .def("addItemText", &XCAdapterMap::AddItemText, "name"_a, "value"_a) 16 | .def("addItemImage", [](XCAdapterMap& self, const std::wstring& name, const XCImage& image) { 17 | return self.AddItemImage(name, image.getImageHandle()); 18 | }, "name"_a,"image"_a) 19 | .def("deleteItem", &XCAdapterMap::DeleteItem, "name"_a) 20 | .def("getCount", &XCAdapterMap::GetCount) 21 | .def("getItemText", &XCAdapterMap::GetItemText, "name"_a) 22 | 23 | .def("getItemImage", [](XCAdapterMap& self, const std::wstring& name) -> XCImage* { 24 | auto handle = self.GetItemImage(name); 25 | if (!handle) return nullptr; 26 | return new XCImage(handle); 27 | }, "name"_a, py::return_value_policy::take_ownership) 28 | 29 | .def("setItemText", &XCAdapterMap::SetItemText, "name"_a,"value"_a) 30 | .def("setItemImage", [](XCAdapterMap& self, const std::wstring& name, const XCImage& image){ 31 | return self.SetItemImage(name, image.getImageHandle()); 32 | }, "name"_a, "image"_a) 33 | 34 | 35 | ; 36 | } 37 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/XCObjectUI.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "XCObject.hpp" 4 | 5 | namespace xcgui { 6 | class XCObjectUI :virtual public XCObject 7 | { 8 | public: 9 | XCObjectUI() 10 | : XCObject() 11 | { 12 | } 13 | XCObjectUI(HXCGUI handle) 14 | { 15 | m_handle = handle; 16 | } 17 | 18 | // 设置UI对象样式 19 | void SetStyle(XC_OBJECT_STYLE nStyle) 20 | { 21 | XUI_SetStyle(m_handle, nStyle); 22 | } 23 | 24 | // 获取UI对象样式 25 | XC_OBJECT_STYLE GetStyle() 26 | { 27 | return XUI_GetStyle(m_handle); 28 | } 29 | 30 | //启用或禁用样式 31 | void EnableCSS(bool bEnable) 32 | { 33 | XUI_EnableCSS(m_handle, bEnable); 34 | } 35 | 36 | // 设置CSS[套用样式]名称 37 | void SetCssName(const std::wstring& name) 38 | { 39 | return XUI_SetCssName(m_handle, name.c_str()); 40 | } 41 | 42 | // 获取CSS样式名称 43 | std::wstring GetCssName() 44 | { 45 | auto pName = XUI_GetCssName(m_handle); 46 | if (pName) { 47 | return std::wstring(pName); 48 | } 49 | return L""; 50 | } 51 | 52 | // 通过name获取对象句柄 53 | HXCGUI FindObjectByName(const std::wstring& name) { 54 | return XC_GetObjectByName(name.c_str()); 55 | } 56 | 57 | // 通过UID获取对象句柄,不包括窗口对象. 58 | HXCGUI FindObjectByUID(int nId) { 59 | return XC_GetObjectByUID(nId); 60 | } 61 | 62 | // 通过UID名称获取对象句柄 63 | HXCGUI FindObjectByUIDName(const std::wstring& name) { 64 | return XC_GetObjectByUIDName(name.c_str()); 65 | } 66 | 67 | }; 68 | } -------------------------------------------------------------------------------- /pyxcgui/binding/animation/XAnimationItem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/animation/XCAnimationItem.hpp" 4 | #include "binding/manager/XUserDataManager.hpp" 5 | #include "binding/manager/XCallbackManager.hpp" 6 | 7 | namespace xcgui { 8 | 9 | void declareAnimationItem(py::module& m) { 10 | py::class_(m, "XAnimationItem") 11 | PYCASTOBJECT(XCAnimationItem) 12 | PYOBJECTVALID(XCAnimationItem, XC_ANIMATION_ITEM) 13 | .def("enableAutoDestroy", &XCAnimationItem::EnableAutoDestroy, "enable"_a) 14 | 15 | .def("enableCompleteRelease", &XCAnimationItem::EnableCompleteRelease, "enable"_a) 16 | 17 | .def("setCallback", [](XCAnimationItem& self, const XAnimationItemCallback& callback) { 18 | XCallbackManager::GetInstance()->SetAnimationItemCallback(self.GetHandle(), callback); 19 | }, "callback"_a) 20 | 21 | .def("getUserData", [](XCAnimationItem& self) { 22 | XUserDataManager::GetInstance()->GetUserData(self.GetHandle()); 23 | }) 24 | 25 | .def("setUserData", [](XCAnimationItem& self, const py::object& object) { 26 | XUserDataManager::GetInstance()->SetUserData(self.GetHandle(), object); 27 | }, "userdata"_a) 28 | 29 | .def("rotateSetCenter", &XCAnimationItem::RotateSetCenter, "x"_a, "y"_a, "offset"_a) 30 | .def("scaleSetPosition", &XCAnimationItem::ScaleSetPosition, "position"_a) 31 | .def("moveSetFlag", &XCAnimationItem::MoveSetFlag, "flags"_a) 32 | ; 33 | } 34 | } -------------------------------------------------------------------------------- /pyxcgui/pch.h: -------------------------------------------------------------------------------- 1 | #ifndef PCH_H 2 | #define PCH_H 3 | 4 | #include "framework.h" 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | namespace py = pybind11; 16 | using namespace pybind11::literals; 17 | 18 | #include "xcgui.h" 19 | 20 | #define SINGLETON_DEFINE(TypeName) \ 21 | static TypeName* GetInstance() \ 22 | { \ 23 | static TypeName type_instance; \ 24 | return &type_instance; \ 25 | } \ 26 | \ 27 | TypeName(const TypeName&) = delete; \ 28 | TypeName& operator=(const TypeName&) = delete 29 | 30 | #define PYCAST(TypeName)\ 31 | .def_static("cast", [](uintptr_t pointer) -> TypeName* { \ 32 | if (::IsBadReadPtr((const void*)pointer, sizeof(uintptr_t))) { \ 33 | return nullptr; \ 34 | } \ 35 | return (TypeName*)(pointer); \ 36 | }, "pointer"_a, py::return_value_policy::reference) 37 | 38 | #define PYCASTOBJECT(TypeName)\ 39 | .def_static("cast", [](uintptr_t pointer) -> TypeName* {\ 40 | return new TypeName((HXCGUI)pointer); \ 41 | }, "handle"_a, py::return_value_policy::take_ownership) 42 | 43 | #define PYOBJECTVALID(TypeName, ObjectType) \ 44 | .def("isValid", [](TypeName& self) -> bool { \ 45 | return self.GetType() == ObjectType; \ 46 | }) 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /examples/resources/svg/接口配置.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /pyxcgui/binding/element/XTextLink.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCTextLink.hpp" 4 | 5 | 6 | namespace xcgui { 7 | 8 | void declareTextLink(py::module& m) { 9 | py::class_(m, "XTextLink") 10 | PYCASTOBJECT(XCTextLink) 11 | PYOBJECTVALID(XCTextLink, XC_TEXTLINK) 12 | .def(py::init([](int x, int y, int cx, int cy, const std::wstring& text, XCObjectUI* parent = nullptr) { 13 | HXCGUI handle = nullptr; 14 | if (parent) { 15 | handle = parent->GetHandle(); 16 | } 17 | XCTextLink textLink(x, y, cx, cy, text, handle); 18 | return textLink; 19 | }), "x"_a, "y"_a, "width"_a, "height"_a, "text"_a, "parent"_a = nullptr) 20 | 21 | . def(py::init([](int cx, int cy, const std::wstring& text, XCObjectUI* parent=nullptr) { 22 | HXCGUI handle = nullptr; 23 | if (parent) { 24 | handle = parent->GetHandle(); 25 | } 26 | XCTextLink textLink(0,0, cx, cy, text, handle); 27 | return textLink; 28 | }), "width"_a, "height"_a, "text"_a, "parent"_a=nullptr) 29 | 30 | .def("enableUnderlineLeave", &XCTextLink::EnableUnderlineLeave, "enable"_a) 31 | .def("enableUnderlineStay", &XCTextLink::EnableUnderlineStay, "enable"_a) 32 | .def("setTextColorStay", &XCTextLink::SetTextColorStay, "color"_a) 33 | .def("setUnderlineColorLeave", &XCTextLink::SetUnderlineColorLeave, "color"_a) 34 | .def("setUnderlineColorStay", &XCTextLink::SetUnderlineColorStay, "color"_a) 35 | 36 | ; 37 | } 38 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/utils/String.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | std::vector SplitWithCharacters(const std::string& str, int splitLength) { 10 | int NumSubstrings = str.length() / splitLength; 11 | std::vector ret; 12 | 13 | for (int i = 0; i < NumSubstrings; i++) { 14 | ret.push_back(str.substr(i * splitLength, splitLength)); 15 | } 16 | 17 | // If there are leftover characters, create a shorter item at the end. 18 | if (str.length() % splitLength != 0) { 19 | ret.push_back(str.substr(splitLength * NumSubstrings)); 20 | } 21 | return ret; 22 | } 23 | 24 | // requires at least C++11 25 | const std::string vformat(const char* const zcFormat, ...) { 26 | 27 | // initialize use of the variable argument array 28 | va_list vaArgs; 29 | va_start(vaArgs, zcFormat); 30 | 31 | // reliably acquire the size 32 | // from a copy of the variable argument array 33 | // and a functionally reliable call to mock the formatting 34 | va_list vaArgsCopy; 35 | va_copy(vaArgsCopy, vaArgs); 36 | const int iLen = std::vsnprintf(NULL, 0, zcFormat, vaArgsCopy); 37 | va_end(vaArgsCopy); 38 | 39 | // return a formatted string without risking memory mismanagement 40 | // and without assuming any compiler or platform specific behavior 41 | std::vector zc(iLen + 1); 42 | std::vsnprintf(zc.data(), zc.size(), zcFormat, vaArgs); 43 | va_end(vaArgs); 44 | return std::string(zc.data(), iLen); 45 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCLayoutEle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCElement.hpp" 4 | #include "xcgui/XCLayoutBox.hpp" 5 | 6 | namespace xcgui { 7 | 8 | class XCLayoutEle : public XCElement, public XCLayoutBox 9 | { 10 | public: 11 | XCLayoutEle(HXCGUI handle) 12 | { 13 | m_handle = handle; 14 | } 15 | 16 | XCLayoutEle() = default; 17 | 18 | XCLayoutEle(int x, int y, int width, int height, HXCGUI parent = NULL) { 19 | m_handle = XLayout_Create(x, y, width, height, parent); 20 | } 21 | 22 | HXCGUI CreateEx(HXCGUI parent) { 23 | m_handle = XLayout_CreateEx(parent); 24 | return m_handle; 25 | } 26 | 27 | //@备注 启用布局功能. 28 | //@参数 bEnable 是否启用. 29 | //@别名 启用() 30 | void EnableLayout(bool bEnable) { 31 | XLayout_EnableLayout(getEleHandle(), bEnable); 32 | } 33 | 34 | //@备注 是否已经启用布局功能 35 | //@返回 如果启用布局返回TRUE,否则返回FALSE 36 | //@别名 是否启用() 37 | bool IsEnableLayout() { 38 | return XLayout_IsEnableLayout(getEleHandle()); 39 | } 40 | 41 | //@备注 显示布局边界. 42 | //@参数 bEnable 是否显示 43 | //@别名 显示布局边界() 44 | void ShowLayoutFrame(bool bEnable) { 45 | XLayout_ShowLayoutFrame(getEleHandle(), bEnable); 46 | } 47 | 48 | //@备注 获取宽度,不包含内边距大小 49 | //@返回 返回宽度 50 | //@别名 取内宽度() 51 | int GetWidthIn() { 52 | return XLayout_GetWidthIn(getEleHandle()); 53 | } 54 | 55 | //@备注 获取高度,不包含内边距大小 56 | //@返回 返回高度 57 | //@别名 取内高度() 58 | int GetHeightIn() { 59 | return XLayout_GetHeightIn(getEleHandle()); 60 | } 61 | 62 | 63 | 64 | }; 65 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/XCObject.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | 4 | namespace xcgui { 5 | 6 | class XCObject 7 | { 8 | public: 9 | XCObject() 10 | : m_handle(NULL) 11 | {} 12 | virtual ~XCObject() = default; 13 | 14 | XCObject(HXCGUI handle) 15 | { 16 | m_handle = handle; 17 | } 18 | 19 | // 获取对象最终类型 20 | XC_OBJECT_TYPE GetType() 21 | { 22 | return XObj_GetType(m_handle); 23 | } 24 | 25 | // 获取对象的基础类型 26 | XC_OBJECT_TYPE GetTypeBase() 27 | { 28 | return XObj_GetTypeBase(m_handle); 29 | } 30 | 31 | // 获取对象扩展类型 32 | XC_OBJECT_TYPE_EX GetTypeEx() 33 | { 34 | return XObj_GetTypeEx(m_handle); 35 | } 36 | 37 | // 如果是按钮, 请使用按钮的增强接口 XBtn_SetTypeEx() 38 | void SetTypeEx(XC_OBJECT_TYPE_EX nType) 39 | { 40 | XObj_SetTypeEx(m_handle, nType); 41 | } 42 | 43 | 44 | // 获取对象属性. 45 | std::wstring GetProperty(const std::wstring& name) { 46 | auto pName = XC_GetProperty(m_handle, name.c_str()); 47 | if (!pName) { 48 | return L""; 49 | } 50 | return pName; 51 | } 52 | 53 | bool SetProperty(const std::wstring& name, const std::wstring& value) { 54 | return XC_SetProperty(m_handle, name.c_str(), value.c_str()); 55 | } 56 | 57 | void ReleaseAnimation(bool end=true) { 58 | XAnima_ReleaseEx(m_handle, end); 59 | } 60 | 61 | virtual HXCGUI GetHandle() const 62 | { 63 | return m_handle; 64 | } 65 | 66 | 67 | void SetHandle(HXCGUI handle) 68 | { 69 | m_handle = handle; 70 | } 71 | 72 | protected: 73 | HXCGUI m_handle; 74 | }; 75 | 76 | } -------------------------------------------------------------------------------- /pyxcgui/binding/window/XModelWindow.hpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "xcgui/window/XCModelWindow.hpp" 3 | #include "xcgui/XCElement.hpp" 4 | #include "xcgui/XCStruct.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareModelWindow(py::module& m) { 9 | 10 | py::class_(m, "XModelWindow") 11 | PYCASTOBJECT(XCModelWindow) 12 | PYOBJECTVALID(XCModelWindow, XC_MODALWINDOW) 13 | .def(py::init<>()) 14 | .def(py::init([](int width, int height, const std::wstring& title) { 15 | XCModelWindow window(width, height, title, 0, window_style_default); 16 | return window; 17 | }), "width"_a, "height"_a, "title"_a) 18 | .def(py::init() 19 | ,"width"_a, "height"_a, "title"_a, "hwndParent"_a, "xcStyle"_a= (int)window_style_modal) 20 | 21 | .def(py::init() 23 | , "exStyle"_a, "style"_a, "className"_a, "x"_a, "y"_a, "width"_a, "height"_a, 24 | "title"_a, "hwndParent"_a, "xcStyle"_a= (int)window_style_modal) 25 | 26 | .def("attach", &XCModelWindow::Attach, "hwnd"_a, "style"_a) 27 | .def("doModal", &XCModelWindow::DoModal, py::call_guard()) 28 | .def("enableAutoClose", &XCModelWindow::EnableAutoClose, "enable"_a) 29 | .def("enableEscClose", &XCModelWindow::EnableEscClose, "enable"_a) 30 | .def("endModal", &XCModelWindow::EndModal, "result"_a, py::call_guard()) 31 | ; 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /examples/resources/WmUi/列表视图项模板.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCLayoutFrame.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCScrollView.hpp" 4 | #include "xcgui/XCLayoutBox.hpp" 5 | 6 | namespace xcgui { 7 | 8 | 9 | class XCLayoutFrame : public XCScrollView, public XCLayoutBox 10 | { 11 | 12 | public: 13 | XCLayoutFrame(HXCGUI handle) 14 | { 15 | m_handle = handle; 16 | } 17 | 18 | XCLayoutFrame() = default; 19 | 20 | XCLayoutFrame(int x, int y, int width, int height, HXCGUI parent = NULL) { 21 | 22 | m_handle = XLayoutFrame_Create(x, y, width, height, parent); 23 | } 24 | 25 | HXCGUI CreateEx(HXCGUI parent) { 26 | m_handle = XLayoutFrame_CreateEx(parent); 27 | return m_handle; 28 | } 29 | 30 | //@备注 启用布局功能 31 | //@参数 bEnable 是否启用 32 | //@别名 启用() 33 | void EnableLayout(bool bEnable) { 34 | XLayoutFrame_EnableLayout(getEleHandle(), bEnable); 35 | } 36 | 37 | //@备注 是否已经启用布局功能 38 | //@返回 如果启用布局返回TRUE,否则返回FALSE 39 | //@别名 是否启用() 40 | bool IsEnableLayout() { 41 | return XLayoutFrame_IsEnableLayout(getEleHandle()); 42 | } 43 | 44 | //@参数 bEnable 是否显示 45 | //@别名 显示布局边界() 46 | void ShowLayoutFrame(bool bEnable) { 47 | XLayoutFrame_ShowLayoutFrame(getEleHandle(), bEnable); 48 | } 49 | 50 | //@备注 获取宽度,不包含内边距大小 51 | //@返回 返回宽度 52 | //@别名 取内宽度() 53 | int GetWidthIn() { 54 | return XLayoutFrame_GetWidthIn(getEleHandle()); 55 | } 56 | 57 | //@备注 获取高度,不包含内边距大小 58 | //@返回 返回高度 59 | //@别名 取内高度() 60 | int GetHeightIn() { 61 | return XLayoutFrame_GetHeightIn(getEleHandle()); 62 | } 63 | 64 | 65 | }; 66 | } -------------------------------------------------------------------------------- /pyxcgui/binding/element/XLayoutEle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCLayoutEle.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareLayoutEle(py::module& m) { 8 | py::class_(m, "XLayoutEle") 9 | PYCASTOBJECT(XCLayoutEle) 10 | PYOBJECTVALID(XCLayoutEle, XC_ELE_LAYOUT) 11 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 12 | HXCGUI handle = nullptr; 13 | if (parent) { 14 | handle = parent->GetHandle(); 15 | } 16 | XCLayoutEle obj(x, y, cx, cy, handle); 17 | return obj; 18 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 19 | 20 | .def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 21 | HXCGUI handle = nullptr; 22 | if (parent) { 23 | handle = parent->GetHandle(); 24 | } 25 | XCLayoutEle obj(0,0, cx, cy, handle); 26 | return obj; 27 | }), "width"_a, "height"_a, "parent"_a=nullptr) 28 | 29 | .def(py::init([](XCObjectUI* parent) { 30 | HXCGUI handle = nullptr; 31 | if (parent) { 32 | handle = parent->GetHandle(); 33 | } 34 | XCLayoutEle obj; 35 | obj.CreateEx(handle); 36 | return obj; 37 | }), "parent"_a=nullptr) 38 | 39 | .def("enableLayout", &XCLayoutEle::EnableLayout, "enable"_a) 40 | .def("isEnableLayout", &XCLayoutEle::IsEnableLayout) 41 | .def("showLayoutFrame", &XCLayoutEle::ShowLayoutFrame, "enable"_a) 42 | .def("getWidthIn", &XCLayoutEle::GetWidthIn) 43 | .def("getHeightIn", &XCLayoutEle::GetHeightIn) 44 | 45 | ; 46 | } 47 | } -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShapeRect.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShapeRect.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareShapeRect(py::module& m) { 8 | py::class_(m, "XShapeRect") 9 | PYCASTOBJECT(XCShapeRect) 10 | PYOBJECTVALID(XCShapeRect, XC_SHAPE_RECT) 11 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 12 | HXCGUI handle = nullptr; 13 | if (parent) { 14 | handle = parent->GetHandle(); 15 | } 16 | XCShapeRect obj(x, y, cx, cy, handle); 17 | return obj; 18 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 19 | 20 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 21 | HXCGUI handle = nullptr; 22 | if (parent) { 23 | handle = parent->GetHandle(); 24 | } 25 | XCShapeRect obj(0,0, cx, cy, handle); 26 | return obj; 27 | }), "width"_a, "height"_a, "parent"_a=nullptr) 28 | 29 | 30 | .def("setBorderColor", &XCShapeRect::SetBorderColor, "color"_a) 31 | .def("setFillColor", &XCShapeRect::SetFillColor, "color"_a) 32 | 33 | .def("setRoundAngle", &XCShapeRect::SetRoundAngle, "width"_a, "height"_a) 34 | .def("getRoundAngle", [](XCShapeRect& self) { 35 | XCSize info; 36 | self.GetRoundAngle(&info.width, &info.height); 37 | return info; 38 | }) 39 | .def("enableBorder", &XCShapeRect::EnableBorder, "enable"_a) 40 | .def("enableFill", &XCShapeRect::EnableFill, "enable"_a) 41 | .def("enableRoundAngle", &XCShapeRect::EnableRoundAngle, "enable"_a) 42 | ; 43 | } 44 | } -------------------------------------------------------------------------------- /examples/draw.py: -------------------------------------------------------------------------------- 1 | import xcgui 2 | from xcgui import XApp, XWindow, XDraw, XEvent 3 | 4 | WM_PAINT = 0xF 5 | 6 | 7 | class DemoWindow(XWindow): 8 | def __init__(self): 9 | super(DemoWindow, self).__init__(400, 300, "demo") 10 | 11 | self.enableDragWindow(True) 12 | self.adjustLayout() 13 | 14 | self.regEvent(WM_PAINT, self.on_window_paint) 15 | 16 | self.image = xcgui.XImage.loadFile("resources\\image\\logo.png") 17 | self.image.setDrawType(xcgui.image_draw_type_fixed_ratio) 18 | self.shapePicture = xcgui.XShapePicture(50, 50, self) 19 | self.shapePicture.setImage(self.image) 20 | 21 | 22 | def on_window_paint(self, event: XEvent, _) -> bool: 23 | draw = XDraw.cast(event.wParam) 24 | rect = self.getClientRect() 25 | 26 | self.shapePicture.setAlpha(100) 27 | #draw.imageEx(self.image, 0, 0, rect.right - rect.left, rect.bottom - rect.top) 28 | #self.drawWindow(draw) 29 | 30 | draw.setBrushColor(xcgui.RGBA("#ffffffff")) 31 | rect.left += 20 32 | rect.top += 50 33 | rect.right -= 20 34 | rect.bottom -= 20 35 | draw.drawRect(rect) 36 | 37 | draw.setTextAlign(xcgui.textAlignFlag_center | xcgui.textAlignFlag_vcenter) 38 | draw.drawText("窗口自绘示例", rect) 39 | 40 | return True 41 | 42 | 43 | def main(): 44 | app = XApp(False) 45 | app.enableDPI(True) 46 | window = DemoWindow() 47 | window.showWindow() 48 | app.run() 49 | app.exit() 50 | 51 | 52 | if __name__ == '__main__': 53 | main() 54 | -------------------------------------------------------------------------------- /pyxcgui/binding/element/XLayoutFrame.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCLayoutFrame.hpp" 4 | 5 | namespace xcgui { 6 | 7 | void declareLayoutFrame(py::module& m) { 8 | py::class_(m, "XLayoutFrame") 9 | PYCASTOBJECT(XCLayoutFrame) 10 | PYOBJECTVALID(XCLayoutFrame, XC_LAYOUT_FRAME) 11 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 12 | HXCGUI handle = nullptr; 13 | if (parent) { 14 | handle = parent->GetHandle(); 15 | } 16 | XCLayoutFrame obj(x, y, cx, cy, handle); 17 | return obj; 18 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 19 | 20 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 21 | HXCGUI handle = nullptr; 22 | if (parent) { 23 | handle = parent->GetHandle(); 24 | } 25 | XCLayoutFrame obj(0,0, cx, cy, handle); 26 | return obj; 27 | }), "width"_a, "height"_a, "parent"_a=nullptr) 28 | 29 | .def(py::init([](XCObjectUI* parent) { 30 | HXCGUI handle = nullptr; 31 | if (parent) { 32 | handle = parent->GetHandle(); 33 | } 34 | XCLayoutFrame obj; 35 | obj.CreateEx(handle); 36 | return obj; 37 | }), "parent"_a=nullptr) 38 | 39 | .def("enableLayout", &XCLayoutFrame::EnableLayout, "enable"_a) 40 | .def("isEnableLayout", &XCLayoutFrame::IsEnableLayout) 41 | .def("showLayoutFrame", &XCLayoutFrame::ShowLayoutFrame, "enable"_a) 42 | .def("getWidthIn", &XCLayoutFrame::GetWidthIn) 43 | .def("getHeightIn", &XCLayoutFrame::GetHeightIn) 44 | 45 | ; 46 | } 47 | } -------------------------------------------------------------------------------- /examples/thread.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | import xcgui 3 | import functools 4 | import threading 5 | import requests 6 | from xcgui import XApp, XWindow, XEvent, XButton, XEdit, RunUiThread 7 | 8 | 9 | def threaded(f): 10 | @functools.wraps(f) 11 | def wrapper(*args, **kwargs): 12 | t = threading.Thread(target=f, args=args, kwargs=kwargs) 13 | t.daemon = True 14 | t.start() 15 | 16 | return wrapper 17 | 18 | 19 | class MenuDemo(XWindow): 20 | def __init__(self): 21 | super(MenuDemo, self).__init__(400, 300, "XCGUI界面库 for python") 22 | self.enableLayout(True) 23 | self.setAlignV(xcgui.layout_align_center) 24 | self.setAlignH(xcgui.layout_align_center) 25 | self.enableHorizon(False) 26 | self.setSpace(20) 27 | self.btn = XButton(300, 30, "主线程执行测试", self) 28 | self.btn.regEvent(34, self.onBtnClick) 29 | self.edit = XEdit(300, 30, self) 30 | 31 | # 通过线程获取ip 32 | @threaded 33 | def asyncGetIpInfo(self): 34 | text = requests.get('http://myip.ipip.net/').text 35 | self.updateBtnTextOnUiThread(text) 36 | 37 | def onBtnClick(self, event: XEvent, _) -> bool: 38 | self.asyncGetIpInfo() 39 | 40 | # 通过装饰器,在ui线程执行更改 41 | @RunUiThread() 42 | def updateBtnTextOnUiThread(self, text): 43 | self.edit.setText(text) 44 | self.edit.redraw(True) 45 | 46 | 47 | def main(): 48 | app = XApp() 49 | app.enableDPI(True) 50 | window = MenuDemo() 51 | window.showWindow() 52 | app.run() 53 | app.exit() 54 | 55 | 56 | if __name__ == '__main__': 57 | main() 58 | -------------------------------------------------------------------------------- /examples/msg.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | import xcgui 3 | from xcgui import XApp, XWindow, XEvent, XButton, XMsgWindow 4 | 5 | 6 | class MsgDemo(XWindow): 7 | def __init__(self): 8 | super(MsgDemo, self).__init__(400, 300, "XCGUI界面库 for python") 9 | self.enableLayout(True) 10 | self.setAlignV(xcgui.layout_align_center) 11 | self.setAlignH(xcgui.layout_align_center) 12 | self.btn = XButton(80, 30, "弹出消息框", self) 13 | self.btn.regEvent(xcgui.XE_BNCLICK, self.onBtnClick2) 14 | 15 | def onBtnClick(self, event: XEvent, _) -> bool: 16 | msg = XMsgWindow("炫彩界面库", "标题", 17 | xcgui.messageBox_flag_ok | xcgui.messageBox_flag_icon_info, 18 | self.getHWND(), 19 | xcgui.window_style_modal) 20 | flag = msg.doModal() 21 | print(flag) 22 | 23 | def onBtnClick2(self, event, _): 24 | flag = xcgui.MessageBox("消息提示", "Python库将发布", 25 | xcgui.messageBox_flag_ok | 26 | xcgui.messageBox_flag_cancel | 27 | xcgui.messageBox_flag_icon_qustion, 28 | self.getHWND()) 29 | if flag == xcgui.messageBox_flag_ok: 30 | xcgui.Alert("提示", "你点击了确定") 31 | elif flag == xcgui.messageBox_flag_cancel: 32 | xcgui.Alert("提示", "你点击了取消") 33 | 34 | 35 | def main(): 36 | app = XApp() 37 | app.enableDPI(True) 38 | window = MsgDemo() 39 | window.showWindow() 40 | app.run() 41 | app.exit() 42 | 43 | 44 | if __name__ == '__main__': 45 | main() 46 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCMonthCal.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCElement.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCMonthCal : public XCElement 8 | { 9 | public: 10 | XCMonthCal(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | XCMonthCal() = default; 16 | 17 | XCMonthCal(int x, int y, int width, int height, HXCGUI parent = NULL) { 18 | m_handle = XMonthCal_Create(x, y, width, height, parent); 19 | } 20 | 21 | 22 | HELE GetButton(monthCal_button_type_ nType) { 23 | return XMonthCal_GetButton(getEleHandle(), nType); 24 | } 25 | 26 | //@备注 设置月历当前年月日. 27 | //@参数 nYear 年. 28 | //@参数 nMonth 月. 29 | //@参数 nDay 日. 30 | //@别名 置当前日期() 31 | void SetToday(int nYear, int nMonth, int nDay) { 32 | XMonthCal_SetToday(getEleHandle(), nYear, nMonth, nDay); 33 | } 34 | 35 | //@备注 获取月历当前年月日. 36 | //@参数 pnYear 年.[INT,OUT] 37 | //@参数 pnMonth 月.[INT,OUT] 38 | //@参数 pnDay 日.[INT,OUT] 39 | //@别名 取当前日期() 40 | void GetToday(int* pnYear, int* pnMonth, int* pnDay) { 41 | XMonthCal_GetToday(getEleHandle(), pnYear, pnMonth, pnDay); 42 | } 43 | 44 | //@备注 获取月历选中的年月日. 45 | //@参数 pnYear 年.[INT,OUT] 46 | //@参数 pnMonth 月.[INT,OUT] 47 | //@参数 pnDay 日.[INT,OUT] 48 | //@别名 取选择日期() 49 | void GetSelDate(int* pnYear, int* pnMonth, int* pnDay) { 50 | XMonthCal_GetSelDate(getEleHandle(), pnYear, pnMonth, pnDay); 51 | } 52 | 53 | //@参数 nFlag 1:周六,周日文字颜色, 2:日期文字的颜色; 其它周文字颜色, 使用元素自身颜色 54 | //@参数 color 颜色值 55 | //@别名 置文本颜色() 56 | void SetTextColor(int nFlag, COLORREF color) { 57 | XMonthCal_SetTextColor(getEleHandle(), nFlag, color); 58 | } 59 | 60 | 61 | }; 62 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/window/XCModelWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pch.h" 4 | #include "xcgui/window/XCWindow.hpp" 5 | #include "xcgui/XCElement.hpp" 6 | 7 | namespace xcgui { 8 | 9 | class XCModelWindow : public XCWindow 10 | { 11 | public: 12 | XCModelWindow() = default; 13 | XCModelWindow(HXCGUI handle) 14 | { 15 | m_handle = handle; 16 | } 17 | 18 | XCModelWindow(int width, int height, const std::wstring& title, uintptr_t hWndParent, int xcStyle= window_style_modal) { 19 | m_handle = XModalWnd_Create(width, height, title.c_str(), (HWND)hWndParent, xcStyle); 20 | } 21 | 22 | XCModelWindow(DWORD dwExStyle, DWORD dwStyle, const std::wstring& className, 23 | int x, int y, int cx, int cy, const std::wstring& title, uintptr_t hWndParent, int xcStyle = window_style_modal) 24 | { 25 | m_handle = XModalWnd_CreateEx(dwExStyle, dwStyle, (wchar_t*)className.c_str(), 26 | x, y, cx, cy, (wchar_t*)title.c_str(), (HWND)hWndParent, xcStyle); 27 | } 28 | 29 | virtual bool Attach(uintptr_t hwnd, int style) override { 30 | m_handle = XModalWnd_Attach((HWND)hwnd, style); 31 | return m_handle; 32 | } 33 | 34 | // 启动显示模态窗口,当窗口关闭时返回. 35 | int DoModal() { 36 | return XModalWnd_DoModal(GetWindowHandle()); 37 | } 38 | 39 | // 是否自动关闭窗口,当窗口失去焦点时. 40 | void EnableAutoClose(bool bEnable) { 41 | XModalWnd_EnableAutoClose(GetWindowHandle(), bEnable); 42 | } 43 | 44 | // 当用户按ESC键时自动关闭模态窗口. 45 | void EnableEscClose(bool bEnable) { 46 | XModalWnd_EnableEscClose(GetWindowHandle(), bEnable); 47 | } 48 | 49 | // 结束模态窗口 50 | void EndModal(int result) { 51 | XModalWnd_EndModal(GetWindowHandle(), result); 52 | } 53 | 54 | 55 | 56 | }; 57 | 58 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCMenuBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCElement.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCMenuBar : public XCElement 8 | { 9 | public: 10 | XCMenuBar(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | XCMenuBar() = default; 16 | 17 | XCMenuBar(int x, int y, int width, int height, HXCGUI parent = NULL) { 18 | m_handle = XMenuBar_Create(x, y, width, height, parent); 19 | } 20 | 21 | //@备注 添加弹出菜单按钮. 22 | //@参数 pText 文本内容. 23 | //@返回 返回菜单按钮索引. 24 | //@别名 添加按钮() 25 | int AddButton(const std::wstring& text) { 26 | return XMenuBar_AddButton(getEleHandle(), text.c_str()); 27 | } 28 | 29 | //@备注 设置菜单按钮高度. 30 | //@参数 height 高度. 31 | //@别名 置按钮高度() 32 | void SetButtonHeight(int height) { 33 | XMenuBar_SetButtonHeight(getEleHandle(), height); 34 | } 35 | 36 | //@备注 获取菜单. 37 | //@参数 nIndex 菜单条上菜单按钮的索引. 38 | //@返回 返回菜单句柄. 39 | //@别名 取菜单() 40 | HMENUX GetMenu(int nIndex) { 41 | return XMenuBar_GetMenu(getEleHandle(), nIndex); 42 | } 43 | 44 | //@参数 nIndex 菜单条上菜单按钮的索引 45 | //@返回 返回按钮句柄 46 | //@别名 取菜单按钮() 47 | HELE GetButton(int nIndex) { 48 | return XMenuBar_GetButton(getEleHandle(), nIndex); 49 | } 50 | 51 | //@备注 删除菜单条上的菜单按钮,同时该按钮下的弹出菜单也被销毁. 52 | //@参数 nIndex 菜单条按钮索引. 53 | //@返回 成功返回TRUE否则返回FALSE. 54 | //@别名 删除按钮() 55 | bool DeleteButton(int nIndex) { 56 | return XMenuBar_DeleteButton(getEleHandle(), nIndex); 57 | } 58 | 59 | //@备注 根据内容自动调整宽度 60 | //@参数 bEnable 是否启用. 61 | //@别名 启用自动宽度() 62 | void EnableAutoWidth(bool bEnable) { 63 | XMenuBar_EnableAutoWidth(getEleHandle(), bEnable); 64 | } 65 | 66 | // 3.3.8.1 新增 67 | int GetSelect() { 68 | return XMenuBar_GetSelect(getEleHandle()); 69 | } 70 | 71 | }; 72 | } 73 | -------------------------------------------------------------------------------- /pyxcgui/binding/element/XSliderBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCSliderBar.hpp" 4 | #include "xcgui/element/XCButton.hpp" 5 | #include "xcgui/XCImage.hpp" 6 | 7 | namespace xcgui { 8 | 9 | void declareSliderBar(py::module& m) { 10 | py::class_(m, "XSliderBar") 11 | PYCASTOBJECT(XCSliderBar) 12 | PYOBJECTVALID(XCSliderBar, XC_SLIDERBAR) 13 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 14 | HXCGUI handle = nullptr; 15 | if (parent) { 16 | handle = parent->GetHandle(); 17 | } 18 | XCSliderBar obj(x, y, cx, cy, handle); 19 | return obj; 20 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 21 | 22 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 23 | HXCGUI handle = nullptr; 24 | if (parent) { 25 | handle = parent->GetHandle(); 26 | } 27 | XCSliderBar obj(0,0, cx, cy, handle); 28 | return obj; 29 | }), "width"_a, "height"_a, "parent"_a=nullptr) 30 | 31 | .def("setRange", &XCSliderBar::SetRange, "range"_a) 32 | .def("getRange", &XCSliderBar::GetRange) 33 | 34 | .def("setImageLoad", [](XCSliderBar& self, const XCImage& image) { 35 | self.SetImageLoad(image.getImageHandle()); 36 | }, "image"_a) 37 | 38 | 39 | .def("setButtonWidth", &XCSliderBar::SetButtonWidth, "width"_a) 40 | .def("setButtonHeight", &XCSliderBar::SetButtonHeight, "length"_a) 41 | .def("setPos", &XCSliderBar::SetPos, "pos"_a) 42 | .def("getPos", &XCSliderBar::GetPos) 43 | 44 | .def("getButton", [](XCSliderBar& self) { 45 | auto handle = self.GetButton(); 46 | XCButton btn(handle); 47 | return btn; 48 | }) 49 | .def("enableHorizon", &XCSliderBar::EnableHorizon, "enable"_a) 50 | 51 | ; 52 | } 53 | } -------------------------------------------------------------------------------- /pyxcgui/binding/animation/XAnimation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/animation/XCAnimation.hpp" 4 | #include "binding/manager/XUserDataManager.hpp" 5 | #include "binding/manager/XCallbackManager.hpp" 6 | #include "xcgui/XCObjectUI.hpp" 7 | 8 | namespace xcgui { 9 | 10 | void declareAnimation(py::module& m) { 11 | py::class_(m, "XAnimation") 12 | PYCASTOBJECT(XCAnimation) 13 | .def("run", [](XCAnimation& self, const XCObjectUI& ele) { 14 | self.Run(ele.GetHandle()); 15 | }, "obejctUI"_a) 16 | 17 | .def("release", [](XCAnimation& self, bool end=false) { 18 | self.Release(end); 19 | }, "end"_a) 20 | 21 | .def_static("releaseEx", [](const XCObject& ele, bool bEnd=false) { 22 | XCAnimation::ReleaseEx(ele.GetHandle(), bEnd); 23 | }, "objectUI"_a, "end"_a=false) 24 | 25 | .def("enableAutoDestroy", &XCAnimation::EnableAutoDestroy, "enable"_a) 26 | 27 | .def("getObjectUI", [](XCAnimation& self) -> XCObject* { 28 | auto handle = self.GetObjectUI(); 29 | return XCastManager::GetInstance()->CastObject(handle); 30 | }, py::return_value_policy::take_ownership) 31 | 32 | .def("setCallback", [](XCAnimation& self, const XAnimationCallback& callback) { 33 | XCallbackManager::GetInstance()->SetAnimationCallback(self.GetHandle(), callback); 34 | }, "callback"_a) 35 | 36 | .def("getUserData", [](XCAnimation& self) { 37 | XUserDataManager::GetInstance()->GetUserData(self.GetHandle()); 38 | }) 39 | 40 | .def("setUserData", [](XCAnimation& self, const py::object& object) { 41 | XUserDataManager::GetInstance()->SetUserData(self.GetHandle(), object); 42 | }, "userdata"_a) 43 | 44 | .def("start", &XCAnimation::Start) 45 | .def("pause", &XCAnimation::Pause) 46 | 47 | ; 48 | } 49 | } -------------------------------------------------------------------------------- /pyxcgui/binding/element/XProgressBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCProgressBar.hpp" 4 | #include "xcgui/XCImage.hpp" 5 | 6 | 7 | namespace xcgui { 8 | 9 | void declareProgressBar(py::module& m) { 10 | py::class_(m, "XProgressBar") 11 | PYCASTOBJECT(XCProgressBar) 12 | PYOBJECTVALID(XCProgressBar, XC_PROGRESSBAR) 13 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 14 | HXCGUI handle = nullptr; 15 | if (parent) { 16 | handle = parent->GetHandle(); 17 | } 18 | XCProgressBar obj(x, y, cx, cy, handle); 19 | return obj; 20 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 21 | 22 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 23 | HXCGUI handle = nullptr; 24 | if (parent) { 25 | handle = parent->GetHandle(); 26 | } 27 | XCProgressBar obj(0,0, cx, cy, handle); 28 | return obj; 29 | }), "width"_a, "height"_a, "parent"_a=nullptr) 30 | 31 | .def("enableShowText", &XCProgressBar::EnableShowText, "enable"_a) 32 | .def("enableStretch", &XCProgressBar::EnableStretch, "enable"_a) 33 | .def("setRange", &XCProgressBar::SetRange, "range"_a) 34 | .def("getRange", &XCProgressBar::GetRange) 35 | 36 | .def("setImageLoad", [](XCProgressBar& self, const XCImage& image) { 37 | self.SetImageLoad(image.getImageHandle()); 38 | }, "image"_a) 39 | 40 | // 3.3.8 新增 41 | .def("setColorLoad", [](XCProgressBar& self, unsigned int color) { 42 | XProgBar_SetColorLoad(self.getEleHandle(), color); 43 | }, "color"_a) 44 | 45 | 46 | .def("setPos", &XCProgressBar::SetPos, "pos"_a) 47 | .def("getPos", &XCProgressBar::GetPos) 48 | .def("enableHorizon", &XCProgressBar::EnableHorizon, "enable"_a) 49 | 50 | ; 51 | } 52 | } -------------------------------------------------------------------------------- /pyxcgui/binding/element/XMonthCal.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCMonthCal.hpp" 4 | #include "xcgui/element/XCButton.hpp" 5 | #include "xcgui/XCStruct.hpp" 6 | 7 | 8 | namespace xcgui { 9 | 10 | void declareMonthCal(py::module& m) { 11 | py::class_(m, "XMonthCal") 12 | PYCASTOBJECT(XCMonthCal) 13 | PYOBJECTVALID(XCMonthCal, XC_MONTHCAL) 14 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 15 | HXCGUI handle = nullptr; 16 | if (parent) { 17 | handle = parent->GetHandle(); 18 | } 19 | XCMonthCal obj(x, y, cx, cy, handle); 20 | return obj; 21 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 22 | 23 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 24 | HXCGUI handle = nullptr; 25 | if (parent) { 26 | handle = parent->GetHandle(); 27 | } 28 | XCMonthCal obj(0,0, cx, cy, handle); 29 | return obj; 30 | }), "width"_a, "height"_a, "parent"_a=nullptr) 31 | 32 | .def("getButton", [](XCMonthCal& self, monthCal_button_type_ btnType) -> XCButton* { 33 | auto handle = self.GetButton(btnType); 34 | if (!handle) return nullptr; 35 | return new XCButton(handle); 36 | }, "btnType"_a, py::return_value_policy::take_ownership) 37 | 38 | .def("getToday", [](XCMonthCal& self) -> XCDateInfo { 39 | XCDateInfo info; 40 | self.GetToday(&info.year, &info.month, &info.day); 41 | return info; 42 | }) 43 | .def("GetSelDate", [](XCMonthCal& self) -> XCDateInfo { 44 | XCDateInfo info; 45 | self.GetSelDate(&info.year, &info.month, &info.day); 46 | return info; 47 | }) 48 | .def("setToday", &XCMonthCal::SetToday, "year"_a, "month"_a, "day"_a) 49 | .def("setTextColor", &XCMonthCal::SetTextColor, "flag"_a, "color"_a) 50 | 51 | ; 52 | } 53 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCProgressBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCElement.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCProgressBar : public XCElement 8 | { 9 | public: 10 | XCProgressBar(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | XCProgressBar() = default; 16 | 17 | XCProgressBar(int x, int y, int width, int height, HXCGUI parent = NULL) { 18 | m_handle = XProgBar_Create(x, y, width, height, parent); 19 | } 20 | 21 | //@备注 显示进度值文本 22 | //@参数 bShow 是否启用 23 | //@别名 启用进度文本() 24 | void EnableShowText(bool bShow) { 25 | XProgBar_EnableShowText(getEleHandle(), bShow); 26 | } 27 | 28 | //@备注 缩放进度贴图为当前进度区域(当前进度所显示区域),否则为整体100%进度区域 29 | //@参数 bStretch 缩放 30 | //@返回 如果成功返回TRUE,否则返回FALSE 31 | //@别名 启用缩放() 32 | void EnableStretch(bool bStretch) { 33 | XProgBar_EnableStretch(getEleHandle(), bStretch); 34 | } 35 | 36 | //@备注 设置范围. 37 | //@参数 range 范围. 38 | //@别名 置范围() 39 | void SetRange(int range) { 40 | XProgBar_SetRange(getEleHandle(), range); 41 | } 42 | 43 | //@备注 获取范围. 44 | //@返回 返回范围. 45 | //@别名 取范围() 46 | int GetRange() { 47 | return XProgBar_GetRange(getEleHandle()); 48 | } 49 | 50 | //@备注 设置进度贴图. 51 | //@参数 hImage 图片句柄. 52 | //@别名 置进度图片() 53 | void SetImageLoad(HIMAGE hImage) { 54 | XProgBar_SetImageLoad(getEleHandle(), hImage); 55 | } 56 | 57 | //@备注 设置位置点. 58 | //@参数 pos 位置点. 59 | //@别名 置进度() 60 | void SetPos(int pos) { 61 | XProgBar_SetPos(getEleHandle(), pos); 62 | } 63 | 64 | //@备注 获取当前位置点. 65 | //@返回 返回当前位置点. 66 | //@别名 取进度() 67 | int GetPos() { 68 | return XProgBar_GetPos(getEleHandle()); 69 | } 70 | 71 | //@备注 设置水平或垂直. 72 | //@参数 bHorizon 水平或垂直. 73 | //@别名 启用水平() 74 | void EnableHorizon(bool bHorizon) { 75 | XProgBar_EnableHorizon(getEleHandle(), bHorizon); 76 | } 77 | 78 | 79 | }; 80 | } -------------------------------------------------------------------------------- /examples/resources/login/resource.res: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShapeText.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShapeText.hpp" 4 | #include "xcgui/XCStruct.hpp" 5 | #include "xcgui/XCFont.hpp" 6 | 7 | namespace xcgui { 8 | 9 | void declareShapeText(py::module& m) { 10 | py::class_(m, "XShapeText") 11 | PYCASTOBJECT(XCShapeText) 12 | PYOBJECTVALID(XCShapeText, XC_SHAPE_TEXT) 13 | .def(py::init([](int x, int y, int cx, int cy, const std::wstring& text, XCObjectUI* parent = nullptr) { 14 | HXCGUI handle = nullptr; 15 | if (parent) { 16 | handle = parent->GetHandle(); 17 | } 18 | XCShapeText obj(x, y, cx, cy, text, handle); 19 | return obj; 20 | }), "x"_a, "y"_a, "width"_a, "height"_a, "text"_a, "parent"_a = nullptr) 21 | 22 | . def(py::init([](int cx, int cy, const std::wstring& text, XCObjectUI* parent=nullptr) { 23 | HXCGUI handle = nullptr; 24 | if (parent) { 25 | handle = parent->GetHandle(); 26 | } 27 | XCShapeText obj(0,0, cx, cy, text, handle); 28 | return obj; 29 | }), "width"_a, "height"_a, "text"_a, "parent"_a=nullptr) 30 | 31 | 32 | .def("setText", &XCShapeText::SetText, "text"_a) 33 | .def("getText", &XCShapeText::GetText) 34 | .def("getTextLength", &XCShapeText::GetTextLength) 35 | 36 | .def("setFont", [](XCShapeText& self, const XCFont& font) { 37 | self.SetFont(font.getFontHandle()); 38 | }, "font"_a) 39 | .def("getFont", [](XCShapeText& self) -> XCFont* { 40 | auto handle = self.GetFont(); 41 | if (!handle) return nullptr; 42 | return new XCFont(handle); 43 | }, py::return_value_policy::take_ownership) 44 | 45 | 46 | .def("setTextColor", &XCShapeText::SetTextColor, "color"_a) 47 | .def("getTextColor", &XCShapeText::GetTextColor) 48 | 49 | .def("setTextAlign", &XCShapeText::SetTextAlign, "align"_a) 50 | .def("setOffset", &XCShapeText::SetOffset, "x"_a, "y"_a) 51 | 52 | ; 53 | } 54 | } -------------------------------------------------------------------------------- /pyxcgui/binding/element/XPane.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCPane.hpp" 4 | #include "xcgui/window/XCFrameWindow.hpp" 5 | #include "xcgui/XCDraw.hpp" 6 | 7 | 8 | namespace xcgui { 9 | 10 | void declarePanel(py::module& m) { 11 | py::class_(m, "XPane") 12 | PYCASTOBJECT(XCPane) 13 | PYOBJECTVALID(XCPane, XC_PANE) 14 | .def(py::init([](const std::wstring& name, int width, int height, XCFrameWindow* parent) { 15 | HWINDOW handle = nullptr; 16 | if (parent) { 17 | handle = parent->GetWindowHandle(); 18 | } 19 | XCPane obj(name, width, height, handle); 20 | return obj; 21 | }), "name"_a, "width"_a, "height"_a, "parent"_a = nullptr) 22 | 23 | .def("setView", [](XCPane& self, const XCElement& ele) { 24 | self.SetView(ele.getEleHandle()); 25 | }, "ele"_a) 26 | 27 | .def("setTitle", &XCPane::SetTitle, "title"_a) 28 | .def("getTitle", &XCPane::GetTitle) 29 | 30 | .def("setCaptionHeight", &XCPane::SetCaptionHeight, "height"_a) 31 | .def("getCaptionHeight", &XCPane::GetCaptionHeight) 32 | 33 | .def("isShowPane", &XCPane::IsShowPane) 34 | .def("isGroupActivate", &XCPane::IsGroupActivate) 35 | 36 | .def("setSize", &XCPane::SetSize, "width"_a, "height"_a) 37 | 38 | .def("getState", &XCPane::GetState) 39 | 40 | .def("getViewRect", [](XCPane& self) { 41 | XCRect rect; 42 | self.GetViewRect((RECT*)&rect); 43 | return rect; 44 | }) 45 | 46 | .def("hidePane", &XCPane::HidePane, "groupDelay"_a=false) 47 | .def("showPane", &XCPane::ShowPane, "groupActivate"_a) 48 | .def("dockPane", &XCPane::DockPane) 49 | .def("lockPane", &XCPane::LockPane) 50 | .def("floatPane", &XCPane::FloatPane) 51 | 52 | .def("drawPane", [](XCPane& self, const XCDraw& draw) { 53 | self.DrawPane(draw.getDrawHandle()); 54 | }, "draw"_a) 55 | 56 | .def("setSelect", &XCPane::SetSelect) 57 | 58 | ; 59 | } 60 | } -------------------------------------------------------------------------------- /pyxcgui/binding/XResource.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCResource.hpp" 4 | #include "xcgui/bkmanager/XCBkManager.hpp" 5 | #include "xcgui/XCImage.hpp" 6 | #include "xcgui/XCFont.hpp" 7 | #include "binding/manager/XCallbackManager.hpp" 8 | 9 | namespace xcgui { 10 | 11 | void declareResource(py::module& m) { 12 | py::class_(m, "XResource") 13 | .def_static("enableDelayLoad", &XCResource::EnableDelayLoad, "enable"_a) 14 | .def_static("getColor", &XCResource::GetColor, "name"_a) 15 | .def_static("getIDValue", &XCResource::GetIDValue, "name"_a) 16 | .def_static("getBkManager", [](const std::wstring& name) -> XCBkManager* { 17 | auto handle = XCResource::GetBkM(name); 18 | if (!handle) 19 | return nullptr; 20 | 21 | return new XCBkManager(handle); 22 | }, "name"_a, py::return_value_policy::take_ownership) 23 | 24 | .def_static("getFont", [](const std::wstring& name) -> XCFont* { 25 | auto handle = XCResource::GetFont(name); 26 | if (!handle) 27 | return nullptr; 28 | 29 | return new XCFont(handle); 30 | }, "name"_a, py::return_value_policy::take_ownership) 31 | 32 | .def_static("getImage", [](const std::wstring& name) -> XCImage* { 33 | auto handle = XCResource::GetImage(name); 34 | if (!handle) 35 | return nullptr; 36 | 37 | return new XCImage(handle); 38 | }, "name"_a, py::return_value_policy::take_ownership) 39 | 40 | .def_static("getImageEx", [](const std::wstring& fileName, const std::wstring& name) -> XCImage* { 41 | auto handle = XCResource::GetImageEx(fileName, name); 42 | if (!handle) 43 | return nullptr; 44 | 45 | return new XCImage(handle); 46 | }, "filename"_a, "name"_a, py::return_value_policy::take_ownership) 47 | 48 | .def_static("setLoadFileCallback", [](const XResourceLoadFileCallback& callback) { 49 | XCallbackManager::GetInstance()->SetLoadFileCallback(callback); 50 | }, "callback"_a); 51 | } 52 | } -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShape.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShape.hpp" 4 | #include "xcgui/XCStruct.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareShape(py::module& m) { 9 | py::class_(m, "XShape") 10 | PYCASTOBJECT(XCShape) 11 | PYOBJECTVALID(XCShape, XC_SHAPE) 12 | .def("removeShape", &XCShape::RemoveShape) 13 | .def("getZOrder", &XCShape::GetZOrder) 14 | .def("redraw", &XCShape::Redraw) 15 | .def("getWidth", &XCShape::GetWidth) 16 | .def("setPosition", &XCShape::SetPosition, "x"_a, "y"_a) 17 | .def("getPosition", [](XCShape& self) { 18 | XCPoint pt; 19 | self.GetPosition(&pt.x, &pt.y); 20 | return pt; 21 | }) 22 | 23 | .def("setSize", &XCShape::SetSize, "width"_a, "height"_a) 24 | .def("getSize", [](XCShape& self) { 25 | XCSize info; 26 | self.GetSize(&info.width, &info.height); 27 | return info; 28 | }) 29 | 30 | .def("setAlpha", &XCShape::SetAlpha, "alpha"_a) 31 | .def("getAlpha", &XCShape::GetAlpha) 32 | 33 | .def("getRect", [](XCShape& self) { 34 | XCRect info; 35 | self.GetRect((RECT*)&info); 36 | return info; 37 | }) 38 | 39 | .def("setRectLogic", [](XCShape& self, const XCRect& rect, bool bRedraw) { 40 | return self.SetRectLogic((RECT*)&rect, bRedraw); 41 | }, "rect"_a, "redraw"_a) 42 | .def("getRectLogic", [](XCShape& self) { 43 | XCRect info; 44 | self.GetRectLogic((RECT*)&info); 45 | return info; 46 | }) 47 | .def("getWndClientRect", [](XCShape& self) { 48 | XCRect info; 49 | self.GetWndClientRect((RECT*)&info); 50 | return info; 51 | }) 52 | .def("getContentSize", [](XCShape& self) { 53 | XCSize info; 54 | self.GetContentSize((SIZE*)&info); 55 | return info; 56 | }) 57 | 58 | 59 | .def("showLayout", &XCShape::ShowLayout, "enable"_a) 60 | .def("adjustLayout", &XCShape::AdjustLayout) 61 | .def("destroy", &XCShape::Destroy) 62 | 63 | ; 64 | } 65 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCSliderBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCElement.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCSliderBar : public XCElement 8 | { 9 | public: 10 | XCSliderBar(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | XCSliderBar() = default; 16 | 17 | XCSliderBar(int x, int y, int width, int height, HXCGUI parent = NULL) { 18 | m_handle = XSliderBar_Create(x, y, width, height, parent); 19 | } 20 | 21 | //@备注 设置滑动范围. 22 | //@参数 range 范围. 23 | //@别名 置范围() 24 | void SetRange(int range) { 25 | XSliderBar_SetRange(getEleHandle(), range); 26 | } 27 | 28 | //@备注 获取滚动范围. 29 | //@返回 返回滚动范围. 30 | //@别名 取范围() 31 | int GetRange() { 32 | return XSliderBar_GetRange(getEleHandle()); 33 | } 34 | 35 | //@备注 设置进度贴图. 36 | //@参数 hImage 图片句柄. 37 | //@别名 置进度图片() 38 | void SetImageLoad(HIMAGE hImage) { 39 | XSliderBar_SetImageLoad(getEleHandle(), hImage); 40 | } 41 | 42 | //@备注 设置滑块按钮宽度. 43 | //@参数 width 宽度. 44 | //@别名 置滑块宽度() 45 | void SetButtonWidth(int width) { 46 | XSliderBar_SetButtonWidth(getEleHandle(), width); 47 | } 48 | 49 | //@备注 设置滑块按钮高度. 50 | //@参数 height 高度. 51 | //@别名 置滑块高度() 52 | void SetButtonHeight(int height) { 53 | XSliderBar_SetButtonHeight(getEleHandle(), height); 54 | } 55 | 56 | //@备注 设置当前进度点. 57 | //@参数 pos 进度点. 58 | //@别名 置当前位置() 59 | void SetPos(int pos) { 60 | XSliderBar_SetPos(getEleHandle(), pos); 61 | } 62 | 63 | //@备注 获取当前进度点. 64 | //@返回 返回当前进度点. 65 | //@别名 取当前位置() 66 | int GetPos() { 67 | return XSliderBar_GetPos(getEleHandle()); 68 | } 69 | 70 | //@备注 获取滑块按钮. 71 | //@返回 按钮句柄. 72 | //@别名 取滑块() 73 | HELE GetButton() { 74 | return XSliderBar_GetButton(getEleHandle()); 75 | } 76 | 77 | //@备注 设置水平或垂直. 78 | //@参数 bHorizon 水平或垂直. 79 | //@别名 启用水平() 80 | void EnableHorizon(bool bHorizon) { 81 | XSliderBar_EnableHorizon(getEleHandle(), bHorizon); 82 | } 83 | 84 | }; 85 | } -------------------------------------------------------------------------------- /pyxcgui/binding/menu/XMenuBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCMenuBar.hpp" 4 | #include "xcgui/menu/XCMenu.hpp" 5 | #include "xcgui/element/XCButton.hpp" 6 | 7 | 8 | namespace xcgui { 9 | 10 | void declareMenuBar(py::module& m) { 11 | py::class_(m, "XMenuBar") 12 | PYCASTOBJECT(XCMenuBar) 13 | PYOBJECTVALID(XCMenuBar, XC_MENUBAR) 14 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 15 | HXCGUI handle = nullptr; 16 | if (parent) { 17 | handle = parent->GetHandle(); 18 | } 19 | XCMenuBar obj(x, y, cx, cy, handle); 20 | return obj; 21 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 22 | 23 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 24 | HXCGUI handle = nullptr; 25 | if (parent) { 26 | handle = parent->GetHandle(); 27 | } 28 | XCMenuBar obj(0,0, cx, cy, handle); 29 | return obj; 30 | }), "width"_a, "height"_a, "parent"_a=nullptr) 31 | 32 | .def("addButton", &XCMenuBar::AddButton, "text"_a) 33 | .def("setButtonHeight", &XCMenuBar::SetButtonHeight, "height"_a) 34 | .def("getMenu", [](XCMenuBar& self, int index) -> py::object { 35 | auto handle = self.GetMenu(index); 36 | if (!handle) return py::none(); 37 | auto menu = new XCMenu(handle); 38 | return py::cast(menu, py::return_value_policy::take_ownership); 39 | }, "index"_a) 40 | 41 | .def("getButton", [](XCMenuBar& self, int index) -> XCButton* { 42 | auto handle = self.GetButton(index); 43 | if (!handle) return nullptr; 44 | return new XCButton(handle); 45 | }, "index"_a, py::return_value_policy::take_ownership) 46 | 47 | .def("deleteButton", &XCMenuBar::DeleteButton, "index"_a) 48 | .def("enableAutoWidth", &XCMenuBar::EnableAutoWidth, "enable"_a) 49 | 50 | // 3.3.8.1 新增 51 | .def("getSelect", [](XCMenuBar& self) { 52 | return XMenuBar_GetSelect(self.getEleHandle()); 53 | }) 54 | 55 | ; 56 | } 57 | } -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "setuptools>=61.0", 4 | "wheel", 5 | "pybind11>=2.10.0", 6 | ] 7 | # build-backend = "setuptools.build_meta" 8 | 9 | [project] 10 | name = "xcgui" 11 | version = "0.1.9" 12 | description = "xcgui - bundled xcgui for python" 13 | readme = "README.md" 14 | license = "MIT" 15 | authors = [ 16 | {name = "evilbeast", email = "houshao55@gmail.com"} 17 | ] 18 | keywords = ["xcgui", "pybind11", "ui"] 19 | classifiers = [ 20 | "Development Status :: 4 - Beta", 21 | "Programming Language :: Python :: 3.9", 22 | "Programming Language :: Python :: 3.10", 23 | "Programming Language :: Python :: 3.11", 24 | "Programming Language :: Python :: 3.12", 25 | "Programming Language :: Python :: 3.13", 26 | "Programming Language :: Python :: 3.14", 27 | ] 28 | requires-python = ">=3.9" 29 | 30 | [project.urls] 31 | Homepage = "https://github.com/smallevilbeast/pyxcgui" 32 | Repository = "https://github.com/smallevilbeast/pyxcgui" 33 | 34 | [project.optional-dependencies] 35 | dev = [ 36 | "pybind11-stubgen>=2.5.5", 37 | "build>=0.10.0", 38 | "twine>=4.0.0", 39 | "cibuildwheel>=2.16.0", 40 | ] 41 | 42 | [tool.setuptools] 43 | include-package-data = true 44 | 45 | [tool.setuptools.packages.find] 46 | include = ["xcgui*"] 47 | 48 | [tool.setuptools.package-data] 49 | "*" = ["py.typed", "*.pyi"] 50 | 51 | [tool.cibuildwheel] 52 | # 构建的 Python 版本(只构建你支持的版本) 53 | build = ["cp39-win_amd64", "cp310-win_amd64", "cp311-win_amd64", "cp312-win_amd64", "cp313-win_amd64", "cp314-win_amd64"] 54 | 55 | # 跳过不需要的构建 56 | skip = ["*-win32", "*-manylinux_i686", "*-musllinux_*", "pp*"] 57 | 58 | # 跳过测试,因为需要外部 DLL 依赖 59 | test-skip = "*" 60 | 61 | 62 | # Windows 特定配置 63 | [tool.cibuildwheel.windows] 64 | # 构建前安装依赖并设置环境变量 65 | before-build = [ 66 | "pip install --upgrade pip setuptools wheel", 67 | "pip install pybind11>=2.10.0", 68 | ] 69 | 70 | # 配置环境变量,让 cibuildwheel 自动找到 VS 71 | environment = { CIBW_BUILD_VERBOSITY = "1", Py_DEBUG = "0" } -------------------------------------------------------------------------------- /pyxcgui/xcgui/shape/XCShapeRect.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShape.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCShapeRect : public XCShape 8 | { 9 | public: 10 | XCShapeRect() = default; 11 | 12 | XCShapeRect(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCShapeRect(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 18 | this->Create(x, y, cx, cy, hParent); 19 | } 20 | 21 | HXCGUI Create(int x, int y, int cx, int cy, HXCGUI hParent = NULL) { 22 | m_handle = XShapeRect_Create(x, y, cx, cy, hParent); 23 | return m_handle; 24 | } 25 | 26 | //@备注 设置边框颜色. 27 | //@参数 color 颜色值, 请使用宏: RGBA() 28 | //@别名 置边框色() 29 | void SetBorderColor(COLORREF color) { 30 | XShapeRect_SetBorderColor(m_handle, color); 31 | } 32 | 33 | //@备注 设置填充颜色. 34 | //@参数 color 颜色值, 请使用宏: RGBA() 35 | //@别名 置填充色() 36 | void SetFillColor(COLORREF color) { 37 | XShapeRect_SetFillColor(m_handle, color); 38 | } 39 | 40 | //@备注 设置圆角大小. 41 | //@参数 nWidth 圆角宽度. 42 | //@参数 nHeight 圆角高度. 43 | //@返回 成功返回TRUE否则返回FALSE. 44 | //@别名 置圆角大小() 45 | void SetRoundAngle(int nWidth, int nHeight) { 46 | XShapeRect_SetRoundAngle(m_handle, nWidth, nHeight); 47 | } 48 | 49 | //@备注 获取圆角大小. 50 | //@参数 pWidth 圆角宽度. 51 | //@参数 pHeight 圆角高度. 52 | //@别名 取圆角大小() 53 | void GetRoundAngle(int* pWidth, int* pHeight) { 54 | XShapeRect_GetRoundAngle(m_handle, pWidth, pHeight); 55 | } 56 | 57 | //@备注 启用绘制矩形边框. 58 | //@参数 bEnable 是否启用. 59 | //@别名 启用边框() 60 | void EnableBorder(bool bEnable) { 61 | XShapeRect_EnableBorder(m_handle, bEnable); 62 | } 63 | 64 | //@备注 启用填充矩形. 65 | //@参数 bEnable 是否启用. 66 | //@别名 启用填充() 67 | void EnableFill(bool bEnable) { 68 | XShapeRect_EnableFill(m_handle, bEnable); 69 | } 70 | 71 | //@备注 启用圆角. 72 | //@参数 bEnable 是否启用. 73 | //@别名 启用圆角() 74 | void EnableRoundAngle(bool bEnable) { 75 | XShapeRect_EnableRoundAngle(m_handle, bEnable); 76 | } 77 | 78 | }; 79 | } -------------------------------------------------------------------------------- /pyxcgui/binding/manager/XUserDataManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include 4 | #include 5 | #include 6 | 7 | #include "xcgui/window/XCWindow.hpp" 8 | 9 | namespace xcgui { 10 | 11 | class XUserDataManager { 12 | public: 13 | SINGLETON_DEFINE(XUserDataManager); 14 | XUserDataManager() : 15 | m_none(py::none()) 16 | { 17 | 18 | } 19 | ~XUserDataManager() { 20 | Release(); 21 | } 22 | 23 | 24 | public: 25 | void Release() { 26 | m_mData.clear(); 27 | 28 | for (auto& iter : m_mItemData) { 29 | iter.second.clear(); 30 | } 31 | m_mItemData.clear(); 32 | } 33 | 34 | void ReleaseByHandle(HXCGUI handle) { 35 | auto iter = m_mData.find(handle); 36 | if (iter != m_mData.end()) { 37 | m_mData.erase(iter); 38 | } 39 | 40 | auto iterItem = m_mItemData.find(handle); 41 | if (iterItem != m_mItemData.end()) { 42 | iterItem->second.clear(); 43 | m_mItemData.erase(iterItem); 44 | } 45 | } 46 | 47 | void SetUserData(HXCGUI handle, const py::object& object) { 48 | m_mData[handle] = object; 49 | } 50 | 51 | void SetItemUserData(HELE handle, const std::string& item, const py::object& object) { 52 | m_mItemData[handle][item] = object; 53 | } 54 | 55 | py::object& getItemUserData(HELE handle, const std::string& item) { 56 | auto iter = m_mItemData.find(handle); 57 | if (iter == m_mItemData.end()) { 58 | return m_none; 59 | } 60 | auto& itemData = iter->second; 61 | auto itemIter = itemData.find(item); 62 | if (itemIter == itemData.end()) { 63 | return m_none; 64 | } 65 | return itemIter->second; 66 | } 67 | 68 | py::object& GetUserData(HXCGUI handle) { 69 | auto iter = m_mData.find(handle); 70 | if (iter == m_mData.end()) { 71 | return m_none; 72 | } 73 | return m_mData[handle]; 74 | } 75 | 76 | 77 | protected: 78 | py::object m_none; 79 | std::map m_mData; 80 | std::map> m_mItemData; 81 | }; 82 | } -------------------------------------------------------------------------------- /pyxcgui/binding/manager/XMainThreadManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include 4 | #include 5 | #include 6 | 7 | #include "xcgui/window/XCWindow.hpp" 8 | #include "XCastManager.hpp" 9 | #include "xcgui/XCStruct.hpp" 10 | #include "xcgui/XCResource.hpp" 11 | 12 | /* 13 | 14 | def threaded(f): 15 | @functools.wraps(f) 16 | def wrapper(*args, **kwargs): 17 | t = threading.Thread(target=f, args=args, kwargs=kwargs) 18 | t.daemon = True 19 | t.start() 20 | 21 | return wrapper 22 | 23 | 24 | class callUiThread: 25 | def __init__(self): 26 | pass 27 | 28 | def __call__(self, func): 29 | self.func = func 30 | 31 | @functools.wraps(func) 32 | def objCall(*args, **kwargs): 33 | _callUiThread(self.func, *args, **kwargs) 34 | return objCall 35 | 36 | */ 37 | 38 | namespace xcgui { 39 | 40 | using XUiThreadCallback = std::function; 41 | class XMainThreadObject { 42 | public: 43 | XMainThreadObject() = default; 44 | XMainThreadObject(const py::object& method, const py::args& args, const py::kwargs& kwargs) 45 | :method(method) 46 | ,args(args) 47 | ,kwargs(kwargs) 48 | { 49 | } 50 | 51 | py::object method; 52 | py::args args; 53 | py::kwargs kwargs; 54 | }; 55 | 56 | 57 | 58 | class XMainThreadManager { 59 | public: 60 | SINGLETON_DEFINE(XMainThreadManager); 61 | XMainThreadManager() = default; 62 | ~XMainThreadManager() { 63 | Release(); 64 | } 65 | 66 | 67 | public: 68 | void CallUiThread(const py::object& method, const py::args& args, const py::kwargs& kwargs) { 69 | auto pMainObject = new XMainThreadObject(method, args, kwargs); 70 | XC_CallUiThread(&XMainThreadManager::OnUiThreadCallback, (vint)pMainObject); 71 | } 72 | 73 | static vint WINAPI OnUiThreadCallback(vint data) { 74 | auto pMainObject = (XMainThreadObject*)(data); 75 | pMainObject->method(*pMainObject->args, **pMainObject->kwargs); 76 | delete pMainObject; 77 | return 0; 78 | } 79 | 80 | void Release() { 81 | } 82 | 83 | }; 84 | } -------------------------------------------------------------------------------- /examples/resources/WmUi/WmUi_Base.res: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShapeGroupBox.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShapeGroupBox.hpp" 4 | #include "xcgui/XCStruct.hpp" 5 | #include "xcgui/XCFont.hpp" 6 | 7 | namespace xcgui { 8 | 9 | void declareShapeGroupBox(py::module& m) { 10 | py::class_(m, "XShapeGroupBox") 11 | PYCASTOBJECT(XCShapeGroupBox) 12 | PYOBJECTVALID(XCShapeGroupBox, XC_SHAPE_GROUPBOX) 13 | .def(py::init([](int x, int y, int cx, int cy, const std::wstring& text, XCObjectUI* parent = nullptr) { 14 | HXCGUI handle = nullptr; 15 | if (parent) { 16 | handle = parent->GetHandle(); 17 | } 18 | XCShapeGroupBox obj(x, y, cx, cy, text, handle); 19 | return obj; 20 | }), "x"_a, "y"_a, "width"_a, "height"_a, "text"_a, "parent"_a = nullptr) 21 | 22 | . def(py::init([](int cx, int cy, const std::wstring& text, XCObjectUI* parent=nullptr) { 23 | HXCGUI handle = nullptr; 24 | if (parent) { 25 | handle = parent->GetHandle(); 26 | } 27 | XCShapeGroupBox obj(0,0, cx, cy, text, handle); 28 | return obj; 29 | }), "width"_a, "height"_a, "text"_a, "parent"_a=nullptr) 30 | 31 | 32 | .def("setBorderColor", &XCShapeGroupBox::SetBorderColor, "color"_a) 33 | .def("setTextColor", &XCShapeGroupBox::SetTextColor, "color"_a) 34 | .def("setFont", [](XCShapeGroupBox& self, const XCFont& font) { 35 | self.SetFontX(font.getFontHandle()); 36 | }, "font"_a) 37 | 38 | 39 | .def("setTextOffset", &XCShapeGroupBox::SetTextOffset, "offsetX"_a, "offsetY"_a) 40 | .def("setRoundAngle", &XCShapeGroupBox::SetRoundAngle, "width"_a, "height"_a) 41 | .def("setText", &XCShapeGroupBox::SetText, "text"_a) 42 | .def("getTextOffset", [](XCShapeGroupBox& self) { 43 | XCPoint pt; 44 | self.GetTextOffset(&pt.x, &pt.y); 45 | return pt; 46 | }) 47 | .def("getRoundAngle", [](XCShapeGroupBox& self) { 48 | XCSize info; 49 | self.GetRoundAngle(&info.width, &info.height); 50 | return info; 51 | }) 52 | .def("enableRoundAngle", &XCShapeGroupBox::EnableRoundAngle, "enable"_a) 53 | 54 | ; 55 | } 56 | } -------------------------------------------------------------------------------- /pyxcgui/binding/element/XDateTime.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCDateTime.hpp" 4 | #include "xcgui/element/XCButton.hpp" 5 | #include "xcgui/XCStruct.hpp" 6 | 7 | 8 | namespace xcgui { 9 | 10 | void declareDateTime(py::module& m) { 11 | py::class_(m, "XDateTime") 12 | PYCASTOBJECT(XCDateTime) 13 | PYOBJECTVALID(XCDateTime, XC_DATETIME) 14 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 15 | HXCGUI handle = nullptr; 16 | if (parent) { 17 | handle = parent->GetHandle(); 18 | } 19 | XCDateTime obj(x, y, cx, cy, handle); 20 | return obj; 21 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 22 | 23 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 24 | HXCGUI handle = nullptr; 25 | if (parent) { 26 | handle = parent->GetHandle(); 27 | } 28 | XCDateTime obj(0,0, cx, cy, handle); 29 | return obj; 30 | }), "width"_a, "height"_a, "parent"_a=nullptr) 31 | 32 | .def("setStyle", &XCDateTime::SetStyle, "style"_a) 33 | .def("getStyle", &XCDateTime::GetStyle) 34 | .def("getButton", [](XCDateTime& self, int btnType) -> XCButton* { 35 | auto handle = self.GetButton(btnType); 36 | if (!handle) return nullptr; 37 | return new XCButton(handle); 38 | }, "btnType"_a, py::return_value_policy::take_ownership) 39 | 40 | .def("getSelBkColor", &XCDateTime::GetSelBkColor) 41 | .def("setSelBkColor", &XCDateTime::SetSelBkColor, "color"_a) 42 | .def("getDate", [](XCDateTime& self) -> XCDateInfo { 43 | XCDateInfo info; 44 | self.GetDate(&info.year, &info.month, &info.day); 45 | return info; 46 | }) 47 | .def("setDate", &XCDateTime::SetDate, "year"_a, "month"_a, "day"_a) 48 | .def("getTime", [](XCDateTime& self) -> XCTimeInfo { 49 | XCTimeInfo info; 50 | self.GetTime(&info.hour, &info.minute, &info.second); 51 | return info; 52 | }) 53 | .def("setTime", &XCDateTime::SetDate, "hour"_a, "minute"_a, "second"_a) 54 | .def("popup", &XCDateTime::Popup) 55 | 56 | ; 57 | } 58 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/XCApp.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | 4 | namespace xcgui { 5 | class XCApp 6 | { 7 | public: 8 | XCApp(bool bD2D = false) 9 | { 10 | XInitXCGUI(bD2D); 11 | } 12 | 13 | void Run() 14 | { 15 | XRunXCGUI(); 16 | } 17 | 18 | void Exit() 19 | { 20 | XExitXCGUI(); 21 | } 22 | 23 | // 添加文件搜索路径, 默认路为exe目录和程序当前运行目录 24 | void AddFileSearchPath(const std::wstring& path) { 25 | XC_AddFileSearchPath(path.c_str()); 26 | } 27 | 28 | // 启动或禁用自动退出程序,当检测到所有用户创建的窗口都关闭时,自动退出程序; 可调用 XC_PostQuitMessage() 手动退出程序 29 | void EnableAutoExitApp(bool bEnable) { 30 | XC_EnableAutoExitApp(bEnable); 31 | } 32 | 33 | // 打印调试信息到文件 34 | void DebugToFileInfo(const std::string& file) { 35 | XC_DebugToFileInfo(file.c_str()); 36 | } 37 | 38 | // 启用debug文件 39 | void EnableDebugFile(bool bEnable) { 40 | XC_EnableDebugFile(bEnable); 41 | } 42 | 43 | // 启用错误弹出,通过该接口可以设置遇到严重错误时不弹出消息提示框. 44 | void EnableErrorMessageBox(bool bEnable) { 45 | XC_EnableErrorMessageBox(bEnable); 46 | } 47 | 48 | // 启用GDI绘制文本 将影响到以下函数: XDraw_TextOut XDraw_TextOutEx XDraw_TextOutA 49 | void EnableGdiDrawText(bool bEnable) { 50 | XC_EnableGdiDrawText(bEnable); 51 | } 52 | 53 | void EnableAutoRedrawUI(bool bEnable) { 54 | XC_EnableAutoRedrawUI(bEnable); 55 | } 56 | 57 | // 启用资源监视器 58 | void EnableResMonitor(bool bEnable) { 59 | XC_EnableResMonitor(bEnable); 60 | } 61 | 62 | // 显示布局对象边界 63 | void ShowLayoutFrame(bool bShow) { 64 | XC_ShowLayoutFrame(bShow); 65 | } 66 | 67 | // 显示边界 辅助功能 68 | void ShowSvgFrame(bool bShow) { 69 | XC_ShowSvgFrame(bShow); 70 | } 71 | 72 | // 设置布局边框颜色 73 | void SetLayoutFrameColor(COLORREF color) { 74 | XC_SetLayoutFrameColor(color); 75 | } 76 | 77 | // 设置UI的最小重绘频率 78 | void SetPaintFrequency(uint32_t milliseconds) { 79 | XC_SetPaintFrequency(milliseconds); 80 | } 81 | 82 | // 设置文本渲染质量GDI+. 83 | void SetTextRenderingHint(int nType) { 84 | XC_SetTextRenderingHint(nType); 85 | } 86 | 87 | // SetD2dTextRenderingMode 88 | void SetD2dTextRenderingMode(XC_DWRITE_RENDERING_MODE mode) { 89 | XC_SetD2dTextRenderingMode(mode); 90 | } 91 | 92 | 93 | 94 | 95 | }; 96 | } 97 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/animation/XCAnimationItem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCObject.hpp" 4 | 5 | namespace xcgui { 6 | 7 | 8 | class XCAnimationItem : public XCObject 9 | { 10 | 11 | public: 12 | XCAnimationItem(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCAnimationItem() = default; 18 | 19 | //@参数 hAnimationItem 动画项句柄 20 | //@参数 bEnable 是否启用 21 | //@别名 动画项_启用自动销毁() 22 | void EnableAutoDestroy(bool bEnable) { 23 | XAnimaItem_EnableAutoDestroy(m_handle, bEnable); 24 | } 25 | 26 | //@备注 当动画项完成后自动释放 27 | //@参数 hAnimationItem 动画项句柄 28 | //@参数 bEnable 是否启用 29 | //@别名 动画项_启用完成释放() 30 | void EnableCompleteRelease(bool bEnable) { 31 | XAnimaItem_EnableCompleteRelease(m_handle, bEnable); 32 | } 33 | 34 | 35 | //@参数 hAnimationItem 动画项句柄 36 | //@参数 callback 回调函数 37 | //@别名 动画项_置回调() 38 | void SetCallback(funAnimationItem callback) { 39 | XAnimaItem_SetCallback(m_handle, callback); 40 | } 41 | 42 | 43 | //@参数 hAnimationItem 动画项句柄 44 | //@参数 nUserData 用户数据 45 | //@别名 动画项_置用户数据() 46 | void SetUserData(vint nUserData) { 47 | XAnimaItem_SetUserData(m_handle, nUserData); 48 | } 49 | 50 | //@参数 hAnimationItem 动画项句柄 51 | //@返回 返回用户数据 52 | //@别名 动画项_取用户数据() 53 | vint GetUserData() { 54 | XAnimaItem_GetUserData(m_handle); 55 | } 56 | 57 | //@备注 设置旋转中心点坐标 58 | //@参数 hAnimationRotate 动画旋转项句柄 59 | //@参数 x 坐标X 60 | //@参数 y 坐标Y 61 | //@参数 bOffset true:相对于自身中心点偏移, false:绝对坐标 62 | //@返回 如果成功返回true,否则返回false 63 | //@别名 动画旋转_置中心() 64 | void RotateSetCenter(float x, float y, bool bOffset = false) { 65 | XAnimaRotate_SetCenter(m_handle, x, y, bOffset); 66 | } 67 | 68 | 69 | //@备注 设置缩放起点, 确定延伸方向 70 | //@参数 hAnimationScale 动画缩放项句柄 71 | //@参数 position 位置 72 | //@返回 如果成功返回true,否则返回false 73 | //@别名 动画缩放_置延伸位置() 74 | void ScaleSetPosition(position_flag_ position) { 75 | XAnimaScale_SetPosition(m_handle, position); 76 | } 77 | 78 | 79 | //@备注 此接口可独立设置x轴移动或y轴移动 80 | //@参数 hAnimationMove 动画移动项句柄 81 | //@参数 flags @ref animation_move_x : X轴移动, @ref animation_move_y : Y轴移动, 可组合使用, @ref animation_move_ 82 | //@别名 动画移动_置标识() 83 | void MoveSetFlag(int flags) { 84 | return XAnimaMove_SetFlag(m_handle, flags); 85 | } 86 | 87 | 88 | }; 89 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/shape/XCShapeText.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShape.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCShapeText : public XCShape 8 | { 9 | public: 10 | XCShapeText() = default; 11 | 12 | XCShapeText(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCShapeText(int x, int y, int cx, int cy, const std::wstring& name, HXCGUI hParent = NULL) { 18 | this->Create(x, y, cx, cy, name, hParent); 19 | } 20 | 21 | HXCGUI Create(int x, int y, int cx, int cy, const std::wstring& name, HXCGUI hParent = NULL) { 22 | m_handle = XShapeText_Create(x, y, cx, cy, name.c_str(), hParent); 23 | return m_handle; 24 | } 25 | 26 | //@备注 设置文本内容. 27 | //@参数 name.c_str() 文本内容. 28 | //@别名 置文本() 29 | void SetText(const std::wstring& name) { 30 | XShapeText_SetText(m_handle, name.c_str()); 31 | } 32 | 33 | //@备注 获取文本内容. 34 | //@别名 取文本() 35 | std::wstring GetText() { 36 | auto pText = XShapeText_GetText(m_handle); 37 | if (!pText) return L""; 38 | return pText; 39 | } 40 | 41 | //@备注 获取文本长度. 42 | //@返回 文本长度. 43 | //@别名 取文本长度() 44 | int GetTextLength() { 45 | return XShapeText_GetTextLength(m_handle); 46 | } 47 | 48 | //@备注 设置字体. 49 | //@参数 hFontx 字体句柄. 50 | //@别名 置字体() 51 | void SetFont(HFONTX hFontx) { 52 | XShapeText_SetFont(m_handle, hFontx); 53 | } 54 | 55 | //@备注 获取字体. 56 | //@返回 返回字体句柄. 57 | //@别名 取字体() 58 | HFONTX GetFont() { 59 | return XShapeText_GetFont(m_handle); 60 | } 61 | 62 | //@备注 设置文本颜色. 63 | //@参数 color 颜色值, 请使用宏: RGBA() 64 | //@别名 置文本颜色() 65 | void SetTextColor(COLORREF color) { 66 | XShapeText_SetTextColor(m_handle, color); 67 | } 68 | 69 | //@备注 获取文本颜色. 70 | //@返回 颜色值. 71 | //@别名 取文本颜色() 72 | COLORREF GetTextColor() { 73 | return XShapeText_GetTextColor(m_handle); 74 | } 75 | 76 | //@备注 设置文本对齐方式. 77 | //@参数 align 文本对齐方式; @ref textFormatFlag_ . 78 | //@别名 置文本对齐() 79 | void SetTextAlign(int align) { 80 | XShapeText_SetTextAlign(m_handle, align); 81 | } 82 | 83 | //@备注 设置内容偏移. 84 | //@参数 x X坐标. 85 | //@参数 y Y坐标. 86 | //@返回 成功返回TRUE否则返回FALSE. 87 | //@别名 置偏移() 88 | void SetOffset(int x, int y) { 89 | XShapeText_SetOffset(m_handle, x, y); 90 | } 91 | }; 92 | } -------------------------------------------------------------------------------- /examples/resources/WmUi/control/窗口_输入框.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pyxcgui/binding/bkmanager/XBkManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/bkmanager/XCBkManager.hpp" 4 | #include "xcgui/bkmanager/XCBkObject.hpp" 5 | #include "xcgui/XCImage.hpp" 6 | #include "xcgui/XCDraw.hpp" 7 | #include "xcgui/XCStruct.hpp" 8 | 9 | namespace xcgui { 10 | 11 | void declareBkManager(py::module& m) { 12 | 13 | py::class_(m, "XBkManager") 14 | PYCASTOBJECT(XCBkManager) 15 | PYOBJECTVALID(XCBkManager, XC_BKINFOM) 16 | .def(py::init<>()) 17 | .def("setInfo", &XCBkManager::SetInfo, "text"_a) 18 | .def("addInfo", &XCBkManager::AddInfo, "text"_a) 19 | .def("addBorder", &XCBkManager::AddBorder, "state"_a, "color"_a, "width"_a, "bkId"_a=0) 20 | .def("addFill", &XCBkManager::AddFill, "state"_a, "color"_a, "bkId"_a=0) 21 | .def("addImage", [](XCBkManager& self, int state, const XCImage& image, int bkId=0) { 22 | self.AddImage(state, image.getImageHandle(), bkId); 23 | }, "state"_a, "image"_a, "bkId"_a = 0) 24 | .def("getCount", &XCBkManager::GetCount) 25 | .def("clear", &XCBkManager::Clear) 26 | .def("draw", [](XCBkManager& self, int state, const XCDraw& draw, const XCRect& rect) { 27 | return self.Draw(state, draw.getDrawHandle(), (RECT*)&rect); 28 | }, "state"_a, "draw"_a, "rect"_a) 29 | .def("drawEx", [](XCBkManager& self, int state, const XCDraw& draw, const XCRect& rect, int stateEx) { 30 | return self.DrawEx(state, draw.getDrawHandle(), (RECT*)&rect, stateEx); 31 | }, "state"_a, "draw"_a, "rect"_a, "stateEx"_a) 32 | .def("getStateTextColor", [](XCBkManager& self, int state) -> COLORREF { 33 | COLORREF color; 34 | if (!self.GetStateTextColor(state, &color)) 35 | return 0; 36 | return color; 37 | }, "state"_a) 38 | .def("getBkObjectHandle", &XCBkManager::GetBkObject, "bkId"_a=0) 39 | .def("getBkObject", [](XCBkManager& self, int bkId=0) -> XCBkObject* { 40 | auto handle = self.GetBkObject(bkId); 41 | if (!handle) { 42 | return nullptr; 43 | } 44 | return new XCBkObject(handle); 45 | 46 | }, "bkId"_a=0, py::return_value_policy::take_ownership) 47 | 48 | .def("enableAutoDestroy", &XCBkManager::EnableAutoDestroy, "enable"_a) 49 | .def("addRef", &XCBkManager::AddRef) 50 | .def("release", &XCBkManager::Release) 51 | .def("getRefCount", &XCBkManager::GetRefCount) 52 | .def("destroy", &XCBkManager::Destroy); 53 | } 54 | } -------------------------------------------------------------------------------- /examples/resources/svg/淘公仔文字.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyxcgui/binding/element/XScrollBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCScrollBar.hpp" 4 | #include "xcgui/element/XCButton.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareScrollBar(py::module& m) { 9 | py::class_(m, "XScrollBar") 10 | PYCASTOBJECT(XCScrollBar) 11 | PYOBJECTVALID(XCScrollBar, XC_SCROLLBAR) 12 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 13 | HXCGUI handle = nullptr; 14 | if (parent) { 15 | handle = parent->GetHandle(); 16 | } 17 | XCScrollBar obj(x, y, cx, cy, handle); 18 | return obj; 19 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 20 | 21 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 22 | HXCGUI handle = nullptr; 23 | if (parent) { 24 | handle = parent->GetHandle(); 25 | } 26 | XCScrollBar obj(0,0, cx, cy, handle); 27 | return obj; 28 | }), "width"_a, "height"_a, "parent"_a=nullptr) 29 | 30 | .def("setRange", &XCScrollBar::SetRange, "range"_a) 31 | .def("getRange", &XCScrollBar::GetRange) 32 | .def("showButton", &XCScrollBar::ShowButton, "enable"_a) 33 | 34 | 35 | .def("setSliderLength", &XCScrollBar::SetSliderLength, "length"_a) 36 | .def("setSliderMinLength", &XCScrollBar::SetSliderMinLength, "length"_a) 37 | .def("setSliderPadding", &XCScrollBar::SetSliderPadding, "padding"_a) 38 | .def("enableHorizon", &XCScrollBar::EnableHorizon, "enable"_a) 39 | .def("getSliderMaxLength", &XCScrollBar::GetSliderMaxLength) 40 | .def("scrollUp", &XCScrollBar::ScrollUp) 41 | .def("scrollDown", &XCScrollBar::ScrollDown) 42 | .def("scrollTop", &XCScrollBar::ScrollTop) 43 | .def("scrollBottom", &XCScrollBar::ScrollBottom) 44 | .def("scrollPos", &XCScrollBar::ScrollPos, "pos"_a) 45 | .def("scrollUp", &XCScrollBar::ScrollUp) 46 | 47 | 48 | .def("getButtonUp", [](XCScrollBar& self) { 49 | auto handle = self.GetButtonUp(); 50 | XCButton btn(handle); 51 | return btn; 52 | }) 53 | 54 | .def("getButtonDown", [](XCScrollBar& self) { 55 | auto handle = self.GetButtonDown(); 56 | XCButton btn(handle); 57 | return btn; 58 | }) 59 | 60 | .def("getButtonSlider", [](XCScrollBar& self) { 61 | auto handle = self.GetButtonSlider(); 62 | XCButton btn(handle); 63 | return btn; 64 | }) 65 | 66 | ; 67 | } 68 | } -------------------------------------------------------------------------------- /pyxcgui/binding/element/XToolBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCToolBar.hpp" 4 | #include "xcgui/XCStruct.hpp" 5 | #include "binding/manager/XCastManager.hpp" 6 | #include "xcgui/utils/Color.hpp" 7 | 8 | namespace xcgui { 9 | 10 | void declareToolbar(py::module& m) { 11 | py::class_(m, "XToolBar") 12 | PYCASTOBJECT(XCToolBar) 13 | PYOBJECTVALID(XCToolBar, XC_TOOLBAR) 14 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 15 | HXCGUI handle = nullptr; 16 | if (parent) { 17 | handle = parent->GetHandle(); 18 | } 19 | XCToolBar obj(x, y, cx, cy, handle); 20 | return obj; 21 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 22 | 23 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 24 | HXCGUI handle = nullptr; 25 | if (parent) { 26 | handle = parent->GetHandle(); 27 | } 28 | XCToolBar obj(0,0, cx, cy, handle); 29 | return obj; 30 | }), "width"_a, "height"_a, "parent"_a=nullptr) 31 | 32 | 33 | .def("insertEle", [](XCToolBar& self, const XCElement& ele, int index) { 34 | self.InsertEle(ele.getEleHandle(), index); 35 | }, "ele"_a, "index"_a) 36 | 37 | .def("insertSeparator", &XCToolBar::InsertSeparator, "index"_a=-1, 38 | "color"_a= (COLORREF)(COLORREF_MAKE(128, 128, 128, 255))) 39 | 40 | .def("enableButtonMenu", &XCToolBar::EnableButtonMenu, "enable"_a) 41 | .def("getEle", [](XCToolBar& self, int index) -> XCObject* { 42 | auto handel = self.GetEle(index); 43 | return XCastManager::GetInstance()->CastObject(handel); 44 | }, "index"_a) 45 | .def("getButtonLeft", [](XCToolBar& self) -> XCObject* { 46 | auto handle = self.GetButtonLeft(); 47 | return XCastManager::GetInstance()->CastObject(handle); 48 | }) 49 | .def("getButtonRight", [](XCToolBar& self) -> XCObject* { 50 | auto handle = self.GetButtonRight(); 51 | return XCastManager::GetInstance()->CastObject(handle); 52 | }) 53 | .def("getButtonMenu", [](XCToolBar& self) -> XCObject* { 54 | auto handle = self.GetButtonMenu(); 55 | return XCastManager::GetInstance()->CastObject(handle); 56 | }) 57 | 58 | .def("setSpace", &XCToolBar::SetSpace, "size"_a) 59 | .def("deleteEle", &XCToolBar::DeleteEle, "index"_a) 60 | .def("deleteAllEle", &XCToolBar::DeleteAllEle) 61 | 62 | ; 63 | } 64 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/adapter/XCAdapterMap.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pch.h" 4 | #include "xcgui/adapter/XCAdapter.hpp" 5 | 6 | namespace xcgui { 7 | 8 | class XCAdapterMap : public XCAdapter 9 | { 10 | public: 11 | XCAdapterMap(HXCGUI handle) { 12 | m_handle = handle; 13 | } 14 | 15 | XCAdapterMap() { 16 | m_handle = XAdMap_Create(); 17 | } 18 | 19 | /// @brief 增加数据项. 20 | /// @param name.c_str() 字段称. 21 | /// @param value.c_str() 值. 22 | /// @return 成功返回TRUE否则返回FALSE. 23 | 24 | bool AddItemText(const std::wstring& name, const std::wstring& value) 25 | { 26 | return XAdMap_AddItemText(m_handle, name.c_str(), value.c_str()); 27 | } 28 | 29 | /// @brief 添加项图片. 30 | /// @param name.c_str() 图片句柄. 31 | /// @param hImage 图片句柄. 32 | /// @return 成功返回TRUE否则返回FALSE. 33 | bool AddItemImage(const std::wstring& name, HIMAGE hImage) 34 | { 35 | return XAdMap_AddItemImage(m_handle, name.c_str(), hImage);; 36 | } 37 | 38 | /// @brief 删除项 39 | /// @param name.c_str() 字段称. 40 | /// @return 成功返回TRUE否则返回FALSE. 41 | bool DeleteItem(const std::wstring& name) 42 | { 43 | return XAdMap_DeleteItem(m_handle, name.c_str()); 44 | } 45 | /// @brief 取项数量 46 | /// @return 取项数量 47 | int GetCount() 48 | { 49 | return XAdMap_GetCount(m_handle); 50 | } 51 | 52 | /// @brief 取项文本 53 | /// @param name.c_str() 字段称. 54 | /// @return 返回文本内容. 55 | std::wstring GetItemText(const std::wstring& name) 56 | { 57 | auto pText = XAdMap_GetItemText(m_handle, name.c_str()); 58 | if (!pText) return L""; 59 | return pText; 60 | } 61 | /// @brief 返回文本内容. 62 | /// @param name.c_str() 字段称. 63 | /// @return 返回图片句柄. 64 | HIMAGE GetItemImage(const std::wstring& name) 65 | { 66 | return XAdMap_GetItemImage(m_handle, name.c_str()); 67 | } 68 | 69 | /// @brief 置项文本 70 | /// @param name.c_str() 字段称. 71 | /// @param value.c_str() 值. 72 | /// @return 成功返回TRUE否则返回FALSE. 73 | bool SetItemText(const std::wstring& name, const std::wstring& value) 74 | { 75 | return XAdMap_SetItemText(m_handle, name.c_str(), value.c_str()); 76 | } 77 | /// @brief 置项图片 78 | /// @param name.c_str() 置项图片 79 | /// @param hImage 置项图片 80 | /// @return 成功返回TRUE否则返回FALSE. 81 | bool SetItemImage(const std::wstring& name, HIMAGE hImage) 82 | { 83 | return XAdMap_SetItemImage(m_handle, name.c_str(), hImage); 84 | } 85 | }; 86 | } 87 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCToolBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCElement.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCToolBar : public XCElement 8 | { 9 | public: 10 | XCToolBar(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | 16 | XCToolBar() = default; 17 | 18 | XCToolBar(int x, int y, int width, int height, HXCGUI parent = NULL) { 19 | m_handle = XToolBar_Create(x, y, width, height, parent); 20 | } 21 | 22 | 23 | //@备注 插入元素到工具条. 24 | //@参数 hNewEle 将要插入的元素. 25 | //@参数 index 插入位置索引, (-1)插入末尾.. 26 | //@返回 返回插入位置索引. 27 | //@别名 插入元素() 28 | int InsertEle(HELE hNewEle, int index = -1) { 29 | return XToolBar_InsertEle(getEleHandle(), hNewEle, index); 30 | } 31 | 32 | //@备注 插入分隔符到工具条. 33 | //@参数 index 插入位置索引, (-1)插入末尾. 34 | //@参数 color 颜色值, 请使用宏: RGBA() 35 | //@返回 返回插入位置索引. 36 | //@别名 插入分割栏() 37 | int InsertSeparator(int index = -1, COLORREF color = COLORREF_MAKE(128, 128, 128, 255)) { 38 | return XToolBar_InsertSeparator(getEleHandle(), index, color); 39 | } 40 | 41 | //@备注 启用下拉菜单,显示隐藏的项. 42 | //@参数 bEnable 是否启用. 43 | //@别名 启用下拉菜单() 44 | void EnableButtonMenu(bool bEnable) { 45 | XToolBar_EnableButtonMenu(getEleHandle(), bEnable); 46 | } 47 | 48 | //@备注 获取工具条上指定元素. 49 | //@参数 index 索引值. 50 | //@返回 返回元素句柄. 51 | //@别名 取元素() 52 | HELE GetEle(int index) { 53 | return XToolBar_GetEle(getEleHandle(), index); 54 | } 55 | 56 | //@备注 获取左滚动按钮. 57 | //@返回 返回按钮句柄. 58 | //@别名 取左滚动按钮() 59 | HELE GetButtonLeft() { 60 | return XToolBar_GetButtonLeft(getEleHandle()); 61 | } 62 | 63 | //@备注 获取右滚动按钮. 64 | //@返回 返回按钮句柄. 65 | //@别名 取右滚动按钮() 66 | HELE GetButtonRight() { 67 | return XToolBar_GetButtonRight(getEleHandle()); 68 | } 69 | 70 | //@备注 获取菜单按钮. 71 | //@返回 返回菜单按钮句柄. 72 | //@别名 取菜单按钮() 73 | HELE GetButtonMenu() { 74 | return XToolBar_GetButtonMenu(getEleHandle()); 75 | } 76 | 77 | //@备注 设置对象之间的间距. 78 | //@参数 nSize 间距大小. 79 | //@别名 置间距() 80 | void SetSpace(int nSize) { 81 | XToolBar_SetSpace(getEleHandle(), nSize); 82 | } 83 | 84 | //@备注 删除元素,并且销毁. 85 | //@参数 index 索引值. 86 | //@别名 删除元素() 87 | void DeleteEle(int index) { 88 | XToolBar_DeleteEle(getEleHandle(), index); 89 | } 90 | 91 | //@备注 删除所有元素,并且销毁. 92 | //@别名 删除全部() 93 | void DeleteAllEle() { 94 | XToolBar_DeleteAllEle(getEleHandle()); 95 | } 96 | }; 97 | } 98 | -------------------------------------------------------------------------------- /examples/resources/WmUi/control/窗口_信息框.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/shape/XCShapeGroupBox.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShape.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCShapeGroupBox : public XCShape 8 | { 9 | public: 10 | XCShapeGroupBox() = default; 11 | 12 | XCShapeGroupBox(HXCGUI handle) 13 | { 14 | m_handle = handle; 15 | } 16 | 17 | XCShapeGroupBox(int x, int y, int cx, int cy, const std::wstring& name, HXCGUI hParent = NULL) { 18 | this->Create(x, y, cx, cy, name, hParent); 19 | } 20 | 21 | HXCGUI Create(int x, int y, int cx, int cy, const std::wstring& name, HXCGUI hParent = NULL) { 22 | m_handle = XShapeGroupBox_Create(x, y, cx, cy, name.c_str(), hParent); 23 | return m_handle; 24 | } 25 | 26 | //@备注 设置边框颜色. 27 | //@参数 color 颜色值, 请使用宏: RGBA() 28 | //@别名 置边框颜色() 29 | void SetBorderColor(COLORREF color) { 30 | XShapeGroupBox_SetBorderColor(m_handle, color); 31 | } 32 | 33 | //@备注 设置文本颜色. 34 | //@参数 color 颜色值, 请使用宏: RGBA() 35 | //@别名 置文本颜色() 36 | void SetTextColor(COLORREF color) { 37 | XShapeGroupBox_SetTextColor(m_handle, color); 38 | } 39 | 40 | //@备注 设置字体. 41 | //@参数 hFontX 炫彩字体. 42 | //@别名 置字体() 43 | void SetFontX(HFONTX hFontX) { 44 | XShapeGroupBox_SetFontX(m_handle, hFontX); 45 | } 46 | 47 | //@备注 设置文本偏移量. 48 | //@参数 offsetX 水平偏移. 49 | //@参数 offsetY 垂直偏移. 50 | //@别名 置文本偏移() 51 | void SetTextOffset(int offsetX, int offsetY) { 52 | XShapeGroupBox_SetTextOffset(m_handle, offsetX, offsetY); 53 | } 54 | 55 | //@备注 设置圆角大小. 56 | //@参数 nWidth 圆角宽度. 57 | //@参数 nHeight 圆角高度. 58 | //@别名 置圆角大小() 59 | void SetRoundAngle(int nWidth, int nHeight) { 60 | XShapeGroupBox_SetRoundAngle(m_handle, nWidth, nHeight); 61 | } 62 | 63 | //@备注 设置文本内容. 64 | //@参数 pText 文本内容. 65 | //@别名 置文本() 66 | void SetText(const std::wstring& text) { 67 | XShapeGroupBox_SetText(m_handle, text.c_str()); 68 | } 69 | 70 | //@备注 获取文本偏移量. 71 | //@参数 pOffsetX X坐标偏移量. 72 | //@参数 pOffsetY Y坐标偏移量. 73 | //@返回 成功返回TRUE否则返回FALSE. 74 | //@别名 取文本偏移() 75 | void GetTextOffset(int* pOffsetX, int* pOffsetY) { 76 | XShapeGroupBox_GetTextOffset(m_handle, pOffsetX, pOffsetY); 77 | } 78 | 79 | //@备注 获取圆角大小. 80 | //@参数 pWidth 返回圆角宽度. 81 | //@参数 pHeight 返回圆角高度. 82 | //@别名 取圆角大小() 83 | void GetRoundAngle(int* pWidth, int* pHeight) { 84 | XShapeGroupBox_GetRoundAngle(m_handle, pWidth, pHeight); 85 | } 86 | 87 | //@备注 启用圆角. 88 | //@参数 bEnable 是否启用. 89 | //@别名 启用圆角() 90 | void EnableRoundAngle(bool bEnable) { 91 | XShapeGroupBox_EnableRoundAngle(m_handle, bEnable); 92 | } 93 | 94 | }; 95 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/animation/XCAnimation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCObject.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCAnimation : public XCObject 8 | { 9 | public: 10 | XCAnimation(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | XCAnimation() = default; 16 | 17 | 18 | //@备注 将动画加入动画系统中运行 19 | //@参数 hAnimationEx 动画序列或动画组句柄 20 | //@参数 hRedrawObjectUI 当更新UI时重绘的UI层; UI对象句柄: 窗口句柄,元素句柄,形状句柄,SVG句柄 21 | //@别名 动画_运行() 22 | void Run(HXCGUI hRedRawObjectUI) { 23 | XAnima_Run(m_handle, hRedRawObjectUI); 24 | } 25 | //@备注 将动画从动画系统中移除,并且自动销毁(如果启用自动销毁) 26 | //@参数 hAnimationEx 动画序列或动画组句柄 27 | //@参数 bEnd 是否立即执行到终点 28 | //@别名 动画_释放() 29 | bool Release(bool bEnd = true) { 30 | return XAnima_Release(m_handle, bEnd); 31 | 32 | } 33 | //@备注 从动画系统中移除与指定UI对象关联的所有动画, 并且自动销毁(如果启用自动销毁) 34 | //@参数 hObjectUI 指定UI对象句柄 35 | //@参数 bEnd 是否立即执行到终点 36 | //@返回 返回释放动画数量 37 | //@别名 动画_释放扩展() 38 | static int ReleaseEx(HXCGUI objectUI, bool bEnd) { 39 | return XAnima_ReleaseEx(objectUI, bEnd); 40 | } 41 | 42 | 43 | 44 | //@备注 true:自动销毁 false:手动销毁 45 | //@参数 hAnimationEx 动画序列或动画组句柄 46 | //@参数 bEnable 是否启用 47 | //@别名 动画_启用自动销毁() 48 | void EnableAutoDestroy(bool bEnable) { 49 | XAnima_EnableAutoDestroy(m_handle, bEnable); 50 | } 51 | 52 | 53 | //@备注 获取动画关联的UI对象 54 | //@参数 hAnimationEx 动画序列或动画组或动画项句柄 55 | //@返回 返回UI对象句柄 56 | //@别名 动画_取UI对象() 57 | HXCGUI GetObjectUI() { 58 | return XAnima_GetObjectUI(m_handle); 59 | } 60 | 61 | //@参数 hAnimationEx 动画序列或动画组句柄 62 | //@参数 callback 回调函数 63 | //@别名 动画_置回调() 64 | void SetCallBack(funAnimation callback) { 65 | XAnima_SetCallback(m_handle, callback); 66 | } 67 | 68 | 69 | //@参数 hAnimationEx 动画序列或动画组句柄 70 | //@参数 nUserData 用数据 71 | //@别名 动画_置用户数据() 72 | void SetUserData(vint nUserData) { 73 | return XAnima_SetUserData(m_handle, nUserData); 74 | } 75 | 76 | 77 | //@参数 hAnimationEx 动画序列或动画组句柄 78 | //@返回 返回用户数据 79 | //@别名 动画_取用户数据() 80 | vint GetUserData() { 81 | return XAnima_GetUserData(m_handle); 82 | } 83 | 84 | //@参数 hAnimationEx 动画序列或动画组句柄 85 | //@别名 动画_停止() 86 | void Stop() { 87 | XAnima_Stop(m_handle); 88 | } 89 | 90 | 91 | //@参数 hAnimationEx 动画序列或动画组句柄 92 | //@别名 动画_开始() 93 | void Start() { 94 | XAnima_Start(m_handle); 95 | } 96 | 97 | //@备注 未实现功能 98 | //@参数 hAnimationEx 动画序列或动画组句柄 99 | //@别名 动画_暂停() 100 | void Pause() { 101 | XAnima_Pause(m_handle); 102 | } 103 | 104 | protected: 105 | HXCGUI m_objectHandle; 106 | }; 107 | } -------------------------------------------------------------------------------- /pyxcgui/binding/XWidget.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCWidget.hpp" 4 | #include "manager/XCastManager.hpp" 5 | 6 | 7 | namespace xcgui { 8 | 9 | void declareWidget(py::module& m) { 10 | 11 | py::class_(m, "XLayoutSize") 12 | .def(py::init<>()) 13 | .def(py::init(), "sizeType"_a, "size"_a) 14 | .def_readwrite("sizeType", &XCLayoutSize::sizeType) 15 | .def_readwrite("size", &XCLayoutSize::size); 16 | 17 | py::class_(m, "XWidget") 18 | PYCASTOBJECT(XCWidget) 19 | PYOBJECTVALID(XCWidget, XC_WIDGET_UI) 20 | .def("isShow", &XCWidget::IsShow) 21 | .def("show", &XCWidget::Show, "show"_a) 22 | .def("enableLayoutControl", &XCWidget::EnableLayoutControl, "enable"_a) 23 | .def("isLayoutControl", &XCWidget::IsLayoutControl) 24 | 25 | .def("getParentEle", [](const XCWidget& self) -> XCObject* { 26 | return XCastManager::GetInstance()->CastObject(self.GetParentEle()); 27 | }, py::return_value_policy::take_ownership) 28 | 29 | 30 | .def("getParent", [](const XCWidget& self) -> XCObject* { 31 | return XCastManager::GetInstance()->CastObject(self.getParent()); 32 | }, py::return_value_policy::take_ownership) 33 | 34 | 35 | .def("getHWND", &XCWidget::GetHWND) 36 | .def("getWindow", [](const XCWidget& self) -> XCObject* { 37 | return XCastManager::GetInstance()->CastObject(self.GetWindow()); 38 | }, py::return_value_policy::take_ownership) 39 | 40 | .def("setID", &XCWidget::SetID, "id"_a) 41 | .def("getID", &XCWidget::GetID) 42 | .def("setUID", &XCWidget::SetUID, "uid"_a) 43 | .def("getUID", &XCWidget::GetUID) 44 | .def("setName", &XCWidget::SetName, "name"_a) 45 | .def("getName", &XCWidget::GetName) 46 | .def("layoutEnableWrap", &XCWidget::LayoutEnableWrap, "wrap"_a) 47 | .def("layoutEnableSwap", &XCWidget::LayoutEnableSwap, "swap"_a) 48 | .def("layoutEnableFloat", &XCWidget::LayoutEnableFloat, "float"_a) 49 | .def("layoutSetWidth", &XCWidget::LayoutSetWidth, "sizeType"_a, "size"_a=0) 50 | .def("layoutSetHeight", &XCWidget::LayoutSetHeight, "sizeType"_a, "size"_a = 0) 51 | .def("layoutGetWidth", &XCWidget::LayoutGetWidth) 52 | .def("layoutGetHeight", &XCWidget::LayoutGetHeight) 53 | .def("layoutSetAlign", &XCWidget::LayoutSetAlign, "align"_a) 54 | .def("layoutSetMargin", &XCWidget::LayoutSetMargin, "left"_a, "top"_a, "right"_a, "bottom"_a) 55 | .def("layoutGetMargin", &XCWidget::LayoutGetMargin) 56 | .def("layoutSetMinSize", &XCWidget::LayoutSetMinSize, "width"_a, "height"_a) 57 | .def("layoutSetPosition", &XCWidget::LayoutSetPosition, "left"_a, "top"_a, "right"_a, "bottom"_a); 58 | 59 | } 60 | } -------------------------------------------------------------------------------- /pyxcgui/binding/bkmanager/XBkObject.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/bkmanager/XCBkObject.hpp" 4 | #include "xcgui/XCImage.hpp" 5 | #include "xcgui/XCFont.hpp" 6 | #include "xcgui/XCStruct.hpp" 7 | 8 | namespace xcgui { 9 | 10 | void declareBkObject(py::module& m) { 11 | py::class_(m, "XBkObject") 12 | PYCASTOBJECT(XCBkObject) 13 | .def("setMargin", &XCBkObject::SetMargin, "left"_a, "top"_a, "right"_a, "bottom"_a) 14 | .def("setAlign", &XCBkObject::SetAlign, "flags"_a) 15 | .def("setImage", [](XCBkObject& self, const XCImage& image) { 16 | self.SetImage(image.getImageHandle()); 17 | }, "image"_a) 18 | .def("setAlign", &XCBkObject::SetAlign, "flags"_a) 19 | .def("setFillColor", &XCBkObject::SetFillColor, "color"_a) 20 | .def("setBorderWidth", &XCBkObject::SetBorderWidth, "width"_a) 21 | .def("setBorderColor", &XCBkObject::SetBorderColor, "color"_a) 22 | .def("setRectRoundAngle", &XCBkObject::SetRectRoundAngle, "leftTop"_a, "leftBottom"_a, "rightTop"_a, "rightBottom"_a) 23 | .def("enableFill", &XCBkObject::EnableFill, "enable"_a) 24 | .def("enableBorder", &XCBkObject::EnableBorder, "enable"_a) 25 | .def("setText", &XCBkObject::SetText, "text"_a) 26 | 27 | .def("setFont", [](XCBkObject& self, const XCFont& font) { 28 | self.SetFont(font.getFontHandle()); 29 | }, "font"_a) 30 | 31 | .def("setTextAlign", &XCBkObject::SetTextAlign, "align"_a) 32 | .def("getMargin", [](XCBkObject& self) { 33 | XCRect rect; 34 | self.GetMargin((marginSize_*)&rect); 35 | return rect; 36 | }) 37 | 38 | .def("getAlign", &XCBkObject::GetAlign) 39 | 40 | .def("getImage", [](XCBkObject& self) -> XCImage* { 41 | auto handle = self.GetImage(); 42 | if (!handle) { 43 | return nullptr; 44 | } 45 | return new XCImage(handle); 46 | }, py::return_value_policy::take_ownership) 47 | 48 | .def("getRotate", &XCBkObject::GetRotate) 49 | .def("getFillColor", &XCBkObject::GetFillColor) 50 | .def("getBorderColor", &XCBkObject::GetBorderColor) 51 | .def("getBorderWidth", &XCBkObject::GetBorderWidth) 52 | 53 | .def("getRectRoundAngle", [](XCBkObject& self) { 54 | XCRect rect; 55 | self.GetRectRoundAngle((RECT*)&rect); 56 | return rect; 57 | }) 58 | 59 | .def("isFill", &XCBkObject::IsFill) 60 | .def("isBorder", &XCBkObject::IsBorder) 61 | .def("getText", &XCBkObject::GetText) 62 | .def("getFont", [](XCBkObject& self) -> XCFont* { 63 | auto handle = self.GetFont(); 64 | if (!handle) { 65 | return nullptr; 66 | } 67 | return new XCFont(handle); 68 | }, py::return_value_policy::take_ownership) 69 | 70 | .def("getTextAlign", &XCBkObject::GetTextAlign) 71 | .def("getId", &XCBkObject::GetId); 72 | } 73 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/bkmanager/XCBkManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCObject.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCBkManager: public XCObject 8 | { 9 | public: 10 | XCBkManager() 11 | : XCObject() 12 | { 13 | m_handle = XBkM_Create(); 14 | } 15 | 16 | ~XCBkManager() { 17 | } 18 | 19 | XCBkManager(HXCGUI handle) 20 | { 21 | m_handle = handle; 22 | } 23 | 24 | HBKM GetBkmHandle() const { 25 | return (HBKM)m_handle; 26 | } 27 | 28 | // 设置背景内容 29 | int SetBkInfo(const std::wstring& text) { 30 | return XBkM_SetBkInfo(GetBkmHandle(), text.c_str()); 31 | } 32 | 33 | // 设置背景内容 34 | int SetInfo(const std::wstring& text) { 35 | return XBkM_SetInfo(GetBkmHandle(), text.c_str()); 36 | } 37 | 38 | // 添加背景内容 39 | int AddInfo(const std::wstring& text) { 40 | return XBkM_AddInfo(GetBkmHandle(), text.c_str()); 41 | } 42 | 43 | // 添加边框() 44 | void AddBorder(int nState, COLORREF color, int width, int id = 0) { 45 | XBkM_AddBorder(GetBkmHandle(), nState, color, width, id); 46 | } 47 | 48 | // 添加背景内容填充 49 | void AddFill(int nState, COLORREF color, int id = 0) { 50 | XBkM_AddFill(GetBkmHandle(), nState, color, id); 51 | } 52 | 53 | // 添加背景内容图片 54 | void AddImage(int nState, HIMAGE hImage, int id = 0) { 55 | XBkM_AddImage(GetBkmHandle(), nState, hImage, id); 56 | } 57 | 58 | // 获取背景内容数量 59 | int GetCount() { 60 | return XBkM_GetCount(GetBkmHandle()); 61 | } 62 | 63 | // 清空背景内容 64 | void Clear() { 65 | XBkM_Clear(GetBkmHandle()); 66 | } 67 | 68 | // 绘制背景内容 69 | bool Draw(int nState, HDRAW hDraw, RECT* pRect) { 70 | return XBkM_Draw(GetBkmHandle(), nState, hDraw, pRect); 71 | } 72 | 73 | // 绘制背景内容, 设置条件 74 | bool DrawEx(int nState, HDRAW hDraw, RECT* pRect, int nStateEx) { 75 | return XBkM_DrawEx(GetBkmHandle(), nState, hDraw, pRect, nStateEx); 76 | } 77 | 78 | // 取指定状态文本颜色 79 | bool GetStateTextColor(int nState, COLORREF* color) { 80 | return XBkM_GetStateTextColor(GetBkmHandle(), nState, color); 81 | } 82 | 83 | // 背景对象ID 84 | vint GetBkObject(int id) { 85 | return XBkM_GetObject(GetBkmHandle(), id); 86 | } 87 | 88 | // 是否自动销毁 89 | void EnableAutoDestroy(BOOL bEnable) { 90 | XBkM_EnableAutoDestroy(GetBkmHandle(), bEnable); 91 | } 92 | 93 | // 增加引用计数 94 | void AddRef() { 95 | XBkM_AddRef(GetBkmHandle()); 96 | } 97 | 98 | // 释放引用计数,当引用计数为0时,自动销毁 99 | void Release() { 100 | XBkM_Release(GetBkmHandle()); 101 | } 102 | 103 | // 获取引用计数 104 | int GetRefCount() { 105 | return XBkM_GetRefCount(GetBkmHandle()); 106 | } 107 | 108 | // 109 | void Destroy() { 110 | XBkM_Destroy(GetBkmHandle()); 111 | } 112 | 113 | }; 114 | } 115 | -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCDateTime.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCElement.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCDateTime : public XCElement 8 | { 9 | public: 10 | XCDateTime(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | XCDateTime() = default; 16 | 17 | XCDateTime(int x, int y, int width, int height, HXCGUI parent = NULL) { 18 | m_handle = XDateTime_Create(x, y, width, height, parent); 19 | } 20 | 21 | //@备注 设置样式. 22 | //@参数 nStyle 样式, 0为日期元素,1为时间元素. 23 | //@别名 置样式() 24 | void SetStyle(int nStyle) { 25 | XDateTime_SetStyle(getEleHandle(), nStyle); 26 | } 27 | 28 | //@备注 获取样式. 29 | //@返回 元素样式. 30 | //@别名 取样式() 31 | int GetStyle() { 32 | return XDateTime_GetStyle(getEleHandle()); 33 | } 34 | 35 | //@备注 切换分割栏为:斜线或横线. 36 | //@参数 bSlash TRUE:斜线, FALSE:横线. 37 | //@别名 启用分割栏为斜线() 38 | void EnableSplitSlash(bool bSlash) { 39 | XDateTime_EnableSplitSlash(getEleHandle(), bSlash); 40 | } 41 | 42 | //@备注 获取内部按钮元素. 43 | //@参数 nType 按钮类型, 0:日历下拉按钮, 1:上箭头按钮, 2:下箭头按钮 44 | //@返回 元素样式. 45 | //@别名 取内部按钮() 46 | HELE GetButton(int nType) { 47 | return XDateTime_GetButton(getEleHandle(), nType); 48 | } 49 | 50 | //@备注 获取被选择文字的背景颜色. 51 | //@返回 元素样式. 52 | //@别名 取选择日期背景颜色() 53 | COLORREF GetSelBkColor() { 54 | return XDateTime_GetSelBkColor(getEleHandle()); 55 | } 56 | 57 | //@备注 设置被选择文字的背景颜色. 58 | //@参数 crSelectBk 文字被选中背景色, 颜色值, 请使用宏: RGBA() 59 | //@别名 置选择日期背景颜色() 60 | void SetSelBkColor(COLORREF crSelectBk) { 61 | XDateTime_SetSelBkColor(getEleHandle(), crSelectBk); 62 | } 63 | 64 | //@备注 获取当前日期. 65 | //@参数 pnYear 年.[OUT] 66 | //@参数 pnMonth 月.[OUT] 67 | //@参数 pnDay 日.[OUT] 68 | //@别名 取当前日期() 69 | void GetDate(int* pnYear, int* pnMonth, int* pnDay) { 70 | XDateTime_GetDate(getEleHandle(), pnYear, pnMonth, pnDay); 71 | } 72 | 73 | //@备注 设置当前日期. 74 | //@参数 nYear 年. 75 | //@参数 nMonth 月. 76 | //@参数 nDay 日. 77 | //@别名 置当前日期() 78 | void SetDate(int nYear, int nMonth, int nDay) { 79 | XDateTime_SetDate(getEleHandle(), nYear, nMonth, nDay); 80 | } 81 | 82 | //@备注 获取当前时间. 83 | //@参数 pnHour 时.[OUT] 84 | //@参数 pnMinute 分.[OUT] 85 | //@参数 pnSecond 秒.[OUT] 86 | //@别名 取当前时间() 87 | void GetTime(int* pnHour, int* pnMinute, int* pnSecond) { 88 | XDateTime_GetTime(getEleHandle(), pnHour, pnMinute, pnSecond); 89 | } 90 | 91 | //@备注 设置当前时分秒. 92 | //@参数 nHour 时. 93 | //@参数 nMinute 分. 94 | //@参数 nSecond 秒. 95 | //@别名 置当前时间() 96 | void SetTime(int nHour, int nMinute, int nSecond) { 97 | XDateTime_SetTime(getEleHandle(), nHour, nMinute, nSecond); 98 | } 99 | 100 | //@备注 弹出月历卡片 101 | //@别名 弹出() 102 | void Popup() { 103 | XDateTime_Popup(getEleHandle()); 104 | } 105 | 106 | }; 107 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/ease/XCEase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | 4 | namespace xcgui { 5 | 6 | class XCEase 7 | { 8 | public: 9 | //@备注 线性 10 | //@参数 pos 位置, 0.0f - 1.0f 11 | //@返回 返回计算结果 12 | //@别名 缓动_Linear() 13 | static float Linear(float pos) { 14 | return XEase_Linear(pos); 15 | } 16 | 17 | //@备注 二次方曲线 18 | //@参数 pos 位置, 0.0f - 1.0f 19 | //@参数 flag 缓动方式 20 | //@返回 返回计算结果 21 | //@别名 缓动_Quad() 22 | static float Quad(float pos, ease_type_ flag) { 23 | return XEase_Quad(pos, flag); 24 | } 25 | 26 | //@备注 三次方曲线 圆弧 27 | //@参数 pos 位置, 0.0f - 1.0f 28 | //@参数 flag 缓动方式 29 | //@返回 返回计算结果 30 | //@别名 缓动_Cubic() 31 | static float Cubic(float pos, ease_type_ flag) { 32 | return XEase_Cubic(pos, flag); 33 | } 34 | 35 | //@备注 四方曲线 36 | //@参数 pos 位置, 0.0f - 1.0f 37 | //@参数 flag 缓动方式 38 | //@返回 返回计算结果 39 | //@别名 缓动_Quart() 40 | static float Quart(float pos, ease_type_ flag) { 41 | return XEase_Quart(pos, flag); 42 | } 43 | 44 | //@备注 五次方曲线 45 | //@参数 pos 位置, 0.0f - 1.0f 46 | //@参数 flag 缓动方式 47 | //@返回 返回计算结果 48 | //@别名 缓动_Quint() 49 | static float Quint(float pos, ease_type_ flag) { 50 | return XEase_Quint(pos, flag); 51 | } 52 | 53 | 54 | //@备注 正弦曲线, 在末端变化 55 | //@参数 pos 位置, 0.0f - 1.0f 56 | //@参数 flag 缓动方式 57 | //@返回 返回计算结果 58 | //@别名 缓动_Sine() 59 | static float Sine(float pos, ease_type_ flag) { 60 | return XEase_Sine(pos, flag); 61 | } 62 | 63 | //@备注 突击曲线, 突然一下 64 | //@参数 pos 位置, 0.0f - 1.0f 65 | //@参数 flag 缓动方式 66 | //@返回 返回计算结果 67 | //@别名 缓动_Expo() 68 | static float Expo(float pos, ease_type_ flag) { 69 | return XEase_Expo(pos, flag); 70 | } 71 | 72 | //@备注 圆环, 好比绕过一个圆环 73 | //@参数 pos 位置, 0.0f - 1.0f 74 | //@参数 flag 缓动方式 75 | //@返回 返回计算结果 76 | //@别名 缓动_Circ() 77 | static float Circ(float pos, ease_type_ flag) { 78 | return XEase_Circ(pos, flag); 79 | } 80 | 81 | 82 | //@备注 强力回弹 83 | //@参数 pos 位置, 0.0f - 1.0f 84 | //@参数 flag 缓动方式 85 | //@返回 返回计算结果 86 | //@别名 缓动_Elastic() 87 | static float Elastic(float pos, ease_type_ flag) { 88 | return XEase_Elastic(pos, flag); 89 | } 90 | 91 | //@备注 回弹, 比较缓慢 92 | //@参数 pos 位置, 0.0f - 1.0f 93 | //@参数 flag 缓动方式 94 | //@返回 返回计算结果 95 | //@别名 缓动_Back() 96 | static float Back(float pos, ease_type_ flag) { 97 | return XEase_Back(pos, flag); 98 | } 99 | 100 | //@备注 弹跳 模拟小球落地弹跳 101 | //@参数 pos 位置, 0.0f - 1.0f 102 | //@参数 flag 缓动方式 103 | //@返回 返回计算结果 104 | //@别名 缓动_Bounce() 105 | static float Bounce(float pos, ease_type_ flag) { 106 | return XEase_Bounce(pos, flag); 107 | } 108 | 109 | 110 | //@备注 全部缓动类型 111 | //@参数 pos 位置, 0.0f - 1.0f 112 | //@参数 flag 缓动方式 @ref ease_flag_ 113 | //@返回 返回计算结果 114 | //@别名 缓动_扩展() 115 | static float Ex(float pos, int flag) { 116 | return XEase_Ex(pos, flag); 117 | } 118 | }; 119 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

XCGUI for Python

2 |

3 | release 4 | XCGUI 5 | License 6 |

7 | 程序示例   8 | 官方文档   9 | 官方资源 10 |

11 | 12 | 13 | 14 | 15 | ## 介绍 16 | 17 | - 本库封装自炫彩界面库,功能丰富(1000多个API接口),简单易用,轻量级,高度DIY自定义,支持一键换肤。 18 | - 炫彩界面库是由C/C++语言开发:软件运行效率高,不需要第三方库的支持,不依赖MFC,ATL,WINDOWS标准控件等。 19 | - DirectUI设计思想:在窗口内没有子窗口,界面元素都是逻辑上的区域(无HWND句柄,安全,灵活),所有UI元素都是自主开发(不受系统限制),更加灵活的实现各种程序界面,满足不同用户的需求。 20 | - 拥有免费的UI设计器:快速开发工具,所见即所得,高度自定义系统(DIY),让UI开发变的更加简单。 21 | - 支持Direct2D,硬件加速,能更大程度的发挥硬件特性,创建高性能,高质量的2D图形。 22 | - 有完善的中文官方文档:[中文官方文档](http://www.xcgui.com/doc-ui/) 23 | 24 | ## 获取 25 | 26 | ```bash 27 | pip install xcgui 28 | ``` 29 | 国内源安装 30 | ```bash 31 | pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xcgui 32 | ``` 33 | 34 | ## 可视化UI设计器 35 | 36 | 使用UI设计器可以快速设计界面,节省大量代码。 37 | 38 | ![uidesigner](https://z3.ax1x.com/2021/09/15/4Vmh9S.png) 39 | 40 | [设计器使用例子]只有这么多代码: 41 | 42 | ```python 43 | from xcgui import XApp, XWindow, XDesigner 44 | 45 | app = XApp() 46 | app.enableDPI(True) 47 | XDesigner.loadResource("baidu\\resource.res") 48 | 49 | 50 | class BaiduWindow(XWindow): 51 | def __init__(self): 52 | super(BaiduWindow, self).__init__() 53 | self.loadLayout("baidu\\main.xml") 54 | 55 | 56 | window = BaiduWindow() 57 | window.showWindow() 58 | app.run() 59 | app.exit() 60 | ``` 61 | 62 | 63 | ## 简单窗口(纯代码) 64 | 65 | 66 | 67 | ```python 68 | # -*- coding: utf8 -*- 69 | import xcgui 70 | from xcgui import XApp, XWindow, XButton, XEdit 71 | 72 | 73 | class DemoWindow(XWindow): 74 | def __init__(self): 75 | super(DemoWindow, self).__init__(400, 300, "XCGUI界面库 for python") 76 | self.enableLayout(True) 77 | self.setAlignV(xcgui.layout_align_center) 78 | self.setAlignH(xcgui.layout_align_center) 79 | self.enableHorizon(False) 80 | self.setSpace(20) 81 | self.btn = XButton(100, 30, "测试", self) 82 | self.btn.regEvent(xcgui.XE_BNCLICK, self.onBtnClick) 83 | self.edit = XEdit(200, 30, self) 84 | 85 | def onBtnClick(self, event, userdata): 86 | self.edit.setText("你好,世界!") 87 | self.edit.redraw(True) 88 | 89 | 90 | def main(): 91 | app = XApp() 92 | app.enableDPI(True) 93 | window = DemoWindow() 94 | window.showWindow() 95 | app.run() 96 | app.exit() 97 | 98 | 99 | if __name__ == '__main__': 100 | main() 101 | 102 | ``` -------------------------------------------------------------------------------- /pyxcgui/binding/window/XFrameWindow.hpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "xcgui/window/XCFrameWindow.hpp" 3 | #include "xcgui/XCElement.hpp" 4 | #include "xcgui/XCStruct.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareFrameWindow(py::module& m) { 9 | 10 | py::class_(m, "XFrameWindow") 11 | PYCASTOBJECT(XCFrameWindow) 12 | PYOBJECTVALID(XCFrameWindow, XC_FRAMEWND) 13 | .def(py::init<>()) 14 | .def(py::init([](int width, int height, const std::wstring& title) { 15 | XCFrameWindow window(0, 0, width, height, title, 0, window_style_default); 16 | return window; 17 | }), "width"_a, "height"_a, "title"_a) 18 | .def(py::init() 19 | , "x"_a, "y"_a, "width"_a, "height"_a, "title"_a, "hwndParent"_a, "xcStyle"_a=(int)window_style_default) 20 | 21 | .def(py::init() 23 | , "exStyle"_a, "style"_a, "className"_a, "x"_a, "y"_a, "width"_a, "height"_a, 24 | "title"_a, "hwndParent"_a, "xcStyle"_a=int(window_style_default)) 25 | 26 | .def("attach", &XCFrameWindow::Attach, "hwnd"_a, "style"_a) 27 | .def("setView", [](XCFrameWindow& self, const XCElement& ele){ 28 | self.SetView(ele.getEleHandle()); 29 | }, "ele"_a) 30 | 31 | .def("setTabBarHeight", &XCFrameWindow::SetTabBarHeight, "height"_a) 32 | .def("setPaneSplitBarColor", &XCFrameWindow::SetPaneSplitBarColor, "color"_a) 33 | .def("saveLayoutToFile", &XCFrameWindow::SaveLayoutToFile, "filename"_a) 34 | .def("addPane", [](XCFrameWindow& self, const XCElement& dest, const XCElement& newEle, pane_align_ align){ 35 | return self.AddPane(dest.getEleHandle(), newEle.getEleHandle(), align); 36 | }, "panelDest"_a, "paneNew"_a, "align"_a) 37 | 38 | .def("mergePane", [](XCFrameWindow& self, const XCElement& dest, const XCElement& newEle){ 39 | return self.MergePane(dest.getEleHandle(), newEle.getEleHandle()); 40 | }, "panelDest"_a, "paneNew"_a) 41 | 42 | .def("loadLayoutFile", [](XCFrameWindow& self, std::vector paneList, const std::wstring& fileName){ 43 | std::vector vEles; 44 | for (auto& ele : paneList) { 45 | vEles.emplace_back(ele.getEleHandle()); 46 | } 47 | return self.LoadLayoutFile(&vEles[0], paneList.size(), fileName); 48 | }, "panelList"_a, "filename"_a) 49 | 50 | .def("getLayoutAreaRect", [](XCFrameWindow& self) { 51 | XCRect rect; 52 | self.GetLayoutAreaRect((RECT*)&rect); 53 | return rect; 54 | }) 55 | 56 | // 3.3.5 新增 57 | .def("getDragFloatWndTopFlag", &XCFrameWindow::GetDragFloatWndTopFlag) 58 | 59 | // 3.3.8 新增 60 | .def("getViewRect", [](XCFrameWindow& self) { 61 | XCRect rect; 62 | self.GetViewRect((RECT*)&rect); 63 | return rect; 64 | }) 65 | .def("setPaneSplitBarWidth", &XCFrameWindow::SetPaneSplitBarWidth, "width"_a) 66 | .def("getPaneSplitBarWidth", &XCFrameWindow::GetPaneSplitBarWidth) 67 | ; 68 | } 69 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/window/XCFrameWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pch.h" 4 | #include "xcgui/window/XCWindow.hpp" 5 | #include "xcgui/XCElement.hpp" 6 | 7 | namespace xcgui { 8 | 9 | class XCFrameWindow : public XCWindow 10 | { 11 | public: 12 | XCFrameWindow() = default; 13 | XCFrameWindow(HXCGUI handle) 14 | { 15 | m_handle = handle; 16 | } 17 | XCFrameWindow(int x, int y, int cx, int cy, const std::wstring& title, uintptr_t hWndParent, int xcStyle= window_style_default) { 18 | m_handle = XFrameWnd_Create(x, y, cx, cy, title.c_str(), (HWND)hWndParent, xcStyle); 19 | } 20 | 21 | XCFrameWindow(DWORD dwExStyle, DWORD dwStyle, const std::wstring& className, 22 | int x, int y, int cx, int cy, const std::wstring& title, uintptr_t hWndParent, int xcStyle= window_style_default) 23 | { 24 | m_handle = XFrameWnd_CreateEx(dwExStyle, dwStyle, (wchar_t*)className.c_str(), 25 | x, y, cx, cy, (wchar_t*)title.c_str(), (HWND)hWndParent, xcStyle); 26 | } 27 | 28 | virtual bool Attach(uintptr_t hwnd, int style) override { 29 | m_handle = XFrameWnd_Attach((HWND)hwnd, style); 30 | return m_handle; 31 | } 32 | 33 | // 设置主视图元素 34 | void SetView(HELE ele) { 35 | XFrameWnd_SetView(GetWindowHandle(), ele); 36 | } 37 | 38 | // 设置窗格组TabBar高度 39 | void SetTabBarHeight(int height) { 40 | XFrameWnd_SetTabBarHeight(GetWindowHandle(), height); 41 | } 42 | 43 | // 设置窗格分隔条颜色. 44 | void SetPaneSplitBarColor(COLORREF color) { 45 | XFrameWnd_SetPaneSplitBarColor(GetWindowHandle(), color); 46 | } 47 | 48 | // 获取主视图区域 49 | void GetViewRect(RECT* pRect) { 50 | XFrameWnd_GetViewRect(GetWindowHandle(), pRect); 51 | } 52 | 53 | // 设置窗格分隔条宽度 54 | void SetPaneSplitBarWidth(int width) { 55 | XFrameWnd_SetPaneSplitBarWidth(GetWindowHandle(), width); 56 | } 57 | 58 | // 获取窗格分隔条宽度 59 | int GetPaneSplitBarWidth() { 60 | return XFrameWnd_GetPaneSplitBarWidth(GetWindowHandle()); 61 | } 62 | 63 | // 保存布局信息到文件 64 | bool SaveLayoutToFile(const std::wstring& fileName) { 65 | return XFrameWnd_SaveLayoutToFile(GetWindowHandle(), fileName.c_str()); 66 | } 67 | 68 | // 添加窗格到框架窗口 69 | bool AddPane(HELE paneDest, HELE paneNew, pane_align_ align) { 70 | return XFrameWnd_AddPane(GetWindowHandle(), paneDest, paneNew, align); 71 | } 72 | 73 | // 合并窗格 74 | bool MergePane(HELE paneDest, HELE paneNew) { 75 | return XFrameWnd_MergePane(GetWindowHandle(), paneDest, paneNew); 76 | } 77 | 78 | // 加载布局信息文件 79 | bool LoadLayoutFile(in_buffer_ HELE* aPaneList, int nPaneCount, const std::wstring& fileName) { 80 | return XFrameWnd_LoadLayoutFile(GetWindowHandle(), aPaneList, nPaneCount, fileName.c_str()); 81 | } 82 | 83 | // 用来布局窗格的区域坐标,不包含码头 84 | void GetLayoutAreaRect(RECT* pRect) { 85 | XFrameWnd_GetLayoutAreaRect(GetWindowHandle(), pRect); 86 | } 87 | 88 | 89 | // 3.3.5 新增 90 | frameWnd_cell_type_ GetDragFloatWndTopFlag() { 91 | return XFrameWnd_GetDragFloatWndTopFlag(GetWindowHandle()); 92 | } 93 | 94 | 95 | }; 96 | 97 | } -------------------------------------------------------------------------------- /pyxcgui/binding/element/XButton.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCButton.hpp" 4 | #include "xcgui/XCImage.hpp" 5 | #include "binding/manager/XCastManager.hpp" 6 | 7 | namespace xcgui { 8 | 9 | void declareButton(py::module& m) { 10 | py::class_(m, "XButton") 11 | PYCASTOBJECT(XCButton) 12 | PYOBJECTVALID(XCButton, XC_BUTTON) 13 | .def(py::init([](int x, int y, int cx, int cy, const std::wstring& text, XCObjectUI* parent=nullptr) { 14 | HXCGUI handle = nullptr; 15 | if (parent) { 16 | handle = parent->GetHandle(); 17 | } 18 | XCButton button(x, y, cx, cy, text, handle); 19 | return button; 20 | }), "x"_a, "y"_a, "width"_a, "height"_a, "text"_a, "parent"_a=nullptr) 21 | 22 | .def(py::init([](int cx, int cy, const std::wstring& text, XCObjectUI* parent=nullptr) { 23 | HXCGUI handle = nullptr; 24 | if (parent) { 25 | handle = parent->GetHandle(); 26 | } 27 | XCButton button(0,0, cx, cy, text, handle); 28 | return button; 29 | }), "width"_a, "height"_a, "text"_a, "parent"_a=nullptr) 30 | 31 | .def("isCheck", &XCButton::IsCheck) 32 | .def("setCheck", &XCButton::SetCheck, "checked"_a) 33 | .def("setState", &XCButton::SetState, "state"_a) 34 | .def("getState", &XCButton::GetState) 35 | .def("getStateEx", &XCButton::GetStateEx) 36 | .def("setBtnTypeEx", &XCButton::SetBtnTypeEx, "nType"_a) 37 | .def("setGroupId", &XCButton::SetGroupID, "groupId"_a) 38 | .def("getGroupId", &XCButton::GetGroupID) 39 | .def("setBindEle", [](XCButton& self, const XCWidget& ele) { 40 | self.SetBindEle((HELE)ele.GetHandle()); 41 | }, "ele"_a) 42 | .def("getBindEle", [](XCButton& self) { 43 | auto handle = self.GetBindEle(); 44 | return XCastManager::GetInstance()->CastObject(handle); 45 | }, py::return_value_policy::take_ownership) 46 | .def("setTextAlign", &XCButton::SetTextAlign, "flags"_a) 47 | .def("getTextAlign", &XCButton::GetTextAlign) 48 | .def("setIconAlign", &XCButton::SetIconAlign, "align"_a) 49 | .def("setOffset", &XCButton::SetOffset, "x"_a, "y"_a) 50 | .def("setOffsetIcon", &XCButton::SetOffsetIcon, "x"_a, "y"_a) 51 | .def("setIconSpace", &XCButton::SetIconSpace, "size"_a) 52 | .def("setText", &XCButton::SetText, "text"_a) 53 | .def("getText", &XCButton::GetText) 54 | .def("setIcon", [](XCButton& self, const XCImage& image) { 55 | self.SetIcon(image.getImageHandle()); 56 | }, "image"_a) 57 | .def("setIconDisable", [](XCButton& self, const XCImage& image) { 58 | self.SetIconDisable(image.getImageHandle()); 59 | }, "image"_a) 60 | .def("getIcon", [](XCButton& self, int nType) { 61 | auto handle = self.GetIcon(nType); 62 | return XCImage(handle); 63 | }, "nType"_a) 64 | .def("addAnimationFrame", [](XCButton& self, const XCImage& image, UINT elapse) { 65 | self.AddAnimationFrame(image.getImageHandle(), elapse); 66 | }, "image"_a, "elapse"_a) 67 | .def("getText", &XCButton::EnableAnimation, "enable"_a, "loopPlay"_a = false); 68 | } 69 | } -------------------------------------------------------------------------------- /examples/resources/WmUi/control/布局_分页器.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /pyxcgui/binding/adapter/XAdapterTree.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/adapter/XCAdapterTree.hpp" 4 | #include "xcgui/XCImage.hpp" 5 | 6 | namespace xcgui { 7 | 8 | void declareAdapterTree(py::module& m) { 9 | 10 | py::class_(m, "XAdapterTree") 11 | PYCASTOBJECT(XCAdapterTree) 12 | PYOBJECTVALID(XCAdapterTree, XC_ADAPTER_TREE) 13 | .def(py::init<>()) 14 | .def("addColumn", &XCAdapterTree::AddColumn, "name"_a) 15 | .def("setColumn", &XCAdapterTree::SetColumn, "colName"_a) 16 | 17 | .def("insertItemText", &XCAdapterTree::InsertItemText, "value"_a, "parentId"_a =XC_ID_ROOT, "insertId"_a=XC_ID_LAST) 18 | .def("insertItemTextEx", &XCAdapterTree::InsertItemTextEx, "name"_a, 19 | "value"_a, "parentId"_a =XC_ID_ROOT, "insertId"_a=XC_ID_LAST) 20 | 21 | 22 | .def("insertItemImage", [](XCAdapterTree& self, const XCImage& image, 23 | int nParentID = XC_ID_ROOT, int insertID = XC_ID_LAST) 24 | { 25 | return self.InsertItemImage(image.getImageHandle(), nParentID, insertID); 26 | }, "image"_a, "parentId"_a = XC_ID_ROOT, "insertId"_a = XC_ID_LAST) 27 | 28 | .def("insertItemImageEx", [](XCAdapterTree& self, const std::wstring& name, const XCImage& image, 29 | int nParentID = XC_ID_ROOT, int insertID = XC_ID_LAST) 30 | { 31 | return self.InsertItemImageEx(name, image.getImageHandle(), nParentID, insertID); 32 | }, "name"_a, "image"_a, "parentId"_a = XC_ID_ROOT, "insertId"_a = XC_ID_LAST) 33 | 34 | .def("getCount", &XCAdapterTree::GetCount) 35 | .def("getCountColumn", &XCAdapterTree::GetCountColumn) 36 | 37 | .def("setItemText", &XCAdapterTree::SetItemText, "nId"_a, "column"_a, "value"_a) 38 | .def("setItemTextEx", &XCAdapterTree::SetItemTextEx, "nId"_a, "name"_a, "value"_a) 39 | 40 | .def("setItemImage", [](XCAdapterTree& self, int nID, int iColumn, const XCImage& image){ 41 | return self.SetItemImage(nID, iColumn, image.getImageHandle()); 42 | }, "nId"_a, "column"_a, "image"_a) 43 | 44 | .def("setItemImageEx", [](XCAdapterTree& self, int nID, const std::wstring& name, const XCImage& image){ 45 | return self.SetItemImageEx(nID, name, image.getImageHandle()); 46 | }, "nId"_a, "name"_a, "image"_a) 47 | 48 | .def("getItemText", &XCAdapterTree::GetItemText, "nId"_a, "column"_a) 49 | .def("getItemTextEx", &XCAdapterTree::GetItemTextEx, "nId"_a, "name"_a) 50 | 51 | .def("getItemImage", [](XCAdapterTree& self, int nId, int column) -> XCImage* { 52 | auto handle = self.GetItemImage(nId, column); 53 | if (!handle) return nullptr; 54 | return new XCImage(handle); 55 | }, "nId"_a, "column"_a, py::return_value_policy::take_ownership) 56 | 57 | .def("getItemImageEx", [](XCAdapterTree& self, int nId, const std::wstring& name) -> XCImage* { 58 | auto handle = self.GetItemImageEx(nId, name); 59 | if (!handle) return nullptr; 60 | return new XCImage(handle); 61 | }, "nId"_a, "name"_a, py::return_value_policy::take_ownership) 62 | 63 | .def("deleteItem", &XCAdapterTree::DeleteItem, "nId"_a) 64 | .def("deleteItemAll", &XCAdapterTree::DeleteItemAll) 65 | .def("deleteColumnAll", &XCAdapterTree::DeleteColumnAll) 66 | ; 67 | } 68 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/XCGlobal.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | 4 | namespace xcgui { 5 | 6 | 7 | class XCGlobal { 8 | public: 9 | 10 | // 弹出提示框 11 | static void Alert(const std::wstring& title, const std::wstring& text) { 12 | XC_Alert(title.c_str(), text.c_str()); 13 | } 14 | 15 | // 消息框 16 | static int MessageBox(const std::wstring& title, const std::wstring& text, int flags, HWND hWndParent, int XCStyle) { 17 | return XC_MessageBox(title.c_str(), text.c_str(), flags, hWndParent, XCStyle); 18 | } 19 | 20 | static bool PostMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { 21 | return ::PostMessage(hWnd, msg, wParam, lParam); 22 | } 23 | 24 | static bool SendMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { 25 | return ::SendMessage(hWnd, msg, wParam, lParam); 26 | } 27 | 28 | static void PostQuitMessage(int exitCode) { 29 | return XC_PostQuitMessage(exitCode); 30 | } 31 | 32 | static bool RegisterWindowClassName(const std::wstring& className) { 33 | return XC_RegisterWindowClassName(className.c_str()); 34 | } 35 | 36 | // 激活当前进程最上层窗口 37 | static bool SetActivateTopWindow() { 38 | return XC_SetActivateTopWindow(); 39 | } 40 | 41 | static void SetDefaultFont(HFONTX font) { 42 | XC_SetDefaultFont(font); 43 | } 44 | 45 | static HFONTX GetDefaultFont() { 46 | return XC_GetDefaultFont(); 47 | } 48 | 49 | 50 | static void CombineRect(RECT* pDest, RECT* pSrc1, RECT* pSrc2) { 51 | XC_CombineRect(pDest, pSrc1, pSrc2); 52 | } 53 | 54 | 55 | static bool RectInRect(RECT* pRect1, RECT* pRect2) { 56 | return XC_RectInRect(pRect1, pRect2); 57 | } 58 | 59 | 60 | static void* Malloc(int size) { 61 | return XC_Malloc(size); 62 | } 63 | 64 | static FARPROC GetProcAddress(HMODULE hModule, const std::string& procName) { 65 | return XC_GetProcAddress(hModule, procName.c_str()); 66 | } 67 | 68 | static HMODULE LoadDll(const std::wstring& dll) { 69 | return XC_LoadDll(dll.c_str()); 70 | } 71 | 72 | static HMODULE LoadLibrary(const std::wstring& fileName) { 73 | return XC_LoadLibrary(fileName.c_str()); 74 | } 75 | 76 | 77 | static void Free(void* p) { 78 | XC_Free(p); 79 | } 80 | 81 | static bool FreeLibrary(HMODULE hModule) { 82 | return XC_FreeLibrary(hModule); 83 | } 84 | 85 | static void GetTextShowRect(const std::wstring& text, HFONTX font, int textAlign, int maxWidth, out_ SIZE* pOutSize) { 86 | XC_GetTextShowRect(text.c_str(), text.size(), font, textAlign, maxWidth, pOutSize); 87 | } 88 | 89 | static void GetTextShowSize(const std::wstring& text, HFONTX font, out_ SIZE* pOutSize) { 90 | XC_GetTextShowSize(text.c_str(), text.size(), font, pOutSize); 91 | } 92 | 93 | static void GetTextShowSizeEx(const std::wstring& text, HFONTX font, int textAlign, out_ SIZE* pOutSize) { 94 | XC_GetTextShowSizeEx(text.c_str(), text.size(), font, textAlign, pOutSize); 95 | } 96 | 97 | static void GetTextSize(const std::wstring& text, HFONTX font, out_ SIZE* pOutSize) { 98 | XC_GetTextSize(text.c_str(), text.size(), font, pOutSize); 99 | } 100 | 101 | 102 | }; 103 | 104 | 105 | 106 | 107 | 108 | 109 | } -------------------------------------------------------------------------------- /pyxcgui/binding/element/XScrollView.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/element/XCScrollView.hpp" 4 | #include "xcgui/element/XCButton.hpp" 5 | #include "binding/manager/XCastManager.hpp" 6 | 7 | namespace xcgui { 8 | 9 | void declareScrollView(py::module& m) { 10 | py::class_(m, "XScrollView") 11 | PYCASTOBJECT(XCScrollView) 12 | PYOBJECTVALID(XCScrollView, XC_SCROLLVIEW) 13 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 14 | HXCGUI handle = nullptr; 15 | if (parent) { 16 | handle = parent->GetHandle(); 17 | } 18 | XCScrollView obj(x, y, cx, cy, handle); 19 | return obj; 20 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 21 | 22 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 23 | HXCGUI handle = nullptr; 24 | if (parent) { 25 | handle = parent->GetHandle(); 26 | } 27 | XCScrollView obj(0,0, cx, cy, handle); 28 | return obj; 29 | }), "width"_a, "height"_a, "parent"_a=nullptr) 30 | 31 | .def("setTotalSize", &XCScrollView::SetTotalSize, "width"_a, "height"_a) 32 | .def("getTotalSize", [](XCScrollView& self) { 33 | XCSize size; 34 | self.GetTotalSize((SIZE*)&size); 35 | return size; 36 | }) 37 | 38 | .def("setLineSize", &XCScrollView::SetLineSize, "width"_a, "height"_a) 39 | .def("getLineSize", [](XCScrollView& self) { 40 | XCSize size; 41 | self.GetLineSize((SIZE*)&size); 42 | return size; 43 | }) 44 | 45 | .def("setScrollBarSize", &XCScrollView::SetScrollBarSize, "size"_a) 46 | .def("getViewPosH", &XCScrollView::GetViewPosH) 47 | .def("getViewPosV", &XCScrollView::GetViewPosV) 48 | .def("getViewWidth", &XCScrollView::GetViewWidth) 49 | .def("getViewHeight", &XCScrollView::GetViewHeight) 50 | 51 | .def("getViewRect", [](XCScrollView& self) { 52 | XCRect info; 53 | self.GetViewRect((RECT*)&info); 54 | return info; 55 | }) 56 | 57 | .def("getScrollBarH", [](XCScrollView& self) -> XCObject* { 58 | auto handle = self.GetScrollBarH(); 59 | return XCastManager::GetInstance()->CastObject(handle); 60 | }) 61 | .def("getScrollBarV", [](XCScrollView& self) -> XCObject* { 62 | auto handle = self.GetScrollBarV(); 63 | return XCastManager::GetInstance()->CastObject(handle); 64 | }) 65 | 66 | .def("scrollPosH", &XCScrollView::ScrollPosH, "pos"_a) 67 | .def("scrollPosV", &XCScrollView::ScrollPosV, "pos"_a) 68 | .def("scrollPosXH", &XCScrollView::ScrollPosXH, "pos"_a) 69 | .def("scrollPosYV", &XCScrollView::ScrollPosYV, "pos"_a) 70 | 71 | 72 | .def("showSBarH", &XCScrollView::ShowSBarH, "enable"_a) 73 | .def("showSBarV", &XCScrollView::ShowSBarV, "enable"_a) 74 | .def("enableAutoShowScrollBar", &XCScrollView::EnableAutoShowScrollBar, "enable"_a) 75 | .def("scrollLeftLine", &XCScrollView::ScrollLeftLine) 76 | .def("scrollRightLine", &XCScrollView::ScrollRightLine) 77 | .def("scrollTopLine", &XCScrollView::ScrollTopLine) 78 | .def("scrollBottomLine", &XCScrollView::ScrollBottomLine) 79 | .def("scrollLeft", &XCScrollView::ScrollLeft) 80 | .def("scrollRight", &XCScrollView::ScrollRight) 81 | .def("scrollTop", &XCScrollView::ScrollTop) 82 | .def("scrollBottom", &XCScrollView::ScrollBottom) 83 | 84 | ; 85 | } 86 | } -------------------------------------------------------------------------------- /pyxcgui/binding/shape/XShapeTable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/shape/XCShapeTable.hpp" 4 | #include "xcgui/XCStruct.hpp" 5 | #include "xcgui/XCFont.hpp" 6 | 7 | namespace xcgui { 8 | 9 | void declareShapeTable(py::module& m) { 10 | py::class_(m, "XShapeTable") 11 | PYCASTOBJECT(XCShapeTable) 12 | PYOBJECTVALID(XCShapeTable, XC_SHAPE_TABLE) 13 | .def(py::init([](int x, int y, int cx, int cy, XCObjectUI* parent = nullptr) { 14 | HXCGUI handle = nullptr; 15 | if (parent) { 16 | handle = parent->GetHandle(); 17 | } 18 | XCShapeTable obj(x, y, cx, cy, handle); 19 | return obj; 20 | }), "x"_a, "y"_a, "width"_a, "height"_a, "parent"_a = nullptr) 21 | 22 | . def(py::init([](int cx, int cy, XCObjectUI* parent=nullptr) { 23 | HXCGUI handle = nullptr; 24 | if (parent) { 25 | handle = parent->GetHandle(); 26 | } 27 | XCShapeTable obj(0,0, cx, cy, handle); 28 | return obj; 29 | }), "width"_a, "height"_a, "parent"_a=nullptr) 30 | 31 | 32 | .def("reset", &XCShapeTable::Reset, "row"_a, "column"_a) 33 | .def("comboRow", &XCShapeTable::ComboRow, "row"_a, "column"_a, "count"_a) 34 | .def("comboColumn", &XCShapeTable::ComboCol, "row"_a, "column"_a, "count"_a) 35 | .def("setColumnWidth", &XCShapeTable::SetColWidth, "column"_a, "width"_a) 36 | .def("setRowHeight", &XCShapeTable::SetRowHeight, "row"_a, "height"_a) 37 | .def("setBorderColor", &XCShapeTable::SetBorderColor, "color"_a) 38 | .def("setTextColor", &XCShapeTable::SetTextColor, "color"_a) 39 | .def("setFont", [](XCShapeTable& self, const XCFont& font) { 40 | self.SetFont(font.getFontHandle()); 41 | }, "font"_a) 42 | 43 | .def("setItemPadding", &XCShapeTable::SetItemPadding, "left"_a, "top"_a, "right"_a, "bottom"_a) 44 | .def("setItemText", &XCShapeTable::SetItemText, "row"_a, "column"_a, "text"_a) 45 | .def("setItemFont", [](XCShapeTable& self, int iRow, int iCol, const XCFont& font) { 46 | self.SetItemFont(iRow, iCol, font.getFontHandle()); 47 | }, "row"_a, "column"_a, "font"_a) 48 | .def("setItemTextAlign", &XCShapeTable::SetItemTextAlign, "row"_a, "column"_a, "align"_a) 49 | .def("setItemTextColor", &XCShapeTable::SetItemTextColor, "row"_a, "column"_a, "color"_a, "enable"_a) 50 | .def("setItemBkColor", &XCShapeTable::SetItemBkColor, "row"_a, "column"_a, "color"_a, "enable"_a) 51 | .def("setItemLine", &XCShapeTable::SetItemLine, "row1"_a, "column1"_a, "row2"_a, "column2"_a, "flag"_a, "color"_a) 52 | .def("setItemFlag", &XCShapeTable::SetItemFlag, "row"_a, "column"_a, "flag"_a) 53 | .def("getItemRect", [](XCShapeTable& self, int iRow, int iCol) { 54 | XCRect info; 55 | self.GetItemRect(iRow, iCol,(RECT*)&info); 56 | return info; 57 | }, "row"_a, "column"_a) 58 | 59 | // 3.3.9.1 新增 60 | .def("setItemTextEx", [](XCShapeTable& self, int iRow, int iCol, const std::wstring& text, 61 | int textColor, int bkColor, bool bTextColor = true, bool bBkColor = true, const XCFont* font = nullptr) { 62 | HFONTX hFont = font ? font->getFontHandle() : nullptr; 63 | XTable_SetItemTextEx(self.GetHandle(), iRow, iCol, text.c_str(), textColor, bkColor, bTextColor, bBkColor, hFont); 64 | }, "row"_a, "column"_a, "text"_a, "textColor"_a, "bkColor"_a, "textColorEnable"_a = true, "bkColorEnable"_a = true, "font"_a = nullptr) 65 | ; 66 | } 67 | } -------------------------------------------------------------------------------- /pyxcgui/xcgui/element/XCScrollBar.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "pch.h" 3 | #include "xcgui/XCElement.hpp" 4 | 5 | namespace xcgui { 6 | 7 | class XCScrollBar : public XCElement 8 | { 9 | public: 10 | XCScrollBar(HXCGUI handle) 11 | { 12 | m_handle = handle; 13 | } 14 | 15 | XCScrollBar() = default; 16 | 17 | XCScrollBar(int x, int y, int width, int height, HXCGUI parent = NULL) { 18 | m_handle = XSBar_Create(x, y, width, height, parent); 19 | } 20 | 21 | //@备注 设置滚动范围. 22 | //@参数 range 范围. 23 | //@别名 置范围() 24 | void SetRange(int range) { 25 | XSBar_SetRange(getEleHandle(), range); 26 | } 27 | 28 | //@备注 获取滚动范围. 29 | //@返回 滚动范围. 30 | //@别名 取范围() 31 | int GetRange() { 32 | return XSBar_GetRange(getEleHandle()); 33 | } 34 | 35 | //@备注 显示隐藏滚动条上下按钮. 36 | //@参数 bShow 是否显示. 37 | //@别名 显示上下按钮() 38 | void ShowButton(bool bShow) { 39 | XSBar_ShowButton(getEleHandle(), bShow); 40 | } 41 | 42 | //@备注 设置滑块长度. 43 | //@参数 length 长度. 44 | //@别名 置滑块长度() 45 | void SetSliderLength(int length) { 46 | XSBar_SetSliderLength(getEleHandle(), length); 47 | } 48 | 49 | //@备注 设置滑块最小长度. 50 | //@参数 minLength 长度. 51 | //@别名 置滑块最小长度() 52 | void SetSliderMinLength(int minLength) { 53 | XSBar_SetSliderMinLength(getEleHandle(), minLength); 54 | } 55 | 56 | //@备注 设置滑块两边的间隔大小. 57 | //@参数 nPadding 间隔大小. 58 | //@别名 置滑块两边间隔() 59 | void SetSliderPadding(int nPadding) { 60 | XSBar_SetSliderPadding(getEleHandle(), nPadding); 61 | } 62 | 63 | //@备注 设置水平或者垂直. 64 | //@参数 bEnable 水平或垂直. 65 | //@返回 如果改变返回TRUE否则返回FALSE. 66 | //@别名 启用水平() 67 | bool EnableHorizon(bool bHorizon) { 68 | return XSBar_EnableHorizon(getEleHandle(), bHorizon); 69 | } 70 | 71 | //@备注 获取滑块最大长度. 72 | //@返回 长度. 73 | //@别名 取滑块最大长度() 74 | int GetSliderMaxLength() { 75 | return XSBar_GetSliderMaxLength(getEleHandle()); 76 | } 77 | 78 | //@备注 向上滚动. 79 | //@返回 成功返回TRUE否则返回FALSE. 80 | //@别名 向上滚动() 81 | bool ScrollUp() { 82 | return XSBar_ScrollUp(getEleHandle()); 83 | } 84 | 85 | //@备注 向下滚动. 86 | //@返回 成功返回TRUE否则返回FALSE. 87 | //@别名 向下滚动() 88 | bool ScrollDown() { 89 | return XSBar_ScrollDown(getEleHandle()); 90 | } 91 | 92 | //@备注 滚动到顶部. 93 | //@返回 成功返回TRUE否则返回FALSE. 94 | //@别名 滚动到顶部() 95 | bool ScrollTop() { 96 | return XSBar_ScrollTop(getEleHandle()); 97 | } 98 | 99 | //@备注 滚动到底部. 100 | //@返回 成功返回TRUE否则返回FALSE. 101 | //@别名 滚动到底部() 102 | bool ScrollBottom() { 103 | return XSBar_ScrollBottom(getEleHandle()); 104 | } 105 | 106 | //@备注 滚动到指定位置点 ,触发事件 107 | //@参数 pos 位置点. 108 | //@返回 成功返回TRUE否则返回FALSE. 109 | //@别名 滚动到指定位置() 110 | bool ScrollPos(int pos) { 111 | return XSBar_ScrollPos(getEleHandle(), pos); 112 | } 113 | 114 | //@备注 获取上按钮. 115 | //@返回 返回按钮句柄. 116 | //@别名 取上按钮() 117 | HELE GetButtonUp() { 118 | return XSBar_GetButtonUp(getEleHandle()); 119 | } 120 | 121 | //@备注 获取下按钮. 122 | //@返回 返回按钮句柄. 123 | //@别名 取下按钮() 124 | HELE GetButtonDown() { 125 | return XSBar_GetButtonDown(getEleHandle()); 126 | } 127 | 128 | //@备注 获取滑动按钮. 129 | //@返回 返回按钮句柄. 130 | //@别名 取滑块() 131 | HELE GetButtonSlider() { 132 | return XSBar_GetButtonSlider(getEleHandle()); 133 | } 134 | 135 | }; 136 | } --------------------------------------------------------------------------------