1340 lines
44 KiB
C++
1340 lines
44 KiB
C++
#pragma once
|
|
|
|
#include "ImXui/ImXui.h"
|
|
|
|
#include <cstring>
|
|
#include <cwchar>
|
|
#include <string>
|
|
|
|
|
|
#if defined(_WIN32) && !defined(_XBOX)
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
|
|
#ifndef _HRESULT_DEFINED
|
|
typedef long HRESULT;
|
|
#define _HRESULT_DEFINED
|
|
#endif
|
|
|
|
|
|
#ifndef S_OK
|
|
#define S_OK ((HRESULT)0x00000000L)
|
|
#endif
|
|
#ifndef S_FALSE
|
|
#define S_FALSE ((HRESULT)0x00000001L)
|
|
#endif
|
|
#ifndef E_FAIL
|
|
#define E_FAIL ((HRESULT)0x80004005L)
|
|
#endif
|
|
#ifndef E_NOTIMPL
|
|
#define E_NOTIMPL ((HRESULT)0x80004001L)
|
|
#endif
|
|
#ifndef E_INVALIDARG
|
|
#define E_INVALIDARG ((HRESULT)0x80070057L)
|
|
#endif
|
|
#ifndef E_OUTOFMEMORY
|
|
#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
|
|
#endif
|
|
#ifndef E_POINTER
|
|
#define E_POINTER ((HRESULT)0x80004003L)
|
|
#endif
|
|
#ifndef FAILED
|
|
#define FAILED(hr) (((HRESULT)(hr)) < 0)
|
|
#endif
|
|
#ifndef SUCCEEDED
|
|
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
|
|
#endif
|
|
|
|
#ifndef TRUE
|
|
#define TRUE 1
|
|
#define FALSE 0
|
|
#endif
|
|
|
|
#ifndef _WINDEF_
|
|
typedef int BOOL;
|
|
#ifndef _BASETSD_H_
|
|
typedef int INT;
|
|
#endif
|
|
typedef unsigned char BYTE;
|
|
typedef unsigned short WORD;
|
|
typedef unsigned long DWORD;
|
|
typedef long LONG;
|
|
typedef unsigned int UINT;
|
|
typedef void VOID;
|
|
typedef wchar_t WCHAR;
|
|
typedef const WCHAR* LPCWSTR;
|
|
typedef WCHAR* LPWSTR;
|
|
typedef void* LPVOID;
|
|
typedef const void* LPCVOID;
|
|
#endif
|
|
#include <cstddef>
|
|
|
|
#ifndef _WIN32
|
|
#ifndef _RECT_DEFINED
|
|
typedef struct tagRECT { LONG left; LONG top; LONG right; LONG bottom; } RECT;
|
|
#define _RECT_DEFINED
|
|
#endif
|
|
#endif
|
|
#ifndef ZeroMemory
|
|
#define ZeroMemory(dst, len) memset((dst), 0, (len))
|
|
#endif
|
|
|
|
|
|
#ifndef D3DXVECTOR3_DEFINED
|
|
struct D3DXVECTOR3 { float x, y, z;
|
|
D3DXVECTOR3() : x(0), y(0), z(0) {}
|
|
D3DXVECTOR3(float ix, float iy, float iz) : x(ix), y(iy), z(iz) {}
|
|
};
|
|
#define D3DXVECTOR3_DEFINED
|
|
#endif
|
|
#ifndef D3DXMATRIX_DEFINED
|
|
struct D3DXMATRIX {
|
|
union {
|
|
struct { float _11,_12,_13,_14,_21,_22,_23,_24,_31,_32,_33,_34,_41,_42,_43,_44; };
|
|
float m[4][4];
|
|
};
|
|
D3DXMATRIX() { ZeroMemory(this, sizeof(*this)); _11 = _22 = _33 = _44 = 1.0f; }
|
|
};
|
|
#define D3DXMATRIX_DEFINED
|
|
#endif
|
|
|
|
#ifndef D3DXVECTOR2_DEFINED
|
|
struct D3DXVECTOR2 { float x, y;
|
|
D3DXVECTOR2() : x(0), y(0) {}
|
|
D3DXVECTOR2(float ix, float iy) : x(ix), y(iy) {} };
|
|
#define D3DXVECTOR2_DEFINED
|
|
#endif
|
|
|
|
|
|
class CXuiElementImplBase;
|
|
class CXuiObject;
|
|
typedef CXuiElementImplBase* HXUIOBJ;
|
|
typedef CXuiObject* HXUIOBJBASE;
|
|
typedef void* HXUICLASS;
|
|
typedef void* HXUIBRUSH;
|
|
typedef void* HFONTOBJ;
|
|
typedef void* HXUIDC;
|
|
typedef void* HXUIRESOURCE;
|
|
typedef void* HXUITIMELINE;
|
|
typedef void* HXUISCENE;
|
|
class IXuiTexture;
|
|
|
|
|
|
#define XM_RENDER 0
|
|
#define XM_PRERENDER 1
|
|
#define XM_HITTEST 3
|
|
#define XM_CHILD_ADDED 4
|
|
#define XM_PARENT_CHANGED 5
|
|
#define XM_GET_BOUNDS 6
|
|
#define XM_PARENT_SIZE_CHANGING 8
|
|
#define XM_SKIN_CHANGED 9
|
|
#define XM_DESTROY 10
|
|
#define XM_WANT_FOCUS 11
|
|
#define XM_SET_FOCUS 12
|
|
#define XM_KILL_FOCUS 13
|
|
#define XM_NOTIFY 14
|
|
#define XM_TIMELINE_END 15
|
|
#define XM_SIZE 16
|
|
#define XM_GET_SHOWSTATE 17
|
|
#define XM_SET_SHOWSTATE 18
|
|
#define XM_INIT 19
|
|
#define XM_TIMELINE_START 20
|
|
#define XM_NAV_RETURN 26
|
|
#define XM_GET_BACKSCENE 27
|
|
#define XM_SET_BACKSCENE 28
|
|
#define XM_TRANSITION_START 29
|
|
#define XM_TRANSITION_END 30
|
|
#define XM_LOCALE_CHANGED 31
|
|
#define XM_KEYDOWN 36
|
|
#define XM_KEYUP 37
|
|
#define XM_CHAR 38
|
|
#define XM_TIMER 39
|
|
#define XM_DISCARD_RESOURCES 40
|
|
#define XM_INIT_RESOURCES 41
|
|
#define XM_NAV_FORWARD 43
|
|
#define XM_GET_CHECKSTATE 2000
|
|
#define XM_SET_CHECKSTATE 2001
|
|
#define XM_GET_ENABLESTATE 2002
|
|
#define XM_SET_ENABLESTATE 2003
|
|
#define XM_GET_CHECKED 2004
|
|
#define XM_SET_CHECKED 2005
|
|
#define XM_PLAY_VISUAL 2006
|
|
#define XM_GET_CURSEL 2007
|
|
#define XM_SET_CURSEL 2008
|
|
#define XM_GET_ITEMCONTROL 2009
|
|
#define XM_GET_TOPITEM 2010
|
|
#define XM_SET_TOPITEM 2011
|
|
#define XM_GET_ITEMCOUNT 2012
|
|
#define XM_INSERT_ITEMS 2013
|
|
#define XM_DELETE_ITEMS 2014
|
|
#define XM_GET_SOURCE_TEXT 2015
|
|
#define XM_SET_SOURCE_TEXT 2016
|
|
#define XM_GET_SOURCE_IMAGE 2017
|
|
#define XM_SET_SOURCE_IMAGE 2018
|
|
#define XM_GET_ITEMCHECK 2019
|
|
#define XM_SET_ITEMCHECK 2020
|
|
#define XM_PRESS 2021
|
|
#define XM_CONTROL_NAVIGATE 2022
|
|
#define XM_SET_SCROLLEND_STATE 2023
|
|
#define XM_GET_ITEMENABLE 2024
|
|
#define XM_SET_ITEMENABLE 2025
|
|
#define XM_MSG_RETURN 2028
|
|
#define XM_DESIGN_FIRST 3000
|
|
#define XM_INIT_DATA (XM_DESIGN_FIRST + 1)
|
|
#define XM_USER 0x8000000
|
|
|
|
|
|
#define XN_PRESS 1
|
|
#define XN_SET_FOCUS 2
|
|
#define XN_KILL_FOCUS 3
|
|
#define XN_SELCHANGED 4
|
|
#define XN_SCROLLING_END 5
|
|
#define XN_ITEM_CHECKCHANGED 6
|
|
#define XN_PRESSING 7
|
|
#define XN_VIDEO_END 8
|
|
#define XN_VALUE_CHANGING 10
|
|
#define XN_VALUE_CHANGED 11
|
|
#define XN_EDIT_SELCHANGED 12
|
|
#define XN_EDIT_TEXTCHANGED 13
|
|
#define XN_COMBOBOX_LIST_OPENING 17
|
|
|
|
|
|
typedef enum XUI_ITEMCOUNT {
|
|
XUI_ITEMCOUNT_ALL,
|
|
XUI_ITEMCOUNT_VISIBLE,
|
|
XUI_ITEMCOUNT_CHECKED,
|
|
XUI_ITEMCOUNT_MAX_VISIBLE,
|
|
XUI_ITEMCOUNT_MAX_LINES,
|
|
XUI_ITEMCOUNT_MAX_PER_LINE
|
|
} XUI_ITEMCOUNT;
|
|
|
|
|
|
#define XUI_CLASS_ELEMENT L"XuiElement"
|
|
#define XUI_CLASS_CANVAS L"XuiCanvas"
|
|
#define XUI_CLASS_FIGURE L"XuiFigure"
|
|
#define XUI_CLASS_CONTROL L"XuiControl"
|
|
#define XUI_CLASS_SCENE L"XuiScene"
|
|
#define XUI_CLASS_BUTTON L"XuiButton"
|
|
#define XUI_CLASS_NAVBUTTON L"XuiNavButton"
|
|
#define XUI_CLASS_CHECKBOX L"XuiCheckbox"
|
|
#define XUI_CLASS_RADIOBUTTON L"XuiRadioButton"
|
|
#define XUI_CLASS_TEXT L"XuiText"
|
|
#define XUI_CLASS_GROUP L"XuiGroup"
|
|
#define XUI_CLASS_SOUND L"XuiSound"
|
|
#define XUI_CLASS_SOUND_XACT L"XuiSoundXACT"
|
|
#define XUI_CLASS_SOUND_XAUDIO L"XuiSoundXAudio"
|
|
#define XUI_CLASS_TRANSITION L"XuiTransition"
|
|
#define XUI_CLASS_LIST L"XuiList"
|
|
#define XUI_CLASS_COMMONLIST L"XuiCommonList"
|
|
#define XUI_CLASS_LISTITEM L"XuiListItem"
|
|
#define XUI_CLASS_SCROLLBAR L"XuiScrollBar"
|
|
#define XUI_CLASS_PROGRESSBAR L"XuiProgressBar"
|
|
#define XUI_CLASS_SLIDER L"XuiSlider"
|
|
#define XUI_CLASS_EDIT L"XuiEdit"
|
|
#define XUI_CLASS_IMAGE L"XuiImage"
|
|
#define XUI_CLASS_MESSAGEBOX L"XuiMessageBox"
|
|
#define XUI_CLASS_LABEL L"XuiLabel"
|
|
#define XUI_CLASS_TABSCENE L"XuiTabScene"
|
|
#define XUI_CLASS_NINE_GRID L"XuiNineGrid"
|
|
#define XUI_CLASS_COMBOBOX L"XuiComboBox"
|
|
#define XUI_CLASS_COMBOBOXLIST L"XuiComboBoxList"
|
|
#define XUI_CLASS_MULTILINEEDIT L"XuiMultilineEdit"
|
|
|
|
|
|
typedef enum _XUI_CONTROL_NAVIGATE {
|
|
XUI_CONTROL_NAVIGATE_UP = 0,
|
|
XUI_CONTROL_NAVIGATE_DOWN,
|
|
XUI_CONTROL_NAVIGATE_LEFT,
|
|
XUI_CONTROL_NAVIGATE_RIGHT,
|
|
XUI_CONTROL_NAVIGATE_TABFORWARD,
|
|
XUI_CONTROL_NAVIGATE_TABBACKWARD,
|
|
} XUI_CONTROL_NAVIGATE;
|
|
|
|
|
|
#define XUI_KEYDOWN 0x00000001
|
|
#define XUI_KEYUP 0x00000002
|
|
#define XUI_KEYSTATE_REPEAT 0x00000004
|
|
|
|
|
|
#define XUI_DISCARD_TEXTURES 0x00000001
|
|
#define XUI_DISCARD_FONTS 0x00000002
|
|
#define XUI_DISCARD_ALL 0xFFFFFFFF
|
|
|
|
|
|
#define XUI_SMOOTHSCROLL_VERTICAL 0x00000001
|
|
#define XUI_SMOOTHSCROLL_HORIZONTAL 0x00000002
|
|
|
|
|
|
#define XUI_FONT_STYLE_NORMAL 0x00000000
|
|
#define XUI_FONT_STYLE_BOLD 0x00000001
|
|
#define XUI_FONT_STYLE_ITALIC 0x00000002
|
|
#define XUI_FONT_STYLE_VERTICAL_CENTER 0x00000004
|
|
#define XUI_FONT_STYLE_SINGLE_LINE 0x00000008
|
|
#define XUI_FONT_STYLE_DROP_SHADOW 0x00000010
|
|
|
|
|
|
#define VK_PAD_A 0x5800
|
|
#define VK_PAD_B 0x5801
|
|
#define VK_PAD_X 0x5802
|
|
#define VK_PAD_Y 0x5803
|
|
#define VK_PAD_RSHOULDER 0x5804
|
|
#define VK_PAD_LSHOULDER 0x5805
|
|
#define VK_PAD_LTRIGGER 0x5806
|
|
#define VK_PAD_RTRIGGER 0x5807
|
|
#define VK_PAD_DPAD_UP 0x5810
|
|
#define VK_PAD_DPAD_DOWN 0x5811
|
|
#define VK_PAD_DPAD_LEFT 0x5812
|
|
#define VK_PAD_DPAD_RIGHT 0x5813
|
|
#define VK_PAD_START 0x5814
|
|
#define VK_PAD_BACK 0x5815
|
|
#define VK_PAD_LSTICK_UP 0x5820
|
|
#define VK_PAD_LSTICK_DOWN 0x5821
|
|
#define VK_PAD_LSTICK_LEFT 0x5822
|
|
#define VK_PAD_LSTICK_RIGHT 0x5823
|
|
#define VK_PAD_RSTICK_UP 0x5824
|
|
#define VK_PAD_RSTICK_DOWN 0x5825
|
|
#define VK_PAD_RSTICK_LEFT 0x5826
|
|
#define VK_PAD_RSTICK_RIGHT 0x5827
|
|
|
|
|
|
typedef void XUIMessageData;
|
|
|
|
typedef struct XUIMessage
|
|
{
|
|
DWORD cbSize;
|
|
DWORD dwMessage;
|
|
BOOL bHandled;
|
|
size_t cbData;
|
|
void *pvData;
|
|
} XUIMessage;
|
|
|
|
struct XUIMessageInit { void* pvInitData; };
|
|
struct XUIMessageDestroy { void* pvData; };
|
|
struct XUIMessageRender { HXUIDC hDC; DWORD dwColorFactor; DWORD nBlendMode; DWORD dwColorWriteFlags; DWORD dwRenderFlags; };
|
|
struct XUIMessageTimer { DWORD nId; };
|
|
struct XUIMessageInput { DWORD dwKeyCode; WCHAR wch; DWORD dwFlags; BYTE UserIndex; };
|
|
struct XUIMessageChar { WCHAR wch; DWORD dwFlags; BYTE UserIndex; };
|
|
struct XUIMessageFocus { HXUIOBJ hOther; BYTE UserIndex; };
|
|
typedef XUIMessageFocus XUIMessageSetFocus;
|
|
typedef XUIMessageFocus XUIMessageKillFocus;
|
|
struct XUIMessageWantFocus { BOOL bWantFocus; };
|
|
struct XUIMessageGetBounds { float fWidth; float fHeight; };
|
|
struct XUITextFormatInfo;
|
|
|
|
|
|
struct XUIMessageSourceText
|
|
{
|
|
int iItem;
|
|
int iData;
|
|
BOOL bItemData;
|
|
LPCWSTR szText;
|
|
float fPointSizeOverride;
|
|
BOOL bDisplay;
|
|
float fVScroll;
|
|
DWORD dwStyleFlags;
|
|
int nTextFormatInfo;
|
|
XUITextFormatInfo* pTextFormatInfo;
|
|
};
|
|
typedef XUIMessageSourceText XUIMessageGetSourceText;
|
|
struct XUIMessageSourceImage
|
|
{
|
|
int iItem;
|
|
int iData;
|
|
BOOL bItemData;
|
|
BOOL bDirty;
|
|
LPCWSTR szPath;
|
|
HXUIBRUSH hBrush;
|
|
HXUIOBJ hObj;
|
|
};
|
|
typedef XUIMessageSourceImage XUIMessageGetSourceImage;
|
|
struct XUIMessageItemCount
|
|
{
|
|
XUI_ITEMCOUNT nType;
|
|
int cItems;
|
|
};
|
|
typedef XUIMessageItemCount XUIMessageGetItemCount;
|
|
struct XUIMessageItemEnable
|
|
{
|
|
int iItem;
|
|
BOOL bEnabled;
|
|
};
|
|
typedef XUIMessageItemEnable XUIMessageGetItemEnable;
|
|
struct XUIMessageTransition
|
|
{
|
|
DWORD dwTransType;
|
|
BOOL bStartedSelfTransition;
|
|
DWORD dwTransAction;
|
|
};
|
|
struct XUIMessageNavReturn { HXUIOBJ hScene; };
|
|
struct XUIMessageNavForward { HXUIOBJ hScene; };
|
|
struct XUIMessageControlNavigate { XUI_CONTROL_NAVIGATE nControlNavigate; HXUIOBJ hObjSource; HXUIOBJ hObjDest; BOOL bSkipNavigate; };
|
|
|
|
|
|
struct XUINotify
|
|
{
|
|
DWORD dwNotify;
|
|
HXUIOBJ hObjSource;
|
|
size_t cbData;
|
|
void *pvData;
|
|
};
|
|
struct XUINotifyFocus { HXUIOBJ hObjOther; };
|
|
struct XUINotifySelChanged { int iItem; int iOldItem; };
|
|
struct XUINotifyPress { BYTE UserIndex; };
|
|
struct XUINotifyPressing { BOOL bInPress; };
|
|
struct XUINotifyValueChanged { int nValue; };
|
|
struct XUINotifyValueChanging { int nValue; };
|
|
struct XUINotifyItemCheckChanged { HXUIOBJ hObjItem; BOOL fChecked; };
|
|
typedef void XUINotifyData;
|
|
|
|
|
|
inline void XuiMessage(XUIMessage *pMsg, DWORD dwMessage) {
|
|
memset(pMsg, 0x00, sizeof(*pMsg));
|
|
pMsg->cbSize = sizeof(*pMsg);
|
|
pMsg->dwMessage = dwMessage;
|
|
}
|
|
|
|
inline void _XuiMessageExtra(XUIMessage* pMsg, XUIMessageData* pvData, size_t cbData) {
|
|
pMsg->pvData = pvData;
|
|
pMsg->cbData = cbData;
|
|
}
|
|
|
|
inline void XuiMessageInit(XUIMessage* pMsg, XUIMessageInit* pData, void* pvInitData) {
|
|
XuiMessage(pMsg, XM_INIT);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->pvInitData = pvInitData;
|
|
}
|
|
|
|
inline void XuiMessageDestroy(XUIMessage* pMsg, XUIMessageDestroy* pData) {
|
|
XuiMessage(pMsg, XM_DESTROY);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->pvData = NULL;
|
|
}
|
|
|
|
inline void XuiMessageTimer(XUIMessage* pMsg, XUIMessageTimer* pData, DWORD nId) {
|
|
XuiMessage(pMsg, XM_TIMER);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->nId = nId;
|
|
}
|
|
|
|
inline void XuiMessageInput(XUIMessage* pMsg, XUIMessageInput* pData, int iType,
|
|
DWORD dwKeyCode, WCHAR wch, DWORD dwFlags, BYTE UserIndex) {
|
|
XuiMessage(pMsg, ((iType == XUI_KEYDOWN) ? XM_KEYDOWN : XM_KEYUP));
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->dwKeyCode = dwKeyCode;
|
|
pData->wch = wch;
|
|
pData->dwFlags = dwFlags;
|
|
pData->UserIndex = UserIndex;
|
|
}
|
|
|
|
inline void XuiMessageChar(XUIMessage* pMsg, XUIMessageChar* pData, WCHAR wch,
|
|
DWORD dwFlags, BYTE UserIndex) {
|
|
XuiMessage(pMsg, XM_CHAR);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->wch = wch;
|
|
pData->dwFlags = dwFlags;
|
|
pData->UserIndex = UserIndex;
|
|
}
|
|
|
|
inline void XuiMessageGetSourceText(XUIMessage* pMsg, XUIMessageGetSourceText* pData,
|
|
INT iItem, INT iData, BOOL bItemData) {
|
|
XuiMessage(pMsg, XM_GET_SOURCE_TEXT);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->iItem = iItem;
|
|
pData->iData = iData;
|
|
pData->bItemData = bItemData;
|
|
pData->szText = NULL;
|
|
pData->fPointSizeOverride = 0.0f;
|
|
pData->bDisplay = TRUE;
|
|
pData->fVScroll = 0.0f;
|
|
pData->dwStyleFlags = 0;
|
|
pData->nTextFormatInfo = 0;
|
|
pData->pTextFormatInfo = NULL;
|
|
}
|
|
|
|
inline void XuiMessageGetSourceImage(XUIMessage* pMsg, XUIMessageGetSourceImage* pData,
|
|
INT iItem, INT iData, BOOL bItemData) {
|
|
XuiMessage(pMsg, XM_GET_SOURCE_IMAGE);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->iItem = iItem;
|
|
pData->iData = iData;
|
|
pData->bItemData = bItemData;
|
|
pData->bDirty = FALSE;
|
|
pData->szPath = NULL;
|
|
pData->hBrush = NULL;
|
|
pData->hObj = NULL;
|
|
}
|
|
|
|
inline void XuiMessageGetItemCount(XUIMessage* pMsg, XUIMessageGetItemCount* pData, XUI_ITEMCOUNT nType) {
|
|
XuiMessage(pMsg, XM_GET_ITEMCOUNT);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->nType = nType;
|
|
pData->cItems = 0;
|
|
}
|
|
|
|
inline void XuiMessageGetItemEnable(XUIMessage* pMsg, XUIMessageGetItemEnable* pData, INT iItem) {
|
|
XuiMessage(pMsg, XM_GET_ITEMENABLE);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pData, sizeof(*pData));
|
|
pData->iItem = iItem;
|
|
pData->bEnabled = TRUE;
|
|
}
|
|
|
|
inline void XuiNotify(XUIMessage *pMsg, XUINotify *pNotify, DWORD dwNotify, HXUIOBJ hObjSource) {
|
|
XuiMessage(pMsg, XM_NOTIFY);
|
|
_XuiMessageExtra(pMsg, (XUIMessageData*)pNotify, sizeof(*pNotify));
|
|
pNotify->dwNotify = dwNotify;
|
|
pNotify->hObjSource = hObjSource;
|
|
}
|
|
|
|
inline void _XuiNotifyExtra(XUINotify* pNotify, XUINotifyData* pnmData, size_t cbData) {
|
|
pNotify->pvData = pnmData;
|
|
memset(pnmData, 0x00, cbData);
|
|
pNotify->cbData = cbData;
|
|
}
|
|
|
|
inline void XuiNotifySelChanged(XUIMessage *pMsg, XUINotify* pNotify, XUINotifySelChanged* pnmData,
|
|
HXUIOBJ hObjSource, int iItem, int iOldItem) {
|
|
XuiNotify(pMsg, pNotify, XN_SELCHANGED, hObjSource);
|
|
_XuiNotifyExtra(pNotify, (XUINotifyData*)pnmData, sizeof(*pnmData));
|
|
pnmData->iItem = iItem;
|
|
pnmData->iOldItem = iOldItem;
|
|
}
|
|
|
|
inline void XuiNotifyPress(XUIMessage *pMsg, XUINotify* pNotify, XUINotifyPress* pnmData,
|
|
HXUIOBJ hObjSource, BYTE UserIndex) {
|
|
XuiNotify(pMsg, pNotify, XN_PRESS, hObjSource);
|
|
_XuiNotifyExtra(pNotify, (XUINotifyData*)pnmData, sizeof(*pnmData));
|
|
pnmData->UserIndex = UserIndex;
|
|
}
|
|
|
|
inline void XuiNotifyValueChanged(XUIMessage *pMsg, XUINotify* pNotify, XUINotifyValueChanged* pnmData,
|
|
HXUIOBJ hObjSource, int nValue) {
|
|
XuiNotify(pMsg, pNotify, XN_VALUE_CHANGED, hObjSource);
|
|
_XuiNotifyExtra(pNotify, (XUINotifyData*)pnmData, sizeof(*pnmData));
|
|
pnmData->nValue = nValue;
|
|
}
|
|
|
|
|
|
#define XUI_BEGIN_MSG_MAP() \
|
|
HRESULT DispatchMessageMap(XUIMessage *pMessage) \
|
|
{
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define XUI_END_MSG_MAP() \
|
|
return __super::DispatchMessageMap(pMessage); \
|
|
}
|
|
#else
|
|
|
|
|
|
#define XUI_END_MSG_MAP() \
|
|
return CXuiElementImplBase::DispatchMessageMap(pMessage); \
|
|
}
|
|
#endif
|
|
|
|
|
|
#define XUI_ON_MESSAGE(dwMsg, MemberFunc) \
|
|
if (pMessage->dwMessage == dwMsg) \
|
|
{ \
|
|
return MemberFunc(pMessage); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_INIT(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_INIT) \
|
|
{ \
|
|
XUIMessageInit *pData = (XUIMessageInit *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_DESTROY(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_DESTROY) \
|
|
{ \
|
|
return MemberFunc(); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_RENDER(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_RENDER) \
|
|
{ \
|
|
XUIMessageRender *pData = (XUIMessageRender *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_TIMER(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_TIMER) \
|
|
{ \
|
|
XUIMessageTimer *pData = (XUIMessageTimer *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_KEYDOWN(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_KEYDOWN) \
|
|
{ \
|
|
XUIMessageInput *pData = (XUIMessageInput *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_KEYUP(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_KEYUP) \
|
|
{ \
|
|
XUIMessageInput *pData = (XUIMessageInput *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_CHAR(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_CHAR) \
|
|
{ \
|
|
XUIMessageChar *pData = (XUIMessageChar *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_SKIN_CHANGED(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_SKIN_CHANGED) \
|
|
{ \
|
|
return MemberFunc(pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_GET_SOURCE_TEXT(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_GET_SOURCE_TEXT) \
|
|
{ \
|
|
XUIMessageGetSourceText *pData = (XUIMessageGetSourceText *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_GET_SOURCE_IMAGE(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_GET_SOURCE_IMAGE) \
|
|
{ \
|
|
XUIMessageGetSourceImage *pData = (XUIMessageGetSourceImage *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_GET_ITEMCOUNT_ALL(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_GET_ITEMCOUNT && ((XUIMessageGetItemCount *) pMessage->pvData)->nType == XUI_ITEMCOUNT_ALL) \
|
|
{ \
|
|
XUIMessageGetItemCount *pData = (XUIMessageGetItemCount *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_GET_ITEMENABLE(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_GET_ITEMENABLE) \
|
|
{ \
|
|
XUIMessageGetItemEnable *pData = (XUIMessageGetItemEnable *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NOTIFY(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NOTIFY) \
|
|
{ \
|
|
XUINotify *pData = (XUINotify *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NOTIFY_SELCHANGED(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NOTIFY) \
|
|
{ \
|
|
XUINotify *pNotify = (XUINotify *) pMessage->pvData; \
|
|
if (pNotify->dwNotify == XN_SELCHANGED) \
|
|
{ \
|
|
XUINotifySelChanged *pNotifySelChanged = (XUINotifySelChanged *) pNotify->pvData; \
|
|
return MemberFunc(pNotify->hObjSource, pNotifySelChanged, pMessage->bHandled); \
|
|
} \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NOTIFY_PRESS(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NOTIFY) \
|
|
{ \
|
|
XUINotify *pNotify = (XUINotify *) pMessage->pvData; \
|
|
if (pNotify->dwNotify == XN_PRESS) \
|
|
{ \
|
|
return MemberFunc(pNotify->hObjSource, pMessage->bHandled); \
|
|
} \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NOTIFY_PRESS_EX(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NOTIFY) \
|
|
{ \
|
|
XUINotify *pNotify = (XUINotify *) pMessage->pvData; \
|
|
if (pNotify->dwNotify == XN_PRESS) \
|
|
return MemberFunc(pNotify->hObjSource, (XUINotifyPress *) pNotify->pvData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NOTIFY_SET_FOCUS(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NOTIFY) \
|
|
{ \
|
|
XUINotify *pNotify = (XUINotify *) pMessage->pvData; \
|
|
if (pNotify->dwNotify == XN_SET_FOCUS) \
|
|
{ \
|
|
XUINotifyFocus *pNotifyFocus = (XUINotifyFocus *) pNotify->pvData; \
|
|
return MemberFunc(pNotify->hObjSource, pNotifyFocus, pMessage->bHandled); \
|
|
} \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NOTIFY_KILL_FOCUS(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NOTIFY) \
|
|
{ \
|
|
XUINotify *pNotify = (XUINotify *) pMessage->pvData; \
|
|
if (pNotify->dwNotify == XN_KILL_FOCUS) \
|
|
{ \
|
|
XUINotifyFocus *pNotifyFocus = (XUINotifyFocus *) pNotify->pvData; \
|
|
return MemberFunc(pNotify->hObjSource, pNotifyFocus, pMessage->bHandled); \
|
|
} \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NOTIFY_VALUE_CHANGED(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NOTIFY) \
|
|
{ \
|
|
XUINotify *pNotify = (XUINotify *) pMessage->pvData; \
|
|
if (pNotify->dwNotify == XN_VALUE_CHANGED) \
|
|
{ \
|
|
XUINotifyValueChanged *pNotifyValueChanged = (XUINotifyValueChanged *) pNotify->pvData; \
|
|
return MemberFunc(pNotify->hObjSource, pNotifyValueChanged, pMessage->bHandled); \
|
|
} \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NOTIFY_VALUE_CHANGING(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NOTIFY) \
|
|
{ \
|
|
XUINotify *pNotify = (XUINotify *) pMessage->pvData; \
|
|
if (pNotify->dwNotify == XN_VALUE_CHANGING) \
|
|
{ \
|
|
XUINotifyValueChanging *pNotifyValueChanging = (XUINotifyValueChanging *) pNotify->pvData; \
|
|
return MemberFunc(pNotify->hObjSource, pNotifyValueChanging, pMessage->bHandled); \
|
|
} \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_TIMELINE_END(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_TIMELINE_END) \
|
|
{ \
|
|
return MemberFunc(pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_TRANSITION_START(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_TRANSITION_START) \
|
|
{ \
|
|
XUIMessageTransition *pData = (XUIMessageTransition *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_TRANSITION_END(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_TRANSITION_END) \
|
|
{ \
|
|
XUIMessageTransition *pData = (XUIMessageTransition *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_CONTROL_NAVIGATE(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_CONTROL_NAVIGATE) \
|
|
{ \
|
|
XUIMessageControlNavigate *pData = (XUIMessageControlNavigate *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NAV_FORWARD(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NAV_FORWARD) \
|
|
{ \
|
|
XUIMessageNavForward *pData = (XUIMessageNavForward *) pMessage->pvData; \
|
|
return MemberFunc(pData, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_NAV_RETURN(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_NAV_RETURN) \
|
|
{ \
|
|
XUIMessageNavReturn *pData = (XUIMessageNavReturn *) pMessage->pvData; \
|
|
return MemberFunc(pData->hScene, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
#define XUI_ON_XM_KILL_FOCUS(MemberFunc) \
|
|
if (pMessage->dwMessage == XM_KILL_FOCUS) \
|
|
{ \
|
|
XUIMessageKillFocus *pData = (XUIMessageKillFocus *) pMessage->pvData; \
|
|
return MemberFunc(pData->hOther, pMessage->bHandled); \
|
|
}
|
|
|
|
|
|
struct XUIElementPropDef;
|
|
typedef const XUIElementPropDef* (APIENTRY *PFN_GETPROPDEF)(DWORD* pdwCount);
|
|
typedef HRESULT (APIENTRY *PFN_OBJECT_PROC)(HXUIOBJ hObj, XUIMessage* pMessage, void* pvThis);
|
|
typedef HRESULT (APIENTRY *PFN_CREATEINST)(HXUIOBJ hObj, void** ppvObj);
|
|
typedef HRESULT (APIENTRY *PFN_DESTROYINST)(void* pvObj);
|
|
|
|
struct XUIObjectMethods
|
|
{
|
|
PFN_OBJECT_PROC ObjectProc;
|
|
PFN_CREATEINST CreateInstance;
|
|
PFN_DESTROYINST DestroyInstance;
|
|
};
|
|
|
|
struct XUIClass
|
|
{
|
|
DWORD cbSize;
|
|
LPCWSTR szClassName;
|
|
LPCWSTR szBaseClassName;
|
|
LPCWSTR szClassDetails;
|
|
XUIObjectMethods Methods;
|
|
const XUIElementPropDef* pPropDefs;
|
|
DWORD dwPropDefCount;
|
|
BOOL bExtensionClass;
|
|
};
|
|
|
|
namespace ImXuiCompat {
|
|
|
|
struct ClassFactoryRecord {
|
|
XUIClass cls;
|
|
ClassFactoryRecord* next;
|
|
};
|
|
|
|
class ClassRegistry {
|
|
public:
|
|
static ClassRegistry& Get();
|
|
|
|
|
|
HXUICLASS Register(const XUIClass* pClass);
|
|
HXUICLASS Find(const wchar_t* name);
|
|
bool DerivesFrom(HXUICLASS derivedClass, HXUICLASS baseClass);
|
|
HRESULT Unregister(const wchar_t* name);
|
|
private:
|
|
ClassRegistry() : m_head(NULL) {}
|
|
ClassFactoryRecord* m_head;
|
|
};
|
|
|
|
}
|
|
|
|
#define XUI_IMPLEMENT_CLASS(className, xuiClassName, xuiBaseClassName) \
|
|
static HRESULT Register() \
|
|
{ \
|
|
HXUICLASS hClass; \
|
|
XUIClass cls; \
|
|
memset(&cls, 0x00, sizeof(cls)); \
|
|
cls.szClassName = xuiClassName; \
|
|
cls.szBaseClassName = xuiBaseClassName; \
|
|
cls.Methods.CreateInstance = (PFN_CREATEINST) CreateInstance; \
|
|
cls.Methods.DestroyInstance = (PFN_DESTROYINST) DestroyInstance; \
|
|
cls.Methods.ObjectProc = (PFN_OBJECT_PROC) _ObjectProc; \
|
|
cls.pPropDefs = _GetPropDef(&cls.dwPropDefCount); \
|
|
HRESULT hr = XuiRegisterClass(&cls, &hClass); \
|
|
if (FAILED(hr)) return hr; \
|
|
return S_OK; \
|
|
} \
|
|
static HRESULT Unregister() \
|
|
{ \
|
|
return XuiUnregisterClass(xuiClassName); \
|
|
} \
|
|
static HRESULT APIENTRY CreateInstance(HXUIOBJ hObj, void** ppvObj) \
|
|
{ \
|
|
*ppvObj = NULL; \
|
|
className* pThis = new className(); \
|
|
if (!pThis) return E_OUTOFMEMORY; \
|
|
pThis->m_hObj = hObj ? hObj : (HXUIOBJ)(CXuiElementImplBase*)pThis; \
|
|
HRESULT hr = pThis->OnCreate(); \
|
|
if (FAILED(hr)) { DestroyInstance(pThis); return hr; } \
|
|
*ppvObj = pThis; \
|
|
return S_OK; \
|
|
} \
|
|
static HRESULT APIENTRY DestroyInstance(void* pvObj) \
|
|
{ \
|
|
className* pThis = (className*)pvObj; \
|
|
delete pThis; \
|
|
return S_OK; \
|
|
}
|
|
|
|
|
|
HRESULT XuiRegisterClass(const XUIClass* pClass, HXUICLASS* phClass);
|
|
HRESULT XuiUnregisterClass(LPCWSTR pwszClassName);
|
|
|
|
|
|
class CXuiObject
|
|
{
|
|
public:
|
|
HXUIOBJ m_hObj;
|
|
CXuiObject() : m_hObj(NULL) {}
|
|
operator HXUIOBJ() const { return m_hObj; }
|
|
bool IsValid() const { return m_hObj != NULL; }
|
|
void Bind(HXUIOBJ hObj) { m_hObj = hObj; }
|
|
};
|
|
|
|
class CXuiElementImplBase : public ImXui::ElementImplBase
|
|
{
|
|
public:
|
|
CXuiElementImplBase();
|
|
virtual ~CXuiElementImplBase();
|
|
|
|
|
|
HXUIOBJ m_hObj;
|
|
|
|
|
|
void AttachToElement(ImXui::Element* element) { m_pElement = element; }
|
|
ImXui::Element* GetBoundElement() const { return m_pElement; }
|
|
void SetOuter(CXuiElementImplBase* outer) { m_pOuter = outer; }
|
|
CXuiElementImplBase* GetOuter() const { return m_pOuter; }
|
|
void SetClassName(const std::wstring& className) { m_className = className; }
|
|
const std::wstring& GetClassNameW() const { return m_className; }
|
|
|
|
|
|
virtual HXUIOBJ GetChildByIdHandle(LPCWSTR pwszId) {
|
|
(void)pwszId;
|
|
return NULL;
|
|
}
|
|
|
|
|
|
virtual HRESULT ObjectProc(XUIMessage* pMessage) {
|
|
return DispatchMessageMap(pMessage);
|
|
}
|
|
|
|
virtual HRESULT DispatchMessageMap(XUIMessage* ) {
|
|
return S_OK;
|
|
}
|
|
|
|
|
|
static HRESULT APIENTRY _ObjectProc(HXUIOBJ , XUIMessage* pMessage, void* pvThis) {
|
|
CXuiElementImplBase* pThis = (CXuiElementImplBase*)pvThis;
|
|
return pThis->ObjectProc(pMessage);
|
|
}
|
|
|
|
static const XUIElementPropDef* APIENTRY _GetPropDef(DWORD* pdwCount) {
|
|
*pdwCount = 0;
|
|
return NULL;
|
|
}
|
|
|
|
|
|
HRESULT OnCreate() {
|
|
return S_OK;
|
|
}
|
|
|
|
|
|
ImXui::Vec3 GetPositionV() const;
|
|
void SetPositionV(float x, float y, float z);
|
|
float GetPosX() const;
|
|
float GetPosY() const;
|
|
float GetWidthF() const;
|
|
float GetHeightF() const;
|
|
void SetShow(bool show);
|
|
bool IsShownB() const;
|
|
void SetOpacityF(float opacity);
|
|
float GetOpacityF() const;
|
|
void SetUserDataP(void* data);
|
|
void* GetUserDataP() const;
|
|
|
|
protected:
|
|
ImXui::Element* m_pElement;
|
|
CXuiElementImplBase* m_pOuter;
|
|
std::wstring m_className;
|
|
};
|
|
|
|
|
|
class CXuiGenericObject : public CXuiElementImplBase {};
|
|
|
|
|
|
class CXuiControlImpl : public CXuiElementImplBase
|
|
{
|
|
public:
|
|
|
|
|
|
XUI_IMPLEMENT_CLASS(CXuiControlImpl, L"XuiControl", L"XuiElement")
|
|
|
|
|
|
HRESULT SetText(LPCWSTR pwszText);
|
|
HRESULT GetText(LPWSTR pwszBuffer, UINT cchMax);
|
|
std::wstring GetTextW();
|
|
HRESULT SetFont(DWORD dwFontId);
|
|
|
|
|
|
HRESULT SetEnable(BOOL fEnabled);
|
|
BOOL IsEnabledB() const;
|
|
BOOL HasFocusState();
|
|
|
|
|
|
HRESULT AttachVisual();
|
|
HRESULT GetVisual(HXUIOBJ* phVisual);
|
|
HRESULT SetImageBrush(HXUIBRUSH hBrush);
|
|
|
|
|
|
BOOL HasFocus();
|
|
HRESULT TakeFocus();
|
|
HRESULT Navigate(XUI_CONTROL_NAVIGATE direction);
|
|
|
|
|
|
HRESULT FirePress(DWORD userIndex);
|
|
};
|
|
|
|
class CXuiListImpl : public CXuiControlImpl
|
|
{
|
|
public:
|
|
XUI_IMPLEMENT_CLASS(CXuiListImpl, L"XuiList", L"XuiControl")
|
|
|
|
INT GetCurSel(INT* piOldItem);
|
|
INT GetItemCountAll();
|
|
HXUIOBJ GetItemControl(INT iItem);
|
|
HRESULT SetCurSel(INT iItem);
|
|
std::wstring GetItemText(INT iItem);
|
|
BOOL GetItemEnabled(INT iItem);
|
|
|
|
HRESULT FireSelChanged(INT iItem, INT iOldItem);
|
|
};
|
|
|
|
class CXuiListItemImpl : public CXuiControlImpl
|
|
{
|
|
public:
|
|
CXuiListItemImpl();
|
|
XUI_IMPLEMENT_CLASS(CXuiListItemImpl, L"XuiListItem", L"XuiControl")
|
|
INT GetItemIndex() const { return m_iItemIndex; }
|
|
void SetItemIndex(INT iItem) { m_iItemIndex = iItem; }
|
|
private:
|
|
INT m_iItemIndex;
|
|
};
|
|
|
|
class CXuiComboBoxImpl : public CXuiListImpl
|
|
{
|
|
public:
|
|
CXuiComboBoxImpl();
|
|
XUI_IMPLEMENT_CLASS(CXuiComboBoxImpl, L"XuiComboBox", L"XuiList")
|
|
HRESULT OpenDropDown(BOOL fOpen);
|
|
BOOL IsDropDownOpen() const { return m_fDropDownOpen; }
|
|
private:
|
|
BOOL m_fDropDownOpen;
|
|
};
|
|
|
|
class CXuiSceneImpl : public CXuiControlImpl
|
|
{
|
|
public:
|
|
CXuiSceneImpl();
|
|
XUI_IMPLEMENT_CLASS(CXuiSceneImpl, L"XuiScene", L"XuiControl")
|
|
|
|
|
|
HXUIOBJ GetChildByIdHandle(LPCWSTR pwszId);
|
|
HRESULT GetChildById(LPCWSTR pwszId, HXUIOBJ* phObj);
|
|
template <typename WrapperT>
|
|
HRESULT GetChildById(LPCWSTR pwszId, WrapperT& wrapper) {
|
|
wrapper.Bind(GetChildByIdHandle(pwszId));
|
|
return wrapper.IsValid() ? S_OK : E_FAIL;
|
|
}
|
|
|
|
|
|
virtual HRESULT MapChildControls() { return S_OK; }
|
|
|
|
ImXui::Scene* GetImScene() const { return m_pScene; }
|
|
void BindScene(ImXui::Scene* scene) { m_pScene = scene; }
|
|
|
|
|
|
HRESULT NavigateBack();
|
|
HRESULT NavigateForward(HXUIOBJ hSceneNew);
|
|
HRESULT SetBackScene(HXUIOBJ hScene);
|
|
HXUIOBJ GetBackScene();
|
|
|
|
|
|
HRESULT SetTimer(UINT uId, UINT uMs);
|
|
HRESULT KillTimer(UINT uId);
|
|
|
|
HRESULT DispatchMessageMap(XUIMessage* pMessage);
|
|
|
|
protected:
|
|
ImXui::Scene* m_pScene;
|
|
};
|
|
|
|
|
|
class CXuiObjectWrapper
|
|
{
|
|
public:
|
|
HXUIOBJ m_hObj;
|
|
CXuiObjectWrapper() : m_hObj(NULL) {}
|
|
|
|
|
|
CXuiObjectWrapper(HXUIOBJ hObj) : m_hObj(hObj) {}
|
|
operator HXUIOBJ() const { return m_hObj; }
|
|
bool IsValid() const { return m_hObj != NULL; }
|
|
void Bind(HXUIOBJ hObj) { m_hObj = hObj; }
|
|
CXuiElementImplBase* Obj() const { return m_hObj; }
|
|
|
|
|
|
HRESULT GetChildById(LPCWSTR pwszId, CXuiObjectWrapper* pWrapper) {
|
|
if (!pWrapper) return E_POINTER;
|
|
HXUIOBJ h = m_hObj ? m_hObj->GetChildByIdHandle(pwszId) : NULL;
|
|
pWrapper->Bind(h);
|
|
return h ? S_OK : E_FAIL;
|
|
}
|
|
};
|
|
|
|
|
|
typedef struct _TypefaceDescriptor {
|
|
LPCWSTR szTypeface;
|
|
LPCWSTR szLocator;
|
|
LPCWSTR szFallbackTypeface;
|
|
} TypefaceDescriptor;
|
|
|
|
typedef struct _XUIFontMetrics {
|
|
FLOAT fLineSpacing;
|
|
FLOAT fLineHeight;
|
|
FLOAT fMaxAscent;
|
|
FLOAT fMaxDescent;
|
|
} XUIFontMetrics;
|
|
|
|
typedef struct _XUICharMetrics {
|
|
UINT nWidth;
|
|
UINT nHeight;
|
|
INT nOffsetX;
|
|
INT nOffsetY;
|
|
UINT nAdvance;
|
|
} XUICharMetrics;
|
|
|
|
typedef struct _CharData {
|
|
WCHAR wch;
|
|
FLOAT x;
|
|
FLOAT y;
|
|
DWORD dwColor;
|
|
DWORD dwStyle;
|
|
FLOAT fScale;
|
|
} CharData;
|
|
|
|
class IXuiTexture
|
|
{
|
|
public:
|
|
virtual ~IXuiTexture() {}
|
|
virtual HRESULT Lock(UINT, UINT, VOID** ppvBits, UINT* pPitch) = 0;
|
|
virtual HRESULT Unlock() = 0;
|
|
};
|
|
|
|
#ifndef STDMETHODCALLTYPE
|
|
#define STDMETHODCALLTYPE
|
|
#endif
|
|
#ifndef STDMETHOD
|
|
#define STDMETHOD(name) virtual HRESULT STDMETHODCALLTYPE name
|
|
#endif
|
|
|
|
class IXuiFontRenderer
|
|
{
|
|
public:
|
|
virtual ~IXuiFontRenderer() {}
|
|
virtual HRESULT Init(FLOAT fDpi) = 0;
|
|
virtual VOID Term() = 0;
|
|
virtual HRESULT GetCaps(DWORD* pdwCaps) = 0;
|
|
virtual HRESULT CreateFont(const TypefaceDescriptor* pTypefaceDescriptor,
|
|
FLOAT fPointSize, DWORD dwStyle,
|
|
DWORD dwReserved, HFONTOBJ* phFont) = 0;
|
|
virtual VOID ReleaseFont(HFONTOBJ hFont) = 0;
|
|
virtual HRESULT GetFontMetrics(HFONTOBJ hFont, XUIFontMetrics* pFontMetrics) = 0;
|
|
virtual HRESULT GetCharMetrics(HFONTOBJ hFont, WCHAR wch,
|
|
XUICharMetrics* pCharMetrics) = 0;
|
|
virtual HRESULT DrawCharToTexture(HFONTOBJ hFont, WCHAR wch, HXUIDC hDC,
|
|
IXuiTexture* pTexture, UINT x, UINT y,
|
|
UINT width, UINT height,
|
|
UINT insetX, UINT insetY) = 0;
|
|
virtual HRESULT DrawCharsToDevice(HFONTOBJ hFont, CharData* pCharData,
|
|
DWORD dwCount, RECT* pClipRect,
|
|
HXUIDC hDC,
|
|
D3DXMATRIX* pWorldViewProj) = 0;
|
|
};
|
|
|
|
|
|
class CXuiElement : public CXuiObjectWrapper {
|
|
public:
|
|
CXuiElement() {}
|
|
CXuiElement(HXUIOBJ hObj) : CXuiObjectWrapper(hObj) {}
|
|
};
|
|
class CXuiControl : public CXuiObjectWrapper
|
|
{
|
|
public:
|
|
CXuiControl() {}
|
|
CXuiControl(HXUIOBJ hObj) : CXuiObjectWrapper(hObj) {}
|
|
|
|
|
|
HRESULT SetText(LPCWSTR pwszText);
|
|
BOOL IsEnabledB() const;
|
|
ImXui::Vec3 GetPositionV() const;
|
|
};
|
|
|
|
class CXuiScene : public CXuiObjectWrapper
|
|
{
|
|
public:
|
|
CXuiScene() {}
|
|
CXuiScene(HXUIOBJ hObj) : CXuiObjectWrapper(hObj) {}
|
|
ImXui::Scene* GetImScene() const;
|
|
};
|
|
|
|
class CXuiProgressBarW : public CXuiObjectWrapper { public: CXuiProgressBarW() {} CXuiProgressBarW(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
class CXuiSliderW : public CXuiObjectWrapper { public: CXuiSliderW() {} CXuiSliderW(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
class CXuiCheckbox : public CXuiObjectWrapper { public: CXuiCheckbox() {} CXuiCheckbox(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
class CXuiListW : public CXuiObjectWrapper { public: CXuiListW() {} CXuiListW(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
class CXuiImageElement : public CXuiObjectWrapper { public: CXuiImageElement() {} CXuiImageElement(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
class CXuiSoundW : public CXuiObjectWrapper { public: CXuiSoundW() {} CXuiSoundW(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
class CXuiStringTable : public CXuiObjectWrapper { public: CXuiStringTable() {} CXuiStringTable(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
class CXuiHtmlControl : public CXuiObjectWrapper { public: CXuiHtmlControl() {} CXuiHtmlControl(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
class CXuiHtmlElement : public CXuiObjectWrapper { public: CXuiHtmlElement() {} CXuiHtmlElement(HXUIOBJ h) : CXuiObjectWrapper(h) {} };
|
|
|
|
|
|
HRESULT XuiInit();
|
|
VOID XuiShutdown();
|
|
BOOL XuiIsInitialized();
|
|
|
|
|
|
HRESULT XuiCreateObject(LPCWSTR pwszClassName, HXUIOBJ* phObj);
|
|
VOID XuiDestroyObject(HXUIOBJ hObj);
|
|
HRESULT XuiObjectFromHandle(HXUIOBJ hObj, VOID** ppvObject);
|
|
HXUICLASS XuiFindClass(LPCWSTR pwszClassName);
|
|
HXUICLASS XuiGetObjectClass(HXUIOBJ hObj);
|
|
BOOL XuiClassDerivesFrom(HXUICLASS hDerivedClass, HXUICLASS hBaseClass);
|
|
HRESULT XuiRegisterClass(const XUIClass* pClass, HXUICLASS* phClass);
|
|
HRESULT XuiUnregisterClass(LPCWSTR pwszClassName);
|
|
BOOL XuiIsInstanceOf(HXUIOBJ hObj, HXUICLASS hClass);
|
|
HRESULT XuiGetBaseObject(HXUIOBJ hObj, HXUIOBJ* phBaseObj);
|
|
HXUIOBJ XuiGetOuter(HXUIOBJ hObj);
|
|
|
|
|
|
HRESULT XuiSendMessage(HXUIOBJ hObj, XUIMessage* pMessage);
|
|
HRESULT XuiBroadcastMessage(HXUIOBJ hObjRoot, XUIMessage* pMessage);
|
|
HRESULT XuiBubbleMessage(HXUIOBJ hObj, XUIMessage* pMessage);
|
|
|
|
|
|
HRESULT XuiSetTimer(HXUIOBJ hObj, UINT uId, UINT uMs);
|
|
HRESULT XuiKillTimer(HXUIOBJ hObj, UINT uId);
|
|
BOOL XuiTimersRun();
|
|
|
|
|
|
HRESULT XuiElementGetChildById(HXUIOBJ hParent, LPCWSTR pwszId, HXUIOBJ* phChild);
|
|
HRESULT XuiElementAddChild(HXUIOBJ hParent, HXUIOBJ hChild);
|
|
HRESULT XuiElementGetFirstChild(HXUIOBJ hObj, HXUIOBJ* phChild);
|
|
HRESULT XuiElementGetNext(HXUIOBJ hObj, HXUIOBJ* phNext);
|
|
HRESULT XuiElementGetParent(HXUIOBJ hObj, HXUIOBJ* phParent);
|
|
HRESULT XuiElementGetId(HXUIOBJ hObj, LPCWSTR* ppwszId);
|
|
HRESULT XuiElementGetPosition(HXUIOBJ hObj, D3DXVECTOR3* pPos);
|
|
HRESULT XuiElementSetPosition(HXUIOBJ hObj, const D3DXVECTOR3* pPos);
|
|
HRESULT XuiElementGetBounds(HXUIOBJ hObj, FLOAT* pfWidth, FLOAT* pfHeight);
|
|
HRESULT XuiElementSetBounds(HXUIOBJ hObj, FLOAT fWidth, FLOAT fHeight);
|
|
HRESULT XuiElementSetScale(HXUIOBJ hObj, const D3DXVECTOR3* pScale);
|
|
HRESULT XuiElementGetScale(HXUIOBJ hObj, D3DXVECTOR3* pScale);
|
|
HRESULT XuiElementSetPivot(HXUIOBJ hObj, const D3DXVECTOR3* pPivot);
|
|
HRESULT XuiElementGetPivot(HXUIOBJ hObj, D3DXVECTOR3* pPivot);
|
|
HRESULT XuiElementSetOpacity(HXUIOBJ hObj, FLOAT fOpacity);
|
|
HRESULT XuiElementGetFullXForm(HXUIOBJ hObj, D3DXMATRIX* pMatrix);
|
|
HRESULT XuiElementSetShow(HXUIOBJ hObj, BOOL fShown);
|
|
HRESULT XuiElementIsShown(HXUIOBJ hObj, BOOL* pfShown);
|
|
HRESULT XuiElementGetUserData(HXUIOBJ hObj, VOID** ppvUserData);
|
|
HRESULT XuiElementSetUserData(HXUIOBJ hObj, VOID* pvUserData);
|
|
HRESULT XuiElementSetDisableFocusRecursion(HXUIOBJ hObj, BOOL fDisable);
|
|
HRESULT XuiElementDiscardResources(HXUIOBJ hObjRoot, DWORD dwDiscardMask);
|
|
HRESULT XuiFreeVisuals(LPCWSTR pwszPrefix);
|
|
HRESULT XuiGetObjectPropertyId(HXUIOBJ hObj, LPCWSTR pwszPropertyName, UINT* puId);
|
|
HRESULT XuiObjectGetPropertyId(HXUIOBJ hObj, LPCWSTR pwszPropertyName, UINT* puId);
|
|
HRESULT XuiObjectSetProperty(HXUIOBJ hObj, UINT uId, VOID* pvUnused, VOID* pvValue);
|
|
|
|
|
|
HRESULT XuiElementSetUserFocus(HXUIOBJ hObj, DWORD UserIndex);
|
|
HRESULT XuiElementInitUserFocus(HXUIOBJ hObj, DWORD UserIndex, BOOL fRecursive);
|
|
HRESULT XuiElementGetFocusUser(BYTE* pbUserIndex);
|
|
HRESULT XuiElementGetFocus(HXUIOBJ* phObjFocused);
|
|
HRESULT XuiElementSetFocus(HXUIOBJ hObj);
|
|
|
|
|
|
HRESULT XuiControlSetText(HXUIOBJ hObj, LPCWSTR pwszText);
|
|
HRESULT XuiControlGetText(HXUIOBJ hObj, LPWSTR pwszBuffer, UINT cchMax);
|
|
HRESULT XuiControlSetEnable(HXUIOBJ hObj, BOOL fEnable);
|
|
HRESULT XuiControlAttachVisual(HXUIOBJ hObj);
|
|
HRESULT XuiControlGetVisual(HXUIOBJ hObj, HXUIOBJ* phVisual);
|
|
HRESULT XuiControlSetImageBrush(HXUIOBJ hObj, HXUIBRUSH hBrush);
|
|
HXUIOBJ XuiControlGetNavigation(HXUIOBJ hObjSource, XUI_CONTROL_NAVIGATE navDirection,
|
|
BOOL fWrapA, BOOL fWrapB);
|
|
LPCWSTR XuiTextElementGetText(HXUIOBJ hObj);
|
|
|
|
|
|
INT XuiListGetCurSel(HXUIOBJ hObj, INT* piOldItem);
|
|
HXUIOBJ XuiListGetItemControl(HXUIOBJ hObj, INT iItem);
|
|
HRESULT XuiNotifySelChangedSend(HXUIOBJ hObjSource, INT iItem, INT iOldItem);
|
|
HRESULT XuiNotifyValueChangedSend(HXUIOBJ hObjSource, INT iValue);
|
|
|
|
|
|
HRESULT XuiEditSetTextLimit(HXUIOBJ hObj, UINT uLimit);
|
|
UINT XuiEditGetTextLimit(HXUIOBJ hObj);
|
|
HRESULT XuiEditSetCaretPosition(HXUIOBJ hObj, INT iPos);
|
|
|
|
|
|
HRESULT XuiTextPresenterMeasureText(HXUIOBJ hObj, LPCWSTR pwszText, RECT* pRect);
|
|
|
|
|
|
HRESULT XuiHtmlRegister();
|
|
HRESULT XuiHtmlUnregister();
|
|
HRESULT XuiHtmlSetText(HXUIOBJ hObj, LPCWSTR pwszText);
|
|
HRESULT XuiHtmlControlVScrollBy(HXUIOBJ hObj, INT iAmount);
|
|
HRESULT XuiHtmlControlGetVScrollInfo(HXUIOBJ hObj, VOID* pInfo);
|
|
HRESULT XuiHtmlControlSetSmoothScroll(HXUIOBJ hObj, DWORD dwDirection, BOOL fEnable,
|
|
FLOAT fAccel, FLOAT fDecelRatio, FLOAT fMaxSpeed);
|
|
HRESULT XuiHtmlGetContentDims(HXUIOBJ hObj, D3DXVECTOR2* pDims);
|
|
|
|
|
|
HRESULT XuiSceneCreate(LPCWSTR pwszPath, LPCWSTR pwszName, VOID* pvInitData, HXUIOBJ* phScene);
|
|
HRESULT XuiSceneNavigateForward(HXUIOBJ hSceneCur, BOOL fDeferred, HXUIOBJ hSceneNew, VOID* pvInitData);
|
|
HRESULT XuiSceneNavigateBack(HXUIOBJ hSceneCur, HXUIOBJ hSceneBack, DWORD UserIndex);
|
|
HRESULT XuiSceneNavigateBackToFirst(HXUIOBJ hSceneCur, DWORD UserIndex);
|
|
HRESULT XuiSceneSetBackScene(HXUIOBJ hSceneCur, HXUIOBJ hSceneBack);
|
|
HXUIOBJ XuiSceneGetBackScene(HXUIOBJ hSceneCur);
|
|
HRESULT XuiApplyLocale(HXUIOBJ hObjRoot, VOID* pvReserved);
|
|
|
|
|
|
HRESULT XuiSetLocale(LPCWSTR pwszLocalePath);
|
|
LPCWSTR XuiGetLocale();
|
|
HRESULT XuiRegisterLocale(LPCWSTR pwszLocalePath, DWORD dwLangId);
|
|
|
|
|
|
HRESULT XuiResourceOpenNoLoc(LPCWSTR pwszLocator, HXUIRESOURCE* phResource, BOOL* pfMemoryResource);
|
|
HRESULT XuiResourceLoadAll(LPCWSTR pwszLocator, VOID** ppvData, DWORD* pcbSize);
|
|
HRESULT XuiResourceLoadAllNoLoc(LPCWSTR pwszLocator, VOID** ppvData, DWORD* pcbSize);
|
|
HRESULT XuiResourceClose(HXUIRESOURCE hResource);
|
|
VOID* XuiAlloc(SIZE_T cb);
|
|
VOID XuiFree(VOID* pv);
|
|
HRESULT XuiMountResourcePackage(const char* szXzpPath);
|
|
HRESULT XuiMountResourcePackageMemory(const void* pData, size_t cbSize);
|
|
|
|
|
|
HRESULT XuiCreateTextureBrush(LPCWSTR pwszLocator, HXUIBRUSH* phBrush);
|
|
HRESULT XuiCreateTextureBrushFromMemory(const BYTE* pbData, DWORD cbData, HXUIBRUSH* phBrush);
|
|
HRESULT XuiDestroyBrush(HXUIBRUSH hBrush);
|
|
|
|
|
|
HRESULT XuiSoundPlay(HXUIOBJ hSound);
|
|
HRESULT XuiSoundStop(HXUIOBJ hSound);
|
|
HRESULT XuiSoundXACTRegister();
|
|
HRESULT XuiSoundXAudioRegister();
|
|
|
|
|
|
HRESULT XuiRegisterTypeface(TypefaceDescriptor* pDescriptor, BOOL fDefault);
|
|
HRESULT XuiFontSetRenderer(IXuiFontRenderer* pRenderer);
|
|
IXuiFontRenderer* XuiFontGetRenderer();
|
|
HFONTOBJ XuiFontCreate(LPCWSTR pwszTypeface, FLOAT fPointSize, DWORD dwStyle);
|
|
|
|
|
|
HRESULT XuiRenderPushState(HXUIDC hDC);
|
|
HRESULT XuiRenderRestoreState(HXUIDC hDC);
|
|
HRESULT XuiGetTextDropShadowColor(HXUIDC hDC, DWORD* pdwColor);
|
|
HRESULT XuiSetTextDropShadowColor(HXUIDC hDC, DWORD dwColor);
|
|
HXUIDC XuiRenderCreateDeviceContext();
|
|
VOID XuiRenderDestroyDeviceContext(HXUIDC hDC);
|
|
|
|
|
|
HRESULT XuiElementGetTimeline(HXUIOBJ hObj, HXUITIMELINE* phTimeline);
|
|
HRESULT XuiElementFindNamedFrame(HXUIOBJ hObj, LPCWSTR pwszFrameName, INT* piFrame);
|
|
HRESULT XuiElementPlayTimeline(HXUIOBJ hObj, INT iStart, INT iEnd, INT iLoop, BOOL fPause, BOOL fReverse);
|
|
HRESULT XuiElementStopTimeline(HXUIOBJ hObj, BOOL fGotoEnd);
|