Size Canvas::ArrangeOverrideWithError (Size finalSize, MoonError *error) { VisualTreeWalker walker = VisualTreeWalker (this); while (FrameworkElement *child = (FrameworkElement *)walker.Step ()) { Size desired = child->GetDesiredSize (); Rect child_final = Rect (GetLeft (child), GetTop (child), desired.width, desired.height); child->ArrangeWithError (child_final, error); //child->ClearValue (LayoutInformation::LayoutClipProperty); } return finalSize; }
void GuiCheckbox::InitCheckImg() { /*PLuint border = sCaption.GetBorder(); PLfloat hOff = (GetHeight() - fSpacing)/2 - border*GuiComponent::fYfactor; PLfloat hSize = fSpacing; if (hOff < 0) { hOff = border*GuiComponent::fYfactor; hSize = GetHeight() - 2*border*GuiComponent::fYfactor; if (hSize < 0) hSize = 0; } else hOff += border*GuiComponent::fYfactor;*/ PLfloat border = sCaption.GetBorder(); PLfloat hSize; PLfloat hOff = GetCheckImgSize(border, hSize); vboCheckImg = CreateVertexObj( GetLeft()+border, GetTop()+hOff, hSize, hSize); sCaption.SetRenderRect( GetLeft()+border+hSize, GetTop(), GetWidth()-border-hSize, GetHeight()); }
void wxRect2DInt::ConstrainTo( const wxRect2DInt &rect ) { if ( GetLeft() < rect.GetLeft() ) SetLeft( rect.GetLeft() ); if ( GetRight() > rect.GetRight() ) SetRight( rect.GetRight() ); if ( GetBottom() > rect.GetBottom() ) SetBottom( rect.GetBottom() ); if ( GetTop() < rect.GetTop() ) SetTop( rect.GetTop() ); }
void nsStyleSides::AppendToString(nsString& aBuffer) const { aBuffer.AppendLiteral("left: "); GetLeft().AppendToString(aBuffer); aBuffer.AppendLiteral("top: "); GetTop().AppendToString(aBuffer); aBuffer.AppendLiteral("right: "); GetRight().AppendToString(aBuffer); aBuffer.AppendLiteral("bottom: "); GetBottom().AppendToString(aBuffer); }
int main() { Stack s; ElemType x; cout<<"(1)³õʼ»¯Õ»s"<<endl; InitStack(s); cout<<"(2)ջΪ"<<(StackEmpty(s)?"¿Õ":"·Ç¿Õ")<<endl; cout<<"(3)ÒÀ´ÎÊäÈë×ÖĸÐòÁУ¬ÒÔ¡°#¡±½áÊø£º"<<endl; cin>>x; while( x!='#') { Push(s,x); cin>>x; } cout<<"(4)ջΪ"<<(StackEmpty(s)?"¿Õ":"·Ç¿Õ")<<endl; cout<<"(5)Õ»³¤¶ÈStackLength(s):"<<StackLength(s)<<endl; cout<<"(6a)Õ»¶¥ÔªËØGetTop(s)Ϊ£º"; cout<<GetTop(s)<<endl; cout<<"(6b)Õ»¶¥ÔªËØGetTop1(s,x)Ϊ£º"<<endl; GetTop1(s,x); cout<<x<<endl; cout<<"(7)´ÓÕ»¶¥µ½Õ»µ×ÔªËØPrintStack(s)Ϊ£º"<<endl; PrintStack(s); cout<<"(8)³öÕ»Pop1(s,x)µÄÔªËØΪ£º"<<endl; Pop1(s,x); cout<<x<<endl; cout<<"(9)³öÕ»ÐòÁÐ:"<<endl; while(!StackEmpty(s)) { cout<<Pop(s)<<" "; } cout<<endl; cout<<"(10)ջΪ:"<<(StackEmpty(s)?"¿Õ":"·Ç¿Õ")<<endl; cout<<"(11)ÒÀ´Î½øÕ»ÔªËØa,b,c:"<<endl; Push(s,'a'); Push(s,'b'); Push(s,'c'); cout<<"(12)´ÓÕ»¶¥µ½Õ»µ×ÔªËØPrintStack(s)Ϊ£º"<<endl; PrintStack(s); cout<<"(13)Çå¿ÕÕ»ClearStack(s)"<<endl; ClearStack(s); cout<<"(14)ջΪ"<<(StackEmpty(s)?"¿Õ":"·Ç¿Õ")<<endl; cout<<"(15)Ïú»ÙÕ»s:"<<endl; DestoryStack(s); cout<<"(16)Ïú»ÙÕ»ºóµ÷ÓÃPush(s,e)ºÍPrintStack(s)"<<endl; Push(s,'e'); PrintStack(s); return 0; }
// ----------------------------------------------------------------------------- // Draws function text (spec+args) for [context] at [left,top]. // Returns a rect of the bounds of the drawn text // ----------------------------------------------------------------------------- wxRect SCallTip::drawFunctionContext( wxDC& dc, const TLFunction::Context& context, int left, int top, wxColour& col_faded, wxFont& bold) const { auto rect_func = drawFunctionSpec(dc, context, left, top); auto rect_args = drawArgs(dc, context, rect_func.GetRight() + 1, rect_func.GetTop(), col_faded, bold); return wxRect{ rect_func.GetTopLeft(), wxPoint{ std::max(rect_func.GetRight(), rect_args.GetRight()), std::max(rect_func.GetBottom(), rect_args.GetBottom()) } }; }
int SystemMenuProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2) { int mx, my; WINDOW wnd1; switch (msg) { case CREATE_WINDOW: wnd->holdmenu = ActiveMenuBar; ActiveMenuBar = &SystemMenu; SystemMenu.PullDown[0].Selection = 0; break; case LEFT_BUTTON: wnd1 = GetParent(wnd); mx = (int) p1 - GetLeft(wnd1); my = (int) p2 - GetTop(wnd1); if (HitControlBox(wnd1, mx, my)) return TRUE; break; case LB_CHOOSE: PostMessage(wnd, CLOSE_WINDOW, 0, 0); break; case DOUBLE_CLICK: if (p2 == GetTop(GetParent(wnd))) { PostMessage(GetParent(wnd), msg, p1, p2); SendMessage(wnd, CLOSE_WINDOW, TRUE, 0); } return TRUE; case SHIFT_CHANGED: return TRUE; case CLOSE_WINDOW: ActiveMenuBar = wnd->holdmenu; break; default: break; } return DefaultWndProc(wnd, msg, p1, p2); }
/** * @brief get head element from the queue. * * @param[in] Q queue struct pointer * @param[out] e the element * * @return return OK if success, else return ERROR */ Status GetHead(Queue* Q, ElementType* e) { assert(Q != NULL && e != NULL); if (StackEmpty(&Q->s2) == FALSE) { GetTop(&Q->s2, e); return OK; } else if (StackEmpty(&Q->s1) == FALSE) { while (Pop(&Q->s1, e)) { Push(&Q->s2, *e); } return OK; } else { return ERROR; } }
/* 我自己写的,可以运行,代码不如示例的简洁 */ void InOrderTraverse1_xdwang(BiTree T,Status(*Visit)(TElemType)) { SqStack sq; SElemType s; if (T) { InitStack(&sq); Push(&sq, T); while (GetTop(sq, &s) && s->lchild) { Push(&sq, s->lchild); } while (GetTop(sq, &s)) { Pop(&sq, &s); Visit(s->data); if (s->rchild) { Push(&sq, s->rchild); while (GetTop(sq, &s) && s->lchild) { Push(&sq, s->lchild); } } } } }
//******************** void main_SeqStack(){ SeqStack S; int i; DataType a[]={'a','b','c','d','e'}; DataType e; InitStack(&S); for(i=0;i<sizeof(a)/sizeof(a[0]);i++) { if(PushStack(&S,a[i])==0) { printf("栈已满,不能进栈!"); return; } } printf("出栈的元素是:"); if(PopStack(&S,&e)==1) printf("%4c",e); if(PopStack(&S,&e)==1) printf("%4c",e); printf("\n"); printf("当前栈顶的元素是:"); if(GetTop(S,&e)==0) { printf("栈已空!"); return; } else printf("%4c\n",e); if(PushStack(&S,'f')==0) { printf("栈已满,不能进栈!"); return; } if(PushStack(&S,'g')==0) { printf("栈已满,不能进栈!"); return; } printf("当前栈中的元素个数是:%d\n",StackLength(S)); printf("元素出栈的序列是:"); while(!StackEmpty(S)) { PopStack(&S,&e); printf("%4c",e); } printf("\n"); system("pause"); }
void Forward() { GetTop(); if (t == NULL) return; if (!strcmp(cname, "IEFrame") || !strcmp(cname, "CabinetWClass")) { //FindIE(t); if (t) { wb2 wb = GetIE(t); if (wb) { wb->raw_GoForward(); } } } }
/*中序遍历,非递归算法*/ void InOrderTraverse1(BiTree T,void (*visit)(BiTree)){ Stack stack; BiTree p; init(stack); push(stack,T); //根指针进栈 while(!empty(stack)){ while(p = GetTop(stack)) push(stack,p->lchild); //向左走到尽头 pop(stack,p); //空指针出栈 if(!empty(stack)){ pop(stack,p); visit(p); //访问节点 push(stack,p->rchild); //右孩子指针进栈 } } }
template<class T> void HTMLElementDisplay<T>::SetXYPosition(DISPLAY_INT iXPos, DISPLAY_INT iYPos) { switch (GetPosition()) { case TU_POSITION_RELATIVE: // tbd - this should take into account right and bottom if left or top aren't defined iXPos += GetLeft(); iYPos += GetTop(); // intentional fall-through default: T::SetFixedPosition(WEBC_FALSE); break; } T::MoveTo(iXPos, iYPos); }
void Scrollbar::Thumb::Arrange() { if (auto sb = _scrollbar.lock()) { auto scrollDelegate = sb->GetScrollDelegate(); auto p = GetParent(); SetLeft(p->GetLeft()); SetRight(p->GetRight()); auto trackHeight = p->GetHeight(); auto height = scrollDelegate->GetThumbSizePercent() * trackHeight; auto top = p->GetTop() + (scrollDelegate->GetCurrentOffsetPercent() * trackHeight); SetTop(std::round(top)); SetBottom(std::round(top + height)); } }
void CDiagramEntity::MoveRect( double x, double y ) /* ============================================================ Function : CDiagramEntity::MoveRect Description : Moves the object rect. Return : void Parameters : double x - Move x steps horizontally. double y - Move y steps vertically. Usage : Call to move the object on screen. ============================================================*/ { SetRect( GetLeft() + x, GetTop() + y, GetRight() + x, GetBottom() + y ); }
void GuiFrameImage::Draw() { if(!IsVisible()) return; if( oldWidth != GetWidth() || oldHeight != GetHeight() || oldX != GetLeft() || oldY != GetTop() || oldZ != 0 || oldAlpha != GetAlpha()) { CreateDrawList(); } GX_CallDispList(DrawList, DrawListSize); }
void BiTree_free(BiTree *T) { SqStack S=NULL; S=InitStack(S); BiTree p=NULL; p = *T; Push(S, p); while(!StackEmpty(S)) { while(p){ if(p->lflag != 1 ) { p->lflag = 1; if(p->lchild){ Push(S, p->lchild); p = p->lchild; } }else if(p->rflag != 1) { p->rflag = 1; if(p->rchild){ Push(S, p->rchild); p = p->rchild; } }else if(p->lflag == 1 && p->rflag == 1){ break; } } p = Pop(S); //printf("%4c", p->data); free(p); p = NULL; if(StackEmpty(S)) { break; } p = GetTop(S); } *T = NULL; free(S->base); free(S); }
CRect CDiagramEntity::GetRect() const /* ============================================================ Function : CDiagramEntity::GetRect Description : Returns the object rect. Return : CRect - The object rect. Parameters : none Usage : Call to get the object position and size. Will round of fractions. ============================================================*/ { CRect rect( ( int ) GetLeft(), ( int ) GetTop(), ( int ) GetRight(), ( int ) GetBottom() ); return rect; }
int main (){ Stack *S = (Stack *) malloc (sizeof (Stack)); InitStack(S); printf ("Push: a, b, c, d, e, f\nThe length:"); Push(S, 'a'); Push(S, 'b'); Push(S, 'c'); Push(S, 'd'); Push(S, 'e'); Push(S, 'f'); StackLength1(S); printf ("The top value is "); GetTop(S); printf ("---\nPop:\n"); for(int i = 0; i < 6; i++) Pop(S); return 0; }
int HorsePath(struct around start) { struct around curpos; int horsestep=0, off; struct zhan elem; int i; curpos = start; do{ i++; if(Pass(curpos)) { horsestep++; elem.di = 0; elem.ord = horsestep; elem.seat = curpos; Push(elem); if(N*N == horsestep) { printf("%d\n",i); return 1; } off = borad[elem.seat.x][elem.seat.y][elem.di]+1; curpos = NextPos(elem.seat, off); } else { if(s.top) { while(s.top && elem.di == 8){ Pop(&elem); if(s.top) { elem = GetTop(); horsestep = elem.ord; } } if(s.top && elem.di < 8) { Pop(&elem); off = borad[elem.seat.x][elem.seat.y][++elem.di]; curpos = NextPos(elem.seat, off+1); Push(elem); } } } }while(s.top != 0); printf("no way\n"); exit(0); }
void GuiArrowOption::SetOptionValue(int i, const char * text) { if(i < 0 || i >= (int) OptionsText.size()) return; int PositionY = OptionsText.at(i)->GetTop()-GetTop(); int Center = OptionsText.at(i)->GetLeft()+OptionsText.at(i)->GetTextWidth()/2-GetLeft(); OptionsText.at(i)->SetTextf(text); int textWidth = OptionsText.at(i)->GetTextWidth(); OptionsText.at(i)->SetPosition(Center-textWidth/2, PositionY); OptionsBtn.at(i)->SetSize(textWidth, 18); OptionsBtn.at(i)->SetPosition(Center-textWidth/2, PositionY); OptionsBtnLeft.at(i)->SetPosition(Center-textWidth/2-OptionsBtnLeft.at(i)->GetWidth()-10, PositionY); OptionsBtnRight.at(i)->SetPosition(Center+textWidth/2+10, PositionY); }
void GenTopEvent::Print() const{ std::cout << "top" << std::endl; PrintParticle(GetTop()); std::cout << "top decay quark" << std::endl; PrintParticle(GetTopDecayQuark()); std::cout << "higgs" << std::endl; PrintParticle(GetHiggs()); std::cout << "higgs decay products" << std::endl; PrintParticles(GetHiggsDecayProducts()); std::cout << "topbar" << std::endl; PrintParticle(GetTopBar()); std::cout << "topbar decay quark" << std::endl; PrintParticle(GetTopBarDecayQuark()); std::cout << "wplus" << std::endl; PrintParticle(GetWplus()); std::cout << "wplus decay products" << std::endl; PrintParticles(GetWplusDecayProducts()); std::cout << "wminus" << std::endl; PrintParticle(GetWminus()); std::cout << "wminus decay products" << std::endl; PrintParticles(GetWminusDecayProducts()); std::cout << "all top hads" << std::endl; PrintParticles(GetAllTopHads()); std::cout << "all W hads" << std::endl; PrintParticles(GetAllWhads()); std::cout << "all tophad bs" << std::endl; PrintParticles(GetAllTopHadDecayQuarks()); std::cout << "all tophad W quarks" << std::endl; PrintParticles(GetAllWQuarks()); std::cout << "all tophad W anti quarks" << std::endl; PrintParticles(GetAllWAntiQuarks()); std::cout << "all top leps" << std::endl; PrintParticles(GetAllTopLeps()); std::cout << "all w leps" << std::endl; PrintParticles(GetAllWleps()); std::cout << "all top lep bs" << std::endl; PrintParticles(GetAllTopLepDecayQuarks()); std::cout << "all leptons" << std::endl; PrintParticles(GetAllLeptons()); std::cout << "all neutrinos" << std::endl; PrintParticles(GetAllNeutrinos()); std::cout << "============================" << std::endl; }
void main() { int j; LinkStack s; SElemType e; if(InitStack(&s)) for(j=1;j<=5;j++) Push(s,2*j); printf("栈中的元素从栈底到栈顶依次为: "); StackTraverse(s,print); Pop(s,&e); printf("弹出的栈顶元素为%d\n",e); printf("栈空否: %d(1:空 0:否)\n",StackEmpty(s)); GetTop(s,&e); printf("当前栈顶元素为%d,栈的长度为%d\n",e,StackLength(s)); ClearStack(s); printf("清空栈后,栈空否: %d(1:空 0:否),栈的长度为%d\n",StackEmpty(s),StackLength(s)); printf("是否销毁栈了: %d(1:是 0:否)\n",DestroyStack(&s)); }
int main() { int j; LinkStack s; int e; if(InitStack(&s)==OK) for(j=1;j<=10;j++) Push(&s,j); printf("栈中元素依次为:"); StackTraverse(s); Pop(&s,&e); printf("弹出的栈顶元素 e=%d\n",e); printf("栈空否:%d(1:空 0:否)\n",StackEmpty(s)); GetTop(s,&e); printf("栈顶元素 e=%d 栈的长度为%d\n",e,StackLength(s)); ClearStack(&s); printf("清空栈后,栈空否:%d(1:空 0:否)\n",StackEmpty(s)); return 0; }
void rb_free(rb_node_t **root) { stack S=NULL; S=InitStack(S); rb_node_t *p=NULL; p = *root; Push(S, p); while(!StackEmpty(S)) { while(p){ if(p->lflag != 1 ) { p->lflag = 1; if(p->left){ Push(S, p->left); p = p->left; } }else if(p->rflag != 1 ) { p->rflag = 1; if(p->right){ Push(S, p->right); p = p->right; } } if(p->lflag == 1 && p->rflag == 1){ break; } } p = Pop(S); rb_node_free(&p); if(StackEmpty(S)) { break; } p = GetTop(S); } *root = NULL; Stack_destroy(&S, NULL); }
int PBImage::OnDraw(bool force) { if (IsVisible() && (IsChanged() || force)) { PBGraphics *graphics = GetGraphics(); if (m_Fill) graphics->FillArea(GetLeft(), GetTop(), GetWidth(), GetHeight(), m_Background); if (m_BW) { graphics->DrawBitmapRectBW(GetClientLeft(), GetClientTop(), GetClientWidth(), GetClientHeight(), GetBitmap(), GetProperties()); } else { graphics->DrawBitmapRect(GetClientLeft(), GetClientTop(), GetClientWidth(), GetClientHeight(), GetBitmap(), GetProperties()); } } return 0; }
/* 中序遍历二叉树T的非递归算法(利用栈),对每个数据元素调用函数Visit */ Status InOrderTraverse2(BiTree T,Status(*Visit)(TElemType)) { SqStack S; BiTree p; InitStack(&S); Push(&S, T); while (!StackEmpty(S)) { while (GetTop(S, &p) && p) Push(&S, p->lchild); Pop(&S, &p); if (!StackEmpty(S)) { Pop(&S, &p); if (!Visit(p->data)) return ERROR; Push(&S, p->rchild); } } return OK; }
void nsStyleSides::AppendToString(nsString& aBuffer) const { nsStyleCoord temp; GetLeft(temp); aBuffer.AppendLiteral("left: "); temp.AppendToString(aBuffer); GetTop(temp); aBuffer.AppendLiteral("top: "); temp.AppendToString(aBuffer); GetRight(temp); aBuffer.AppendLiteral("right: "); temp.AppendToString(aBuffer); GetBottom(temp); aBuffer.AppendLiteral("bottom: "); temp.AppendToString(aBuffer); }
main() { int i; int temp; int arr[8] = {49,38,65,97,76,13,27,49}; int pivotloc; SqStack sta;//初始化栈 InitStack(&sta); Data data={0,7}; Data get; Push(&sta,(Elem)data);//0,7进栈 while(EMPTY!=EmptyStack(&sta)) { GetTop(&sta,(pElem)(&get)); Pop(&sta); pivotloc = Partition(arr,get.low,get.high); temp = get.high; get.high = pivotloc-1; if(get.low<get.high) { Push(&sta,(Elem)get); } get.low = pivotloc+1; get.high = temp; if(get.low<get.high) { Push(&sta,(Elem)get); } } for(i=0;i<8;i++) { printf("%d ",arr[i]); } printf("\n"); }
int main() { int a; SqStack S; SElemType x, e; if(InitStack(S)) // 判断顺序表是否创建成功,请填空 { printf("A Stack Has Created.\n"); } while(1) { printf("1:Push \n2:Pop \n3:Get the Top \n4:Return the Length of the Stack\n5:Load the Stack\n0:Exit\nPlease choose:\n"); scanf("%d",&a); switch(a) { case 1: scanf("%d", &x); if(!Push(S,x)) printf("Push Error!\n"); // 判断Push是否合法,请填空 else printf("The Element %d is Successfully Pushed!\n", x); break; case 2: if(!Pop(S,e)) printf("Pop Error!\n"); // 判断Pop是否合法,请填空 else printf("The Element %d is Successfully Poped!\n", e); break; case 3: if(!GetTop(S,e))printf("Get Top Error!\n"); // 判断Get Top是否合法,请填空 else printf("The Top Element is %d!\n", e); break; case 4: printf("The Length of the Stack is %d!\n",StackLength(S)); //请填空 break; case 5: StackTraverse(S); //请填空 break; case 0: return 1; } } }