mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-26 15:23:48 +01:00
Define BasicUI::WindowPlacement and subclass for wxWidgets...
... An elaborate way to hold a wxWindow* as parent of a window, but avoiding
mention of wxWindow* in the member functions of BasicUI::Services, to be defined
next
Original commit: 2facbe0d53
Signed-off-by: Panagiotis Vasilopoulos <hello@alwayslivid.com>
This commit is contained in:
committed by
Panagiotis Vasilopoulos
parent
e5cffb7620
commit
2364504437
@@ -13,6 +13,8 @@ Paul Licameli
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace BasicUI {
|
namespace BasicUI {
|
||||||
|
WindowPlacement::~WindowPlacement() = default;
|
||||||
|
|
||||||
Services::~Services() = default;
|
Services::~Services() = default;
|
||||||
|
|
||||||
static Services *theInstance = nullptr;
|
static Services *theInstance = nullptr;
|
||||||
|
|||||||
@@ -20,6 +20,20 @@ namespace BasicUI {
|
|||||||
|
|
||||||
using Action = std::function<void()>;
|
using Action = std::function<void()>;
|
||||||
|
|
||||||
|
//! Subclasses may hold information such as a parent window pointer for a dialog.
|
||||||
|
/*! The default-constructed empty value of this base class must be accepted by overrides of methods of
|
||||||
|
Services */
|
||||||
|
class BASIC_UI_API WindowPlacement {
|
||||||
|
public:
|
||||||
|
WindowPlacement() = default;
|
||||||
|
|
||||||
|
//! Don't slice
|
||||||
|
WindowPlacement( const WindowPlacement& ) PROHIBITED;
|
||||||
|
//! Don't slice
|
||||||
|
WindowPlacement &operator=( const WindowPlacement& ) PROHIBITED;
|
||||||
|
virtual ~WindowPlacement();
|
||||||
|
};
|
||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Abstract class defines a few user interface services, not mentioning particular toolkits
|
//! Abstract class defines a few user interface services, not mentioning particular toolkits
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ Paul Licameli
|
|||||||
|
|
||||||
using namespace BasicUI;
|
using namespace BasicUI;
|
||||||
|
|
||||||
|
wxWidgetsWindowPlacement::~wxWidgetsWindowPlacement() = default;
|
||||||
|
|
||||||
wxWidgetsBasicUI::~wxWidgetsBasicUI() = default;
|
wxWidgetsBasicUI::~wxWidgetsBasicUI() = default;
|
||||||
|
|
||||||
void wxWidgetsBasicUI::DoCallAfter(const Action &action)
|
void wxWidgetsBasicUI::DoCallAfter(const Action &action)
|
||||||
@@ -23,3 +25,13 @@ void wxWidgetsBasicUI::DoYield()
|
|||||||
{
|
{
|
||||||
wxTheApp->Yield();
|
wxTheApp->Yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
wxWindow *GetParent(const BasicUI::WindowPlacement &placement)
|
||||||
|
{
|
||||||
|
if (auto *pPlacement =
|
||||||
|
dynamic_cast<const wxWidgetsWindowPlacement*>(&placement))
|
||||||
|
return pPlacement->pWindow;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,8 +13,22 @@ Paul Licameli
|
|||||||
|
|
||||||
#include "BasicUI.h"
|
#include "BasicUI.h"
|
||||||
|
|
||||||
|
class wxWindow;
|
||||||
|
|
||||||
|
//! Window placement information for wxWidgetsBasicUI can be constructed from a wxWindow pointer
|
||||||
|
struct TENACITY_DLL_API wxWidgetsWindowPlacement final
|
||||||
|
: BasicUI::WindowPlacement {
|
||||||
|
wxWidgetsWindowPlacement() = default;
|
||||||
|
explicit wxWidgetsWindowPlacement( wxWindow *pWindow )
|
||||||
|
: pWindow{ pWindow }
|
||||||
|
{}
|
||||||
|
|
||||||
|
~wxWidgetsWindowPlacement() override;
|
||||||
|
wxWindow *pWindow{};
|
||||||
|
};
|
||||||
|
|
||||||
//! An implementation of BasicUI::Services in terms of the wxWidgets toolkit
|
//! An implementation of BasicUI::Services in terms of the wxWidgets toolkit
|
||||||
/*! This is a singleton that doesn't need AUDACITY_DLL_API visibility */
|
/*! This is a singleton that doesn't need TENACITY_DLL_API visibility */
|
||||||
class wxWidgetsBasicUI final : public BasicUI::Services {
|
class wxWidgetsBasicUI final : public BasicUI::Services {
|
||||||
public:
|
public:
|
||||||
~wxWidgetsBasicUI() override;
|
~wxWidgetsBasicUI() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user