1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
|
/***********************************************************************
* fwindow.h - Intermediate base class for all window objects *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2023 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* FINAL CUT 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 *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
/* Inheritance diagram
* ═══════════════════
*
* ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
* ▕ FVTerm ▏ ▕ FObject ▏
* ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
* ▲ ▲
* │ │
* └─────┬─────┘
* │
* ▕▔▔▔▔▔▔▔▔▔▏
* ▕ FWidget ▏
* ▕▁▁▁▁▁▁▁▁▁▏
* ▲
* │
* ▕▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▔▏
* ▕ FWindow ▏-┬- - - -▕ FEvent ▏
* ▕▁▁▁▁▁▁▁▁▁▏ : ▕▁▁▁▁▁▁▁▁▏
* :
* : *▕▔▔▔▔▔▔▔▔▏
* :- - - -▕ FPoint ▏
* : ▕▁▁▁▁▁▁▁▁▏
* :
* : *▕▔▔▔▔▔▔▔▔▔▏
* └- - - -▕ FWidget ▏
* ▕▁▁▁▁▁▁▁▁▁▏
*/
#ifndef FWINDOW_H
#define FWINDOW_H
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
#include "final/fwidget.h"
namespace finalcut
{
//----------------------------------------------------------------------
// class FWindow
//----------------------------------------------------------------------
class FWindow : public FWidget
{
public:
// Using-declaration
using FWidget::setGeometry;
// Constructor
explicit FWindow (FWidget* = nullptr);
// Disable copy constructor
FWindow (const FWindow&) = delete;
// Disable move constructor
FWindow (FWindow&&) noexcept = delete;
// Destructor
~FWindow () override;
// Disable copy assignment operator (=)
auto operator = (const FWindow&) -> FWindow& = delete;
// Disable move assignment operator (=)
auto operator = (FWindow&&) noexcept -> FWindow& = delete;
// Accessors
auto getClassName() const -> FString override;
template<typename WidgetT>
static auto getWindowWidget (WidgetT*) -> FWindow*;
template<typename WidgetT>
static auto getWindowLayer (WidgetT*) -> int;
auto getWindowFocusWidget() const -> FWidget*;
// Mutators
auto setWindowWidget (bool = true) -> bool;
auto unsetWindowWidget() -> bool;
static void setActiveWindow (FWindow*);
void setWindowFocusWidget (FWidget*);
auto activateWindow (bool = true) -> bool;
void unsetActiveWindow() const;
auto deactivateWindow() -> bool;
virtual auto setResizeable (bool = true) -> bool;
auto unsetResizeable() -> bool;
virtual auto setMinimizable (bool = true) -> bool;
auto unsetMinimizable() -> bool;
auto setTransparentShadow (bool = true) -> bool;
auto unsetTransparentShadow() -> bool;
auto setShadow (bool = true) -> bool;
auto unsetShadow() -> bool;
auto setAlwaysOnTop (bool = true) -> bool;
auto unsetAlwaysOnTop() -> bool;
// Inquiries
auto isZoomed() const noexcept -> bool;
auto isMinimized() const -> bool;
auto isWindowActive() const noexcept -> bool;
auto isWindowHidden() const -> bool;
auto isResizeable() const -> bool;
auto isMinimizable() const -> bool;
auto isAlwaysOnTop() const -> bool;
auto hasTransparentShadow() const -> bool;
auto hasShadow() const -> bool;
// Methods
void drawBorder() override;
void show() override;
void hide() override;
void setX (int, bool = true) override;
void setY (int, bool = true) override;
void setPos (const FPoint&, bool = true) override;
void setWidth (std::size_t, bool = true) override;
void setHeight (std::size_t, bool = true) override;
void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
void move (const FPoint&) override;
static auto getWindowWidgetAt (const FPoint&) -> FWindow*;
static auto getWindowWidgetAt (int, int) -> FWindow*;
static void addWindow (FWidget*);
static void delWindow (const FWidget*);
static void swapWindow (const FWidget*, const FWidget*);
static auto raiseWindow (FWidget*) -> bool;
auto raiseWindow() -> bool;
static auto lowerWindow (FWidget*) -> bool;
auto lowerWindow() -> bool;
virtual auto zoomWindow() -> bool;
virtual auto minimizeWindow() -> bool;
static void switchToPrevWindow (const FWidget*);
static auto activatePrevWindow() -> bool;
void setShadowSize (const FSize&) override;
protected:
// Method
void adjustSize() override;
// Mutator
static void setPreviousWindow (FWindow*);
// Event handlers
auto event (FEvent*) -> bool override;
virtual void onWindowActive (FEvent*);
virtual void onWindowInactive (FEvent*);
virtual void onWindowRaised (FEvent*);
virtual void onWindowLowered (FEvent*);
private:
// Methods
void createVWin() noexcept;
static auto getVisibleTermGeometry (FWindow*) -> FRect;
static void deleteFromAlwaysOnTopList (const FWidget*);
static void processAlwaysOnTop();
static auto getWindowWidgetImpl (FWidget*) -> FWindow*;
static auto getWindowLayerImpl (FWidget*) -> int;
static void reactivateWindow (FWindow*);
// Data members
FWidget* win_focus_widget{nullptr};
FRect normalGeometry{};
static FWindow* previous_window;
bool window_active{false};
bool zoomed{false};
};
// non-member function forward declarations
//----------------------------------------------------------------------
class FMouseData; // class forward declaration
void closeDropDownMouseHandler (const FMouseData&);
void closeDropDown (const FWidget*, const FPoint&);
void unselectMenubarItemsMouseHandler (const FMouseData&);
void unselectMenubarItems (const FWidget*, const FPoint&);
// FWindow inline functions
//----------------------------------------------------------------------
inline auto FWindow::getClassName() const -> FString
{ return "FWindow"; }
//----------------------------------------------------------------------
template<typename WidgetT>
inline auto FWindow::getWindowWidget (WidgetT* obj) -> FWindow*
{
return getWindowWidgetImpl (static_cast<FWidget*>(obj));
}
//----------------------------------------------------------------------
template<typename WidgetT>
inline auto FWindow::getWindowLayer (WidgetT* obj) -> int
{
return getWindowLayerImpl (static_cast<FWidget*>(obj));
}
//----------------------------------------------------------------------
inline auto FWindow::unsetWindowWidget() -> bool
{ return setWindowWidget(false); }
//----------------------------------------------------------------------
inline auto FWindow::deactivateWindow() -> bool
{ return activateWindow(false); }
//----------------------------------------------------------------------
inline auto FWindow::unsetResizeable() -> bool
{ return setResizeable(false); }
//----------------------------------------------------------------------
inline auto FWindow::unsetMinimizable() -> bool
{ return setMinimizable(false); }
//----------------------------------------------------------------------
inline auto FWindow::unsetTransparentShadow() -> bool
{ return setTransparentShadow(false); }
//----------------------------------------------------------------------
inline auto FWindow::unsetShadow() -> bool
{ return setShadow(false); }
//----------------------------------------------------------------------
inline auto FWindow::unsetAlwaysOnTop() -> bool
{ return setAlwaysOnTop(false); }
//----------------------------------------------------------------------
inline auto FWindow::isZoomed() const noexcept -> bool
{ return zoomed; }
//----------------------------------------------------------------------
inline auto FWindow::isWindowActive() const noexcept -> bool
{ return window_active; }
//----------------------------------------------------------------------
inline auto FWindow::isResizeable() const -> bool
{ return getFlags().feature.resizeable; }
//----------------------------------------------------------------------
inline auto FWindow::isMinimizable() const -> bool
{ return getFlags().feature.minimizable; }
//----------------------------------------------------------------------
inline auto FWindow::isAlwaysOnTop() const -> bool
{ return getFlags().visibility.always_on_top; }
//----------------------------------------------------------------------
inline auto FWindow::hasTransparentShadow() const -> bool
{ return getFlags().shadow.trans_shadow; }
//----------------------------------------------------------------------
inline auto FWindow::hasShadow() const -> bool
{ return getFlags().shadow.shadow; }
//----------------------------------------------------------------------
inline auto FWindow::getWindowWidgetAt (const FPoint& pos) -> FWindow*
{ return getWindowWidgetAt (pos.getX(), pos.getY()); }
//----------------------------------------------------------------------
inline auto FWindow::raiseWindow() -> bool
{ return raiseWindow(this); }
//----------------------------------------------------------------------
inline auto FWindow::lowerWindow() -> bool
{ return lowerWindow(this); }
//----------------------------------------------------------------------
inline void FWindow::setPreviousWindow (FWindow* w)
{ previous_window = w; }
} // namespace finalcut
#endif // FWINDOW_H
|