Skip to content

Commit e12d5b1

Browse files
committed
put implementations on cpp files
1 parent ef483bd commit e12d5b1

File tree

7 files changed

+221
-151
lines changed

7 files changed

+221
-151
lines changed

src/items.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ idx_t prompt::printRaw(menuOut& out,idx_t len) const {
88
return print_P(out,getText(),len);
99
}
1010

11-
bool prompt::changed(const navNode &nav,const menuOut& out,bool sub=true,bool test=false) {
11+
bool prompt::changed(const navNode &nav,const menuOut& out,bool sub,bool test) {
1212
trace(MENU_DEBUG_OUT<<"prompt::changed"<<endl);
1313
return dirty;
1414
}
@@ -108,7 +108,7 @@ constText* textField::validator(int i) {return ((textFieldShadow*)shadow)->opera
108108
#endif
109109

110110
#ifdef MENU_ASYNC
111-
const char* textField::typeName() const override {return "textField";}
111+
const char* textField::typeName() const {return "textField";}
112112
#endif
113113

114114

@@ -232,7 +232,7 @@ void menuNode::clearChanged(const navNode &nav,const menuOut& out,bool sub) {
232232
#endif
233233

234234
#ifdef MENU_ASYNC
235-
const char* menuNode::typeName() const override {return "mn";}
235+
const char* menuNode::typeName() const {return "mn";}
236236
#endif
237237

238238

src/items.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
virtual result sysHandler(SYS_FUNC_PARAMS) {return proceed;}
7979
virtual result eventHandler(eventMask e,navNode& nav,idx_t i);
8080
#ifdef MENU_FMT_WRAPS
81-
virtual classes type();
81+
virtual classes type() const;
8282
#endif
8383
#ifdef MENU_ASYNC
8484
// virtual prompt* seek(idx_t* uri,idx_t len) {return len?NULL:this;}
@@ -142,7 +142,7 @@
142142
void doNav(navNode& nav,navCmd cmd) override;
143143
Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr=0) override;
144144
#ifdef MENU_FMT_WRAPS
145-
classes type() const override;
145+
virtual classes type() const;
146146
#endif
147147
#ifdef MENU_ASYNC
148148
bool async(const char*uri,navRoot& root,idx_t lvl) override;
@@ -157,7 +157,7 @@
157157
bool tunning=false;
158158
inline fieldBase(constMEM promptShadow& shadow):navTarget(shadow) {}
159159
#ifdef MENU_FMT_WRAPS
160-
classes type() const override;
160+
virtual classes type() const;
161161
#endif
162162
#ifdef MENU_ASYNC
163163
bool async(const char*uri,navRoot& root,idx_t lvl) override;
@@ -239,7 +239,7 @@
239239
inline menuNode(constText* text,idx_t sz,prompt* constMEM data[],action a=noAction,eventMask e=noEvent,styles style=wrapStyle,systemStyles ss=(systemStyles)(_menuData|_canNav))
240240
:navTarget(*new menuNodeShadow(text,sz,data,a,e,style,ss)) {}
241241
#ifdef MENU_FMT_WRAPS
242-
classes type() const override;
242+
virtual classes type() const;
243243
#endif
244244
inline prompt& operator[](idx_t i) const {return ((menuNodeShadow*)shadow)->operator[](i);}
245245
bool changed(const navNode &nav,const menuOut& out,bool sub=true,bool test=false) override;

src/itemsTemplates.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace Menu {
2828
reflex=target();
2929
}
3030
template<typename T>
31-
bool menuField<T>::changed(const navNode &nav,const menuOut& out,bool sub=true,bool test=false) {
31+
bool menuField<T>::changed(const navNode &nav,const menuOut& out,bool sub,bool test) {
3232
trace(if (test&&dirty) MENU_DEBUG_OUT<<"field dirty"<<endl);
3333
trace(if (test&&(reflex!=target())) MENU_DEBUG_OUT<<"reflex!=target reflex:"<<reflex<<" target:"<<target()<<endl);
3434
return dirty||(reflex!=target());
@@ -104,7 +104,7 @@ namespace Menu {
104104

105105
#ifdef MENU_ASYNC
106106
template<typename T>
107-
const char* typeName() const {return "toggle";}
107+
const char* toggle<T>::typeName() const {return "toggle";}
108108
template<typename T>
109109
bool toggle<T>::async(const char*uri,navRoot& root,idx_t lvl) {
110110
trace(MENU_DEBUG_OUT<<(*(prompt*)this)<<" toggle::async! uri:"<<uri<<endl);
@@ -192,7 +192,7 @@ namespace Menu {
192192
}
193193

194194
template<typename T>
195-
bool choose<T>::changed(const navNode &nav,const menuOut& out,bool sub=true,bool test=false) {
195+
bool choose<T>::changed(const navNode &nav,const menuOut& out,bool sub,bool test) {
196196
return menuVariant<T>::changed(nav,out)||menuNode::changed(nav,out);
197197
}
198198

src/menuIo.cpp

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,47 @@
11
#include "menu.h"
22
using namespace Menu;
33

4+
void menuIn::setFieldMode(bool) {}
5+
bool menuIn::fieldMode() const {return false;}
6+
7+
size_t noInput::write(uint8_t) {return 0;}
8+
int noInput::available() {return 0;}
9+
int noInput::read() {return -1;}
10+
int noInput::peek() {return -1;}
11+
12+
#ifdef MENU_ASYNC
13+
int StringStream::available() {return 0!=*src;}
14+
int StringStream::read() {return *src++;}
15+
int StringStream::peek() {return *src?*src:-1;}
16+
void StringStream::flush() {while(*src) src++;}
17+
size_t StringStream::write(uint8_t) {return 0;}
18+
#endif
19+
420
////////////////////////////////////////////////////////////////////////////////
521
////////////////////////////////////////////////////////////////////////////////
622
////////////////////////////////////////////////////////////////////////////////
723
// menuOut - base menu output device
824
//
925
////////////////////////////////////////////////////////////////////////////////
26+
#if defined(MENU_DEBUG) || defined(MENU_ASYNC)
27+
#ifdef ESP8266
28+
template<typename T>
29+
menuOut& menuOut::operator<<(T o) {(*(Stream*)this)<<(o);return *this;}
30+
#endif
31+
#endif
32+
1033
#ifdef MENU_ASYNC
1134
bool menuOut::isAsync() {return false;}
1235
#endif
1336

37+
menuOut& menuOut::fill(
38+
int x1, int y1, int x2, int y2,char ch,
39+
colorDefs color,
40+
bool selected,
41+
status stat,
42+
bool edit
43+
) {return *this;}
44+
1445
idx_t menuOut::printRaw(const char* at,idx_t len) {
1546
trace(MENU_DEBUG_OUT<<"menuOut::printRaw"<<endl);
1647
const char* p=at;
@@ -43,13 +74,68 @@ void menuOut::doNav(navCmd cmd,navNode &nav) {
4374
}
4475
}
4576

77+
void menuOut::setColor(colorDefs c,bool selected,status s,bool edit) {}
78+
void menuOut::drawCursor(idx_t ln,bool selected,status stat,bool edit,idx_t panelNr) {
79+
setColor(cursorColor, selected, stat,edit);
80+
write(selected?(stat==disabledStatus? options->disabledCursor : options->selectedCursor):' ');
81+
}
82+
idx_t menuOut::startCursor(navRoot& root,idx_t x,idx_t y,bool charEdit,idx_t panelNr) {write(charEdit?">":"[");return 1;}
83+
idx_t menuOut::endCursor(navRoot& root,idx_t x,idx_t y,bool charEdit,idx_t panelNr) {write(charEdit?"<":"]");return 1;}
84+
idx_t menuOut::editCursor(navRoot& root,idx_t x,idx_t y,bool editing,bool charEdit,idx_t panelNr) {return 0;}
85+
void menuOut::rect(idx_t panelNr,idx_t x,idx_t y,idx_t w,idx_t h,colorDefs c,bool selected,status stat,bool edit) {}
86+
void menuOut::box(idx_t panelNr,idx_t x,idx_t y,idx_t w,idx_t h,colorDefs c,bool selected,status stat,bool edit) {}
87+
#ifdef MENU_FMT_WRAPS
88+
result menuOut::fmtStart(prompt& target,fmtParts part,navNode &nav,idx_t idx) {return proceed;}
89+
result menuOut::fmtEnd(prompt& target,fmtParts part,navNode &nav,idx_t idx) {return proceed;}
90+
#endif
91+
4692
#if defined(MENU_DEBUG) || defined(MENU_ASYNC)
4793
menuOut& menuOut::operator<<(const prompt& p) {
4894
print_P(*this,p.getText());
4995
return *this;
5096
}
5197
#endif
5298

99+
void cursorOut::clearLine(idx_t ln,idx_t panelNr,colorDefs color,bool selected,status stat,bool edit) {
100+
setCursor(0,ln,panelNr);
101+
for(int n=0;n<maxX();n++) print(' ');
102+
setCursor(0,ln,panelNr);
103+
}
104+
105+
menuOut& cursorOut::fill(
106+
int x1, int y1, int x2, int y2,char ch,
107+
colorDefs color,
108+
bool selected,
109+
status stat,
110+
bool edit
111+
) {
112+
for(int r=y1;r<=y2;r++) {
113+
setCursor(x1,r);
114+
for(int c=x1;c<=x2;c++)
115+
write(ch);
116+
}
117+
return *this;
118+
}
119+
120+
idx_t gfxOut::startCursor(navRoot& root,idx_t x,idx_t y,bool charEdit,idx_t panelNr) {
121+
if (charEdit) {
122+
rect(panelNr, x-1, y, 1, 1, bgColor, false, enabledStatus, false);
123+
setColor(fgColor,false,enabledStatus,false);
124+
}/* else
125+
box(panelNr, x, y, 1, 1, bgColor, false, enabledStatus, false);*/
126+
return 0;
127+
}
128+
129+
idx_t gfxOut::endCursor(navRoot& root,idx_t x,idx_t y,bool charEdit,idx_t panelNr) {
130+
setColor(fgColor,true,enabledStatus,true);return 0;
131+
}
132+
133+
idx_t gfxOut::editCursor(navRoot& root,idx_t x,idx_t y,bool editing,bool charEdit,idx_t panelNr) {
134+
//TODO: next version, this furntiosn should return an USED value (and avoid nasty x-1)
135+
if (editing) box(panelNr,x-1,y);
136+
return 0;
137+
}
138+
53139
Used outputsList::printMenu(navNode& nav) const {
54140
trace(MENU_DEBUG_OUT<<"outputsList::printMenu"<<endl);
55141
for(int n=0;n<cnt;n++) {
@@ -91,6 +177,19 @@ result outputsList::idle(idleFunc f,idleEvent e,bool idleChanged) {
91177
return proceed;
92178
}
93179

180+
void outputsList::refresh() {
181+
for(int n=0;n<cnt;n++) ((menuOut*)memPtr(outs[n]))->drawn=NULL;
182+
}
183+
void outputsList::clearChanged(navNode& nav) const {
184+
for(int n=0;n<cnt;n++) ((menuOut*)memPtr(outs[n]))->clearChanged(nav);
185+
}
186+
void outputsList::clear() {
187+
for(int n=0;n<cnt;n++) ((menuOut*)memPtr(outs[n]))->clear();
188+
}
189+
void outputsList::doNav(navCmd cmd,class navNode &nav) {
190+
for(int n=0;n<cnt;n++) ((menuOut*)memPtr(outs[n]))->doNav(cmd,nav);
191+
}
192+
94193
// draw a menu preview on a panel
95194
void menuOut::previewMenu(navRoot& root,menuNode& menu,idx_t panelNr) {
96195
trace(MENU_DEBUG_OUT<<"menuOut::previewMenu"<<endl);

0 commit comments

Comments
 (0)