add last backwards-compatible version

This commit is contained in:
2021-12-14 00:33:46 -07:00
parent 68b10d413b
commit b0dd3f07f3
335 changed files with 4746 additions and 19627 deletions

View File

@@ -1,8 +1,3 @@
#pragma once
#include <climits> // UINT_MAX
#include "completion_notify.h"
//! This interface allows you to show generic nonmodal noninteractive dialog with a text message. This should be used instead of MessageBox where possible.\n
//! Usage: use popup_message::g_show / popup_message::g_show_ex static helpers, or popup_message::get() to obtain an instance.\n
@@ -23,12 +18,12 @@ public:
//! @param p_msg Message to show (UTF-8 encoded string).
//! @param p_title Title of dialog to show (UTF-8 encoded string).
//! @param p_icon Icon of the dialog - can be set to icon_information, icon_error or icon_query.
inline void show(const char * p_msg,const char * p_title,t_icon p_icon = icon_information) {show_ex(p_msg,UINT_MAX,p_title,UINT_MAX,p_icon);}
inline void show(const char * p_msg,const char * p_title,t_icon p_icon = icon_information) {show_ex(p_msg,~0,p_title,~0,p_icon);}
//! Static helper function instantiating the service and activating the message dialog. See show_ex() for description of parameters.
static void g_show_ex(const char * p_msg,unsigned p_msg_length,const char * p_title,unsigned p_title_length,t_icon p_icon = icon_information);
//! Static helper function instantiating the service and activating the message dialog. See show() for description of parameters.
static inline void g_show(const char * p_msg,const char * p_title,t_icon p_icon = icon_information) {g_show_ex(p_msg,UINT_MAX,p_title,UINT_MAX,p_icon);}
static inline void g_show(const char * p_msg,const char * p_title,t_icon p_icon = icon_information) {g_show_ex(p_msg,~0,p_title,~0,p_icon);}
//! Shows generic box with a failure message
static void g_complain(const char * what);
@@ -37,20 +32,14 @@ public:
//! <whatfailed>: <msg>
static void g_complain(const char * p_whatFailed, const char * msg);
#ifdef FOOBAR2000_MODERN
static void g_showToast(const char * msg);
static void g_showToastLongDuration(const char * msg);
#endif
FB2K_MAKE_SERVICE_COREAPI(popup_message);
FB2K_MAKE_SERVICE_COREAPI(popup_message);
};
#define EXCEPTION_TO_POPUP_MESSAGE(CODE,LABEL) try { CODE; } catch(std::exception const & e) {popup_message::g_complain(LABEL,e);}
#ifdef FOOBAR2000_DESKTOP_WINDOWS
//! \since 1.1
class NOVTABLE popup_message_v2 : public service_base {
FB2K_MAKE_SERVICE_COREAPI(popup_message_v2);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(popup_message_v2);
public:
virtual void show(HWND parent, const char * msg, t_size msg_length, const char * title, t_size title_length) = 0;
void show(HWND parent, const char * msg, const char * title) {show(parent, msg, ~0, title, ~0);}
@@ -59,83 +48,3 @@ public:
static void g_complain(HWND parent, const char * whatFailed, const char * msg);
static void g_complain(HWND parent, const char * whatFailed, const std::exception & e);
};
#endif
#ifdef FOOBAR2000_MODERN
namespace fb2k {
class popup_toast : public service_base {
FB2K_MAKE_SERVICE_COREAPI( popup_toast );
public:
struct arg_t {
bool longDuration = false;
};
virtual void show_toast(const char * msg, arg_t const & arg) = 0;
};
void showToast( const char * msg );
void showToastLongDuration( const char * msg );
class toastFormatter : public pfc::string_formatter {
public:
~toastFormatter() {
if ( this->length() > 0 ) showToast( c_str() );
}
};
}
#define FB2K_Toast() ::fb2k::toastFormatter()._formatter()
#endif
#if FOOBAR2000_TARGET_VERSION >= 80
//! \since 1.5
class NOVTABLE popup_message_v3 : public service_base {
FB2K_MAKE_SERVICE_COREAPI(popup_message_v3);
public:
//! show_query button codes. \n
//! Combine one or more of these to create a button mask to pass to show_query().
enum {
buttonOK = 1 << 0,
buttonCancel = 1 << 1,
buttonYes = 1 << 2,
buttonNo = 1 << 3,
buttonRetry = 1 << 4,
buttonAbort = 1 << 5,
buttonIgnore = 1 << 6,
flagDoNotAskAgain = 1 << 16,
iconNone = 0,
iconInformation,
iconQuestion,
iconWarning,
iconError,
};
struct query_t {
const char * title = nullptr;
const char * msg = nullptr;
uint32_t buttons = 0;
uint32_t defButton = 0;
uint32_t icon = iconNone;
completion_notify::ptr reply;
#ifdef _WIN32
HWND wndParent = NULL;
#endif
const char * msgDoNotAskAgain = nullptr;
};
//! Shows an interactive query presenting the user with multiple actions to choose from.
virtual void show_query(query_t const &) = 0;
//! Modal version of show_query. Reply part of the argument can be empty; the status code will be returned.
virtual uint32_t show_query_modal(query_t const &) = 0;
#ifdef FOOBAR2000_DESKTOP_WINDOWS
// Minimalist MessageBox() reimplementation wrapper
int messageBox(HWND, const char*, const char*, UINT);
#endif
//! Old method wrapper
void show_query( const char * title, const char * msg, unsigned buttons, completion_notify::ptr reply);
};
#endif // FOOBAR2000_TARGET_VERSION >= 80