void WgResourceSerializerXML::WriteNode(std::stringstream& ss, const OutNode& node, int nDepth) { ss << GetIndent(nDepth) << "<" << node.xmlNode.GetName(); for(Uint32 iAttr = 0; iAttr < node.xmlNode.GetAttributeCount(); iAttr++) { std::string escaped; WgUtil::XMLEscape(node.xmlNode.GetAttribute(iAttr).GetValue(), escaped); ss << " " << node.xmlNode.GetAttribute(iAttr).GetName() << "=\"" << escaped << "\""; } if( node.children.size() || node.text.str().size() ) { ss << ">" << node.text.str(); if(node.children.size()) { ss << std::endl; WriteNode(ss, *node.children[0], nDepth + 1); for(Uint32 iChild = 1; iChild < node.children.size(); iChild++) { if(node.children[iChild - 1]->children.size() > 0 || node.children[iChild]->children.size() > 0) ss << std::endl; WriteNode(ss, *node.children[iChild], nDepth + 1); } } ss << GetIndent(nDepth) << "</" << node.xmlNode.GetName() << ">" << std::endl; } else { ss << "/>" << std::endl; } }
void PrintVisitor::VisitSetOptsCmd(const SetOptsCmd* Cmd) { Out << GetIndent() << "(set-opts ("; IndentLevel++; for(auto const& Opt : Cmd->GetOpts()) { Out << endl << GetIndent() << "(" << Opt.first << " \"" << Opt.second << "\")"; } Out << endl; IndentLevel--; Out << GetIndent() << "))" << endl << endl; }
void PrintVisitor::VisitLetGTerm(const LetGTerm* TheTerm) { Out << "(let (" << endl; IndentLevel++; for(auto const& Binding : TheTerm->GetBindings()) { Binding->Accept(this); } Out << ")" << endl; Out << GetIndent(); TheTerm->GetBoundInTerm()->Accept(this); IndentLevel--; Out << endl << GetIndent() << ")"; }
void PrintVisitor::VisitNTDef(const NTDef* Def) { Out << "(" << Def->GetName() << " "; Def->GetSort()->Accept(this); Out << " (" << endl; IndentLevel++; for(auto const& Expansion : Def->GetExpansions()) { Out << GetIndent(); Expansion->Accept(this); } IndentLevel--; Out << "))"; Out << endl << GetIndent(); }
void EmitterState::StartedGroup(GroupType::value type) { StartedNode(); const int lastGroupIndent = (m_groups.empty() ? 0 : m_groups.back()->indent); m_curIndent += lastGroupIndent; // TODO: Create move constructors for settings types to simplify transfer std::unique_ptr<Group> pGroup(new Group(type)); // transfer settings (which last until this group is done) // // NB: if pGroup->modifiedSettings == m_modifiedSettings, // m_modifiedSettings is not changed! pGroup->modifiedSettings = std::move(m_modifiedSettings); // set up group if (GetFlowType(type) == Block) { pGroup->flowType = FlowType::Block; } else { pGroup->flowType = FlowType::Flow; } pGroup->indent = GetIndent(); m_groups.push_back(std::move(pGroup)); }
void XsiExp::ExportNodeHeader( INode * node, TCHAR * type, int indentLevel) { TSTR indent = GetIndent(indentLevel); // node header: object type and name fprintf(pStream,"%s%s frm-%s {\n\n", indent.data(), type, FixupName(node->GetName())); }
SpecialPresetTreeView(wxWindow* parent) : wxDataViewTreeCtrl{ parent, -1 }, root_{ wxDataViewItem(nullptr) }, parent_dialog_{ nullptr } { // Computing the minimum width of the tree is slightly complicated, since // wx doesn't expose it to us directly wxClientDC dc(this); dc.SetFont(GetFont()); wxSize textsize; // Populate tree addPresets(Game::customSpecialPresets(), textsize, dc); // User custom presets addPresets(Game::configuration().specialPresets(), textsize, dc); // From game configuration wxDataViewCtrl::Expand(root_); // Bind events Bind(wxEVT_DATAVIEW_ITEM_START_EDITING, [&](wxDataViewEvent& e) { e.Veto(); }); Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [&](wxDataViewEvent& e) { if (GetChildCount(e.GetItem()) > 0) { // Expand if group node Expand(e.GetItem()); e.Skip(); } else if (parent_dialog_) parent_dialog_->EndModal(wxID_OK); }); // 64 is an arbitrary fudge factor -- should be at least the width of a // scrollbar plus the expand icons plus any extra padding int min_width = textsize.GetWidth() + GetIndent() + UI::scalePx(64); wxWindowBase::SetMinSize(wxSize(min_width, UI::scalePx(200))); }
void PrintVisitor::VisitFunDefCmd(const FunDefCmd* Cmd) { Out << GetIndent() << "(define-fun " << Cmd->GetFunName() << " ("; for(auto const& ASPair : Cmd->GetArgs()) { ASPair->Accept(this); } Out << ") "; Cmd->GetSort()->Accept(this); Out << endl; IndentLevel++; Out << GetIndent(); Cmd->GetTerm()->Accept(this); Out << endl; IndentLevel--; Out << ")" << endl << endl; }
const cli::tk::String NativeTraces::Begin(const char* const STR_Method) { m_iJniStackSize ++; cli::StringDevice cli_Begin(0, false); cli_Begin << GetIndent() << ">> " << STR_Method; return cli_Begin.GetString(); }
const cli::tk::String NativeTraces::EndFloat(const char* const STR_Method, const double D_Value) { cli::StringDevice cli_End(0, false); cli_End << GetIndent() << "<< " << STR_Method << " : " << D_Value; m_iJniStackSize --; return cli_End.GetString(); }
const cli::tk::String NativeTraces::EndPtr(const char* const STR_Method, void* const PV_Value) { cli::StringDevice cli_End(0, false); cli_End << GetIndent() << "<< " << STR_Method << " : " << PV_Value; m_iJniStackSize --; return cli_End.GetString(); }
const cli::tk::String NativeTraces::EndVoid(const char* const STR_Method) { cli::StringDevice cli_End(0, false); cli_End << GetIndent() << "<< " << STR_Method; m_iJniStackSize --; return cli_End.GetString(); }
void PrintVisitor::VisitConstraintCmd(const ConstraintCmd* Cmd) { Out << "(constraint " << endl; IndentLevel++; Cmd->GetTerm()->Accept(this); IndentLevel--; Out << endl << GetIndent() << ")" << endl << endl; }
void PrintVisitor::VisitFunDeclCmd(const FunDeclCmd* Cmd) { Out << GetIndent() << "(declare-fun " << Cmd->GetFunName() << " ("; for(auto const& Sort : Cmd->GetArgSorts()) { Sort->Accept(this); } Out << ") "; Cmd->GetSort()->Accept(this); Out << ")" << endl << endl; }
void CTreeFileCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; *pResult = 0; SelectItem(pNMTreeView->itemNew.hItem); if (!IsDropSource(pNMTreeView->itemNew.hItem) || !m_bAllowDragDrop) return; m_pilDrag = CreateDragImage(pNMTreeView->itemNew.hItem); if (!m_pilDrag) return; m_hItemDrag = pNMTreeView->itemNew.hItem; m_hItemDrop = NULL; // Calculate the offset to the hotspot CPoint offsetPt(8,8); // Initialize a default offset CPoint dragPt = pNMTreeView->ptDrag; // Get the Drag point UINT nHitFlags = 0; HTREEITEM htiHit = HitTest(dragPt, &nHitFlags); if (htiHit != NULL) { // The drag point has Hit an item in the tree CRect itemRect; if (GetItemRect(htiHit, &itemRect, FALSE)) { // Count indent levels HTREEITEM htiParent = htiHit; int nIndentCnt = 0; while (htiParent != NULL) { htiParent = GetParentItem(htiParent); nIndentCnt++; } if (!(GetStyle() & TVS_LINESATROOT)) nIndentCnt--; // Calculate the new offset offsetPt.y = dragPt.y - itemRect.top; offsetPt.x = dragPt.x - (nIndentCnt * GetIndent()) + GetScrollPos(SB_HORZ); } } //Begin the dragging m_pilDrag->BeginDrag(0, offsetPt); POINT pt = pNMTreeView->ptDrag; ClientToScreen(&pt); m_pilDrag->DragEnter(NULL, pt); SetCapture(); m_nTimerID = SetTimer(1, 300, NULL); }
BOOL XsiExp::nodeEnumBone( INode * node, int indentLevel) { if(exportSelected && node->Selected() == FALSE) { return TREE_CONTINUE; } nCurNode++; ip->ProgressUpdate( (int)((float)nCurNode/nTotalNodeCount*100.0f) ); // Stop recursing if the user pressed Cancel if (ip->GetCancel()) { return FALSE; } // Only export if exporting everything or it's selected if(!exportSelected || node->Selected()) { // The ObjectState is a 'thing' that flows down the pipeline containing // all information about the object. By calling EvalWorldState() we tell // max to eveluate the object at end of the pipeline. ObjectState os = node->EvalWorldState(0); // The obj member of ObjectState is the actual object we will export. if (os.obj) { // We look at the super class ID to determine the type of the object. switch(os.obj->SuperClassID()) { case HELPER_CLASS_ID: ExportBoneObject(node, indentLevel); break; default: return FALSE; } } } // For each child of this node, we recurse into ourselves // until no more children are found. for (int c = 0; c < node->NumberOfChildren(); c++) { if (!nodeEnumBone(node->GetChildNode(c), indentLevel+1)) { return FALSE; } } TSTR indent = GetIndent(indentLevel); fprintf(pStream,"%s}\n\n", indent.data()); return TRUE; }
BOOL AscOut::nodeEnum(INode* node, int indentLevel) { nCurNode++; ip->ProgressUpdate((int)((float)nCurNode/nTotalNodeCount*100.0f)); // Stop recursing if the user pressed Cancel if (ip->GetCancel()) return FALSE; TSTR indent = GetIndent(indentLevel); // Only export if exporting everything or it's selected if(!exportSelected || node->Selected()) { // The ObjectState is a 'thing' that flows down the pipeline containing // all information about the object. By calling EvalWorldState() we tell // max to eveluate the object at end of the pipeline. ObjectState os = node->EvalWorldState(0); // The obj member of ObjectState is the actual object we will export. if (os.obj) { // We look at the super class ID to determine the type of the object. switch(os.obj->SuperClassID()) { case GEOMOBJECT_CLASS_ID: ExportGeomObject(node, indentLevel); break; case CAMERA_CLASS_ID: ExportCameraObject(node, indentLevel); break; case LIGHT_CLASS_ID: ExportLightObject(node, indentLevel); break; case SHAPE_CLASS_ID: ExportShapeObject(node, indentLevel); break; case HELPER_CLASS_ID: ExportHelperObject(node, indentLevel); break; } } } // For each child of this node, we recurse into ourselves // until no more children are found. for (int c = 0; c < node->NumberOfChildren(); c++) { if (!nodeEnum(node->GetChildNode(c), indentLevel)) return FALSE; } return TRUE; }
const cli::tk::String NativeTraces::Instance(const int I_NativeObjectRef, const int I_Tokens, const bool B_AutoDelete) { cli::StringDevice cli_Trace(0, false); cli_Trace << GetIndent(); cli_Trace << "[object " << I_NativeObjectRef << "] "; cli_Trace << "tokens = " << I_Tokens << ", "; cli_Trace << "auto-delete: " << (B_AutoDelete ? "yes" : "no"); if ((I_Tokens <= 0) && (B_AutoDelete)) { cli_Trace << " -> deletion"; } return cli_Trace.GetString(); }
void PrintVisitor::VisitSynthFunCmd(const SynthFunCmd* Cmd) { Out << GetIndent() << "(synth-fun " << Cmd->GetFunName() << " ("; for(auto const& ASPair : Cmd->GetArgs()) { ASPair->Accept(this); } Out << ") "; Cmd->GetSort()->Accept(this); Out << endl; IndentLevel++; Out << GetIndent() << "("; IndentLevel++; for(auto const& Rule : Cmd->GetGrammarRules()) { Rule->Accept(this); Out << endl; } IndentLevel--; Out << ")" << endl; IndentLevel--; Out << ")" << endl << endl; }
int MgProperty::Save(IoDataStream *s, const char *keyword) { int valid, mask; register int i; const KeywordTable *ktab = GetKeywordTable(); valid = mValid; #if PRINTPOINTERS s->PrintF("%s%s { #### addr = 0x%08x [mRefCount=%3d]\n", GetIndent(), keyword, this, RefCount()); #else s->PrintF("%s%s {\n", GetIndent(), keyword); #endif for(i = 0; i < GetNumKeywords(); i++) { mask = ktab[i].mask; if((valid & mask) == 0) continue; valid &= ~mask; s->PrintF( "\t%s%c %c%s", GetIndent(), (mOverride & mask) ? '*' : ' ', ((ktab[i].numargs == 0) && (mFlags&mask) == 0) ? '-' : ' ', ktab[i].word ); if (ktab[i].numargs > 0) s->PutC(' '); if (!SaveProcess(s, mask)) return 0; s->PutC('\n'); } if (!SaveProcessMore(s)) return 0; s->PrintF("%s}\n", GetIndent()); return 1; }
void XsiExp::ExportMeshObject( INode * node, int indentLevel) { Object * obj = node->EvalWorldState(GetStaticFrame()).obj; if (!obj || obj->ClassID() == Class_ID(TARGET_CLASS_ID, 0)) { return; } TSTR indent = GetIndent(indentLevel); ExportNodeHeader(node, "Frame", indentLevel); ExportNodeTM(node, indentLevel); ExportMesh(node, GetStaticFrame(), indentLevel); }
void EmitterState::BeginGroup(GROUP_TYPE type) { unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top()->indent); m_curIndent += lastIndent; std::unique_ptr <Group> pGroup(new Group(type)); // transfer settings (which last until this group is done) pGroup->modifiedSettings = m_modifiedSettings; // set up group pGroup->flow = GetFlowType(type); pGroup->indent = GetIndent(); pGroup->usingLongKey = (GetMapKeyFormat() == LongKey ? true : false); m_groups.push(pGroup.release()); }
suic::Size TreeViewItem::MeasureOverride(const suic::Size& availableSize) { _expand->Measure(availableSize); _check.Measure(availableSize); suic::Size retSize; if (!IsCollapsed()) { retSize = __super::MeasureOverride(availableSize); } retSize.cy += GetPadding().top; retSize.cy += GetPadding().bottom; retSize.cx += GetIndent(); return retSize; }
void PythonCodeCtrl::OnCharAdded(wxScintillaEvent& ke) { //User has pressed enter //if the cursor is at the end of a completed statement, submit the statement to the interpreter //otherwise, do auto-indentation if (ke.GetKey() == _T('\n')) { //int pos = GetCurrentPos(); int line = LineFromPosition(GetCurrentPos()); if(line>0) { wxString prevlinetext = GetLine(line-1).Trim(); int indentation = GetLineIndentation(line-1); if((indentation==0) //submit a return pressed on an unindented line || (indentation>0 && prevlinetext==wxEmptyString)) // or an indented block where the previous line was empty { long rs,re; GetSelection(&rs,&re); //if(rs==re && GetLastPosition()==rs) if(rs==re && GetLength()==rs) // only submit if the cursor is at the end of the control (and there is no selection) { m_pyctrl->DispatchCode(GetValue()); ke.Skip(); } } // Otherwise indent the code if necessary if (GetLine(line-1).Trim().EndsWith(_T(":"))) { if(GetStyleAt(GetLineEndPosition(line-1)-1) == wxSCI_P_OPERATOR) indentation+=GetIndent(); } if (indentation>0) { SetLineIndentation(line,indentation); SetCurrentPos(PositionFromLine(line)+indentation); SetAnchor(PositionFromLine(line)+indentation); } } } ke.Skip(); }
void PHPFormatterBuffer::AppendEOL(eDepthCommand depth) { m_buffer << m_options.eol; switch(depth) { case kDepthDec: --m_depth; break; case kDepthIncTemporarily: case kDepthInc: ++m_depth; break; default: break; } m_buffer << GetIndent(); if(kDepthIncTemporarily == depth) { --m_depth; } }
//Función que vuelca el contenido de los atributos de un elemento del fichero XML, y // devuelve el número de atributos del elemento. int cLoadXML::Output_attributes(TiXmlElement* lpElement, unsigned int luiIndent) { if ( !lpElement ) return 0; //Se accede al primer atributo del elemento. TiXmlAttribute* lpAttrib = lpElement->FirstAttribute(); int i = 0; int liVal; double ldVal; //Se obtiene la cadena de indentación. const char* kpcIndent = GetIndent(luiIndent, true); OutputDebugString("\n"); //Se recorren los atributos. while (lpAttrib) { //Se imprime la indentación concatenada con el nombre del atributo y su valor. OutputDebugString( ((std::string)kpcIndent + lpAttrib->Name() + ": value = " + lpAttrib->Value()).c_str()); //"QueryIntValue()" es una alternativa al método IntValue() con verificación de error. Si el valor del atributo es integer, es almacenado en el parámetro // "liVal" y se retorna TIXML_SUCCESS. Si no es integer se devuelve TIXML_WRONG_TYPE. if (lpAttrib->QueryIntValue(&liVal)==TIXML_SUCCESS) { char lpcCadenaNum[4]; //Convertimos el número integer en cadena sprintf_s(lpcCadenaNum, 4, "%d", liVal); OutputDebugString((", the value is integer = " + (std::string)lpcCadenaNum).c_str()); } //"QueryDoubleValue()" es una alternativa al método DoubleValue() con verificación de error. Si el valor del atributo es double, es almacenado en el parámetro // "ldVal" y se retorna TIXML_SUCCESS. Si no es double se devuelve TIXML_WRONG_TYPE. else if (lpAttrib->QueryDoubleValue(&ldVal)==TIXML_SUCCESS) { char lpcCadenaNum[20]; //Convertimos el número integer en cadena sprintf_s(lpcCadenaNum, 20, "%0.2f", ldVal); OutputDebugString((", the value is double = " + (std::string)lpcCadenaNum).c_str()); } OutputDebugString("\n"); i++; //Next(): Get the next sibling attribute in the DOM. Returns null at end. lpAttrib=lpAttrib->Next(); } //Se devuelve el número de atributos return i; }
void XsiExp::DumpMatrix3( Matrix3 * m, int indentLevel) { Point3 row; TSTR indent = GetIndent(indentLevel); // swap y and z; max to soft correction decomp_affine( *m, &affine); // translate float temp = affine.t.z; affine.t.z = -affine.t.y; affine.t.y = temp; // rotate AngAxis aa( affine.q); temp = aa.axis.z; aa.axis.z = -aa.axis.y; aa.axis.y = temp; affine.q.Set(aa); // scale aa.Set( affine.u); temp = aa.axis.z; aa.axis.z = -aa.axis.y; aa.axis.y = temp; affine.u.Set( aa); temp = affine.k.z; affine.k.z = affine.k.y; affine.k.y = temp; Matrix3 matrix(1); matrix.PreTranslate(affine.t); PreRotateMatrix(matrix, affine.q); row = matrix.GetRow(0); fprintf(pStream,"%s %.6f,%.6f,%.6f,0.000000,\n", indent.data(), row.x, row.y, row.z); row = matrix.GetRow(1); fprintf(pStream,"%s %.6f,%.6f,%.6f,0.000000,\n", indent.data(), row.x, row.y, row.z); row = matrix.GetRow(2); fprintf(pStream,"%s %.6f,%.6f,%.6f,0.000000,\n", indent.data(), row.x, row.y, row.z); row = matrix.GetRow(3); fprintf(pStream,"%s %.6f,%.6f,%.6f,1.000000;;\n", indent.data(), row.x, row.y, row.z); }
void XsiExp::ExportNodeTM( INode * node, int indentLevel) { // dump the full matrix Matrix3 matrix = node->GetNodeTM(GetStaticFrame()); TSTR indent = GetIndent(indentLevel); fprintf(pStream,"%s\t%s {\n\n", indent.data(), "FrameTransformMatrix"); Object * obj = node->EvalWorldState(0).obj; BOOL isBone = obj && obj->ClassID() == Class_ID(BONE_CLASS_ID, 0) ? TRUE : FALSE; if (node->GetParentNode() && node->GetParentNode()->IsRootNode()) { // bone chains get grafted into the hierarchy tree // if (!isBone) { // root mesh oTopMatrix = matrix; AffineParts ap; decomp_affine( matrix, &ap); topMatrix.Set( Point3( ap.k.x,0.0f,0.0f), Point3( 0.0f,ap.k.z,0.0f), Point3(0.0f,0.0f,ap.k.y), Point3(0,0,0)); // root transform is controlled by the engine matrix.IdentityMatrix(); } } else { matrix = matrix * Inverse(node->GetParentTM(GetStaticFrame())); if (!isBone) { matrix.SetRow( 3, topMatrix * matrix.GetRow(3)); } } // write the matrix values DumpMatrix3( &matrix, indentLevel+2); // transform close brace fprintf(pStream,"%s\t}\n", indent.data()); }
void AsciiExp::DumpRotSample(INode* node, int indentLevel) { TSTR indent = GetIndent(indentLevel); _ftprintf(pStream, _T("%s\t\t%s {\n"), indent.data(), ID_ROT_TRACK); TimeValue start = ip->GetAnimRange().Start(); TimeValue end = ip->GetAnimRange().End(); TimeValue t; int delta = GetTicksPerFrame() * GetKeyFrameStep(); Matrix3 tm; AffineParts ap; Quat prevQ; prevQ.Identity(); for (t=start; t<=end; t+=delta) { tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t)); decomp_affine(tm, &ap); // Rotation keys should be relative, so we need to convert these // absolute samples to relative values. Quat q = ap.q / prevQ; prevQ = ap.q; if (q.IsIdentity()) { // No point in exporting null keys... continue; } // Output the sample _ftprintf(pStream, _T("%s\t\t\t%s %d\t%s\n"), indent.data(), ID_ROT_SAMPLE, t, Format(q)); } _ftprintf(pStream, _T("%s\t\t}\n"), indent.data()); }
void XsiExp::ExportBoneObject( INode * node, int indentLevel) { Object * obj = node->EvalWorldState(GetStaticFrame()).obj; if (!obj || obj->ClassID() != Class_ID(BONE_CLASS_ID, 0)) { // reject non-bones return; } if (!node->GetParentNode() || node->GetParentNode()->IsRootNode()) { // bone matrices get passed to children // drop root bone return; } TSTR indent = GetIndent(indentLevel); ExportNodeHeader(node, "Frame", indentLevel); // export parent as this bone ExportNodeTM(node->GetParentNode(), indentLevel); }