void Trade::Impl::updateGoodsInfo() { if( !gbInfo ) return; Widget::Widgets children = gbInfo->children(); for( auto&& child : children ) { child->deleteLater(); } Point startDraw( 0, 5 ); Size btnSize( gbInfo->width(), 20 ); trade::Options& copt = city->tradeOptions(); int indexOffset=0; for( auto gtype : good::all() ) { trade::Order tradeState = copt.getOrder( gtype ); if( tradeState == trade::disabled || gtype == good::none) { continue; } bool workState = getWorkState( gtype ); int exportQty = copt.tradeLimit( trade::exporting, gtype ).ivalue(); int importQty = copt.tradeLimit( trade::importing, gtype ).ivalue(); TradeGoodInfo* btn = new TradeGoodInfo( gbInfo, Rect( startDraw + Point( 0, btnSize.height()) * indexOffset, btnSize ), gtype, allgoods[ gtype ], workState, tradeState, exportQty, importQty ); indexOffset++; CONNECT( btn, onClickedA(), this, Impl::showGoodOrderManageWindow ); } }
void Dialog::showEvent(QShowEvent *e) { if (!shown) { shown=true; QSize mwSize=mainWidget()->minimumSize(); if (mwSize.width()<16 || mwSize.height()<16) { mwSize=mainWidget()->minimumSizeHint(); } if (mwSize.width()>15 && mwSize.height()>15) { QSize btnSize(24, 32); for (int i=0; i<15; ++i) { int code=1<<i; KPushButton *btn=KDialog::button((KDialog::ButtonCode)code); if (btn) { btnSize=btn->sizeHint(); break; } } QLayout *lay=layout(); int sp=lay ? layout()->spacing() : KDialog::spacingHint(); int mar=lay ? layout()->margin() : KDialog::marginHint(); setMinimumHeight(qMax(minimumHeight(), btnSize.height()+sp+mwSize.height()+(2*mar))); setMinimumWidth(qMax(minimumWidth(), mwSize.width()+(2*mar))); } } KDialog::showEvent(e); }
PushButton* StartMenu::addButton( const std::string& caption, int id ) { Size btnSize( 200, 25 ); int offsetY = 40; PushButton* btn = new PushButton( this, Rect( Point( 0, 0 ), btnSize ), caption, id ); Point offsetBtn( ( getWidth() - btnSize.getWidth() ) / 2, ( getHeight() - offsetY * 3 ) / 2 ); List< PushButton* > buttons = findChildren< PushButton* >(); foreach( PushButton* btn, buttons ) { btn->setPosition( offsetBtn ); offsetBtn += Point( 0, offsetY ); }
void ofxGamepad::draw(int x, int y) { int curX=0; int highestY; ofPushMatrix(); ofTranslate(x, y); ofSetColor(255); ofPushMatrix(); ofRotate(90); ofDrawBitmapString(name+" ("+ofToString(id)+")", 0, 0); ofPopMatrix(); curX=17; int margin=3; ofRectangle axisSize(curX,0,85, 17); for(int i=0; i<getNumAxis(); i++) { ofSetColor(70); ofRect(axisSize); ofSetColor(255); float x = ofMap(getAxisValue(i), -1, 1, axisSize.x, axisSize.width+axisSize.x); ofLine(x, axisSize.y, x, axisSize.y+axisSize.height); ofSetColor(20); ofDrawBitmapString(ofToString(i), axisSize.x, axisSize.y+axisSize.height-1); axisSize.y+=axisSize.height+margin; if(axisSize.y>highestY) highestY=axisSize.y; } curX+=axisSize.width+margin; ofRectangle btnSize(curX,0,17,17); for(int i=0; i<getNumButtons(); i++) { if(getButtonValue(i)) ofSetColor(255); else ofSetColor(70); ofRect(btnSize); btnSize.y+=btnSize.height+margin; ofSetColor(20); ofDrawBitmapString(ofToString(i), btnSize.x, btnSize.y-4); if(btnSize.y>highestY) highestY=axisSize.y; } curX+=btnSize.width; ofPopMatrix(); drawSize.x=curX; drawSize.y=highestY; }
PushButton* StartMenu::addButton( const std::string& caption, int id ) { Size btnSize( 200, 25 ); int offsetY = 40; PushButton* btn = new PushButton( this, Rect( Point( 0, 0 ), btnSize ), caption, id ); Point offsetBtn( ( getWidth() - btnSize.getWidth() ) / 2, ( getHeight() - offsetY * 3 ) / 2 ); List< PushButton* > buttons = findChildren< PushButton* >(); for( List< PushButton* >::iterator it=buttons.begin(); it != buttons.end(); it++ ) { (*it)->setPosition( offsetBtn ); offsetBtn += Point( 0, offsetY ); } return btn; }
CRect SourceWindow::PaintEdge(CDC& dcPaint, int y, int w, CDibSection* image, bool top) { // Create a bitmap to draw into CDC dc; dc.CreateCompatibleDC(&dcPaint); CDibSection bitmap; CSize sz = image->GetSize(); if (bitmap.CreateBitmap(dc.GetSafeHdc(),w,sz.cy) == FALSE) return CRect(0,0,0,0); bitmap.FillSolid(::GetSysColor(COLOR_BTNFACE)); // Draw the torn edge int x = 0; while (x < w) { bitmap.AlphaBlend(image,x,0); x += sz.cx; } // Draw the arrow button CDibSection* btn = theApp.GetCachedImage("TearArrow"); CRect btnRect(CPoint(w/2,sz.cy/2),CSize(0,0)); CSize btnSize(btn->GetSize()); btnRect.InflateRect(btnSize.cx/2,btnSize.cy/2); bitmap.AlphaBlend(btn,btnRect.left,btnRect.top,!top); // Copy the bitmap to the device context CBitmap* oldBitmap = CDibSection::SelectDibSection(dc,&bitmap); dcPaint.BitBlt(0,y,w,sz.cy,&dc,0,0,SRCCOPY); dc.SelectObject(oldBitmap); // Return a rectangle around the arrow button btnRect.InflateRect(btnSize.cx/2,btnSize.cy/2); btnRect.OffsetRect(0,y); return btnRect; }