UINT CCheckTreeView::CalcParentCheckState (HTREEITEM hItem) { _ASSERTE(m_fUsePartialCheckMarks); UINT uiCurrState = GetCheckState(hItem); if (TV_CHECK_NOMARK == uiCurrState || TV_CHECK_PASSIVE == uiCurrState) return uiCurrState; // hat nichts anzuhaken // jetzt alle Childs durchgehen, um unseren CheckState zu berechnen HTREEITEM hChildItem = NULL; if (TVI_ROOT == hItem) hChildItem = GetNextItem (NULL, TVGN_CHILD); else hChildItem = GetChildItem (hItem); UINT uiMinState = TV_CHECK_ON; UINT uiMaxState = TV_CHECK_NOMARK; while (NULL != hChildItem) { UINT uiState = GetCheckState(hChildItem); switch (uiState) { case TV_CHECK_NOMARK: case TV_CHECK_PASSIVE: break; // do not bother case TV_CHECK_OFF: if (TV_CHECK_ON != uiMaxState && TV_CHECK_PARTIAL_ON != uiMaxState) uiMaxState = uiState; uiMinState = uiState; break; case TV_CHECK_PARTIAL_ON: if (TV_CHECK_ON != uiMaxState) uiMaxState = uiState; if (TV_CHECK_OFF != uiMinState) uiMinState = uiState; break; case TV_CHECK_ON: uiMaxState = uiState; if (TV_CHECK_OFF != uiMinState && TV_CHECK_PARTIAL_ON != uiMinState) uiMinState = uiState; break; default: _ASSERTE(FALSE); break; } hChildItem = GetNextItem (hChildItem, TVGN_NEXT); } return (uiMinState == uiMaxState) ? uiMinState : TV_CHECK_PARTIAL_ON; }
void CheckBox::MouseClick() { if (! CanAutoChangeCheckState()) { return; } CheckState new_check_state = CheckState::Unchecked; switch (GetCheckState()) { case CheckState::Unchecked: new_check_state = CheckState::Checked; break; case CheckState::Checked: new_check_state = CanBeIndeterminate() ? CheckState::Indeterminate : CheckState::Unchecked; break; case CheckState::Indeterminate: new_check_state = CheckState::Unchecked; break; default: ZAF_FAIL(); break; } SetCheckState(new_check_state); }
void CheckBox::SetCanBeIndeterminate(bool can_be_ndeterminate) { GetPropertyMap().SetProperty(kCanBeIndeterminatePropertyName, can_be_ndeterminate); if (! can_be_ndeterminate && (GetCheckState() == CheckState::Indeterminate)) { SetCheckState(CheckState::Checked); } }
void CPropTreeItemCheck::OnActivate( int activateType, CPoint point ) { if( activateType == CPropTreeItem::ACTIVATE_TYPE_MOUSE ) { //Check where the user clicked if( point.x < m_rc.left + CHECK_BOX_SIZE ) { SetCheckState( !GetCheckState() ); CommitChanges(); } else { SetWindowPos( NULL, m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(), SWP_NOZORDER | SWP_SHOWWINDOW ); SetFocus(); } } else { SetWindowPos( NULL, m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(), SWP_NOZORDER | SWP_SHOWWINDOW ); SetFocus(); } }
LRESULT CTreeView::OnClick(NMHDR* pnmh) { // Q261289 DWORD dwpos = GetMessagePos(); CPoint pt(GET_X_LPARAM(dwpos), GET_Y_LPARAM(dwpos)); ScreenToClient(&pt); UINT flags = 0; HTREEITEM hItem = HitTest(pt, &flags); if (flags & TVHT_ONITEMSTATEICON) { m_pMainFrame->EnQueue([this, hItem]() { CheckTreeItem(hItem, GetCheckState(hItem) != FALSE); }); } return 0; }
void CheckBox::PaintBox(Canvas& canvas, const Rect& box_rect) const { //Paint the box. canvas.SetBrushWithColor(GetBoxBackgroundColor()); canvas.DrawRectangle(box_rect); canvas.SetBrushWithColor(GetBoxBorderColor()); canvas.DrawRectangleFrame(box_rect, 1); //Paint the check state mark. auto check_state = GetCheckState(); if (check_state == CheckState::Indeterminate) { Rect mark_rect = box_rect; mark_rect.Inflate(-3); canvas.DrawRectangle(mark_rect); } else if (check_state == CheckState::Checked) { auto path = GetResourceFactory()->CreatePathGeometry(); if (path == nullptr) { return; } auto sink = path->Open(); if (sink == nullptr) { return; } Rect mark_rect = box_rect; mark_rect.Inflate(-2); Point start_point(mark_rect.position.x + mark_rect.size.width, mark_rect.position.y); Point middle_point(mark_rect.position.x + mark_rect.size.width * 0.4f, mark_rect.position.y + mark_rect.size.height - 1); Point end_point(mark_rect.position.x, mark_rect.position.y + mark_rect.size.height * 0.4f); sink->BeginFigure(start_point, GeometrySink::BeginFigureOption::Hollow); sink->AddLine(middle_point); sink->AddLine(end_point); sink->EndFigure(GeometrySink::EndFigureOption::Open); sink->Close(); canvas.DrawGeometryFrame(path, 1.5); } }
void CTreeView::UncheckTreeItem(HTREEITEM hItem) { SetCheckState(hItem, false); HTREEITEM hParent = GetParentItem(hItem); if (hParent == nullptr) return; HTREEITEM hChild = GetChildItem(hParent); bool allUnchecked = true; while (hChild) { if (GetCheckState(hChild) != FALSE) allUnchecked = false; hChild = GetNextSiblingItem(hChild); } if (allUnchecked) UncheckTreeItem(hParent); }
void CCheckTreeView::SetCheckState (HTREEITEM hItem, UINT uiState, bool fPropagateUp, bool fPropagateDown) { if (!m_fUseCheckMarks) return; TV_ITEM tvi; tvi.hItem = hItem; tvi.mask = TVIF_STATE; tvi.state = uiState; tvi.stateMask = TVIS_STATEIMAGEMASK; SetItem (&tvi); // ggf. die Änderung nach oben/unten propagieren if (m_fUsePartialCheckMarks) { HTREEITEM hParent = GetParentItem(hItem); if (fPropagateUp && (TVI_ROOT != hParent && NULL != hParent)) { UINT uiOldState = GetCheckState(hParent); UINT uiNewState = CalcParentCheckState(hParent); if (uiOldState != uiNewState) SetCheckState(hParent, uiNewState, true, false); // eine Etage hoch, aber nicht wieder runter } // wenns eindeutig ist, dann alle drunter liegenden auch umschalten if (fPropagateDown && (TV_CHECK_ON == uiState || TV_CHECK_OFF == uiState)) { HTREEITEM hChildItem = NULL; if (TVI_ROOT == hItem) hChildItem = GetNextItem (NULL, TVGN_CHILD); else hChildItem = GetChildItem (hItem); while (NULL != hChildItem) { SetCheckState (hChildItem, uiState, false, true); // nicht wieder nach oben propagieren hChildItem = GetNextItem (hChildItem, TVGN_NEXT); } } } }
void CCheckTreeView::HandleCheckMark(Point point, UINT uiMsg) { Rectangle rc = CanvasRect(); CoOrd dY = rc.Top()-rc.Bottom(); TV_HITTESTINFO ht; ht.pt.x = point.X(); ht.pt.y = dY-point.Y(); HTREEITEM hNewTarget = HitTest (&ht); if (hNewTarget && (ht.flags & TVHT_ONITEMSTATEICON)) { UINT uiState = ChangingCheckState (hNewTarget, uiMsg); if (TV_CHECK_NOCHANGE != uiState) { if (TV_CHECK_NOMARK != uiState) SetCheckState (hNewTarget, uiState); else ToggleCheckMark (hNewTarget); NotifyChecked (hNewTarget, uiMsg, GetCheckState(hNewTarget)); } } }
LPARAM CPropTreeItemCheck::GetItemValue() { return ( LPARAM )GetCheckState(); }
static uintptr_t OnConfigureControl( CONTROL_NAME )( uintptr_t psv, PSI_CONTROL parent_frame ) { PSLIDER_INFO info = (PSLIDER_INFO)psv; { PSI_CONTROL frame = NULL; int okay = 0; int done = 0; if( !frame ) { frame = LoadXMLFrame( "seek_slider_properties.frame" ); if( frame ) { TEXTCHAR buffer[256]; SetCommonButtonControls( frame ); SetCheckState( GetControl( frame, CHECKBOX_HORIZONTAL ), info->flags.bHorizontal ); SetCheckState( GetControl( frame, CHECKBOX_DRAGGING ), info->flags.bDragging ); SetControlText( GetControl( frame, EDIT_BACKGROUND_IMAGE ), info->image_name ); snprintf(buffer, sizeof(buffer), "%d", info->min); SetControlText( GetControl( frame, EDIT_MIN ), buffer ); snprintf(buffer, sizeof(buffer), "%d", info->max); SetControlText( GetControl( frame, EDIT_MAX ), buffer ); snprintf(buffer, sizeof(buffer), "%d", info->current); SetControlText( GetControl( frame, EDIT_CURRENT ), buffer ); SetCommonButtons( frame, &done, &okay ); DisplayFrameOver( frame, parent_frame ); CommonWait( frame ); if( okay ) { GetCommonButtonControls( frame ); info->font = InterShell_GetCurrentButtonFont(); if( info->font ) SetCommonFont( info->control, (*info->font ) ); info->color = GetColorFromWell( GetControl( frame, CLR_TEXT_COLOR ) ); info->backcolor = GetColorFromWell( GetControl( frame, CLR_BACKGROUND ) ); { GetControlText( GetControl( frame, EDIT_BACKGROUND_IMAGE ), buffer, sizeof( buffer ) ); if( info->image_name ) Release( info->image_name ); info->image_name = StrDup( buffer ); } // SetSliderColor( info->control, info->color ); // SetSliderkBackColor( info->control, info->backcolor ); info->flags.bHorizontal = GetCheckState( GetControl( frame, CHECKBOX_HORIZONTAL ) ); info->flags.bDragging = GetCheckState( GetControl( frame, CHECKBOX_DRAGGING ) ); GetControlText( GetControl( frame, EDIT_MIN), buffer, sizeof( buffer ) ); info->min = atoi(buffer); GetControlText( GetControl( frame, EDIT_MAX), buffer, sizeof( buffer ) ); info->max = atoi(buffer); GetControlText( GetControl( frame, EDIT_CURRENT), buffer, sizeof( buffer ) ); info->current = atoi(buffer); } DestroyFrame( &frame ); } } } return psv; }