ScummVM API documentation
StateButton.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_STATEBUTTON_H
32 #define CRAB_STATEBUTTON_H
33 
34 #include "crab/ui/button.h"
35 
36 namespace Crab {
37 
38 namespace pyrodactyl {
39 namespace ui {
41  ButtonImage _normal, _select;
42 
43  StateButtonImage() {}
44  StateButtonImage(rapidxml::xml_node<char> *node) {
45  if (nodeValid("normal", node))
46  _normal.load(node->first_node("normal"));
47 
48  if (nodeValid("select", node, false))
49  _select.load(node->first_node("select"));
50  else
51  _select = _normal;
52  }
53 };
54 
56  int _col, _colS;
57 
59  _col = 0;
60  _colS = 0;
61  }
62 };
63 
64 // This button has two sets of images (b, h, s) and switching is done by clicking it
65 // Similar to the checkbox UI element in windows/web
66 class StateButton : public Button {
67  // The two images
68  StateButtonImage _imgSet;
69 
70  // The color for the caption when the image is selected
71  StateButtonColor _colNormal, _colSelect;
72 
73 public:
74  StateButton() {}
75  ~StateButton() {}
76 
77  void init(const StateButton &ref, const int &xOffset = 0, const int &yOffset = 0);
78  void load(rapidxml::xml_node<char> *node, const bool &echo = true);
79 
80  // The state of the button - false is original image, true is second image
81  void state(const bool val);
82  bool state() {
83  return (_img == _imgSet._select);
84  }
85 
86  // Set the image
87  void img(const StateButtonImage &sbi);
88 };
89 } // End of namespace ui
90 } // End of namespace pyrodactyl
91 
92 } // End of namespace Crab
93 
94 #endif // CRAB_STATEBUTTON_H
Definition: StateButton.h:66
Definition: StateButton.h:55
Definition: StateButton.h:40
Definition: button.h:58
Definition: moveeffect.h:37
Definition: button.h:86