COptionTreeItem * COptionTree::FocusLast() { // Declare variables COptionTreeItem* otiNext; COptionTreeItem* otiChange; // Set pointers otiChange = m_otiFocus; otiNext = m_otiVisibleList; // Set focu on last if (otiNext != NULL) { while (otiNext->GetNextVisible()) { otiNext = otiNext->GetNextVisible(); } SetFocusedItem(otiNext); if (m_otiFocus != NULL) { SelectItems(NULL, FALSE); m_otiFocus->Select(); } } // Send notify to user if (otiChange != m_otiFocus) { SendNotify(OT_NOTIFY_SELCHANGE, m_otiFocus); } return otiNext; }
void COptionTree::AddToVisibleList(COptionTreeItem *otiItem) { // Declare variables COptionTreeItem *otiNext; // Make sure item is not NULL if (!otiItem) { return; } // Check for an empty visible list if (!m_otiVisibleList) { m_otiVisibleList = otiItem; } else { // -- Add the new item to the end of the list otiNext = m_otiVisibleList; while (otiNext->GetNextVisible()) { otiNext = otiNext->GetNextVisible(); } otiNext->SetNextVisible(otiItem); } // Set next visible otiItem->SetNextVisible(NULL); }
BOOL COptionTree::EnumItems(COptionTreeItem* otiItem, ENUM_OPTIONITEMPROC enumProc, LPARAM lParam) { // Declare variables COptionTreeItem* otiNext; BOOL bRet = TRUE; // Validate items if (!otiItem || !enumProc) { return FALSE; } // Don't count the root item in any enumerations if (otiItem != &m_otiRoot && !enumProc(this, otiItem, lParam)) { return FALSE; } // Recurse thru all child items otiNext = otiItem->GetChild(); while (otiNext != NULL) { if (!EnumItems(otiNext, enumProc, lParam)) { bRet = FALSE; } otiNext = otiNext->GetSibling(); } return bRet; }
void COptionTree::EnsureVisible(COptionTreeItem *otiItem) { // Declare variables COptionTreeItem* otiParent; CRect rcClient; CPoint ptPoint; long lOY; // Make sure valid if (otiItem == NULL) { return; } // Item is not scroll visible (expand all parents) if (IsItemVisible(otiItem) == FALSE) { otiParent = otiItem->GetParent(); while (otiParent != NULL) { otiParent->Expand(); otiParent = otiParent->GetParent(); } UpdatedItems(); UpdateWindow(); } // Item should be visible if (IsItemVisible(otiItem) == FALSE) { return; } // Calculate list client rectangle m_otlList.GetClientRect(rcClient); rcClient.OffsetRect(0, m_ptOrigin.y); rcClient.bottom -= otiItem->GetHeight(); // Get item location ptPoint = otiItem->GetLocation(); //when the item is at the end will get a bug ,so avoid it ptPoint.y -= 2; if (!rcClient.PtInRect(ptPoint)) { if (ptPoint.y < rcClient.top) { lOY = ptPoint.y; } else { lOY = ptPoint.y - rcClient.Height() + otiItem->GetHeight(); } m_otlList.OnVScroll(SB_THUMBTRACK, lOY, NULL); } }
COptionTreeItem * COptionTree::InsertItem(COptionTreeItem *otiItem, COptionTreeItem *otiParent) { // Declare variables COptionTreeItem* otiNext; // Make sure item is not NULL if (otiItem == NULL) { return NULL; } // If parent is NULL, becomes root if (otiParent == NULL) { otiParent = &m_otiRoot; } // Set child if (otiParent->GetChild() == NULL) { otiParent->SetChild(otiItem); } else { // -- Add to end of the sibling list otiNext = otiParent->GetChild(); while (otiNext->GetSibling() != NULL) { otiNext = otiNext->GetSibling(); } otiNext->SetSibling(otiItem); } // Auto generate a default ID m_uLastUID++; otiItem->SetCtrlID(m_uLastUID); // Set item information otiItem->SetParent(otiParent); otiItem->SetOptionsOwner(this); // Send notification to user SendNotify(OT_NOTIFY_INSERTITEM, otiItem); //// Updated items //UpdatedItems(); //// Force redraw //Invalidate(); //// Update window //UpdateWindow(); return otiItem; }
COptionTreeItem * COptionTree::FocusPrev() { // Declare variables COptionTreeItem* otiNext; COptionTreeItem* otiChange; // Set pointers otiChange = m_otiFocus; // Get the last visible item if (m_otiFocus == NULL) { otiNext = m_otiVisibleList; while (otiNext && otiNext->GetNextVisible()) { otiNext = otiNext->GetNextVisible(); } } else { otiNext = m_otiVisibleList; while (otiNext && otiNext->GetNextVisible() != m_otiFocus) { otiNext = otiNext->GetNextVisible(); } } // Set focus items if (otiNext) { SetFocusedItem(otiNext); } // Select items if (m_otiFocus != NULL) { SelectItems(NULL, FALSE); m_otiFocus->Select(); } // Send notify to user if (otiChange != m_otiFocus) { SendNotify(OT_NOTIFY_SELCHANGE, m_otiFocus); } return otiNext; }
BOOL CALLBACK COptionTree::EnumGetLargestVisibleLabelRect(COptionTree* otProp, COptionTreeItem* otiItem, LPARAM lParam) { // Declare variables COptionTreeItem *otParent; // Validate items if (otiItem == NULL) { return FALSE; } // Make sure not root if (otiItem->IsRootLevel()) { return TRUE; } // Get parent otParent = otiItem->GetParent(); // Validate parent if (otParent == NULL) { return TRUE; } if (otParent->IsExpanded() == FALSE) { return TRUE; } // Declare variables CRect rcRect; // Get lable rect rcRect = otiItem->GetLabelRect(); // See if label right is greater if (rcRect.right > m_rcLargestLabel.right) { m_rcLargestLabel = rcRect; } return TRUE; }
void COptionTreeList::CheckVisibleFocus() { // Declare variables COptionTreeItem *otiItem; // Validate option if (m_otOption == NULL) { return; } // Get focused item otiItem = m_otOption->GetFocusedItem(); if (otiItem == NULL) { return; } // See if item is visible if (!m_otOption->IsItemVisible(otiItem)) { // -- Single select if (m_otOption->IsSingleSelection()) { otiItem->Select(FALSE); } // -- Set focus m_otOption->SetFocusedItem(NULL); // -- Send notify to user m_otOption->SendNotify(OT_NOTIFY_SELCHANGE, NULL); // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); } }
BOOL COptionTree::IsItemVisible(COptionTreeItem *otiItem) { // Declare varibles COptionTreeItem *otiNext = NULL; // Make sure item is valid if (otiItem == NULL) { return FALSE; } // Search fr visible for (otiNext = m_otiVisibleList; otiNext; otiNext = otiNext->GetNextVisible()) { if (otiNext == otiItem) { return TRUE; } } return FALSE; }
long COptionTree::HitTest(const POINT &pt) { // Declare variables COptionTreeItem* otiItem; POINT ptPoint = pt; CRect rcLabel; // Convert screen to tree coordinates ptPoint.y += m_ptOrigin.y; // Run the hit test if ((otiItem = FindItem(pt)) != NULL) { // -- Column if (!otiItem->IsRootLevel() && pt.x >= m_ptOrigin.x - OT_COLRNG && pt.x <= m_ptOrigin.x + OT_COLRNG) { return OT_HIT_COLUMN; } // -- Attribute if (pt.x > m_ptOrigin.x + OT_COLRNG) { return OT_HIT_ATTRIBUTE; } // -- Expand if (otiItem->HitExpand(ptPoint)) { return OT_HIT_EXPAND; } // -- Label return OT_HIT_LABEL; } // -- Client return OT_HIT_CLIENT; }
COptionTreeItem* COptionTree::FindItem(const POINT& pt) { // Delcare variables COptionTreeItem* otiItem; CPoint ptPoint = pt; CPoint ptLoc; // Convert screen to tree coordinates ptPoint.y += m_ptOrigin.y; // Search the visible list for the item for (otiItem = m_otiVisibleList; otiItem; otiItem = otiItem->GetNextVisible()) { // -- Get item location ptLoc = otiItem->GetLocation(); if (ptPoint.y >= ptLoc.y && ptPoint.y < ptLoc.y + otiItem->GetHeight()) { return otiItem; } } return NULL; }
void COptionTreeList::OnLButtonDown(UINT nFlags, CPoint point) { // Validate option if (m_otOption == NULL) { CWnd::OnLButtonDown(nFlags, point); return; } // See if disabled if (m_otOption->IsDisableInput() || !m_otOption->IsWindowEnabled()) { CWnd::OnLButtonDown(nFlags, point); return; } // Send notify to user m_otOption->SendNotify(NM_CLICK); // Declare variables long lHit; COptionTreeItem *otiItem; COptionTreeItem *oliOldFocus; CRect rcClient; // Get client rectangle GetClientRect(rcClient); // Set focus to window SetFocus(); // Hit test lHit = m_otOption->HitTest(point); switch (lHit) { case OT_HIT_COLUMN: if (m_otOption->SendNotify(OT_NOTIFY_COLUMNCLICK)) { break; } // -- Set capture m_bColDrag = TRUE; SetCapture(); m_lColumn = m_otOption->GetOrigin().x; // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); break; case OT_HIT_EXPAND: if ((otiItem = m_otOption->FindItem(point)) != NULL) { if (otiItem->GetChild() && !m_otOption->SendNotify(OT_NOTIFY_ITEMEXPANDING, otiItem)) { // -- Expand otiItem->Expand(!otiItem->IsExpanded()); // -- Update resize UpdateResize(); // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); // -- Check visible CheckVisibleFocus(); } } break; default: if ((otiItem = m_otOption->FindItem(point)) != NULL) { // -- Get old focus oliOldFocus = m_otOption->GetFocusedItem(); // -- Select items m_otOption->SelectItems(NULL, FALSE); // -- Select otiItem->Select(); // -- Make sure new item if (otiItem != oliOldFocus) { m_otOption->SendNotify(OT_NOTIFY_SELCHANGE, otiItem); } // -- Send notify if (lHit == OT_HIT_ATTRIBUTE && !otiItem->IsRootLevel()) { if (!m_otOption->SendNotify(OT_NOTIFY_PROPCLICK, otiItem) && !otiItem->IsReadOnly()) { otiItem->Activate(); } } // -- Set focus item m_otOption->SetFocusedItem(otiItem); // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); } else { // -- Select items m_otOption->SelectItems(NULL, FALSE); // -- Set focus item m_otOption->SetFocusedItem(NULL); // -- Send notify m_otOption->SendNotify(OT_NOTIFY_SELCHANGE); // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); } break; } CWnd::OnLButtonDown(nFlags, point); }
void COptionTreeList::OnPaint() { // Make sure valid if (m_otOption == NULL) { return; } // Declare variables CPaintDC dc(this); CDC* pDCMem = new CDC; CBitmap bpMem; CBitmap *bmOld; COptionTreeItem* otiItem; CRect rcClient; HGDIOBJ hOldBrush; long lTotal, lHeight; HRGN hRgn; // Get client rectangle GetClientRect(rcClient); // Clear visible list m_otOption->ClearVisibleList(); // Clear all label rectangle m_otOption->ClearAllLabelRect(); // Create DC pDCMem->CreateCompatibleDC(&dc); // Create bitmap bpMem.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height()); // Select bitmap bmOld = pDCMem->SelectObject(&bpMem); // Draw control background hOldBrush = pDCMem->SelectObject(GetSysColorBrush(COLOR_BTNFACE)); pDCMem->PatBlt(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), PATCOPY); // Draw control inside fill color rcClient.DeflateRect(2, 2); if (m_otOption->IsWindowEnabled() == TRUE) { pDCMem->SelectObject(GetSysColorBrush(COLOR_WINDOW)); } else { pDCMem->SelectObject(GetSysColorBrush(COLOR_3DFACE)); } pDCMem->PatBlt(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), PATCOPY); rcClient.InflateRect(2, 2); // Draw expand column if (m_otOption->GetShadeExpandColumn() == TRUE || m_otOption->IsWindowEnabled() == FALSE) { pDCMem->SelectObject(GetSysColorBrush(COLOR_BTNFACE)); } else { pDCMem->SelectObject(GetSysColorBrush(COLOR_WINDOW)); } pDCMem->PatBlt(0, 0, OT_EXPANDCOLUMN, rcClient.Height(), PATCOPY); // Create clip region hRgn = CreateRectRgn(rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); SelectClipRgn(pDCMem->m_hDC, hRgn); // Draw all items lTotal = 0; for (otiItem = m_otOption->GetRootItem()->GetChild(); otiItem != NULL; otiItem = otiItem->GetSibling()) { lHeight = otiItem->DrawItem(pDCMem, rcClient, 0, lTotal); lTotal += lHeight; } // Remove clip region SelectClipRgn(pDCMem->GetSafeHdc(), NULL); DeleteObject(hRgn); // Draw vertical sep _DrawDarkVLine(pDCMem->GetSafeHdc(), OT_EXPANDCOLUMN, 0, rcClient.bottom); // Draw edge pDCMem->DrawEdge(&rcClient, BDR_SUNKENOUTER, BF_RECT); // Draw draw column if (m_bColDrag == TRUE) { _DrawXorBar(pDCMem->GetSafeHdc(), m_lColumn - OT_COLRNG / 2, 0, 4, rcClient.bottom); } // Copy back buffer to the display dc.BitBlt(0, 0, rcClient.Width(), rcClient.Height(), pDCMem, 0, 0, SRCCOPY); // Select old objects pDCMem->SelectObject(hOldBrush); pDCMem->SelectObject(bmOld); // Delete objects if (pDCMem->GetSafeHdc() != NULL) { pDCMem->DeleteDC(); } delete pDCMem; if (bpMem.GetSafeHandle() != NULL) { bpMem.DeleteObject(); } }
void COptionTree::Delete(COptionTreeItem *otiItem) { // Declare variables COptionTreeItem* otiIter; COptionTreeItem* otiNext; // Clear visible list ClearVisibleList(); // Send notify to user SendNotify(OT_NOTIFY_DELETEITEM, otiItem); // Passing in a NULL deletes frm root if (otiItem == NULL) { otiItem = &m_otiRoot; } // Delete children otiIter = otiItem->GetChild(); while (otiIter != NULL) { // -- Get sibling otiNext = otiIter->GetSibling(); // -- Delete DeleteItem(otiIter); // -- Get next otiIter = otiNext; } // Unlink from tree if (otiItem->GetParent() != NULL) { if (otiItem->GetParent()->GetChild() == otiItem) { otiItem->GetParent()->SetChild(otiItem->GetSibling()); } else { otiIter = otiItem->GetParent()->GetChild(); while (otiIter->GetSibling() && otiIter->GetSibling() != otiItem) { otiIter = otiIter->GetSibling(); } if (otiIter->GetSibling()) { otiIter->SetSibling(otiItem->GetSibling()); } } } // Delete item if (otiItem != &m_otiRoot) { if (otiItem == GetFocusedItem()) { SetFocusedItem(NULL); } otiItem->CleanDestroyWindow(); delete otiItem; } }
BOOL CReportLabelProperties::OnInitDialog() { CDialog::OnInitDialog(); COptionTreeItem *otiRoot = NULL; COptionTreeItem *otiItem = NULL; CRect rcClient; DWORD dwStyle, dwOptions; LOGFONT lfFont, lfDefaultFont; // Get log fonts GetFont()->GetLogFont(&lfFont); GetFont()->GetLogFont(&lfDefaultFont); //strcpy(lfDefaultFont.lfFaceName, _T("Arial"));#OBSOLETE strcpy_s(lfDefaultFont.lfFaceName,sizeof(lfDefaultFont.lfFaceName), _T("Arial")); // Get the clients rectangle GetClientRect(rcClient); // Setup the window style dwStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Setup the tree options // OT_OPTIONS_SHOWINFOWINDOW dwOptions = OT_OPTIONS_SHADEEXPANDCOLUMN | OT_OPTIONS_SHADEROOTITEMS | OT_OPTIONS_SHOWINFOWINDOW; int trBot=rcClient.bottom; if (GetDlgItem(IDOK)) { CRect rrrr; GetDlgItem(IDOK)->GetWindowRect(rrrr); ScreenToClient(rrrr); trBot = rrrr.top -4; } // Create tree options CRect trR = rcClient; trR.bottom = trBot; if (m_otTree.Create(dwStyle, trR, this, dwOptions, 1004) == FALSE) { TRACE0("Failed to create options control.\r\n"); return FALSE; } // Want to be notified m_otTree.SetNotify(TRUE, this); CString resStr; // -- Edit Items otiRoot = m_otTree.InsertItem(new COptionTreeItem()); resStr.LoadString(IDS_REP_LAB); otiRoot->SetLabelText(resStr); resStr.LoadString(IDS_REP_FULL_LAB); otiRoot->SetInfoText(resStr); CClientDC dc( this ); int inch = dc.GetDeviceCaps( LOGPIXELSX ); double pt = static_cast< double >( inch ) / 72; m_otiFont = (COptionTreeItemFont*)m_otTree.InsertItem(new COptionTreeItemFont(), otiRoot); resStr.LoadString(IDS_REP_LAB_FONT); m_otiFont->SetLabelText(resStr); resStr.LoadString(IDS_REP_LAB_FULL_FONT); m_otiFont->SetInfoText(resStr); if (m_otiFont->CreateFontItem(&m_lf,pt)) { m_otiFont->SetColor(m_color); } m_text_edit = (COptionTreeItemEdit*) m_otTree.InsertItem(new COptionTreeItemEdit(), otiRoot); resStr.LoadString(IDS_REP_LAB); m_text_edit->SetLabelText(resStr); m_text_edit->SetInfoText(resStr); if (m_text_edit->CreateEditItem(/*OT_EDIT_MULTILINE*/NULL, ES_WANTRETURN | ES_AUTOVSCROLL | ES_AUTOHSCROLL) == TRUE) { m_text_edit->SetWindowText(_T("Label")); } m_otiAngle_radio = (COptionTreeItemRadio*)m_otTree.InsertItem(new COptionTreeItemRadio(), otiRoot); resStr.LoadString(IDS_REPORT_TEXT_ANG); m_otiAngle_radio->SetLabelText(resStr); resStr.LoadString(IDS_REPORT_FULL_TEXT_ANG); m_otiAngle_radio->SetInfoText(resStr); if (m_otiAngle_radio->CreateRadioItem() == TRUE) { resStr.LoadString(IDS_REPORT_0_ANG); m_otiAngle_radio->InsertNewRadio(resStr, FALSE); resStr.LoadString(IDS_REPORT_90_ANG); m_otiAngle_radio->InsertNewRadio(resStr, FALSE); resStr.LoadString(IDS_REPORT_M90_ANG); m_otiAngle_radio->InsertNewRadio(resStr, FALSE); resStr.LoadString(IDS_REPORT_180_ANG); m_otiAngle_radio->InsertNewRadio(resStr, FALSE); } m_otiAlign_radio = (COptionTreeItemRadio*)m_otTree.InsertItem(new COptionTreeItemRadio(), otiRoot); resStr.LoadString(IDS_REP_LAB_ALIGN); m_otiAlign_radio->SetLabelText(resStr); resStr.LoadString(IDS_REP_LAB_FULL_ALIGN); m_otiAlign_radio->SetInfoText(resStr); if (m_otiAlign_radio->CreateRadioItem() == TRUE) { resStr.LoadString(IDS_REP_LAB_ALIGN_L); m_otiAlign_radio->InsertNewRadio(resStr, FALSE); resStr.LoadString(IDS_REP_LAB_ALIGN_C); m_otiAlign_radio->InsertNewRadio(resStr, FALSE); resStr.LoadString(IDS_REP_LAB_ALIGN_R); m_otiAlign_radio->InsertNewRadio(resStr, FALSE); } otiRoot->Expand(); otiRoot = m_otTree.InsertItem(new COptionTreeItem()); resStr.LoadString(IDS_REP_PR_DL_FRAME); otiRoot->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_FRAME); otiRoot->SetInfoText(resStr); CString yesS; yesS.LoadString(IDS_YES); CString noS; noS.LoadString(IDS_NO); m_otiExistLeft = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_LEFT); m_otiExistLeft->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_LEFT); m_otiExistLeft->SetInfoText(resStr); if (m_otiExistLeft->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_LEFT, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistLeft->SetCheckText(yesS, noS); } m_otiExistRight = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_RIGHT); m_otiExistRight->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_RIGHT); m_otiExistRight->SetInfoText(resStr); if (m_otiExistRight->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_RIGHT, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistRight->SetCheckText(yesS, noS); } m_otiExistTop = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_TOP); m_otiExistTop->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_TOP); m_otiExistTop->SetInfoText(resStr); if (m_otiExistTop->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_TOP, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistTop->SetCheckText(yesS, noS); } m_otiExistBottom = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_BOTTOM); m_otiExistBottom->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_BOTTOM); m_otiExistBottom->SetInfoText(resStr); if (m_otiExistBottom->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_BOTTOM, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistBottom->SetCheckText(yesS, noS); } m_otiFrameColorCombo = (COptionTreeItemColorComboBox*)m_otTree.InsertItem(new COptionTreeItemColorComboBox(), otiRoot); resStr.LoadString(IDS_PER_PR_DL_COL_FR); m_otiFrameColorCombo->SetLabelText(resStr); resStr.LoadString(IDS_PER_PR_DL_FULL_COL_FR); m_otiFrameColorCombo->SetInfoText(resStr); if (m_otiFrameColorCombo->CreateComboItem(NULL) == TRUE) { m_otiFrameColorCombo->SetCurColor(m_borderColor); } m_otiFrameThicknessCombo = (COptionTreeItemLineThikComboBox*)m_otTree.InsertItem(new COptionTreeItemLineThikComboBox(), otiRoot); resStr.LoadString(IDS_PER_PR_DL_TH_FR); m_otiFrameThicknessCombo->SetLabelText(resStr); resStr.LoadString(IDS_PER_PR_DL_FULL_TH_FR); m_otiFrameThicknessCombo->SetInfoText(resStr); if (m_otiFrameThicknessCombo->CreateComboItem(NULL) == TRUE) { m_otiFrameThicknessCombo->SetLineThickness(m_borderThickness); } otiRoot->Expand(); return TRUE; }
void COptionTreeWrapper::SerializeIn(IArchive &Archive, CHashString name) { CHashString basicType(_T("")); CHashString OptionTreeItemType(_T("")); // get the first option tree item in tree COptionTreeItem *item = m_mTrees[name.GetUniqueID()].m_Root->GetChild(); if (item == NULL) { return; } for (UINT i=0; i<m_mViewOList[name.GetUniqueID()].size(); i++) { VIEWOBJECTLIST::iterator volIter = m_mViewOList[name.GetUniqueID()][i]->begin(); for(; volIter != m_mViewOList[name.GetUniqueID()][i]->end(); volIter++) { ViewFormatObject *vo; vo = *volIter; basicType = vo->GetBasicType().c_str(); OptionTreeItemType = vo->GetViewType().c_str(); MAPTYPETOFUNCMAP::iterator mttfmIter; // find the map from basicType to write option tree item mttfmIter = m_TypeFuncMap.find(OptionTreeItemType.GetUniqueID()); if (mttfmIter == m_TypeFuncMap.end()) { // warning, continue.... // Sorry, that type of item is not known! StdString error = _T("COptionTreeItem of this type is unknown: "); error += OptionTreeItemType.GetString(); ::MessageBox(NULL, error, _T("INVALID OPERATION"), MB_OK); continue; } MAPTYPECREATEFUNC *createFuncs; createFuncs = mttfmIter->second; MAPTYPECREATEFUNC::iterator mtcfIter; // find the function that writes the option tree item w/ this basicType mtcfIter = createFuncs->find(basicType.GetUniqueID()); if (mtcfIter == createFuncs->end()) { // warning, continue // Sorry this item does not accept items of type %s, OptionTreeItemType StdString error = _T("This basic type is unknown: "); error += basicType.GetString(); ::MessageBox(NULL, error, _T("INVALID OPERATION"), MB_OK); } OTCREATETYPEFUNC funcPtr; funcPtr = mtcfIter->second; // call the function that writes the value from option tree item into the archive (this->*funcPtr)(Archive, item, true); item = item->GetSibling(); } } }
void COptionTreeList::OnLButtonDblClk(UINT nFlags, CPoint point) { // Validate option if (m_otOption == NULL) { CWnd::OnLButtonDblClk(nFlags, point); return; } // See if disabled if (m_otOption->IsDisableInput() || !m_otOption->IsWindowEnabled()) { CWnd::OnLButtonDblClk(nFlags, point); return; } // Declare variables COptionTreeItem *otiItem; COptionTreeItem *oliOldFocus; CRect rcClient, rcLabel; // Send notify to user m_otOption->SendNotify(NM_DBLCLK); // Get client rect GetClientRect(rcClient); // Hit test if ((otiItem = m_otOption->FindItem(point)) != NULL && otiItem->GetChild()) { switch (m_otOption->HitTest(point)) { case OT_HIT_COLUMN: // -- Get largest visible label rcLabel = m_otOption->GetLargestVisibleLabel(); // -- Resize limit // -- -- Right if (rcLabel.right + OT_SPACE > (rcClient.right - OT_RESIZEBUFFER)) { // -- -- -- Set column m_otOption->SetColumn(rcClient.right - OT_RESIZEBUFFER); } else { // -- -- -- Set column m_otOption->SetColumn(rcLabel.right + OT_SPACE); } // -- Update move items m_otOption->UpdateMoveAllItems(); // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); break; case OT_HIT_ATTRIBUTE: if (!otiItem->IsRootLevel()) { break; } default: // -- Get focus item oliOldFocus = m_otOption->GetFocusedItem(); // -- Select items m_otOption->SelectItems(NULL, FALSE); // -- Set focus item m_otOption->SetFocusedItem(otiItem); // -- Select otiItem->Select(); // -- Send notify to user if (otiItem != oliOldFocus) { m_otOption->SendNotify(OT_NOTIFY_SELCHANGE, otiItem); } case OT_HIT_EXPAND: if (!m_otOption->SendNotify(OT_NOTIFY_ITEMEXPANDING, otiItem)) { // -- Expand otiItem->Expand(!otiItem->IsExpanded()); // -- Update resize UpdateResize(); // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); // -- Check visible CheckVisibleFocus(); } break; } } else { switch (m_otOption->HitTest(point)) { case OT_HIT_COLUMN: // -- Get largest visible label rcLabel = m_otOption->GetLargestVisibleLabel(); // -- Resize limit // -- -- Right if (rcLabel.right + OT_SPACE > (rcClient.right - OT_RESIZEBUFFER)) { // -- -- -- Set column m_otOption->SetColumn(rcClient.right - OT_RESIZEBUFFER); } else { // -- -- -- Set column m_otOption->SetColumn(rcLabel.right + OT_SPACE); } // -- Update move items m_otOption->UpdateMoveAllItems(); // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); break; } } CWnd::OnLButtonDblClk(nFlags, point); }
void COptionTreeList::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // Declare variables COptionTreeItem* otiItem; CRect rcClient; // Get client rectangle GetClientRect(rcClient); // Validate option if (m_otOption == NULL) { CWnd::OnKeyDown(nChar, nRepCnt, nFlags); return; } // See if disabled if (m_otOption->IsDisableInput() || !m_otOption->IsWindowEnabled()) { CWnd::OnKeyDown(nChar, nRepCnt, nFlags); return; } switch (nChar) { case VK_TAB: // -- Shift if (GetKeyState(VK_SHIFT) < 0) { // -- -- Focus next otiItem = m_otOption->GetFocusedItem(); if (otiItem != NULL && !otiItem->IsRootLevel()) { m_otOption->FocusPrev(); } // -- -- Activate otiItem = m_otOption->GetFocusedItem(); if (otiItem != NULL && !otiItem->IsRootLevel() && !otiItem->IsReadOnly()) { otiItem->Activate(); } Invalidate(); UpdateWindow(); } // -- No shift else { // -- -- Focus next otiItem = m_otOption->GetFocusedItem(); if (otiItem != NULL && !otiItem->IsRootLevel()) { m_otOption->FocusNext(); } // -- -- Activate otiItem = m_otOption->GetFocusedItem(); if (otiItem != NULL && !otiItem->IsRootLevel() && !otiItem->IsReadOnly()) { otiItem->Activate(); } Invalidate(); UpdateWindow(); } break; case VK_RETURN: // -- Activate otiItem = m_otOption->GetFocusedItem(); if (otiItem != NULL && !otiItem->IsRootLevel() && !otiItem->IsReadOnly()) { otiItem->Activate(); } break; case VK_HOME: // -- Focus on first item if (m_otOption->FocusFirst()) { Invalidate(); UpdateWindow(); } break; case VK_END: // -- Focus on last item if (m_otOption->FocusLast()) { Invalidate(); UpdateWindow(); } break; case VK_LEFT: // -- Get focused item otiItem = m_otOption->GetFocusedItem(); if (otiItem != NULL) { // -- -- Send notify to user if (!m_otOption->SendNotify(OT_NOTIFY_ITEMEXPANDING, otiItem)) { // -- -- -- Validate if (otiItem->GetChild() && otiItem->IsExpanded()) { // -- Expand otiItem->Expand(FALSE); // -- Update resize UpdateResize(); // -- Force redraw Invalidate(); // -- Update window UpdateWindow(); // -- Check visible CheckVisibleFocus(); break; } } } else break; case VK_UP: // -- Move focus up if (m_otOption->FocusPrev()) { Invalidate(); UpdateWindow(); } break; case VK_RIGHT: // -- Get focused item otiItem = m_otOption->GetFocusedItem(); if (otiItem != NULL) { // -- -- Send notify to user if (!m_otOption->SendNotify(OT_NOTIFY_ITEMEXPANDING, otiItem)) { // -- -- -- Validate if (otiItem->GetChild() && !otiItem->IsExpanded()) { // -- -- -- -- Expand otiItem->Expand(TRUE); // -- -- -- -- Update resize UpdateResize(); // -- -- -- -- Force redraw Invalidate(); // -- -- -- -- Update window UpdateWindow(); // -- -- -- -- Check visible CheckVisibleFocus(); break; } } } else break; case VK_DOWN: // -- Move focus down if (m_otOption->FocusNext()) { Invalidate(); UpdateWindow(); } break; } CWnd::OnKeyDown(nChar, nRepCnt, nFlags); }
BOOL CReportPictureProperties::OnInitDialog() /* ============================================================ Function : CReportPictureProperties::OnInitDialog Description : Handler for the "WM_INITDIALOG" messag Access : Protected Return : BOOL - Always "TRUE" Parameters : none Usage : Called from MFC ============================================================*/ { CDialog::OnInitDialog(); COptionTreeItem *otiRoot = NULL; COptionTreeItem *otiItem = NULL; CRect rcClient; DWORD dwStyle, dwOptions; LOGFONT lfFont, lfDefaultFont; // Get log fonts GetFont()->GetLogFont(&lfFont); GetFont()->GetLogFont(&lfDefaultFont); //strcpy(lfDefaultFont.lfFaceName, _T("Arial"));#OBSOLETE strcpy_s(lfDefaultFont.lfFaceName,sizeof(lfDefaultFont.lfFaceName), _T("Arial")); // Get the clients rectangle GetClientRect(rcClient); // Setup the window style dwStyle = WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Setup the tree options // OT_OPTIONS_SHOWINFOWINDOW dwOptions = OT_OPTIONS_SHADEEXPANDCOLUMN | OT_OPTIONS_SHADEROOTITEMS | OT_OPTIONS_SHOWINFOWINDOW; int trBot=rcClient.bottom; if (GetDlgItem(IDOK)) { CRect rrrr; GetDlgItem(IDOK)->GetWindowRect(rrrr); ScreenToClient(rrrr); trBot = rrrr.top -4; } // Create tree options CRect trR = rcClient; trR.bottom = trBot; if (m_otTree.Create(dwStyle, trR, this, dwOptions, 1004) == FALSE) { TRACE0("Failed to create options control.\r\n"); return FALSE; } // Want to be notified m_otTree.SetNotify(TRUE, this); // -- Edit Items CString resStr; otiRoot = m_otTree.InsertItem(new COptionTreeItem()); resStr.LoadString(IDS_REP_COMMON_PROPS); otiRoot->SetLabelText(resStr); resStr.LoadString(IDS_REP_FULL_COMMON_PROPS); otiRoot->SetInfoText(resStr); m_otiFile = (COptionTreeItemFile*)m_otTree.InsertItem(new COptionTreeItemFile(), otiRoot); resStr.LoadString(IDS_REP_PR_FILE); m_otiFile->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_FULL_FILE); m_otiFile->SetInfoText(resStr); if (m_otiFile->CreateFileItem("",GetExtFromType(0).Mid(2,3),GetFileTypes(TRUE), OT_FILE_OPENDIALOG | OT_FILE_SHOWFULLPATH, OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY | OFN_FILEMUSTEXIST) == TRUE) { } otiRoot->Expand(); otiRoot = m_otTree.InsertItem(new COptionTreeItem()); resStr.LoadString(IDS_REP_PR_DL_FRAME); otiRoot->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_FRAME); otiRoot->SetInfoText(resStr); CString yesS; yesS.LoadString(IDS_YES); CString noS; noS.LoadString(IDS_NO); m_otiExistLeft = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_LEFT); m_otiExistLeft->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_LEFT); m_otiExistLeft->SetInfoText(resStr); if (m_otiExistLeft->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_LEFT, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistLeft->SetCheckText(yesS, noS); } m_otiExistRight = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_RIGHT); m_otiExistRight->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_RIGHT); m_otiExistRight->SetInfoText(resStr); if (m_otiExistRight->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_RIGHT, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistRight->SetCheckText(yesS, noS); } m_otiExistTop = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_TOP); m_otiExistTop->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_TOP); m_otiExistTop->SetInfoText(resStr); if (m_otiExistTop->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_TOP, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistTop->SetCheckText(yesS, noS); } m_otiExistBottom = (COptionTreeItemCheckBox*)m_otTree.InsertItem(new COptionTreeItemCheckBox(), otiRoot); resStr.LoadString(IDS_REP_PR_DL_BOTTOM); m_otiExistBottom->SetLabelText(resStr); resStr.LoadString(IDS_REP_PR_DL_FULL_BOTTOM); m_otiExistBottom->SetInfoText(resStr); if (m_otiExistBottom->CreateCheckBoxItem(m_borderStyle&DIAGRAM_FRAME_STYLE_BOTTOM, OT_CHECKBOX_SHOWCHECK) == TRUE) { m_otiExistBottom->SetCheckText(yesS, noS); } m_otiFrameColorCombo = (COptionTreeItemColorComboBox*)m_otTree.InsertItem(new COptionTreeItemColorComboBox(), otiRoot); resStr.LoadString(IDS_PER_PR_DL_COL_FR); m_otiFrameColorCombo->SetLabelText(resStr); resStr.LoadString(IDS_PER_PR_DL_FULL_COL_FR); m_otiFrameColorCombo->SetInfoText(resStr); if (m_otiFrameColorCombo->CreateComboItem(NULL) == TRUE) { m_otiFrameColorCombo->SetCurColor(m_borderColor); } m_otiFrameThicknessCombo = (COptionTreeItemLineThikComboBox*)m_otTree.InsertItem(new COptionTreeItemLineThikComboBox(), otiRoot); resStr.LoadString(IDS_PER_PR_DL_TH_FR); m_otiFrameThicknessCombo->SetLabelText(resStr); resStr.LoadString(IDS_PER_PR_DL_FULL_TH_FR); m_otiFrameThicknessCombo->SetInfoText(resStr); if (m_otiFrameThicknessCombo->CreateComboItem(NULL) == TRUE) { m_otiFrameThicknessCombo->SetLineThickness(m_borderThickness); } otiRoot->Expand(); return TRUE; }