The Battle for Wesnoth  1.19.0-dev
Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
windows_tray_notification Class Reference

#include <windows_tray_notification.hpp>

Static Public Member Functions

static bool show (std::string title, std::string message)
 Displays a tray notification. More...
 
static void handle_system_event (const SDL_Event &event)
 Frees resources when a notification disappears, switches user to the wesnoth window if the notification popup was clicked by user. More...
 

Private Member Functions

 windows_tray_notification ()
 
 windows_tray_notification (const windows_tray_notification &w)
 
windows_tray_notificationoperator= (const windows_tray_notification &w)
 

Static Private Member Functions

static bool create_tray_icon ()
 
static void destroy_tray_icon ()
 
static bool set_tray_message (const std::string &title, const std::string &message)
 
static void adjust_length (std::string &title, std::string &message)
 
static HWND get_window_handle ()
 
static void switch_to_wesnoth_window ()
 
static std::wstring string_to_wstring (const std::string &string, std::size_t maxlength)
 

Static Private Attributes

static NOTIFYICONDATA * nid = nullptr
 
static bool message_reset = false
 
static const int ICON_ID = 1007
 
static const unsigned int WM_TRAYNOTIFY = 32868
 
static const std::size_t MAX_TITLE_LENGTH = 63
 
static const std::size_t MAX_MESSAGE_LENGTH = 255
 

Detailed Description

Definition at line 41 of file windows_tray_notification.hpp.

Constructor & Destructor Documentation

◆ windows_tray_notification() [1/2]

windows_tray_notification::windows_tray_notification ( )
explicitprivate

◆ windows_tray_notification() [2/2]

windows_tray_notification::windows_tray_notification ( const windows_tray_notification w)
private

Member Function Documentation

◆ adjust_length()

void windows_tray_notification::adjust_length ( std::string &  title,
std::string &  message 
)
staticprivate

Definition at line 159 of file windows_tray_notification.cpp.

References utils::ellipsis_truncate(), MAX_MESSAGE_LENGTH, and MAX_TITLE_LENGTH.

Referenced by show().

◆ create_tray_icon()

bool windows_tray_notification::create_tray_icon ( )
staticprivate

◆ destroy_tray_icon()

void windows_tray_notification::destroy_tray_icon ( )
staticprivate

Definition at line 29 of file windows_tray_notification.cpp.

References message_reset, and nid.

Referenced by handle_system_event(), and show().

◆ get_window_handle()

HWND windows_tray_notification::get_window_handle ( )
staticprivate

Definition at line 172 of file windows_tray_notification.cpp.

References video::get_window().

Referenced by create_tray_icon(), and switch_to_wesnoth_window().

◆ handle_system_event()

void windows_tray_notification::handle_system_event ( const SDL_Event &  event)
static

Frees resources when a notification disappears, switches user to the wesnoth window if the notification popup was clicked by user.

Parameters
eventSystem event.

Definition at line 44 of file windows_tray_notification.cpp.

References destroy_tray_icon(), message_reset, NIN_BALLOONTIMEOUT, NIN_BALLOONUSERCLICK, switch_to_wesnoth_window(), and WM_TRAYNOTIFY.

Referenced by events::pump().

◆ operator=()

windows_tray_notification& windows_tray_notification::operator= ( const windows_tray_notification w)
private

◆ set_tray_message()

bool windows_tray_notification::set_tray_message ( const std::string &  title,
const std::string &  message 
)
staticprivate

Definition at line 146 of file windows_tray_notification.cpp.

References MAX_MESSAGE_LENGTH, MAX_TITLE_LENGTH, message_reset, nid, and string_to_wstring().

Referenced by show().

◆ show()

bool windows_tray_notification::show ( std::string  title,
std::string  message 
)
static

Displays a tray notification.

When user clicks on the notification popup, the user switches to the wesnoth window.

Parameters
titleTitle of a notification. Gets truncated if longer than 64 characters, including the terminating null character.
messageMessage of a notification. Gets truncated if longer than 256 characters, including the terminating null character.
Returns
True if message was shown successfully, False otherwise.

Definition at line 210 of file windows_tray_notification.cpp.

References adjust_length(), create_tray_icon(), destroy_tray_icon(), nid, and set_tray_message().

◆ string_to_wstring()

std::wstring windows_tray_notification::string_to_wstring ( const std::string &  string,
std::size_t  maxlength 
)
staticprivate

Definition at line 198 of file windows_tray_notification.cpp.

Referenced by create_tray_icon(), and set_tray_message().

◆ switch_to_wesnoth_window()

void windows_tray_notification::switch_to_wesnoth_window ( )
staticprivate

Definition at line 185 of file windows_tray_notification.cpp.

References get_window_handle().

Referenced by handle_system_event().

Member Data Documentation

◆ ICON_ID

const int windows_tray_notification::ICON_ID = 1007
staticprivate

Definition at line 67 of file windows_tray_notification.hpp.

Referenced by create_tray_icon().

◆ MAX_MESSAGE_LENGTH

const std::size_t windows_tray_notification::MAX_MESSAGE_LENGTH = 255
staticprivate

Definition at line 70 of file windows_tray_notification.hpp.

Referenced by adjust_length(), and set_tray_message().

◆ MAX_TITLE_LENGTH

const std::size_t windows_tray_notification::MAX_TITLE_LENGTH = 63
staticprivate

Definition at line 69 of file windows_tray_notification.hpp.

Referenced by adjust_length(), create_tray_icon(), and set_tray_message().

◆ message_reset

bool windows_tray_notification::message_reset = false
staticprivate

◆ nid

NOTIFYICONDATA * windows_tray_notification::nid = nullptr
staticprivate

◆ WM_TRAYNOTIFY

const unsigned int windows_tray_notification::WM_TRAYNOTIFY = 32868
staticprivate

Definition at line 68 of file windows_tray_notification.hpp.

Referenced by create_tray_icon(), and handle_system_event().


The documentation for this class was generated from the following files: