Commit f79916092b551a956ad18956f7afbda1f5513afe
1 parent
9be3d764
Updated txtwin
Showing
4 changed files
with
19 additions
and
12 deletions
examples05/02-txtwin/cpoint.h
| 1 | +#ifndef _CPOINT_H_ | |
| 2 | +#define _CPOINT_H_ | |
| 3 | + | |
| 1 | 4 | struct CPoint { |
| 2 | 5 | int x; |
| 3 | 6 | int y; |
| ... | ... | @@ -15,3 +18,5 @@ struct CRect { |
| 15 | 18 | CPoint size; |
| 16 | 19 | CRect(CPoint t1 = CPoint(), CPoint s = CPoint()) : topleft(t1), size(s){}; |
| 17 | 20 | }; |
| 21 | + | |
| 22 | +#endif /* _CPOINT_H_ */ | |
| 18 | 23 | \ No newline at end of file | ... | ... |
examples05/02-txtwin/screen.cpp
examples05/02-txtwin/screen.h
examples05/02-txtwin/winsys.cpp
| 1 | -#include "cpoint.h" | |
| 2 | -#include "screen.h" | |
| 1 | +#include <ncurses.h> | |
| 3 | 2 | #include <ctype.h> |
| 4 | 3 | #include <list> |
| 5 | 4 | #include <string> |
| 5 | + | |
| 6 | +#include "cpoint.h" | |
| 7 | +#include "screen.h" | |
| 6 | 8 | using namespace std; |
| 7 | 9 | |
| 8 | 10 | class CView { |
| ... | ... | @@ -118,9 +120,8 @@ class CGroup : public CView { |
| 118 | 120 | CGroup(CRect g) : CView(g){}; |
| 119 | 121 | void paint() |
| 120 | 122 | { |
| 121 | - for (list<CView*>::iterator i = children.begin(); i != children.end(); | |
| 122 | - i++) | |
| 123 | - (*i)->paint(); | |
| 123 | + for (CView* i : children) | |
| 124 | + i->paint(); | |
| 124 | 125 | }; |
| 125 | 126 | bool handleEvent(int key) |
| 126 | 127 | { |
| ... | ... | @@ -141,9 +142,8 @@ class CGroup : public CView { |
| 141 | 142 | }; |
| 142 | 143 | ~CGroup() |
| 143 | 144 | { |
| 144 | - for (list<CView*>::iterator i = children.begin(); i != children.end(); | |
| 145 | - i++) | |
| 146 | - delete (*i); | |
| 145 | + for (CView* i : children) | |
| 146 | + delete i; | |
| 147 | 147 | }; |
| 148 | 148 | }; |
| 149 | 149 | |
| ... | ... | @@ -184,7 +184,7 @@ class CDesktop : public CGroup { |
| 184 | 184 | refresh(); |
| 185 | 185 | while (1) { |
| 186 | 186 | c = getEvent(); |
| 187 | - if (c == 27) | |
| 187 | + if (c == 27) // ESC key | |
| 188 | 188 | break; |
| 189 | 189 | if (handleEvent(c)) { |
| 190 | 190 | paint(); | ... | ... |