YggdrasilWM  0.1.1
A tiny window manager coded in C++
ConfigDataBar Class Reference

ConfigDataBar class Contains the configuration data for one bar in the window manager Inherits from ConfigDataBase class. More...

#include <ConfigDataBar.hpp>

Inheritance diagram for ConfigDataBar:
Inheritance graph
Collaboration diagram for ConfigDataBar:
Collaboration graph

Public Member Functions

 ConfigDataBar ()
 ConfigDataBar class constructor. More...
 
 ~ConfigDataBar () override=default
 
void configInit (const Json::Value &root) override
 Initializes the configuration data for the bar You must call configInit() in each ConfigDataBase Child class to load the data. More...
 
Json::Value configSave () override
 return a Json::Value object containing the Bar configuration data More...
 
int getBarSize () const
 Get the Bar Heightb. More...
 
const std::string & getBarFont () const
 Get the Bar Font. More...
 
unsigned int getBarFontColor () const
 Get the Bar Font Color. More...
 
int getBarFontSize () const
 Get the Bar Font Size. More...
 
unsigned int getBarBackgroundColor () const
 Get the Bar Background Color. More...
 
int getBarBorderSize () const
 Get the Bar Border Size. More...
 
unsigned int getBarBorderColor () const
 Get the Bar Border Color. More...
 
const std::string & getBarPosition () const
 
const std::vector< std::shared_ptr< ConfigDataWidget > > & getWidgets () const
 

Private Attributes

int barSize_
 
std::string barFont_
 
std::string barPosition_
 
unsigned int barFontColor_
 
int barFontSize_
 
unsigned int barBackgroundColor_
 
int barBorderSize_
 
unsigned int barBorderColor_
 
std::vector< std::shared_ptr< ConfigDataWidget > > widgets
 

Detailed Description

ConfigDataBar class Contains the configuration data for one bar in the window manager Inherits from ConfigDataBase class.

See also
ConfigDataBase

Constructor & Destructor Documentation

◆ ConfigDataBar()

ConfigDataBar::ConfigDataBar ( )

ConfigDataBar class constructor.

36  :
37  barSize_(20),
38  barFont_("Arial"),
39  barFontColor_(0x00ff00),
40  barFontSize_(12),
41  barBackgroundColor_(0x00ff00),
42  barBorderSize_(2),
43  barBorderColor_(0x00ff00) {
44 
45 }
int barBorderSize_
Definition: ConfigDataBar.hpp:108
unsigned int barBorderColor_
Definition: ConfigDataBar.hpp:109
int barSize_
Definition: ConfigDataBar.hpp:102
int barFontSize_
Definition: ConfigDataBar.hpp:106
unsigned int barBackgroundColor_
Definition: ConfigDataBar.hpp:107
std::string barFont_
Definition: ConfigDataBar.hpp:103
unsigned int barFontColor_
Definition: ConfigDataBar.hpp:105

◆ ~ConfigDataBar()

ConfigDataBar::~ConfigDataBar ( )
overridedefault

Member Function Documentation

◆ configInit()

void ConfigDataBar::configInit ( const Json::Value &  root)
overridevirtual

Initializes the configuration data for the bar You must call configInit() in each ConfigDataBase Child class to load the data.

Parameters
rootJson::Value& object containing the Bar configuration data

Implements ConfigDataBase.

46  {
47  if (root.empty() || !root.isObject()) {
48  throw std::runtime_error("Invalid configuration file");
49  }
50  if (root["Bar_Size"].empty() || !root["Bar_Size"].isInt()) {
51  Logger::GetInstance()->Log("ConfigDataBar::Bar_Size is empty or not an integer",L_ERROR);
52  } else {
53  barSize_ = root["Bar_Size"].asInt();
54  }
55  if (root["Font"].empty() || !root["Font"].isString()) {
56  Logger::GetInstance()->Log("ConfigDataBar::Font is empty or not a string", L_ERROR);
57  } else {
58  barFont_ = root["Font"].asString();
59  }
60  if (root["Font_Color"].empty() || !root["Font_Color"].isString()) {
61  Logger::GetInstance()->Log("ConfigDataBar::Font_Color is empty or not a string",L_ERROR);
62  } else
63  {
64  barFontColor_ = ConfigHandler::colorCodeToULong(root["Font_Color"].asString());
65  }
66  if (root["Background_Color"].empty() || !root["Background_Color"].isString()) {
67  Logger::GetInstance()->Log("ConfigDataBar::Background_Color is empty or not a string",L_ERROR);
68  } else
69  {
70  barBackgroundColor_ = ConfigHandler::colorCodeToULong(root["Background_Color"].asString());
71  }
72  if (root["Border_Color"].empty() || !root["Border_Color"].isString()) {
73  Logger::GetInstance()->Log("ConfigDataBar::Border_Color is empty or not a string",L_ERROR);
74  } else
75  {
76  barBorderColor_ = ConfigHandler::colorCodeToULong(root["Border_Color"].asString());
77  }
78  if (root["Font_Size"].empty() || !root["Font_Size"].isInt()) {
79  Logger::GetInstance()->Log("ConfigDataBar::Font_Size is empty or not an integer",L_ERROR);
80  } else {
81  barFontSize_ = root["Font_Size"].asInt();
82  }
83  if (root["Border_Size"].empty() || !root["Border_Size"].isInt()) {
84  Logger::GetInstance()->Log("ConfigDataBar::Border_Size is empty or not an integer",L_ERROR);
85  } else {
86  barBorderSize_ = root["Border_Size"].asInt();
87  }
88  if (root["Position"].empty() || !root["Position"].isString()) {
89  Logger::GetInstance()->Log("ConfigDataBar::Position is empty or not a string",L_ERROR);
90  } else {
91  barPosition_ = root["Position"].asString();
92  }
93  for (auto &widget : root["Widgets"]) {
94  std::shared_ptr<ConfigDataWidget> widgetData = std::make_shared<ConfigDataWidget>();
95  widgetData->configInit(widget);
96  widgets.push_back(widgetData);
97  }
98  std::stringstream msg;
99  msg << "Bar :\t Height [" << barSize_ << "] Font [" << barFont_ << "] FontSize [" << barFontSize_ << "] BorderSize [" << barBorderSize_ << "]";
100  Logger::GetInstance()->Log(msg.str(),L_INFO);
101 }
@ L_ERROR
Definition: Logger.hpp:51
@ L_INFO
Definition: Logger.hpp:49
std::vector< std::shared_ptr< ConfigDataWidget > > widgets
Definition: ConfigDataBar.hpp:110
std::string barPosition_
Definition: ConfigDataBar.hpp:104
static unsigned long colorCodeToULong(const std::string &colorCode)
Convert a string containing a color code to unsigned long.
Definition: ConfigHandler.cpp:94
virtual void Log(const std::string &message, LogLevel level) const
Log a message This method logs a message to the log file or stream. The message is only logged if the...
Definition: Logger.cpp:73
static Logger * GetInstance()
Get the Logger object.
Definition: Logger.cpp:41

References barBackgroundColor_, barBorderColor_, barBorderSize_, barFont_, barFontColor_, barFontSize_, barPosition_, barSize_, ConfigHandler::colorCodeToULong(), Logger::GetInstance(), L_ERROR, L_INFO, Logger::Log(), and widgets.

Here is the call graph for this function:

◆ configSave()

Json::Value ConfigDataBar::configSave ( )
overridevirtual

return a Json::Value object containing the Bar configuration data

Implements ConfigDataBase.

102  {
103  return Json::Value();
104 }

◆ getBarBackgroundColor()

unsigned int ConfigDataBar::getBarBackgroundColor ( ) const

Get the Bar Background Color.

109 { return barBackgroundColor_; }

References barBackgroundColor_.

◆ getBarBorderColor()

unsigned int ConfigDataBar::getBarBorderColor ( ) const

Get the Bar Border Color.

111 { return barBorderColor_; }

References barBorderColor_.

◆ getBarBorderSize()

int ConfigDataBar::getBarBorderSize ( ) const

Get the Bar Border Size.

110 { return barBorderSize_; }

References barBorderSize_.

◆ getBarFont()

const std::string & ConfigDataBar::getBarFont ( ) const

Get the Bar Font.

106 { return barFont_; }

References barFont_.

◆ getBarFontColor()

unsigned int ConfigDataBar::getBarFontColor ( ) const

Get the Bar Font Color.

107 { return barFontColor_; }

References barFontColor_.

◆ getBarFontSize()

int ConfigDataBar::getBarFontSize ( ) const

Get the Bar Font Size.

108 { return barFontSize_; }

References barFontSize_.

◆ getBarPosition()

const std::string & ConfigDataBar::getBarPosition ( ) const
112 { return barPosition_; }

References barPosition_.

◆ getBarSize()

int ConfigDataBar::getBarSize ( ) const

Get the Bar Heightb.

Returns
105 { return barSize_; }

References barSize_.

◆ getWidgets()

const std::vector< std::shared_ptr< ConfigDataWidget > > & ConfigDataBar::getWidgets ( ) const
114  {
115  return widgets;
116 }

References widgets.

Member Data Documentation

◆ barBackgroundColor_

unsigned int ConfigDataBar::barBackgroundColor_
private

◆ barBorderColor_

unsigned int ConfigDataBar::barBorderColor_
private

Referenced by configInit(), and getBarBorderColor().

◆ barBorderSize_

int ConfigDataBar::barBorderSize_
private

Referenced by configInit(), and getBarBorderSize().

◆ barFont_

std::string ConfigDataBar::barFont_
private

Referenced by configInit(), and getBarFont().

◆ barFontColor_

unsigned int ConfigDataBar::barFontColor_
private

Referenced by configInit(), and getBarFontColor().

◆ barFontSize_

int ConfigDataBar::barFontSize_
private

Referenced by configInit(), and getBarFontSize().

◆ barPosition_

std::string ConfigDataBar::barPosition_
private

Referenced by configInit(), and getBarPosition().

◆ barSize_

int ConfigDataBar::barSize_
private

Referenced by configInit(), and getBarSize().

◆ widgets

std::vector<std::shared_ptr<ConfigDataWidget> > ConfigDataBar::widgets
private

Referenced by configInit(), and getWidgets().


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