bool C4Video::RecordFrame() { // No buffer if (!Buffer) return false; // Lock source int iPitch,iWidth,iHeight; if (!Surface->Lock()) { Log("Video: lock surface failure"); Stop(); return false; } iPitch = Surface->PrimarySurfaceLockPitch; BYTE *bypBits = Surface->PrimarySurfaceLockBits; iWidth = Surface->Wdt; iHeight = Surface->Hgt; // Adjust source position if (!AdjustPosition()) { Log("Video: player/viewport failure"); Stop(); return false; } // Blit screen to buffer StdBlit((uint8_t*)bypBits,iPitch,-iHeight, X,Y,Width,Height, (uint8_t*)Buffer+InfoSize, DWordAligned(Width) * (Config.Graphics.BitDepth/8),Height, 0,0,Width,Height, Config.Graphics.BitDepth/8); // Unlock source Surface->Unlock(); // Write frame to file if (!AVIPutFrame(pAviStream, AviFrame, Buffer,InfoSize, Buffer+InfoSize,BufferSize-InfoSize)) { Log("AVIPutFrame failure"); Stop(); return false; } // Advance frame AviFrame++; // Show flash ShowFlash=1; // Success return true; }
//------------------------------------------------------- //音量的初始化 //------------------------------------------------------- void CVolumeButton::Init(UINT nBkgndID,CString strTipText) { m_nBkgndID=nBkgndID; m_ToolTip.UpdateTipText(strTipText,this,ID_TIP); m_nPos=0; AdjustPosition(); }
void CInfo::AddString( const char* pszTxt, DWORD color, HNODE hFont, UINT uFormat ) { if( pszTxt == NULL ) { Clear(); return; } SIZE sizeString = getFontTextExtent( hFont, pszTxt ); m_iHeight += 18;//sizeString.cy + 5; if( m_iWidth < sizeString.cx + 5) m_iWidth = sizeString.cx + 5; if( strlen( pszTxt ) > m_uMaxSizeString ) m_uMaxSizeString = strlen( pszTxt ); CTString String; String.SetColor( color ); String.SetString( pszTxt ); String.SetFormat( uFormat ); String.SetFont( hFont ); m_listString.push_back( String ); AdjustPosition(); }
void CImageDialogTools::Show( bool bShow ) { m_bIsShowing = bShow; if ( m_bIsShowing ) m_pbShowHideButton.SetWindowText( "<<" ); else m_pbShowHideButton.SetWindowText( ">>" ); AdjustPosition(); }
/* ----------------------------------------------------------------- Subclassed WndProc of Controler Dialog ----------------------------------------------------------------- */ static LRESULT CALLBACK SubclassDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_TIMER: if (bControlerEnable) { AdjustPosition(hwnd); CheckPlaying(); } SetTimer(hwnd, wParam, 100, NULL); break; case WM_APP: if (iControlerRequest & (1 << CR_SHOW)) { AdjustPosition(hwnd); ControlerPlayState(hwnd); SendDlgItemMessage(hwnd, IDC_NEZSONGSPIN, UDM_SETRANGE, 0, MAKELONG(num_songs,1)); SetControler(hwnd, cur_song); iControlerRequest &= ~((1 << CR_SHOW) | (1 << CR_UPDATE)); ShowWindow(hwnd, SW_SHOWNA); } if (iControlerRequest & (1 << CR_UPDATE)) { ControlerPlayState(hwnd); SendDlgItemMessage(hwnd, IDC_NEZSONGSPIN, UDM_SETRANGE, 0, MAKELONG(num_songs,1)); SetControler(hwnd, cur_song); iControlerRequest &= ~(1 << CR_UPDATE); } if (iControlerRequest & (1 << CR_HIDE)) { ShowWindow(hwnd, SW_HIDE); iControlerRequest &= ~(1 << CR_HIDE); } break; case WM_DESTROY: { return CallWindowProc(wpOrigDialogProc, hwnd, uMsg, wParam, lParam); } break; } return CallWindowProc(wpOrigDialogProc, hwnd, uMsg, wParam, lParam); }
void C4Video::Resize(int iChange) { // Not while recording if (Recording) return; // Resize Width = BoundBy( Width+iChange, 56, 800 ); Height = BoundBy( (int) ((double)Width/AspectRatio), 40, 600 ); // Adjust position AdjustPosition(); // Show flash ShowFlash=50; }
// Mimi Enermy_Mimi::Enermy_Mimi(GameWorld *pgw, int x_value, int y_value) :Enermy(pgw, x_value, y_value) { sx=41; sy=0; w=33; h=28; cx=7; cy=4; cw=20; ch=21; Life = 2; dy=5; BulletType=Bullet::ENERMY_BULLET_2; SetLastFireTime(); AdjustPosition(); }
// Jack Enermy_Jack::Enermy_Jack(GameWorld *pgw, int x_value, int y_value) :Enermy(pgw, x_value, y_value) { sx=74; sy=0; w=43; h=42; cx=12; cy=5; cw=19; ch=25; Life = 5; dy=3; BulletType=Bullet::ENERMY_BULLET_3; SetLastFireTime(); AdjustPosition(); }
// Tom Enermy_Tom::Enermy_Tom(GameWorld *pgw, int x_value, int y_value) :Enermy(pgw, x_value, y_value) { sx=0; sy=33; w=62; h=50; cx=16; cy=12; cw=31; ch=29; Life = 8; dy=2; Direction=DIR_FORWARD; BulletType=Bullet::ENERMY_BULLET_1; SetLastFireTime(); AdjustPosition(); }
bool C4Menu::SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls) { // Not active if (!IsActive()) return false; // Outside Limits / Selectable C4MenuItem *pNewSel = GetItem(iSelection); if ((iSelection==-1 && !ItemCount) || (pNewSel && pNewSel->IsSelectable)) { // Selection change if (iSelection!=Selection) { // calls C4MenuItem *pSel = GetSelectedItem(); if (pSel) pSel->SetSelected(false); // Set selection Selection=iSelection; // Reset time on selection TimeOnSelection=0; } // always recheck selection for internal refill C4MenuItem *pSel = GetSelectedItem(); if (pSel) pSel->SetSelected(true); // set main caption by selection if (Style == C4MN_Style_Normal) { if (pSel) SetTitle(*(pSel->Caption) ? pSel->Caption : " ", HasMouse()); else SetTitle(*Caption ? Caption : " ", HasMouse()); } } // adjust position, if desired if (fAdjustPosition) AdjustPosition(); // do selection callback if (fDoCalls) OnSelectionChanged(Selection); // Done return true; }
void CDPlot::GenPixelMatrix(CDGeometry &cGeometry) { if (m_nPlotType == 2) // Box { #ifdef _VTK_FILE m_vtkData = vtkDoubleArray::New(); m_vtkData->SetNumberOfTuples(m_nPixel_1*m_nPixel_2*m_nPixel_3); #else // resize pixel data for voxel format m_vPixelData3D.resize(m_nPixel_1*m_nPixel_2*m_nPixel_3); #endif int nMat, nCell; int nPixIndex, nPixValue; for(int n1 = 0; n1 < m_nPixel_1; n1++) { for(int n2 = 0; n2 < m_nPixel_2; n2++) { for(int n3 = 0; n3 < m_nPixel_3; n3++) { CDVector3 OVertex_temp = m_OVertex1; OVertex_temp.MoveDistance(m_ODir1, (n1 + 0.5)*m_dDeltaWidth1); //move to current voxel OVertex_temp.MoveDistance(m_ODir2, (n2 + 0.5)*m_dDeltaWidth2); // OVertex_temp.MoveDistance(m_ODir3, (n3 + 0.5)*m_dDeltaWidth3); // GetMatbyLocatePos(cGeometry, OVertex_temp, nMat, nCell); nPixIndex = n3*m_nPixel_2*m_nPixel_1 + n2*m_nPixel_1 + n1; if (m_nColorType == CELL) { nPixValue = nCell; } else { nPixValue = nMat; } #ifdef _VTK_FILE m_vtkData->SetValue(nPixIndex, nPixValue); #else m_vPixelData3D[nPixIndex] = nPixValue; #endif } } } return; } // Slice //Set PixelMatrix m_vPixelMatrix2D.resize(m_nPixel_2); for (int i = 0; i < m_vPixelMatrix2D.size(); i++) { m_vPixelMatrix2D[i].resize(m_nPixel_1); } //// *** STEP 1: Tracking particle by line in width direction, generate PixelMatrix, some pixels are skipped *** /// vector<int> vOneLinePixels; vOneLinePixels.resize(m_nPixel_1); for (int j_height = 0; j_height < m_nPixel_2; j_height++) { //Set pos of first point in new line CDVector3 cVexTemp = m_OVertex1; cVexTemp.MoveDistance(m_ODir1, m_dDeltaWidth1/2.0); cVexTemp.MoveDistance(m_ODir2, j_height*m_dDeltaWidth2 + m_dDeltaWidth2/2.0); //check first line: adjust vertexes of image( to output) if (j_height == 0) { int nAdjust = AdjustPosition(cGeometry, cVexTemp, m_ODir1);// adjust position in surface normal direction if (nAdjust > 0)// adjust success { m_OVertex1 = cVexTemp;//VexTemp is the position already adjusted m_OVertex1.MoveDistance(m_ODir1, -m_dDeltaWidth1/2.0); m_OVertex1.MoveDistance(m_ODir2, -m_dDeltaWidth2/2.0); m_OVertex2 = m_OVertex1 + m_ODir1; m_OVertex3 = m_OVertex2 + m_ODir2; Output.OutputMessage([&](){sprintf(Output.p_sPrintStr," ");}, Output.p_fpOutputFilePtr, CDOutput::_NORMAL); Output.OutputMessage([&](){sprintf(Output.p_sPrintStr," Vertexes are adjusted, to be not on a surface defined in Geometry.");}, Output.p_fpOutputFilePtr, CDOutput::_WARNING); } else if (nAdjust < 0)// adjust failed { Output.OutputMessage([&](){sprintf(Output.p_sPrintStr," ");}, Output.p_fpOutputFilePtr, CDOutput::_NORMAL); Output.OutputMessage([&](){sprintf(Output.p_sPrintStr," Vertexes are on a surface defined in Geometry and adjust failed.\n");}, Output.p_fpOutputFilePtr, CDOutput::_ERROR); } } //check points on surf or not bool bOnSurf = CheckOnSurf(cGeometry, cVexTemp, m_ODir1); //not on surf, flying this line if (!bOnSurf) { FlyOneLine(cGeometry, cVexTemp, m_ODir1, m_dDeltaWidth1,m_nColorType, vOneLinePixels, m_bIsLowResolution); } //on surf, use previous line m_vPixelMatrix2D[j_height] = vOneLinePixels; } if (m_bIsLowResolution ) { Output.OutputMessage([&](){sprintf(Output.p_sPrintStr," ");}, Output.p_fpOutputFilePtr, CDOutput::_NORMAL); Output.OutputMessage([&](){sprintf(Output.p_sPrintStr," Image resolution for PlotID: %d is low for some surfaces.\n",m_nPlotID);}, Output.p_fpOutputFilePtr, CDOutput::_WARNING); } // *** STEP 2: for MAT / CELL color case, auto-completion of the skipped pixels *** // if (m_nColorType != SURF) { for (int j = 0; j < m_nPixel_2; j++) { if (m_vPixelMatrix2D[j][0] < 0) { Output.OutputMessage([&](){sprintf(Output.p_sPrintStr,"cannot locating left point of line %d . Check if the up-left vertex is on a surface.\n",j);}, Output.p_fpOutputFilePtr, CDOutput::_ERROR); } for (int i = 1; i < m_nPixel_1; i++) { if(m_vPixelMatrix2D[j][i] < 0) m_vPixelMatrix2D[j][i] = m_vPixelMatrix2D[j][i-1]; } } } // for Surf shown case: scan in Height direction if (m_nColorType == SURF || m_nColorType == MAT_SURF || m_nColorType == CELL_SURF) { vOneLinePixels.resize(m_nPixel_2); for (int i_width = 0; i_width < m_nPixel_1; i_width++) { //Set pos of first point in new line CDVector3 cVexTemp = m_OVertex1; cVexTemp.MoveDistance(m_ODir2, m_dDeltaWidth2/2.0); cVexTemp.MoveDistance(m_ODir1, i_width*m_dDeltaWidth1 + m_dDeltaWidth1/2.0); //check points on surf or not bool bOnSurf = CheckOnSurf(cGeometry, cVexTemp, m_ODir2); //not on surf, flying this line if (!bOnSurf) { FlyOneLine(cGeometry, cVexTemp, m_ODir2, m_dDeltaWidth2,m_nColorType, vOneLinePixels, m_bIsLowResolution); } //Set surface value to pixel matrix for (int j = 0; j < m_nPixel_2; j++) { if (vOneLinePixels[j] == 0) { m_vPixelMatrix2D[j][i_width] = 0; } } } } return; }
void CInfo::SetPosition( POINT pt ) { m_ptPosition = pt; AdjustPosition(); }
BOOL TableClass::Layout (struct LayoutMessage &lmsg) { if(Flags & FLG_AllElementsPresent) { FindImage(lmsg); if(!(Flags & FLG_AllocatedColours)) AllocateColours(lmsg.Share->Scr->ViewPort.ColorMap); if(lmsg.Y != lmsg.MinY || !lmsg.IsAtNewline()) lmsg.AddYSpace(4); lmsg.EnsureNewline(); Top = lmsg.Y; Left = lmsg.X; lmsg.TopChange = min(Top, lmsg.TopChange); if(!(Flags & FLG_KnowsMinMax)) { struct MinMaxMessage mmsg(lmsg.Share->Fonts, &lmsg); mmsg.Reset(); MinMax(mmsg); } ULONG scr_width = lmsg.ScrWidth() - (Columns+1)*Spacing - 2*BorderSize; if(GivenWidth) { if(GivenWidth->Type == Size_Percent) Width = max(Min, ((lmsg.ScrWidth() * GivenWidth->Size) / 100) - (Columns+1)*Spacing - 2*BorderSize); else Width = max(GivenWidth->Size-(Columns+1)*Spacing-2*BorderSize, Min); } else Width = (Min <= scr_width) ? min(scr_width, Max) : Min; /* Set all cells to their min or max width */ LONG scale = Width, table_delta = 0, relative = 0; for(ULONG i = 0; i < Columns; i++) { if(!Widths[i].Percent) { LONG cellwidth = Width >= Max ? Widths[i].Max : Widths[i].Min; table_delta += Widths[i].Max - Widths[i].Min; scale -= cellwidth; relative += Widths[i].Relative; Widths[i].Width = cellwidth; } } /* Set all cells with a width given in percent */ for(ULONG i = 0; i < Columns; i++) { if(Widths[i].Percent) { ULONG cellwidth = max(Widths[i].Min, min((ULONG)scale, (Width * Widths[i].Percent) / 100)); Widths[i].Width = cellwidth; scale -= cellwidth; } } if(scale > 0) { if(relative) { Spread(scale, relative, RelativeScale); } else if(table_delta) { Spread(scale, table_delta, NormalScale); } else { LONG width = Max; for(UWORD i = 0; i < Columns; i++) { if(Widths[i].Fixed) width -= Widths[i].Max; } if(width) Spread(scale, width, LeftOverScale); else Width -= scale; } } else { Width -= scale; } struct CellWidth *oldwidths = lmsg.Widths; ULONG oldspace = lmsg.Spacing, oldpad = lmsg.Padding; struct TextFont *oldfont = lmsg.Font; ULONG oldcols = lmsg.Columns, oldimageleftindent = lmsg.ImageLeftIndent, oldimagerightindent = lmsg.ImageRightIndent; lmsg.ImageLeftIndent = lmsg.ImageRightIndent = 0; struct FloadingImage *fleft = lmsg.FLeft, *fright = lmsg.FRight; lmsg.FLeft = lmsg.FRight = NULL; lmsg.Widths = Widths; lmsg.Spacing = Spacing; lmsg.Padding = Padding + (BorderSize ? 1 : 0); lmsg.Columns = Columns; ULONG oldminx = lmsg.MinX; lmsg.MinX = lmsg.X += BorderSize; lmsg.AddYSpace(Spacing+BorderSize); Flags &= ~FLG_Virgin; ULONG *oldopencounts = lmsg.RowOpenCounts; lmsg.RowOpenCounts = (ULONG *)memset(RowOpenCounts, 0, Columns * sizeof(ULONG)); ULONG *oldheights = lmsg.Heights; ULONG pass = lmsg.Pass; lmsg.Pass = 0; lmsg.Heights = (ULONG *)memset(Heights, 0, Rows*sizeof(ULONG)); ULONG realrows = 0; struct ChildsList *first = FirstChild; while(first) { ((class TRClass *)first->Obj)->TRLayout(lmsg); first = first->Next; realrows++; } /* Should some cell set a rowspan that ends outside the table, then we enlarge all height entries */ while(realrows < Rows) { Heights[realrows] = max(Heights[realrows], Heights[realrows-1]); realrows++; } Bottom = Rows ? Heights[Rows-1] : lmsg.Y; lmsg.Y = Bottom + Spacing; lmsg.Pass = 1; lmsg.Heights = Heights; first = FirstChild; while(first) { ((class TRClass *)first->Obj)->TRLayout(lmsg); first = first->Next; } lmsg.Pass = pass; lmsg.Heights = oldheights; lmsg.RowOpenCounts = oldopencounts; lmsg.MinX = oldminx; lmsg.AddYSpace(BorderSize); lmsg.Widths = oldwidths; lmsg.Columns = oldcols; lmsg.Spacing = oldspace; lmsg.Padding = oldpad; lmsg.FLeft = fleft; lmsg.FRight = fright; lmsg.ImageLeftIndent = oldimageleftindent; lmsg.ImageRightIndent = oldimagerightindent; lmsg.X += oldimageleftindent; lmsg.Font = oldfont; lmsg.Width = max((ULONG)lmsg.Width, lmsg.MinX+Width+((Columns+1)*Spacing)+2*BorderSize+lmsg.MarginWidth+lmsg.ImageRightIndent); Bottom = lmsg.Y-1; lmsg.AddYSpace(4); LONG width = Width+((Columns+1)*Spacing)+2*BorderSize; LONG delta = lmsg.ScrWidth() - width; UBYTE oldalign = lmsg.Align; if(delta > 0) { LONG offset = 0; if(Alignment == Align_Left || Alignment == Align_Right) { LONG width = Width + (Columns+1)*Spacing + 2*BorderSize; struct FloadingImage *img = new (std::nothrow) struct FloadingImage(Top, Left, width, (Bottom-Top)+1, this, lmsg.Parent); if (img) { LONG left = lmsg.AddImage(img, Alignment == Align_Right); offset = left - Left; } lmsg.Y = Top; lmsg.Baseline = lmsg.Bottom = 0; } else if(lmsg.Align == Align_Center || Alignment == Align_Center) { offset = delta/2; } else if(lmsg.Align == Align_Right) { offset = delta; } if(offset) AdjustPosition(offset, 0); } lmsg.Align = oldalign; if(Alignment != Align_Left && Alignment != Align_Right) lmsg.CheckFloatingObjects(); Flags |= FLG_Layouted; } else { lmsg.TopChange = min(lmsg.TopChange, MAX_HEIGHT); } return TRUE; }
void PhysicsObject::SetPosition(Vec2 v){ AdjustPosition(v - Pos); Pos = v; }
void BhvGoalie::Execute(){ // bhvDrible.Execute(); // SetHeadMode(HEAD_TRACK); // return; if(savingflag){ SaveMotion(); return; } /* if(GaitMaker::IsStop()){ int x,y; scanf("%d",&x); scanf("%d",&y); int walk = dpmla.get_action(x,y,0); printf("%d\n",walk); SetPresetWalk(walk); } */ /* SetHeadMode(HEAD_TRACK_KP); Saving(); return; */ if(mode != RETURN_GOALMOUTH) gmcnt = 0; switch(mode){ case GO_BACK: GoBack(); break; case RETURN_GOALAREA: SetFaceLED(FACE_ONE); SetTailMode(TAIL_STOP); ReturnToGoalArea(); break; case ADJUST_POSITION: SetFaceLED(FACE_TWO); SetTailMode(TAIL_ANGRY); AdjustPosition(); break; case WAIT: SetFaceLED(FACE_THREE); SetTailMode(TAIL_SWING); Wait(); break; case CHASE: SetFaceLED(FACE_FOUR); // OSYSPRINT(("%.1f\n",state.ball.distance)); ChaseBall(); SetTailMode(TAIL_ANGRY); break; case CLEAR: SetFaceLED(FACE_FIVE); Clear(); SetTailMode(TAIL_STOP); break; case RETURN_GOALMOUTH: ReturnGoalMouth(); break; } }
void PhysicsObject::AdjustPosition(double x,double y){ Vec2 v(x,y); AdjustPosition(v); }
void C4Menu::InitLocation(C4Facet &cgoArea) { // Item size by style switch (Style) { case C4MN_Style_Normal: ItemWidth=ItemHeight=C4SymbolSize; break; case C4MN_Style_Context: { ItemHeight = std::max<int32_t>(C4MN_SymbolSize, ::GraphicsResource.FontRegular.GetLineHeight()); int32_t iWdt, iHgt; ::GraphicsResource.FontRegular.GetTextExtent(Caption, ItemWidth, iHgt, true); // FIXME: Blah. This stuff should be calculated correctly by pTitle. ItemWidth += ItemHeight + 16; C4MenuItem *pItem; for (int i = 0; (pItem = GetItem(i)); ++i) { ::GraphicsResource.FontRegular.GetTextExtent(pItem->Caption, iWdt, iHgt, true); ItemWidth = std::max(ItemWidth, iWdt + pItem->GetSymbolWidth(ItemHeight)); } ItemWidth += 3; // Add some extra space so text doesn't touch right border frame... break; } case C4MN_Style_Info: { // calculate size from a default size determined by a window width of C4MN_DefInfoWdt int32_t iWdt,iHgt,iLargestTextWdt; ::GraphicsResource.FontRegular.GetTextExtent(Caption,iWdt,iHgt, true); iLargestTextWdt = iWdt + 2 * C4MN_SymbolSize + C4MN_FrameWidth; ItemWidth=std::min<int>(cgoArea.Wdt - 2*C4MN_FrameWidth, std::max(iLargestTextWdt, C4MN_DefInfoWdt)); ItemHeight=0; StdStrBuf sText; C4MenuItem *pItem; for (int32_t i=0; (pItem=GetItem(i)); ++i) { ::GraphicsResource.FontRegular.BreakMessage(pItem->InfoCaption, ItemWidth, &sText, true); ::GraphicsResource.FontRegular.GetTextExtent(sText.getData(),iWdt,iHgt, true); assert(iWdt <= ItemWidth); ItemWidth=std::max(ItemWidth,iWdt); ItemHeight=std::max(ItemHeight,iHgt); iLargestTextWdt = std::max(iLargestTextWdt, iWdt); } // although width calculation is done from C4MN_DefInfoWdt, this may be too large for some very tiny info windows // so make sure no space is wasted ItemWidth = std::min(ItemWidth, iLargestTextWdt); // Add some extra space so text doesn't touch right border frame... ItemWidth += 3; // Now add some space to show the picture on the left ItemWidth += C4PictureSize; // And set a minimum item height (again, for the picture) ItemHeight = std::max<int>(ItemHeight, C4PictureSize); break; } case C4MN_Style_Dialog: { // dialog window: Item width is whole dialog, portrait subtracted if any // Item height varies int32_t iWdt,iHgt; ::GraphicsResource.FontRegular.GetTextExtent(Caption,iWdt,iHgt, true); ItemWidth=std::min<int>(cgoArea.Wdt - 2*C4MN_FrameWidth, std::max<int>(iWdt + 2 * C4MN_SymbolSize + C4MN_FrameWidth, C4MN_DlgWdt)); ItemHeight=iHgt; // Items may be multiline and higher if (HasPortrait()) { // subtract portrait only if this would not make the dialog too small if (ItemWidth > C4MN_DlgPortraitWdt*2 && cgoArea.Hgt > cgoArea.Wdt) ItemWidth = std::max<int>(ItemWidth - C4MN_DlgPortraitWdt - C4MN_DlgPortraitIndent, 40); } } } int DisplayedItemCount = ItemCount - HasPortrait(); if (Style == C4MN_Style_Dialog) Lines = C4MN_DlgLines; else Lines = DisplayedItemCount/Columns+std::min<int32_t>(DisplayedItemCount%Columns,1); // adjust by max. height Lines=std::max<int32_t>(std::min<int32_t>((cgoArea.Hgt-100)/std::max<int32_t>(ItemHeight,1),Lines),1); InitSize(); int32_t X,Y; if (Alignment & C4MN_Align_Free) { X = rcBounds.x; Y = rcBounds.y; } else { X = (cgoArea.Wdt - rcBounds.Wdt)/2; Y = (cgoArea.Hgt - rcBounds.Hgt)/2; } // Alignment if (Alignment & C4MN_Align_Left) X=C4SymbolSize; if (Alignment & C4MN_Align_Right) X=cgoArea.Wdt-2*C4SymbolSize-rcBounds.Wdt; if (Alignment & C4MN_Align_Top) Y=C4SymbolSize; if (Alignment & C4MN_Align_Bottom) Y=cgoArea.Hgt-C4SymbolSize-rcBounds.Hgt; if (Alignment & C4MN_Align_Free) { X=Clamp<int32_t>(X,0,cgoArea.Wdt-rcBounds.Wdt); Y=Clamp<int32_t>(Y,0,cgoArea.Hgt-rcBounds.Hgt); } // Centered (due to small viewport size) if (rcBounds.Wdt>cgoArea.Wdt-2*C4SymbolSize) X=(cgoArea.Wdt-rcBounds.Wdt)/2; if (rcBounds.Hgt>cgoArea.Hgt-2*C4SymbolSize) Y=(cgoArea.Hgt-rcBounds.Hgt)/2; SetPos(X, Y); // Position initialized: Make it visible to be used! SetVisibility(true); // now align all menu items correctly UpdateElementPositions(); // and correct scroll pos UpdateScrollBar(); AdjustPosition(); }
// ----------------------------------------------------------------------------- // Relocate // // ----------------------------------------------------------------------------- // void CAknInfoPopupNote::Relocate() { if ( !iFloatingPositionUsed ) { return; } TRect rect( Rect() ); TPoint delta( 0, 0 ); switch (iAlignment) { case EHLeftVTop: { // Tooltip is left and top aligned. break; } case EHLeftVCenter: { // Tooltip left aligned and centred vertically. delta.iY = rect.Height() / 2; break; } case EHLeftVBottom: { // Tooltip is left aligned and at the bottom. delta.iY = rect.Height(); break; } case EHCenterVTop: { // Tooltip is centre aligned horizontally and at the top. delta.iX = rect.Width() / 2; break; } case EHCenterVCenter: { // Tooltip is centred horizontally and vertically. delta.SetXY( rect.Width() / 2, rect.Height() / 2 ); break; } case EHCenterVBottom: { // Tooltip is centred horizontally and at the bottom. delta.SetXY( rect.Width() / 2, rect.Height() ); break; } case EHRightVTop: { // Tooltip is right and top aligned. delta.iX = rect.Width(); break; } case EHRightVCenter: { // Tooltip right aligned and centred vertically. delta.SetXY( rect.Width(), rect.Height() / 2 ); break; } case EHRightVBottom: { // Tooltip is right aligned and at the bottom. delta.SetXY( rect.Width(), rect.Height() ); break; } default: { break; } } AdjustPosition( TPoint( iFloatingPosition - delta ) ); if ( iFloatingPosition != iPosition ) { SetPosition( iFloatingPosition ); } }