2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
2010-05-03 14:08:02 +00:00
|
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-08-20 14:34:48 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-08-20 14:34:48 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-08-20 14:34:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2010-06-04 19:50:31 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGuiTools.h
|
|
|
|
//
|
|
|
|
// This file is meant to contain utility classes for users of the wxWidgets library.
|
|
|
|
// All classes in this file are dependent on wxBase and wxCore libraries! Meaning
|
|
|
|
// you will have to use wxCore header files and link against wxCore (GUI) to build
|
|
|
|
// them. For tools which require only wxBase, see wxBaseTools.h
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2009-11-01 09:27:16 +00:00
|
|
|
#if wxUSE_GUI
|
|
|
|
|
2009-08-20 14:34:48 +00:00
|
|
|
#include "Dependencies.h"
|
2016-01-27 17:51:08 +00:00
|
|
|
#include <memory>
|
2009-11-01 09:27:16 +00:00
|
|
|
#include <stack>
|
2009-08-20 14:34:48 +00:00
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
#include <wx/wx.h>
|
|
|
|
|
2009-11-18 07:53:02 +00:00
|
|
|
class pxStaticText;
|
2009-11-20 03:26:10 +00:00
|
|
|
class pxStaticHeading;
|
2009-11-18 07:53:02 +00:00
|
|
|
class pxCheckBox;
|
2010-01-04 20:55:47 +00:00
|
|
|
class wxSpinCtrl;
|
2009-11-18 07:53:02 +00:00
|
|
|
|
2010-06-04 19:50:31 +00:00
|
|
|
namespace pxSizerFlags
|
|
|
|
{
|
2016-11-19 10:27:20 +00:00
|
|
|
static int StdPadding = 4;
|
2016-11-12 15:28:37 +00:00
|
|
|
|
|
|
|
extern wxSizerFlags StdSpace();
|
|
|
|
extern wxSizerFlags StdCenter();
|
|
|
|
extern wxSizerFlags StdExpand();
|
|
|
|
extern wxSizerFlags TopLevelBox();
|
|
|
|
extern wxSizerFlags SubGroup();
|
|
|
|
extern wxSizerFlags StdButton();
|
|
|
|
extern wxSizerFlags Checkbox();
|
2016-11-19 10:27:20 +00:00
|
|
|
extern void SetBestPadding();
|
2010-06-04 19:50:31 +00:00
|
|
|
};
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
#define wxSF wxSizerFlags()
|
2009-11-19 05:08:24 +00:00
|
|
|
|
2009-11-20 03:26:10 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// pxAlignment / pxStretchType
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// These are full blown class types instead of enumerations because wxSizerFlags has an
|
|
|
|
// implicit conversion from integer (silly design flaw creating more work for me!)
|
|
|
|
//
|
|
|
|
struct pxAlignmentType
|
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
enum {
|
|
|
|
Centre,
|
|
|
|
Center = Centre,
|
|
|
|
Middle,
|
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
Top,
|
|
|
|
Bottom
|
|
|
|
};
|
|
|
|
|
|
|
|
int intval;
|
|
|
|
|
|
|
|
wxSizerFlags Apply(wxSizerFlags flags = wxSizerFlags()) const;
|
|
|
|
|
|
|
|
wxSizerFlags operator&(const wxSizerFlags &_flgs) const
|
|
|
|
{
|
|
|
|
return Apply(_flgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxSizerFlags Expand() const
|
|
|
|
{
|
|
|
|
return Apply().Expand();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxSizerFlags Border(int dir, int padding) const
|
|
|
|
{
|
|
|
|
return Apply().Border(dir, padding);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxSizerFlags Proportion() const
|
|
|
|
{
|
|
|
|
return Apply().Proportion(intval);
|
|
|
|
}
|
|
|
|
|
|
|
|
operator wxSizerFlags() const
|
|
|
|
{
|
|
|
|
return Apply();
|
|
|
|
}
|
2009-11-20 03:26:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pxStretchType
|
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
enum {
|
|
|
|
Shrink,
|
|
|
|
Expand,
|
|
|
|
Shaped,
|
|
|
|
ReserveHidden,
|
|
|
|
FixedMinimum
|
|
|
|
};
|
|
|
|
|
|
|
|
int intval;
|
|
|
|
|
|
|
|
wxSizerFlags Apply(wxSizerFlags flags = wxSizerFlags()) const;
|
|
|
|
|
|
|
|
wxSizerFlags operator&(const wxSizerFlags &_flgs) const
|
|
|
|
{
|
|
|
|
return Apply(_flgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxSizerFlags Border(int dir, int padding) const
|
|
|
|
{
|
|
|
|
return Apply().Border(dir, padding);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxSizerFlags Proportion() const
|
|
|
|
{
|
|
|
|
return Apply().Proportion(intval);
|
|
|
|
}
|
|
|
|
|
|
|
|
operator wxSizerFlags() const
|
|
|
|
{
|
|
|
|
return Apply();
|
|
|
|
}
|
2009-12-14 12:18:55 +00:00
|
|
|
};
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
static __fi wxSizerFlags pxProportion(int prop)
|
2009-12-14 12:18:55 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
return wxSizerFlags(prop);
|
2010-03-05 14:24:44 +00:00
|
|
|
}
|
2010-01-31 02:21:58 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
static __fi wxSizerFlags pxBorder(int dir = wxALL, int pad = pxSizerFlags::StdPadding)
|
2010-03-05 14:24:44 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
return wxSizerFlags().Border(dir, pad);
|
2010-03-05 14:24:44 +00:00
|
|
|
}
|
2010-01-31 02:21:58 +00:00
|
|
|
|
2010-03-05 14:24:44 +00:00
|
|
|
class pxStretchSpacer
|
2010-01-31 02:21:58 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-11-12 15:28:37 +00:00
|
|
|
int proportion;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
pxStretchSpacer(int prop = 0)
|
|
|
|
{
|
|
|
|
proportion = prop;
|
|
|
|
}
|
2009-11-20 03:26:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const pxAlignmentType
|
2016-11-12 15:28:37 +00:00
|
|
|
pxCentre, // Horizontal centered alignment
|
|
|
|
pxCenter,
|
|
|
|
pxMiddle, // vertical centered alignment
|
2009-11-20 03:26:10 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
pxAlignLeft,
|
|
|
|
pxAlignRight,
|
|
|
|
pxAlignTop,
|
|
|
|
pxAlignBottom;
|
2009-11-20 03:26:10 +00:00
|
|
|
|
|
|
|
extern const pxStretchType
|
2016-11-12 15:28:37 +00:00
|
|
|
pxShrink,
|
|
|
|
pxExpand,
|
|
|
|
pxShaped,
|
|
|
|
pxReserveHidden,
|
|
|
|
pxFixedMinimum;
|
2009-11-20 03:26:10 +00:00
|
|
|
|
2009-11-19 05:08:24 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// pxWindowAndFlags
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// This struct is a go-between for combining windows and sizer flags in "neat" fashion.
|
|
|
|
// To create the struct, use the | operator, like so:
|
|
|
|
//
|
|
|
|
// myPanel | wxSizerFlags().Expand()
|
|
|
|
//
|
|
|
|
// Implementation Note: This struct is a template as it allows us to use a special
|
|
|
|
// version of the += operator that retains the type information of the window, in case
|
|
|
|
// the window implements its own += overloads (one example is pxStaticText). Without the
|
|
|
|
// template, the type of the window would only be known as "wxWindow" when it's added to the
|
|
|
|
// sizer, and would thus fail to invoke the correct operator overload.
|
|
|
|
//
|
2016-11-12 15:28:37 +00:00
|
|
|
template <typename WinType>
|
2009-11-19 05:08:24 +00:00
|
|
|
struct pxWindowAndFlags
|
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
WinType *window;
|
|
|
|
wxSizerFlags flags;
|
2009-11-19 05:08:24 +00:00
|
|
|
};
|
|
|
|
|
2009-11-20 03:26:10 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
extern wxSizerFlags operator&(const wxSizerFlags &_flgs, const wxSizerFlags &_flgs2);
|
2009-11-20 03:26:10 +00:00
|
|
|
|
2018-08-17 08:36:17 +00:00
|
|
|
template <typename WinType, typename = typename std::enable_if<std::is_base_of<wxObject, WinType>::value>::type>
|
2016-11-12 15:28:37 +00:00
|
|
|
pxWindowAndFlags<WinType> operator|(WinType *_win, const wxSizerFlags &_flgs)
|
2009-11-19 05:08:24 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
pxWindowAndFlags<WinType> result = {_win, _flgs};
|
|
|
|
return result;
|
2009-11-19 05:08:24 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 08:36:17 +00:00
|
|
|
template <typename WinType, typename = typename std::enable_if<std::is_base_of<wxObject, WinType>::value>::type>
|
2016-11-12 15:28:37 +00:00
|
|
|
pxWindowAndFlags<WinType> operator|(WinType &_win, const wxSizerFlags &_flgs)
|
2009-11-19 05:08:24 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
pxWindowAndFlags<WinType> result = {&_win, _flgs};
|
|
|
|
return result;
|
2009-11-19 05:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// wxSizer Operator += .. a wxSizer.Add() Substitute
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// This set of operators is the *recommended* method for adding windows to sizers, not just
|
|
|
|
// because it's a lot prettier but also because it allows controls like pxStaticText to over-
|
|
|
|
// ride default sizerflags behavior.
|
|
|
|
//
|
|
|
|
// += operator works on either sizers, wxDialogs or wxPanels. In the latter case, the window
|
|
|
|
// is added to the dialog/panel's toplevel sizer (wxPanel.GetSizer() is used). If the panel
|
|
|
|
// has no sizer set via SetSizer(), an assertion is generated.
|
|
|
|
//
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
extern void operator+=(wxSizer &target, wxWindow *src);
|
|
|
|
extern void operator+=(wxSizer &target, wxSizer *src);
|
|
|
|
extern void operator+=(wxSizer &target, wxWindow &src);
|
|
|
|
extern void operator+=(wxSizer &target, wxSizer &src);
|
2009-11-25 03:54:57 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
extern void operator+=(wxSizer *target, wxWindow &src);
|
|
|
|
extern void operator+=(wxSizer *target, wxSizer &src);
|
2009-12-14 12:18:55 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
extern void operator+=(wxSizer &target, int spacer);
|
|
|
|
extern void operator+=(wxWindow &target, int spacer);
|
|
|
|
extern void operator+=(wxSizer &target, const pxStretchSpacer &spacer);
|
|
|
|
extern void operator+=(wxWindow &target, const pxStretchSpacer &spacer);
|
2009-11-19 05:08:24 +00:00
|
|
|
|
2009-12-14 12:18:55 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2009-11-20 11:25:48 +00:00
|
|
|
// Important: This template is needed in order to retain window type information and
|
|
|
|
// invoke the proper overloaded version of += (which is used by pxStaticText and other
|
|
|
|
// classes to perform special actions when added to sizers).
|
2016-11-12 15:28:37 +00:00
|
|
|
template <typename WinType>
|
|
|
|
void operator+=(wxWindow &target, WinType *src)
|
2009-11-20 11:25:48 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
if (!pxAssert(target.GetSizer() != NULL))
|
|
|
|
return;
|
|
|
|
*target.GetSizer() += src;
|
2009-11-20 11:25:48 +00:00
|
|
|
}
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
template <typename WinType>
|
|
|
|
void operator+=(wxWindow &target, WinType &src)
|
2009-11-25 03:54:57 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
if (!pxAssert(target.GetSizer() != NULL))
|
|
|
|
return;
|
|
|
|
*target.GetSizer() += src;
|
2009-12-14 12:18:55 +00:00
|
|
|
}
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
template <typename WinType>
|
|
|
|
void operator+=(wxWindow &target, const pxWindowAndFlags<WinType> &src)
|
2009-12-14 12:18:55 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
if (!pxAssert(target.GetSizer() != NULL))
|
|
|
|
return;
|
|
|
|
*target.GetSizer() += src;
|
2009-11-25 03:54:57 +00:00
|
|
|
}
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
template <typename WinType>
|
|
|
|
void operator+=(wxSizer &target, const pxWindowAndFlags<WinType> &src)
|
2009-11-19 05:08:24 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
target.Add(src.window, src.flags);
|
2009-11-19 05:08:24 +00:00
|
|
|
}
|
|
|
|
|
2016-06-14 22:17:37 +00:00
|
|
|
wxDECLARE_EVENT(pxEvt_OnDialogCreated, wxCommandEvent);
|
2010-06-04 19:50:31 +00:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// pxDialogCreationFlags
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
class pxDialogCreationFlags
|
|
|
|
{
|
|
|
|
public:
|
2016-11-12 15:28:37 +00:00
|
|
|
wxSize MinimumSize;
|
|
|
|
wxOrientation BoxSizerOrient;
|
2010-06-04 19:50:31 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
bool isResizable;
|
|
|
|
bool hasContextHelp;
|
|
|
|
bool hasCaption;
|
|
|
|
bool hasMinimizeBox;
|
|
|
|
bool hasMaximizeBox;
|
|
|
|
bool hasSystemMenu;
|
|
|
|
bool hasCloseBox;
|
2010-06-04 19:50:31 +00:00
|
|
|
|
|
|
|
public:
|
2017-05-06 12:53:02 +00:00
|
|
|
virtual ~pxDialogCreationFlags() = default;
|
2016-11-12 15:28:37 +00:00
|
|
|
|
|
|
|
pxDialogCreationFlags()
|
|
|
|
{
|
|
|
|
MinimumSize = wxDefaultSize;
|
|
|
|
BoxSizerOrient = wxVERTICAL;
|
|
|
|
isResizable = false;
|
|
|
|
hasContextHelp = false;
|
|
|
|
|
|
|
|
hasCloseBox = true;
|
|
|
|
hasSystemMenu = true;
|
|
|
|
hasMinimizeBox = false;
|
|
|
|
hasMaximizeBox = false;
|
|
|
|
hasCaption = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetSizerOrient(wxOrientation orient)
|
|
|
|
{
|
|
|
|
BoxSizerOrient = orient;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetResize(bool enable = true)
|
|
|
|
{
|
|
|
|
isResizable = enable;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetMinimize(bool enable = true)
|
|
|
|
{
|
|
|
|
hasMinimizeBox = enable;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetMaximize(bool enable = true)
|
|
|
|
{
|
|
|
|
hasMaximizeBox = enable;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Enabling system menu on dialogs usually doesn't work, and might cause
|
|
|
|
// other unwanted behavior, such as a missing close button.
|
|
|
|
pxDialogCreationFlags &SetSystemMenu(bool enable = true)
|
|
|
|
{
|
|
|
|
hasSystemMenu = enable;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetCaption(bool enable = true)
|
|
|
|
{
|
|
|
|
hasCaption = enable;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetCloseBox(bool enable = true)
|
|
|
|
{
|
|
|
|
hasCloseBox = enable;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags SetContextHelp(bool enabled = true)
|
|
|
|
{
|
|
|
|
hasContextHelp = enabled;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetMinWidth(int width)
|
|
|
|
{
|
|
|
|
if (width > MinimumSize.x)
|
|
|
|
MinimumSize.SetWidth(width);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetMinHeight(int height)
|
|
|
|
{
|
|
|
|
if (height > MinimumSize.y)
|
|
|
|
MinimumSize.SetHeight(height);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags &SetMinSize(const wxSize &size)
|
|
|
|
{
|
|
|
|
return SetMinWidth(size.x).SetMinHeight(size.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pxDialogCreationFlags Horizontal() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetSizerOrient(wxHORIZONTAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags Vertical() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetSizerOrient(wxVERTICAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags NoSizer() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetSizerOrient((wxOrientation)0);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags Resize(bool enable = true) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetResize(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags Minimize(bool enable = true) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetMinimize(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags Maximize(bool enable = true) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetMaximize(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Enabling system menu on dialogs usually doesn't work, and might cause
|
|
|
|
// other unwanted behavior, such as a missing close button.
|
|
|
|
pxDialogCreationFlags SystemMenu(bool enable = true) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetSystemMenu(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags Caption(bool enable = true) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetCaption(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags CloseBox(bool enable = true) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetCloseBox(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags NoResize() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetResize(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags NoMinimize() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetMinimize(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags NoMaximize() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetMaximize(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags NoSystemMenu() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetSystemMenu(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags NoCaption() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetCaption(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags NoCloseBox() const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetCloseBox(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags MinWidth(int width) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetMinWidth(width);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags MinHeight(int height) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetMinHeight(height);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags MinSize(const wxSize &size) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetMinSize(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxDialogCreationFlags MinSize(int width, int height) const
|
|
|
|
{
|
|
|
|
return pxDialogCreationFlags(*this).SetMinWidth(width).SetMinHeight(height);
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetWxWindowFlags() const
|
|
|
|
{
|
|
|
|
int retval = 0;
|
|
|
|
if (isResizable)
|
|
|
|
retval |= wxRESIZE_BORDER;
|
|
|
|
if (hasCaption)
|
|
|
|
retval |= wxCAPTION;
|
|
|
|
if (hasMaximizeBox)
|
|
|
|
retval |= wxMAXIMIZE_BOX;
|
|
|
|
if (hasMinimizeBox)
|
|
|
|
retval |= wxMINIMIZE_BOX;
|
|
|
|
if (hasSystemMenu)
|
|
|
|
retval |= wxSYSTEM_MENU;
|
|
|
|
if (hasCloseBox)
|
|
|
|
retval |= wxCLOSE_BOX;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2010-06-04 19:50:31 +00:00
|
|
|
};
|
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// wxDialogWithHelpers
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
class wxDialogWithHelpers : public wxDialog
|
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
typedef wxDialog _parent;
|
2019-05-12 03:43:47 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDialogWithHelpers);
|
2009-11-18 07:53:02 +00:00
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
bool m_hasContextHelp;
|
|
|
|
wxBoxSizer *m_extraButtonSizer;
|
|
|
|
wxRect m_CreatedRect;
|
2010-06-06 23:26:07 +00:00
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
public:
|
2016-11-12 15:28:37 +00:00
|
|
|
wxDialogWithHelpers();
|
|
|
|
wxDialogWithHelpers(wxWindow *parent, const wxString &title, const pxDialogCreationFlags &cflags = pxDialogCreationFlags());
|
2017-05-06 11:00:55 +00:00
|
|
|
virtual ~wxDialogWithHelpers() = default;
|
2016-11-12 15:28:37 +00:00
|
|
|
|
|
|
|
void Init(const pxDialogCreationFlags &cflags);
|
|
|
|
void AddOkCancel(wxSizer &sizer, bool hasApply = false);
|
|
|
|
void AddOkCancel(wxSizer *sizer = NULL, bool hasApply = false);
|
|
|
|
void RememberPosition();
|
|
|
|
|
|
|
|
virtual void SmartCenterFit();
|
|
|
|
virtual int ShowModal();
|
|
|
|
virtual bool Show(bool show = true);
|
|
|
|
|
|
|
|
// Must return the same thing as GetNameStatic; a name ideal for use in uniquely
|
|
|
|
// identifying dialogs. (this version is the 'instance' version, which is called
|
|
|
|
// by BaseConfigurationDialog to assign the wxWidgets dialog name, and for saving
|
|
|
|
// screenshots to disk)
|
|
|
|
virtual wxString GetDialogName() const;
|
|
|
|
|
|
|
|
virtual wxStaticText &Label(const wxString &label);
|
|
|
|
virtual pxStaticText &Text(const wxString &label);
|
|
|
|
virtual pxStaticText &Heading(const wxString &label);
|
|
|
|
|
|
|
|
wxDialogWithHelpers &SetMinWidth(int newWidth);
|
|
|
|
wxDialogWithHelpers &SetMinHeight(int newHeight);
|
|
|
|
|
|
|
|
int GetCharHeight() const;
|
2009-11-14 08:36:57 +00:00
|
|
|
|
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
void OnDialogCreated(wxCommandEvent &evt);
|
|
|
|
void OnOkCancel(wxCommandEvent &evt);
|
2010-06-15 14:13:23 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
bool ShouldPreventAppExit() const { return false; }
|
2010-06-15 14:13:23 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
void DoAutoCenter();
|
2009-11-14 08:36:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// wxPanelWithHelpers
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-11-19 05:08:24 +00:00
|
|
|
// Overview of Helpers provided by this class:
|
|
|
|
// * Simpler constructors that have wxID, position, and size parameters removed (We never
|
|
|
|
// use them in pcsx2)
|
|
|
|
//
|
|
|
|
// * Automatic 'primary box sizer' creation, assigned via SetSizer() -- use GetSizer()
|
|
|
|
// to retrieve it, or use the "*this += window;" syntax to add windows directly to it.
|
|
|
|
//
|
|
|
|
// * Built-in support for StaticBoxes (aka groupboxes). Create one at construction with
|
2009-11-21 07:44:11 +00:00
|
|
|
// a wxString label, or add one "after the fact" using AddFrame.
|
2009-11-19 05:08:24 +00:00
|
|
|
//
|
|
|
|
// * Propagates IdealWidth settings from parenting wxPanelWithHelpers classes, and auto-
|
|
|
|
// matically adjusts the width based on the sizer type (groupsizers get truncated to
|
|
|
|
// account for borders).
|
|
|
|
//
|
2009-11-14 08:36:57 +00:00
|
|
|
class wxPanelWithHelpers : public wxPanel
|
|
|
|
{
|
2019-05-12 03:43:47 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPanelWithHelpers);
|
2009-11-18 07:53:02 +00:00
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
public:
|
2016-11-12 15:28:37 +00:00
|
|
|
wxPanelWithHelpers(wxWindow *parent, wxOrientation orient, const wxString &staticBoxLabel);
|
|
|
|
wxPanelWithHelpers(wxWindow *parent, wxOrientation orient);
|
|
|
|
wxPanelWithHelpers(wxWindow *parent, const wxPoint &pos, const wxSize &size = wxDefaultSize);
|
|
|
|
explicit wxPanelWithHelpers(wxWindow *parent = NULL);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
wxPanelWithHelpers *AddFrame(const wxString &label, wxOrientation orient = wxVERTICAL);
|
2009-11-14 08:36:57 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
wxStaticText &Label(const wxString &label);
|
|
|
|
pxStaticText &Text(const wxString &label);
|
|
|
|
pxStaticText &Heading(const wxString &label);
|
2009-11-20 03:26:10 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
virtual wxPanelWithHelpers &SetMinWidth(int newWidth);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
void Init();
|
2009-11-14 08:36:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-09-20 20:54:45 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// pxTextWrapperBase
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-08-20 14:34:48 +00:00
|
|
|
// this class is used to wrap the text on word boundary: wrapping is done by calling
|
|
|
|
// OnStartLine() and OnOutputLine() functions. This class by itself can be used as a
|
|
|
|
// line counting tool, but produces no formatted text output.
|
|
|
|
//
|
|
|
|
// [class "borrowed" from wxWidgets private code, made public, and renamed to avoid possible
|
|
|
|
// conflicts with future editions of wxWidgets which might make it public. Why this isn't
|
|
|
|
// publicly available already in wxBase I'll never know-- air]
|
|
|
|
//
|
|
|
|
class pxTextWrapperBase
|
|
|
|
{
|
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
bool m_eol;
|
|
|
|
int m_linecount;
|
|
|
|
wxString m_indent;
|
2009-08-20 14:34:48 +00:00
|
|
|
|
|
|
|
public:
|
2017-05-06 12:53:02 +00:00
|
|
|
virtual ~pxTextWrapperBase() = default;
|
2009-08-20 14:34:48 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
pxTextWrapperBase(const wxString &indent = wxEmptyString)
|
|
|
|
: m_indent(indent)
|
|
|
|
{
|
|
|
|
m_eol = false;
|
|
|
|
m_linecount = 0;
|
|
|
|
}
|
2009-08-20 14:34:48 +00:00
|
|
|
|
|
|
|
// win is used for getting the font, text is the text to wrap, width is the
|
|
|
|
// max line width or -1 to disable wrapping
|
2016-11-12 15:28:37 +00:00
|
|
|
pxTextWrapperBase &Wrap(const wxWindow &win, const wxString &text, int widthMax);
|
2009-08-20 14:34:48 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
int GetLineCount() const
|
|
|
|
{
|
|
|
|
return m_linecount;
|
|
|
|
}
|
2009-08-20 14:34:48 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// line may be empty
|
2016-11-12 15:28:37 +00:00
|
|
|
virtual void OnOutputLine(const wxString &line) {}
|
2009-08-20 14:34:48 +00:00
|
|
|
|
|
|
|
// called at the start of every new line (except the very first one)
|
2016-11-12 15:28:37 +00:00
|
|
|
virtual void OnNewLine() {}
|
2009-08-20 14:34:48 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
void DoOutputLine(const wxString &line);
|
2009-11-08 01:56:24 +00:00
|
|
|
bool IsStartOfNewLine();
|
2009-08-20 14:34:48 +00:00
|
|
|
};
|
|
|
|
|
2009-09-20 20:54:45 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// pxTextWrapper
|
|
|
|
// --------------------------------------------------------------------------------------
|
2009-08-20 14:34:48 +00:00
|
|
|
// This class extends pxTextWrapperBase and adds the ability to retrieve the formatted
|
|
|
|
// result of word wrapping.
|
|
|
|
//
|
|
|
|
class pxTextWrapper : public pxTextWrapperBase
|
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
typedef pxTextWrapperBase _parent;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-08-20 14:34:48 +00:00
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
wxString m_text;
|
2009-08-20 14:34:48 +00:00
|
|
|
|
|
|
|
public:
|
2016-11-12 15:28:37 +00:00
|
|
|
pxTextWrapper(const wxString &wrapPrefix = wxEmptyString)
|
|
|
|
: pxTextWrapperBase(wrapPrefix)
|
|
|
|
{
|
|
|
|
}
|
2010-06-21 04:04:32 +00:00
|
|
|
|
2017-05-06 12:53:02 +00:00
|
|
|
virtual ~pxTextWrapper() = default;
|
2009-08-20 14:34:48 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
const wxString &GetResult() const
|
2009-08-20 14:34:48 +00:00
|
|
|
{
|
2016-11-12 15:28:37 +00:00
|
|
|
return m_text;
|
2009-08-20 14:34:48 +00:00
|
|
|
}
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
pxTextWrapper &Wrap(const wxWindow &win, const wxString &text, int widthMax);
|
|
|
|
pxTextWrapper &Wrap(const wxWindow *win, const wxString &text, int widthMax);
|
2009-08-20 14:34:48 +00:00
|
|
|
|
2009-11-08 01:56:24 +00:00
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
void OnOutputLine(const wxString &line);
|
2010-06-21 04:04:32 +00:00
|
|
|
void OnNewLine();
|
2009-08-20 14:34:48 +00:00
|
|
|
};
|
2009-09-20 20:54:45 +00:00
|
|
|
|
2010-05-20 12:23:13 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// pxWindowTextWriter
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
class pxWindowTextWriter
|
|
|
|
{
|
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
wxDC &m_dc;
|
2010-05-20 12:23:13 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
wxAlignment m_align;
|
|
|
|
wxPoint m_curpos;
|
|
|
|
int m_leading;
|
2010-05-20 12:23:13 +00:00
|
|
|
|
2019-09-01 19:49:09 +00:00
|
|
|
virtual void _DoWriteLn(const wxString &msg);
|
2016-11-12 15:28:37 +00:00
|
|
|
void _DoWrite(const wxChar *msg);
|
2010-05-20 12:23:13 +00:00
|
|
|
|
|
|
|
public:
|
2016-11-12 15:28:37 +00:00
|
|
|
pxWindowTextWriter(wxDC &dc);
|
2017-05-06 12:53:02 +00:00
|
|
|
virtual ~pxWindowTextWriter() = default;
|
2016-11-12 15:28:37 +00:00
|
|
|
|
|
|
|
virtual void OnFontChanged();
|
|
|
|
|
|
|
|
pxWindowTextWriter &WriteLn();
|
|
|
|
pxWindowTextWriter &FormatLn(const wxChar *fmt, ...);
|
|
|
|
pxWindowTextWriter &WriteLn(const wxChar *fmt);
|
|
|
|
pxWindowTextWriter &SetFont(const wxFont &font);
|
|
|
|
pxWindowTextWriter &Align(const wxAlignment &align);
|
|
|
|
pxWindowTextWriter &WriteLn(const wxString fmt);
|
|
|
|
|
|
|
|
pxWindowTextWriter &SetLeading(int lead)
|
|
|
|
{
|
|
|
|
m_leading = lead;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxWindowTextWriter &SetWeight(wxFontWeight weight);
|
|
|
|
pxWindowTextWriter &SetStyle(wxFontStyle style);
|
|
|
|
pxWindowTextWriter &Normal();
|
|
|
|
|
|
|
|
pxWindowTextWriter &Bold()
|
|
|
|
{
|
|
|
|
return SetWeight(wxFONTWEIGHT_BOLD);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxWindowTextWriter &Italic()
|
|
|
|
{
|
|
|
|
return SetStyle(wxFONTSTYLE_ITALIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
pxWindowTextWriter &SetPos(const wxPoint &pos);
|
|
|
|
pxWindowTextWriter &MovePos(const wxSize &delta);
|
|
|
|
|
|
|
|
pxWindowTextWriter &SetPos(int xpos, int ypos)
|
|
|
|
{
|
|
|
|
return SetPos(wxPoint(xpos, ypos));
|
|
|
|
}
|
|
|
|
|
|
|
|
pxWindowTextWriter &MovePos(int xdelta, int ydelta)
|
|
|
|
{
|
|
|
|
return MovePos(wxSize(xdelta, ydelta));
|
|
|
|
}
|
|
|
|
|
|
|
|
pxWindowTextWriter &SetY(int ypos);
|
|
|
|
pxWindowTextWriter &MoveY(int ydelta);
|
2010-05-20 12:23:13 +00:00
|
|
|
};
|
|
|
|
|
2009-11-01 09:27:16 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// MoreStockCursors
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// Because (inexplicably) the ArrowWait cursor isn't in wxWidgets stock list.
|
|
|
|
//
|
|
|
|
class MoreStockCursors
|
|
|
|
{
|
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
std::unique_ptr<wxCursor> m_arrowWait;
|
2009-11-01 09:27:16 +00:00
|
|
|
|
|
|
|
public:
|
2016-11-12 15:28:37 +00:00
|
|
|
MoreStockCursors() {}
|
2017-05-06 12:53:02 +00:00
|
|
|
virtual ~MoreStockCursors() = default;
|
2016-11-12 15:28:37 +00:00
|
|
|
const wxCursor &GetArrowWait();
|
2009-11-01 09:27:16 +00:00
|
|
|
};
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
enum BusyCursorType {
|
|
|
|
Cursor_NotBusy,
|
|
|
|
Cursor_KindaBusy,
|
|
|
|
Cursor_ReallyBusy,
|
2009-11-01 09:27:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern MoreStockCursors StockCursors;
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// ScopedBusyCursor
|
|
|
|
// --------------------------------------------------------------------------------------
|
2010-04-25 00:31:27 +00:00
|
|
|
// ... because wxWidgets wxBusyCursor doesn't really do proper nesting (doesn't let me
|
2009-11-01 09:27:16 +00:00
|
|
|
// override a partially-busy cursor with a really busy one)
|
|
|
|
|
|
|
|
class ScopedBusyCursor
|
|
|
|
{
|
|
|
|
protected:
|
2016-11-12 15:28:37 +00:00
|
|
|
static std::stack<BusyCursorType> m_cursorStack;
|
|
|
|
static BusyCursorType m_defBusyType;
|
2009-11-01 09:27:16 +00:00
|
|
|
|
|
|
|
public:
|
2016-11-12 15:28:37 +00:00
|
|
|
ScopedBusyCursor(BusyCursorType busytype);
|
2017-05-06 12:22:00 +00:00
|
|
|
virtual ~ScopedBusyCursor();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
static void SetDefault(BusyCursorType busytype);
|
|
|
|
static void SetManualBusyCursor(BusyCursorType busytype);
|
2009-11-01 09:27:16 +00:00
|
|
|
};
|
|
|
|
|
2010-01-04 11:51:09 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// pxFitToDigits
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// Fits a given text or spinner control to the number of digits requested, since by default
|
|
|
|
// they're usually way over-sized.
|
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
extern void pxFitToDigits(wxWindow *win, int digits);
|
|
|
|
extern void pxFitToDigits(wxSpinCtrl *win, int digits);
|
|
|
|
extern wxTextCtrl *CreateNumericalTextCtrl(wxWindow *parent, int digits, long flags = wxTE_RIGHT);
|
2010-01-04 11:51:09 +00:00
|
|
|
|
|
|
|
|
2009-11-10 17:53:22 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
2009-09-20 20:54:45 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
extern bool pxDialogExists(const wxString &name);
|
|
|
|
extern bool pxIsValidWindowPosition(const wxWindow &window, const wxPoint &windowPos);
|
2009-09-20 20:54:45 +00:00
|
|
|
extern wxRect wxGetDisplayArea();
|
2010-06-21 10:25:06 +00:00
|
|
|
extern wxString pxGetAppName();
|
2009-11-01 09:27:16 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
extern int pxGetCharHeight(const wxWindow *wind, int rows = 1);
|
|
|
|
extern int pxGetCharHeight(const wxWindow &wind, int rows = 1);
|
2010-06-09 17:37:11 +00:00
|
|
|
|
2016-11-12 15:28:37 +00:00
|
|
|
extern void pxSetToolTip(wxWindow *wind, const wxString &src);
|
|
|
|
extern void pxSetToolTip(wxWindow &wind, const wxString &src);
|
2016-11-08 23:28:14 +00:00
|
|
|
extern wxFont pxGetFixedFont(int ptsize = 8, wxFontWeight weight = wxFONTWEIGHT_NORMAL, bool underline = false);
|
2009-12-14 12:18:55 +00:00
|
|
|
|
2010-06-04 19:50:31 +00:00
|
|
|
extern pxDialogCreationFlags pxDialogFlags();
|
2009-11-10 17:53:22 +00:00
|
|
|
|
2009-11-01 09:27:16 +00:00
|
|
|
#endif
|