📄 whitebox.h
字号:
#ifndef WHITEBOX_H#define WHITEBOX_H#include <algae/visible.h>#include <algorithm>#include <strstream>#include <vector>//// A WhiteBox is simply a white (and therefore invisible) container// of other Visible items. It forms a convenient way to gather a// a group of small visible items into a row or column so that they// don't scatter all around the screen. It can also represent a programming// convenience, since by showing/hiding the whitebox, the visibility of all // of the elements added to it can be altered at once.// class WhiteBox : public Visible{public: WhiteBox (bool vertical = false); void add (const Visible* newComponent); void add (const Visible& newComponent); void remove (Visible* oldComponent); // // The usual Visible overrides: virtual void touchAllComponents() const; virtual void writeText (STD ostream &) const {}private: vector<const Visible*> contents; struct WBsearch { const Visible* lookFor; WBsearch (const Visible* lf): lookFor(lf) {} bool operator() (const Visible* v) {return v->id() == lookFor->id();} };};inline WhiteBox::WhiteBox (bool vertical) : Visible(AlgAE::White, vertical){}inline void WhiteBox::add (const Visible* newComponent){ contents.push_back (newComponent);}inline void WhiteBox::add (const Visible& newComponent){ contents.push_back (&newComponent);}inline void WhiteBox::remove (Visible* oldComponent){ vector<const Visible*>::iterator p = find_if(contents.begin(), contents.end(), WBsearch(oldComponent)); if (p != contents.end()) contents.erase (p);}inline void WhiteBox::touchAllComponents() const{ for (int i = 0; i < contents.size(); ++i) touch (contents[i]);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -