本文整理汇总了C++中COptionTreeItem类的典型用法代码示例。如果您正苦于以下问题:C++ COptionTreeItem类的具体用法?C++ COptionTreeItem怎么用?C++ COptionTreeItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了COptionTreeItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
示例2: AddToVisibleList
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);
}
示例3: EnumItems
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;
}
示例4: EnsureVisible
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);
}
}
示例5: EnumGetLargestVisibleLabelRect
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;
}
示例6: CheckVisibleFocus
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();
}
}
示例7: IsItemVisible
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;
}
示例8: HitTest
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;
}
示例9: FindItem
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;
}
示例10: OnLButtonDown
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
//.........这里部分代码省略.........
示例11: dc
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);
//.........这里部分代码省略.........
示例12: Delete
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;
}
}
示例13: GetFont
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);
//.........这里部分代码省略.........
示例14: basicType
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();
}
}
}
示例15: OnLButtonDblClk
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();
//.........这里部分代码省略.........