Subversion Server


Framework

Compare Path:  Rev
With Path:  Rev

This comparison shows the changes necessary to convert path /tags (Rev 438) TO /tags (Rev 450)

Reverse comparison

suserver_0.06/include/win32/DeviceContext.h

@@ -0,0 +1,31 @@
#ifndef _DEVICECONTEXT_H_
#define _DEVICECONTEXT_H_
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CDeviceContext
                {
                public:
                                                        CDeviceContext(HDC);
                        virtual ~CDeviceContext();
 
                                                        operator HDC();
 
                        void FillRect(RECT*, COLORREF);
                        void DrawLine(int, int, int, int);
                        void DrawLine(int, int, int, int, COLORREF);
                        void TextOut(int, int, const TCHAR*);
                        void TextOut(int, int, const TCHAR*, COLORREF);
                        HGDIOBJ SelectObject(HGDIOBJ);
 
                protected:
                        HDC m_dc;
                };
        }
}
 
#endif


suserver_0.06/include/win32/Font.h

@@ -0,0 +1,12 @@
#pragma once
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                HFONT CreateFont(const TCHAR*, unsigned int);
                SIZE GetFixedFontSize(HFONT);
        }
}


suserver_0.06/include/win32/ClientDeviceContext.h

@@ -0,0 +1,19 @@
#pragma once
 
#include "win32/DeviceContext.h"
 
namespace Framework
{
        namespace Win32
        {
                class CClientDeviceContext : public CDeviceContext
                {
                public:
                                                CClientDeviceContext(HWND);
                        virtual ~CClientDeviceContext();
 
                private:
                        HWND m_wnd;
                };
        }
}


suserver_0.06/include/win32/Rect.h

@@ -0,0 +1,46 @@
#pragma once
 
#include <Windows.h>
#include "Types.h"
 
namespace Framework
{
        namespace Win32
        {
                class CRect
                {
                public:
                                                CRect(int, int, int, int);
                                                CRect(const RECT&);
                        virtual ~CRect();
 
                                                operator RECT*();
                                                operator RECT&();
 
                        int Left() const;
                        int Top() const;
                        int Right() const;
                        int Bottom() const;
 
                        void SetLeft(int);
                        void SetTop(int);
                        void SetRight(int);
                        void SetBottom(int);
 
                        int Width() const;
                        int Height() const;
 
                        CRect& Adjust(uint32, bool = false);
                        CRect& Inflate(int, int);
                        CRect& CenterInside(const CRect&);
                        CRect& ScreenToClient(HWND);
                        CRect& ClientToScreen(HWND);
                        bool PtIn(int, int) const;
 
                private:
                        RECT m_rect;
                };
 
                CRect MakeRectPositionSize(int, int, int, int);
        }
}


suserver_0.06/include/win32/ComPtr.h

@@ -0,0 +1,127 @@
#pragma once
 
#include <Windows.h>
#include <assert.h>
 
namespace Framework
{
        namespace Win32
        {
                template <typename PtrType>
                class CComPtr
                {
                public:
                        CComPtr()
                        : m_ptr(nullptr)
                        {
 
                        }
 
                        explicit CComPtr(PtrType* ptr)
                        : m_ptr(ptr)
                        {
 
                        }
 
                        CComPtr(const CComPtr& rhs)
                        : m_ptr(nullptr)
                        {
                                CopyFrom(rhs);
                        }
 
                        CComPtr(CComPtr&& rhs)
                        : m_ptr(nullptr)
                        {
                                MoveFrom(std::move(rhs));
                        }
 
                        ~CComPtr()
                        {
                                Reset();
                        }
 
                        operator PtrType*()
                        {
                                return m_ptr;
                        }
 
                        operator PtrType*() const
                        {
                                return m_ptr;
                        }
 
                        operator PtrType**()
                        {
                                return &m_ptr;
                        }
 
                        CComPtr& operator =(const CComPtr& rhs)
                        {
                                if(&rhs != this)
                                {
                                        Reset();
                                        CopyFrom(rhs);
                                }
                                return (*this);
                        }
 
                        CComPtr& operator =(CComPtr&& rhs)
                        {
                                Reset();
                                MoveFrom(std::move(rhs));
                                return (*this);
                        }
 
                        PtrType* operator ->() const
                        {
                                return m_ptr;
                        }
 
                        PtrType** operator &()
                        {
                                //Usually used for creation, must be empty
                                assert(m_ptr == nullptr);
                                return &m_ptr;
                        }
 
                        PtrType* Detach()
                        {
                                PtrType* result = m_ptr;
                                m_ptr = nullptr;
                                return result;
                        }
 
                        void Reset()
                        {
                                if(m_ptr != nullptr)
                                {
                                        m_ptr->Release();
                                        m_ptr = nullptr;
                                }
                        }
 
                        bool IsEmpty() const
                        {
                                return (m_ptr == nullptr);
                        }
 
                private:
                        void CopyFrom(const CComPtr& src)
                        {
                                assert(m_ptr == nullptr);
                                m_ptr = src.m_ptr;
                                if(m_ptr != nullptr)
                                {
                                        m_ptr->AddRef();
                                }
                        }
 
                        void MoveFrom(CComPtr&& src)
                        {
                                std::swap(m_ptr, src.m_ptr);
                        }
 
                        PtrType* m_ptr;
                };
        };
};


suserver_0.06/include/win32/Tab.h

@@ -0,0 +1,40 @@
#pragma once
 
#include "win32/Window.h"
#include <commctrl.h>
 
namespace Framework
{
        namespace Win32
        {
                class CTab : public CWindow
                {
                public:
                                                                        CTab(HWND = 0);
                                                                        CTab(HWND, const RECT&, unsigned long = 0, unsigned long = 0);
                        virtual ~CTab();
 
                        CTab& operator =(CTab&&);
 
                        int InsertTab(const TCHAR*);
                        void DeleteTab(int);
 
                        std::tstring GetTabText(int);
                        void SetTabText(int, const TCHAR*);
 
                        LPARAM GetTabData(int);
                        void SetTabData(int, LPARAM);
 
                        int GetSelection();
                        void SetSelection(int);
                        unsigned int GetItemCount();
 
                        int HitTest(int, int);
 
                        Framework::Win32::CRect GetDisplayAreaRect();
 
                private:
 
                };
        }
}


suserver_0.06/include/win32/ToolBar.h

@@ -0,0 +1,41 @@
#pragma once
 
#include <map>
#include "win32/Window.h"
#include <commctrl.h>
 
namespace Framework
{
        namespace Win32
        {
                class CToolBar : public CWindow
                {
                public:
                                                                CToolBar();
                                                                CToolBar(HWND, unsigned int, HINSTANCE, unsigned int, unsigned int, unsigned int);
                                                                CToolBar(HWND, DWORD style = TBSTYLE_TOOLTIPS);
                                                                CToolBar(const CToolBar&) = delete;
                        virtual ~CToolBar();
 
                        CToolBar& operator =(CToolBar&&);
                        CToolBar& operator =(const CToolBar&) = delete;
 
                        void LoadStandardImageList(unsigned int);
                        void InsertImageButton(unsigned int, unsigned int);
                        void InsertTextButton(const TCHAR*, unsigned int);
                        void Resize();
                        HWND GetToolTips();
                        void SetButtonChecked(unsigned int, bool);
                        void SetButtonToolTipText(unsigned int, const TCHAR*);
                        void ProcessNotify(WPARAM, NMHDR*);
 
                private:
                        typedef std::map<unsigned int, std::tstring> ButtonToolTipMap;
 
                        void Reset();
                        void MoveFrom(CToolBar&&);
 
                        ButtonToolTipMap m_buttonToolTips;
                };
        }
}


suserver_0.06/include/win32/Window.h

@@ -0,0 +1,116 @@
#pragma once
 
#include <windows.h>
#include "tcharx.h"
#include "ScrollBar.h"
#include "Rect.h"
#include "DefaultWndClass.h"
 
namespace Framework
{
        namespace Win32
        {
                class CWindow
                {
                public:
                                                                        CWindow();
                                                                        CWindow(const CWindow&) = delete;
                        virtual ~CWindow();
 
                        CWindow& operator =(const CWindow&) = delete;
                                                                        operator HWND() const;
 
                        static LRESULT WINAPI WndProc(HWND, unsigned int, WPARAM, LPARAM);
                        static LRESULT WINAPI SubClassWndProc(HWND, unsigned int, WPARAM, LPARAM);
                        static void StdMsgLoop(CWindow&);
                        static void DlgMsgLoop(CWindow&);
                        static int MessageBoxFormat(HWND, unsigned int, const TCHAR*, const TCHAR*, ...);
                        void SetClassPtr();
                        void ClearClassPtr();
                        static CWindow* GetClassPtr(HWND);
                        void SubClass();
                        long CallBaseWndProc(unsigned int, WPARAM, LPARAM);
                        static bool DoesWindowClassExist(const TCHAR*);
                        static bool IsNotifySource(const CWindow*, const NMHDR*);
                        static bool IsCommandSource(const CWindow*, HWND);
 
                        //Helpers
                        void Create(unsigned long, const TCHAR*, const TCHAR*, unsigned long, const CRect&, HWND, void*);
                        unsigned int Destroy();
                        unsigned int Show(int);
                        unsigned int Enable(unsigned int);
                        bool IsWindow();
                        bool IsVisible();
                        std::tstring GetText();
                        int GetText(TCHAR*, int);
                        unsigned int GetTextLength();
                        unsigned int SetText(const TCHAR*);
                        unsigned int SetTextA(const char*);
                        HFONT GetFont();
                        void SetFont(HFONT);
                        void SetMenu(HMENU);
                        void SetIcon(unsigned int, HICON);
                        void SetFocus();
                        void SetSize(unsigned int, unsigned int);
                        void SetPosition(unsigned int, unsigned int);
                        void SetSizePosition(const CRect&);
                        void Center(HWND = 0);
                        CRect GetClientRect();
                        CRect GetWindowRect();
                        HWND GetParent();
                        void Redraw();
                        void ModifyStyleOr(unsigned long);
                        void SetRedraw(bool);
                        CScrollBar GetVerticalScrollBar();
                        CScrollBar GetHorizontalScrollBar();
 
                protected:
                        void Reset();
                        void MoveFrom(CWindow&&);
 
                        virtual long OnClose();
                        virtual long OnCommand(unsigned short, unsigned short, HWND);
                        virtual long OnSysCommand(unsigned int, LPARAM);
                        virtual long OnNotify(WPARAM, NMHDR*);
                        virtual long OnWndProc(unsigned int, WPARAM, LPARAM);
                        virtual long OnSize(unsigned int, unsigned int, unsigned int);
                        virtual long OnLeftButtonUp(int, int);
                        virtual long OnLeftButtonDown(int, int);
                        virtual long OnLeftButtonDblClk(int, int);
                        virtual long OnRightButtonDown(int, int);
                        virtual long OnRightButtonUp(int, int);
                        virtual long OnMouseMove(WPARAM, int, int);
                        virtual long OnMouseWheel(int, int, short);
                        virtual long OnVScroll(unsigned int, unsigned int);
                        virtual long OnHScroll(unsigned int, unsigned int);
                        virtual long OnSysKeyDown(unsigned int);
                        virtual long OnKeyDown(WPARAM, LPARAM);
                        virtual long OnKeyUp(WPARAM, LPARAM);
                        virtual long OnDestroy();
                        virtual long OnCtlColorStatic(HDC, HWND);
                        virtual long OnActivate(unsigned int, bool, HWND);
                        virtual long OnActivateApp(bool, unsigned long);
                        virtual long OnSetCursor(HWND, unsigned int, unsigned int);
                        virtual long OnDrawItem(unsigned int, LPDRAWITEMSTRUCT);
                        virtual long OnCopy();
                        virtual long OnNcCalcSize(WPARAM, LPARAM);
                        virtual long OnNcPaint(WPARAM);
                        virtual long OnGetDlgCode(WPARAM, LPARAM);
                        virtual long OnThemeChanged();
 
                        //Add parameters for these
                        virtual long OnPaint();
                        virtual long OnMouseLeave();
                        virtual long OnEraseBkgnd();
                        virtual long OnTimer(WPARAM);
                        virtual long OnSetFocus();
                        virtual long OnKillFocus();
 
                public:
                        HWND m_hWnd;
                        bool m_hasClassPtr;
                        bool m_noCallDef;
                        WNDPROC m_baseWndProc;
                };
        }
};


suserver_0.06/include/win32/GdiObj.h

@@ -0,0 +1,77 @@
#pragma once
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                template <typename Type> class CGdiObj
                {
                public:
                        CGdiObj(Type handle = NULL)
                                : m_handle(handle)
                        {
 
                        }
 
                        CGdiObj(const CGdiObj&) = delete;
 
                        CGdiObj(CGdiObj&& src)
                        {
                                m_handle = src.m_handle;
                                src.m_handle = NULL;
                        }
 
                        virtual ~CGdiObj()
                        {
                                Release();
                        }
 
                        CGdiObj& operator =(const CGdiObj&) = delete;
 
                        CGdiObj& operator =(CGdiObj&& src)
                        {
                                if(&src != this)
                                {
                                        Release();
                                        m_handle = src.m_handle;
                                        src.m_handle = NULL;
                                }
                                return (*this);
                        }
 
                        bool IsValid() const
                        {
                                return m_handle != NULL;
                        }
 
                        operator HGDIOBJ() const
                        {
                                return m_handle;
                        }
 
                        operator Type() const
                        {
                                return m_handle;
                        }
 
                private:
                        void Release()
                        {
                                if(m_handle)
                                {
                                        DeleteObject(m_handle);
                                        m_handle = NULL;
                                }
                        }
 
                        Type m_handle;
                };
 
                typedef CGdiObj<HFONT> CFont;
                typedef CGdiObj<HBRUSH> CBrush;
                typedef CGdiObj<HBITMAP> CBitmap;
                typedef CGdiObj<HPEN> CPen;
        }
}


suserver_0.06/include/win32/VerticalSplitter.h

@@ -0,0 +1,20 @@
#pragma once
 
#include "win32/Splitter.h"
 
namespace Framework
{
        namespace Win32
        {
                class CVerticalSplitter : public CSplitter
                {
                public:
                                                        CVerticalSplitter(HWND, const RECT&);
 
                protected:
                        virtual CRect GetEdgeRect() override;
                        virtual CRect GetPaneRect(unsigned int) override;
                        virtual void UpdateEdgePosition(int, int) override;
                };
        }
}


suserver_0.06/include/win32/Splitter.h

@@ -0,0 +1,48 @@
#pragma once
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CSplitter : public CWindow
                {
                public:
                                                        CSplitter(HWND, const RECT&, HCURSOR, unsigned int);
                        virtual ~CSplitter();
 
                        void SetChild(unsigned int, HWND);
                        void SetMasterChild(unsigned int);
 
                        void SetEdgePosition(double);
                        void SetFixed(bool);
 
                protected:
                        long OnSize(unsigned int, unsigned int, unsigned int);
                        long OnMouseMove(WPARAM, int, int);
                        long OnLeftButtonDown(int, int);
                        long OnLeftButtonUp(int, int);
                        long OnNotify(WPARAM, NMHDR*);
 
                        virtual CRect GetPaneRect(unsigned int) = 0;
                        virtual CRect GetEdgeRect() = 0;
                        virtual void UpdateEdgePosition(int, int) = 0;
 
                        unsigned int m_edgePosition = 0;
                        unsigned int m_masterChild = 0;
                        HWND m_child[2];
 
                        enum EDGESIZE
                        {
                                EDGESIZE = 4,
                        };
 
                private:
                        void ResizeChild(unsigned int);
 
                        HCURSOR m_cursor;
                        bool m_fixed = false;
                };
        }
}


suserver_0.06/include/win32/HorizontalSplitter.h

@@ -0,0 +1,21 @@
#pragma once
 
#include "win32/Splitter.h"
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CHorizontalSplitter : public CSplitter
                {
                public:
                                                        CHorizontalSplitter(HWND, const RECT&);
 
                protected:
                        virtual CRect GetEdgeRect() override;
                        virtual CRect GetPaneRect(unsigned int) override;
                        virtual void UpdateEdgePosition(int, int) override;
                };
        }
}


suserver_0.06/include/win32/ListBox.h

@@ -0,0 +1,27 @@
#pragma once
 
#include "Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CListBox : public CWindow
                {
                public:
                                                        CListBox(HWND = 0);
                                                        CListBox(HWND, const RECT&, unsigned long = 0, unsigned long = WS_EX_CLIENTEDGE);
 
                        CListBox& operator =(CListBox&&);
 
                        unsigned int AddString(const TCHAR*);
                        void ResetContent();
 
                        int GetCurrentSelection();
                        void SetCurrentSelection(unsigned int);
 
                        INT_PTR GetItemData(unsigned int);
                        void SetItemData(unsigned int, INT_PTR);
                };
        }
}


suserver_0.06/include/win32/ComStreamAdapter.h

@@ -0,0 +1,41 @@
#pragma once
 
#include <Windows.h>
#include "Stream.h"
 
namespace Framework
{
        namespace Win32
        {
                class CComStreamAdapter : public IStream
                {
                public:
                                                                        CComStreamAdapter(Framework::CStream&);
                        virtual ~CComStreamAdapter();
 
                        //IUnknown
                        STDMETHODIMP_(ULONG) AddRef() override;
                        STDMETHODIMP_(ULONG) Release() override;
                        STDMETHODIMP QueryInterface(const IID&, void**) override;
 
                        //ISequentialStream
                        STDMETHODIMP Read(void*, ULONG, ULONG*) override;
                        STDMETHODIMP Write(const void* data, ULONG length, ULONG* lengthWritten) override;
 
                        //IStream
                        STDMETHODIMP Seek(LARGE_INTEGER, DWORD, ULARGE_INTEGER*) override;
                        STDMETHODIMP SetSize(ULARGE_INTEGER) override;
                        STDMETHODIMP CopyTo(IStream*, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*) override;
                        STDMETHODIMP Commit(DWORD) override;
                        STDMETHODIMP Revert() override;
                        STDMETHODIMP LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD) override;
                        STDMETHODIMP UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD) override;
                        STDMETHODIMP Stat(STATSTG*, DWORD) override;
                        STDMETHODIMP Clone(IStream**) override;
 
                private:
                        ULONG m_refCount = 1;
                        Framework::CStream& m_stream;
                };
        }
}


suserver_0.06/include/win32/ListView.h

@@ -0,0 +1,56 @@
#pragma once
 
#include "Window.h"
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x501
#endif
#include <commctrl.h>
 
namespace Framework
{
        namespace Win32
        {
                class CListView : public CWindow
                {
                public:
                                                        CListView(HWND = 0);
                                                        CListView(HWND, const RECT&, unsigned long = 0, unsigned long = WS_EX_CLIENTEDGE);
                        virtual ~CListView();
 
                        CListView& operator =(CListView&&);
 
                        int GetItemCount();
                        int FindItemData(unsigned long);
                        void DeleteItem(unsigned int);
                        bool DeleteColumn(unsigned int);
                        void DeleteAllItems();
                        int InsertItem(const LVITEM&);
                        void InsertColumn(unsigned int, const LVCOLUMN&);
 
                        std::tstring GetItemText(unsigned int, unsigned int);
                        void SetItemText(unsigned int, unsigned int, const TCHAR*);
 
                        void SetItemState(unsigned int, unsigned int, unsigned int);
 
                        unsigned long GetItemData(unsigned int);
 
                        int GetSelection();
                        void SetSelection(int);
 
                        void EnableGroupView(bool);
                        int InsertGroup(const TCHAR*, unsigned int, unsigned int = -1);
                        void RemoveAllGroups();
 
                        void SetColumnWidth(unsigned int, unsigned int);
 
                        void SetExtendedListViewStyle(unsigned long);
                        unsigned long GetExtendedListViewStyle();
 
                        void SetItemCount(int);
 
                        void EnsureItemVisible(unsigned int, bool);
 
                        HWND GetHeader();
                };
        }
}


suserver_0.06/include/win32/MenuItem.h

@@ -0,0 +1,33 @@
#ifndef _WIN32_MENUITEM_H_
#define _WIN32_MENUITEM_H_
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CMenuItem
                {
                public:
                                                                CMenuItem(HMENU = NULL, int = 0);
                        virtual ~CMenuItem();
 
                                                                operator HMENU() const;
 
                        void Check(bool);
                        void Enable(bool);
                        void SetText(const TCHAR*);
                        bool IsEmpty() const;
 
                        CMenuItem FindById(unsigned int);
                        static CMenuItem FindById(HMENU, unsigned int);
 
                private:
                        HMENU m_menu;
                        int m_position;
                };
        }
}
 
#endif


suserver_0.06/include/win32/TrayIconServer.h

@@ -0,0 +1,38 @@
#pragma once
 
#include "TrayIcon.h"
#include <functional>
#include <memory>
#include <map>
#include <boost/signals2.hpp>
 
namespace Framework
{
        namespace Win32
        {
                class CTrayIconServer : public CWindow
                {
                public:
                        typedef std::function<void (CTrayIcon*, LPARAM)> IconEventHandlerType;
 
                                                                        CTrayIconServer();
                        virtual ~CTrayIconServer();
 
                        CTrayIcon* Insert();
 
                        void RegisterHandler(const IconEventHandlerType&);
 
                protected:
                        long OnWndProc(unsigned int, WPARAM, LPARAM);
 
                private:
                        typedef std::map<unsigned int, std::unique_ptr<CTrayIcon>> TrayIconMapType;
                        typedef boost::signals2::signal<void (CTrayIcon*, LPARAM)> IconEventSignalType;
 
                        TrayIconMapType m_icons;
                        IconEventSignalType m_iconEventSignal;
                        unsigned int m_nextIconId = 1;
                        unsigned int m_taskBarCreatedMessage = 0;
                };
        }
}


suserver_0.06/include/win32/TrayIcon.h

@@ -0,0 +1,34 @@
#pragma once
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CTrayIcon
                {
                public:
                                                        CTrayIcon(HWND, unsigned int);
                        virtual ~CTrayIcon();
 
                        void SetTip(const TCHAR*);
                        void SetIcon(HICON);
                        void SetMessage(unsigned int);
                        unsigned int GetID() const;
                        void Rebuild();
 
                private:
                        void Add();
                        void Delete();
                        void InitStructure(NOTIFYICONDATA*);
 
                        std::tstring m_tip;
                        HICON m_icon;
                        unsigned int m_message;
 
                        HWND m_wnd;
                        unsigned int m_id;
                };
        }
}


suserver_0.06/include/win32/ActiveXHost.h

@@ -0,0 +1,117 @@
#pragma once
 
#include "win32/Window.h"
#include "win32/ComPtr.h"
#include <functional>
 
namespace Framework
{
        namespace Win32
        {
                class CActiveXHost : public Framework::Win32::CWindow
                {
                public:
                        struct INonDelegatingUnknown
                        {
                                virtual STDMETHODIMP NonDelegatingQueryInterface(const IID&, void**) = 0;
                                virtual STDMETHODIMP_(ULONG) NonDelegatingAddRef() = 0;
                                virtual STDMETHODIMP_(ULONG) NonDelegatingRelease() = 0;
                        };
 
                        class CClientSite : public IOleClientSite, public IOleInPlaceSite, public IDispatch,
                                public IAdviseSink, public IOleInPlaceFrame, public INonDelegatingUnknown
                        {
                        public:
                                static CComPtr<IUnknown> Create(HWND, IUnknown*);
 
                        private:
                                                                                        CClientSite(HWND, IUnknown*);
                                virtual ~CClientSite();
 
                        public:
                                //IUnknown
                                STDMETHODIMP QueryInterface(const IID&, void**);
                                STDMETHODIMP_(ULONG) AddRef();
                                STDMETHODIMP_(ULONG) Release();
 
                                //INonDelegatingUnknown
                                STDMETHODIMP NonDelegatingQueryInterface(const IID&, void**);
                                STDMETHODIMP_(ULONG) NonDelegatingAddRef();
                                STDMETHODIMP_(ULONG) NonDelegatingRelease();
 
                                //IOleClientSite
                                STDMETHODIMP SaveObject();
                                STDMETHODIMP GetMoniker(DWORD, DWORD, IMoniker**);
                                STDMETHODIMP GetContainer(IOleContainer**);
                                STDMETHODIMP ShowObject();
                                STDMETHODIMP OnShowWindow(BOOL);
                                STDMETHODIMP RequestNewObjectLayout();
 
                                //IOleInPlaceSite
                                STDMETHODIMP GetWindow(HWND*);
                                STDMETHODIMP ContextSensitiveHelp(BOOL);
                                STDMETHODIMP CanInPlaceActivate();
                                STDMETHODIMP OnUIActivate();
                                STDMETHODIMP OnInPlaceActivate();
                                STDMETHODIMP OnUIDeactivate(BOOL);
                                STDMETHODIMP OnInPlaceDeactivate();
                                STDMETHODIMP GetWindowContext(IOleInPlaceFrame**, IOleInPlaceUIWindow**, LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO);
                                STDMETHODIMP Scroll(SIZE);
                                STDMETHODIMP DiscardUndoState();
                                STDMETHODIMP DeactivateAndUndo();
                                STDMETHODIMP OnPosRectChange(LPCRECT);
 
                                //IOleInPlaceFrame
                                STDMETHODIMP GetBorder(LPRECT);
                                STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS);
                                STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS);
                                STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject*, LPCOLESTR);
                                STDMETHODIMP InsertMenus(HMENU, LPOLEMENUGROUPWIDTHS);
                                STDMETHODIMP SetMenu(HMENU, HOLEMENU, HWND);
                                STDMETHODIMP RemoveMenus(HMENU);
                                STDMETHODIMP EnableModeless(BOOL);
                                STDMETHODIMP TranslateAccelerator(LPMSG, WORD);
                                STDMETHODIMP SetStatusText(LPCOLESTR);
 
                                //IDispatch
                                STDMETHODIMP GetTypeInfoCount(UINT*);
                                STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo**);
                                STDMETHODIMP GetIDsOfNames(const IID&, LPOLESTR*, UINT, LCID, DISPID*);
                                STDMETHODIMP Invoke(DISPID, const IID&, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*);
 
                                //IAdviseSink
                                STDMETHODIMP_(void) OnDataChange(FORMATETC*, STGMEDIUM*);
                                STDMETHODIMP_(void) OnViewChange(DWORD, LONG);
                                STDMETHODIMP_(void) OnRename(IMoniker*);
                                STDMETHODIMP_(void) OnSave();
                                STDMETHODIMP_(void) OnClose();
 
                        private:
                                IUnknown* m_outerUnk;
                                ULONG m_refCount;
                                HWND m_window;
                        };
                        typedef CComPtr<IUnknown> UnknownPtr;
                        typedef std::function<UnknownPtr (HWND)> ClientSiteFactory;
 
                                                                        CActiveXHost();
                                                                        CActiveXHost(HWND, const RECT&, const CLSID&,
                                                                                const ClientSiteFactory& = &DefaultClientSiteFactory);
                        virtual ~CActiveXHost();
 
                protected:
                        void Reset();
                        void MoveFrom(CActiveXHost&&);
 
                        long OnSize(unsigned int, unsigned int, unsigned int) override;
 
                        CComPtr<IOleObject> m_oleObject;
 
                private:
                        static UnknownPtr DefaultClientSiteFactory(HWND);
 
                        UnknownPtr m_clientSite;
                        CComPtr<IStorage> m_storage;
                };
        }
}


suserver_0.06/include/win32/WebBrowser.h

@@ -0,0 +1,116 @@
#pragma once
 
#include "ActiveXHost.h"
#include <ExDisp.h>
#include <MsHTML.h>
#include <MsHtmHst.h>
#include <set>
 
namespace Framework
{
        namespace Win32
        {
                class CWebBrowser : public CActiveXHost
                {
                public:
                        enum
                        {
                                NOTIFICATION_BEFORENAVIGATE = 0xA000,
                        };
 
                        struct BEFORENAVIGATE_INFO : public NMHDR
                        {
                                std::tstring navigateUrl;
                                bool cancel;
                        };
 
                                                                                CWebBrowser();
                                                                                CWebBrowser(HWND, const RECT&);
                        virtual ~CWebBrowser();
 
                        CWebBrowser& operator =(CWebBrowser&&);
 
                        CComPtr<IHTMLDocument2> GetDocument();
 
                        void Navigate(const TCHAR*);
                        void Stop();
 
                protected:
                        class CWebBrowserClientSite : public IDocHostUIHandler
                        {
                        public:
                                                                                CWebBrowserClientSite(HWND);
                                virtual ~CWebBrowserClientSite();
 
                                //IUnknown
                                STDMETHODIMP QueryInterface(const IID&, void**);
                                STDMETHODIMP_(ULONG) AddRef();
                                STDMETHODIMP_(ULONG) Release();
 
                                //IDocHostUIHandler
                                STDMETHODIMP ShowContextMenu(DWORD, POINT*, IUnknown*, IDispatch*);
                                STDMETHODIMP GetHostInfo(DOCHOSTUIINFO*);
                                STDMETHODIMP ShowUI(DWORD, IOleInPlaceActiveObject*, IOleCommandTarget*, IOleInPlaceFrame*, IOleInPlaceUIWindow*);
                                STDMETHODIMP HideUI();
                                STDMETHODIMP UpdateUI();
                                STDMETHODIMP EnableModeless(BOOL);
                                STDMETHODIMP OnDocWindowActivate(BOOL);
                                STDMETHODIMP OnFrameWindowActivate(BOOL);
                                STDMETHODIMP ResizeBorder(LPCRECT, IOleInPlaceUIWindow*, BOOL);
                                STDMETHODIMP TranslateAccelerator(LPMSG, const GUID*, DWORD);
                                STDMETHODIMP GetOptionKeyPath(LPOLESTR*, DWORD);
                                STDMETHODIMP GetDropTarget(IDropTarget*, IDropTarget**);
                                STDMETHODIMP GetExternal(IDispatch**);
                                STDMETHODIMP TranslateUrl(DWORD, LPWSTR, LPWSTR*);
                                STDMETHODIMP FilterDataObject(IDataObject*, IDataObject**);
 
                        private:
                                CComPtr<IUnknown> m_clientSite;
                                ULONG m_refCount;
                        };
 
                        void Reset();
                        void MoveFrom(CWebBrowser&&);
 
                private:
                        class CEventSink : public DWebBrowserEvents2
                        {
                        public:
                                                                                CEventSink(HWND);
                                virtual ~CEventSink();
 
                                //IUnknown
                                STDMETHODIMP QueryInterface(const IID&, void**);
                                STDMETHODIMP_(ULONG) AddRef();
                                STDMETHODIMP_(ULONG) Release();
 
                                //IDispatch
                                STDMETHODIMP GetTypeInfoCount(UINT*);
                                STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo**);
                                STDMETHODIMP GetIDsOfNames(const IID&, LPOLESTR*, UINT, LCID, DISPID*);
                                STDMETHODIMP Invoke(DISPID, const IID&, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*);
 
                        private:
                                ULONG m_refCount;
                                HWND m_browserWnd;
                        };
 
                        static void EnsureIE9ModeIsActivated();
                        static UnknownPtr WebBrowserClientSiteFactory(HWND);
 
                        static LRESULT CALLBACK MsgFilterHook(int, WPARAM, LPARAM);
                        static void RegisterFilterHook(CWindow*);
                        static void UnregisterFilterHook(CWindow*);
                        static void ExchangeFilterHook(CWindow*, CWindow*);
 
                        static ULONG __declspec(thread) g_hookCount;
                        static HHOOK __declspec(thread) g_hookHandle;
                        static std::set<CWindow*> g_hookListeners;
 
                        CComPtr<IWebBrowser2> m_webBrowser;
                        CComPtr<IConnectionPoint> m_eventsConnectionPoint;
                        CComPtr<CEventSink> m_eventSink;
                        DWORD m_adviseCookie;
                };
        };
}


suserver_0.06/include/win32/Edit.h

@@ -0,0 +1,23 @@
#pragma once
 
#include "Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CEdit : public CWindow
                {
                public:
                                                CEdit(HWND = 0);
                                                CEdit(HWND, const RECT&, const TCHAR* = _T(""), unsigned long = 0, unsigned long = WS_EX_CLIENTEDGE);
 
                        CEdit& operator =(CEdit&&);
 
                        void SetSelection(int, int);
                        void ReplaceSelectionA(bool, const char*);
                        void SetTextLimit(int);
                        void SetLeftMargin(unsigned int);
                };
        }
}


suserver_0.06/include/win32/Progress.h

@@ -0,0 +1,21 @@
#pragma once
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CProgress : public CWindow
                {
                public:
                                                        CProgress(HWND = 0);
 
                        CProgress& operator =(CProgress&&);
 
                        void SetState(uint32);
                        void SetPosition(uint32);
                        void SetRange(uint32, uint32);
                };
        }
}


suserver_0.06/include/win32/Button.h

@@ -0,0 +1,25 @@
#pragma once
 
#include "Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CButton : public CWindow
                {
                public:
                                                CButton(HWND = 0);
                                                CButton(const TCHAR*, HWND, const RECT&, unsigned long = 0);
 
                        CButton& operator =(CButton&&);
 
                        bool GetCheck();
                        void SetCheck(bool = true);
                        void ResetCheck();
 
                        void SetBitmap(HBITMAP);
                        void SetIcon(HICON);
                };
        }
}


suserver_0.06/include/win32/DblBufferedCtrl.h

@@ -0,0 +1,79 @@
#ifndef _DBLBUFFEREDCTRL_H_
#define _DBLBUFFEREDCTRL_H_
 
#include "win32/Window.h"
 
namespace Framework
{
    namespace Win32
    {
        template <typename Control> class CDblBufferedCtrl : public CWindow
        {
        public:
                CDblBufferedCtrl(Control* pControl)
            {
                m_pControl = pControl;
                m_hWnd = m_pControl->m_hWnd;
                SubClass();
            }
 
            virtual ~CDblBufferedCtrl()
            {
                delete m_pControl;
            }
 
            Control* GetControl()
            {
                return m_pControl;
            }
 
        protected:
            long OnWndProc(unsigned int nMsg, WPARAM wParam, LPARAM lParam)
            {
                    switch(nMsg)
                    {
                    case WM_ERASEBKGND:
                            return FALSE;
                            break;
 
                    case WM_PAINT:
                    {
                                PAINTSTRUCT ps;
                                HDC hWDC, hDC;
                                RECT rwin;
                                HBITMAP hBM;
 
                                BeginPaint(m_hWnd, &ps);
                                hWDC = ps.hdc;
 
                        rwin = m_pControl->GetClientRect();
 
                                hDC = CreateCompatibleDC(hWDC);
                                hBM = CreateCompatibleBitmap(hWDC, rwin.right, rwin.bottom);
                                SelectObject(hDC, hBM);
 
                                CallWindowProc(m_baseWndProc, m_hWnd, WM_PRINT, (WPARAM)hDC, PRF_CLIENT | PRF_ERASEBKGND);
 
                                BitBlt(hWDC, 0, 0, rwin.right, rwin.bottom, hDC, 0, 0, SRCCOPY);
 
                                DeleteObject(hBM);
                                DeleteDC(hDC);
 
                                EndPaint(m_hWnd, &ps);
 
                                return TRUE;
                    }
 
                            break;
                    }
 
                    return static_cast<long>(CallWindowProc(m_baseWndProc, m_hWnd, nMsg, wParam, lParam));
            }
 
        private:
            Control* m_pControl;
        };
    }
}
 
#endif


suserver_0.06/include/win32/Static.h

@@ -0,0 +1,24 @@
#ifndef _STATIC_H_
#define _STATIC_H_
 
#include "Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CStatic : public CWindow
                {
                public:
                                                        CStatic(HWND = 0);
                                                        CStatic(HWND, const RECT&, unsigned long = 0);
                                                        CStatic(HWND, const TCHAR*, unsigned long = 0);
 
                        CStatic& operator =(CStatic&&);
 
                        void SetIcon(HANDLE);
                };
        }
}
 
#endif


suserver_0.06/include/win32/ComboBox.h

@@ -0,0 +1,29 @@
#pragma once
 
#include "Window.h"
#include "Types.h"
 
namespace Framework
{
        namespace Win32
        {
                class CComboBox : public CWindow
                {
                public:
                                                        CComboBox(HWND = 0);
                                                        CComboBox(HWND, const RECT&, unsigned long = 0);
 
                        CComboBox& operator =(CComboBox&&);
 
                        unsigned int AddString(const TCHAR*);
                        int GetSelection();
                        void SetSelection(int);
                        unsigned int GetItemCount();
                        void SetItemData(unsigned int, uint32);
                        uint32 GetItemData(unsigned int);
                        int FindItemData(uint32);
                        void FixHeight(unsigned int);
                        void ResetContent();
                };
        }
}


suserver_0.06/include/win32/Win32Defs.h

@@ -0,0 +1,9 @@
#pragma once
 
#include <Windows.h>
 
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#define FRAMEWORK_WIN_DESKTOP
#else
#define FRAMEWORK_WIN_APP
#endif


suserver_0.06/include/win32/CustomDrawn.h

@@ -0,0 +1,28 @@
#pragma once
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CCustomDrawn : public virtual CWindow
                {
                protected:
                                                        CCustomDrawn();
                        virtual ~CCustomDrawn();
 
                        virtual void Paint(HDC) = 0;
 
                        virtual long OnEraseBkgnd() override;
                        virtual long OnPaint() override;
                        virtual long OnSize(unsigned int, unsigned int, unsigned int) override;
 
                private:
                        void RecreateBitmap(HDC);
                        void InvalidateBitmap();
                        HBITMAP m_Bitmap;
                        HDC m_MemDc;
                };
        }
}


suserver_0.06/include/win32/DefaultWndClass.h

@@ -0,0 +1,15 @@
#pragma once
 
#include <tchar.h>
 
namespace Framework
{
        namespace Win32
        {
                class CDefaultWndClass
                {
                public:
                        static const TCHAR* GetName();
                };
        }
}


suserver_0.06/include/win32/TreeView.h

@@ -0,0 +1,61 @@
#ifndef _TREEVIEW_H_
#define _TREEVIEW_H_
 
#include "Window.h"
#include <commctrl.h>
 
namespace Framework
{
        namespace Win32
        {
                class CTreeView : public virtual CWindow
                {
                public:
                                                        CTreeView(HWND, const RECT&, unsigned long = 0, unsigned long = WS_EX_CLIENTEDGE);
                        HTREEITEM InsertItem(TVINSERTSTRUCT*);
                        HTREEITEM InsertItem(HTREEITEM, const TCHAR*);
                        HTREEITEM GetSelection();
                        bool GetItem(HTREEITEM, TVITEM*);
                        HTREEITEM GetItemParent(HTREEITEM);
                        void GetItemText(HTREEITEM, TCHAR*, size_t);
                        std::tstring GetItemText(HTREEITEM);
                        void* GetItemParam(HTREEITEM);
                        void GetItemLabelRect(HTREEITEM, RECT*);
                        void SetItem(HTREEITEM, TVITEM*);
                        void SetItemText(HTREEITEM, const TCHAR*);
                        void SetItemParam(HTREEITEM, void*);
                        void SetItemParam(HTREEITEM, unsigned int);
                        void SetImageList(HIMAGELIST);
                        HTREEITEM GetRoot();
                        HTREEITEM GetChild(HTREEITEM);
                        HTREEITEM GetNextSibling(HTREEITEM);
                        bool SetSelection(HTREEITEM);
                        bool Expand(HTREEITEM, unsigned int = TVE_EXPAND);
                        void DeleteChildren(HTREEITEM);
                        bool DeleteAllItems();
                        void SortChildren(HTREEITEM, bool);
 
                        //Some templates
                        template <typename Type>
                        Type GetItemParam(HTREEITEM hItem)
                        {
                                TVITEM Item;
                                memset(&Item, 0, sizeof(TVITEM));
                                Item.hItem = hItem;
                                Item.mask = TVIF_PARAM;
 
                                GetItem(hItem, &Item);
 
                                return static_cast<Type>(Item.lParam);
                        }
 
                        template <typename Type>
                        Type* GetItemParamPtr(HTREEITEM hItem)
                        {
                                return reinterpret_cast<Type*>(GetItemParam(hItem));
                        }
                };
        }
}
 
#endif

\ No newline at end of file


suserver_0.06/include/win32/Header.h

@@ -0,0 +1,33 @@
#ifndef _HEADER_H_
#define _HEADER_H_
 
#include "win32/Window.h"
#include <commctrl.h>
 
namespace Framework
{
        namespace Win32
        {
                class CHeader : public CWindow
                {
                public:
                                        CHeader(HWND);
                                        CHeader(HWND, const RECT&, unsigned long = 0, unsigned long = 0);
 
                        void GetItem(unsigned int, HDITEM*);
                        void SetItem(unsigned int, HDITEM*);
 
                        int InsertItem(const TCHAR*);
                        int InsertItem(const TCHAR*, unsigned int);
                        int InsertItem(unsigned int, HDITEM*);
 
                        void GetItemRect(unsigned int, RECT*);
                        int GetItemCount();
 
                        void SetItemWidth(unsigned int, unsigned int);
                        void SetItemWidth(unsigned int, double);
                };
        }
}
 
#endif


suserver_0.06/include/win32/ColumnTreeView.h

@@ -0,0 +1,46 @@
#ifndef _COLUMNTREEVIEW_H_
#define _COLUMNTREEVIEW_H_
 
#include "win32/TreeView.h"
#include "win32/Header.h"
#include "win32/DblBufferedCtrl.h"
 
namespace Framework
{
 
        namespace Win32
        {
 
                class CColumnTreeView : public CWindow
                {
                public:
                        struct MESSAGE : public NMHDR
                        {
                                NMHDR* pOriginalMsg;
                        };
                                                                                        CColumnTreeView(HWND, const RECT&, unsigned long = 0);
                        virtual ~CColumnTreeView();
                        CHeader* GetHeader();
                        CTreeView* GetTreeView();
 
                protected:
                        long OnSize(unsigned int, unsigned int, unsigned int);
                        long OnEraseBkgnd();
                        long OnNotify(WPARAM, NMHDR*);
 
                private:
                        void UpdateLayout();
                        void ComputeHeaderHeight();
                        void DrawColumnLines(HDC);
                        void DrawItem(NMTVCUSTOMDRAW*);
 
                        unsigned int m_nHeaderHeight;
                        CDblBufferedCtrl<CTreeView>* m_pTreeView;
                        CHeader* m_pHeader;
                };
 
        }
 
}
 
#endif


suserver_0.06/include/win32/StatusBar.h

@@ -0,0 +1,29 @@
#ifndef _WIN32_STATUSBAR_H_
#define _WIN32_STATUSBAR_H_
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
 
                class CStatusBar : public CWindow
                {
                public:
                                                        CStatusBar(HWND);
                        virtual ~CStatusBar();
 
                        void SetText(unsigned int, const TCHAR*);
                        void SetParts(unsigned int, const double*);
 
                        void RefreshGeometry();
 
                        unsigned int GetHeight();
                        RECT GetRect();
                };
        }
 
}
 
#endif


suserver_0.06/include/win32/InputBox.h

@@ -0,0 +1,47 @@
#ifndef _INPUTBOX_H_
#define _INPUTBOX_H_
 
#include "win32/Window.h"
#include "win32/Button.h"
#include "win32/Edit.h"
#include "layout/VerticalLayout.h"
 
namespace Framework
{
        namespace Win32
        {
                class CInputBox : public CWindow
                {
                public:
                                                                                CInputBox(const TCHAR*, const TCHAR*, const TCHAR*);
                                                                                ~CInputBox();
                        const TCHAR* GetValue(HWND);
 
                        void SetIsMultiline(bool);
 
                protected:
                        long OnCommand(unsigned short, unsigned short, HWND);
                        long OnSysCommand(unsigned int, LPARAM);
 
                private:
                        void RestoreFocus();
                        void RefreshLayout();
                        void ConfirmDialog();
                        void CancelDialog();
                        HACCEL CreateAccelerators();
 
                        std::tstring m_sTitle;
                        std::tstring m_sPrompt;
                        std::tstring m_sValue;
 
                        bool m_nCancelled;
                        bool m_isMultiline;
                        CButton* m_pOk;
                        CButton* m_pCancel;
                        CEdit* m_pValue;
                        FlatLayoutPtr m_layout;
                };
        }
}
 
#endif

\ No newline at end of file


suserver_0.06/include/win32/Dialog.h

@@ -0,0 +1,76 @@
#ifndef _DIALOG_H_
#define _DIALOG_H_
 
#include <vector>
#include <string>
#include "Stream.h"
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CDialog : public CWindow
                {
                public:
                                                                        CDialog(const TCHAR*, HWND = NULL);
                        virtual ~CDialog();
 
                        HWND GetItem(int);
 
                        void DoModal();
 
                protected:
                        unsigned int Destroy();
 
                private:
                        struct SZ_OR_ORD
                        {
                                WORD isString;
                                std::wstring str;
                                WORD ord;
                        };
 
                        struct DIALOGTEMPLATE
                        {
                                typedef std::vector<uint8> ByteArray;
 
                                WORD dlgVer;
                                WORD signature;
                                DWORD helpID;
                                DWORD exStyle;
                                DWORD style;
                                WORD cDlgItems;
                                short x;
                                short y;
                                short cx;
                                short cy;
                                SZ_OR_ORD menu;
                                SZ_OR_ORD windowClass;
                                std::wstring title;
                                WORD pointsize;
                                WORD weight;
                                BYTE italic;
                                BYTE charset;
                                std::wstring typeface;
 
                                ByteArray dialogItemData;
                        };
 
                        static INT_PTR WINAPI DialogProc(HWND, UINT, WPARAM, LPARAM);
 
                        static std::wstring ReadString(CStream&);
                        static void WriteString(const std::wstring&, CStream&);
 
                        static SZ_OR_ORD ReadSzOrOrd(CStream&);
                        static void WriteSzOrOrd(const SZ_OR_ORD&, CStream&);
 
                        static DIALOGTEMPLATE ReadDialogTemplate(CStream&);
                        static void WriteDialogTemplate(DIALOGTEMPLATE&, CStream&);
 
                        bool m_isModal;
                };
        };
}
 
#endif


suserver_0.06/include/win32/ModalWindow.h

@@ -0,0 +1,27 @@
#ifndef _MODALWINDOW_H_
#define _MODALWINDOW_H_
 
#include "win32/Window.h"
 
namespace Framework
{
        namespace Win32
        {
                class CModalWindow : public virtual CWindow
                {
                public:
                                                        CModalWindow(HWND);
                        virtual ~CModalWindow();
                        void DoModal();
 
                protected:
                        virtual void OnEscPressed();
 
                        unsigned int Destroy();
                        long OnSysCommand(unsigned int, LPARAM);
                        void UnModalWindow();
                };
        }
}
 
#endif


suserver_0.06/include/win32/DefaultFonts.h

@@ -0,0 +1,23 @@
#ifndef _DEFAULTFONTS_H_
#define _DEFAULTFONTS_H_
 
#include "GdiObj.h"
 
namespace Framework
{
        namespace Win32
        {
                class CDefaultFonts
                {
                public:
                        static HFONT GetMessageFont();
                        static void GetNonClientMetrics(NONCLIENTMETRICS&);
 
                private:
                        static HFONT CreateMessageFont();
                        static CFont m_messageFont;
                };
        }
}
 
#endif


suserver_0.06/include/win32/TaskBarList.h

@@ -0,0 +1,41 @@
#ifndef _WIN32_TASKBARLIST_H_
#define _WIN32_TASKBARLIST_H_
 
#include "win32/Window.h"
#include <shobjidl.h>
#include <vector>
 
namespace Framework
{
        namespace Win32
        {
                class CTaskBarList
                {
                public:
                                                                CTaskBarList();
                        virtual ~CTaskBarList();
 
                        void Initialize(HWND);
                        bool IsInitialized() const;
 
                        void CreateThumbButtons(unsigned int, const UINT*);
                        void SetThumbButtonText(UINT, const TCHAR*);
                        void SetThumbButtonIcon(UINT, HICON);
                        void SetThumbButtonEnabled(UINT, bool);
 
                        UINT GetCreatedMessage() const;
 
                private:
                        typedef std::vector<THUMBBUTTON> ButtonArray;
 
                        ITaskbarList3* m_taskBarList;
 
                        UINT m_buttonCreatedMessage;
                        bool m_thumbButtonsCreated;
 
                        HWND m_ownerWnd;
                };
        }
}
 
#endif


suserver_0.06/include/win32/ToolTip.h

@@ -0,0 +1,33 @@
#ifndef _TOOLTIP_H_
#define _TOOLTIP_H_
 
#include "win32/Window.h"
#include <commctrl.h>
 
namespace Framework
{
    namespace Win32
    {
            class CToolTip : public CWindow
            {
            public:
                                                    CToolTip(HWND);
                    void Activate(bool);
            void TrackActivate(unsigned int, bool);
            void TrackPosition(int, int);
            void AddTool(HWND, const TCHAR*);
                    unsigned int AddTool(const RECT&, const TCHAR*);
            unsigned int AddTrackTool(const TCHAR*);
            unsigned int GetToolCount();
            void SetToolText(UINT_PTR, const TCHAR*);
                    void DeleteTool(unsigned int);
                    void DeleteAllTools();
 
            private:
            TOOLINFO GetTool(UINT_PTR);
                    HWND m_hParent;
            };
    }
}
 
#endif


suserver_0.06/include/win32/MDIClient.h

@@ -0,0 +1,25 @@
#ifndef _MDICLIENT_H_
#define _MDICLIENT_H_
 
#include "Window.h"
 
namespace Framework
{
    namespace Win32
    {
            class CMDIClient : public CWindow
            {
            public:
                                            CMDIClient(HWND, HMENU);
                        virtual ~CMDIClient();
 
                        void DestroyChild(HWND);
                    void Cascade();
                    void TileHorizontal();
                    void TileVertical();
            HWND GetActiveWindow();
            };
    }
}
 
#endif

\ No newline at end of file


suserver_0.06/include/win32/MDIFrame.h

@@ -0,0 +1,26 @@
#ifndef _MDIFRAME_H_
#define _MDIFRAME_H_
 
#include "Window.h"
#include "MDIClient.h"
 
namespace Framework
{
    namespace Win32
    {
            class CMDIFrame : public CWindow
            {
            public:
                                                    CMDIFrame();
                    virtual ~CMDIFrame();
 
                protected:
                    virtual long OnWndProc(unsigned int, WPARAM, LPARAM);
                    void CreateClient(HMENU);
 
                    CMDIClient* m_pMDIClient;
            };
    }
}
 
#endif

\ No newline at end of file


suserver_0.06/include/win32/FileDialog.h

@@ -0,0 +1,33 @@
#ifndef _FILEDIALOG_H_
#define _FILEDIALOG_H_
 
#include "win32/Window.h"
#include <list>
 
namespace Framework
{
        namespace Win32
        {
                class CFileDialog
                {
                public:
            typedef std::list<std::tstring> PathList;
 
                                                        CFileDialog(unsigned int bufferSize = MAX_PATH);
                        virtual ~CFileDialog();
 
            const TCHAR* GetPath() const;
            PathList GetMultiPaths() const;
 
                        int SummonOpen(HWND);
            int SummonSave(HWND);
 
            OPENFILENAME m_OFN;
 
                private:
            TCHAR* m_sFile;
                };
        }
}
 
#endif


suserver_0.06/include/win32/GuidUtils.h

@@ -0,0 +1,97 @@
#ifndef _GUIDUTILS_H_
#define _GUIDUTILS_H_
 
#include <iostream>
#include "lexical_cast_ex.h"
 
static bool operator < (const GUID& guid1, const GUID& guid2)
{
    return memcmp(&guid1, &guid2, sizeof(GUID)) < 0;
}
 
static std::istream& operator >>(std::istream& Input, GUID& rGUID)
{
    char nTemp[9];
 
    //Data 1
    Input.read(nTemp, 8);
    nTemp[8] = 0;
    rGUID.Data1 = lexical_cast_hex<std::string>(nTemp);
 
    //Validation
    Input.read(nTemp, 1);
    if(nTemp[0] != '-')
    {
        throw std::exception();
    }
 
    unsigned short* pShortVals[2] =
    {
        &rGUID.Data2,
        &rGUID.Data3,
    };
 
    //Data2, 3
    for(unsigned int i = 0; i < 2; i++)
    {
        Input.read(nTemp, 4);
        nTemp[4] = 0;
        *pShortVals[i] = lexical_cast_hex<std::string>(nTemp);
 
        //Validation
        Input.read(nTemp, 1);
        if(nTemp[0] != '-')
        {
            throw std::exception();
        }
    }
 
    for(unsigned int i = 0; i < 2; i++)
    {
        Input.read(nTemp, 2);
        nTemp[2] = 0;
        rGUID.Data4[i] = lexical_cast_hex<std::string>(nTemp);
    }
 
    //Validation
    Input.read(nTemp, 1);
    if(nTemp[0] != '-')
    {
        throw std::exception();
    }
 
    for(unsigned int i = 2; i < 8; i++)
    {
        Input.read(nTemp, 2);
        nTemp[2] = 0;
        rGUID.Data4[i] = lexical_cast_hex<std::string>(nTemp);
    }
 
    return Input;
}
 
static std::ostream& operator <<(std::ostream& Output, const GUID& rGUID)
{
    //{CCCCCCCC-CCCC-CCCC-CCCC-CCCCCCCCCCCC}
 
    Output << std::hex << std::uppercase << std::setfill('0');
    Output << std::setw(8) << rGUID.Data1 << '-';
    Output << std::setw(4) << rGUID.Data2 << '-';
    Output << std::setw(4) << rGUID.Data3 << '-';
 
    for(unsigned int i = 0; i < 2; i++)
    {
        Output << std::setw(2) << static_cast<unsigned int>(rGUID.Data4[i]);
    }
 
    Output << '-';
 
    for(unsigned int i = 2; i < 8; i++)
    {
        Output << std::setw(2) << static_cast<unsigned int>(rGUID.Data4[i]);
    }
 
    return Output;
}
 
#endif


suserver_0.06/include/win32/AcceleratorTableGenerator.h

@@ -0,0 +1,28 @@
#ifndef _ACCELERATORTABLEGENERATOR_H_
#define _ACCELERATORTABLEGENERATOR_H_
 
#include "Window.h"
#include <vector>
 
namespace Framework
{
    namespace Win32
    {
        class CAcceleratorTableGenerator
        {
        public:
                                    CAcceleratorTableGenerator();
            virtual ~CAcceleratorTableGenerator();
 
            void Insert(unsigned int, unsigned int, unsigned int);
            HACCEL Create();
 
        private:
            typedef std::vector<ACCEL> AcceleratorTableType;
 
            AcceleratorTableType m_table;
        };
    }
}
 
#endif


suserver_0.06/include/win32/LayoutWindow.h

@@ -0,0 +1,37 @@
#ifndef _LAYOUTWINDOW_H_
#define _LAYOUTWINDOW_H_
 
#include "Window.h"
#include "layout/LayoutObject.h"
 
namespace Framework
{
    namespace Win32
    {
        class CLayoutWindow : public CLayoutObject
        {
        public:
            virtual ~CLayoutWindow();
 
            static LayoutObjectPtr CreateButtonBehavior(unsigned int, unsigned int, CWindow*);
            static LayoutObjectPtr CreateTextBoxBehavior(unsigned int, unsigned int, CWindow*);
            static LayoutObjectPtr CreateCustomBehavior(unsigned int, unsigned int, unsigned int, unsigned int, CWindow*, bool = true);
 
            unsigned int GetPreferredWidth();
            unsigned int GetPreferredHeight();
            void RefreshGeometry();
 
        private:
                                                    CLayoutWindow(unsigned int, unsigned int, unsigned int, unsigned int, CWindow*, bool = true);
 
            CWindow* m_pWindow;
            unsigned int m_nPrefWidth;
            unsigned int m_nPrefHeight;
            bool m_nUseNoCopy;
 
            };
    }
}
 
 
#endif


suserver_0.06/include/win32/Layouts.h

@@ -0,0 +1,10 @@
#ifndef _LAYOUTS_H_
#define _LAYOUTS_H_
 
#include "../layout/VerticalLayout.h"
#include "../layout/HorizontalLayout.h"
#include "../layout/GridLayout.h"
#include "../layout/LayoutStretch.h"
#include "LayoutWindow.h"
 
#endif


suserver_0.06/include/win32/FindFile.h

@@ -0,0 +1,26 @@
#ifndef _FINDFILE_H_
#define _FINDFILE_H_
 
#include "win32/Window.h"
 
namespace Framework
{
    namespace Win32
    {
        class CFindFile
        {
        public:
                                CFindFile(const TCHAR*);
            virtual ~CFindFile();
 
            bool GetNext(WIN32_FIND_DATA*);
 
        private:
            WIN32_FIND_DATA m_FindData;
            HANDLE m_Handle;
            bool m_nDone;
        };
    }
}
 
#endif


suserver_0.06/include/win32/ScrollBar.h

@@ -0,0 +1,29 @@
#ifndef _SCROLLBAR_H_
#define _SCROLLBAR_H_
 
#include <windows.h>
 
namespace Framework
{
    namespace Win32
    {
        class CScrollBar
        {
        public:
                        CScrollBar(HWND, int);
            virtual ~CScrollBar();
 
            int GetPosition() const;
            int GetThumbPosition() const;
 
            void SetPosition(int);
            void SetRange(int, int);
 
        private:
            HWND m_hWnd;
            int m_nBar;
        };
    }
};
 
#endif


suserver_0.06/include/win32/RichTextEdit.h

@@ -0,0 +1,30 @@
#ifndef _RICHTEXTEDIT_H_
#define _RICHTEXTEDIT_H_
 
#include "win32/Window.h"
#include <richedit.h>
 
namespace Framework
{
    namespace Win32
    {
        class CRichTextEdit : public CWindow
        {
        public:
                        CRichTextEdit(HWND, const RECT&, DWORD, DWORD);
            virtual ~CRichTextEdit();
 
            int GetCharFromPosition(int, int);
            POINTL GetPositionFromChar(int);
            void SetSelection(int, int);
            void SetSelectionAsLink(bool = true);
            void SetEventMask(unsigned int);
 
        private:
 
        };
 
    }
}
 
#endif


suserver_0.06/include/win32/MDIChild.h

@@ -0,0 +1,22 @@
#ifndef _MDICHILD_H_
#define _MDICHILD_H_
 
#include "Window.h"
 
namespace Framework
{
    namespace Win32
    {
            class CMDIChild : public CWindow
            {
            public:
                    void Create(unsigned long, const TCHAR*, const TCHAR*, unsigned long, RECT*, HWND, void*);
 
            protected:
                    long OnWndProc(unsigned int, WPARAM, LPARAM);
 
            };
    }
}
 
#endif

\ No newline at end of file


suserver_0.06/include/win32/MemoryDeviceContext.h

@@ -0,0 +1,19 @@
#ifndef _MEMORYDEVICECONTEXT_H_
#define _MEMORYDEVICECONTEXT_H_
 
#include "DeviceContext.h"
 
namespace Framework
{
        namespace Win32
        {
                class CMemoryDeviceContext : public CDeviceContext
                {
                public:
                                                CMemoryDeviceContext(HDC);
                        virtual ~CMemoryDeviceContext();
                };
        }
}
 
#endif


suserver_0.06/include/StdStream.h

@@ -0,0 +1,40 @@
#pragma once
 
#include "Stream.h"
#include <stdio.h>
 
namespace Framework
{
 
        class CStdStream : public CStream
        {
        public:
                                                CStdStream();
                                                CStdStream(CStdStream&&);
                explicit CStdStream(FILE*);
                                                CStdStream(const char*, const char*);
                                                CStdStream(const wchar_t*, const wchar_t*);
                virtual ~CStdStream();
 
                void Clear();
                bool IsEmpty() const;
 
                                                operator FILE*() const;
                CStdStream& operator =(CStdStream&&);
 
                void Seek(int64, STREAM_SEEK_DIRECTION) override;
                uint64 Tell() override;
                uint64 Read(void*, uint64) override;
                uint64 Write(const void*, uint64) override;
                bool IsEOF() override;
                void Flush() override;
                void Close();
 
        private:
                                                CStdStream(const CStdStream&) {}
                CStdStream& operator =(const CStdStream&) { return *this; }
 
                FILE* m_file = nullptr;
        };
 
}


suserver_0.06/include/layout/LayoutStretch.h

@@ -0,0 +1,20 @@
#pragma once
 
#include "LayoutObject.h"
 
namespace Framework
{
 
        class CLayoutStretch : public CLayoutObject
        {
        public:
                                                                        CLayoutStretch(unsigned int, unsigned int);
 
                static LayoutObjectPtr Create(unsigned int = 1, unsigned int = 1);
 
                unsigned int GetPreferredWidth() override;
                unsigned int GetPreferredHeight() override;
                void RefreshGeometry() override;
        };
 
}


suserver_0.06/include/layout/GridLayout.h

@@ -0,0 +1,42 @@
#pragma once
 
#include "LayoutObject.h"
#include "LayoutBase.h"
#include <boost/multi_array.hpp>
 
namespace Framework
{
        class CGridLayout;
        typedef std::shared_ptr<CGridLayout> GridLayoutPtr;
 
        class CGridLayout : public CLayoutObject
        {
        public:
                                                                CGridLayout(unsigned int, unsigned int, unsigned int);
                virtual ~CGridLayout();
 
                static GridLayoutPtr Create(unsigned int, unsigned int, unsigned int = LAYOUT_DEFAULT_SPACING);
 
                unsigned int GetPreferredWidth() override;
                unsigned int GetPreferredHeight() override;
                void RefreshGeometry() override;
 
                void SetObject(unsigned int, unsigned int, const LayoutObjectPtr&);
 
        private:
                typedef boost::multi_array<LayoutObjectPtr, 2> GridArray;
 
                void RebuildLayouts();
                CLayoutBaseItem CreateColLayoutBaseItem(unsigned int) const;
                CLayoutBaseItem CreateRowLayoutBaseItem(unsigned int) const;
 
                unsigned int m_cols;
                unsigned int m_rows;
                unsigned int m_spacing;
 
                GridArray m_objects;
 
                CLayoutBase m_horzLayout;
                CLayoutBase m_vertLayout;
        };
}


suserver_0.06/include/layout/LayoutEngine.h

@@ -0,0 +1,145 @@
#pragma once
 
#include <list>
#include "layout/LayoutObject.h"
#include "layout/VerticalLayout.h"
#include "layout/HorizontalLayout.h"
 
namespace Framework
{
        class LayoutExpression
        {
        public:
                LayoutExpression(const LayoutObjectPtr& object) :
                m_object(object)
                {
 
                }
 
                virtual ~LayoutExpression()
                {
 
                }
 
                operator LayoutObjectPtr() const
                {
                        return m_object;
                }
 
        protected:
                LayoutObjectPtr m_object;
        };
 
        class LayoutExpressionList
        {
        public:
                typedef std::list<LayoutExpression> ExpressionList;
 
                LayoutExpressionList()
                {
 
                }
 
                LayoutExpressionList(const LayoutExpression& expr)
                {
                        m_expressions.push_back(expr);
                }
 
                LayoutExpressionList(const LayoutExpression& lhs, const LayoutExpression& rhs)
                {
                        m_expressions.push_back(lhs);
                        m_expressions.push_back(rhs);
                }
 
                LayoutExpressionList& operator +(const LayoutExpression& rhs)
                {
                        m_expressions.push_back(rhs);
                        return (*this);
                }
 
                LayoutExpressionList operator +(const LayoutExpressionList& rhs) const
                {
                        const LayoutExpressionList& lhs(*this);
                        LayoutExpressionList result;
                        std::copy(lhs.m_expressions.begin(), lhs.m_expressions.end(),
                                std::back_inserter(result.m_expressions));
                        std::copy(rhs.m_expressions.begin(), rhs.m_expressions.end(),
                                std::back_inserter(result.m_expressions));
                        return result;
                }
 
                ExpressionList m_expressions;
        };
 
        //----------------------------------
        // Transformers
        //----------------------------------
 
        struct LayoutSetHorizontalStretch
        {
                LayoutSetHorizontalStretch(unsigned int value) : value(value) {}
                unsigned int value;
        };
 
        struct LayoutSetVerticalStretch
        {
                LayoutSetVerticalStretch(unsigned int value) : value(value) {}
                unsigned int value;
        };
 
        //----------------------------------
        // Operators
        //----------------------------------
 
        static LayoutExpressionList operator +(const LayoutExpression& lhs, const LayoutExpression& rhs)
        {
                return LayoutExpressionList(lhs, rhs);
        }
 
        static LayoutExpression& operator *(LayoutExpression& expression, const LayoutSetHorizontalStretch& stretch)
        {
                static_cast<LayoutObjectPtr>(expression)->SetHorizontalStretch(stretch.value);
                return expression;
        }
 
        static LayoutExpression& operator *(LayoutExpression& expression, const LayoutSetVerticalStretch& stretch)
        {
                static_cast<LayoutObjectPtr>(expression)->SetVerticalStretch(stretch.value);
                return expression;
        }
 
        //----------------------------------
        // Others
        //----------------------------------
 
        template<typename LayoutType>
        class FlatLayoutContainer : public LayoutExpression
        {
        public:
                FlatLayoutContainer(const LayoutExpressionList& contents) :
                        LayoutExpression(LayoutType::Create())
                {
                        m_layout = dynamic_cast<LayoutType*>(m_object.get());
                        if(m_layout == NULL)
                        {
                                throw std::exception();
                        }
                        for(LayoutExpressionList::ExpressionList::const_iterator exprIterator(contents.m_expressions.begin());
                                exprIterator != contents.m_expressions.end(); exprIterator++)
                        {
                                m_layout->InsertObject(*exprIterator);
                        }
                }
 
                virtual ~FlatLayoutContainer()
                {
 
                }
 
        private:
                LayoutType* m_layout;
        };
 
        typedef FlatLayoutContainer<CVerticalLayout> VerticalLayoutContainer;
        typedef FlatLayoutContainer<CHorizontalLayout> HorizontalLayoutContainer;
}


suserver_0.06/include/layout/FlatLayout.h

@@ -0,0 +1,39 @@
#pragma once
 
#include <list>
#include "LayoutObject.h"
#include "LayoutBase.h"
 
namespace Framework
{
 
        class CFlatLayout : public CLayoutObject
        {
        public:
                typedef std::list<LayoutObjectPtr> ObjectList;
                typedef ObjectList::const_iterator ObjectIterator;
 
                                                                        CFlatLayout(unsigned int, unsigned int, unsigned int = LAYOUT_DEFAULT_SPACING);
                                                                        CFlatLayout(const CFlatLayout&) = delete;
                virtual ~CFlatLayout();
 
                CFlatLayout& operator =(const CFlatLayout&) = delete;
 
                void InsertObject(const LayoutObjectPtr&);
                virtual void RefreshGeometry() override;
 
        protected:
                virtual CLayoutBaseItem CreateLayoutBaseItem(const LayoutObjectPtr&) = 0;
                virtual void SetObjectRange(const LayoutObjectPtr&, unsigned int, unsigned int) = 0;
                virtual unsigned int GetObjectPreferredSize(const LayoutObjectPtr&) = 0;
                virtual unsigned int GetLayoutSize() = 0;
                unsigned int GetPreferredSize() const;
                ObjectList m_objects;
 
        private:
                CLayoutBase m_layoutBase;
                unsigned int m_spacing;
        };
 
        typedef std::shared_ptr<CFlatLayout> FlatLayoutPtr;
}


suserver_0.06/include/layout/LayoutObject.h

@@ -0,0 +1,53 @@
#pragma once
 
#include <memory>
 
#define LAYOUT_DEFAULT_SPACING (5)
 
namespace Framework
{
        class CLayoutBaseItem;
 
        class CLayoutObject : public std::enable_shared_from_this<CLayoutObject>
        {
        public:
                                                                CLayoutObject(unsigned int, unsigned int);
                virtual ~CLayoutObject();
 
                virtual unsigned int GetPreferredWidth() = 0;
                virtual unsigned int GetPreferredHeight() = 0;
                virtual void RefreshGeometry() = 0;
 
                void SetHorizontalStretch(unsigned int);
                void SetVerticalStretch(unsigned int);
 
                unsigned int GetHorizontalStretch() const;
                unsigned int GetVerticalStretch() const;
 
                void SetLeft(unsigned int);
                void SetRight(unsigned int);
                void SetTop(unsigned int);
                void SetBottom(unsigned int);
                void SetRect(unsigned int, unsigned int, unsigned int, unsigned int);
 
                unsigned int GetLeft() const;
                unsigned int GetRight() const;
                unsigned int GetTop() const;
                unsigned int GetBottom() const;
 
                CLayoutBaseItem CreateHorizontalBaseLayoutItem();
                CLayoutBaseItem CreateVerticalBaseLayoutItem();
 
        private:
 
                unsigned int m_left = 0;
                unsigned int m_right = 0;
                unsigned int m_top = 0;
                unsigned int m_bottom = 0;
 
                unsigned int m_horizontalStretch = 0;
                unsigned int m_verticalStretch = 0;
        };
 
        typedef std::shared_ptr<CLayoutObject> LayoutObjectPtr;
};


suserver_0.06/include/layout/HorizontalLayout.h

@@ -0,0 +1,24 @@
#pragma once
 
#include "FlatLayout.h"
 
namespace Framework
{
 
        class CHorizontalLayout : public CFlatLayout
        {
        public:
                                                                CHorizontalLayout(unsigned int);
 
                static FlatLayoutPtr Create(unsigned int = LAYOUT_DEFAULT_SPACING);
                unsigned int GetPreferredWidth() override;
                unsigned int GetPreferredHeight() override;
 
        protected:
                CLayoutBaseItem CreateLayoutBaseItem(const LayoutObjectPtr&) override;
                void SetObjectRange(const LayoutObjectPtr&, unsigned int, unsigned int) override;
                unsigned int GetObjectPreferredSize(const LayoutObjectPtr&) override;
                unsigned int GetLayoutSize() override;
        };
 
}


suserver_0.06/include/layout/LayoutBaseItem.h

@@ -0,0 +1,35 @@
#pragma once
 
#include "LayoutObject.h"
 
namespace Framework
{
 
        class CLayoutBaseItem
        {
        public:
                                                        CLayoutBaseItem() = default;
                                                        CLayoutBaseItem(unsigned int, unsigned int, const LayoutObjectPtr&);
                                                        CLayoutBaseItem(unsigned int, unsigned int, unsigned int = -1);
 
                unsigned int GetPreferredSize() const;
                unsigned int GetStretch() const;
                LayoutObjectPtr GetObject() const;
                unsigned int GetKey() const;
 
                unsigned int GetRangeStart() const;
                unsigned int GetRangeEnd() const;
                void SetRange(unsigned int, unsigned int);
 
        private:
                unsigned int m_preferredSize = 0;
                unsigned int m_stretch = 0;
 
                LayoutObjectPtr m_object;
                unsigned int m_key = 0;
 
                unsigned int m_rangeStart = 0;
                unsigned int m_rangeEnd = 0;
        };
 
}


suserver_0.06/include/layout/VerticalLayout.h

@@ -0,0 +1,30 @@
#pragma once
 
#include "FlatLayout.h"
 
namespace Framework
{
 
        class CVerticalLayout : public CFlatLayout
        {
        public:
                                                                CVerticalLayout(unsigned int);
 
                static FlatLayoutPtr Create(unsigned int = LAYOUT_DEFAULT_SPACING);
 
                unsigned int GetPreferredWidth() override;
                unsigned int GetPreferredHeight() override;
 
        protected:
                CLayoutBaseItem CreateLayoutBaseItem(const LayoutObjectPtr&) override;
                void SetObjectRange(const LayoutObjectPtr&, unsigned int, unsigned int) override;
                unsigned int GetObjectPreferredSize(const LayoutObjectPtr&) override;
                unsigned int GetLayoutSize() override;
 
 
        private:
 
 
        };
 
}


suserver_0.06/include/layout/LayoutBase.h

@@ -0,0 +1,32 @@
#pragma once
 
#include <vector>
#include "LayoutBaseItem.h"
 
namespace Framework
{
 
        class CLayoutBase
        {
        public:
                typedef std::vector<CLayoutBaseItem> ItemList;
                typedef ItemList::const_iterator ItemIterator;
 
                                                                        ~CLayoutBase();
 
                void Clear();
 
                void InsertItem(const CLayoutBaseItem&);
                void ComputeRanges(unsigned int);
                unsigned int GetPreferredSize() const;
 
                const ItemList& GetItems() const;
 
        private:
                bool HasOnlyNonStretchable() const;
                unsigned int GetTotalStretchUnits() const;
 
                ItemList m_items;
        };
 
}


suserver_0.06/include/mpeg2/VLCTable.h

@@ -0,0 +1,49 @@
#pragma once
 
#include "BitStream.h"
 
namespace MPEG2
{
        struct VLCTABLEENTRY
        {
                uint32 code;
                unsigned int codeLength;
                uint32 value;
        };
 
        class CVLCTable
        {
        public:
                class CVLCTableException : public std::exception
                {
 
                };
 
                enum DECODE_STATUS
                {
                        DECODE_STATUS_SUCCESS = 0,
                        DECODE_STATUS_NOTENOUGHDATA = -1,
                        DECODE_STATUS_SYMBOLNOTFOUND = -2,
                };
 
                virtual ~CVLCTable();
 
                DECODE_STATUS TryPeekSymbol(Framework::CBitStream*, const VLCTABLEENTRY*&);
                DECODE_STATUS TryGetSymbol(Framework::CBitStream*, const VLCTABLEENTRY*&);
                DECODE_STATUS TryGetSymbol(Framework::CBitStream*, uint32&);
 
                uint32 GetSymbol(Framework::CBitStream*);
 
        protected:
                                                CVLCTable(unsigned int, VLCTABLEENTRY*, unsigned int, unsigned int*);
 
                void ThrowError(DECODE_STATUS);
 
        private:
                unsigned int m_maxBits;
                VLCTABLEENTRY* m_tableEntry;
                unsigned int m_entryCount;
                unsigned int* m_indexTable;
        };
 
};


suserver_0.06/include/mpeg2/DctCoefficientTable.h

@@ -0,0 +1,41 @@
#pragma once
 
#include "BitStream.h"
#include "VLCTable.h"
 
namespace MPEG2
{
        struct RUNLEVELPAIR
        {
                unsigned int run;
                unsigned int level;
        };
 
        enum RUNSPECIAL
        {
                RUN_ESCAPE = 102,
        };
 
        class CDctCoefficientTable : protected CVLCTable
        {
        public:
                virtual ~CDctCoefficientTable() {}
 
                virtual DECODE_STATUS TryGetRunLevelPair(Framework::CBitStream*, RUNLEVELPAIR*, bool) = 0;
                virtual DECODE_STATUS TryGetRunLevelPairDc(Framework::CBitStream*, RUNLEVELPAIR*, bool) = 0;
 
                virtual DECODE_STATUS TryIsEndOfBlock(Framework::CBitStream*, bool&) = 0;
                virtual DECODE_STATUS TrySkipEndOfBlock(Framework::CBitStream*) = 0;
 
                void GetRunLevelPair(Framework::CBitStream*, RUNLEVELPAIR*, bool);
                void GetRunLevelPairDc(Framework::CBitStream*, RUNLEVELPAIR*, bool);
 
                bool IsEndOfBlock(Framework::CBitStream*);
                void SkipEndOfBlock(Framework::CBitStream*);
 
        protected:
                                                                CDctCoefficientTable(unsigned int, VLCTABLEENTRY*, unsigned int, unsigned int*);
 
                static bool TryPeekValueOfs(Framework::CBitStream*, uint8, uint8&, uint32&);
        };
};


suserver_0.06/include/mpeg2/DctCoefficientTable0.h

@@ -0,0 +1,34 @@
#pragma once
 
#include "Singleton.h"
#include "mpeg2/DctCoefficientTable.h"
 
namespace MPEG2
{
        class CDctCoefficientTable0 : public CDctCoefficientTable, public CSingleton<CDctCoefficientTable0>
        {
        public:
                                                                                CDctCoefficientTable0();
 
                enum MAXBITS
                {
                        MAXBITS = 16,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 112,
                };
 
                DECODE_STATUS TryGetRunLevelPair(Framework::CBitStream*, RUNLEVELPAIR*, bool) override;
                DECODE_STATUS TryGetRunLevelPairDc(Framework::CBitStream*, RUNLEVELPAIR*, bool) override;
 
                DECODE_STATUS TryIsEndOfBlock(Framework::CBitStream*, bool&) override;
                DECODE_STATUS TrySkipEndOfBlock(Framework::CBitStream*) override;
 
        private:
                static RUNLEVELPAIR m_runLevelTable[ENTRYCOUNT];
                static VLCTABLEENTRY m_vlcTable[ENTRYCOUNT];
                static unsigned int m_indexTable[MAXBITS];
        };
};


suserver_0.06/include/mpeg2/DctCoefficientTable1.h

@@ -0,0 +1,34 @@
#pragma once
 
#include "Singleton.h"
#include "mpeg2/DctCoefficientTable.h"
 
namespace MPEG2
{
        class CDctCoefficientTable1 : public CDctCoefficientTable, public CSingleton<CDctCoefficientTable1>
        {
        public:
                                                                                CDctCoefficientTable1();
 
                enum MAXBITS
                {
                        MAXBITS = 16,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 112,
                };
 
                DECODE_STATUS TryGetRunLevelPair(Framework::CBitStream*, RUNLEVELPAIR*, bool) override;
                DECODE_STATUS TryGetRunLevelPairDc(Framework::CBitStream*, RUNLEVELPAIR*, bool) override;
 
                DECODE_STATUS TryIsEndOfBlock(Framework::CBitStream*, bool&) override;
                DECODE_STATUS TrySkipEndOfBlock(Framework::CBitStream*) override;
 
        private:
                static RUNLEVELPAIR m_runLevelTable[ENTRYCOUNT];
                static VLCTABLEENTRY m_vlcTable[ENTRYCOUNT];
                static unsigned int m_indexTable[MAXBITS];
        };
};


suserver_0.06/include/mpeg2/MacroblockAddressIncrementTable.h

@@ -0,0 +1,32 @@
#ifndef _MPEG2_MACROBLOCKADDRESSINCREMENTTABLE_H_
#define _MPEG2_MACROBLOCKADDRESSINCREMENTTABLE_H_
 
#include "mpeg2/VLCTable.h"
 
namespace MPEG2
{
        class CMacroblockAddressIncrementTable : public MPEG2::CVLCTable
        {
        public:
                                                                                CMacroblockAddressIncrementTable();
                static MPEG2::CVLCTable* GetInstance();
 
                enum MAXBITS
                {
                        MAXBITS = 11,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 35,
                };
 
        private:
                static MPEG2::VLCTABLEENTRY m_pTable[ENTRYCOUNT];
                static unsigned int m_pIndexTable[MAXBITS];
                static MPEG2::CVLCTable* m_pInstance;
        };
 
}
 
#endif


suserver_0.06/include/mpeg2/MacroblockTypeITable.h

@@ -0,0 +1,33 @@
#ifndef _MPEG2_MACROBLOCKTYPEITABLE_H_
#define _MPEG2_MACROBLOCKTYPEITABLE_H_
 
#include "mpeg2/VLCTable.h"
 
namespace MPEG2
{
 
        class CMacroblockTypeITable : public MPEG2::CVLCTable
        {
        public:
                                                                        CMacroblockTypeITable();
                static MPEG2::CVLCTable* GetInstance();
 
                enum MAXBITS
                {
                        MAXBITS = 2,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 2,
                };
 
        private:
                static MPEG2::VLCTABLEENTRY m_pTable[ENTRYCOUNT];
                static unsigned int m_pIndexTable[MAXBITS];
                static MPEG2::CVLCTable* m_pInstance;
        };
 
}
 
#endif


suserver_0.06/include/mpeg2/MacroblockTypePTable.h

@@ -0,0 +1,33 @@
#ifndef _MPEG2_MACROBLOCKTYPEPTABLE_H_
#define _MPEG2_MACROBLOCKTYPEPTABLE_H_
 
#include "mpeg2/VLCTable.h"
 
namespace MPEG2
{
 
        class CMacroblockTypePTable : public MPEG2::CVLCTable
        {
        public:
                                                                        CMacroblockTypePTable();
                static MPEG2::CVLCTable* GetInstance();
 
                enum MAXBITS
                {
                        MAXBITS = 6,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 7,
                };
 
        private:
                static MPEG2::VLCTABLEENTRY m_pTable[ENTRYCOUNT];
                static unsigned int m_pIndexTable[MAXBITS];
                static MPEG2::CVLCTable* m_pInstance;
        };
 
}
 
#endif


suserver_0.06/include/mpeg2/MacroblockTypeBTable.h

@@ -0,0 +1,31 @@
#ifndef _MPEG2_MACROBLOCKTYPEBTABLE_H_
#define _MPEG2_MACROBLOCKTYPEBTABLE_H_
 
#include "mpeg2/VLCTable.h"
 
namespace MPEG2
{
        class CMacroblockTypeBTable : public MPEG2::CVLCTable
        {
        public:
                                                                                CMacroblockTypeBTable();
                static CVLCTable* GetInstance();
 
                enum MAXBITS
                {
                        MAXBITS = 6,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 11,
                };
 
        private:
                static MPEG2::VLCTABLEENTRY m_pTable[ENTRYCOUNT];
                static unsigned int m_pIndexTable[MAXBITS];
                static MPEG2::CVLCTable* m_pInstance;
        };
}
 
#endif


suserver_0.06/include/mpeg2/MotionCodeTable.h

@@ -0,0 +1,31 @@
#ifndef _MPEG2_MOTIONCODETABLE_H_
#define _MPEG2_MOTIONCODETABLE_H_
 
#include "mpeg2/VLCTable.h"
 
namespace MPEG2
{
        class CMotionCodeTable : public MPEG2::CVLCTable
        {
        public:
                                                                                CMotionCodeTable();
                static CVLCTable* GetInstance();
 
                enum MAXBITS
                {
                        MAXBITS = 11,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 33,
                };
 
        private:
                static MPEG2::VLCTABLEENTRY m_pTable[ENTRYCOUNT];
                static unsigned int m_pIndexTable[MAXBITS];
                static MPEG2::CVLCTable* m_pInstance;
        };
};
 
#endif


suserver_0.06/include/mpeg2/QuantiserScaleTable.h

@@ -0,0 +1,15 @@
#ifndef _MPEG2_QUANTISERSCALETABLE_H_
#define _MPEG2_QUANTISERSCALETABLE_H_
 
namespace MPEG2
{
        class CQuantiserScaleTable
        {
        public:
                static unsigned int m_nTable0[0x20];
                static unsigned int m_nTable1[0x20];
 
        };
}
 
#endif


suserver_0.06/include/mpeg2/InverseScanTable.h

@@ -0,0 +1,14 @@
#ifndef _MPEG2_INVERSESCANTABLE_H_
#define _MPEG2_INVERSESCANTABLE_H_
 
namespace MPEG2
{
        class CInverseScanTable
        {
        public:
                static unsigned int m_nTable0[0x40];
                static unsigned int m_nTable1[0x40];
        };
}
 
#endif


suserver_0.06/include/mpeg2/CodedBlockPatternTable.h

@@ -0,0 +1,31 @@
#ifndef _MPEG2_CODEDBLOCKPATTERNTABLE_H_
#define _MPEG2_CODEDBLOCKPATTERNTABLE_H_
 
#include "mpeg2/VLCTable.h"
 
namespace MPEG2
{
        class CCodedBlockPatternTable : public CVLCTable
        {
        public:
                                                                CCodedBlockPatternTable();
                static CVLCTable* GetInstance();
 
                enum MAXBITS
                {
                        MAXBITS = 9,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 64,
                };
 
        private:
                static VLCTABLEENTRY m_pTable[ENTRYCOUNT];
                static unsigned int m_pIndexTable[MAXBITS];
                static CVLCTable* m_pInstance;
        };
}
 
#endif


suserver_0.06/include/mpeg2/DcSizeChrominanceTable.h

@@ -0,0 +1,31 @@
#ifndef _MPEG2_DCSIZECHROMINANCETABLE_H_
#define _MPEG2_DCSIZECHROMINANCETABLE_H_
 
#include "mpeg2/VLCTable.h"
 
namespace MPEG2
{
        class CDcSizeChrominanceTable : public CVLCTable
        {
        public:
                                                                CDcSizeChrominanceTable();
                static CVLCTable* GetInstance();
 
                enum MAXBITS
                {
                        MAXBITS = 10,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 12,
                };
 
        private:
                static VLCTABLEENTRY m_pTable[ENTRYCOUNT];
                static unsigned int m_pIndexTable[MAXBITS];
                static CVLCTable* m_pInstance;
        };
};
 
#endif


suserver_0.06/include/mpeg2/DcSizeLuminanceTable.h

@@ -0,0 +1,31 @@
#ifndef _MPEG2_DCSIZELUMINANCETABLE_H_
#define _MPEG2_DCSIZELUMINANCETABLE_H_
 
#include "mpeg2/VLCTable.h"
 
namespace MPEG2
{
        class CDcSizeLuminanceTable : public CVLCTable
        {
        public:
                                                                CDcSizeLuminanceTable();
                static CVLCTable* GetInstance();
 
                enum MAXBITS
                {
                        MAXBITS = 9,
                };
 
                enum ENTRYCOUNT
                {
                        ENTRYCOUNT = 12,
                };
 
        private:
                static VLCTABLEENTRY m_pTable[ENTRYCOUNT];
                static unsigned int m_pIndexTable[MAXBITS];
                static CVLCTable* m_pInstance;
        };
};
 
#endif


suserver_0.06/include/MemStream.h

@@ -0,0 +1,38 @@
#pragma once
 
#include "Stream.h"
 
namespace Framework
{
 
        class CMemStream : public CStream
        {
        public:
                                                        CMemStream();
                                                        CMemStream(const CMemStream&);
                virtual ~CMemStream();
 
                CMemStream& operator =(const CMemStream&) = delete;
 
                uint64 Read(void*, uint64);
                uint64 Write(const void*, uint64);
                uint64 Tell();
                void Seek(int64, STREAM_SEEK_DIRECTION);
                bool IsEOF();
                void ResetBuffer();
                void Allocate(unsigned int);
                void Truncate();
                uint8* GetBuffer() const;
                unsigned int GetSize() const;
 
        private:
                void CopyFrom(const CMemStream&);
 
                unsigned int m_size = 0;
                unsigned int m_grow = 0;
                unsigned int m_position = 0;
                uint8* m_data = nullptr;
                bool m_isEof = false;
        };
 
}


suserver_0.06/include/xml/Utils.h

@@ -0,0 +1,41 @@
#ifndef _XML_UTILS_H_
#define _XML_UTILS_H_
 
#include <string>
#include "Node.h"
 
namespace Framework
{
        namespace Xml
        {
                bool GetNodeStringValue(CNode*, const char*, const char**);
                bool GetNodeIntValue(CNode*, const char*, int*);
                bool GetNodeBoolValue(CNode*, const char*, bool*);
 
                std::string GetNodeStringValue(CNode*, const char*);
                int GetNodeIntValue(CNode*, const char*);
 
                bool GetAttributeStringValue(CNode*, const char*, const char**);
                bool GetAttributeStringValue(CNode*, const char*, std::string*);
                bool GetAttributeIntValue(CNode*, const char*, int*);
                bool GetAttributeFloatValue(CNode*, const char*, float*);
                bool GetAttributeBoolValue(CNode*, const char*, bool*);
 
                std::string GetAttributeStringValue(CNode*, const char*);
                int GetAttributeIntValue(CNode*, const char*);
                float GetAttributeFloatValue(CNode*, const char*);
 
                Xml::CNode* CreateNodeStringValue(const char*, const char*);
                Xml::CNode* CreateNodeIntValue(const char*, int);
                Xml::CNode* CreateNodeBoolValue(const char*, bool);
 
                AttributeType CreateAttributeStringValue(const char*, const char*);
                AttributeType CreateAttributeIntValue(const char*, int);
                AttributeType CreateAttributeBoolValue(const char*, bool);
 
                std::string EscapeText(const std::string&);
                std::string UnescapeText(const std::string&);
        }
}
 
#endif


suserver_0.06/include/xml/Node.h

@@ -0,0 +1,67 @@
#ifndef _XML_NODE_H_
#define _XML_NODE_H_
 
#include <string>
#include <list>
#include <map>
 
namespace Framework
{
 
        namespace Xml
        {
 
                typedef std::pair<std::string, std::string> AttributeType;
 
                class CNode
                {
                public:
                        typedef std::list<CNode*> NodeList;
                        typedef std::map<std::string, std::string> AttributeList;
                        typedef NodeList::iterator NodeIterator;
                        typedef AttributeList::iterator AttributeIterator;
 
                                                                                CNode();
                                                                                CNode(const char*, bool);
                                                                                ~CNode();
 
                        CNode* InsertNode(CNode*);
                        CNode* InsertTextNode(const char*);
                        CNode* InsertTagNode(const char*);
                        void InsertNodeAt(CNode*, NodeIterator&);
                        const char* GetText() const;
                        const char* GetInnerText() const;
                        bool IsTag() const;
 
                        CNode* InsertAttribute(const AttributeType&);
                        CNode* InsertAttribute(const char*, const char*);
 
                        CNode* GetParent() const;
                        CNode* GetFirstChild();
                        unsigned int GetChildCount() const;
                        const NodeList& GetChildren() const;
                        void RemoveChild(NodeIterator);
 
                        const char* GetAttribute(const char*) const;
                        unsigned int GetAttributeCount() const;
                        const AttributeList& GetAttributes() const;
 
                        CNode* Search(const char*);
                        CNode* Select(const char*);
                        NodeList SelectNodes(const char*);
 
                private:
                        template <bool> NodeList SelectNodesImpl(const char*);
 
                        std::string m_text;
                        CNode* m_parent = nullptr;
                        bool m_isTag = false;
                        NodeList m_children;
                        AttributeList m_attributes;
                };
 
        }
 
}
 
#endif


suserver_0.06/include/xml/Writer.h

@@ -0,0 +1,27 @@
#pragma once
 
#include "Stream.h"
#include "Node.h"
 
namespace Framework
{
        namespace Xml
        {
 
                class CWriter
                {
                public:
                        static void WriteDocument(CStream&, CNode*);
 
                private:
                                                                CWriter(CStream&);
                                                                ~CWriter();
                        void WriteNode(CNode*, unsigned int);
                        void DumpString(const char*);
                        void DumpTabs(unsigned int);
                        void DumpAttributes(CNode*);
                        CStream& m_stream;
                };
 
        }
}


suserver_0.06/include/xml/FilteringNodeIterator.h

@@ -0,0 +1,30 @@
#ifndef _XML_FILTERINGNODEITERATOR_H_
#define _XML_FILTERINGNODEITERATOR_H_
 
#include "Node.h"
 
namespace Framework
{
        namespace Xml
        {
                class CFilteringNodeIterator
                {
                public:
                                                                                                CFilteringNodeIterator(CNode*, const char*);
                        virtual ~CFilteringNodeIterator();
 
                        CNode* operator *();
                        CFilteringNodeIterator& operator ++(int);
                        bool IsEnd() const;
 
                private:
                        void SeekToNext();
 
                        CNode::NodeList::const_iterator m_nodeIterator;
                        CNode* m_node;
                        const char* m_filter;
                };
        }
}
 
#endif


suserver_0.06/include/xml/Parser.h

@@ -0,0 +1,54 @@
#ifndef _XML_PARSER_H_
#define _XML_PARSER_H_
 
#include "Node.h"
#include "Stream.h"
 
namespace Framework
{
 
        namespace Xml
        {
 
                class CParser
                {
                public:
                        static CNode* ParseDocument(CStream&);
 
                private:
                                                                                CParser(CStream&, CNode*);
                                                                                ~CParser();
 
                        bool Parse();
                        void DumpText();
                        bool ProcessChar_Text(char);
                        bool ProcessChar_Tag(char);
                        bool ProcessChar_AttributeName(char);
                        bool ProcessChar_AttributeValue(char);
                        bool ProcessChar_Comment(char);
 
                        enum STATE
                        {
                                STATE_TEXT,
                                STATE_TAG,
                                STATE_ATTRIBUTE_NAME,
                                STATE_ATTRIBUTE_VALUE,
                                STATE_COMMENT,
                        };
 
                        CStream& m_stream;
                        CNode* m_node;
                        std::string m_text;
                        std::string m_attributeName;
                        std::string m_attributeValue;
                        std::list<AttributeType> m_attributes;
                        STATE m_state;
                        bool m_isTagEnd;
                        bool m_tagSpace;
                };
 
        }
 
}
 
#endif


suserver_0.06/include/bitmap/Bitmap.h

@@ -0,0 +1,73 @@
#pragma once
 
#include "Types.h"
#include <functional>
 
namespace Framework
{
        class CColor
        {
        public:
                CColor()
                        : r(0), g(0), b(0), a(0)
                {
 
                }
 
                CColor(uint8 r, uint8 g, uint8 b, uint8 a)
                        : r(r), g(g), b(b), a(a)
                {
 
                }
 
                uint8 r;
                uint8 g;
                uint8 b;
                uint8 a;
        };
 
        class CBitmap
        {
        public:
                                                CBitmap();
                                                CBitmap(const CBitmap&);
                                                CBitmap(CBitmap&&);
                                                CBitmap(unsigned int, unsigned int, unsigned int);
                                                ~CBitmap();
 
                CBitmap& operator =(const CBitmap&);
                CBitmap& operator =(CBitmap&&);
 
                void Allocate(unsigned int, unsigned int, unsigned int);
                void Reset();
 
                bool IsEmpty() const;
 
                unsigned int GetPixelSize() const;
                unsigned int GetPixelsSize() const;
                unsigned int GetPitch() const;
                unsigned int GetWidth() const;
                unsigned int GetHeight() const;
                unsigned int GetBitsPerPixel() const;
 
                CColor GetPixel(unsigned int, unsigned int) const;
                void SetPixel(unsigned int, unsigned int, const CColor&);
 
                uint8* GetPixels() const;
                void Blit(const CBitmap&, unsigned int, unsigned int);
 
                CBitmap AddAlphaChannel(uint8 alphaValue) const;
                CBitmap Resize(unsigned int, unsigned int) const;
                CBitmap ResizeCanvas(unsigned int, unsigned int) const;
 
        private:
                void CopyFrom(const CBitmap&);
                void MoveFrom(CBitmap&&);
 
                unsigned int m_width;
                unsigned int m_height;
                unsigned int m_bpp;
                uint8* m_pixels;
        };
 
}


suserver_0.06/include/bitmap/TGA.h

@@ -0,0 +1,42 @@
#pragma once
 
#include "Bitmap.h"
#include "Stream.h"
 
namespace Framework
{
        class CTGA
        {
        public:
                static CBitmap ReadBitmap(CStream&);
 
        private:
                enum TGA_IMAGE_TYPE
                {
                        TGA_IMAGE_RGB = 2,
                };
 
#pragma pack(push, 1)
                struct TGA_HEADER
                {
                        uint8 idSize;
                        uint8 colorMapType;
                        uint8 imageType;
 
                        int16 colorMapStart;
                        int16 colorMapLength;
                        uint8 colorMapBits;
 
                        int16 startX;
                        int16 startY;
                        int16 width;
                        int16 height;
 
                        uint8 bits;
                        uint8 descriptor;
                };
#pragma pack(pop)
 
                static_assert(sizeof(TGA_HEADER) == 0x12, "TGA Header must be 0x12 bytes.");
        };
}


suserver_0.06/include/bitmap/BMP.h

@@ -0,0 +1,44 @@
#pragma once
 
#include <functional>
#include "Stream.h"
#include "Bitmap.h"
 
namespace Framework
{
 
        class CBMP
        {
        public:
                static CBitmap ReadBitmap(CStream&);
                static void WriteBitmap(const CBitmap&, CStream&);
 
        private:
                typedef std::function<void (CStream&, const CColor&)> PixelWriterFunction;
 
#pragma pack(push, 1)
                struct HEADER
                {
                        uint16 nID;
                        uint32 nFileSize;
                        uint32 nReserved;
                        uint32 nDataOffset;
                        uint32 nHeaderSize;
                        uint32 nWidth;
                        uint32 nHeight;
                        uint16 nPlanes;
                        uint16 nBPP;
                        uint32 nCompression;
                        uint32 nDataSize;
                        uint32 nHorzResolution;
                        uint32 nVertResolution;
                        uint32 nColors;
                        uint32 nImportantColors;
                };
#pragma pack(pop)
 
                static void PixelWriter24(CStream&, const CColor&);
                static void PixelWriter32(CStream&, const CColor&);
        };
 
}


suserver_0.06/include/bitmap/PNG.h

@@ -0,0 +1,52 @@
#pragma once
 
#include "Types.h"
#include "Stream.h"
#include "Bitmap.h"
 
namespace Framework
{
 
        class CPNG
        {
        public:
                static CBitmap ReadBitmap(CStream&);
 
        private:
                                                        CPNG();
                                                        ~CPNG();
 
                class CIHDR
                {
                public:
                        void Unserialize(CStream&);
                        unsigned int GetSamplesPerPixel();
                        unsigned int CalculateNeededBufferSize();
 
                        uint32 m_nWidth;
                        uint32 m_nHeight;
                        uint8 m_nDepth;
                        uint8 m_nColorType;
                        uint8 m_nCompression;
                        uint8 m_nFilter;
                        uint8 m_nInterlace;
                };
 
                CBitmap DoRead(CStream&);
                void UncompressIDAT();
                void SubFilter(uint8*, int, unsigned int, unsigned int);
                void UpFilter(uint8*, int, unsigned int, unsigned int);
                void AverageFilter(uint8*, int, unsigned int, unsigned int);
                void PaethFilter(uint8*, int, unsigned int, unsigned int);
                uint8 PaethPredictor(uint8, uint8, uint8);
                CBitmap CreateBitmap();
                CBitmap ConvertTo32(const CBitmap&) const;
 
                CIHDR m_IHDR;
                uint8 m_nPalette[0x300];
                uint8* m_pBuffer;
                uint8* m_pIDAT;
                unsigned int m_nIDATSize;
        };
 
}


suserver_0.06/include/bitmap/JPEG.h

@@ -0,0 +1,116 @@
#pragma once
 
#include "Stream.h"
#include "BitStream.h"
#include "Bitmap.h"
#include "idct/Interface.h"
 
namespace Framework
{
        class CJPEG
        {
        public:
                static CBitmap ReadBitmap(CStream&);
 
                enum JERROR
                {
                        JERROR_SUCCESS = 0,
                        JERROR_QTDEST_INVALID = 1,
                        JERROR_QT16BITS = 2,
                        JERROR_HTDEST_INVALID = 3,
                        JERROR_NOTBASELINE = 4,
                        JERROR_NOT3CHANNELS = 5,
                        JERROR_UNKNMARKER = 6,
                        JERROR_UNSUPPORTED_YSCALING = 7,
                };
 
        private:
 
                struct QUANTIZATIONTABLE
                {
                        uint8 nPqTq;
                        uint8* pQ;
                };
 
                struct FRAMECOMPONENT
                {
                        uint8 nC;
                        uint8 nHV;
                        uint8 nTq;
                };
 
                struct FRAME
                {
                        uint16 nType;
                        uint8 nPrecision;
                        uint16 nCY;
                        uint16 nCX;
                        uint8 nComponents;
                        FRAMECOMPONENT* pCompoment;
                };
 
                struct SCANCOMPONENT
                {
                        unsigned char nCs;
                        unsigned char nTdTa;
                };
 
                struct SCAN
                {
                        unsigned char nComponents;
                        SCANCOMPONENT* pComponent;
                        unsigned char nStartSpectral;
                        unsigned char nEndSpectral;
                        unsigned char nAhAl;
                };
 
                struct HUFFMANTABLE
                {
                        uint8 nTcTh;
                        uint8 nL[16];
                        uint8* pV[16];
                        uint16* nCodeTable;
                        int16 nMin[16];
                        int16 nMax[16];
                };
                                                                        CJPEG(Framework::CStream&);
                                                                        ~CJPEG();
 
                uint8 HuffGetBit();
                uint8 HuffDecode(HUFFMANTABLE*);
                uint32 HuffReceive(unsigned int);
                uint32 HuffExtend(uint32, unsigned int);
                void HuffGenerateSubTables(HUFFMANTABLE*);
                uint8* HuffGenerateSizeTable(HUFFMANTABLE*);
                uint16* HuffGenerateCodeTable(uint8*);
                void HuffGenerateMinMaxTables(HUFFMANTABLE*);
 
                unsigned int Decode();
                unsigned int DecodeMCU(int, uint8*, int*);
                void Draw8x8Block(unsigned int, unsigned int, uint8*, uint8*, uint8*, uint8*);
                uint8 FixRange(double);
 
                Framework::CBitmap Process();
                unsigned int ProcessSOF0();
                unsigned int ProcessDHT();
                unsigned int ProcessSOS();
                unsigned int ProcessDQT();
                void ProcessAPPx();
                void ProcessCOM();
 
                QUANTIZATIONTABLE m_Qt[4];
                FRAME m_Frame;
                SCAN m_Scan;
                HUFFMANTABLE m_DCHt[4];
                HUFFMANTABLE m_ACHt[4];
 
                //Static members
                static IDCT::CInterface* m_pIDCT;
                static unsigned char m_nZigZag[64];
 
                bool m_nHuffSkipNext;
 
                Framework::CBitStream* m_stream;
                Framework::CBitmap m_bitmap;
        };
}


suserver_0.06/include/Endian.h

@@ -0,0 +1,16 @@
#ifndef _ENDIAN_H_
#define _ENDIAN_H_
 
#include "Types.h"
 
namespace Framework
{
        class CEndian
        {
        public:
                static uint32 FromMSBF32(uint32);
                static uint32 FromLSBF32(uint32);
        };
}
 
#endif


suserver_0.06/include/mysql/Result.h

@@ -0,0 +1,38 @@
#pragma once
 
#include "MySqlDefs.h"
#include <unordered_map>
#include <string>
 
namespace Framework
{
        namespace MySql
        {
                class CResult
                {
                public:
                        typedef std::unordered_map<std::string, int> FieldIndexMap;
 
                                                        CResult(MYSQL_RES*);
                                                        CResult(CResult&&);
                        virtual ~CResult();
 
                        void Reset();
                        bool IsEmpty() const;
                        CResult& operator =(CResult&&);
 
                        MYSQL_ROW FetchRow();
                        unsigned int GetRowCount();
                        unsigned int GetFieldCount();
                        FieldIndexMap GetFieldIndices();
 
                private:
                                                        CResult(const CResult&);
                        CResult& operator =(const CResult&);
 
                        void MoveFrom(CResult&&);
 
                        MYSQL_RES* m_result;
                };
        };
}


suserver_0.06/include/mysql/AccessInfo.h

@@ -0,0 +1,20 @@
#pragma once
 
#include <string>
 
namespace Framework
{
        namespace MySql
        {
                class CAccessInfo
                {
                public:
                        CAccessInfo(const char* = "", const char* = "", const char* = "", const char* = "");
 
                        std::string address;
                        std::string userName;
                        std::string password;
                        std::string databaseName;
                };
        }
}


suserver_0.06/include/mysql/Client.h

@@ -0,0 +1,33 @@
#pragma once
 
#include "MySqlDefs.h"
#include "Result.h"
 
namespace Framework
{
        namespace MySql
        {
                class CClient
                {
                public:
                                                        CClient();
                                                        CClient(CClient&&);
                                                        CClient(const char* hostName, const char* userName, const char* password, const char* database);
                        virtual ~CClient();
 
                        void Reset();
                        bool IsEmpty() const;
                        CClient& operator =(CClient&&);
 
                        CResult Query(const char*);
 
                private:
                                                        CClient(const CClient&);
                        CClient& operator =(const CClient&);
 
                        void MoveFrom(CClient&&);
 
                        MYSQL* m_connection;
                };
        }
}


suserver_0.06/include/mysql/MySqlDefs.h

@@ -0,0 +1,6 @@
#pragma once
 
#ifdef _WIN32
#include <Windows.h>
#endif
#include <mysql.h>


suserver_0.06/include/make_unique.h

@@ -0,0 +1,38 @@
#pragma once
 
#include <memory>
 
#ifdef _MSC_VER
 
#if (_MSC_VER < 1800) //Visual C++ 2013 already has make_unique, Visual C++ 2010/2012 need a special hack
 
namespace std
{
 
#define _MAKE_UNIQUE(TEMPLATE_LIST, PADDING_LIST, LIST, COMMA, X1, X2, X3, X4) \
\
template<class T COMMA LIST(_CLASS_TYPE)> \
inline std::unique_ptr<T> make_unique(LIST(_TYPE_REFREF_ARG)) \
{ \
    return std::unique_ptr<T>(new T(LIST(_FORWARD_ARG))); \
}
 
_VARIADIC_EXPAND_0X(_MAKE_UNIQUE, , , , )
#undef _MAKE_UNIQUE
 
}
 
#endif //(_MSC_VER < 1800)
 
#else
 
namespace std
{
        template<typename T, typename ...Args>
        unique_ptr<T> make_unique( Args&& ...args )
        {
                return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
        }
}
 
#endif


suserver_0.06/include/Stream.h

@@ -0,0 +1,47 @@
#pragma once
 
#include "Types.h"
#include <string>
 
namespace Framework
{
 
        enum STREAM_SEEK_DIRECTION
        {
                STREAM_SEEK_SET = 0,
                STREAM_SEEK_END = 1,
                STREAM_SEEK_CUR = 2,
        };
 
        class CStream
        {
        public:
                virtual ~CStream();
                virtual void Seek(int64, STREAM_SEEK_DIRECTION) = 0;
                virtual uint64 Tell() = 0;
                virtual uint64 Read(void*, uint64) = 0;
                virtual uint64 Write(const void*, uint64) = 0;
                virtual bool IsEOF() = 0;
                virtual void Flush();
                virtual uint64 GetLength();
                virtual uint64 GetRemainingLength();
 
                uint8 Read8();
                uint16 Read16();
                uint32 Read32();
                uint64 Read64();
 
                uint16 Read16_MSBF();
                uint32 Read32_MSBF();
 
                float ReadFloat32();
 
                std::string ReadString();
                std::string ReadString(size_t);
 
                void Write8(uint8);
                void Write16(uint16);
                void Write32(uint32);
        };
 
}


suserver_0.06/include/LockFreeQueue.h

@@ -0,0 +1,63 @@
#pragma once
 
#include <atomic>
 
template <typename ValueType>
class CLockFreeQueue
{
public:
        CLockFreeQueue(unsigned int maxItemCount)
                : m_prodIndex(0)
                , m_consIndex(0)
                , m_itemCount(0)
                , m_maxItemCount(maxItemCount)
        {
                m_items = new ValueType[m_maxItemCount];
        }
 
        virtual ~CLockFreeQueue()
        {
                delete [] m_items;
        }
 
        bool TryPop(ValueType& item)
        {
                if(m_itemCount == 0)
                {
                        return false;
                }
 
                item = m_items[m_consIndex];
 
                m_consIndex++;
                m_consIndex %= m_maxItemCount;
 
                m_itemCount--;
 
                return true;
        }
 
        bool TryPush(const ValueType& item)
        {
                if(m_itemCount == m_maxItemCount)
                {
                        return false;
                }
 
                m_items[m_prodIndex] = item;
 
                m_prodIndex++;
                m_prodIndex %= m_maxItemCount;
 
                m_itemCount++;
 
                return true;
        }
 
private:
        ValueType* m_items;
        std::atomic<unsigned int> m_itemCount;
        unsigned int m_maxItemCount;
        unsigned int m_prodIndex;
        unsigned int m_consIndex;
};


suserver_0.06/include/Singleton.h

@@ -0,0 +1,48 @@
#pragma once
 
#include <mutex>
#include <memory>
 
template <typename Type> class CSingleton
{
public:
        static Type& GetInstance()
        {
                std::call_once(m_onceFlag,
                        [] ()
                        {
                                m_instance.reset(new Type());
                        }
                );
                return *m_instance;
        }
 
private:
        static std::unique_ptr<Type> m_instance;
        static std::once_flag m_onceFlag;
};
 
template <typename Type, typename DependantType> class CDependantSingleton
{
public:
        static Type& GetInstance()
        {
                std::call_once(m_onceFlag,
                        [] ()
                        {
                                m_instance.reset(new Type(DependantType::GetInstance()));
                        }
                );
                return *m_instance;
        }
 
private:
        static std::unique_ptr<Type> m_instance;
        static std::once_flag m_onceFlag;
};
 
template <typename Type> std::unique_ptr<Type> CSingleton<Type>::m_instance;
template <typename Type> std::once_flag CSingleton<Type>::m_onceFlag;
 
template <typename Type, typename DependantType> std::unique_ptr<Type> CDependantSingleton<Type, DependantType>::m_instance;
template <typename Type, typename DependantType> std::once_flag CDependantSingleton<Type, DependantType>::m_onceFlag;


suserver_0.06/include/string_format.h

@@ -0,0 +1,64 @@
#pragma once
 
#include <string>
#include <stdarg.h>
 
static std::string string_format(const char* format, va_list ap)
{
        int size = 256;
        std::string result;
        while(1)
        {
                result.resize(size);
                int n = vsnprintf(const_cast<char*>(result.data()), size, format, ap);
                if((n > -1) && (n < size))
                {
                        result.resize(n);
                        return result;
                }
                if (n > -1)
                {
                        size = n + 1;
                }
                else
                {
                        size *= 2;
                }
        }
        return result;
}
 
static std::wstring string_format(const wchar_t* format, va_list ap)
{
        int size = 256;
        std::wstring result;
        while(1)
        {
                result.resize(size);
                int n = vswprintf(const_cast<wchar_t*>(result.c_str()), size, format, ap);
                if((n > -1) && (n < size))
                {
                        result.resize(n);
                        return result;
                }
                if (n > -1)
                {
                        size = n + 1;
                }
                else
                {
                        size *= 2;
                }
        }
        return result;
}
 
template <typename CharType>
static std::basic_string<CharType> string_format(const CharType* format, ...)
{
        va_list ap;
        va_start(ap, format);
        auto result = string_format(format, ap);
        va_end(ap);
        return result;
}


suserver_0.06/include/Config.h

@@ -0,0 +1,113 @@
#pragma once
 
#include <string>
#include <boost/utility.hpp>
#include <boost/filesystem/path.hpp>
#include <map>
#include <mutex>
#include "xml/Node.h"
 
namespace Framework
{
        class CConfig : public boost::noncopyable
        {
        public:
                typedef boost::filesystem::path PathType;
 
                                                                                        CConfig(const PathType&, bool readonly = false);
                virtual ~CConfig();
 
                static std::string MakePreferenceName(const std::string&, const std::string& = "", const std::string& = "", const std::string& = "");
 
                void RegisterPreferenceInteger(const char*, int);
                void RegisterPreferenceBoolean(const char*, bool);
                void RegisterPreferenceString(const char*, const char*);
 
                int GetPreferenceInteger(const char*);
                bool GetPreferenceBoolean(const char*);
                const char* GetPreferenceString(const char*);
 
                bool SetPreferenceInteger(const char*, int);
                bool SetPreferenceBoolean(const char*, bool);
                bool SetPreferenceString(const char*, const char*);
 
                void Save();
                PathType GetConfigPath() const;
 
        private:
                enum PREFERENCE_TYPE
                {
                        TYPE_INTEGER,
                        TYPE_BOOLEAN,
                        TYPE_STRING,
                };
 
                class CPreference
                {
                public:
                                                                                        CPreference(const char*, PREFERENCE_TYPE);
                        virtual ~CPreference();
                        const char* GetName() const;
                        PREFERENCE_TYPE GetType() const;
                        const char* GetTypeString() const;
                        virtual void Serialize(Framework::Xml::CNode*) const;
 
                private:
                        std::string m_name;
                        PREFERENCE_TYPE m_type;
                };
 
                class CPreferenceInteger : public CPreference
                {
                public:
                                                                                        CPreferenceInteger(const char*, int);
                        virtual ~CPreferenceInteger();
                        int GetValue() const;
                        void SetValue(int);
                        virtual void Serialize(Framework::Xml::CNode*) const;
 
                private:
                        int m_value;
                };
 
                class CPreferenceBoolean : public CPreference
                {
                public:
                                                                                        CPreferenceBoolean(const char*, bool);
                        virtual ~CPreferenceBoolean();
                        bool GetValue() const;
                        void SetValue(bool);
                        virtual void Serialize(Framework::Xml::CNode*) const;
 
                private:
                        bool m_value;
                };
 
                class CPreferenceString : public CPreference
                {
                public:
                                                                                        CPreferenceString(const char*, const char*);
                        virtual ~CPreferenceString();
                        const char* GetValue() const;
                        void SetValue(const char*);
                        virtual void Serialize(Framework::Xml::CNode*) const;
 
                private:
                        std::string m_value;
                };
 
                typedef std::shared_ptr<CPreference> PreferencePtr;
                typedef std::map<std::string, PreferencePtr> PreferenceMapType;
 
                void Load();
                void InsertPreference(const PreferencePtr&);
 
                template <typename Type> std::shared_ptr<Type> FindPreference(const char*);
                template <typename Type> static std::shared_ptr<Type> CastPreference(const PreferencePtr&);
 
                PreferenceMapType m_preferences;
                std::mutex m_mutex;
                PathType m_path;
                bool m_readonly;
        };
}


suserver_0.06/include/alloca_def.h

@@ -0,0 +1,10 @@
#ifndef _ALLOCA_DEF_H_
#define _ALLOCA_DEF_H_
 
#ifdef _MSC_VER
#include <malloc.h>
#else
#include <stdlib.h>
#endif
 
#endif


suserver_0.06/include/openal/Source.h

@@ -0,0 +1,29 @@
#ifndef _OPENAL_SOURCE_H_
#define _OPENAL_SOURCE_H_
 
#include "OpenAlDef.h"
 
namespace OpenAl
{
        class CSource
        {
        public:
                                                CSource();
                virtual ~CSource();
 
                                                operator ALuint() const;
 
                ALint GetState();
 
                void Play();
                void Stop();
 
                void QueueBuffer(ALuint);
                int GetBuffersProcessed() const;
 
        private:
                ALuint m_name;
        };
};
 
#endif


suserver_0.06/include/openal/Buffer.h

@@ -0,0 +1,21 @@
#ifndef _OPENAL_BUFFER_H_
#define _OPENAL_BUFFER_H_
 
#include "OpenAlDef.h"
 
namespace OpenAl
{
        class CBuffer
        {
        public:
                                                CBuffer();
                virtual ~CBuffer();
 
                                                operator ALuint() const;
 
        private:
                ALuint m_name;
        };
};
 
#endif


suserver_0.06/include/openal/OpenAlDef.h

@@ -0,0 +1,12 @@
#ifndef _OPENALDEF_H_
#define _OPENALDEF_H_
 
#ifdef WIN32
#include <al.h>
#include <alc.h>
#else
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#endif
 
#endif


suserver_0.06/include/openal/Device.h

@@ -0,0 +1,21 @@
#ifndef _OPENAL_DEVICE_H_
#define _OPENAL_DEVICE_H_
 
#include "OpenAlDef.h"
 
namespace OpenAl
{
        class CDevice
        {
        public:
                                        CDevice(const char* = 0);
                virtual ~CDevice();
 
                                        operator ALCdevice*() const;
 
        private:
                ALCdevice* m_device;
        };
}
 
#endif


suserver_0.06/include/openal/Context.h

@@ -0,0 +1,21 @@
#ifndef _CONTEXT_H_
#define _CONTEXT_H_
 
#include "OpenAlDef.h"
 
namespace OpenAl
{
        class CContext
        {
        public:
                                                CContext(ALCdevice*, ALCint*, bool = true);
                virtual ~CContext();
 
                void MakeCurrent();
 
        private:
                ALCcontext* m_context;
        };
}
 
#endif


suserver_0.06/include/Convertible.h

@@ -0,0 +1,30 @@
#ifndef _CONVERTIBLE_H_
#define _CONVERTIBLE_H_
 
template<typename IntType>
struct convertible
{
        typedef IntType IntegerType;
 
        operator IntegerType() const
        {
                return *reinterpret_cast<const IntegerType*>(this);
        }
 
        convertible& operator <<=(IntegerType value)
        {
                *reinterpret_cast<IntegerType*>(this) = value;
                return (*this);
        }
};
 
template<typename ConvertibleType>
ConvertibleType make_convertible(typename ConvertibleType::IntegerType value)
{
        static_assert(sizeof(typename ConvertibleType::IntegerType) == sizeof(ConvertibleType), "Convertible structure size must be the same as integer type.");
        ConvertibleType result = ConvertibleType();
        *reinterpret_cast<typename ConvertibleType::IntegerType*>(&result) = value;
        return result;
}
 
#endif


suserver_0.06/include/PathUtils.h

@@ -0,0 +1,30 @@
#ifndef _PATHUTILS_H_
#define _PATHUTILS_H_
 
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
 
namespace Framework
{
        namespace PathUtils
        {
#ifdef _WIN32
                boost::filesystem::path GetPathFromCsidl(int);
                boost::filesystem::path GetRoamingDataPath();
                boost::filesystem::path GetPersonalDataPath();
                boost::filesystem::path GetAppResourcesPath();
#endif
#if defined(_POSIX_VERSION)
#if defined(__APPLE__)
                boost::filesystem::path GetSettingsPath();
                boost::filesystem::path GetRoamingDataPath();
                boost::filesystem::path GetAppResourcesPath();
#endif // DEFINED(__APPLE__)
                boost::filesystem::path GetPersonalDataPath();
#endif // DEFINED(_POSIX_VERSION)
 
                void EnsurePathExists(const boost::filesystem::path&);
        };
};
 
#endif


suserver_0.06/include/zip/ZipArchiveReader.h

@@ -0,0 +1,36 @@
#pragma once
 
#include <map>
#include <list>
#include <string>
#include <memory>
#include "ZipDefs.h"
#include "Stream.h"
 
namespace Framework
{
        class CZipArchiveReader
        {
        public:
                typedef std::map<std::string, Zip::ZIPDIRFILEHEADER> FileHeaderList;
                typedef std::shared_ptr<Framework::CStream> StreamPtr;
                typedef std::list<std::string> FileNameList;
 
                                                                                CZipArchiveReader(Framework::CStream&);
                virtual ~CZipArchiveReader();
 
                const FileHeaderList& GetFileHeaders() const;
 
                StreamPtr BeginReadFile(const char*);
                const Zip::ZIPDIRFILEHEADER* GetFileHeader(const char*) const;
                FileNameList GetFileNameList(const char*);
 
        private:
                void Read(Framework::CStream&);
                void EndReadFile(Framework::CStream*);
 
                Framework::CStream& m_stream;
                FileHeaderList m_files;
                bool m_readingLock;
        };
}


suserver_0.06/include/zip/ZipStoreStream.h

@@ -0,0 +1,26 @@
#ifndef _ZIPSTORESTREAM_H_
#define _ZIPSTORESTREAM_H_
 
#include "Stream.h"
 
namespace Framework
{
        class CZipStoreStream : public Framework::CStream
        {
        public:
                                                                CZipStoreStream(Framework::CStream&, unsigned int);
                virtual ~CZipStoreStream();
 
                virtual void Seek(int64, Framework::STREAM_SEEK_DIRECTION);
                virtual uint64 Tell();
                virtual uint64 Read(void*, uint64);
                virtual uint64 Write(const void*, uint64);
                virtual bool IsEOF();
 
        private:
                Framework::CStream& m_baseStream;
                unsigned int m_length;
        };
}
 
#endif


suserver_0.06/include/zip/ZipFile.h

@@ -0,0 +1,24 @@
#ifndef _ZIPFILE_H_
#define _ZIPFILE_H_
 
#include "Stream.h"
#include <string>
 
namespace Framework
{
        class CZipFile
        {
        public:
                                                CZipFile(const char*);
                virtual ~CZipFile();
 
                const char* GetName() const;
 
                virtual void Write(Framework::CStream&) = 0;
 
        private:
                std::string m_name;
        };
}
 
#endif


suserver_0.06/include/zip/ZipArchiveWriter.h

@@ -0,0 +1,26 @@
#ifndef _ZIPARCHIVEWRITER_H_
#define _ZIPARCHIVEWRITER_H_
 
#include <list>
#include "ZipFile.h"
#include "Stream.h"
 
namespace Framework
{
    class CZipArchiveWriter
    {
    public:
                                CZipArchiveWriter();
        virtual ~CZipArchiveWriter();
 
        void Write(Framework::CStream&);
        void InsertFile(CZipFile*);
 
    private:
        typedef std::list<CZipFile*> FileList;
 
        FileList m_files;
    };
}
 
#endif


suserver_0.06/include/zip/ZipInflateStream.h

@@ -0,0 +1,35 @@
#ifndef _ZIPINFLATESTREAM_H_
#define _ZIPINFLATESTREAM_H_
 
#include <zlib.h>
#include "Stream.h"
 
namespace Framework
{
    class CZipInflateStream : public Framework::CStream
    {
    public:
                                CZipInflateStream(Framework::CStream&, unsigned int);
        virtual ~CZipInflateStream();
 
        virtual void Seek(int64, Framework::STREAM_SEEK_DIRECTION);
            virtual uint64 Tell();
            virtual uint64 Read(void*, uint64);
            virtual uint64 Write(const void*, uint64);
            virtual bool IsEOF();
 
    private:
        enum BUFFERSIZE
        {
            BUFFERSIZE = 0x2000,
        };
 
        void FeedBuffer();
        Framework::CStream& m_baseStream;
        int m_compressedLength;
        z_stream m_zStream;
        Bytef m_inputBuffer[BUFFERSIZE];
    };
}
 
#endif


suserver_0.06/include/zip/ZipDeflateStream.h

@@ -0,0 +1,40 @@
#ifndef _ZIPDEFLATESTREAM_H_
#define _ZIPDEFLATESTREAM_H_
 
#include <zlib.h>
#include "Stream.h"
 
namespace Framework
{
    class CZipDeflateStream : public Framework::CStream
    {
    public:
                                CZipDeflateStream(Framework::CStream&);
        virtual ~CZipDeflateStream();
 
        uint32 GetCrc() const;
        uint64 GetCompressedLength() const;
        uint64 GetUncompressedLength() const;
 
        virtual void Seek(int64, Framework::STREAM_SEEK_DIRECTION);
            virtual uint64 Tell();
            virtual uint64 Read(void*, uint64);
            virtual uint64 Write(const void*, uint64);
            virtual bool IsEOF();
        virtual void Flush();
 
    private:
        enum BUFFERSIZE
        {
            BUFFERSIZE = 0x2000,
        };
 
        Framework::CStream& m_baseStream;
        uint32 m_crc;
        uint64 m_compressedLength;
        uint64 m_uncompressedLength;
        z_stream m_zStream;
    };
}
 
#endif


suserver_0.06/include/zip/ZipDefs.h

@@ -0,0 +1,78 @@
#ifndef _ZIPDEFS_H_
#define _ZIPDEFS_H_
 
#include "Types.h"
 
namespace Framework
{
    namespace Zip
    {
        enum FILEHEADER_SIG
        {
            FILEHEADER_SIG = 0x04034B50,
        };
 
        enum DIRFILEHEADER_SIG
        {
            DIRFILEHEADER_SIG = 0x02014B50,
        };
 
        enum DIRENDHEADER_SIG
        {
            DIRENDHEADER_SIG = 0x06054B50,
        };
 
    #pragma pack(push, 1)
        struct ZIPFILEHEADER
        {
            uint32 signature;
            uint16 versionNeeded;
            uint16 flags;
            uint16 compressionMethod;
            uint16 fileTime;
            uint16 fileDate;
            uint32 crc;
            uint32 compressedSize;
            uint32 uncompressedSize;
            uint16 fileNameLength;
            uint16 extraFieldLength;
        };
 
        struct ZIPDIRFILEHEADER
        {
            uint32 signature;
            uint16 versionMadeBy;
            uint16 versionNeeded;
            uint16 flags;
            uint16 compressionMethod;
            uint16 fileTime;
            uint16 fileDate;
            uint32 crc;
            uint32 compressedSize;
            uint32 uncompressedSize;
            uint16 fileNameLength;
            uint16 extraFieldLength;
            uint16 fileCommentLength;
            uint16 diskNumberStart;
            uint16 internalFileAttributes;
            uint32 externalFileAttributes;
            uint32 fileStartOffset;
        };
 
        struct ZIPDIRENDHEADER
        {
            uint32 signature;
            uint16 diskNumber;
            uint16 centralDirDiskNumber;
            uint16 dirEntryCount;
            uint16 totalDirEntryCount;
            uint32 dirSize;
            uint32 dirStartOffset;
            uint16 fileCommentLength;
        };
 
    #pragma pack(pop)
    }
}
 
#endif


suserver_0.06/include/PtrMacro.h

@@ -0,0 +1,30 @@
/*
 
        Framework - PtrMacro.h
        File Version 1.0.000
        Various pointer related macros
 
*/
 
#ifndef _PTRMACRO_H_
#define _PTRMACRO_H_
 
#ifndef NULL
#define NULL 0
#endif
 
#define FREEPTR(p) \
        if((p) != NULL) \
        { \
                free((p)); \
                (p) = NULL; \
        }
 
#define DELETEPTR(p) \
        if((p) != NULL) \
        { \
                delete (p); \
                (p) = NULL; \
        }
 
#endif


suserver_0.06/include/winrt/StorageFileStream.h

@@ -0,0 +1,27 @@
#pragma once
 
#include "Stream.h"
 
namespace Framework
{
        namespace WinRt
        {
                class CStorageFileStream : public CStream
                {
                public:
                                                                CStorageFileStream();
                                                                CStorageFileStream(Windows::Storage::StorageFile^);
                        virtual ~CStorageFileStream();
 
                        virtual void Seek(int64, STREAM_SEEK_DIRECTION);
                        virtual uint64 Tell();
                        virtual uint64 Read(void*, uint64);
                        virtual uint64 Write(const void*, uint64);
                        virtual bool IsEOF();
 
                private:
                        Windows::Storage::Streams::IRandomAccessStream^ m_stream;
 
                };
        }
}


suserver_0.06/include/ThreadPool.h

@@ -0,0 +1,35 @@
#pragma once
 
#include <functional>
#include <thread>
#include <vector>
#include <deque>
#include <mutex>
#include <condition_variable>
 
namespace Framework
{
        class CThreadPool
        {
        public:
                typedef std::function<void ()> TaskFunction;
 
                                                                        CThreadPool(unsigned int);
                virtual ~CThreadPool();
 
                void Enqueue(const TaskFunction&);
 
        private:
                typedef std::vector<std::thread> ThreadArray;
                typedef std::deque<TaskFunction> TaskArray;
 
                void WorkerThreadProc();
 
                TaskArray m_tasks;
                std::mutex m_tasksMutex;
 
                std::condition_variable m_condition;
                ThreadArray m_workers;
                bool m_stop;
        };
}


suserver_0.06/include/PtrStream.h

@@ -0,0 +1,24 @@
#pragma once
 
#include "Stream.h"
 
namespace Framework
{
 
        class CPtrStream : public CStream
        {
        public:
                                        CPtrStream(const void*, uint64);
                void Seek(int64, STREAM_SEEK_DIRECTION);
                uint64 Tell();
                uint64 Read(void*, uint64);
                uint64 Write(const void*, uint64);
                bool IsEOF();
        private:
                uint64 m_position;
                uint64 m_size;
                const char* m_data;
                bool m_isEof;
        };
 
}


suserver_0.06/include/Base64.h

@@ -0,0 +1,12 @@
#pragma once
 
#include "Types.h"
#include <vector>
#include <string>
 
namespace Framework
{
        std::string ToBase64(const std::string&);
        std::string ToBase64(const void* buffer, size_t size);
        std::vector<uint8> FromBase64(const char* source);
}


suserver_0.06/include/Utf8.h

@@ -0,0 +1,144 @@
#ifndef _UTF8_H_
#define _UTF8_H_
 
#include <stdexcept>
#include <string>
 
namespace Framework
{
        namespace Utf8
        {
                template <typename IteratorType>
                std::wstring ConvertFrom(const IteratorType& itBegin, const IteratorType& itEnd)
                {
                        std::wstring sTemp;
 
                        for(IteratorType itChar(itBegin); itChar != itEnd; itChar++)
                        {
                                char nChar(*itChar);
                                if((nChar & 0x80) == 0)
                                {
                                        sTemp += nChar;
                                }
                                else
                                {
                                        if((nChar & 0xE0) == 0xC0)
                                        {
                                                bool valid = false;
 
                                                char byte1 = 0;
                                                ++itChar;
                                                if(itChar != itEnd)
                                                {
                                                        byte1 = (*itChar);
                                                        valid = true;
                                                }
 
                                                if((byte1 & 0xC0) != 0x80) valid = false;
 
                                                if(valid)
                                                {
                                                        wchar_t nWChar = ((nChar & 0x1F) << 6) | (byte1 & 0x3F);
                                                        sTemp += nWChar;
                                                }
                                                else
                                                {
                                                        sTemp += '?';
                                                }
                                        }
                                        else if((nChar & 0xF0) == 0xE0)
                                        {
                                                bool valid = false;
 
                                                char byte1 = 0;
                                                char byte2 = 0;
                                                ++itChar;
                                                if(itChar != itEnd)
                                                {
                                                        byte1 = (*itChar);
                                                        ++itChar;
                                                        if(itChar != itEnd)
                                                        {
                                                                byte2 = (*itChar);
                                                                valid = true;
                                                        }
                                                }
 
                                                if((byte1 & 0xC0) != 0x80) valid = false;
                                                if((byte2 & 0xC0) != 0x80) valid = false;
 
                                                if(valid)
                                                {
                                                        wchar_t nWChar = ((nChar & 0x0F) << 12) | ((byte1 & 0x3F) << 6) | (byte2 & 0x3F);
                                                        sTemp += nWChar;
                                                }
                                                else
                                                {
                                                        sTemp += '?';
                                                }
                                        }
                                        else
                                        {
                                                sTemp += '?';
                                        }
                                }
 
                                if(itChar == itEnd)
                                {
                                        //Can get in here if we failed to fetch a character
                                        break;
                                }
                        }
 
                        return sTemp;
                }
 
                template <typename IteratorType>
                std::string ConvertTo(const IteratorType& itBegin, const IteratorType& itEnd)
                {
                        std::string result;
 
                        for(IteratorType itChar(itBegin); itChar != itEnd; itChar++)
                        {
                                wchar_t ch = (*itChar);
                                if(ch <= 0x7F)
                                {
                                        result += static_cast<char>(ch);
                                }
                                else
                                {
                                        if(ch <= 0x7FF)
                                        {
                                                wchar_t byte1 = 0xC0 | ((ch & 0x700) >> 6) | ((ch & 0xC0) >> 6);
                                                wchar_t byte2 = 0x80 | (ch & 0x3F);
                                                result += static_cast<char>(byte1);
                                                result += static_cast<char>(byte2);
                                        }
                                        else
                                        {
                                                if(ch <= 0xFFFF)
                                                {
                                                        wchar_t byte1 = 0xE0 | ((ch & 0xF000) >> 12);
                                                        wchar_t byte2 = 0x80 | ((ch & 0x0F00) >> 6) | ((ch & 0xC0) >> 6);
                                                        wchar_t byte3 = 0x80 | (ch & 0x3F);
                                                        result += static_cast<char>(byte1);
                                                        result += static_cast<char>(byte2);
                                                        result += static_cast<char>(byte3);
                                                }
                                                else
                                                {
                                                        throw std::exception();
                                                }
                                        }
                                }
                        }
 
                        return result;
                }
 
                std::wstring ConvertFrom(const std::string&);
                std::string ConvertTo(const std::wstring&);
        };
}
 
#endif


suserver_0.06/include/LzAri.h

@@ -0,0 +1,90 @@
#ifndef _LZARI_H_
#define _LZARI_H_
 
#include <stdio.h>
#include "Types.h"
#include "Stream.h"
 
namespace Framework
{
        class CLzAri
        {
        public:
                static void Compress(Framework::CStream& dst, Framework::CStream& src);
                static void Decompress(Framework::CStream& dst, Framework::CStream& src);
 
        private:
                enum
                {
                        N = 4096, /* size of ring buffer */
                        F = 60, /* upper limit for match_length */
                        THRESHOLD = 2, /* encode string into position and length
                                                                           if match_length is greater than this */
                        NIL = N, /* index for root of binary search trees */
 
                        M = 15,
 
                        /* Q1 (= 2 to the M) must be sufficiently large, but not so
                        large as the unsigned long 4 * Q1 * (Q1 - 1) overflows. */
 
                        Q1 = (1UL << M),
                        Q2 = (2 * Q1),
                        Q3 = (3 * Q1),
                        Q4 = (4 * Q1),
                        MAX_CUM = (Q1 - 1),
 
                        N_CHAR = (256 - THRESHOLD + F) /* character code = 0, 1, ..., N_CHAR - 1 */
                };
 
                                                                CLzAri();
                virtual ~CLzAri();
 
                void PutBit(int);
                void FlushBitBuffer();
                int GetBit();
 
                void InitTree();
                void InsertNode(int);
                void DeleteNode(int);
 
                void StartModel();
                void UpdateModel(int);
 
                void Output(int);
 
                void EncodeChar(int);
                void EncodePosition(int);
                void EncodeEnd();
 
                int BsrcSym(unsigned int);
                int BsrcPos(unsigned int);
 
                void StartDecode();
                int DecodeChar();
                int DecodePosition();
 
                void Encode();
                void Decode();
 
                unsigned char text_buf[N + F - 1]; /* ring buffer of size N, with extra F-1 bytes to facilitate string comparison */
                int match_position, match_length; /* of longest match. These are set by the InsertNode() procedure. */
                int lson[N + 1], rson[N + 257], dad[N + 1]; /* left & right children & parents -- These constitute binary search trees. */
 
                uint32 low, high, value;
                int shifts; /* counts for magnifying low and high around Q2 */
                int char_to_sym[N_CHAR], sym_to_char[N_CHAR + 1];
                unsigned int sym_freq[N_CHAR + 1]; /* frequency for symbols */
                unsigned int sym_cum[N_CHAR + 1]; /* cumulative freq for symbols */
                unsigned int position_cum[N + 1]; /* cumulative freq for positions */
 
                Framework::CStream* inputStream;
                Framework::CStream* outputStream;
 
                unsigned int putBuffer;
                unsigned int putMask;
                unsigned int getBuffer;
                unsigned int getMask;
        };
}
 
#endif


suserver_0.06/include/StdStreamUtils.h

@@ -0,0 +1,39 @@
#ifndef _STDSTREAMUTILS_H_
#define _STDSTREAMUTILS_H_
 
#include "StdStream.h"
 
namespace Framework
{
        template <typename StringType>
        static CStdStream CreateInputStdStream(const StringType&);
 
        template <typename StringType>
        static CStdStream CreateOutputStdStream(const StringType&);
 
        template <>
        static CStdStream CreateInputStdStream(const std::wstring& path)
        {
                return CStdStream(path.c_str(), L"rb");
        }
 
        template <>
        static CStdStream CreateInputStdStream(const std::string& path)
        {
                return CStdStream(path.c_str(), "rb");
        }
 
        template <>
        static CStdStream CreateOutputStdStream(const std::wstring& path)
        {
                return CStdStream(path.c_str(), L"wb");
        }
 
        template <>
        static CStdStream CreateOutputStdStream(const std::string& path)
        {
                return CStdStream(path.c_str(), "wb");
        }
}
 
#endif


suserver_0.06/include/Types.h

@@ -0,0 +1,33 @@
#ifndef _TYPES_H_
#define _TYPES_H_
 
typedef char int8;
typedef unsigned char uint8;
 
typedef short int16;
typedef unsigned short uint16;
 
typedef int int32;
 
//Fixes compilation problem under xcode
#ifndef _UINT32
#define _UINT32
typedef unsigned int uint32;
#endif
 
typedef long long int64;
typedef unsigned long long uint64;
 
static_assert(sizeof(int8) == 1, "int8 size must be 1 byte.");
static_assert(sizeof(uint8) == 1, "uint8 size must be 1 byte.");
 
static_assert(sizeof(int16) == 2, "int16 size must be 2 bytes.");
static_assert(sizeof(uint16) == 2, "uint16 size must be 2 bytes.");
 
static_assert(sizeof(int32) == 4, "int32 size must be 4 bytes.");
static_assert(sizeof(uint32) == 4, "uint32 size must be 4 bytes.");
 
static_assert(sizeof(int64) == 8, "int64 size must be 8 bytes.");
static_assert(sizeof(uint64) == 8, "uint64 size must be 8 bytes.");
 
#endif


suserver_0.06/include/opengl/Shader.h

@@ -0,0 +1,34 @@
#ifndef _SHADER_H_
#define _SHADER_H_
 
#include "OpenGlDef.h"
#include <stdlib.h>
 
namespace Framework
{
        namespace OpenGl
        {
                class CShader
                {
                public:
                        explicit CShader(GLenum);
                                                CShader(CShader&&);
                                                ~CShader();
 
                        CShader& operator =(CShader&&);
 
                        operator GLuint() const;
 
                        void SetSource(const char*, size_t = 0);
                        bool Compile();
 
                private:
                                                CShader(const CShader&) {}
                                                CShader& operator =(const CShader&) {}
 
                        GLuint m_nHandle;
                };
        }
}
 
#endif


suserver_0.06/include/opengl/Program.h

@@ -0,0 +1,37 @@
#ifndef _PROGRAM_H_
#define _PROGRAM_H_
 
#include "OpenGlDef.h"
#include <memory>
 
namespace Framework
{
        namespace OpenGl
        {
                class CProgram
                {
                public:
                                                        CProgram();
                                                        ~CProgram();
 
                        operator GLuint() const;
 
                        void AttachShader(GLuint);
                        void DetachShader(GLuint);
                        bool Link();
                        void SetUniformf(const char*, float, float);
                        void SetUniformi(const char*, int);
                        void SetUniformi(const char*, int, int);
 
                private:
                                                        CProgram(const CProgram&) {}
                                                        CProgram& operator =(const CProgram&) {}
 
                        GLuint m_nHandle;
                };
 
                typedef std::shared_ptr<CProgram> ProgramPtr;
        }
}
 
#endif


suserver_0.06/include/opengl/OpenGlDef.h

@@ -0,0 +1,15 @@
#ifndef _OPENGLDEF_H_
#define _OPENGLDEF_H_
 
#ifdef WIN32
#include <windows.h>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#else
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/OpenGL.h>
#endif
 
#endif


suserver_0.06/include/offsetof_def.h

@@ -0,0 +1,7 @@
#ifndef _OFFSETOF_DEF_H_
#define _OFFSETOF_DEF_H_
 
#undef offsetof
#define offsetof(a, b) static_cast<size_t>(reinterpret_cast<uint8*>(&reinterpret_cast<a*>(0x10)->b) - reinterpret_cast<uint8*>(0x10))
 
#endif


suserver_0.06/include/directinput/Manager.h

@@ -0,0 +1,60 @@
#ifndef _DIRECTINPUTMANAGER_H_
#define _DIRECTINPUTMANAGER_H_
 
#include "DirectInput.h"
#include <memory>
#include <list>
#include <map>
#include <unordered_map>
#include "win32/GuidUtils.h"
#include "Device.h"
 
namespace Framework
{
        namespace DirectInput
        {
                class CManager
                {
                public:
                        typedef std::function<void (const GUID&, uint32, uint32)> InputEventHandler;
 
                                                                        CManager();
                        virtual ~CManager();
 
                        uint32 RegisterInputEventHandler(const InputEventHandler&);
                        void UnregisterInputEventHandler(uint32);
 
                        void CreateKeyboard(HWND);
                        void CreateJoysticks(HWND);
                        bool GetDeviceInfo(const GUID&, DIDEVICEINSTANCE*);
                        bool GetDeviceObjectInfo(const GUID&, uint32, DIDEVICEOBJECTINSTANCE*);
 
                private:
                        typedef std::shared_ptr<CDevice> DevicePtr;
                        typedef std::map<GUID, DevicePtr> DeviceList;
                        typedef std::list<GUID> JoystickInstanceList;
                        typedef std::unordered_map<uint32, InputEventHandler> InputEventHandlerMap;
 
                        void CallInputEventHandlers(const GUID&, uint32, uint32);
 
                        DWORD UpdateThreadProc();
                        static DWORD CALLBACK UpdateThreadProcStub(void*);
 
                        static BOOL CALLBACK EnumDevicesCallback(LPCDIDEVICEINSTANCE, LPVOID);
                        BOOL EnumDevicesCallbackImpl(LPCDIDEVICEINSTANCE);
 
                        LPDIRECTINPUT8 m_directInput;
                        JoystickInstanceList m_joystickInstances;
                        DeviceList m_devices;
 
                        InputEventHandlerMap m_inputEventHandlers;
                        uint32 m_nextInputEventHandlerId;
 
                        HANDLE m_updateThreadHandle;
                        bool m_updateThreadOver;
                        CRITICAL_SECTION m_updateMutex;
                };
        }
}
 
#endif


suserver_0.06/include/directinput/Device.h

@@ -0,0 +1,30 @@
#ifndef _DIRECTINPUTDEVICE_H_
#define _DIRECTINPUTDEVICE_H_
 
#include "DirectInput.h"
#include <functional>
#include "Types.h"
 
namespace Framework
{
        namespace DirectInput
        {
                class CDevice
                {
                public:
                        typedef std::function<void (const GUID&, uint32, uint32)> InputEventHandler;
 
                                                                                CDevice(LPDIRECTINPUTDEVICE8);
                        virtual ~CDevice();
 
                        virtual void ProcessEvents(const InputEventHandler&) = 0;
                        bool GetInfo(DIDEVICEINSTANCE*);
                        bool GetObjectInfo(uint32, DIDEVICEOBJECTINSTANCE*);
 
                protected:
                        LPDIRECTINPUTDEVICE8 m_device;
                };
        }
}
 
#endif


suserver_0.06/include/directinput/Joystick.h

@@ -0,0 +1,30 @@
#ifndef _DIRECTINPUTJOYSTICK_H_
#define _DIRECTINPUTJOYSTICK_H_
 
#include "DirectInput.h"
#include "Device.h"
 
namespace Framework
{
        namespace DirectInput
        {
                class CJoystick : public CDevice
                {
                public:
                                                                        CJoystick(LPDIRECTINPUTDEVICE8, HWND);
                        virtual ~CJoystick();
 
                        int GetButtonCount() const;
                        virtual void ProcessEvents(const InputEventHandler&);
 
                private:
                        static BOOL CALLBACK EnumObjectsCallback(LPCDIDEVICEOBJECTINSTANCE, LPVOID);
                        BOOL EnumObjectsCallbackImpl(LPCDIDEVICEOBJECTINSTANCE);
 
                        GUID m_deviceGuid;
                        int m_buttonCount;
                };
        }
}
 
#endif


suserver_0.06/include/directinput/Keyboard.h

@@ -0,0 +1,21 @@
#ifndef _DIRECTINPUTKEYBOARD_H_
#define _DIRECTINPUTKEYBOARD_H_
 
#include "Device.h"
 
namespace Framework
{
        namespace DirectInput
        {
                class CKeyboard : public CDevice
                {
                public:
                                                                        CKeyboard(LPDIRECTINPUTDEVICE8, HWND);
                        virtual ~CKeyboard();
 
                        virtual void ProcessEvents(const InputEventHandler&);
                };
        }
}
 
#endif


suserver_0.06/include/directinput/DirectInput.h

@@ -0,0 +1,7 @@
#ifndef _DIRECTINPUT_H_
#define _DIRECTINPUT_H_
 
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
 
#endif


suserver_0.06/include/BasicUnion.h

@@ -0,0 +1,30 @@
#ifndef _BASICUNION_H_
#define _BASICUNION_H_
 
#include "Types.h"
 
template <typename FullType, typename HalfType>
struct basic_union
{
        static_assert(sizeof(FullType) == (2 * sizeof(HalfType)), "Full type size isn't twice of half type size.");
 
        basic_union() {}
        basic_union(const FullType& f) : f(f) {}
        basic_union(const HalfType& h0, const HalfType& h1) : h0(h0), h1(h1) {}
 
        union
        {
                struct
                {
                        HalfType h0;
                        HalfType h1;
                };
                FullType f;
        };
};
 
typedef basic_union<uint32, uint16> UNION32_16;
typedef basic_union<uint64, uint32> UNION64_32;
typedef basic_union<uint64, UNION32_16> UNION64_32_16;
 
#endif


suserver_0.06/include/ObjCMemberFunctionPointer.h

@@ -0,0 +1,27 @@
#ifndef _OBJCMEMBERFUNCTIONPOINTER_H_
#define _OBJCMEMBERFUNCTIONPOINTER_H_
 
#import <objc/message.h>
 
struct ObjCMemberFunctionPointer
{
public:
        ObjCMemberFunctionPointer(id object, SEL sel)
        : m_object(object)
        , m_sel(sel)
        {
 
        }
 
        void operator()() const
        {
                objc_msgSend(m_object, m_sel);
        }
 
private:
 
        id m_object;
        SEL m_sel;
};
 
#endif


Property changes :

Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: suserver_0.06/include/lexical_cast_ex.h
===================================================================
--- suserver_0.06/include/lexical_cast_ex.h (nonexistent)
+++ suserver_0.06/include/lexical_cast_ex.h (revision 450)
@@ -0,0 +1,76 @@
+#ifndef _LEXICAL_CAST_EX_H_
+#define _LEXICAL_CAST_EX_H_
+
+#include
+#include
+#include
+#include "alloca_def.h"
+#include
+#include
+
+template
+Format lexical_cast_hex(unsigned int nNumber, unsigned int nWidth = 1)
+{
+ enum MAXNIBBLE
+ {
+ MAXNIBBLE = 8,
+ };
+
+ assert(nWidth <= MAXNIBBLE);
+ if(nWidth == 0) nWidth = 1;
+
+ unsigned int nNumSize = 0;
+ for(unsigned int i = 0; i < MAXNIBBLE; nNumSize++, i++)
+ {
+ if((nNumber >> (i * 4)) == 0) break;
+ }
+
+ nWidth = std::min(nWidth, MAXNIBBLE);
+ nWidth = std::max(nNumSize, nWidth);
+
+ typename Format::value_type* sBuffer;
+ sBuffer = reinterpret_cast(alloca(sizeof(typename Format::value_type) * (nWidth + 1)));
+
+ for(unsigned int i = 0; i < nWidth; i++)
+ {
+ unsigned int nNibble;
+ nNibble = (nNumber >> ((nWidth - i - 1) * 4)) & 0xF;
+ sBuffer[i] = (nNibble > 9) ? (nNibble - 0xA + 'A') : (nNibble + '0');
+ }
+ sBuffer[nWidth] = 0;
+
+ return Format(sBuffer);
+}
+
+template
+unsigned int lexical_cast_hex(const Format& sValue)
+{
+ unsigned int nNumber;
+ std::basic_istringstream Stream(sValue);
+ Stream >> std::hex >> nNumber;
+
+ if(Stream.fail())
+ {
+ throw std::exception();
+ }
+
+ return nNumber;
+}
+
+template
+Format lexical_cast_uint(unsigned int number, unsigned int width = 1)
+{
+ std::basic_ostringstream stream;
+ stream << std::setw(width) << std::setfill(static_cast('0')) << number;
+ return stream.str();
+}
+
+template
+Format lexical_cast_int(int number, unsigned int width = 1, typename Format::value_type fillChar = '0')
+{
+ std::basic_ostringstream stream;
+ stream << std::setw(width) << std::setfill(fillChar) << number;
+ return stream.str();
+}
+
+#endif
Index: suserver_0.06/include/placeholder_def.h
===================================================================
--- suserver_0.06/include/placeholder_def.h (nonexistent)
+++ suserver_0.06/include/placeholder_def.h (revision 450)
@@ -0,0 +1,24 @@
+#ifndef _PLACEHOLDER_DEF_H_
+#define _PLACEHOLDER_DEF_H_
+
+#ifdef _MSC_VER
+
+#define PLACEHOLDER_1 std::tr1::placeholders::_1
+#define PLACEHOLDER_2 std::tr1::placeholders::_2
+#define PLACEHOLDER_3 std::tr1::placeholders::_3
+#define PLACEHOLDER_4 std::tr1::placeholders::_4
+#define PLACEHOLDER_5 std::tr1::placeholders::_5
+#define PLACEHOLDER_6 std::tr1::placeholders::_6
+
+#else
+
+#define PLACEHOLDER_1 _1
+#define PLACEHOLDER_2 _2
+#define PLACEHOLDER_3 _3
+#define PLACEHOLDER_4 _4
+#define PLACEHOLDER_5 _5
+#define PLACEHOLDER_6 _6
+
+#endif
+
+#endif
Index: suserver_0.06/include/string_cast_win1252.h
===================================================================
--- suserver_0.06/include/string_cast_win1252.h (nonexistent)
+++ suserver_0.06/include/string_cast_win1252.h (revision 450)
@@ -0,0 +1,8 @@
+#ifndef _STRING_CAST_WIN1252_H_
+#define _STRING_CAST_WIN1252_H_
+
+#include
+
+std::wstring string_cast_win1252(const std::string&);
+
+#endif
Index: suserver_0.06/include/BitStream.h
===================================================================
--- suserver_0.06/include/BitStream.h (nonexistent)
+++ suserver_0.06/include/BitStream.h (revision 450)
@@ -0,0 +1,42 @@
+#ifndef _BITSTREAM_H_
+#define _BITSTREAM_H_
+
+#include "Types.h"
+#include
+
+namespace Framework
+{
+ class CBitStream
+ {
+ public:
+ class CBitStreamException : public std::exception
+ {
+ public:
+
+ private:
+
+ };
+
+ virtual ~CBitStream() {};
+
+ virtual void Advance(uint8) = 0;
+ virtual uint8 GetBitIndex() const = 0;
+
+ virtual bool TryPeekBits_LSBF(uint8, uint32&) = 0;
+ virtual bool TryPeekBits_MSBF(uint8, uint32&) = 0;
+
+ bool TryGetBits_LSBF(uint8, uint32&);
+ bool TryGetBits_MSBF(uint8, uint32&);
+
+ uint32 GetBits_LSBF(uint8);
+ uint32 GetBits_MSBF(uint8);
+
+ uint32 PeekBits_LSBF(uint8);
+ uint32 PeekBits_MSBF(uint8);
+
+ void SeekToByteAlign();
+ bool IsOnByteBoundary() const;
+ };
+}
+
+#endif
\ No newline at end of file
Index: suserver_0.06/include/StreamBitStream.h
===================================================================
--- suserver_0.06/include/StreamBitStream.h (nonexistent)
+++ suserver_0.06/include/StreamBitStream.h (revision 450)
@@ -0,0 +1,38 @@
+#ifndef _STREAMBITSTREAM_H_
+#define _STREAMBITSTREAM_H_
+
+#include
+#include "Types.h"
+#include "Stream.h"
+#include "BitStream.h"
+
+namespace Framework
+{
+ class CStreamBitStream : public CBitStream
+ {
+ public:
+
+ CStreamBitStream(Framework::CStream&);
+ virtual ~CStreamBitStream();
+
+ virtual void Advance(uint8);
+ virtual uint8 GetBitIndex() const;
+
+ virtual bool TryPeekBits_LSBF(uint8, uint32&);
+ virtual bool TryPeekBits_MSBF(uint8, uint32&);
+
+ private:
+ enum
+ {
+ BUFFER_SIZE = 16,
+ };
+
+ uint8 m_buffer[BUFFER_SIZE];
+ unsigned int m_cursor;
+ unsigned int m_availableBits;
+
+ Framework::CStream& m_stream;
+ };
+}
+
+#endif
\ No newline at end of file
Index: suserver_0.06/include/stricmp.h
===================================================================
--- suserver_0.06/include/stricmp.h (nonexistent)
+++ suserver_0.06/include/stricmp.h (revision 450)
@@ -0,0 +1,22 @@
+#ifndef _STRICMP_H_
+#define _STRICMP_H_
+
+#ifdef WIN32
+#define stricmp _stricmp
+#else
+#define stricmp strcasecmp
+#endif
+
+#ifdef WIN32
+#define strnicmp _strnicmp
+#else
+#define strnicmp strncasecmp
+#endif
+
+#ifdef WIN32
+#define wcsicmp _wcsicmp
+#else
+#define wcsicmp wcscasecmp
+#endif
+
+#endif
Index: suserver_0.06/include/string_cast_sjis.h
===================================================================
--- suserver_0.06/include/string_cast_sjis.h (nonexistent)
+++ suserver_0.06/include/string_cast_sjis.h (revision 450)
@@ -0,0 +1,8 @@
+#ifndef _STRING_CAST_SJIS_H_
+#define _STRING_CAST_SJIS_H_
+
+#include
+
+std::wstring string_cast_sjis(const std::string&);
+
+#endif
Index: suserver_0.06/include/IosIStream.h
===================================================================
--- suserver_0.06/include/IosIStream.h (nonexistent)
+++ suserver_0.06/include/IosIStream.h (revision 450)
@@ -0,0 +1,28 @@
+#ifndef _IOSOSTREAM_H_
+#define _IOSOSTREAM_H_
+
+#include "Stream.h"
+#include
+
+namespace Framework
+{
+
+ class CIosIStream : public CStream
+ {
+ public:
+ CIosIStream(std::istream&);
+ virtual ~CIosIStream();
+
+ virtual void Seek(int64, STREAM_SEEK_DIRECTION);
+ virtual uint64 Tell();
+ virtual uint64 Read(void*, uint64);
+ virtual uint64 Write(const void*, uint64);
+ virtual bool IsEOF();
+
+ private:
+ std::istream& m_Stream;
+ };
+
+}
+
+#endif
Index: suserver_0.06/include/IosOStream.h
===================================================================
--- suserver_0.06/include/IosOStream.h (nonexistent)
+++ suserver_0.06/include/IosOStream.h (revision 450)
@@ -0,0 +1,28 @@
+#ifndef _IOSOSTREAM_H_
+#define _IOSOSTREAM_H_
+
+#include "Stream.h"
+#include
+
+namespace Framework
+{
+
+ class CIosOStream : public CStream
+ {
+ public:
+ CIosOStream(std::ostream&);
+ virtual ~CIosOStream();
+
+ virtual void Seek(int64, STREAM_SEEK_DIRECTION);
+ virtual uint64 Tell();
+ virtual uint64 Read(void*, uint64);
+ virtual uint64 Write(const void*, uint64);
+ virtual bool IsEOF();
+
+ private:
+ std::ostream& m_Stream;
+ };
+
+}
+
+#endif
Index: suserver_0.06/include/tcharx.h
===================================================================
--- suserver_0.06/include/tcharx.h (nonexistent)
+++ suserver_0.06/include/tcharx.h (revision 450)
@@ -0,0 +1,31 @@
+#ifndef _TCHARX_H_
+#define _TCHARX_H_
+
+#include
+#include
+#include
+#include "countof.h"
+
+namespace std
+{
+ typedef basic_string< TCHAR, char_traits, allocator > tstring;
+ typedef basic_stringstream< TCHAR, char_traits, allocator > tstringstream;
+};
+
+#ifdef _UNICODE
+
+__inline const TCHAR* tcond(const char* sChar, const wchar_t* sWide)
+{
+ return sWide;
+}
+
+#else
+
+__inline const TCHAR* tcond(const char* sChar, const wchar_t* sWide)
+{
+ return sChar;
+}
+
+#endif
+
+#endif
Index: suserver_0.06/include/odbc/Statement.h
===================================================================
--- suserver_0.06/include/odbc/Statement.h (nonexistent)
+++ suserver_0.06/include/odbc/Statement.h (revision 450)
@@ -0,0 +1,33 @@
+#ifndef _ODBC_STATEMENT_H_
+#define _ODBC_STATEMENT_H_
+
+#include "Connection.h"
+
+namespace Framework
+{
+ namespace Odbc
+ {
+ class CStatement
+ {
+ public:
+ CStatement(CConnection*);
+ ~CStatement();
+ void Execute(const TCHAR*);
+ unsigned int GetColumnIndex(const TCHAR*);
+ void BindColumn(int, unsigned int*);
+ template T GetData(const TCHAR*);
+ unsigned int GetDataInt(unsigned int);
+ std::string GetDataStr(unsigned int);
+ std::wstring GetDataWStr(unsigned int);
+ const wchar_t* GetDataWStr(unsigned int, wchar_t*, unsigned int);
+
+ bool FetchRow();
+
+ private:
+ void ThrowErrorException();
+ SQLHANDLE m_StmtHandle;
+ };
+ }
+}
+
+#endif
Index: suserver_0.06/include/odbc/Connection.h
===================================================================
--- suserver_0.06/include/odbc/Connection.h (nonexistent)
+++ suserver_0.06/include/odbc/Connection.h (revision 450)
@@ -0,0 +1,31 @@
+#ifndef _ODBC_CONNECTION_H_
+#define _ODBC_CONNECTION_H_
+
+#ifdef WIN32
+#include
+#endif
+#include
+#include
+#include "tcharx.h"
+
+namespace Framework
+{
+ namespace Odbc
+ {
+ class CConnection
+ {
+ public:
+ CConnection(const TCHAR*);
+ ~CConnection();
+
+ SQLHANDLE GetConnectionHandle();
+
+ private:
+ void ThrowErrorException();
+ SQLHANDLE m_EnvHandle;
+ SQLHANDLE m_ConHandle;
+ };
+ }
+}
+
+#endif
Index: suserver_0.06/include/countof.h
===================================================================
--- suserver_0.06/include/countof.h (nonexistent)
+++ suserver_0.06/include/countof.h (revision 450)
@@ -0,0 +1,6 @@
+#ifndef _COUNTOF_H_
+#define _COUNTOF_H_
+
+#define countof(a) (sizeof(a) / sizeof(a[0]))
+
+#endif
Index: suserver_0.06/include/string_cast.h
===================================================================
--- suserver_0.06/include/string_cast.h (nonexistent)
+++ suserver_0.06/include/string_cast.h (revision 450)
@@ -0,0 +1,7 @@
+#ifndef _STRING_CAST_H_
+#define _STRING_CAST_H_
+
+template Target string_cast(const Source&);
+template Target string_cast(const Source*);
+
+#endif
Index: suserver_0.06/include/idct/TrivialC.h
===================================================================
--- suserver_0.06/include/idct/TrivialC.h (nonexistent)
+++ suserver_0.06/include/idct/TrivialC.h (revision 450)
@@ -0,0 +1,26 @@
+#ifndef _IDCT_TRIVIALC_H_
+#define _IDCT_TRIVIALC_H_
+
+#include "idct/Interface.h"
+
+namespace IDCT
+{
+
+ class CTrivialC : public CInterface
+ {
+ public:
+ CTrivialC();
+ virtual ~CTrivialC();
+ static CInterface* GetInstance();
+ virtual void Transform(int16*, int16*);
+
+ private:
+ void PrepareTables();
+
+ double m_nCosTable[8][8];
+ static CInterface* m_pInstance;
+ };
+
+}
+
+#endif
Index: suserver_0.06/include/idct/Interface.h
===================================================================
--- suserver_0.06/include/idct/Interface.h (nonexistent)
+++ suserver_0.06/include/idct/Interface.h (revision 450)
@@ -0,0 +1,18 @@
+#ifndef _IDCT_INTERFACE_H_
+#define _IDCT_INTERFACE_H_
+
+#include "Types.h"
+
+namespace IDCT
+{
+
+ class CInterface
+ {
+ public:
+ virtual ~CInterface() {} ;
+ virtual void Transform(int16*, int16*) = 0;
+ };
+
+}
+
+#endif
Index: suserver_0.06/include/idct/IEEE1180.h
===================================================================
--- suserver_0.06/include/idct/IEEE1180.h (nonexistent)
+++ suserver_0.06/include/idct/IEEE1180.h (revision 450)
@@ -0,0 +1,26 @@
+#ifndef _IDCT_IEEE1180_H_
+#define _IDCT_IEEE1180_H_
+
+#include "idct/Interface.h"
+
+namespace IDCT
+{
+
+ class CIEEE1180 : public CInterface
+ {
+ public:
+ CIEEE1180();
+ virtual ~CIEEE1180();
+ static CInterface* GetInstance();
+ virtual void Transform(int16*, int16*);
+
+ private:
+ void PrepareTable();
+
+ double m_nC[8][8];
+ static CInterface* m_pInstance;
+ };
+
+};
+
+#endif
Index: suserver_0.06/include/GZipStream.h
===================================================================
--- suserver_0.06/include/GZipStream.h (nonexistent)
+++ suserver_0.06/include/GZipStream.h (revision 450)
@@ -0,0 +1,25 @@
+#ifndef _GZIPSTREAM_H_
+#define _GZIPSTREAM_H_
+
+#include
+#include "Stream.h"
+
+namespace Framework
+{
+ class CGZipStream : public CStream
+ {
+ public:
+ CGZipStream(const char*, const char*);
+ virtual ~CGZipStream();
+ void Seek(int64, STREAM_SEEK_DIRECTION);
+ uint64 Tell();
+ uint64 Read(void*, uint64);
+ uint64 Write(const void*, uint64);
+ bool IsEOF();
+
+ private:
+ gzFile m_File;
+ };
+}
+
+#endif
Index: suserver_0.06/src/win32/ColumnTreeView.cpp
===================================================================
--- suserver_0.06/src/win32/ColumnTreeView.cpp (nonexistent)
+++ suserver_0.06/src/win32/ColumnTreeView.cpp (revision 450)
@@ -0,0 +1,254 @@
+// Column TreeView control ----------------------------//
+// Based on Michal Mecinski's idea (http://www.mimec.org)
+
+#include "win32/ColumnTreeView.h"
+#include "win32/ClientDeviceContext.h"
+#include "win32/Font.h"
+
+#define CLSNAME _T("CColumnTreeView")
+
+using namespace Framework;
+using namespace Framework::Win32;
+
+CColumnTreeView::CColumnTreeView(HWND hParent, const RECT& rect, unsigned long nTreeViewStyle)
+: m_pHeader(nullptr)
+, m_pTreeView(nullptr)
+{
+ if(!DoesWindowClassExist(CLSNAME))
+ {
+ WNDCLASSEX wc;
+ memset(&wc, 0, sizeof(WNDCLASSEX));
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
+ wc.hInstance = GetModuleHandle(NULL);
+ wc.lpszClassName = CLSNAME;
+ wc.lpfnWndProc = CWindow::WndProc;
+ wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
+ RegisterClassEx(&wc);
+ }
+
+ Create(WS_EX_CLIENTEDGE, CLSNAME, _T(""), WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, rect, hParent, NULL);
+ SetClassPtr();
+
+ m_pHeader = new CHeader(m_hWnd, rect, HDS_FULLDRAG | HDS_HOTTRACK);
+ m_pTreeView = new CDblBufferedCtrl(new CTreeView(m_hWnd, rect, nTreeViewStyle, 0));
+
+ m_pHeader->SetFont(m_pTreeView->GetFont());
+
+ ComputeHeaderHeight();
+
+ UpdateLayout();
+}
+
+CColumnTreeView::~CColumnTreeView()
+{
+ delete m_pHeader;
+ delete m_pTreeView;
+}
+
+CHeader* CColumnTreeView::GetHeader()
+{
+ return m_pHeader;
+}
+
+CTreeView* CColumnTreeView::GetTreeView()
+{
+ return m_pTreeView->GetControl();
+}
+
+long CColumnTreeView::OnSize(unsigned int nX, unsigned int nY, unsigned int nType)
+{
+ UpdateLayout();
+ return TRUE;
+}
+
+long CColumnTreeView::OnEraseBkgnd()
+{
+ return FALSE;
+}
+
+long CColumnTreeView::OnNotify(WPARAM nId, NMHDR* pHdr)
+{
+ bool nRelay = true;
+
+ if(m_pTreeView != NULL)
+ {
+ if(pHdr->hwndFrom == m_pTreeView->m_hWnd)
+ {
+ if(pHdr->code == NM_CUSTOMDRAW)
+ {
+ NMTVCUSTOMDRAW* pCustomDraw;
+ pCustomDraw = reinterpret_cast(pHdr);
+ nRelay = false;
+
+ switch(pCustomDraw->nmcd.dwDrawStage)
+ {
+ case CDDS_PREPAINT:
+ DrawColumnLines(pCustomDraw->nmcd.hdc);
+ return CDRF_NOTIFYITEMDRAW;
+ break;
+ case CDDS_ITEMPREPAINT:
+ return CDRF_DODEFAULT | CDRF_NOTIFYPOSTPAINT;
+ break;
+ case CDDS_ITEMPOSTPAINT:
+ DrawItem(pCustomDraw);
+ break;
+ }
+ }
+ }
+ }
+
+ if(m_pHeader != NULL)
+ {
+ if(pHdr->hwndFrom == m_pHeader->m_hWnd)
+ {
+ switch(pHdr->code)
+ {
+ case HDN_ITEMCHANGING:
+ case HDN_ENDTRACK:
+ m_pTreeView->Redraw();
+ break;
+ }
+ }
+ }
+
+ if(nRelay)
+ {
+ MESSAGE Msg;
+ Msg.hwndFrom = m_hWnd;
+ Msg.idFrom = 0;
+ Msg.code = pHdr->code;
+ Msg.pOriginalMsg = pHdr;
+ return static_cast(SendMessage(GetParent(), WM_NOTIFY, nId, reinterpret_cast(&Msg)));
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+void CColumnTreeView::UpdateLayout()
+{
+ RECT clientRect = GetClientRect();
+
+ if(m_pHeader != NULL)
+ {
+ m_pHeader->SetPosition(0, 0);
+ m_pHeader->SetSize(clientRect.right, m_nHeaderHeight);
+ }
+
+ if(m_pTreeView != NULL)
+ {
+ m_pTreeView->SetPosition(0, m_nHeaderHeight);
+ m_pTreeView->SetSize(clientRect.right, clientRect.bottom - m_nHeaderHeight);
+ }
+}
+
+void CColumnTreeView::ComputeHeaderHeight()
+{
+ auto fontSize = Win32::GetFixedFontSize(m_pHeader->GetFont());
+ m_nHeaderHeight = fontSize.cy + 7;
+}
+
+void CColumnTreeView::DrawItem(NMTVCUSTOMDRAW* pCustomDraw)
+{
+ HTREEITEM nItem;
+ RECT LabelRect;
+ TCHAR sItemText[256];
+ const TCHAR* sNext;
+ const TCHAR* sTemp;
+ unsigned int nColumnCount;
+
+ nItem = reinterpret_cast(pCustomDraw->nmcd.dwItemSpec);
+
+ GetTreeView()->GetItemLabelRect(nItem, &LabelRect);
+ GetTreeView()->GetItemText(nItem, sItemText, countof(sItemText));
+
+ CDeviceContext DeviceContext(pCustomDraw->nmcd.hdc);
+ DeviceContext.FillRect(&LabelRect, GetSysColor(COLOR_WINDOW));
+
+ DrawColumnLines(DeviceContext);
+
+ sNext = sItemText;
+ nColumnCount = m_pHeader->GetItemCount();
+
+ for(unsigned int nColumn = 0; nColumn < nColumnCount; nColumn++)
+ {
+ size_t nCount;
+ RECT ColumnRect;
+ RECT ItemRect;
+ RECT OverlayRect;
+
+ sTemp = _tcschr(sNext, _T('\t'));
+
+ nCount = (sTemp != NULL) ? (sTemp - sNext) : _tcslen(sNext);
+
+ m_pHeader->GetItemRect(nColumn, &ColumnRect);
+
+ ItemRect.bottom = LabelRect.bottom;
+ ItemRect.top = LabelRect.top;
+
+ if(nColumn == 0)
+ {
+ ItemRect.left = LabelRect.left;
+ ItemRect.right = ColumnRect.right;
+ }
+ else
+ {
+ ItemRect.left = ColumnRect.left + 2;
+ ItemRect.right = ColumnRect.right;
+ }
+
+ ItemRect.left += 2;
+ ItemRect.right -= 2;
+
+ ItemRect.top += 1;
+
+ CopyRect(&OverlayRect, &ItemRect);
+
+ OverlayRect.left -= 2;
+ DeviceContext.FillRect(&OverlayRect, (nColumn == 0) ? pCustomDraw->clrTextBk : GetSysColor(COLOR_WINDOW));
+
+ if(nColumn == 0)
+ {
+ SetTextColor(DeviceContext, pCustomDraw->clrText);
+ SetBkColor(DeviceContext, pCustomDraw->clrTextBk);
+ }
+ else
+ {
+ SetTextColor(DeviceContext, GetSysColor(COLOR_WINDOWTEXT));
+ SetBkColor(DeviceContext, GetSysColor(COLOR_WINDOW));
+ }
+
+ DrawText(DeviceContext, sNext, static_cast(nCount), &ItemRect, DT_END_ELLIPSIS);
+
+ if((pCustomDraw->nmcd.uItemState) & CDIS_FOCUS && (nColumn == 0))
+ {
+ DrawFocusRect(DeviceContext, &OverlayRect);
+ }
+
+ if(sTemp == NULL) break;
+ sNext = sTemp + 1;
+ }
+}
+
+void CColumnTreeView::DrawColumnLines(HDC hDC)
+{
+ return;
+
+ CDeviceContext DeviceContext(hDC);
+
+ RECT clientRect = m_pTreeView->GetClientRect();
+ unsigned int nColCount = m_pHeader->GetItemCount();
+
+ for(unsigned int i = 0; i < nColCount; i++)
+ {
+ RECT ColumnRect;
+ m_pHeader->GetItemRect(i, &ColumnRect);
+ ColumnRect.top = 0;
+ ColumnRect.bottom = clientRect.bottom;
+ ColumnRect.right--;
+ DrawEdge(DeviceContext, &ColumnRect, BDR_SUNKENINNER, BF_RIGHT);
+ }
+}
Index: suserver_0.06/src/win32/DeviceContext.cpp
===================================================================
--- suserver_0.06/src/win32/DeviceContext.cpp (nonexistent)
+++ suserver_0.06/src/win32/DeviceContext.cpp (revision 450)
@@ -0,0 +1,58 @@
+#include
+#include "win32/DeviceContext.h"
+#include "win32/GdiObj.h"
+
+using namespace Framework;
+using namespace Framework::Win32;
+
+CDeviceContext::CDeviceContext(HDC dc)
+: m_dc(dc)
+{
+
+}
+
+CDeviceContext::~CDeviceContext()
+{
+
+}
+
+CDeviceContext::operator HDC()
+{
+ return m_dc;
+}
+
+void CDeviceContext::FillRect(RECT* pRect, COLORREF nColor)
+{
+ assert(pRect != NULL);
+ CBrush Brush(CreateSolidBrush(nColor));
+ ::FillRect(m_dc, pRect, Brush);
+}
+
+void CDeviceContext::DrawLine(int nX1, int nY1, int nX2, int nY2)
+{
+ MoveToEx(m_dc, nX1, nY1, NULL);
+ LineTo(m_dc, nX2, nY2);
+}
+
+void CDeviceContext::DrawLine(int nX1, int nY1, int nX2, int nY2, COLORREF nColor)
+{
+ CPen pen(CreatePen(PS_SOLID, 0, nColor));
+ SelectObject(pen);
+ DrawLine(nX1, nY1, nX2, nY2);
+}
+
+void CDeviceContext::TextOut(int x, int y, const TCHAR* text)
+{
+ ::TextOut(m_dc, x, y, text, static_cast(_tcslen(text)));
+}
+
+void CDeviceContext::TextOut(int x, int y, const TCHAR* text, COLORREF color)
+{
+ SetTextColor(m_dc, color);
+ TextOut(x, y, text);
+}
+
+HGDIOBJ CDeviceContext::SelectObject(HGDIOBJ hObject)
+{
+ return ::SelectObject(m_dc, hObject);
+}
Index: suserver_0.06/src/win32/InputBox.cpp
===================================================================
--- suserver_0.06/src/win32/InputBox.cpp (nonexistent)
+++ suserver_0.06/src/win32/InputBox.cpp (revision 450)
@@ -0,0 +1,214 @@
+#include "win32/InputBox.h"
+#include "PtrMacro.h"
+#include "layout/HorizontalLayout.h"
+#include "layout/LayoutStretch.h"
+#include "win32/Static.h"
+#include "win32/LayoutWindow.h"
+#include "win32/DefaultFonts.h"
+#include "win32/AcceleratorTableGenerator.h"
+
+#define CLSNAME _T("CInputBox")
+#define WNDSTYLE (WS_CAPTION | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU)
+#define WNDSTYLEEX (WS_EX_DLGMODALFRAME)
+
+#define IDC_SELECTALL (0xBEEF)
+#define SCALE(x) MulDiv(x, ydpi, 96)
+
+using namespace Framework;
+using namespace Framework::Win32;
+
+CInputBox::CInputBox(const TCHAR* sTitle, const TCHAR* sPrompt, const TCHAR* sValue)
+: m_pOk(NULL)
+, m_pCancel(NULL)
+, m_pValue(NULL)
+, m_nCancelled(false)
+, m_sTitle(sTitle)
+, m_sPrompt(sPrompt)
+, m_sValue((sValue != NULL) ? sValue : _T(""))
+, m_isMultiline(false)
+{
+
+}
+
+CInputBox::~CInputBox()
+{
+
+}
+
+void CInputBox::SetIsMultiline(bool isMultiline)
+{
+ m_isMultiline = isMultiline;
+}
+
+const TCHAR* CInputBox::GetValue(HWND hParent)
+{
+ EnableWindow(GetActiveWindow(), FALSE);
+
+ HFONT nFont = CDefaultFonts::GetMessageFont();
+
+ if(!DoesWindowClassExist(CLSNAME))
+ {
+ WNDCLASSEX wc;
+ memset(&wc, 0, sizeof(WNDCLASSEX));
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
+ wc.hInstance = GetModuleHandle(NULL);
+ wc.lpszClassName = CLSNAME;
+ wc.lpfnWndProc = CWindow::WndProc;
+ RegisterClassEx(&wc);
+ }
+
+ int ydpi = GetDeviceCaps(GetDC(NULL), LOGPIXELSY);
+
+ {
+ RECT rc;
+ if(m_isMultiline)
+ {
+ SetRect(&rc, 0, 0, SCALE(300), SCALE(150));
+ }
+ else
+ {
+ SetRect(&rc, 0, 0, SCALE(300), SCALE(115));
+ }
+ Create(WNDSTYLEEX, CLSNAME, m_sTitle.c_str(), WNDSTYLE, rc, hParent, NULL);
+ SetClassPtr();
+ }
+
+ m_pOk = new CButton(_T("OK"), m_hWnd, CRect(0, 0, 0, 0));
+ m_pOk->SetFont(nFont);
+ m_pOk->ModifyStyleOr(BS_DEFPUSHBUTTON);
+
+ m_pCancel = new CButton(_T("Cancel"), m_hWnd, CRect(0, 0, 0, 0));
+ m_pCancel->SetFont(nFont);
+
+ m_pValue = new CEdit(m_hWnd, CRect(0, 0, 0, 0), m_sValue.c_str(), m_isMultiline ? ES_MULTILINE : 0);
+ m_pValue->SetFont(nFont);
+ m_pValue->SetSelection(0, -1);
+ m_pValue->SetFocus();
+
+ FlatLayoutPtr pSubLayout0 = CHorizontalLayout::Create();
+ pSubLayout0->InsertObject(CLayoutStretch::Create());
+ pSubLayout0->InsertObject(CLayoutWindow::CreateButtonBehavior(SCALE(75), SCALE(23), m_pOk));
+ pSubLayout0->InsertObject(CLayoutWindow::CreateButtonBehavior(SCALE(75), SCALE(23), m_pCancel));
+ pSubLayout0->SetVerticalStretch(0);
+
+ m_layout = CVerticalLayout::Create();
+ m_layout->InsertObject(CLayoutWindow::CreateTextBoxBehavior(SCALE(100), SCALE(14), new CStatic(m_hWnd, m_sPrompt.c_str())));
+ if(m_isMultiline)
+ {
+ m_layout->InsertObject(CLayoutWindow::CreateCustomBehavior(SCALE(100), SCALE(20), 1, 1, m_pValue));
+ }
+ else
+ {
+ m_layout->InsertObject(CLayoutWindow::CreateTextBoxBehavior(SCALE(100), SCALE(21), m_pValue));
+ m_layout->InsertObject(CLayoutStretch::Create());
+ }
+ m_layout->InsertObject(pSubLayout0);
+
+ RefreshLayout();
+
+ HACCEL hAccel = CreateAccelerators();
+
+ Center();
+ Show(SW_SHOW);
+
+ while(IsWindow())
+ {
+ MSG msg;
+ GetMessage(&msg, NULL, 0, 0);
+ if(!TranslateAccelerator(m_hWnd, hAccel, &msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ DestroyAcceleratorTable(hAccel);
+
+ return m_nCancelled ? NULL : m_sValue.c_str();
+}
+
+void CInputBox::RefreshLayout()
+{
+ RECT rc = GetClientRect();
+
+ rc.left += 10;
+ rc.right -= 10;
+ rc.top += 7;
+ rc.bottom -= 7;
+
+ m_layout->SetRect(rc.left, rc.top, rc.right, rc.bottom);
+ m_layout->RefreshGeometry();
+}
+
+void CInputBox::RestoreFocus()
+{
+ EnableWindow(GetParent(), TRUE);
+ SetForegroundWindow(GetParent());
+}
+
+void CInputBox::ConfirmDialog()
+{
+ TCHAR sTemp[256];
+
+ m_pValue->GetText(sTemp, 255);
+ m_sValue = sTemp;
+
+ m_nCancelled = false;
+
+ RestoreFocus();
+ Destroy();
+}
+
+void CInputBox::CancelDialog()
+{
+ m_nCancelled = true;
+
+ RestoreFocus();
+ Destroy();
+}
+
+HACCEL CInputBox::CreateAccelerators()
+{
+ CAcceleratorTableGenerator generator;
+ generator.Insert(IDOK, VK_RETURN, FVIRTKEY);
+ generator.Insert(IDCANCEL, VK_ESCAPE, FVIRTKEY);
+ generator.Insert(IDC_SELECTALL, 'A', FVIRTKEY | FCONTROL);
+ return generator.Create();
+}
+
+long CInputBox::OnCommand(unsigned short nID, unsigned short nSubMsg, HWND hSender)
+{
+ if((hSender == m_pOk->m_hWnd) || (nID == IDOK))
+ {
+ ConfirmDialog();
+ return FALSE;
+ }
+ else if((hSender == m_pCancel->m_hWnd) || (nID == IDCANCEL))
+ {
+ CancelDialog();
+ return FALSE;
+ }
+ else if(nID == IDC_SELECTALL)
+ {
+ HWND focusWnd = GetFocus();
+ if(focusWnd == m_pValue->m_hWnd)
+ {
+ SendMessage(m_pValue->m_hWnd, EM_SETSEL, 0, -1);
+ }
+ return FALSE;
+ }
+ return TRUE;
+}
+
+long CInputBox::OnSysCommand(unsigned int nCmd, LPARAM lParam)
+{
+ switch(nCmd)
+ {
+ case SC_CLOSE:
+ CancelDialog();
+ return TRUE;
+ }
+ return TRUE;
+}
Index: suserver_0.06/src/win32/Font.cpp
===================================================================
--- suserver_0.06/src/win32/Font.cpp (nonexistent)
+++ suserver_0.06/src/win32/Font.cpp (revision 450)
@@ -0,0 +1,35 @@
+#include "win32/Font.h"
+#include "win32/ClientDeviceContext.h"
+
+using namespace Framework;
+
+HFONT Win32::CreateFont(const TCHAR* faceName, unsigned int height)
+{
+ LOGFONT font;
+ memset(&font, 0, sizeof(font));
+ font.lfHeight = -MulDiv(height, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72);
+ font.lfWidth = 0;
+ font.lfOrientation = 0;
+ font.lfWeight = FW_NORMAL;
+ font.lfItalic = FALSE;
+ font.lfUnderline = FALSE;
+ font.lfStrikeOut = FALSE;
+ font.lfCharSet = DEFAULT_CHARSET;
+ font.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ font.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ font.lfQuality = DEFAULT_QUALITY;
+ font.lfPitchAndFamily = DEFAULT_PITCH;
+ _tcsncpy(font.lfFaceName, faceName, LF_FACESIZE);
+ return CreateFontIndirect(&font);
+}
+
+SIZE Win32::GetFixedFontSize(HFONT font)
+{
+ Framework::Win32::CClientDeviceContext dc(NULL);
+
+ dc.SelectObject(font);
+
+ SIZE s = { 0, 0 };
+ GetTextExtentPoint32(dc, _T("0"), 1, &s);
+ return s;
+}
Index: suserver_0.06/src/win32/Rect.cpp
===================================================================
--- suserver_0.06/src/win32/Rect.cpp (nonexistent)
+++ suserver_0.06/src/win32/Rect.cpp (revision 450)
@@ -0,0 +1,128 @@
+#include "win32/Rect.h"
+
+using namespace Framework::Win32;
+
+CRect::CRect(int nLeft, int nTop, int nRight, int nBottom)
+{
+ SetRect(&m_rect, nLeft, nTop, nRight, nBottom);
+}
+
+CRect::CRect(const RECT& Source)
+{
+ CopyRect(&m_rect, &Source);
+}
+
+CRect::~CRect()
+{
+
+}
+
+CRect::operator RECT*()
+{
+ return &m_rect;
+}
+
+CRect::operator RECT&()
+{
+ return m_rect;
+}
+
+int CRect::Left() const
+{
+ return m_rect.left;
+}
+
+int CRect::Top() const
+{
+ return m_rect.top;
+}
+
+int CRect::Right() const
+{
+ return m_rect.right;
+}
+
+int CRect::Bottom() const
+{
+ return m_rect.bottom;
+}
+
+void CRect::SetLeft(int left)
+{
+ m_rect.left = left;
+}
+
+void CRect::SetTop(int top)
+{
+ m_rect.top = top;
+}
+
+void CRect::SetRight(int right)
+{
+ m_rect.right = right;
+}
+
+void CRect::SetBottom(int bottom)
+{
+ m_rect.bottom = bottom;
+}
+
+int CRect::Width() const
+{
+ return m_rect.right - m_rect.left;
+}
+
+int CRect::Height() const
+{
+ return m_rect.bottom - m_rect.top;
+}
+
+CRect& CRect::Adjust(uint32 nStyle, bool nMenu)
+{
+ AdjustWindowRect(&m_rect, nStyle, (nMenu) ? TRUE : FALSE);
+ return (*this);
+}
+
+CRect& CRect::Inflate(int nDx, int nDy)
+{
+ InflateRect(&m_rect, nDx, nDy);
+ return (*this);
+}
+
+CRect& CRect::CenterInside(const CRect& parentRect)
+{
+ unsigned int width = Width();
+ unsigned int height = Height();
+ m_rect.left = parentRect.Left() + ((parentRect.Width() - width) / 2);
+ m_rect.top = parentRect.Top() + ((parentRect.Height() - height) / 2);
+ m_rect.right = m_rect.left + width;
+ m_rect.bottom = m_rect.top + height;
+ return (*this);
+}
+
+CRect& CRect::ScreenToClient(HWND window)
+{
+ ::ScreenToClient(window, reinterpret_cast(&m_rect) + 0);
+ ::ScreenToClient(window, reinterpret_cast(&m_rect) + 1);
+ return (*this);
+}
+
+CRect& CRect::ClientToScreen(HWND window)
+{
+ ::ClientToScreen(window, reinterpret_cast(&m_rect) + 0);
+ ::ClientToScreen(window, reinterpret_cast(&m_rect) + 1);
+ return (*this);
+}
+
+bool CRect::PtIn(int nX, int nY) const
+{
+ POINT pt;
+ pt.x = nX;
+ pt.y = nY;
+ return PtInRect(&m_rect, pt) != 0;
+}
+
+CRect Framework::Win32::MakeRectPositionSize(int left, int top, int width, int height)
+{
+ return CRect(left, top, left + width, top + height);
+}
Index: suserver_0.06/src/win32/Tab.cpp
===================================================================
--- suserver_0.06/src/win32/Tab.cpp (nonexistent)
+++ suserver_0.06/src/win32/Tab.cpp (revision 450)
@@ -0,0 +1,110 @@
+#include "win32/Tab.h"
+#include "win32/DefaultFonts.h"
+
+using namespace Framework::Win32;
+
+CTab::CTab(HWND hWnd)
+{
+ m_hWnd = hWnd;
+}
+
+CTab::CTab(HWND hParent, const RECT& rect, unsigned long nStyle, unsigned long nExStyle)
+{
+ InitCommonControls();
+ Create(nExStyle, WC_TABCONTROL, _T(""), WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | nStyle, rect, hParent, NULL);
+ SetFont(CDefaultFonts::GetMessageFont());
+}
+
+CTab::~CTab()
+{
+
+}
+
+CTab& CTab::operator =(CTab&& rhs)
+{
+ CWindow::Reset();
+ CWindow::MoveFrom(std::move(rhs));
+ return (*this);
+}
+
+int CTab::InsertTab(const TCHAR* text)
+{
+ TC_ITEM item = {};
+ item.mask = TCIF_TEXT;
+ item.pszText = const_cast(text);
+
+ return TabCtrl_InsertItem(m_hWnd, GetItemCount(), &item);
+}
+
+void CTab::DeleteTab(int tab)
+{
+ TabCtrl_DeleteItem(m_hWnd, tab);
+}
+
+std::tstring CTab::GetTabText(int tab)
+{
+ TCHAR text[_MAX_PATH];
+
+ TC_ITEM item = {};
+ item.mask = TCIF_TEXT;
+ item.pszText = text;
+ item.cchTextMax = countof(text);
+
+ TabCtrl_GetItem(m_hWnd, tab, &item);
+
+ return std::tstring(text);
+}
+
+void CTab::SetTabText(int tab, const TCHAR* text)
+{
+ TC_ITEM item = {};
+ item.mask = TCIF_TEXT;
+ item.pszText = const_cast(text);
+ TabCtrl_SetItem(m_hWnd, tab, &item);
+}
+
+LPARAM CTab::GetTabData(int tab)
+{
+ TC_ITEM item = {};
+ item.mask = TCIF_PARAM;
+ TabCtrl_GetItem(m_hWnd, tab, &item);
+ return item.lParam;
+}
+
+void CTab::SetTabData(int tab, LPARAM param)
+{
+ TC_ITEM item = {};
+ item.mask = TCIF_PARAM;
+ item.lParam = param;
+ TabCtrl_SetItem(m_hWnd, tab, &item);
+}
+
+int CTab::GetSelection()
+{
+ return TabCtrl_GetCurSel(m_hWnd);
+}
+
+void CTab::SetSelection(int nSelection)
+{
+ TabCtrl_SetCurSel(m_hWnd, nSelection);
+}
+
+unsigned int CTab::GetItemCount()
+{
+ return TabCtrl_GetItemCount(m_hWnd);
+}
+
+int CTab::HitTest(int x, int y)
+{
+ TCHITTESTINFO hitTestInfo = {};
+ hitTestInfo.pt.x = x;
+ hitTestInfo.pt.y = y;
+ return TabCtrl_HitTest(m_hWnd, &hitTestInfo);
+}
+
+Framework::Win32::CRect CTab::GetDisplayAreaRect()
+{
+ RECT rect = GetClientRect();
+ TabCtrl_AdjustRect(m_hWnd, FALSE, &rect);
+ return rect;
+}
Index: suserver_0.06/src/win32/ToolBar.cpp
===================================================================
--- suserver_0.06/src/win32/ToolBar.cpp (nonexistent)
+++ suserver_0.06/src/win32/ToolBar.cpp (revision 450)
@@ -0,0 +1,122 @@
+#include "win32/ToolBar.h"
+
+using namespace Framework::Win32;
+
+CToolBar::CToolBar()
+{
+
+}
+
+CToolBar::CToolBar(HWND hParent, unsigned int nBitmapNumber, HINSTANCE hInstance, unsigned int nBitmapId, unsigned int nButtonWidth, unsigned int nButtonHeight)
+{
+ m_hWnd = CreateToolbarEx(hParent, WS_VISIBLE | TBSTYLE_TOOLTIPS, NULL,
+ nBitmapNumber, hInstance, nBitmapId, NULL, 0, nButtonWidth, nButtonHeight, nButtonWidth, nButtonHeight, sizeof(TBBUTTON));
+}
+
+CToolBar::CToolBar(HWND parentWnd, DWORD style)
+{
+ m_hWnd = CreateWindowEx(NULL, TOOLBARCLASSNAME, NULL, WS_VISIBLE | WS_CHILD | style, 0, 0, 1, 1, parentWnd, NULL, GetModuleHandle(NULL), NULL);
+ SendMessage(m_hWnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
+}
+
+CToolBar::~CToolBar()
+{
+
+}
+
+CToolBar& CToolBar::operator =(CToolBar&& rhs)
+{
+ Reset();
+ MoveFrom(std::move(rhs));
+ return (*this);
+}
+
+void CToolBar::Reset()
+{
+ m_buttonToolTips.clear();
+ CWindow::Reset();
+}
+
+void CToolBar::MoveFrom(CToolBar&& rhs)
+{
+ m_buttonToolTips = std::move(rhs.m_buttonToolTips);
+ CWindow::MoveFrom(std::move(rhs));
+}
+
+void CToolBar::InsertImageButton(unsigned int bitmapId, unsigned int commandId)
+{
+ TBBUTTON button;
+
+ memset(&button, 0, sizeof(TBBUTTON));
+ button.iBitmap = bitmapId;
+ button.idCommand = commandId;
+ button.fsState = TBSTATE_ENABLED;
+ button.fsStyle = TBSTYLE_BUTTON;
+
+ SendMessage(m_hWnd, TB_ADDBUTTONS, 1, reinterpret_cast(&button));
+}
+
+void CToolBar::InsertTextButton(const TCHAR* text, unsigned int commandId)
+{
+ TBBUTTON button;
+
+ memset(&button, 0, sizeof(TBBUTTON));
+ button.iBitmap = I_IMAGENONE;
+ button.idCommand = commandId;
+ button.fsState = TBSTATE_ENABLED;
+ button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
+ button.iString = reinterpret_cast(text);
+
+ SendMessage(m_hWnd, TB_ADDBUTTONS, 1, reinterpret_cast(&button));
+}
+
+void CToolBar::LoadStandardImageList(unsigned int nIndex)
+{
+ SendMessage(m_hWnd, TB_LOADIMAGES, nIndex, reinterpret_cast(HINST_COMMCTRL));
+}
+
+void CToolBar::Resize()
+{
+ SendMessage(m_hWnd, TB_AUTOSIZE, 0, 0);
+}
+
+HWND CToolBar::GetToolTips()
+{
+ return reinterpret_cast(SendMessage(m_hWnd, TB_GETTOOLTIPS, NULL, NULL));
+}
+
+void CToolBar::SetButtonToolTipText(unsigned int nId, const TCHAR* sText)
+{
+ m_buttonToolTips[nId] = sText;
+}
+
+void CToolBar::SetButtonChecked(unsigned int id, bool checked)
+{
+ TBBUTTONINFO buttonInfo = {};
+ buttonInfo.cbSize = sizeof(TBBUTTONINFO);
+ buttonInfo.idCommand = id;
+ buttonInfo.fsState = TBSTATE_ENABLED | (checked ? TBSTATE_CHECKED : 0);
+ buttonInfo.dwMask = TBIF_STATE;
+
+ SendMessage(m_hWnd, TB_SETBUTTONINFO, id, reinterpret_cast(&buttonInfo));
+}
+
+void CToolBar::ProcessNotify(WPARAM wparam, NMHDR* hdr)
+{
+ if(hdr->hwndFrom != GetToolTips()) return;
+
+ switch(hdr->code)
+ {
+ case TTN_GETDISPINFO:
+ {
+ LPTOOLTIPTEXT toolTipText(reinterpret_cast(hdr));
+
+ auto toolTipIterator = m_buttonToolTips.find(static_cast(hdr->idFrom));
+ if(toolTipIterator == m_buttonToolTips.end()) return;
+
+ toolTipText->hinst = GetModuleHandle(NULL);
+ toolTipText->lpszText = const_cast((*toolTipIterator).second.c_str());
+ }
+ break;
+ }
+}
Index: suserver_0.06/src/win32/VerticalSplitter.cpp
===================================================================
--- suserver_0.06/src/win32/VerticalSplitter.cpp (nonexistent)
+++ suserver_0.06/src/win32/VerticalSplitter.cpp (revision 450)
@@ -0,0 +1,77 @@
+#include
+#include
+#include "win32/VerticalSplitter.h"
+
+using namespace Framework::Win32;
+
+CVerticalSplitter::CVerticalSplitter(HWND hParent, const RECT& Rect) :
+CSplitter(hParent, Rect, LoadCursor(NULL, IDC_SIZENS), ((Rect.bottom - Rect.top) - EDGESIZE) / 2)
+{
+
+}
+
+CRect CVerticalSplitter::GetEdgeRect()
+{
+ auto clientRect = GetClientRect();
+ Framework::Win32::CRect result(0, 0, clientRect.Right(), 0);
+ if(m_masterChild == 0)
+ {
+ result.SetTop(m_edgePosition);
+ result.SetBottom(m_edgePosition + EDGESIZE);
+ }
+ else
+ {
+ result.SetTop(clientRect.Bottom() - m_edgePosition);
+ result.SetBottom(clientRect.Bottom() - m_edgePosition + EDGESIZE);
+ }
+ assert(result.Height() == EDGESIZE);
+ return result;
+}
+
+CRect CVerticalSplitter::GetPaneRect(unsigned int nIndex)
+{
+ auto clientRect = GetClientRect();
+ Framework::Win32::CRect result(0, 0, clientRect.Right(), 0);
+ if(m_masterChild == 0)
+ {
+ if(nIndex == 0)
+ {
+ result.SetTop(0);
+ result.SetBottom(m_edgePosition);
+ }
+ else if(nIndex == 1)
+ {
+ result.SetTop(m_edgePosition + EDGESIZE);
+ result.SetBottom(clientRect.Bottom());
+ }
+ }
+ else
+ {
+ if(nIndex == 0)
+ {
+ result.SetTop(0);
+ result.SetBottom(clientRect.Bottom() - m_edgePosition);
+ }
+ else if(nIndex == 1)
+ {
+ result.SetTop(clientRect.Bottom() - m_edgePosition + EDGESIZE);
+ result.SetBottom(clientRect.Bottom());
+ }
+ }
+ return result;
+}
+
+void CVerticalSplitter::UpdateEdgePosition(int nX, int nY)
+{
+ auto clientRect = GetClientRect();
+ nY = std::max(nY, EDGESIZE);
+ nY = std::min(nY, clientRect.Bottom() - EDGESIZE);
+ if(m_masterChild == 0)
+ {
+ m_edgePosition = nY;
+ }
+ else
+ {
+ m_edgePosition = clientRect.Bottom() - nY;
+ }
+}
Index: suserver_0.06/src/win32/Splitter.cpp
===================================================================
--- suserver_0.06/src/win32/Splitter.cpp (nonexistent)
+++ suserver_0.06/src/win32/Splitter.cpp (revision 450)
@@ -0,0 +1,127 @@
+#include "win32/Splitter.h"
+#include
+
+#define CLSNAME _T("CSplitter")
+
+using namespace Framework;
+using namespace Framework::Win32;
+
+CSplitter::CSplitter(HWND parentWnd, const RECT& rect, HCURSOR cursor, unsigned int edgePosition)
+: m_cursor(cursor)
+, m_edgePosition(edgePosition)
+{
+ m_child[0] = nullptr;
+ m_child[1] = nullptr;
+
+ if(!DoesWindowClassExist(CLSNAME))
+ {
+ WNDCLASSEX w;
+ memset(&w, 0, sizeof(WNDCLASSEX));
+ w.cbSize = sizeof(WNDCLASSEX);
+ w.lpfnWndProc = CWindow::WndProc;
+ w.lpszClassName = CLSNAME;
+ w.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
+ w.hInstance = GetModuleHandle(NULL);
+ w.hCursor = LoadCursor(NULL, IDC_ARROW);
+ w.style = CS_VREDRAW | CS_HREDRAW;
+ RegisterClassEx(&w);
+ }
+
+ Create(WS_EX_CONTROLPARENT, CLSNAME, _T(""), WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, rect, parentWnd, NULL);
+ SetClassPtr();
+}
+
+CSplitter::~CSplitter()
+{
+
+}
+
+void CSplitter::SetChild(unsigned int index, HWND hWnd)
+{
+ m_child[index] = hWnd;
+ ResizeChild(index);
+}
+
+void CSplitter::SetMasterChild(unsigned int masterChild)
+{
+ assert(masterChild == 0 || masterChild == 1);
+ m_masterChild = masterChild;
+}
+
+void CSplitter::SetEdgePosition(double fraction)
+{
+ RECT clientRect = GetClientRect();
+ short x = (short)((double)clientRect.right * fraction);
+ short y = (short)((double)clientRect.bottom * fraction);
+
+ UpdateEdgePosition(x, y);
+
+ ResizeChild(0);
+ ResizeChild(1);
+}
+
+void CSplitter::SetFixed(bool fixed)
+{
+ m_fixed = fixed;
+}
+
+long CSplitter::OnSize(unsigned int nX, unsigned int nY, unsigned int nType)
+{
+ ResizeChild(0);
+ ResizeChild(1);
+ return TRUE;
+}
+
+long CSplitter::OnMouseMove(WPARAM wParam, int nX, int nY)
+{
+ if(GetCapture() == m_hWnd)
+ {
+ UpdateEdgePosition(nX, nY);
+
+ ResizeChild(0);
+ ResizeChild(1);
+ }
+
+ auto edgeRect = GetEdgeRect();
+
+ if(!m_fixed && edgeRect.PtIn(nX, nY))
+ {
+ SetCursor(m_cursor);
+ }
+
+ return TRUE;
+}
+
+long CSplitter::OnLeftButtonDown(int nX, int nY)
+{
+ auto edgeRect = GetEdgeRect();
+
+ if(!m_fixed && edgeRect.PtIn(nX, nY))
+ {
+ SetCapture(m_hWnd);
+ SetCursor(m_cursor);
+ }
+
+ return TRUE;
+}
+
+long CSplitter::OnLeftButtonUp(int nX, int nY)
+{
+ ReleaseCapture();
+ return TRUE;
+}
+
+long CSplitter::OnNotify(WPARAM wParam, NMHDR* pH)
+{
+ return (long)SendMessage(GetParent(), WM_NOTIFY, wParam, (LPARAM)pH);
+}
+
+void CSplitter::ResizeChild(unsigned int index)
+{
+ if(m_child[index] == nullptr) return;
+
+ auto paneRect = GetPaneRect(index);
+ SetWindowPos(m_child[index], NULL, paneRect.Left(), paneRect.Top(), paneRect.Width(), paneRect.Height(), SWP_NOZORDER);
+
+ SendMessage(GetParent(), WM_COMMAND, MAKEWPARAM(0, 0), reinterpret_cast(m_hWnd));
+}
Index: suserver_0.06/src/win32/HorizontalSplitter.cpp
===================================================================
--- suserver_0.06/src/win32/HorizontalSplitter.cpp (nonexistent)
+++ suserver_0.06/src/win32/HorizontalSplitter.cpp (revision 450)
@@ -0,0 +1,77 @@
+#include
+#include
+#include "win32/HorizontalSplitter.h"
+
+using namespace Framework::Win32;
+
+CHorizontalSplitter::CHorizontalSplitter(HWND hParent, const RECT& Rect) :
+CSplitter(hParent, Rect, LoadCursor(NULL, IDC_SIZEWE), ((Rect.right - Rect.left) - EDGESIZE) / 2)
+{
+
+}
+
+CRect CHorizontalSplitter::GetEdgeRect()
+{
+ auto clientRect = GetClientRect();
+ Framework::Win32::CRect result(0, 0, 0, clientRect.Bottom());
+ if(m_masterChild == 0)
+ {
+ result.SetLeft(m_edgePosition);
+ result.SetRight(m_edgePosition + EDGESIZE);
+ }
+ else
+ {
+ result.SetLeft(clientRect.Right() - m_edgePosition);
+ result.SetRight(clientRect.Right() - m_edgePosition + EDGESIZE);
+ }
+ assert(result.Width() == EDGESIZE);
+ return result;
+}
+
+CRect CHorizontalSplitter::GetPaneRect(unsigned int nIndex)
+{
+ auto clientRect = GetClientRect();
+ Framework::Win32::CRect result(0, 0, 0, clientRect.Bottom());
+ if(m_masterChild == 0)
+ {
+ if(nIndex == 0)
+ {
+ result.SetLeft(0);
+ result.SetRight(m_edgePosition);
+ }
+ else if(nIndex == 1)
+ {
+ result.SetLeft(m_edgePosition + EDGESIZE);
+ result.SetRight(clientRect.Right());
+ }
+ }
+ else
+ {
+ if(nIndex == 0)
+ {
+ result.SetLeft(0);
+ result.SetRight(clientRect.Right() - m_edgePosition);
+ }
+ else if(nIndex == 1)
+ {
+ result.SetLeft(clientRect.Right() - m_edgePosition + EDGESIZE);
+ result.SetRight(clientRect.Right());
+ }
+ }
+ return result;
+}
+
+void CHorizontalSplitter::UpdateEdgePosition(int nX, int nY)
+{
+ auto clientRect = GetClientRect();
+ nX = std::max(nX, EDGESIZE);
+ nX = std::min(nX, clientRect.Right() - EDGESIZE);
+ if(m_masterChild == 0)
+ {
+ m_edgePosition = nX;
+ }
+ else
+ {
+ m_edgePosition = clientRect.Right() - nX;
+ }
+}
Index: suserver_0.06/src/win32/ListBox.cpp
===================================================================
--- suserver_0.06/src/win32/ListBox.cpp (nonexistent)
+++ suserver_0.06/src/win32/ListBox.cpp (revision 450)
@@ -0,0 +1,53 @@
+#include "win32/ListBox.h"
+#include "win32/DefaultFonts.h"
+
+using namespace Framework;
+using namespace Framework::Win32;
+
+CListBox::CListBox(HWND hWnd)
+{
+ m_hWnd = hWnd;
+}
+
+CListBox::CListBox(HWND hParent, const RECT& rect, unsigned long nStyle, unsigned long nStyleEx)
+{
+ Create(nStyleEx, _T("LISTBOX"), _T(""), WS_VISIBLE | WS_CHILD | nStyle, rect, hParent, NULL);
+ SetFont(CDefaultFonts::GetMessageFont());
+}
+
+CListBox& CListBox::operator =(CListBox&& rhs)
+{
+ CWindow::Reset();
+ CWindow::MoveFrom(std::move(rhs));
+ return (*this);
+}
+
+unsigned int CListBox::AddString(const TCHAR* sValue)
+{
+ return static_cast(SendMessage(m_hWnd, LB_ADDSTRING, NULL, (LPARAM)sValue));
+}
+
+void CListBox::ResetContent()
+{
+ SendMessage(m_hWnd, LB_RESETCONTENT, NULL, NULL);
+}
+
+int CListBox::GetCurrentSelection()
+{
+ return static_cast(SendMessage(m_hWnd, LB_GETCURSEL, 0, 0));
+}
+
+void CListBox::SetCurrentSelection(unsigned int index)
+{
+ SendMessage(m_hWnd, LB_SETCURSEL, index, 0);
+}
+
+INT_PTR CListBox::GetItemData(unsigned int index)
+{
+ return SendMessage(m_hWnd, LB_GETITEMDATA, index, 0);
+}
+
+void CListBox::SetItemData(unsigned int index, INT_PTR itemData)
+{
+ SendMessage(m_hWnd, LB_SETITEMDATA, index, itemData);
+}
Index: suserver_0.06/src/win32/Window.cpp
===================================================================
--- suserver_0.06/src/win32/Window.cpp (nonexistent)
+++ suserver_0.06/src/win32/Window.cpp (revision 450)
@@ -0,0 +1,677 @@
+#include "win32/Window.h"
+#include
+#include
+
+using namespace Framework;
+using namespace Framework::Win32;
+
+#define PROPNAME _T("CWindow::this")
+
+CWindow::CWindow()
+: m_hWnd(NULL)
+, m_baseWndProc(nullptr)
+, m_noCallDef(false)
+, m_hasClassPtr(false)
+{
+
+}
+
+CWindow::~CWindow()
+{
+
+}
+
+void CWindow::Reset()
+{
+ if(m_hWnd && m_hasClassPtr)
+ {
+ ClearClassPtr();
+ }
+ m_hWnd = NULL;
+ m_baseWndProc = nullptr;
+ m_hasClassPtr = false;
+ m_noCallDef = false;
+}
+
+void CWindow::MoveFrom(CWindow&& rhs)
+{
+ assert(m_hWnd == NULL);
+ std::swap(m_hWnd, rhs.m_hWnd);
+ std::swap(m_baseWndProc, rhs.m_baseWndProc);
+ std::swap(m_hasClassPtr, rhs.m_hasClassPtr);
+ std::swap(m_noCallDef, rhs.m_noCallDef);
+ if(m_hasClassPtr)
+ {
+ SetClassPtr();
+ }
+}
+
+CWindow::operator HWND() const
+{
+ return m_hWnd;
+}
+
+void CWindow::StdMsgLoop(CWindow& window)
+{
+ while(window.IsWindow())
+ {
+ MSG m;
+ GetMessage(&m, NULL, NULL, NULL);
+ TranslateMessage(&m);
+ DispatchMessage(&m);
+ }
+}
+
+void CWindow::DlgMsgLoop(CWindow& window)
+{
+ while(window.IsWindow())
+ {
+ MSG m;
+ GetMessage(&m, NULL, NULL, NULL);
+ if(!IsDialogMessage(window.m_hWnd, &m))
+ {
+ TranslateMessage(&m);
+ DispatchMessage(&m);
+ }
+ }
+}
+
+int CWindow::MessageBoxFormat(HWND hWnd, unsigned int nType, const TCHAR* sTitle, const TCHAR* sFormat, ...)
+{
+ TCHAR sMessage[256];
+ va_list Args;
+
+ va_start(Args, sFormat);
+ _vsntprintf(sMessage, 256, sFormat, Args);
+ va_end(Args);
+
+ return MessageBox(hWnd, sMessage, sTitle, nType);
+}
+
+void CWindow::SetClassPtr()
+{
+ SetProp(m_hWnd, PROPNAME, this);
+ m_hasClassPtr = true;
+}
+
+void CWindow::ClearClassPtr()
+{
+ assert(m_hasClassPtr == true);
+ SetProp(m_hWnd, PROPNAME, NULL);
+ m_hasClassPtr = false;
+}
+
+CWindow* CWindow::GetClassPtr(HWND hWnd)
+{
+ return reinterpret_cast(GetProp(hWnd, PROPNAME));
+}
+
+void CWindow::SubClass()
+{
+ SetClassPtr();
+ m_baseWndProc = reinterpret_cast(SetWindowLongPtr(m_hWnd, GWLP_WNDPROC, reinterpret_cast(SubClassWndProc)));
+}
+
+long CWindow::CallBaseWndProc(unsigned int uiMsg, WPARAM wParam, LPARAM lParam)
+{
+ return (long)CallWindowProc(m_baseWndProc, m_hWnd, uiMsg, wParam, lParam);
+}
+
+bool CWindow::DoesWindowClassExist(const TCHAR* className)
+{
+ WNDCLASS wc;
+ return GetClassInfo(GetModuleHandle(NULL), className, &wc) != 0;
+}
+
+bool CWindow::IsNotifySource(const CWindow* pWindow, const NMHDR* pHdr)
+{
+ return (pWindow != NULL) && (pWindow->m_hWnd == pHdr->hwndFrom);
+}
+
+bool CWindow::IsCommandSource(const CWindow* pWindow, HWND hWndFrom)
+{
+ return (pWindow != NULL) && (pWindow->m_hWnd == hWndFrom);
+}
+
+///////////////////////////////////////////////////////////
+//Window Message Helpers
+///////////////////////////////////////////////////////////
+
+void CWindow::Create(unsigned long nStyleEx, const TCHAR* sClass, const TCHAR* sWindow, unsigned long nStyle, const CRect& rect, HWND hParent, void* pParam)
+{
+ m_hWnd = CreateWindowEx(nStyleEx, sClass, sWindow, nStyle, rect.Left(), rect.Top(), rect.Width(), rect.Height(),
+ hParent, NULL, GetModuleHandle(NULL), pParam);
+ assert(m_hWnd != NULL);
+}
+
+bool CWindow::IsWindow()
+{
+ return (::IsWindow(m_hWnd) ? true : false);
+}
+
+bool CWindow::IsVisible()
+{
+ long nStyle;
+ nStyle = GetWindowLong(m_hWnd, GWL_STYLE);
+ if(nStyle & WS_VISIBLE) return true;
+ return false;
+}
+
+unsigned int CWindow::Destroy()
+{
+ return DestroyWindow(m_hWnd);
+}
+
+unsigned int CWindow::Show(int nMode)
+{
+ return ShowWindow(m_hWnd, nMode);
+}
+
+unsigned int CWindow::Enable(unsigned int nEnable)
+{
+ return EnableWindow(m_hWnd, nEnable);
+}
+
+std::tstring CWindow::GetText()
+{
+ TCHAR* sBuffer;
+ unsigned int nLength(GetTextLength() + 1);
+ sBuffer = reinterpret_cast(_alloca(sizeof(TCHAR) * nLength));
+ GetText(sBuffer, nLength);
+ return std::tstring(sBuffer);
+}
+
+int CWindow::GetText(TCHAR* sText, int nMax)
+{
+ return GetWindowText(m_hWnd, sText, nMax);
+}
+
+unsigned int CWindow::GetTextLength()
+{
+ return (unsigned int)SendMessage(m_hWnd, WM_GETTEXTLENGTH, 0, 0);
+}
+
+unsigned int CWindow::SetText(const TCHAR* sText)
+{
+ return SetWindowText(m_hWnd, sText);
+}
+
+unsigned int CWindow::SetTextA(const char* sText)
+{
+ return SetWindowTextA(m_hWnd, sText);
+}
+
+void CWindow::SetFocus()
+{
+ ::SetFocus(m_hWnd);
+}
+
+void CWindow::SetFont(HFONT nFont)
+{
+ SendMessage(m_hWnd, WM_SETFONT, (WPARAM)nFont, TRUE);
+}
+
+HFONT CWindow::GetFont()
+{
+ return reinterpret_cast(SendMessage(m_hWnd, WM_GETFONT, 0, 0));
+}
+
+void CWindow::SetMenu(HMENU nMenu)
+{
+ ::SetMenu(m_hWnd, nMenu);
+}
+
+void CWindow::SetIcon(unsigned int nWhich, HICON nIcon)
+{
+ SendMessage(m_hWnd, WM_SETICON, nWhich, (LPARAM)nIcon);
+}
+
+HWND CWindow::GetParent()
+{
+ return ::GetParent(m_hWnd);
+}
+
+CRect CWindow::GetClientRect()
+{
+ RECT rect;
+ ::GetClientRect(m_hWnd, &rect);
+ return rect;
+}
+
+CRect CWindow::GetWindowRect()
+{
+ RECT rect;
+ ::GetWindowRect(m_hWnd, &rect);
+ return rect;
+}
+
+void CWindow::Center(HWND hParent)
+{
+ RECT rParent;
+
+ RECT rWindow = GetWindowRect();
+ if(hParent == NULL)
+ {
+ SetRect(&rParent, 0, 0, GetDeviceCaps(GetDC(NULL), HORZRES), GetDeviceCaps(GetDC(NULL), VERTRES));
+ }
+ else
+ {
+ ::GetClientRect(hParent, &rParent);
+ }
+
+ POINT result;
+ result.x = (rParent.right - (rWindow.right - rWindow.left)) / 2;
+ result.y = (rParent.bottom - (rWindow.bottom - rWindow.top)) / 2;
+
+ if(hParent != NULL)
+ {
+ POINT origin;
+ origin.x = 0;
+ origin.y = 0;
+ ClientToScreen(hParent, &origin);
+ result.x += origin.x;
+ result.y += origin.y;
+ }
+
+ SetWindowPos(m_hWnd, NULL, result.x, result.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+}
+
+void CWindow::SetSize(unsigned int nWidth, unsigned int nHeight)
+{
+ SetWindowPos(m_hWnd, NULL, 0, 0, nWidth, nHeight, SWP_NOMOVE | SWP_NOZORDER);
+}
+
+void CWindow::SetPosition(unsigned int nX, unsigned int nY)
+{
+ SetWindowPos(m_hWnd, NULL, nX, nY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+}
+
+void CWindow::SetSizePosition(const CRect& rect)
+{
+ SetWindowPos(m_hWnd, NULL, rect.Left(), rect.Top(), rect.Width(), rect.Height(), SWP_NOZORDER);
+}
+
+void CWindow::Redraw()
+{
+ RedrawWindow(m_hWnd, NULL, NULL, RDW_ERASE | RDW_UPDATENOW | RDW_INVALIDATE);
+}
+
+void CWindow::ModifyStyleOr(unsigned long nStyleBit)
+{
+ SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE) | nStyleBit);
+}
+
+void CWindow::SetRedraw(bool nRedrawAllowed)
+{
+ SendMessage(m_hWnd, WM_SETREDRAW, (nRedrawAllowed) ? TRUE : FALSE, 0);
+}
+
+CScrollBar CWindow::GetVerticalScrollBar()
+{
+ return CScrollBar(m_hWnd, SB_VERT);
+}
+
+CScrollBar CWindow::GetHorizontalScrollBar()
+{
+ return CScrollBar(m_hWnd, SB_HORZ);
+}
+
+///////////////////////////////////////////////////////////
+//Window Message Handlers
+///////////////////////////////////////////////////////////
+
+LRESULT WINAPI CWindow::WndProc(HWND hWnd, unsigned int uiMsg, WPARAM wParam, LPARAM lParam)
+{
+ if(uiMsg == WM_NCCREATE)
+ {
+ CWindow* window(NULL);
+ bool foundWnd = false;
+
+ HWND parentWnd = ::GetParent(hWnd);
+ if(parentWnd != NULL)
+ {
+ TCHAR className[255];
+ GetClassName(parentWnd, className, 255);
+ if(!_tcsicmp(className, _T("MDIClient")))
+ {
+ CREATESTRUCT* createStruct(reinterpret_cast(lParam));
+ MDICREATESTRUCT* mdiCreateStruct(reinterpret_cast(createStruct->lpCreateParams));
+ window = reinterpret_cast(mdiCreateStruct->lParam);
+ foundWnd = true;
+ }
+ }
+
+ if(!foundWnd)
+ {
+ CREATESTRUCT* createStruct(reinterpret_cast(lParam));
+ window = reinterpret_cast(createStruct->lpCreateParams);
+ }
+
+ if(window != NULL)
+ {
+ window->m_hWnd = hWnd;
+ window->SetClassPtr();
+ }
+ }
+ CWindow* pThis = GetClassPtr(hWnd);
+ if(pThis == NULL)
+ {
+ return DefWindowProc(hWnd, uiMsg, wParam, lParam);
+ }
+ switch(uiMsg)
+ {
+ case WM_CLOSE:
+ if(!pThis->OnClose()) return FALSE;
+ break;
+ case WM_SYSCOMMAND:
+ if(!pThis->OnSysCommand((unsigned int)wParam, lParam)) return FALSE;
+ break;
+ case WM_SIZE:
+ if(!pThis->OnSize((unsigned int)wParam, LOWORD(lParam), HIWORD(lParam))) return FALSE;
+ break;
+ case WM_SETFOCUS:
+ pThis->OnSetFocus();
+ break;
+ case WM_KILLFOCUS:
+ pThis->OnKillFocus();
+ break;
+ case WM_PAINT:
+ if(!pThis->OnPaint()) return FALSE;
+ break;
+ case WM_ERASEBKGND:
+ {
+ long nRet = pThis->OnEraseBkgnd();
+ if(nRet != 0) return nRet;
+ }
+ break;
+ case WM_KEYDOWN:
+ if(!pThis->OnKeyDown(wParam, lParam)) return FALSE;
+ break;
+ case WM_KEYUP:
+ if(!pThis->OnKeyUp(wParam, lParam)) return FALSE;
+ break;
+ case WM_SYSKEYDOWN:
+ if(!pThis->OnSysKeyDown((unsigned int)wParam)) return FALSE;
+ break;
+ case WM_COMMAND:
+ if(!pThis->OnCommand(LOWORD(wParam), HIWORD(wParam), (HWND)lParam)) return FALSE;
+ break;
+ case WM_NOTIFY:
+ return pThis->OnNotify(wParam, (NMHDR*)lParam);
+ break;
+ case WM_TIMER:
+ pThis->OnTimer(wParam);
+ return FALSE;
+ break;
+ case WM_HSCROLL:
+ if(!pThis->OnHScroll(LOWORD(wParam), HIWORD(wParam))) return FALSE;
+ break;
+ case WM_VSCROLL:
+ if(!pThis->OnVScroll(LOWORD(wParam), HIWORD(wParam))) return FALSE;
+ break;
+ case WM_MOUSEMOVE:
+ if(!pThis->OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) return FALSE;
+ break;
+ case WM_LBUTTONDOWN:
+ if(!pThis->OnLeftButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) return FALSE;
+ break;
+ case WM_LBUTTONUP:
+ if(!pThis->OnLeftButtonUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) return FALSE;
+ break;
+ case WM_LBUTTONDBLCLK:
+ if(!pThis->OnLeftButtonDblClk(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) return FALSE;
+ break;
+ case WM_RBUTTONDOWN:
+ if(!pThis->OnRightButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) return FALSE;
+ break;
+ case WM_RBUTTONUP:
+ if(!pThis->OnRightButtonUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) return FALSE;
+ break;
+ case WM_MOUSEWHEEL:
+ if(!pThis->OnMouseWheel(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), GET_WHEEL_DELTA_WPARAM(wParam))) return FALSE;
+ break;
+ case WM_MOUSELEAVE:
+ if(!pThis->OnMouseLeave()) return FALSE;
+ break;
+ case WM_DESTROY:
+ if(!pThis->OnDestroy()) return FALSE;
+ break;
+ case WM_NCDESTROY:
+ //Window Handle not valid after this
+ pThis->m_hWnd = NULL;
+ break;
+ case WM_CTLCOLORSTATIC:
+ {
+ long nBrush = pThis->OnCtlColorStatic((HDC)wParam, (HWND)lParam);
+ if(!nBrush)
+ {
+ return (long)DefWindowProc(hWnd, uiMsg, wParam, lParam);
+ }
+ else
+ {
+ return nBrush;
+ }
+ }
+ break;
+ case WM_ACTIVATE:
+ if(!pThis->OnActivate(LOWORD(wParam), HIWORD(wParam) != 0, (HWND)lParam)) return FALSE;
+ break;
+ case WM_ACTIVATEAPP:
+ if(!pThis->OnActivateApp(LOWORD(wParam) != 0, (unsigned long)lParam)) return FALSE;
+ break;
+ case WM_SETCURSOR:
+ if(!pThis->OnSetCursor((HWND)wParam, LOWORD(lParam), HIWORD(lParam))) return FALSE;
+ break;
+ case WM_DRAWITEM:
+ if(pThis->OnDrawItem((unsigned int)wParam, (LPDRAWITEMSTRUCT)lParam)) return TRUE;
+ break;
+ case WM_COPY:
+ pThis->OnCopy();
+ return TRUE;
+ break;
+ case WM_NCCALCSIZE:
+ if(!pThis->OnNcCalcSize(wParam, lParam)) return FALSE;
+ break;
+ case WM_NCPAINT:
+ if(!pThis->OnNcPaint(wParam)) return FALSE;
+ break;
+ case WM_GETDLGCODE:
+ return pThis->OnGetDlgCode(wParam, lParam);
+ break;
+ case WM_THEMECHANGED:
+ if(!pThis->OnThemeChanged()) return FALSE;
+ break;
+ }
+ if(!pThis->OnWndProc(uiMsg, wParam, lParam)) return FALSE;
+ if(!pThis->m_noCallDef)
+ {
+ return DefWindowProc(hWnd, uiMsg, wParam, lParam);
+ }
+ return TRUE;
+}
+
+LRESULT WINAPI CWindow::SubClassWndProc(HWND hWnd, unsigned int uiMsg, WPARAM wParam, LPARAM lParam)
+{
+ CWindow* pThis = GetClassPtr(hWnd);
+ if(pThis != NULL)
+ {
+ return pThis->OnWndProc(uiMsg, wParam, lParam);
+ }
+ //Probably isn't good if we get here...
+ return DefWindowProc(hWnd, uiMsg, wParam, lParam);
+}
+
+long CWindow::OnWndProc(unsigned int uiMsg, WPARAM wParam, LPARAM lParam)
+{
+ return TRUE;
+}
+
+long CWindow::OnClose()
+{
+ return TRUE;
+}
+
+long CWindow::OnCommand(unsigned short nID, unsigned short nMsg, HWND hWnd)
+{
+ return TRUE;
+}
+
+long CWindow::OnSysCommand(unsigned int nCmd, LPARAM lParam)
+{
+ return TRUE;
+}
+
+long CWindow::OnNotify(WPARAM wParam, NMHDR* pHDR)
+{
+ return FALSE;
+}
+
+long CWindow::OnSize(unsigned int nType, unsigned int nWidth, unsigned int nHeight)
+{
+ return TRUE;
+}
+
+long CWindow::OnMouseLeave()
+{
+ return TRUE;
+}
+
+long CWindow::OnMouseMove(WPARAM nButton, int nX, int nY)
+{
+ return TRUE;
+}
+
+long CWindow::OnLeftButtonDown(int nX, int nY)
+{
+ return TRUE;
+}
+
+long CWindow::OnLeftButtonUp(int nX, int nY)
+{
+ return TRUE;
+}
+
+long CWindow::OnLeftButtonDblClk(int nX, int nY)
+{
+ return TRUE;
+}
+
+long CWindow::OnRightButtonDown(int nX, int nY)
+{
+ return TRUE;
+}
+
+long CWindow::OnRightButtonUp(int nX, int nY)
+{
+ return TRUE;
+}
+
+long CWindow::OnMouseWheel(int x, int y, short z)
+{
+ return TRUE;
+}
+
+long CWindow::OnDestroy()
+{
+ return TRUE;
+}
+
+long CWindow::OnPaint()
+{
+ return TRUE;
+}
+
+long CWindow::OnTimer(WPARAM)
+{
+ return TRUE;
+}
+
+long CWindow::OnEraseBkgnd()
+{
+ return FALSE;
+}
+
+long CWindow::OnVScroll(unsigned int nType, unsigned int nTrackPos)
+{
+ return TRUE;
+}
+
+long CWindow::OnHScroll(unsigned int nType, unsigned int nTrackPos)
+{
+ return TRUE;
+}
+
+long CWindow::OnSysKeyDown(unsigned int nKey)
+{
+ return TRUE;
+}
+
+long CWindow::OnKeyDown(WPARAM, LPARAM)
+{
+ return TRUE;
+}
+
+long CWindow::OnKeyUp(WPARAM, LPARAM)
+{
+ return TRUE;
+}
+
+long CWindow::OnKillFocus()
+{
+ return TRUE;
+}
+
+long CWindow::OnSetFocus()
+{
+ return TRUE;
+}
+
+long CWindow::OnCtlColorStatic(HDC hDC, HWND hWnd)
+{
+ return FALSE;
+}
+
+long CWindow::OnActivate(unsigned int nType, bool bMinimized, HWND hWnd)
+{
+ return TRUE;
+}
+
+long CWindow::OnActivateApp(bool nActive, DWORD nThreadId)
+{
+ return TRUE;
+}
+
+long CWindow::OnSetCursor(HWND hWndFrom, unsigned int nHitTest, unsigned int nMsgId)
+{
+ return TRUE;
+}
+
+long CWindow::OnDrawItem(unsigned int nId, LPDRAWITEMSTRUCT pDrawItem)
+{
+ return FALSE;
+}
+
+long CWindow::OnCopy()
+{
+ return TRUE;
+}
+
+long CWindow::OnNcCalcSize(WPARAM, LPARAM)
+{
+ return TRUE;
+}
+
+long CWindow::OnNcPaint(WPARAM)
+{
+ return TRUE;
+}
+
+long CWindow::OnGetDlgCode(WPARAM wParam, LPARAM lParam)
+{
+ return static_cast(DefWindowProc(m_hWnd, WM_GETDLGCODE, wParam, lParam));
+}
+
+long CWindow::OnThemeChanged()
+{
+ return TRUE;
+}
Index: suserver_0.06/src/win32/ComStreamAdapter.cpp
===================================================================
--- suserver_0.06/src/win32/ComStreamAdapter.cpp (nonexistent)
+++ suserver_0.06/src/win32/ComStreamAdapter.cpp (revision 450)
@@ -0,0 +1,121 @@
+#include "win32/ComStreamAdapter.h"
+
+using namespace Framework;
+using namespace Framework::Win32;
+
+CComStreamAdapter::CComStreamAdapter(CStream& stream)
+: m_stream(stream)
+{
+
+}
+
+CComStreamAdapter::~CComStreamAdapter()
+{
+
+}
+
+STDMETHODIMP_(ULONG) CComStreamAdapter::AddRef()
+{
+ InterlockedIncrement(&m_refCount);
+ return m_refCount;
+}
+
+STDMETHODIMP_(ULONG) CComStreamAdapter::Release()
+{
+ InterlockedDecrement(&m_refCount);
+ if(m_refCount == 0)
+ {
+ delete this;
+ return 0;
+ }
+ else
+ {
+ return m_refCount;
+ }
+}
+
+STDMETHODIMP CComStreamAdapter::QueryInterface(const IID& iid, void** intrf)
+{
+ (*intrf) = NULL;
+ if(iid == IID_IUnknown)
+ {
+ (*intrf) = static_cast(this);
+ }
+
+ if(*intrf)
+ {
+ reinterpret_cast(*intrf)->AddRef();
+ return S_OK;
+ }
+ else
+ {
+ return E_NOINTERFACE;
+ }
+}
+
+//ISequentialStream
+STDMETHODIMP CComStreamAdapter::Read(void* data, ULONG length, ULONG* lengthRead)
+{
+ auto result = m_stream.Read(data, length);
+ if(lengthRead)
+ {
+ (*lengthRead) = result;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CComStreamAdapter::Write(const void* data, ULONG length, ULONG* lengthWritten)
+{
+ auto result = m_stream.Write(data, length);
+ if(lengthWritten)
+ {
+ (*lengthWritten) = result;
+ }
+ return S_OK;
+}
+
+//IStream
+STDMETHODIMP CComStreamAdapter::Seek(LARGE_INTEGER, DWORD, ULARGE_INTEGER*)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CComStreamAdapter::SetSize(ULARGE_INTEGER)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CComStreamAdapter::CopyTo(IStream*, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CComStreamAdapter::Commit(DWORD)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CComStreamAdapter::Revert()
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CComStreamAdapter::LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CComStreamAdapter::UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CComStreamAdapter::Stat(STATSTG*, DWORD)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CComStreamAdapter::Clone(IStream**)
+{
+ return E_NOTIMPL;
+}
Index: suserver_0.06/src/win32/ListView.cpp
===================================================================
--- suserver_0.06/src/win32/ListView.cpp (nonexistent)
+++ suserver_0.06/src/win32/ListView.cpp (revision 450)
@@ -0,0 +1,171 @@
+#include "win32/ListView.h"
+
+using namespace Framework::Win32;
+
+CListView::CListView(HWND hWnd)
+{
+ m_hWnd = hWnd;
+}
+
+CListView::CListView(HWND hParent, const RECT& rect, unsigned long nStyle, unsigned long nExStyle)
+{
+ InitCommonControls();
+ Create(nExStyle, WC_LISTVIEW, _T(""), WS_CHILD | WS_VISIBLE | nStyle, rect, hParent, NULL);
+}
+
+CListView::~CListView()
+{
+
+}
+
+CListView& CListView::operator =(CListView&& rhs)
+{
+ CWindow::Reset();
+ CWindow::MoveFrom(std::move(rhs));
+ return (*this);
+}
+
+int CListView::GetItemCount()
+{
+ return ListView_GetItemCount(m_hWnd);
+}
+
+int CListView::FindItemData(unsigned long nData)
+{
+ LVFINDINFO info;
+ memset(&info, 0, sizeof(LVFINDINFO));
+
+ info.flags = LVFI_PARAM;
+ info.lParam = nData;
+
+ return ListView_FindItem(m_hWnd, -1, &info);
+}
+
+void CListView::DeleteItem(unsigned int itemIdx)
+{
+ ListView_DeleteItem(m_hWnd, itemIdx);
+}
+
+bool CListView::DeleteColumn(unsigned int itemIdx)
+{
+ return ListView_DeleteColumn(m_hWnd, itemIdx) != FALSE;
+}
+
+void CListView::DeleteAllItems()
+{
+ ListView_DeleteAllItems(m_hWnd);
+}
+
+int CListView::InsertItem(const LVITEM& item)
+{
+ return ListView_InsertItem(m_hWnd, &item);
+}
+
+void CListView::SetColumnWidth(unsigned int nCol, unsigned int nCX)
+{
+ ListView_SetColumnWidth(m_hWnd, nCol, nCX);
+}
+
+void CListView::InsertColumn(unsigned int index, const LVCOLUMN& column)
+{
+ ListView_InsertColumn(m_hWnd, index, &column);
+}
+
+std::tstring CListView::GetItemText(unsigned int itemIndex, unsigned int subItemIndex)
+{
+ int size = 0x100;
+ std::tstring result;
+ while(1)
+ {
+ result.resize(size);
+ LV_ITEM item = {};
+ item.cchTextMax = result.size();
+ item.pszText = const_cast(result.data());
+ item.iSubItem = subItemIndex;
+ int n = SendMessage(m_hWnd, LVM_GETITEMTEXT, itemIndex, reinterpret_cast(&item));
+ if((n + 1) != size)
+ {
+ result.resize(n);
+ return result;
+ }
+ size *= 2;
+ }
+}
+
+unsigned long CListView::GetItemData(unsigned int nItem)
+{
+ LVITEM it;
+ memset(&it, 0, sizeof(LVITEM));
+ it.iItem = nItem;
+ it.mask = LVIF_PARAM;
+
+ ListView_GetItem(m_hWnd, &it);
+
+ return (unsigned long)it.lParam;
+}
+
+void CListView::SetItemText(unsigned int nItem, unsigned int nSubItem, const TCHAR* sText)
+{
+ ListView_SetItemText(m_hWnd, nItem, nSubItem, const_cast(sText));
+}
+
+void CListView::SetItemState(unsigned int itemIdx, unsigned int state, unsigned int mask)
+{
+ ListView_SetItemState(m_hWnd, itemIdx, state, mask);
+}
+
+int CListView::GetSelection()
+{
+ return ListView_GetSelectionMark(m_hWnd);
+}
+
+void CListView::SetSelection(int nIndex)
+{
+ ListView_SetSelectionMark(m_hWnd, nIndex);
+}
+
+void CListView::EnableGroupView(bool enabled)
+{
+ ListView_EnableGroupView(m_hWnd, enabled);
+}
+
+int CListView::InsertGroup(const TCHAR* name, unsigned int id, unsigned int index)
+{
+ LVGROUP group;
+ memset(&group, 0, sizeof(group));
+ group.cbSize = sizeof(LVGROUP);
+ group.mask = LVGF_HEADER | LVGF_GROUPID;
+ group.pszHeader = const_cast(name);
+ group.iGroupId = id;
+ return ListView_InsertGroup(m_hWnd, index, &group);
+}
+
+void CListView::RemoveAllGroups()
+{
+ ListView_RemoveAllGroups(m_hWnd);
+}
+
+void CListView::SetExtendedListViewStyle(unsigned long nStyle)
+{
+ ListView_SetExtendedListViewStyle(m_hWnd, nStyle);
+}
+
+unsigned long CListView::GetExtendedListViewStyle()
+{
+ return ListView_GetExtendedListViewStyle(m_hWnd);
+}
+
+void CListView::SetItemCount(int nCount)
+{
+ ListView_SetItemCount(m_hWnd, nCount);
+}
+
+void CListView::EnsureItemVisible(unsigned int nItem, bool nPartialOk)
+{
+ ListView_EnsureVisible(m_hWnd, nItem, nPartialOk);
+}
+
+HWND CListView::GetHeader()
+{
+ return ListView_GetHeader(m_hWnd);
+}
Index: suserver_0.06/src/win32/Dialog.cpp
===================================================================
--- suserver_0.06/src/win32/Dialog.cpp (nonexistent)
+++ suserver_0.06/src/win32/Dialog.cpp (revision 450)
@@ -0,0 +1,272 @@
+#include
+#include "win32/Dialog.h"
+#include "win32/DefaultFonts.h"
+#include "PtrStream.h"
+#include "MemStream.h"
+
+using namespace Framework;
+using namespace Framework::Win32;
+
+CDialog::CDialog(const TCHAR* resourceName, HWND parentWnd)
+: m_isModal(false)
+{
+ DIALOGTEMPLATE dialogTemplate;
+
+ {
+ HRSRC resourceSrc = FindResource(GetModuleHandle(NULL), resourceName, RT_DIALOG);
+ DWORD resourceSize = SizeofResource(GetModuleHandle(NULL), resourceSrc);
+ HGLOBAL resourceHandle = LoadResource(GetModuleHandle(NULL), resourceSrc);
+
+ DLGTEMPLATE* dialogTemplateSrc = reinterpret_cast(LockResource(resourceHandle));
+ Framework::CPtrStream dialogTemplateStream(dialogTemplateSrc, resourceSize);
+ dialogTemplate = ReadDialogTemplate(dialogTemplateStream);
+ UnlockResource(resourceHandle);
+ }
+
+ NONCLIENTMETRICS metrics;
+ CDefaultFonts::GetNonClientMetrics(metrics);
+ dialogTemplate.pointsize = -MulDiv(metrics.lfMessageFont.lfHeight, 72, GetDeviceCaps(GetDC(NULL), LOGPIXELSY));
+ dialogTemplate.weight = static_cast(metrics.lfMessageFont.lfWeight);
+ dialogTemplate.italic = metrics.lfMessageFont.lfItalic;
+ dialogTemplate.charset = metrics.lfMessageFont.lfCharSet;
+ dialogTemplate.typeface = metrics.lfMessageFont.lfFaceName;
+
+ {
+ Framework::CMemStream dialogTemplateStream;
+ WriteDialogTemplate(dialogTemplate, dialogTemplateStream);
+
+ m_hWnd = CreateDialogIndirect(GetModuleHandle(NULL),
+ reinterpret_cast(dialogTemplateStream.GetBuffer()), parentWnd, &CDialog::DialogProc);
+ }
+}
+
+CDialog::~CDialog()
+{
+
+}
+
+void CDialog::DoModal()
+{
+ m_isModal = true;
+ HWND parentWnd = GetParent();
+ EnableWindow(parentWnd, FALSE);
+ Center(parentWnd);
+ Show(SW_SHOW);
+
+ while(IsWindow())
+ {
+ MSG m;
+ GetMessage(&m, NULL, NULL, NULL);
+ if(!IsDialogMessage(m_hWnd, &m))
+ {
+ TranslateMessage(&m);