2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

CWE Directory Reorganization

Rearrange directory structure of CWE to be loosely equivalent to
the H'uru Plasma repository.

Part 1: Movement of directories and files.
This commit is contained in:
rarified
2021-05-15 12:49:46 -06:00
parent c3f4a640a3
commit 96903e8dca
4002 changed files with 159 additions and 644 deletions

View File

@ -0,0 +1,84 @@
#include "hsTypes.h"
// Stolen from: http://www.mvps.org/user32/webhost.cab
// No copyright notices, so I assume it's public domain -Colin
#include "basewnd.h"
#include "hsConfig.h"
#if HS_BUILD_FOR_WIN32
wchar_t basewnd::szClassName[] = L"BASEWND";
void basewnd::Initialize(HINSTANCE hAppInstance,UINT style)
{
WNDCLASSEX wc =
{
sizeof(wc),
style,
WindowProc,
0,0,
hAppInstance,
LoadIcon(NULL,IDI_APPLICATION),
LoadCursor(NULL,IDC_ARROW),
(HBRUSH)(COLOR_WINDOW+1),
NULL,
szClassName,
LoadIcon(NULL,IDI_APPLICATION)
};
RegisterClassEx(&wc);
}
LRESULT CALLBACK basewnd::WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
basewnd* _this;
if(uMsg == WM_CREATE && (_this = (basewnd*)(LPCREATESTRUCT(lParam))->lpCreateParams))
{
SetWindowLong(hwnd,GWL_USERDATA,(long)_this);
_this->hwnd = hwnd;
_this->AddRef();
}
else
_this = (basewnd*)GetWindowLong(hwnd,GWL_USERDATA);
LRESULT result = 0;
BOOL fDoDef = !(_this && _this->HandleMessage(uMsg,wParam,lParam,&result));
if(uMsg == WM_DESTROY)
{
SetWindowLong(hwnd,GWL_USERDATA,(long)NULL);
_this->Release();
}
return fDoDef?DefWindowProc(hwnd,uMsg,wParam,lParam):result;
}
basewnd::basewnd()
: mcRef(1)
{
}
basewnd::~basewnd()
{
}
ULONG basewnd::AddRef()
{
return mcRef++;
}
ULONG basewnd::Release()
{
if(--mcRef)
return mcRef;
delete this;
return 0;
}
#endif

View File

@ -0,0 +1,33 @@
// Stolen from: http://www.mvps.org/user32/webhost.cab
// No copyright notices, so I assume it's public domain -Colin
#include "hsConfig.h"
#if HS_BUILD_FOR_WIN32
#pragma once
#include <windows.h>
struct basewnd
{
static wchar_t szClassName[];
static LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
static void Initialize(HINSTANCE hAppInstance,UINT style=0);
HWND hwnd;
ULONG mcRef;
basewnd();
virtual ~basewnd();
public:
virtual ULONG AddRef();
virtual ULONG Release();
virtual BOOL HandleMessage(UINT,WPARAM,LPARAM,LRESULT*)=0;
public: // inline overrides
BOOL ShowWindow(int nCmdShow){return ::ShowWindow(hwnd,nCmdShow);}
BOOL UpdateWindow(void){return ::UpdateWindow(hwnd);}
};
#endif

View File

@ -0,0 +1,109 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plButton_h_inc
#define plButton_h_inc
class plButton : public plControl
{
public:
DECLARE_WINDOWSUBCLASS(plButton,plControl)
plDelegate fClickDelegate;
plDelegate fDoubleClickDelegate;
plDelegate fPushDelegate;
plDelegate fUnPushDelegate;
plDelegate fSetFocusDelegate;
plDelegate fKillFocusDelegate;
plButton()
{}
plButton( plWindow * inOwner, int inId=0, plDelegate inClicked=plDelegate(), WNDPROC inSuperProc=nil )
: plControl( inOwner, inId, inSuperProc?inSuperProc:_SuperProc )
, fClickDelegate( inClicked )
{}
void OpenWindow( bool visible, int X, int Y, int XL, int YL, const wchar_t * text )
{
PerformCreateWindowEx
(
0,
nil,
WS_CHILD,
X, Y,
XL, YL,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
SendMessage( *this, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(0,0) );
SetText( text );
if( visible )
ShowWindow( *this, SW_SHOWNOACTIVATE );
}
void SetVisibleText( const wchar_t * text )
{
CHECK(Handle());
if( text )
SetText( text );
Show( text!=nil );
}
void Click()
{
SendMessage( *this, BM_CLICK, 0, 0 );
}
bool InterceptControlCommand( unsigned int message, unsigned int wParam, LONG lParam )
{
if ( HIWORD(wParam)==BN_CLICKED ) {fClickDelegate(); return 1;}
else if( HIWORD(wParam)==BN_DBLCLK ) {fDoubleClickDelegate(); return 1;}
else if( HIWORD(wParam)==BN_PUSHED ) {fPushDelegate(); return 1;}
else if( HIWORD(wParam)==BN_UNPUSHED ) {fUnPushDelegate(); return 1;}
else if( HIWORD(wParam)==BN_SETFOCUS ) {fSetFocusDelegate(); return 1;}
else if( HIWORD(wParam)==BN_KILLFOCUS ) {fUnPushDelegate(); return 1;}
else return 0;
}
};
#endif // plButton_h_inc

View File

@ -0,0 +1,101 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plCheckBox_h_inc
#define plCheckBox_h_inc
class plCheckBox : public plButton
{
DECLARE_WINDOWSUBCLASS(plCheckBox,plButton)
plCheckBox()
{}
plCheckBox( plWindow * inOwner, int inId=0, plDelegate inClicked=plDelegate(), WNDPROC inSuperProc=nil )
: plButton( inOwner, inId, inClicked, inSuperProc?inSuperProc:_SuperProc )
{}
void OpenWindow( bool visible, int X, int Y, int XL, int YL, const wchar_t * text )
{
PerformCreateWindowEx
(
0,
nil,
WS_CHILD|BS_CHECKBOX,
X, Y,
XL, YL,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
SendMessage( *this, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(0,0) );
SetText( text );
if( visible )
ShowWindow( *this, SW_SHOWNOACTIVATE );
}
void Check(bool check=true)
{
SendMessage(*this,BM_SETCHECK,(check)?BST_CHECKED:BST_UNCHECKED,0);
}
bool IsChecked() const
{
return (SendMessage(*this,BM_GETCHECK,0,0)==BST_CHECKED);
}
bool IsUnchecked() const
{
return !IsChecked();
}
std::string IGetValue() const
{
char tmp[20];
sprintf(tmp,"%s",IsChecked()?"true":"false");
return tmp;
}
void ISetValue(const char * value)
{
if (stricmp(value,"true")==0)
Check(true);
else if (stricmp(value,"false")==0)
Check(false);
else
Check(atoi(value)?true:false);
}
};
#endif // plCheckBox_h_inc

View File

@ -0,0 +1,229 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plComboBox_h_inc
#define plComboBox_h_inc
class plComboBox : public plControl
{
public:
DECLARE_WINDOWSUBCLASS(plComboBox,plControl)
plDelegate fDoubleClickDelegate;
plDelegate fDropDownDelegate;
plDelegate fCloseComboDelegate;
plDelegate fEditChangeDelegate;
plDelegate fEditUpdateDelegate;
plDelegate fSetFocusDelegate;
plDelegate fKillFocusDelegate;
plDelegate fSelectionChangeDelegate;
plDelegate fSelectionEndOkDelegate;
plDelegate fSelectionEndCancelDelegate;
plDelegate fEnterKeyPressedDelegate;
plComboBox()
{}
plComboBox( plWindow * inOwner, int inId=0, WNDPROC inSuperProc=nil )
: plControl( inOwner, inId, inSuperProc?inSuperProc:_SuperProc )
{}
void OpenWindow( bool visible )
{
PerformCreateWindowEx
(
0,
nil,
WS_CHILD | WS_VSCROLL | CBS_DROPDOWNLIST | (visible?WS_VISIBLE:0),
0, 0,
64, 384,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
SendMessage( *this, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(0,0) );
}
LONG WndProc( unsigned int message, unsigned int wParam, LONG lParam )
{
switch (message)
{
case WM_GETDLGCODE:
return DLGC_WANTALLKEYS;
case WM_CHAR:
//Process this message to avoid message beeps.
if ((wParam == VK_RETURN) || (wParam == VK_TAB))
return 0;
else
return plControl::WndProc( message, wParam, lParam );
default:
return plControl::WndProc( message, wParam, lParam );
}
}
void OnKeyDown( UInt16 ch )
{
if (ch==VK_RETURN)
fEnterKeyPressedDelegate();
else if (ch==VK_TAB)
PostMessage (*fOwnerWindow, WM_NEXTDLGCTL, 0, 0L);
}
bool InterceptControlCommand( unsigned int message, unsigned int wParam, LONG lParam )
{
if ( HIWORD(wParam)==CBN_DBLCLK ) {fDoubleClickDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_DROPDOWN ) {fDropDownDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_CLOSEUP ) {fCloseComboDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_EDITCHANGE ) {fEditChangeDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_EDITUPDATE ) {fEditUpdateDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_SETFOCUS ) {fSetFocusDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_KILLFOCUS ) {fKillFocusDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_SELCHANGE ) {fSelectionChangeDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_SELENDOK ) {fSelectionEndOkDelegate(); return 1;}
else if( HIWORD(wParam)==CBN_SELENDCANCEL ) {fSelectionEndCancelDelegate(); return 1;}
else return 0;
}
virtual int InsertString( int index, const wchar_t * str )
{
return SendMessage( *this, CB_INSERTSTRING, index, (LPARAM)str );
}
virtual void InsertStringAndData( int index, const wchar_t * str, void * item )
{
int i = SendMessage( *this, CB_INSERTSTRING, index, (LPARAM)str );
SetItemData(i,item);
}
virtual int AddString( const wchar_t * str )
{
return SendMessage( *this, CB_ADDSTRING, 0, (LPARAM)str );
}
virtual void AddStringAndData( const wchar_t * str, void * item )
{
int index = SendMessage( *this, CB_ADDSTRING, 0, (LPARAM)str );
SetItemData(index,item);
}
virtual void AddStrings( const std::vector<std::wstring> & strings )
{
for (int i=0; i<strings.size(); i++)
SendMessage( *this, CB_ADDSTRING, 0, (LPARAM)strings[i].c_str() );
}
virtual void AddStrings( const std::vector<std::string> & strings )
{
for (int i=0; i<strings.size(); i++)
{
wchar_t* temp = hsStringToWString(strings[i].c_str());
SendMessage( *this, CB_ADDSTRING, 0, (LPARAM)temp );
delete [] temp;
}
}
virtual void SetItemData(int index, void * item)
{
SendMessage( *this, CB_SETITEMDATA, index, (LPARAM)item );
}
virtual void * GetItemData(int index)
{
return (void*)SendMessage( *this, CB_GETITEMDATA, index, 0 );
}
virtual std::wstring GetString( int index ) const
{
int length = SendMessage( *this, CB_GETLBTEXTLEN, index, 0 );
if( length==CB_ERR || length == 0 )
return L"";
std::wstring text;
text.resize(length);
SendMessage( *this, CB_GETLBTEXT, index, (LPARAM)text.data() );
return text;
}
virtual void DeleteString(int index)
{
SendMessage(*this,CB_DELETESTRING, index, 0);
}
virtual int GetCount()
{
return SendMessage( *this, CB_GETCOUNT, 0, 0 );
}
virtual void SetCurrent( int index )
{
SendMessage( *this, CB_SETCURSEL, index, 0 );
}
virtual int GetCurrent() const
{
return SendMessage( *this, CB_GETCURSEL, 0, 0 );
}
virtual int FindStringExact( const wchar_t * string, int fromIdx = -1 )
{
int index = SendMessage( *this, CB_FINDSTRINGEXACT, fromIdx, (LPARAM)string );
return index!=CB_ERR ? index : -1;
}
virtual int FindString( const wchar_t * string, int fromIdx = -1 )
{
int index = SendMessage( *this, CB_FINDSTRING, fromIdx, (LPARAM)string );
return index!=CB_ERR ? index : -1;
}
void Empty()
{
SendMessage( *this, CB_RESETCONTENT, 0, 0 );
}
std::string IGetValue() const
{
std::string retVal = "";
std::wstring tempString = L"";
int index = GetCurrent();
if (index>=0)
tempString = GetString(index);
else
tempString = GetText();
char *temp = hsWStringToString(tempString.c_str());
retVal = temp;
delete [] temp;
return retVal;
}
void ISetValue(const char * value)
{
wchar_t *temp = hsStringToWString(value);
SetCurrent(FindString(temp));
delete [] temp;
}
};
#endif // plComboBox_h_inc

View File

@ -0,0 +1,111 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plControl_h_inc
#define plControl_h_inc
class plControl : public plWindow
{
public:
WNDPROC WindowDefWndProc;
plControl()
{}
plControl( plWindow * ownerWindow, int inId, WNDPROC inSuperProc )
: plWindow( ownerWindow )
{
CHECK(fOwnerWindow);
WindowDefWndProc = inSuperProc;
fControlID = inId ? inId : ownerWindow->fTopControlID++;
fOwnerWindow->fControls.push_back( this );
}
~plControl()
{
CHECK(fOwnerWindow);
std::vector<plControl*>::iterator it = std::find(fOwnerWindow->fControls.begin(),fOwnerWindow->fControls.end(),this);
if (it!=fOwnerWindow->fControls.end())
fOwnerWindow->fControls.erase(it);
}
int CallDefaultProc( unsigned int message, unsigned int wParam, LONG lParam )
{
return CallWindowProc( WindowDefWndProc, Handle(), message, wParam, lParam );
}
static WNDPROC RegisterWindowClass( const wchar_t * name, const wchar_t * winBaseClass )
{
#ifdef UNICODE
WNDPROC superProc=nil;
WNDCLASSEX cls;
HSMemory::ClearMemory( &cls, sizeof(cls) );
cls.cbSize = sizeof(cls);
CHECK( GetClassInfoEx( nil, winBaseClass, &cls ) );
superProc = cls.lpfnWndProc;
cls.lpfnWndProc = plWindow::StaticWndProc;
cls.lpszClassName = name;
cls.hInstance = plWndCtrls::Instance();
CHECK(cls.lpszMenuName==nil);
CHECK(RegisterClassEx( &cls ));
#else
char* cWinBaseClass = hsWStringToString(winBaseClass);
char* cName = hsWStringToString(name);
WNDPROC superProc=nil;
WNDCLASSEX cls;
HSMemory::ClearMemory( &cls, sizeof(cls) );
cls.cbSize = sizeof(cls);
CHECK( GetClassInfoEx( nil, cWinBaseClass, &cls ) );
superProc = cls.lpfnWndProc;
cls.lpfnWndProc = plWindow::StaticWndProc;
cls.lpszClassName = cName;
cls.hInstance = plWndCtrls::Instance();
CHECK(cls.lpszMenuName==nil);
CHECK(RegisterClassEx( &cls ));
delete [] cName;
delete [] cWinBaseClass;
#endif
return superProc;
}
};
#endif // plControl_h_inc

View File

@ -0,0 +1,151 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plDialog_h_inc
#define plDialog_h_inc
class plDialog : public plWindow
{
protected:
DLGTEMPLATE* ILoadDlgTemplate()
{
HRSRC hRsrc = FindResourceEx(plWndCtrls::Instance(), RT_DIALOG, MAKEINTRESOURCE(fControlID), (WORD)(plWndCtrls::GetLanguage()));
HGLOBAL hGlobal = LoadResource(plWndCtrls::Instance(), hRsrc);
LPVOID lpsz = LockResource(hGlobal);
return (DLGTEMPLATE*)lpsz;
}
public:
plDialog()
{}
plDialog( int inDialogId, plWindow * ownerWindow=nil )
: plWindow( ownerWindow )
{
fControlID = inDialogId;
}
int CallDefaultProc( unsigned int message, unsigned int wParam, LONG lParam )
{
return 0;
}
virtual int DoModal()
{
CHECK(Handle()==nil);
_Windows.push_back( this );
_ModalCount++;
int result = 0;
if (plWndCtrls::GetLanguage() != 0)
result = DialogBoxIndirectParam(plWndCtrls::Instance(),ILoadDlgTemplate(),fOwnerWindow?fOwnerWindow->Handle():nil,(int(APIENTRY*)(HWND,unsigned int,WPARAM,LPARAM))StaticWndProc,(LPARAM)this);
else
result = DialogBoxParam(plWndCtrls::Instance(),MAKEINTRESOURCE(fControlID),fOwnerWindow?fOwnerWindow->Handle():nil,(int(APIENTRY*)(HWND,unsigned int,WPARAM,LPARAM))StaticWndProc,(LPARAM)this);
int err = GetLastError();
_ModalCount--;
return result;
}
void OpenWindow(bool visible=true)
{
CHECK(Handle()==nil);
_Windows.push_back( this );
HWND hWndCreated = nil;
if (plWndCtrls::GetLanguage() != 0)
hWndCreated = CreateDialogIndirectParam(plWndCtrls::Instance(),ILoadDlgTemplate(),nil,(int(APIENTRY*)(HWND,unsigned int,WPARAM,LPARAM))StaticWndProc,(LPARAM)this);
else
hWndCreated = CreateDialogParam(plWndCtrls::Instance(),MAKEINTRESOURCE(fControlID),nil,(int(APIENTRY*)(HWND,unsigned int,WPARAM,LPARAM))StaticWndProc,(LPARAM)this);
int err = GetLastError();
CHECK(hWndCreated);
CHECK(hWndCreated==Handle());
Show(visible);
}
void OpenChildWindow( int inControlId, bool visible )
{
CHECK(!Handle());
_Windows.push_back( this );
HWND hWndParent = inControlId ? GetDlgItem(fOwnerWindow->Handle(),inControlId) : fOwnerWindow ? fOwnerWindow->Handle() : nil;
HWND hWndCreated = nil;
if (plWndCtrls::GetLanguage() != 0)
hWndCreated = CreateDialogIndirectParam(plWndCtrls::Instance(),ILoadDlgTemplate(),hWndParent,(int(APIENTRY*)(HWND,unsigned int,WPARAM,LPARAM))StaticWndProc,(LPARAM)this);
else
hWndCreated = CreateDialogParam(plWndCtrls::Instance(),MAKEINTRESOURCE(fControlID),hWndParent,(int(APIENTRY*)(HWND,unsigned int,WPARAM,LPARAM))StaticWndProc,(LPARAM)this);
int err = GetLastError();
CHECK(hWndCreated);
CHECK(hWndCreated==Handle());
Show( visible );
}
virtual void OnInitDialog()
{
plWindow::OnInitDialog();
for( int i=0; i<fControls.size(); i++ )
{
// Bind all child controls.
plControl * control = fControls[i];
CHECK(!control->Handle());
control->Handle() = GetDlgItem( *this, control->fControlID );
CHECK(control->Handle());
_Windows.push_back(control);
control->WindowDefWndProc = (WNDPROC)GetWindowLong( control->Handle(), GWL_WNDPROC );
SetWindowLong( control->Handle(), GWL_WNDPROC, (LONG)plWindow::StaticWndProc );
}
for( int i=0; i<fControls.size(); i++ )
{
// Send create to all controls.
fControls[i]->OnCreate();
}
}
void EndDialog( int result )
{
::EndDialog( Handle(), result );
}
void EndDialogTrue()
{
EndDialog( 1 );
}
void EndDialogFalse()
{
EndDialog( 0 );
}
};
#endif // plDialog_h_inc

View File

@ -0,0 +1,162 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plEdit_h_inc
#define plEdit_h_inc
class plEdit : public plControl
{
private:
bool fRestrictToAlphaNum;
public:
DECLARE_WINDOWSUBCLASS(plEdit,plControl)
plDelegate fChangeDelegate;
plDelegate fKillFocusDelegate;
plEdit()
{fRestrictToAlphaNum = false;}
plEdit( plWindow * inOwner, int inId=0, WNDPROC inSuperProc=nil, bool restrict=false )
: plControl( inOwner, inId, inSuperProc?inSuperProc:_SuperProc ), fRestrictToAlphaNum(restrict)
{}
void OpenWindow( bool visible, bool multiline, bool readOnly )
{
PerformCreateWindowEx
(
WS_EX_CLIENTEDGE,
nil,
WS_CHILD | (visible?WS_VISIBLE:0) | ES_LEFT | (multiline?(ES_MULTILINE|WS_VSCROLL|WS_HSCROLL):0) | ES_AUTOVSCROLL | ES_AUTOHSCROLL | (readOnly?ES_READONLY:0),
0, 0,
0, 0,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
SendMessage( *this, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(0,0) );
}
bool InterceptControlCommand( unsigned int message, unsigned int wParam, LONG lParam )
{
if (HIWORD(wParam)==EN_CHANGE)
{
fChangeDelegate();
return 1;
}
else if(HIWORD(wParam)==EN_KILLFOCUS)
{
fKillFocusDelegate();
return 1;
}
else
return 0;
}
virtual LONG OnChar( char ch )
{
if (fRestrictToAlphaNum)
{
// we only accept 0-9, a-z, A-Z, or backspace
if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'z') && (ch < 'A' || ch >'Z') && !(ch == VK_BACK))
{
MessageBeep(-1); // alert the user
return FALSE; // and make sure the default handler doesn't get it
}
}
return TRUE;
}
bool GetReadOnly()
{
CHECK(Handle());
return (GetWindowLong( *this, GWL_STYLE )&ES_READONLY)!=0;
}
void SetReadOnly( bool readOnly )
{
CHECK(Handle());
SendMessage( *this, EM_SETREADONLY, readOnly, 0 );
}
int GetLineCount()
{
CHECK(Handle());
return SendMessage( *this, EM_GETLINECOUNT, 0, 0 );
}
int GetLineIndex( int line )
{
CHECK(Handle());
return SendMessage( *this, EM_LINEINDEX, line, 0 );
}
void GetSelection( int& start, int& end )
{
CHECK(Handle());
SendMessage( *this, EM_GETSEL, (WPARAM)&start, (LPARAM)&end );
}
void SetSelection( int start, int end )
{
CHECK(Handle());
SendMessage( *this, EM_SETSEL, start, end );
}
void SetSelectedText( const wchar_t * text )
{
CHECK(Handle());
SendMessage( *this, EM_REPLACESEL, 1, (LPARAM)text );
}
void SetLimitText( int maxChars )
{
CHECK(Handle());
SendMessage( *this, EM_SETLIMITTEXT, maxChars, 0 );
}
bool GetModify()
{
return SendMessage( *this, EM_GETMODIFY, 0, 0 )!=0;
}
void SetModify( bool modified )
{
SendMessage( *this, EM_SETMODIFY, modified, 0 );
}
void ScrollCaret()
{
SendMessage( *this, EM_SCROLLCARET, 0, 0 );
}
};
#endif // plEdit_h_inc

View File

@ -0,0 +1,75 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plLabel_h_inc
#define plLabel_h_inc
class plLabel : public plControl
{
public:
DECLARE_WINDOWSUBCLASS(plLabel,plControl)
plLabel()
{}
plLabel( plWindow * inOwner, int inId=0, WNDPROC inSuperProc=nil )
: plControl( inOwner, inId, inSuperProc?inSuperProc:_SuperProc )
{}
void OpenWindow( bool visible )
{
PerformCreateWindowEx
(
WS_EX_CLIENTEDGE,
nil,
WS_CHILD | (visible?WS_VISIBLE:0),
0, 0,
0, 0,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
SendMessage( *this, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(0,0) );
}
};
#endif // plLabel_h_inc

View File

@ -0,0 +1,252 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plListBox_h_inc
#define plListBox_h_inc
class plListBox : public plControl
{
public:
DECLARE_WINDOWSUBCLASS(plListBox,plControl)
plDelegate DoubleClickDelegate;
plDelegate SelectionChangeDelegate;
plDelegate SelectionCancelDelegate;
plDelegate SetFocusDelegate;
plDelegate KillFocusDelegate;
plListBox()
{}
plListBox( plWindow * inOwner, int inId=0, WNDPROC inSuperProc=nil )
: plControl( inOwner, inId, inSuperProc?inSuperProc:_SuperProc )
{
CHECK(fOwnerWindow);
}
void OpenWindow( bool visible, bool integral, bool multiSel, bool ownerDrawVariable )
{
PerformCreateWindowEx
(
WS_EX_CLIENTEDGE,
nil,
WS_CHILD | WS_BORDER | WS_VSCROLL | WS_CLIPCHILDREN | LBS_NOTIFY | (visible?WS_VISIBLE:0) | (integral?0:LBS_NOINTEGRALHEIGHT) | (multiSel?(LBS_EXTENDEDSEL|LBS_MULTIPLESEL):0) | (ownerDrawVariable?LBS_OWNERDRAWVARIABLE:0),
0, 0,
0, 0,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
SendMessage( *this, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(0,0) );
}
bool InterceptControlCommand( unsigned int message, unsigned int wParam, LONG lParam )
{
if ( HIWORD(wParam)==LBN_DBLCLK ) {DoubleClickDelegate(); return 1;}
else if( HIWORD(wParam)==LBN_SELCHANGE) {SelectionChangeDelegate(); return 1;}
else if( HIWORD(wParam)==LBN_SELCANCEL) {SelectionCancelDelegate(); return 1;}
else if( HIWORD(wParam)==LBN_SETFOCUS) {SetFocusDelegate(); return 1;}
else if( HIWORD(wParam)==LBN_KILLFOCUS) {KillFocusDelegate(); return 1;}
else return 0;
}
std::wstring GetString( int index ) const
{
int length = SendMessage(*this,LB_GETTEXTLEN,index,0);
if (length == LB_ERR)
return L"";
std::wstring ch;
ch.resize(length);
length = SendMessage( *this, LB_GETTEXT, index, (LPARAM)ch.data() );
ch.resize(length);
return ch;
}
void * GetItemData( int index )
{
return (void*)SendMessage( *this, LB_GETITEMDATA, index, 0 );
}
void SetItemData( int index, void * value )
{
SendMessage( *this, LB_SETITEMDATA, index, (LPARAM)value );
}
int GetCurrent() const
{
return SendMessage( *this, LB_GETCARETINDEX, 0, 0 );
}
void SetCurrent( int index, bool bScrollIntoView )
{
SendMessage( *this, LB_SETCURSEL, index, 0 );
SendMessage( *this, LB_SETCARETINDEX, index, bScrollIntoView );
}
int GetTop()
{
return SendMessage( *this, LB_GETTOPINDEX, 0, 0 );
}
void SetTop( int index )
{
SendMessage( *this, LB_SETTOPINDEX, index, 0 );
}
void DeleteString( int index )
{
SendMessage( *this, LB_DELETESTRING, index, 0 );
}
int GetCount()
{
return SendMessage( *this, LB_GETCOUNT, 0, 0 );
}
int GetItemHeight( int index )
{
return SendMessage( *this, LB_GETITEMHEIGHT, index, 0 );
}
int ItemFromPoint( const plPoint & P )
{
DWORD result=SendMessage( *this, LB_ITEMFROMPOINT, 0, MAKELPARAM(P.X,P.Y) );
return HIWORD(result) ? -1 : LOWORD(result);
}
plRect GetItemRect( int index )
{
RECT R; R.left=R.right=R.top=R.bottom=0;
SendMessage( *this, LB_GETITEMRECT, index, (LPARAM)&R );
return R;
}
void Empty()
{
SendMessage( *this, LB_RESETCONTENT, 0, 0 );
}
bool GetSelected( int index )
{
return SendMessage( *this, LB_GETSEL, index, 0 )?true:false;
}
int AddString( const wchar_t * C )
{
return SendMessage( *this, LB_ADDSTRING, 0, (LPARAM)C );
}
void AddStrings( std::vector<std::wstring> & strings )
{
for (int i=0; i<strings.size(); i++)
SendMessage( *this, LB_ADDSTRING, 0, (LPARAM)strings[i].c_str() );
}
void InsertString( int index, const wchar_t * C )
{
SendMessage( *this, LB_INSERTSTRING, index, (LPARAM)C );
}
int FindString( const wchar_t * C )
{
return SendMessage( *this, LB_FINDSTRING, -1, (LPARAM)C );
}
int FindStringExact( const wchar_t * C )
{
return SendMessage( *this, LB_FINDSTRINGEXACT, -1, (LPARAM)C );
}
int FindStringChecked( const wchar_t * C )
{
int result = SendMessage( *this, LB_FINDSTRING, -1, (LPARAM)C );
CHECK(result!=LB_ERR);
return result;
}
int FindStringExactChecked( const wchar_t * C )
{
int result = SendMessage( *this, LB_FINDSTRINGEXACT, -1, (LPARAM)C );
CHECK(result!=LB_ERR);
return result;
}
void InsertStringAfter( const wchar_t * existing, const wchar_t * str )
{
InsertString( FindStringChecked(existing)+1, str );
}
int AddItem( const void * C )
{
return SendMessage( *this, LB_ADDSTRING, 0, (LPARAM)C );
}
void InsertItem( int index, const void * C )
{
SendMessage( *this, LB_INSERTSTRING, index, (LPARAM)C );
}
int FindItem( const void * C, int fromIdx=-1 )
{
return SendMessage( *this, LB_FINDSTRING, fromIdx, (LPARAM)C );
}
int FindItemExact( const void * C, int fromIdx=-1 )
{
return SendMessage( *this, LB_FINDSTRINGEXACT, fromIdx, (LPARAM)C );
}
int FindItemChecked( const void * C, int fromIdx=-1 )
{
int result = SendMessage( *this, LB_FINDSTRING, fromIdx, (LPARAM)C );
CHECK(result!=LB_ERR);
return result;
}
int FindItemExactChecked( const void * C, int fromIdx=-1 )
{
int result = SendMessage( *this, LB_FINDSTRINGEXACT, fromIdx, (LPARAM)C );
CHECK(result!=LB_ERR);
return result;
}
void InsertItemAfter( const void * existing, const void * str )
{
InsertItem( FindItemChecked(existing)+1, str );
}
std::string IGetValue() const
{
std::string retVal = "";
std::wstring tempString = L"";
int index = GetCurrent();
if (index>=0)
tempString = GetString(index);
else
tempString = GetText();
char *temp = hsWStringToString(tempString.c_str());
retVal = temp;
delete [] temp;
return retVal;
}
void ISetValue(const char * value)
{
wchar_t *temp = hsStringToWString(value);
SetCurrent(FindString(temp), true);
delete [] temp;
}
};
#endif // plListBox_h_inc

View File

@ -0,0 +1,106 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plProgressBar_h_inc
#define plProgressBar_h_inc
class plProgressBar : public plControl
{
public:
DECLARE_WINDOWSUBCLASS(plProgressBar,plControl)
int fPercent;
int fMax;
plProgressBar()
{}
plProgressBar( plWindow * inOwner, int inId=0, WNDPROC inSuperProc=nil )
: plControl( inOwner, inId, inSuperProc?inSuperProc:_SuperProc )
, fPercent( 0 )
, fMax( 100 )
{}
void OpenWindow( bool Visible )
{
PerformCreateWindowEx
(
WS_EX_CLIENTEDGE,
nil,
WS_CHILD | (Visible?WS_VISIBLE:0),
0, 0,
0, 0,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
SendMessage( *this, PBM_SETRANGE, 0, 100 );
}
void SetMax(int inMax)
{
fMax = inMax;
}
void SetProgress( int inCurrent )
{
int inPercent = (int)((float(inCurrent)/float(Max(fMax,1)))*100.f);
if( inPercent!=fPercent )
SendMessage( *this, PBM_SETPOS, inPercent, 0 );
fPercent = inPercent;
}
int GetProgress() const
{
int value = SendMessage( *this, PBM_GETPOS, 0, 0 );
return value;
}
std::string IGetValue() const
{
char tmp[20];
sprintf(tmp,"%d",GetProgress());
return tmp;
}
void ISetValue(const char * value)
{
SetProgress(atoi(value));
}
};
#endif // plProgressBar_h_inc

View File

@ -0,0 +1,97 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plRadioButton_h_inc
#define plRadioButton_h_inc
class plRadioButton : public plButton
{
DECLARE_WINDOWSUBCLASS(plRadioButton,plButton)
plRadioButton()
{}
plRadioButton( plWindow * inOwner, int inId=0, plDelegate inClicked=plDelegate(), WNDPROC inSuperProc=nil )
: plButton( inOwner, inId, inClicked, inSuperProc?inSuperProc:_SuperProc )
{}
void OpenWindow( bool visible, int X, int Y, int XL, int YL, const wchar_t * text )
{
PerformCreateWindowEx
(
0,
nil,
WS_CHILD|BS_RADIOBUTTON,
X, Y,
XL, YL,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
SendMessage( *this, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(0,0) );
SetText( text );
if( visible )
ShowWindow( *this, SW_SHOWNOACTIVATE );
}
void Check(bool check=true)
{
SendMessage(*this,BM_SETCHECK,(check)?BST_CHECKED:BST_UNCHECKED,0);
}
bool IsChecked() const
{
return (SendMessage(*this,BM_GETCHECK,0,0)==BST_CHECKED);
}
std::string IGetValue() const
{
char tmp[20];
sprintf(tmp,"%s",IsChecked()?"true":"false");
return tmp;
}
void ISetValue(const char * value)
{
if (stricmp(value,"true")==0)
Check(true);
else if (stricmp(value,"false")==0)
Check(false);
else
Check(atoi(value)?true:false);
}
};
#endif // plRadioButton_h_inc

View File

@ -0,0 +1,84 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plStatusBar_h_inc
#define plStatusBar_h_inc
class plStatusBar : public plControl
{
public:
DECLARE_WINDOWSUBCLASS(plStatusBar,plControl)
plStatusBar()
{}
plStatusBar( plWindow * inOwner, int inId=0, WNDPROC inSuperProc=nil )
: plControl( inOwner, inId, inSuperProc?inSuperProc:_SuperProc )
{}
void OpenWindow( plWindow * inOwner, bool Visible )
{
if (inOwner)
{
if (fOwnerWindow)
{
std::vector<plControl*>::iterator it = std::find(fOwnerWindow->fControls.begin(),fOwnerWindow->fControls.end(),this);
if (it!=fOwnerWindow->fControls.end())
fOwnerWindow->fControls.erase(it);
}
fOwnerWindow = inOwner;
fOwnerWindow->fControls.push_back( this );
}
CHECK(fOwnerWindow);
LONG style = WS_CHILD|WS_BORDER;
if (Visible)
style |= WS_VISIBLE;
#if UNICODE
fhWnd = CreateStatusWindow(style,
L"",*fOwnerWindow,fControlID);
#else
fhWnd = CreateStatusWindow(style,
"",*fOwnerWindow,fControlID);
#endif
}
};
#endif // plStatusBar_h_inc

View File

@ -0,0 +1,118 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plTrackBar_h_inc
#define plTrackBar_h_inc
class plTrackBar : public plControl
{
public:
DECLARE_WINDOWSUBCLASS(plTrackBar,plControl)
plDelegate fThumbTrackDelegate;
plDelegate fThumbPositionDelegate;
plTrackBar()
{}
plTrackBar( plWindow * inOwner, int inId=0, WNDPROC inSuperProc=nil )
: plControl( inOwner, inId, inSuperProc?inSuperProc:_SuperProc )
{}
void OpenWindow( bool Visible )
{
PerformCreateWindowEx
(
WS_EX_CLIENTEDGE,
nil,
WS_CHILD | TBS_HORZ | TBS_AUTOTICKS | TBS_BOTTOM | (Visible?WS_VISIBLE:0),
0, 0,
0, 0,
*fOwnerWindow,
(HMENU)fControlID,
plWndCtrls::Instance()
);
}
bool InterceptControlCommand( unsigned int Message, unsigned int wParam, LONG lParam )
{
if ( Message==WM_HSCROLL && LOWORD(wParam)==TB_THUMBTRACK ) {fThumbTrackDelegate(); return 1;}
else if( Message==WM_HSCROLL ) {fThumbPositionDelegate(); return 1;}
else return 0;
}
void SetTicFreq( int TicFreq )
{
SendMessage( *this, TBM_SETTICFREQ, TicFreq, 0 );
}
void SetRange( int Min, int Max )
{
SendMessage( *this, TBM_SETRANGE, 1, MAKELONG(Min,Max) );
}
void SetPos( int Pos )
{
SendMessage( *this, TBM_SETPOS, 1, Pos );
}
int GetRangeMin()
{
return SendMessage(*this, TBM_GETRANGEMIN, 0, 0);
}
int GetRangeMax()
{
return SendMessage(*this, TBM_GETRANGEMAX, 0, 0);
}
int GetPos() const
{
return SendMessage( *this, TBM_GETPOS, 0, 0 );
}
std::string IGetValue() const
{
char tmp[20];
sprintf(tmp,"%d",GetPos());
return tmp;
}
void ISetValue(const char * value)
{
SetPos(atoi(value));
}
};
#endif // plTrackBar_h_inc

View File

@ -0,0 +1,677 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plWindow_h_inc
#define plWindow_h_inc
class plControl;
#include <strstream>
class plWindow
: public plClass // plClass _must_ be the first base class in list.
, public plConfigValueBase
{
public:
HWND fhWnd;
WORD fControlID;
WORD fTopControlID;
bool fDestroyed;
bool fMdiChild;
plWindow * fOwnerWindow;
std::vector<plControl*> fControls;
HWND & Handle() { return fhWnd;}
const HWND & Handle() const { return fhWnd;}
bool fEdited;
static int _ModalCount;
static std::vector<plWindow*> _Windows;
static std::vector<plWindow*> _DeleteWindows;
static LONG APIENTRY StaticWndProc(HWND hWnd, unsigned int message, unsigned int wParam, LONG lParam )
{
// look for this hwnd in window list
int i;
for(i=0; i<_Windows.size(); i++ )
if( _Windows[i]->Handle()==hWnd )
break;
if (i==_Windows.size())
{
// hsStatusMessage("hwnd not found in _Windows.\n");
}
// if window not found and this is WM_NCCREATE or WM_INITDIALOG msg...
if( i==_Windows.size() && (message==WM_NCCREATE || message==WM_INITDIALOG || message==WM_ACTIVATE) )
{
// get the plWindow object
plWindow * WindowCreate
= message!=WM_NCCREATE
? (plWindow*)lParam
: (GetWindowLong(hWnd,GWL_EXSTYLE) & WS_EX_MDICHILD)
? (plWindow*)((MDICREATESTRUCT*)((CREATESTRUCT*)lParam)->lpCreateParams)->lParam
: (plWindow*)((CREATESTRUCT*)lParam)->lpCreateParams;
CHECK(WindowCreate);
CHECK(!WindowCreate->Handle());
// set the hwnd for this plWindow
WindowCreate->Handle() = hWnd;
// look for this plWindow in window list
for( i=0; i<_Windows.size(); i++ )
if( _Windows[i]==WindowCreate )
break;
if (i==_Windows.size())
{
hsStatusMessage("plWindow not found in _Windows.\n");
}
CHECK(i<_Windows.size());
}
// if window not found and message is not WM_NCCREATE or WM_INITDIALOG msg...
if( i==_Windows.size() )
{
// Gets through before WM_NCCREATE: WM_GETMINMAXINFO
return DefWindowProc( hWnd, message, wParam, lParam );
}
else
{
// call the plWindow class's message handler
return _Windows[i]->WndProc( message, wParam, lParam );
}
}
static WNDPROC RegisterWindowClass( const wchar_t * name, DWORD style, int iconId=0 )
{
#ifdef UNICODE
WNDCLASSEX cls;
HSMemory::ClearMemory( &cls, sizeof(cls) );
cls.cbSize = sizeof(cls);
cls.style = style;
cls.lpfnWndProc = StaticWndProc;
cls.hInstance = plWndCtrls::Instance();
cls.hIcon = LoadIcon(plWndCtrls::Instance(),MAKEINTRESOURCE(iconId));
cls.lpszClassName = name;
cls.hIconSm = LoadIcon(plWndCtrls::Instance(),MAKEINTRESOURCE(iconId));
CHECK(RegisterClassEx( &cls ));
#else
char *cName = hsWStringToString(name);
WNDCLASSEX cls;
HSMemory::ClearMemory( &cls, sizeof(cls) );
cls.cbSize = sizeof(cls);
cls.style = style;
cls.lpfnWndProc = StaticWndProc;
cls.hInstance = plWndCtrls::Instance();
cls.hIcon = LoadIcon(plWndCtrls::Instance(),MAKEINTRESOURCE(iconId));
cls.lpszClassName = cName;
cls.hIconSm = LoadIcon(plWndCtrls::Instance(),MAKEINTRESOURCE(iconId));
CHECK(RegisterClassEx( &cls ));
delete [] cName;
#endif
return nil;
}
plWindow( plWindow * ownerWindow=nil )
: fhWnd (nil)
, fControlID (0)
, fTopControlID (FIRST_AUTO_CONTROL)
, fDestroyed (0)
, fMdiChild (0)
, fOwnerWindow (ownerWindow)
, fEdited (false)
{
fReadEvaluate = plEvaluate(this,(TEvaluate)HasConfigName);
fWriteEvaluate = plEvaluate(this,(TEvaluate)HasConfigName);
}
virtual ~plWindow()
{
MaybeDestroy();
std::vector<plWindow*>::iterator it = std::find(_DeleteWindows.begin(),_DeleteWindows.end(),this);
if (it!=_DeleteWindows.end())
_DeleteWindows.erase(it);
}
plRect GetClientRect() const
{
RECT R;
::GetClientRect( Handle(), &R );
return plRect( R );
}
plRect GetUpdateRect(bool erase) const
{
RECT R;
::GetUpdateRect(*this,&R,erase);
return plRect(R);
}
void MoveWindow( plRect R, bool bRepaint )
{
::MoveWindow( Handle(), R.Min.X, R.Min.Y, R.Width(), R.Height(), bRepaint );
}
plRect GetWindowRect() const
{
RECT R;
::GetWindowRect( Handle(), &R );
return fOwnerWindow ? fOwnerWindow->ScreenToClient(R) : plRect(R);
}
plPoint ClientToScreen( const plPoint& inP )
{
POINT P;
P.x = inP.X;
P.y = inP.Y;
::ClientToScreen( Handle(), &P );
return plPoint( P.x, P.y );
}
plPoint ScreenToClient( const plPoint& inP )
{
POINT P;
P.x = inP.X;
P.y = inP.Y;
::ScreenToClient( Handle(), &P );
return plPoint( P.x, P.y );
}
plRect ClientToScreen( const plRect& inR )
{
return plRect( ClientToScreen(inR.Min), ClientToScreen(inR.Max) );
}
plRect ScreenToClient( const plRect& inR )
{
return plRect( ScreenToClient(inR.Min), ScreenToClient(inR.Max) );
}
plPoint GetCursorPos()
{
plPoint mouse;
::GetCursorPos( mouse );
return ScreenToClient( mouse );
}
void Show( bool show = true )
{
ShowWindow( Handle(), show ? SW_SHOW : SW_HIDE );
}
void ShowHow( int how )
{
ShowWindow( Handle(), how );
}
void Hide()
{
Show(false);
}
bool IsVisible()
{
return ::IsWindowVisible(*this)?true:false;
}
virtual void DoDestroy()
{
if( Handle() )
DestroyWindow( *this );
std::vector<plWindow*>::iterator it = std::find(_Windows.begin(),_Windows.end(),this);
if (it!=_Windows.end())
_Windows.erase(it);
}
virtual void GetWindowClassName( wchar_t * result )=0;
virtual LONG WndProc( unsigned int message, unsigned int wParam, LONG lParam )
{
try
{
if( message==WM_DESTROY )
{
OnDestroy();
}
else if( message==WM_DRAWITEM )
{
DRAWITEMSTRUCT * Info = (DRAWITEMSTRUCT*)lParam;
for( int i=0; i<fControls.size(); i++ )
if( ((plWindow*)fControls[i])->Handle()==Info->hwndItem )
{((plWindow*)fControls[i])->OnDrawItem(Info); break;}
return 1;
}
else if( message==WM_MEASUREITEM )
{
MEASUREITEMSTRUCT * Info = (MEASUREITEMSTRUCT*)lParam;
for( int i=0; i<fControls.size(); i++ )
if( ((plWindow*)fControls[i])->fControlID==Info->CtlID )
{((plWindow*)fControls[i])->OnMeasureItem(Info); break;}
return 1;
}
else if ( message==WM_NOTIFY )
{
OnNotify((int)wParam,(LPNMHDR)lParam);
}
else if( message==WM_CLOSE )
{
OnClose();
}
else if( message==WM_CHAR )
{
if (!OnChar( wParam )) // give the control a chance to filter input
return FALSE;
}
else if( message==WM_KEYDOWN )
{
OnKeyDown( wParam );
}
else if( message==WM_KEYUP )
{
OnKeyUp( wParam );
}
else if( message==WM_PAINT )
{
OnPaint();
}
else if( message==WM_CREATE )
{
OnCreate();
}
else if( message==WM_TIMER )
{
OnTimer( (int)wParam );
}
else if( message==WM_INITDIALOG )
{
OnInitDialog();
}
else if( message==WM_SETFOCUS )
{
OnSetFocus( (HWND)wParam );
}
else if( message==WM_ACTIVATE )
{
OnActivate( LOWORD(wParam)!=0 );
}
else if( message==WM_KILLFOCUS )
{
OnKillFocus( (HWND)wParam );
}
else if( message==WM_SIZE )
{
OnSize( wParam, LOWORD(lParam), HIWORD(lParam) );
}
else if( message==WM_PASTE )
{
OnPaste();
}
else if( message==WM_SHOWWINDOW )
{
OnShowWindow( wParam?true:false );
}
else if( message==WM_COPYDATA )
{
OnCopyData( (HWND)wParam, (COPYDATASTRUCT*)lParam );
}
else if( message==WM_CAPTURECHANGED )
{
OnReleaseCapture();
}
else if( message==WM_MDIACTIVATE )
{
OnMdiActivate( (HWND)lParam==Handle());
}
else if( message==WM_MOUSEMOVE )
{
OnMouseMove( wParam, plPoint(LOWORD(lParam), HIWORD(lParam)) );
}
else if( message==WM_LBUTTONDOWN )
{
OnLeftButtonDown();
}
else if( message==WM_RBUTTONDOWN )
{
OnRightButtonDown();
}
else if( message==WM_LBUTTONUP )
{
OnLeftButtonUp();
}
else if( message==WM_RBUTTONUP )
{
OnRightButtonUp();
}
else if( message==WM_CUT )
{
OnCut();
}
else if( message==WM_COPY )
{
OnCopy();
}
else if( message==WM_UNDO )
{
OnUndo();
}
else if( message==WM_SETCURSOR )
{
if( OnSetCursor() )
return 1;
}
else if( message==WM_COMMAND || message==WM_HSCROLL || message==WM_VSCROLL )
{
for( int i=0; i<fControls.size(); i++ )
if
( (HWND)lParam==((plWindow*)fControls[i])->Handle()
&& ((plWindow*)fControls[i])->InterceptControlCommand(message,wParam,lParam) )
return 1;
OnCommand( wParam );
}
else if ( message==WM_SYSCOMMAND )
{
OnSysCommand( wParam );
}
return CallDefaultProc( message, wParam, lParam );
}
catch( const char * e )
{
hsStatusMessage( e );
hsStatusMessage("\n");
return 0;
}
}
virtual int CallDefaultProc( unsigned int message, unsigned int wParam, LONG lParam )
{
if( fMdiChild )
return DefMDIChildProc( Handle(), message, wParam, lParam );
else
return DefWindowProc( Handle(), message, wParam, lParam );
}
virtual bool InterceptControlCommand( unsigned int message, unsigned int wParam, LONG lParam )
{
return 0;
}
virtual std::wstring GetText() const
{
CHECK(Handle());
int length = GetLength();
std::wstring result;
if (length==0)
return result;
result.resize(length);
SendMessage( *this, WM_GETTEXT, length+1, (LPARAM)result.data() );
return result;
}
virtual void SetText( const wchar_t * text )
{
CHECK(Handle());
SendMessage( *this, WM_SETTEXT, 0, (LPARAM)text );
}
virtual void SetTextF( const wchar_t * fmt, ... )
{
va_list args;
va_start( args, fmt );
SetTextV( fmt, args );
va_end( args );
}
virtual void SetTextV( const wchar_t * fmt, va_list args )
{
std::wstring s;
xtl::formatv( s, fmt, args );
SetText( s.c_str() );
}
virtual void SetEnabled(bool enabled)
{
CHECK(Handle());
EnableWindow(*this,enabled);
}
virtual bool IsEnabled()
{
return IsWindowEnabled(*this)?true:false;
}
virtual int GetLength() const
{
CHECK(Handle());
return SendMessage( *this, WM_GETTEXTLENGTH, 0, 0 );
}
virtual void SetFocus()
{
::SetFocus(*this);
}
virtual void Activate()
{
::SetActiveWindow(*this);
}
// plWindow notifications.
virtual void OnNotify( int idCtrl, LPNMHDR pnmh )
{}
virtual void OnCopyData( HWND hWndSender, COPYDATASTRUCT * CD )
{}
virtual void OnSetFocus( HWND hWndLosingFocus )
{}
virtual void OnKillFocus( HWND hWndGainingFocus )
{}
virtual void OnSize( DWORD flags, int newX, int newY )
{}
virtual void OnCommand( int command )
{}
virtual void OnSysCommand( int command )
{}
virtual void OnActivate( bool active )
{}
virtual LONG OnChar( char ch ) // Return TRUE if you want to let the default handler grab it, FALSE if you don't
{return TRUE;}
virtual void OnKeyDown( UInt16 ch )
{}
virtual void OnKeyUp( UInt16 ch )
{}
virtual void OnCut()
{}
virtual void OnCopy()
{}
virtual void OnPaste()
{}
virtual void OnShowWindow( bool bShow )
{}
virtual void OnUndo()
{}
virtual void OnPaint()
{}
virtual void OnCreate()
{}
virtual void OnDrawItem( DRAWITEMSTRUCT * info )
{}
virtual void OnMeasureItem( MEASUREITEMSTRUCT * info )
{}
virtual void OnInitDialog()
{}
virtual void OnMouseEnter()
{}
virtual void OnMouseLeave()
{}
virtual void OnMouseHover()
{}
virtual void OnTimer( int timer )
{}
virtual void OnReleaseCapture()
{}
virtual void OnMdiActivate( bool active )
{}
virtual void OnMouseMove( DWORD flags, plPoint location )
{}
virtual void OnLeftButtonDown()
{}
virtual void OnRightButtonDown()
{}
virtual void OnLeftButtonUp()
{}
virtual void OnRightButtonUp()
{}
virtual int OnSetCursor()
{
return 0;
}
virtual void OnClose()
{
DestroyWindow( *this );
}
virtual void OnDestroy()
{
CHECK(Handle());
std::vector<plWindow*>::iterator it = std::find(_Windows.begin(),_Windows.end(),this);
if (it!=_Windows.end())
_Windows.erase(it);
Handle() = nil;
}
// plWindow functions.
void MaybeDestroy()
{
if( !fDestroyed )
{
fDestroyed=1;
DoDestroy();
}
}
void _CloseWindow()
{
CHECK(Handle());
DestroyWindow( *this );
}
operator HWND() const
{
return Handle();
}
void SetFont( HFONT hFont )
{
SendMessage( *this, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(0,0) );
}
void SetSmallIcon( HICON hIcon )
{
SendMessage( *this, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
}
void SetBigIcon( HICON hIcon )
{
SendMessage( *this, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
}
void PerformCreateWindowEx(
DWORD dwExStyle,
LPCTSTR lpWindowName,
DWORD dwStyle,
int x, int y,
int nWidth, int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance)
{
CHECK(Handle()==nil);
_Windows.push_back( this );
wchar_t className[256];
GetWindowClassName( className );
#ifdef UNICODE
HWND hWndCreated = CreateWindowEx(
dwExStyle,
className,
lpWindowName,
dwStyle,x,y,
nWidth,nHeight,
hWndParent,hMenu,
plWndCtrls::Instance(),
this);
#else
char *cClassName = hsWStringToString(className);
HWND hWndCreated = CreateWindowEx(
dwExStyle,
cClassName,
lpWindowName,
dwStyle,x,y,
nWidth,nHeight,
hWndParent,hMenu,
plWndCtrls::Instance(),
this);
delete [] cClassName;
#endif
/*
#define SAFE(s) ((s)?s:"null")
std::strstream str;
str
<< "vars: " << std::endl
<< dwExStyle << std::endl
<< SAFE(className) << std::endl
<< SAFE(lpWindowName) << std::endl
<< dwStyle << std::endl
<< x << std::endl
<< y << std::endl
<< nWidth << std::endl
<< nHeight << std::endl
<< hWndParent << std::endl
<< hMenu << std::endl
<< plWndCtrls::Instance() << std::endl
<< '\0';
MessageBox(nil,str.str(),"",MB_OK);
str.freeze(false);
*/
if( !hWndCreated )
hsStatusMessage( "CreateWindowEx failed" );
CHECK(hWndCreated);
CHECK(hWndCreated==Handle());
}
void SetRedraw( bool redraw )
{
SendMessage( *this, WM_SETREDRAW, redraw, 0 );
}
// plConfigValueBase
std::string IGetValue() const
{
std::string sText = "";
char *temp = hsWStringToString(GetText().c_str());
sText = temp;
delete [] temp;
return sText;
}
void ISetValue(const char * value)
{
wchar_t *wValue = hsStringToWString(value);
SetText(wValue);
delete [] wValue;
}
virtual void SetEdited(bool value)
{
fEdited = value;
}
virtual bool Edited() const
{
return fEdited;
}
};
#endif plWindow_h_inc

View File

@ -0,0 +1,107 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "plWndCtrls.h"
#include "basewnd.h"
#if HS_BUILD_FOR_WIN32
////////////////////////////////////////////////////////////////////
int plWindow::_ModalCount = 0;
std::vector<plWindow*> plWindow::_Windows;
std::vector<plWindow*> plWindow::_DeleteWindows;
////////////////////////////////////////////////////////////////////
WNDPROC plButton::_SuperProc = nil;
WNDPROC plCheckBox::_SuperProc = nil;
WNDPROC plRadioButton::_SuperProc = nil;
WNDPROC plEdit::_SuperProc = nil;
WNDPROC plLabel::_SuperProc = nil;
WNDPROC plProgressBar::_SuperProc = nil;
WNDPROC plTrackBar::_SuperProc = nil;
WNDPROC plComboBox::_SuperProc = nil;
WNDPROC plListBox::_SuperProc = nil;
WNDPROC plStatusBar::_SuperProc = nil;
////////////////////////////////////////////////////////////////////
HINSTANCE plWndCtrls::hInstance = nil;
DWORD plWndCtrls::fLanguage = 0;
////////////////////////////////////////////////////////////////////
void plWndCtrls::Init(HINSTANCE hInst)
{
hInstance = hInst;
CoInitialize(NULL);
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
REGISTER_WINDOWSUBCLASS(plEdit,L"EDIT");
REGISTER_WINDOWSUBCLASS(plButton,L"BUTTON");
REGISTER_WINDOWSUBCLASS(plCheckBox,L"BUTTON");
REGISTER_WINDOWSUBCLASS(plRadioButton,L"BUTTON");
REGISTER_WINDOWSUBCLASS(plLabel,L"STATIC");
REGISTER_WINDOWSUBCLASS(plComboBox,L"COMBOBOX");
REGISTER_WINDOWSUBCLASS(plListBox,L"LISTBOX");
REGISTER_WINDOWSUBCLASS(plTrackBar,TRACKBAR_CLASS);
REGISTER_WINDOWSUBCLASS(plProgressBar,PROGRESS_CLASS);
REGISTER_WINDOWSUBCLASS(plStatusBar,STATUSCLASSNAME);
basewnd::Initialize( hInst );
}
void plWndCtrls::Shutdown()
{
CoUninitialize();
}
////////////////////////////////////////////////////////////////////
#endif // HS_BUILD_FOR_WIN32

View File

@ -0,0 +1,323 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plWndCtrls_h_inc
#define plWndCtrls_h_inc
#include "hsConfig.h"
#if HS_BUILD_FOR_WIN32
#include "hsUtils.h"
#include "hsMemory.h"
#include "../plContainer/plConfigInfo.h"
#include <windows.h>
#include <commctrl.h>
#include <string>
#include <vector>
#include <algorithm>
////////////////////////////////////////////////////////////////////
class plWndCtrls
{
public:
static void Init(HINSTANCE hInst);
static void Shutdown();
static HINSTANCE Instance() { return hInstance;}
static void MakeWndClassName(wchar_t * result, const wchar_t * base)
{
swprintf(result, L"Plasma_%s", base);
}
static void SetLanguage(DWORD lang) { fLanguage = lang; }
static DWORD GetLanguage() { return fLanguage; }
private:
static HINSTANCE hInstance;
static DWORD fLanguage;
plWndCtrls();
plWndCtrls & operator=(const plWndCtrls &);
};
////////////////////////////////////////////////////////////////////
#define CHECK(c) hsAssert(c,#c)
#define N_ELEMENTS(a) ( sizeof(a) / sizeof((a)[0]) )
template<class T> inline T Max(const T & A, const T & B){return (A>=B)?A:B;}
template<class T> inline T Min(const T & A, const T & B){return (A<=B)?A:B;}
////////////////////////////////////////////////////////////////////
// Window class definition macros.
#define DECLARE_WINDOWCLASS(cls,parentcls) \
public: \
void GetWindowClassName( wchar_t * result ) {plWndCtrls::MakeWndClassName(result,L#cls);}
#define DECLARE_WINDOWSUBCLASS(cls,parentcls) \
DECLARE_WINDOWCLASS(cls,parentcls) \
static WNDPROC _SuperProc;
#define REGISTER_WINDOWCLASS(cls,clsf) \
{wchar_t Temp[256]; plWndCtrls::MakeWndClassName(Temp,L#cls); cls::RegisterWindowClass( Temp, clsf );}
#define REGISTER_WINDOWCLASSWITHICON(cls,clsf,iconid) \
{wchar_t Temp[256]; plWndCtrls::MakeWndClassName(Temp,L#cls); cls::RegisterWindowClass( Temp, clsf, iconid );}
#define REGISTER_WINDOWSUBCLASS(cls,wincls) \
{wchar_t Temp[256]; plWndCtrls::MakeWndClassName(Temp,L#cls); cls::_SuperProc = cls::RegisterWindowClass( Temp, wincls );}
#define FIRST_AUTO_CONTROL 8192
////////////////////////////////////////////////////////////////////
struct plPoint
{
int X, Y;
plPoint()
{}
plPoint( int InX, int InY )
: X( InX )
, Y( InY )
{}
static plPoint ZeroValue()
{
return plPoint(0,0);
}
static plPoint NoneValue()
{
return plPoint(-1,-1);
}
operator POINT*() const
{
return (POINT*)this;
}
const int& operator()( int i ) const
{
return (&X)[i];
}
int& operator()( int i )
{
return (&X)[i];
}
static int Num()
{
return 2;
}
bool operator==( const plPoint& Other ) const
{
return X==Other.X && Y==Other.Y;
}
bool operator!=( const plPoint& Other ) const
{
return X!=Other.X || Y!=Other.Y;
}
plPoint& operator+=( const plPoint& Other )
{
X += Other.X;
Y += Other.Y;
return *this;
}
plPoint& operator-=( const plPoint& Other )
{
X -= Other.X;
Y -= Other.Y;
return *this;
}
plPoint operator+( const plPoint& Other ) const
{
return plPoint(*this) += Other;
}
plPoint operator-( const plPoint& Other ) const
{
return plPoint(*this) -= Other;
}
};
////////////////////////////////////////////////////////////////////
struct plRect
{
plPoint Min, Max;
plRect()
{}
plRect( int X0, int Y0, int X1, int Y1 )
: Min( X0, Y0 )
, Max( X1, Y1 )
{}
plRect( plPoint InMin, plPoint InMax )
: Min( InMin )
, Max( InMax )
{}
plRect( RECT R )
: Min( R.left, R.top )
, Max( R.right, R.bottom )
{}
operator RECT*() const
{
return (RECT*)this;
}
const plPoint& operator()( int i ) const
{
return (&Min)[i];
}
plPoint& operator()( int i )
{
return (&Min)[i];
}
bool operator==( const plRect& Other ) const
{
return Min==Other.Min && Max==Other.Max;
}
bool operator!=( const plRect& Other ) const
{
return Min!=Other.Min || Max!=Other.Max;
}
plRect Right( int Width )
{
return plRect( ::Max(Min.X,Max.X-Width), Min.Y, Max.X, Max.Y );
}
plRect Bottom( int Height )
{
return plRect( Min.X, ::Max(Min.Y,Max.Y-Height), Max.X, Max.Y );
}
plPoint Size()
{
return plPoint( Max.X-Min.X, Max.Y-Min.Y );
}
void Resize(plPoint size)
{
Max.X=Min.X+size.X;
Max.Y=Min.Y+size.Y;
}
int Width()
{
return Max.X-Min.X;
}
int Height()
{
return Max.Y-Min.Y;
}
plRect& operator+=( const plPoint& P )
{
Min += P;
Max += P;
return *this;
}
plRect& operator-=( const plPoint& P )
{
Min -= P;
Max -= P;
return *this;
}
plRect operator+( const plPoint& P ) const
{
return plRect( Min+P, Max+P );
}
plRect operator-( const plPoint& P ) const
{
return plRect( Min-P, Max-P );
}
plRect operator+( const plRect& R ) const
{
return plRect( Min+R.Min, Max+R.Max );
}
plRect operator-( const plRect& R ) const
{
return plRect( Min-R.Min, Max-R.Max );
}
plRect Inner( plPoint P ) const
{
return plRect( Min+P, Max-P );
}
bool Contains( plPoint P ) const
{
return P.X>=Min.X && P.X<Max.X && P.Y>=Min.Y && P.Y<Max.Y;
}
};
////////////////////////////////////////////////////////////////////
typedef void (plClass::*TDelegate)();
struct plDelegate
{
plClass * fTarget;
void (plClass::*fDelegate)();
plDelegate( plClass * target=nil, TDelegate delegate=nil )
: fTarget( target )
, fDelegate( delegate )
{}
void operator()() { if (fTarget){(fTarget->*fDelegate)();} }
};
////////////////////////////////////////////////////////////////////
// include private headers
// 'this' : used in base member initializer list
#pragma warning(disable:4355)
#include "plWindow.h"
#include "plControl.h"
#include "plLabel.h"
#include "plButton.h"
#include "plCheckBox.h"
#include "plRadioButton.h"
#include "plComboBox.h"
#include "plEdit.h"
#include "plButton.h"
#include "plDialog.h"
#include "plTrackBar.h"
#include "plProgressBar.h"
#include "plListBox.h"
#include "plStatusBar.h"
#pragma warning(default:4355)
////////////////////////////////////////////////////////////////////
#endif // HS_BUILD_FOR_WIN32
#endif // plWndCtrls_h_inc

View File

@ -0,0 +1,470 @@
#include "hsTypes.h"
#include "hsConfig.h"
#if HS_BUILD_FOR_WIN32
// Stolen from: http://www.mvps.org/user32/webhost.cab
// No copyright notices, so I assume it's public domain -Colin
#include "webhost.h"
#include "plWndCtrls.h"
// IUnknown
STDMETHODIMP CNullStorage::QueryInterface(REFIID riid,void ** ppvObject)
{
NOTIMPLEMENTED;
}
STDMETHODIMP_(ULONG) CNullStorage::AddRef(void)
{
return 1;
}
STDMETHODIMP_(ULONG) CNullStorage::Release(void)
{
return 1;
}
// IStorage
STDMETHODIMP CNullStorage::CreateStream(const WCHAR * pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2,IStream ** ppstm)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::OpenStream(const WCHAR * pwcsName,void * reserved1,DWORD grfMode,DWORD reserved2,IStream ** ppstm)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::CreateStorage(const WCHAR * pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2,IStorage ** ppstg)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::OpenStorage(const WCHAR * pwcsName,IStorage * pstgPriority,DWORD grfMode,SNB snbExclude,DWORD reserved,IStorage ** ppstg)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::CopyTo(DWORD ciidExclude,IID const * rgiidExclude,SNB snbExclude,IStorage * pstgDest)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::MoveElementTo(const OLECHAR * pwcsName,IStorage * pstgDest,const OLECHAR* pwcsNewName,DWORD grfFlags)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::Commit(DWORD grfCommitFlags)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::Revert(void)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::EnumElements(DWORD reserved1,void * reserved2,DWORD reserved3,IEnumSTATSTG ** ppenum)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::DestroyElement(const OLECHAR * pwcsName)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::RenameElement(const WCHAR * pwcsOldName,const WCHAR * pwcsNewName)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::SetElementTimes(const WCHAR * pwcsName,FILETIME const * pctime,FILETIME const * patime,FILETIME const * pmtime)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::SetClass(REFCLSID clsid)
{
return S_OK;
}
STDMETHODIMP CNullStorage::SetStateBits(DWORD grfStateBits,DWORD grfMask)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CNullStorage::Stat(STATSTG * pstatstg,DWORD grfStatFlag)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMySite::QueryInterface(REFIID riid,void ** ppvObject)
{
if(riid == IID_IUnknown || riid == IID_IOleClientSite)
*ppvObject = (IOleClientSite*)this;
else if(riid == IID_IOleInPlaceSite) // || riid == IID_IOleInPlaceSiteEx || riid == IID_IOleInPlaceSiteWindowless)
*ppvObject = (IOleInPlaceSite*)this;
else
{
*ppvObject = NULL;
return E_NOINTERFACE;
}
return S_OK;
}
STDMETHODIMP_(ULONG) CMySite::AddRef(void)
{
return 1;
}
STDMETHODIMP_(ULONG) CMySite::Release(void)
{
return 1;
}
// IOleClientSite
STDMETHODIMP CMySite::SaveObject()
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMySite::GetMoniker(DWORD dwAssign,DWORD dwWhichMoniker,IMoniker ** ppmk)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMySite::GetContainer(LPOLECONTAINER FAR* ppContainer)
{
// We are a simple object and don't support a container.
*ppContainer = NULL;
return E_NOINTERFACE;
}
STDMETHODIMP CMySite::ShowObject()
{
// NOTIMPLEMENTED;
// huh?
return NOERROR;
}
STDMETHODIMP CMySite::OnShowWindow(BOOL fShow)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMySite::RequestNewObjectLayout()
{
NOTIMPLEMENTED;
}
// IOleWindow
STDMETHODIMP CMySite::GetWindow(HWND FAR* lphwnd)
{
*lphwnd = host->hwnd;
return S_OK;
}
STDMETHODIMP CMySite::ContextSensitiveHelp(BOOL fEnterMode)
{
NOTIMPLEMENTED;
}
// IOleInPlaceSite
STDMETHODIMP CMySite::CanInPlaceActivate()
{
// Yes we can
return S_OK;
}
STDMETHODIMP CMySite::OnInPlaceActivate()
{
// Why disagree.
return S_OK;
}
STDMETHODIMP CMySite::OnUIActivate()
{
return S_OK;
}
STDMETHODIMP CMySite::GetWindowContext(
LPOLEINPLACEFRAME FAR* ppFrame,
LPOLEINPLACEUIWINDOW FAR* ppDoc,
LPRECT prcPosRect,
LPRECT prcClipRect,
LPOLEINPLACEFRAMEINFO lpFrameInfo)
{
*ppFrame = &host->frame;
*ppDoc = NULL;
GetClientRect(host->hwnd,prcPosRect);
GetClientRect(host->hwnd,prcClipRect);
lpFrameInfo->fMDIApp = FALSE;
lpFrameInfo->hwndFrame = host->hwnd;
lpFrameInfo->haccel = NULL;
lpFrameInfo->cAccelEntries = 0;
return S_OK;
}
STDMETHODIMP CMySite::Scroll(SIZE scrollExtent)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMySite::OnUIDeactivate(BOOL fUndoable)
{
return S_OK;
}
STDMETHODIMP CMySite::OnInPlaceDeactivate()
{
return S_OK;
}
STDMETHODIMP CMySite::DiscardUndoState()
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMySite::DeactivateAndUndo()
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMySite::OnPosRectChange(LPCRECT lprcPosRect)
{
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
//
// CMyFrame
//
// IUnknown
STDMETHODIMP CMyFrame::QueryInterface(REFIID riid,void ** ppvObject)
{
NOTIMPLEMENTED;
}
STDMETHODIMP_(ULONG) CMyFrame::AddRef(void)
{
return 1;
}
STDMETHODIMP_(ULONG) CMyFrame::Release(void)
{
return 1;
}
// IOleWindow
STDMETHODIMP CMyFrame::GetWindow(HWND FAR* lphwnd)
{
*lphwnd = this->host->hwnd;
return S_OK;
// NOTIMPLEMENTED;
}
STDMETHODIMP CMyFrame::ContextSensitiveHelp(BOOL fEnterMode)
{
NOTIMPLEMENTED;
}
// IOleInPlaceUIWindow
STDMETHODIMP CMyFrame::GetBorder(LPRECT lprectBorder)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMyFrame::RequestBorderSpace(LPCBORDERWIDTHS pborderwidths)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMyFrame::SetBorderSpace(LPCBORDERWIDTHS pborderwidths)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMyFrame::SetActiveObject(IOleInPlaceActiveObject *pActiveObject,LPCOLESTR pszObjName)
{
return S_OK;
}
// IOleInPlaceFrame
STDMETHODIMP CMyFrame::InsertMenus(HMENU hmenuShared,LPOLEMENUGROUPWIDTHS lpMenuWidths)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMyFrame::SetMenu(HMENU hmenuShared,HOLEMENU holemenu,HWND hwndActiveObject)
{
return S_OK;
}
STDMETHODIMP CMyFrame::RemoveMenus(HMENU hmenuShared)
{
NOTIMPLEMENTED;
}
STDMETHODIMP CMyFrame::SetStatusText(LPCOLESTR pszStatusText)
{
return S_OK;
}
STDMETHODIMP CMyFrame::EnableModeless(BOOL fEnable)
{
return S_OK;
}
STDMETHODIMP CMyFrame::TranslateAccelerator( LPMSG lpmsg,WORD wID)
{
NOTIMPLEMENTED;
}
webhostwnd::webhostwnd()
{
site.host = this;
frame.host = this;
}
webhostwnd::~webhostwnd()
{
}
HWND webhostwnd::operator =(webhostwnd* rhs)
{
return hwnd;
}
webhostwnd* webhostwnd::Create(HWND hParent, RECT& rect)
{
webhostwnd* _this = TRACKED_NEW webhostwnd;
CreateWindowEx(
0,
szClassName,L"TheWebbyWindow",
WS_CHILD,
rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,
hParent,NULL,plWndCtrls::Instance(),_this);
int err = GetLastError();
return _this;
}
BOOL webhostwnd::HandleMessage(UINT uMsg,WPARAM wParam,LPARAM lParam,LRESULT* r)
{
if(uMsg == WM_DESTROY)
{
UnCreateEmbeddedWebControl();
PostQuitMessage(0);
return TRUE;
}
else if(uMsg == WM_CREATE)
{
CreateEmbeddedWebControl();
return TRUE;
}
return FALSE;
}
void webhostwnd::CreateEmbeddedWebControl(void)
{
OleCreate(CLSID_WebBrowser,IID_IOleObject,OLERENDER_DRAW,0,&site,&storage,(void**)&mpWebObject);
mpWebObject->SetHostNames(L"Web Host",L"Web View");
// I have no idea why this is necessary. remark it out and everything works perfectly.
OleSetContainedObject(mpWebObject,TRUE);
RECT rect;
GetClientRect(hwnd,&rect);
mpWebObject->DoVerb(OLEIVERB_SHOW,NULL,&site,-1,hwnd,&rect);
IWebBrowser2* iBrowser;
mpWebObject->QueryInterface(IID_IWebBrowser2,(void**)&iBrowser);
VARIANT vURL;
vURL.vt = VT_BSTR;
vURL.bstrVal = SysAllocString(L"about:blank");
VARIANT ve1, ve2, ve3, ve4;
ve1.vt = VT_EMPTY;
ve2.vt = VT_EMPTY;
ve3.vt = VT_EMPTY;
ve4.vt = VT_EMPTY;
iBrowser->put_Left(0);
iBrowser->put_Top(0);
iBrowser->put_Width(rect.right);
iBrowser->put_Height(rect.bottom);
iBrowser->Navigate2(&vURL, &ve1, &ve2, &ve3, &ve4);
VariantClear(&vURL);
iBrowser->Release();
}
void webhostwnd::UnCreateEmbeddedWebControl(void)
{
mpWebObject->Close(OLECLOSE_NOSAVE);
mpWebObject->Release();
}
#include <comdef.h>
void webhostwnd::GoToPage(const char* address)
{
IWebBrowser2* iBrowser;
mpWebObject->QueryInterface(IID_IWebBrowser2,(void**)&iBrowser);
_bstr_t s(address);
VARIANT vURL;
vURL.vt = VT_BSTR;
vURL.bstrVal = SysAllocString(s);
VARIANT vHeaders;
vHeaders.vt = VT_EMPTY;
VARIANT ve1, ve2, ve3;
ve1.vt = VT_EMPTY;
ve2.vt = VT_EMPTY;
ve3.vt = VT_EMPTY;
iBrowser->Navigate2(&vURL, &ve1, &ve2, &ve3, &vHeaders);
VariantClear(&vURL);
iBrowser->Release();
}
// OleUninitialize();
#endif

View File

@ -0,0 +1,143 @@
// Stolen from: http://www.mvps.org/user32/webhost.cab
// No copyright notices, so I assume it's public domain -Colin
#include <windows.h>
#include "basewnd.h"
#include <shlobj.h>
#include <lmcons.h>
#include <exdisp.h>
#define NOTIMPLEMENTED __asm{ int 3 }; return E_NOTIMPL
struct CNullStorage
: public IStorage
{
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid,void ** ppvObject);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// IStorage
STDMETHODIMP CreateStream(const WCHAR * pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2,IStream ** ppstm);
STDMETHODIMP OpenStream(const WCHAR * pwcsName,void * reserved1,DWORD grfMode,DWORD reserved2,IStream ** ppstm);
STDMETHODIMP CreateStorage(const WCHAR * pwcsName,DWORD grfMode,DWORD reserved1,DWORD reserved2,IStorage ** ppstg);
STDMETHODIMP OpenStorage(const WCHAR * pwcsName,IStorage * pstgPriority,DWORD grfMode,SNB snbExclude,DWORD reserved,IStorage ** ppstg);
STDMETHODIMP CopyTo(DWORD ciidExclude,IID const * rgiidExclude,SNB snbExclude,IStorage * pstgDest);
STDMETHODIMP MoveElementTo(const OLECHAR * pwcsName,IStorage * pstgDest,const OLECHAR* pwcsNewName,DWORD grfFlags);
STDMETHODIMP Commit(DWORD grfCommitFlags);
STDMETHODIMP Revert(void);
STDMETHODIMP EnumElements(DWORD reserved1,void * reserved2,DWORD reserved3,IEnumSTATSTG ** ppenum);
STDMETHODIMP DestroyElement(const OLECHAR * pwcsName);
STDMETHODIMP RenameElement(const WCHAR * pwcsOldName,const WCHAR * pwcsNewName);
STDMETHODIMP SetElementTimes(const WCHAR * pwcsName,FILETIME const * pctime,FILETIME const * patime,FILETIME const * pmtime);
STDMETHODIMP SetClass(REFCLSID clsid);
STDMETHODIMP SetStateBits(DWORD grfStateBits,DWORD grfMask);
STDMETHODIMP Stat(STATSTG * pstatstg,DWORD grfStatFlag);
};
struct webhostwnd;
struct CMyFrame
: public IOleInPlaceFrame
{
webhostwnd* host;
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid,void ** ppvObject);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// IOleWindow
STDMETHODIMP GetWindow(HWND FAR* lphwnd);
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
// IOleInPlaceUIWindow
STDMETHODIMP GetBorder(LPRECT lprectBorder);
STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS pborderwidths);
STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS pborderwidths);
STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject *pActiveObject,LPCOLESTR pszObjName);
// IOleInPlaceFrame
STDMETHODIMP InsertMenus(HMENU hmenuShared,LPOLEMENUGROUPWIDTHS lpMenuWidths);
STDMETHODIMP SetMenu(HMENU hmenuShared,HOLEMENU holemenu,HWND hwndActiveObject);
STDMETHODIMP RemoveMenus(HMENU hmenuShared);
STDMETHODIMP SetStatusText(LPCOLESTR pszStatusText);
STDMETHODIMP EnableModeless(BOOL fEnable);
STDMETHODIMP TranslateAccelerator( LPMSG lpmsg,WORD wID);
};
struct CMySite
: public IOleClientSite,
public IOleInPlaceSite
{
webhostwnd* host;
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid,void ** ppvObject);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// IOleClientSite
STDMETHODIMP SaveObject();
STDMETHODIMP GetMoniker(DWORD dwAssign,DWORD dwWhichMoniker,IMoniker ** ppmk);
STDMETHODIMP GetContainer(LPOLECONTAINER FAR* ppContainer);
STDMETHODIMP ShowObject();
STDMETHODIMP OnShowWindow(BOOL fShow);
STDMETHODIMP RequestNewObjectLayout();
// IOleWindow
STDMETHODIMP GetWindow(HWND FAR* lphwnd);
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
// IOleInPlaceSite methods
STDMETHODIMP CanInPlaceActivate();
STDMETHODIMP OnInPlaceActivate();
STDMETHODIMP OnUIActivate();
STDMETHODIMP GetWindowContext(LPOLEINPLACEFRAME FAR* lplpFrame,LPOLEINPLACEUIWINDOW FAR* lplpDoc,LPRECT lprcPosRect,LPRECT lprcClipRect,LPOLEINPLACEFRAMEINFO lpFrameInfo);
STDMETHODIMP Scroll(SIZE scrollExtent);
STDMETHODIMP OnUIDeactivate(BOOL fUndoable);
STDMETHODIMP OnInPlaceDeactivate();
STDMETHODIMP DiscardUndoState();
STDMETHODIMP DeactivateAndUndo();
STDMETHODIMP OnPosRectChange(LPCRECT lprcPosRect);
};
struct CMyContainer
: public IOleContainer
{
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid,void ** ppvObject);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
// IParseDisplayName
STDMETHODIMP ParseDisplayName(IBindCtx *pbc,LPOLESTR pszDisplayName,ULONG *pchEaten,IMoniker **ppmkOut);
// IOleContainer
STDMETHODIMP EnumObjects(DWORD grfFlags,IEnumUnknown **ppenum);
STDMETHODIMP LockContainer(BOOL fLock);
};
struct webhostwnd : public basewnd
{
webhostwnd();
~webhostwnd();
static webhostwnd* Create(HWND hParent, RECT& rect);
virtual BOOL HandleMessage(UINT,WPARAM,LPARAM,LRESULT*);
void CreateEmbeddedWebControl(void);
void UnCreateEmbeddedWebControl(void);
HWND operator =(webhostwnd* rhs);
CNullStorage storage;
CMySite site;
CMyFrame frame;
IOleObject* mpWebObject;
void OnPaint(HDC hdc);
void GoToPage(const char* address);
};