Razorbotz RMC 2021-2022 Documentation
Loading...
Searching...
No Matches
InfoFrame.hpp
1#include <iostream>
2#include <vector>
3#include <string>
4#include <memory>
5
6#include <gtkmm.h>
7#include <gdkmm.h>
8
9#include <InfoItem.hpp>
10
11class InfoFrame:public Gtk::Frame{
12public:
13 Gtk::Frame* frame;
14 Gtk::Box* contentsBox;
15
16 std::vector<std::shared_ptr<InfoItem>> itemList;
17
18 public:
19 InfoFrame(std::string frameName);
20 void addItem(std::string itemName);
21 void removeItem(std::string itemName);
22 void removeAllItems();
23 void addWidget(Gtk::Widget& widget);
24 template <typename T>
25 void setItem(std::string itemName, T itemValue) {
26 for (std::shared_ptr<InfoItem> infoItem : itemList) {
27 if (infoItem->getName() == itemName) {
28 infoItem->setValue(itemValue);
29 return;
30 }
31 }
32 addItem(itemName);
33 if (!itemList.empty() && itemList.back()->getName() == itemName) {
34 itemList.back()->setValue(itemValue);
35 } else {
36 for (std::shared_ptr<InfoItem> infoItem : itemList) {
37 if (infoItem->getName() == itemName) {
38 infoItem->setValue(itemValue);
39 return;
40 }
41 }
42 }
43 }
44
45 void setBackground(std::string itemName, std::string color);
46 void setTextColor(std::string itemName, std::string color, bool bold);
47};