History

#19171 split of menu.cpp in menuColumn.cpp and menuRow.cpp

vincent committed 13 years ago

Commit eb646ad1 parent d6189697 files · +263 −231Browse files

Showing the changes to interface/src/MenuRow.cpp (1 of 7 files). Show all

Unified · Split

interface/src/MenuRow.cpp+53−0
@@ -0,0 +1,53 @@
1+
2+#include <algorithm>
3+#include "InterfaceConfig.h"
4+#include "MenuRow.h"
5+#include "MenuColumn.h"
6+#include "Menu.h"
7+#include "Util.h"
8+
9+
10+MenuRow::MenuRow()
11+{
12+}
13+MenuRow::MenuRow(char * columnName, PFNRowCallback callback)
14+{
15+ int length = std::min(MAX_COLUMN_NAME - 5,(int) strlen(columnName));
16+ strncpy(this->rowName, columnName, length);
17+ memcpy(this->rowName + length, " \0", 5);
18+ this->callback = callback;
19+ rowWidth = 0;
20+}
21+
22+MenuRow::~MenuRow()
23+{
24+}
25+
26+void MenuRow::call() {
27+ callback(-2);
28+}
29+
30+char * MenuRow::getName() {
31+ int length = (int) strlen(this->rowName) - 4;
32+ int currentValue = callback(-1);
33+ if (currentValue == 0) {
34+ memcpy(this->rowName + length, " OFF\0", 5);
35+ } else if (currentValue == 1) {
36+ memcpy(this->rowName + length, " ON \0", 5);
37+ } else {
38+ memcpy(this->rowName + length, " \0", 5);
39+ }
40+ return this->rowName;
41+}
42+
43+int MenuRow::getWidth(float scale, int mono, int leftPosition){
44+ if (rowWidth == 0) {
45+ rowWidth = widthText( scale, mono, this->rowName);
46+ }
47+ return rowWidth;
48+}
49+
50+int MenuRow::getWidth(){
51+ return rowWidth;
52+}
53+