OpenCPN Partial API docs
Loading...
Searching...
No Matches
ui_utils.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2025 NoCodeHummel *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19#ifndef UI_UTILS_H
20#define UI_UTILS_H
21
26#include <set>
27#include <wx/window.h>
28#include <wx/scrolwin.h>
29#include <wx/event.h>
30
31// Declare custom events
32wxDECLARE_EVENT(EVT_LAYOUT_RESIZE, wxCommandEvent);
33
37namespace GUI {
38
39// Screen breakpoints.
40enum class Breakpoint : int {
41 kExtraSmall = 1, // extra small
42 kSmall = 480, // small
43 kMedium = 767, // medium
44 kLarge = 1024, // large
45 kExtraLarge = 1440 // extra large
46};
47
52static const int kSpacing = 6;
53
59template <typename T>
60bool HasKey(const std::set<int>& set, T key) {
61 return set.find(static_cast<int>(key)) != set.end();
62}
63
71int GetSpacing(wxWindow* ctx, int factor);
72
77void LayoutResizeEvent(wxWindow* ctx);
78
84Breakpoint GetScreenSize(wxRect* rect);
85} // namespace GUI
86
87#endif // UI_UTILS_H
Organizes constant variables and methods.
Definition ui_utils.h:37
void LayoutResizeEvent(wxWindow *ctx)
Trigger window layout event.
int GetSpacing(wxWindow *ctx, int factor)
Multiply default spacing with a factor, and calculate device independent pixels.
Breakpoint GetScreenSize(wxRect *rect)
Get screen size breakpoint.
bool HasKey(const std::set< int > &set, T key)
Check if a key exists in a set.
Definition ui_utils.h:60