void Aggregate::popN(Token n, ... ) const{ CHECKUNDERFLOW(n); va_list refVars;va_start(refVars,n); for(uWord i=hP()->n-n;i<hP()->n;i++) *va_arg(refVars,Word*)=data(i); va_end(refVars); hP()->n-=n; }
void Aggregate::checkResize(Word n) const{ uWord m=n+hP()->n,r=hP()->size; if(m>r){ for(;m>r;r+=1+r/8); resize<hAggregate,Word>(r); hP()->size=r; } }
void Aggregate::checkUnderflow(Word n,const char* m)const{ if(!isToken() || !((obj)n).isInt() || n>hP()->n){ std::stringstream s; if(m) s<<m; s<<" checkUnderflow n="<<n<<" elements()="<<elements(); throw(std::runtime_error(s.str())); } }
static void OnProgressPaint(WindowControl * Sender, LKSurface& Surface) { RECT PrintAreaR = Sender->GetClientRect(); const auto oldFont = Surface.SelectObject(MapWindowBoldFont); Surface.FillRect(&PrintAreaR, LKBrush_Petrol); // Create text area // we cannot use LKPen here because they are not still initialised for startup menu. no problem LKPen hP(PEN_SOLID,NIBLSCALE(1),RGB_GREEN); auto ohP = Surface.SelectObject(hP); const auto ohB = Surface.SelectObject(LKBrush_Petrol); Surface.Rectangle(PrintAreaR.left,PrintAreaR.top,PrintAreaR.right,PrintAreaR.bottom); Surface.SelectObject(ohP); hP.Release(); hP.Create(PEN_SOLID,NIBLSCALE(1),RGB_BLACK); ohP = Surface.SelectObject(hP); Surface.SelectObject(LK_HOLLOW_BRUSH); InflateRect(&PrintAreaR, -NIBLSCALE(2), -NIBLSCALE(2)); Surface.Rectangle(PrintAreaR.left,PrintAreaR.top,PrintAreaR.right,PrintAreaR.bottom); Surface.SetTextColor(RGB_WHITE); Surface.SetBackgroundTransparent(); InflateRect(&PrintAreaR, -NIBLSCALE(2), -NIBLSCALE(2)); const TCHAR* text = Sender->GetCaption(); Surface.DrawText(text, &PrintAreaR, DT_VCENTER|DT_SINGLELINE); Surface.SelectObject(ohB); Surface.SelectObject(ohP); Surface.SelectObject(oldFont); }
Word Aggregate::elements(uWord n) const{ uWord r=hP()->n;hP()->n=n;return r; }
Word Aggregate::elements() const{return hP()->n;}
Word Aggregate::maxElements() const{return hP()->size;}
Word& Aggregate::data(uWord i) const {return hP()->data(i);}
Word* Aggregate::dataP() const {return hP()->dataP();}
void Aggregate::push(Word w) const{ checkResize(1); hP()->data(hP()->n++)=w; }
Word& Aggregate::operator[](Word i) const { #ifndef NBOUNDCHECKS ADJUSTOFFSET(elements(),i); #endif return hP()->data(i); }
Word& Aggregate::at(Word i) const { ADJUSTOFFSET(elements(),i); return hP()->data(i); }
void Aggregate::roll(bool direction,int n){ int d=elements();Word w;int i; if(direction) {i=d-1;w=hP()->data(i);for(;i>=(d-n+1) ;i--) hP()->data(i)=hP()->data(i-1);} else {i=d-n;w=hP()->data(i);for(;i<d-1 ;i++) hP()->data(i)=hP()->data(i+1);} hP()->data(i)=w; }