CtrlCore: for(Ctrl& q : widget) now possible

git-svn-id: svn://ultimatepp.org/upp/trunk@15470 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-11-20 09:36:17 +00:00
parent 9f04d9459f
commit a5a3b685f6
3 changed files with 39 additions and 9 deletions

View file

@ -1218,7 +1218,7 @@ public:
bool IsDragAndDropSource() { return this == GetDragAndDropSource(); }
bool IsDragAndDropTarget() { return this == GetDragAndDropTarget(); }
static Size StdSampleSize() { return Size(DPI(126), DPI(106)); }
public:
static void SetSkin(void (*skin)());
@ -1289,6 +1289,31 @@ public:
Ctrl();
virtual ~Ctrl();
private: // support for for(Ctrl& q : *this)
class CtrlConstIterator {
protected:
friend class Ctrl;
const Ctrl *q;
public:
void operator++() { q = q->GetNext(); }
bool operator!=(CtrlConstIterator& b) const { return q != b.q; }
const Ctrl& operator*() const { return *q; }
};
class CtrlIterator : public CtrlConstIterator { // support for(Ctrl *q : *this)
friend class Ctrl;
public:
Ctrl& operator*() { return *const_cast<Ctrl *>(q); }
};
public:
CtrlConstIterator begin() const { CtrlConstIterator c; c.q = GetFirstChild(); return c; }
CtrlIterator begin() { CtrlIterator c; c.q = GetFirstChild(); return c; }
CtrlConstIterator end() const { CtrlConstIterator c; c.q = NULL; return c; }
CtrlIterator end() { CtrlIterator c; c.q = NULL; return c; }
};
inline Size GetScreenSize() { return Ctrl::GetVirtualScreenArea().GetSize(); } // Deprecated

View file

@ -393,8 +393,8 @@ Tuple<dword, const char *> KeyNames__[ ] = {
{ K_OPTION_KEY, tt_("key\vOption") },
#endif
{ IK_DBL_CLICK, tt_("key\v[double-click]") },
{ K_MOUSE_FORWARD, tt_("key\v[Forward]") },
{ K_MOUSE_BACKWARD, tt_("key\v[Backward]") },
{ (dword)K_MOUSE_FORWARD, tt_("key\v[Forward]") },
{ (dword)K_MOUSE_BACKWARD, tt_("key\v[Backward]") },
{ 0, NULL }
};

View file

@ -2710,12 +2710,6 @@ stream.&]
[s7;i1120;a17; [%-*C@3 s]-|Stream.&]
[s3;%- &]
[s4;%- &]
[s5;:Ctrl`:`:InitWin32`(HINSTANCE`):%- [@(0.0.255) static] [@(0.0.255) void]_[* InitWin32](
HINSTANCE_[*@3 hinst])&]
[s2;b17;a17; Flushes all drawing operations to screen (what it EXACTLY
does is platform specific).&]
[s3;%- &]
[s4;%- &]
[s5;:Ctrl`:`:GuiSleep`(int`):%- [@(0.0.255) static] [@(0.0.255) void]_[* GuiSleep]([@(0.0.255) i
nt]_[*@3 ms])&]
[s2;b17;a17; Sleeps (while allowing other applications or threads
@ -2757,6 +2751,17 @@ can finish.&]
single input event (mouse event or keyboard event) is processed.
This is helpful in certain caching situations `- e.g. if you
want to lazy fetch some data, but only once per input event.&]
[s3;%- &]
[s4;%- &]
[s5;:Upp`:`:Ctrl`:`:begin`(`)const:%- [_^Upp`:`:Ctrl`:`:CtrlConstIterator^ CtrlConstIte
rator]_[* begin]()_[@(0.0.255) const]&]
[s5;:Upp`:`:Ctrl`:`:begin`(`):%- [_^Upp`:`:Ctrl`:`:CtrlIterator^ CtrlIterator]_[* begin](
)&]
[s5;:Upp`:`:Ctrl`:`:end`(`)const:%- [_^Upp`:`:Ctrl`:`:CtrlConstIterator^ CtrlConstItera
tor]_[* end]()_[@(0.0.255) const]&]
[s5;:Upp`:`:Ctrl`:`:end`(`):%- [_^Upp`:`:Ctrl`:`:CtrlIterator^ CtrlIterator]_[* end]()&]
[s2; Adds rudimentary iterators over child widgets. Allows range`-based
for loops: for(Ctrl`& q : widget).&]
[s0;%- &]
[s0;%- &]
[ {{10000@(113.42.0) [s0; [*@7;4 Ctrl`::Logc]]}}&]