#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library 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 IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_PLATFORM_INTERACTION_MODERNGUIMESSAGESERVICE_H #define NUCLEX_PLATFORM_INTERACTION_MODERNGUIMESSAGESERVICE_H #include "Nuclex/Platform/Config.h" #include "Nuclex/Platform/Interaction/ExtendedMessageService.h" #include // for std::shared_ptr namespace Nuclex { namespace Platform { namespace Interaction { // ------------------------------------------------------------------------------------------- // class ActiveWindowTracker; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Platform::Interaction namespace Nuclex { namespace Platform { namespace Interaction { // ------------------------------------------------------------------------------------------- // /// Shows notifications and questions to be displayed to an interactive user class NUCLEX_PLATFORM_TYPE ModernGuiMessageService : ExtendedMessageService { /// Initializes a new GUI-based message service /// /// Used to obtain the active top-level window that should become the owner of any /// message boxes that are displayed. /// public: NUCLEX_PLATFORM_API ModernGuiMessageService( const std::shared_ptr &activeWindowTracker = ( std::shared_ptr() ) ); /// Frees all resources owned by the instance public: NUCLEX_PLATFORM_API ~ModernGuiMessageService() override = default; /// Displays a notification containing information to the user /// Topic of the information (normally used as the window title) /// Headline of the message (normally written in bold) /// Message text containing detailed informations public: NUCLEX_PLATFORM_API void Inform( const std::string &topic, const std::string &heading, const std::string &message ) override; /// Displays a warning to the user /// Topic of the warning (normally used as the window title) /// Headline of the message (normally written in bold) /// Message text containing more details public: NUCLEX_PLATFORM_API void Warn( const std::string &topic, const std::string &heading, const std::string &message ) override; /// Displays an error message to the user /// Topic of the error (normally used as the window title) /// Headline of the message (normally written in bold) /// Message text containing more details public: NUCLEX_PLATFORM_API void Complain( const std::string &topic, const std::string &heading, const std::string &message ) override; /// Displays a question to the user, answerable with either yes or no /// Topic of the question (normally used as the window title) /// Basic question being asked (normally written in bold) /// Message text elaborating in the question and actions /// True if the user answered yes, false if the user answered no public: NUCLEX_PLATFORM_API bool AskYesNo( const std::string &topic, const std::string &heading, const std::string &message ) override; /// /// Displays a confirmation prompt to the user, answerable with either ok or cancel /// /// Topic of the conformation (normally used as the window title) /// What the user has to confirm (normally written in bold) /// Message text elaborating the action to be confirmed /// True if the user answered ok, false if the user answered cancel public: NUCLEX_PLATFORM_API bool AskOkCancel( const std::string &topic, const std::string &heading, const std::string &message ) override; /// Displays a question to the user, answerable with yes, no or cancel /// Topic of the question (normally used as the window title) /// Basic question being asked (normally written in bold) /// Message text elaborating in the question and actions /// /// True if the user answered yes, false if the user answered no and nothing if /// the user wishes to cancel /// public: NUCLEX_PLATFORM_API std::optional AskYesNoCancel( const std::string &topic, const std::string &heading, const std::string &message ) override; /// Requires the user to choose between a set of options /// Topic of the question (normally used as the window title) /// Basic question being asked (normally written in bold) /// Message text elaborating the question and choices /// Choices that are available for the user /// The index of the choice that the user has made public: NUCLEX_PLATFORM_API std::optional GiveChoices( const std::string &topic, const std::string &heading, const std::string &message, const std::initializer_list &choices ) override; /// Requests confirmation from the user for a dangerous action /// Topic of the question (normally used as the window title) /// Basic question being asked (normally written in bold) /// Message text elaborating what will happen /// Choices that are available for the user /// True if the user gave confirmation, false otherwise public: NUCLEX_PLATFORM_API bool RequestConfirmation( const std::string &topic, const std::string &heading, const std::string &message, std::chrono::milliseconds buttonEnableDelay = std::chrono::milliseconds(2000) ) override; /// Offers the user a chance to cancel an action for a limited time /// Topic of the action (normally used as the window title) /// Thing that can be cancelled (normally written in bold) /// Message text elaborating what will happen /// /// Time after which the dialog will automatically be confirmed /// /// True if the user gave confirmation, false otherwise public: NUCLEX_PLATFORM_API bool OfferCancellation( const std::string &topic, const std::string &heading, const std::string &message, std::chrono::milliseconds autoAcceptDelay = std::chrono::milliseconds(5000) ) override; /// Provides the currently active top-level window private: std::shared_ptr activeWindowTracker; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Platform::Interaction #endif // NUCLEX_PLATFORM_INTERACTION_MODERNGUIMESSAGESERVICE_H