本文整理汇总了C++中CField::GetUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ CField::GetUnit方法的具体用法?C++ CField::GetUnit怎么用?C++ CField::GetUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CField
的用法示例。
在下文中一共展示了CField::GetUnit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateFieldDescription
//----------------------------------------
void CFieldsTreeCtrl::UpdateFieldDescription(const wxTreeItemId& id)
{
if (!id.IsOk())
{
return;
}
CFieldsTreeItemData* itemData = GetItemDataValue(id);;
if (itemData == NULL)
{
return;
}
CField* field = itemData->GetField();
if (field == NULL)
{
return;
}
itemData->SetSplittedFieldDescr(field);
wxString str;
if (field->GetUnit().empty())
{
str.Printf(wxT("%s"), field->GetName().c_str());
}
else
{
str.Printf(wxT("%s (%s)"), field->GetName().c_str(), field->GetUnit().c_str());
}
SetItemText(id, str);
Refresh();
}
示例2: GetFieldUnit
//----------------------------------------
wxString CFieldsTreeCtrl::GetFieldUnit(const wxTreeItemId& item)
{
CUnit unit;
CFieldsTreeItemData* itemData = item.IsOk() ? dynamic_cast<CFieldsTreeItemData*>(GetItemData(item))
: NULL;
CField* field = NULL;
if (itemData != NULL)
{
field = itemData->GetField();
}
if (field == NULL)
{
return unit.GetText().c_str();
}
return field->GetUnit().c_str();
}
示例3: main
int main (int argc, char *argv[])
{
string FileName;
CStringArray InputFiles;
CProduct *Product = NULL;
bool Error = false;
bool Help = false;
if (argc != 2)
Error = true;
else if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0))
Help = true;
else
{
FileName.assign(argv[1]);
if (! CTools::FileExists(FileName))
{
cerr << "ERROR: Data file '" << FileName << "' not found" << endl << endl;
Error = true;
}
InputFiles.push_back(FileName);
}
if (Error || Help)
{
cerr << "Usage : " << argv[0] << " [ -h | --help] FileName" << endl;
cerr << "Where FileName is the name of a file to show" << endl;
}
if (Help)
cerr << endl << "Displays the fields available for a product file" << endl;
if (Error || Help)
return 2;
if (getenv(BRATHL_ENVVAR) == NULL)
{
CTools::SetDataDirForExecutable(argv[0]);
}
try
{
// auto_ptr<CTrace>pTrace(CTrace::GetInstance());
// construct the product
Product = CProduct::Construct(InputFiles);
Product->Open(FileName);
CTreeField *Tree = Product->GetTreeField();
if (Tree->GetRoot() != NULL)
{
Tree->SetWalkDownRootPivot();
do
{
CField *field = dynamic_cast<CField*>(Tree->GetWalkCurrent()->GetData());
if (field == NULL)
{
throw CException("ERROR at least one of the tree object is not a CField object",
BRATHL_INCONSISTENCY_ERROR);
}
if (typeid(*field) == typeid(CFieldRecord))
continue;
if ((typeid(*field) == typeid(CFieldArray)) &&
(! field->IsFixedSize()))
continue;
string Unit = field->GetUnit();
cout << CTools::Format("%-20s", field->GetRecordName().c_str())
<< field->GetFullName();
if (Unit != "")
cout << " (" << Unit << ")";
cout << endl;
}
while (Tree->SubTreeWalkDown());
}
delete Product;
return 0;
}
catch (CException &e)
{
cerr << "BRAT ERROR: " << e.what() << endl;
return 1;
}
catch (exception &e)
{
cerr << "BRAT RUNTIME ERROR: " << e.what() << endl;
return 254;
}
catch (...)
{
cerr << "BRAT FATAL ERROR: Unexpected error" << endl;
return 255;
}
}
示例4: InsertField
//----------------------------------------
wxTreeItemId CFieldsTreeCtrl::InsertField(const wxTreeItemId& parentId, CObjectTreeNode* node)
{
int32_t depth = node->GetLevel();
long numChildren = node->ChildCount();
CField *field = dynamic_cast<CField*>(node->GetData());
if (field == NULL)
{
wxMessageBox("ERROR in CFieldsTreeCtrl::InsertField - at least one of the tree object is not a CField object",
"Error",
wxOK | wxICON_ERROR);
return parentId;
}
if ((typeid(*field) == typeid(CFieldIndex)) && field->IsVirtual())
{
return parentId;
}
if ( depth <= 1 )
{
wxString str;
str.Printf(wxT("%s"), field->GetName().c_str());
// here we pass to AppendItem() normal and selected item images (we
// suppose that selected image follows the normal one in the enum)
int32_t image = TreeCtrlIcon_Folder;
int32_t imageSel = image + 1;
wxTreeItemId id = AddRoot(str, image, image, new CFieldsTreeItemData(field));
return id;
}
bool hasChildren = numChildren > 0;
wxString str;
if (field->GetUnit().empty())
{
str.Printf(wxT("%s"), field->GetName().c_str());
}
else
{
str.Printf(wxT("%s (%s)"), field->GetName().c_str(), field->GetUnit().c_str());
}
/*
// at depth 1 elements won't have any more children
if ( hasChildren )
{
str.Printf(wxT("%s"), field->GetName().c_str());
}
else
{
str.Printf(wxT("%s child %d.%d"), wxT("File"), folder, n + 1);
}
*/
// here we pass to AppendItem() normal and selected item images (we
// suppose that selected image follows the normal one in the enum)
int32_t image = (hasChildren) ? TreeCtrlIcon_Folder : TreeCtrlIcon_File;
int32_t imageSel = image + 1;
//wxTreeItemId id = AppendItem(idParent, str, image, imageSel,
// new MyTreeItemData(str));
wxTreeItemId id = AppendItem(parentId, str, image, imageSel,
new CFieldsTreeItemData(field));
//Expand(parentId);
if ( (typeid(*field) == typeid(CFieldRecord))
|| ( (typeid(*field) == typeid(CFieldArray)) && (field->IsFixedSize() == false) ) )
{
SetItemBold(id, true);
//SetItemFont(parentId, *wxSWISS_FONT);
//SetItemFont(rootId, *wxITALIC_FONT);
}
// and now we also set the expanded one (only for the folders)
if ( hasChildren )
{
SetItemImage(id, TreeCtrlIcon_FolderOpened,
wxTreeItemIcon_Expanded);
}
// remember the last child for OnEnsureVisible()
if ( !hasChildren )
{
m_lastItem = id;
}
wxTreeItemId returnId;
if (hasChildren)
//.........这里部分代码省略.........