diff --git a/src/monitor/FDblDialog.h b/src/monitor/FDblDialog.h new file mode 100644 index 00000000..3b0efaee --- /dev/null +++ b/src/monitor/FDblDialog.h @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Host Monitor Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file FDblDialog.h + * @ingroup monitor + */ +#if !defined(__F_DBL_DIALOG_H__) +#define __F_DBL_DIALOG_H__ + +#include "common/Defines.h" + +#include +using namespace finalcut; + +// --------------------------------------------------------------------------- +// Class Declaration +// --------------------------------------------------------------------------- + +/** + * @brief This class implements the double-border dialog. + * @ingroup monitor + */ +class HOST_SW_API FDblDialog : public finalcut::FDialog { +public: + /** + * @brief Initializes a new instance of the FDblDialog class. + * @param widget + */ + explicit FDblDialog(FWidget* widget = nullptr) : finalcut::FDialog{widget} + { + /* stub */ + } + +protected: + /** + * @brief + */ + void drawBorder() override + { + if (!hasBorder()) + return; + + setColor(); + + FRect box{{1, 2}, getSize()}; + box.scaleBy(0, -1); + + FRect rect = box; + if (rect.x1_ref() > rect.x2_ref()) + std::swap(rect.x1_ref(), rect.x2_ref()); + + if (rect.y1_ref() > rect.y2_ref()) + std::swap(rect.y1_ref(), rect.y2_ref()); + + rect.x1_ref() = std::max(rect.x1_ref(), 1); + rect.y1_ref() = std::max(rect.y1_ref(), 1); + rect.x2_ref() = std::min(rect.x2_ref(), rect.x1_ref() + int(getWidth()) - 1); + rect.y2_ref() = std::min(rect.y2_ref(), rect.y1_ref() + int(getHeight()) - 1); + + if (box.getWidth() < 3) + return; + + // Use box-drawing characters to draw a border + constexpr std::array box_char + {{ + static_cast(0x2554), // ╔ + static_cast(0x2550), // ═ + static_cast(0x2557), // ╗ + static_cast(0x2551), // ║ + static_cast(0x2551), // ║ + static_cast(0x255A), // ╚ + static_cast(0x2550), // ═ + static_cast(0x255D) // ╝ + }}; + + drawGenericBox(this, box, box_char); + } +}; + +#endif // __F_DBL_DIALOG_H__ diff --git a/src/monitor/TransmitWndBase.h b/src/monitor/TransmitWndBase.h index d0be1b0a..8796f9e9 100644 --- a/src/monitor/TransmitWndBase.h +++ b/src/monitor/TransmitWndBase.h @@ -20,6 +20,8 @@ #include "remote/RESTClient.h" #include "MonitorMain.h" +#include "FDblDialog.h" + #include using namespace finalcut; @@ -31,14 +33,14 @@ using namespace finalcut; * @brief This class implements the base class for transmit windows. * @ingroup monitor */ -class HOST_SW_API TransmitWndBase : public finalcut::FDialog { +class HOST_SW_API TransmitWndBase : public FDblDialog { public: /** * @brief Initializes a new instance of the TransmitWndBase class. * @param channel Channel data. * @param widget */ - explicit TransmitWndBase(lookups::VoiceChData channel, FWidget* widget = nullptr) : FDialog{widget}, + explicit TransmitWndBase(lookups::VoiceChData channel, FWidget* widget = nullptr) : FDblDialog{widget}, m_selectedCh(channel) { /* stub */ diff --git a/src/sysview/AffListWnd.h b/src/sysview/AffListWnd.h index 63af7aac..6ec5137b 100644 --- a/src/sysview/AffListWnd.h +++ b/src/sysview/AffListWnd.h @@ -19,6 +19,7 @@ #include "fne/network/RESTDefines.h" #include "remote/RESTClient.h" +#include "FDblDialog.h" #include "SysViewMainWnd.h" #include @@ -39,13 +40,13 @@ using namespace finalcut; * @brief This class implements the affiliations list window. * @ingroup fneSysView */ -class HOST_SW_API AffListWnd final : public finalcut::FDialog { +class HOST_SW_API AffListWnd final : public FDblDialog { public: /** * @brief Initializes a new instance of the AffListWnd class. * @param widget */ - explicit AffListWnd(FWidget* widget = nullptr) : FDialog{widget} + explicit AffListWnd(FWidget* widget = nullptr) : FDblDialog{widget} { m_timerId = addTimer(10000); // starts the timer every 10 seconds } diff --git a/src/sysview/FDblDialog.h b/src/sysview/FDblDialog.h new file mode 100644 index 00000000..98e754b6 --- /dev/null +++ b/src/sysview/FDblDialog.h @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - FNE System View + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file FDblDialog.h + * @ingroup fneSysView + */ +#if !defined(__F_DBL_DIALOG_H__) +#define __F_DBL_DIALOG_H__ + +#include "common/Defines.h" + +#include +using namespace finalcut; + +// --------------------------------------------------------------------------- +// Class Declaration +// --------------------------------------------------------------------------- + +/** + * @brief This class implements the double-border dialog. + * @ingroup fneSysView + */ +class HOST_SW_API FDblDialog : public finalcut::FDialog { +public: + /** + * @brief Initializes a new instance of the FDblDialog class. + * @param widget + */ + explicit FDblDialog(FWidget* widget = nullptr) : finalcut::FDialog{widget} + { + /* stub */ + } + +protected: + /** + * @brief + */ + void drawBorder() override + { + if (!hasBorder()) + return; + + setColor(); + + FRect box{{1, 2}, getSize()}; + box.scaleBy(0, -1); + + FRect rect = box; + if (rect.x1_ref() > rect.x2_ref()) + std::swap(rect.x1_ref(), rect.x2_ref()); + + if (rect.y1_ref() > rect.y2_ref()) + std::swap(rect.y1_ref(), rect.y2_ref()); + + rect.x1_ref() = std::max(rect.x1_ref(), 1); + rect.y1_ref() = std::max(rect.y1_ref(), 1); + rect.x2_ref() = std::min(rect.x2_ref(), rect.x1_ref() + int(getWidth()) - 1); + rect.y2_ref() = std::min(rect.y2_ref(), rect.y1_ref() + int(getHeight()) - 1); + + if (box.getWidth() < 3) + return; + + // Use box-drawing characters to draw a border + constexpr std::array box_char + {{ + static_cast(0x2554), // ╔ + static_cast(0x2550), // ═ + static_cast(0x2557), // ╗ + static_cast(0x2551), // ║ + static_cast(0x2551), // ║ + static_cast(0x255A), // ╚ + static_cast(0x2550), // ═ + static_cast(0x255D) // ╝ + }}; + + drawGenericBox(this, box, box_char); + } +}; + +#endif // __F_DBL_DIALOG_H__ diff --git a/src/sysview/NodeStatusWnd.h b/src/sysview/NodeStatusWnd.h index 37c8fd18..250d9a44 100644 --- a/src/sysview/NodeStatusWnd.h +++ b/src/sysview/NodeStatusWnd.h @@ -19,6 +19,8 @@ #include "common/Thread.h" #include "SysViewMain.h" +#include "FDblDialog.h" + #include using namespace finalcut; @@ -769,13 +771,13 @@ private: * @brief This class implements the node status window. * @ingroup fneSysView */ -class HOST_SW_API NodeStatusWnd final : public finalcut::FDialog { +class HOST_SW_API NodeStatusWnd final : public FDblDialog { public: /** * @brief Initializes a new instance of the NodeStatusWnd class. * @param widget */ - explicit NodeStatusWnd(FWidget* widget = nullptr) : FDialog{widget}, + explicit NodeStatusWnd(FWidget* widget = nullptr) : FDblDialog{widget}, m_killed(false), m_threadStopped(false) { diff --git a/src/sysview/PeerListWnd.h b/src/sysview/PeerListWnd.h index 0ad263fd..2f0f51aa 100644 --- a/src/sysview/PeerListWnd.h +++ b/src/sysview/PeerListWnd.h @@ -19,6 +19,7 @@ #include "fne/network/RESTDefines.h" #include "remote/RESTClient.h" +#include "FDblDialog.h" #include "SysViewMainWnd.h" #include @@ -39,13 +40,13 @@ using namespace finalcut; * @brief This class implements the peer list window. * @ingroup fneSysView */ -class HOST_SW_API PeerListWnd final : public finalcut::FDialog { +class HOST_SW_API PeerListWnd final : public FDblDialog { public: /** * @brief Initializes a new instance of the PeerListWnd class. * @param widget */ - explicit PeerListWnd(FWidget* widget = nullptr) : FDialog{widget} + explicit PeerListWnd(FWidget* widget = nullptr) : FDblDialog{widget} { m_timerId = addTimer(25000); // starts the timer every 25 seconds } diff --git a/src/sysview/TransmitWndBase.h b/src/sysview/TransmitWndBase.h index 48644a2f..9411841f 100644 --- a/src/sysview/TransmitWndBase.h +++ b/src/sysview/TransmitWndBase.h @@ -28,6 +28,8 @@ #include "host/modem/Modem.h" #include "SysViewMain.h" +#include "FDblDialog.h" + #include using namespace finalcut; @@ -83,13 +85,13 @@ public: * @brief This class implements the base class for transmit windows. * @ingroup fneSysView */ -class HOST_SW_API TransmitWndBase : public finalcut::FDialog { +class HOST_SW_API TransmitWndBase : public FDblDialog { public: /** * @brief Initializes a new instance of the TransmitWndBase class. * @param widget */ - explicit TransmitWndBase(FWidget* widget = nullptr) : FDialog{widget} + explicit TransmitWndBase(FWidget* widget = nullptr) : FDblDialog{widget} { /* stub */ } diff --git a/src/tged/CloseWndBase.h b/src/tged/CloseWndBase.h index 908443e8..40c3d4c4 100644 --- a/src/tged/CloseWndBase.h +++ b/src/tged/CloseWndBase.h @@ -16,6 +16,8 @@ #include "common/Thread.h" +#include "FDblDialog.h" + #include using namespace finalcut; @@ -27,13 +29,13 @@ using namespace finalcut; * @brief This class implements the base class for windows with close buttons. * @ingroup tged */ -class HOST_SW_API CloseWndBase : public finalcut::FDialog { +class HOST_SW_API CloseWndBase : public FDblDialog { public: /** * @brief Initializes a new instance of the CloseWndBase class. * @param widget */ - explicit CloseWndBase(FWidget* widget = nullptr) : FDialog{widget} + explicit CloseWndBase(FWidget* widget = nullptr) : FDblDialog{widget} { /* stub */ } diff --git a/src/tged/FDblDialog.h b/src/tged/FDblDialog.h new file mode 100644 index 00000000..ffdbdf45 --- /dev/null +++ b/src/tged/FDblDialog.h @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Talkgroup Editor + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file FDblDialog.h + * @ingroup tged + */ +#if !defined(__F_DBL_DIALOG_H__) +#define __F_DBL_DIALOG_H__ + +#include "common/Defines.h" + +#include +using namespace finalcut; + +// --------------------------------------------------------------------------- +// Class Declaration +// --------------------------------------------------------------------------- + +/** + * @brief This class implements the double-border dialog. + * @ingroup tged + */ +class HOST_SW_API FDblDialog : public finalcut::FDialog { +public: + /** + * @brief Initializes a new instance of the FDblDialog class. + * @param widget + */ + explicit FDblDialog(FWidget* widget = nullptr) : finalcut::FDialog{widget} + { + /* stub */ + } + +protected: + /** + * @brief + */ + void drawBorder() override + { + if (!hasBorder()) + return; + + setColor(); + + FRect box{{1, 2}, getSize()}; + box.scaleBy(0, -1); + + FRect rect = box; + if (rect.x1_ref() > rect.x2_ref()) + std::swap(rect.x1_ref(), rect.x2_ref()); + + if (rect.y1_ref() > rect.y2_ref()) + std::swap(rect.y1_ref(), rect.y2_ref()); + + rect.x1_ref() = std::max(rect.x1_ref(), 1); + rect.y1_ref() = std::max(rect.y1_ref(), 1); + rect.x2_ref() = std::min(rect.x2_ref(), rect.x1_ref() + int(getWidth()) - 1); + rect.y2_ref() = std::min(rect.y2_ref(), rect.y1_ref() + int(getHeight()) - 1); + + if (box.getWidth() < 3) + return; + + // Use box-drawing characters to draw a border + constexpr std::array box_char + {{ + static_cast(0x2554), // ╔ + static_cast(0x2550), // ═ + static_cast(0x2557), // ╗ + static_cast(0x2551), // ║ + static_cast(0x2551), // ║ + static_cast(0x255A), // ╚ + static_cast(0x2550), // ═ + static_cast(0x255D) // ╝ + }}; + + drawGenericBox(this, box, box_char); + } +}; + +#endif // __F_DBL_DIALOG_H__ diff --git a/src/tged/TGListWnd.h b/src/tged/TGListWnd.h index 5dd2391c..94315f78 100644 --- a/src/tged/TGListWnd.h +++ b/src/tged/TGListWnd.h @@ -16,6 +16,7 @@ #include "common/Log.h" +#include "FDblDialog.h" #include "TGEdMainWnd.h" #include "TGEditWnd.h" @@ -37,13 +38,13 @@ using namespace finalcut; * @brief This class implements the talkgroup list window. * @ingroup tged */ -class HOST_SW_API TGListWnd final : public finalcut::FDialog { +class HOST_SW_API TGListWnd final : public FDblDialog { public: /** * @brief Initializes a new instance of the TGListWnd class. * @param widget */ - explicit TGListWnd(FWidget* widget = nullptr) : FDialog{widget} + explicit TGListWnd(FWidget* widget = nullptr) : FDblDialog{widget} { /* stub */ } @@ -284,6 +285,50 @@ private: loadListView(); } + /** + * @brief + */ + void drawBorder() override + { + if (!hasBorder()) + return; + + setColor(); + + FRect box{{1, 2}, getSize()}; + box.scaleBy(0, -1); + + FRect rect = box; + if (rect.x1_ref() > rect.x2_ref()) + std::swap(rect.x1_ref(), rect.x2_ref()); + + if (rect.y1_ref() > rect.y2_ref()) + std::swap(rect.y1_ref(), rect.y2_ref()); + + rect.x1_ref() = std::max(rect.x1_ref(), 1); + rect.y1_ref() = std::max(rect.y1_ref(), 1); + rect.x2_ref() = std::min(rect.x2_ref(), rect.x1_ref() + int(getWidth()) - 1); + rect.y2_ref() = std::min(rect.y2_ref(), rect.y1_ref() + int(getHeight()) - 1); + + if (box.getWidth() < 3) + return; + + // Use box-drawing characters to draw a border + constexpr std::array box_char + {{ + static_cast(0x2554), + static_cast(0x2550), + static_cast(0x2557), + static_cast(0x2551), + static_cast(0x2551), + static_cast(0x255A), + static_cast(0x2550), + static_cast(0x255D) + }}; + + drawGenericBox(this, box, box_char); + } + /* ** Event Handlers */