本文整理汇总了C++中CAction::Prepare1方法的典型用法代码示例。如果您正苦于以下问题:C++ CAction::Prepare1方法的具体用法?C++ CAction::Prepare1怎么用?C++ CAction::Prepare1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAction
的用法示例。
在下文中一共展示了CAction::Prepare1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PerformAction
CAction* CLayoutEditor::PerformAction(CAction *action, BOOL bRepeat)
{
// variables
long id, gid, prevObj, objLayer;
long i, oid;
CLayer *lyr;
CObj *o, *o2;
CObjType *oT;
CObjList objs;
CString text;
BOOL b, tb;
BOOL bMoreInstances;
POSITION pos, pos2;
g_pLayoutView = this;
g_pFrame = layout;
g_pApp = application;
long tid, tprevObj, tobjLayer, tglobalID;
// do stuff
CArchive *ar = action->Unprepare1();
CAction *actionNew = new CAction();
if (bRepeat)
actionNew->m_bGroup = FALSE;
CArchive *arNew = actionNew->Prepare1();
switch (action->m_type)
{
case ACTION_MOVESIZE:
*ar >> id;
o = GetObject(id);
// START UNDO INFO //
actionNew->m_type = ACTION_MOVESIZE;
tid = o->GetInstanceID();
*arNew << tid;
o->Serialize(*arNew);
// END UNDO INFO //
o->Serialize(*ar);
InitializeObject(o);
g_PropertyBar->Update(this, TYPE_OBJECT, &m_sel, layout, &layout->objects, application); // show object props
break;
case ACTION_CHANGETYPE:
*ar >> id;
// START UNDO INFO //
actionNew->m_type = ACTION_CHANGETYPE;
*arNew << id;
application->object_types[id]->Serialize(*arNew);
// END UNDO INFO //
application->object_types[id]->Serialize(*ar);
g_PropertyBar->Update(this, TYPE_OBJECT, &m_sel, layout, &layout->objects, application); // show object props
break;
case ACTION_CHANGELAYER:
*ar >> id;
pos = layout->layers.GetHeadPosition();
for (i = 0; i < layout->layers.GetCount(); i++)
{
lyr = layout->layers.GetPrev(pos);
if( lyr->m_layerID == id)
break;
}
// START UNDO INFO //
actionNew->m_type = ACTION_CHANGELAYER;
*arNew << id;
lyr->Serialize(*arNew);
// END UNDO INFO //
lyr->Serialize(*ar);
g_PropertyBar->Update(this, TYPE_LAYER, &m_sel, layout, &layout->objects, application, 0, lyr); // show object props
break;
case ACTION_SETVISIBLE:
*ar >> id >> b;
o = GetObject(id);
// START UNDO INFO //
actionNew->m_type = ACTION_SETVISIBLE;
tid = o->GetInstanceID();
tb = !b;
*arNew << tid << tb;
// END UNDO INFO //
o->SetVisible(b);
break;
case ACTION_SETLOCK:
*ar >> id >> b;
o = GetObject(id);
//.........这里部分代码省略.........
示例2: OnLayerDel
void CLayerDlg::OnLayerDel()
{
if(!m_layerListBox.layout_editor)
return;
if(m_layerListBox.GetCurSel() == -1)
return;
CLayer *layer = (CLayer*)m_layerListBox.GetItemDataPtr(m_layerListBox.GetCurSel());
if (layer->m_layerType == LAYER_NONFRAME) return;
if (m_layerListBox.layout_editor->layout->layers.GetCount() == 2)
{
CErrorDlg error;
error.Error("Error removing layer", "You can't remove the last layer.");
return;
}
bool do_delete = false;
if (layer)
{
CExtMsgBox msg(NULL, CONF_DELETE, CONFIRMATION, __EXT_MB_YESNO | __EXT_MB_ICONINFORMATION | __EXT_MB_DO_NOT_ASK_AGAIN, 0, "DeleteLayer", __EXT_MB_EX_CHECK_BOX_IS_NOT_CHECKED_INTIALLY);
int result = msg.DoModal();
if (result == IDYES)
do_delete = true;
else
msg.ResetMsgBox();
}
if (do_delete)
{
POSITION pos = layer->m_zOrder.GetHeadPosition();
vector<long> deletelist;
for (int i = 0; i < layer->m_zOrder.GetCount(); i++) {
deletelist.push_back(layer->m_zOrder.GetNext(pos));
}
for(int i = 0; i < deletelist.size(); i++)
{
m_layerListBox.layout_editor->DeleteObject(deletelist.at(i), TRUE);
}
// START UNDO INFO //
CAction *action = new CAction();
action->m_type = ACTION_CHANGEZORDER;
CArchive *ar = action->Prepare1();
m_layerListBox.layout_editor->SerializeAllZLists(ar);
action->Prepare2();
m_layerListBox.layout_editor->m_undo->AddAction(action);
// END UNDO INFO //
m_layerListBox.layout_editor->layout->layers.RemoveAt(m_layerListBox.layout_editor->layout->layers.Find(layer));
m_layerListBox.DeleteString(m_layerListBox.GetCurSel());
m_layerListBox.SetCurSel(0);
OnSelchange();
g_PropertyBar->Update(layout_editor, TYPE_LAYER, NULL, NULL,NULL, layout_editor->application, 0, layout_editor->layout->layers.GetAt(layout_editor->layout->layers.GetTailPosition())); // update the property editor
m_layerListBox.layout_editor->Invalidate();
CChildFrame* pCF = (CChildFrame*)m_layerListBox.layout_editor->GetParentFrame();
pCF->object_bar.Refresh();
layout_editor->layout->SetChanged(true);
}
}