void FGStandardComboBox::openPopUpCtrl() { if (popUpCtrl) { //find the soundfx manager Sfx::Manager *sfx = Sfx::Manager::find(manager); if (sfx) sfx->play(stringTable.insert("Button5.wav"), 0, &base2dSfxProfile); // set up the data for the pop up ctrl StandardListCtrl *plCtrl = (StandardListCtrl*)getArrayCtrl(); AssertFatal(plCtrl, "pop up control is missing a text list"); plCtrl->onWake(); Point2I globalPos = localToGlobalCoord(Point2I(0,0)); popUpCtrl->setPos(globalPos.x - 1, globalPos.y + extent.y - 1); SimGui::ArrayCtrl *ac = popUpCtrl->getArrayCtrl(); if (ac) { popUpCtrl->setDim(extent.x + 2, ac->extent.y, 240); } else { popUpCtrl->setDim(extent.x + 2, 240, 240); } root->pushDialogControl(popUpCtrl); root->tabNext(); popUpActive = true; root->mouseLock(popUpCtrl); updateFromArrayCtrl(); } }
void TestButton::onRender(GFXSurface *sfc, Point2I offset, const Box2I &updateRect) { GFXFont *useFont = (stateOver) ? hFontHL : hFont; Int32 backColor = 249; Int32 insideBorderColor = (root->getFirstResponder() == this) ? 245 : 255; Int32 outsideBorderColor = 249; if (useFont) { Int32 txt_w = useFont->getStrWidth(text); Point2I localStart; // align the horizontal switch (alignment) { case RightJustify: localStart.x = extent.x - txt_w; break; case CenterJustify: localStart.x = (extent.x - txt_w) / 2; break; default: // LeftJustify localStart.x = 0; } // center the vertical localStart.y = (extent.y - useFont->getHeight()) / 2; // first draw the background RectI r(offset.x, offset.y, offset.x + extent.x - 1, offset.y + extent.y - 1); r.upperL+=2; r.lowerR-=2; sfc->drawRect2d_f(&r, backColor); // draw the inside border r.upperL-=1; r.lowerR+=1; drawBorder(sfc, r, insideBorderColor); // draw the oustside border r.upperL-=1; r.lowerR+=1; drawBorder(sfc, r, outsideBorderColor); // finally draw the text localStart.y += textVPosDelta; if (stateDepressed) localStart+=1; Point2I globalStart = localToGlobalCoord(localStart); sfc->drawText_p(useFont, &globalStart, text); } renderChildControls(sfc, offset, updateRect); }
void GuiPopupMenuTextListCtrl::onCellHighlighted(Point2I cell) { // If this text list control is part of a submenu, then don't worry about // passing this along if (!isSubMenu) { RectI globalbounds(getBounds()); Point2I globalpoint = localToGlobalCoord(globalbounds.point); globalbounds.point = globalpoint; } }
void GuiSplitContainer::onRender( Point2I offset, const RectI &updateRect ) { Parent::onRender( offset, updateRect ); // Only render if we're dragging the splitter if ( mDragging && mSplitRect.isValidRect() ) { // Splitter Rectangle (will adjust positioning only) RectI splitterRect = mSplitRect; // Currently being dragged to Rect Point2I splitterPoint = localToGlobalCoord( mSplitRect.point ); splitterRect.point = localToGlobalCoord( mSplitPoint ); RectI clientRect = getClientRect(); clientRect.point = localToGlobalCoord( clientRect.point ); if ( mOrientation == Horizontal ) { splitterRect.point.y -= mSplitterSize; splitterRect.point.x = splitterPoint.x; } else { splitterRect.point.x -= mSplitterSize; splitterRect.point.y = splitterPoint.y; } RectI oldClip = GFX->getClipRect(); GFX->setClipRect( clientRect ); GFX->getDrawUtil()->drawRectFill( splitterRect, mProfile->mFillColorHL ); GFX->setClipRect( oldClip ); } else { RectI splitterRect = mSplitRect; splitterRect.point += offset; GFX->getDrawUtil()->drawRectFill( splitterRect, mProfile->mFillColor ); } }
void GuiTheoraCtrl::onRender(Point2I offset, const RectI &updateRect) { if( mDone && mIsLooping ) mTheoraTexture.play(); const RectI rect(offset, getBounds().extent); if( mTheoraTexture.isReady() ) { mTheoraTexture.refresh(); if( mTheoraTexture.isPlaying() || mTheoraTexture.isPaused() ) { // Draw the frame. GFXDrawUtil* drawUtil = GFX->getDrawUtil(); drawUtil->clearBitmapModulation(); drawUtil->drawBitmapStretch( mTheoraTexture.getTexture(), rect ); // Draw frame info, if requested. if( mRenderDebugInfo ) { String info = String::ToString( "Frame Number: %i | Frame Time: %.2fs | Playback Time: %.2fs | Dropped: %i", mTheoraTexture.getFrameNumber(), mTheoraTexture.getFrameTime(), F32( mTheoraTexture.getPosition() ) / 1000.f, mTheoraTexture.getNumDroppedFrames() ); drawUtil->setBitmapModulation( mProfile->mFontColors[ 0 ] ); drawUtil->drawText( mProfile->mFont, localToGlobalCoord( Point2I( 0, 0 ) ), info, mProfile->mFontColors ); } } else mDone = true; } else GFX->getDrawUtil()->drawRectFill(rect, mBackgroundColor); // black rect renderChildControls(offset, updateRect); }
S32 GuiTextEditCtrl::calculateCursorPos( const Point2I &globalPos ) { Point2I ctrlOffset = localToGlobalCoord( Point2I( 0, 0 ) ); S32 charLength = 0; S32 curX; curX = globalPos.x - ctrlOffset.x; setUpdate(); //if the cursor is too far to the left if ( curX < 0 ) return -1; //if the cursor is too far to the right if ( curX >= ctrlOffset.x + getExtent().x ) return -2; curX = globalPos.x - mTextOffset.x; S32 count=0; if(mTextBuffer.length() == 0) return 0; for(count=0; count<mTextBuffer.length(); count++) { UTF16 c = mTextBuffer.getChar(count); if(!mPasswordText && !mProfile->mFont->isValidChar(c)) continue; if(mPasswordText) charLength += mProfile->mFont->getCharXIncrement( mPasswordMask[0] ); else charLength += mProfile->mFont->getCharXIncrement( c ); if ( charLength > curX ) break; } return count; }