Add wx headers and ext

This commit is contained in:
Joey Yakimowich-Payne 2023-02-06 09:04:33 -07:00
commit 66d3c7b811
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
1531 changed files with 295895 additions and 0 deletions

View file

@ -0,0 +1,76 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/button.h
// Purpose: helper functions used with native BUTTON control
// Author: Vadim Zeitlin
// Created: 2008-06-07
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_BUTTON_H_
#define _WX_MSW_PRIVATE_BUTTON_H_
// define some standard button constants which may be missing in the headers
#ifndef BS_PUSHLIKE
#define BS_PUSHLIKE 0x00001000L
#endif
#ifndef BST_UNCHECKED
#define BST_UNCHECKED 0x0000
#endif
#ifndef BST_CHECKED
#define BST_CHECKED 0x0001
#endif
#ifndef BST_INDETERMINATE
#define BST_INDETERMINATE 0x0002
#endif
namespace wxMSWButton
{
// returns BS_MULTILINE if the label contains new lines or 0 otherwise
inline int GetMultilineStyle(const wxString& label)
{
return label.find(wxT('\n')) == wxString::npos ? 0 : BS_MULTILINE;
}
// update the style of the specified HWND to include or exclude BS_MULTILINE
// depending on whether the label contains the new lines
void UpdateMultilineStyle(HWND hwnd, const wxString& label);
// flags for ComputeBestSize() and GetFittingSize()
enum
{
Size_AuthNeeded = 1,
Size_ExactFit = 2
};
// NB: All the functions below are implemented in src/msw/button.cpp
// Compute the button size (as if wxBU_EXACTFIT were specified, i.e. without
// adjusting it to be of default size if it's smaller) for the given label size
WXDLLIMPEXP_CORE wxSize
GetFittingSize(wxWindow *win, const wxSize& sizeLabel, int flags = 0);
// Compute the button size (as if wxBU_EXACTFIT were specified) by computing
// its label size and then calling GetFittingSize().
wxSize ComputeBestFittingSize(wxControl *btn, int flags = 0);
// Increase the size passed as parameter to be at least the standard button
// size if the control doesn't have wxBU_EXACTFIT style and also cache it as
// the best size and return its value -- this is used in DoGetBestSize()
// implementation.
wxSize IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size);
// helper of wxToggleButton::DoGetBestSize()
inline wxSize ComputeBestSize(wxControl *btn, int flags = 0)
{
return IncreaseToStdSizeAndCache(btn, ComputeBestFittingSize(btn, flags));
}
} // namespace wxMSWButton
#endif // _WX_MSW_PRIVATE_BUTTON_H_

View file

@ -0,0 +1,134 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/comptr.h
// Purpose: Smart pointer for COM interfaces.
// Author: PB
// Created: 2012-04-16
// Copyright: (c) 2012 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_COMPTR_H_
#define _WX_MSW_PRIVATE_COMPTR_H_
// ----------------------------------------------------------------------------
// wxCOMPtr: A minimalistic smart pointer for use with COM interfaces.
// ----------------------------------------------------------------------------
template <class T>
class wxCOMPtr
{
public:
typedef T element_type;
wxCOMPtr()
: m_ptr(NULL)
{
}
explicit wxCOMPtr(T* ptr)
: m_ptr(ptr)
{
if ( m_ptr )
m_ptr->AddRef();
}
wxCOMPtr(const wxCOMPtr& ptr)
: m_ptr(ptr.get())
{
if ( m_ptr )
m_ptr->AddRef();
}
~wxCOMPtr()
{
if ( m_ptr )
m_ptr->Release();
}
void reset(T* ptr = NULL)
{
if ( m_ptr != ptr)
{
if ( ptr )
ptr->AddRef();
if ( m_ptr )
m_ptr->Release();
m_ptr = ptr;
}
}
wxCOMPtr& operator=(const wxCOMPtr& ptr)
{
reset(ptr.get());
return *this;
}
wxCOMPtr& operator=(T* ptr)
{
reset(ptr);
return *this;
}
operator T*() const
{
return m_ptr;
}
T& operator*() const
{
return *m_ptr;
}
T* operator->() const
{
return m_ptr;
}
// It would be better to forbid direct access completely but we do need
// for QueryInterface() and similar functions, so provide it but it can
// only be used to initialize the pointer, not to modify an existing one.
T** operator&()
{
wxASSERT_MSG(!m_ptr,
wxS("Can't get direct access to initialized pointer"));
return &m_ptr;
}
T* get() const
{
return m_ptr;
}
T* Get() const
{
return m_ptr;
}
bool operator<(T* ptr) const
{
return get() < ptr;
}
private:
T* m_ptr;
};
// Define a helper for the macro below: we just need a function taking a
// pointer and not returning anything to avoid warnings about unused return
// value of the cast in the macro itself.
namespace wxPrivate { inline void PPV_ARGS_CHECK(void*) { } }
// Takes the interface name and a pointer to a pointer of the interface type
// and expands into the IID of this interface and the same pointer but after a
// type-safety check.
//
// This is similar to the standard IID_PPV_ARGS macro but takes the pointer
// type instead of relying on the non-standard Microsoft __uuidof().
#define wxIID_PPV_ARGS(IType, pType) \
IID_##IType, \
(wxPrivate::PPV_ARGS_CHECK(static_cast<IType*>(*pType)), \
reinterpret_cast<void**>(pType))
#endif // _WX_MSW_PRIVATE_COMPTR_H_

View file

@ -0,0 +1,85 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/cotaskmemptr.h
// Purpose: RAII class for pointers to be freed with ::CoTaskMemFree().
// Author: PB
// Created: 2020-06-09
// Copyright: (c) 2020 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_COTASKMEMPTR_H_
#define _WX_MSW_PRIVATE_COTASKMEMPTR_H_
// needed for ::CoTaskMem{Alloc|Free}()
#include "wx/msw/wrapwin.h"
// ----------------------------------------------------------------------------
// wxCoTaskMemPtr: A barebone RAII class for pointers to be freed with ::CoTaskMemFree().
// ----------------------------------------------------------------------------
template <class T>
class wxCoTaskMemPtr
{
public:
typedef T element_type;
wxCoTaskMemPtr()
: m_ptr(NULL)
{}
explicit wxCoTaskMemPtr(T* ptr)
: m_ptr(ptr)
{}
// Uses ::CoTaskMemAlloc() to allocate size bytes.
explicit wxCoTaskMemPtr(size_t size)
: m_ptr(static_cast<T*>(::CoTaskMemAlloc(size)))
{}
~wxCoTaskMemPtr()
{
::CoTaskMemFree(m_ptr);
}
void reset(T* ptr = NULL)
{
if ( m_ptr != ptr )
{
::CoTaskMemFree(m_ptr);
m_ptr = ptr;
}
}
operator T*() const
{
return m_ptr;
}
// It would be better to forbid direct access completely but we do need it,
// so provide it but it can only be used to initialize the pointer,
// not to modify an existing one.
T** operator&()
{
wxASSERT_MSG(!m_ptr,
wxS("Can't get direct access to initialized pointer"));
return &m_ptr;
}
// Gives up the ownership of the pointer,
// making the caller responsible for freeing it.
T* release()
{
T* ptr(m_ptr);
m_ptr = NULL;
return ptr;
}
private:
T* m_ptr;
wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCoTaskMemPtr, T);
};
#endif // _WX_MSW_PRIVATE_COTASKMEMPTR_H_

View file

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/customdraw.h
// Purpose: Helper for implementing custom drawing support in wxMSW
// Author: Vadim Zeitlin
// Created: 2016-04-16
// Copyright: (c) 2016 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_CUSTOMDRAW_H_
#define _WX_MSW_CUSTOMDRAW_H_
#include "wx/itemattr.h"
#include "wx/msw/wrapcctl.h"
namespace wxMSWImpl
{
// ----------------------------------------------------------------------------
// CustomDraw: inherit from this class and forward NM_CUSTOMDRAW to it
// ----------------------------------------------------------------------------
class CustomDraw
{
public:
// Trivial default ctor needed for non-copyable class.
CustomDraw()
{
}
// Virtual dtor for the base class.
virtual ~CustomDraw()
{
}
// Implementation of NM_CUSTOMDRAW handler, returns one of CDRF_XXX
// constants, possibly CDRF_DODEFAULT if custom drawing is not necessary.
LPARAM HandleCustomDraw(LPARAM lParam);
private:
// Return true if we need custom drawing at all.
virtual bool HasCustomDrawnItems() const = 0;
// Return the attribute to use for the given item, can return NULL if this
// item doesn't need to be custom-drawn.
virtual const wxItemAttr* GetItemAttr(DWORD_PTR dwItemSpec) const = 0;
// Set the colours and font for the specified HDC, return CDRF_NEWFONT if
// the font was changed.
LPARAM HandleItemPrepaint(const wxItemAttr& attr, HDC hdc);
wxDECLARE_NO_COPY_CLASS(CustomDraw);
};
} // namespace wxMSWImpl
#endif // _WX_MSW_CUSTOMDRAW_H_

View file

@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/datecontrols.h
// Purpose: implementation helpers for wxDatePickerCtrl and wxCalendarCtrl
// Author: Vadim Zeitlin
// Created: 2008-04-04
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSW_PRIVATE_DATECONTROLS_H_
#define _MSW_PRIVATE_DATECONTROLS_H_
#include "wx/datetime.h"
#include "wx/msw/wrapwin.h"
// namespace for the helper functions related to the date controls
namespace wxMSWDateControls
{
// do the one time only initialization of date classes of comctl32.dll, return
// true if ok or log an error and return false if we failed (this can only
// happen with a very old version of common controls DLL, i.e. before 4.70)
extern bool CheckInitialization();
} // namespace wxMSWDateControls
#endif // _MSW_PRIVATE_DATECONTROLS_H_

View file

@ -0,0 +1,147 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/dc.h
// Purpose: private wxMSW helpers for working with HDCs
// Author: Vadim Zeitlin
// Created: 2009-06-16 (extracted from src/msw/dc.cpp)
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _MSW_PRIVATE_DC_H_
#define _MSW_PRIVATE_DC_H_
#include "wx/msw/dc.h"
#include "wx/msw/wrapwin.h"
namespace wxMSWImpl
{
// various classes to change some DC property temporarily
// text background and foreground colours
class wxTextColoursChanger
{
public:
wxTextColoursChanger(HDC hdc, const wxMSWDCImpl& dc)
: m_hdc(hdc)
{
Change(dc.GetTextForeground(), dc.GetTextBackground());
}
wxTextColoursChanger(HDC hdc, const wxColour& colFg, const wxColour& colBg)
: m_hdc(hdc)
{
Change(colFg, colBg);
}
wxTextColoursChanger(HDC hdc, COLORREF colFg, COLORREF colBg)
: m_hdc(hdc)
{
Change(colFg, colBg);
}
~wxTextColoursChanger()
{
if ( m_oldColFg != CLR_INVALID )
::SetTextColor(m_hdc, m_oldColFg);
if ( m_oldColBg != CLR_INVALID )
::SetBkColor(m_hdc, m_oldColBg);
}
protected:
// this ctor doesn't change mode immediately, call Change() later to do it
// only if needed
wxTextColoursChanger(HDC hdc)
: m_hdc(hdc)
{
m_oldColFg =
m_oldColBg = CLR_INVALID;
}
void Change(const wxColour& colFg, const wxColour& colBg)
{
Change(colFg.IsOk() ? colFg.GetPixel() : CLR_INVALID,
colBg.IsOk() ? colBg.GetPixel() : CLR_INVALID);
}
void Change(COLORREF colFg, COLORREF colBg)
{
if ( colFg != CLR_INVALID )
{
m_oldColFg = ::SetTextColor(m_hdc, colFg);
if ( m_oldColFg == CLR_INVALID )
{
wxLogLastError(wxT("SetTextColor"));
}
}
else
{
m_oldColFg = CLR_INVALID;
}
if ( colBg != CLR_INVALID )
{
m_oldColBg = ::SetBkColor(m_hdc, colBg);
if ( m_oldColBg == CLR_INVALID )
{
wxLogLastError(wxT("SetBkColor"));
}
}
else
{
m_oldColBg = CLR_INVALID;
}
}
private:
const HDC m_hdc;
COLORREF m_oldColFg,
m_oldColBg;
wxDECLARE_NO_COPY_CLASS(wxTextColoursChanger);
};
// background mode
class wxBkModeChanger
{
public:
// set background mode to opaque if mode != wxBRUSHSTYLE_TRANSPARENT
wxBkModeChanger(HDC hdc, int mode)
: m_hdc(hdc)
{
Change(mode);
}
~wxBkModeChanger()
{
if ( m_oldMode )
::SetBkMode(m_hdc, m_oldMode);
}
protected:
// this ctor doesn't change mode immediately, call Change() later to do it
// only if needed
wxBkModeChanger(HDC hdc) : m_hdc(hdc) { m_oldMode = 0; }
void Change(int mode)
{
m_oldMode = ::SetBkMode(m_hdc, mode == wxBRUSHSTYLE_TRANSPARENT
? TRANSPARENT
: OPAQUE);
if ( !m_oldMode )
{
wxLogLastError(wxT("SetBkMode"));
}
}
private:
const HDC m_hdc;
int m_oldMode;
wxDECLARE_NO_COPY_CLASS(wxBkModeChanger);
};
} // namespace wxMSWImpl
#endif // _MSW_PRIVATE_DC_H_

View file

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/dcdynwrap.h
// Purpose: Private dynamically loaded HDC-related functions
// Author: Vadim Zeitlin
// Created: 2016-05-26 (extracted from src/msw/dc.cpp)
// Copyright: (c) 2016 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_DCDYNWRAP_H_
#define _WX_MSW_PRIVATE_DCDYNWRAP_H_
#include "wx/msw/wrapwin.h"
// Namespace for the wrapper functions, hopefully one day we'll be able to get
// rid of all of them and then it will be easy to find all occurrences of their
// use by just searching for this namespace name.
//
// All of the functions in this namespace must work *exactly* like the standard
// functions with the same name and just return an error if dynamically loading
// them failed.
//
// And they're all implemented in src/msw/dc.cpp.
namespace wxDynLoadWrappers
{
DWORD GetLayout(HDC hdc);
DWORD SetLayout(HDC hdc, DWORD dwLayout);
BOOL AlphaBlend(HDC hdcDest, int xDest, int yDest, int wDest, int hDest,
HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc,
BLENDFUNCTION bf);
BOOL GradientFill(HDC hdc, PTRIVERTEX pVert, ULONG numVert,
PVOID pMesh, ULONG numMesh, ULONG mode);
} // namespace wxDynLoadWrappers
#endif // _WX_MSW_PRIVATE_DCDYNWRAP_H_

View file

@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/dpiaware.h
// Purpose: AutoSystemDpiAware class
// Author: Maarten Bent
// Created: 2016-10-06
// Copyright: (c) Maarten Bent
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_DPI_AWARE_H_
#define _WX_MSW_DPI_AWARE_H_
#ifndef WX_PRECOMP
#include "wx/msw/missing.h"
#endif
#include "wx/dynlib.h"
#if wxUSE_DYNLIB_CLASS
namespace wxMSWImpl
{
// ----------------------------------------------------------------------------
// Temporarily change the DPI Awareness context to GDIScaled or System
// ----------------------------------------------------------------------------
class AutoSystemDpiAware
{
#define WXDPI_AWARENESS_CONTEXT_UNAWARE ((WXDPI_AWARENESS_CONTEXT)-1)
#define WXDPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((WXDPI_AWARENESS_CONTEXT)-2)
#define WXDPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((WXDPI_AWARENESS_CONTEXT)-5)
typedef WXDPI_AWARENESS_CONTEXT
(WINAPI *SetThreadDpiAwarenessContext_t)(WXDPI_AWARENESS_CONTEXT);
public:
AutoSystemDpiAware()
: m_prevContext(WXDPI_AWARENESS_CONTEXT_UNAWARE)
{
if ( ms_pfnSetThreadDpiAwarenessContext == (SetThreadDpiAwarenessContext_t)-1)
{
wxLoadedDLL dllUser32("user32.dll");
wxDL_INIT_FUNC(ms_pfn, SetThreadDpiAwarenessContext, dllUser32);
}
if ( ms_pfnSetThreadDpiAwarenessContext )
{
m_prevContext = ms_pfnSetThreadDpiAwarenessContext(
WXDPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED);
if ( !m_prevContext )
{
m_prevContext = ms_pfnSetThreadDpiAwarenessContext(
WXDPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
}
}
}
~AutoSystemDpiAware()
{
if ( ms_pfnSetThreadDpiAwarenessContext )
{
ms_pfnSetThreadDpiAwarenessContext(m_prevContext);
}
}
private:
WXDPI_AWARENESS_CONTEXT m_prevContext;
// This static member is defined in src/msw/window.cpp.
static SetThreadDpiAwarenessContext_t ms_pfnSetThreadDpiAwarenessContext;
};
#else // !wxUSE_DYNLIB_CLASS
// Just a stub to avoid littering the code with wxUSE_DYNLIB_CLASS checks.
class AutoSystemDpiAware { };
#endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS
} // namespace wxMSWImpl
#endif // _WX_MSW_DPI_AWARE_H_

View file

@ -0,0 +1,104 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/event.h
// Purpose: Simple Windows 'event object' wrapper.
// Author: Troelsk, Vadim Zeitlin
// Created: 2014-05-07
// Copyright: (c) 2014 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_EVENT_H_
#define _WX_MSW_PRIVATE_EVENT_H_
#include "wx/msw/private.h"
namespace wxWinAPI
{
class Event : public AutoHANDLE<0>
{
public:
enum Kind
{
ManualReset,
AutomaticReset
};
enum InitialState
{
Signaled,
Nonsignaled
};
Event()
{
}
// Wrappers around {Create,Set,Reset}Event() Windows API functions, with
// the same semantics.
bool Create(Kind kind = AutomaticReset,
InitialState initialState = Nonsignaled,
const wxChar* name = NULL);
bool Set();
bool Reset();
private:
wxDECLARE_NO_COPY_CLASS(Event);
};
} // namespace wxWinAPI
// ----------------------------------------------------------------------------
// Implementations requiring windows.h; these are to moved out-of-line if
// this class is moved to a public header, or if [parts of] msw/private.h is
// changed to not depend on windows.h being included.
// ----------------------------------------------------------------------------
inline bool
wxWinAPI::Event::Create(wxWinAPI::Event::Kind kind,
wxWinAPI::Event::InitialState initialState,
const wxChar* name)
{
wxCHECK_MSG( !IsOk(), false, wxS("Event can't be created twice") );
WXHANDLE handle = ::CreateEvent(NULL,
kind == ManualReset,
initialState == Signaled,
name);
if ( !handle )
{
wxLogLastError(wxS("CreateEvent"));
return false;
}
m_handle = handle;
return true;
}
inline bool wxWinAPI::Event::Set()
{
wxCHECK_MSG( m_handle, false, wxS("Event must be valid") );
if ( !::SetEvent(m_handle) )
{
wxLogLastError(wxS("SetEvent"));
return false;
}
return true;
}
inline bool wxWinAPI::Event::Reset()
{
wxCHECK_MSG( m_handle, false, wxS("Event must be valid") );
if ( !::ResetEvent(m_handle) )
{
wxLogLastError(wxS("ResetEvent"));
return false;
}
return true;
}
#endif // _WX_MSW_PRIVATE_EVENT_H_

View file

@ -0,0 +1,89 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/filedialog.h
// Purpose: IFileDialog-related functions
// Author: Vadim Zeitlin
// Created: 2022-05-15
// Copyright: (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_FILEDIALOG_H_
#define _WX_MSW_PRIVATE_FILEDIALOG_H_
#include "wx/msw/private.h"
#include "wx/msw/wrapshl.h"
// We want to use IFileDialog if either wxDirDialog or wxFileDialog are used.
//
// IFileOpenDialog implementation needs wxDynamicLibrary for
// run-time linking SHCreateItemFromParsingName(), available
// only under Windows Vista and newer.
// It also needs a compiler providing declarations and definitions
// of interfaces available in Windows Vista.
// And it needs OLE support to actually use these interfaces.
#if (wxUSE_DIRDLG || wxUSE_FILEDLG) && wxUSE_DYNLIB_CLASS && wxUSE_OLE && \
defined(__IFileOpenDialog_INTERFACE_DEFINED__)
#define wxUSE_IFILEOPENDIALOG 1
#else
#define wxUSE_IFILEOPENDIALOG 0
#endif
#if wxUSE_IFILEOPENDIALOG
#include "wx/msw/private/comptr.h"
namespace wxMSWImpl
{
// For historical reasons, this class is defined in src/msw/dirdlg.cpp.
class wxIFileDialog
{
public:
// Create the dialog of the specified type.
//
// CLSID must be either CLSID_FileOpenDialog or CLSID_FileSaveDialog.
//
// Use IsOk() to check if the dialog was created successfully.
explicit wxIFileDialog(const CLSID& clsid);
// If this returns false, the dialog can't be used at all.
bool IsOk() const { return m_fileDialog.Get() != NULL; }
// Set the dialog title.
void SetTitle(const wxString& title);
// Set the initial path to show in the dialog.
void SetInitialPath(const wxString& path);
// Add a shortcut.
void AddPlace(const wxString& path, FDAP fdap);
// Show the file dialog with the given parent window and options.
//
// Returns the selected path, or paths, in the provided output parameters,
// depending on whether FOS_ALLOWMULTISELECT is part of the options.
//
// The return value is wxID_OK if any paths were returned, wxID_CANCEL if the
// dialog was cancelled.
int
Show(HWND owner, int options, wxArrayString* pathsOut, wxString* pathOut);
// Behave as IFileDialog.
IFileDialog* Get() const { return m_fileDialog.Get(); }
IFileDialog* operator->() const { return m_fileDialog.Get(); }
private:
wxCOMPtr<IFileDialog> m_fileDialog;
};
// Initialize an IShellItem object with the given path.
HRESULT InitShellItemFromPath(wxCOMPtr<IShellItem>& item, const wxString& path);
// Extract the filesystem path corresponding to the given shell item.
HRESULT GetFSPathFromShellItem(const wxCOMPtr<IShellItem>& item, wxString& path);
} // namespace wxMSWImpl
#endif // wxUSE_IFILEOPENDIALOG
#endif // _WX_MSW_PRIVATE_FILEDIALOG_H_

View file

@ -0,0 +1,335 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/fswatcher.h
// Purpose: File system watcher impl classes
// Author: Bartosz Bekier
// Created: 2009-05-26
// Copyright: (c) 2009 Bartosz Bekier <bartosz.bekier@gmail.com>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef WX_MSW_PRIVATE_FSWATCHER_H_
#define WX_MSW_PRIVATE_FSWATCHER_H_
#include "wx/filename.h"
#include "wx/vector.h"
#include "wx/msw/private.h"
// ============================================================================
// wxFSWatcherEntry implementation & helper declarations
// ============================================================================
class wxFSWatcherImplMSW;
class wxFSWatchEntryMSW : public wxFSWatchInfo
{
public:
enum
{
BUFFER_SIZE = 4096 // TODO parametrize
};
wxFSWatchEntryMSW(const wxFSWatchInfo& winfo) :
wxFSWatchInfo(winfo)
{
// get handle for this path
m_handle = OpenDir(m_path);
m_overlapped = (OVERLAPPED*)calloc(1, sizeof(OVERLAPPED));
wxZeroMemory(m_buffer);
}
virtual ~wxFSWatchEntryMSW()
{
wxLogTrace(wxTRACE_FSWATCHER, "Deleting entry '%s'", m_path);
if (m_handle != INVALID_HANDLE_VALUE)
{
if (!CloseHandle(m_handle))
{
wxLogSysError(_("Unable to close the handle for '%s'"),
m_path);
}
}
free(m_overlapped);
}
bool IsOk() const
{
return m_handle != INVALID_HANDLE_VALUE;
}
HANDLE GetHandle() const
{
return m_handle;
}
void* GetBuffer()
{
return m_buffer;
}
OVERLAPPED* GetOverlapped() const
{
return m_overlapped;
}
private:
// opens dir with all flags, attributes etc. necessary to be later
// asynchronous watched with ReadDirectoryChangesW
static HANDLE OpenDir(const wxString& path)
{
HANDLE handle = CreateFile(path.t_str(),
FILE_LIST_DIRECTORY,
FILE_SHARE_READ |
FILE_SHARE_WRITE |
FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS |
FILE_FLAG_OVERLAPPED,
NULL);
if (handle == INVALID_HANDLE_VALUE)
{
wxLogSysError(_("Failed to open directory \"%s\" for monitoring."),
path);
}
return handle;
}
HANDLE m_handle; // handle to opened directory
char m_buffer[BUFFER_SIZE]; // buffer for fs events
OVERLAPPED* m_overlapped;
wxDECLARE_NO_COPY_CLASS(wxFSWatchEntryMSW);
};
// ============================================================================
// wxFSWatcherImplMSW helper classes implementations
// ============================================================================
class wxIOCPService
{
public:
wxIOCPService() :
m_iocp(INVALID_HANDLE_VALUE)
{
Init();
}
~wxIOCPService()
{
if (m_iocp != INVALID_HANDLE_VALUE)
{
if (!CloseHandle(m_iocp))
{
wxLogSysError(_("Unable to close I/O completion port handle"));
}
}
m_watches.clear();
}
// associates a wxFSWatchEntryMSW with completion port
bool Add(wxSharedPtr<wxFSWatchEntryMSW> watch)
{
wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" );
wxCHECK_MSG( watch->IsOk(), false, "Invalid watch" );
// associate with IOCP
HANDLE ret = CreateIoCompletionPort(watch->GetHandle(), m_iocp,
(ULONG_PTR)watch.get(), 0);
if (ret == NULL)
{
wxLogSysError(_("Unable to associate handle with "
"I/O completion port"));
return false;
}
else if (ret != m_iocp)
{
wxFAIL_MSG(_("Unexpectedly new I/O completion port was created"));
return false;
}
// add to watch map
wxFSWatchEntries::value_type val(watch->GetPath(), watch);
return m_watches.insert(val).second;
}
// Removes a watch we're currently using. Notice that this doesn't happen
// immediately, CompleteRemoval() must be called later when it's really
// safe to delete the watch, i.e. after completion of the IO operation
// using it.
bool ScheduleForRemoval(const wxSharedPtr<wxFSWatchEntryMSW>& watch)
{
wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" );
wxCHECK_MSG( watch->IsOk(), false, "Invalid watch" );
const wxString path = watch->GetPath();
wxFSWatchEntries::iterator it = m_watches.find(path);
wxCHECK_MSG( it != m_watches.end(), false,
"Can't remove a watch we don't use" );
// We can't just delete the watch here as we can have pending events
// for it and if we destroyed it now, we could get a dangling (or,
// worse, reused to point to another object) pointer in ReadEvents() so
// just remember that this one should be removed when CompleteRemoval()
// is called later.
m_removedWatches.push_back(watch);
m_watches.erase(it);
return true;
}
// Really remove the watch previously passed to ScheduleForRemoval().
//
// It's ok to call this for a watch that hadn't been removed before, in
// this case we'll just return false and do nothing.
bool CompleteRemoval(wxFSWatchEntryMSW* watch)
{
for ( Watches::iterator it = m_removedWatches.begin();
it != m_removedWatches.end();
++it )
{
if ( (*it).get() == watch )
{
// Removing the object from here will result in deleting the
// watch itself as it's not referenced from anywhere else now.
m_removedWatches.erase(it);
return true;
}
}
return false;
}
// post completion packet
bool PostEmptyStatus()
{
wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" );
// The special values of 0 will make GetStatus() return Status_Exit.
const int ret = PostQueuedCompletionStatus(m_iocp, 0, 0, NULL);
if (!ret)
{
wxLogSysError(_("Unable to post completion status"));
}
return ret != 0;
}
// Possible return values of GetStatus()
enum Status
{
// Status successfully retrieved into the provided arguments.
Status_OK,
// Special status indicating that we should exit retrieved.
Status_Exit,
// An error occurred because the watched directory was deleted.
Status_Deleted,
// Some other error occurred.
Status_Error
};
// Wait for completion status to arrive.
// This function can block forever in it's wait for completion status.
// Use PostEmptyStatus() to wake it up (and end the worker thread)
Status
GetStatus(DWORD* count, wxFSWatchEntryMSW** watch,
OVERLAPPED** overlapped)
{
wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, Status_Error,
"Invalid IOCP object" );
wxCHECK_MSG( count && watch && overlapped, Status_Error,
"Output parameters can't be NULL" );
const int ret = GetQueuedCompletionStatus(m_iocp, count, (ULONG_PTR *)watch,
overlapped, INFINITE);
if ( ret != 0 )
{
return *count || *watch || *overlapped ? Status_OK : Status_Exit;
}
// An error is returned if the underlying directory has been deleted,
// but this is not really an unexpected failure, so handle it
// specially.
if ( wxSysErrorCode() == ERROR_ACCESS_DENIED &&
*watch && !wxFileName::DirExists((*watch)->GetPath()) )
return Status_Deleted;
// Some other error, at least log it.
wxLogSysError(_("Unable to dequeue completion packet"));
return Status_Error;
}
protected:
bool Init()
{
m_iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
if (m_iocp == NULL)
{
wxLogSysError(_("Unable to create I/O completion port"));
}
return m_iocp != NULL;
}
HANDLE m_iocp;
// The hash containing all the wxFSWatchEntryMSW objects currently being
// watched keyed by their paths.
wxFSWatchEntries m_watches;
// Contains the watches which had been removed but are still pending.
typedef wxVector< wxSharedPtr<wxFSWatchEntryMSW> > Watches;
Watches m_removedWatches;
};
class wxIOCPThread : public wxThread
{
public:
wxIOCPThread(wxFSWatcherImplMSW* service, wxIOCPService* iocp);
// finishes this thread
bool Finish();
protected:
// structure to hold information needed to process one native event
// this is just a dummy holder, so it doesn't take ownership of its data
struct wxEventProcessingData
{
wxEventProcessingData(const FILE_NOTIFY_INFORMATION* ne,
const wxFSWatchEntryMSW* watch_) :
nativeEvent(ne), watch(watch_)
{}
const FILE_NOTIFY_INFORMATION* nativeEvent;
const wxFSWatchEntryMSW* watch;
};
virtual ExitCode Entry() wxOVERRIDE;
// wait for events to occur, read them and send to interested parties
// returns false it empty status was read, which means we would exit
// true otherwise
bool ReadEvents();
void ProcessNativeEvents(wxVector<wxEventProcessingData>& events);
void SendEvent(wxFileSystemWatcherEvent& evt);
static int Native2WatcherFlags(int flags);
static wxString FileNotifyInformationToString(
const FILE_NOTIFY_INFORMATION& e);
static wxFileName GetEventPath(const wxFSWatchEntryMSW& watch,
const FILE_NOTIFY_INFORMATION& e);
wxFSWatcherImplMSW* m_service;
wxIOCPService* m_iocp;
};
#endif /* WX_MSW_PRIVATE_FSWATCHER_H_ */

View file

@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/graphicsd2d.h
// Purpose: Allow functions from graphicsd2d.cpp to be used in other files
// Author: New Pagodi
// Created: 2017-10-31
// Copyright: (c) 2017 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef WX_MSW_PRIVATE_GRAPHICSD2D_H_
#define WX_MSW_PRIVATE_GRAPHICSD2D_H_
#if wxUSE_GRAPHICS_DIRECT2D
// Ensure no previous defines interfere with the Direct2D API headers
#undef GetHwnd
// include before wincodec.h to prevent winsock/winsock2 redefinition warnings
#include "wx/msw/wrapwin.h"
#include <d2d1.h>
#include <dwrite.h>
#include <wincodec.h>
WXDLLIMPEXP_CORE IWICImagingFactory* wxWICImagingFactory();
WXDLLIMPEXP_CORE ID2D1Factory* wxD2D1Factory();
WXDLLIMPEXP_CORE IDWriteFactory* wxDWriteFactory();
#endif // wxUSE_GRAPHICS_DIRECT2D
#endif // WX_MSW_PRIVATE_GRAPHICSD2D_H_

View file

@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/hiddenwin.h
// Purpose: Helper for creating a hidden window used by wxMSW internally.
// Author: Vadim Zeitlin
// Created: 2011-09-16
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_HIDDENWIN_H_
#define _WX_MSW_PRIVATE_HIDDENWIN_H_
#include "wx/msw/private.h"
/*
Creates a hidden window with supplied window proc registering the class for
it if necessary (i.e. the first time only). Caller is responsible for
destroying the window and unregistering the class (note that this must be
done because wxWidgets may be used as a DLL and so may be loaded/unloaded
multiple times into/from the same process so we can't rely on automatic
Windows class unregistration).
pclassname is a pointer to a caller stored classname, which must initially be
NULL. classname is the desired wndclass classname. If function successfully
registers the class, pclassname will be set to classname.
*/
extern "C" WXDLLIMPEXP_BASE HWND
wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc);
#endif // _WX_MSW_PRIVATE_HIDDENWIN_H_

View file

@ -0,0 +1,41 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/keyboard.h
// Purpose: Helper keyboard-related functions.
// Author: Vadim Zeitlin
// Created: 2010-09-09
// Copyright: (c) 2010 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_KEYBOARD_H_
#define _WX_MSW_PRIVATE_KEYBOARD_H_
#include "wx/defs.h"
namespace wxMSWKeyboard
{
// ----------------------------------------------------------------------------
// Functions for translating between MSW virtual keys codes and wx key codes
//
// These functions are currently implemented in src/msw/window.cpp.
// ----------------------------------------------------------------------------
// Translate MSW virtual key code to wx key code. lParam is used to distinguish
// between numpad and extended version of the keys, extended is assumed by
// default if lParam == 0.
//
// Returns WXK_NONE if translation couldn't be done at all (this happens e.g.
// for dead keys and in this case uc will be WXK_NONE too) or if the key
// corresponds to a non-Latin-1 character in which case uc is filled with its
// Unicode value.
WXDLLIMPEXP_CORE int VKToWX(WXWORD vk, WXLPARAM lParam = 0, wchar_t *uc = NULL);
// Translate wxKeyCode enum element (passed as int for compatibility reasons)
// to MSW virtual key code. isExtended is set to true if the key corresponds to
// a non-numpad version of a key that exists both on numpad and outside it.
WXDLLIMPEXP_CORE WXWORD WXToVK(int id, bool *isExtended = NULL);
} // namespace wxMSWKeyboard
#endif // _WX_MSW_PRIVATE_KEYBOARD_H_

View file

@ -0,0 +1,58 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/metrics.h
// Purpose: various helper functions to retrieve system metrics
// Author: Vadim Zeitlin
// Created: 2008-09-05
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_METRICS_H_
#define _WX_MSW_PRIVATE_METRICS_H_
#include "wx/msw/private.h"
namespace wxMSWImpl
{
// return NONCLIENTMETRICS as retrieved by SystemParametersInfo()
//
// currently this is not cached as the values may change when system settings
// do and we don't react to this to invalidate the cache but it could be done
// in the future
//
// MT-safety: this function is only meant to be called from the main thread
inline const NONCLIENTMETRICS GetNonClientMetrics(const wxWindow* win)
{
WinStruct<NONCLIENTMETRICS> nm;
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS),
&nm,
0,
win) )
{
#if WINVER >= 0x0600
// a new field has been added to NONCLIENTMETRICS under Vista, so
// the call to SystemParametersInfo() fails if we use the struct
// size incorporating this new value on an older system -- retry
// without it
nm.cbSize -= sizeof(int);
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS),
&nm,
0,
win) )
#endif // WINVER >= 0x0600
{
// maybe we should initialize the struct with some defaults?
wxLogLastError(wxT("SystemParametersInfo(SPI_GETNONCLIENTMETRICS)"));
}
}
return nm;
}
} // namespace wxMSWImpl
#endif // _WX_MSW_PRIVATE_METRICS_H_

View file

@ -0,0 +1,93 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/msgdlg.h
// Purpose: helper functions used with native message dialog
// Author: Rickard Westerlund
// Created: 2010-07-12
// Copyright: (c) 2010 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_MSGDLG_H_
#define _WX_MSW_PRIVATE_MSGDLG_H_
#include "wx/msw/wrapcctl.h"
#include "wx/scopedarray.h"
// Macro to help identify if task dialogs are available: we rely on
// TD_WARNING_ICON being defined in the headers for this as this symbol is used
// by the task dialogs only. Also notice that task dialogs are available for
// Unicode applications only.
#if defined(TD_WARNING_ICON) && wxUSE_UNICODE
#define wxHAS_MSW_TASKDIALOG
#endif
// Provides methods for creating a task dialog.
namespace wxMSWMessageDialog
{
#ifdef wxHAS_MSW_TASKDIALOG
class wxMSWTaskDialogConfig
{
public:
enum { MAX_BUTTONS = 4 };
wxMSWTaskDialogConfig()
: buttons(new TASKDIALOG_BUTTON[MAX_BUTTONS]),
parent(NULL),
iconId(0),
style(0),
useCustomLabels(false)
{ }
// initializes the object from a message dialog.
wxMSWTaskDialogConfig(const wxMessageDialogBase& dlg);
wxScopedArray<TASKDIALOG_BUTTON> buttons;
wxWindow *parent;
wxString caption;
wxString message;
wxString extendedMessage;
long iconId;
long style;
bool useCustomLabels;
wxString btnYesLabel;
wxString btnNoLabel;
wxString btnOKLabel;
wxString btnCancelLabel;
wxString btnHelpLabel;
// Will create a task dialog with it's parameters for it's creation
// stored in the provided TASKDIALOGCONFIG parameter.
// NOTE: The wxMSWTaskDialogConfig object needs to remain accessible
// during the subsequent call to TaskDialogIndirect().
void MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc);
// Used by MSWCommonTaskDialogInit() to add a regular button or a
// button with a custom label if used.
void AddTaskDialogButton(TASKDIALOGCONFIG &tdc,
int btnCustomId,
int btnCommonId,
const wxString& customLabel);
}; // class wxMSWTaskDialogConfig
typedef HRESULT (WINAPI *TaskDialogIndirect_t)(const TASKDIALOGCONFIG *,
int *, int *, BOOL *);
// Return the pointer to TaskDialogIndirect(). This should only be called
// if HasNativeTaskDialog() returned true and is normally guaranteed to
// succeed in this case.
TaskDialogIndirect_t GetTaskDialogIndirectFunc();
#endif // wxHAS_MSW_TASKDIALOG
// Check if the task dialog is available: this simply checks the OS version
// as we know that it's only present in Vista and later.
bool HasNativeTaskDialog();
// Translates standard MSW button IDs like IDCANCEL into an equivalent
// wx constant such as wxCANCEL.
int MSWTranslateReturnCode(int msAns);
}; // namespace wxMSWMessageDialog
#endif // _WX_MSW_PRIVATE_MSGDLG_H_

View file

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/paint.h
// Purpose: Helpers for handling repainting
// Author: Vadim Zeitlin
// Created: 2020-02-10
// Copyright: (c) 2020 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_PAINT_H_
#define _WX_MSW_PRIVATE_PAINT_H_
#include "wx/stack.h"
namespace wxMSWImpl
{
// Data used by WM_PAINT handler
struct PaintData
{
explicit PaintData(wxWindowMSW* window_)
: window(window_),
createdPaintDC(false)
{
}
// The window being repainted (never null).
wxWindowMSW* const window;
// True if the user-defined paint handler created wxPaintDC.
bool createdPaintDC;
};
// Stack storing data for the possibly nested WM_PAINT handlers.
extern wxStack<PaintData> paintStack;
} // namespace wxMSWImpl
#endif // _WX_MSW_PRIVATE_PAINT_H_

View file

@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/pipestream.h
// Purpose: MSW wxPipeInputStream and wxPipeOutputStream declarations
// Author: Vadim Zeitlin
// Created: 2013-06-08 (extracted from src/msw/utilsexc.cpp)
// Copyright: (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_PIPESTREAM_H_
#define _WX_MSW_PRIVATE_PIPESTREAM_H_
class wxPipeInputStream : public wxInputStream
{
public:
explicit wxPipeInputStream(HANDLE hInput);
virtual ~wxPipeInputStream();
// returns true if the pipe is still opened
bool IsOpened() const { return m_hInput != INVALID_HANDLE_VALUE; }
// returns true if there is any data to be read from the pipe
virtual bool CanRead() const wxOVERRIDE;
protected:
virtual size_t OnSysRead(void *buffer, size_t len) wxOVERRIDE;
protected:
HANDLE m_hInput;
wxDECLARE_NO_COPY_CLASS(wxPipeInputStream);
};
class wxPipeOutputStream: public wxOutputStream
{
public:
explicit wxPipeOutputStream(HANDLE hOutput);
virtual ~wxPipeOutputStream() { Close(); }
bool Close() wxOVERRIDE;
protected:
size_t OnSysWrite(const void *buffer, size_t len) wxOVERRIDE;
protected:
HANDLE m_hOutput;
wxDECLARE_NO_COPY_CLASS(wxPipeOutputStream);
};
#endif // _WX_MSW_PRIVATE_PIPESTREAM_H_

View file

@ -0,0 +1,96 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/gsockmsw.h
// Purpose: MSW-specific socket implementation
// Authors: Guilhem Lavaux, Guillermo Rodriguez Garcia, Vadim Zeitlin
// Created: April 1997
// Copyright: (C) 1999-1997, Guilhem Lavaux
// (C) 1999-2000, Guillermo Rodriguez Garcia
// (C) 2008 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_GSOCKMSW_H_
#define _WX_MSW_GSOCKMSW_H_
#include "wx/msw/wrapwin.h"
#if defined(__CYGWIN__)
//CYGWIN gives annoying warning about runtime stuff if we don't do this
# define USE_SYS_TYPES_FD_SET
# include <sys/types.h>
#endif
#if defined(__CYGWIN__)
#include <winsock.h>
#ifdef __LP64__
// We can't use long in this case because it is 64 bits with Cygwin, so
// use their special type used for working around this instead.
#define wxIoctlSocketArg_t __ms_u_long
#endif
#endif
#ifndef wxIoctlSocketArg_t
#define wxIoctlSocketArg_t u_long
#endif
#define wxCloseSocket closesocket
// ----------------------------------------------------------------------------
// MSW-specific socket implementation
// ----------------------------------------------------------------------------
class wxSocketImplMSW : public wxSocketImpl
{
public:
wxSocketImplMSW(wxSocketBase& wxsocket);
virtual ~wxSocketImplMSW();
virtual wxSocketError GetLastError() const wxOVERRIDE;
virtual void ReenableEvents(wxSocketEventFlags WXUNUSED(flags)) wxOVERRIDE
{
// notifications are never disabled in this implementation, there is no
// need for this as WSAAsyncSelect() only sends notification once when
// the new data becomes available anyhow, so there is no need to do
// anything here
}
virtual void UpdateBlockingState() wxOVERRIDE
{
if ( GetSocketFlags() & wxSOCKET_BLOCK )
{
// Counter-intuitively, we make the socket non-blocking even in
// this case as it is necessary e.g. for Read() to return
// immediately if there is no data available. However we must not
// install a callback for it as blocking sockets don't use any
// events and generating them would actually be harmful (and not
// just useless) as they would be dispatched by the main thread
// while this blocking socket can be used from a worker one, so it
// would result in data races and other unpleasantness.
wxIoctlSocketArg_t trueArg = 1;
ioctlsocket(m_fd, FIONBIO, &trueArg);
// Uninstall it in case it was installed before.
wxSocketManager::Get()->Uninstall_Callback(this);
}
else
{
// No need to make the socket non-blocking, Install_Callback() will
// do it as a side effect of calling WSAAsyncSelect().
wxSocketManager::Get()->Install_Callback(this);
}
}
private:
virtual void DoClose() wxOVERRIDE;
int m_msgnumber;
friend class wxSocketMSWManager;
wxDECLARE_NO_COPY_CLASS(wxSocketImplMSW);
};
#endif /* _WX_MSW_GSOCKMSW_H_ */

View file

@ -0,0 +1,63 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/textmeasure.h
// Purpose: wxMSW-specific declaration of wxTextMeasure class
// Author: Manuel Martin
// Created: 2012-10-05
// Copyright: (c) 1997-2012 wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_TEXTMEASURE_H_
#define _WX_MSW_PRIVATE_TEXTMEASURE_H_
#include "wx/msw/wrapwin.h"
// ----------------------------------------------------------------------------
// wxTextMeasure for MSW.
// ----------------------------------------------------------------------------
class wxTextMeasure : public wxTextMeasureBase
{
public:
explicit wxTextMeasure(const wxDC *dc, const wxFont *font = NULL)
: wxTextMeasureBase(dc, font)
{
Init();
}
explicit wxTextMeasure(const wxWindow *win, const wxFont *font = NULL)
: wxTextMeasureBase(win, font)
{
Init();
}
protected:
void Init();
virtual void BeginMeasuring() wxOVERRIDE;
virtual void EndMeasuring() wxOVERRIDE;
virtual void DoGetTextExtent(const wxString& string,
wxCoord *width,
wxCoord *height,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL) wxOVERRIDE;
virtual bool DoGetPartialTextExtents(const wxString& text,
wxArrayInt& widths,
double scaleX) wxOVERRIDE;
// We use either the HDC of the provided wxDC or an HDC created for our
// window.
HDC m_hdc;
// If we change the font in BeginMeasuring(), we restore it to the old one
// in EndMeasuring().
HFONT m_hfontOld;
wxDECLARE_NO_COPY_CLASS(wxTextMeasure);
};
#endif // _WX_MSW_PRIVATE_TEXTMEASURE_H_

View file

@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/timer.h
// Purpose: wxTimer class
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_TIMER_H_
#define _WX_MSW_PRIVATE_TIMER_H_
#if wxUSE_TIMER
#include "wx/private/timer.h"
#include "wx/msw/wrapwin.h" // for WPARAM
class WXDLLIMPEXP_BASE wxMSWTimerImpl : public wxTimerImpl
{
public:
wxMSWTimerImpl(wxTimer *timer) : wxTimerImpl(timer) { m_id = 0; }
virtual bool Start(int milliseconds = -1, bool oneShot = false) wxOVERRIDE;
virtual void Stop() wxOVERRIDE;
virtual bool IsRunning() const wxOVERRIDE { return m_id != 0; }
protected:
// this must be 64 bit under Win64 as WPARAM (storing timer ids) is 64 bit
// there and so the ids may possibly not fit in 32 bits
WPARAM m_id;
};
#endif // wxUSE_TIMER
#endif // _WX_TIMERH_

View file

@ -0,0 +1,163 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/tlwgeom.h
// Purpose: wxMSW-specific wxTLWGeometry class.
// Author: Vadim Zeitlin
// Created: 2018-04-29
// Copyright: (c) 2018 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_TLWGEOM_H_
#define _WX_MSW_PRIVATE_TLWGEOM_H_
#include "wx/log.h"
#include "wx/msw/private.h"
// names for MSW-specific options
#define wxPERSIST_TLW_MAX_X "xmax"
#define wxPERSIST_TLW_MAX_Y "ymax"
class wxTLWGeometry : public wxTLWGeometryBase
{
public:
wxTLWGeometry()
{
wxZeroMemory(m_placement);
m_placement.length = sizeof(m_placement);
}
virtual bool Save(const Serializer& ser) const wxOVERRIDE
{
// For compatibility with the existing saved positions/sizes, use the
// same keys as the generic version (which was previously used under
// MSW too).
// Normal position and size.
const RECT& rc = m_placement.rcNormalPosition;
if ( !ser.SaveField(wxPERSIST_TLW_X, rc.left) ||
!ser.SaveField(wxPERSIST_TLW_Y, rc.top) )
return false;
if ( !ser.SaveField(wxPERSIST_TLW_W, rc.right - rc.left) ||
!ser.SaveField(wxPERSIST_TLW_H, rc.bottom - rc.top) )
return false;
// Maximized/minimized state.
UINT show = m_placement.showCmd;
if ( !ser.SaveField(wxPERSIST_TLW_MAXIMIZED, show == SW_SHOWMAXIMIZED) )
return false;
if ( !ser.SaveField(wxPERSIST_TLW_ICONIZED, show == SW_SHOWMINIMIZED) )
return false;
// Maximized window position.
const POINT pt = m_placement.ptMaxPosition;
if ( !ser.SaveField(wxPERSIST_TLW_MAX_X, pt.x) ||
!ser.SaveField(wxPERSIST_TLW_MAX_Y, pt.y) )
return false;
// We don't currently save the minimized window position, it doesn't
// seem useful for anything and is probably just a left over from
// Windows 3.1 days, when icons were positioned on the desktop instead
// of being located in the taskbar.
return true;
}
virtual bool Restore(Serializer& ser) wxOVERRIDE
{
// Normal position and size.
wxRect r;
if ( !ser.RestoreField(wxPERSIST_TLW_X, &r.x) ||
!ser.RestoreField(wxPERSIST_TLW_Y, &r.y) ||
!ser.RestoreField(wxPERSIST_TLW_W, &r.width) ||
!ser.RestoreField(wxPERSIST_TLW_H, &r.height) )
return false;
wxCopyRectToRECT(r, m_placement.rcNormalPosition);
// Maximized/minimized state.
//
// Note the special case of SW_MINIMIZE: while GetWindowPlacement()
// returns SW_SHOWMINIMIZED when the window is iconized, we restore it
// as SW_MINIMIZE as this is what the code in wxTLW checks to determine
// whether the window is supposed to be iconized or not.
//
// Just to confuse matters further, note that SW_MAXIMIZE is exactly
// the same thing as SW_SHOWMAXIMIZED.
int tmp;
UINT& show = m_placement.showCmd;
if ( ser.RestoreField(wxPERSIST_TLW_MAXIMIZED, &tmp) && tmp )
show = SW_MAXIMIZE;
else if ( ser.RestoreField(wxPERSIST_TLW_ICONIZED, &tmp) && tmp )
show = SW_MINIMIZE;
else
show = SW_SHOWNORMAL;
// Maximized window position.
if ( ser.RestoreField(wxPERSIST_TLW_MAX_X, &r.x) &&
ser.RestoreField(wxPERSIST_TLW_MAX_Y, &r.y) )
{
m_placement.ptMaxPosition.x = r.x;
m_placement.ptMaxPosition.y = r.y;
}
return true;
}
virtual bool GetFrom(const wxTopLevelWindow* tlw) wxOVERRIDE
{
if ( !::GetWindowPlacement(GetHwndOf(tlw), &m_placement) )
{
wxLogLastError(wxS("GetWindowPlacement"));
return false;
}
return true;
}
virtual bool ApplyTo(wxTopLevelWindow* tlw) wxOVERRIDE
{
// There is a subtlety here: if the window is currently hidden,
// restoring its geometry shouldn't show it, so we must use SW_HIDE as
// show command, but showing it later should restore it to the correct
// state, so we need to remember it in wxTLW itself. And even if it's
// currently shown, we still need to update its show command, so that
// it matches the real window state after SetWindowPlacement() call.
tlw->MSWSetShowCommand(m_placement.showCmd);
if ( !tlw->IsShown() )
{
m_placement.showCmd = SW_HIDE;
}
const wxSize oldDPI = tlw->GetDPI();
if ( !::SetWindowPlacement(GetHwndOf(tlw), &m_placement) )
{
wxLogLastError(wxS("SetWindowPlacement"));
return false;
}
// Check if a window DPI hasn't changed, as the result of being placed
// on a monitor with a different DPI from the main one because in this
// case its size is not restored properly.
const wxSize newDPI = tlw->GetDPI();
if ( oldDPI != newDPI )
{
// So try setting the placement again as now it will use the
// correct scaling factor, because the window is already on the
// correct monitor.
if ( !::SetWindowPlacement(GetHwndOf(tlw), &m_placement) )
{
wxLogLastError(wxS("SetWindowPlacement (2nd time)"));
return false;
}
}
return true;
}
private:
WINDOWPLACEMENT m_placement;
};
#endif // _WX_MSW_PRIVATE_TLWGEOM_H_

View file

@ -0,0 +1,31 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/uilocale.h
// Purpose: MSW-specific locale-related helpers
// Author: Vadim Zeitlin
// Created: 2021-08-14
// Copyright: (c) 2021 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_UILOCALE_H_
#define _WX_MSW_PRIVATE_UILOCALE_H_
#include "wx/msw/private.h" // Include <windows.h> to get LCID.
#ifndef LOCALE_SNAME
#define LOCALE_SNAME 0x5c
#endif
#ifndef LOCALE_CUSTOM_UI_DEFAULT
#define LOCALE_CUSTOM_UI_DEFAULT 0x1400
#endif
// Use the specific LCID for the current thread.
void wxUseLCID(LCID lcid);
// These functions are defined in src/common/intl.cpp
wxString wxGetInfoFromLCID(LCID lcid, wxLocaleInfo index, wxLocaleCategory cat);
LCTYPE wxGetLCTYPEFormatFromLocalInfo(wxLocaleInfo index);
WXDLLIMPEXP_BASE wxString wxTranslateFromUnicodeFormat(const wxString& fmt);
#endif // _WX_MSW_PRIVATE_UILOCALE_H_

View file

@ -0,0 +1,178 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/webrequest_winhttp.h
// Purpose: wxWebRequest WinHTTP implementation
// Author: Tobias Taschner
// Created: 2018-10-17
// Copyright: (c) 2018 wxWidgets development team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_WEBREQUEST_WINHTTP_H
#define _WX_MSW_WEBREQUEST_WINHTTP_H
#include "wx/private/webrequest.h"
#include "wx/msw/wrapwin.h"
#include <winhttp.h>
#include "wx/buffer.h"
class wxWebSessionWinHTTP;
class wxWebRequestWinHTTP;
class wxWebResponseWinHTTP : public wxWebResponseImpl
{
public:
wxWebResponseWinHTTP(wxWebRequestWinHTTP& request);
wxFileOffset GetContentLength() const wxOVERRIDE { return m_contentLength; }
wxString GetURL() const wxOVERRIDE;
wxString GetHeader(const wxString& name) const wxOVERRIDE;
int GetStatus() const wxOVERRIDE;
wxString GetStatusText() const wxOVERRIDE;
bool ReadData();
bool ReportAvailableData(DWORD dataLen);
private:
HINTERNET m_requestHandle;
wxFileOffset m_contentLength;
wxDECLARE_NO_COPY_CLASS(wxWebResponseWinHTTP);
};
class wxWebAuthChallengeWinHTTP : public wxWebAuthChallengeImpl
{
public:
wxWebAuthChallengeWinHTTP(wxWebAuthChallenge::Source source,
wxWebRequestWinHTTP& request);
bool Init();
void SetCredentials(const wxWebCredentials& cred) wxOVERRIDE;
private:
wxWebRequestWinHTTP& m_request;
DWORD m_target;
DWORD m_selectedScheme;
wxDECLARE_NO_COPY_CLASS(wxWebAuthChallengeWinHTTP);
};
class wxWebRequestWinHTTP : public wxWebRequestImpl
{
public:
wxWebRequestWinHTTP(wxWebSession& session,
wxWebSessionWinHTTP& sessionImpl,
wxEvtHandler* handler,
const wxString& url,
int id);
~wxWebRequestWinHTTP();
void Start() wxOVERRIDE;
wxWebResponseImplPtr GetResponse() const wxOVERRIDE
{ return m_response; }
wxWebAuthChallengeImplPtr GetAuthChallenge() const wxOVERRIDE
{ return m_authChallenge; }
wxFileOffset GetBytesSent() const wxOVERRIDE { return m_dataWritten; }
wxFileOffset GetBytesExpectedToSend() const wxOVERRIDE { return m_dataSize; }
void HandleCallback(DWORD dwInternetStatus, LPVOID lpvStatusInformation,
DWORD dwStatusInformationLength);
HINTERNET GetHandle() const { return m_request; }
wxWebRequestHandle GetNativeHandle() const wxOVERRIDE
{
return (wxWebRequestHandle)GetHandle();
}
private:
void DoCancel() wxOVERRIDE;
wxWebSessionWinHTTP& m_sessionImpl;
wxString m_url;
HINTERNET m_connect;
HINTERNET m_request;
wxObjectDataPtr<wxWebResponseWinHTTP> m_response;
wxObjectDataPtr<wxWebAuthChallengeWinHTTP> m_authChallenge;
wxMemoryBuffer m_dataWriteBuffer;
wxFileOffset m_dataWritten;
void SendRequest();
void WriteData();
void CreateResponse();
// Set the state to State_Failed with the error string including the
// provided description of the operation and the error message for this
// error code.
void SetFailed(const wxString& operation, DWORD errorCode);
void SetFailedWithLastError(const wxString& operation)
{
SetFailed(operation, ::GetLastError());
}
friend class wxWebAuthChallengeWinHTTP;
wxDECLARE_NO_COPY_CLASS(wxWebRequestWinHTTP);
};
class wxWebSessionWinHTTP : public wxWebSessionImpl
{
public:
wxWebSessionWinHTTP();
~wxWebSessionWinHTTP();
static bool Initialize();
wxWebRequestImplPtr
CreateRequest(wxWebSession& session,
wxEvtHandler* handler,
const wxString& url,
int id) wxOVERRIDE;
wxVersionInfo GetLibraryVersionInfo() wxOVERRIDE;
HINTERNET GetHandle() const { return m_handle; }
wxWebSessionHandle GetNativeHandle() const wxOVERRIDE
{
return (wxWebSessionHandle)GetHandle();
}
private:
HINTERNET m_handle;
bool Open();
wxDECLARE_NO_COPY_CLASS(wxWebSessionWinHTTP);
};
class wxWebSessionFactoryWinHTTP : public wxWebSessionFactory
{
public:
wxWebSessionImpl* Create() wxOVERRIDE
{
return new wxWebSessionWinHTTP();
}
bool Initialize() wxOVERRIDE
{
return wxWebSessionWinHTTP::Initialize();
}
};
#endif // _WX_MSW_WEBREQUEST_WINHTTP_H

View file

@ -0,0 +1,115 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/msw/private/webview_edge.h
// Purpose: wxMSW Edge Chromium wxWebView backend private classes
// Author: Tobias Taschner
// Created: 2020-01-15
// Copyright: (c) 2020 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef wxWebViewEdge_PRIVATE_H
#define wxWebViewEdge_PRIVATE_H
#if !wxUSE_WEBVIEW_EDGE_STATIC
#include "wx/dynlib.h"
#endif
#include "wx/msw/private/comptr.h"
#include <WebView2.h>
#ifndef __ICoreWebView2_2_INTERFACE_DEFINED__
#error "WebView2 SDK version 1.0.705.50 or newer is required"
#endif
#ifndef __VISUALC__
__CRT_UUID_DECL(ICoreWebView2_2, 0x9E8F0CF8, 0xE670, 0x4B5E, 0xB2, 0xBC, 0x73, 0xE0, 0x61, 0xE3, 0x18, 0x4C);
__CRT_UUID_DECL(ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler, 0xb99369f3, 0x9b11, 0x47b5, 0xbc,0x6f, 0x8e,0x78,0x95,0xfc,0xea,0x17);
__CRT_UUID_DECL(ICoreWebView2ContainsFullScreenElementChangedEventHandler, 0xe45d98b1, 0xafef, 0x45be, 0x8b,0xaf, 0x6c,0x77,0x28,0x86,0x7f,0x73);
__CRT_UUID_DECL(ICoreWebView2ContentLoadingEventHandler, 0x364471e7, 0xf2be, 0x4910, 0xbd,0xba, 0xd7,0x20,0x77,0xd5,0x1c,0x4b);
__CRT_UUID_DECL(ICoreWebView2CreateCoreWebView2ControllerCompletedHandler, 0x6c4819f3, 0xc9b7, 0x4260, 0x81,0x27, 0xc9,0xf5,0xbd,0xe7,0xf6,0x8c);
__CRT_UUID_DECL(ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler, 0x4e8a3389, 0xc9d8, 0x4bd2, 0xb6,0xb5, 0x12,0x4f,0xee,0x6c,0xc1,0x4d);
__CRT_UUID_DECL(ICoreWebView2DocumentTitleChangedEventHandler, 0xf5f2b923, 0x953e, 0x4042, 0x9f,0x95, 0xf3,0xa1,0x18,0xe1,0xaf,0xd4);
__CRT_UUID_DECL(ICoreWebView2DOMContentLoadedEventHandler, 0x4BAC7E9C, 0x199E, 0x49ED, 0x87, 0xED, 0x24, 0x93, 0x03, 0xAC, 0xF0, 0x19);
__CRT_UUID_DECL(ICoreWebView2Environment, 0xb96d755e, 0x0319, 0x4e92, 0xa2,0x96, 0x23,0x43,0x6f,0x46,0xa1,0xfc);
__CRT_UUID_DECL(ICoreWebView2EnvironmentOptions, 0x2fde08a8, 0x1e9a, 0x4766, 0x8c,0x05, 0x95,0xa9,0xce,0xb9,0xd1,0xc5);
__CRT_UUID_DECL(ICoreWebView2ExecuteScriptCompletedHandler, 0x49511172, 0xcc67, 0x4bca, 0x99,0x23, 0x13,0x71,0x12,0xf4,0xc4,0xcc);
__CRT_UUID_DECL(ICoreWebView2NavigationCompletedEventHandler, 0xd33a35bf, 0x1c49, 0x4f98, 0x93,0xab, 0x00,0x6e,0x05,0x33,0xfe,0x1c);
__CRT_UUID_DECL(ICoreWebView2NavigationStartingEventHandler, 0x9adbe429, 0xf36d, 0x432b, 0x9d,0xdc, 0xf8,0x88,0x1f,0xbd,0x76,0xe3);
__CRT_UUID_DECL(ICoreWebView2NewWindowRequestedEventHandler, 0xd4c185fe, 0xc81c, 0x4989, 0x97,0xaf, 0x2d,0x3f,0xa7,0xab,0x56,0x51);
__CRT_UUID_DECL(ICoreWebView2SourceChangedEventHandler, 0x3c067f9f, 0x5388, 0x4772, 0x8b,0x48, 0x79,0xf7,0xef,0x1a,0xb3,0x7c);
__CRT_UUID_DECL(ICoreWebView2WebMessageReceivedEventHandler, 0x57213f19, 0x00e6, 0x49fa, 0x8e,0x07, 0x89,0x8e,0xa0,0x1e,0xcb,0xd2);
#endif
class wxWebViewEdgeImpl
{
public:
explicit wxWebViewEdgeImpl(wxWebViewEdge* webview);
~wxWebViewEdgeImpl();
bool Create();
wxWebViewEdge* m_ctrl;
wxCOMPtr<ICoreWebView2Environment> m_webViewEnvironment;
wxCOMPtr<ICoreWebView2_2> m_webView;
wxCOMPtr<ICoreWebView2Controller> m_webViewController;
bool m_initialized;
bool m_isBusy;
wxString m_pendingURL;
wxString m_pendingPage;
int m_pendingContextMenuEnabled;
int m_pendingAccessToDevToolsEnabled;
wxVector<wxString> m_pendingUserScripts;
wxVector<wxString> m_userScriptIds;
wxString m_scriptMsgHandlerName;
wxString m_customUserAgent;
// WebView Events tokens
EventRegistrationToken m_navigationStartingToken = { };
EventRegistrationToken m_sourceChangedToken = { };
EventRegistrationToken m_navigationCompletedToken = { };
EventRegistrationToken m_newWindowRequestedToken = { };
EventRegistrationToken m_documentTitleChangedToken = { };
EventRegistrationToken m_DOMContentLoadedToken = { };
EventRegistrationToken m_containsFullScreenElementChangedToken = { };
EventRegistrationToken m_webMessageReceivedToken = { };
// WebView Event handlers
HRESULT OnNavigationStarting(ICoreWebView2* sender, ICoreWebView2NavigationStartingEventArgs* args);
HRESULT OnSourceChanged(ICoreWebView2* sender, ICoreWebView2SourceChangedEventArgs* args);
HRESULT OnNavigationCompleted(ICoreWebView2* sender, ICoreWebView2NavigationCompletedEventArgs* args);
HRESULT OnNewWindowRequested(ICoreWebView2* sender, ICoreWebView2NewWindowRequestedEventArgs* args);
HRESULT OnDocumentTitleChanged(ICoreWebView2* sender, IUnknown* args);
HRESULT OnDOMContentLoaded(ICoreWebView2* sender, ICoreWebView2DOMContentLoadedEventArgs* args);
HRESULT OnContainsFullScreenElementChanged(ICoreWebView2* sender, IUnknown* args);
HRESULT OnWebMessageReceived(ICoreWebView2* sender, ICoreWebView2WebMessageReceivedEventArgs* args);
HRESULT OnAddScriptToExecuteOnDocumentedCreatedCompleted(HRESULT errorCode, LPCWSTR id);
HRESULT OnEnvironmentCreated(HRESULT result, ICoreWebView2Environment* environment);
HRESULT OnWebViewCreated(HRESULT result, ICoreWebView2Controller* webViewController);
wxVector<wxSharedPtr<wxWebViewHistoryItem> > m_historyList;
int m_historyPosition;
bool m_historyLoadingFromList;
bool m_historyEnabled;
void UpdateBounds();
ICoreWebView2Settings* GetSettings();
void UpdateWebMessageHandler();
#if !wxUSE_WEBVIEW_EDGE_STATIC
static wxDynamicLibrary ms_loaderDll;
#endif
static wxString ms_browserExecutableDir;
static bool Initialize();
static void Uninitialize();
friend class wxWebViewEdgeModule;
};
#endif // wxWebViewEdge_PRIVATE_H

View file

@ -0,0 +1,240 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/msw/private/webview_ie.h
// Purpose: wxMSW IE wxWebView backend private classes
// Author: Marianne Gagnon
// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef wxWebViewIE_PRIVATE_H
#define wxWebViewIE_PRIVATE_H
#include "wx/msw/ole/automtn.h"
#include "wx/msw/private/comptr.h"
#include "wx/msw/private/webview_missing.h"
class ClassFactory;
class wxIEContainer;
class DocHostUIHandler;
class wxFindPointers;
class wxWebViewIEImpl
{
public:
explicit wxWebViewIEImpl(wxWebViewIE* webview);
~wxWebViewIEImpl();
bool Create();
wxWebViewIE* m_webview;
wxIEContainer* m_container;
wxAutomationObject m_ie;
IWebBrowser2* m_webBrowser;
wxCOMPtr<DocHostUIHandler> m_uiHandler;
//We store the current zoom type;
wxWebViewZoomType m_zoomType;
/** The "Busy" property of IWebBrowser2 does not always return busy when
* we'd want it to; this variable may be set to true in cases where the
* Busy property is false but should be true.
*/
bool m_isBusy;
//We manage our own history, the history list contains the history items
//which are added as documentcomplete events arrive, unless we are loading
//an item from the history. The position is stored as an int, and reflects
//where we are in the history list.
wxVector<wxSharedPtr<wxWebViewHistoryItem> > m_historyList;
wxVector<ClassFactory*> m_factories;
int m_historyPosition;
bool m_historyLoadingFromList;
bool m_historyEnabled;
//We store find flag, results and position.
wxVector<wxFindPointers> m_findPointers;
int m_findFlags;
wxString m_findText;
int m_findPosition;
//Generic helper functions
bool CanExecCommand(wxString command) const;
void ExecCommand(wxString command);
wxCOMPtr<IHTMLDocument2> GetDocument() const;
bool IsElementVisible(wxCOMPtr<IHTMLElement> elm);
//Find helper functions.
long Find(const wxString& text, int flags = wxWEBVIEW_FIND_DEFAULT);
void FindInternal(const wxString& text, int flags, int internal_flag);
long FindNext(int direction = 1);
void FindClear();
//Toggles control features see INTERNETFEATURELIST for values.
bool EnableControlFeature(long flag, bool enable = true);
wxDECLARE_NO_COPY_CLASS(wxWebViewIEImpl);
};
class VirtualProtocol : public wxIInternetProtocol, public wxIInternetProtocolInfo
{
protected:
wxIInternetProtocolSink* m_protocolSink;
wxString m_html;
VOID * fileP;
wxFSFile* m_file;
wxSharedPtr<wxWebViewHandler> m_handler;
public:
VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
virtual ~VirtualProtocol() {}
//IUnknown
DECLARE_IUNKNOWN_METHODS;
//IInternetProtocolRoot
HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
DWORD WXUNUSED(dwOptions)) wxOVERRIDE
{ return E_NOTIMPL; }
HRESULT STDMETHODCALLTYPE Continue(wxPROTOCOLDATA *WXUNUSED(pProtocolData)) wxOVERRIDE
{ return S_OK; }
HRESULT STDMETHODCALLTYPE Resume() wxOVERRIDE { return S_OK; }
HRESULT STDMETHODCALLTYPE Start(LPCWSTR szUrl,
wxIInternetProtocolSink *pOIProtSink,
wxIInternetBindInfo *pOIBindInfo,
DWORD grfPI,
HANDLE_PTR dwReserved) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE Suspend() wxOVERRIDE { return S_OK; }
HRESULT STDMETHODCALLTYPE Terminate(DWORD WXUNUSED(dwOptions)) wxOVERRIDE { return S_OK; }
//IInternetProtocol
HRESULT STDMETHODCALLTYPE LockRequest(DWORD WXUNUSED(dwOptions)) wxOVERRIDE
{ return S_OK; }
HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER WXUNUSED(dlibMove),
DWORD WXUNUSED(dwOrigin),
ULARGE_INTEGER* WXUNUSED(plibNewPosition)) wxOVERRIDE
{ return E_FAIL; }
HRESULT STDMETHODCALLTYPE UnlockRequest() wxOVERRIDE { return S_OK; }
//IInternetProtocolInfo
HRESULT STDMETHODCALLTYPE CombineUrl(
LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl,
DWORD dwCombineFlags, LPWSTR pwzResult,
DWORD cchResult, DWORD *pcchResult,
DWORD dwReserved) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE ParseUrl(
LPCWSTR pwzUrl, wxPARSEACTION ParseAction,
DWORD dwParseFlags, LPWSTR pwzResult,
DWORD cchResult, DWORD *pcchResult,
DWORD dwReserved) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE CompareUrl(
LPCWSTR pwzUrl1,
LPCWSTR pwzUrl2,
DWORD dwCompareFlags) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE QueryInfo(
LPCWSTR pwzUrl, wxQUERYOPTION OueryOption,
DWORD dwQueryFlags, LPVOID pBuffer,
DWORD cbBuffer, DWORD *pcbBuf,
DWORD dwReserved) wxOVERRIDE;
};
class ClassFactory : public IClassFactory
{
public:
ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler)
{ AddRef(); }
virtual ~ClassFactory() {}
wxString GetName() { return m_handler->GetName(); }
//IClassFactory
HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
REFIID riid, void** ppvObject) wxOVERRIDE;
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock) wxOVERRIDE;
//IUnknown
DECLARE_IUNKNOWN_METHODS;
private:
wxSharedPtr<wxWebViewHandler> m_handler;
};
class wxIEContainer : public wxActiveXContainer
{
public:
wxIEContainer(wxWindow *parent, REFIID iid, IUnknown *pUnk, DocHostUIHandler* uiHandler = NULL);
virtual ~wxIEContainer();
virtual bool QueryClientSiteInterface(REFIID iid, void **_interface, const char *&desc) wxOVERRIDE;
private:
DocHostUIHandler* m_uiHandler;
};
class DocHostUIHandler : public wxIDocHostUIHandler
{
public:
DocHostUIHandler(wxWebView* browser) { m_browser = browser; }
virtual ~DocHostUIHandler() {}
virtual HRESULT wxSTDCALL ShowContextMenu(DWORD dwID, POINT *ppt,
IUnknown *pcmdtReserved,
IDispatch *pdispReserved) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetHostInfo(DOCHOSTUIINFO *pInfo) wxOVERRIDE;
virtual HRESULT wxSTDCALL ShowUI(DWORD dwID,
IOleInPlaceActiveObject *pActiveObject,
IOleCommandTarget *pCommandTarget,
IOleInPlaceFrame *pFrame,
IOleInPlaceUIWindow *pDoc) wxOVERRIDE;
virtual HRESULT wxSTDCALL HideUI(void) wxOVERRIDE;
virtual HRESULT wxSTDCALL UpdateUI(void) wxOVERRIDE;
virtual HRESULT wxSTDCALL EnableModeless(BOOL fEnable) wxOVERRIDE;
virtual HRESULT wxSTDCALL OnDocWindowActivate(BOOL fActivate) wxOVERRIDE;
virtual HRESULT wxSTDCALL OnFrameWindowActivate(BOOL fActivate) wxOVERRIDE;
virtual HRESULT wxSTDCALL ResizeBorder(LPCRECT prcBorder,
IOleInPlaceUIWindow *pUIWindow,
BOOL fRameWindow) wxOVERRIDE;
virtual HRESULT wxSTDCALL TranslateAccelerator(LPMSG lpMsg,
const GUID *pguidCmdGroup,
DWORD nCmdID) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetOptionKeyPath(LPOLESTR *pchKey,
DWORD dw) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetDropTarget(IDropTarget *pDropTarget,
IDropTarget **ppDropTarget) wxOVERRIDE;
virtual HRESULT wxSTDCALL GetExternal(IDispatch **ppDispatch) wxOVERRIDE;
virtual HRESULT wxSTDCALL TranslateUrl(DWORD dwTranslate,
OLECHAR *pchURLIn,
OLECHAR **ppchURLOut) wxOVERRIDE;
virtual HRESULT wxSTDCALL FilterDataObject(IDataObject *pDO,
IDataObject **ppDORet) wxOVERRIDE;
//IUnknown
DECLARE_IUNKNOWN_METHODS;
private:
wxWebView* m_browser;
};
class wxFindPointers
{
public:
wxFindPointers(wxIMarkupPointer *ptrBegin, wxIMarkupPointer *ptrEnd)
{
begin = ptrBegin;
end = ptrEnd;
}
//The two markup pointers.
wxIMarkupPointer *begin, *end;
};
#endif // wxWebViewIE_PRIVATE_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,134 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/winstyle.h
// Purpose: Small helper class for updating MSW windows style
// Author: Vadim Zeitlin
// Created: 2017-12-09
// Copyright: (c) 2017 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_WINSTYLE_H_
#define _WX_MSW_PRIVATE_WINSTYLE_H_
// ----------------------------------------------------------------------------
// wxMSWWinLongUpdater
// ----------------------------------------------------------------------------
/*
This class is not used directly, but either as wxMSWWinStyleUpdater or
wxMSWWinExStyleUpdater, both of which inherit from it and can be used like
this:
void SomeFunction()
{
wxMSWWinStyleUpdater updateStyle(GetHwndOf(m_win));
if ( some-condition )
updateStyle.TurnOn(XX_YYY);
// Style update happens here implicitly -- or call Apply().
}
*/
class wxMSWWinLongUpdater
{
public:
// Get the current style.
LONG_PTR Get() const
{
return m_styleCurrent;
}
// Check if the given style bit(s) is (are all) currently turned on.
bool IsOn(LONG_PTR style) const
{
return (m_styleCurrent & style) == style;
}
// Turn on some bit(s) in the style.
wxMSWWinLongUpdater& TurnOn(LONG_PTR on)
{
m_style |= on;
return *this;
}
// Turn off some bit(s) in the style.
wxMSWWinLongUpdater& TurnOff(LONG_PTR off)
{
m_style &= ~off;
return *this;
}
// Turn some bit(s) on or off depending on the condition.
wxMSWWinLongUpdater& TurnOnOrOff(bool cond, LONG_PTR style)
{
return cond ? TurnOn(style) : TurnOff(style);
}
// Perform the style update (only if necessary, i.e. if the style really
// changed).
//
// Notice that if this method is not called, it's still done from the dtor,
// so it's just a convenient way to do it sooner and avoid having to create
// a new scope for ensuring that the dtor runs at the right place, but
// otherwise is equivalent to do this.
bool Apply()
{
if ( m_style == m_styleCurrent )
return false;
::SetWindowLongPtr(m_hwnd, m_gwlSlot, m_style);
m_styleCurrent = m_style;
return true;
}
~wxMSWWinLongUpdater()
{
Apply();
}
protected:
// Create the object for updating the style or extended style of the given
// window.
//
// Ctor is protected, this class can only be used as wxMSWWinStyleUpdater
// or wxMSWWinExStyleUpdater.
wxMSWWinLongUpdater(HWND hwnd, int gwlSlot)
: m_hwnd(hwnd),
m_gwlSlot(gwlSlot),
m_styleCurrent(::GetWindowLongPtr(hwnd, gwlSlot)),
m_style(m_styleCurrent)
{
}
private:
const HWND m_hwnd;
const int m_gwlSlot;
LONG_PTR m_styleCurrent;
LONG_PTR m_style;
wxDECLARE_NO_COPY_CLASS(wxMSWWinLongUpdater);
};
// A variant of wxMSWWinLongUpdater which updates the extended style.
class wxMSWWinStyleUpdater : public wxMSWWinLongUpdater
{
public:
explicit wxMSWWinStyleUpdater(HWND hwnd)
: wxMSWWinLongUpdater(hwnd, GWL_STYLE)
{
}
};
// A variant of wxMSWWinLongUpdater which updates the extended style.
class wxMSWWinExStyleUpdater : public wxMSWWinLongUpdater
{
public:
explicit wxMSWWinExStyleUpdater(HWND hwnd)
: wxMSWWinLongUpdater(hwnd, GWL_EXSTYLE)
{
}
};
#endif // _WX_MSW_PRIVATE_WINSTYLE_H_