FINAL CUT
fcolorpair.h
1 /***********************************************************************
2 * fcolorpair.h - Foreground and background color of a character *
3 * *
4 * This file is part of the FINAL CUT widget toolkit *
5 * *
6 * Copyright 2019-2022 Markus Gans *
7 * *
8 * FINAL CUT is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation; either version 3 of *
11 * the License, or (at your option) any later version. *
12 * *
13 * FINAL CUT is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this program. If not, see *
20 * <http://www.gnu.org/licenses/>. *
21 ***********************************************************************/
22 
23 /* Standalone class
24  * ════════════════
25  *
26  * ▕▔▔▔▔▔▔▔▔▔▔▔▔▏
27  * ▕ FColorPair ▏
28  * ▕▁▁▁▁▁▁▁▁▁▁▁▁▏
29  */
30 
31 #ifndef FCOLORPAIR_H
32 #define FCOLORPAIR_H
33 
34 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
35  #error "Only <final/final.h> can be included directly."
36 #endif
37 
38 #include "final/fc.h"
39 #include "final/ftypes.h"
40 #include "final/util/fstring.h"
41 
42 namespace finalcut
43 {
44 
45 //----------------------------------------------------------------------
46 // class FColorPair
47 //----------------------------------------------------------------------
48 
50 {
51  public:
52  // Constructors
53  explicit FColorPair (FColor fg = FColor::Default, FColor bg = FColor::Default)
54  : fg_color{fg}
55  , bg_color{bg}
56  { }
57 
58  // Accessor
59  auto getClassName() const -> FString
60  { return "FColorPair"; }
61 
62  inline auto getForegroundColor() const noexcept -> FColor
63  { return fg_color; }
64 
65  inline auto getBackgroundColor() const noexcept -> FColor
66  { return bg_color; }
67 
68  // Mutators
69  inline void setForegroundColor (FColor color) noexcept
70  { fg_color = color; }
71 
72  inline void setBackgroundColor (FColor color) noexcept
73  { bg_color = color; }
74 
75  inline void setColorPair (const FColorPair& pair) noexcept
76  {
77  fg_color = pair.fg_color;
78  bg_color = pair.bg_color;
79  }
80 
81  inline void setColorPair (FColor fg, FColor bg) noexcept
82  {
83  fg_color = fg;
84  bg_color = bg;
85  }
86 
87  // Methods
88  inline void swap() noexcept
89  {
90  std::swap (fg_color, bg_color);
91  }
92 
93  private:
94  // Data members
95  FColor fg_color; // Foreground color
96  FColor bg_color; // Background color
97 };
98 
99 } // namespace finalcut
100 
101 #endif // FCOLORPAIR_H
Definition: class_template.cpp:25
Definition: fstring.h:79
Definition: fcolorpair.h:49