// Sets the text on the control //-------------------------------------------------------------------------------- void CPUTButton::SetText(const std::string String) { // Zero out the size and location InitializeState(); // create the static text object if it doesn't exist if(NULL == mpButtonText) { mpButtonText = CPUTText::Create(mpFont); } // set the Static control's text mpButtonText->SetText(String); // get the dimensions of the string in pixels CPUT_RECT rect; mpButtonText->GetDimensions(rect.width, rect.height); // resize this control to fix that string with padding Resize(rect.width, rect.height); // move the text to a nice inset location inside the 'safe' area // of the button image int x,y; GetInsetTextCoordinate(x, y); mpButtonText->SetPosition(x, y); }
// //-------------------------------------------------------------------------------- void CPUTButton::SetPosition(int x, int y) { m_ButtonDimensions.x = x; m_ButtonDimensions.y = y; // move the static text (if any) if(m_pButtonText) { int insetX, insetY; GetInsetTextCoordinate(insetX, insetY); m_pButtonText->SetPosition(insetX, insetY); } }
// Set the upper-left screen coordinate location of this control //-------------------------------------------------------------------------------- void CPUTButton::SetPosition(int x, int y) { // move the button graphics mButtonDimensions.x = x; mButtonDimensions.y = y; // move the static text (if any) if(mpButtonText) { // resize things in the buffers CPUT_RECT rect; mpButtonText->GetDimensions(rect.width, rect.height); Resize(rect.width, rect.height); int insetX, insetY; GetInsetTextCoordinate(insetX, insetY); mpButtonText->SetPosition(insetX, insetY); } }
// Sets the text on the control //-------------------------------------------------------------------------------- void CPUTButton::SetText(const cString String) { // Zero out the size and location InitializeState(); // create the static text object if it doesn't exist if(NULL == mpButtonText) { mpButtonText = new CPUTText(mpFont); } // set the Static control's text mpButtonText->SetText(String); // get the dimensions of the string in pixels CPUT_RECT rect; mpButtonText->GetDimensions(rect.width, rect.height); // resize this control to fix that string with padding Resize(rect.width, rect.height); // move the text to a nice inset location inside the 'safe' area // of the button image int x,y; GetInsetTextCoordinate(x, y); mpButtonText->SetPosition(x, y); // position or size may move - force a recalculation of this control's location // if it is managed by the auto-arrange function if(this->IsAutoArranged()) { mControlNeedsArrangmentResizing = true; } else { // otherwise, we mark this as dirty mControlGraphicsDirty = true; } }
// sets the dimensions of the button //-------------------------------------------------------------------------------- void CPUTButton::SetDimensions(int width, int height) { // Zero out the size and location InitializeState(); if(mControlAutoArranged) { // get the dimensions of the string in pixels CPUT_RECT rect; mpButtonText->GetDimensions(rect.width, rect.height); width = std::max(rect.width, width); height = std::max(rect.height, height); } // resize this control to fix that string with padding Resize(width, height); // move the text to a nice inset location inside the 'safe' area // of the button image int x,y; GetInsetTextCoordinate(x, y); mpButtonText->SetPosition(x, y); }
// //-------------------------------------------------------------------------------- void CPUTButton::SetText(const cString String) { // create the static text object if it doesn't exist if(NULL == m_pButtonText) { m_pButtonText = new CPUTStatic(); } m_pButtonText->SetText( String ); // get the dimensions of the string in pixels CPUT_RECT rect; m_pButtonText->GetDimensions(rect.width, rect.height); // resize this control to fix that string with padding Resize( rect.width, rect.height); // move the text to a nice inset location inside the 'safe' area // of the button image int x,y; GetInsetTextCoordinate(x, y); m_pButtonText->SetPosition(x, y); }