// /// Set the three-state property. // void TCheckListItem::SetThreeStates(bool hasThreeStates) { if (IsEnabled()){ HasThreeStates = hasThreeStates; if (IsIndeterminate() && !hasThreeStates) Check(); } }
double HTMLProgressElement::Position() const { if (IsIndeterminate()) { return kIndeterminatePosition; } return Value() / Max(); }
//------------------------------------------------------------ NS_IMETHODIMP nsGfxCheckboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { nsresult rv = nsFormControlFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists); NS_ENSURE_SUCCESS(rv, rv); // Get current checked state through content model. if ((!IsChecked() && !IsIndeterminate()) || !IsVisibleForPainting(aBuilder)) return NS_OK; // we're not checked or not visible, nothing to paint. if (IsThemed()) return NS_OK; // No need to paint the checkmark. The theme will do it. return aLists.Content()->AppendNewToTop(new (aBuilder) nsDisplayGeneric(aBuilder, this, IsIndeterminate() ? PaintIndeterminateMark : PaintCheckMark, "CheckedCheckbox", nsDisplayItem::TYPE_CHECKED_CHECKBOX)); }
// /// Toggle the state of the item. /// If the item has three states, the cycle goes from /// unchecked -> checked -> indeterminate -> back to unchecked. /// Otherwise the state toggles between /// unchecked and checked. // void TCheckListItem::Toggle() { if (!IsEnabled()) return; if (HasThreeStates) { if (IsIndeterminate()) Uncheck(); else if (IsChecked()) SetIndeterminate(); else Check(); } else { if (IsChecked()) Uncheck(); else Check(); } }