nsresult nsGfxButtonControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const { nsresult rv = NS_OK; if (nsGkAtoms::defaultLabel == aName) { // This property is used by accessibility to get // the default label of the button. nsXPIDLString temp; rv = GetDefaultLabel(temp); aValue = temp; } else { aValue.Truncate(); } return rv; }
nsresult nsGfxButtonControlFrame::GetLabel(nsXPIDLString& aLabel) { // Get the text from the "value" property on our content if there is // one; otherwise set it to a default value (localized). nsresult rv; nsCOMPtr<nsIDOMHTMLInputElement> elt = do_QueryInterface(mContent); if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::value) && elt) { rv = elt->GetValue(aLabel); } else { // Generate localized label. // We can't make any assumption as to what the default would be // because the value is localized for non-english platforms, thus // it might not be the string "Reset", "Submit Query", or "Browse..." rv = GetDefaultLabel(aLabel); } NS_ENSURE_SUCCESS(rv, rv); // Compress whitespace out of label if needed. if (!GetStyleText()->WhiteSpaceIsSignificant()) { aLabel.CompressWhitespace(); } else if (aLabel.Length() > 2 && aLabel.First() == ' ' && aLabel.CharAt(aLabel.Length() - 1) == ' ') { // This is a bit of a hack. The reason this is here is as follows: we now // have default padding on our buttons to make them non-ugly. // Unfortunately, IE-windows does not have such padding, so people will // stick values like " ok " (with the spaces) in the buttons in an attempt // to make them look decent. Unfortunately, if they do this the button // looks way too big in Mozilla. Worse yet, if they do this _and_ set a // fixed width for the button we run into trouble because our focus-rect // border/padding and outer border take up 10px of the horizontal button // space or so; the result is that the text is misaligned, even with the // recentering we do in nsHTMLButtonFrame::Reflow. So to solve this, even // if the whitespace is significant, single leading and trailing _spaces_ // (and not other whitespace) are removed. The proper solution, of // course, is to not have the focus rect painting taking up 6px of // horizontal space. We should do that instead (via XBL form controls or // changing the renderer) and remove this. aLabel.Cut(0, 1); aLabel.Truncate(aLabel.Length() - 1); } return NS_OK; }
void CGUIDialogBoxBase::OnInitWindow() { // set focus to default m_lastControlID = m_defaultControl; m_hasTextbox = false; const CGUIControl *control = GetControl(CONTROL_TEXTBOX); if (control && control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX) m_hasTextbox = true; // set initial labels { CSingleLock lock(m_section); for (int i = 0 ; i < DIALOG_MAX_CHOICES ; ++i) { if (m_strChoices[i].empty()) m_strChoices[i] = GetDefaultLabel(CONTROL_CHOICES_START + i); } } CGUIDialog::OnInitWindow(); }